rari 0.14.12 → 0.15.1

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.
Files changed (100) hide show
  1. package/README.md +8 -44
  2. package/dist/alias-resolver-CHTPYtdq.mjs +1 -0
  3. package/dist/api-routes-ChRr3O5-.mjs +1 -0
  4. package/dist/cli.d.mts +3 -2
  5. package/dist/cli.mjs +39 -41
  6. package/dist/define-CRFUKkcA.d.mts +14 -0
  7. package/dist/define-rCXgNOOk.mjs +1 -0
  8. package/dist/feed-B3mYPCnT.mjs +3 -0
  9. package/dist/get-client-component-CDaY3lOP.mjs +1 -0
  10. package/dist/headers.d.mts +38 -3
  11. package/dist/headers.mjs +1 -1
  12. package/dist/http-C5Y9ZrK9.mjs +1 -0
  13. package/dist/{image/index.d.mts → image.d.mts} +1 -1
  14. package/dist/image.mjs +1 -0
  15. package/dist/index.d.mts +4 -4
  16. package/dist/index.mjs +1 -1
  17. package/dist/mdx/define.d.mts +2 -0
  18. package/dist/mdx/define.mjs +1 -0
  19. package/dist/mdx/registry.d.mts +4 -0
  20. package/dist/mdx/registry.mjs +1 -0
  21. package/dist/mdx.d.mts +30 -8
  22. package/dist/mdx.mjs +1 -1
  23. package/dist/names-N6JRDeT1.mjs +1 -0
  24. package/dist/{og/index.d.mts → og.d.mts} +1 -1
  25. package/dist/platform.d.mts +1 -1
  26. package/dist/platform.mjs +2 -2
  27. package/dist/preload-modules-CJQ_IouX.mjs +2 -0
  28. package/dist/proxy/RariRequest.d.mts +2 -2
  29. package/dist/proxy/RariResponse.d.mts +2 -2
  30. package/dist/proxy/RariResponse.mjs +1 -1
  31. package/dist/proxy/runtime-executor.d.mts +2 -2
  32. package/dist/proxy/runtime-executor.mjs +1 -1
  33. package/dist/{railway--nFNI3h8.mjs → railway-fmDbDigI.mjs} +1 -1
  34. package/dist/rari-global-Dygfa818.mjs +1 -0
  35. package/dist/regex-constants-Wm7xRA3u.mjs +1 -0
  36. package/dist/{render-EieI0V5b.mjs → render-2I7-kFd_.mjs} +1 -1
  37. package/dist/router-Ctpd1kcp.mjs +1 -0
  38. package/dist/router.d.mts +3 -3
  39. package/dist/router.mjs +1 -1
  40. package/dist/runtime/AppRouterProvider.d.mts +2 -2
  41. package/dist/runtime/AppRouterProvider.mjs +1 -5
  42. package/dist/runtime/ErrorBoundaryWrapper.d.mts +1 -1
  43. package/dist/runtime/ErrorBoundaryWrapper.mjs +1 -1
  44. package/dist/runtime/LoadingErrorBoundary.d.mts +1 -1
  45. package/dist/runtime/action-flight-refresh.d.mts +17 -0
  46. package/dist/runtime/action-flight-refresh.mjs +1 -0
  47. package/dist/runtime/action-revalidation-kind.d.mts +8 -0
  48. package/dist/runtime/action-revalidation-kind.mjs +1 -0
  49. package/dist/runtime/call-server.d.mts +4 -0
  50. package/dist/runtime/call-server.mjs +1 -0
  51. package/dist/runtime/entry-client.mjs +3 -3
  52. package/dist/runtime/flight-route-cache.d.mts +34 -0
  53. package/dist/runtime/flight-route-cache.mjs +1 -0
  54. package/dist/runtime/flight-router-state.d.mts +11 -0
  55. package/dist/runtime/flight-router-state.mjs +1 -0
  56. package/dist/runtime/merge-flight-refresh.d.mts +6 -0
  57. package/dist/runtime/merge-flight-refresh.mjs +1 -0
  58. package/dist/runtime/rsc-client-runtime.d.mts +1 -40
  59. package/dist/runtime/rsc-client-runtime.mjs +1 -2
  60. package/dist/runtime/rsc-references.d.mts +7 -0
  61. package/dist/runtime/rsc-references.mjs +1 -0
  62. package/dist/sitemap-BekxZtgA.mjs +7 -0
  63. package/dist/{types-3dq9RGI5.d.mts → types-BC33STEP.d.mts} +1 -1
  64. package/dist/types-DJQFFYSj.d.mts +160 -0
  65. package/dist/{types-BwhW3M72.d.mts → types-DlF9FHQc.d.mts} +1 -1
  66. package/dist/utils-CW4FEV95-DI7wf2Fu.mjs +37 -0
  67. package/dist/vite.d.mts +211 -106
  68. package/dist/vite.mjs +117 -96
  69. package/dist/xml-N8OZmN7u.mjs +1 -0
  70. package/package.json +65 -32
  71. package/dist/ReactFlightClientConfig-C_nD8rsi.d.mts +0 -35
  72. package/dist/alias-resolver-BIWqeQml.mjs +0 -1
  73. package/dist/client.d.mts +0 -104
  74. package/dist/client.mjs +0 -1
  75. package/dist/feed-generator-CM9mK131.mjs +0 -3
  76. package/dist/get-client-component-B4Y2T40R.mjs +0 -1
  77. package/dist/image/index.mjs +0 -1
  78. package/dist/metadata-route-_d5FkjlL.d.mts +0 -108
  79. package/dist/navigate-DuyUa6qD.mjs +0 -1
  80. package/dist/preload-modules-xvnJ_8eh.mjs +0 -2
  81. package/dist/props-extractor-C8FRV5vW.mjs +0 -1
  82. package/dist/regex-constants-DQ2vkSU5.mjs +0 -1
  83. package/dist/resolve-R6nLL3qq.mjs +0 -1
  84. package/dist/runtime/actions.d.mts +0 -21
  85. package/dist/runtime/actions.mjs +0 -1
  86. package/dist/runtime/react-server-dom-shim.d.mts +0 -21
  87. package/dist/runtime/react-server-dom-shim.mjs +0 -1
  88. package/dist/runtime/vendor/react-flight-client/ReactFlightClient.d.mts +0 -71
  89. package/dist/runtime/vendor/react-flight-client/ReactFlightClient.mjs +0 -2
  90. package/dist/runtime/vendor/react-flight-client/ReactFlightClientConfig.d.mts +0 -2
  91. package/dist/runtime/vendor/react-flight-client/ReactFlightClientConfig.mjs +0 -1
  92. package/dist/runtime/vendor/react-flight-client/index.d.mts +0 -12
  93. package/dist/runtime/vendor/react-flight-client/index.mjs +0 -1
  94. package/dist/server-config-D7_4Hk9w.d.mts +0 -107
  95. package/dist/sitemap-generator-DWgqfKQu.mjs +0 -7
  96. package/dist/suspense-CsIYuC_l.mjs +0 -1
  97. package/dist/types-zPQ3RHgH.d.mts +0 -34
  98. package/dist/utils-DtilLmFs-CiitZqwE.mjs +0 -37
  99. /package/dist/{og/index.mjs → og.mjs} +0 -0
  100. /package/dist/{robots-generator-CsTVq3Jp.mjs → robots-CsTVq3Jp.mjs} +0 -0
package/README.md CHANGED
@@ -2,61 +2,25 @@
2
2
 
3
3
  > Runtime Accelerated Rendering Infrastructure
4
4
 
5
- **rari** is a high-performance React Server Components framework powered by a Rust runtime. Built for performance, scalability, and developer experience.
6
-
7
- ## Quick Start
8
-
9
- Create a new rari application in seconds:
10
-
11
- ```bash
12
- npm create rari-app@latest my-app
13
- cd my-app
14
- npm run dev
15
- ```
16
-
17
- That's it! Your app will be running at `http://localhost:5173`.
18
-
19
- Visit [rari.build/docs](https://rari.build/docs) for complete documentation, guides, and examples.
5
+ A high-performance React Server Components framework powered by Rust.
20
6
 
21
7
  ## Installation
22
8
 
23
- Install rari in an existing project:
24
-
25
9
  ```bash
26
- npm install rari react react-dom
10
+ npm install rari
27
11
  ```
28
12
 
29
- Or use the CLI to create a new project:
13
+ Or create a new project:
30
14
 
31
15
  ```bash
32
- npm create rari-app@latest
16
+ npm create rari-app@latest my-app
33
17
  ```
34
18
 
35
- ## Documentation
36
-
37
- **[Read the full documentation](https://rari.build/docs)** to learn more about:
38
-
39
- - Getting started with rari
40
- - App Router and file-based routing
41
- - Server Components and Client Components
42
- - Server Actions and data mutations
43
- - Streaming SSR and Suspense
44
- - Deployment and production optimization
45
-
46
- ## Contributing
47
-
48
- We welcome contributions! Here's how you can help:
49
-
50
- - **Report Bugs** - Found an issue? [Open a bug report](https://github.com/rari-build/rari/issues/new)
51
- - **Suggest Features** - Have ideas? [Share your suggestions](https://github.com/rari-build/rari/discussions)
52
- - **Improve Docs** - Help make our documentation better
53
- - **Submit PRs** - Check out our [Contributing Guide](https://github.com/rari-build/rari/blob/main/.github/CONTRIBUTING.md)
54
-
55
- ## Community
19
+ ## Links
56
20
 
57
- - **Discord** - [Join our community](https://discord.gg/GSh2Ak3b8Q)
58
- - **GitHub** - [Star the repo](https://github.com/rari-build/rari)
59
- - **Documentation** - [rari.build/docs](https://rari.build/docs)
21
+ - **Documentation:** [rari.build/docs](https://rari.build/docs)
22
+ - **GitHub:** [github.com/rari-build/rari](https://github.com/rari-build/rari)
23
+ - **Discord:** [Join our community](https://discord.gg/GSh2Ak3b8Q)
60
24
 
61
25
  ## License
62
26
 
@@ -0,0 +1 @@
1
+ import e from"node:fs";import t from"node:path";const n=new Map,r=new Map;function i(t){let r=n.get(t);return r===void 0?(r=e.existsSync(t),n.set(t,r),r):r}function a(t){let n=r.get(t);if(n!==void 0)return n;try{n=e.statSync(t).isDirectory()}catch{n=!1}return r.set(t,n),n}function o(){n.clear(),r.clear()}function s(e,t){let n=null;for(let r of t)if(e.endsWith(r)&&(n??=i(e),n))return e;for(let n of t){let t=`${e}${n}`;if(i(t))return t}return null}function c(e,n){if(i(e)){if(!a(e))return null;for(let r of n){let n=t.join(e,`index${r}`);if(i(n))return n}}return null}const l=[`.tsx`,`.jsx`,`.ts`,`.js`];function u(e,n,r={},i=l){let a=e;for(let[t,n]of Object.entries(r))if(e.startsWith(`${t}/`)){a=e.replace(t,n);break}else if(e===t){a=n;break}let o=t.resolve(t.dirname(n),a);return s(o,i)||c(o,i)||`${o}.tsx`}const d=[`.ts`,`.tsx`,`.js`,`.jsx`,`.mjs`];function f(e,t=d){return s(e,t)??c(e,t)}const p=new WeakMap;function m(e){let t=p.get(e);return t||(t=Object.entries(e).sort((e,t)=>t[0].length-e[0].length),p.set(e,t),t)}function h(e,n,r){if(typeof e!=`string`)throw TypeError(`Expected source to be a string, but received ${typeof e}`);if(n==null)throw TypeError(`Expected aliases to be an object, but received ${n}`);if(typeof n!=`object`||Array.isArray(n))throw TypeError(`Expected aliases to be a plain object, but received ${Array.isArray(n)?`array`:typeof n}`);if(Object.getPrototypeOf(n)!==Object.prototype&&Object.getPrototypeOf(n)!==null)throw TypeError(`Expected aliases to be a plain object, but received ${n.constructor?.name||`object with custom prototype`}`);if(typeof r!=`string`)throw TypeError(`Expected projectRoot to be a string, but received ${typeof r}`);let i=m(n);for(let[n,a]of i)if(e.startsWith(`${n}/`)||e===n){let i=e.slice(n.length).replace(/^\/+/,``),o=t.join(a,i);return t.isAbsolute(o)?o:t.resolve(r,o)}return null}export{s as a,c as i,o as n,f as o,u as r,h as t};
@@ -0,0 +1 @@
1
+ var e=class extends Response{static json(e,t){return Response.json(e,t)}static redirect(e,t=307){return/^https?:\/\//i.test(e)?Response.redirect(e,t):new Response(null,{status:t,headers:{location:e}})}static noContent(e){return new Response(null,{...e,status:204})}};export{e as t};
package/dist/cli.d.mts CHANGED
@@ -1,5 +1,6 @@
1
- //#region src/cli.d.ts
2
- declare function detectPackageManager(): 'pnpm' | 'yarn' | 'bun' | 'npm';
1
+ //#region src/cli/index.d.ts
2
+ type PackageManager = 'pnpm' | 'yarn' | 'bun' | 'npm';
3
+ declare function detectPackageManager(): PackageManager;
3
4
  declare function isRailwayEnvironment(): boolean;
4
5
  declare function isRenderEnvironment(): boolean;
5
6
  declare function getDeploymentConfig(): {
package/dist/cli.mjs CHANGED
@@ -1,65 +1,63 @@
1
- #!/usr/bin/env node
2
- import{getBinaryPath as e,getInstallationInstructions as t}from"./platform.mjs";import{spawn as n}from"node:child_process";import{existsSync as r,readFileSync as i,realpathSync as a}from"node:fs";import{resolve as o}from"node:path";import s from"node:process";import{fileURLToPath as c}from"node:url";import{styleText as l}from"node:util";function u(e){console.warn(`${l(`blue`,`info`)} ${e}`)}function d(e){console.warn(`${l(`green`,`✓`)} ${e}`)}function f(e){console.error(`${l(`red`,`✗`)} ${e}`)}function p(e){console.warn(`${l(`yellow`,`⚠`)} ${e}`)}const m=/^([^=]+)=(.*)$/;function h(e){let t=e.trim();if(!t||t.startsWith(`#`))return null;let n=t.match(m);if(!n)return null;let[,r,i]=n,a=r.trim(),o=i.trim();return(o.startsWith(`"`)&&o.endsWith(`"`)||o.startsWith(`'`)&&o.endsWith(`'`))&&(o=o.slice(1,-1)),{key:a,value:o}}function g(){let e=o(s.cwd(),`.env`);if(!r(e))return;let t=i(e,`utf-8`);for(let e of t.split(`
3
- `)){let t=h(e);t&&!s.env[t.key]&&(s.env[t.key]=t.value)}}g();const[,,_,...v]=s.argv;function y(e){let t=s.cwd();for(;;){let n=e(t);if(n!==null)return n;let r=o(t,`..`);if(r===t)break;t=r}return null}function b(e){return r(o(e,`pnpm-lock.yaml`))?`pnpm`:r(o(e,`yarn.lock`))?`yarn`:r(o(e,`bun.lockb`))?`bun`:r(o(e,`package-lock.json`))?`npm`:null}function x(e){try{let t=o(e,`package.json`);if(!r(t))return null;let n=JSON.parse(i(t,`utf-8`));if(n.packageManager?.startsWith(`pnpm`))return`pnpm`;if(n.packageManager?.startsWith(`yarn`))return`yarn`;if(n.packageManager?.startsWith(`bun`))return`bun`;if(n.packageManager?.startsWith(`npm`))return`npm`}catch{}return null}function S(){return y(e=>b(e)??x(e))??`npm`}function C(){let e=S(),t=s.platform===`win32`;switch(e){case`bun`:return t?`bun.cmd`:`bun`;case`pnpm`:return t?`pnpm.cmd`:`pnpm`;case`yarn`:return t?`yarn.cmd`:`yarn`;default:return t?`npx.cmd`:`npx`}}function w(){return y(e=>{try{let t=o(e,`package.json`);if(r(t)){let e=JSON.parse(i(t,`utf-8`)),n={...e.dependencies,...e.devDependencies};if(n[`vite-plus`])return`vp`;if(n.vite)return`vite`}}catch{}return null})??`vite`}function T(e,t,r={}){let i=s.platform===`win32`;if(e===`npx`){let e=C();if(e.includes(`bun`))return n(i?`bunx.cmd`:`bunx`,t,{...r,shell:i});if(e.includes(`pnpm`))return n(e,[`exec`,...t],{...r,shell:i});if(e.includes(`yarn`)){let[a,...o]=t;return n(e,a===`vp`?[`dlx`,`-p`,`vite-plus`,`vp`,...o]:[`dlx`,...t],{...r,shell:i})}}return i&&e===`npx`?n(`npx.cmd`,t,{...r,shell:!0}):n(e,t,r)}function E(e){if(e instanceof Error)return e.message;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function D(){return!!(s.env.RAILWAY_ENVIRONMENT||s.env.RAILWAY_PROJECT_ID||s.env.RAILWAY_SERVICE_ID)}function O(){return!!(s.env.RENDER||s.env.RENDER_SERVICE_ID||s.env.RENDER_SERVICE_NAME)}function k(){return D()||O()}function A(){return D()?`Railway`:O()?`Render`:`local`}function j(){return{port:s.env.PORT||s.env.RSC_PORT||`3000`,mode:s.env.NODE_ENV||`production`,host:k()?`0.0.0.0`:`127.0.0.1`}}async function M(){await R(),u(`Type checking...`);let e=T(`npx`,[`tsgo`],{stdio:`inherit`,cwd:s.cwd()});await new Promise((t,n)=>{e.on(`exit`,e=>{e===0?(d(`Type check passed`),t()):(f(`Type check failed with code ${e}`),n(Error(`Type check failed with code ${e}`)))}),e.on(`error`,n)}),u(`Building for production...`);let t=T(`npx`,[w(),`build`],{stdio:`inherit`,cwd:s.cwd()});await new Promise((e,n)=>{t.on(`exit`,t=>{t===0?(d(`Build complete`),e()):(f(`Build failed with code ${t}`),n(Error(`Build failed with code ${t}`)))}),t.on(`error`,n)}),await N()}async function N(){if(r(o(s.cwd(),`dist`,`server`,`image.json`))&&r(o(s.cwd(),`public`)))try{let t=n(e(),[`optimize-images`],{stdio:`inherit`,cwd:s.cwd(),shell:!1});await new Promise(e=>{t.on(`exit`,t=>{t===0||p(`Image pre-optimization exited with code ${t}`),e()}),t.on(`error`,t=>{p(`Image pre-optimization error: ${E(t)}`),e()})})}catch(e){p(`Could not pre-optimize images: ${E(e)}`)}}async function P(){let{existsSync:e}=await import(`node:fs`),{resolve:t}=await import(`node:path`),n=w();if(!e(t(s.cwd(),`dist`))){u(`First run detected - building project...`);let e=T(`npx`,[n,`build`,`--mode`,`development`],{stdio:`inherit`,cwd:s.cwd()});await new Promise((t,n)=>{e.on(`exit`,e=>{e===0?(d(`Initial build complete`),t()):(f(`Build failed with code ${e}`),n(Error(`Build failed with code ${e}`)))}),e.on(`error`,n)})}u(`Starting Vite${n===`vp`?`+`:``} dev server...`);let r=T(`npx`,[n,`dev`],{stdio:`inherit`,cwd:s.cwd()}),i=()=>{u(`Shutting down dev server...`),r.kill(`SIGTERM`)};return s.on(`SIGINT`,i),s.on(`SIGTERM`,i),r.on(`error`,e=>{f(`Failed to start Vite: ${e.message}`),s.exit(1)}),r.on(`exit`,e=>{e!==0&&e!==null&&(f(`Vite exited with code ${e}`),s.exit(e))}),new Promise(()=>{})}async function F(){let r;try{r=e()}catch{f(`Failed to obtain rari binary`),f(t()),s.exit(1)}let{port:i,mode:a,host:o}=j();if(k()){let e=A();u(`${e} environment detected`),u(`Starting rari server for ${e} deployment...`),u(`Mode: ${a}, Host: ${o}, Port: ${i}`),u(`using binary: ${r}`)}let c=n(r,[`--mode`,a,`--port`,i,`--host`,o],{stdio:`inherit`,cwd:s.cwd(),env:{...s.env,RUST_LOG:s.env.RUST_LOG||`error`}}),l=()=>{u(`shutting down...`),c.kill(`SIGTERM`)};return s.on(`SIGINT`,l),s.on(`SIGTERM`,l),c.on(`error`,e=>{f(`Failed to start rari server: ${e.message}`),e.message.includes(`ENOENT`)&&f(`Binary not found. Please ensure rari is properly installed.`),s.exit(1)}),c.on(`exit`,(e,t)=>{t?u(`server stopped by signal ${t}`):e===0?d(`server stopped successfully`):(f(`server exited with code ${e}`),s.exit(e||1))}),new Promise(()=>{})}async function I(){u(`Setting up Railway deployment...`),k()&&(f(`Already running in ${A()} environment. Use "rari start" instead.`),s.exit(1));let{createRailwayDeployment:e}=await import(`./railway--nFNI3h8.mjs`);await e()}async function L(){u(`Setting up Render deployment...`),k()&&(f(`Already running in ${A()} environment. Use "rari start" instead.`),s.exit(1));let{createRenderDeployment:e}=await import(`./render-EieI0V5b.mjs`);await e()}async function R(){let{existsSync:e,rmSync:t}=await import(`node:fs`),{resolve:n}=await import(`node:path`),r=n(s.cwd(),`dist`);e(r)?(u(`Cleaning dist folder...`),t(r,{recursive:!0,force:!0}),d(`Cleaned dist folder`)):u(`No dist folder to clean`)}async function z(){switch(_){case void 0:case`help`:case`--help`:case`-h`:console.warn(`${l(`bold`,`rari CLI`)}
1
+ import{getBinaryPath as e,getInstallationInstructions as t}from"./platform.mjs";import{spawn as n}from"node:child_process";import{existsSync as r,readFileSync as i,readdirSync as a,realpathSync as o,rmSync as s}from"node:fs";import{resolve as c}from"node:path";import l from"node:process";import{fileURLToPath as u}from"node:url";import{parseArgs as d,styleText as f}from"node:util";function p(e){console.warn(`${f(`blue`,`info`)} ${e}`)}function m(e){console.warn(`${f(`green`,`✓`)} ${e}`)}function h(e){console.error(`${f(`red`,`✗`)} ${e}`)}function g(e){console.warn(`${f(`yellow`,`⚠`)} ${e}`)}let _=null;function v(e){let t=r(e)?new Set(y(e)):new Set;return t.has(`pnpm-lock.yaml`)?`pnpm`:t.has(`yarn.lock`)?`yarn`:t.has(`bun.lockb`)||t.has(`bun.lock`)?`bun`:t.has(`package-lock.json`)?`npm`:b(e)}function y(e){try{return a(e)}catch{return[]}}function b(e){try{let t=c(e,`package.json`);if(!r(t))return null;let n=JSON.parse(i(t,`utf-8`));if(n.packageManager?.startsWith(`pnpm`))return`pnpm`;if(n.packageManager?.startsWith(`yarn`))return`yarn`;if(n.packageManager?.startsWith(`bun`))return`bun`;if(n.packageManager?.startsWith(`npm`))return`npm`}catch{}return null}function x(e){try{let t=c(e,`package.json`);if(!r(t))return null;let n=JSON.parse(i(t,`utf-8`)),a={...n.dependencies,...n.devDependencies};if(a[`vite-plus`])return`vp`;if(a.vite)return`vite`}catch{}return null}function S(e){let t=e,n=null,r=null;for(;n||=v(t),r||=x(t),!(n&&r);){let e=c(t,`..`);if(e===t)break;t=e}return{cwd:e,packageManager:n??`npm`,viteBin:r??`vite`}}function C(){let e=l.cwd();return _?.cwd===e||(_=S(e)),_}function w(){return C().packageManager}function T(){let e=C().packageManager,t=l.platform===`win32`;switch(e){case`bun`:return t?`bun.cmd`:`bun`;case`pnpm`:return t?`pnpm.cmd`:`pnpm`;case`yarn`:return t?`yarn.cmd`:`yarn`;default:return t?`npx.cmd`:`npx`}}function E(e,t=l.cwd()){let n=l.platform===`win32`,i=t;for(;;){let t=c(i,`node_modules`,`.bin`),a=n?[c(t,`${e}.cmd`),c(t,`${e}.exe`),c(t,e)]:[c(t,e)];for(let e of a)if(r(e))return e;let o=c(i,`..`);if(o===i)break;i=o}return null}function D(e,t,r={}){let i=l.platform===`win32`;if(e===`npx`){let e=T();if(e.includes(`bun`))return n(i?`bunx.cmd`:`bunx`,t,{...r,shell:i});if(e.includes(`pnpm`))return n(e,[`exec`,...t],{...r,shell:i});if(e.includes(`yarn`)){let[a,...o]=t;return n(e,a===`vp`?[`dlx`,`-p`,`vite-plus`,`vp`,...o]:[`dlx`,...t],{...r,shell:i})}}return i&&e===`npx`?n(`npx.cmd`,t,{...r,shell:!0}):n(e,t,r)}function O(e,t,r={}){let i=E(e);return i?n(i,t,l.platform===`win32`&&i.endsWith(`.cmd`)?{...r,shell:!0}:r):D(`npx`,[e,...t],r)}async function k(e,t={}){return new Promise((n,r)=>{e.on(`exit`,e=>{n(e)}),e.on(`error`,e=>{t.tolerateErrors?(g(A(e)),n(1)):r(e)})})}function A(e){if(e instanceof Error)return e.message;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function j(){let e=c(l.cwd(),`.env`);r(e)&&l.loadEnvFile(e)}function M(e){let{values:t,positionals:n}=d({args:e,options:{help:{type:`boolean`,short:`h`,default:!1}},allowPositionals:!0,strict:!1});if(t.help)return{command:`help`,args:[]};let[r,...i]=n;return{command:r,args:i}}function N(){return!!(l.env.RAILWAY_ENVIRONMENT||l.env.RAILWAY_PROJECT_ID||l.env.RAILWAY_SERVICE_ID)}function P(){return!!(l.env.RENDER||l.env.RENDER_SERVICE_ID||l.env.RENDER_SERVICE_NAME)}function F(){return N()||P()}function I(){return N()?`Railway`:P()?`Render`:`local`}function L(){return{port:l.env.PORT||l.env.RSC_PORT||`3000`,mode:l.env.NODE_ENV||`production`,host:F()?`0.0.0.0`:`127.0.0.1`}}async function R(){await W();let e=C().viteBin;p(`Type checking...`);let t=await k(O(`tsc`,[],{stdio:`inherit`,cwd:l.cwd()}));if(t===0)m(`Type check passed`);else throw h(`Type check failed with code ${t}`),Error(`Type check failed with code ${t}`);p(`Building for production...`);let n=await k(O(e,[`build`],{stdio:`inherit`,cwd:l.cwd()}));if(n===0)m(`Build complete`);else throw h(`Build failed with code ${n}`),Error(`Build failed with code ${n}`);await z()}async function z(){if(r(c(l.cwd(),`dist`,`server`,`image.json`))&&r(c(l.cwd(),`public`)))try{let t=await k(n(e(),[`optimize-images`],{stdio:`inherit`,cwd:l.cwd(),shell:!1}),{tolerateErrors:!0});t!==0&&g(`Image pre-optimization exited with code ${t}`)}catch(e){g(`Could not pre-optimize images: ${A(e)}`)}}async function B(){let e=C().viteBin;if(!r(c(l.cwd(),`dist`))){p(`First run detected - building project...`);let t=await k(O(e,[`build`,`--mode`,`development`],{stdio:`inherit`,cwd:l.cwd()}));if(t===0)m(`Initial build complete`);else throw h(`Build failed with code ${t}`),Error(`Build failed with code ${t}`)}p(`Starting Vite${e===`vp`?`+`:``} dev server...`);let t=O(e,[`dev`],{stdio:`inherit`,cwd:l.cwd()}),n=()=>{p(`Shutting down dev server...`),t.kill(`SIGTERM`)};return l.on(`SIGINT`,n),l.on(`SIGTERM`,n),t.on(`error`,e=>{h(`Failed to start Vite: ${e.message}`),l.exit(1)}),t.on(`exit`,e=>{e!==0&&e!==null&&(h(`Vite exited with code ${e}`),l.exit(e))}),new Promise(()=>{})}async function V(){let r;try{r=e()}catch{h(`Failed to obtain rari binary`),h(t()),l.exit(1)}let{port:i,mode:a,host:o}=L();if(F()){let e=I();p(`${e} environment detected`),p(`Starting rari server for ${e} deployment...`),p(`Mode: ${a}, Host: ${o}, Port: ${i}`),p(`using binary: ${r}`)}let s=[`--mode`,a,`--port`,i,`--host`,o],c=l.platform!==`win32`&&!!l.stdin.isTTY,u=n(r,s,{stdio:`inherit`,cwd:l.cwd(),detached:c,env:{...l.env,RUST_LOG:l.env.RUST_LOG||`error`}}),d=!1,f,g=()=>{d||(d=!0,p(`shutting down...`),u.kill(`SIGTERM`),f=setTimeout(()=>{u.kill(`SIGKILL`),l.exit(1)},5e3),f.unref?.())};return l.on(`SIGINT`,g),l.on(`SIGTERM`,g),l.on(`exit`,()=>{try{u.kill(`SIGKILL`)}catch{}}),u.on(`error`,e=>{h(`Failed to start rari server: ${e.message}`),e.message.includes(`ENOENT`)&&h(`Binary not found. Please ensure rari is properly installed.`),l.exit(1)}),u.on(`exit`,(e,t)=>{f&&clearTimeout(f),t?(d&&(p(`server stopped by signal ${t}`),l.exit(0)),h(`server stopped unexpectedly by signal ${t}`),l.exit(1)):e===0?(m(`server stopped successfully`),l.exit(0)):(h(`server exited with code ${e}`),l.exit(e||1))}),new Promise(()=>{})}async function H(){p(`Setting up Railway deployment...`),F()&&(h(`Already running in ${I()} environment. Use "rari start" instead.`),l.exit(1));let{createRailwayDeployment:e}=await import(`./railway-fmDbDigI.mjs`);await e()}async function U(){p(`Setting up Render deployment...`),F()&&(h(`Already running in ${I()} environment. Use "rari start" instead.`),l.exit(1));let{createRenderDeployment:e}=await import(`./render-2I7-kFd_.mjs`);await e()}async function W(){let e=c(l.cwd(),`dist`);r(e)?(p(`Cleaning dist folder...`),s(e,{recursive:!0,force:!0}),m(`Cleaned dist folder`)):p(`No dist folder to clean`)}function G(){console.warn(`${f(`bold`,`rari CLI`)}
4
2
 
5
- ${l(`bold`,`Usage:`)}
6
- ${l(`cyan`,`rari dev`)} Start the development server with Vite
7
- ${l(`cyan`,`rari build`)} Build for production
8
- ${l(`cyan`,`rari start`)} Start the rari server (defaults to production)
9
- ${l(`cyan`,`rari clean`)} Remove the dist folder
10
- ${l(`cyan`,`rari deploy railway`)} Setup Railway deployment
11
- ${l(`cyan`,`rari deploy render`)} Setup Render deployment
12
- ${l(`cyan`,`rari help`)} Show this help message
3
+ ${f(`bold`,`Usage:`)}
4
+ ${f(`cyan`,`rari dev`)} Start the development server with Vite
5
+ ${f(`cyan`,`rari build`)} Build for production
6
+ ${f(`cyan`,`rari start`)} Start the rari server (defaults to production)
7
+ ${f(`cyan`,`rari clean`)} Remove the dist folder
8
+ ${f(`cyan`,`rari deploy railway`)} Setup Railway deployment
9
+ ${f(`cyan`,`rari deploy render`)} Setup Render deployment
10
+ ${f(`cyan`,`rari help`)} Show this help message
13
11
 
14
- ${l(`bold`,`Environment Variables:`)}
15
- ${l(`yellow`,`PORT`)} Server port (default: 3000)
16
- ${l(`yellow`,`RSC_PORT`)} Alternative server port
17
- ${l(`yellow`,`NODE_ENV`)} Environment (default: production for start, development for dev)
18
- ${l(`yellow`,`RUST_LOG`)} Rust logging level (default: info)
12
+ ${f(`bold`,`Environment Variables:`)}
13
+ ${f(`yellow`,`PORT`)} Server port (default: 3000)
14
+ ${f(`yellow`,`RSC_PORT`)} Alternative server port
15
+ ${f(`yellow`,`NODE_ENV`)} Environment (default: production for start, development for dev)
16
+ ${f(`yellow`,`RUST_LOG`)} Rust logging level (default: info)
19
17
 
20
- ${l(`bold`,`Examples:`)}
21
- ${l(`gray`,`# Start development server with Vite`)}
22
- ${l(`cyan`,`rari dev`)}
18
+ ${f(`bold`,`Examples:`)}
19
+ ${f(`gray`,`# Start development server with Vite`)}
20
+ ${f(`cyan`,`rari dev`)}
23
21
 
24
- ${l(`gray`,`# Build for production`)}
25
- ${l(`cyan`,`rari build`)}
22
+ ${f(`gray`,`# Build for production`)}
23
+ ${f(`cyan`,`rari build`)}
26
24
 
27
- ${l(`gray`,`# Clean dist folder`)}
28
- ${l(`cyan`,`rari clean`)}
25
+ ${f(`gray`,`# Clean dist folder`)}
26
+ ${f(`cyan`,`rari clean`)}
29
27
 
30
- ${l(`gray`,`# Start production server (default)`)}
31
- ${l(`cyan`,`rari start`)}
28
+ ${f(`gray`,`# Start production server (default)`)}
29
+ ${f(`cyan`,`rari start`)}
32
30
 
33
- ${l(`gray`,`# Start in development mode`)}
34
- ${l(`cyan`,`NODE_ENV=development rari start`)}
31
+ ${f(`gray`,`# Start in development mode`)}
32
+ ${f(`cyan`,`NODE_ENV=development rari start`)}
35
33
 
36
- ${l(`gray`,`# Start production server on port 8080`)}
37
- ${l(`cyan`,`PORT=8080 rari start`)}
34
+ ${f(`gray`,`# Start production server on port 8080`)}
35
+ ${f(`cyan`,`PORT=8080 rari start`)}
38
36
 
39
- ${l(`gray`,`# Setup Railway deployment`)}
40
- ${l(`cyan`,`rari deploy railway`)}
37
+ ${f(`gray`,`# Setup Railway deployment`)}
38
+ ${f(`cyan`,`rari deploy railway`)}
41
39
 
42
- ${l(`gray`,`# Setup Render deployment`)}
43
- ${l(`cyan`,`rari deploy render`)}
40
+ ${f(`gray`,`# Setup Render deployment`)}
41
+ ${f(`cyan`,`rari deploy render`)}
44
42
 
45
- ${l(`gray`,`# Start with debug logging`)}
46
- ${l(`cyan`,`RUST_LOG=debug rari start`)}
43
+ ${f(`gray`,`# Start with debug logging`)}
44
+ ${f(`cyan`,`RUST_LOG=debug rari start`)}
47
45
 
48
- ${l(`bold`,`Deployment:`)}
49
- ${l(`cyan`,`rari deploy railway`)} Creates Railway deployment files
50
- ${l(`cyan`,`rari deploy render`)} Creates Render deployment files
46
+ ${f(`bold`,`Deployment:`)}
47
+ ${f(`cyan`,`rari deploy railway`)} Creates Railway deployment files
48
+ ${f(`cyan`,`rari deploy render`)} Creates Render deployment files
51
49
 
52
50
  Platform deployment automatically detects the environment and configures:
53
51
  - Host binding (0.0.0.0 for platforms, 127.0.0.1 for local)
54
52
  - Port from platform's PORT environment variable
55
53
  - Production mode optimization
56
54
 
57
- ${l(`bold`,`Binary Resolution:`)}
55
+ ${f(`bold`,`Binary Resolution:`)}
58
56
  1. Platform-specific package (rari-{platform}-{arch})
59
57
  2. Global binary in PATH
60
58
  3. Install from source with Cargo
61
59
 
62
- ${l(`bold`,`Notes:`)}
60
+ ${f(`bold`,`Notes:`)}
63
61
  - 'rari start' defaults to production mode unless NODE_ENV is set
64
62
  - 'rari dev' runs in development mode with Vite hot reload
65
63
  - 'rari build' cleans, type checks, and builds for production
@@ -67,4 +65,4 @@ ${l(`bold`,`Notes:`)}
67
65
  - Platform deployment is automatically detected and configured
68
66
  - Use Ctrl+C to stop the server gracefully
69
67
 
70
- `);break;case`dev`:await P();break;case`build`:await M();break;case`start`:await F();break;case`clean`:await R();break;case`deploy`:v[0]===`railway`?await I():v[0]===`render`?await L():(f(`Unknown deployment target. Available: railway, render`),s.exit(1));break;default:console.error(`${l(`bold`,`Unknown command:`)} ${_}`),console.warn(`Run "${l(`cyan`,`rari help`)}" for available commands`),s.exit(1)}}const B=s.argv[1]?a(o(s.argv[1])):``,V=a(c(import.meta.url));B&&V===B&&z().catch(e=>{f(`CLI Error: ${E(e)}`),console.error(e),s.exit(1)});export{S as detectPackageManager,j as getDeploymentConfig,D as isRailwayEnvironment,O as isRenderEnvironment};
68
+ `)}async function K(){j();let{command:e,args:t}=M(l.argv.slice(2));switch(e){case void 0:case`help`:G();break;case`dev`:await B();break;case`build`:await R();break;case`start`:await V();break;case`clean`:await W();break;case`deploy`:t[0]===`railway`?await H():t[0]===`render`?await U():(h(`Unknown deployment target. Available: railway, render`),l.exit(1));break;default:console.error(`${f(`bold`,`Unknown command:`)} ${e}`),console.warn(`Run "${f(`cyan`,`rari help`)}" for available commands`),l.exit(1)}}function q(){let e=l.argv[1]?o(c(l.argv[1])):``,t=o(u(import.meta.url));return!!e&&t===e}q()&&K().catch(e=>{h(`CLI Error: ${A(e)}`),console.error(e),l.exit(1)});export{w as detectPackageManager,L as getDeploymentConfig,N as isRailwayEnvironment,P as isRenderEnvironment};
@@ -0,0 +1,14 @@
1
+ import { ComponentType } from "react";
2
+
3
+ //#region src/mdx/components/define.d.ts
4
+ interface MdxComponentEntry {
5
+ name: string;
6
+ component: ComponentType<any>;
7
+ id: string;
8
+ client?: boolean;
9
+ exportName?: string;
10
+ }
11
+ type MdxComponentsInput = Record<string, ComponentType<any> | MdxComponentEntry>;
12
+ declare function defineMdxComponents(input: MdxComponentEntry[] | MdxComponentsInput): (content: string) => Record<string, any>;
13
+ //#endregion
14
+ export { defineMdxComponents as n, MdxComponentEntry as t };
@@ -0,0 +1 @@
1
+ import{s as e}from"./regex-constants-Wm7xRA3u.mjs";import{t}from"./names-N6JRDeT1.mjs";import{registerClientReference as n}from"./runtime/rsc-references.mjs";import{r}from"./rari-global-Dygfa818.mjs";function i(t,i,a=`default`){let o=`${i}#${a}`;if(typeof globalThis<`u`){let n=r(),s=i.replace(e,``).split(`/`).pop()||a,c={id:a==="default"?s:a,path:i,type:`client`,component:t,registered:!0};n[o]=c,n[s]=c,n[i]=c}function s(){throw Error(`Attempted to call ${a}() from the server but ${a} is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.`)}return n(s,i,a)}function a(e){let t={};for(let[n,{component:r,id:a,exportName:o=`default`}]of Object.entries(e))t[n]=i(r,a,o);return t}function o(e){return typeof e==`object`&&!!e&&`component`in e&&`id`in e}function s(e){return Array.isArray(e)?e:Object.entries(e).map(([e,t])=>{if(o(t))return{component:t.component,id:t.id,exportName:t.exportName,name:e,client:t.client??!0};throw Error(`[rari/mdx] Component "${e}" is missing module metadata. Pass components to defineMdxComponents({ ... }) in a file processed by the rari vite plugin.`)})}function c(e){let n=s(e);return e=>{let r={},i={},o=new Set(t(e));for(let e of n)if(o.has(e.name)){if(e.client===!1){r[e.name]=e.component;continue}i[e.name]={component:e.component,id:e.id,exportName:e.exportName}}return{...r,...a(i)}}}export{c as t};
@@ -0,0 +1,3 @@
1
+ import{o as e,t}from"./alias-resolver-CHTPYtdq.mjs";import{t as n}from"./xml-N8OZmN7u.mjs";import{Buffer as r}from"node:buffer";import{promises as i}from"node:fs";import a from"node:path";const o=`\0virtual:feed`;function s(e){return(typeof e==`string`?new Date(e):e).toUTCString()}function c(e){return e?typeof e==`string`?` <dc:creator>${n(e)}</dc:creator>`:e.email?` <author>${n(`${e.email} (${e.name})`)}</author>`:` <dc:creator>${n(e.name)}</dc:creator>`:``}function l(e){let t=[` <item>`];t.push(` <title>${n(e.title)}</title>`),t.push(` <link>${n(e.url)}</link>`),e.description&&t.push(` <description>${n(e.description)}</description>`),e.content&&t.push(` <content:encoded><![CDATA[${e.content.replace(/\]\]>/g,`]]]]><![CDATA[>`)}]]></content:encoded>`);let r=c(e.author);if(r&&t.push(r),e.pubDate&&t.push(` <pubDate>${s(e.pubDate)}</pubDate>`),t.push(` <guid isPermaLink="${e.guid?`false`:`true`}">${n(e.guid||e.url)}</guid>`),e.categories)for(let r of e.categories)t.push(` <category>${n(r)}</category>`);if(e.enclosure){let r=[`url="${n(e.enclosure.url)}"`];e.enclosure.length!==void 0&&r.push(`length="${e.enclosure.length}"`),r.push(`type="${n(e.enclosure.type||`application/octet-stream`)}"`),t.push(` <enclosure ${r.join(` `)} />`)}return t.push(` </item>`),t.join(`
2
+ `)}function u(e){let t=e.items.some(e=>e.content),r=e.items.some(e=>typeof e.author==`string`||typeof e.author==`object`&&e.author!==null&&!e.author.email),i=[];t&&i.push(`xmlns:content="http://purl.org/rss/1.0/modules/content/"`),r&&i.push(`xmlns:dc="http://purl.org/dc/elements/1.1/"`),i.push(`xmlns:atom="http://www.w3.org/2005/Atom"`);let a=[`<?xml version="1.0" encoding="UTF-8"?>`,`<rss version="2.0"${i.length>0?` ${i.join(` `)}`:``}>`,` <channel>`,` <title>${n(e.title)}</title>`,` <link>${n(e.link)}</link>`,` <description>${n(e.description)}</description>`,` <atom:link href="${n(`${e.link.replace(/\/+$/,``)}/feed.xml`)}" rel="self" type="application/rss+xml" />`];e.language&&a.push(` <language>${n(e.language)}</language>`),e.copyright&&a.push(` <copyright>${n(e.copyright)}</copyright>`),e.lastBuildDate&&a.push(` <lastBuildDate>${s(e.lastBuildDate)}</lastBuildDate>`),e.ttl!==void 0&&a.push(` <ttl>${e.ttl}</ttl>`),e.image&&(a.push(` <image>`),a.push(` <url>${n(e.image.url)}</url>`),a.push(` <title>${n(e.image.title)}</title>`),a.push(` <link>${n(e.image.link)}</link>`),e.image.width!==void 0&&a.push(` <width>${e.image.width}</width>`),e.image.height!==void 0&&a.push(` <height>${e.image.height}</height>`),a.push(` </image>`));for(let t of e.items)a.push(l(t));return a.push(` </channel>`),a.push(`</rss>`),a.join(`
3
+ `)}function d(e){switch(e){case`ts`:return`ts`;case`tsx`:return`tsx`;case`js`:case`mjs`:return`js`;case`jsx`:return`jsx`;default:throw Error(`Unsupported feed file extension: ".${e}". Allowed extensions are: .ts, .tsx, .js, .jsx, .mjs`)}}async function f(e,t=[`.ts`,`.tsx`,`.js`,`.jsx`,`.mjs`]){let n=a.join(e,`feed.xml`);try{return await i.access(n),{type:`static`,path:n}}catch{}for(let n of t){let t=a.join(e,`feed${n}`);try{return await i.access(t),{type:`dynamic`,path:t}}catch{}}return null}function p(n,r,s={},c){return{name:`virtual-feed`,resolveId(r,i){if(r===o)return r;if(Object.keys(s).length>0){let n=t(r,s,c);if(n)return e(n)||n}if(r.startsWith(`.`)){let t=!i||i.startsWith(`\0`)?n.path:i,o=a.resolve(a.dirname(t),r);return e(o)||o}return null},async load(e){if(e===o)return{code:r,moduleType:d(a.extname(n.path).slice(1))};if(e&&!e.startsWith(`\0`))try{return{code:await i.readFile(e,`utf-8`),moduleType:d(a.extname(e).slice(1))}}catch{return null}return null}}}async function m(e){let{appDir:t,outDir:n,extensions:s,aliases:c={}}=e,l=await f(t,s);if(!l)return!1;await i.mkdir(n,{recursive:!0});let d=a.join(n,`feed.xml`);if(l.type===`static`)return await i.copyFile(l.path,d),!0;try{let{build:e}=await import(`rolldown`),n=await i.readFile(l.path,`utf-8`),s=a.dirname(a.dirname(t)),f=await e({input:o,external:[`rari`],platform:`node`,write:!1,output:{format:`esm`,codeSplitting:!1},plugins:[p(l,n,c,s)]});if(!f.output||f.output.length===0)throw Error(`Failed to build feed module`);let m=f.output.find(e=>e.type===`chunk`&&e.isEntry)||f.output.find(e=>e.type===`chunk`);if(!m||m.type!==`chunk`)throw Error(`No chunk output found in feed build result`);let h=m.code,g=await import(`data:text/javascript;base64,${r.from(h).toString(`base64`)}`);if(!g||g.default==null)throw Error(`Feed file must export a default export (either an object or a function)`);let _;if(typeof g.default==`function`){let e=g.default();_=e instanceof Promise?await e:e}else _=g.default;let v=u(_);return await i.writeFile(d,v),!0}catch(e){return console.error(`[rari] Failed to build/execute feed file:`,e),!1}}export{m as generateFeedFile};
@@ -0,0 +1 @@
1
+ import{a as e,r as t}from"./rari-global-Dygfa818.mjs";import*as n from"react";function r(e){return e.startsWith(`./`)?[e,e.slice(2)]:[e,`./${e}`]}function i(e){let t=e.replace(/\\/g,`/`),n=new Set([t]),r=t.indexOf(`/src/`);r!==-1&&n.add(t.slice(r+1));let i=t.indexOf(`/components/`);return i!==-1&&n.add(t.slice(i+1)),[...n]}function a(e,t){if(t!==void 0)return t;let n=e.exportName;if(n)return n}function o(e,t){let n=e.replace(/\\/g,`/`),r=t.replace(/\\/g,`/`);return!!(n===r||r.includes(`/`)&&n.endsWith(`/${r}`)||n.includes(`/`)&&r.endsWith(`/${n}`))}function s(e,t,n){for(let s of i(e))for(let e of r(s)){let r=Object.values(n).find(t=>t?.path?o(t.path,e):!1);if(r)return{info:r,exportName:a(r,t)}}return null}function c(e){return e.loading=!0,e.loadPromise=e.loader().then(t=>(e.component=t,e.registered=!0,e.loading=!1,t)).catch(t=>{throw console.error(`[rari] Failed to load component ${e.id}:`,t),e.loading=!1,e.loadError=t,e.loadPromise=void 0,t}),e.loadPromise}async function l(e,t){return e.component==null?e.loadPromise?(await e.loadPromise,u(e,t)):e.loader?await c(e)==null?null:u(e,t):null:u(e,t)}function u(e,t){if(e.component==null)return null;let n=e.component;return!t||t==="default"?n.default??n:n[t]===void 0?n.default?.[t]===void 0?null:n.default[t]:n[t]}function d(e,t){let n=t[`~clientComponents`]||{},i=t[`~clientComponentPaths`]||{},o=t[`~clientComponentNames`]||{},c=e.replace(/\\/g,`/`);for(let t of c===e?[c]:[c,e]){let e=n[t];if(e){let n=t.indexOf(`#`);return{info:e,exportName:a(e,n===-1?void 0:t.slice(n+1))}}}let l=c.indexOf(`#`),u=l===-1?c:c.slice(0,l),d=l===-1?void 0:c.slice(l+1);for(let t of c===e?[c]:[c,e]){let e=t.indexOf(`#`),r=n[e===-1?t:t.slice(0,e)];if(r)return{info:r,exportName:a(r,d)}}let f=c===e?[u]:[u,e.includes(`#`)?e.slice(0,e.indexOf(`#`)):e];for(let e of f){for(let t of r(e)){let e=i[t];if(e){let t=n[e];if(t)return{info:t,exportName:a(t,d)}}}let t=o[e];if(t){let e=n[t];if(e)return{info:e,exportName:a(e,d)}}}return s(u,d,n)||null}function f(e){return e.component||!e.loader?e.loadPromise:e.loadError?Promise.reject(e.loadError):e.loadPromise?e.loadPromise:c(e)}function p(e,t,n){let r=a(e,n),i=u({...e,component:t},r);if(i==null)return typeof t==`object`&&t&&(`default`in t||`__esModule`in t)?t:typeof t==`function`?{default:t,[r||`default`]:t,__esModule:!0}:t;let o=r||`default`;return{...t,default:i,[o]:i,__esModule:!0}}function m(e,t,r,i){let o=a(e,i),s=o||`default`,c=i=>{if(e.loadError)throw e.loadError;if(e.component){let r=u(e,o);if(r==null)throw Error(`[rari] Lazy component "${t}" loaded but export "${s}" is missing`);return n.createElement(r,i)}throw r};return c.displayName=`Lazy(${e.displayName||e.exportName||t})`,{default:c,[s]:c,__esModule:!0}}function h(t){let n=d(t,e());if(!n)return import.meta.env?.DEV&&console.warn(`[rari] __rari_rsc_require__: component "${t}" not found in registry`),{};let{info:r,exportName:i}=n;if(r.component)return p(r,r.component,i);if(r.loader){if(r.loadError)return m(r,t,Promise.resolve(),i);let e=f(r);if(e)return m(r,t,e,i)}return{}}async function g(t){let n=d(t,e());return n?l(n.info,n.exportName):null}function _(){typeof window>`u`||(globalThis.__rari_chunk_load__=e=>{let n=t(),r=n[e];if(!r){let t=e.replace(/\\/g,`/`);r=n[t]||Object.values(n).find(n=>n&&(n.path===e||n.path===t))}if(r&&!r.component&&r.loader){let e=f(r);if(e)return e}return r&&r.loadPromise?r.loadPromise:Promise.resolve()})}export{_ as n,h as r,g as t};
@@ -1,6 +1,41 @@
1
- import { i as ReadonlyCookie, n as CookieStore, t as CookieOptions } from "./types-zPQ3RHgH.mjs";
2
-
1
+ //#region src/runtime/shared/types.d.ts
2
+ interface CookieOptions {
3
+ path?: string;
4
+ domain?: string;
5
+ expires?: Date;
6
+ maxAge?: number;
7
+ httpOnly?: boolean;
8
+ secure?: boolean;
9
+ sameSite?: boolean | 'lax' | 'strict' | 'none';
10
+ priority?: 'low' | 'medium' | 'high';
11
+ partitioned?: boolean;
12
+ }
13
+ interface ReadonlyCookie {
14
+ name: string;
15
+ value: string;
16
+ }
17
+ interface ReadonlyHeaders {
18
+ get: (name: string) => string | null;
19
+ has: (name: string) => boolean;
20
+ entries: () => IterableIterator<[string, string]>;
21
+ forEach: (callback: (value: string, key: string) => void) => void;
22
+ keys: () => IterableIterator<string>;
23
+ values: () => IterableIterator<string>;
24
+ }
25
+ interface CookieStore {
26
+ get: (name: string) => ReadonlyCookie | undefined;
27
+ getAll: (name?: string) => ReadonlyCookie[];
28
+ has: (name: string) => boolean;
29
+ set: ((name: string, value: string, options?: CookieOptions) => void) & ((options: {
30
+ name: string;
31
+ value: string;
32
+ } & CookieOptions) => void);
33
+ delete: (name: string) => void;
34
+ toString: () => string;
35
+ }
36
+ //#endregion
3
37
  //#region src/headers.d.ts
4
38
  declare function cookies(): Promise<CookieStore>;
39
+ declare function headers(): Promise<ReadonlyHeaders>;
5
40
  //#endregion
6
- export { type CookieOptions, type CookieStore, type ReadonlyCookie, cookies };
41
+ export { type CookieOptions, type CookieStore, type ReadonlyCookie, type ReadonlyHeaders, cookies, headers };
package/dist/headers.mjs CHANGED
@@ -1 +1 @@
1
- async function e(){let e=globalThis[`~rari`]?.cookies?.();if(!e)throw Error(`[rari] cookies() is only available in server actions and server components.`);return e}export{e as cookies};
1
+ import{i as e}from"./rari-global-Dygfa818.mjs";function t(){let t=e();if(t.markUseCacheDynamic){t.markUseCacheDynamic();return}t.useCacheDynamicDepth=(t.useCacheDynamicDepth??0)+1}async function n(){t();let n=e().cookies?.();if(!n)throw Error(`[rari] cookies() is only available in server actions and server components.`);return n}async function r(){t();let n=e().headers?.();if(!n)throw Error(`[rari] headers() is only available in server actions and server components.`);return n}export{n as cookies,r as headers};
@@ -0,0 +1 @@
1
+ async function e(e){if(!e.ok){let t;try{t=await e.text()}catch{t=`<unable to read response body>`}let n=t.length>200?`${t.slice(0,200)}...`:t,r=Error(`HTTP ${e.status}: ${e.statusText}`);throw r.status=e.status,r.statusText=e.statusText,r.bodyPreview=n,r}}export{e as t};
@@ -7,7 +7,7 @@ declare const DEFAULT_QUALITY_LEVELS: number[];
7
7
  declare const DEFAULT_MINIMUM_CACHE_TTL = 60;
8
8
  declare const DEFAULT_MAX_CACHE_SIZE: number;
9
9
  //#endregion
10
- //#region src/image/Image.d.ts
10
+ //#region src/image/image.d.ts
11
11
  interface ImageProps {
12
12
  src: string | StaticImageData;
13
13
  alt: string;
package/dist/image.mjs ADDED
@@ -0,0 +1 @@
1
+ import{a as e,i as t,n,o as r,r as i,t as a}from"./constants-De7aSsCq.mjs";import{useCallback as o,useEffect as s,useRef as c,useState as l}from"react";import{jsx as u,jsxs as d}from"react/jsx-runtime";function f(e,t,n,r){let i=new URLSearchParams;return i.set(`url`,e),i.set(`w`,t.toString()),i.set(`q`,n.toString()),r&&i.set(`f`,r),`/_rari/image?${i}`}function p({src:e,alt:t,width:r,height:i,quality:p=75,preload:m=!1,loading:h=`lazy`,placeholder:g=`empty`,blurDataURL:_,fill:v=!1,sizes:y,style:b,className:x,onLoad:S,onError:C,unoptimized:w=!1,loader:T,overrideSrc:E,decoding:D}){let O=typeof e==`string`?e:e.src,k=r||(typeof e==`string`?void 0:e.width),A=i||(typeof e==`string`?void 0:e.height),j=_||(typeof e==`string`?void 0:e.blurDataURL),M=E||O,N=m,P=D||(m?`sync`:`async`),[F,I]=l(!1),[L,R]=l(!1),z=c(null),B=c(S),V=c(null);s(()=>{B.current=S},[S]);let H=o(e=>{let t=e.currentTarget;t.src&&t.complete&&(g===`blur`&&I(!0),B.current&&B.current(e))},[g]),U=o(e=>{R(!0),g===`blur`&&I(!0),C&&C(e)},[g,C]);s(()=>{if(N){let e=document.createElement(`link`);return e.rel=`preload`,e.as=`image`,T?e.href=T({src:M,width:k||1920,quality:p}):w?e.href=M:e.href=f(M,k||1920,p),y&&e.setAttribute(`imagesizes`,y),document.head.appendChild(e),()=>{e.parentNode===document.head&&document.head.removeChild(e)}}},[N,M,k,p,y,T,w]),s(()=>{if(N||w||h===`eager`)return;let e=z.current;if(!e)return;let t=new IntersectionObserver(n=>{n.forEach(n=>{n.isIntersecting&&t.unobserve(e)})},{rootMargin:`50px`});return t.observe(e),()=>{t.disconnect()}},[N,w,h]);let W={...b,...v&&{position:`absolute`,inset:0,width:`100%`,height:`100%`,objectFit:`cover`},...g===`blur`&&j&&!F&&{backgroundImage:`url(${j})`,backgroundSize:`cover`,backgroundPosition:`center`,filter:`blur(20px)`,transition:`filter 0.3s ease-out`},...g===`blur`&&F&&{filter:`none`,transition:`filter 0.3s ease-out`}};if(w)return u(`img`,{ref:z,src:T?T({src:M,width:k||1920,quality:p}):M,alt:L?t:``,width:v?void 0:k,height:v?void 0:A,loading:N?`eager`:h,fetchPriority:N?`high`:`auto`,decoding:P,onLoad:H,onError:U,style:W,className:x});let G=k||1920,K=k?[k]:a,q=e=>T?K.map(e=>`${T({src:M,width:e,quality:p})} ${e}w`).join(`, `):K.map(t=>`${f(M,t,p,e)} ${t}w`).join(`, `),J=T?T({src:M,width:G,quality:p}):f(M,G,p),Y=K.length>1||K[0]!==G,X=u(`img`,{ref:z,src:J,srcSet:Y?q():void 0,sizes:Y?y:void 0,alt:L?t:``,width:v?void 0:k,height:v?void 0:A,loading:N?`eager`:h,fetchPriority:N?`high`:`auto`,decoding:P,onLoad:H,onError:U,style:W,className:x});return Y?d(`picture`,{ref:V,children:[n.includes(`avif`)&&u(`source`,{type:`image/avif`,srcSet:q(`avif`),sizes:y}),n.includes(`webp`)&&u(`source`,{type:`image/webp`,srcSet:q(`webp`),sizes:y}),X]}):X}const m=typeof window>`u`,h=p;m&&(h.$$typeof=Symbol.for(`react.client.reference`),h.$$id=`rari/image#Image`);export{a as DEFAULT_DEVICE_SIZES,n as DEFAULT_FORMATS,i as DEFAULT_IMAGE_SIZES,t as DEFAULT_MAX_CACHE_SIZE,e as DEFAULT_MINIMUM_CACHE_TTL,r as DEFAULT_QUALITY_LEVELS,h as Image};
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
- import { d as Metadata, l as LayoutProps, p as PageProps } from "./types-BwhW3M72.mjs";
2
- import { a as Sitemap, c as SitemapVideo, i as RobotsRule, n as FeedEntry, o as SitemapEntry, r as Robots, s as SitemapImage, t as Feed } from "./metadata-route-_d5FkjlL.mjs";
3
- import { c as RariURL, n as ProxyConfig, r as ProxyFunction, s as RariFetchEvent } from "./types-3dq9RGI5.mjs";
1
+ import { a as Sitemap, c as SitemapVideo, d as RouteContext, f as RouteHandler, i as RobotsRule, l as ApiResponse, n as FeedEntry, o as SitemapEntry, r as Robots, s as SitemapImage, t as Feed, u as ApiRouteHandlers } from "./types-DJQFFYSj.mjs";
2
+ import { c as RariURL, n as ProxyConfig, r as ProxyFunction, s as RariFetchEvent } from "./types-BC33STEP.mjs";
4
3
  import { RariRequest } from "./proxy/RariRequest.mjs";
5
4
  import { RariResponse } from "./proxy/RariResponse.mjs";
6
- export { type Feed, type FeedEntry, type LayoutProps, type Metadata, type PageProps, type ProxyConfig, type ProxyFunction, type RariFetchEvent, RariRequest, RariResponse, type RariURL, type Robots, type RobotsRule, type Sitemap, type SitemapEntry, type SitemapImage, type SitemapVideo };
5
+ import { a as ErrorProps, d as Metadata, l as LayoutProps, p as PageProps } from "./types-DlF9FHQc.mjs";
6
+ export { ApiResponse, type ApiRouteHandlers, type ErrorProps, type Feed, type FeedEntry, type LayoutProps, type Metadata, type PageProps, type ProxyConfig, type ProxyFunction, type RariFetchEvent, RariRequest, RariResponse, type RariURL, type Robots, type RobotsRule, type RouteContext, type RouteHandler, type Sitemap, type SitemapEntry, type SitemapImage, type SitemapVideo };
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{RariRequest as e}from"./proxy/RariRequest.mjs";import{RariResponse as t}from"./proxy/RariResponse.mjs";export{e as RariRequest,t as RariResponse};
1
+ import{RariRequest as e}from"./proxy/RariRequest.mjs";import{RariResponse as t}from"./proxy/RariResponse.mjs";import{t as n}from"./api-routes-ChRr3O5-.mjs";export{n as ApiResponse,e as RariRequest,t as RariResponse};
@@ -0,0 +1,2 @@
1
+ import { n as defineMdxComponents, t as MdxComponentEntry } from "../define-CRFUKkcA.mjs";
2
+ export { type MdxComponentEntry, defineMdxComponents };
@@ -0,0 +1 @@
1
+ import{t as e}from"../define-rCXgNOOk.mjs";export{e as defineMdxComponents};
@@ -0,0 +1,4 @@
1
+ //#region src/mdx/registry.d.ts
2
+ declare function getMDXComponents(_content: string): Record<string, any>;
3
+ //#endregion
4
+ export { getMDXComponents };
@@ -0,0 +1 @@
1
+ function e(e){throw Error(`[rari/mdx] Client component registry is generated by the rari vite plugin. Use evaluate from "rari/mdx" in a project using the rari() plugin.`)}export{e as getMDXComponents};
package/dist/mdx.d.mts CHANGED
@@ -1,10 +1,32 @@
1
- //#region src/runtime/mdx-client-components.d.ts
2
- interface MDXClientComponentConfig {
3
- component: any;
4
- id: string;
5
- exportName?: string;
1
+ import { n as defineMdxComponents, t as MdxComponentEntry } from "./define-CRFUKkcA.mjs";
2
+ import { ComponentType, ElementType, ExoticComponent, FragmentProps, Key, ReactElement } from "react";
3
+
4
+ //#region src/mdx/evaluate.d.ts
5
+ interface EvaluateOptions {
6
+ components?: Record<string, any>;
7
+ baseUrl?: string | URL;
8
+ development?: boolean;
9
+ remarkPlugins?: unknown[];
10
+ rehypePlugins?: unknown[];
11
+ recmaPlugins?: unknown[];
12
+ Fragment?: ExoticComponent<FragmentProps>;
13
+ jsx?: (type: ElementType, props: unknown, key?: Key) => ReactElement;
14
+ jsxs?: (type: ElementType, props: unknown, key?: Key) => ReactElement;
15
+ jsxDEV?: (type: ElementType, props: unknown, key?: Key, isStaticChildren?: boolean, source?: object, self?: unknown) => ReactElement;
16
+ useMDXComponents?: () => Record<string, ComponentType<any>>;
17
+ jsxImportSource?: string;
18
+ format?: 'detect' | 'mdx' | 'md';
19
+ outputFormat?: 'program' | 'function-body';
20
+ [key: string]: unknown;
6
21
  }
7
- declare function createMDXClientReference(component: any, id: string, exportName?: string): any;
8
- declare function createMDXClientReferences(components: Record<string, MDXClientComponentConfig>): Record<string, any>;
22
+ interface EvaluateResult {
23
+ default: ComponentType<{
24
+ components?: Record<string, any>;
25
+ }>;
26
+ }
27
+ declare function evaluate(source: string, options?: EvaluateOptions): Promise<EvaluateResult>;
28
+ //#endregion
29
+ //#region src/mdx/scan/names.d.ts
30
+ declare function scanMdxComponentNames(content: string): string[];
9
31
  //#endregion
10
- export { type MDXClientComponentConfig, createMDXClientReference, createMDXClientReferences };
32
+ export { type EvaluateOptions, type EvaluateResult, type MdxComponentEntry, defineMdxComponents, evaluate, scanMdxComponentNames };
package/dist/mdx.mjs CHANGED
@@ -1 +1 @@
1
- import{s as e}from"./regex-constants-DQ2vkSU5.mjs";import{registerClientComponent as t,registerClientReference as n}from"./runtime/react-server-dom-shim.mjs";function r(r,i,a=`default`){let o=`${i}#${a}`;if(t(r,i,a),typeof globalThis<`u`){let t=globalThis;t[`~clientComponents`]||={};let n=i.replace(e,``).split(`/`).pop()||a,s={id:a==="default"?n:a,path:i,type:`client`,component:r,registered:!0};t[`~clientComponents`][o]=s,t[`~clientComponents`][n]=s,t[`~clientComponents`][i]=s}function s(){throw Error(`Attempted to call ${a}() from the server but ${a} is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.`)}return n(s,i,a)}function i(e){let t={};for(let[n,{component:i,id:a,exportName:o=`default`}]of Object.entries(e))t[n]=r(i,a,o);return t}export{r as createMDXClientReference,i as createMDXClientReferences};
1
+ import{t as e}from"./names-N6JRDeT1.mjs";import{t}from"./define-rCXgNOOk.mjs";import{createElement as n}from"react";import{evaluate as r}from"@mdx-js/mdx";import{getMDXComponents as i}from"rari/mdx/registry";async function a(e,t={}){let{components:a={},...o}=t,s=await r(e,o),c=s.default,l=i(e);function u(e){let t={...l,...a,...e.components};return n(c,{...e,components:t})}return{...s,default:u}}export{t as defineMdxComponents,a as evaluate,e as scanMdxComponentNames};
@@ -0,0 +1 @@
1
+ const e=/<([A-Z][A-Za-z0-9]*)(?=[\s>/])/;function t(t){let n=new Set,r=new RegExp(e.source,`g`);for(let e of t.matchAll(r))n.add(e[1]);return[...n]}export{t};
@@ -1,6 +1,6 @@
1
1
  import { ReactElement } from "react";
2
2
 
3
- //#region src/og/ImageResponse.d.ts
3
+ //#region src/og/image-response.d.ts
4
4
  interface ImageResponseOptions {
5
5
  width?: number;
6
6
  height?: number;
@@ -1,4 +1,4 @@
1
- //#region src/platform.d.ts
1
+ //#region src/cli/platform.d.ts
2
2
  declare function getBinaryPath(): string;
3
3
  declare function getInstallationInstructions(): string;
4
4
  //#endregion
package/dist/platform.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import{existsSync as e}from"node:fs";import{dirname as t,join as n}from"node:path";import r from"node:process";import{fileURLToPath as i}from"node:url";const a={"linux-x64":`rari-linux-x64`,"linux-arm64":`rari-linux-arm64`,"darwin-x64":`rari-darwin-x64`,"darwin-arm64":`rari-darwin-arm64`,"win32-arm64":`rari-win32-arm64`,"win32-x64":`rari-win32-x64`};function o(){let e=r.platform,t=r.arch,n;switch(e){case`darwin`:n=`darwin`;break;case`linux`:n=`linux`;break;case`win32`:n=`win32`;break;default:throw Error(`Unsupported platform: ${e}. rari supports Linux, macOS, and Windows.`)}let i;switch(t){case`x64`:i=`x64`;break;case`arm64`:i=`arm64`;break;default:throw Error(`Unsupported architecture: ${t}. rari supports x64 and ARM64.`)}let o=a[`${n}-${i}`];if(!o)throw Error(`Unsupported platform combination: ${n}-${i}. Supported platforms: ${Object.keys(a).join(`, `)}`);return{platform:n,arch:i,packageName:o,binaryName:n===`win32`?`rari.exe`:`rari`}}function s(){let{packageName:r,binaryName:a}=o(),s=t(i(import.meta.url));for(;;){if(e(n(s,`pnpm-workspace.yaml`))){let t=n(s,`packages`,r,`bin`,a);if(e(t))return t;break}let i=t(s);if(i===s)break;s=i}try{let t=import.meta.resolve(`${r}/package.json`),o=n(i(new URL(`.`,t)),`bin`,a);if(e(o))return o;throw Error(`Binary not found at ${o}`)}catch{throw Error(`Failed to locate rari binary for ${r}. Please ensure the platform package is installed: npm install ${r}`)}}function c(){let{packageName:e}=o();return`
1
+ import{existsSync as e}from"node:fs";import{dirname as t,join as n}from"node:path";import r from"node:process";import{fileURLToPath as i}from"node:url";const a={"linux-x64":`rari-linux-x64`,"linux-arm64":`rari-linux-arm64`,"darwin-x64":`rari-darwin-x64`,"darwin-arm64":`rari-darwin-arm64`,"win32-arm64":`rari-win32-arm64`,"win32-x64":`rari-win32-x64`};function o(){let e=r.platform,t=r.arch,n;switch(e){case`darwin`:n=`darwin`;break;case`linux`:n=`linux`;break;case`win32`:n=`win32`;break;default:throw Error(`Unsupported platform: ${e}. rari supports Linux, macOS, and Windows.`)}let i;switch(t){case`x64`:i=`x64`;break;case`arm64`:i=`arm64`;break;default:throw Error(`Unsupported architecture: ${t}. rari supports x64 and ARM64.`)}let o=`${n}-${i}`,s=a[o];if(!s)throw Error(`Unsupported platform combination: ${n}-${i}. Supported platforms: ${Object.keys(a).join(`, `)}`);return{platform:n,arch:i,packageName:s,binaryName:n===`win32`?`rari.exe`:`rari`}}let s=null;function c(){let{packageName:r,binaryName:a}=o(),s=t(i(import.meta.url));for(;;){if(e(n(s,`pnpm-workspace.yaml`))){let t=n(s,`packages`,r,`bin`,a);if(e(t))return t;break}let i=t(s);if(i===s)break;s=i}try{let t=import.meta.resolve(`${r}/package.json`),o=n(i(new URL(`.`,t)),`bin`,a);if(e(o))return o;throw Error(`Binary not found at ${o}`)}catch{throw Error(`Failed to locate rari binary for ${r}. Please ensure the platform package is installed: npm install ${r}`)}}function l(){return s||(s=c(),s)}function u(){let{packageName:e}=o();return`
2
2
  To install rari for your platform, run:
3
3
 
4
4
  npm install ${e}
@@ -14,4 +14,4 @@ Or if you're using yarn:
14
14
  If you continue to have issues, you can also install from source:
15
15
 
16
16
  cargo install --git https://github.com/rari-build/rari
17
- `}export{s as getBinaryPath,c as getInstallationInstructions};
17
+ `}export{l as getBinaryPath,u as getInstallationInstructions};
@@ -0,0 +1,2 @@
1
+ import{t as e}from"./get-client-component-CDaY3lOP.mjs";async function t(t,n){let r=t.split(`
2
+ `),i=new Set;for(let e of r){let t=e.trim();if(!t)continue;let r=t.indexOf(`:`);if(r===-1)continue;let a=t.substring(r+1);if(a.startsWith(`I`))try{let e=a.substring(1),t=JSON.parse(e);if(Array.isArray(t)){let e=t[0],r=t[2],a=e.replace(/\\/g,`/`),o;o=a.includes(`#`)?a:r&&r!=="default"?`${a}#${r}`:a,(!n||!n.has(o))&&i.add(o)}}catch{}}i.size>0&&await Promise.all(Array.from(i,async t=>{try{if(!await e(t)){console.warn(`[rari] Failed to preload component: ${t}`);return}n?.add(t)}catch(e){console.error(`[rari] Error preloading component ${t}:`,e)}}))}export{t};
@@ -1,6 +1,6 @@
1
- import { c as RariURL, l as RequestCookies } from "../types-3dq9RGI5.mjs";
1
+ import { c as RariURL, l as RequestCookies } from "../types-BC33STEP.mjs";
2
2
 
3
- //#region src/proxy/RariRequest.d.ts
3
+ //#region src/proxy/http/request.d.ts
4
4
  declare class RariRequest {
5
5
  url: string;
6
6
  method: string;
@@ -1,6 +1,6 @@
1
- import { u as ResponseCookies } from "../types-3dq9RGI5.mjs";
1
+ import { u as ResponseCookies } from "../types-BC33STEP.mjs";
2
2
 
3
- //#region src/proxy/RariResponse.d.ts
3
+ //#region src/proxy/http/response.d.ts
4
4
  declare class RariResponse extends Response {
5
5
  cookies: ResponseCookies;
6
6
  constructor(body?: BodyInit | null, init?: ResponseInit);
@@ -1 +1 @@
1
- var e=class{cookies;constructor(){this.cookies=new Map}get(e){let t=this.cookies.get(e);if(t)return{name:t.name,value:t.value,path:t.options?.path}}getAll(){return Array.from(this.cookies.values(),e=>({name:e.name,value:e.value,path:e.options?.path}))}set(e,t,n){if(typeof e==`string`)this.cookies.set(e,{name:e,value:t,options:n});else{let{name:t,value:n,...r}=e;this.cookies.set(t,{name:t,value:n,options:r})}}delete(e){this.cookies.delete(e)}toSetCookieHeaders(){return Array.from(this.cookies.values(),e=>{let t=`${e.name}=${e.value}`;return e.options&&(e.options.path&&(t+=`; Path=${e.options.path}`),e.options.domain&&(t+=`; Domain=${e.options.domain}`),e.options.maxAge&&(t+=`; Max-Age=${e.options.maxAge}`),e.options.expires&&(t+=`; Expires=${e.options.expires.toUTCString()}`),e.options.httpOnly&&(t+=`; HttpOnly`),e.options.secure&&(t+=`; Secure`),e.options.sameSite&&(t+=`; SameSite=${e.options.sameSite}`)),t})}},t=class t extends Response{cookies;constructor(t,n){super(t,n),this.cookies=new e}static next(e){let n=new t(null,{status:200,headers:{"x-rari-proxy-continue":`true`}});return e?.request?.headers&&(e.request.headers instanceof Headers?e.request.headers:new Headers(e.request.headers)).forEach((e,t)=>{n.headers.set(`x-rari-proxy-request-${t}`,e)}),n}static redirect(e,n){return new t(null,{status:n||307,headers:{Location:e.toString()}})}static rewrite(e){return new t(null,{status:200,headers:{"x-rari-proxy-rewrite":e.toString()}})}static json(e,n){return new t(JSON.stringify(e),{...n,headers:{"Content-Type":`application/json`,...n?.headers}})}};export{t as RariResponse};
1
+ var e=class{cookies;constructor(){this.cookies=new Map}get(e){let t=this.cookies.get(e);if(t)return{name:t.name,value:t.value,path:t.options?.path}}getAll(){return Array.from(this.cookies.values(),e=>({name:e.name,value:e.value,path:e.options?.path}))}set(e,t,n){if(typeof e==`string`)this.cookies.set(e,{name:e,value:t,options:n});else{let{name:t,value:n,...r}=e;this.cookies.set(t,{name:t,value:n,options:r})}}delete(e){this.cookies.delete(e)}toSetCookieHeaders(){return Array.from(this.cookies.values(),e=>{let t=`${e.name}=${e.value}`;return e.options&&(e.options.path&&(t+=`; Path=${e.options.path}`),e.options.domain&&(t+=`; Domain=${e.options.domain}`),e.options.maxAge&&(t+=`; Max-Age=${e.options.maxAge}`),e.options.expires&&(t+=`; Expires=${e.options.expires.toUTCString()}`),e.options.httpOnly&&(t+=`; HttpOnly`),e.options.secure&&(t+=`; Secure`),e.options.sameSite&&(t+=`; SameSite=${e.options.sameSite}`)),t})}},t=class t extends Response{cookies;constructor(t,n){super(t,n),this.cookies=new e}static next(e){let n=new t(null,{status:200,headers:{"x-rari-proxy-continue":`true`}});return e?.request?.headers&&(e.request.headers instanceof Headers?e.request.headers:new Headers(e.request.headers)).forEach((e,t)=>{n.headers.set(`x-rari-proxy-request-${t}`,e)}),n}static redirect(e,n){return new t(null,{status:n||307,headers:{Location:e.toString()}})}static rewrite(e){return new t(null,{status:200,headers:{"x-rari-proxy-rewrite":e.toString()}})}static json(e,n){let r=JSON.stringify(e);return new t(r,{...n,headers:{"Content-Type":`application/json`,...n?.headers}})}};export{t as RariResponse};
@@ -1,4 +1,4 @@
1
- //#region src/proxy/shared/types.d.ts
1
+ //#region src/proxy/runtime/shared/types.d.ts
2
2
  interface SimpleRequest {
3
3
  url: string;
4
4
  method: string;
@@ -20,7 +20,7 @@ interface SimpleProxyResult {
20
20
  };
21
21
  }
22
22
  //#endregion
23
- //#region src/proxy/runtime-executor.d.ts
23
+ //#region src/proxy/runtime/runtime-executor.d.ts
24
24
  declare global {
25
25
  interface GlobalThis {
26
26
  '~rariExecuteProxy'?: (request: SimpleRequest) => Promise<SimpleProxyResult>;
@@ -1 +1 @@
1
- function e(e,t,n){if(Object.hasOwn(e,t)){let r=e[t];e[t]=Array.isArray(r)?[...r,n]:[r,n]}else e[t]=n}function t(t){let n={},r={};return t?.forEach&&t.forEach((t,i)=>{let a=i.toLowerCase();a.startsWith(`x-rari-proxy-request-`)?e(n,a.replace(`x-rari-proxy-request-`,``),t):a.startsWith(`x-rari-proxy-`)||e(r,a,t)}),{requestHeaders:Object.keys(n).length>0?n:void 0,responseHeaders:Object.keys(r).length>0?r:void 0}}function n(t){let n={};return t?.forEach&&t.forEach((t,r)=>{e(n,r.toLowerCase(),t)}),n}function r(e){if(!e)return null;let t=e.headers?.get?.(`x-rari-proxy-rewrite`);return t?{continue:!1,rewrite:t}:null}function i(e){if(!e||e.status==null)return null;let t=e.headers?.get?.(`location`);return t&&e.status>=300&&e.status<400?{continue:!1,redirect:{destination:t,permanent:e.status===301||e.status===308}}:null}function a(e){let{requestHeaders:n,responseHeaders:r}=t(e.headers);return{continue:!0,requestHeaders:n,responseHeaders:r}}async function o(e){let t=n(e.headers),r;try{e.text&&typeof e.text==`function`?r=await e.text():e.body!=null&&typeof e.body==`string`?r=e.body:e.body!=null&&console.warn(`[rari] Proxy: Response body is not extractable as text`)}catch(e){console.error(`[rari] Proxy: Failed to extract response body:`,e)}return{continue:!1,response:{status:e.status??200,headers:t,body:r}}}async function s(e){return e?r(e)||i(e)||(e.headers?.get?.(`x-rari-proxy-continue`)===`true`?a(e):e.status==null?{continue:!0}:await o(e)):{continue:!0}}async function c(e,t){try{let n=await import(e);if(!n||!n.proxy)return console.error(`[rari] Proxy: proxy function not found in module`),!1;let{RariRequest:r}=await import(t);return globalThis[`~rariExecuteProxy`]=async function(e){try{let t=new r(e.url,{method:e.method,headers:new Headers(e.headers)}),i=[],a=await n.proxy(t,{waitUntil:e=>{e.catch(()=>{}),i.push(e)}});return i.length>0&&Promise.allSettled(i).then(e=>{e.forEach((e,t)=>{e.status===`rejected`&&console.error(`[rari] Proxy: waitUntil promise ${t} failed:`,e.reason)})}),await s(a)}catch(e){return console.error(`[rari] Proxy: Proxy execution error:`,e),{continue:!0}}},!0}catch(e){return console.error(`[rari] Proxy: Failed to initialize proxy executor:`,e),!1}}export{c as initializeProxyExecutor};
1
+ function e(e,t,n){if(Object.hasOwn(e,t)){let r=e[t];e[t]=Array.isArray(r)?[...r,n]:[r,n]}else e[t]=n}function t(t){let n={},r={};return t?.forEach&&t.forEach((t,i)=>{let a=i.toLowerCase();if(a.startsWith(`x-rari-proxy-request-`)){let r=a.replace(`x-rari-proxy-request-`,``);e(n,r,t)}else a.startsWith(`x-rari-proxy-`)||e(r,a,t)}),{requestHeaders:Object.keys(n).length>0?n:void 0,responseHeaders:Object.keys(r).length>0?r:void 0}}function n(t){let n={};return t?.forEach&&t.forEach((t,r)=>{e(n,r.toLowerCase(),t)}),n}function r(e){if(!e)return null;let t=e.headers?.get?.(`x-rari-proxy-rewrite`);return t?{continue:!1,rewrite:t}:null}function i(e){if(!e||e.status==null)return null;let t=e.headers?.get?.(`location`);return t&&e.status>=300&&e.status<400?{continue:!1,redirect:{destination:t,permanent:e.status===301||e.status===308}}:null}function a(e){let{requestHeaders:n,responseHeaders:r}=t(e.headers);return{continue:!0,requestHeaders:n,responseHeaders:r}}async function o(e){let t=n(e.headers),r;try{e.text&&typeof e.text==`function`?r=await e.text():e.body!=null&&typeof e.body==`string`?r=e.body:e.body!=null&&console.warn(`[rari] Proxy: Response body is not extractable as text`)}catch(e){console.error(`[rari] Proxy: Failed to extract response body:`,e)}return{continue:!1,response:{status:e.status??200,headers:t,body:r}}}async function s(e){return e?r(e)||i(e)||(e.headers?.get?.(`x-rari-proxy-continue`)===`true`?a(e):e.status==null?{continue:!0}:await o(e)):{continue:!0}}async function c(e,t){try{let n=await import(e);if(!n||!n.proxy)return console.error(`[rari] Proxy: proxy function not found in module`),!1;let{RariRequest:r}=await import(t);return globalThis[`~rariExecuteProxy`]=async function(e){try{let t=new r(e.url,{method:e.method,headers:new Headers(e.headers)}),i=[],a=await n.proxy(t,{waitUntil:e=>{e.catch(()=>{}),i.push(e)}});return i.length>0&&Promise.allSettled(i).then(e=>{e.forEach((e,t)=>{e.status===`rejected`&&console.error(`[rari] Proxy: waitUntil promise ${t} failed:`,e.reason)})}),await s(a)}catch(e){return console.error(`[rari] Proxy: Proxy execution error:`,e),{continue:!0}}},!0}catch(e){return console.error(`[rari] Proxy: Failed to initialize proxy executor:`,e),!1}}export{c as initializeProxyExecutor};
@@ -1,4 +1,4 @@
1
- import{a as e,i as t,n,o as r,r as i,t as a}from"./utils-DtilLmFs-CiitZqwE.mjs";import{existsSync as o,readFileSync as s,writeFileSync as c}from"node:fs";import{join as l}from"node:path";import u from"node:process";import{styleText as d}from"node:util";function f(){let r=u.cwd();e(`Creating Railway deployment configuration...`),t(r,{providerName:`Railway`,deployScript:`echo "Push to GitHub and connect to Railway to deploy"`,startScript:`rari start`,dependency:n()}),p(r),a(r,`Railway`,`.railway`),m(r),h()}function p(e){i(e,`railway.toml`,`[build]
1
+ import{a as e,i as t,n,o as r,r as i,t as a}from"./utils-CW4FEV95-DI7wf2Fu.mjs";import{existsSync as o,readFileSync as s,writeFileSync as c}from"node:fs";import{join as l}from"node:path";import u from"node:process";import{styleText as d}from"node:util";function f(){let r=u.cwd();e(`Creating Railway deployment configuration...`),t(r,{providerName:`Railway`,deployScript:`echo "Push to GitHub and connect to Railway to deploy"`,startScript:`rari start`,dependency:a()}),p(r),n(r,`Railway`,`.railway`),m(r),h()}function p(e){i(e,`railway.toml`,`[build]
2
2
  builder = "RAILPACK"
3
3
 
4
4
  [deploy]
@@ -0,0 +1 @@
1
+ function e(){return globalThis}function t(){let t=e();return t[`~rari`]??={},t[`~rari`]}function n(){let t=e();return t[`~clientComponents`]??={},t[`~clientComponents`]}function r(){let t=e();return t[`~clientComponentPaths`]??={},t[`~clientComponentPaths`]}function i(){let t=e();return t[`~clientComponentNames`]??={},t[`~clientComponentNames`]}function a(){return typeof window>`u`?null:window}function o(){let e=a();return e?(e[`~rari`]??=t(),e[`~rari`]):null}export{e as a,t as i,r as n,o,n as r,i as t};
@@ -0,0 +1 @@
1
+ const e=/\.(?:tsx?|jsx?)$/,t=/^[A-Z]:\\/i,n=/\\/g,r=/[/\\]/,i=/\/$/,a=/^src\//,o=/^file:\/\//,s=/^https?:\/\//,c={AMPERSAND:/&/g,LT:/</g,GT:/>/g,QUOTE:/"/g,APOS:/'/g},l=/[^\w/-]/g,u=/export\s+(?:function|const|class)\s+(\w+)/,d=/export\s+(?:default\s+)?(?:async\s+)?(?:function|class)[\s{(]/,f=/export\s+default\s+(?:(?:async\s+)?\(|(?:async\s+)?[a-zA-Z_$][\w$]*\s*=>)/,p=/export\s+(?:const|let|var)\s+[a-zA-Z_$][\w$]*(?:\s*:[^;]*[^;=\s])?\s*=\s*(?:async\s+)?(?:function[\s*(]|\([^)]*\)\s*=>|[a-zA-Z_$][\w$]*\s*=>)/,m=/\.[^.]*$/,h=/['"]/g;export{d as a,o as c,r as d,i as f,t as g,e as h,f as i,c as l,a as m,l as n,u as o,h as p,p as r,m as s,n as t,s as u};
@@ -1,4 +1,4 @@
1
- import{a as e,i as t,n,o as r,r as i,t as a}from"./utils-DtilLmFs-CiitZqwE.mjs";import{existsSync as o,readFileSync as s,writeFileSync as c}from"node:fs";import{join as l}from"node:path";import u from"node:process";import{styleText as d}from"node:util";function f(){let r=u.cwd();e(`Creating Render deployment configuration...`),t(r,{providerName:`Render`,deployScript:`echo "Push to GitHub and connect to Render to deploy"`,startScript:`rari start`,dependency:n()}),p(r),a(r,`Render`,`.render`),m(r),h()}function p(e){i(e,`render.yaml`,`services:
1
+ import{a as e,i as t,n,o as r,r as i,t as a}from"./utils-CW4FEV95-DI7wf2Fu.mjs";import{existsSync as o,readFileSync as s,writeFileSync as c}from"node:fs";import{join as l}from"node:path";import u from"node:process";import{styleText as d}from"node:util";function f(){let r=u.cwd();e(`Creating Render deployment configuration...`),t(r,{providerName:`Render`,deployScript:`echo "Push to GitHub and connect to Render to deploy"`,startScript:`rari start`,dependency:a()}),p(r),n(r,`Render`,`.render`),m(r),h()}function p(e){i(e,`render.yaml`,`services:
2
2
  - type: web
3
3
  name: rari-app
4
4
  runtime: node
@@ -0,0 +1 @@
1
+ import{createContext as e,use as t,useEffect as n,useMemo as r,useRef as i,useState as a}from"react";import{jsx as o}from"react/jsx-runtime";let s=null;function c(){return s}function l(e){if(typeof window>`u`){console.warn(`[rari] Router cannot register navigate in non-browser environment`);return}s&&typeof process<`u`&&process.env.NODE_ENV!==`production`&&console.warn(`[rari] Router: registerNavigate called multiple times, overwriting existing navigate function`,{previous:s,new:e}),s=e,window.dispatchEvent(new CustomEvent(`rari:register-navigate`,{detail:{navigate:e}}))}function u(){if(typeof window>`u`){console.warn(`[rari] Router cannot deregister navigate in non-browser environment`);return}s=null,window.dispatchEvent(new CustomEvent(`rari:deregister-navigate`))}async function d(e,t){if(typeof window>`u`){console.warn(`[rari] Router cannot navigate in non-browser environment`);return}if(!s){console.warn(`[rari] Router not initialized, falling back to window.location`),t?.replace?window.location.replace(e):window.location.href=e;return}return s(e,t)}const f=e(null);function p({children:e,initialPathname:t}){let[s,l]=a(t),[u,d]=a(()=>typeof window<`u`?new URLSearchParams(window.location.search):new URLSearchParams),p=i(null);n(()=>{let e=e=>{let t=e.detail;t?.to&&(l(t.to),d(new URLSearchParams(window.location.search)))};return window.addEventListener(`rari:navigate`,e),()=>{window.removeEventListener(`rari:navigate`,e)}},[]),n(()=>{let e=c();e&&(p.current=e);let t=e=>{p.current=e.detail.navigate},n=()=>{p.current=null};return window.addEventListener(`rari:register-navigate`,t),window.addEventListener(`rari:deregister-navigate`,n),()=>{window.removeEventListener(`rari:register-navigate`,t),window.removeEventListener(`rari:deregister-navigate`,n)}},[]);let m=r(()=>({pathname:s,params:{},searchParams:u,push:async(e,t)=>{p.current?await p.current(e,t):(console.warn(`[rari] Router not ready, falling back to window.location`),window.location.href=e)},replace:async(e,t)=>{p.current?await p.current(e,{...t,replace:!0}):(console.warn(`[rari] Router not ready, falling back to window.location`),window.location.replace(e))},back:()=>{window.history.back()},forward:()=>{window.history.forward()},refresh:()=>{window.dispatchEvent(new CustomEvent(`rari:app-router-rerender`))},prefetch:async e=>{try{let t=new URL(e,window.location.origin);await fetch(t.pathname+t.search,{headers:{Accept:`text/x-component`},priority:`low`})}catch(e){console.warn(`[rari] Prefetch failed:`,e)}}}),[s,u]);return o(f,{value:m,children:e})}function m(){let e=t(f);if(!e)throw Error(`useRouter must be used within a RouterProvider`);return e}function h(){return m().pathname}function g(){return m().params}function _(){return m().searchParams}export{_ as a,l as c,m as i,g as n,u as o,h as r,d as s,p as t};
package/dist/router.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- //#region src/router/navigation-types.d.ts
1
+ //#region src/router/navigation/types.d.ts
2
2
  interface NavigationOptions {
3
3
  replace?: boolean;
4
4
  scroll?: boolean;
@@ -6,10 +6,10 @@ interface NavigationOptions {
6
6
  historyKey?: string;
7
7
  }
8
8
  //#endregion
9
- //#region src/router/navigate.d.ts
9
+ //#region src/router/navigation/navigate.d.ts
10
10
  declare function navigate(href: string, options?: NavigationOptions): Promise<void>;
11
11
  //#endregion
12
- //#region src/router/use-router.d.ts
12
+ //#region src/router/navigation/use-router.d.ts
13
13
  interface RouterContextValue {
14
14
  pathname: string;
15
15
  params: Record<string, string | string[]>;