@veluai/velu 0.2.14 → 0.2.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +80 -80
- package/dist/cli.js +35 -33
- package/package.json +64 -64
- package/runtime/velu-ui/base.css +320 -320
- package/runtime/velu-ui/components/Accordion.jsx +64 -64
- package/runtime/velu-ui/components/ApiClient.jsx +207 -207
- package/runtime/velu-ui/components/ApiField.jsx +87 -87
- package/runtime/velu-ui/components/ApiPath.jsx +63 -63
- package/runtime/velu-ui/components/ApiReferencePage.jsx +384 -384
- package/runtime/velu-ui/components/ApiSamples.jsx +36 -36
- package/runtime/velu-ui/components/ApiSidebar.jsx +125 -122
- package/runtime/velu-ui/components/AskBar.jsx +71 -71
- package/runtime/velu-ui/components/Callout.jsx +114 -114
- package/runtime/velu-ui/components/Card.jsx +131 -131
- package/runtime/velu-ui/components/Chatbot.jsx +885 -885
- package/runtime/velu-ui/components/CodeBlock.jsx +375 -375
- package/runtime/velu-ui/components/Columns.jsx +56 -56
- package/runtime/velu-ui/components/ContextMenu.jsx +298 -298
- package/runtime/velu-ui/components/ErrorCard.jsx +138 -138
- package/runtime/velu-ui/components/Field.jsx +81 -81
- package/runtime/velu-ui/components/Image.jsx +163 -163
- package/runtime/velu-ui/components/Logo.jsx +31 -31
- package/runtime/velu-ui/components/MethodBadge.jsx +31 -31
- package/runtime/velu-ui/components/NavSelect.jsx +108 -108
- package/runtime/velu-ui/components/NotFound.jsx +63 -63
- package/runtime/velu-ui/components/PageFeedback.jsx +219 -219
- package/runtime/velu-ui/components/PageFooter.jsx +145 -145
- package/runtime/velu-ui/components/PageHeader.jsx +422 -422
- package/runtime/velu-ui/components/PageNav.jsx +77 -77
- package/runtime/velu-ui/components/PoweredBy.jsx +51 -51
- package/runtime/velu-ui/components/Prompt.jsx +115 -115
- package/runtime/velu-ui/components/Search.jsx +460 -460
- package/runtime/velu-ui/components/Sidebar.jsx +246 -254
- package/runtime/velu-ui/components/SocialLinks.jsx +90 -90
- package/runtime/velu-ui/components/Steps.jsx +65 -65
- package/runtime/velu-ui/components/ThemeToggle.jsx +48 -48
- package/runtime/velu-ui/components/Toc.jsx +537 -537
- package/runtime/velu-ui/components/TocBar.jsx +195 -195
- package/runtime/velu-ui/components/Tree.jsx +87 -87
- package/runtime/velu-ui/components/TryItBar.jsx +102 -102
- package/runtime/velu-ui/components/accordion.css +92 -92
- package/runtime/velu-ui/components/api-page.css +208 -208
- package/runtime/velu-ui/components/api.css +635 -635
- package/runtime/velu-ui/components/ask-bar.css +94 -94
- package/runtime/velu-ui/components/card.css +105 -105
- package/runtime/velu-ui/components/chatbot.css +622 -622
- package/runtime/velu-ui/components/code-block.css +263 -263
- package/runtime/velu-ui/components/context-menu.css +173 -173
- package/runtime/velu-ui/components/docs-layout.css +822 -822
- package/runtime/velu-ui/components/field.css +82 -82
- package/runtime/velu-ui/components/image.css +237 -237
- package/runtime/velu-ui/components/nav-select.css +157 -157
- package/runtime/velu-ui/components/not-found.css +94 -94
- package/runtime/velu-ui/components/page-feedback.css +241 -241
- package/runtime/velu-ui/components/page-footer.css +130 -130
- package/runtime/velu-ui/components/page-header.css +558 -558
- package/runtime/velu-ui/components/page-nav.css +50 -50
- package/runtime/velu-ui/components/powered-by.css +92 -92
- package/runtime/velu-ui/components/prompt.css +99 -99
- package/runtime/velu-ui/components/search.css +307 -307
- package/runtime/velu-ui/components/sidebar.css +205 -205
- package/runtime/velu-ui/components/steps.css +77 -77
- package/runtime/velu-ui/components/theme-toggle.css +102 -102
- package/runtime/velu-ui/components/toc-bar.css +234 -234
- package/runtime/velu-ui/components/tree.css +49 -49
- package/runtime/velu-ui/index.js +55 -54
- package/runtime/velu-ui/lib/api-send.js +118 -92
- package/runtime/velu-ui/lib/brand-icons.jsx +103 -103
- package/runtime/velu-ui/lib/component-schemas.js +100 -100
- package/runtime/velu-ui/lib/copyText.js +64 -64
- package/runtime/velu-ui/lib/docs-assistant.js +250 -250
- package/runtime/velu-ui/lib/lang-icons.jsx +147 -147
- package/runtime/velu-ui/lib/pagefind.js +113 -113
- package/runtime/velu-ui/lib/prism-langs.js +957 -957
- package/runtime/velu-ui/lib/prism-loader.js +74 -74
- package/runtime/velu-ui/lib/resolveIcon.jsx +29 -29
- package/runtime/velu-ui/lib/scrollIntoNearestView.js +66 -66
- package/runtime/velu-ui/mdx-components.jsx +105 -105
- package/runtime/velu-ui/primitives/Cluster.jsx +49 -49
- package/runtime/velu-ui/primitives/Stack.jsx +63 -63
- package/runtime/velu-ui/primitives/Switcher.jsx +57 -57
- package/runtime/velu-ui/primitives/stack.css +3 -3
- package/runtime/velu-ui/primitives/switcher.css +25 -25
- package/runtime/velu-ui/styles.css +46 -46
- package/runtime/velu-ui/tokens.css +4 -4
- package/schema/velu.schema.json +423 -423
- package/src/lib/extract-mdx-error.js +170 -170
- package/src/lib/issues.js +159 -159
- package/src/lib/known-components.js +34 -34
- package/src/navigation.js +459 -443
- package/src/runtime/App.jsx +1688 -1669
- package/src/runtime/ErrorBoundary.jsx +54 -54
- package/src/runtime/client-entry.jsx +22 -22
- package/src/runtime/server-entry.jsx +16 -16
- package/src/template.html +48 -48
- package/templates/starter/ai-tools/claude-code.mdx +26 -26
- package/templates/starter/ai-tools/cursor.mdx +17 -17
- package/templates/starter/api-reference/introduction.mdx +43 -43
- package/templates/starter/development.mdx +19 -19
- package/templates/starter/essentials/code.mdx +29 -29
- package/templates/starter/essentials/images.mdx +29 -29
- package/templates/starter/essentials/markdown.mdx +25 -25
- package/templates/starter/essentials/navigation.mdx +39 -39
- package/templates/starter/essentials/settings.mdx +30 -30
- package/templates/starter/favicon.svg +6 -6
- package/templates/starter/index.mdx +31 -31
- package/templates/starter/openapi.json +160 -160
- package/templates/starter/quickstart.mdx +31 -31
- package/templates/starter/velu.json +41 -41
package/README.md
CHANGED
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
# Velu
|
|
2
|
-
|
|
3
|
-
A documentation-site generator with live preview. Scaffold a docs project
|
|
4
|
-
and run it locally with two commands — author your pages in Markdown +
|
|
5
|
-
components, configure the site with a single `velu.json`.
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install -g @veluai/velu
|
|
9
|
-
velu init my-docs
|
|
10
|
-
velu dev my-docs
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
Then open <http://localhost:8358>. Editing any `.mdx` page or `velu.json`
|
|
14
|
-
reloads the browser automatically.
|
|
15
|
-
|
|
16
|
-
> Requires **Node.js 18+**. Prefer not to install globally? Use
|
|
17
|
-
> `npx @veluai/velu init my-docs` and `npx @veluai/velu dev my-docs`.
|
|
18
|
-
|
|
19
|
-
## Commands
|
|
20
|
-
|
|
21
|
-
| Command | What it does |
|
|
22
|
-
| --- | --- |
|
|
23
|
-
| `velu init <dir>` | Scaffold a new docs project into `<dir>` (creates `velu.json`, a favicon, and a set of starter `.mdx` pages). |
|
|
24
|
-
| `velu dev [dir]` | Start the live-preview dev server for the project in `<dir>` (defaults to the current directory). |
|
|
25
|
-
|
|
26
|
-
Set a custom port with the `PORT` env var:
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
PORT=5180 velu dev my-docs
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## Project layout
|
|
33
|
-
|
|
34
|
-
`velu init` produces a project shaped like this:
|
|
35
|
-
|
|
36
|
-
```
|
|
37
|
-
my-docs/
|
|
38
|
-
├─ velu.json # site config: name, colors, font, favicon, navigation
|
|
39
|
-
├─ favicon.svg
|
|
40
|
-
├─ index.mdx # pages, organized however your navigation references them
|
|
41
|
-
├─ quickstart.mdx
|
|
42
|
-
└─ …
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
## `velu.json`
|
|
46
|
-
|
|
47
|
-
`velu.json` drives the whole site — branding and navigation:
|
|
48
|
-
|
|
49
|
-
```json
|
|
50
|
-
{
|
|
51
|
-
"$schema": "https://veluai.com/velu.schema.json",
|
|
52
|
-
"name": "My Docs",
|
|
53
|
-
"colors": { "primary": "#dc143c" },
|
|
54
|
-
"favicon": "/favicon.svg",
|
|
55
|
-
"font": { "family": "Inter" },
|
|
56
|
-
"navigation": {
|
|
57
|
-
"tabs": [
|
|
58
|
-
{
|
|
59
|
-
"tab": "Guides",
|
|
60
|
-
"groups": [
|
|
61
|
-
{ "group": "Getting started", "pages": ["index", "quickstart"] }
|
|
62
|
-
]
|
|
63
|
-
}
|
|
64
|
-
]
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
- **`colors`** — `primary` is required; `light` and `dark` default to `primary`.
|
|
70
|
-
- **`navigation`** — Mintlify-compatible: `products → versions → languages →
|
|
71
|
-
tabs → anchors → groups → pages`. Switchable axes (products, versions,
|
|
72
|
-
languages) become URL path prefixes; the default value of each axis is
|
|
73
|
-
unprefixed. Languages are stored as ISO 639-1 codes and shown with their
|
|
74
|
-
native name.
|
|
75
|
-
|
|
76
|
-
Page labels come from each page's frontmatter `title`.
|
|
77
|
-
|
|
78
|
-
## License
|
|
79
|
-
|
|
80
|
-
Proprietary. © Velu.
|
|
1
|
+
# Velu
|
|
2
|
+
|
|
3
|
+
A documentation-site generator with live preview. Scaffold a docs project
|
|
4
|
+
and run it locally with two commands — author your pages in Markdown +
|
|
5
|
+
components, configure the site with a single `velu.json`.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @veluai/velu
|
|
9
|
+
velu init my-docs
|
|
10
|
+
velu dev my-docs
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Then open <http://localhost:8358>. Editing any `.mdx` page or `velu.json`
|
|
14
|
+
reloads the browser automatically.
|
|
15
|
+
|
|
16
|
+
> Requires **Node.js 18+**. Prefer not to install globally? Use
|
|
17
|
+
> `npx @veluai/velu init my-docs` and `npx @veluai/velu dev my-docs`.
|
|
18
|
+
|
|
19
|
+
## Commands
|
|
20
|
+
|
|
21
|
+
| Command | What it does |
|
|
22
|
+
| --- | --- |
|
|
23
|
+
| `velu init <dir>` | Scaffold a new docs project into `<dir>` (creates `velu.json`, a favicon, and a set of starter `.mdx` pages). |
|
|
24
|
+
| `velu dev [dir]` | Start the live-preview dev server for the project in `<dir>` (defaults to the current directory). |
|
|
25
|
+
|
|
26
|
+
Set a custom port with the `PORT` env var:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
PORT=5180 velu dev my-docs
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Project layout
|
|
33
|
+
|
|
34
|
+
`velu init` produces a project shaped like this:
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
my-docs/
|
|
38
|
+
├─ velu.json # site config: name, colors, font, favicon, navigation
|
|
39
|
+
├─ favicon.svg
|
|
40
|
+
├─ index.mdx # pages, organized however your navigation references them
|
|
41
|
+
├─ quickstart.mdx
|
|
42
|
+
└─ …
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## `velu.json`
|
|
46
|
+
|
|
47
|
+
`velu.json` drives the whole site — branding and navigation:
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
{
|
|
51
|
+
"$schema": "https://veluai.com/velu.schema.json",
|
|
52
|
+
"name": "My Docs",
|
|
53
|
+
"colors": { "primary": "#dc143c" },
|
|
54
|
+
"favicon": "/favicon.svg",
|
|
55
|
+
"font": { "family": "Inter" },
|
|
56
|
+
"navigation": {
|
|
57
|
+
"tabs": [
|
|
58
|
+
{
|
|
59
|
+
"tab": "Guides",
|
|
60
|
+
"groups": [
|
|
61
|
+
{ "group": "Getting started", "pages": ["index", "quickstart"] }
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
- **`colors`** — `primary` is required; `light` and `dark` default to `primary`.
|
|
70
|
+
- **`navigation`** — Mintlify-compatible: `products → versions → languages →
|
|
71
|
+
tabs → anchors → groups → pages`. Switchable axes (products, versions,
|
|
72
|
+
languages) become URL path prefixes; the default value of each axis is
|
|
73
|
+
unprefixed. Languages are stored as ISO 639-1 codes and shown with their
|
|
74
|
+
native name.
|
|
75
|
+
|
|
76
|
+
Page labels come from each page's frontmatter `title`.
|
|
77
|
+
|
|
78
|
+
## License
|
|
79
|
+
|
|
80
|
+
Proprietary. © Velu.
|
package/dist/cli.js
CHANGED
|
@@ -1,34 +1,36 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var
|
|
3
|
-
`,"utf-8");let o=await
|
|
4
|
-
`)}var bn,xn,ge,he,Ue,$n,Y=A(()=>{Ie();Ie();bn="#dc143c",xn="Google Sans Flex",ge="/@velu-logo-light",he="/@velu-logo-dark",Ue="/@velu-favicon",$n={".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 Sn}from"unist-util-visit";import{toString as kn}from"mdast-util-to-string";import An from"github-slugger";import{valueToEstree as jn}from"estree-util-value-to-estree";function ie(){return e=>{let t=new An,n=[];Sn(e,"heading",a=>{let s=kn(a);n.push({depth:a.depth,id:t.slug(s),label:s})});let r={children:[]},o=[{node:r,depth:0}];for(let a of n){for(;o.length>1&&o[o.length-1].depth>=a.depth;)o.pop();let s={id:a.id,label:a.label},l=o[o.length-1].node;l.children||(l.children=[]),l.children.push(s),o.push({node:s,depth:a.depth})}let i=r.children;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:"toc"},init:jn(i)}]}}]}}})}}var ze=A(()=>{});import On from"github-slugger";import Tn from"iso-639-1";function Pn(e){let t=String(e).toLowerCase();return Tn.getNativeName(t)||e}function ye(e){return new On().slug(String(e??""))}function _n(e){let t=String(e).replace(/^\/+|\/+$/g,"").split("/").filter(Boolean);return t[t.length-1]==="index"&&t.pop(),"/"+t.join("/")}function ft(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 U(e){let t={kind:"root",children:se(e??{})};return gt(t.children),t}function se(e){let t=Array.isArray(e.anchors)?e.anchors.map(In):[];if(Array.isArray(e.products))return[...t,...e.products.map(Cn)];if(Array.isArray(e.versions))return[...t,...e.versions.map(En)];if(Array.isArray(e.languages))return[...t,...e.languages.map(Fn)];if(Array.isArray(e.tabs))return[...t,...e.tabs.map(Nn)];let n=[...t];return Array.isArray(e.groups)&&n.push(...e.groups.map(mt)),Array.isArray(e.pages)&&n.push(...e.pages.map(dt)),n}function Cn(e){return{kind:"product",label:e.name??e.product,slug:ye(e.product),icon:e.icon,color:e.color,default:!!e.default,children:se(e)}}function En(e){return{kind:"version",label:e.version,slug:ye(e.version),default:!!e.default,children:se(e)}}function Fn(e){let t=String(e.language);return{kind:"language",code:t,label:Pn(t),slug:ye(t),default:!!e.default,children:se(e)}}function Nn(e){return{kind:"tab",label:e.tab,slug:ye(e.tab),icon:e.icon,href:e.href,children:se(e)}}function In(e){return{kind:"anchor",label:e.anchor,icon:e.icon,href:e.href,color:e.color}}function mt(e){let t=(e.pages??[]).map(dt);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 dt(e){return typeof e=="string"?{kind:"page",pagePath:e}:e&&e.apiPage?{kind:"page",pagePath:e.apiPage,label:e.label,method:e.method,api:!0}:mt(e)}function gt(e){for(let t of Ln){let n=e.filter(r=>r.kind===t);n.length&&!n.some(r=>r.default)&&(n[0].default=!0)}for(let t of e)t.children&>(t.children)}function K(e){let t=[],n=(r,o,i)=>{if(r.kind==="page"){t.push({pagePath:r.pagePath,url:Rn(r.pagePath,o),ctx:{...o},ancestors:i,node:r});return}let a=o;r.kind==="product"?a={...o,product:r.default?null:r.slug}:r.kind==="version"?a={...o,version:r.default?null:r.slug}:r.kind==="language"&&(a={...o,language:r.default?null:r.slug});let s=r.kind==="root"?i:[...i,r];for(let l of r.children??[])n(l,a,s)};return n(e,{product:null,version:null,language:null},[]),t}function Rn(e,t){let n=[t.product,t.version,t.language].filter(Boolean),r=_n(e).split("/").filter(Boolean);return"/"+[...n,...r].join("/")}var Ln,B=A(()=>{Ln=["product","version","language"]});import Un from"node:fs";import ht from"node:path";function M(e,t){let n=[],r=[],o=new Set;for(let i of K(e)){if(i.node?.api){o.add(i.url);continue}if(o.has(i.url)){n.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=ht.join(t,...a.split("/"))+".mdx",l=Un.existsSync(s);l||n.push(`page "${i.pagePath}" \u2192 ${ht.relative(t,s)} not found`),r.push({pagePath:i.pagePath,url:i.url,fileAbsPath:s,exists:l})}return{pageEntries:r,warnings:n}}var ae=A(()=>{B()});import Mn from"@apidevtools/swagger-parser";async function Gn(e){return Mn.dereference(e)}function G(e){return!e||typeof e!="object"?e||{}:Array.isArray(e.allOf)?e.allOf.reduce((t,n)=>{let r=G(n);return{...t,...r,properties:{...t.properties||{},...r.properties||{}},required:[...t.required||[],...r.required||[]]}},{...e,allOf:void 0}):Array.isArray(e.oneOf)&&e.oneOf.length?G(e.oneOf[0]):Array.isArray(e.anyOf)&&e.anyOf.length?G(e.anyOf[0]):e}function ve(e){let t=G(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`${ve(t.items||{})}[]`;let n=t.type||(t.properties?"object":"any");return t.format?`${n}<${t.format}>`:n}function le(e,t=0){let n=G(e);if(!n||typeof n!="object")return null;if(n.example!==void 0)return n.example;if(n.default!==void 0)return n.default;if(Array.isArray(n.enum)&&n.enum.length)return n.enum[0];if(t>=Bn)return n.type==="object"?{}:null;switch(n.type){case"object":{let r={};for(let[o,i]of Object.entries(n.properties||{}))r[o]=le(i,t+1);return r}case"array":return[le(n.items||{},t+1)];case"integer":case"number":return 0;case"boolean":return!0;default:return Jn(n)}}function Jn(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 vt(e){let t=G(e);if(!t||t.type!=="object"||!t.properties)return t&&(t.type||t.items)?[{name:"body",type:ve(t),required:!1,description:t.description||""}]:[];let n=new Set(t.required||[]);return Object.entries(t.properties).map(([r,o])=>{let i=G(o);return{name:r,type:ve(i),required:n.has(r),description:i.description||"",enum:Array.isArray(i.enum)?i.enum:void 0,deprecated:i.deprecated||void 0}})}function Vn(e){let t=e.schema||{};return{name:e.name,in:e.in,required:e.in==="path"?!0:!!e.required,type:ve(t),description:e.description||"",enum:Array.isArray(t.enum)?t.enum:void 0,example:le(t),deprecated:e.deprecated||void 0}}function bt(e){if(!e||typeof e!="object")return null;let t=Object.keys(e),n=t.find(r=>/json/i.test(r))||t[0];return n?{contentType:n,media:e[n]}:null}function qn(e){if(!e)return null;let t=bt(e.content);if(!t)return null;let n=t.media.schema||{};return{required:!!e.required,description:e.description||"",contentType:t.contentType,fields:vt(n),example:t.media.example??le(n)}}function Hn(e){return!e||typeof e!="object"?[]:Object.entries(e).map(([t,n])=>{let r=bt(n?.content),o=r?.media?.schema||{};return{status:t,description:n?.description||"",contentType:r?.contentType||null,fields:r?vt(o):[],example:r?r.media.example??le(o):null}})}function Dn(e,t){if(!Array.isArray(e)||!t)return[];let n=[],r=new Set;for(let o of e)for(let i of Object.keys(o||{})){let a=t[i];!a||r.has(i)||(r.add(i),n.push(Xn(i,a)))}return n.filter(Boolean)}function Xn(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 yt(e){return String(e).replace(/\{[^}]+\}/g,t=>t.slice(1,-1)).replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-+|-+$/g,"").toLowerCase()}function Yn(e){let{method:t,path:n,op:r,sharedParams:o,servers:i,schemes:a}=e,s=[...o||[],...r.parameters||[]],l={path:[],query:[],header:[],cookie:[]};for(let u of s)u&&l[u.in]&&l[u.in].push(Vn(u));let p=r.security??e.globalSecurity;return{id:r.operationId?yt(r.operationId):`${t}-${yt(n)}`,method:t.toUpperCase(),path:n,title:r.summary||r.operationId||`${t.toUpperCase()} ${n}`,description:r.description||r.summary||"",tags:Array.isArray(r.tags)&&r.tags.length?r.tags:["API"],deprecated:r.deprecated||!1,auth:Dn(p,a),parameters:l,body:qn(r.requestBody),responses:Hn(r.responses),servers:(i||[]).map(u=>u.url).filter(Boolean)}}function Kn(e,t,n,r,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=(r.servers||i||[]).filter(Boolean);l.length&&(s.servers=l);let p={};Array.isArray(o)&&o.length&&(p.parameters=o),p[n]=r,s.paths={[t]:p};let u=r.security??e.security;if(a&&Array.isArray(u)&&u.length){let c={};for(let b of u)for(let d of Object.keys(b||{}))a[d]&&(c[d]=a[d]);Object.keys(c).length&&(e.swagger?s.securityDefinitions=c:s.components={securitySchemes:c})}return s}function Wn(e){let t=[],n=[],r=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||[],p=s.servers||i;for(let u of zn){let c=s[u];!c||typeof c!="object"||(t.push(Yn({method:u,path:a,op:c,sharedParams:l,servers:c.servers||p,globalSecurity:o,schemes:r})),n.push(Kn(e,a,u,c,l,c.servers||p,r)))}}return{operations:t,segments:n}}async function xt(e){let t=await Gn(e),n=t.servers||(t.host?[{url:`https://${t.host}${t.basePath||""}`}]:[]),{operations:r,segments:o}=Wn(t);return{title:t.info?.title||"API Reference",version:t.info?.version||"",servers:n.map(i=>i.url).filter(Boolean),operations:r,segments:o}}var zn,Bn,$t=A(()=>{zn=["get","post","put","patch","delete","options","head","trace"],Bn=6});function Zn(e,{server:t}={}){let r=`${(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:r,headers:o,body:i?e.body.example??{}:null}}function Qn(e){let t=`curl --request ${e.method} \\
|
|
2
|
+
var En=Object.defineProperty;var A=(e,t)=>()=>(e&&(t=e(e=0)),t);var ye=(e,t)=>{for(var n in t)En(e,n,{get:t[n],enumerable:!0})};var vt={};ye(vt,{initProject:()=>Un});import Y from"node:fs/promises";import W from"node:path";import{fileURLToPath as Cn}from"node:url";async function Un(e,t){try{if((await Y.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 Y.mkdir(e,{recursive:!0}),await Y.cp(Nn,e,{recursive:!0});let n=W.join(e,"velu.json"),r=JSON.parse(await Y.readFile(n,"utf-8"));r.name=t,await Y.writeFile(n,JSON.stringify(r,null,2)+`
|
|
3
|
+
`,"utf-8");let o=await yt(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 yt(e,t=e,n=[]){let r=await Y.readdir(e,{withFileTypes:!0});for(let o of r){let i=W.join(e,o.name);o.isDirectory()?await yt(i,t,n):n.push(W.relative(t,i).split(W.sep).join("/"))}return n.sort()}var Fn,Nn,bt=A(()=>{Fn=W.dirname(Cn(import.meta.url)),Nn=W.resolve(Fn,"..","templates","starter")});var Be={};ye(Be,{currentVersion:()=>Ie,getLatestVersion:()=>ze,isNewer:()=>Me,maybeAutoUpdate:()=>Xn,updateCommand:()=>Wn});import{spawnSync as $t}from"node:child_process";import{readFileSync as wt,writeFileSync as Rn,mkdirSync as In}from"node:fs";import{fileURLToPath as Mn}from"node:url";import{homedir as zn,tmpdir as Bn}from"node:os";import Re from"node:path";import N from"node:process";function Ie(){try{return JSON.parse(wt(new URL("../package.json",import.meta.url),"utf8")).version}catch{return"unknown"}}function Hn(e,t){let n=i=>String(i).split("-")[0].split(".").map(a=>Number(a)||0),r=n(e),o=n(t);for(let i=0;i<3;i++){let a=(r[i]||0)-(o[i]||0);if(a!==0)return a<0?-1:1}return 0}function Me(e,t){return!e||!t||t==="unknown"?!1:Hn(e,t)>0}function St(){let e=Re.join(zn()||Bn(),".velu");return Re.join(e,"update-check.json")}function xt(){try{return JSON.parse(wt(St(),"utf8"))}catch{return null}}function qn(e){try{let t=St();In(Re.dirname(t),{recursive:!0}),Rn(t,JSON.stringify(e))}catch{}}async function Dn(){let e=`${Gn}/-/package/${ve}/dist-tags`,t=new AbortController,n=setTimeout(()=>t.abort(),Jn);try{let r=await fetch(e,{signal:t.signal,headers:{accept:"application/json"}});if(!r.ok)return null;let o=await r.json();return o&&typeof o.latest=="string"?o.latest:null}catch{return null}finally{clearTimeout(n)}}async function ze({force:e=!1}={}){if(!e){let n=xt();if(n?.latest&&Date.now()-(n.checkedAt||0)<Vn)return n.latest}let t=await Dn();return t?(qn({latest:t,checkedAt:Date.now()}),t):xt()?.latest??null}function kt(){let e=N.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=Mn(import.meta.url).replace(/\\/g,"/")}catch{}return t.includes("/pnpm/")?"pnpm":t.includes("/yarn/")||t.includes("/.yarn/")?"yarn":t.includes("/.bun/")?"bun":"npm"}function Yn(e){let t=`${ve}@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 At(e){let[t,n]=Yn(e);return $t(t,n,{stdio:"inherit",shell:N.platform==="win32"}).status===0}async function Wn(){let e=Ie(),t=await ze({force:!0});if(t&&!Me(t,e)){console.log(`velu is already up to date (v${e}).`);return}let n=kt();console.log(t?`Updating velu ${e} \u2192 ${t} (via ${n})\u2026`:`Could not reach the npm registry; installing ${ve}@latest (via ${n}) anyway\u2026`),At(n)?console.log('\u2713 Updated. Run "velu version" to confirm.'):(console.error("Update failed. You can update manually with:"),console.error(` npm install -g ${ve}@latest`),N.exitCode=1)}async function Xn(){if(N.env.VELU_NO_UPDATE==="1"||N.env.VELU_UPDATED==="1"||!N.stdout.isTTY)return;let e=Ie();if(e==="unknown")return;let t=null;try{t=await ze()}catch{return}if(!Me(t,e))return;let n=kt();if(console.log(`
|
|
4
|
+
New velu version available: ${e} \u2192 ${t}. Updating\u2026`),!At(n)){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
|
|
5
|
+
`);let r=$t(N.execPath,N.argv.slice(1),{stdio:"inherit",env:{...N.env,VELU_UPDATED:"1"}});N.exit(r.status??0)}var ve,Gn,Vn,Jn,Ge=A(()=>{ve="@veluai/velu",Gn="https://registry.npmjs.org",Vn=720*60*1e3,Jn=3e3});function Je({light:e,dark:t,family:n}){return[":root:root {",` --accent-color: ${e};`,` --font-sans: "${n}", sans-serif;`,"}",':root:root[data-theme="dark"] {',` --accent-color: ${t};`,"}"].join(`
|
|
6
|
+
`)}function ne(e){if(!e||typeof e!="object")return null;let t=[];if(e.socials&&typeof e.socials=="object")for(let[r,o]of Object.entries(e.socials))typeof o!="string"||!o.trim()||t.push({kind:Kn[r]??r,href:o.trim()});let n=Array.isArray(e.links)?e.links.filter(r=>r&&typeof r=="object").map(r=>({title:(r.header??r.title??"").trim(),items:(Array.isArray(r.items)?r.items:[]).filter(o=>o&&o.label).map(o=>({label:o.label,href:o.href??"#"}))})).filter(r=>r.title||r.items.length):[];return!t.length&&!n.length?null:{socials:t,links:n}}function Ve(e){return/^(https?:)?\/\//.test(e)||/^(mailto|tel):/.test(e)}function re(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:Ve(o.href.trim())})),n=null,r=e.primary;if(r&&typeof r=="object"&&typeof r.href=="string"&&r.href.trim()){let o=r.href.trim();n=r.type==="github"?{kind:"github",label:r.label??"GitHub",href:o,external:Ve(o)}:{kind:"button",label:r.label??"",href:o,external:Ve(o)}}return!t.length&&!n?null:{links:t,primary:n}}function He(e){if(e==null)return{options:[...jt],display:"header"};if(typeof e!="object")return{options:[],display:"header"};let t=e.display==="toc"?"toc":"header",n=Array.isArray(e.options)?e.options:jt,r=[];for(let o of n)typeof o=="string"?Zn.has(o)&&r.push(o):o&&typeof o=="object"&&o.title&&o.href&&r.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:r,display:t}}function R(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 oe(e){if(!e||typeof e!="object")return null;let t=typeof e.apiBase=="string"&&e.apiBase.trim()?e.apiBase.trim().replace(/\/+$/,""):null,n=typeof e.host=="string"&&e.host.trim()?e.host.trim():null,r=Array.isArray(e.suggestions)?e.suggestions.filter(o=>typeof o=="string"&&o.trim()).map(o=>o.trim()).slice(0,6):[];return!t&&!r.length?null:{apiBase:t,host:n,suggestions:r}}var Kn,Zn,jt,be=A(()=>{Kn={twitter:"x","x-twitter":"x"};Zn=new Set(["copy","assistant","view","download-pdf","download-spec","chatgpt","claude","perplexity","grok","aistudio","devin","windsurf","mcp","add-mcp","cursor","vscode","devin-mcp"]),jt=["copy","view","chatgpt","claude"]});import Qn from"node:fs/promises";import qe from"node:path";function Ot(e){if(!e.favicon)return null;let t=qe.extname(e.favicon).toLowerCase();return{url:De+t,type:nr[t]||""}}function ie(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?.(),n=(e.dark??e.light)?.trim?.();return!t||!n?null:{light:t,dark:n,href:e.href?.trim?.()||"/"}}return null}function rr(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 Ye(e={},t){let n=e.colors?.primary??er;return{name:e.name??t??"docs",url:typeof e.url=="string"&&e.url.trim()?e.url.trim().replace(/\/+$/,""):null,seo:rr(e.seo),assistant:oe(e.assistant),thumbnails:e.thumbnails&&typeof e.thumbnails=="object"&&typeof e.thumbnails.background=="string"?{background:e.thumbnails.background}:null,colors:{primary:n,light:e.colors?.light??n,dark:e.colors?.dark??n},favicon:e.favicon??null,api:R(e.api),logo:ie(e.logo),footer:ne(e.footer),navbar:re(e.navbar),font:{family:e.font?.family??tr},navigation:e.navigation??null}}async function Tt(e){let t=qe.join(e,"velu.json"),n;try{n=await Qn.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 r;try{r=JSON.parse(n)}catch(o){throw new Error(`velu.json is not valid JSON: ${o.message}`)}return Ye(r,qe.basename(e))}function Lt(e){let{colors:t,font:n}=e;return Je({light:t.light,dark:t.dark,family:n.family})}var er,tr,xe,$e,De,nr,se=A(()=>{be();be();er="#dc143c",tr="Google Sans Flex",xe="/@velu-logo-light",$e="/@velu-logo-dark",De="/@velu-favicon",nr={".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 or}from"unist-util-visit";import{toString as ir}from"mdast-util-to-string";import sr from"github-slugger";import{valueToEstree as ar}from"estree-util-value-to-estree";function ae(){return e=>{let t=new sr,n=[];or(e,"heading",a=>{let s=ir(a);n.push({depth:a.depth,id:t.slug(s),label:s})});let r={children:[]},o=[{node:r,depth:0}];for(let a of n){for(;o.length>1&&o[o.length-1].depth>=a.depth;)o.pop();let s={id:a.id,label:a.label},l=o[o.length-1].node;l.children||(l.children=[]),l.children.push(s),o.push({node:s,depth:a.depth})}let i=r.children;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:"toc"},init:ar(i)}]}}]}}})}}var We=A(()=>{});import lr from"github-slugger";import cr from"iso-639-1";function pr(e){let t=String(e).toLowerCase();return cr.getNativeName(t)||e}function we(e){return new lr().slug(String(e??""))}function fr(e){let t=String(e).replace(/^\/+|\/+$/g,"").split("/").filter(Boolean);return t[t.length-1]==="index"&&t.pop(),"/"+t.join("/")}function _t(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 z(e){let t={kind:"root",children:le(e??{})};return Ct(t.children),t}function le(e){let t=Array.isArray(e.anchors)?e.anchors.map(yr):[];if(Array.isArray(e.products))return[...t,...e.products.map(mr)];if(Array.isArray(e.versions))return[...t,...e.versions.map(dr)];if(Array.isArray(e.languages))return[...t,...e.languages.map(gr)];if(Array.isArray(e.tabs))return[...t,...e.tabs.map(hr)];let n=[...t];return Array.isArray(e.groups)&&n.push(...e.groups.map(Pt)),Array.isArray(e.pages)&&n.push(...e.pages.map(Et)),n}function mr(e){return{kind:"product",label:e.name??e.product,slug:we(e.product),icon:e.icon,color:e.color,default:!!e.default,children:le(e)}}function dr(e){return{kind:"version",label:e.version,slug:we(e.version),default:!!e.default,children:le(e)}}function gr(e){let t=String(e.language);return{kind:"language",code:t,label:pr(t),slug:we(t),default:!!e.default,children:le(e)}}function hr(e){return{kind:"tab",label:e.tab,slug:we(e.tab),icon:e.icon,href:e.href,children:le(e)}}function yr(e){return{kind:"anchor",label:e.anchor,icon:e.icon,href:e.href,color:e.color}}function Pt(e){let t=(e.pages??[]).map(Et);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 Et(e){return typeof e=="string"?{kind:"page",pagePath:e}:e&&e.apiPage?{kind:"page",pagePath:e.apiPage,label:e.label,method:e.method,api:!0}:Pt(e)}function Ct(e){for(let t of ur){let n=e.filter(r=>r.kind===t);n.length&&!n.some(r=>r.default)&&(n[0].default=!0)}for(let t of e)t.children&&Ct(t.children)}function X(e){let t=[],n=(r,o,i)=>{if(r.kind==="page"){t.push({pagePath:r.pagePath,url:vr(r.pagePath,o),ctx:{...o},ancestors:i,node:r});return}let a=o;r.kind==="product"?a={...o,product:r.default?null:r.slug}:r.kind==="version"?a={...o,version:r.default?null:r.slug}:r.kind==="language"&&(a={...o,language:r.default?null:r.slug});let s=r.kind==="root"?i:[...i,r];for(let l of r.children??[])n(l,a,s)};return n(e,{product:null,version:null,language:null},[]),t}function vr(e,t){let n=[t.product,t.version,t.language].filter(Boolean),r=fr(e).split("/").filter(Boolean);return"/"+[...n,...r].join("/")}var ur,G=A(()=>{ur=["product","version","language"]});import br from"node:fs";import Ft from"node:path";function B(e,t){let n=[],r=[],o=new Set;for(let i of X(e)){if(i.node?.api){o.add(i.url);continue}if(o.has(i.url)){n.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=Ft.join(t,...a.split("/"))+".mdx",l=br.existsSync(s);l||n.push(`page "${i.pagePath}" \u2192 ${Ft.relative(t,s)} not found`),r.push({pagePath:i.pagePath,url:i.url,fileAbsPath:s,exists:l})}return{pageEntries:r,warnings:n}}var ce=A(()=>{G()});function V(e){return!e||typeof e!="object"?e||{}:Array.isArray(e.allOf)?e.allOf.reduce((t,n)=>{let r=V(n);return{...t,...r,properties:{...t.properties||{},...r.properties||{}},required:[...t.required||[],...r.required||[]]}},{...e,allOf:void 0}):Array.isArray(e.oneOf)&&e.oneOf.length?V(e.oneOf[0]):Array.isArray(e.anyOf)&&e.anyOf.length?V(e.anyOf[0]):e}function ue(e){let t=V(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`${ue(t.items||{})}[]`;let n=t.type||(t.properties?"object":"any");return t.format?`${n}<${t.format}>`:n}function K(e,t=0){let n=V(e);if(!n||typeof n!="object")return null;if(n.example!==void 0)return n.example;if(n.default!==void 0)return n.default;if(Array.isArray(n.enum)&&n.enum.length)return n.enum[0];if(t>=6)return n.type==="object"?{}:null;switch(n.type){case"object":{let r={};for(let[o,i]of Object.entries(n.properties||{}))r[o]=K(i,t+1);return r}case"array":return[K(n.items||{},t+1)];case"integer":case"number":return 0;case"boolean":return!0;default:return $r(n)}}function $r(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 Xe(e){let t=V(e);if(!t||t.type!=="object"||!t.properties)return t&&(t.type||t.items)?[{name:"body",type:ue(t),required:!1,description:t.description||""}]:[];let n=new Set(t.required||[]);return Object.entries(t.properties).map(([r,o])=>{let i=V(o);return{name:r,type:ue(i),required:n.has(r),description:i.description||"",enum:Array.isArray(i.enum)?i.enum:void 0,deprecated:i.deprecated||void 0}})}function wr(e){let t=e.schema||{};return{name:e.name,in:e.in,required:e.in==="path"?!0:!!e.required,type:ue(t),description:e.description||"",enum:Array.isArray(t.enum)?t.enum:void 0,example:K(t),deprecated:e.deprecated||void 0}}function Ut(e){if(!e||typeof e!="object")return null;let t=Object.keys(e),n=t.find(r=>/json/i.test(r))||t[0];return n?{contentType:n,media:e[n]}:null}function Sr(e){if(!e)return null;let t=Ut(e.content);if(!t)return null;let n=t.media.schema||{};return{required:!!e.required,description:e.description||"",contentType:t.contentType,fields:Xe(n),example:t.media.example??K(n)}}function kr(e){return!e||typeof e!="object"?[]:Object.entries(e).map(([t,n])=>{let r=Ut(n?.content),o=r?.media?.schema||{};return{status:t,description:n?.description||"",contentType:r?.contentType||null,fields:r?Xe(o):[],example:r?r.media.example??K(o):null}})}function Ar(e,t){if(!Array.isArray(e)||!t)return[];let n=[],r=new Set;for(let o of e)for(let i of Object.keys(o||{})){let a=t[i];!a||r.has(i)||(r.add(i),n.push(jr(i,a)))}return n.filter(Boolean)}function jr(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 Nt(e){return String(e).replace(/\{[^}]+\}/g,t=>t.slice(1,-1)).replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-+|-+$/g,"").toLowerCase()}function Or(e){let{method:t,path:n,op:r,sharedParams:o,servers:i,schemes:a}=e,s=[...o||[],...r.parameters||[]],l={path:[],query:[],header:[],cookie:[]};for(let c of s)c&&l[c.in]&&l[c.in].push(wr(c));let p=r.security??e.globalSecurity;return{id:r.operationId?Nt(r.operationId):`${t}-${Nt(n)}`,method:t.toUpperCase(),path:n,title:r.summary||r.operationId||`${t.toUpperCase()} ${n}`,description:r.description||r.summary||"",tags:Array.isArray(r.tags)&&r.tags.length?r.tags:["API"],deprecated:r.deprecated||!1,auth:Ar(p,a),parameters:l,body:Sr(r.requestBody),responses:kr(r.responses),servers:(i||[]).map(c=>c.url).filter(Boolean)}}function Tr(e,t,n,r,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=(r.servers||i||[]).filter(Boolean);l.length&&(s.servers=l);let p={};Array.isArray(o)&&o.length&&(p.parameters=o),p[n]=r,s.paths={[t]:p};let c=r.security??e.security;if(a&&Array.isArray(c)&&c.length){let u={};for(let b of c)for(let d of Object.keys(b||{}))a[d]&&(u[d]=a[d]);Object.keys(u).length&&(e.swagger?s.securityDefinitions=u:s.components={securitySchemes:u})}return s}function Rt(e){let t=[],n=[],r=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||[],p=s.servers||i;for(let c of xr){let u=s[c];!u||typeof u!="object"||(t.push(Or({method:c,path:a,op:u,sharedParams:l,servers:u.servers||p,globalSecurity:o,schemes:r})),n.push(Tr(e,a,c,u,l,u.servers||p,r)))}}return{operations:t,segments:n}}function Ke(e){let t=e.servers||(e.host?[{url:`https://${e.host}${e.basePath||""}`}]:[]),{operations:n,segments:r}=Rt(e);return{title:e.info?.title||"API Reference",version:e.info?.version||"",servers:t.map(o=>o.url).filter(Boolean),operations:n,segments:r}}var xr,Ze=A(()=>{xr=["get","post","put","patch","delete","options","head","trace"]});import Lr from"@apidevtools/swagger-parser";async function _r(e){return Lr.dereference(e)}async function It(e){return Ke(await _r(e))}var Mt=A(()=>{Ze();Ze()});function Pr(e,{server:t}={}){let r=`${(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:r,headers:o,body:i?e.body.example??{}:null}}function Er(e){let t=`curl --request ${e.method} \\
|
|
5
7
|
--url ${e.url}`;for(let[n,r]of Object.entries(e.headers))t+=` \\
|
|
6
8
|
--header '${n}: ${r}'`;return e.body!=null&&(t+=` \\
|
|
7
|
-
--data '${JSON.stringify(e.body)}'`),t}function
|
|
9
|
+
--data '${JSON.stringify(e.body)}'`),t}function Cr(e){let t=[` method: '${e.method}'`];if(Object.keys(e.headers).length){let n=Object.entries(e.headers).map(([r,o])=>` '${r}': '${o}'`).join(`,
|
|
8
10
|
`);t.push(` headers: {
|
|
9
11
|
${n}
|
|
10
|
-
}`)}return e.body!=null&&t.push(` body: JSON.stringify(${
|
|
12
|
+
}`)}return e.body!=null&&t.push(` body: JSON.stringify(${Qe(e.body," ")})`),[`const res = await fetch('${e.url}', {`,t.join(`,
|
|
11
13
|
`),"});","const data = await res.json();"].join(`
|
|
12
|
-
`)}function
|
|
14
|
+
`)}function Fr(e){let t=["import requests","",`url = "${e.url}"`];if(Object.keys(e.headers).length){let r=Object.entries(e.headers).map(([o,i])=>` "${o}": "${i}"`).join(`,
|
|
13
15
|
`);t.push(`headers = {
|
|
14
16
|
${r}
|
|
15
|
-
}`)}let n=["url"];return e.body!=null&&(t.push(`payload = ${
|
|
16
|
-
`)}function
|
|
17
|
-
`)}function
|
|
17
|
+
}`)}let n=["url"];return e.body!=null&&(t.push(`payload = ${Qe(e.body,"")}`),n.push("json=payload")),Object.keys(e.headers).length&&n.push("headers=headers"),t.push("",`response = requests.${e.method.toLowerCase()}(${n.join(", ")})`,"print(response.json())"),t.join(`
|
|
18
|
+
`)}function Nr(e){let t=e.method.charAt(0)+e.method.slice(1).toLowerCase(),n=["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[r,o]of Object.entries(e.headers))n.push(`request['${r}'] = '${o}'`);return e.body!=null&&n.push(`request.body = ${Qe(e.body,"")}.to_json`),n.push("","response = http.request(request)","puts response.body"),n.join(`
|
|
19
|
+
`)}function Bt(e,{server:t,languages:n=et}={}){let r=Pr(e,{server:t});return n.filter(o=>zt[o]).map(o=>({key:o,label:Ur[o],language:Rr[o],code:zt[o](r)}))}var Qe,zt,Ur,Rr,et,Gt=A(()=>{Qe=(e,t)=>JSON.stringify(e,null,2).split(`
|
|
18
20
|
`).map((n,r)=>r===0?n:t+n).join(`
|
|
19
|
-
`);
|
|
21
|
+
`);zt={curl:Er,javascript:Cr,python:Fr,ruby:Nr},Ur={curl:"cURL",javascript:"JavaScript",python:"Python",ruby:"Ruby"},Rr={curl:"bash",javascript:"javascript",python:"python",ruby:"ruby"},et=["curl","javascript","python","ruby"]});function Vt(e,t){if(!t||typeof t!="object")return e;let n=R(t);return{server:t.server!=null?n.server:e?.server??null,proxy:t.playground!=null?n.proxy:e?.proxy!==!1,languages:t.examples?.languages!=null?n.languages:e?.languages}}function Ir(e,{base:t,api:n,ops:r}){let o=n?.server,i=n?.languages||et,a={proxy:n?.proxy!==!1,server:o??null},s=new Map;for(let p of e){let c=p.op.tags?.[0]||"API";s.has(c)||s.set(c,[]),s.get(c).push(p)}let l=[];for(let[p,c]of s){let u=c.map(({op:b,segment:d})=>{let x=`${t}/${tt(p)}/${b.id}`;return r[x]={operation:b,samples:Bt(b,{server:o||b.servers?.[0],languages:i}),segment:d,title:b.title,description:b.description,method:b.method,api:a},{apiPage:x,label:b.title,method:b.method}});l.push({group:p,pages:u})}return l}async function Jt(e,{loadOps:t,base:n,api:r,ops:o}){let i=Array.isArray(e)?e:[e],a=[];for(let s of i){let{operations:l,segments:p,servers:c}=await t(s);l.forEach((u,b)=>{!u.servers?.length&&c?.length&&(u.servers=c),a.push({op:u,segment:p[b]})})}return Ir(a,{base:n,api:r,ops:o})}async function Ht(e,t){if(!e||typeof e!="object")return e;if(typeof e.tab=="string"&&e.openapi){let r=tt(e.tab),o=Vt(t.api,e.api),i=await Jt(e.openapi,{...t,base:r,api:o}),{openapi:a,api:s,...l}=e;return{...l,groups:[...l.groups||[],...i]}}if(typeof e.group=="string"&&e.openapi){let r=tt(e.group),o=Vt(t.api,e.api),i=await Jt(e.openapi,{...t,base:r,api:o}),{openapi:a,api:s,...l}=e,p=i.flatMap(c=>c.pages);return{...l,pages:[...l.pages||[],...p]}}let n={...e};for(let r of["products","versions","languages","tabs","groups"])Array.isArray(e[r])&&(n[r]=await Promise.all(e[r].map(o=>Ht(o,t))));return n}async function qt(e,{api:t,loadOps:n}){let r={};return!e||typeof e!="object"?{nav:e,ops:r}:{nav:await Ht(e,{api:t,loadOps:n,ops:r}),ops:r}}var tt,Dt=A(()=>{be();Gt();tt=e=>String(e??"").replace(/\{[^}]+\}/g,t=>t.slice(1,-1)).replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-+|-+$/g,"").toLowerCase()||"x"});import Mr from"node:path";function zr(e,t){return/^https?:\/\//.test(e)?e:Mr.resolve(t,e.replace(/^\/+/,""))}async function Se(e,{targetDir:t,api:n}={}){return qt(e,{api:n,loadOps:r=>It(zr(r,t))})}var nt=A(()=>{Mt();Dt()});import Br from"node:fs";import pe from"node:path";function Xt(e){return{name:"velu-site",resolveId(t){return t===Wt?Yt:null},async load(t){return t!==Yt?null:Gr(e)}}}async function Gr(e){let t={};try{t=JSON.parse(Br.readFileSync(pe.join(e,"velu.json"),"utf-8"))}catch{}let n=R(t.api),r=t.navigation??{},o={};try{let $=await Se(t.navigation??{},{targetDir:e,api:n});r=$.nav,o=$.ops}catch($){console.warn(`[velu] openapi: ${$.message}`)}let i=z(r),{pageEntries:a,warnings:s}=B(i,e);for(let $ of s)console.warn(`[velu] nav: ${$}`);let l=ie(t.logo),p={name:t.name??pe.basename(e),logo:l?{light:xe,dark:$e,href:l.href,mono:l.light===l.dark}:null,footer:ne(t.footer),navbar:re(t.navbar),contextual:He(t.contextual),assistant:oe(t.assistant)},c=[],u=[],b=0;for(let $ of a){if(!$.exists)continue;let y=JSON.stringify($.fileAbsPath.split(pe.sep).join("/")),f=JSON.stringify(pe.relative(e,$.fileAbsPath).split(pe.sep).join("/")),g=`__p${b++}`;c.push(`import * as ${g} from ${y};`),u.push(` ${JSON.stringify($.url)}: { Component: ${g}.default, frontmatter: ${g}.frontmatter, toc: ${g}.toc, relPath: ${f} },`)}let d=new Set(a.filter($=>$.exists).map($=>$.url));for(let $ of a)!$.exists&&!d.has($.url)&&u.push(` ${JSON.stringify($.url)}: { missing: true },`);let x=[],m=[],L=[],h=!1,w=0;for(let $ of X(i)){if(!$.node?.api)continue;let y=o[$.pagePath];if(!y)continue;h=!0;let f=`__op${w}`,g=`__samples${w}`,v=`__api${w}`;w+=1,x.push(`const ${f} = ${JSON.stringify(y.operation)};`),x.push(`const ${g} = ${JSON.stringify(y.samples)};`),L.push(`{ id: ${JSON.stringify(y.operation.id)}, method: ${JSON.stringify(y.operation.method)}, title: ${JSON.stringify(y.operation.title)}, url: ${JSON.stringify($.url)}, operation: ${f}, samples: ${g}, api: ${JSON.stringify(y.api||{proxy:!0,server:null})} }`),m.push(`function ${v}(){ return React.createElement(ApiReferencePage, { operation: ${f}, samples: ${g}, apiOperations: __apiOperations, api: ${JSON.stringify(y.api||{proxy:!0,server:null})} }); }`),u.push(` ${JSON.stringify($.url)}: { Component: ${v}, frontmatter: { title: ${JSON.stringify(y.title)}, description: ${JSON.stringify(y.description)} }, toc: [], operation: ${f}, samples: ${g}, api: true },`)}h&&(x.push(`const __apiOperations = [
|
|
20
22
|
${L.join(`,
|
|
21
23
|
`)}
|
|
22
|
-
];`)
|
|
24
|
+
];`),x.push(m.join(`
|
|
23
25
|
`)));let F=[];return h&&(F.push("import React from 'react';"),F.push("import { ApiReferencePage } from 'velu-ui';")),["// AUTO-GENERATED by vite-plugin-velu-site. Do not edit.",F.join(`
|
|
24
|
-
`),
|
|
25
|
-
`)
|
|
26
|
-
`),"","export const pages = {",
|
|
26
|
+
`),c.join(`
|
|
27
|
+
`),x.join(`
|
|
28
|
+
`),"","export const pages = {",u.join(`
|
|
27
29
|
`),"};",`export const navigation = ${JSON.stringify(i)};`,`export const site = ${JSON.stringify(p)};`,""].join(`
|
|
28
|
-
`)}var
|
|
29
|
-
`))i.push(` ${a}`);return e.suggestion&&i.push(` ${
|
|
30
|
-
`)}function
|
|
31
|
-
`)}var
|
|
30
|
+
`)}var Wt,Yt,Kt=A(()=>{G();ce();se();nt();Wt="virtual:velu-site",Yt="\0"+Wt});import{visit as Vr}from"unist-util-visit";function Jr(e,t){let n=Zt(e).replace(/[?#].*$/,""),r=Zt(t).replace(/\/+$/,"");return r&&n.toLowerCase().startsWith(r.toLowerCase())?n.slice(r.length).replace(/^\/+/,""):null}function Qt(e,t){return()=>(n,r)=>{typeof e=="function"&&Vr(n,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:Jr(r?.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 Zt,en=A(()=>{Zt=e=>String(e||"").replace(/\\/g,"/")});import ke from"node:path";import Hr from"node:fs";import{createRequire as qr}from"node:module";import Dr from"@tailwindcss/vite";import Yr from"@vitejs/plugin-react";import Wr from"@mdx-js/rollup";import Xr from"remark-frontmatter";import Kr from"remark-mdx-frontmatter";import Zr from"remark-gfm";import Qr from"rehype-slug";function eo(e){let n=qr(import.meta.url).resolve("@mdx-js/react"),r=ke.resolve(e,"runtime","velu-ui"),o=Hr.existsSync(r)?r:ke.resolve(e,"..","velu-ui","src");return[{find:"@mdx-js/react",replacement:n},{find:/^velu-ui$/,replacement:ke.join(o,"index.js")},{find:/^velu-ui\//,replacement:o+"/"}]}function tn({targetDir:e,VITE_ROOT:t,validateProps:n}){return{root:t,plugins:[Xt(e),Wr({remarkPlugins:[Xr,Kr,Zr,ae,Qt(n,e)],rehypePlugins:[Qr],providerImportSource:"@mdx-js/react"}),Yr(),Dr({optimize:!1})],cacheDir:ke.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:eo(t),dedupe:["react","react-dom","@mdx-js/react"]}}}var nn=A(()=>{We();Kt();en()});function j(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 to(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 n=Array.from({length:t.length+1},(o,i)=>i),r=new Array(t.length+1);for(let o=1;o<=e.length;o++){r[0]=o;for(let i=1;i<=t.length;i++){let a=e[o-1]===t[i-1]?0:1;r[i]=Math.min(r[i-1]+1,n[i]+1,n[i-1]+a)}[n,r]=[r,n]}return n[t.length]}function Ae(e,t=[]){if(!e)return null;let n=String(e).toLowerCase(),r=null,o=1/0;for(let a of t){let s=to(n,String(a).toLowerCase());s<o&&(o=s,r=a)}let i=Math.min(3,Math.max(2,Math.floor(n.length/4)));return o<=i?r:null}function no(e,t){return e==="warning"?C(t,E.yellow,"\u26A0"):e==="info"?C(t,E.cyan,"\u2139"):C(t,E.red,"\u2716")}function ot(e,{color:t=!1}={}){let n=rt[e.category]||e.category,r=e.line?`${e.line}${e.column?`:${e.column}`:""}`:"",o=e.file?`${e.file}${r?`:${r}`:""}`:r,i=[];if(i.push(`${no(e.severity,t)} ${C(t,E.bold,n)}`+(o?` ${C(t,E.dim,o)}`:"")),e.title&&i.push(` ${e.title}`),e.detail&&e.detail!==e.title&&i.push(` ${C(t,E.dim,e.detail)}`),e.frame)for(let a of String(e.frame).split(`
|
|
31
|
+
`))i.push(` ${a}`);return e.suggestion&&i.push(` ${C(t,E.cyan,`Did you mean <${e.suggestion}>?`)}`),e.hint&&i.push(` ${C(t,E.dim,`\u2192 ${e.hint}`)}`),i.join(`
|
|
32
|
+
`)}function je(e,{color:t=!1}={}){if(!e.length)return C(t,E.cyan,"\u2713 No issues found.");let n=new Map;for(let s of e){let l=s.file||"velu.json";n.has(l)||n.set(l,[]),n.get(l).push(s)}let r=[];for(let[s,l]of n){r.push(C(t,E.bold,s));for(let p of l)r.push(ot({...p,file:null},{color:t}).replace(/^/gm," "));r.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 r.push(C(t,o?E.red:E.yellow,a)),r.join(`
|
|
33
|
+
`)}var rt,E,C,J=A(()=>{rt={"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"};E={reset:"\x1B[0m",red:"\x1B[31m",yellow:"\x1B[33m",cyan:"\x1B[36m",dim:"\x1B[2m",bold:"\x1B[1m"},C=(e,t,n)=>e?`${t}${n}${E.reset}`:n});function ro(e){let t=e,n=0;for(;t&&t.cause&&n<3&&!(t.loc||t.line||/`[^`]+` to be defined/.test(t.message||""));)t=t.cause,n+=1;return t||e}function it(e,t){if(!e)return null;let n=rn(e).replace(/[?#].*$/,""),r=t?rn(t).replace(/\/+$/,""):"";return r&&n.toLowerCase().startsWith(r.toLowerCase())?n.slice(r.length).replace(/^\/+/,""):!/^([a-zA-Z]:\/|\/)/.test(n)&&!/node_modules/.test(n)?n:null}function oo(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 io(e){let t=/\((\d+):(\d+)(?:-\d+:\d+)?\)\s*$/.exec(String(e||""));return t?{line:Number(t[1]),column:Number(t[2])}:null}function so(e){return String(e||"").replace(/\s*\(\d+:\d+(?:-\d+:\d+)?\)\s*$/,"").trim()}function lo(e,t){if(!e||!t)return null;let n=String(e);return/node_modules|[\\/]vite[\\/]|@veluai[\\/]/.test(n)?null:n}function fe(e,t={}){let{projectDir:n="",knownComponents:r=[],file:o=null}=t,i=null;for(let h=e,w=0;h&&w<6;h=h.cause,w+=1)if(h.veluIssue){i=h.veluIssue;break}if(i)return j({...i,file:i.file||o});let a=ro(e)||{},s=a.message||String(e||""),l=/Expected component `([^`]+)` to be defined/.exec(s);if(l){let h=l[1],w=/referenced in your code at `(\d+):(\d+)/.exec(s),F=/\bin `([^`]+)`/.exec(s),$=F?it(F[1],n):null;return j({category:"unknown-component",file:$||o,line:w?Number(w[1]):null,column:w?Number(w[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:Ae(h,r)})}let p=a.loc||(a.line!=null?{line:a.line,column:a.column,file:a.file}:null)||io(a.reason||s),c=a.id||p&&p.file||a.file||null,u=it(c,n)||o,b=!!u&&it(c,n)!=null,d=lo(a.frame,b||!!o),x=oo(so(a.reason||s)),m=ao.test(s),L=a.source==="remark-frontmatter"||/\byaml\b|frontmatter/i.test(s)||p&&p.line===1&&/unexpected|expected/i.test(s)&&/---/.test(s);return p||m||d&&b?j({category:L?"frontmatter":"mdx-syntax",file:u,line:p?p.line:null,column:p?p.column:null,frame:d,title:x||(L?"Invalid frontmatter":"MDX syntax error"),detail:"",hint:L?"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)?j({category:"invalid-props",file:u,title:"A component received an invalid value",detail:x,hint:"Check the props/options you passed to a component on this page."}):j({category:"render-crash",file:u,title:"This page failed to render",detail:x,hint:"Set VELU_DEBUG=1 for the full stack trace."})}var rn,ao,st=A(()=>{J();rn=e=>String(e).replace(/\\/g,"/");ao=/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 co(e){let t=rt[e.category]||e.category,n=e.file?`${e.file}${e.line?`:${e.line}${e.column?`:${e.column}`:""}`:""}`:"",r=[];return r.push('<div class="velu-err-card">'),r.push('<div class="velu-err-head">'),r.push(`<span class="velu-err-pill">${I(t)}</span>`),r.push("</div>"),e.title&&r.push(`<div class="velu-err-title">${I(e.title)}</div>`),n&&r.push(`<a class="velu-err-loc" title="${I(n)}">${I(n)}</a>`),e.detail&&r.push(`<div class="velu-err-detail">${I(e.detail)}</div>`),e.frame&&r.push(`<pre class="velu-err-frame">${I(e.frame)}</pre>`),e.suggestion&&r.push(`<div class="velu-err-suggest">Did you mean <code><${I(e.suggestion)}></code>?</div>`),e.hint&&r.push(`<div class="velu-err-hint">${I(e.hint)}</div>`),r.push("</div>"),r.join("")}function at(e,t={}){let n=Array.isArray(e)?e:[e],r=t.title||(n.length>1?`${n.length} problems to fix`:"There\u2019s a problem to fix"),o=n.map(co).join(`
|
|
32
34
|
`);return`<!doctype html>
|
|
33
35
|
<html lang="en">
|
|
34
36
|
<head>
|
|
@@ -100,21 +102,21 @@ ${L.join(`,
|
|
|
100
102
|
<div class="velu-err-foot">Fix the file and save \u2014 this page reloads automatically.</div>
|
|
101
103
|
</div>
|
|
102
104
|
</body>
|
|
103
|
-
</html>`}var I,
|
|
104
|
-
`).length}function
|
|
105
|
-
`).length}function
|
|
106
|
-
`).length}function
|
|
107
|
-
${e}`;let n=e.match(/^---\r?\n[\s\S]*?\r?\n---\r?\n/),r=`> ${
|
|
105
|
+
</html>`}var I,on=A(()=>{J();I=e=>String(e??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")});var H,lt=A(()=>{H=["Callout","Card","CardGroup","Accordion","AccordionGroup","Columns","Field","Prompt","Steps","Step","Tree","Folder","File","Image","CodeBlock","CodeGroup","MethodBadge","ApiPath","TryItBar","ApiField","ApiClient","ApiSidebar"]});import Oe from"node:fs";import de from"node:path";import{fileURLToPath as uo}from"node:url";import po from"iso-639-1";function me(e,t){if(!t)return null;let n=e.indexOf(`"${t}"`);return n===-1?null:e.slice(0,n).split(`
|
|
106
|
+
`).length}function go(e,t){return t==null||t<0?null:e.slice(0,t).split(`
|
|
107
|
+
`).length}function ct(e,t){if(!t)return null;let n=e.indexOf(`"${t}"`);return n===-1?null:e.slice(0,n).split(`
|
|
108
|
+
`).length}function ho(e,t,n){let r=[];return s(e,t,"",null),r;function o(l){if(l&&l.$ref){let p=l.$ref.replace(/^#\//,"").split("/"),c=n;for(let u of p)c=c?.[u];return c||{}}return l}function i(l){return Array.isArray(l)?"array":l===null?"null":typeof l}function a(l,p){let c=r.length;s(l,p,"",null,!0);let u=r.length===c;return u||(r.length=c),u}function s(l,p,c,u,b){let d=o(p);if(d){if(d.oneOf){d.oneOf.some(m=>a(l,m))||r.push({path:c,key:u,message:"value does not match any allowed shape"});return}if(d.type&&i(l)!==d.type){r.push({path:c,key:u,message:`expected ${d.type}, got ${i(l)}`});return}if(d.type==="string"&&d.minLength!=null&&l.length<d.minLength&&r.push({path:c,key:u,message:"must not be empty"}),d.type==="object"&&i(l)==="object"){for(let m of d.required||[])m in l||r.push({path:c?`${c}.${m}`:m,key:m,message:`missing required "${m}"`});let x=d.properties||{};if(d.additionalProperties===!1)for(let m of Object.keys(l))m in x||r.push({path:c?`${c}.${m}`:m,key:m,message:`unknown field "${m}"`});for(let[m,L]of Object.entries(x))m in l&&s(l[m],L,c?`${c}.${m}`:m,m,b)}d.type==="array"&&Array.isArray(l)&&d.items&&l.forEach((x,m)=>s(x,d.items,`${c}[${m}]`,u,b))}}}function yo(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 Te(e){let t=[],n=de.join(e,"velu.json"),r;try{r=Oe.readFileSync(n,"utf-8")}catch(s){return s.code==="ENOENT"?t.push(j({category:"config-json",file:"velu.json",title:"No velu.json found",hint:"Run `velu init <name>` to scaffold a project."})):t.push(j({category:"config-json",file:"velu.json",title:"Could not read velu.json"})),t}let o;try{o=JSON.parse(r)}catch(s){let l=/position (\d+)/.exec(s.message||""),p=l?go(r,Number(l[1])):null;return t.push(j({category:"config-json",file:"velu.json",line:p,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(Oe.readFileSync(mo,"utf-8"))}catch{}if(i)for(let s of ho(o,i,i)){let l=/^unknown field/.test(s.message);t.push(j({category:"config-schema",severity:l?"warning":"error",file:"velu.json",line:me(r,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&&!yo(l)&&t.push(j({category:"config-schema",severity:"warning",file:"velu.json",line:me(r,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=de.resolve(e,o.favicon.replace(/^\/+/,""));Oe.existsSync(s)||t.push(j({category:"config-asset",file:"velu.json",line:me(r,"favicon"),title:`favicon not found: ${o.favicon}`,hint:"The path is relative to the project root."}))}let a=ie(o.logo);if(a){let s=new Map;for(let l of["light","dark"]){let p=a[l];p&&s.set(p,[...s.get(p)||[],l])}for(let[l,p]of s)if(!Oe.existsSync(de.resolve(e,l.replace(/^\/+/,"")))){let c=p.length===2?"logo":`logo (${p[0]})`;t.push(j({category:"config-asset",file:"velu.json",line:ct(r,l),title:`${c} not found: ${l}`,hint:"The path is relative to the project root."}))}}if(o.navigation&&typeof o.navigation=="object"){let s;try{s=z(o.navigation)}catch(l){t.push(j({category:"config-nav",file:"velu.json",line:me(r,"navigation"),title:"navigation could not be processed",detail:String(l.message||"")})),s=null}if(s){let{pageEntries:l,warnings:p}=B(s,e);for(let c of p){let u=/not found$/.test(c),b=/page "([^"]+)"/.exec(c),d=b?ct(r,b[1]):null;t.push(j({category:"config-nav",severity:u?"error":"warning",file:"velu.json",line:d,title:c,hint:u?"Create the .mdx file, or remove the page from navigation.":""}))}vo(s,r,t)}}return t}function vo(e,t,n){let r=new Set,o=i=>{if(!(!i||typeof i!="object")){if(i.language&&!r.has(i.language)){r.add(i.language);let a=String(i.language).toLowerCase();po.validate(a)||n.push(j({category:"config-nav",severity:"warning",file:"velu.json",line:ct(t,i.language)||me(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 fo,mo,ut=A(()=>{J();G();ce();se();fo=de.dirname(uo(import.meta.url)),mo=de.resolve(fo,"..","..","schema","velu.schema.json")});import bo from"node:fs/promises";import xo from"node:fs";import q from"node:path";import{fileURLToPath as $o,pathToFileURL as wo}from"node:url";import{compile as So}from"@mdx-js/mdx";import ko from"remark-frontmatter";import Ao from"remark-mdx-frontmatter";import jo from"remark-gfm";import Oo from"rehype-slug";import{visit as To}from"unist-util-visit";function pt(){if(Le)return Le;let e=q.dirname($o(import.meta.url)),t=[q.resolve(e,"..","runtime","velu-ui"),q.resolve(e,"..","..","runtime","velu-ui"),q.resolve(e,"..","..","..","velu-ui","src")],n=null;for(let r of t){let o=q.join(r,"lib","component-schemas.js");if(xo.existsSync(o)){n=o;break}}return Le=n?import(wo(n).href).then(r=>r.validateProps).catch(()=>null):Promise.resolve(null),Le}function Lo(e){let t={};for(let n of e.attributes||[])n.type==="mdxJsxAttribute"&&(n.value==null?t[n.name]=!0:typeof n.value=="string"&&(t[n.name]=n.value));return t}function _o(e,t){return()=>n=>{To(n,r=>{if((r.type==="mdxJsxFlowElement"||r.type==="mdxJsxTextElement")&&typeof r.name=="string"&&/^[A-Z]/.test(r.name)&&!r.name.includes(".")&&e.push({name:r.name,props:Lo(r),line:r.position?.start?.line??null,column:r.position?.start?.column??null}),r.type==="mdxjsEsm"&&typeof r.value=="string")for(let o of r.value.matchAll(/\b([A-Z][A-Za-z0-9_]*)\b/g))t.add(o[1])})}}async function Po(e,t){let n=[],r;try{r=await bo.readFile(t.fileAbsPath,"utf-8")}catch{return n}let o=q.relative(e,t.fileAbsPath).split(q.sep).join("/"),i=[],a=new Set;try{await So({value:r,path:t.fileAbsPath},{remarkPlugins:[ko,Ao,jo,ae,_o(i,a)],rehypePlugins:[Oo],providerImportSource:"@mdx-js/react"})}catch(c){return n.push(fe(c,{projectDir:e,knownComponents:H,file:o})),n}let s=new Set(H),l=await pt(),p=new Set;for(let c of i)if(!a.has(c.name)){if(!s.has(c.name)){if(p.has(c.name))continue;p.add(c.name),n.push(j({category:"unknown-component",file:o,line:c.line,column:c.column,title:`<${c.name}> is not a built-in component`,hint:"Components are built in \u2014 check the spelling and capitalization (you don\u2019t import them).",suggestion:Ae(c.name,H)}));continue}if(l){let u=l(c.name,c.props,{checkRequired:!1});u&&n.push(j({...u,file:o,line:c.line,column:c.column}))}}return n}async function sn(e,t){let n=t.filter(s=>s.exists),r=[],o=8,i=0;async function a(){for(;i<n.length;){let s=n[i++],l=await Po(e,s);for(let p of l)r.push(p)}}return await Promise.all(Array.from({length:Math.min(o,n.length)},a)),r}var Le,ft=A(()=>{We();J();st();lt()});import _e from"node:fs";import mt from"node:path";import cn from"js-yaml";function dt(e,t,n){if(n>24||e===null||typeof e!="object")return n>24&&e&&typeof e=="object"?null:e;if(t.has(e))return null;t.add(e);let r;if(Array.isArray(e))r=e.map(o=>dt(o,t,n+1));else{r={};for(let[o,i]of Object.entries(e))r[o]=dt(i,t,n+1)}return t.delete(e),r}function un(e){return cn.dump(dt(e,new Set,0),{noRefs:!0,lineWidth:100,skipInvalid:!0})}function pn(e){let t=String(e).replace(/\.md$/i,"");return t===""||t==="/"||t==="/index"?"/":t.replace(/\/+$/,"")||"/"}function Eo(e){return e==="/"?"/index.md":`${e}.md`}function gt(e,t){if(t==="api")return`# ${an}
|
|
109
|
+
${e}`;let n=e.match(/^---\r?\n[\s\S]*?\r?\n---\r?\n/),r=`> ${an}
|
|
108
110
|
|
|
109
|
-
`;return n?e.slice(0,n[0].length)+r+e.slice(n[0].length):r+e}function
|
|
110
|
-
`)}async function
|
|
111
|
+
`;return n?e.slice(0,n[0].length)+r+e.slice(n[0].length):r+e}function Fo(e){return e.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/,"")}function No(e){try{let t=_e.readFileSync(e,"utf-8").match(/^---\r?\n([\s\S]*?)\r?\n---/);if(!t)return{};let n=cn.load(t[1]);return n&&typeof n=="object"?n:{}}catch{return{}}}async function ge(e){let t={};try{t=JSON.parse(_e.readFileSync(mt.join(e,"velu.json"),"utf-8"))}catch{return{name:mt.basename(e),baseUrl:"",pages:[]}}let n=t.name??mt.basename(e),r=typeof t.url=="string"?t.url.replace(/\/+$/,""):"",o=R(t.api),i=t.navigation??{},a={};try{let u=await Se(t.navigation??{},{targetDir:e,api:o});i=u.nav,a=u.ops}catch(u){console.warn(`[velu] openapi: ${u.message}`)}let s=z(i),{pageEntries:l}=B(s,e),p=new Map(l.map(u=>[u.url,u])),c=[];for(let u of X(s)){if(!u.url)continue;let b=u.ancestors.filter(h=>h.kind==="group").pop(),d=u.ancestors.filter(h=>h.kind==="tab").pop(),x=b?.label||d?.label||"Pages",m=u.ancestors.filter(h=>h.kind==="tab"||h.kind==="group").map(h=>h.label),L=u.ancestors.filter(h=>h.kind==="language").pop()?.code||null;if(u.node?.api){let h=a[u.pagePath];if(!h)continue;let w=h.title||ln(u.url);c.push({url:u.url,title:w,description:h.description||"",group:x,breadcrumb:[...m,w],lang:L,frontmatter:{title:h.title,description:h.description},source:{kind:"api",segment:h.segment}})}else{let h=p.get(u.url);if(!h||!h.exists)continue;let w=No(h.fileAbsPath),F=w.title||ln(u.url);c.push({url:u.url,title:F,description:w.description||"",group:x,breadcrumb:[...m,F],lang:L,frontmatter:w,source:{kind:"mdx",fileAbsPath:h.fileAbsPath}})}}return{name:n,baseUrl:r,pages:c}}function Ee(e){return new Map(e.pages.map(t=>[t.url,{...t.source,title:t.title}]))}async function Uo(e){return Ee(await ge(e))}async function ht(e,t,n){let o=(n||await Uo(e)).get(t);if(!o)return null;if(o.kind==="mdx")try{return{body:_e.readFileSync(o.fileAbsPath,"utf-8"),contentType:"text/markdown; charset=utf-8",kind:"mdx"}}catch{return null}return o.segment?{body:un(o.segment),contentType:"text/yaml; charset=utf-8",kind:"api"}:null}async function fn(e,t){let n=t||await ge(e),r=s=>n.baseUrl?n.baseUrl+s:s,o=[`# ${n.name}`,"",`> Documentation index for ${n.name}. Append \`.md\` to any page URL (or send \`Accept: text/markdown\`) for its Markdown; fetch ${Pe} for the whole site in one document.`,""],i=[],a=new Map;for(let s of n.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}](${r(Eo(l.url))})${l.description?`: ${l.description}`:""}`);o.push("")}return o.join(`
|
|
112
|
+
`)}async function mn(e,t){let n=t||await ge(e),r=[`# ${n.name}`,"",`> Full documentation \u2014 every page concatenated. Index: ${Z}`];for(let o of n.pages)if(r.push("","---","",`# ${o.title}`,`Source: ${o.url}`,""),o.source.kind==="mdx")try{r.push(Fo(_e.readFileSync(o.source.fileAbsPath,"utf-8")).trim())}catch{}else o.source.segment&&r.push("```yaml",un(o.source.segment).trim(),"```");return r.join(`
|
|
111
113
|
`)+`
|
|
112
|
-
`}var
|
|
114
|
+
`}var Z,Pe,Co,Q,an,ln,dn=A(()=>{G();ce();se();nt();Z="/llms.txt",Pe="/llms-full.txt",Co=`<${Z}>; rel="llms-txt", <${Pe}>; rel="llms-full-txt"`,Q={Link:Co,"X-Llms-Txt":Z},an=`Full documentation index: ${Z}`;ln=e=>(e.split("/").filter(Boolean).pop()||"Home").replace(/[-_]+/g," ").replace(/\b\w/g,n=>n.toUpperCase())});var wn={};ye(wn,{startDevServer:()=>Zo});import gn from"node:fs/promises";import ee from"node:fs";import Ro from"node:http";import{spawn as Io}from"node:child_process";import _ from"node:path";import{fileURLToPath as Mo}from"node:url";import zo from"chokidar";import hn from"express";import{createServer as Bo,searchForWorkspaceRoot as Go}from"vite";function Do(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 yn(e,t){let n=ot(e,{color:!!process.stderr.isTTY});console.error(`
|
|
113
115
|
`+n+`
|
|
114
|
-
`),process.env.VELU_DEBUG&&t&&console.error(t)}function
|
|
115
|
-
`)}function
|
|
116
|
-
`+
|
|
117
|
-
`),f}let l=e;try{l=
|
|
118
|
-
${
|
|
119
|
-
</style>`,
|
|
120
|
-
`),
|
|
116
|
+
`),process.env.VELU_DEBUG&&t&&console.error(t)}function vn(){try{return JSON.parse(ee.readFileSync(_.join(Ce,"package.json"),"utf8")).version||"unknown"}catch{return"unknown"}}function Yo(e,t){let n=_.resolve(e,".velu"),r=_.resolve(n,".velu-version"),o=null;try{o=ee.readFileSync(r,"utf8").trim()}catch{}if(o!==t){if(o!==null)try{ee.rmSync(_.join(n,"vite-cache"),{recursive:!0,force:!0}),console.log("[velu] new version detected \u2014 refreshing the preview cache\u2026")}catch{}try{ee.mkdirSync(n,{recursive:!0}),ee.writeFileSync(r,t)}catch{}}}async function bn(e){try{return await Tt(e)}catch{return Ye({},_.basename(e))}}async function xn(e,t){let n=await e.moduleGraph.getModuleByUrl(t,!0),r=new Map,o=new Set;async function i(a){if(!(!a||o.has(a.url))){if(o.add(a.url),a.id&&Jo.test(a.id)){let s=a.url.includes("?")?"&":"?",l=await e.transformRequest(`${a.url}${s}direct`);l?.code&&r.set(a.url,l.code)}for(let s of a.importedModules)await i(s)}}return await i(n),[...r.values()].join(`
|
|
117
|
+
`)}function Ko(e,t,n){let r=()=>{process.stdout.isTTY&&!process.env.VELU_NO_BELL&&process.stdout.write("\x07")},o=process.stdout.isTTY,i=x=>o&&process.stdout.write(`\x1B]${x}\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=n&&n!=="unknown"?`v${n}`:"";if(!e)return console.log(`Starting Velu${l?" "+l:""}\u2026`),{ready:x=>{console.log(`Velu${l?" "+l:""} ready \u2192 ${x}`),s(),r()}};let p="\x1B[38;2;220;20;60m",c="\x1B[0m",u="\x1B[2m";console.log("");for(let x of Wo)console.log(`${p}${x}${c}`);l&&console.log(` ${u}${l}${c}`),console.log("");let b=null;try{b=Io(process.execPath,["-e",Xo],{stdio:["ignore","inherit","ignore"]}),b.on("error",()=>{})}catch{}let d=()=>{if(b){try{b.kill()}catch{}b=null}};return process.once("exit",d),{ready:x=>{d(),process.stdout.write("\x1B[2K\r"),console.log(` \x1B[32m\u2713${c} Velu${l?" "+l:""} ready \u2192 \x1B[36m${x}${c}`),s(),r()}}}async function Zo(e){let t=!!process.env.VELU_PROFILE,n=performance.now(),r=(y,f)=>t&&console.log(`[velu-profile] ${y}: ${(performance.now()-f).toFixed(0)}ms`),o=Ko(!!process.stdout.isTTY&&!t,_.basename(e),vn()),i=await bn(e),a=s();function s(){let f=Te(e).filter(g=>g.severity==="error"&&(g.category==="config-json"||g.category==="config-schema"));return f.length&&console.error(`
|
|
118
|
+
`+je(f,{color:!!process.stderr.isTTY})+`
|
|
119
|
+
`),f}let l=e;try{l=ee.realpathSync(e)}catch{}let p=0,c=y=>{let f=performance.now();if(f-p<500)return;p=f;let g=fe(y,{projectDir:l,knownComponents:H});yn(g,y)};process.on("unhandledRejection",c),process.on("uncaughtException",c);let u=Number(process.env.PORT)||8358,b=await pt();Yo(e,vn());let d=hn(),x=Ro.createServer(d),m=await Bo({...tn({targetDir:e,VITE_ROOT:Ce,validateProps:b}),appType:"custom",logLevel:t?"info":"warn",server:{middlewareMode:!0,fs:{allow:[Go(Ce),e,l]},hmr:{server:x}}});r("vite server created",n),d.use(m.middlewares),d.get(new RegExp(`^${De}(\\.[a-z0-9]+)?$`,"i"),async(y,f)=>{if(!i.favicon)return f.status(404).end();let g=_.resolve(e,i.favicon.replace(/^\//,""));f.sendFile(g,v=>{v&&f.status(404).end()})});let L=y=>(f,g)=>{let v=i.logo?.[y];if(!v)return g.status(404).end();g.sendFile(_.resolve(e,v.replace(/^\//,"")),O=>{O&&g.status(404).end()})};d.get(xe,L("light")),d.get($e,L("dark")),d.post("/@velu-api-proxy",hn.json({limit:"8mb"}),async(y,f)=>{let{method:g="GET",url:v,headers:O={},body:S}=y.body||{};if(typeof v!="string"||!/^https?:\/\//i.test(v))return f.status(400).json({error:"A valid http(s) target URL is required."});try{let k=await fetch(v,{method:g,headers:O,body:S!=null&&S!==""?S:void 0}),U=await k.text(),D=k.headers.get("content-type")||"",T={};k.headers.forEach((te,Ue)=>{T[Ue]=te});let M=U;if(/json/i.test(D))try{M=JSON.parse(U)}catch{}f.json({status:k.status,statusText:k.statusText,headers:T,body:M})}catch(k){f.json({error:`Request failed: ${k.message}`})}});let h=null,w=async()=>h||=await ge(e);d.get(/\.md$/i,async(y,f,g)=>{try{let v=await w(),O=await ht(e,pn(decodeURIComponent(y.path)),Ee(v));if(!O)return g();f.status(200).set({"Content-Type":O.contentType,...Q}).end(gt(O.body,O.kind))}catch{g()}}),d.get(Z,async(y,f,g)=>{try{let v=await fn(e,await w());f.status(200).set({"Content-Type":"text/plain; charset=utf-8",...Q}).end(v)}catch{g()}}),d.get(Pe,async(y,f,g)=>{try{let v=await mn(e,await w());f.status(200).set({"Content-Type":"text/plain; charset=utf-8",...Q}).end(v)}catch{g()}}),d.use("*",async(y,f,g)=>{let v=y.originalUrl,O=performance.now();if(/text\/markdown/i.test(y.headers.accept||""))try{let S=await w(),k=await ht(e,_t(v),Ee(S));if(k)return f.status(200).set({"Content-Type":k.contentType,...Q}).end(gt(k.body,k.kind))}catch{}if(a.length)return f.status(200).set({"Content-Type":"text/html"}).end(at(a,{title:"Fix velu.json to continue"}));try{let S=performance.now(),k=await gn.readFile($n,"utf-8");k=await m.transformIndexHtml(v,k),r(`transformIndexHtml ${v}`,S);let U="/src/runtime/server-entry.jsx";S=performance.now();let{render:D}=await m.ssrLoadModule(U);r(`ssrLoadModule ${v} (1st req includes dep pre-bundle)`,S),S=performance.now();let T=await D(v);r(`render ${v}`,S),S=performance.now();let M=await xn(m,U);r(`collectSsrCss ${v}`,S);let te=M?`<style data-velu-ssr>${M}</style>`:"",Ue=`<style data-velu-config>
|
|
120
|
+
${Lt(i)}
|
|
121
|
+
</style>`,Tn=Ho.has(i.font.family)?"":Do(i.font.family),he=Ot(i),Ln=he?`<link rel="icon"${he.type?` type="${he.type}"`:""} href="${he.url}" />`:"",_n=[te,Ue,Tn,Ln].filter(Boolean).join(`
|
|
122
|
+
`),Pn=k.replace("<!--app-title-->",qo(i.name)).replace("<!--app-head-->",_n).replace("<!--app-html-->",T);f.status(200).set({"Content-Type":"text/html",...Q}).end(Pn),r(`TOTAL ${v}`,O)}catch(S){m.ssrFixStacktrace(S);let k=fe(S,{projectDir:l,knownComponents:H});yn(k,S),f.status(200).set({"Content-Type":"text/html"}).end(at([k]))}}),zo.watch(e,{ignoreInitial:!0,ignored:/(^|[\\/])(node_modules|\.git|\.velu)([\\/]|$)/,awaitWriteFinish:{stabilityThreshold:100,pollInterval:20}}).on("all",async(y,f)=>{console.log(`[velu-cli] content ${y}: ${_.relative(e,f)}`);let g=_.basename(f)==="velu.json",v=f.endsWith(".mdx"),O=g||v&&(y==="add"||y==="unlink");if((O||v||/\.(ya?ml|json)$/i.test(f))&&(h=null),g&&(i=await bn(e),a=s()),O)m.moduleGraph.invalidateAll();else if(v){let S=f.split(_.sep).join("/"),k=m.moduleGraph.getModulesByFile(S);if(k)for(let U of k)m.moduleGraph.invalidateModule(U)}m.ws.send({type:"full-reload"})});async function $(y){let f=new Set,g=12,v=0,O=[],S=()=>v<g?(v+=1,Promise.resolve()):new Promise(T=>O.push(T)).then(()=>{v+=1}),k=()=>{v-=1,O.shift()?.()},U=T=>/[\\/]\.velu[\\/]vite-cache[\\/]|[\\/]deps[\\/]/.test(T)||/[\\/]node_modules[\\/]/.test(T)&&!/velu-ui/.test(T);async function D(T){if(!(!T||f.has(T)||U(T))){f.add(T);try{await S();try{await m.transformRequest(T,{ssr:!1})}finally{k()}let M=await m.moduleGraph.getModuleByUrl(T,!1);M?.importedModules?.size&&await Promise.all([...M.importedModules].map(te=>D(te.url)))}catch{}}}return await D(y),f.size}x.listen(u,async()=>{let y=performance.now(),f=0;try{let{render:g}=await m.ssrLoadModule("/src/runtime/server-entry.jsx");await $("/src/runtime/client-entry.jsx"),typeof m.waitForRequestsIdle=="function"&&await m.waitForRequestsIdle();let[v]=await Promise.allSettled([$("/src/runtime/client-entry.jsx"),g("/"),m.transformIndexHtml("/",await gn.readFile($n,"utf-8")),xn(m,"/src/runtime/server-entry.jsx")]).then(O=>O.map(S=>S.status==="fulfilled"?S.value:0));f=v}catch(g){t&&console.log("[velu-profile] warmup error:",g?.message)}r(`cold-start warm-up (${f} client modules)`,y),o.ready(`http://localhost:${u}`)})}var Vo,Jo,Ho,qo,Ce,$n,Wo,Xo,Sn=A(()=>{se();nn();st();on();J();lt();ut();ft();dn();G();Vo=_.dirname(Mo(import.meta.url)),Jo=/\.(css|less|sass|scss|styl|stylus|pcss|postcss)(\?|$)/,Ho=new Set(["Google Sans Flex","Google Sans Code","Outfit"]),qo=e=>String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""");Ce=_.resolve(Vo,".."),$n=_.resolve(Ce,"src","template.html"),Wo=[" _ __ __","| | / /__ / /_ __","| | / / _ \\/ / / / /","| |/ / __/ / /_/ /","|___/\\___/_/\\__,_/"],Xo="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 An={};ye(An,{default:()=>ni,runValidate:()=>kn});import Qo from"node:fs";import ei from"node:path";function ti(e){try{let t=JSON.parse(Qo.readFileSync(ei.join(e,"velu.json"),"utf-8"));if(!t.navigation||typeof t.navigation!="object")return[];let n=z(t.navigation);return B(n,e).pageEntries}catch{return[]}}async function kn(e){let t=Te(e),n=ti(e),r=await sn(e,n),o=[...t,...r],i=!!process.stdout.isTTY;return console.log(je(o,{color:i})),o.some(s=>s.severity!=="warning"&&s.severity!=="info")?1:0}var ni,jn=A(()=>{G();ce();ut();ft();J();ni=kn});import Fe from"node:path";import P from"node:process";import{readFileSync as ri}from"node:fs";var[,,On,Ne]=P.argv;function oi(){try{return JSON.parse(ri(new URL("../package.json",import.meta.url),"utf8")).version}catch{return"unknown"}}function ii(){let e=P.argv.slice(3);for(let t=0;t<e.length;t++){let n=e[t];if(n==="--out"){t++;continue}if(!n.startsWith("-"))return n}}async function si(){switch(On){case"--version":case"-v":case"version":{console.log(oi());break}case"init":{Ne||(console.error("Usage: velu init <project-name>"),P.exit(1));let e=Ne,t=Fe.resolve(P.cwd(),e),{initProject:n}=await Promise.resolve().then(()=>(bt(),vt));await n(t,e);break}case"dev":{let{maybeAutoUpdate:e}=await Promise.resolve().then(()=>(Ge(),Be));await e();let t=Fe.resolve(P.cwd(),Ne??"."),{startDevServer:n}=await Promise.resolve().then(()=>(Sn(),wn));await n(t);break}case"update":{let{updateCommand:e}=await Promise.resolve().then(()=>(Ge(),Be));await e();break}case"validate":{let e=Fe.resolve(P.cwd(),Ne??"."),{runValidate:t}=await Promise.resolve().then(()=>(jn(),An)),n=await t(e);P.exit(n);break}case"build":{let e=Fe.resolve(P.cwd(),ii()??"."),t=P.argv.indexOf("--out"),n=t>-1?P.argv[t+1]:void 0,r=new URL(["..","src","build","index.js"].join("/"),import.meta.url).href,o=a=>import(a),i;try{({runBuild:i}=await o(r))}catch{console.error("velu build is an internal command, not available in this distribution."),P.exit(1)}await i(e,{out:n});break}default:console.log("Usage:"),console.log(" velu init <project-name> scaffold a new docs project"),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"),P.exit(On?1:0)}}si().catch(e=>{console.error(P.env.VELU_DEBUG?e:`Error: ${e.message}`),P.exit(1)});
|