rari 0.17.3 → 0.17.5

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 (32) hide show
  1. package/dist/cli.mjs +1 -1
  2. package/dist/{define-B5IGgRrU.mjs → define-CuBTL1jt.mjs} +1 -1
  3. package/dist/{execute-D_MjcLUi.mjs → execute-DJ7w3uhW.mjs} +1 -1
  4. package/dist/{feed-0uhXs0oQ.mjs → feed-CfjUO7Zz.mjs} +1 -1
  5. package/dist/{get-client-component-DFAmn8Ey.mjs → get-client-component-D2K213pV.mjs} +1 -1
  6. package/dist/image.mjs +1 -1
  7. package/dist/mdx/define.mjs +1 -1
  8. package/dist/mdx.mjs +1 -1
  9. package/dist/og.mjs +1 -1
  10. package/dist/{preload-modules-D_bnDKi8.mjs → preload-modules-BDQFWAlZ.mjs} +1 -1
  11. package/dist/proxy/executor.mjs +1 -1
  12. package/dist/react-helpers-duOBWuYF.mjs +1 -0
  13. package/dist/{robots-D3a0R_Ni.mjs → robots-C4JcczMZ.mjs} +1 -1
  14. package/dist/{route-cache-Cgh5HhiB.mjs → route-cache-D2iIKQIU.mjs} +1 -1
  15. package/dist/{router-6mdxF_x7.mjs → router-Cc9lVbtA.mjs} +1 -1
  16. package/dist/router.mjs +1 -1
  17. package/dist/{rsc-vite-build-Btih-0Tu.mjs → rsc-vite-build-Cyc5ad0S.mjs} +1 -1
  18. package/dist/runtime/AppRouterProvider.d.mts +2 -0
  19. package/dist/runtime/AppRouterProvider.mjs +1 -1
  20. package/dist/runtime/ClientRouter.mjs +4 -4
  21. package/dist/runtime/ErrorBoundaryWrapper.mjs +1 -1
  22. package/dist/runtime/action-flight-refresh.mjs +1 -1
  23. package/dist/runtime/call-server.mjs +1 -1
  24. package/dist/runtime/entry-client.mjs +2 -2
  25. package/dist/runtime/merge-flight-refresh.mjs +1 -1
  26. package/dist/runtime/rsc-client-runtime.mjs +1 -1
  27. package/dist/{sitemap-WDyhpXk3.mjs → sitemap-BcUkIffd.mjs} +1 -1
  28. package/dist/type-guards-BLY2PlGR.mjs +1 -0
  29. package/dist/vite.mjs +18 -18
  30. package/package.json +9 -9
  31. package/dist/react-helpers-BKmKvCbj.mjs +0 -1
  32. package/dist/type-guards-BozK2q2n.mjs +0 -1
package/dist/cli.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import{b as e,u as t,v as n,y as r}from"./type-guards-BozK2q2n.mjs";import{n as i,t as a}from"./dist-paths-C4EV064W.mjs";import{getBinaryPath as o,getInstallationInstructions as s}from"./platform.mjs";import{spawn as c}from"node:child_process";import{existsSync as l,readFileSync as u,readdirSync as d,realpathSync as f,rmSync as p}from"node:fs";import{basename as m,dirname as h,isAbsolute as g,join as _,resolve as v}from"node:path";import y from"node:process";import{fileURLToPath as b}from"node:url";import{once as ee}from"node:events";import{parseArgs as x,styleText as S}from"node:util";function C(e){console.warn(`${S(`blue`,`info`)} ${e}`)}function w(e){console.warn(`${S(`green`,`✓`)} ${e}`)}function T(e){console.error(`${S(`red`,`✗`)} ${e}`)}function E(e){console.warn(`${S(`yellow`,`⚠`)} ${e}`)}const te=[`vite.config.ts`];function D(e,t=`build`){let n=/(?:^|[,{\s])defaultPackage\s*:\s*['"]([^'"]+)['"]/.exec(e);if(n?.[1]!=null&&n[1]!==``)return n[1];let r=/(?:^|[,{\s])defaultPackage\s*:\s*\{([^}]*)\}/.exec(e);if(r?.[1]==null)return null;let i=RegExp(`(?:^|[,\\s])${t}\\s*:\\s*['"]([^'"]+)['"]`).exec(r[1])?.[1];return i!=null&&i!==``?i:null}function O(e){let t=/(?:^|[,{\s])outDir\s*:\s*['"]([^'"]+)['"]/.exec(e)?.[1];return t!=null&&t!==``?t:null}function k(e){let t=/(?:^|[,{\s])root\s*:\s*['"]([^'"]+)['"]/.exec(e)?.[1];return t!=null&&t!==``?t:null}function A(e){for(let t of te){let n=v(e,t);if(l(n))try{return u(n,`utf8`)}catch{return null}}return null}function j(e,t){return g(t)?t:v(e,t)}function M(e,t){let n=t==null?null:k(t);return n==null||n===``?e:j(e,n)}function N(e,t=`vp`,n=`build`){if(t!==`vp`)return e;let r=A(e);if(r==null)return e;let i=D(r,n);if(i==null||i===``)return e;let a=v(e,i);return l(a)?a:e}function P(e){let t=A(e),n=M(e,t),r=t==null?null:O(t);return r==null||r===``?v(n,a):j(n,r)}function ne(e){return m(e)===`client`?h(e):e}function F(e){let t=P(e),n=[_(ne(t),`server`,`image.json`),_(t,`server`,`image.json`),_(e,i,`server`,`image.json`)];for(let e of n)if(l(e))return e;let r;try{r=d(e)}catch{return null}for(let t of r){if(t===`node_modules`||t===`dist`||t.startsWith(`.`))continue;let n=_(e,t,`server`,`image.json`);if(l(n))return n}return null}function I(e,t){let r=h(e),i=h(r),a=M(t,A(t)),o=n(u(e,`utf8`))?.outDir;return typeof o==`string`&&o!==``?g(o)?o:v(a,o):_(i,`client`)}let L=null;function R(e){let t=l(e)?new Set(z(e)):/* @__PURE__ */ 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`:re(e)}function z(e){try{return d(e)}catch{return[]}}function re(e){try{let t=v(e,`package.json`);if(!l(t))return null;let i=n(u(t,`utf-8`));return i?r(i):null}catch{}return null}function ie(t){try{let r=v(t,`package.json`);if(!l(r))return null;let i=n(u(r,`utf-8`));return i?e(i):null}catch{}return null}function ae(e){let t=e,n=null,r=null;for(;t!==v(t,`..`)&&(n??=R(t),r??=ie(t),!(n&&r));)t=v(t,`..`);return{cwd:e,packageManager:n??`npm`,viteBin:r??`vite`}}function B(){let e=y.cwd();return L?.cwd===e||(L=ae(e)),L}function oe(){return B().packageManager}function V(){let e=B().packageManager,t=y.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`;case`npm`:return t?`npx.cmd`:`npx`;default:return t?`npx.cmd`:`npx`}}function H(e,t=y.cwd()){let n=y.platform===`win32`,r=t;for(;r!==v(r,`..`);){let t=v(r,`node_modules`,`.bin`),i=n?[v(t,`${e}.cmd`),v(t,`${e}.exe`),v(t,e)]:[v(t,e)];for(let e of i)if(l(e))return e;r=v(r,`..`)}return null}function U(e,t,n={}){let r=y.platform===`win32`;if(e===`npx`){let e=V();if(e.includes(`bun`))return c(r?`bunx.cmd`:`bunx`,t,{...n,shell:r});if(e.includes(`pnpm`))return c(e,[`exec`,...t],{...n,shell:r});if(e.includes(`yarn`)){let[i,...a]=t,o=i===`vp`?[`dlx`,`-p`,`vite-plus`,`vp`,...a]:[`dlx`,...t];return c(e,o,{...n,shell:r})}}return r&&e===`npx`?c(`npx.cmd`,t,{...n,shell:!0}):c(e,t,n)}function W(e,t,n={}){let r=H(e);if(r!=null&&r!==``){let e=y.platform===`win32`&&r.endsWith(`.cmd`);return c(r,t,e?{...n,shell:!0}:n)}return U(`npx`,[e,...t],n)}async function G(e,t={}){try{let[t]=await ee(e,`close`);return t}catch(e){if(t.tolerateErrors)return E(K(e)),1;throw e}}function K(e){if(t(e))return e.message;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function se(){let e=v(y.cwd(),`.env`);l(e)&&y.loadEnvFile(e)}function ce(e){let{values:t,positionals:n}=x({args:e,options:{help:{type:`boolean`,short:`h`,default:!1}},allowPositionals:!0,strict:!1});if(t.help===!0)return{command:`help`,args:[]};let[r=`help`,...i]=n;return{command:r,args:i}}function q(){return y.env.RAILWAY_ENVIRONMENT!=null&&y.env.RAILWAY_ENVIRONMENT!==``||y.env.RAILWAY_PROJECT_ID!=null&&y.env.RAILWAY_PROJECT_ID!==``||y.env.RAILWAY_SERVICE_ID!=null&&y.env.RAILWAY_SERVICE_ID!==``}function J(){return y.env.RENDER!=null&&y.env.RENDER!==``||y.env.RENDER_SERVICE_ID!=null&&y.env.RENDER_SERVICE_ID!==``||y.env.RENDER_SERVICE_NAME!=null&&y.env.RENDER_SERVICE_NAME!==``}function Y(){return q()||J()}function X(){return q()?`Railway`:J()?`Render`:`local`}function Z(){return{port:y.env.PORT!=null&&y.env.PORT!==``?y.env.PORT:y.env.RSC_PORT!=null&&y.env.RSC_PORT!==``?y.env.RSC_PORT:`3000`,mode:y.env.NODE_ENV!=null&&y.env.NODE_ENV!==``?y.env.NODE_ENV:`production`,host:Y()?`0.0.0.0`:`127.0.0.1`}}async function Q(){$();let e=B().viteBin;C(`Type checking...`);let t=await G(W(`tsc`,[],{stdio:`inherit`,cwd:y.cwd()}));if(t===0)w(`Type check passed`);else throw T(`Type check failed with code ${t}`),Error(`Type check failed with code ${t}`);C(`Building for production...`);let n=await G(W(e,[`build`],{stdio:`inherit`,cwd:y.cwd()}));if(n===0)w(`Build complete`);else throw T(`Build failed with code ${n}`),Error(`Build failed with code ${n}`);await le()}async function le(){let e=y.cwd(),{viteBin:t}=B(),r=N(e,t),i=F(r);if(i==null)return;let a=I(i,r),s=h(i),d=`assets`;try{let e=n(u(i,`utf-8`));e&&typeof e.assetsDir==`string`&&e.assetsDir.length>0&&(d=e.assetsDir.replaceAll(/^\/+|\/+$/g,``))}catch{}let f=v(r,`public`),p=v(a,d),m=v(s,`static-image-sources.json`);if(l(f)||l(p)||l(m))try{let e=o(),t=await G(c(e,[`optimize-images`,`--config`,i],{stdio:`inherit`,cwd:r,shell:!1}),{tolerateErrors:!0});t!==0&&E(`Image pre-optimization exited with code ${t}`)}catch(e){E(`Could not pre-optimize images: ${K(e)}`)}}async function ue(){let e=B().viteBin,t=v(y.cwd(),`dist`);if(!l(t)){C(`First run detected - building project...`);let t=await G(W(e,[`build`,`--mode`,`development`],{stdio:`inherit`,cwd:y.cwd()}));if(t===0)w(`Initial build complete`);else throw T(`Build failed with code ${t}`),Error(`Build failed with code ${t}`)}C(`Starting Vite${e===`vp`?`+`:``} dev server...`);let n=W(e,[`dev`],{stdio:`inherit`,cwd:y.cwd()}),r=()=>{C(`Shutting down dev server...`),n.kill(`SIGTERM`)};return y.on(`SIGINT`,r),y.on(`SIGTERM`,r),n.on(`error`,e=>{T(`Failed to start Vite: ${e.message}`),y.exit(1)}),n.on(`exit`,e=>{e!==0&&e!==null&&(T(`Vite exited with code ${e}`),y.exit(e))}),new Promise(()=>{})}async function de(){let e;try{e=o()}catch{T(`Failed to obtain rari binary`),T(s()),y.exit(1)}let{port:t,mode:n,host:r}=Z();if(Y()){let i=X();C(`${i} environment detected`),C(`Starting rari server for ${i} deployment...`),C(`Mode: ${n}, Host: ${r}, Port: ${t}`),C(`using binary: ${e}`)}let i=[`--mode`,n,`--port`,t,`--host`,r],a=y.platform!==`win32`&&y.stdin.isTTY,l=c(e,i,{stdio:`inherit`,cwd:y.cwd(),detached:a,env:{...y.env,RUST_LOG:y.env.RUST_LOG!=null&&y.env.RUST_LOG!==``?y.env.RUST_LOG:`error`}}),u=!1,d,f=()=>{u||(u=!0,C(`shutting down...`),l.kill(`SIGTERM`),d=setTimeout(()=>{l.kill(`SIGKILL`),y.exit(1)},5e3),d.unref())};return y.on(`SIGINT`,f),y.on(`SIGTERM`,f),y.on(`exit`,()=>{try{l.kill(`SIGKILL`)}catch{}}),l.on(`error`,e=>{T(`Failed to start rari server: ${e.message}`),e.message.includes(`ENOENT`)&&T(`Binary not found. Please ensure rari is properly installed.`),y.exit(1)}),l.on(`exit`,(e,t)=>{d&&clearTimeout(d),t!=null&&t!==``?(u&&(C(`server stopped by signal ${t}`),y.exit(0)),T(`server stopped unexpectedly by signal ${t}`),y.exit(1)):e===0?(w(`server stopped successfully`),y.exit(0)):(T(`server exited with code ${e}`),y.exit(e!=null&&e!==0?e:1))}),new Promise(()=>{})}async function fe(){C(`Setting up Railway deployment...`),Y()&&(T(`Already running in ${X()} environment. Use "rari start" instead.`),y.exit(1));let{createRailwayDeployment:e}=await import(`./railway-CE3nqaKt.mjs`);e()}async function pe(){C(`Setting up Render deployment...`),Y()&&(T(`Already running in ${X()} environment. Use "rari start" instead.`),y.exit(1));let{createRenderDeployment:e}=await import(`./render-D0eMtn5L.mjs`);e()}function $(){let e=v(y.cwd(),`dist`);l(e)?(C(`Cleaning dist folder...`),p(e,{recursive:!0,force:!0}),w(`Cleaned dist folder`)):C(`No dist folder to clean`)}function me(){console.warn(`${S(`bold`,`rari CLI`)}
1
+ import{b as e,d as t,x as n,y as r}from"./type-guards-BLY2PlGR.mjs";import{n as i,t as a}from"./dist-paths-C4EV064W.mjs";import{getBinaryPath as o,getInstallationInstructions as s}from"./platform.mjs";import{spawn as c}from"node:child_process";import{existsSync as l,readFileSync as u,readdirSync as d,realpathSync as f,rmSync as p}from"node:fs";import{basename as m,dirname as h,isAbsolute as g,join as _,resolve as v}from"node:path";import y from"node:process";import{fileURLToPath as b}from"node:url";import{once as ee}from"node:events";import{parseArgs as x,styleText as S}from"node:util";function C(e){console.warn(`${S(`blue`,`info`)} ${e}`)}function w(e){console.warn(`${S(`green`,`✓`)} ${e}`)}function T(e){console.error(`${S(`red`,`✗`)} ${e}`)}function E(e){console.warn(`${S(`yellow`,`⚠`)} ${e}`)}const te=[`vite.config.ts`];function D(e,t=`build`){let n=/(?:^|[,{\s])defaultPackage\s*:\s*['"]([^'"]+)['"]/.exec(e);if(n?.[1]!=null&&n[1]!==``)return n[1];let r=/(?:^|[,{\s])defaultPackage\s*:\s*\{([^}]*)\}/.exec(e);if(r?.[1]==null)return null;let i=RegExp(`(?:^|[,\\s])${t}\\s*:\\s*['"]([^'"]+)['"]`).exec(r[1])?.[1];return i!=null&&i!==``?i:null}function O(e){let t=/(?:^|[,{\s])outDir\s*:\s*['"]([^'"]+)['"]/.exec(e)?.[1];return t!=null&&t!==``?t:null}function k(e){let t=/(?:^|[,{\s])root\s*:\s*['"]([^'"]+)['"]/.exec(e)?.[1];return t!=null&&t!==``?t:null}function A(e){for(let t of te){let n=v(e,t);if(l(n))try{return u(n,`utf8`)}catch{return null}}return null}function j(e,t){return g(t)?t:v(e,t)}function M(e,t){let n=t==null?null:k(t);return n==null||n===``?e:j(e,n)}function N(e,t=`vp`,n=`build`){if(t!==`vp`)return e;let r=A(e);if(r==null)return e;let i=D(r,n);if(i==null||i===``)return e;let a=v(e,i);return l(a)?a:e}function P(e){let t=A(e),n=M(e,t),r=t==null?null:O(t);return r==null||r===``?v(n,a):j(n,r)}function ne(e){return m(e)===`client`?h(e):e}function F(e){let t=P(e),n=[_(ne(t),`server`,`image.json`),_(t,`server`,`image.json`),_(e,i,`server`,`image.json`)];for(let e of n)if(l(e))return e;let r;try{r=d(e)}catch{return null}for(let t of r){if(t===`node_modules`||t===`dist`||t.startsWith(`.`))continue;let n=_(e,t,`server`,`image.json`);if(l(n))return n}return null}function I(e,t){let n=h(e),i=h(n),a=M(t,A(t)),o=r(u(e,`utf8`))?.outDir;return typeof o==`string`&&o!==``?g(o)?o:v(a,o):_(i,`client`)}let L=null;function R(e){let t=l(e)?new Set(z(e)):/* @__PURE__ */ 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`:re(e)}function z(e){try{return d(e)}catch{return[]}}function re(t){try{let n=v(t,`package.json`);if(!l(n))return null;let i=r(u(n,`utf-8`));return i?e(i):null}catch{}return null}function ie(e){try{let t=v(e,`package.json`);if(!l(t))return null;let i=r(u(t,`utf-8`));return i?n(i):null}catch{}return null}function ae(e){let t=e,n=null,r=null;for(;t!==v(t,`..`)&&(n??=R(t),r??=ie(t),!(n&&r));)t=v(t,`..`);return{cwd:e,packageManager:n??`npm`,viteBin:r??`vite`}}function B(){let e=y.cwd();return L?.cwd===e||(L=ae(e)),L}function oe(){return B().packageManager}function V(){let e=B().packageManager,t=y.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`;case`npm`:return t?`npx.cmd`:`npx`;default:return t?`npx.cmd`:`npx`}}function H(e,t=y.cwd()){let n=y.platform===`win32`,r=t;for(;r!==v(r,`..`);){let t=v(r,`node_modules`,`.bin`),i=n?[v(t,`${e}.cmd`),v(t,`${e}.exe`),v(t,e)]:[v(t,e)];for(let e of i)if(l(e))return e;r=v(r,`..`)}return null}function U(e,t,n={}){let r=y.platform===`win32`;if(e===`npx`){let e=V();if(e.includes(`bun`))return c(r?`bunx.cmd`:`bunx`,t,{...n,shell:r});if(e.includes(`pnpm`))return c(e,[`exec`,...t],{...n,shell:r});if(e.includes(`yarn`)){let[i,...a]=t,o=i===`vp`?[`dlx`,`-p`,`vite-plus`,`vp`,...a]:[`dlx`,...t];return c(e,o,{...n,shell:r})}}return r&&e===`npx`?c(`npx.cmd`,t,{...n,shell:!0}):c(e,t,n)}function W(e,t,n={}){let r=H(e);if(r!=null&&r!==``){let e=y.platform===`win32`&&r.endsWith(`.cmd`);return c(r,t,e?{...n,shell:!0}:n)}return U(`npx`,[e,...t],n)}async function G(e,t={}){try{let[t]=await ee(e,`close`);return t}catch(e){if(t.tolerateErrors)return E(K(e)),1;throw e}}function K(e){if(t(e))return e.message;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function se(){let e=v(y.cwd(),`.env`);l(e)&&y.loadEnvFile(e)}function ce(e){let{values:t,positionals:n}=x({args:e,options:{help:{type:`boolean`,short:`h`,default:!1}},allowPositionals:!0,strict:!1});if(t.help===!0)return{command:`help`,args:[]};let[r=`help`,...i]=n;return{command:r,args:i}}function q(){return y.env.RAILWAY_ENVIRONMENT!=null&&y.env.RAILWAY_ENVIRONMENT!==``||y.env.RAILWAY_PROJECT_ID!=null&&y.env.RAILWAY_PROJECT_ID!==``||y.env.RAILWAY_SERVICE_ID!=null&&y.env.RAILWAY_SERVICE_ID!==``}function J(){return y.env.RENDER!=null&&y.env.RENDER!==``||y.env.RENDER_SERVICE_ID!=null&&y.env.RENDER_SERVICE_ID!==``||y.env.RENDER_SERVICE_NAME!=null&&y.env.RENDER_SERVICE_NAME!==``}function Y(){return q()||J()}function X(){return q()?`Railway`:J()?`Render`:`local`}function Z(){return{port:y.env.PORT!=null&&y.env.PORT!==``?y.env.PORT:y.env.RSC_PORT!=null&&y.env.RSC_PORT!==``?y.env.RSC_PORT:`3000`,mode:y.env.NODE_ENV!=null&&y.env.NODE_ENV!==``?y.env.NODE_ENV:`production`,host:Y()?`0.0.0.0`:`127.0.0.1`}}async function Q(){$();let e=B().viteBin;C(`Type checking...`);let t=await G(W(`tsc`,[],{stdio:`inherit`,cwd:y.cwd()}));if(t===0)w(`Type check passed`);else throw T(`Type check failed with code ${t}`),Error(`Type check failed with code ${t}`);C(`Building for production...`);let n=await G(W(e,[`build`],{stdio:`inherit`,cwd:y.cwd()}));if(n===0)w(`Build complete`);else throw T(`Build failed with code ${n}`),Error(`Build failed with code ${n}`);await le()}async function le(){let e=y.cwd(),{viteBin:t}=B(),n=N(e,t),i=F(n);if(i==null)return;let a=I(i,n),s=h(i),d=`assets`;try{let e=r(u(i,`utf-8`));e&&typeof e.assetsDir==`string`&&e.assetsDir.length>0&&(d=e.assetsDir.replaceAll(/^\/+|\/+$/g,``))}catch{}let f=v(n,`public`),p=v(a,d),m=v(s,`static-image-sources.json`);if(l(f)||l(p)||l(m))try{let e=o(),t=await G(c(e,[`optimize-images`,`--config`,i],{stdio:`inherit`,cwd:n,shell:!1}),{tolerateErrors:!0});t!==0&&E(`Image pre-optimization exited with code ${t}`)}catch(e){E(`Could not pre-optimize images: ${K(e)}`)}}async function ue(){let e=B().viteBin,t=v(y.cwd(),`dist`);if(!l(t)){C(`First run detected - building project...`);let t=await G(W(e,[`build`,`--mode`,`development`],{stdio:`inherit`,cwd:y.cwd()}));if(t===0)w(`Initial build complete`);else throw T(`Build failed with code ${t}`),Error(`Build failed with code ${t}`)}C(`Starting Vite${e===`vp`?`+`:``} dev server...`);let n=W(e,[`dev`],{stdio:`inherit`,cwd:y.cwd()}),r=()=>{C(`Shutting down dev server...`),n.kill(`SIGTERM`)};return y.on(`SIGINT`,r),y.on(`SIGTERM`,r),n.on(`error`,e=>{T(`Failed to start Vite: ${e.message}`),y.exit(1)}),n.on(`exit`,e=>{e!==0&&e!==null&&(T(`Vite exited with code ${e}`),y.exit(e))}),new Promise(()=>{})}async function de(){let e;try{e=o()}catch{T(`Failed to obtain rari binary`),T(s()),y.exit(1)}let{port:t,mode:n,host:r}=Z();if(Y()){let i=X();C(`${i} environment detected`),C(`Starting rari server for ${i} deployment...`),C(`Mode: ${n}, Host: ${r}, Port: ${t}`),C(`using binary: ${e}`)}let i=[`--mode`,n,`--port`,t,`--host`,r],a=y.platform!==`win32`&&y.stdin.isTTY,l=c(e,i,{stdio:`inherit`,cwd:y.cwd(),detached:a,env:{...y.env,RUST_LOG:y.env.RUST_LOG!=null&&y.env.RUST_LOG!==``?y.env.RUST_LOG:`error`}}),u=!1,d,f=()=>{u||(u=!0,C(`shutting down...`),l.kill(`SIGTERM`),d=setTimeout(()=>{l.kill(`SIGKILL`),y.exit(1)},5e3),d.unref())};return y.on(`SIGINT`,f),y.on(`SIGTERM`,f),y.on(`exit`,()=>{try{l.kill(`SIGKILL`)}catch{}}),l.on(`error`,e=>{T(`Failed to start rari server: ${e.message}`),e.message.includes(`ENOENT`)&&T(`Binary not found. Please ensure rari is properly installed.`),y.exit(1)}),l.on(`exit`,(e,t)=>{d&&clearTimeout(d),t!=null&&t!==``?(u&&(C(`server stopped by signal ${t}`),y.exit(0)),T(`server stopped unexpectedly by signal ${t}`),y.exit(1)):e===0?(w(`server stopped successfully`),y.exit(0)):(T(`server exited with code ${e}`),y.exit(e!=null&&e!==0?e:1))}),new Promise(()=>{})}async function fe(){C(`Setting up Railway deployment...`),Y()&&(T(`Already running in ${X()} environment. Use "rari start" instead.`),y.exit(1));let{createRailwayDeployment:e}=await import(`./railway-CE3nqaKt.mjs`);e()}async function pe(){C(`Setting up Render deployment...`),Y()&&(T(`Already running in ${X()} environment. Use "rari start" instead.`),y.exit(1));let{createRenderDeployment:e}=await import(`./render-D0eMtn5L.mjs`);e()}function $(){let e=v(y.cwd(),`dist`);l(e)?(C(`Cleaning dist folder...`),p(e,{recursive:!0,force:!0}),w(`Cleaned dist folder`)):C(`No dist folder to clean`)}function me(){console.warn(`${S(`bold`,`rari CLI`)}
2
2
 
3
3
  ${S(`bold`,`Usage:`)}
4
4
  ${S(`cyan`,`rari dev`)} Start the development server with Vite
@@ -1 +1 @@
1
- import{h as e}from"./type-guards-BozK2q2n.mjs";import{s as t}from"./regex-constants-DzXwNGh2.mjs";import{t as n}from"./names-CLmM0CPi.mjs";import{registerClientReference as r}from"./runtime/rsc-references.mjs";import{r as i}from"./rari-global-5vGzhToD.mjs";function a(e,n,a=`default`){let o=`${n}#${a}`;if(typeof globalThis<`u`){let r=i(),s=n.replace(t,``).split(`/`).pop(),c=s!=null&&s!==``?s:a,l={id:a==="default"?c:a,path:n,type:`client`,component:e,registered:!0};r[o]=l,r[c]=l,r[n]=l}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 r(s,n,a)}function o(e){let t={};for(let[n,{component:r,id:i,exportName:o=`default`}]of Object.entries(e))t[n]=a(r,i,o);return t}function s(t){return e(t)&&typeof t.id==`string`&&`component`in t}function c(e){return Array.isArray(e)?[...e]:Object.entries(e).map(([e,t])=>{if(s(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 l(e){let t=c(e);return e=>{let r={},i={},a=new Set(n(e));for(let e of t)if(a.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,...o(i)}}}export{l as t};
1
+ import{g as e}from"./type-guards-BLY2PlGR.mjs";import{s as t}from"./regex-constants-DzXwNGh2.mjs";import{t as n}from"./names-CLmM0CPi.mjs";import{registerClientReference as r}from"./runtime/rsc-references.mjs";import{r as i}from"./rari-global-5vGzhToD.mjs";function a(e,n,a=`default`){let o=`${n}#${a}`;if(typeof globalThis<`u`){let r=i(),s=n.replace(t,``).split(`/`).pop(),c=s!=null&&s!==``?s:a,l={id:a==="default"?c:a,path:n,type:`client`,component:e,registered:!0};r[o]=l,r[c]=l,r[n]=l}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 r(s,n,a)}function o(e){let t={};for(let[n,{component:r,id:i,exportName:o=`default`}]of Object.entries(e))t[n]=a(r,i,o);return t}function s(t){return e(t)&&typeof t.id==`string`&&`component`in t}function c(e){return Array.isArray(e)?[...e]:Object.entries(e).map(([e,t])=>{if(s(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 l(e){let t=c(e);return e=>{let r={},i={},a=new Set(n(e));for(let e of t)if(a.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,...o(i)}}}export{l as t};
@@ -1 +1 @@
1
- import{a as e,h as t}from"./type-guards-BozK2q2n.mjs";import{s as n,t as r,u as i}from"./rsc-vite-build-Btih-0Tu.mjs";import{promises as a}from"node:fs";import o from"node:path";import{pathToFileURL as s}from"node:url";import{randomUUID as c}from"node:crypto";const l=[`.ts`,`.tsx`,`.js`,`.jsx`,`.mjs`];async function u(t){let{appDir:n,staticFileName:r,dynamicBaseName:i,extensions:s=l,rethrowNonEnoent:c=!1}=t,u=o.join(n,r);try{return await a.access(u),{type:`static`,path:u}}catch(t){if(c&&e(t)!==`ENOENT`)throw t}for(let t of s){let r=o.join(n,`${i}${t}`);try{return await a.access(r),{type:`dynamic`,path:r}}catch(t){if(c&&e(t)!==`ENOENT`)throw t}}return null}function d(e,t){switch(e){case`ts`:return`ts`;case`tsx`:return`tsx`;case`js`:case`mjs`:return`js`;case`jsx`:return`jsx`;case`json`:if(t===`sitemap`)return`json`}throw Error(`Unsupported ${t} file extension: ".${e}". Allowed extensions are: ${t===`sitemap`?`.ts, .tsx, .js, .jsx, .mjs, .json`:`.ts, .tsx, .js, .jsx, .mjs`}`)}function f(e){let{name:t,virtualId:r,sourcePath:s,sourceCode:c,aliases:l={},projectRoot:u,kind:f}=e;return{name:t,resolveId(e,t){if(e===r)return e;if(Object.keys(l).length>0){let t=n(e,l,u);if(t!=null&&t!==``){let e=i(t);return e!=null&&e!==``?e:t}}if(e.startsWith(`.`)){let n=t==null||t===``||t.startsWith(`\0`)?s:t,r=o.resolve(o.dirname(n),e),a=i(r);return a!=null&&a!==``?a:r}return null},async load(e){if(e===r){let e=o.extname(s).slice(1);return{code:c,moduleType:d(e,f)}}if(e&&!e.startsWith(`\0`))try{return{code:await a.readFile(e,`utf-8`),moduleType:d(o.extname(e).slice(1),f)}}catch{return null}return null}}}function p(e){return e===`rari`||e.startsWith(`rari/`)}async function m(e){let{virtualId:t,sourcePath:n,sourceCode:i,aliases:l={},projectRoot:u,kind:d,pluginName:m,label:h}=e,g=await r({root:u,virtualId:t,external:p,plugins:[f({name:m,virtualId:t,sourcePath:n,sourceCode:i,aliases:l,projectRoot:u,kind:d})]});if(g==null)throw Error(`Failed to build ${h} module`);let _=o.join(u,`node_modules`,`.cache`,`rari-metadata`);await a.mkdir(_,{recursive:!0});let v=o.join(_,`${h}-${c()}.mjs`);await using y=new AsyncDisposableStack;return y.defer(async()=>{await a.rm(v,{force:!0})}),await a.writeFile(v,g.code,`utf8`),await import(s(v).href)}function h(e,n){if(!t(e))throw Error(`${n} file must export a default export (either an object or a function)`);let r=e.default;if(r==null)throw Error(`${n} file must export a default export (either an object or a function)`);return r}function g(e){return o.resolve(e,`..`,`..`)}export{u as i,g as n,h as r,m as t};
1
+ import{a as e,g as t}from"./type-guards-BLY2PlGR.mjs";import{s as n,t as r,u as i}from"./rsc-vite-build-Cyc5ad0S.mjs";import{promises as a}from"node:fs";import o from"node:path";import{pathToFileURL as s}from"node:url";import{randomUUID as c}from"node:crypto";const l=[`.ts`,`.tsx`,`.js`,`.jsx`,`.mjs`];async function u(t){let{appDir:n,staticFileName:r,dynamicBaseName:i,extensions:s=l,rethrowNonEnoent:c=!1}=t,u=o.join(n,r);try{return await a.access(u),{type:`static`,path:u}}catch(t){if(c&&e(t)!==`ENOENT`)throw t}for(let t of s){let r=o.join(n,`${i}${t}`);try{return await a.access(r),{type:`dynamic`,path:r}}catch(t){if(c&&e(t)!==`ENOENT`)throw t}}return null}function d(e,t){switch(e){case`ts`:return`ts`;case`tsx`:return`tsx`;case`js`:case`mjs`:return`js`;case`jsx`:return`jsx`;case`json`:if(t===`sitemap`)return`json`}throw Error(`Unsupported ${t} file extension: ".${e}". Allowed extensions are: ${t===`sitemap`?`.ts, .tsx, .js, .jsx, .mjs, .json`:`.ts, .tsx, .js, .jsx, .mjs`}`)}function f(e){let{name:t,virtualId:r,sourcePath:s,sourceCode:c,aliases:l={},projectRoot:u,kind:f}=e;return{name:t,resolveId(e,t){if(e===r)return e;if(Object.keys(l).length>0){let t=n(e,l,u);if(t!=null&&t!==``){let e=i(t);return e!=null&&e!==``?e:t}}if(e.startsWith(`.`)){let n=t==null||t===``||t.startsWith(`\0`)?s:t,r=o.resolve(o.dirname(n),e),a=i(r);return a!=null&&a!==``?a:r}return null},async load(e){if(e===r){let e=o.extname(s).slice(1);return{code:c,moduleType:d(e,f)}}if(e&&!e.startsWith(`\0`))try{return{code:await a.readFile(e,`utf-8`),moduleType:d(o.extname(e).slice(1),f)}}catch{return null}return null}}}function p(e){return e===`rari`||e.startsWith(`rari/`)}async function m(e){let{virtualId:t,sourcePath:n,sourceCode:i,aliases:l={},projectRoot:u,kind:d,pluginName:m,label:h}=e,g=await r({root:u,virtualId:t,external:p,plugins:[f({name:m,virtualId:t,sourcePath:n,sourceCode:i,aliases:l,projectRoot:u,kind:d})]});if(g==null)throw Error(`Failed to build ${h} module`);let _=o.join(u,`node_modules`,`.cache`,`rari-metadata`);await a.mkdir(_,{recursive:!0});let v=o.join(_,`${h}-${c()}.mjs`);await using y=new AsyncDisposableStack;return y.defer(async()=>{await a.rm(v,{force:!0})}),await a.writeFile(v,g.code,`utf8`),await import(s(v).href)}function h(e,n){if(!t(e))throw Error(`${n} file must export a default export (either an object or a function)`);let r=e.default;if(r==null)throw Error(`${n} file must export a default export (either an object or a function)`);return r}function g(e){return o.resolve(e,`..`,`..`)}export{u as i,g as n,h as r,m as t};
@@ -1,4 +1,4 @@
1
- import{h as e}from"./type-guards-BozK2q2n.mjs";import{t}from"./xml-DPsk9WTz.mjs";import{i as n,n as r,r as i,t as a}from"./execute-D_MjcLUi.mjs";import{promises as o}from"node:fs";import s from"node:path";function c(t){return e(t)&&typeof t.title==`string`&&typeof t.description==`string`&&typeof t.link==`string`&&Array.isArray(t.items)}async function l(e){if(typeof e==`function`){let t=e(),n=t instanceof Promise?await t:t;if(!c(n))throw Error(`Feed default export must resolve to a feed object`);return n}if(!c(e))throw Error(`Feed default export must be a feed object`);return e}function u(e){return(typeof e==`string`?new Date(e):e).toUTCString()}function d(e){return e==null||e===``?``:typeof e==`string`?` <dc:creator>${t(e)}</dc:creator>`:e.email!=null&&e.email!==``?` <author>${t(`${e.email} (${e.name})`)}</author>`:` <dc:creator>${t(e.name)}</dc:creator>`}function f(e){let n=[` <item>`,` <title>${t(e.title)}</title>`,` <link>${t(e.url)}</link>`];return e.description!=null&&e.description!==``&&n.push(` <description>${t(e.description)}</description>`),n.push(...p(e),...m(e),...h(e)),n.push(` </item>`),n.join(`
1
+ import{g as e}from"./type-guards-BLY2PlGR.mjs";import{t}from"./xml-DPsk9WTz.mjs";import{i as n,n as r,r as i,t as a}from"./execute-DJ7w3uhW.mjs";import{promises as o}from"node:fs";import s from"node:path";function c(t){return e(t)&&typeof t.title==`string`&&typeof t.description==`string`&&typeof t.link==`string`&&Array.isArray(t.items)}async function l(e){if(typeof e==`function`){let t=e(),n=t instanceof Promise?await t:t;if(!c(n))throw Error(`Feed default export must resolve to a feed object`);return n}if(!c(e))throw Error(`Feed default export must be a feed object`);return e}function u(e){return(typeof e==`string`?new Date(e):e).toUTCString()}function d(e){return e==null||e===``?``:typeof e==`string`?` <dc:creator>${t(e)}</dc:creator>`:e.email!=null&&e.email!==``?` <author>${t(`${e.email} (${e.name})`)}</author>`:` <dc:creator>${t(e.name)}</dc:creator>`}function f(e){let n=[` <item>`,` <title>${t(e.title)}</title>`,` <link>${t(e.url)}</link>`];return e.description!=null&&e.description!==``&&n.push(` <description>${t(e.description)}</description>`),n.push(...p(e),...m(e),...h(e)),n.push(` </item>`),n.join(`
2
2
  `)}function p(e){let t=[];e.content!=null&&e.content!==``&&t.push(` <content:encoded><![CDATA[${e.content.replace(/\]\]>/g,`]]]]><![CDATA[>`)}]]></content:encoded>`);let n=d(e.author);return n&&t.push(n),t}function m(e){let n=[];if(e.pubDate!=null&&n.push(` <pubDate>${u(e.pubDate)}</pubDate>`),n.push(` <guid isPermaLink="${e.guid!=null&&e.guid!==``?`false`:`true`}">${t(e.guid!=null&&e.guid!==``?e.guid:e.url)}</guid>`),e.categories)for(let r of e.categories)n.push(` <category>${t(r)}</category>`);return n}function h(e){if(!e.enclosure)return[];let n=[`url="${t(e.enclosure.url)}"`];return e.enclosure.length!==void 0&&n.push(`length="${e.enclosure.length}"`),n.push(`type="${t(e.enclosure.type!=null&&e.enclosure.type!==``?e.enclosure.type:`application/octet-stream`)}"`),[` <enclosure ${n.join(` `)} />`]}function g(e){let n=e.items.some(e=>e.content!=null&&e.content!==``),r=e.items.some(e=>{let t=e.author;return t==null||t===``?!1:typeof t==`string`||t.email==null||t.email===``}),i=[];n&&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>${t(e.title)}</title>`,` <link>${t(e.link)}</link>`,` <description>${t(e.description)}</description>`,` <atom:link href="${t(`${e.link.replace(/\/+$/,``)}/feed.xml`)}" rel="self" type="application/rss+xml" />`];e.language!=null&&e.language!==``&&a.push(` <language>${t(e.language)}</language>`),e.copyright!=null&&e.copyright!==``&&a.push(` <copyright>${t(e.copyright)}</copyright>`),e.lastBuildDate!=null&&a.push(` <lastBuildDate>${u(e.lastBuildDate)}</lastBuildDate>`),e.ttl!==void 0&&a.push(` <ttl>${e.ttl}</ttl>`),e.image&&(a.push(` <image>`),a.push(` <url>${t(e.image.url)}</url>`),a.push(` <title>${t(e.image.title)}</title>`),a.push(` <link>${t(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(f(t));return a.push(` </channel>`),a.push(`</rss>`),a.join(`
3
3
  `)}
4
4
  /* v8 ignore start - file system operations, better tested in integration/e2e */
@@ -1 +1 @@
1
- import{h as e,l as t,p as n,x as r}from"./type-guards-BozK2q2n.mjs";import{o as i}from"./path-CTEC1xmy.mjs";import{n as a,r as o,t as s}from"./rari-global-5vGzhToD.mjs";import{createElement as c}from"react";function l(e){return e.startsWith(`./`)?[e,e.slice(2)]:[e,`./${e}`]}function u(e){let t=i(e),n=/* @__PURE__ */ new Set([t]),r=t.indexOf(`/src/`);r!==-1&&n.add(t.slice(r+1));let a=t.indexOf(`/components/`);return a!==-1&&n.add(t.slice(a+1)),[...n]}function d(e,t){if(t!==void 0)return t;let n=e.exportName;if(n!=null&&n!==``)return n}function f(e,t){let n=i(e),r=i(t);return!!(n===r||r.includes(`/`)&&n.endsWith(`/${r}`)||n.includes(`/`)&&r.endsWith(`/${n}`))}function p(e,t,n){for(let r of u(e))for(let e of l(r)){let r=Object.values(n).find(t=>typeof t.path!=`string`||t.path===``?!1:f(t.path,e));if(r)return{info:r,exportName:d(r,t)}}return null}function m(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 h(e,t){return e.component==null?e.loadPromise?(await e.loadPromise,g(e,t)):e.loader?await m(e)==null?null:g(e,t):null:g(e,t)}function g(t,r){let i=t.component;if(i==null)return null;if(n(i))return i;if(!e(i))return null;if(r==null||r===``||r==="default")return i.default??i;if(r in i)return i[r];let a=i.default;return e(a)&&r in a?a[r]:null}function _(e){let t=i(e);return t===e?[t]:[t,e]}function v(e){let t=o(),n=a(),r=s(),c=i(e),l=y(e,t);if(l!=null)return l;let u=c.indexOf(`#`),d=u===-1?c:c.slice(0,u),f=u===-1?void 0:c.slice(u+1);return b(e,f,t)??x(e,d,f,t,n,r)??p(d,f,t)}function y(e,t){for(let n of _(e)){if(!(n in t))continue;let e=t[n],r=n.indexOf(`#`);return{info:e,exportName:d(e,r===-1?void 0:n.slice(r+1))}}return null}function b(e,t,n){for(let r of _(e)){let e=r.indexOf(`#`),i=e===-1?r:r.slice(0,e);if(i in n)return{info:n[i],exportName:d(n[i],t)}}return null}function x(e,t,n,r,a,o){let s=i(e)===e?[t]:[t,e.includes(`#`)?e.slice(0,e.indexOf(`#`)):e];for(let e of s){let t=S(e,n,r,a);if(t!=null)return t;let i=C(e,n,r,o);if(i!=null)return i}return null}function S(e,t,n,r){for(let i of l(e)){if(!(i in r))continue;let e=r[i];if(e!==``&&e in n)return{info:n[e],exportName:d(n[e],t)}}return null}function C(e,t,n,r){if(!(e in r))return null;let i=r[e];return i===``||!(i in n)?null:{info:n[i],exportName:d(n[i],t)}}function w(e){return e.component!=null||e.loader==null?e.loadPromise:e.loadError==null?e.loadPromise?e.loadPromise:m(e):Promise.reject(r(e.loadError))}function T(t,r,i){let a=d(t,i),o=g({...t,component:r},a);if(o==null)return e(r)&&(`default`in r||`__esModule`in r)?r:n(r)?{default:r,[a!=null&&a!==``?a:`default`]:r,__esModule:!0}:r;let s=a!=null&&a!==``?a:`default`;return{...e(r)?r:{},default:o,[s]:o,__esModule:!0}}function E(e,n,i,a){let o=d(e,a),s=o!=null&&o!==``?o:`default`,l=a=>{if(e.loadError!=null)throw r(e.loadError);if(e.component!=null){let r=g(e,o);if(r==null)throw Error(`[rari] Lazy component "${n}" loaded but export "${s}" is missing`);if(!t(r))throw Error(`[rari] Lazy component "${n}" export "${s}" is not a component`);return c(r,a)}throw i};return l.displayName=`Lazy(${e.displayName??e.exportName??n})`,{default:l,[s]:l,__esModule:!0}}function D(e){let t=v(e);if(!t)return import.meta.env.DEV&&console.warn(`[rari] __rari_rsc_require__: component "${e}" not found in registry`),{};let{info:n,exportName:r}=t;if(n.component!=null)return T(n,n.component,r);if(n.loader){if(n.loadError!=null)return E(n,e,Promise.resolve(),r);let t=w(n);if(t)return E(n,e,t,r)}return{}}async function O(e){let t=v(e);return t?h(t.info,t.exportName):null}function k(){if(typeof window>`u`)return;let e=e=>{let t=o(),n=i(e);return e in t?t[e]:n in t?t[n]:Object.values(t).find(t=>t.path===e||t.path===n)};Reflect.set(globalThis,`__rari_get_script_filename__`,t=>{let n=e(t)?.path??i(t),r=i(n);if(r.startsWith(`http://`)||r.startsWith(`https://`))return r;let a=r.indexOf(`/src/`);return a===-1?r.startsWith(`src/`)?`/${r}`:r.startsWith(`/`)?r:`/${r}`:r.slice(a)}),Reflect.set(globalThis,`__rari_chunk_load__`,async t=>{let n=e(t);if(n&&n.component==null&&n.loader!=null){let e=w(n);if(e)return e.then(()=>void 0)}return n?.loadPromise==null?Promise.resolve():n.loadPromise.then(()=>void 0)})}export{k as n,D as r,O as t};
1
+ import{S as e,g as t,m as n,u as r}from"./type-guards-BLY2PlGR.mjs";import{o as i}from"./path-CTEC1xmy.mjs";import{n as a,r as o,t as s}from"./rari-global-5vGzhToD.mjs";import{createElement as c}from"react";function l(e){return e.startsWith(`./`)?[e,e.slice(2)]:[e,`./${e}`]}function u(e){let t=i(e),n=/* @__PURE__ */ new Set([t]),r=t.indexOf(`/src/`);r!==-1&&n.add(t.slice(r+1));let a=t.indexOf(`/components/`);return a!==-1&&n.add(t.slice(a+1)),[...n]}function d(e,t){if(t!==void 0)return t;let n=e.exportName;if(n!=null&&n!==``)return n}function f(e,t){let n=i(e),r=i(t);return!!(n===r||r.includes(`/`)&&n.endsWith(`/${r}`)||n.includes(`/`)&&r.endsWith(`/${n}`))}function p(e,t,n){for(let r of u(e))for(let e of l(r)){let r=Object.values(n).find(t=>typeof t.path!=`string`||t.path===``?!1:f(t.path,e));if(r)return{info:r,exportName:d(r,t)}}return null}function m(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 h(e,t){return e.component==null?e.loadPromise?(await e.loadPromise,g(e,t)):e.loader?await m(e)==null?null:g(e,t):null:g(e,t)}function g(e,r){let i=e.component;if(i==null)return null;if(n(i))return i;if(!t(i))return null;if(r==null||r===``||r==="default")return i.default??i;if(r in i)return i[r];let a=i.default;return t(a)&&r in a?a[r]:null}function _(e){let t=i(e);return t===e?[t]:[t,e]}function v(e){let t=o(),n=a(),r=s(),c=i(e),l=y(e,t);if(l!=null)return l;let u=c.indexOf(`#`),d=u===-1?c:c.slice(0,u),f=u===-1?void 0:c.slice(u+1);return b(e,f,t)??x(e,d,f,t,n,r)??p(d,f,t)}function y(e,t){for(let n of _(e)){if(!(n in t))continue;let e=t[n],r=n.indexOf(`#`);return{info:e,exportName:d(e,r===-1?void 0:n.slice(r+1))}}return null}function b(e,t,n){for(let r of _(e)){let e=r.indexOf(`#`),i=e===-1?r:r.slice(0,e);if(i in n)return{info:n[i],exportName:d(n[i],t)}}return null}function x(e,t,n,r,a,o){let s=i(e)===e?[t]:[t,e.includes(`#`)?e.slice(0,e.indexOf(`#`)):e];for(let e of s){let t=S(e,n,r,a);if(t!=null)return t;let i=C(e,n,r,o);if(i!=null)return i}return null}function S(e,t,n,r){for(let i of l(e)){if(!(i in r))continue;let e=r[i];if(e!==``&&e in n)return{info:n[e],exportName:d(n[e],t)}}return null}function C(e,t,n,r){if(!(e in r))return null;let i=r[e];return i===``||!(i in n)?null:{info:n[i],exportName:d(n[i],t)}}function w(t){return t.component!=null||t.loader==null?t.loadPromise:t.loadError==null?t.loadPromise?t.loadPromise:m(t):Promise.reject(e(t.loadError))}function T(e,r,i){let a=d(e,i),o=g({...e,component:r},a);if(o==null)return t(r)&&(`default`in r||`__esModule`in r)?r:n(r)?{default:r,[a!=null&&a!==``?a:`default`]:r,__esModule:!0}:r;let s=a!=null&&a!==``?a:`default`;return{...t(r)?r:{},default:o,[s]:o,__esModule:!0}}function E(t,n,i,a){let o=d(t,a),s=o!=null&&o!==``?o:`default`,l=a=>{if(t.loadError!=null)throw e(t.loadError);if(t.component!=null){let e=g(t,o);if(e==null)throw Error(`[rari] Lazy component "${n}" loaded but export "${s}" is missing`);if(!r(e))throw Error(`[rari] Lazy component "${n}" export "${s}" is not a component`);return c(e,a)}throw i};return l.displayName=`Lazy(${t.displayName??t.exportName??n})`,{default:l,[s]:l,__esModule:!0}}function D(e){let t=v(e);if(!t)return import.meta.env.DEV&&console.warn(`[rari] __rari_rsc_require__: component "${e}" not found in registry`),{};let{info:n,exportName:r}=t;if(n.component!=null)return T(n,n.component,r);if(n.loader){if(n.loadError!=null)return E(n,e,Promise.resolve(),r);let t=w(n);if(t)return E(n,e,t,r)}return{}}async function O(e){let t=v(e);return t?h(t.info,t.exportName):null}function k(){if(typeof window>`u`)return;let e=e=>{let t=o(),n=i(e);return e in t?t[e]:n in t?t[n]:Object.values(t).find(t=>t.path===e||t.path===n)};Reflect.set(globalThis,`__rari_get_script_filename__`,t=>{let n=e(t)?.path??i(t),r=i(n);if(r.startsWith(`http://`)||r.startsWith(`https://`))return r;let a=r.indexOf(`/src/`);return a===-1?r.startsWith(`src/`)?`/${r}`:r.startsWith(`/`)?r:`/${r}`:r.slice(a)}),Reflect.set(globalThis,`__rari_chunk_load__`,async t=>{let n=e(t);if(n&&n.component==null&&n.loader!=null){let e=w(n);if(e)return e.then(()=>void 0)}return n?.loadPromise==null?Promise.resolve():n.loadPromise.then(()=>void 0)})}export{k as n,D as r,O as t};
package/dist/image.mjs CHANGED
@@ -1 +1 @@
1
- import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"./constants-CRK2JRKf.mjs";import{c as s}from"react/compiler-runtime";import{useEffect as c,useLayoutEffect as l,useRef as u,useState as d}from"react";import{jsx as f,jsxs as p}from"react/jsx-runtime";const m=Math.max(...i);function h(e){return Math.min(Math.max(e,1),m)}function g(e){let{fill:t,width:n,intrinsicWidth:r}=e;if(t)return{defaultWidth:m,widths:i};let a=n!=null&&n!==0?n:r!=null&&r!==0?r:void 0;if(a==null)return{defaultWidth:1920,widths:i};let o=h(a);return{defaultWidth:o,widths:[o]}}function _(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 v(e,t,n,r,i){return e==null?_(t,n,r,i):e({src:t,width:n,quality:r})}function y(e,t,n=!1){return e!=null&&e!==``?e:t||n?`100vw`:void 0}function b(e){let{link:n,finalSrc:r,defaultWidth:a,quality:o,sizes:s,loader:c,unoptimized:l,fill:u,shouldUseSrcSet:d}=e,f=d&&!l,p=y(s,f,u),m=c==null&&t.length===1&&t[0]===`avif`,h=m?`avif`:void 0;if(l){n.setAttribute(`href`,c==null?r:c({src:r,width:a,quality:o}));return}if(f){let e=i.map(e=>`${v(c,r,e,o,h)} ${e}w`).join(`, `);n.setAttribute(`href`,v(c,r,a,o,h)),n.setAttribute(`imagesrcset`,e),p!=null&&n.setAttribute(`imagesizes`,p),m&&n.setAttribute(`type`,`image/avif`);return}n.setAttribute(`href`,v(c,r,a,o)),p!=null&&n.setAttribute(`imagesizes`,p)}function x(e,t,n){if(e!=null&&e!==0)return e;if(!t&&n!=null&&n!==0)return n}function S(e){let{src:t,width:n,height:r,fill:i,placeholder:a,blurDataURL:o,loader:s}=e,c=typeof t==`string`?t:t.src,l=typeof t==`string`?void 0:t.width,u=typeof t==`string`?void 0:t.height,d=o!=null&&o!==``?o:typeof t==`string`?void 0:t.blurDataURL,f=d!=null&&d!==``?d:void 0,p=a===`blur`&&f==null?v(s,c,16,25,`jpeg`):void 0;return{imgSrc:c,imgWidth:x(n,i,l),imgHeight:x(r,i,u),inlineBlurDataURL:f,optimizerBlurUrl:p}}function C(e){return{position:`absolute`,inset:0,width:`100%`,height:`100%`,objectFit:e?.objectFit??`cover`}}function w(e){return{backgroundImage:`url("${e}")`,backgroundSize:`cover`,backgroundPosition:`center`,filter:`blur(20px)`,transition:`filter 0.3s ease-out`}}function ee(e){return e.complete&&e.naturalWidth>0}function te(e){let{style:t,fill:n,placeholder:r,imgBlurDataURL:i,blurComplete:a}=e,o=r===`blur`&&i!=null&&i!==``&&!a,s=r===`blur`&&a;return{...t,...n?C(t):null,...o?w(i):null,...s?{filter:`none`,transition:`filter 0.3s ease-out`}:null}}function ne(e,t,n,r,i){return n.map(n=>`${v(e,t,n,r,i)} ${n}w`).join(`, `)}function re(e){let{unoptimized:t,loader:n,finalSrc:r,width:i,quality:a}=e;return t?n==null?r:n({src:r,width:i,quality:a}):v(n,r,i,a)}function ie(e){if(!e.enabled)return;let t=document.createElement(`link`);return t.rel=`preload`,t.as=`image`,b({link:t,finalSrc:e.finalSrc,defaultWidth:e.defaultWidth,quality:e.quality,sizes:e.sizes,loader:e.loader,unoptimized:e.unoptimized,fill:e.fill,shouldUseSrcSet:e.shouldUseSrcSet}),document.head.appendChild(t),()=>{t.parentNode===document.head&&document.head.removeChild(t)}}function T(e,t,n){if(!t||e==null)return;let r=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&(n(),r.disconnect())},{rootMargin:`200px`});return r.observe(e),()=>{r.disconnect()}}function ae(e){let{imgElement:n,loader:r,finalSrc:i,widths:a,quality:o,sizes:s}=e;return/* @__PURE__ */ p(`picture`,{children:[t.includes(`avif`)&&/* @__PURE__ */ f(`source`,{type:`image/avif`,srcSet:ne(r,i,a,o,`avif`),sizes:s}),t.includes(`webp`)&&/* @__PURE__ */ f(`source`,{type:`image/webp`,srcSet:ne(r,i,a,o,`webp`),sizes:s}),n]})}function oe(e){let t=s(19),{finalSrc:n,shouldEagerBlur:r,inlineBlurDataURL:i,optimizerBlurUrl:a,placeholder:o}=e,[f,p]=d(!1),[m,h]=d(n),[g,_]=d(r),v=u(null);m!==n&&(h(n),_(r),p(!1));let y;t[0]===o?y=t[1]:(y=()=>{if(o!==`blur`)return;let e=v.current;e!=null&&ee(e)&&p(!0)},t[0]=o,t[1]=y);let b;t[2]!==n||t[3]!==o?(b=[o,n],t[2]=n,t[3]=o,t[4]=b):b=t[4],l(y,b);let x;t[5]!==g||t[6]!==a||t[7]!==o||t[8]!==r?(x=()=>T(v.current,!r&&!g&&a!=null&&o===`blur`,()=>{_(!0)}),t[5]=g,t[6]=a,t[7]=o,t[8]=r,t[9]=x):x=t[9];let S;t[10]!==n||t[11]!==g||t[12]!==a||t[13]!==o||t[14]!==r?(S=[r,g,a,o,n],t[10]=n,t[11]=g,t[12]=a,t[13]=o,t[14]=r,t[15]=S):S=t[15],c(x,S);let C=i??(r||g?a:void 0),w;return t[16]!==f||t[17]!==C?(w={imgRef:v,blurComplete:f,setBlurComplete:p,activeBlurUrl:C},t[16]=f,t[17]=C,t[18]=w):w=t[18],w}function E(e){let t=s(83),{src:n,alt:r,width:i,height:a,quality:o,preload:l,loading:p,placeholder:m,blurDataURL:h,fill:_,sizes:v,style:b,className:x,onLoad:C,onError:w,unoptimized:ee,loader:T,overrideSrc:E,decoding:se}=e,D=o===void 0?75:o,O=l!==void 0&&l,ce=p===void 0?`lazy`:p,k=m===void 0?`empty`:m,A=_!==void 0&&_,j=ee!==void 0&&ee,M;t[0]!==h||t[1]!==A||t[2]!==a||t[3]!==T||t[4]!==k||t[5]!==n||t[6]!==i?(M=S({src:n,width:i,height:a,fill:A,placeholder:k,blurDataURL:h,loader:T}),t[0]=h,t[1]=A,t[2]=a,t[3]=T,t[4]=k,t[5]=n,t[6]=i,t[7]=M):M=t[7];let{imgSrc:le,imgWidth:ue,imgHeight:de,inlineBlurDataURL:fe,optimizerBlurUrl:pe}=M,N=E!=null&&E!==``?E:le,me=se??(O?`sync`:`async`),he=typeof n==`string`?void 0:n.width,P;t[8]!==A||t[9]!==he||t[10]!==i?(P=g({fill:A,width:i,intrinsicWidth:he}),t[8]=A,t[9]=he,t[10]=i,t[11]=P):P=t[11];let F=P,I=F.widths.length>1||F.widths[0]!==F.defaultWidth,ge=O||ce===`eager`,[_e,ve]=d(!1),ye=u(C),L;t[12]!==N||t[13]!==fe||t[14]!==pe||t[15]!==k||t[16]!==ge?(L={finalSrc:N,shouldEagerBlur:ge,inlineBlurDataURL:fe,optimizerBlurUrl:pe,placeholder:k},t[12]=N,t[13]=fe,t[14]=pe,t[15]=k,t[16]=ge,t[17]=L):L=t[17];let{imgRef:be,blurComplete:xe,setBlurComplete:R,activeBlurUrl:Se}=oe(L),z,B;t[18]===C?(z=t[19],B=t[20]):(z=()=>{ye.current=C},B=[C],t[18]=C,t[19]=z,t[20]=B),c(z,B);let V;t[21]!==k||t[22]!==R?(V=e=>{let t=e.currentTarget;(t.currentSrc===``?t.src:t.currentSrc)!==``&&t.complete&&(k===`blur`&&R(!0),ye.current&&ye.current(e))},t[21]=k,t[22]=R,t[23]=V):V=t[23];let Ce=V,H;t[24]!==w||t[25]!==k||t[26]!==R?(H=e=>{ve(!0),k===`blur`&&R(!0),w&&w(e)},t[24]=w,t[25]=k,t[26]=R,t[27]=H):H=t[27];let we=H,U,W;t[28]!==A||t[29]!==N||t[30]!==T||t[31]!==O||t[32]!==D||t[33]!==I||t[34]!==F.defaultWidth||t[35]!==v||t[36]!==j?(U=()=>ie({enabled:O,finalSrc:N,defaultWidth:F.defaultWidth,quality:D,sizes:v,loader:T,unoptimized:j,fill:A,shouldUseSrcSet:I}),W=[O,N,F.defaultWidth,D,v,T,j,A,I],t[28]=A,t[29]=N,t[30]=T,t[31]=O,t[32]=D,t[33]=I,t[34]=F.defaultWidth,t[35]=v,t[36]=j,t[37]=U,t[38]=W):(U=t[37],W=t[38]),c(U,W);let G;t[39]!==Se||t[40]!==xe||t[41]!==A||t[42]!==k||t[43]!==b?(G=te({style:b,fill:A,placeholder:k,imgBlurDataURL:Se,blurComplete:xe}),t[39]=Se,t[40]=xe,t[41]=A,t[42]=k,t[43]=b,t[44]=G):G=t[44];let Te=G,K;t[45]!==N||t[46]!==T||t[47]!==D||t[48]!==F.defaultWidth||t[49]!==j?(K=re({unoptimized:j,loader:T,finalSrc:N,width:F.defaultWidth,quality:D}),t[45]=N,t[46]=T,t[47]=D,t[48]=F.defaultWidth,t[49]=j,t[50]=K):K=t[50];let Ee=K,q;t[51]!==I||t[52]!==v?(q=y(v,I),t[51]=I,t[52]=v,t[53]=q):q=t[53];let J=q,Y;t[54]!==N||t[55]!==T||t[56]!==D||t[57]!==I||t[58]!==F.widths||t[59]!==j?(Y=!j&&I?ne(T,N,F.widths,D):void 0,t[54]=N,t[55]=T,t[56]=D,t[57]=I,t[58]=F.widths,t[59]=j,t[60]=Y):Y=t[60];let X=Y,De=X==null?void 0:J,Oe=_e?r:``,ke=A?void 0:ue,Ae=A?void 0:de,je=O?`eager`:ce,Me=O?`high`:`auto`,Ne=k===`blur`||C!=null?Ce:void 0,Z;t[61]!==x||t[62]!==we||t[63]!==me||t[64]!==be||t[65]!==Te||t[66]!==Ee||t[67]!==X||t[68]!==De||t[69]!==Oe||t[70]!==ke||t[71]!==Ae||t[72]!==je||t[73]!==Me||t[74]!==Ne?(Z=/* @__PURE__ */ f(`img`,{ref:be,src:Ee,srcSet:X,sizes:De,alt:Oe,width:ke,height:Ae,loading:je,fetchPriority:Me,decoding:me,onLoad:Ne,onError:we,style:Te,className:x}),t[61]=x,t[62]=we,t[63]=me,t[64]=be,t[65]=Te,t[66]=Ee,t[67]=X,t[68]=De,t[69]=Oe,t[70]=ke,t[71]=Ae,t[72]=je,t[73]=Me,t[74]=Ne,t[75]=Z):Z=t[75];let Q=Z;if(j||!I)return Q;let $;return t[76]!==N||t[77]!==Q||t[78]!==T||t[79]!==D||t[80]!==J||t[81]!==F.widths?($=ae({imgElement:Q,loader:T,finalSrc:N,widths:F.widths,quality:D,sizes:J}),t[76]=N,t[77]=Q,t[78]=T,t[79]=D,t[80]=J,t[81]=F.widths,t[82]=$):$=t[82],$}const se=typeof window>`u`,D=E;se&&(D.$$typeof=Symbol.for(`react.client.reference`),D.$$id=`rari/image#Image`);export{o as BLUR_PLACEHOLDER_QUALITY,n as BLUR_PLACEHOLDER_WIDTH,i as DEFAULT_DEVICE_SIZES,t as DEFAULT_FORMATS,e as DEFAULT_IMAGE_SIZES,r as DEFAULT_MINIMUM_CACHE_TTL,a as DEFAULT_QUALITY_LEVELS,D as Image};
1
+ import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"./constants-CRK2JRKf.mjs";import{c as s}from"react/compiler-runtime";import{useEffect as c,useLayoutEffect as l,useRef as u,useState as d}from"react";import{jsx as f,jsxs as p}from"react/jsx-runtime";import{preload as m}from"react-dom";const h=Math.max(...i);function g(e){return Math.min(Math.max(e,1),h)}function _(e){let{fill:t,width:n,intrinsicWidth:r}=e;if(t)return{defaultWidth:h,widths:i};let a=n!=null&&n!==0?n:r!=null&&r!==0?r:void 0;if(a==null)return{defaultWidth:1920,widths:i};let o=g(a);return{defaultWidth:o,widths:[o]}}function v(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 y(e,t,n,r,i){return e==null?v(t,n,r,i):e({src:t,width:n,quality:r})}function b(e,t,n=!1){return e!=null&&e!==``?e:t||n?`100vw`:void 0}function x(e){if(e==null&&t.length===1&&t[0]===`avif`)return`avif`}function S(e){if(!e.enabled)return;let{finalSrc:t,defaultWidth:n,widths:r,quality:i,sizes:a,loader:o,unoptimized:s,fill:c,shouldUseSrcSet:l,format:u}=e;if(s){m(o==null?t:o({src:t,width:n,quality:i}),{as:`image`});return}let d=y(o,t,n,i,u),f=l,p=b(a,f,c);if(f){m(d,{as:`image`,imageSrcSet:O(o,t,r,i,u),...p==null?{}:{imageSizes:p},...u===`avif`?{type:`image/avif`}:{}});return}m(d,{as:`image`,...u===`avif`?{type:`image/avif`}:{}})}function C(e,t,n){if(e!=null&&e!==0)return e;if(!t&&n!=null&&n!==0)return n}function w(e){let{src:t,width:n,height:r,fill:i,placeholder:a,blurDataURL:o,loader:s}=e,c=typeof t==`string`?t:t.src,l=typeof t==`string`?void 0:t.width,u=typeof t==`string`?void 0:t.height,d=o!=null&&o!==``?o:typeof t==`string`?void 0:t.blurDataURL,f=d!=null&&d!==``?d:void 0,p=a===`blur`&&f==null?y(s,c,16,25,`jpeg`):void 0;return{imgSrc:c,imgWidth:C(n,i,l),imgHeight:C(r,i,u),inlineBlurDataURL:f,optimizerBlurUrl:p}}function T(e){return{position:`absolute`,inset:0,width:`100%`,height:`100%`,objectFit:e?.objectFit??`cover`}}function E(e){return{backgroundImage:`url("${e}")`,backgroundSize:`cover`,backgroundPosition:`center`,filter:`blur(20px)`,transition:`filter 0.3s ease-out`}}function D(e){return e.complete&&e.naturalWidth>0}function ee(e){let{style:t,fill:n,placeholder:r,imgBlurDataURL:i,blurComplete:a}=e,o=r===`blur`&&i!=null&&i!==``&&!a,s=r===`blur`&&a;return{...t,...n?T(t):null,...o?E(i):null,...s?{filter:`none`,transition:`filter 0.3s ease-out`}:null}}function O(e,t,n,r,i){return n.map(n=>`${y(e,t,n,r,i)} ${n}w`).join(`, `)}function te(e){let{unoptimized:t,loader:n,finalSrc:r,width:i,quality:a,format:o}=e;return t?n==null?r:n({src:r,width:i,quality:a}):y(n,r,i,a,o)}function k(e,t,n){if(!t||e==null)return;let r=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&(n(),r.disconnect())},{rootMargin:`200px`});return r.observe(e),()=>{r.disconnect()}}function ne(e){let{imgElement:n,loader:r,finalSrc:i,widths:a,quality:o,sizes:s}=e;return/* @__PURE__ */ p(`picture`,{children:[t.includes(`avif`)&&/* @__PURE__ */ f(`source`,{type:`image/avif`,srcSet:O(r,i,a,o,`avif`),sizes:s}),t.includes(`webp`)&&/* @__PURE__ */ f(`source`,{type:`image/webp`,srcSet:O(r,i,a,o,`webp`),sizes:s}),n]})}function re(e){let t=s(19),{finalSrc:n,shouldEagerBlur:r,inlineBlurDataURL:i,optimizerBlurUrl:a,placeholder:o}=e,[f,p]=d(!1),[m,h]=d(n),[g,_]=d(r),v=u(null);m!==n&&(h(n),_(r),p(!1));let y;t[0]===o?y=t[1]:(y=()=>{if(o!==`blur`)return;let e=v.current;e!=null&&D(e)&&p(!0)},t[0]=o,t[1]=y);let b;t[2]!==n||t[3]!==o?(b=[o,n],t[2]=n,t[3]=o,t[4]=b):b=t[4],l(y,b);let x;t[5]!==g||t[6]!==a||t[7]!==o||t[8]!==r?(x=()=>k(v.current,!r&&!g&&a!=null&&o===`blur`,()=>{_(!0)}),t[5]=g,t[6]=a,t[7]=o,t[8]=r,t[9]=x):x=t[9];let S;t[10]!==n||t[11]!==g||t[12]!==a||t[13]!==o||t[14]!==r?(S=[r,g,a,o,n],t[10]=n,t[11]=g,t[12]=a,t[13]=o,t[14]=r,t[15]=S):S=t[15],c(x,S);let C=i??(r||g?a:void 0),w;return t[16]!==f||t[17]!==C?(w={imgRef:v,blurComplete:f,setBlurComplete:p,activeBlurUrl:C},t[16]=f,t[17]=C,t[18]=w):w=t[18],w}function A(e){let t=s(16),{src:n,alt:r,width:i,height:a,quality:o,preload:l,loading:p,placeholder:m,blurDataURL:h,fill:g,sizes:v,style:y,className:C,onLoad:T,onError:E,unoptimized:D,loader:k,overrideSrc:A,decoding:j}=e,M=o===void 0?75:o,N=l!==void 0&&l,P=p===void 0?`lazy`:p,F=m===void 0?`empty`:m,I=g!==void 0&&g,L=D!==void 0&&D,{imgSrc:ie,imgWidth:ae,imgHeight:oe,inlineBlurDataURL:se,optimizerBlurUrl:ce}=w({src:n,width:i,height:a,fill:I,placeholder:F,blurDataURL:h,loader:k}),R=A!=null&&A!==``?A:ie,le=j??(N?`sync`:`async`),z=_({fill:I,width:i,intrinsicWidth:typeof n==`string`?void 0:n.width}),B=z.widths.length>1||z.widths[0]!==z.defaultWidth,ue=N||P===`eager`,V=x(k),[de,fe]=d(!1),H=u(T),{imgRef:pe,blurComplete:U,setBlurComplete:W,activeBlurUrl:G}=re({finalSrc:R,shouldEagerBlur:ue,inlineBlurDataURL:se,optimizerBlurUrl:ce,placeholder:F}),K,q;t[0]===T?(K=t[1],q=t[2]):(K=()=>{H.current=T},q=[T],t[0]=T,t[1]=K,t[2]=q),c(K,q);let J;t[3]!==F||t[4]!==W?(J=e=>{let t=e.currentTarget;(t.currentSrc===``?t.src:t.currentSrc)!==``&&t.complete&&(F===`blur`&&W(!0),H.current&&H.current(e))},t[3]=F,t[4]=W,t[5]=J):J=t[5];let me=J,Y;t[6]!==E||t[7]!==F||t[8]!==W?(Y=e=>{fe(!0),F===`blur`&&W(!0),E&&E(e)},t[6]=E,t[7]=F,t[8]=W,t[9]=Y):Y=t[9];let he=Y,X;t[10]!==G||t[11]!==U||t[12]!==I||t[13]!==F||t[14]!==y?(X=ee({style:y,fill:I,placeholder:F,imgBlurDataURL:G,blurComplete:U}),t[10]=G,t[11]=U,t[12]=I,t[13]=F,t[14]=y,t[15]=X):X=t[15];let ge=X,_e=te({unoptimized:L,loader:k,finalSrc:R,width:z.defaultWidth,quality:M,format:V}),Z=b(v,B,I),Q=!L&&B?O(k,R,z.widths,M,V):void 0;S({enabled:N,finalSrc:R,defaultWidth:z.defaultWidth,widths:z.widths,quality:M,sizes:Z,loader:k,unoptimized:L,fill:I,shouldUseSrcSet:B,format:V});let $=/* @__PURE__ */ f(`img`,{ref:pe,src:_e,srcSet:Q,sizes:Q==null?void 0:Z,alt:de?r:``,width:I?void 0:ae,height:I?void 0:oe,loading:N?`eager`:P,fetchPriority:N?`high`:`auto`,decoding:le,onLoad:F===`blur`||T!=null?me:void 0,onError:he,style:ge,className:C});return L||!B?$:ne({imgElement:$,loader:k,finalSrc:R,widths:z.widths,quality:M,sizes:Z})}const j=typeof window>`u`,M=A;j&&(M.$$typeof=Symbol.for(`react.client.reference`),M.$$id=`rari/image#Image`);export{o as BLUR_PLACEHOLDER_QUALITY,n as BLUR_PLACEHOLDER_WIDTH,i as DEFAULT_DEVICE_SIZES,t as DEFAULT_FORMATS,e as DEFAULT_IMAGE_SIZES,r as DEFAULT_MINIMUM_CACHE_TTL,a as DEFAULT_QUALITY_LEVELS,M as Image};
@@ -1 +1 @@
1
- import{t as e}from"../define-B5IGgRrU.mjs";export{e as defineMdxComponents};
1
+ import{t as e}from"../define-CuBTL1jt.mjs";export{e as defineMdxComponents};
package/dist/mdx.mjs CHANGED
@@ -1 +1 @@
1
- import{t as e}from"./names-CLmM0CPi.mjs";import{t}from"./define-B5IGgRrU.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};
1
+ import{t as e}from"./names-CLmM0CPi.mjs";import{t}from"./define-CuBTL1jt.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};
package/dist/og.mjs CHANGED
@@ -1 +1 @@
1
- import{f as e,h as t}from"./type-guards-BozK2q2n.mjs";import{isValidElement as n}from"react";const r=Symbol.for(`react.memo`),i=Symbol.for(`react.forward_ref`);function a(e){return t(e)&&typeof e.toString==`function`}function o(e){let t=e;for(;a(t);)if(t.$$typeof===r&&t.type!==void 0)t=t.type;else if(t.$$typeof===i&&t.render!==void 0)t=t.render;else break;return typeof t==`function`||a(t)?t:null}var s=class{element;options;constructor(e,t={}){this.element=e,this.options={width:t.width!=null&&t.width!==0?t.width:1200,height:t.height!=null&&t.height!==0?t.height:630}}toJSON(){return{type:`ImageResponse`,element:this.serializeElement(this.element),options:this.options}}resolveAndInvoke(t,n){let r=o(t);if(r==null||typeof r!=`function`)return null;try{let t=r(n);return t!==null&&e(t)?(console.warn(`[ImageResponse] async/server component "${r.name||r.toString()}" is not supported; skipping`),null):this.serializeElement(t)}catch(e){return console.error(`[ImageResponse] failed to render component "${r.name||r.toString()}":`,e),null}}serializeElement(e){if(typeof e==`string`||typeof e==`number`)return{type:`text`,value:String(e)};if(!n(e))return null;let{type:r}=e,i=t(e.props)?e.props:{},s=o(r);if(typeof s==`function`||s!=null&&a(s))return this.resolveAndInvoke(r,i);let c=this.serializeChildren(i.children);return{type:`element`,elementType:r,props:this.serializeProps(i),children:c}}serializeChildren(e){if(e==null)return[];if(Array.isArray(e))return e.flatMap(e=>{let t=this.serializeElement(e);return t?[t]:[]});let t=this.serializeElement(e);return t?[t]:[]}serializeProps(e){let t={};for(let[n,r]of Object.entries(e)){if(n===`children`)continue;let e=this.serializePropValue(r);e!==void 0&&(t[n]=e)}return t}serializePropValue(e,n=/* @__PURE__ */ new Set){if(e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return e;if(Array.isArray(e)){if(n.has(e))return;n.add(e);try{return e.map(e=>this.serializePropValue(e,n)).filter(e=>e!==void 0)}finally{n.delete(e)}}if(t(e)){if(n.has(e))return;n.add(e);try{let t={};for(let[r,i]of Object.entries(e)){let e=this.serializePropValue(i,n);e!==void 0&&(t[r]=e)}return t}finally{n.delete(e)}}}};export{s as ImageResponse};
1
+ import{g as e,p as t}from"./type-guards-BLY2PlGR.mjs";import{isValidElement as n}from"react";const r=Symbol.for(`react.memo`),i=Symbol.for(`react.forward_ref`);function a(t){return e(t)&&typeof t.toString==`function`}function o(e){let t=e;for(;a(t);)if(t.$$typeof===r&&t.type!==void 0)t=t.type;else if(t.$$typeof===i&&t.render!==void 0)t=t.render;else break;return typeof t==`function`||a(t)?t:null}var s=class{element;options;constructor(e,t={}){this.element=e,this.options={width:t.width!=null&&t.width!==0?t.width:1200,height:t.height!=null&&t.height!==0?t.height:630}}toJSON(){return{type:`ImageResponse`,element:this.serializeElement(this.element),options:this.options}}resolveAndInvoke(e,n){let r=o(e);if(r==null||typeof r!=`function`)return null;try{let e=r(n);return e!==null&&t(e)?(console.warn(`[ImageResponse] async/server component "${r.name||r.toString()}" is not supported; skipping`),null):this.serializeElement(e)}catch(e){return console.error(`[ImageResponse] failed to render component "${r.name||r.toString()}":`,e),null}}serializeElement(t){if(typeof t==`string`||typeof t==`number`)return{type:`text`,value:String(t)};if(!n(t))return null;let{type:r}=t,i=e(t.props)?t.props:{},s=o(r);if(typeof s==`function`||s!=null&&a(s))return this.resolveAndInvoke(r,i);let c=this.serializeChildren(i.children);return{type:`element`,elementType:r,props:this.serializeProps(i),children:c}}serializeChildren(e){if(e==null)return[];if(Array.isArray(e))return e.flatMap(e=>{let t=this.serializeElement(e);return t?[t]:[]});let t=this.serializeElement(e);return t?[t]:[]}serializeProps(e){let t={};for(let[n,r]of Object.entries(e)){if(n===`children`)continue;let e=this.serializePropValue(r);e!==void 0&&(t[n]=e)}return t}serializePropValue(t,n=/* @__PURE__ */ new Set){if(t==null||typeof t==`string`||typeof t==`number`||typeof t==`boolean`)return t;if(Array.isArray(t)){if(n.has(t))return;n.add(t);try{return t.map(e=>this.serializePropValue(e,n)).filter(e=>e!==void 0)}finally{n.delete(t)}}if(e(t)){if(n.has(t))return;n.add(t);try{let e={};for(let[r,i]of Object.entries(t)){let t=this.serializePropValue(i,n);t!==void 0&&(e[r]=t)}return e}finally{n.delete(t)}}}};export{s as ImageResponse};
@@ -1,2 +1,2 @@
1
- import{d as e}from"./type-guards-BozK2q2n.mjs";import{o as t}from"./path-CTEC1xmy.mjs";import{t as n}from"./get-client-component-DFAmn8Ey.mjs";import{Fragment as r,createElement as i,isValidElement as a}from"react";function o(e){return a(e)||e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`}function s(e){if(!Array.isArray(e))return e;let t=e;return t.length===1&&a(t[0])?t[0]:t.length>0&&t.every(o)?i(r,null,...t):e}async function c(e,t){let r=l(e,t);r.size!==0&&await Promise.all(Array.from(r,async e=>{try{if(await n(e)==null){console.warn(`[rari] Failed to preload component: ${e}`);return}t?.add(e)}catch(t){console.error(`[rari] Error preloading component ${e}:`,t)}}))}function l(e,t){let n=/* @__PURE__ */ new Set;for(let r of e.split(`
1
+ import{f as e}from"./type-guards-BLY2PlGR.mjs";import{o as t}from"./path-CTEC1xmy.mjs";import{t as n}from"./get-client-component-D2K213pV.mjs";import{Fragment as r,createElement as i,isValidElement as a}from"react";function o(e){return a(e)||e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`}function s(e){if(!Array.isArray(e))return e;let t=e;return t.length===1&&a(t[0])?t[0]:t.length>0&&t.every(o)?i(r,null,...t):e}async function c(e,t){let r=l(e,t);r.size!==0&&await Promise.all(Array.from(r,async e=>{try{if(await n(e)==null){console.warn(`[rari] Failed to preload component: ${e}`);return}t?.add(e)}catch(t){console.error(`[rari] Error preloading component ${e}:`,t)}}))}function l(e,t){let n=/* @__PURE__ */ new Set;for(let r of e.split(`
2
2
  `)){let e=u(r);e!=null&&(!t||!t.has(e))&&n.add(e)}return n}function u(n){let r=n.trim();if(!r)return null;let i=r.indexOf(`:`);if(i===-1)return null;let a=r.substring(i+1);if(!a.startsWith(`I`))return null;try{let n=JSON.parse(a.substring(1));if(!e(n))return null;let r=n[0];if(!r.includes(`/`)&&r.startsWith(`$`))return null;let i=typeof n[2]==`string`?n[2]:void 0,o=t(r);return o.includes(`#`)?o:i!=null&&i!==``&&i!=="default"?`${o}#${i}`:o}catch{return null}}export{s as n,c as t};
@@ -1,4 +1,4 @@
1
- import{h as e,p as t}from"../type-guards-BozK2q2n.mjs";import{r as n}from"../path-CTEC1xmy.mjs";const r={collapseSlashes:!0,ensureLeadingSlash:!1},i=/:(\w+)([?*+]?)|\*/g,a=/[\\+?(){}]/g,o=/[?#]/g,s=/* @__PURE__ */ new Map;function c(e){return e.replace(o,e=>encodeURIComponent(e))}function l(e){return c(e).replace(a,`\\$&`)}function u(e){let t=[],n=``,r=0;for(let a of e.matchAll(i)){let i=a.index;n+=l(e.slice(r,i));let o=a[0];if(o===`*`)n+=`*`;else{let e=a[1],r=a[2];t.push(e),n+=`:${e}${r}`}r=i+o.length}return n+=l(e.slice(r)),{pathname:n,paramNames:t}}function d(e){let t=n(e,r),i=s.get(t);if(i)return i;let{pathname:a,paramNames:o}=u(t),c={urlPattern:new URLPattern({pathname:a}),paramNames:o};return s.set(t,c),c}function f(e,t){let i=c(n(e,r));return d(t).urlPattern.exec({pathname:i})}
1
+ import{g as e,m as t}from"../type-guards-BLY2PlGR.mjs";import{r as n}from"../path-CTEC1xmy.mjs";const r={collapseSlashes:!0,ensureLeadingSlash:!1},i=/:(\w+)([?*+]?)|\*/g,a=/[\\+?(){}]/g,o=/[?#]/g,s=/* @__PURE__ */ new Map;function c(e){return e.replace(o,e=>encodeURIComponent(e))}function l(e){return c(e).replace(a,`\\$&`)}function u(e){let t=[],n=``,r=0;for(let a of e.matchAll(i)){let i=a.index;n+=l(e.slice(r,i));let o=a[0];if(o===`*`)n+=`*`;else{let e=a[1],r=a[2];t.push(e),n+=`:${e}${r}`}r=i+o.length}return n+=l(e.slice(r)),{pathname:n,paramNames:t}}function d(e){let t=n(e,r),i=s.get(t);if(i)return i;let{pathname:a,paramNames:o}=u(t),c={urlPattern:new URLPattern({pathname:a}),paramNames:o};return s.set(t,c),c}function f(e,t){let i=c(n(e,r));return d(t).urlPattern.exec({pathname:i})}
2
2
  /* v8 ignore start - requires complex RariRequest mocking */
3
3
  function p(e,t){return e.headers.get(t)}function m(e,t){return e.rariUrl.searchParams.get(t)}function h(e,t){let n=e.cookies.get(t);return n?n.value:null}function g(e,t){return e.rariUrl.hostname===t?e.rariUrl.hostname:null}function _(e,t){switch(t.type){case`header`:return p(e,t.key);case`query`:return m(e,t.key);case`cookie`:return h(e,t.key);case`host`:return g(e,t.key);default:throw Error(`Unknown condition type: ${t.type}`)}}function v(e,t){let n=_(e,t);return!(n===null||t.value!==void 0&&n!==t.value)}function y(e,t){let n=_(e,t);return n===null||t.value!==void 0&&n!==t.value}function b(e,t){if(t.has){for(let n of t.has)if(!v(e,n))return!1}if(t.missing){for(let n of t.missing)if(!y(e,n))return!1}return!0}
4
4
  /* v8 ignore stop */
@@ -0,0 +1 @@
1
+ import{g as e,p as t}from"./type-guards-BLY2PlGR.mjs";import{Suspense as n,cloneElement as r,isValidElement as i}from"react";const a=Symbol.for(`react.suspense`),o=Symbol.for(`react.lazy`);function s(e){return i(e)&&(e.type===`html`||e.type===`HTML`)}function c(e){if(e==null||e===!1||e===!0)return[];if(!Array.isArray(e))return[e];let t=[];for(let n=0;n<e.length;n+=1){let r=e[n];t.push(r)}return t}function l(t){if(t.type===n)return!0;let r=t.type;return r===a||e(r)&&r.$$typeof===a}function u(t){return e(t.props)&&`errorComponentId`in t.props}function d(e){return e.type===`rari-layout-reuse`}function f(e){return e.props.children}function p(e){return d(e)||u(e)?!0:!(l(e)||typeof e.type==`string`)}function m(e){if(!i(e))return{fallback:null,content:e};if(l(e)){let t=e.props;return{fallback:t.fallback??null,content:t.children}}if(!p(e))return{fallback:null,content:e};let t=f(e),n=m(t);return n.fallback==null&&Object.is(n.content,t)?{fallback:null,content:e}:{fallback:n.fallback,content:r(e,void 0,n.content)}}function h(e){return m(e).fallback!=null}function g(t){return t===o||e(t)&&t.$$typeof===o}function _(e){return g(e.type)}function v(e){return e===`fulfilled`||e===`rejected`||e===`errored`}function y(t){return e(t)&&v(t.status)?!1:D(t)?!0:e(t)&&typeof t._status==`number`?t._status===-1||t._status===0:e(t)&&typeof t.status==`string`?t.status===`pending`||t.status===`pending_weak`||t.status===`blocked`||t.status===`halted`||t.status===`resolved_model`||t.status===`resolved_module`:!1}function b(t){if(!_(t))return!1;let n=t.type;return e(n)?y(n._payload):!1}function x(t){return!g(t)||!e(t)?!1:y(t._payload)}function S(e){for(let t of c(e))if(t!=null&&t!==!1&&t!==!0&&!(D(t)||x(t))&&(typeof t==`string`||typeof t==`number`||typeof t==`bigint`||i(t)))return!0;return!1}function C(e){for(let t of c(e))if(D(t)||x(t)||i(t)&&!_(t)&&C(f(t)))return!0;return!1}function w(e){let t=f(e);return C(t)?!0:S(t)?!1:T(t)?!0:b(e)}function T(e){for(let t of c(e))if(D(t)||x(t)||i(t)&&(_(t)?w(t):T(f(t))))return!0;return!1}function E(e){if(e==null||e===!1||e===!0)return!1;if(D(e)||x(e))return!0;if(Array.isArray(e)){for(let t of c(e))if(E(t))return!0;return!1}if(!i(e))return!1;if(l(e)){let t=e.props.children;return T(t)?!0:E(t)}return _(e),E(e.props.children)}function D(n){return t(n)?!e(n)||!v(n.status):!1}export{m as a,h as i,E as n,s as r,c as t};
@@ -1,4 +1,4 @@
1
- import{h as e}from"./type-guards-BozK2q2n.mjs";import{i as t,n,r,t as i}from"./execute-D_MjcLUi.mjs";import{promises as a}from"node:fs";import o from"node:path";function s(t){return e(t)&&t.rules!=null}async function c(e){if(typeof e==`function`){let t=e(),n=t instanceof Promise?await t:t;if(!s(n))throw Error(`Robots default export must resolve to a robots object`);return n}if(!s(e))throw Error(`Robots default export must be a robots object`);return e}function l(e){return typeof e==`string`?e===``?[`*`]:[e]:e==null?[`*`]:[...e]}function u(e){return e===void 0?[]:typeof e==`string`?e===``?[]:[e]:[...e].filter(e=>e!==``)}function d(e){let t=[],n=l(e.userAgent);for(let r of n){t.push(`User-Agent: ${r}`);let n=u(e.allow);for(let e of n)t.push(`Allow: ${e}`);let i=u(e.disallow);for(let e of i)t.push(`Disallow: ${e}`);e.crawlDelay!==void 0&&t.push(`Crawl-delay: ${e.crawlDelay}`),t.push(``)}return t}function f(e){return e==null||e===``?[]:[`Host: ${e}`,``]}function p(e){return u(e).map(e=>`Sitemap: ${e}`)}function m(e){let t=[],n=Array.isArray(e.rules)?e.rules:[e.rules];for(let e of n)t.push(...d(e));return t.push(...f(e.host)),t.push(...p(e.sitemap)),t.join(`
1
+ import{g as e}from"./type-guards-BLY2PlGR.mjs";import{i as t,n,r,t as i}from"./execute-DJ7w3uhW.mjs";import{promises as a}from"node:fs";import o from"node:path";function s(t){return e(t)&&t.rules!=null}async function c(e){if(typeof e==`function`){let t=e(),n=t instanceof Promise?await t:t;if(!s(n))throw Error(`Robots default export must resolve to a robots object`);return n}if(!s(e))throw Error(`Robots default export must be a robots object`);return e}function l(e){return typeof e==`string`?e===``?[`*`]:[e]:e==null?[`*`]:[...e]}function u(e){return e===void 0?[]:typeof e==`string`?e===``?[]:[e]:[...e].filter(e=>e!==``)}function d(e){let t=[],n=l(e.userAgent);for(let r of n){t.push(`User-Agent: ${r}`);let n=u(e.allow);for(let e of n)t.push(`Allow: ${e}`);let i=u(e.disallow);for(let e of i)t.push(`Disallow: ${e}`);e.crawlDelay!==void 0&&t.push(`Crawl-delay: ${e.crawlDelay}`),t.push(``)}return t}function f(e){return e==null||e===``?[]:[`Host: ${e}`,``]}function p(e){return u(e).map(e=>`Sitemap: ${e}`)}function m(e){let t=[],n=Array.isArray(e.rules)?e.rules:[e.rules];for(let e of n)t.push(...d(e));return t.push(...f(e.host)),t.push(...p(e.sitemap)),t.join(`
2
2
  `)}
3
3
  /* v8 ignore start - file system operations, better tested in integration/e2e */
4
4
  async function h(e,n=[`.ts`,`.tsx`,`.js`,`.jsx`,`.mjs`]){return t({appDir:e,staticFileName:`robots.txt`,dynamicBaseName:`robots`,extensions:n,rethrowNonEnoent:!0})}
@@ -1 +1 @@
1
- import{isLayoutReuseMarker as e,layoutPathOf as t}from"./runtime/merge-flight-refresh.mjs";import{r as n,t as r}from"./react-helpers-BKmKvCbj.mjs";import{cloneElement as i,createElement as a,isValidElement as o}from"react";const s=`children`;function c(e){let t=e.length;for(;t>1&&e[t-1]===`/`;)--t;return e.slice(0,t)}function l(e){let t=e===`/`||e===``?`/`:c(e)||`/`,n=t===`/`?[]:t.slice(1).split(`/`).filter(Boolean),r=[``,{}];for(let e=n.length-1;e>=0;--e)r=[n[e],{[s]:r}];return[``,{[s]:r}]}function u(e){let t=[],n=e;for(;n;){let e=n[0],r=n[1];e&&t.push(e),n=r.children}return t}function d(e){return u(l(e))}const f=`rari-layout-slot`;function p(){return{rsc:null,data:/* @__PURE__ */ new Map,slots:null}}function m(e,t){e.slots??=/* @__PURE__ */ new Map;let n=e.slots.get(t);return n??(n=p(),e.slots.set(t,n)),n}function h(e,t){let n=e;for(let e of t)n=m(n,e);return n}function g(e,t){let n=e;for(let e of t){let t=n.slots?.get(e);if(t==null)return null;n=t}return n}function _(e,t){if(t.length===0){e.rsc=null,e.data.clear(),e.slots=null;return}let n=e;for(let e=0;e<t.length-1;e+=1){let r=t[e],i=n.slots?.get(r);if(i==null)return;n=i}let r=t[t.length-1];n.slots!=null&&n.slots.has(r)&&(n.slots.delete(r),n.slots.size===0&&(n.slots=null))}function v(e){return e===`/`||e===``?[]:e.replace(/^\//,``).split(`/`).filter(Boolean)}function y(e){return e.props.children}function b(e){let t={...e.props};return delete t.children,t}function x(e,t){let n=r(t);return i(e,b(e),...n.length===0?[null]:n)}function S(e){return e.type===f}function C(e){if(Array.isArray(e)){for(let t of r(e))if(C(t))return!0;return!1}return o(e)?S(e)?!0:C(y(e)):!1}function w(e){return a(f,{"data-rari-layout-path":e,style:{display:`contents`}})}function T(e,t){return e===`/`?t!==`/`:t.startsWith(`${e}/`)}function E(e,n){if(Array.isArray(e)){for(let t of r(e))E(t,n);return}if(!o(e))return;let i=t(e);i!=null&&!n.includes(i)&&n.push(i);for(let t of r(y(e)))E(t,n)}function D(e,n){let i=[];function a(e){if(e==null||e===!1||e===!0)return e;if(Array.isArray(e))return r(e).map(a);if(!o(e))return e;let s=t(e);if(s!=null&&s!==n&&T(n,s)&&!S(e))return i.push({path:s,content:y(e)}),w(s);let c=y(e);if(c==null)return e;let l=a(c);return Object.is(l,c)?e:x(e,l)}return{chrome:a(e),nested:i}}function O(e,n){if(t(e)===n)return e;for(let t of r(y(e))){if(!o(t))continue;let e=O(t,n);if(e!=null)return e}return null}function k(e,t){if(Array.isArray(e)){for(let n of r(e)){let e=k(n,t);if(e!=null)return e}return null}return o(e)?O(e,t):null}function A(e){return e.length===0?`/`:`/${e.join(`/`)}`}function j(e){return e.rsc==null&&e.data.size===0&&(e.slots==null||e.slots.size===0)}function M(n){let i=[];function a(n){if(n==null||n===!1||n===!0)return n;if(Array.isArray(n))return r(n).map(a);if(!o(n))return n;let s=t(n);if(s!=null&&!S(n)&&!e(n))return i.push({path:s,content:y(n)}),x(n,w(s));let c=y(n);if(c==null)return n;let l=a(c);return Object.is(l,c)?n:x(n,l)}let s=a(n);return o(s)?{shell:s,entries:i}:{shell:n,entries:i}}function N(n){let r=n,i=null;for(;o(r)&&e(r);){let e=t(r);if(e==null)return{targetPath:null,content:n};i=e,r=y(r)}return{targetPath:i,content:r}}const P=new class{shell=null;root=p();version=0;listeners=/* @__PURE__ */ new Set;documentSnapshot=null;subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getVersion=()=>this.version;bump(){this.version+=1;for(let e of this.listeners)e()}notify(){this.documentSnapshot=null,this.bump()}getShell(){return this.shell}getDocumentSnapshot=()=>{let{pathname:e,search:t}=F(),n=`${e}${t}`,r=this.hasRoute(e,t);return this.documentSnapshot!=null&&this.documentSnapshot.shell===this.shell&&this.documentSnapshot.routeKey===n&&this.documentSnapshot.ok===r||(this.documentSnapshot={shell:this.shell,routeKey:n,ok:r}),this.documentSnapshot};hasRoute(e,t){return g(this.root,d(e))?.data.has(t)===!0}readChrome(e){return g(this.root,v(e))?.rsc??null}readLeaf(e,t){let n=g(this.root,d(e));return n==null||!n.data.has(t)?null:n.data.get(t)??null}readSegmentSnapshot(e,t){let{pathname:n,search:r}=t??F();return this.isDeepestLayout(e,n)?this.readLeaf(n,r):this.readChrome(e)}isDeepestLayout(e,t){let n=this.readChrome(e);if(n==null)return!0;let r=[];E(n,r);let i=t===`/`||t===``?`/`:t.replace(/\/$/,``)||`/`;return!r.some(t=>T(e,t)?t===`/`||i===t||i.startsWith(`${t}/`):!1)}ingest(e,t,r){if(!n(e)||C(e))return!1;let{shell:i,entries:a}=M(e);if(this.shell=i,a.length===0)return h(this.root,d(t)).data.set(r,e),this.bump(),!0;for(let e of a)this.writeStampContent(e.path,e.content,t,r);return this.bump(),!0}ingestSegment(e,n,r){if(this.shell==null||!o(e))return!1;let{targetPath:i,content:a}=N(e);return i==null?!o(a)||t(a)==null||!this.ingestStampTree(a,n,r)?!1:(this.bump(),!0):this.isAddressableLayoutPath(i)?(this.writeStampContent(i,a,n,r),this.bump(),!0):!1}ingestStampTree(e,t,n){let r=[];if(E(e,r),r.length===0)return!1;for(let i of r){let r=O(e,i);r==null||S(r)||this.writeStampContent(i,y(r),t,n)}return!0}isAddressableLayoutPath(e){if(this.shell!=null&&O(this.shell,e)!=null)return!0;let t=v(e);for(let n=0;n<t.length;n+=1){let r=A(t.slice(0,n)),i=this.readChrome(r);if(i!=null&&k(i,e)!=null)return!0}return!1}writeStampContent(e,t,n,r){if(o(t)&&S(t))return;let{chrome:i,nested:a}=D(t,e===``?`/`:e);if(o(i)&&S(i)&&a.length===0)return;let s=h(this.root,v(e));if(s.rsc=i,a.length===0){h(this.root,d(n)).data.set(r,t);return}for(let e of a)this.writeStampContent(e.path,e.content,n,r)}getElement(e,t){if(this.hasRoute(e,t))return this.shell??void 0}set(e,t,r){n(r)&&this.ingest(r,e,t)}invalidate(e,t){let n=d(e);if(n.length===0){this.shell=null,this.root=p(),this.bump();return}let r=g(this.root,n);r!=null&&(r.data.delete(t),r.rsc=null,r.slots=null,j(r)&&_(this.root,n),this.bump())}evictLeaf(e,t){let n=d(e),r=g(this.root,n);r!=null&&(r.data.delete(t),j(r)&&_(this.root,n),this.bump())}clear(){this.shell=null,this.root=p(),this.documentSnapshot=null,this.bump()}};function F(){return typeof window>`u`?{pathname:`/`,search:``}:{pathname:window.location.pathname,search:window.location.search}}function I(){let{pathname:e,search:t}=F();return JSON.stringify({pathname:e,search:t,tree:l(e)})}export{I as a,S as i,F as n,P as r,C as t};
1
+ import{isLayoutReuseMarker as e,layoutPathOf as t}from"./runtime/merge-flight-refresh.mjs";import{r as n,t as r}from"./react-helpers-duOBWuYF.mjs";import{cloneElement as i,createElement as a,isValidElement as o}from"react";const s=`children`;function c(e){let t=e.length;for(;t>1&&e[t-1]===`/`;)--t;return e.slice(0,t)}function l(e){let t=e===`/`||e===``?`/`:c(e)||`/`,n=t===`/`?[]:t.slice(1).split(`/`).filter(Boolean),r=[``,{}];for(let e=n.length-1;e>=0;--e)r=[n[e],{[s]:r}];return[``,{[s]:r}]}function u(e){let t=[],n=e;for(;n;){let e=n[0],r=n[1];e&&t.push(e),n=r.children}return t}function d(e){return u(l(e))}const f=`rari-layout-slot`;function p(){return{rsc:null,data:/* @__PURE__ */ new Map,slots:null}}function m(e,t){e.slots??=/* @__PURE__ */ new Map;let n=e.slots.get(t);return n??(n=p(),e.slots.set(t,n)),n}function h(e,t){let n=e;for(let e of t)n=m(n,e);return n}function g(e,t){let n=e;for(let e of t){let t=n.slots?.get(e);if(t==null)return null;n=t}return n}function _(e,t){if(t.length===0){e.rsc=null,e.data.clear(),e.slots=null;return}let n=e;for(let e=0;e<t.length-1;e+=1){let r=t[e],i=n.slots?.get(r);if(i==null)return;n=i}let r=t[t.length-1];n.slots!=null&&n.slots.has(r)&&(n.slots.delete(r),n.slots.size===0&&(n.slots=null))}function v(e){return e===`/`||e===``?[]:e.replace(/^\//,``).split(`/`).filter(Boolean)}function y(e){return e.props.children}function b(e){let t={...e.props};return delete t.children,t}function x(e,t){let n=r(t);return i(e,b(e),...n.length===0?[null]:n)}function S(e){return e.type===f}function C(e){if(Array.isArray(e)){for(let t of r(e))if(C(t))return!0;return!1}return o(e)?S(e)?!0:C(y(e)):!1}function w(e){return a(f,{"data-rari-layout-path":e,style:{display:`contents`}})}function T(e,t){return e===`/`?t!==`/`:t.startsWith(`${e}/`)}function E(e,n){if(Array.isArray(e)){for(let t of r(e))E(t,n);return}if(!o(e))return;let i=t(e);i!=null&&!n.includes(i)&&n.push(i);for(let t of r(y(e)))E(t,n)}function D(e,n){let i=[];function a(e){if(e==null||e===!1||e===!0)return e;if(Array.isArray(e))return r(e).map(a);if(!o(e))return e;let s=t(e);if(s!=null&&s!==n&&T(n,s)&&!S(e))return i.push({path:s,content:y(e)}),w(s);let c=y(e);if(c==null)return e;let l=a(c);return Object.is(l,c)?e:x(e,l)}return{chrome:a(e),nested:i}}function O(e,n){if(t(e)===n)return e;for(let t of r(y(e))){if(!o(t))continue;let e=O(t,n);if(e!=null)return e}return null}function k(e,t){if(Array.isArray(e)){for(let n of r(e)){let e=k(n,t);if(e!=null)return e}return null}return o(e)?O(e,t):null}function A(e){return e.length===0?`/`:`/${e.join(`/`)}`}function j(e){return e.rsc==null&&e.data.size===0&&(e.slots==null||e.slots.size===0)}function M(n){let i=[];function a(n){if(n==null||n===!1||n===!0)return n;if(Array.isArray(n))return r(n).map(a);if(!o(n))return n;let s=t(n);if(s!=null&&!S(n)&&!e(n))return i.push({path:s,content:y(n)}),x(n,w(s));let c=y(n);if(c==null)return n;let l=a(c);return Object.is(l,c)?n:x(n,l)}let s=a(n);return o(s)?{shell:s,entries:i}:{shell:n,entries:i}}function N(n){let r=n,i=null;for(;o(r)&&e(r);){let e=t(r);if(e==null)return{targetPath:null,content:n};i=e,r=y(r)}return{targetPath:i,content:r}}const P=new class{shell=null;root=p();version=0;listeners=/* @__PURE__ */ new Set;documentSnapshot=null;subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getVersion=()=>this.version;bump(){this.version+=1;for(let e of this.listeners)e()}notify(){this.documentSnapshot=null,this.bump()}getShell(){return this.shell}getDocumentSnapshot=()=>{let{pathname:e,search:t}=F(),n=`${e}${t}`,r=this.hasRoute(e,t);return this.documentSnapshot!=null&&this.documentSnapshot.shell===this.shell&&this.documentSnapshot.routeKey===n&&this.documentSnapshot.ok===r||(this.documentSnapshot={shell:this.shell,routeKey:n,ok:r}),this.documentSnapshot};hasRoute(e,t){return g(this.root,d(e))?.data.has(t)===!0}readChrome(e){return g(this.root,v(e))?.rsc??null}readLeaf(e,t){let n=g(this.root,d(e));return n==null||!n.data.has(t)?null:n.data.get(t)??null}readSegmentSnapshot(e,t){let{pathname:n,search:r}=t??F();return this.isDeepestLayout(e,n)?this.readLeaf(n,r):this.readChrome(e)}isDeepestLayout(e,t){let n=this.readChrome(e);if(n==null)return!0;let r=[];E(n,r);let i=t===`/`||t===``?`/`:t.replace(/\/$/,``)||`/`;return!r.some(t=>T(e,t)?t===`/`||i===t||i.startsWith(`${t}/`):!1)}ingest(e,t,r){if(!n(e)||C(e))return!1;let{shell:i,entries:a}=M(e);if(this.shell=i,a.length===0)return h(this.root,d(t)).data.set(r,e),this.bump(),!0;for(let e of a)this.writeStampContent(e.path,e.content,t,r);return this.bump(),!0}ingestSegment(e,n,r){if(this.shell==null||!o(e))return!1;let{targetPath:i,content:a}=N(e);return i==null?!o(a)||t(a)==null||!this.ingestStampTree(a,n,r)?!1:(this.bump(),!0):this.isAddressableLayoutPath(i)?(this.writeStampContent(i,a,n,r),this.bump(),!0):!1}ingestStampTree(e,t,n){let r=[];if(E(e,r),r.length===0)return!1;for(let i of r){let r=O(e,i);r==null||S(r)||this.writeStampContent(i,y(r),t,n)}return!0}isAddressableLayoutPath(e){if(this.shell!=null&&O(this.shell,e)!=null)return!0;let t=v(e);for(let n=0;n<t.length;n+=1){let r=A(t.slice(0,n)),i=this.readChrome(r);if(i!=null&&k(i,e)!=null)return!0}return!1}writeStampContent(e,t,n,r){if(o(t)&&S(t))return;let{chrome:i,nested:a}=D(t,e===``?`/`:e);if(o(i)&&S(i)&&a.length===0)return;let s=h(this.root,v(e));if(s.rsc=i,a.length===0){h(this.root,d(n)).data.set(r,t);return}for(let e of a)this.writeStampContent(e.path,e.content,n,r)}getElement(e,t){if(this.hasRoute(e,t))return this.shell??void 0}set(e,t,r){n(r)&&this.ingest(r,e,t)}invalidate(e,t){let n=d(e);if(n.length===0){this.shell=null,this.root=p(),this.bump();return}let r=g(this.root,n);r!=null&&(r.data.delete(t),r.rsc=null,r.slots=null,j(r)&&_(this.root,n),this.bump())}evictLeaf(e,t){let n=d(e),r=g(this.root,n);r!=null&&(r.data.delete(t),j(r)&&_(this.root,n),this.bump())}clear(){this.shell=null,this.root=p(),this.documentSnapshot=null,this.bump()}};function F(){return typeof window>`u`?{pathname:`/`,search:``}:{pathname:window.location.pathname,search:window.location.search}}function I(){let{pathname:e,search:t}=F();return JSON.stringify({pathname:e,search:t,tree:l(e)})}export{I as a,S as i,F as n,P as r,C as t};
@@ -1 +1 @@
1
- import{n as e}from"./navigate-DuyUa6qD.mjs";import{h as t,i as n}from"./type-guards-BozK2q2n.mjs";import{i as r,n as i,r as a,t as o}from"./navigation-transition-store-dfNJmkIX.mjs";import{c as s}from"react/compiler-runtime";import{createContext as c,use as l,useEffect as u,useRef as d,useSyncExternalStore as f}from"react";import{jsx as p}from"react/jsx-runtime";const m=c(null);function h(){let e=l(m);if(!e)throw Error(`useRouter must be used within a RouterProvider`);return e}function g(){return h().pathname}function _(){return h().searchParams}function v(){return f(a,b,y)}function y(){return o().generation}function b(){return i().generation}function x(e){return t(e)&&typeof e.navigate==`function`}function S(t){let r=s(17),{children:c,initialPathname:l}=t,h;r[0]===l?h=r[1]:(h=()=>o(l),r[0]=l,r[1]=h);let g=f(a,i,h),_=d(null),v;r[2]===Symbol.for(`react.memo_cache_sentinel`)?(v=[],r[2]=v):v=r[2],u(D,v);let y,b;r[3]===Symbol.for(`react.memo_cache_sentinel`)?(y=()=>{let t=e();t&&(_.current=t);let r=e=>{let t=n(e,x);t&&(_.current=t.navigate)},i=()=>{_.current=null};return window.addEventListener(`rari:register-navigate`,r),window.addEventListener(`rari:deregister-navigate`,i),()=>{window.removeEventListener(`rari:register-navigate`,r),window.removeEventListener(`rari:deregister-navigate`,i)}},b=[],r[3]=y,r[4]=b):(y=r[3],b=r[4]),u(y,b);let S;r[5]===g.search?S=r[6]:(S=g.search.startsWith(`?`)?g.search.slice(1):g.search,r[5]=g.search,r[6]=S);let O;r[7]===S?O=r[8]:(O=new URLSearchParams(S),r[7]=S,r[8]=O);let k=O,A,j;r[9]===Symbol.for(`react.memo_cache_sentinel`)?(A=async(e,t)=>{_.current?await _.current(e,t):(console.warn(`[rari] Router not ready, falling back to window.location`),window.location.href=e)},j=async(e,t)=>{_.current?await _.current(e,{...t,replace:!0}):(console.warn(`[rari] Router not ready, falling back to window.location`),window.location.replace(e))},r[9]=A,r[10]=j):(A=r[9],j=r[10]);let M;r[11]!==k||r[12]!==g.pathname?(M={pathname:g.pathname,searchParams:k,push:A,replace:j,back:E,forward:T,refresh:w,prefetch:C},r[11]=k,r[12]=g.pathname,r[13]=M):M=r[13];let N=M,P;return r[14]!==c||r[15]!==N?(P=/* @__PURE__ */ p(m,{value:N,children:c}),r[14]=c,r[15]=N,r[16]=P):P=r[16],P}async function C(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)}}function w(){window.dispatchEvent(new CustomEvent(`rari:app-router-rerender`))}function T(){window.history.forward()}function E(){window.history.back()}function D(){r()}export{v as a,_ as i,g as n,h as r,S as t};
1
+ import{n as e}from"./navigate-DuyUa6qD.mjs";import{g as t,i as n}from"./type-guards-BLY2PlGR.mjs";import{i as r,n as i,r as a,t as o}from"./navigation-transition-store-dfNJmkIX.mjs";import{c as s}from"react/compiler-runtime";import{createContext as c,use as l,useEffect as u,useRef as d,useSyncExternalStore as f}from"react";import{jsx as p}from"react/jsx-runtime";const m=c(null);function h(){let e=l(m);if(!e)throw Error(`useRouter must be used within a RouterProvider`);return e}function g(){return h().pathname}function _(){return h().searchParams}function v(){return f(a,b,y)}function y(){return o().generation}function b(){return i().generation}function x(e){return t(e)&&typeof e.navigate==`function`}function S(t){let r=s(17),{children:c,initialPathname:l}=t,h;r[0]===l?h=r[1]:(h=()=>o(l),r[0]=l,r[1]=h);let g=f(a,i,h),_=d(null),v;r[2]===Symbol.for(`react.memo_cache_sentinel`)?(v=[],r[2]=v):v=r[2],u(D,v);let y,b;r[3]===Symbol.for(`react.memo_cache_sentinel`)?(y=()=>{let t=e();t&&(_.current=t);let r=e=>{let t=n(e,x);t&&(_.current=t.navigate)},i=()=>{_.current=null};return window.addEventListener(`rari:register-navigate`,r),window.addEventListener(`rari:deregister-navigate`,i),()=>{window.removeEventListener(`rari:register-navigate`,r),window.removeEventListener(`rari:deregister-navigate`,i)}},b=[],r[3]=y,r[4]=b):(y=r[3],b=r[4]),u(y,b);let S;r[5]===g.search?S=r[6]:(S=g.search.startsWith(`?`)?g.search.slice(1):g.search,r[5]=g.search,r[6]=S);let O;r[7]===S?O=r[8]:(O=new URLSearchParams(S),r[7]=S,r[8]=O);let k=O,A,j;r[9]===Symbol.for(`react.memo_cache_sentinel`)?(A=async(e,t)=>{_.current?await _.current(e,t):(console.warn(`[rari] Router not ready, falling back to window.location`),window.location.href=e)},j=async(e,t)=>{_.current?await _.current(e,{...t,replace:!0}):(console.warn(`[rari] Router not ready, falling back to window.location`),window.location.replace(e))},r[9]=A,r[10]=j):(A=r[9],j=r[10]);let M;r[11]!==k||r[12]!==g.pathname?(M={pathname:g.pathname,searchParams:k,push:A,replace:j,back:E,forward:T,refresh:w,prefetch:C},r[11]=k,r[12]=g.pathname,r[13]=M):M=r[13];let N=M,P;return r[14]!==c||r[15]!==N?(P=/* @__PURE__ */ p(m,{value:N,children:c}),r[14]=c,r[15]=N,r[16]=P):P=r[16],P}async function C(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)}}function w(){window.dispatchEvent(new CustomEvent(`rari:app-router-rerender`))}function T(){window.history.forward()}function E(){window.history.back()}function D(){r()}export{v as a,_ as i,g as n,h as r,S as t};
package/dist/router.mjs CHANGED
@@ -1 +1 @@
1
- import{r as e}from"./navigate-DuyUa6qD.mjs";import{a as t,i as n,n as r,r as i,t as a}from"./router-6mdxF_x7.mjs";export{a as RouterProvider,e as navigate,r as usePathname,i as useRouter,n as useSearchParams,t as useViewTransitionKey};
1
+ import{r as e}from"./navigate-DuyUa6qD.mjs";import{a as t,i as n,n as r,r as i,t as a}from"./router-Cc9lVbtA.mjs";export{a as RouterProvider,e as navigate,r as usePathname,i as useRouter,n as useSearchParams,t as useViewTransitionKey};
@@ -1 +1 @@
1
- import{h as e}from"./type-guards-BozK2q2n.mjs";import{o as t}from"./path-CTEC1xmy.mjs";import{Buffer as n}from"node:buffer";import r from"node:fs";import i from"node:path";import{createBuilder as a}from"vite-plus";const o=/* @__PURE__ */ new Map,s=/* @__PURE__ */ new Map;function c(e){let t=o.get(e);return t===void 0?(t=r.existsSync(e),o.set(e,t),t):t}function l(e){let t=s.get(e);if(t!==void 0)return t;try{t=r.statSync(e).isDirectory()}catch{t=!1}return s.set(e,t),t}function u(){o.clear(),s.clear()}function d(e,t){let n=null;for(let r of t)if(r!==``&&e.endsWith(r)&&(n??=c(e),n&&!l(e)))return e;for(let n of t){let t=`${e}${n}`;if(c(t)&&!l(t))return t}return null}function f(e,t){if(c(e)){if(!l(e))return null;for(let n of t){let t=i.join(e,`index${n}`);if(c(t))return t}}return null}const p=[`.tsx`,`.jsx`,`.ts`,`.js`];function m(e,t,n={},r=p){let a=e;for(let[t,r]of Object.entries(n))if(e.startsWith(`${t}/`)){a=e.replace(t,r);break}else if(e===t){a=r;break}let o=i.resolve(i.dirname(t),a),s=d(o,r);if(s!=null&&s!==``)return s;let c=f(o,r);return c!=null&&c!==``?c:`${o}.tsx`}const h=[`.ts`,`.tsx`,`.js`,`.jsx`,`.mjs`];function g(e,t=h){return d(e,t)??f(e,t)}const _=/* @__PURE__ */ new WeakMap;function v(e){let t=_.get(e);return t||(t=Object.entries(e).sort((e,t)=>t[0].length-e[0].length),_.set(e,t),t)}function y(e,t,n){if(typeof e!=`string`)throw TypeError(`Expected source to be a string, but received ${typeof e}`);if(typeof t!=`object`||Array.isArray(t))throw TypeError(`Expected aliases to be a plain object, but received ${Array.isArray(t)?`array`:typeof t}`);if(Object.getPrototypeOf(t)!==Object.prototype&&Object.getPrototypeOf(t)!==null)throw TypeError(`Expected aliases to be a plain object, but received ${t.constructor.name||`object with custom prototype`}`);if(typeof n!=`string`)throw TypeError(`Expected projectRoot to be a string, but received ${typeof n}`);let r=v(t);for(let[t,a]of r)if(e.startsWith(`${t}/`)||e===t){let r=e.slice(t.length).replace(/^\/+/,``),o=i.join(a,r);return i.isAbsolute(o)?o:i.resolve(n,o)}return null}const b=/^node:/,x=/* @__PURE__ */ new Map;function S(e){let t=i.resolve(e.root);return JSON.stringify({root:t,configFile:e.configFile??null,logLevel:e.logLevel??null})}async function C(e){let t=typeof e==`string`?{root:e}:e,n=i.resolve(t.root),r=S(t),o=x.get(r);return o??(o=a({root:n,...t.configFile===void 0?{}:{configFile:t.configFile},...t.logLevel==null?{}:{logLevel:t.logLevel},oxc:{jsx:{development:!1}}}).catch(e=>{throw x.delete(r),e}),x.set(r,o)),o}function w(t){let n=i.resolve(t);for(let t of x.keys()){let r=JSON.parse(t);e(r)&&r.root===n&&x.delete(t)}}function T(e){return typeof e==`object`&&!!e&&`type`in e}function E(e){let t=Array.isArray(e)?e:[e],n=[];for(let e of t){if(typeof e!=`object`||!e)continue;let t=e.output;if(Array.isArray(t))for(let e of t)T(e)&&n.push(e)}return n}function D(e){return typeof e==`string`?e:n.from(e).toString(`utf8`)}function O(e){return e==null?[]:e instanceof Set?[...e].map(e=>t(String(e))):Array.isArray(e)?e.map(e=>t(String(e))):[]}const k=[b,`react`,`react-dom`,`react/jsx-runtime`,`react/jsx-dev-runtime`,`react/compiler-runtime`,/^rari(?:\/|$)/,`react-server-dom-rari/server`],A=[b,`react`,`react-dom`,`react/jsx-runtime`,`react/jsx-dev-runtime`,`react/compiler-runtime`,/^rari(?:\/|$)/,`react-server-dom-webpack/client`,/^react-server-dom-webpack\//];function j(e){return{write:e.write,emptyOutDir:e.emptyOutDir,copyPublicDir:e.copyPublicDir,minify:e.minify,emitAssets:e.emitAssets,rolldownOptions:e.rolldownOptions}}function M(e,t){e.write=t.write,e.emptyOutDir=t.emptyOutDir,e.copyPublicDir=t.copyPublicDir,e.minify=t.minify,e.emitAssets=t.emitAssets,e.rolldownOptions=t.rolldownOptions}function N(e){let n=/* @__PURE__ */ new Map,r=[],i=/* @__PURE__ */ new Map,a=/* @__PURE__ */ new Map;for(let o of e){if(o.type===`asset`){let e=t(o.fileName);e.endsWith(`.css`)?n.set(e,D(o.source)):r.push({fileName:e,code:o.source});continue}let e=t(o.fileName);if(o.isEntry){let e=o.name;if(e==null||e===``)continue;i.set(e,{code:o.code,cssAssetSources:[]}),a.set(e,O(o.viteMetadata?.importedCss));continue}r.push({fileName:e,code:o.code})}return{cssByFileName:n,extraFiles:r,entryOutputs:i,entryCssFiles:a}}function P(e,t,n){for(let[r,i]of e){let a=(t.get(r)??[]).map(e=>n.get(e)).filter(e=>e!=null);if(a.length===0&&e.size===1&&n.size>0){e.set(r,{...i,cssAssetSources:[...n.values()]});continue}e.set(r,{...i,cssAssetSources:a})}}async function F(e){let t=/* @__PURE__ */ new Map,n=[];for(let r of e.entries){let i=await L({...e,entries:[r]});if(i==null)return null;for(let[e,n]of i.outputs)t.set(e,n);n.push(...i.extraFiles)}return{outputs:t,extraFiles:n}}function I(e,t,n,r){e.write=!1,e.emptyOutDir=!1,e.copyPublicDir=!1,e.emitAssets=!0,e.minify=t.minify===!0&&`oxc`,e.rolldownOptions={...r,input:n,platform:`node`,output:{format:`es`,entryFileNames:`[name].js`,chunkFileNames:`chunks/[name]-[hash].js`,assetFileNames:`assets/[name]-[hash][extname]`,...t.codeSplitting===!1?{codeSplitting:!1}:{}},external:[...t.environmentName===`ssr`?A:k]}}async function L(t){if(t.entries.length===0)return{outputs:/* @__PURE__ */ new Map,extraFiles:[]};if(t.codeSplitting===!1&&t.entries.length>1)return F(t);let n=t.viteBuilder.environments[t.environmentName];if(n==null)return null;await n.init();let r={};for(let e of t.entries)r[e.entryName]=e.filePath;let i=n.config.build,a=j(i),o=e(a.rolldownOptions)?{...a.rolldownOptions}:{},s=t.label??t.environmentName.toUpperCase();try{I(i,t,r,o);let e=E(await t.viteBuilder.build(n));if(e.length===0)return null;let a=N(e);P(a.entryOutputs,a.entryCssFiles,a.cssByFileName);for(let e of t.entries)if(!a.entryOutputs.has(e.entryName))return null;return{outputs:a.entryOutputs,extraFiles:a.extraFiles}}catch(e){return console.warn(`[rari] Vite ${s} environment build failed:`,e),null}finally{M(i,a)}}async function R(e){return L({viteBuilder:e.viteBuilder,environmentName:`rsc`,entries:e.entries.map(e=>({entryName:e.componentId,filePath:e.filePath})),minify:e.minify,codeSplitting:e.codeSplitting,label:`RSC`})}async function z(e){return L({viteBuilder:e.viteBuilder,environmentName:`ssr`,entries:e.entries,minify:e.minify??!1,label:`SSR`})}function B(e,n){return t(i.join(e,`${n}.js`))}async function V(e){let t=await a({configFile:!1,root:e.root,logLevel:`error`,plugins:[...e.plugins],define:{global:`globalThis`},resolve:{conditions:[`import`,`module`,`default`],extensions:[`.mjs`,`.js`,`.ts`,`.tsx`,`.jsx`],mainFields:[`module`,`main`]},environments:{ssr:{consumer:`server`,build:{write:!1,emptyOutDir:!1,copyPublicDir:!1,emitAssets:!1,minify:!1,cssMinify:!1,target:`esnext`,rolldownOptions:{input:{entry:e.virtualId},platform:`node`,external:e.external,output:{format:`es`,codeSplitting:!1,entryFileNames:`[name].js`}}}}},builder:{sharedPlugins:!0},css:{transformer:`lightningcss`}}),n=t.environments.ssr;await n.init();let r=E(await t.build(n)),i=r.find(e=>e.type===`chunk`&&e.isEntry)??r.find(e=>e.type===`chunk`);return i?.type===`chunk`?{code:i.code}:null}export{C as a,u as c,w as i,m as l,R as n,B as o,z as r,y as s,V as t,g as u};
1
+ import{g as e}from"./type-guards-BLY2PlGR.mjs";import{o as t}from"./path-CTEC1xmy.mjs";import{Buffer as n}from"node:buffer";import r from"node:fs";import i from"node:path";import{createBuilder as a}from"vite-plus";const o=/* @__PURE__ */ new Map,s=/* @__PURE__ */ new Map;function c(e){let t=o.get(e);return t===void 0?(t=r.existsSync(e),o.set(e,t),t):t}function l(e){let t=s.get(e);if(t!==void 0)return t;try{t=r.statSync(e).isDirectory()}catch{t=!1}return s.set(e,t),t}function u(){o.clear(),s.clear()}function d(e,t){let n=null;for(let r of t)if(r!==``&&e.endsWith(r)&&(n??=c(e),n&&!l(e)))return e;for(let n of t){let t=`${e}${n}`;if(c(t)&&!l(t))return t}return null}function f(e,t){if(c(e)){if(!l(e))return null;for(let n of t){let t=i.join(e,`index${n}`);if(c(t))return t}}return null}const p=[`.tsx`,`.jsx`,`.ts`,`.js`];function m(e,t,n={},r=p){let a=e;for(let[t,r]of Object.entries(n))if(e.startsWith(`${t}/`)){a=e.replace(t,r);break}else if(e===t){a=r;break}let o=i.resolve(i.dirname(t),a),s=d(o,r);if(s!=null&&s!==``)return s;let c=f(o,r);return c!=null&&c!==``?c:`${o}.tsx`}const h=[`.ts`,`.tsx`,`.js`,`.jsx`,`.mjs`];function g(e,t=h){return d(e,t)??f(e,t)}const _=/* @__PURE__ */ new WeakMap;function v(e){let t=_.get(e);return t||(t=Object.entries(e).sort((e,t)=>t[0].length-e[0].length),_.set(e,t),t)}function y(e,t,n){if(typeof e!=`string`)throw TypeError(`Expected source to be a string, but received ${typeof e}`);if(typeof t!=`object`||Array.isArray(t))throw TypeError(`Expected aliases to be a plain object, but received ${Array.isArray(t)?`array`:typeof t}`);if(Object.getPrototypeOf(t)!==Object.prototype&&Object.getPrototypeOf(t)!==null)throw TypeError(`Expected aliases to be a plain object, but received ${t.constructor.name||`object with custom prototype`}`);if(typeof n!=`string`)throw TypeError(`Expected projectRoot to be a string, but received ${typeof n}`);let r=v(t);for(let[t,a]of r)if(e.startsWith(`${t}/`)||e===t){let r=e.slice(t.length).replace(/^\/+/,``),o=i.join(a,r);return i.isAbsolute(o)?o:i.resolve(n,o)}return null}const b=/^node:/,x=/* @__PURE__ */ new Map;function S(e){let t=i.resolve(e.root);return JSON.stringify({root:t,configFile:e.configFile??null,logLevel:e.logLevel??null})}async function C(e){let t=typeof e==`string`?{root:e}:e,n=i.resolve(t.root),r=S(t),o=x.get(r);return o??(o=a({root:n,...t.configFile===void 0?{}:{configFile:t.configFile},...t.logLevel==null?{}:{logLevel:t.logLevel},oxc:{jsx:{development:!1}}}).catch(e=>{throw x.delete(r),e}),x.set(r,o)),o}function w(t){let n=i.resolve(t);for(let t of x.keys()){let r=JSON.parse(t);e(r)&&r.root===n&&x.delete(t)}}function T(e){return typeof e==`object`&&!!e&&`type`in e}function E(e){let t=Array.isArray(e)?e:[e],n=[];for(let e of t){if(typeof e!=`object`||!e)continue;let t=e.output;if(Array.isArray(t))for(let e of t)T(e)&&n.push(e)}return n}function D(e){return typeof e==`string`?e:n.from(e).toString(`utf8`)}function O(e){return e==null?[]:e instanceof Set?[...e].map(e=>t(String(e))):Array.isArray(e)?e.map(e=>t(String(e))):[]}const k=[b,`react`,`react-dom`,`react/jsx-runtime`,`react/jsx-dev-runtime`,`react/compiler-runtime`,/^rari(?:\/|$)/,`react-server-dom-rari/server`],A=[b,`react`,`react-dom`,`react/jsx-runtime`,`react/jsx-dev-runtime`,`react/compiler-runtime`,/^rari(?:\/|$)/,`react-server-dom-webpack/client`,/^react-server-dom-webpack\//];function j(e){return{write:e.write,emptyOutDir:e.emptyOutDir,copyPublicDir:e.copyPublicDir,minify:e.minify,emitAssets:e.emitAssets,rolldownOptions:e.rolldownOptions}}function M(e,t){e.write=t.write,e.emptyOutDir=t.emptyOutDir,e.copyPublicDir=t.copyPublicDir,e.minify=t.minify,e.emitAssets=t.emitAssets,e.rolldownOptions=t.rolldownOptions}function N(e){let n=/* @__PURE__ */ new Map,r=[],i=/* @__PURE__ */ new Map,a=/* @__PURE__ */ new Map;for(let o of e){if(o.type===`asset`){let e=t(o.fileName);e.endsWith(`.css`)?n.set(e,D(o.source)):r.push({fileName:e,code:o.source});continue}let e=t(o.fileName);if(o.isEntry){let e=o.name;if(e==null||e===``)continue;i.set(e,{code:o.code,cssAssetSources:[]}),a.set(e,O(o.viteMetadata?.importedCss));continue}r.push({fileName:e,code:o.code})}return{cssByFileName:n,extraFiles:r,entryOutputs:i,entryCssFiles:a}}function P(e,t,n){for(let[r,i]of e){let a=(t.get(r)??[]).map(e=>n.get(e)).filter(e=>e!=null);if(a.length===0&&e.size===1&&n.size>0){e.set(r,{...i,cssAssetSources:[...n.values()]});continue}e.set(r,{...i,cssAssetSources:a})}}async function F(e){let t=/* @__PURE__ */ new Map,n=[];for(let r of e.entries){let i=await L({...e,entries:[r]});if(i==null)return null;for(let[e,n]of i.outputs)t.set(e,n);n.push(...i.extraFiles)}return{outputs:t,extraFiles:n}}function I(e,t,n,r){e.write=!1,e.emptyOutDir=!1,e.copyPublicDir=!1,e.emitAssets=!0,e.minify=t.minify===!0&&`oxc`,e.rolldownOptions={...r,input:n,platform:`node`,output:{format:`es`,entryFileNames:`[name].js`,chunkFileNames:`chunks/[name]-[hash].js`,assetFileNames:`assets/[name]-[hash][extname]`,...t.codeSplitting===!1?{codeSplitting:!1}:{}},external:[...t.environmentName===`ssr`?A:k]}}async function L(t){if(t.entries.length===0)return{outputs:/* @__PURE__ */ new Map,extraFiles:[]};if(t.codeSplitting===!1&&t.entries.length>1)return F(t);let n=t.viteBuilder.environments[t.environmentName];if(n==null)return null;await n.init();let r={};for(let e of t.entries)r[e.entryName]=e.filePath;let i=n.config.build,a=j(i),o=e(a.rolldownOptions)?{...a.rolldownOptions}:{},s=t.label??t.environmentName.toUpperCase();try{I(i,t,r,o);let e=E(await t.viteBuilder.build(n));if(e.length===0)return null;let a=N(e);P(a.entryOutputs,a.entryCssFiles,a.cssByFileName);for(let e of t.entries)if(!a.entryOutputs.has(e.entryName))return null;return{outputs:a.entryOutputs,extraFiles:a.extraFiles}}catch(e){return console.warn(`[rari] Vite ${s} environment build failed:`,e),null}finally{M(i,a)}}async function R(e){return L({viteBuilder:e.viteBuilder,environmentName:`rsc`,entries:e.entries.map(e=>({entryName:e.componentId,filePath:e.filePath})),minify:e.minify,codeSplitting:e.codeSplitting,label:`RSC`})}async function z(e){return L({viteBuilder:e.viteBuilder,environmentName:`ssr`,entries:e.entries,minify:e.minify??!1,label:`SSR`})}function B(e,n){return t(i.join(e,`${n}.js`))}async function V(e){let t=await a({configFile:!1,root:e.root,logLevel:`error`,plugins:[...e.plugins],define:{global:`globalThis`},resolve:{conditions:[`import`,`module`,`default`],extensions:[`.mjs`,`.js`,`.ts`,`.tsx`,`.jsx`],mainFields:[`module`,`main`]},environments:{ssr:{consumer:`server`,build:{write:!1,emptyOutDir:!1,copyPublicDir:!1,emitAssets:!1,minify:!1,cssMinify:!1,target:`esnext`,rolldownOptions:{input:{entry:e.virtualId},platform:`node`,external:e.external,output:{format:`es`,codeSplitting:!1,entryFileNames:`[name].js`}}}}},builder:{sharedPlugins:!0},css:{transformer:`lightningcss`}}),n=t.environments.ssr;await n.init();let r=E(await t.build(n)),i=r.find(e=>e.type===`chunk`&&e.isEntry)??r.find(e=>e.type===`chunk`);return i?.type===`chunk`?{code:i.code}:null}export{C as a,u as c,w as i,m as l,R as n,B as o,z as r,y as s,V as t,g as u};
@@ -11,7 +11,9 @@ interface RscPayload {
11
11
  readonly element: FlightContent;
12
12
  readonly flightProtocol?: string;
13
13
  readonly maySuspend?: boolean;
14
+ readonly hasLoadingFallback?: boolean;
14
15
  readonly pendingEvictLeaf?: PendingLeafEviction;
16
+ readonly bodyComplete?: Promise<boolean>;
15
17
  }
16
18
  interface NavigationOptions {
17
19
  readonly historyKey?: string;
@@ -1 +1 @@
1
- import{f as e,h as t,i as n,r,u as i,x as a}from"../type-guards-BozK2q2n.mjs";import{i as o}from"../navigation-transition-store-dfNJmkIX.mjs";import{isLayoutReuseMarker as s,layoutPathOf as c,mergeFlightRefresh as l,unwrapFulfilledFlightNode as u}from"./merge-flight-refresh.mjs";import{n as d,r as f,t as p}from"../react-helpers-BKmKvCbj.mjs";import{i as m,n as h,r as g,t as _}from"../route-cache-Cgh5HhiB.mjs";import"./action-revalidation-kind.mjs";import{n as v,t as y}from"../preload-modules-D_bnDKi8.mjs";import{n as ee,r as te}from"../form-state-DAygOjc8.mjs";import{c as b}from"react/compiler-runtime";import{Fragment as x,addTransitionType as ne,cloneElement as re,createElement as S,isValidElement as C,startTransition as ie,useCallback as ae,useEffect as w,useLayoutEffect as oe,useRef as T,useState as E,useSyncExternalStore as D}from"react";import{Fragment as se,jsx as O,jsxs as k}from"react/jsx-runtime";import{createFromFetch as ce,createFromReadableStream as le}from"virtual:react-flight-client";const A={position:`fixed`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,padding:`24px`,background:`rgba(220, 38, 38, 0.95)`,color:`white`,borderRadius:`8px`,fontSize:`14px`,zIndex:1e4,maxWidth:`500px`,boxShadow:`0 4px 6px rgba(0, 0, 0, 0.3)`},j={padding:`8px 16px`,background:`white`,color:`#dc2626`,border:`none`,borderRadius:`4px`,cursor:`pointer`,fontWeight:`bold`,fontSize:`14px`},M={padding:`8px 16px`,background:`rgba(255, 255, 255, 0.2)`,color:`white`,border:`1px solid rgba(255, 255, 255, 0.3)`,borderRadius:`4px`,cursor:`pointer`,fontSize:`14px`},N={fetch:`Failed to fetch updated content from server.`,parse:`Failed to parse server response.`,stale:`Server returned stale content.`,network:`Network error occurred.`};function P(e){return N[e]}function ue(e){let t=b(27),{failure:n,maxRetries:r,onRefresh:i,onDismiss:a}=e,o,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=/* @__PURE__ */ O(`div`,{style:{marginBottom:`16px`,fontWeight:`bold`,fontSize:`16px`},children:`⚠️ HMR Update Failed`}),s={marginBottom:`12px`,opacity:.9},t[0]=o,t[1]=s):(o=t[0],s=t[1]);let c;t[2]===n.type?c=t[3]:(c=P(n.type),t[2]=n.type,t[3]=c);let l;t[4]===c?l=t[5]:(l=/* @__PURE__ */ O(`div`,{style:s,children:c}),t[4]=c,t[5]=l);let u;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(u={marginBottom:`16px`,fontSize:`12px`,opacity:.8,fontFamily:`monospace`},t[6]=u):u=t[6];let d;t[7]===n.details?d=t[8]:(d=/* @__PURE__ */ O(`div`,{style:u,children:n.details}),t[7]=n.details,t[8]=d);let f;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(f={marginBottom:`12px`,fontSize:`12px`,opacity:.7},t[9]=f):f=t[9];let p;t[10]!==n.consecutiveFailures||t[11]!==r?(p=/* @__PURE__ */ k(`div`,{style:f,children:[`Consecutive failures: `,n.consecutiveFailures,` / `,r]}),t[10]=n.consecutiveFailures,t[11]=r,t[12]=p):p=t[12];let m;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(m={display:`flex`,gap:`8px`},t[13]=m):m=t[13];let h;t[14]===i?h=t[15]:(h=/* @__PURE__ */ O(`button`,{onClick:i,type:`button`,style:j,children:`Refresh Page`}),t[14]=i,t[15]=h);let g;t[16]===a?g=t[17]:(g=/* @__PURE__ */ O(`button`,{onClick:a,type:`button`,style:M,children:`Dismiss`}),t[16]=a,t[17]=g);let _;t[18]!==h||t[19]!==g?(_=/* @__PURE__ */ k(`div`,{style:m,children:[h,g]}),t[18]=h,t[19]=g,t[20]=_):_=t[20];let v;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(v=/* @__PURE__ */ O(`div`,{style:{marginTop:`12px`,fontSize:`11px`,opacity:.6},children:`Check the console for detailed error logs.`}),t[21]=v):v=t[21];let y;return t[22]!==_||t[23]!==l||t[24]!==d||t[25]!==p?(y=/* @__PURE__ */ k(`div`,{style:A,children:[o,l,d,p,_,v]}),t[22]=_,t[23]=l,t[24]=d,t[25]=p,t[26]=y):y=t[26],y}function de(e,t,n){g.getShell()??g.ingest(e,t,n)}function F(e){if(e.fromPathname!==`/`&&(e.fromPathname!==e.toPathname||e.fromSearch!==e.search))return{pathname:e.fromPathname,search:e.fromSearch}}function I(e){if(de(e.previousDocument,e.fromPathname,e.fromSearch),f(e.refresh)){if(!g.ingest(e.refresh,e.toPathname,e.search))return{kind:`hard-nav`}}else if(C(e.refresh)){if(!g.ingestSegment(e.refresh,e.toPathname,e.search))return{kind:`hard-nav`}}else return{kind:`hard-nav`};if(g.getShell()==null||!g.hasRoute(e.toPathname,e.search))return{kind:`hard-nav`};let t=d(e.refresh),n=F(e);return f(e.refresh)?{kind:`merged`,element:e.refresh,maySuspend:t,pendingEvictLeaf:n}:{kind:`merged`,element:e.previousDocument,maySuspend:t,pendingEvictLeaf:n}}function L(e,t,n,r){if(f(t))return g.ingest(t,n,r);if(C(t)&&g.getShell()!=null)return g.ingestSegment(t,n,r);let i=l(e,t);return C(t)&&s(t)&&i===e||!f(i)?!1:g.ingest(i,n,r)}function R(e,t){let n=d(e);return f(e)?{kind:`merged`,element:e,maySuspend:n}:f(t)?{kind:`merged`,element:t,maySuspend:n}:{kind:`hard-nav`}}function fe(e){return f(e.previousDocument)&&g.getShell()==null&&!g.ingest(e.previousDocument,e.pathname,e.search)||!L(e.previousDocument,e.refresh,e.pathname,e.search)||g.getShell()==null||!g.hasRoute(e.pathname,e.search)?{kind:`hard-nav`}:R(e.refresh,e.previousDocument)}function pe(e){return e.historyKey!=null&&e.historyKey!==``?[`nav`,`nav-traverse`]:e.replace===!0?[`nav`,`nav-replace`]:[`nav`,`nav-forward`]}function me(e,t){if(e==null||e.url===``)return t;try{let t=`http://localhost/`;if(typeof window<`u`)try{t=window.location.href}catch{}let n=new URL(e.url,t);return{pathname:n.pathname,search:n.search}}catch{return t}}function z(e){e!=null&&typeof window<`u`&&(e.replace===!0?window.history.replaceState(e.state,``,e.url):window.history.pushState(e.state,``,e.url))}function he(e){let{parsedPayload:t,shouldScrollToTop:n,navigationId:r,transitionTypes:i,maySuspend:a=!1,pendingHistory:o,routeLocation:s,startTransition:c=ie,currentNavigationIdRef:l,pendingScrollPayloadRef:u,setRenderKey:d,setRscPayload:f,setRouteLocation:p,clearHmrError:m,pendingNavigateCommittedIdRef:h,pendingEvictLeaf:_}=e;l.current===r&&(a&&z(o),c(()=>{if(l.current===r){if(i!=null)for(let e of i)ne(e);a||z(o),s!=null&&p?.(s),_!=null&&g.evictLeaf(_.pathname,_.search),d(e=>{let r=e+1;return u.current=n?{payload:t,commitKey:r}:null,r}),f(t),m(),h.current=r}}))}function B(){return D(g.subscribe,g.getVersion,g.getVersion)}function V(e){return c(e)!=null&&!m(e)&&!s(e)}function H(e,t,n){if(e==null||e===!1||e===!0)return e;if(Array.isArray(e))return p(e).map(e=>H(e,t,n));if(!C(e))return e;if(m(e)||V(e)){let r=c(e);return r==null?null:S(W,{key:r,layoutPath:r,pathname:t,search:n})}let r=e.props,i=r.children;if(i==null)return e;let a=H(i,t,n);if(Object.is(a,i))return e;let o=p(a),s={...r};return delete s.children,re(e,s,...o.length===0?[null]:o)}function U({layoutPath:e,pathname:t,search:n}){let r=g.readSegmentSnapshot(e,{pathname:t,search:n});return r==null||C(r)&&m(r)?null:g.isDeepestLayout(e,t)?S(x,{key:`${t}${n}`},r):H(r,t,n)}function W(e){let t=b(2);B();let n;return t[0]===e?n=t[1]:(n=U(e),t[0]=e,t[1]=n),n}function G({fallback:e=null,pathname:t,search:n}){let r=g.getShell();if(r!=null){let e=H(r,t,n);return C(e)?e:null}return e!=null&&_(e)?null:e}function ge(e){let t=b(2);B();let n;return t[0]===e?n=t[1]:(n=G(e),t[0]=e,t[1]=n),n}function _e(e,t,n){return e==null||e.commitKey!==n?{shouldScroll:!1,nextPending:null}:t===e.payload?{shouldScroll:!0,nextPending:null}:{shouldScroll:!1,nextPending:e}}function ve(t){if(t==null)return null;if(e(t)){let e=u(t);return e===t||!f(e)?null:e}return f(t)?t:null}const ye=/"timestamp":(\d+)/;function be(e){if(!i(e)||e.name===`AbortError`)return!1;let t=e.message;return t===`Failed to fetch`||t.includes(`NetworkError`)||t.includes(`network error`)||t.includes(`Load failed`)}async function xe(e){await new Promise(t=>{setTimeout(t,e)})}function Se(e){return e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`||C(e)||Array.isArray(e)}function Ce(e){return t(e)&&typeof e.from==`string`&&typeof e.to==`string`&&typeof e.navigationId==`number`&&t(e.options)}function we(e){return t(e)&&`element`in e}function Te(e){return t(e)&&typeof e.navigationId==`number`&&typeof e.targetPath==`string`}function Ee(n){if(!e(n))return n;if(t(n)&&n.status===`fulfilled`)return Se(n.value)?n.value:void 0}function K(e){return f(e)||C(e)&&s(e)}function De(e){let t=e.pendingHistory?.url;if(t!=null&&t!==``)try{return new URL(t,window.location.origin).search}catch{}return h().search}function Oe(e,t){console.error(`[rari] AppRouter: Navigation failed:`,t),window.dispatchEvent(new CustomEvent(`rari:navigate-error`,{detail:{from:e.from,to:e.to,error:t,navigationId:e.navigationId}}))}function ke(e){let t=e.pendingHistory?.url,n=t!=null&&t!==``?new URL(t,window.location.origin).hash.length>0:window.location.hash.length>0;return(e.options.historyKey==null||e.options.historyKey===``)&&!n&&e.options.scroll!==!1}async function Ae(e,t,n,r,i,a,o,c){let l=await je(e.element);if(r!==n)return{kind:`superseded`};if(!K(l))return{kind:`error`,error:/* @__PURE__ */ Error(`[rari] AppRouter: navigated Flight content did not resolve to an <html> document root`)};let u=ve(t);if(C(l)&&s(l)&&u==null)return{kind:`error`,error:/* @__PURE__ */ Error(`[rari] AppRouter: layout-reuse Flight marker requires a previous <html> document`)};if(u==null)return f(l)?(g.set(a,o,l),{kind:`payload`,payload:{...e,element:l,maySuspend:d(l)}}):{kind:`error`,error:/* @__PURE__ */ Error(`[rari] AppRouter: navigated Flight content did not resolve to an <html> document root`)};let p=I({previousDocument:u,refresh:l,fromPathname:i,toPathname:a,fromSearch:c,search:o});return p.kind===`hard-nav`?{kind:`hard-nav`}:{kind:`payload`,payload:{...e,element:p.element,maySuspend:p.maySuspend,pendingEvictLeaf:p.pendingEvictLeaf}}}async function je(t){let n=v(t);for(let t=0;t<10&&e(n);t+=1)n=v(await n);if(e(n))throw Error(`[rari] AppRouter: Flight content did not resolve to a React node`);return n}function q({children:s,initialPayload:c,onNavigate:l}){let[u,d]=E(c),p=T(c),[m,b]=E(0),[x,ne]=E(()=>h()),re=T(x),S=T({x:0,y:0}),D=T(null),A=T(/* @__PURE__ */ new Map),j=T(/* @__PURE__ */ new Set),M=T(l),N=T(0),P=T(0),de=T(/* @__PURE__ */ new Map),F=T(null),I=T(null),L=T(/* @__PURE__ */ new Map),R=T([]),z=T(null),B=T(0),[V,H]=E(null);w(()=>{re.current=x},[x]),w(()=>{M.current=l},[l]),oe(()=>{let{shouldScroll:e,nextPending:t}=_e(D.current,u,m);D.current=t,e&&window.scrollTo(0,0);let n=I.current;n!=null&&(I.current=null,window.dispatchEvent(new CustomEvent(`rari:navigate-committed`,{detail:{navigationId:n}})))},[u,m]),w(()=>{o()},[m]);let U=ae(t=>{if(t==null||e(t)||!C(t)||t.type!==`html`&&t.type!==`HTML`||_(t))return;let{pathname:n,search:r}=x;g.set(n,r,t)},[x]),W=T(U);w(()=>{W.current=U},[U]),w(()=>{p.current=u,u?.element!=null&&U(u.element)},[u,U]),w(()=>{if(u?.element!=null){let e=u.element;if(t(e)&&`status`in e&&e.status===`rejected`){let t=e.reason;t!=null&&t!==``&&console.error(`[rari] AppRouter: Flight payload rejected:`,t)}}},[u]);let G=()=>{A.current=ee()},ve=()=>{te(A.current)};oe(()=>{let e=F.current;e!=null&&u===e&&(F.current=null,window.scrollTo(S.current.x,S.current.y),ve())},[u,m]);let K=(e,t,n,r)=>{B.current+=1;let i={timestamp:Date.now(),error:e,type:t,details:n,filePath:r,consecutiveFailures:B.current};R.current.push(i),R.current.length>10&&R.current.shift(),B.current>=2&&H(i),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`rari:hmr-failure`,{detail:i}))},q=()=>{setTimeout(()=>{window.location.reload()},1e3)},Me=()=>{B.current>0&&(B.current=0)},Ne=e=>{if(z.current==null||z.current===``)return!1;if(e===z.current)return!0;let t=ye.exec(e);if(t){let e=Number.parseInt(t[1],10);if(Date.now()-e>5e3)return!0}return!1},Pe=e=>{y(e,j.current);let t=new ReadableStream({start(t){t.enqueue(new TextEncoder().encode(e)),t.close()}});return{element:le(t),flightProtocol:e}},Fe=async e=>{let t=await e;if(!t.body)throw Error(`Response has no body stream`);let n=t.clone(),r=ce(Promise.resolve(t));return n.text().then(async e=>{await y(e,j.current),e!==``&&(z.current=e)}).catch(()=>{}),{element:r,flightProtocol:``}},Ie=async(e,t)=>{try{let n=await e.clone().text();if(Ne(n))return L.current.delete(t),`stale`;await y(n,j.current);let r=await je(ce(Promise.resolve(e)));if(!f(r))throw Error(`[rari] AppRouter: refetched Flight content did not resolve to an <html> document root`);return{element:r,flightProtocol:n}}catch(e){if(i(e)&&e.name===`AbortError`)throw e;let t=a(e),n=Error(`Failed to parse RSC Flight protocol: ${t.message}`,{cause:t});return K(n,`parse`,n.message,window.location.pathname),n}},Le=async(e,t,n)=>{let r=e!=null&&e!==``?e:window.location.pathname,o=N.current,s=n?.commit!==!1,c=n?.expectedRoute!=null&&n.expectedSeq!=null?`:hmr:${n.expectedRoute}:${n.expectedSeq}`:``,l=`${o}:${r}${window.location.search}:${s?`commit`:`defer`}${c}`,u=L.current.get(l);if(u)return u;let f=n?.expectedRoute,p=n?.expectedSeq,m=(async()=>{try{let e=r+window.location.search,n=await fetch(e,{headers:{Accept:`text/x-component`,"rari-navigation-id":String(N.current)},cache:`no-store`,signal:t});if(!n.ok){let t=/* @__PURE__ */ Error(`Failed to fetch RSC data: ${n.status} ${n.statusText}`);throw K(t,`fetch`,`HTTP ${n.status} when fetching ${e}`,window.location.pathname),t}let i=await Ie(n,l);if(i===`stale`)return;if(i instanceof Error)throw i;let a=f==null||p==null||de.current.get(f)===p;return N.current===o&&a&&(s&&d(i),i.flightProtocol!=null&&i.flightProtocol!==``&&(z.current=i.flightProtocol),Me()),L.current.delete(l),i}catch(e){throw L.current.delete(l),i(e)&&e.name!==`AbortError`&&!e.message.includes(`Failed to fetch RSC data`)&&!e.message.includes(`Failed to parse`)&&K(e,`network`,`Network error: ${e.message}`,window.location.pathname),a(e)}})();return L.current.set(l,m),m},Re=T(Pe),ze=T(Fe),J=T(Le);w(()=>{Re.current=Pe,ze.current=Fe,J.current=Le}),w(()=>{if(typeof window>`u`)return;let t=async e=>{if(e.rscResponsePromise){let t=await e.rscResponsePromise;if(N.current!==e.navigationId)return;let n=await ze.current(Promise.resolve(t));return N.current===e.navigationId?n:void 0}if(e.rscResponse){let t=await ze.current(Promise.resolve(e.rscResponse));return N.current===e.navigationId?t:void 0}if(e.rscFlightProtocol!=null&&e.rscFlightProtocol!==``)return Re.current(e.rscFlightProtocol);if(!e.isStreaming)return J.current(e.to,e.abortSignal,{commit:!1})},o=async(e,t)=>{try{let n=await Ae(t,p.current?.element,e.navigationId,N.current,e.from,e.to,De(e),re.current.search);if(n.kind===`superseded`)return null;if(n.kind===`hard-nav`){let t=e.pendingHistory?.url!=null&&e.pendingHistory.url!==``?e.pendingHistory.url:e.to;return window.dispatchEvent(new CustomEvent(`rari:navigate-committed`,{detail:{navigationId:e.navigationId}})),window.location.assign(t),null}return n.kind===`error`?(Oe(e,n.error),null):N.current===e.navigationId?n.payload:null}catch(t){return Oe(e,a(t)),null}},s=(e,t)=>{let n=me(e.pendingHistory,{pathname:e.to,search:De(e)});he({parsedPayload:t,shouldScrollToTop:ke(e),navigationId:e.navigationId,transitionTypes:pe({historyKey:e.options.historyKey,replace:e.options.replace}),maySuspend:t.maySuspend===!0,pendingHistory:e.pendingHistory,routeLocation:n,pendingEvictLeaf:t.pendingEvictLeaf,startTransition:ie,currentNavigationIdRef:N,pendingScrollPayloadRef:D,setRenderKey:b,setRscPayload:d,setRouteLocation:ne,clearHmrError:()=>{H(null)},pendingNavigateCommittedIdRef:I}),t.flightProtocol!=null&&t.flightProtocol!==``&&(z.current=t.flightProtocol),Me(),M.current&&M.current(e)},c=async e=>{try{return{kind:`payload`,payload:await t(e)}}catch(e){return i(e)&&e.name===`AbortError`?{kind:`aborted`}:{kind:`error`,error:a(e)}}},l=async e=>{let t=n(e,Ce);if(!t||t.navigationId!==N.current)return;S.current={x:window.scrollX,y:window.scrollY},G();let r=await c(t);if(r.kind===`aborted`)return;if(r.kind===`error`){Oe(t,r.error),B.current>=3&&q();return}let i=r.payload;if(i==null&&t.isStreaming&&N.current===t.navigationId||i==null||N.current!==t.navigationId)return;let a=await o(t,i);a!=null&&s(t,a)},u=async e=>{let t;for(let n=0;n<3;n+=1)try{return await J.current(void 0,void 0,{commit:!0,expectedRoute:e.expectedRoute,expectedSeq:e.expectedSeq})}catch(e){if(t=e,!be(e)||n===2)throw e;await xe(150*(n+1))}throw a(t)},f=async()=>{let e=N.current,{pathname:t,search:n}=h(),r=`${t}${n}`,i=de.current,a=(i.get(r)??0)+1;i.set(r,a);let o=await u({expectedRoute:r,expectedSeq:a});if(N.current!==e)return!1;let{pathname:s,search:c}=h();return`${s}${c}`!==r||i.get(r)!==a?!1:(o?.element!=null&&W.current(o.element),!0)},m=async()=>{S.current={x:window.scrollX,y:window.scrollY},G();try{if(!await f())return;let e=N.current,{pathname:t,search:n}=h(),r=`${t}${n}`,i={x:S.current.x,y:S.current.y};b(e=>e+1),H(null),requestAnimationFrame(()=>{if(N.current!==e)return;let{pathname:t,search:n}=h();`${t}${n}`===r&&(window.scrollTo(i.x,i.y),ve())})}catch(e){console.error(`HMR refetch error:`,r(e,String(e))),B.current>=3&&q()}},_=t=>{let r=n(t,we);if(r?.element==null||!Se(r.element)&&!e(r.element))return;let{pathname:i,search:o}=h(),s=++P.current,c=N.current,l=`${i}${o}`;S.current={x:window.scrollX,y:window.scrollY},G();try{r.revalidationKind===1?g.clear():r.revalidatedPath!=null&&r.revalidatedPath!==``?g.invalidate(r.revalidatedPath,o):g.invalidate(i,o);let t=p.current?.element,n=g.getElement(i,o)??(t!=null&&e(t)?null:t??null),u=r.element;(async()=>{try{let e=await je(u);if(s!==P.current||N.current!==c)return;let{pathname:t,search:r}=h();if(`${t}${r}`!==l)return;let a=fe({previousDocument:n??null,refresh:e,pathname:i,search:o});if(a.kind===`hard-nav`){window.location.reload();return}let f=a.element;if(s!==P.current||N.current!==c)return;let p=h();if(`${p.pathname}${p.search}`!==l)return;let m={element:f};F.current=m,ie(()=>{d(m),H(null)}),W.current(f),Me()}catch(e){if(s!==P.current||N.current!==c)return;let t=a(e);K(t,`parse`,`Action flight refresh failed: ${t.message}`,window.location.pathname),B.current>=3&&q()}})()}catch(e){let t=a(e);K(t,`parse`,`Action flight refresh failed: ${t.message}`,window.location.pathname),B.current>=3&&q()}},v=async()=>{try{if(!await f())return;b(e=>e+1),H(null)}catch(e){console.error(`RSC invalidate error:`,r(e,String(e))),B.current>=3&&q()}},y=e=>{let t=n(e,Te);t&&(j.current.clear(),N.current=t.navigationId,P.current+=1,D.current=null,F.current=null)},ee=async()=>{try{if(!await f())return;H(null)}catch(e){console.error(`Manifest update error:`,r(e,String(e))),B.current>=3&&q()}},te=e=>{l(e)},x=()=>{m()},C=()=>{v()},ae=()=>{ee()};return window.addEventListener(`rari:navigation-start`,y),window.addEventListener(`rari:navigate`,te),window.addEventListener(`rari:app-router-rerender`,x),window.addEventListener(`rari:action-flight-refresh`,_),window.addEventListener(`rari:rsc-invalidate`,C),window.addEventListener(`rari:app-router-manifest-updated`,ae),()=>{window.removeEventListener(`rari:navigation-start`,y),window.removeEventListener(`rari:navigate`,te),window.removeEventListener(`rari:app-router-rerender`,x),window.removeEventListener(`rari:action-flight-refresh`,_),window.removeEventListener(`rari:rsc-invalidate`,C),window.removeEventListener(`rari:app-router-manifest-updated`,ae)}},[]),w(()=>{if(typeof window<`u`&&window.location.hash&&u){let e=window.location.hash.slice(1);requestAnimationFrame(()=>{requestAnimationFrame(()=>{let t=document.getElementById(e);t&&t.scrollIntoView({behavior:`instant`,block:`start`})})})}},[u]);let Be=u?.element??s,Y=v(Be),[X,Ve]=E(null),He=Ee(Y),Ue=e(Y)&&He===void 0,Z=He===void 0?e(Y)?null:Y:v(He),Q=Z!=null&&!e(Z)&&f(Z)?Z:null;Q!=null&&!Object.is(Q,X)&&!_(Q)&&Ve(Q);let $=Ue?X:Q,We=$!=null&&f($)&&!_($)?$:X!=null&&f(X)&&!_(X)?X:null;if(We==null&&!g.hasRoute(x.pathname,x.search))throw Error(`[rari] AppRouter: expected a resolved <html> document root`);return/* @__PURE__ */ k(se,{children:[V!=null&&/* @__PURE__ */ O(ue,{failure:V,maxRetries:3,onRefresh:()=>{window.location.reload()},onDismiss:()=>{H(null)}}),/* @__PURE__ */ O(ge,{fallback:We,pathname:x.pathname,search:x.search})]})}export{q as AppRouterProvider};
1
+ import{S as e,d as t,g as n,i as r,p as i,r as a,s as o}from"../type-guards-BLY2PlGR.mjs";import{i as s}from"../navigation-transition-store-dfNJmkIX.mjs";import{isLayoutReuseMarker as c,layoutPathOf as l,mergeFlightRefresh as u,unwrapFulfilledFlightNode as d}from"./merge-flight-refresh.mjs";import{a as f,i as p,n as m,r as h,t as g}from"../react-helpers-duOBWuYF.mjs";import{i as _,n as v,r as y,t as b}from"../route-cache-D2iIKQIU.mjs";import"./action-revalidation-kind.mjs";import{n as x,t as ee}from"../preload-modules-BDQFWAlZ.mjs";import{n as te,r as ne}from"../form-state-DAygOjc8.mjs";import{c as S}from"react/compiler-runtime";import{Suspense as C,addTransitionType as re,cloneElement as ie,createContext as w,createElement as T,isValidElement as E,startTransition as ae,use as D,useCallback as oe,useEffect as O,useLayoutEffect as se,useRef as k,useState as A,useSyncExternalStore as j}from"react";import{jsx as M,jsxs as N}from"react/jsx-runtime";import{createFromFetch as ce,createFromReadableStream as le}from"virtual:react-flight-client";const ue={position:`fixed`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,padding:`24px`,background:`rgba(220, 38, 38, 0.95)`,color:`white`,borderRadius:`8px`,fontSize:`14px`,zIndex:1e4,maxWidth:`500px`,boxShadow:`0 4px 6px rgba(0, 0, 0, 0.3)`},P={padding:`8px 16px`,background:`white`,color:`#dc2626`,border:`none`,borderRadius:`4px`,cursor:`pointer`,fontWeight:`bold`,fontSize:`14px`},F={padding:`8px 16px`,background:`rgba(255, 255, 255, 0.2)`,color:`white`,border:`1px solid rgba(255, 255, 255, 0.3)`,borderRadius:`4px`,cursor:`pointer`,fontSize:`14px`},de={fetch:`Failed to fetch updated content from server.`,parse:`Failed to parse server response.`,stale:`Server returned stale content.`,network:`Network error occurred.`};function I(e){return de[e]}function fe(e){let t=S(27),{failure:n,maxRetries:r,onRefresh:i,onDismiss:a}=e,o,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=/* @__PURE__ */ M(`div`,{style:{marginBottom:`16px`,fontWeight:`bold`,fontSize:`16px`},children:`⚠️ HMR Update Failed`}),s={marginBottom:`12px`,opacity:.9},t[0]=o,t[1]=s):(o=t[0],s=t[1]);let c;t[2]===n.type?c=t[3]:(c=I(n.type),t[2]=n.type,t[3]=c);let l;t[4]===c?l=t[5]:(l=/* @__PURE__ */ M(`div`,{style:s,children:c}),t[4]=c,t[5]=l);let u;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(u={marginBottom:`16px`,fontSize:`12px`,opacity:.8,fontFamily:`monospace`},t[6]=u):u=t[6];let d;t[7]===n.details?d=t[8]:(d=/* @__PURE__ */ M(`div`,{style:u,children:n.details}),t[7]=n.details,t[8]=d);let f;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(f={marginBottom:`12px`,fontSize:`12px`,opacity:.7},t[9]=f):f=t[9];let p;t[10]!==n.consecutiveFailures||t[11]!==r?(p=/* @__PURE__ */ N(`div`,{style:f,children:[`Consecutive failures: `,n.consecutiveFailures,` / `,r]}),t[10]=n.consecutiveFailures,t[11]=r,t[12]=p):p=t[12];let m;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(m={display:`flex`,gap:`8px`},t[13]=m):m=t[13];let h;t[14]===i?h=t[15]:(h=/* @__PURE__ */ M(`button`,{onClick:i,type:`button`,style:P,children:`Refresh Page`}),t[14]=i,t[15]=h);let g;t[16]===a?g=t[17]:(g=/* @__PURE__ */ M(`button`,{onClick:a,type:`button`,style:F,children:`Dismiss`}),t[16]=a,t[17]=g);let _;t[18]!==h||t[19]!==g?(_=/* @__PURE__ */ N(`div`,{style:m,children:[h,g]}),t[18]=h,t[19]=g,t[20]=_):_=t[20];let v;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(v=/* @__PURE__ */ M(`div`,{style:{marginTop:`12px`,fontSize:`11px`,opacity:.6},children:`Check the console for detailed error logs.`}),t[21]=v):v=t[21];let y;return t[22]!==_||t[23]!==l||t[24]!==d||t[25]!==p?(y=/* @__PURE__ */ N(`div`,{style:ue,children:[o,l,d,p,_,v]}),t[22]=_,t[23]=l,t[24]=d,t[25]=p,t[26]=y):y=t[26],y}function L(e,t,n){y.getShell()??y.ingest(e,t,n)}function R(e){if(e.fromPathname!==`/`&&(e.fromPathname!==e.toPathname||e.fromSearch!==e.search))return{pathname:e.fromPathname,search:e.fromSearch}}function z(e){if(L(e.previousDocument,e.fromPathname,e.fromSearch),h(e.refresh)){if(!y.ingest(e.refresh,e.toPathname,e.search))return{kind:`hard-nav`}}else if(E(e.refresh)){if(!y.ingestSegment(e.refresh,e.toPathname,e.search))return{kind:`hard-nav`}}else return{kind:`hard-nav`};if(y.getShell()==null||!y.hasRoute(e.toPathname,e.search))return{kind:`hard-nav`};let t=y.readLeaf(e.toPathname,e.search),n=m(e.refresh)||t!=null&&m(t),r=t!=null&&p(t)||p(e.refresh),i=R(e);return h(e.refresh)?{kind:`merged`,element:e.refresh,maySuspend:n,hasLoadingFallback:r,pendingEvictLeaf:i}:{kind:`merged`,element:e.previousDocument,maySuspend:n,hasLoadingFallback:r,pendingEvictLeaf:i}}function B(e,t,n,r){if(h(t))return y.ingest(t,n,r);if(E(t)&&y.getShell()!=null)return y.ingestSegment(t,n,r);let i=u(e,t);return E(t)&&c(t)&&i===e||!h(i)?!1:y.ingest(i,n,r)}function V(e,t){let n=m(e),r=p(e);return h(e)?{kind:`merged`,element:e,maySuspend:n,hasLoadingFallback:r}:h(t)?{kind:`merged`,element:t,maySuspend:n,hasLoadingFallback:r}:{kind:`hard-nav`}}function pe(e){return h(e.previousDocument)&&y.getShell()==null&&!y.ingest(e.previousDocument,e.pathname,e.search)||!B(e.previousDocument,e.refresh,e.pathname,e.search)||y.getShell()==null||!y.hasRoute(e.pathname,e.search)?{kind:`hard-nav`}:V(e.refresh,e.previousDocument)}function me(e){return e.historyKey!=null&&e.historyKey!==``?[`nav`,`nav-traverse`]:e.replace===!0?[`nav`,`nav-replace`]:[`nav`,`nav-forward`]}function he(e,t){if(e==null||e.url===``)return t;try{let t=`http://localhost/`;if(typeof window<`u`)try{t=window.location.href}catch{}let n=new URL(e.url,t);return{pathname:n.pathname,search:n.search}}catch{return t}}function H(e){e!=null&&typeof window<`u`&&(e.replace===!0?window.history.replaceState(e.state,``,e.url):window.history.pushState(e.state,``,e.url))}function ge(e){let{parsedPayload:t,shouldScrollToTop:n,navigationId:r,transitionTypes:i,maySuspend:a=!1,hasLoadingFallback:o=!1,pendingHistory:s,routeLocation:c,startTransition:l=ae,currentNavigationIdRef:u,pendingScrollPayloadRef:d,setRenderKey:f,setRscPayload:p,setRouteLocation:m,setPendingLoadingLeaf:h,clearHmrError:g,pendingNavigateCommittedIdRef:_,pendingEvictLeaf:v}=e;if(u.current!==r)return;let b=a&&o;a&&H(s),b&&c!=null&&(m?.(c),h?.(c));let x=()=>{u.current===r&&(h?.(null),a||H(s),c!=null&&m?.(c),v!=null&&y.evictLeaf(v.pathname,v.search),f(e=>{let r=e+1;return d.current=n?{payload:t,commitKey:r}:null,r}),p(t),g(),_.current=r)};l(()=>{if(i!=null)for(let e of i)re(e);x()})}const _e=w(null);function U(){return D(_e)}function W(e,t,n){return n?.pathname===e&&n.search===t}function G(){return j(y.subscribe,y.getVersion,y.getVersion)}function K(e){return l(e)!=null&&!_(e)&&!c(e)}function q(e,t,n){if(e==null||e===!1||e===!0)return e;if(Array.isArray(e))return g(e).map(e=>q(e,t,n));if(!E(e))return e;if(_(e)||K(e)){let r=l(e);return r==null?null:T(Y,{key:r,layoutPath:r,pathname:t,search:n})}let r=e.props,i=r.children;if(i==null)return e;let a=q(i,t,n);if(Object.is(a,i))return e;let o=g(a),s={...r};return delete s.children,ie(e,s,...o.length===0?[null]:o)}function J({layoutPath:e,pathname:t,search:n},r,i=null){let a=y.readSegmentSnapshot(e,{pathname:t,search:n});if(a==null||E(a)&&_(a))return null;if(y.isDeepestLayout(e,t)){let{fallback:e,content:r}=f(a);return W(t,n,i)&&e!=null?e:T(C,{fallback:e},r)}return q(a,t,n)}function Y(e){let t=S(4),n=G(),r=U(),i;return t[0]!==n||t[1]!==r||t[2]!==e?(i=J(e,n,r),t[0]=n,t[1]=r,t[2]=e,t[3]=i):i=t[3],i}function ve({fallback:e=null,pathname:t,search:n},r){let i=y.getShell();if(i!=null){let e=q(i,t,n);return E(e)?e:null}return e!=null&&b(e)?null:e}function ye(e){let t=S(3),n=G(),r;return t[0]!==n||t[1]!==e?(r=ve(e,n),t[0]=n,t[1]=e,t[2]=r):r=t[2],r}function be(e,t,n){return e==null||e.commitKey!==n?{shouldScroll:!1,nextPending:null}:t===e.payload?{shouldScroll:!0,nextPending:null}:{shouldScroll:!1,nextPending:e}}function xe(e){if(e==null)return null;if(i(e)){let t=d(e);return t===e||!h(t)?null:t}return h(e)?e:null}const Se=/"timestamp":(\d+)/;function Ce(e){if(!t(e)||o(e))return!1;let n=e.message;return n===`Failed to fetch`||n.includes(`NetworkError`)||n.includes(`network error`)||n.includes(`Load failed`)}async function we(e){await new Promise(t=>{setTimeout(t,e)})}async function X(e,t,n){if(e.maySuspend!==!0||e.hasLoadingFallback!==!0)return e;if(e.bodyComplete==null){await Promise.resolve();let r=y.readLeaf(t,n);return r!=null&&!m(r)?{...e,maySuspend:!1}:e}if(await Promise.race([e.bodyComplete.then(e=>e?`body`:`failed`),we(100).then(()=>`timeout`)])===`body`)return{...e,maySuspend:!1};let r=y.readLeaf(t,n);return r!=null&&!m(r)?{...e,maySuspend:!1}:e}function Te(e){return e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`||E(e)||Array.isArray(e)}function Ee(e){return n(e)&&typeof e.from==`string`&&typeof e.to==`string`&&typeof e.navigationId==`number`&&n(e.options)}function De(e){return n(e)&&`element`in e}function Oe(e){return n(e)&&typeof e.navigationId==`number`&&typeof e.targetPath==`string`}function ke(e){if(!i(e))return e;if(n(e)&&e.status===`fulfilled`)return Te(e.value)?e.value:void 0}function Ae(e){return h(e)||E(e)&&c(e)}function je(e){let t=e.pendingHistory?.url;if(t!=null&&t!==``)try{return new URL(t,window.location.origin).search}catch{}return v().search}function Me(e,t){console.error(`[rari] AppRouter: Navigation failed:`,t),window.dispatchEvent(new CustomEvent(`rari:navigate-error`,{detail:{from:e.from,to:e.to,error:t,navigationId:e.navigationId}}))}function Ne(e){let t=e.pendingHistory?.url,n=t!=null&&t!==``?new URL(t,window.location.origin).hash.length>0:window.location.hash.length>0;return(e.options.historyKey==null||e.options.historyKey===``)&&!n&&e.options.scroll!==!1}async function Pe(e,t,n,r,i,a,o,s){let l=await Fe(e.element);if(r!==n)return{kind:`superseded`};if(!Ae(l))return{kind:`error`,error:/* @__PURE__ */ Error(`[rari] AppRouter: navigated Flight content did not resolve to an <html> document root`)};let u=xe(t);if(E(l)&&c(l)&&u==null)return{kind:`error`,error:/* @__PURE__ */ Error(`[rari] AppRouter: layout-reuse Flight marker requires a previous <html> document`)};if(u==null)return h(l)?(y.set(a,o,l),{kind:`payload`,payload:await X({...e,element:l,maySuspend:m(l),hasLoadingFallback:p(l)},a,o)}):{kind:`error`,error:/* @__PURE__ */ Error(`[rari] AppRouter: navigated Flight content did not resolve to an <html> document root`)};let d=z({previousDocument:u,refresh:l,fromPathname:i,toPathname:a,fromSearch:s,search:o});return d.kind===`hard-nav`?{kind:`hard-nav`}:{kind:`payload`,payload:await X({...e,element:d.element,maySuspend:d.maySuspend,hasLoadingFallback:d.hasLoadingFallback===!0,pendingEvictLeaf:d.pendingEvictLeaf},a,o)}}async function Fe(e){let t=x(e);for(let e=0;e<10&&i(t);e+=1)t=x(await t);if(i(t))throw Error(`[rari] AppRouter: Flight content did not resolve to a React node`);return t}function Ie({children:c,initialPayload:l,onNavigate:u}){let[d,f]=A(l),p=k(l),[m,g]=A(0),[_,S]=A(()=>v()),[C,re]=A(null),ie=k(_),w=k({x:0,y:0}),T=k(null),D=k(/* @__PURE__ */ new Map),j=k(/* @__PURE__ */ new Set),ue=k(u),P=k(0),F=k(0),de=k(/* @__PURE__ */ new Map),I=k(null),L=k(null),R=k(/* @__PURE__ */ new Map),z=k([]),B=k(null),V=k(0),[H,U]=A(null);O(()=>{ie.current=_},[_]),O(()=>{ue.current=u},[u]),se(()=>{let{shouldScroll:e,nextPending:t}=be(T.current,d,m);T.current=t,e&&window.scrollTo(0,0);let n=L.current;n!=null&&(L.current=null,window.dispatchEvent(new CustomEvent(`rari:navigate-committed`,{detail:{navigationId:n}})))},[d,m]),O(()=>{s()},[m]);let W=oe(e=>{if(e==null||i(e)||!E(e)||e.type!==`html`&&e.type!==`HTML`||b(e))return;let{pathname:t,search:n}=_;y.getShell()!=null&&y.hasRoute(t,n)||y.set(t,n,e)},[_]),G=k(W);O(()=>{G.current=W},[W]),O(()=>{p.current=d,d?.element!=null&&W(d.element)},[d,W]),O(()=>{if(d?.element!=null){let e=d.element;if(n(e)&&`status`in e&&e.status===`rejected`){let t=e.reason;t!=null&&t!==``&&console.error(`[rari] AppRouter: Flight payload rejected:`,t)}}},[d]);let K=()=>{D.current=te()},q=()=>{ne(D.current)};se(()=>{let e=I.current;e!=null&&d===e&&(I.current=null,window.scrollTo(w.current.x,w.current.y),q())},[d,m]);let J=(e,t,n,r)=>{V.current+=1;let i={timestamp:Date.now(),error:e,type:t,details:n,filePath:r,consecutiveFailures:V.current};z.current.push(i),z.current.length>10&&z.current.shift(),V.current>=2&&U(i),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`rari:hmr-failure`,{detail:i}))},Y=()=>{setTimeout(()=>{window.location.reload()},1e3)},ve=()=>{V.current>0&&(V.current=0)},xe=e=>{if(B.current==null||B.current===``)return!1;if(e===B.current)return!0;let t=Se.exec(e);if(t){let e=Number.parseInt(t[1],10);if(Date.now()-e>5e3)return!0}return!1},X=e=>{ee(e,j.current);let t=new ReadableStream({start(t){t.enqueue(new TextEncoder().encode(e)),t.close()}});return{element:le(t),flightProtocol:e}},Ae=async e=>{let t=await e;if(!t.body)throw Error(`Response has no body stream`);let n=t.clone();return{element:ce(Promise.resolve(t)),flightProtocol:``,bodyComplete:n.text().then(async e=>(await ee(e,j.current),e!==``&&(B.current=e),!0)).catch(()=>!1)}},Ie=async(t,n)=>{try{let e=await t.text();if(xe(e))return R.current.delete(n),`stale`;let r=await Fe(X(e).element);if(!h(r))throw Error(`[rari] AppRouter: refetched Flight content did not resolve to an <html> document root`);return{element:r,flightProtocol:e}}catch(t){if(o(t))throw t;let n=e(t),r=Error(`Failed to parse RSC Flight protocol: ${n.message}`,{cause:n});return J(r,`parse`,r.message,window.location.pathname),r}},Le=async(n,r,i)=>{let a=n!=null&&n!==``?n:window.location.pathname,s=P.current,c=i?.commit!==!1,l=i?.expectedRoute!=null&&i.expectedSeq!=null?`:hmr:${i.expectedRoute}:${i.expectedSeq}`:``,u=`${s}:${a}${window.location.search}:${c?`commit`:`defer`}${l}`,d=R.current.get(u);if(d)return d;let p=i?.expectedRoute,m=i?.expectedSeq,h=(async()=>{try{let e=a+window.location.search,t=await fetch(e,{headers:{Accept:`text/x-component`,"rari-navigation-id":String(P.current)},cache:`no-store`,signal:r});if(!t.ok){let n=/* @__PURE__ */ Error(`Failed to fetch RSC data: ${t.status} ${t.statusText}`);throw J(n,`fetch`,`HTTP ${t.status} when fetching ${e}`,window.location.pathname),n}let n=await Ie(t,u);if(n===`stale`)return;if(n instanceof Error)throw n;let i=p==null||m==null||de.current.get(p)===m;return P.current===s&&i&&(c&&f(n),n.flightProtocol!=null&&n.flightProtocol!==``&&(B.current=n.flightProtocol),ve()),R.current.delete(u),n}catch(n){throw R.current.delete(u),t(n)&&!o(n)&&!n.message.includes(`Failed to fetch RSC data`)&&!n.message.includes(`Failed to parse`)&&J(n,`network`,`Network error: ${n.message}`,window.location.pathname),e(n)}})();return R.current.set(u,h),h},Re=k(X),ze=k(Ae),Be=k(Le);O(()=>{Re.current=X,ze.current=Ae,Be.current=Le}),O(()=>{if(typeof window>`u`)return;let t=async e=>{if(e.rscResponsePromise){let t=await e.rscResponsePromise;if(P.current!==e.navigationId)return;let n=await ze.current(Promise.resolve(t));return P.current===e.navigationId?n:void 0}if(e.rscResponse){let t=await ze.current(Promise.resolve(e.rscResponse));return P.current===e.navigationId?t:void 0}if(e.rscFlightProtocol!=null&&e.rscFlightProtocol!==``)return Re.current(e.rscFlightProtocol);if(!e.isStreaming)return Be.current(e.to,e.abortSignal,{commit:!1})},n=async(t,n)=>{try{let e=await Pe(n,p.current?.element,t.navigationId,P.current,t.from,t.to,je(t),ie.current.search);if(e.kind===`superseded`)return null;if(e.kind===`hard-nav`){if(P.current!==t.navigationId)return null;let e=t.pendingHistory?.url!=null&&t.pendingHistory.url!==``?t.pendingHistory.url:t.to;return window.dispatchEvent(new CustomEvent(`rari:navigate-committed`,{detail:{navigationId:t.navigationId}})),window.location.assign(e),null}return e.kind===`error`?(Me(t,e.error),null):P.current===t.navigationId?e.payload:null}catch(n){return Me(t,e(n)),null}},s=(e,t)=>{let n=he(e.pendingHistory,{pathname:e.to,search:je(e)});ge({parsedPayload:t,shouldScrollToTop:Ne(e),navigationId:e.navigationId,transitionTypes:me({historyKey:e.options.historyKey,replace:e.options.replace}),maySuspend:t.maySuspend===!0,hasLoadingFallback:t.hasLoadingFallback===!0,pendingHistory:e.pendingHistory,routeLocation:n,pendingEvictLeaf:t.pendingEvictLeaf,startTransition:ae,currentNavigationIdRef:P,pendingScrollPayloadRef:T,setRenderKey:g,setRscPayload:f,setRouteLocation:S,setPendingLoadingLeaf:re,clearHmrError:()=>{U(null)},pendingNavigateCommittedIdRef:L}),t.flightProtocol!=null&&t.flightProtocol!==``&&(B.current=t.flightProtocol),ve(),ue.current&&ue.current(e)},c=async n=>{try{return{kind:`payload`,payload:await t(n)}}catch(t){return o(t)?{kind:`aborted`}:{kind:`error`,error:e(t)}}},l=async e=>{let t=r(e,Ee);if(!t||t.navigationId!==P.current)return;w.current={x:window.scrollX,y:window.scrollY},K();let i=await c(t);if(i.kind===`aborted`)return;if(i.kind===`error`){Me(t,i.error),V.current>=3&&Y();return}let a=i.payload;if(a==null&&t.isStreaming&&P.current===t.navigationId||a==null||P.current!==t.navigationId)return;let o=await n(t,a);o!=null&&s(t,o)},u=async t=>{let n;for(let e=0;e<3;e+=1)try{return await Be.current(void 0,void 0,{commit:!0,expectedRoute:t.expectedRoute,expectedSeq:t.expectedSeq})}catch(t){if(n=t,!Ce(t)||e===2)throw t;await we(150*(e+1))}throw e(n)},d=async()=>{let e=P.current,{pathname:t,search:n}=v(),r=`${t}${n}`,a=de.current,o=(a.get(r)??0)+1;a.set(r,o);let s=await u({expectedRoute:r,expectedSeq:o});if(P.current!==e)return!1;let{pathname:c,search:l}=v();if(`${c}${l}`!==r||a.get(r)!==o)return!1;let d=s?.element;return d!=null&&!i(d)&&E(d)&&(d.type===`html`||d.type===`HTML`)&&!b(d)&&y.set(t,n,d),!0},m=async()=>{w.current={x:window.scrollX,y:window.scrollY},K();try{if(!await d())return;let e=P.current,{pathname:t,search:n}=v(),r=`${t}${n}`,i={x:w.current.x,y:w.current.y};g(e=>e+1),U(null),requestAnimationFrame(()=>{if(P.current!==e)return;let{pathname:t,search:n}=v();`${t}${n}`===r&&(window.scrollTo(i.x,i.y),q())})}catch(e){console.error(`HMR refetch error:`,a(e,String(e))),V.current>=3&&Y()}},h=t=>{let n=r(t,De);if(n?.element==null||!Te(n.element)&&!i(n.element))return;let{pathname:a,search:o}=v(),s=++F.current,c=P.current,l=`${a}${o}`;w.current={x:window.scrollX,y:window.scrollY},K();try{n.revalidationKind===1?y.clear():n.revalidatedPath!=null&&n.revalidatedPath!==``?y.invalidate(n.revalidatedPath,o):y.invalidate(a,o);let t=p.current?.element,r=y.getElement(a,o)??(t!=null&&i(t)?null:t??null),u=n.element;(async()=>{try{let e=await Fe(u);if(s!==F.current||P.current!==c)return;let{pathname:t,search:n}=v();if(`${t}${n}`!==l)return;let i=pe({previousDocument:r??null,refresh:e,pathname:a,search:o});if(i.kind===`hard-nav`){window.location.reload();return}let d=i.element;if(s!==F.current||P.current!==c)return;let p=v();if(`${p.pathname}${p.search}`!==l)return;let m={element:d};I.current=m,ae(()=>{f(m),U(null)}),G.current(d),ve()}catch(t){if(s!==F.current||P.current!==c)return;let n=e(t);J(n,`parse`,`Action flight refresh failed: ${n.message}`,window.location.pathname),V.current>=3&&Y()}})()}catch(t){let n=e(t);J(n,`parse`,`Action flight refresh failed: ${n.message}`,window.location.pathname),V.current>=3&&Y()}},_=async()=>{try{if(!await d())return;g(e=>e+1),U(null)}catch(e){console.error(`RSC invalidate error:`,a(e,String(e))),V.current>=3&&Y()}},x=e=>{let t=r(e,Oe);t&&(j.current.clear(),P.current=t.navigationId,F.current+=1,T.current=null,I.current=null,re(null))},ee=async()=>{try{if(!await d())return;U(null)}catch(e){console.error(`Manifest update error:`,a(e,String(e))),V.current>=3&&Y()}},te=e=>{l(e)},ne=()=>{m()},C=()=>{_()},D=()=>{ee()};return window.addEventListener(`rari:navigation-start`,x),window.addEventListener(`rari:navigate`,te),window.addEventListener(`rari:app-router-rerender`,ne),window.addEventListener(`rari:action-flight-refresh`,h),window.addEventListener(`rari:rsc-invalidate`,C),window.addEventListener(`rari:app-router-manifest-updated`,D),()=>{window.removeEventListener(`rari:navigation-start`,x),window.removeEventListener(`rari:navigate`,te),window.removeEventListener(`rari:app-router-rerender`,ne),window.removeEventListener(`rari:action-flight-refresh`,h),window.removeEventListener(`rari:rsc-invalidate`,C),window.removeEventListener(`rari:app-router-manifest-updated`,D)}},[]),O(()=>{if(typeof window<`u`&&window.location.hash&&d){let e=window.location.hash.slice(1);requestAnimationFrame(()=>{requestAnimationFrame(()=>{let t=document.getElementById(e);t&&t.scrollIntoView({behavior:`instant`,block:`start`})})})}},[d]);let Ve=d?.element??c,He=x(Ve),[Z,Ue]=A(null),We=ke(He),Ge=i(He)&&We===void 0,Ke=We===void 0?i(He)?null:He:x(We),Q=Ke!=null&&!i(Ke)&&h(Ke)?Ke:null;Q!=null&&!Object.is(Q,Z)&&!b(Q)&&Ue(Q);let $=Ge?Z:Q,qe=$!=null&&h($)&&!b($)?$:Z!=null&&h(Z)&&!b(Z)?Z:null;if(qe==null&&!y.hasRoute(_.pathname,_.search))throw Error(`[rari] AppRouter: expected a resolved <html> document root`);return/* @__PURE__ */ N(_e,{value:C,children:[H!=null&&/* @__PURE__ */ M(fe,{failure:H,maxRetries:3,onRefresh:()=>{window.location.reload()},onDismiss:()=>{U(null)}}),/* @__PURE__ */ M(ye,{fallback:qe,pathname:_.pathname,search:_.search})]})}export{Ie as AppRouterProvider};
@@ -1,7 +1,7 @@
1
- import{i as e,t}from"../navigate-DuyUa6qD.mjs";import{h as n,i as r,m as i,n as a,u as o}from"../type-guards-BozK2q2n.mjs";import{r as s}from"../path-CTEC1xmy.mjs";import{a as ee}from"../route-cache-Cgh5HhiB.mjs";import{t as c}from"../form-state-DAygOjc8.mjs";import{c as l}from"react/compiler-runtime";import{useEffect as u,useLayoutEffect as d,useRef as f,useState as p}from"react";function m(e,t,n={}){let r=null,i=0,a=0,o=null,s=null,{leading:ee=!1,trailing:c=!0,maxWait:l}=n;function u(t){let n=o,r=s;o=null,s=null,a=t,e.apply(r,n)}function d(e){let n=e-i,r=e-a;return i===0||n>=t||n<0||l!==void 0&&r>=l}function f(){let e=Date.now();if(d(e)){m(e);return}let n=e-i,o=e-a,s=t-n,ee=l===void 0?1/0:l-o;r=setTimeout(f,Math.min(s,ee))}function p(e){a=e,r=setTimeout(f,t),ee&&u(e)}function m(e){if(r=null,c&&o){u(e);return}o=null,s=null}function h(){r!==null&&clearTimeout(r),a=0,o=null,i=0,s=null,r=null}function g(){r!==null&&m(Date.now())}function _(){return r!==null}function v(...e){let n=Date.now(),a=d(n);if(o=e,s=this,i=n,a){if(r===null){p(i);return}
1
+ import{i as e,t}from"../navigate-DuyUa6qD.mjs";import{d as n,g as r,h as i,i as a,n as o,s}from"../type-guards-BLY2PlGR.mjs";import{r as c}from"../path-CTEC1xmy.mjs";import{a as ee}from"../route-cache-D2iIKQIU.mjs";import{t as l}from"../form-state-DAygOjc8.mjs";import{c as u}from"react/compiler-runtime";import{useEffect as d,useLayoutEffect as f,useRef as p,useState as m}from"react";function h(e,t,n={}){let r=null,i=0,a=0,o=null,s=null,{leading:c=!1,trailing:ee=!0,maxWait:l}=n;function u(t){let n=o,r=s;o=null,s=null,a=t,e.apply(r,n)}function d(e){let n=e-i,r=e-a;return i===0||n>=t||n<0||l!==void 0&&r>=l}function f(){let e=Date.now();if(d(e)){m(e);return}let n=e-i,o=e-a,s=t-n,c=l===void 0?1/0:l-o;r=setTimeout(f,Math.min(s,c))}function p(e){a=e,r=setTimeout(f,t),c&&u(e)}function m(e){if(r=null,ee&&o){u(e);return}o=null,s=null}function h(){r!==null&&clearTimeout(r),a=0,o=null,i=0,s=null,r=null}function g(){r!==null&&m(Date.now())}function _(){return r!==null}function v(...e){let n=Date.now(),a=d(n);if(o=e,s=this,i=n,a){if(r===null){p(i);return}
2
2
  /* v8 ignore start - edge case: isInvoking true with existing timeout and maxWait defined */
3
- if(l!==void 0){r=setTimeout(f,t),u(i);return}}r??=setTimeout(f,t)}return v.cancel=h,v.flush=g,v.pending=_,v}const h=/fetch|networkerror|load failed/i;function g(e,t){return{type:`abort`,message:`Navigation was cancelled`,originalError:e,url:t,timestamp:Date.now(),retryable:!1}}function _(e,t){return{type:`timeout`,message:`Navigation request timed out`,originalError:e,url:t,timestamp:Date.now(),retryable:!0}}function v(e,t,n){if(t===404)return{type:`not-found`,message:`Page not found`,originalError:e,statusCode:t,url:n,timestamp:Date.now(),retryable:!1};if(t>=500)return{type:`server-error`,message:`Server error: ${t}`,originalError:e,statusCode:t,url:n,timestamp:Date.now(),retryable:!0};let r=t===408||t===429;return{type:`fetch-error`,message:`HTTP error: ${t}`,originalError:e,statusCode:t,url:n,timestamp:Date.now(),retryable:r}}function y(e,t){return{type:`network-error`,message:`Network error - check your connection`,originalError:e,url:t,timestamp:Date.now(),retryable:!0}}function b(e,t){return{type:`parse-error`,message:`Failed to parse server response`,
3
+ if(l!==void 0){r=setTimeout(f,t),u(i);return}}r??=setTimeout(f,t)}return v.cancel=h,v.flush=g,v.pending=_,v}const g=/fetch|networkerror|load failed/i;function _(e,t){return{type:`abort`,message:`Navigation was cancelled`,originalError:e,url:t,timestamp:Date.now(),retryable:!1}}function v(e,t){return{type:`timeout`,message:`Navigation request timed out`,originalError:e,url:t,timestamp:Date.now(),retryable:!0}}function y(e,t,n){if(t===404)return{type:`not-found`,message:`Page not found`,originalError:e,statusCode:t,url:n,timestamp:Date.now(),retryable:!1};if(t>=500)return{type:`server-error`,message:`Server error: ${t}`,originalError:e,statusCode:t,url:n,timestamp:Date.now(),retryable:!0};let r=t===408||t===429;return{type:`fetch-error`,message:`HTTP error: ${t}`,originalError:e,statusCode:t,url:n,timestamp:Date.now(),retryable:r}}function b(e,t){return{type:`network-error`,message:`Network error - check your connection`,originalError:e,url:t,timestamp:Date.now(),retryable:!0}}function x(e,t){return{type:`parse-error`,message:`Failed to parse server response`,
4
4
  /* v8 ignore next - defensive check for non-Error values from parse-related condition */
5
- originalError:a(e),url:t,timestamp:Date.now(),retryable:!1}}function x(e,t){return{type:`fetch-error`,message:a(e)?.message??`Unknown error occurred`,originalError:a(e),url:t,timestamp:Date.now(),retryable:!1}}function S(e,t){if(o(e)&&e.name===`AbortError`)return g(e,t);if(o(e)&&(e.name===`TimeoutError`||e.message.includes(`timeout`)))return _(e,t);if(o(e)&&`status`in e){let n=e.status;return typeof n==`number`?v(e,n,t):x(e,t)}return e instanceof TypeError&&h.test(e.message)?y(e,t):e instanceof SyntaxError||o(e)&&e.message.includes(`parse`)?b(e,t):x(e,t)}var te=class{onError;constructor(e={}){
5
+ originalError:o(e),url:t,timestamp:Date.now(),retryable:!1}}function S(e,t){return{type:`fetch-error`,message:o(e)?.message??`Unknown error occurred`,originalError:o(e),url:t,timestamp:Date.now(),retryable:!1}}function C(e,t){if(s(e))return _(o(e)??/* @__PURE__ */ Error(`Aborted`),t);if(n(e)&&(e.name===`TimeoutError`||e.message.includes(`timeout`)))return v(e,t);if(n(e)&&`status`in e){let n=e.status;return typeof n==`number`?y(e,n,t):S(e,t)}return e instanceof TypeError&&g.test(e.message)?b(e,t):e instanceof SyntaxError||n(e)&&e.message.includes(`parse`)?x(e,t):S(e,t)}var te=class{onError;constructor(e={}){
6
6
  /* v8 ignore next - default no-op callback */
7
- this.onError=e.onError??(()=>{})}handleError(e,t){let n=S(e,t);return this.onError(n),console.error(`[rari] Navigation:`,n.type,n.message,{url:n.url,statusCode:n.statusCode,retryable:n.retryable}),n}};function ne(e,t){try{let n=t!=null&&t!==``?t:window.location.origin,r=typeof URL.parse==`function`?URL.parse(e,n):new URL(e,n);return r!=null&&r.origin!==n}catch{return!1}}function re(e){try{let t=typeof URL.parse==`function`?URL.parse(e,window.location.origin):new URL(e,window.location.origin);return t==null?e:`${t.pathname}${t.search}${t.hash}`}catch{return e}}var ie=class{stateHistory;routeAccessOrder;maxHistorySize;scrollableSelector;constructor(e={}){this.stateHistory=/* @__PURE__ */ new Map,this.routeAccessOrder=[],this.maxHistorySize=e.maxHistorySize!=null&&e.maxHistorySize!==0?e.maxHistorySize:50,this.scrollableSelector=e.scrollableSelector!=null&&e.scrollableSelector!==``?e.scrollableSelector:`[data-scrollable], .scrollable, [style*="overflow"]`}captureState(e){let t={scrollPositions:this.captureScrollPositions(),formData:this.captureFormData(),focusedElement:this.captureFocusedElement()};return this.storeState(e,t),t}captureScrollPositions(){let e=/* @__PURE__ */ new Map;try{e.set(`window`,{x:window.scrollX,y:window.scrollY,element:`window`}),document.querySelectorAll(this.scrollableSelector).forEach((t,n)=>{if(t instanceof HTMLElement){let r=t.id||`scrollable-${n}`;(t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth)&&e.set(r,{x:t.scrollLeft,y:t.scrollTop,element:r})}})}catch{}return e}captureFormData(){let e=/* @__PURE__ */ new Map;try{document.querySelectorAll(`form`).forEach((t,n)=>{let r=t.id||t.name||`form-${n}`,i=new FormData(t);i.entries().next().done||e.set(r,i)})}catch{}return e}captureFocusedElement(){try{let e=document.activeElement;if(e&&e!==document.body){if(e.id)return`#${e.id}`;if((e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&e.name)return`[name="${e.name}"]`}}catch{}return null}storeState(e,t){let n=this.routeAccessOrder.indexOf(e);for(n!==-1&&this.routeAccessOrder.splice(n,1),this.routeAccessOrder.push(e),this.stateHistory.set(e,t);this.routeAccessOrder.length>this.maxHistorySize;){let e=this.routeAccessOrder.shift();e!=null&&e!==``&&this.stateHistory.delete(e)}}restoreState(e){let t=this.stateHistory.get(e);if(!t)return!1;let n=!0;return this.restoreScrollPositions(t.scrollPositions)||(n=!1),this.restoreFormData(t.formData)||(n=!1),t.focusedElement!=null&&t.focusedElement!==``&&this.restoreFocus(t.focusedElement),n}restoreScrollPositions(e){let t=!0;try{e.forEach((e,n)=>{try{if(n===`window`)window.scrollTo(e.x,e.y);else{let r=document.getElementById(n)??document.querySelector(`[data-scrollable-id="${n}"]`);r instanceof HTMLElement?(r.scrollLeft=e.x,r.scrollTop=e.y):t=!1}}catch{t=!1}})}catch(e){console.error(`[rari] Router: Failed to restore scroll positions:`,e),t=!1}return t}restoreFormData(e){let t=!0;try{e.forEach((e,n)=>{try{let r=document.getElementById(n),i=r instanceof HTMLFormElement?r:document.querySelector(`form[name="${n}"]`)??document.querySelectorAll(`form`)[Number.parseInt(n.replace(`form-`,``),10)];i instanceof HTMLFormElement&&c(i,e)||(t=!1)}catch{t=!1}})}catch(e){console.error(`[rari] Router: Failed to restore form data:`,e),t=!1}return t}restoreFocus(e){try{let t=document.querySelector(e);t instanceof HTMLElement&&requestAnimationFrame(()=>{try{t.focus()}catch{}})}catch{}}};function C(e){return n(e)&&typeof e.navigationId==`number`}function w(e){return n(e)&&typeof e.navigationId==`number`&&`error`in e}function ae(e){let t=e.headers.get(`x-rari-metadata`);if(t!=null&&t!==``)try{let e=JSON.parse(decodeURIComponent(t));if(!n(e))return;if(typeof e.title==`string`&&e.title!==``&&(document.title=e.title),typeof e.description==`string`&&e.description!==``){let t=document.querySelector(`meta[name="description"]`);t||(t=document.createElement(`meta`),t.setAttribute(`name`,`description`),document.head.appendChild(t)),t.setAttribute(`content`,e.description)}}catch{}}async function oe(e,t){return t.aborted?{error:new DOMException(`Aborted`,`AbortError`)}:new Promise(n=>{function i(){window.removeEventListener(`rari:navigate-committed`,a),window.removeEventListener(`rari:navigate-error`,o),t.removeEventListener(`abort`,s)}function a(t){r(t,C)?.navigationId===e&&(i(),n(`committed`))}function o(t){let a=r(t,w);a?.navigationId===e&&(i(),n({error:a.error}))}function s(){i(),n({error:new DOMException(`Aborted`,`AbortError`)})}window.addEventListener(`rari:navigate-committed`,a),window.addEventListener(`rari:navigate-error`,o),t.addEventListener(`abort`,s,{once:!0})})}function T(n){let r=l(35),{children:a,initialRoute:c}=n,h;r[0]===c?h=r[1]:(h=()=>({currentRoute:typeof window<`u`?`${window.location.pathname}${window.location.search}`:s(c),navigationId:0,error:null}),r[0]=c,r[1]=h);let[g,_]=p(h),v=f(null),y=f(!0),b;r[2]===c?b=r[3]:(b=typeof window<`u`?`${window.location.pathname}${window.location.search}`:s(c),r[2]=c,r[3]=b);let x=f(b),S;r[4]===c?S=r[5]:(S=typeof window<`u`?`${window.location.pathname}${window.location.search}${window.location.hash}`:s(c),r[4]=c,r[5]=S);let C=f(S),w=f(0),T;r[6]===Symbol.for(`react.memo_cache_sentinel`)?(T=new te({onError:le}),r[6]=T):T=r[6];let ue=f(T),E;r[7]===Symbol.for(`react.memo_cache_sentinel`)?(E=/* @__PURE__ */ new Map,r[7]=E):E=r[7];let D=f(E),O;r[8]===Symbol.for(`react.memo_cache_sentinel`)?(O=new ie({maxHistorySize:50}),r[8]=O):O=r[8];let k=f(O),de=ce,A;r[9]===Symbol.for(`react.memo_cache_sentinel`)?(A=()=>{v.current&&=(v.current.abort(),null)},r[9]=A):A=r[9];let fe=A,j;r[10]===Symbol.for(`react.memo_cache_sentinel`)?(j=()=>{for(let[,e]of D.current.entries())e.abortController.abort();D.current.clear()},r[10]=j):j=r[10];let pe=j,M;r[11]===g?M=r[12]:(M=(e,t)=>{D.current.delete(e),y.current&&g.navigationId===t&&_(se)},r[11]=g,r[12]=M);let N=M,P;r[13]===Symbol.for(`react.memo_cache_sentinel`)?(P=(e,t)=>{let n=t===void 0?{}:t,r=`${window.location.pathname}${window.location.search}`,i=e?`${r}#${e}`:r;if(e){let t=document.getElementById(e);t&&t.scrollIntoView({behavior:`smooth`,block:`start`})}i!==`${window.location.pathname}${window.location.search}${window.location.hash}`&&(n.replace?window.history.replaceState(window.history.state,``,i):window.history.pushState(window.history.state,``,i)),C.current=i},r[13]=P):P=r[13];let me=P,F;if(r[14]===Symbol.for(`react.memo_cache_sentinel`)){let e=(e,t,n)=>{n.historyKey!=null&&n.historyKey!==``?requestAnimationFrame(()=>{k.current.restoreState(e)}):t&&requestAnimationFrame(()=>{let e=n=>{let r=n===void 0?0:n,i=document.getElementById(t);i?i.scrollIntoView({behavior:`smooth`,block:`start`}):r<10&&setTimeout(e,50,r+1)};e()})};F=(t,n,r,i,a)=>{y.current&&w.current===i&&(x.current=t,C.current=a,_(e=>({...e,currentRoute:t,navigationId:i,error:null})),e(t,n,r))},r[14]=F}else F=r[14];let he=F,I;r[15]===N?I=r[16]:(I=(e,t,n,r,i)=>{let a=i===void 0?{}:i;if(o(e)&&e.name===`AbortError`){N(t,n);return}let s=ue.current.handleError(e,t);y.current&&(_(e=>({...e,error:s})),window.history.replaceState(window.history.state,``,r)),D.current.delete(t),a.emitEvent!==!1&&window.dispatchEvent(new CustomEvent(`rari:navigate-error`,{detail:{from:r,to:t,error:s,navigationId:n}}))},r[15]=N,r[16]=I);let L=I,R;r[17]!==N||r[18]!==L?(R=async(e,t)=>{let n=t===void 0?{}:t;if(!e||typeof e!=`string`)return;let[r,i]=e.includes(`#`)?e.split(`#`):[e,``],a=s(r);if(a===x.current){me(i,{replace:n.replace===!0});return}let o=D.current.get(a);if(o)return o.promise;pe(),fe();let c=new AbortController;v.current=c,w.current+=1;let l=w.current;window.dispatchEvent(new CustomEvent(`rari:navigation-start`,{detail:{navigationId:l,targetPath:a}}));let u=(async()=>{let e=C.current;try{(n.historyKey==null||n.historyKey===``)&&k.current.captureState(x.current);let t=n.historyKey!=null&&n.historyKey!==``?n.historyKey:de(),r=window.location.origin+a,o={route:a,navigationId:l,scrollPosition:{x:window.scrollX,y:window.scrollY},timestamp:Date.now(),key:t},s=await fetch(r,{headers:{Accept:`text/x-component`,"rari-navigation-id":String(l),"rari-router-state":ee()},cache:`no-store`,signal:c.signal});if(!s.ok&&s.status!==404){L(/* @__PURE__ */ Error(`Failed to fetch: ${s.status}`),a,l,e);return}if(c.signal.aborted){N(a,l);return}let u=new URL(s.url),d=u.pathname,f=`${u.pathname}${u.search}`,p={...o,route:f},m=`${f}${i?`#${i}`:``}`;if(w.current!==l)return;let h=oe(l,c.signal);if(window.dispatchEvent(new CustomEvent(`rari:navigate`,{detail:{from:new URL(e,window.location.origin).pathname,to:d,navigationId:l,options:n,abortSignal:c.signal,rscResponse:s,pendingHistory:{url:m,state:p,replace:n.replace===!0}}})),w.current!==l){c.abort();return}let g=await h;if(w.current!==l)return;if(g!==`committed`){L(g.error,a,l,e,{emitEvent:!1});return}he(f,i,n,l,m),ae(s),D.current.delete(a)}catch(t){L(t,a,l,e)}})();return D.current.set(a,{targetPath:a,navigationId:l,promise:u,abortController:c}),u},r[17]=N,r[18]=L,r[19]=R):R=r[19];let z=R,B=f(z),V;r[20]===z?V=r[21]:(V=()=>(B.current=z,()=>{B.current=null}),r[20]=z,r[21]=V),d(V);let ge=f(null),H,U;r[22]===Symbol.for(`react.memo_cache_sentinel`)?(H=()=>{ge.current??=m((e,t)=>{B.current?.(e,t)},50,{leading:!0,trailing:!0,maxWait:200})},U=[],r[22]=H,r[23]=U):(H=r[22],U=r[23]),d(H,U);let W;r[24]===Symbol.for(`react.memo_cache_sentinel`)?(W=e=>{if(e.button!==0||e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)return;let t=e.target instanceof Element?e.target:null;for(;t&&!(t instanceof HTMLAnchorElement);)t=t.parentElement;if(!(t instanceof HTMLAnchorElement))return;let n=t;if(n.target&&n.target!==`_self`||n.hasAttribute(`download`))return;let r=n.getAttribute(`href`);if(r==null||r===``||ne(r))return;if(r.startsWith(`#`)){e.preventDefault();let t=r.slice(1),n=document.getElementById(t);if(n){n.scrollIntoView({behavior:`smooth`,block:`start`});let e=`${window.location.pathname}${window.location.search}#${t}`;window.history.pushState(window.history.state,``,e),C.current=e}return}e.preventDefault();let i=re(r);ge.current?.(i,{replace:!1})},r[24]=W):W=r[24];let _e=W,G;r[25]===Symbol.for(`react.memo_cache_sentinel`)?(G=e=>{let t=`${window.location.pathname}${window.location.search}${window.location.hash}`,n=i(e.state)?e.state:null;B.current&&B.current(t,{replace:!0,scroll:!1,historyKey:n?.key})},r[25]=G):G=r[25];let ve=G,K;r[26]===Symbol.for(`react.memo_cache_sentinel`)?(K=()=>{let e=i(window.history.state)?window.history.state:null;if(e?.key==null||e.key===``){let e={route:`${window.location.pathname}${window.location.search}`,navigationId:0,scrollPosition:{x:window.scrollX,y:window.scrollY},timestamp:Date.now(),key:de()};window.history.replaceState(e,``,window.location.pathname+window.location.search+window.location.hash)}},r[26]=K):K=r[26];let q;r[27]===c?q=r[28]:(q=[c],r[27]=c,r[28]=q),u(K,q);let J;r[29]===Symbol.for(`react.memo_cache_sentinel`)?(J=e=>{if(e.persisted){let e=window.location.pathname;k.current.captureState(e)}},r[29]=J):J=r[29];let ye=J,Y;r[30]===Symbol.for(`react.memo_cache_sentinel`)?(Y=e=>{if(e.persisted){let e=window.location.pathname,t=i(window.history.state)?window.history.state:null;requestAnimationFrame(()=>{k.current.restoreState(e),t?.scrollPosition&&window.scrollTo(t.scrollPosition.x,t.scrollPosition.y)})}},r[30]=Y):Y=r[30];let be=Y,X,Z;r[31]===Symbol.for(`react.memo_cache_sentinel`)?(X=()=>(document.addEventListener(`click`,_e),window.addEventListener(`popstate`,ve),window.addEventListener(`pagehide`,ye),window.addEventListener(`pageshow`,be),()=>{document.removeEventListener(`click`,_e),window.removeEventListener(`popstate`,ve),window.removeEventListener(`pagehide`,ye),window.removeEventListener(`pageshow`,be)}),Z=[],r[31]=X,r[32]=Z):(X=r[31],Z=r[32]),u(X,Z);let Q,$;return r[33]===Symbol.for(`react.memo_cache_sentinel`)?(Q=()=>(y.current=!0,e(async(e,t)=>B.current?.(e,t)??Promise.resolve()),()=>{y.current=!1,t(),fe(),pe(),ge.current?.cancel()}),$=[],r[33]=Q,r[34]=$):(Q=r[33],$=r[34]),u(Q,$),a}function se(e){return{...e}}function ce(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`hk-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,11)}`}function le(e){console.error(`[rari] Router: Navigation error:`,e)}export{T as ClientRouter};
7
+ this.onError=e.onError??(()=>{})}handleError(e,t){let n=C(e,t);return this.onError(n),console.error(`[rari] Navigation:`,n.type,n.message,{url:n.url,statusCode:n.statusCode,retryable:n.retryable}),n}};function ne(e,t){try{let n=t!=null&&t!==``?t:window.location.origin,r=typeof URL.parse==`function`?URL.parse(e,n):new URL(e,n);return r!=null&&r.origin!==n}catch{return!1}}function re(e){try{let t=typeof URL.parse==`function`?URL.parse(e,window.location.origin):new URL(e,window.location.origin);return t==null?e:`${t.pathname}${t.search}${t.hash}`}catch{return e}}var ie=class{stateHistory;routeAccessOrder;maxHistorySize;scrollableSelector;constructor(e={}){this.stateHistory=/* @__PURE__ */ new Map,this.routeAccessOrder=[],this.maxHistorySize=e.maxHistorySize!=null&&e.maxHistorySize!==0?e.maxHistorySize:50,this.scrollableSelector=e.scrollableSelector!=null&&e.scrollableSelector!==``?e.scrollableSelector:`[data-scrollable], .scrollable, [style*="overflow"]`}captureState(e){let t={scrollPositions:this.captureScrollPositions(),formData:this.captureFormData(),focusedElement:this.captureFocusedElement()};return this.storeState(e,t),t}captureScrollPositions(){let e=/* @__PURE__ */ new Map;try{e.set(`window`,{x:window.scrollX,y:window.scrollY,element:`window`}),document.querySelectorAll(this.scrollableSelector).forEach((t,n)=>{if(t instanceof HTMLElement){let r=t.id||`scrollable-${n}`;(t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth)&&e.set(r,{x:t.scrollLeft,y:t.scrollTop,element:r})}})}catch{}return e}captureFormData(){let e=/* @__PURE__ */ new Map;try{document.querySelectorAll(`form`).forEach((t,n)=>{let r=t.id||t.name||`form-${n}`,i=new FormData(t);i.entries().next().done||e.set(r,i)})}catch{}return e}captureFocusedElement(){try{let e=document.activeElement;if(e&&e!==document.body){if(e.id)return`#${e.id}`;if((e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&e.name)return`[name="${e.name}"]`}}catch{}return null}storeState(e,t){let n=this.routeAccessOrder.indexOf(e);for(n!==-1&&this.routeAccessOrder.splice(n,1),this.routeAccessOrder.push(e),this.stateHistory.set(e,t);this.routeAccessOrder.length>this.maxHistorySize;){let e=this.routeAccessOrder.shift();e!=null&&e!==``&&this.stateHistory.delete(e)}}restoreState(e){let t=this.stateHistory.get(e);if(!t)return!1;let n=!0;return this.restoreScrollPositions(t.scrollPositions)||(n=!1),this.restoreFormData(t.formData)||(n=!1),t.focusedElement!=null&&t.focusedElement!==``&&this.restoreFocus(t.focusedElement),n}restoreScrollPositions(e){let t=!0;try{e.forEach((e,n)=>{try{if(n===`window`)window.scrollTo(e.x,e.y);else{let r=document.getElementById(n)??document.querySelector(`[data-scrollable-id="${n}"]`);r instanceof HTMLElement?(r.scrollLeft=e.x,r.scrollTop=e.y):t=!1}}catch{t=!1}})}catch(e){console.error(`[rari] Router: Failed to restore scroll positions:`,e),t=!1}return t}restoreFormData(e){let t=!0;try{e.forEach((e,n)=>{try{let r=document.getElementById(n),i=r instanceof HTMLFormElement?r:document.querySelector(`form[name="${n}"]`)??document.querySelectorAll(`form`)[Number.parseInt(n.replace(`form-`,``),10)];i instanceof HTMLFormElement&&l(i,e)||(t=!1)}catch{t=!1}})}catch(e){console.error(`[rari] Router: Failed to restore form data:`,e),t=!1}return t}restoreFocus(e){try{let t=document.querySelector(e);t instanceof HTMLElement&&requestAnimationFrame(()=>{try{t.focus()}catch{}})}catch{}}};function w(e){return r(e)&&typeof e.navigationId==`number`}function T(e){return r(e)&&typeof e.navigationId==`number`&&`error`in e}function ae(e){let t=e.headers.get(`x-rari-metadata`);if(t!=null&&t!==``)try{let e=JSON.parse(decodeURIComponent(t));if(!r(e))return;if(typeof e.title==`string`&&e.title!==``&&(document.title=e.title),typeof e.description==`string`&&e.description!==``){let t=document.querySelector(`meta[name="description"]`);t||(t=document.createElement(`meta`),t.setAttribute(`name`,`description`),document.head.appendChild(t)),t.setAttribute(`content`,e.description)}}catch{}}async function oe(e,t){return t.aborted?{error:new DOMException(`Aborted`,`AbortError`)}:new Promise(n=>{function r(){window.removeEventListener(`rari:navigate-committed`,i),window.removeEventListener(`rari:navigate-error`,o),t.removeEventListener(`abort`,s)}function i(t){a(t,w)?.navigationId===e&&(r(),n(`committed`))}function o(t){let i=a(t,T);i?.navigationId===e&&(r(),n({error:i.error}))}function s(){r(),n({error:new DOMException(`Aborted`,`AbortError`)})}window.addEventListener(`rari:navigate-committed`,i),window.addEventListener(`rari:navigate-error`,o),t.addEventListener(`abort`,s,{once:!0})})}function se(n){let r=u(35),{children:a,initialRoute:o}=n,l;r[0]===o?l=r[1]:(l=()=>({currentRoute:typeof window<`u`?`${window.location.pathname}${window.location.search}`:c(o),navigationId:0,error:null}),r[0]=o,r[1]=l);let[g,_]=m(l),v=p(null),y=p(!0),b;r[2]===o?b=r[3]:(b=typeof window<`u`?`${window.location.pathname}${window.location.search}`:c(o),r[2]=o,r[3]=b);let x=p(b),S;r[4]===o?S=r[5]:(S=typeof window<`u`?`${window.location.pathname}${window.location.search}${window.location.hash}`:c(o),r[4]=o,r[5]=S);let C=p(S),w=p(0),T;r[6]===Symbol.for(`react.memo_cache_sentinel`)?(T=new te({onError:ue}),r[6]=T):T=r[6];let se=p(T),E;r[7]===Symbol.for(`react.memo_cache_sentinel`)?(E=/* @__PURE__ */ new Map,r[7]=E):E=r[7];let D=p(E),O;r[8]===Symbol.for(`react.memo_cache_sentinel`)?(O=new ie({maxHistorySize:50}),r[8]=O):O=r[8];let k=p(O),de=le,A;r[9]===Symbol.for(`react.memo_cache_sentinel`)?(A=()=>{v.current&&=(v.current.abort(),null)},r[9]=A):A=r[9];let fe=A,j;r[10]===Symbol.for(`react.memo_cache_sentinel`)?(j=()=>{for(let[,e]of D.current.entries())e.bodyHandedOff?window.dispatchEvent(new CustomEvent(`rari:navigate-error`,{detail:{navigationId:e.navigationId,error:new DOMException(`Aborted`,`AbortError`)}})):e.abortController.abort();D.current.clear()},r[10]=j):j=r[10];let pe=j,M;r[11]===g?M=r[12]:(M=(e,t)=>{D.current.delete(e),y.current&&g.navigationId===t&&_(ce)},r[11]=g,r[12]=M);let N=M,P;r[13]===Symbol.for(`react.memo_cache_sentinel`)?(P=(e,t)=>{let n=t===void 0?{}:t,r=`${window.location.pathname}${window.location.search}`,i=e?`${r}#${e}`:r;if(e){let t=document.getElementById(e);t&&t.scrollIntoView({behavior:`smooth`,block:`start`})}i!==`${window.location.pathname}${window.location.search}${window.location.hash}`&&(n.replace?window.history.replaceState(window.history.state,``,i):window.history.pushState(window.history.state,``,i)),C.current=i},r[13]=P):P=r[13];let me=P,F;if(r[14]===Symbol.for(`react.memo_cache_sentinel`)){let e=(e,t,n)=>{n.historyKey!=null&&n.historyKey!==``?requestAnimationFrame(()=>{k.current.restoreState(e)}):t&&requestAnimationFrame(()=>{let e=n=>{let r=n===void 0?0:n,i=document.getElementById(t);i?i.scrollIntoView({behavior:`smooth`,block:`start`}):r<10&&setTimeout(e,50,r+1)};e()})};F=(t,n,r,i,a)=>{y.current&&w.current===i&&(x.current=t,C.current=a,_(e=>({...e,currentRoute:t,navigationId:i,error:null})),e(t,n,r))},r[14]=F}else F=r[14];let he=F,I;r[15]===N?I=r[16]:(I=(e,t,n,r,i)=>{let a=i===void 0?{}:i;if(s(e)){N(t,n);return}let o=se.current.handleError(e,t);y.current&&(_(e=>({...e,error:o})),window.history.replaceState(window.history.state,``,r)),D.current.delete(t),a.emitEvent!==!1&&window.dispatchEvent(new CustomEvent(`rari:navigate-error`,{detail:{from:r,to:t,error:o,navigationId:n}}))},r[15]=N,r[16]=I);let L=I,R;r[17]!==N||r[18]!==L?(R=async(e,t)=>{let n=t===void 0?{}:t;if(!e||typeof e!=`string`)return;let[r,i]=e.includes(`#`)?e.split(`#`):[e,``],a=c(r);if(a===x.current){me(i,{replace:n.replace===!0});return}let o=D.current.get(a);if(o)return o.promise;pe(),fe();let s=new AbortController;v.current=s,w.current+=1;let l=w.current;window.dispatchEvent(new CustomEvent(`rari:navigation-start`,{detail:{navigationId:l,targetPath:a}}));let u=(async()=>{let e=C.current;try{(n.historyKey==null||n.historyKey===``)&&k.current.captureState(x.current);let t=n.historyKey!=null&&n.historyKey!==``?n.historyKey:de(),r=window.location.origin+a,o={route:a,navigationId:l,scrollPosition:{x:window.scrollX,y:window.scrollY},timestamp:Date.now(),key:t},c=await fetch(r,{headers:{Accept:`text/x-component`,"rari-navigation-id":String(l),"rari-router-state":ee()},cache:`no-store`,signal:s.signal});if(!c.ok&&c.status!==404){L(/* @__PURE__ */ Error(`Failed to fetch: ${c.status}`),a,l,e);return}if(s.signal.aborted){N(a,l);return}let u=new URL(c.url),d=u.pathname,f=`${u.pathname}${u.search}`,p={...o,route:f},m=`${f}${i?`#${i}`:``}`;if(w.current!==l)return;let h=oe(l,s.signal),g=D.current.get(a);if(g!=null&&(g.bodyHandedOff=!0),v.current===s&&(v.current=null),window.dispatchEvent(new CustomEvent(`rari:navigate`,{detail:{from:new URL(e,window.location.origin).pathname,to:d,navigationId:l,options:n,abortSignal:s.signal,rscResponse:c,pendingHistory:{url:m,state:p,replace:n.replace===!0}}})),w.current!==l){window.dispatchEvent(new CustomEvent(`rari:navigate-error`,{detail:{navigationId:l,error:new DOMException(`Aborted`,`AbortError`)}}));return}let _=await h;if(w.current!==l)return;if(_!==`committed`){L(_.error,a,l,e,{emitEvent:!1});return}he(f,i,n,l,m),ae(c),D.current.delete(a)}catch(t){L(t,a,l,e)}})();return D.current.set(a,{targetPath:a,navigationId:l,promise:u,abortController:s,bodyHandedOff:!1}),u},r[17]=N,r[18]=L,r[19]=R):R=r[19];let z=R,B=p(z),V;r[20]===z?V=r[21]:(V=()=>(B.current=z,()=>{B.current=null}),r[20]=z,r[21]=V),f(V);let ge=p(null),H,U;r[22]===Symbol.for(`react.memo_cache_sentinel`)?(H=()=>{ge.current??=h((e,t)=>{B.current?.(e,t)},50,{leading:!0,trailing:!0,maxWait:200})},U=[],r[22]=H,r[23]=U):(H=r[22],U=r[23]),f(H,U);let W;r[24]===Symbol.for(`react.memo_cache_sentinel`)?(W=e=>{if(e.button!==0||e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)return;let t=e.target instanceof Element?e.target:null;for(;t&&!(t instanceof HTMLAnchorElement);)t=t.parentElement;if(!(t instanceof HTMLAnchorElement))return;let n=t;if(n.target&&n.target!==`_self`||n.hasAttribute(`download`))return;let r=n.getAttribute(`href`);if(r==null||r===``||ne(r))return;if(r.startsWith(`#`)){e.preventDefault();let t=r.slice(1),n=document.getElementById(t);if(n){n.scrollIntoView({behavior:`smooth`,block:`start`});let e=`${window.location.pathname}${window.location.search}#${t}`;window.history.pushState(window.history.state,``,e),C.current=e}return}e.preventDefault();let i=re(r);ge.current?.(i,{replace:!1})},r[24]=W):W=r[24];let _e=W,G;r[25]===Symbol.for(`react.memo_cache_sentinel`)?(G=e=>{let t=`${window.location.pathname}${window.location.search}${window.location.hash}`,n=i(e.state)?e.state:null;B.current&&B.current(t,{replace:!0,scroll:!1,historyKey:n?.key})},r[25]=G):G=r[25];let ve=G,K;r[26]===Symbol.for(`react.memo_cache_sentinel`)?(K=()=>{let e=i(window.history.state)?window.history.state:null;if(e?.key==null||e.key===``){let e={route:`${window.location.pathname}${window.location.search}`,navigationId:0,scrollPosition:{x:window.scrollX,y:window.scrollY},timestamp:Date.now(),key:de()};window.history.replaceState(e,``,window.location.pathname+window.location.search+window.location.hash)}},r[26]=K):K=r[26];let q;r[27]===o?q=r[28]:(q=[o],r[27]=o,r[28]=q),d(K,q);let J;r[29]===Symbol.for(`react.memo_cache_sentinel`)?(J=e=>{if(e.persisted){let e=window.location.pathname;k.current.captureState(e)}},r[29]=J):J=r[29];let ye=J,Y;r[30]===Symbol.for(`react.memo_cache_sentinel`)?(Y=e=>{if(e.persisted){let e=window.location.pathname,t=i(window.history.state)?window.history.state:null;requestAnimationFrame(()=>{k.current.restoreState(e),t?.scrollPosition&&window.scrollTo(t.scrollPosition.x,t.scrollPosition.y)})}},r[30]=Y):Y=r[30];let be=Y,X,Z;r[31]===Symbol.for(`react.memo_cache_sentinel`)?(X=()=>(document.addEventListener(`click`,_e),window.addEventListener(`popstate`,ve),window.addEventListener(`pagehide`,ye),window.addEventListener(`pageshow`,be),()=>{document.removeEventListener(`click`,_e),window.removeEventListener(`popstate`,ve),window.removeEventListener(`pagehide`,ye),window.removeEventListener(`pageshow`,be)}),Z=[],r[31]=X,r[32]=Z):(X=r[31],Z=r[32]),d(X,Z);let Q,$;return r[33]===Symbol.for(`react.memo_cache_sentinel`)?(Q=()=>(y.current=!0,e(async(e,t)=>B.current?.(e,t)??Promise.resolve()),()=>{y.current=!1,t(),fe(),pe(),ge.current?.cancel()}),$=[],r[33]=Q,r[34]=$):(Q=r[33],$=r[34]),d(Q,$),a}function ce(e){return{...e}}function le(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`hk-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,11)}`}function ue(e){console.error(`[rari] Router: Navigation error:`,e)}export{se as ClientRouter};
@@ -1 +1 @@
1
- import{h as e,l as t}from"../type-guards-BozK2q2n.mjs";import{t as n}from"../timer-Duul5JHq.mjs";import{r}from"../rari-global-5vGzhToD.mjs";import{Component as i}from"react";import{jsx as a,jsxs as o}from"react/jsx-runtime";function s(n){if(t(n))return n;if(e(n)){let e=n.default??n;return t(e)?e:null}return null}var c=class extends i{_isMounted=!1;_pendingTimer=null;constructor(e){super(e),this.state={hasError:!1,error:null,ErrorComponent:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidMount(){this._isMounted=!0}componentWillUnmount(){this._isMounted=!1,this._pendingTimer=n(this._pendingTimer)}componentDidCatch(e,t){console.error(`[rari] Error boundary caught error:`,e,t);let n=this.props.errorComponentId;if(n!==``){let e=r();if(n in e){let t=e[n],r=s(t.component);r?this.setState({ErrorComponent:r}):t.loader&&!t.loading&&(t.loading=!0,t.loader().then(e=>{let n=s(e);n&&(t.component=n,t.registered=!0,this.setState({ErrorComponent:n})),t.loading=!1}).catch(e=>{t.loading=!1,console.error(`[rari] Failed to load error component ${n}:`,e)}))}}}reset=()=>{this._pendingTimer=n(this._pendingTimer),this._pendingTimer=setTimeout(()=>{this._isMounted&&this.setState({hasError:!1,error:null,ErrorComponent:null}),this._pendingTimer=null},50)};render(){if(this.state.hasError&&this.state.error){let{ErrorComponent:e}=this.state;return e?/* @__PURE__ */ a(e,{error:this.state.error,reset:this.reset}):/* @__PURE__ */ o(`div`,{className:`rari-error`,role:`alert`,style:{color:`red`,border:`1px solid red`,padding:`10px`,borderRadius:`4px`,backgroundColor:`#fff5f5`},children:[/* @__PURE__ */ a(`strong`,{children:`Error loading content: `}),this.state.error.message]})}return this.props.children}};export{c as ErrorBoundaryWrapper};
1
+ import{g as e,s as t,u as n}from"../type-guards-BLY2PlGR.mjs";import{t as r}from"../timer-Duul5JHq.mjs";import{r as i}from"../rari-global-5vGzhToD.mjs";import{Component as a}from"react";import{jsx as o,jsxs as s}from"react/jsx-runtime";function c(t){if(n(t))return t;if(e(t)){let e=t.default??t;return n(e)?e:null}return null}var l=class extends a{_isMounted=!1;_pendingTimer=null;constructor(e){super(e),this.state={hasError:!1,error:null,ErrorComponent:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidMount(){this._isMounted=!0}componentWillUnmount(){this._isMounted=!1,this._pendingTimer=r(this._pendingTimer)}componentDidCatch(e,n){if(t(e))return;console.error(`[rari] Error boundary caught error:`,e,n);let r=this.props.errorComponentId;if(r!==``){let e=i();if(r in e){let t=e[r],n=c(t.component);n?this.setState({ErrorComponent:n}):t.loader&&!t.loading&&(t.loading=!0,t.loader().then(e=>{let n=c(e);n&&(t.component=n,t.registered=!0,this.setState({ErrorComponent:n})),t.loading=!1}).catch(e=>{t.loading=!1,console.error(`[rari] Failed to load error component ${r}:`,e)}))}}}reset=()=>{this._pendingTimer=r(this._pendingTimer),this._pendingTimer=setTimeout(()=>{this._isMounted&&this.setState({hasError:!1,error:null,ErrorComponent:null}),this._pendingTimer=null},50)};render(){if(this.state.hasError&&this.state.error){if(t(this.state.error))return null;let{ErrorComponent:e}=this.state;return e?/* @__PURE__ */ o(e,{error:this.state.error,reset:this.reset}):/* @__PURE__ */ s(`div`,{className:`rari-error`,role:`alert`,style:{color:`red`,border:`1px solid red`,padding:`10px`,borderRadius:`4px`,backgroundColor:`#fff5f5`},children:[/* @__PURE__ */ o(`strong`,{children:`Error loading content: `}),this.state.error.message]})}return this.props.children}};export{l as ErrorBoundaryWrapper};
@@ -1 +1 @@
1
- import{f as e,h as t,r as n}from"../type-guards-BozK2q2n.mjs";import{ActionDidNotRevalidate as r,ActionDidRevalidateDynamicOnly as i,ActionDidRevalidateStaticAndDynamic as a,parseActionRevalidationKind as o}from"./action-revalidation-kind.mjs";import{isValidElement as s}from"react";function c(e){return t(e)?`redirect`in e||`~rariSkipRefresh`in e||`~rariFormState`in e:!1}function l(t){return s(t)||e(t)}function u(e){return e==null||e===``?null:e instanceof Promise?e.then(e=>e==null||e===``?null:e):e}function d(e,t,r){typeof globalThis.dispatchEvent==`function`&&(c(r)||(async()=>{let n=u(t.f),r=n instanceof Promise?await n:n;if(r==null||!l(r))return;let i=o(e.headers.get(`x-action-revalidated`));if(i===0)return;let a=e.headers.get(`x-action-revalidated-path`)??void 0,s=()=>{globalThis.dispatchEvent(new CustomEvent(`rari:action-flight-refresh`,{detail:{element:r,revalidationKind:i,revalidatedPath:a}}))};if(typeof requestAnimationFrame==`function`){requestAnimationFrame(()=>{requestAnimationFrame(s)});return}queueMicrotask(s)})().catch(e=>{console.error(`[rari] Action flight refresh failed:`,n(e,String(e)))}))}export{r as ActionDidNotRevalidate,i as ActionDidRevalidateDynamicOnly,a as ActionDidRevalidateStaticAndDynamic,d as scheduleActionFlightRefresh};
1
+ import{g as e,p as t,r as n}from"../type-guards-BLY2PlGR.mjs";import{ActionDidNotRevalidate as r,ActionDidRevalidateDynamicOnly as i,ActionDidRevalidateStaticAndDynamic as a,parseActionRevalidationKind as o}from"./action-revalidation-kind.mjs";import{isValidElement as s}from"react";function c(t){return e(t)?`redirect`in t||`~rariSkipRefresh`in t||`~rariFormState`in t:!1}function l(e){return s(e)||t(e)}function u(e){return e==null||e===``?null:e instanceof Promise?e.then(e=>e==null||e===``?null:e):e}function d(e,t,r){typeof globalThis.dispatchEvent==`function`&&(c(r)||(async()=>{let n=u(t.f),r=n instanceof Promise?await n:n;if(r==null||!l(r))return;let i=o(e.headers.get(`x-action-revalidated`));if(i===0)return;let a=e.headers.get(`x-action-revalidated-path`)??void 0,s=()=>{globalThis.dispatchEvent(new CustomEvent(`rari:action-flight-refresh`,{detail:{element:r,revalidationKind:i,revalidatedPath:a}}))};if(typeof requestAnimationFrame==`function`){requestAnimationFrame(()=>{requestAnimationFrame(s)});return}queueMicrotask(s)})().catch(e=>{console.error(`[rari] Action flight refresh failed:`,n(e,String(e)))}))}export{r as ActionDidNotRevalidate,i as ActionDidRevalidateDynamicOnly,a as ActionDidRevalidateStaticAndDynamic,d as scheduleActionFlightRefresh};
@@ -1 +1 @@
1
- import{h as e,u as t}from"../type-guards-BozK2q2n.mjs";import{a as n}from"../route-cache-Cgh5HhiB.mjs";import{scheduleActionFlightRefresh as r}from"./action-flight-refresh.mjs";import{createFromFetch as i,createTemporaryReferenceSet as a,encodeReply as o}from"virtual:react-flight-client";const s=3e4;function c(t){if(!e(t))return t;let{"~rariSkipRefresh":n,...r}=t;return r}function l(){return typeof window<`u`?window.location.pathname+window.location.search:`/`}const u=/* @__PURE__ */ new Set([`http:`,`https:`]);function d(e){if(typeof window<`u`)try{let t=new URL(e,window.location.href);if(!u.has(t.protocol))return;t.href!==window.location.href&&(window.location.href=t.href)}catch{}}async function f(e,t){let s=a(),{headers:l,body:u}=p(await o(t,{temporaryReferences:s}));l.Accept=`text/x-component`,l[`rsc-action-id`]=e,l[`rari-router-state`]=n();let d=await m(e,l,u),_=h(d);if(_!=null)return _;await g(e,d);let v=await i(Promise.resolve(d),{callServer:f,temporaryReferences:s}),y=v.a,b=y instanceof Promise?await y:y;return r(d,v,b),c(b)}function p(e){let t={};return typeof e==`string`&&(t[`Content-Type`]=`text/plain;charset=UTF-8`),{headers:t,body:e}}async function m(e,n,r){try{return await fetch(l(),{method:`POST`,headers:n,body:r,signal:AbortSignal.timeout(s)})}catch(n){throw n instanceof DOMException&&n.name===`TimeoutError`||t(n)&&n.name===`AbortError`?Error(`Server action "${e}" timed out after ${s}ms`):n}}function h(e){let t=e.headers.get(`x-action-redirect`);if(t==null||t===``)return null;let[n=``]=t.split(`;`);return n!==``&&d(n),{redirect:n}}async function g(e,t){let n=t.headers.get(`content-type`),r=n!=null&&n!==``?n:``;if(r.startsWith(`text/x-component`))return;let i=t.status>=400&&r.startsWith(`text/plain`)?await t.text().catch(()=>t.statusText):`Server action "${e}" failed with status ${t.status}: ${t.statusText}`;throw Error(i)}export{f as callServer};
1
+ import{d as e,g as t}from"../type-guards-BLY2PlGR.mjs";import{a as n}from"../route-cache-D2iIKQIU.mjs";import{scheduleActionFlightRefresh as r}from"./action-flight-refresh.mjs";import{createFromFetch as i,createTemporaryReferenceSet as a,encodeReply as o}from"virtual:react-flight-client";const s=3e4;function c(e){if(!t(e))return e;let{"~rariSkipRefresh":n,...r}=e;return r}function l(){return typeof window<`u`?window.location.pathname+window.location.search:`/`}const u=/* @__PURE__ */ new Set([`http:`,`https:`]);function d(e){if(typeof window<`u`)try{let t=new URL(e,window.location.href);if(!u.has(t.protocol))return;t.href!==window.location.href&&(window.location.href=t.href)}catch{}}async function f(e,t){let s=a(),{headers:l,body:u}=p(await o(t,{temporaryReferences:s}));l.Accept=`text/x-component`,l[`rsc-action-id`]=e,l[`rari-router-state`]=n();let d=await m(e,l,u),_=h(d);if(_!=null)return _;await g(e,d);let v=await i(Promise.resolve(d),{callServer:f,temporaryReferences:s}),y=v.a,b=y instanceof Promise?await y:y;return r(d,v,b),c(b)}function p(e){let t={};return typeof e==`string`&&(t[`Content-Type`]=`text/plain;charset=UTF-8`),{headers:t,body:e}}async function m(t,n,r){try{return await fetch(l(),{method:`POST`,headers:n,body:r,signal:AbortSignal.timeout(s)})}catch(n){throw n instanceof DOMException&&n.name===`TimeoutError`||e(n)&&n.name===`AbortError`?Error(`Server action "${t}" timed out after ${s}ms`):n}}function h(e){let t=e.headers.get(`x-action-redirect`);if(t==null||t===``)return null;let[n=``]=t.split(`;`);return n!==``&&d(n),{redirect:n}}async function g(e,t){let n=t.headers.get(`content-type`),r=n!=null&&n!==``?n:``;if(r.startsWith(`text/x-component`))return;let i=t.status>=400&&r.startsWith(`text/plain`)?await t.text().catch(()=>t.statusText):`Server action "${e}" failed with status ${t.status}: ${t.statusText}`;throw Error(i)}export{f as callServer};