rari 0.15.3 → 0.15.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 (77) hide show
  1. package/dist/alias-resolver-Cigam7Y7.mjs +1 -0
  2. package/dist/cli.mjs +39 -39
  3. package/dist/define-BafO1-XT.d.mts +13 -0
  4. package/dist/define-CzFpVAjt.mjs +1 -0
  5. package/dist/feed-Ixvy9L12.mjs +3 -0
  6. package/dist/get-client-component-CLpyIcLJ.mjs +1 -0
  7. package/dist/headers.d.mts +1 -36
  8. package/dist/headers.mjs +1 -1
  9. package/dist/image.d.mts +38 -34
  10. package/dist/image.mjs +1 -1
  11. package/dist/index.d.mts +3 -4
  12. package/dist/mdx/define.d.mts +1 -1
  13. package/dist/mdx/define.mjs +1 -1
  14. package/dist/mdx.d.mts +5 -19
  15. package/dist/mdx.mjs +1 -1
  16. package/dist/og.d.mts +18 -8
  17. package/dist/og.mjs +1 -1
  18. package/dist/platform.mjs +2 -2
  19. package/dist/preload-modules-QmSvKk0Q.mjs +2 -0
  20. package/dist/proxy/RariRequest.d.mts +10 -11
  21. package/dist/proxy/RariRequest.mjs +1 -1
  22. package/dist/proxy/RariResponse.d.mts +1 -16
  23. package/dist/proxy/RariResponse.mjs +1 -1
  24. package/dist/proxy/runtime-executor.d.mts +1 -27
  25. package/dist/proxy/runtime-executor.mjs +1 -1
  26. package/dist/{railway-fmDbDigI.mjs → railway-HYTbx27C.mjs} +1 -1
  27. package/dist/rari-global-5vGzhToD.mjs +1 -0
  28. package/dist/{render-2I7-kFd_.mjs → render-CG5rxWXV.mjs} +1 -1
  29. package/dist/robots-BGCTYwKN.mjs +2 -0
  30. package/dist/router-D6mkoDqJ.mjs +1 -0
  31. package/dist/router.d.mts +8 -10
  32. package/dist/router.mjs +1 -1
  33. package/dist/runtime/AppRouterProvider.d.mts +25 -19
  34. package/dist/runtime/AppRouterProvider.mjs +1 -1
  35. package/dist/runtime/ErrorBoundaryWrapper.d.mts +2 -3
  36. package/dist/runtime/ErrorBoundaryWrapper.mjs +1 -1
  37. package/dist/runtime/LoadingErrorBoundary.d.mts +0 -1
  38. package/dist/runtime/action-flight-refresh.d.mts +2 -4
  39. package/dist/runtime/action-flight-refresh.mjs +1 -1
  40. package/dist/runtime/action-revalidation-kind.mjs +1 -1
  41. package/dist/runtime/call-server.d.mts +1 -1
  42. package/dist/runtime/call-server.mjs +1 -1
  43. package/dist/runtime/entry-client.d.mts +2 -0
  44. package/dist/runtime/entry-client.mjs +3 -3
  45. package/dist/runtime/flight-route-cache.d.mts +0 -1
  46. package/dist/runtime/flight-route-cache.mjs +1 -1
  47. package/dist/runtime/flight-router-state.d.mts +3 -3
  48. package/dist/runtime/merge-flight-refresh.d.mts +0 -1
  49. package/dist/runtime/merge-flight-refresh.mjs +1 -1
  50. package/dist/runtime/rsc-client-runtime.d.mts +8 -1
  51. package/dist/runtime/rsc-client-runtime.mjs +1 -1
  52. package/dist/runtime/rsc-references.d.mts +1 -1
  53. package/dist/runtime/rsc-references.mjs +1 -1
  54. package/dist/sitemap-1n5BIACA.mjs +7 -0
  55. package/dist/type-guards-CTkEL8zw.mjs +1 -0
  56. package/dist/types-BYob0lqv.d.mts +185 -0
  57. package/dist/types-DAdRjhuk.d.mts +130 -0
  58. package/dist/{types-DlF9FHQc.d.mts → types-DCEyvFz7.d.mts} +22 -19
  59. package/dist/types-_vPM8QuJ.d.mts +125 -0
  60. package/dist/utils-C-LVG9QI-D-IHIad5.mjs +37 -0
  61. package/dist/vite.d.mts +181 -160
  62. package/dist/vite.mjs +35 -35
  63. package/package.json +15 -14
  64. package/dist/alias-resolver-CHTPYtdq.mjs +0 -1
  65. package/dist/define-CRFUKkcA.d.mts +0 -14
  66. package/dist/define-rCXgNOOk.mjs +0 -1
  67. package/dist/feed-B3mYPCnT.mjs +0 -3
  68. package/dist/get-client-component-CDaY3lOP.mjs +0 -1
  69. package/dist/http-C5Y9ZrK9.mjs +0 -1
  70. package/dist/preload-modules-CJQ_IouX.mjs +0 -2
  71. package/dist/rari-global-Dygfa818.mjs +0 -1
  72. package/dist/robots-CsTVq3Jp.mjs +0 -2
  73. package/dist/router-Ctpd1kcp.mjs +0 -1
  74. package/dist/sitemap-BekxZtgA.mjs +0 -7
  75. package/dist/types-BC33STEP.d.mts +0 -97
  76. package/dist/types-DJQFFYSj.d.mts +0 -160
  77. package/dist/utils-CW4FEV95-DI7wf2Fu.mjs +0 -37
@@ -1,31 +1,5 @@
1
- //#region src/proxy/runtime/shared/types.d.ts
2
- interface SimpleRequest {
3
- url: string;
4
- method: string;
5
- headers: Record<string, string>;
6
- }
7
- interface SimpleProxyResult {
8
- continue: boolean;
9
- redirect?: {
10
- destination: string;
11
- permanent: boolean;
12
- };
13
- rewrite?: string;
14
- requestHeaders?: Record<string, string | string[]>;
15
- responseHeaders?: Record<string, string | string[]>;
16
- response?: {
17
- status: number;
18
- headers: Record<string, string | string[]>;
19
- body?: string;
20
- };
21
- }
22
- //#endregion
1
+ import "../types-_vPM8QuJ.mjs";
23
2
  //#region src/proxy/runtime/runtime-executor.d.ts
24
- declare global {
25
- interface GlobalThis {
26
- '~rariExecuteProxy'?: (request: SimpleRequest) => Promise<SimpleProxyResult>;
27
- }
28
- }
29
3
  declare function initializeProxyExecutor(proxyModulePath: string, rariRequestPath: string): Promise<boolean>;
30
4
  //#endregion
31
5
  export { initializeProxyExecutor };
@@ -1 +1 @@
1
- function e(e,t,n){if(Object.hasOwn(e,t)){let r=e[t];e[t]=Array.isArray(r)?[...r,n]:[r,n]}else e[t]=n}function t(t){let n={},r={};return t?.forEach&&t.forEach((t,i)=>{let a=i.toLowerCase();if(a.startsWith(`x-rari-proxy-request-`)){let r=a.replace(`x-rari-proxy-request-`,``);e(n,r,t)}else a.startsWith(`x-rari-proxy-`)||e(r,a,t)}),{requestHeaders:Object.keys(n).length>0?n:void 0,responseHeaders:Object.keys(r).length>0?r:void 0}}function n(t){let n={};return t?.forEach&&t.forEach((t,r)=>{e(n,r.toLowerCase(),t)}),n}function r(e){if(!e)return null;let t=e.headers?.get?.(`x-rari-proxy-rewrite`);return t?{continue:!1,rewrite:t}:null}function i(e){if(!e||e.status==null)return null;let t=e.headers?.get?.(`location`);return t&&e.status>=300&&e.status<400?{continue:!1,redirect:{destination:t,permanent:e.status===301||e.status===308}}:null}function a(e){let{requestHeaders:n,responseHeaders:r}=t(e.headers);return{continue:!0,requestHeaders:n,responseHeaders:r}}async function o(e){let t=n(e.headers),r;try{e.text&&typeof e.text==`function`?r=await e.text():e.body!=null&&typeof e.body==`string`?r=e.body:e.body!=null&&console.warn(`[rari] Proxy: Response body is not extractable as text`)}catch(e){console.error(`[rari] Proxy: Failed to extract response body:`,e)}return{continue:!1,response:{status:e.status??200,headers:t,body:r}}}async function s(e){return e?r(e)||i(e)||(e.headers?.get?.(`x-rari-proxy-continue`)===`true`?a(e):e.status==null?{continue:!0}:await o(e)):{continue:!0}}async function c(e,t){try{let n=await import(e);if(!n||!n.proxy)return console.error(`[rari] Proxy: proxy function not found in module`),!1;let{RariRequest:r}=await import(t);return globalThis[`~rariExecuteProxy`]=async function(e){try{let t=new r(e.url,{method:e.method,headers:new Headers(e.headers)}),i=[],a=await n.proxy(t,{waitUntil:e=>{e.catch(()=>{}),i.push(e)}});return i.length>0&&Promise.allSettled(i).then(e=>{e.forEach((e,t)=>{e.status===`rejected`&&console.error(`[rari] Proxy: waitUntil promise ${t} failed:`,e.reason)})}),await s(a)}catch(e){return console.error(`[rari] Proxy: Proxy execution error:`,e),{continue:!0}}},!0}catch(e){return console.error(`[rari] Proxy: Failed to initialize proxy executor:`,e),!1}}export{c as initializeProxyExecutor};
1
+ import{p as e,u as t}from"../type-guards-CTkEL8zw.mjs";function n(e,t,n){if(Object.hasOwn(e,t)){let r=e[t];e[t]=Array.isArray(r)?[...r,n]:[r,n]}else e[t]=n}function r(e){if(!e)return[];if(typeof e.getSetCookie==`function`)return e.getSetCookie();let t=[];return e.forEach&&e.forEach((e,n)=>{n.toLowerCase()===`set-cookie`&&t.push(e)}),t}function i(e,t){let r=e.cookies;if(!(!r||typeof r.toSetCookieHeaders!=`function`))for(let e of r.toSetCookieHeaders())n(t,`set-cookie`,e)}function a(e){let t={},i={};e?.forEach&&e.forEach((e,r)=>{let a=r.toLowerCase();if(a!==`set-cookie`)if(a.startsWith(`x-rari-proxy-request-`)){let r=a.replace(`x-rari-proxy-request-`,``);n(t,r,e)}else a.startsWith(`x-rari-proxy-`)||n(i,a,e)});for(let t of r(e))n(i,`set-cookie`,t);return{requestHeaders:Object.keys(t).length>0?t:void 0,responseHeaders:Object.keys(i).length>0?i:void 0}}function o(e){let t={};e?.forEach&&e.forEach((e,r)=>{r.toLowerCase()!==`set-cookie`&&n(t,r.toLowerCase(),e)});for(let i of r(e))n(t,`set-cookie`,i);return t}function s(e){if(!e)return null;let t=e.headers?.get?.(`x-rari-proxy-rewrite`);return t!=null&&t!==``?{continue:!1,rewrite:t}:null}function c(e){if(e?.status==null)return null;let t=e.headers?.get?.(`location`);return t!=null&&t!==``&&e.status>=300&&e.status<400?{continue:!1,redirect:{destination:t,permanent:e.status===301||e.status===308}}:null}function l(e){let{requestHeaders:t,responseHeaders:n={}}=a(e.headers);return i(e,n),{continue:!0,requestHeaders:t,responseHeaders:Object.keys(n).length>0?n:void 0}}async function u(e){let t=o(e.headers);i(e,t);let n;try{e.text&&typeof e.text==`function`?n=await e.text():e.body!=null&&typeof e.body==`string`?n=e.body:e.body!=null&&console.warn(`[rari] Proxy: Response body is not extractable as text`)}catch(e){console.error(`[rari] Proxy: Failed to extract response body:`,e)}return{continue:!1,response:{status:e.status??200,headers:t,body:n}}}async function d(e){return e?s(e)||c(e)||(e.headers?.get?.(`x-rari-proxy-continue`)===`true`?l(e):e.status==null?{continue:!0}:u(e)):{continue:!0}}async function f(n,r){try{let i=await import(n);if(!e(i)||!t(i.proxy))return console.error(`[rari] Proxy: proxy function not found in module`),!1;let a=i.proxy,o=await import(r);if(!e(o)||!t(o.RariRequest))return console.error(`[rari] Proxy: RariRequest constructor not found`),!1;let s=o.RariRequest;return Reflect.set(globalThis,`~rariExecuteProxy`,async e=>{try{let t=new s(e.url,{method:e.method,headers:new Headers(e.headers)}),n=[],r=await a(t,{waitUntil:e=>{e.catch(()=>{}),n.push(e)}});return n.length>0&&Promise.allSettled(n).then(e=>{e.forEach((e,t)=>{e.status===`rejected`&&console.error(`[rari] Proxy: waitUntil promise ${t} failed:`,e.reason)})}),await d(r)}catch(e){return console.error(`[rari] Proxy: Proxy execution error:`,e),{continue:!0}}}),!0}catch(e){return console.error(`[rari] Proxy: Failed to initialize proxy executor:`,e),!1}}export{f as initializeProxyExecutor};
@@ -1,4 +1,4 @@
1
- import{a as e,i as t,n,o as r,r as i,t as a}from"./utils-CW4FEV95-DI7wf2Fu.mjs";import{existsSync as o,readFileSync as s,writeFileSync as c}from"node:fs";import{join as l}from"node:path";import u from"node:process";import{styleText as d}from"node:util";function f(){let r=u.cwd();e(`Creating Railway deployment configuration...`),t(r,{providerName:`Railway`,deployScript:`echo "Push to GitHub and connect to Railway to deploy"`,startScript:`rari start`,dependency:a()}),p(r),n(r,`Railway`,`.railway`),m(r),h()}function p(e){i(e,`railway.toml`,`[build]
1
+ import{a as e,i as t,n,o as r,r as i,t as a}from"./utils-C-LVG9QI-D-IHIad5.mjs";import{existsSync as o,readFileSync as s,writeFileSync as c}from"node:fs";import{join as l}from"node:path";import u from"node:process";import{styleText as d}from"node:util";function f(){let r=u.cwd();e(`Creating Railway deployment configuration...`),i(r,{providerName:`Railway`,deployScript:`echo "Push to GitHub and connect to Railway to deploy"`,startScript:`rari start`,dependency:n()}),p(r),t(r,`Railway`,`.railway`),m(r),h()}function p(e){a(e,`railway.toml`,`[build]
2
2
  builder = "RAILPACK"
3
3
 
4
4
  [deploy]
@@ -0,0 +1 @@
1
+ function e(){return globalThis}function t(){let t=e(),n=t[`~rari`];return n??(n={},t[`~rari`]=n),n}function n(){let t=e();return t[`~clientComponents`]??={},t[`~clientComponents`]}function r(){let t=e();return t[`~clientComponentPaths`]??={},t[`~clientComponentPaths`]}function i(){let t=e();return t[`~clientComponentNames`]??={},t[`~clientComponentNames`]}function a(){return typeof window>`u`?null:window}function o(){let e=a();return e?(e[`~rari`]??=t(),e[`~rari`]):null}export{o as a,t as i,r as n,n as r,i as t};
@@ -1,4 +1,4 @@
1
- import{a as e,i as t,n,o as r,r as i,t as a}from"./utils-CW4FEV95-DI7wf2Fu.mjs";import{existsSync as o,readFileSync as s,writeFileSync as c}from"node:fs";import{join as l}from"node:path";import u from"node:process";import{styleText as d}from"node:util";function f(){let r=u.cwd();e(`Creating Render deployment configuration...`),t(r,{providerName:`Render`,deployScript:`echo "Push to GitHub and connect to Render to deploy"`,startScript:`rari start`,dependency:a()}),p(r),n(r,`Render`,`.render`),m(r),h()}function p(e){i(e,`render.yaml`,`services:
1
+ import{a as e,i as t,n,o as r,r as i,t as a}from"./utils-C-LVG9QI-D-IHIad5.mjs";import{existsSync as o,readFileSync as s,writeFileSync as c}from"node:fs";import{join as l}from"node:path";import u from"node:process";import{styleText as d}from"node:util";function f(){let r=u.cwd();e(`Creating Render deployment configuration...`),i(r,{providerName:`Render`,deployScript:`echo "Push to GitHub and connect to Render to deploy"`,startScript:`rari start`,dependency:n()}),p(r),t(r,`Render`,`.render`),m(r),h()}function p(e){a(e,`render.yaml`,`services:
2
2
  - type: web
3
3
  name: rari-app
4
4
  runtime: node
@@ -0,0 +1,2 @@
1
+ import{p as e,r as t}from"./type-guards-CTkEL8zw.mjs";import{Buffer as n}from"node:buffer";import{promises as r}from"node:fs";import i from"node:path";function a(t){return e(t)&&t.rules!=null}async function o(e){if(typeof e==`function`){let t=e(),n=t instanceof Promise?await t:t;if(!a(n))throw Error(`Robots default export must resolve to a robots object`);return n}if(!a(e))throw Error(`Robots default export must be a robots object`);return e}function s(e){return typeof e==`string`?e===``?[`*`]:[e]:e==null?[`*`]:[...e]}function c(e){return e===void 0?[]:typeof e==`string`?e===``?[]:[e]:[...e].filter(e=>e!==``)}function l(e){let t=[],n=s(e.userAgent);for(let r of n){t.push(`User-Agent: ${r}`);let n=c(e.allow);for(let e of n)t.push(`Allow: ${e}`);let i=c(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 u(e){return e==null||e===``?[]:[`Host: ${e}`,``]}function d(e){return c(e).map(e=>`Sitemap: ${e}`)}function f(e){let t=[],n=Array.isArray(e.rules)?e.rules:[e.rules];for(let e of n)t.push(...l(e));return t.push(...u(e.host)),t.push(...d(e.sitemap)),t.join(`
2
+ `)}async function p(e,n=[`.ts`,`.tsx`,`.js`,`.jsx`,`.mjs`]){let a=i.join(e,`robots.txt`);try{return await r.access(a),{type:`static`,path:a}}catch(e){if(t(e)!==`ENOENT`)throw e}for(let a of n){let n=i.join(e,`robots${a}`);try{return await r.access(n),{type:`dynamic`,path:n}}catch(e){if(t(e)!==`ENOENT`)throw e}}return null}async function m(t){let{appDir:a,outDir:s,extensions:c}=t,l=await p(a,c);if(!l)return!1;let u=i.join(s,`robots.txt`);if(await r.mkdir(i.dirname(u),{recursive:!0}),l.type===`static`)return await r.copyFile(l.path,u),!0;try{let{build:t}=await import(`rolldown`),a=await r.readFile(l.path,`utf-8`),s=`\0virtual:robots`,c=await t({input:s,external:[`rari`],platform:`node`,write:!1,output:{format:`esm`,codeSplitting:!1},plugins:[{name:`virtual-robots`,resolveId(e){return e===s?e:e.startsWith(`.`)?i.resolve(i.dirname(l.path),e):null},load(e){if(e===s){let e=i.extname(l.path).slice(1),t;switch(e){case`ts`:t=`ts`;break;case`tsx`:t=`tsx`;break;case`js`:case`mjs`:t=`js`;break;case`jsx`:t=`jsx`;break;default:throw Error(`Unsupported robots file extension: .${e}. Supported extensions are: .ts, .tsx, .js, .jsx, .mjs`)}return{code:a,moduleType:t}}return null}}]});if(c.output.length===0)throw Error(`Failed to build robots module`);let d=c.output.find(e=>e.type===`chunk`&&e.isEntry)??c.output.find(e=>e.type===`chunk`);if(d?.type!==`chunk`)throw Error(`No chunk output found in robots build result`);let p=d.code,m=await import(`data:text/javascript;base64,${n.from(p).toString(`base64`)}`);if(!e(m))throw Error(`Robots file must export a default export (either an object or a function)`);let h=m.default;if(h==null)throw Error(`Robots file must export a default export (either an object or a function)`);let g=f(await o(h));return await r.writeFile(u,g),!0}catch(e){return console.error(`[rari] Failed to build/execute robots file:`,e),!1}}export{m as generateRobotsFile};
@@ -0,0 +1 @@
1
+ import{n as e,p as t}from"./type-guards-CTkEL8zw.mjs";import{createContext as n,use as r,useEffect as i,useMemo as a,useRef as o,useState as s}from"react";import{jsx as c}from"react/jsx-runtime";let l=null;function u(){return l}function d(e){if(typeof window>`u`){console.warn(`[rari] Router cannot register navigate in non-browser environment`);return}l&&typeof process<`u`&&process.env.NODE_ENV!==`production`&&console.warn(`[rari] Router: registerNavigate called multiple times, overwriting existing navigate function`,{previous:l,new:e}),l=e,window.dispatchEvent(new CustomEvent(`rari:register-navigate`,{detail:{navigate:e}}))}function f(){if(typeof window>`u`){console.warn(`[rari] Router cannot deregister navigate in non-browser environment`);return}l=null,window.dispatchEvent(new CustomEvent(`rari:deregister-navigate`))}async function p(e,t){if(typeof window>`u`){console.warn(`[rari] Router cannot navigate in non-browser environment`);return}if(!l){console.warn(`[rari] Router not initialized, falling back to window.location`),t?.replace?window.location.replace(e):window.location.href=e;return}return l(e,t)}function m(e){return t(e)&&typeof e.to==`string`}function h(e){return t(e)&&typeof e.navigate==`function`}const g=n(null);function _({children:t,initialPathname:n}){let[r,l]=s(n),[d,f]=s(()=>typeof window<`u`?new URLSearchParams(window.location.search):new URLSearchParams),p=o(null);i(()=>{let t=t=>{let n=e(t,m);n&&(l(n.to),f(new URLSearchParams(window.location.search)))};return window.addEventListener(`rari:navigate`,t),()=>{window.removeEventListener(`rari:navigate`,t)}},[]),i(()=>{let t=u();t&&(p.current=t);let n=t=>{let n=e(t,h);n&&(p.current=n.navigate)},r=()=>{p.current=null};return window.addEventListener(`rari:register-navigate`,n),window.addEventListener(`rari:deregister-navigate`,r),()=>{window.removeEventListener(`rari:register-navigate`,n),window.removeEventListener(`rari:deregister-navigate`,r)}},[]);let _=a(()=>({pathname:r,params:{},searchParams:d,push:async(e,t)=>{p.current?await p.current(e,t):(console.warn(`[rari] Router not ready, falling back to window.location`),window.location.href=e)},replace:async(e,t)=>{p.current?await p.current(e,{...t,replace:!0}):(console.warn(`[rari] Router not ready, falling back to window.location`),window.location.replace(e))},back:()=>{window.history.back()},forward:()=>{window.history.forward()},refresh:()=>{window.dispatchEvent(new CustomEvent(`rari:app-router-rerender`))},prefetch:async e=>{try{let t=new URL(e,window.location.origin);await fetch(t.pathname+t.search,{headers:{Accept:`text/x-component`},priority:`low`})}catch(e){console.warn(`[rari] Prefetch failed:`,e)}}}),[r,d]);return c(g,{value:_,children:t})}function v(){let e=r(g);if(!e)throw Error(`useRouter must be used within a RouterProvider`);return e}function y(){return v().pathname}function b(){return v().params}function x(){return v().searchParams}export{x as a,d as c,v as i,b as n,f as o,y as r,p as s,_ as t};
package/dist/router.d.mts CHANGED
@@ -1,9 +1,10 @@
1
+ import "./types-DCEyvFz7.mjs";
1
2
  //#region src/router/navigation/types.d.ts
2
3
  interface NavigationOptions {
3
- replace?: boolean;
4
- scroll?: boolean;
5
- shallow?: boolean;
6
- historyKey?: string;
4
+ readonly replace?: boolean;
5
+ readonly scroll?: boolean;
6
+ readonly shallow?: boolean;
7
+ readonly historyKey?: string;
7
8
  }
8
9
  //#endregion
9
10
  //#region src/router/navigation/navigate.d.ts
@@ -22,13 +23,10 @@ interface RouterContextValue {
22
23
  prefetch: (href: string) => Promise<void>;
23
24
  }
24
25
  interface RouterProviderProps {
25
- children: React.ReactNode;
26
- initialPathname: string;
26
+ readonly children: React.ReactNode;
27
+ readonly initialPathname: string;
27
28
  }
28
- declare function RouterProvider({
29
- children,
30
- initialPathname
31
- }: RouterProviderProps): import("react").JSX.Element;
29
+ declare function RouterProvider({ children, initialPathname }: RouterProviderProps): import("react").JSX.Element;
32
30
  declare function useRouter(): RouterContextValue;
33
31
  declare function usePathname(): string;
34
32
  declare function useParams(): Record<string, string | string[]>;
package/dist/router.mjs CHANGED
@@ -1 +1 @@
1
- import{a as e,i as t,n,r,s as i,t as a}from"./router-Ctpd1kcp.mjs";export{a as RouterProvider,i as navigate,n as useParams,r as usePathname,t as useRouter,e as useSearchParams};
1
+ import{a as e,i as t,n,r,s as i,t as a}from"./router-D6mkoDqJ.mjs";export{a as RouterProvider,i as navigate,n as useParams,r as usePathname,t as useRouter,e as useSearchParams};
@@ -1,27 +1,33 @@
1
1
  import * as React from "react";
2
-
2
+ import { Thenable } from "virtual:react-flight-client";
3
3
  //#region src/runtime/flight/app-router-provider.d.ts
4
+ interface RscPayload {
5
+ readonly element: React.ReactNode | Thenable<React.ReactNode>;
6
+ readonly rawElement?: React.ReactNode | Thenable<React.ReactNode>;
7
+ readonly flightProtocol?: string;
8
+ }
9
+ interface NavigationOptions {
10
+ readonly historyKey?: string;
11
+ readonly scroll?: boolean;
12
+ readonly [key: string]: unknown;
13
+ }
4
14
  interface AppRouterProviderProps {
5
- children: React.ReactNode;
6
- initialPayload?: any;
7
- onNavigate?: (detail: NavigationDetail) => void;
15
+ readonly children: React.ReactNode;
16
+ readonly initialPayload?: RscPayload;
17
+ readonly onNavigate?: (detail: Readonly<NavigationDetail>) => void;
8
18
  }
9
19
  interface NavigationDetail {
10
- from: string;
11
- to: string;
12
- navigationId: number;
13
- options: any;
14
- routeInfo?: any;
15
- abortSignal?: AbortSignal;
16
- rscFlightProtocol?: string;
17
- rscResponse?: Response;
18
- rscResponsePromise?: Promise<Response>;
19
- isStreaming?: boolean;
20
+ readonly from: string;
21
+ readonly to: string;
22
+ readonly navigationId: number;
23
+ readonly options: NavigationOptions;
24
+ readonly routeInfo?: any;
25
+ readonly abortSignal?: AbortSignal;
26
+ readonly rscFlightProtocol?: string;
27
+ readonly rscResponse?: Response;
28
+ readonly rscResponsePromise?: Promise<Response>;
29
+ readonly isStreaming?: boolean;
20
30
  }
21
- declare function AppRouterProvider({
22
- children,
23
- initialPayload,
24
- onNavigate
25
- }: AppRouterProviderProps): React.JSX.Element;
31
+ declare function AppRouterProvider({ children, initialPayload, onNavigate }: AppRouterProviderProps): React.JSX.Element;
26
32
  //#endregion
27
33
  export { AppRouterProvider };
@@ -1 +1 @@
1
- "use client";import{f as e}from"../regex-constants-Wm7xRA3u.mjs";import{o as t}from"../rari-global-Dygfa818.mjs";import"./action-revalidation-kind.mjs";import{mergeFlightRefresh as n}from"./merge-flight-refresh.mjs";import{currentRouteLocation as r,flightRouteCache as i}from"./flight-route-cache.mjs";import{t as a}from"../preload-modules-CJQ_IouX.mjs";import*as o from"react";import{useEffect as s,useRef as c,useState as l}from"react";import{Fragment as u,jsx as d,jsxs as f}from"react/jsx-runtime";import{createFromReadableStream as p}from"virtual:react-flight-client";const m=/"timestamp":(\d+)/;function h({children:h,initialPayload:g,onNavigate:_}){let[v,y]=l(g),b=c(g),x=l(0)[1],S=c({x:0,y:0}),C=c(new Map),w=c(new Set),T=c(_),E=c(0),D=c(new Map),O=c([]),k=c(null),A=c(0),[j,M]=l(null);s(()=>{T.current=_},[_]);let N=e=>{if(e==null)return;let{pathname:t,search:n}=r();i.set(t,n,e)};s(()=>{b.current=v,v?.element!=null&&N(v.element)},[v]),s(()=>{if(v?.element!=null&&v.element&&typeof v.element==`object`&&`status`in v.element&&v.element.status===`rejected`){let e=v.element.reason;e&&console.error(`[rari] AppRouter: Flight payload rejected:`,e)}},[v]);let P=()=>{if(typeof document>`u`)return;let e=document.querySelectorAll(`form`);C.current.clear(),e.forEach((e,t)=>{let n=new FormData(e);C.current.set(`form-${t}`,n)})},F=()=>{typeof document>`u`||document.querySelectorAll(`form`).forEach((e,t)=>{let n=C.current.get(`form-${t}`);n&&n.forEach((t,n)=>{let r=e.elements.namedItem(n);r&&(r.type===`checkbox`||r.type===`radio`?r.checked=t===`on`:r.value=t)})})},I=(e,t,n,r)=>{let i={timestamp:Date.now(),error:e,type:t,details:n,filePath:r};O.current.push(i),A.current+=1,O.current.length>10&&O.current.shift(),A.current>=2&&M(i),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`rari:hmr-failure`,{detail:i}))},L=()=>{setTimeout(()=>{window.location.reload()},1e3)},R=()=>{A.current>0&&(A.current=0)},z=e=>{if(!k.current)return!1;if(e===k.current)return!0;let t=e.match(m);if(t){let e=Number.parseInt(t[1],10);if(Date.now()-e>5e3)return!0}return!1},B=async e=>{await a(e,w.current);let t=await p(new ReadableStream({start(t){t.enqueue(new TextEncoder().encode(e)),t.close()}}));return{element:t,rawElement:t,flightProtocol:e}},V=async(e,t=!1)=>{let n=await e;if(!n.body)throw Error(`Response has no body stream`);if(t){let e=p(n.body);return{element:e,rawElement:e,flightProtocol:``}}let r=await n.clone().text();await a(r,w.current);let i=new Uint8Array(await n.arrayBuffer()),o=await p(new ReadableStream({start(e){e.enqueue(i),e.close()}}));return{element:o,rawElement:o,flightProtocol:r}},H=async(t,n)=>{let r=t||window.location.pathname,i=E.current,o=`${i}:${r}${window.location.search}`,s=D.current.get(o);if(s)return s;let c=(async()=>{try{let t=(import.meta.env.RARI_SERVER_URL||window.location.origin).replace(e,``)+r+window.location.search,o=await fetch(t,{headers:{Accept:`text/x-component`,"rari-navigation-id":String(E.current)},cache:`no-store`,signal:n});if(!o.ok){let e=Error(`Failed to fetch RSC data: ${o.status} ${o.statusText}`);throw I(e,`fetch`,`HTTP ${o.status} when fetching ${t}`,window.location.pathname),e}let s,c=``;try{if(c=await o.clone().text(),z(c)&&v)return v;await a(c,w.current);let e=new Uint8Array(await o.arrayBuffer()),t=await p(new ReadableStream({start(t){t.enqueue(e),t.close()}}));s={element:t,rawElement:t,flightProtocol:c}}catch(e){let t=e instanceof Error?e:Error(String(e));throw I(t,`parse`,`Failed to parse RSC Flight protocol: ${t.message}`,window.location.pathname),t}return E.current===i&&(y(s),k.current=c,R()),s}catch(e){throw e instanceof Error&&!e.message.includes(`Failed to fetch RSC data`)&&!e.message.includes(`Failed to parse`)&&I(e,`network`,`Network error: ${e.message}`,window.location.pathname),e}finally{D.current.delete(o)}})();return D.current.set(o,c),c},U=c(B),W=c(V),G=c(H);s(()=>{U.current=B,W.current=V,G.current=H}),s(()=>{if(typeof window>`u`)return;let e=async e=>{let t=e.detail;if(t.navigationId!==E.current)return;S.current={x:window.scrollX,y:window.scrollY},P();let n=null,r=null,i=!1;try{if(t.rscResponsePromise){let e=await t.rscResponsePromise;if(E.current!==t.navigationId||(i=e.headers.get(`x-render-mode`)===`streaming`,n=await W.current(Promise.resolve(e),i),E.current!==t.navigationId))return}else if(t.rscResponse){if(i=t.rscResponse.headers.get(`x-render-mode`)===`streaming`,n=await W.current(Promise.resolve(t.rscResponse),i),E.current!==t.navigationId)return}else t.rscFlightProtocol?n=await U.current(t.rscFlightProtocol):t.isStreaming||(n=await G.current(t.to,t.abortSignal))}catch(e){if(e instanceof Error&&e.name===`AbortError`)return;r=e}if(r){console.error(`[rari] AppRouter: Navigation failed:`,r),window.dispatchEvent(new CustomEvent(`rari:navigate-error`,{detail:{from:t.from,to:t.to,error:r,navigationId:t.navigationId}})),A.current>=3&&L();return}if(!n&&t.isStreaming&&E.current===t.navigationId)return;n&&E.current===t.navigationId&&(i||t.options?.historyKey?(y(n),x(e=>e+1),M(null)):o.startTransition(()=>{y(n),x(e=>e+1),M(null)}),t.rscFlightProtocol&&(k.current=t.rscFlightProtocol),R(),T.current&&T.current(t));let a=typeof window<`u`&&window.location.hash.length>0;!t.options?.historyKey&&!a&&requestAnimationFrame(()=>{t.options?.scroll!==!1&&window.scrollTo(0,0)})},a=async()=>{S.current={x:window.scrollX,y:window.scrollY},P();try{await G.current(),x(e=>e+1),M(null)}catch(e){console.error(`HMR refetch error:`,e instanceof Error?e.message:String(e)),A.current>=3&&L()}finally{requestAnimationFrame(()=>{window.scrollTo(S.current.x,S.current.y),F()})}},s=e=>{let t=e;if(t.detail?.element!=null){S.current={x:window.scrollX,y:window.scrollY},P();try{let{pathname:e,search:a}=r();t.detail.revalidationKind===1?i.clear():t.detail.revalidatedPath?i.invalidate(t.detail.revalidatedPath,a):i.invalidate(e,a);let s=n(i.getElement(e,a)??b.current?.element,t.detail.element);o.startTransition(()=>{y({element:s,rawElement:s}),M(null)}),N(s),R()}catch(e){let t=e instanceof Error?e:Error(String(e));I(t,`parse`,`Action flight refresh failed: ${t.message}`,window.location.pathname),A.current>=3&&L()}finally{requestAnimationFrame(()=>{window.scrollTo(S.current.x,S.current.y),F()})}}},c=async()=>{try{await G.current(),x(e=>e+1),M(null)}catch(e){console.error(`RSC invalidate error:`,e instanceof Error?e.message:String(e)),A.current>=3&&L()}},l=e=>{let n=e;if(w.current.clear(),E.current=n.detail.navigationId,typeof window<`u`){let e=t();e&&(e.navigationId=n.detail.navigationId)}},u=async()=>{try{await G.current(),M(null)}catch(e){console.error(`Manifest update error:`,e instanceof Error?e.message:String(e)),A.current>=3&&L()}};return window.addEventListener(`rari:navigation-start`,l),window.addEventListener(`rari:navigate`,e),window.addEventListener(`rari:app-router-rerender`,a),window.addEventListener(`rari:action-flight-refresh`,s),window.addEventListener(`rari:rsc-invalidate`,c),window.addEventListener(`rari:app-router-manifest-updated`,u),()=>{window.removeEventListener(`rari:navigation-start`,l),window.removeEventListener(`rari:navigate`,e),window.removeEventListener(`rari:app-router-rerender`,a),window.removeEventListener(`rari:action-flight-refresh`,s),window.removeEventListener(`rari:rsc-invalidate`,c),window.removeEventListener(`rari:app-router-manifest-updated`,u)}},[]),s(()=>{if(!(typeof window>`u`)&&window.location.hash&&v){let e=window.location.hash.slice(1);requestAnimationFrame(()=>{requestAnimationFrame(()=>{let t=document.getElementById(e);t&&t.scrollIntoView({behavior:`instant`,block:`start`})})})}},[v]);let K=()=>{window.location.reload()},q=()=>{M(null)},J=h;return v?.element!=null&&(J=v.element),Array.isArray(J)&&J.length===1&&o.isValidElement(J[0])?J=J[0]:Array.isArray(J)&&J.length>0&&J.every(e=>o.isValidElement(e)||e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`)&&(J=o.createElement(o.Fragment,null,...J)),f(u,{children:[j&&f(`div`,{style:{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)`},children:[d(`div`,{style:{marginBottom:`16px`,fontWeight:`bold`,fontSize:`16px`},children:`⚠️ HMR Update Failed`}),f(`div`,{style:{marginBottom:`12px`,opacity:.9},children:[j.type===`fetch`&&`Failed to fetch updated content from server.`,j.type===`parse`&&`Failed to parse server response.`,j.type===`stale`&&`Server returned stale content.`,j.type===`network`&&`Network error occurred.`]}),d(`div`,{style:{marginBottom:`16px`,fontSize:`12px`,opacity:.8,fontFamily:`monospace`},children:j.details}),f(`div`,{style:{marginBottom:`12px`,fontSize:`12px`,opacity:.7},children:[`Consecutive failures:`,` `,A.current,` `,`/`,` `,3]}),f(`div`,{style:{display:`flex`,gap:`8px`},children:[d(`button`,{onClick:K,type:`button`,style:{padding:`8px 16px`,background:`white`,color:`#dc2626`,border:`none`,borderRadius:`4px`,cursor:`pointer`,fontWeight:`bold`,fontSize:`14px`},children:`Refresh Page`}),d(`button`,{onClick:q,type:`button`,style:{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`},children:`Dismiss`})]}),d(`div`,{style:{marginTop:`12px`,fontSize:`11px`,opacity:.6},children:`Check the console for detailed error logs.`})]}),J]})}export{h as AppRouterProvider};
1
+ "use client";import{n as e,p as t}from"../type-guards-CTkEL8zw.mjs";import{f as n}from"../regex-constants-Wm7xRA3u.mjs";import{a as r}from"../rari-global-5vGzhToD.mjs";import"./action-revalidation-kind.mjs";import{mergeFlightRefresh as i}from"./merge-flight-refresh.mjs";import{currentRouteLocation as a,flightRouteCache as o}from"./flight-route-cache.mjs";import{t as s}from"../preload-modules-QmSvKk0Q.mjs";import*as c from"react";import{useEffect as l,useRef as u,useState as d}from"react";import{Fragment as f,jsx as p,jsxs as m}from"react/jsx-runtime";import{createFromReadableStream as h}from"virtual:react-flight-client";const g=/"timestamp":(\d+)/;function _(e){return t(e)&&typeof e.then==`function`}function v(e){return e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`||c.isValidElement(e)||Array.isArray(e)}function y(e){return t(e)&&typeof e.from==`string`&&typeof e.to==`string`&&typeof e.navigationId==`number`&&t(e.options)}function b(e){return t(e)&&`element`in e}function x(e){return t(e)&&typeof e.navigationId==`number`&&typeof e.targetPath==`string`}function S({children:S,initialPayload:C,onNavigate:w}){let[T,E]=d(C),D=u(C),O=d(0)[1],k=u({x:0,y:0}),A=u(new Map),j=u(new Set),M=u(w),N=u(0),P=u(new Map),F=u([]),I=u(null),L=u(0),[R,z]=d(null);l(()=>{M.current=w},[w]);let B=e=>{if(e==null||_(e))return;let{pathname:t,search:n}=a();o.set(t,n,e)};l(()=>{D.current=T,T?.element!=null&&B(T.element)},[T]),l(()=>{if(T?.element!=null){let e=T.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)}}},[T]);let V=()=>{if(typeof document>`u`)return;let e=document.querySelectorAll(`form`);A.current.clear(),e.forEach((e,t)=>{let n=new FormData(e);A.current.set(`form-${t}`,n)})},H=()=>{typeof document>`u`||document.querySelectorAll(`form`).forEach((e,t)=>{let n=A.current.get(`form-${t}`);n&&n.forEach((t,n)=>{let r=e.elements.namedItem(n);r instanceof HTMLInputElement&&(r.type===`checkbox`||r.type===`radio`?r.checked=t===`on`:typeof t==`string`&&(r.value=t))})})},U=(e,t,n,r)=>{let i={timestamp:Date.now(),error:e,type:t,details:n,filePath:r};F.current.push(i),L.current+=1,F.current.length>10&&F.current.shift(),L.current>=2&&z(i),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`rari:hmr-failure`,{detail:i}))},W=()=>{setTimeout(()=>{window.location.reload()},1e3)},G=()=>{L.current>0&&(L.current=0)},K=e=>{if(I.current==null||I.current===``)return!1;if(e===I.current)return!0;let t=g.exec(e);if(t){let e=Number.parseInt(t[1],10);if(Date.now()-e>5e3)return!0}return!1},q=async e=>{await s(e,j.current);let t=await h(new ReadableStream({start(t){t.enqueue(new TextEncoder().encode(e)),t.close()}}));return{element:t,rawElement:t,flightProtocol:e}},J=async(e,t=!1)=>{let n=await e;if(!n.body)throw Error(`Response has no body stream`);if(t){let e=h(n.body);return{element:e,rawElement:e,flightProtocol:``}}let r=await n.clone().text();await s(r,j.current);let i=new Uint8Array(await n.arrayBuffer()),a=await h(new ReadableStream({start(e){e.enqueue(i),e.close()}}));return{element:a,rawElement:a,flightProtocol:r}},Y=async(e,t)=>{let r=e!=null&&e!==``?e:window.location.pathname,i=N.current,a=`${i}:${r}${window.location.search}`,o=P.current.get(a);if(o)return o;let c=(async()=>{try{let e=(import.meta.env.RARI_SERVER_URL!=null&&import.meta.env.RARI_SERVER_URL!==``?import.meta.env.RARI_SERVER_URL:window.location.origin).replace(n,``)+r+window.location.search,a=await fetch(e,{headers:{Accept:`text/x-component`,"rari-navigation-id":String(N.current)},cache:`no-store`,signal:t});if(!a.ok){let t=Error(`Failed to fetch RSC data: ${a.status} ${a.statusText}`);throw U(t,`fetch`,`HTTP ${a.status} when fetching ${e}`,window.location.pathname),t}let o,c=``;try{if(c=await a.clone().text(),K(c)&&T)return T;await s(c,j.current);let e=new Uint8Array(await a.arrayBuffer()),t=await h(new ReadableStream({start(t){t.enqueue(e),t.close()}}));o={element:t,rawElement:t,flightProtocol:c}}catch(e){let t=e instanceof Error?e:Error(String(e));throw U(t,`parse`,`Failed to parse RSC Flight protocol: ${t.message}`,window.location.pathname),t}return N.current===i&&(E(o),I.current=c,G()),o}catch(e){throw e instanceof Error&&!e.message.includes(`Failed to fetch RSC data`)&&!e.message.includes(`Failed to parse`)&&U(e,`network`,`Network error: ${e.message}`,window.location.pathname),e}finally{P.current.delete(a)}})();return P.current.set(a,c),c},X=u(q),Z=u(J),Q=u(Y);l(()=>{X.current=q,Z.current=J,Q.current=Y}),l(()=>{if(typeof window>`u`)return;let t=async t=>{let n=e(t,y);if(!n||n.navigationId!==N.current)return;k.current={x:window.scrollX,y:window.scrollY},V();let r,i=null,a=!1;try{if(n.rscResponsePromise){let e=await n.rscResponsePromise;if(N.current!==n.navigationId||(a=e.headers.get(`x-render-mode`)===`streaming`,r=await Z.current(Promise.resolve(e),a),N.current!==n.navigationId))return}else if(n.rscResponse){if(a=n.rscResponse.headers.get(`x-render-mode`)===`streaming`,r=await Z.current(Promise.resolve(n.rscResponse),a),N.current!==n.navigationId)return}else n.rscFlightProtocol!=null&&n.rscFlightProtocol!==``?r=await X.current(n.rscFlightProtocol):n.isStreaming||(r=await Q.current(n.to,n.abortSignal))}catch(e){if(e instanceof Error&&e.name===`AbortError`)return;i=e instanceof Error?e:Error(String(e))}if(i){console.error(`[rari] AppRouter: Navigation failed:`,i),window.dispatchEvent(new CustomEvent(`rari:navigate-error`,{detail:{from:n.from,to:n.to,error:i,navigationId:n.navigationId}})),L.current>=3&&W();return}if(!r&&n.isStreaming&&N.current===n.navigationId)return;r&&N.current===n.navigationId&&(a||n.options.historyKey!=null&&n.options.historyKey!==``?(E(r),O(e=>e+1),z(null)):c.startTransition(()=>{E(r),O(e=>e+1),z(null)}),n.rscFlightProtocol!=null&&n.rscFlightProtocol!==``&&(I.current=n.rscFlightProtocol),G(),M.current&&M.current(n));let o=typeof window<`u`&&window.location.hash.length>0;(n.options.historyKey==null||n.options.historyKey===``)&&!o&&requestAnimationFrame(()=>{n.options.scroll!==!1&&window.scrollTo(0,0)})},n=async()=>{k.current={x:window.scrollX,y:window.scrollY},V();try{await Q.current(),O(e=>e+1),z(null)}catch(e){console.error(`HMR refetch error:`,e instanceof Error?e.message:String(e)),L.current>=3&&W()}finally{requestAnimationFrame(()=>{window.scrollTo(k.current.x,k.current.y),H()})}},s=t=>{let n=e(t,b);if(!(n?.element==null||!v(n.element)&&!_(n.element))){k.current={x:window.scrollX,y:window.scrollY},V();try{let{pathname:e,search:t}=a();n.revalidationKind===1?o.clear():n.revalidatedPath!=null&&n.revalidatedPath!==``?o.invalidate(n.revalidatedPath,t):o.invalidate(e,t);let r=D.current?.element,s=o.getElement(e,t)??(r!=null&&_(r)?null:r??null),l=n.element,u=_(l)?l:i(s,l);c.startTransition(()=>{E({element:u,rawElement:u}),z(null)}),B(u),G()}catch(e){let t=e instanceof Error?e:Error(String(e));U(t,`parse`,`Action flight refresh failed: ${t.message}`,window.location.pathname),L.current>=3&&W()}finally{requestAnimationFrame(()=>{window.scrollTo(k.current.x,k.current.y),H()})}}},l=async()=>{try{await Q.current(),O(e=>e+1),z(null)}catch(e){console.error(`RSC invalidate error:`,e instanceof Error?e.message:String(e)),L.current>=3&&W()}},u=t=>{let n=e(t,x);if(n&&(j.current.clear(),N.current=n.navigationId,typeof window<`u`)){let e=r();e&&(e.navigationId=n.navigationId)}},d=async()=>{try{await Q.current(),z(null)}catch(e){console.error(`Manifest update error:`,e instanceof Error?e.message:String(e)),L.current>=3&&W()}},f=e=>{t(e)},p=()=>{n()},m=()=>{l()},h=()=>{d()};return window.addEventListener(`rari:navigation-start`,u),window.addEventListener(`rari:navigate`,f),window.addEventListener(`rari:app-router-rerender`,p),window.addEventListener(`rari:action-flight-refresh`,s),window.addEventListener(`rari:rsc-invalidate`,m),window.addEventListener(`rari:app-router-manifest-updated`,h),()=>{window.removeEventListener(`rari:navigation-start`,u),window.removeEventListener(`rari:navigate`,f),window.removeEventListener(`rari:app-router-rerender`,p),window.removeEventListener(`rari:action-flight-refresh`,s),window.removeEventListener(`rari:rsc-invalidate`,m),window.removeEventListener(`rari:app-router-manifest-updated`,h)}},[]),l(()=>{if(!(typeof window>`u`)&&window.location.hash&&T){let e=window.location.hash.slice(1);requestAnimationFrame(()=>{requestAnimationFrame(()=>{let t=document.getElementById(e);t&&t.scrollIntoView({behavior:`instant`,block:`start`})})})}},[T]);let ee=()=>{window.location.reload()},te=()=>{z(null)},$=S;if(T?.element!=null&&($=T.element),Array.isArray($)){let e=$;e.length===1&&c.isValidElement(e[0])?$=e[0]:e.length>0&&e.every(e=>c.isValidElement(e)||e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`)&&($=c.createElement(c.Fragment,null,...e))}return m(f,{children:[R&&m(`div`,{style:{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)`},children:[p(`div`,{style:{marginBottom:`16px`,fontWeight:`bold`,fontSize:`16px`},children:`⚠️ HMR Update Failed`}),m(`div`,{style:{marginBottom:`12px`,opacity:.9},children:[R.type===`fetch`&&`Failed to fetch updated content from server.`,R.type===`parse`&&`Failed to parse server response.`,R.type===`stale`&&`Server returned stale content.`,R.type===`network`&&`Network error occurred.`]}),p(`div`,{style:{marginBottom:`16px`,fontSize:`12px`,opacity:.8,fontFamily:`monospace`},children:R.details}),m(`div`,{style:{marginBottom:`12px`,fontSize:`12px`,opacity:.7},children:[`Consecutive failures: `,L.current,` / `,3]}),m(`div`,{style:{display:`flex`,gap:`8px`},children:[p(`button`,{onClick:ee,type:`button`,style:{padding:`8px 16px`,background:`white`,color:`#dc2626`,border:`none`,borderRadius:`4px`,cursor:`pointer`,fontWeight:`bold`,fontSize:`14px`},children:`Refresh Page`}),p(`button`,{onClick:te,type:`button`,style:{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`},children:`Dismiss`})]}),p(`div`,{style:{marginTop:`12px`,fontSize:`11px`,opacity:.6},children:`Check the console for detailed error logs.`})]}),$]})}export{S as AppRouterProvider};
@@ -1,10 +1,9 @@
1
1
  import * as React from "react";
2
2
  import { Component, ReactNode } from "react";
3
-
4
3
  //#region src/runtime/boundaries/error-boundary-wrapper.d.ts
5
4
  interface ErrorBoundaryWrapperProps {
6
- errorComponentId: string;
7
- children: ReactNode;
5
+ readonly errorComponentId: string;
6
+ readonly children: ReactNode;
8
7
  }
9
8
  interface ErrorBoundaryWrapperState {
10
9
  hasError: boolean;
@@ -1 +1 @@
1
- "use client";import{t as e}from"../timer-Duul5JHq.mjs";import{r as t}from"../rari-global-Dygfa818.mjs";import{Component as n}from"react";import{jsx as r}from"react/jsx-runtime";var i=class extends n{_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=e(this._pendingTimer)}componentDidCatch(e,n){console.error(`[rari] Error boundary caught error:`,e,n);let r=this.props.errorComponentId;if(r&&typeof window<`u`){let e=t()[r];e&&(e.component&&typeof e.component==`function`?this.setState({ErrorComponent:e.component}):e.loader&&!e.loading&&(e.loading=!0,e.loader().then(t=>{let n=t.default||t;e.component=n,e.registered=!0,e.loading=!1,this.setState({ErrorComponent:n})}).catch(t=>{e.loading=!1,console.error(`[rari] Failed to load error component ${r}:`,t)})))}}reset=()=>{this._pendingTimer=e(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?r(e,{error:this.state.error,reset:this.reset}):null}return this.props.children}};export{i as ErrorBoundaryWrapper};
1
+ "use client";import{c as e,p as t}from"../type-guards-CTkEL8zw.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}from"react/jsx-runtime";function o(n){if(e(n))return n;if(t(n)){let t=n.default??n;return e(t)?t:null}return null}var s=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=o(t.component);r?this.setState({ErrorComponent:r}):t.loader&&!t.loading&&(t.loading=!0,t.loader().then(e=>{let n=o(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?a(e,{error:this.state.error,reset:this.reset}):null}return this.props.children}};export{s as ErrorBoundaryWrapper};
@@ -1,5 +1,4 @@
1
1
  import * as React from "react";
2
-
3
2
  //#region src/runtime/boundaries/loading-error-boundary.d.ts
4
3
  interface LoadingErrorBoundaryProps {
5
4
  children: React.ReactNode;
@@ -1,15 +1,13 @@
1
1
  import { ActionDidNotRevalidate, ActionDidRevalidateDynamicOnly, ActionDidRevalidateStaticAndDynamic, ActionRevalidationKind } from "./action-revalidation-kind.mjs";
2
-
3
2
  //#region src/runtime/actions/flight-refresh.d.ts
4
3
  interface ActionFlightRefreshDetail {
5
4
  element: unknown;
6
5
  revalidationKind: ActionRevalidationKind;
7
6
  revalidatedPath?: string;
8
7
  }
9
- /** Flight action response: `a` is the action result, `f` is the optional refresh tree. */
10
8
  interface ActionFlightResponseShape {
11
- a?: unknown;
12
- f?: unknown;
9
+ readonly a?: unknown;
10
+ readonly f?: unknown;
13
11
  }
14
12
  declare function scheduleActionFlightRefresh(response: Response, flightResponse: ActionFlightResponseShape, actionResult: unknown): void;
15
13
  declare function refreshRouter(): void;
@@ -1 +1 @@
1
- import{ActionDidNotRevalidate as e,ActionDidRevalidateDynamicOnly as t,ActionDidRevalidateStaticAndDynamic as n,parseActionRevalidationKind as r}from"./action-revalidation-kind.mjs";function i(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=e;return`redirect`in t?!0:`~rariSkipRefresh`in t||`~rariFormState`in t}function a(e){return typeof e==`object`&&!!e&&`$$typeof`in e}async function o(e){if(e==null||e===``)return null;let t=e instanceof Promise?await e:e;return t==null||t===``?null:t}function s(e,t,n){typeof globalThis.dispatchEvent==`function`&&(i(n)||(async()=>{let n=await o(t.f);if(n==null||!a(n))return;let i=r(e.headers.get(`x-action-revalidated`));if(i===0)return;let s=e.headers.get(`x-action-revalidated-path`)??void 0,c=()=>{globalThis.dispatchEvent(new CustomEvent(`rari:action-flight-refresh`,{detail:{element:n,revalidationKind:i,revalidatedPath:s}}))};if(typeof requestAnimationFrame==`function`){requestAnimationFrame(()=>{requestAnimationFrame(c)});return}queueMicrotask(c)})().catch(e=>{console.error(`[rari] Action flight refresh failed:`,e instanceof Error?e.message:String(e))}))}function c(){typeof globalThis.dispatchEvent==`function`&&globalThis.dispatchEvent(new CustomEvent(`rari:app-router-rerender`))}export{e as ActionDidNotRevalidate,t as ActionDidRevalidateDynamicOnly,n as ActionDidRevalidateStaticAndDynamic,c as refreshRouter,s as scheduleActionFlightRefresh};
1
+ import{p as e}from"../type-guards-CTkEL8zw.mjs";import{ActionDidNotRevalidate as t,ActionDidRevalidateDynamicOnly as n,ActionDidRevalidateStaticAndDynamic as r,parseActionRevalidationKind as i}from"./action-revalidation-kind.mjs";function a(t){return e(t)?`redirect`in t||`~rariSkipRefresh`in t||`~rariFormState`in t:!1}function o(e){return typeof e==`object`&&!!e&&`$$typeof`in e}function s(t){return e(t)&&typeof t.then==`function`}function c(e){return o(e)||s(e)}function l(e){return e==null||e===``?null:e instanceof Promise?e.then(e=>e==null||e===``?null:e):e}function u(e,t,n){typeof globalThis.dispatchEvent==`function`&&(a(n)||(async()=>{let n=l(t.f),r=n instanceof Promise?await n:n;if(r==null||!c(r))return;let a=i(e.headers.get(`x-action-revalidated`));if(a===0)return;let o=e.headers.get(`x-action-revalidated-path`)??void 0,s=()=>{globalThis.dispatchEvent(new CustomEvent(`rari:action-flight-refresh`,{detail:{element:r,revalidationKind:a,revalidatedPath:o}}))};if(typeof requestAnimationFrame==`function`){requestAnimationFrame(()=>{requestAnimationFrame(s)});return}queueMicrotask(s)})().catch(e=>{console.error(`[rari] Action flight refresh failed:`,e instanceof Error?e.message:String(e))}))}function d(){typeof globalThis.dispatchEvent==`function`&&globalThis.dispatchEvent(new CustomEvent(`rari:app-router-rerender`))}export{t as ActionDidNotRevalidate,n as ActionDidRevalidateDynamicOnly,r as ActionDidRevalidateStaticAndDynamic,d as refreshRouter,u as scheduleActionFlightRefresh};
@@ -1 +1 @@
1
- const e=0,t=1,n=2;function r(e){if(!e)return 0;try{let t=JSON.parse(e);if(t===1||t===2)return t}catch{if(e.startsWith(`/`))return 2}return 0}export{e as ActionDidNotRevalidate,n as ActionDidRevalidateDynamicOnly,t as ActionDidRevalidateStaticAndDynamic,r as parseActionRevalidationKind};
1
+ const e=0,t=1,n=2;function r(e){if(e==null||e===``)return 0;try{let t=JSON.parse(e);if(t===1||t===2)return t}catch{}return 0}export{e as ActionDidNotRevalidate,n as ActionDidRevalidateDynamicOnly,t as ActionDidRevalidateStaticAndDynamic,r as parseActionRevalidationKind};
@@ -1,4 +1,4 @@
1
1
  //#region src/runtime/actions/call-server.d.ts
2
- declare function callServer(id: string, args: unknown[]): Promise<unknown>;
2
+ declare function callServer(id: string, args: readonly unknown[]): Promise<unknown>;
3
3
  //#endregion
4
4
  export { callServer };
@@ -1 +1 @@
1
- import{buildFlightRouterState as e}from"./flight-router-state.mjs";import{scheduleActionFlightRefresh as t}from"./action-flight-refresh.mjs";import{createFromFetch as n,createTemporaryReferenceSet as r,encodeReply as i}from"virtual:react-flight-client";function a(){if(typeof window>`u`)return{pathname:`/`,search:``,tree:e(`/`)};let t=window.location.pathname;return{pathname:t,search:window.location.search,tree:e(t)}}function o(){return JSON.stringify(a())}const s=3e4;function c(e){if(!e||typeof e!=`object`||Array.isArray(e))return e;let t={...e};return delete t[`~rariSkipRefresh`],t}function l(){return typeof window<`u`?window.location.pathname+window.location.search:`/`}const u=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,a){let u=r(),p=await i(a,{temporaryReferences:u}),m={Accept:`text/x-component`,"rsc-action-id":e,"rari-router-state":o()},h;typeof p==`string`&&(m[`Content-Type`]=`text/plain;charset=UTF-8`),h=p;let g=new AbortController,_=setTimeout(()=>g.abort(),s),v;try{v=await fetch(l(),{method:`POST`,headers:m,body:h,signal:g.signal})}catch(t){throw t instanceof Error&&t.name===`AbortError`?Error(`Server action "${e}" timed out after ${s}ms`):t}finally{clearTimeout(_)}let y=v.headers.get(`x-action-redirect`);if(y){let[e]=y.split(`;`);return e&&d(e),{redirect:e}}let b=v.headers.get(`content-type`)||``;if(!b.startsWith(`text/x-component`)){let t=v.status>=400&&b.startsWith(`text/plain`)?await v.text().catch(()=>v.statusText):`Server action "${e}" failed with status ${v.status}: ${v.statusText}`;throw Error(t)}let x=await n(Promise.resolve(v),{callServer:f,temporaryReferences:u}),S=x.a,C=S instanceof Promise?await S:S;return t(v,x,C),c(C)}export{f as callServer};
1
+ import{p as e}from"../type-guards-CTkEL8zw.mjs";import{buildFlightRouterState as t}from"./flight-router-state.mjs";import{scheduleActionFlightRefresh as n}from"./action-flight-refresh.mjs";import{createFromFetch as r,createTemporaryReferenceSet as i,encodeReply as a}from"virtual:react-flight-client";function o(){if(typeof window>`u`)return{pathname:`/`,search:``,tree:t(`/`)};let e=window.location.pathname;return{pathname:e,search:window.location.search,tree:t(e)}}function s(){return JSON.stringify(o())}const c=3e4;function l(t){if(!e(t))return t;let{"~rariSkipRefresh":n,...r}=t;return r}function u(){return typeof window<`u`?window.location.pathname+window.location.search:`/`}const d=new Set([`http:`,`https:`]);function f(e){if(!(typeof window>`u`))try{let t=new URL(e,window.location.href);if(!d.has(t.protocol))return;t.href!==window.location.href&&(window.location.href=t.href)}catch{}}async function p(e,t){let o=i(),d=await a(t,{temporaryReferences:o}),m={Accept:`text/x-component`,"rsc-action-id":e,"rari-router-state":s()},h;typeof d==`string`&&(m[`Content-Type`]=`text/plain;charset=UTF-8`),h=d;let g=new AbortController,_=setTimeout(()=>{g.abort()},c),v;try{v=await fetch(u(),{method:`POST`,headers:m,body:h,signal:g.signal})}catch(t){throw t instanceof Error&&t.name===`AbortError`?Error(`Server action "${e}" timed out after ${c}ms`):t}finally{clearTimeout(_)}let y=v.headers.get(`x-action-redirect`);if(y!=null&&y!==``){let[e=``]=y.split(`;`);return e!==``&&f(e),{redirect:e}}let b=v.headers.get(`content-type`),x=b!=null&&b!==``?b:``;if(!x.startsWith(`text/x-component`)){let t=v.status>=400&&x.startsWith(`text/plain`)?await v.text().catch(()=>v.statusText):`Server action "${e}" failed with status ${v.status}: ${v.statusText}`;throw Error(t)}let S=await r(Promise.resolve(v),{callServer:p,temporaryReferences:o}),C=S.a,w=C instanceof Promise?await C:C;return n(v,S,w),l(w)}export{p as callServer};
@@ -1,3 +1,5 @@
1
+ import "../types-_vPM8QuJ.mjs";
2
+ import "virtual:rsc-integration.ts";
1
3
  //#region src/runtime/entry-client.d.ts
2
4
  declare function preloadClientComponent(id: string): Promise<void>;
3
5
  declare function renderApp(): Promise<void>;
@@ -1,5 +1,5 @@
1
- import{c as e,o as t,t as n}from"../router-Ctpd1kcp.mjs";import{i as r,n as i,o as a,r as o}from"../rari-global-Dygfa818.mjs";import{t as s}from"../get-client-component-CDaY3lOP.mjs";import{t as c}from"../preload-modules-CJQ_IouX.mjs";import*as l from"react";import{useEffect as u,useLayoutEffect as d,useRef as f,useState as p}from"react";import{createFromReadableStream as m}from"virtual:react-flight-client";import{createRoot as h,hydrateRoot as g}from"react-dom/client";import{AppRouterProvider as _}from"virtual:app-router-provider";import"virtual:rsc-integration.ts";function v(e,t,n={}){let r=null,i=0,a=0,o=null,s=null,{leading:c=!1,trailing:l=!0,maxWait:u}=n;function d(t){let n=o,r=s;return o=null,s=null,a=t,e.apply(r,n)}function f(e){let n=e-i,r=e-a;return i===0||n>=t||n<0||u!==void 0&&r>=u}function p(){let e=Date.now();if(f(e))return h(e);let n=e-i,o=e-a,s=t-n,c=u===void 0?1/0:u-o;r=setTimeout(p,Math.min(s,c))}function m(e){return a=e,r=setTimeout(p,t),c?d(e):void 0}function h(e){if(r=null,l&&o)return d(e);o=null,s=null}function g(){r!==null&&clearTimeout(r),a=0,o=null,i=0,s=null,r=null}function _(){return r===null?void 0:h(Date.now())}function v(){return r!==null}function y(...e){let n=Date.now(),a=f(n);if(o=e,s=this,i=n,a){if(r===null)return m(i);if(u!==void 0)return r=setTimeout(p,t),d(i)}r===null&&(r=setTimeout(p,t))}return y.cancel=g,y.flush=_,y.pending=v,y}const y=/fetch|networkerror|load failed/i;function b(e,t){return{type:`abort`,message:`Navigation was cancelled`,originalError:e,url:t,timestamp:Date.now(),retryable:!1}}function x(e,t){return{type:`timeout`,message:`Navigation request timed out`,originalError:e,url:t,timestamp:Date.now(),retryable:!0}}function S(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 C(e,t){return{type:`network-error`,message:`Network error - check your connection`,originalError:e,url:t,timestamp:Date.now(),retryable:!0}}function w(e,t){return{type:`parse-error`,message:`Failed to parse server response`,originalError:e instanceof Error?e:void 0,url:t,timestamp:Date.now(),retryable:!1}}function T(e,t){return{type:`fetch-error`,message:e instanceof Error?e.message:`Unknown error occurred`,originalError:e instanceof Error?e:void 0,url:t,timestamp:Date.now(),retryable:!1}}function E(e,t){if(e instanceof Error&&e.name===`AbortError`)return b(e,t);if(e instanceof Error&&(e.name===`TimeoutError`||e.message.includes(`timeout`)))return x(e,t);if(e instanceof Error&&`status`in e){let n=e.status;return typeof n==`number`?S(e,n,t):T(e,t)}return e instanceof TypeError&&y.test(e.message)?C(e,t):e instanceof SyntaxError||e instanceof Error&&e.message.includes(`parse`)?w(e,t):T(e,t)}var D=class{options;retryCount;constructor(e={}){this.options={timeout:e.timeout??1e4,maxRetries:e.maxRetries??3,onError:e.onError??(()=>{}),onRetry:e.onRetry??(()=>{})},this.retryCount=new Map}handleError(e,t){let n=E(e,t);return this.options.onError(n),console.error(`[rari] Navigation:`,n.type,n.message,{url:n.url,statusCode:n.statusCode,retryable:n.retryable}),n}canRetry(e,t){return e.retryable?(this.retryCount.get(t)??0)<this.options.maxRetries:!1}incrementRetry(e){let t=(this.retryCount.get(e)??0)+1;return this.retryCount.set(e,t),this.options.onRetry(t,{type:`fetch-error`,message:`Retry attempt ${t}`,url:e,timestamp:Date.now(),retryable:!0}),t}resetRetry(e){this.retryCount.delete(e)}getRetryCount(e){return this.retryCount.get(e)??0}clearRetries(){this.retryCount.clear()}};function O(e){if(!e||e===`/`)return`/`;let t=e;for(;t.endsWith(`/`)&&t.length>1;)t=t.slice(0,-1);return t.startsWith(`/`)||(t=`/${t}`),t}function k(e,t){try{return new URL(e,t||window.location.origin).origin!==(t||window.location.origin)}catch{return!1}}function A(e){try{let t=new URL(e,window.location.origin);return t.pathname+t.hash}catch{return e}}const j=new class{cache=new Map;pendingRequests=new Map;async get(e){let t=this.cache.get(e);if(t)return t;let n=this.pendingRequests.get(e);if(n)return n;let r=this.fetchRouteInfo(e);this.pendingRequests.set(e,r);try{let t=await r;return this.cache.set(e,t),t}finally{this.pendingRequests.delete(e)}}async fetchRouteInfo(e){let t=await fetch(`/_rari/route-info`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:e})});if(!t.ok){let e=null;try{e=await t.json()}catch{}throw e?.error?Error(e.error):Error(`Failed to fetch route info: ${t.status} ${t.statusText}`)}let n=t.clone();try{return await t.json()}catch(t){try{let e=await n.text();return JSON.parse(e)}catch(n){throw console.error(`[RouteInfo] Failed to parse response:`,{error:t,parseError:n,path:e}),Error(`Failed to parse route info response`)}}}clear(){this.cache.clear(),this.pendingRequests.clear()}invalidate(e){this.cache.delete(e)}};if(typeof window<`u`){let e=a();e.routeInfoCache=j}var M=class{stateHistory;routeAccessOrder;maxHistorySize;scrollableSelector;constructor(e={}){this.stateHistory=new Map,this.routeAccessOrder=[],this.maxHistorySize=e.maxHistorySize||50,this.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=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=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&&this.stateHistory.delete(e)}}getHistorySize(){return this.stateHistory.size}hasState(e){return this.stateHistory.has(e)}getState(e){return this.stateHistory.get(e)}clearAll(){this.stateHistory.clear(),this.routeAccessOrder=[]}clearState(e){this.stateHistory.delete(e);let t=this.routeAccessOrder.indexOf(e);t!==-1&&this.routeAccessOrder.splice(t,1)}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&&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)||document.querySelector(`form[name="${n}"]`)||document.querySelectorAll(`form`)[Number.parseInt(n.replace(`form-`,``),10)];r instanceof HTMLFormElement?e.forEach((e,n)=>{try{let t=r.elements.namedItem(n);t instanceof RadioNodeList?t.forEach(t=>{t instanceof HTMLInputElement&&(t.type===`radio`||t.type===`checkbox`?t.checked=t.value===e:t.value=e)}):(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)&&(t instanceof HTMLInputElement&&(t.type===`checkbox`||t.type===`radio`)?t.checked=t.value===e:t.value=e)}catch{t=!1}}):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 N(e,t){let n=document.querySelector(e);if(n)t.content&&n.setAttribute(`content`,t.content);else{n=document.createElement(`meta`);for(let[e,r]of Object.entries(t))n.setAttribute(e,r);document.head.appendChild(n)}}function P(e){let t=document.querySelector(e);t&&t.remove()}function F(e){e.title&&(document.title=e.title),e.description?N(`meta[name="description"]`,{name:`description`,content:e.description}):P(`meta[name="description"]`),e.keywords&&e.keywords.length>0?N(`meta[name="keywords"]`,{name:`keywords`,content:e.keywords.join(`, `)}):P(`meta[name="keywords"]`),e.viewport&&N(`meta[name="viewport"]`,{name:`viewport`,content:e.viewport})}function I(e){let t=document.querySelector(`link[rel="canonical"]`);if(e===void 0){t&&t.remove();return}if(t)t.setAttribute(`href`,e);else{let t=document.createElement(`link`);t.setAttribute(`rel`,`canonical`),t.setAttribute(`href`,e),document.head.appendChild(t)}}function L(e){if(e===void 0){P(`meta[name="robots"]`);return}let t=[];e.index!==void 0&&t.push(e.index?`index`:`noindex`),e.follow!==void 0&&t.push(e.follow?`follow`:`nofollow`),e.nocache&&t.push(`nocache`),t.length>0?N(`meta[name="robots"]`,{name:`robots`,content:t.join(`, `)}):P(`meta[name="robots"]`)}function R(e){if(e===void 0){P(`meta[property="og:title"]`),P(`meta[property="og:description"]`),P(`meta[property="og:url"]`),P(`meta[property="og:site_name"]`),P(`meta[property="og:type"]`),document.querySelectorAll(`meta[property="og:image"]`).forEach(e=>e.remove());return}if(e.title?N(`meta[property="og:title"]`,{property:`og:title`,content:e.title}):P(`meta[property="og:title"]`),e.description?N(`meta[property="og:description"]`,{property:`og:description`,content:e.description}):P(`meta[property="og:description"]`),e.url?N(`meta[property="og:url"]`,{property:`og:url`,content:e.url}):P(`meta[property="og:url"]`),e.siteName?N(`meta[property="og:site_name"]`,{property:`og:site_name`,content:e.siteName}):P(`meta[property="og:site_name"]`),e.type?N(`meta[property="og:type"]`,{property:`og:type`,content:e.type}):P(`meta[property="og:type"]`),e.images&&e.images.length>0){document.querySelectorAll(`meta[property="og:image"]`).forEach(e=>e.remove());for(let t of e.images){let e=document.createElement(`meta`);e.setAttribute(`property`,`og:image`),e.setAttribute(`content`,t),document.head.appendChild(e)}}else document.querySelectorAll(`meta[property="og:image"]`).forEach(e=>e.remove())}function z(e){if(e===void 0){P(`meta[name="twitter:card"]`),P(`meta[name="twitter:site"]`),P(`meta[name="twitter:creator"]`),P(`meta[name="twitter:title"]`),P(`meta[name="twitter:description"]`),document.querySelectorAll(`meta[name="twitter:image"]`).forEach(e=>e.remove());return}if(e.card?N(`meta[name="twitter:card"]`,{name:`twitter:card`,content:e.card}):P(`meta[name="twitter:card"]`),e.site?N(`meta[name="twitter:site"]`,{name:`twitter:site`,content:e.site}):P(`meta[name="twitter:site"]`),e.creator?N(`meta[name="twitter:creator"]`,{name:`twitter:creator`,content:e.creator}):P(`meta[name="twitter:creator"]`),e.title?N(`meta[name="twitter:title"]`,{name:`twitter:title`,content:e.title}):P(`meta[name="twitter:title"]`),e.description?N(`meta[name="twitter:description"]`,{name:`twitter:description`,content:e.description}):P(`meta[name="twitter:description"]`),e.images&&e.images.length>0){document.querySelectorAll(`meta[name="twitter:image"]`).forEach(e=>e.remove());for(let t of e.images){let e=document.createElement(`meta`);e.setAttribute(`name`,`twitter:image`),e.setAttribute(`content`,t),document.head.appendChild(e)}}else document.querySelectorAll(`meta[name="twitter:image"]`).forEach(e=>e.remove())}function B(e){F(e),I(e.canonical),L(e.robots),R(e.openGraph),z(e.twitter)}function V({children:n,initialRoute:r,staleWindowMs:i=3e4}){let[a,o]=p(()=>({currentRoute:O(r),navigationId:0,error:null})),s=f(null),c=f(!0),l=f(O(r)),m=f(0),h=f(new D({timeout:1e4,maxRetries:3,onError:e=>{console.error(`[rari] Router: Navigation error:`,e)},onRetry:()=>{}})),g=f(new Map),_=f([]),y=f(new M({maxHistorySize:50})),b=f(null),x=f(i),S=()=>`${Date.now()}-${Math.random().toString(36).substring(2,9)}`,C=()=>{s.current&&=(s.current.abort(),null)},w=()=>{for(let[,e]of g.current.entries())e.abortController.abort();g.current.clear()},T=(e,t)=>{g.current.delete(e),c.current&&a.navigationId===t&&o(e=>({...e}))},E=f(null),N=(e,t)=>{if(!t)return;let n=document.getElementById(t);n&&(n.scrollIntoView({behavior:`smooth`,block:`start`}),window.history.pushState(window.history.state,``,`${e}#${t}`))},P=e=>{try{let t=e.headers.get(`x-rari-metadata`);t&&B(JSON.parse(decodeURIComponent(t)))}catch(e){console.warn(`[rari] Router: Failed to parse x-rari-metadata header:`,e)}},F=(e,t,n,r,i,a)=>{m.current===r&&window.dispatchEvent(new CustomEvent(`rari:navigate`,{detail:{from:t,to:n,navigationId:r,options:i,abortSignal:a.signal,rscResponsePromise:e}}))},I=(e,t,n)=>{n.historyKey?requestAnimationFrame(()=>{y.current.restoreState(e)}):t&&requestAnimationFrame(()=>{let e=(n=0)=>{let r=document.getElementById(t);r?r.scrollIntoView({behavior:`smooth`,block:`start`}):n<10&&setTimeout(e,50,n+1)};e()})},L=(e,t,n,r)=>{c.current&&(l.current=e,o(t=>({...t,currentRoute:e,navigationId:r,error:null})),h.current.resetRetry(e),I(e,t,n))},R=(e,t,n,r)=>{if(e instanceof Error&&e.name===`AbortError`){T(t,n);return}let i=h.current.handleError(e,t);c.current&&(o(e=>({...e,error:i})),window.history.replaceState(window.history.state,``,r)),g.current.delete(t),window.dispatchEvent(new CustomEvent(`rari:navigate-error`,{detail:{from:r,to:t,error:i,navigationId:n}})),E.current?.()},z=async(e,t={})=>{if(!e||typeof e!=`string`)return;let[n,r]=e.includes(`#`)?e.split(`#`):[e,``],i=O(n);if(i===l.current&&!t.replace){N(i,r);return}let a=g.current.get(i);if(a)return a.promise;w(),C();let o=new AbortController;s.current=o,m.current+=1;let c=m.current;window.dispatchEvent(new CustomEvent(`rari:navigation-start`,{detail:{navigationId:c,targetPath:i}}));let u=(async()=>{let e=l.current;try{t.historyKey||y.current.captureState(e);let n=t.historyKey||S(),a=window.location.origin+i,s=r?`${i}#${r}`:i,l={route:i,navigationId:c,scrollPosition:{x:window.scrollX,y:window.scrollY},timestamp:Date.now(),key:n};t.replace?window.history.replaceState(l,``,s):window.history.pushState(l,``,s);let u=await fetch(a,{headers:{Accept:`text/x-component`,"rari-navigation-id":String(c)},signal:o.signal}).then(e=>{if(!e.ok&&e.status!==404)throw Error(`Failed to fetch: ${e.status}`);return e});if(o.signal.aborted){T(i,c);return}let d=new URL(u.url).pathname;if(o.signal.aborted){T(i,c);return}if(d!==i){let e=r?`${d}#${r}`:d;window.history.replaceState({...l,route:d},``,e)}if(F(Promise.resolve(u),e,d,c,t,o),P(u),o.signal.aborted){T(i,c);return}L(d,r,t,c),g.current.delete(i),E.current?.()}catch(t){R(t,i,c,e)}})();return g.current.set(i,{targetPath:i,navigationId:c,promise:u,abortController:o}),u},V=async()=>{if(_.current.length===0)return;let e=_.current.at(-1);e&&(_.current=[],await z(e.path,e.options))},H=f(z);d(()=>(E.current=V,H.current=z,()=>{E.current=null,H.current=null}));let U=f(null);U.current||=v((e,t)=>{H.current?.(e,t)},50,{leading:!0,trailing:!0,maxWait:200});let W=e=>{if(e.button!==0||e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)return;let t=e.target;for(;t&&t.tagName!==`A`;)t=t.parentElement;if(!t||t.tagName!==`A`)return;let n=t;if(n.target&&n.target!==`_self`||n.hasAttribute(`download`))return;let r=n.getAttribute(`href`);if(!r||k(r))return;if(r.startsWith(`#`)){e.preventDefault();let t=r.slice(1),n=document.getElementById(t);n&&(n.scrollIntoView({behavior:`smooth`,block:`start`}),window.history.pushState(window.history.state,``,r));return}e.preventDefault();let i=A(r);U.current&&U.current(i,{replace:!1})},G=e=>{let t=window.location.pathname,n=e.state;H.current&&H.current(t,{replace:!0,scroll:!1,historyKey:n?.key})};u(()=>{let e=window.history.state;if(!e||!e.key){let e={route:O(r),navigationId:0,scrollPosition:{x:window.scrollX,y:window.scrollY},timestamp:Date.now(),key:S()};window.history.replaceState(e,``,window.location.pathname+window.location.search+window.location.hash)}},[r]);let K=e=>{if(e.persisted){let e=window.location.pathname;y.current.captureState(e)}},q=e=>{if(e.persisted){let e=window.location.pathname,t=window.history.state;requestAnimationFrame(()=>{y.current.restoreState(e),t?.scrollPosition&&window.scrollTo(t.scrollPosition.x,t.scrollPosition.y)})}};return u(()=>(document.addEventListener(`click`,W),window.addEventListener(`popstate`,G),window.addEventListener(`pagehide`,K),window.addEventListener(`pageshow`,q),()=>{document.removeEventListener(`click`,W),window.removeEventListener(`popstate`,G),window.removeEventListener(`pagehide`,K),window.removeEventListener(`pageshow`,q)}),[]),u(()=>{x.current=i;let e=()=>{document.hidden?b.current=Date.now():b.current!==null&&Date.now()-b.current>x.current&&j.clear()};return document.addEventListener(`visibilitychange`,e),()=>{document.removeEventListener(`visibilitychange`,e)}},[i]),u(()=>(c.current=!0,e((e,t)=>H.current?.(e,t)??Promise.resolve()),()=>{c.current=!1,t(),C(),w(),U.current?.cancel&&U.current.cancel()}),[]),n}function H(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_COMMENT);for(;t.nextNode();){let e=t.currentNode;if(e.data===`$`||e.data===`$?`||e.data===`/$`)return!0}return!!(e.querySelector(`[data-reactroot]`)||e.querySelectorAll(`template[data-rri]`).length>0)}function U(e){if(H(e))return!0;let t=e.firstElementChild;return t===null||t.tagName===`SCRIPT`?!1:!t.classList.contains(`rari-error`)}function W(e){return H(e)}function G(e){e.querySelectorAll(`.rari-error:not([data-rari-hydration-failure])`).forEach(e=>{e.remove()})}function K(e,t){if(e.querySelector(`.rari-error[data-rari-hydration-failure]`))return;let n=document.createElement(`div`);n.className=`rari-error`,n.setAttribute(`data-rari-hydration-failure`,`true`),n.setAttribute(`role`,`alert`),n.style.cssText=`color:red;border:1px solid red;padding:10px;border-radius:4px;background-color:#fff5f5;margin:10px 0;`;let r=document.createElement(`strong`);r.textContent=`Failed to load page: `,n.append(r,document.createTextNode(t)),e.prepend(n)}function q(){globalThis.__rari_client_ready=!0,window.dispatchEvent(new CustomEvent(`rari:client-ready`))}function J(e,t){W(e)?(G(e),g(e,t,{onRecoverableError(e){import.meta.env.DEV&&console.warn(`[rari] Hydration mismatch:`,e)}})):h(e).render(t),q()}const Y=r();Y.AppRouterProvider=_,Y.ClientRouter=V,Y.getClientComponent=s;async function X(e){try{await s(e)}catch(t){console.error(`[rari] Failed to preload component ${e}:`,t)}}
1
+ import{c as e,o as t,t as n}from"../router-D6mkoDqJ.mjs";import{d as r,g as i,n as a,p as o}from"../type-guards-CTkEL8zw.mjs";import{a as s,i as c,n as l,r as u}from"../rari-global-5vGzhToD.mjs";import{t as d}from"../get-client-component-CLpyIcLJ.mjs";import{t as f}from"../preload-modules-QmSvKk0Q.mjs";import*as p from"react";import{useEffect as m,useLayoutEffect as h,useRef as g,useState as _}from"react";import{createFromReadableStream as v}from"virtual:react-flight-client";import{createRoot as y,hydrateRoot as b}from"react-dom/client";import{AppRouterProvider as x}from"virtual:app-router-provider";import"virtual:rsc-integration.ts";function S(e,t,n={}){let r=null,i=0,a=0,o=null,s=null,{leading:c=!1,trailing:l=!0,maxWait:u}=n;function d(t){let n=o,r=s;o=null,s=null,a=t,e.apply(r,n)}function f(e){let n=e-i,r=e-a;return i===0||n>=t||n<0||u!==void 0&&r>=u}function p(){let e=Date.now();if(f(e)){h(e);return}let n=e-i,o=e-a,s=t-n,c=u===void 0?1/0:u-o;r=setTimeout(p,Math.min(s,c))}function m(e){a=e,r=setTimeout(p,t),c&&d(e)}function h(e){if(r=null,l&&o){d(e);return}o=null,s=null}function g(){r!==null&&clearTimeout(r),a=0,o=null,i=0,s=null,r=null}function _(){r!==null&&h(Date.now())}function v(){return r!==null}function y(...e){let n=Date.now(),a=f(n);if(o=e,s=this,i=n,a){if(r===null){m(i);return}if(u!==void 0){r=setTimeout(p,t),d(i);return}}r??=setTimeout(p,t)}return y.cancel=g,y.flush=_,y.pending=v,y}const C=/fetch|networkerror|load failed/i;function w(e,t){return{type:`abort`,message:`Navigation was cancelled`,originalError:e,url:t,timestamp:Date.now(),retryable:!1}}function T(e,t){return{type:`timeout`,message:`Navigation request timed out`,originalError:e,url:t,timestamp:Date.now(),retryable:!0}}function E(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 D(e,t){return{type:`network-error`,message:`Network error - check your connection`,originalError:e,url:t,timestamp:Date.now(),retryable:!0}}function O(e,t){return{type:`parse-error`,message:`Failed to parse server response`,originalError:e instanceof Error?e:void 0,url:t,timestamp:Date.now(),retryable:!1}}function k(e,t){return{type:`fetch-error`,message:e instanceof Error?e.message:`Unknown error occurred`,originalError:e instanceof Error?e:void 0,url:t,timestamp:Date.now(),retryable:!1}}function A(e,t){if(e instanceof Error&&e.name===`AbortError`)return w(e,t);if(e instanceof Error&&(e.name===`TimeoutError`||e.message.includes(`timeout`)))return T(e,t);if(e instanceof Error&&`status`in e){let n=e.status;return typeof n==`number`?E(e,n,t):k(e,t)}return e instanceof TypeError&&C.test(e.message)?D(e,t):e instanceof SyntaxError||e instanceof Error&&e.message.includes(`parse`)?O(e,t):k(e,t)}var ee=class{options;retryCount;constructor(e={}){this.options={timeout:e.timeout??1e4,maxRetries:e.maxRetries??3,onError:e.onError??(()=>{}),onRetry:e.onRetry??(()=>{})},this.retryCount=new Map}handleError(e,t){let n=A(e,t);return this.options.onError(n),console.error(`[rari] Navigation:`,n.type,n.message,{url:n.url,statusCode:n.statusCode,retryable:n.retryable}),n}canRetry(e,t){return e.retryable?(this.retryCount.get(t)??0)<this.options.maxRetries:!1}incrementRetry(e){let t=(this.retryCount.get(e)??0)+1;return this.retryCount.set(e,t),this.options.onRetry(t,{type:`fetch-error`,message:`Retry attempt ${t}`,url:e,timestamp:Date.now(),retryable:!0}),t}resetRetry(e){this.retryCount.delete(e)}getRetryCount(e){return this.retryCount.get(e)??0}clearRetries(){this.retryCount.clear()}};function j(e){if(!e||e===`/`)return`/`;let t=e;for(;t.endsWith(`/`)&&t.length>1;)t=t.slice(0,-1);return t.startsWith(`/`)||(t=`/${t}`),t}function M(e,t){try{return new URL(e,t!=null&&t!==``?t:window.location.origin).origin!==(t!=null&&t!==``?t:window.location.origin)}catch{return!1}}function te(e){try{let t=new URL(e,window.location.origin);return t.pathname+t.hash}catch{return e}}const N=new class{cache=new Map;pendingRequests=new Map;async get(e){let t=this.cache.get(e);if(t)return t;let n=this.pendingRequests.get(e);if(n)return n;let r=this.fetchRouteInfo(e);this.pendingRequests.set(e,r);try{let t=await r;return this.cache.set(e,t),t}finally{this.pendingRequests.delete(e)}}parseRouteInfoResponse(e){let t=i(e);if(!t||!this.isRouteInfoResponse(t))throw Error(`Failed to parse route info response`);return t}isRouteInfoResponse(e){return o(e)&&typeof e.exists==`boolean`&&Array.isArray(e.layouts)&&(e.loading===null||typeof e.loading==`string`)&&typeof e.isDynamic==`boolean`}async fetchRouteInfo(e){let t=await fetch(`/_rari/route-info`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:e})});if(!t.ok){let e;try{let n=i(await t.text());n&&typeof n.error==`string`&&n.error!==``&&(e=n.error)}catch{}throw Error(e!=null&&e!==``?e:`Failed to fetch route info: ${t.status} ${t.statusText}`)}let n=t.clone();try{let e=await t.text();return this.parseRouteInfoResponse(e)}catch(t){try{let e=await n.text();return this.parseRouteInfoResponse(e)}catch(n){throw console.error(`[RouteInfo] Failed to parse response:`,{error:t,parseError:n,path:e}),Error(`Failed to parse route info response`)}}}clear(){this.cache.clear(),this.pendingRequests.clear()}invalidate(e){this.cache.delete(e)}};if(typeof window<`u`){let e=s();e.routeInfoCache=N}var ne=class{stateHistory;routeAccessOrder;maxHistorySize;scrollableSelector;constructor(e={}){this.stateHistory=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=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=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)}}getHistorySize(){return this.stateHistory.size}hasState(e){return this.stateHistory.has(e)}getState(e){return this.stateHistory.get(e)}clearAll(){this.stateHistory.clear(),this.routeAccessOrder=[]}clearState(e){this.stateHistory.delete(e);let t=this.routeAccessOrder.indexOf(e);t!==-1&&this.routeAccessOrder.splice(t,1)}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?e.forEach((e,n)=>{try{let t=i.elements.namedItem(n);t instanceof RadioNodeList?t.forEach(t=>{t instanceof HTMLInputElement&&(t.type===`radio`||t.type===`checkbox`?t.checked=t.value===e:typeof e==`string`&&(t.value=e))}):(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)&&(t instanceof HTMLInputElement&&(t.type===`checkbox`||t.type===`radio`)?t.checked=t.value===e:typeof e==`string`&&(t.value=e))}catch{t=!1}}):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 P(e,t){let n=document.querySelector(e);if(n)t.content&&n.setAttribute(`content`,t.content);else{n=document.createElement(`meta`);for(let[e,r]of Object.entries(t))n.setAttribute(e,r);document.head.appendChild(n)}}function F(e){let t=document.querySelector(e);t&&t.remove()}function I(e){e.title!=null&&e.title!==``&&(document.title=e.title),e.description!=null&&e.description!==``?P(`meta[name="description"]`,{name:`description`,content:e.description}):F(`meta[name="description"]`),e.keywords&&e.keywords.length>0?P(`meta[name="keywords"]`,{name:`keywords`,content:e.keywords.join(`, `)}):F(`meta[name="keywords"]`),e.viewport!=null&&e.viewport!==``&&P(`meta[name="viewport"]`,{name:`viewport`,content:e.viewport})}function L(e){let t=document.querySelector(`link[rel="canonical"]`);if(e===void 0){t&&t.remove();return}if(t)t.setAttribute(`href`,e);else{let t=document.createElement(`link`);t.setAttribute(`rel`,`canonical`),t.setAttribute(`href`,e),document.head.appendChild(t)}}function R(e){if(e===void 0){F(`meta[name="robots"]`);return}let t=[];e.index!==void 0&&t.push(e.index?`index`:`noindex`),e.follow!==void 0&&t.push(e.follow?`follow`:`nofollow`),e.nocache&&t.push(`nocache`),t.length>0?P(`meta[name="robots"]`,{name:`robots`,content:t.join(`, `)}):F(`meta[name="robots"]`)}function z(e){if(e===void 0){F(`meta[property="og:title"]`),F(`meta[property="og:description"]`),F(`meta[property="og:url"]`),F(`meta[property="og:site_name"]`),F(`meta[property="og:type"]`),document.querySelectorAll(`meta[property="og:image"]`).forEach(e=>{e.remove()});return}if(e.title!=null&&e.title!==``?P(`meta[property="og:title"]`,{property:`og:title`,content:e.title}):F(`meta[property="og:title"]`),e.description!=null&&e.description!==``?P(`meta[property="og:description"]`,{property:`og:description`,content:e.description}):F(`meta[property="og:description"]`),e.url!=null&&e.url!==``?P(`meta[property="og:url"]`,{property:`og:url`,content:e.url}):F(`meta[property="og:url"]`),e.siteName!=null&&e.siteName!==``?P(`meta[property="og:site_name"]`,{property:`og:site_name`,content:e.siteName}):F(`meta[property="og:site_name"]`),e.type!=null&&e.type!==``?P(`meta[property="og:type"]`,{property:`og:type`,content:e.type}):F(`meta[property="og:type"]`),e.images&&e.images.length>0){document.querySelectorAll(`meta[property="og:image"]`).forEach(e=>{e.remove()});for(let t of e.images){let e=document.createElement(`meta`);e.setAttribute(`property`,`og:image`),e.setAttribute(`content`,t),document.head.appendChild(e)}}else document.querySelectorAll(`meta[property="og:image"]`).forEach(e=>{e.remove()})}function B(e){if(e===void 0){F(`meta[name="twitter:card"]`),F(`meta[name="twitter:site"]`),F(`meta[name="twitter:creator"]`),F(`meta[name="twitter:title"]`),F(`meta[name="twitter:description"]`),document.querySelectorAll(`meta[name="twitter:image"]`).forEach(e=>{e.remove()});return}if(e.card!=null&&e.card!==``?P(`meta[name="twitter:card"]`,{name:`twitter:card`,content:e.card}):F(`meta[name="twitter:card"]`),e.site!=null&&e.site!==``?P(`meta[name="twitter:site"]`,{name:`twitter:site`,content:e.site}):F(`meta[name="twitter:site"]`),e.creator!=null&&e.creator!==``?P(`meta[name="twitter:creator"]`,{name:`twitter:creator`,content:e.creator}):F(`meta[name="twitter:creator"]`),e.title!=null&&e.title!==``?P(`meta[name="twitter:title"]`,{name:`twitter:title`,content:e.title}):F(`meta[name="twitter:title"]`),e.description!=null&&e.description!==``?P(`meta[name="twitter:description"]`,{name:`twitter:description`,content:e.description}):F(`meta[name="twitter:description"]`),e.images&&e.images.length>0){document.querySelectorAll(`meta[name="twitter:image"]`).forEach(e=>{e.remove()});for(let t of e.images){let e=document.createElement(`meta`);e.setAttribute(`name`,`twitter:image`),e.setAttribute(`content`,t),document.head.appendChild(e)}}else document.querySelectorAll(`meta[name="twitter:image"]`).forEach(e=>{e.remove()})}function V(e){I(e),L(e.canonical),R(e.robots),z(e.openGraph),B(e.twitter)}function re(e){return o(e)}function H({children:n,initialRoute:a,staleWindowMs:o=3e4}){let[s,c]=_(()=>({currentRoute:j(a),navigationId:0,error:null})),l=g(null),u=g(!0),d=g(j(a)),f=g(0),p=g(new ee({timeout:1e4,maxRetries:3,onError:e=>{console.error(`[rari] Router: Navigation error:`,e)},onRetry:()=>{}})),v=g(new Map),y=g([]),b=g(new ne({maxHistorySize:50})),x=g(null),C=g(o),w=()=>`${Date.now()}-${Math.random().toString(36).substring(2,9)}`,T=()=>{l.current&&=(l.current.abort(),null)},E=()=>{for(let[,e]of v.current.entries())e.abortController.abort();v.current.clear()},D=(e,t)=>{v.current.delete(e),u.current&&s.navigationId===t&&c(e=>({...e}))},O=g(null),k=(e,t)=>{if(!t)return;let n=document.getElementById(t);n&&(n.scrollIntoView({behavior:`smooth`,block:`start`}),window.history.pushState(window.history.state,``,`${e}#${t}`))},A=e=>{try{let t=e.headers.get(`x-rari-metadata`);if(t!=null&&t!==``){let e=i(decodeURIComponent(t));e&&re(e)&&V(e)}}catch(e){console.warn(`[rari] Router: Failed to parse x-rari-metadata header:`,e)}},P=(e,t,n,r,i,a)=>{f.current===r&&window.dispatchEvent(new CustomEvent(`rari:navigate`,{detail:{from:t,to:n,navigationId:r,options:i,abortSignal:a.signal,rscResponsePromise:e}}))},F=(e,t,n)=>{n.historyKey!=null&&n.historyKey!==``?requestAnimationFrame(()=>{b.current.restoreState(e)}):t&&requestAnimationFrame(()=>{let e=(n=0)=>{let r=document.getElementById(t);r?r.scrollIntoView({behavior:`smooth`,block:`start`}):n<10&&setTimeout(e,50,n+1)};e()})},I=(e,t,n,r)=>{u.current&&f.current===r&&(d.current=e,c(t=>({...t,currentRoute:e,navigationId:r,error:null})),p.current.resetRetry(e),F(e,t,n))},L=(e,t,n,r)=>{if(e instanceof Error&&e.name===`AbortError`){D(t,n);return}let i=p.current.handleError(e,t);u.current&&(c(e=>({...e,error:i})),window.history.replaceState(window.history.state,``,r)),v.current.delete(t),window.dispatchEvent(new CustomEvent(`rari:navigate-error`,{detail:{from:r,to:t,error:i,navigationId:n}})),O.current?.()},R=async(e,t={})=>{if(!e||typeof e!=`string`)return;let[n,r]=e.includes(`#`)?e.split(`#`):[e,``],i=j(n);if(i===d.current&&!t.replace){k(i,r);return}let a=v.current.get(i);if(a)return a.promise;E(),T();let o=new AbortController;l.current=o,f.current+=1;let s=f.current;window.dispatchEvent(new CustomEvent(`rari:navigation-start`,{detail:{navigationId:s,targetPath:i}}));let c=(async()=>{let e=d.current;try{(t.historyKey==null||t.historyKey===``)&&b.current.captureState(e);let n=t.historyKey!=null&&t.historyKey!==``?t.historyKey:w(),a=window.location.origin+i,c=r?`${i}#${r}`:i,l={route:i,navigationId:s,scrollPosition:{x:window.scrollX,y:window.scrollY},timestamp:Date.now(),key:n};t.replace?window.history.replaceState(l,``,c):window.history.pushState(l,``,c);let u=await fetch(a,{headers:{Accept:`text/x-component`,"rari-navigation-id":String(s)},signal:o.signal}).then(e=>{if(!e.ok&&e.status!==404)throw Error(`Failed to fetch: ${e.status}`);return e});if(o.signal.aborted){D(i,s);return}let d=new URL(u.url).pathname;if(d!==i){let e=r?`${d}#${r}`:d;window.history.replaceState({...l,route:d},``,e)}P(Promise.resolve(u),e,d,s,t,o),A(u),I(d,r,t,s),v.current.delete(i),O.current?.()}catch(t){L(t,i,s,e)}})();return v.current.set(i,{targetPath:i,navigationId:s,promise:c,abortController:o}),c},z=async()=>{if(y.current.length===0)return;let e=y.current.at(-1);e&&(y.current=[],await R(e.path,e.options))},B=g(R);h(()=>(O.current=z,B.current=R,()=>{O.current=null,B.current=null}));let H=g(null);H.current??=S((e,t)=>{B.current?.(e,t)},50,{leading:!0,trailing:!0,maxWait:200});let U=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===``||M(r))return;if(r.startsWith(`#`)){e.preventDefault();let t=r.slice(1),n=document.getElementById(t);n&&(n.scrollIntoView({behavior:`smooth`,block:`start`}),window.history.pushState(window.history.state,``,r));return}e.preventDefault();let i=te(r);H.current&&H.current(i,{replace:!1})},W=e=>{let t=window.location.pathname,n=r(e.state)?e.state:null;B.current&&B.current(t,{replace:!0,scroll:!1,historyKey:n?.key})};m(()=>{let e=r(window.history.state)?window.history.state:null;if(e?.key==null||e.key===``){let e={route:j(a),navigationId:0,scrollPosition:{x:window.scrollX,y:window.scrollY},timestamp:Date.now(),key:w()};window.history.replaceState(e,``,window.location.pathname+window.location.search+window.location.hash)}},[a]);let G=e=>{if(e.persisted){let e=window.location.pathname;b.current.captureState(e)}},K=e=>{if(e.persisted){let e=window.location.pathname,t=r(window.history.state)?window.history.state:null;requestAnimationFrame(()=>{b.current.restoreState(e),t?.scrollPosition&&window.scrollTo(t.scrollPosition.x,t.scrollPosition.y)})}};return m(()=>(document.addEventListener(`click`,U),window.addEventListener(`popstate`,W),window.addEventListener(`pagehide`,G),window.addEventListener(`pageshow`,K),()=>{document.removeEventListener(`click`,U),window.removeEventListener(`popstate`,W),window.removeEventListener(`pagehide`,G),window.removeEventListener(`pageshow`,K)}),[]),m(()=>{C.current=o;let e=()=>{document.hidden?x.current=Date.now():x.current!==null&&Date.now()-x.current>C.current&&N.clear()};return document.addEventListener(`visibilitychange`,e),()=>{document.removeEventListener(`visibilitychange`,e)}},[o]),m(()=>(u.current=!0,e(async(e,t)=>B.current?.(e,t)??Promise.resolve()),()=>{u.current=!1,t(),T(),E(),H.current?.cancel&&H.current.cancel()}),[]),n}function U(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_COMMENT);for(;t.nextNode();){let e=t.currentNode;if(e.nodeType===8&&`data`in e){let t=e.data;if(t===`$`||t===`$?`||t===`/$`)return!0}}return!!(e.querySelector(`[data-reactroot]`)||e.querySelectorAll(`template[data-rri]`).length>0)}function W(e){if(U(e))return!0;let t=e.firstElementChild;return t===null||t.tagName===`SCRIPT`?!1:!t.classList.contains(`rari-error`)}function G(e){return U(e)}function K(e){e.querySelectorAll(`.rari-error:not([data-rari-hydration-failure])`).forEach(e=>{e.remove()})}function ie(e,t){if(e.querySelector(`.rari-error[data-rari-hydration-failure]`))return;let n=document.createElement(`div`);n.className=`rari-error`,n.setAttribute(`data-rari-hydration-failure`,`true`),n.setAttribute(`role`,`alert`),n.style.cssText=`color:red;border:1px solid red;padding:10px;border-radius:4px;background-color:#fff5f5;margin:10px 0;`;let r=document.createElement(`strong`);r.textContent=`Failed to load page: `,n.append(r,document.createTextNode(t)),e.prepend(n)}function ae(){Reflect.set(globalThis,`__rari_client_ready`,!0),window.dispatchEvent(new CustomEvent(`rari:client-ready`))}function q(e,t){G(e)?(K(e),b(e,t,{onRecoverableError(e){import.meta.env.DEV&&console.warn(`[rari] Hydration mismatch:`,e)}})):y(e).render(t),ae()}const J=c();J.AppRouterProvider=x,J.ClientRouter=H,J.getClientComponent=d;async function Y(e){try{await d(e)}catch(t){console.error(`[rari] Failed to preload component ${e}:`,t)}}
2
2
  /*! @preserve CLIENT_COMPONENT_IMPORTS_PLACEHOLDER */
3
- Y.preloadClientComponent=X,o(),i();
3
+ J.preloadClientComponent=Y,u(),l();
4
4
  /*! @preserve CLIENT_COMPONENT_REGISTRATIONS_PLACEHOLDER */
5
- function Z(){return globalThis.__rari_f}function ee(){return!!Z()?.some(e=>e!==0)}function te(){let e=Z();if(!e?.length)return null;let t=``,n=[];for(let r of e)r!==0&&(typeof r==`string`?t+=r:Array.isArray(r)&&r[0]===2&&typeof r[1]==`string`&&n.push(r[1]));if(n.length>0){let e=n.map(e=>Uint8Array.from(atob(e),e=>e.charCodeAt(0))),t=e.reduce((e,t)=>e+t.length,0),r=new Uint8Array(t),i=0;for(let t of e)r.set(t,i),i+=t.length;return r}return t?new TextEncoder().encode(t):null}async function Q(e,t){await c(new TextDecoder().decode(e));let n=a(),r=n.streaming,i=!!(r?.bufferedRows&&r.bufferedRows.length>0);return t.streaming&&(r?.complete===void 0||i)?m(new ReadableStream({start(t){let r=!1;t.enqueue(e);let i=e=>{if(r)return;let n=e;n.detail?.rscRow&&t.enqueue(new TextEncoder().encode(`\n${n.detail.rscRow}`))},a=()=>{r||(r=!0,t.close(),window.removeEventListener(`rari:html-stream-row`,i),window.removeEventListener(`rari:stream-complete`,a))};if(window.addEventListener(`rari:html-stream-row`,i),window.addEventListener(`rari:stream-complete`,a),n.streaming?.bufferedRows){let e=[...n.streaming.bufferedRows];for(let n of e){if(r)break;t.enqueue(new TextEncoder().encode(`\n${n}`))}n.streaming.bufferedRows=[]}n.streaming?.complete&&a()}})):m(new ReadableStream({start(t){t.enqueue(e),t.close()}}))}async function $(){let e=document.getElementById(`root`);if(!e){console.error(`[rari] Root element not found`);return}let t=ee(),r=te(),i=U(e)||H(e),o=a().streaming,s=!!(o?.bufferedRows&&o.bufferedRows.length>0);try{let o,c=!t&&!s&&!i;if(i&&t&&r){let t=`Could not load interactive page data.`;try{o=await Q(r,{streaming:!1})}catch(e){t=e instanceof Error?e.message:`Failed to parse embedded RSC payload.`;try{let e=window.location.pathname+window.location.search,n=import.meta.env.DEV?import.meta.env.RARI_SERVER_URL||`http://localhost:${import.meta.env.VITE_RSC_PORT||`3000`}`:window.location.origin,r=await fetch(n+e,{headers:{Accept:`text/x-component`},cache:`no-store`});if(r.ok){let e=new Uint8Array(await r.arrayBuffer());o=await m(new ReadableStream({start(t){t.enqueue(e),t.close()}}))}else t=`Failed to fetch RSC payload fallback: HTTP ${r.status}.`}catch(e){t=e instanceof Error?e.message:`Failed to fetch RSC payload fallback.`,console.error(`[rari] Failed to fetch RSC payload fallback:`,e)}}if(o){let t=l.createElement(_,{initialPayload:{element:o}});t=l.createElement(V,{initialRoute:window.location.pathname,children:t}),t=l.createElement(n,{initialPathname:window.location.pathname,children:t}),J(e,t)}else K(e,`${t} Try refreshing the page.`),console.error(`[rari] Hydration skipped: failed to load RSC payload`);return}if(c)try{let e=window.location.pathname+window.location.search,t=(import.meta.env.DEV?import.meta.env.RARI_SERVER_URL||`http://localhost:${import.meta.env.VITE_RSC_PORT||`3000`}`:window.location.origin)+e,n=await fetch(t,{headers:{Accept:`text/x-component`},cache:`no-store`});if(!n.ok&&n.status!==404)throw Error(`Failed to fetch RSC data: ${n.status}`);if(!n.body)throw Error(`RSC response has no body`);o=await m(n.body)}catch(e){if(e instanceof Promise)throw e;console.error(`[rari] Failed to fetch initial RSC data:`,e),o=null}else if(t&&r)try{o=await Q(r,{streaming:!0})}catch(e){console.error(`[rari] Failed to parse embedded RSC payload:`,e),console.error(`[rari] Error stack:`,e instanceof Error?e.stack:`no stack`),o=null}else if(s)try{o=await m(new ReadableStream({start(e){let t=t=>{let n=t;n.detail?.rscRow&&e.enqueue(new TextEncoder().encode(`${n.detail.rscRow}\n`))},n=()=>{e.close(),window.removeEventListener(`rari:html-stream-row`,t),window.removeEventListener(`rari:stream-complete`,n)};window.addEventListener(`rari:html-stream-row`,t),window.addEventListener(`rari:stream-complete`,n);let r=a();if(r.streaming?.bufferedRows){let t=[...r.streaming.bufferedRows];r.streaming.bufferedRows=[];for(let n of t)e.enqueue(new TextEncoder().encode(`${n}\n`))}r.streaming?.complete&&n()}}))}catch(e){console.error(`[rari] Failed to process streaming RSC payload:`,e),o=null}if(!o)throw Error(`No RSC data available for hydration`);let u=l.createElement(_,{initialPayload:{element:o}});u=l.createElement(V,{initialRoute:window.location.pathname,children:u}),u=l.createElement(n,{initialPathname:window.location.pathname,children:u}),J(e,u)}catch(e){console.error(`[rari] Error rendering app:`,e)}}import.meta.hot&&import.meta.hot.data.hasRendered||($().catch(e=>{console.error(`[rari] Fatal error:`,e)}),import.meta.hot&&(import.meta.hot.data.hasRendered=!0));export{X as preloadClientComponent,$ as renderApp};
5
+ function X(){let e=Reflect.get(globalThis,`__rari_f`);if(Array.isArray(e))return e}function Z(e){return o(e)&&typeof e.rscRow==`string`}function oe(e){return Array.isArray(e)&&typeof e[1]==`string`}function se(){return!!X()?.some(e=>e!==0)}function ce(){let e=X();if(e?.length==null||e.length===0)return null;let t=``,n=[];for(let r of e)r!==0&&(typeof r==`string`?t+=r:oe(r)&&n.push(r[1]));if(n.length>0){let e=n.map(e=>Uint8Array.from(atob(e),e=>e.charCodeAt(0))),t=e.reduce((e,t)=>e+t.length,0),r=new Uint8Array(t),i=0;for(let t of e)r.set(t,i),i+=t.length;return r}return t?new TextEncoder().encode(t):null}async function Q(e,t){await f(new TextDecoder().decode(e));let n=s(),r=n.streaming,i=!!(r?.bufferedRows&&r.bufferedRows.length>0);return t.streaming&&(r?.complete===void 0||i)?v(new ReadableStream({start(t){let r=!1;t.enqueue(e);let i=e=>{if(r)return;let n=a(e,Z);n&&t.enqueue(new TextEncoder().encode(`\n${n.rscRow}`))},o=()=>{r||(r=!0,t.close(),window.removeEventListener(`rari:html-stream-row`,i),window.removeEventListener(`rari:stream-complete`,o))};if(window.addEventListener(`rari:html-stream-row`,i),window.addEventListener(`rari:stream-complete`,o),n.streaming?.bufferedRows){let e=[...n.streaming.bufferedRows];for(let n of e)t.enqueue(new TextEncoder().encode(`\n${n}`));n.streaming.bufferedRows=[]}n.streaming?.complete&&o()}})):v(new ReadableStream({start(t){t.enqueue(e),t.close()}}))}async function $(){let e=document.getElementById(`root`);if(!e){console.error(`[rari] Root element not found`);return}let t=se(),r=ce(),i=W(e)||U(e),o=s().streaming,c=!!(o?.bufferedRows&&o.bufferedRows.length>0);try{let o,l=!t&&!c&&!i;if(i&&t&&r){let t=`Could not load interactive page data.`;try{o=await Q(r,{streaming:!1})}catch(e){t=e instanceof Error?e.message:`Failed to parse embedded RSC payload.`;try{let e=window.location.pathname+window.location.search,n=import.meta.env.DEV?import.meta.env.RARI_SERVER_URL!=null&&import.meta.env.RARI_SERVER_URL!==``?import.meta.env.RARI_SERVER_URL:`http://localhost:${import.meta.env.VITE_RSC_PORT!=null&&import.meta.env.VITE_RSC_PORT!==``?import.meta.env.VITE_RSC_PORT:`3000`}`:window.location.origin,r=await fetch(n+e,{headers:{Accept:`text/x-component`},cache:`no-store`});if(r.ok){let e=new Uint8Array(await r.arrayBuffer());o=await v(new ReadableStream({start(t){t.enqueue(e),t.close()}}))}else t=`Failed to fetch RSC payload fallback: HTTP ${r.status}.`}catch(e){t=e instanceof Error?e.message:`Failed to fetch RSC payload fallback.`,console.error(`[rari] Failed to fetch RSC payload fallback:`,e)}}if(o!=null){let t=p.createElement(x,{initialPayload:{element:o}});t=p.createElement(H,{initialRoute:window.location.pathname,children:t}),t=p.createElement(n,{initialPathname:window.location.pathname,children:t}),q(e,t)}else ie(e,`${t} Try refreshing the page.`),console.error(`[rari] Hydration skipped: failed to load RSC payload`);return}if(l)try{let e=window.location.pathname+window.location.search,t=(import.meta.env.DEV?import.meta.env.RARI_SERVER_URL!=null&&import.meta.env.RARI_SERVER_URL!==``?import.meta.env.RARI_SERVER_URL:`http://localhost:${import.meta.env.VITE_RSC_PORT!=null&&import.meta.env.VITE_RSC_PORT!==``?import.meta.env.VITE_RSC_PORT:`3000`}`:window.location.origin)+e,n=await fetch(t,{headers:{Accept:`text/x-component`},cache:`no-store`});if(!n.ok&&n.status!==404)throw Error(`Failed to fetch RSC data: ${n.status}`);if(!n.body)throw Error(`RSC response has no body`);o=await v(n.body)}catch(e){if(e instanceof Promise)throw e;console.error(`[rari] Failed to fetch initial RSC data:`,e),o=null}else if(t&&r)try{o=await Q(r,{streaming:!0})}catch(e){console.error(`[rari] Failed to parse embedded RSC payload:`,e),console.error(`[rari] Error stack:`,e instanceof Error?e.stack:`no stack`),o=null}else if(c)try{o=await v(new ReadableStream({start(e){let t=t=>{let n=a(t,Z);n&&e.enqueue(new TextEncoder().encode(`${n.rscRow}\n`))},n=()=>{e.close(),window.removeEventListener(`rari:html-stream-row`,t),window.removeEventListener(`rari:stream-complete`,n)};window.addEventListener(`rari:html-stream-row`,t),window.addEventListener(`rari:stream-complete`,n);let r=s();if(r.streaming?.bufferedRows){let t=[...r.streaming.bufferedRows];r.streaming.bufferedRows=[];for(let n of t)e.enqueue(new TextEncoder().encode(`${n}\n`))}r.streaming?.complete&&n()}}))}catch(e){console.error(`[rari] Failed to process streaming RSC payload:`,e),o=null}if(o==null)throw Error(`No RSC data available for hydration`);let u=p.createElement(x,{initialPayload:{element:o}});u=p.createElement(H,{initialRoute:window.location.pathname,children:u}),u=p.createElement(n,{initialPathname:window.location.pathname,children:u}),q(e,u)}catch(e){console.error(`[rari] Error rendering app:`,e)}}function le(){let e=import.meta.hot;if(!e)return{};let t=e.data;return o(t)?{hasRendered:t.hasRendered===!0}:{}}function ue(){let e=import.meta.hot;if(!e)return;let t=e.data;o(t)&&(t.hasRendered=!0)}(!import.meta.hot||le().hasRendered!==!0)&&($().catch(e=>{console.error(`[rari] Fatal error:`,e)}),ue());export{Y as preloadClientComponent,$ as renderApp};
@@ -1,6 +1,5 @@
1
1
  import { FlightRouterState, SegmentPath, pathnameFromSegmentPath } from "./flight-router-state.mjs";
2
2
  import { ReactNode } from "react";
3
-
4
3
  //#region src/runtime/flight/route-cache.d.ts
5
4
  interface CacheNode {
6
5
  rsc: ReactNode;
@@ -1 +1 @@
1
- import{buildFlightRouterState as e,pathnameFromSegmentPath as t,segmentPathFromPathname as n}from"./flight-router-state.mjs";function r(e=null){return{rsc:e,slots:null}}function i(e,t){return e.slots||={},e.slots[t]||(e.slots[t]=r()),e.slots[t]}function a(e,t){let n=e;for(let e of t)n=i(n,e);return n}function o(e,t){if(t.length===0){e.rsc=null,e.slots=null;return}let n=e;for(let e=0;e<t.length-1;e+=1){let r=t[e];if(!n.slots?.[r])return;n=n.slots[r]}let r=t[t.length-1];if(!n.slots?.[r])return;let i=n.slots[r];i.rsc=null,i.slots=null,delete n.slots[r],Object.keys(n.slots).length===0&&(n.slots=null)}var s=class{root=r();renderedSearch=``;get(e,t){let r=n(e),i=a(this.root,r);if(i.rsc!=null)return{pathname:e,search:t,segmentPath:r,node:i}}getElement(e,t){return this.get(e,t)?.node.rsc}set(e,t,r){let i=n(e),o=a(this.root,i);o.rsc=r,this.renderedSearch=t}invalidate(e,t=``){o(this.root,n(e))}invalidateSegmentPath(e){o(this.root,e)}getRenderedSearch(){return this.renderedSearch}getRouterTree(t){return e(t)}clear(){this.root=r(),this.renderedSearch=``}};const c=new s;function l(){return typeof window>`u`?{pathname:`/`,search:``}:{pathname:window.location.pathname,search:window.location.search}}function u(){let{pathname:e}=l();return n(e)}export{s as FlightRouteCache,l as currentRouteLocation,u as currentSegmentPath,c as flightRouteCache,t as pathnameFromSegmentPath};
1
+ import{buildFlightRouterState as e,pathnameFromSegmentPath as t,segmentPathFromPathname as n}from"./flight-router-state.mjs";function r(e=null){return{rsc:e,slots:null}}function i(e,t){return e.slots??={},e.slots[t]??=r(),e.slots[t]}function a(e,t){let n=e;for(let e of t)n=i(n,e);return n}function o(e,t){if(t.length===0){e.rsc=null,e.slots=null;return}let n=e;for(let e=0;e<t.length-1;e+=1){let r=t[e];if(!n.slots?.[r])return;n=n.slots[r]}let r=t[t.length-1];if(!n.slots?.[r])return;let i=n.slots[r];i.rsc=null,i.slots=null,delete n.slots[r],Object.keys(n.slots).length===0&&(n.slots=null)}var s=class{root=r();renderedSearch=``;get(e,t){let r=n(e),i=a(this.root,r);if(i.rsc!=null)return{pathname:e,search:t,segmentPath:r,node:i}}getElement(e,t){return this.get(e,t)?.node.rsc}set(e,t,r){let i=n(e),o=a(this.root,i);o.rsc=r,this.renderedSearch=t}invalidate(e,t=``){o(this.root,n(e))}invalidateSegmentPath(e){o(this.root,e)}getRenderedSearch(){return this.renderedSearch}getRouterTree(t){return e(t)}clear(){this.root=r(),this.renderedSearch=``}};const c=new s;function l(){return typeof window>`u`?{pathname:`/`,search:``}:{pathname:window.location.pathname,search:window.location.search}}function u(){let{pathname:e}=l();return n(e)}export{s as FlightRouteCache,l as currentRouteLocation,u as currentSegmentPath,c as flightRouteCache,t as pathnameFromSegmentPath};
@@ -1,8 +1,8 @@
1
1
  //#region src/runtime/flight/router-state.d.ts
2
- type FlightRouterState = [segment: string, parallelRoutes: {
3
- children?: FlightRouterState;
2
+ type FlightRouterState = readonly [segment: string, parallelRoutes: {
3
+ readonly children?: FlightRouterState;
4
4
  }];
5
- type SegmentPath = string[];
5
+ type SegmentPath = readonly string[];
6
6
  declare function buildFlightRouterState(pathname: string): FlightRouterState;
7
7
  declare function segmentPathFromRouterState(tree: FlightRouterState): SegmentPath;
8
8
  declare function segmentPathFromPathname(pathname: string): SegmentPath;
@@ -1,5 +1,4 @@
1
1
  import * as React from "react";
2
-
3
2
  //#region src/runtime/flight/merge-refresh.d.ts
4
3
  declare function mergeFlightRefresh(current: React.ReactNode, refresh: React.ReactNode): React.ReactNode;
5
4
  //#endregion
@@ -1 +1 @@
1
- import*as e from"react";const t=Symbol.for(`react.client.reference`);function n(t){return e.isValidElement(t)}function r(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function i(e){return r(e.type)}function a(t,n){let r=e.Children.toArray(t),i=e.Children.toArray(n);if(r.length===0)return n;if(i.length===0)return t;if(r.length!==i.length)return n;let a=r.map((e,t)=>o(e,i[t]));return a.length===1?a[0]:a}function o(t,r){if(t==null)return r;if(r==null)return t;if(!n(t)||!n(r))return r;if(i(t)&&i(r)){let e=t.type.$$id,n=r.type.$$id;if(e&&n&&e===n&&(t.key??null)===(r.key??null))return r}if(t.type!==r.type)return r;let o=t.props,s=r.props,c=a(o.children,s.children);if(c===s.children)return r;let l=e.Children.toArray(c);return e.cloneElement(r,s,...l)}export{o as mergeFlightRefresh};
1
+ import{a as e,i as t,s as n}from"../type-guards-CTkEL8zw.mjs";import*as r from"react";function i(e){return r.isValidElement(e)}function a(e){return n(e.type)}function o(e,t){let n=r.Children.toArray(e),i=r.Children.toArray(t);if(n.length===0)return t;if(i.length===0)return e;if(n.length!==i.length)return t;let a=n.map((e,t)=>s(e,i[t]));return a.length===1?a[0]:a}function s(n,s){if(n==null)return s;if(s==null)return n;if(!i(n)||!i(s))return s;if(a(n)&&a(s)){let t=e(n.type)?n.type.$$id:void 0,r=e(s.type)?s.type.$$id:void 0;if(t!=null&&t!==``&&r!=null&&r!==``&&t===r&&(n.key??null)===(s.key??null))return s}if(n.type!==s.type)return s;let c=t(n),l=t(s),u=o(c.children,l.children);if(u===l.children)return s;let d=r.Children.toArray(u);return r.cloneElement(s,l,...d)}export{s as mergeFlightRefresh};
@@ -1 +1,8 @@
1
- export { };
1
+ import "../types-_vPM8QuJ.mjs";
2
+ //#region src/runtime/shared/get-client-component.d.ts
3
+ declare function requireClientComponent(id: string): any;
4
+ //#endregion
5
+ //#region src/runtime/rsc/client-runtime.d.ts
6
+ declare global {
7
+ var __rari_rsc_require__: typeof requireClientComponent | undefined;
8
+ }
@@ -1 +1 @@
1
- import{i as e,n as t,o as n,r,t as i}from"../rari-global-Dygfa818.mjs";import{n as a,r as o}from"../get-client-component-CDaY3lOP.mjs";if(e().isDevelopment=process.env.NODE_ENV!==`production`,r(),i(),t(),typeof window<`u`&&(a(),globalThis.__rari_rsc_require__=o),typeof window<`u`){let e=n();e.streaming?e.streaming.bufferedRows||(e.streaming.bufferedRows=[]):e.streaming={bufferedRows:[]}}if(import.meta.hot){function t(){return import.meta.env?.RARI_SERVER_URL?import.meta.env.RARI_SERVER_URL:typeof window<`u`?window.location.origin:`http://localhost:3000`}function r(t){if(!t)return!1;try{return!!e().serverComponents?.has(t)}catch{return!1}}let i=!1,a=[],o=new Map;function s(e,t){o.set(e,t),import.meta.hot.on(e,async n=>{if(!i){a.push({event:e,data:n});return}try{await t(n)}catch(t){console.error(`[rari] HMR: Error in handler for '${e}':`,t)}})}s(`rari:register-server-component`,t=>{if(t?.filePath){let n=e();n.serverComponents=n.serverComponents||new Set,n.serverComponents.add(t.filePath)}}),s(`rari:server-components-registry`,t=>{if(t?.serverComponents&&Array.isArray(t.serverComponents)){let n=e();n.serverComponents=n.serverComponents||new Set,t.serverComponents.forEach(e=>{n.serverComponents?.add(e)})}}),s(`vite:beforeFullReload`,async e=>{e?.path&&r(e.path)&&window.dispatchEvent(new CustomEvent(`rari:rsc-invalidate`,{detail:{filePath:e.path}}))}),s(`rari:server-component-updated`,async e=>{let t=e?.id||e?.componentId,n=e?.t||e?.timestamp;t?window.dispatchEvent(new CustomEvent(`rari:rsc-invalidate`,{detail:{componentId:t,filePath:e.filePath||e.file,type:`server-component`,timestamp:n}})):e?.path&&r(e.path)&&window.dispatchEvent(new CustomEvent(`rari:rsc-invalidate`,{detail:{filePath:e.path}}))}),s(`rari:app-router-updated`,async e=>{if(!(!e||!e.routePath&&(!e.affectedRoutes||e.affectedRoutes.length===0)))try{let r=t(),i=await fetch(`${r}/_rari/hmr`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`register`,file_path:e.filePath})});if(!i.ok)throw Error(`Component reload failed: ${i.status}`);let a=await i.json();if(a?.success!==!0&&a?.reloaded!==!0)throw Error(a?.error||`Component reload unsuccessful`);if(await fetch(`${r}/_rari/hmr`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`invalidate`,componentId:e.routePath||e.filePath,filePath:e.filePath})}),e.metadataChanged&&e.metadata&&(e.metadata.title&&(document.title=e.metadata.title),e.metadata.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.metadata.description)}let o=n();e.manifestUpdated&&o?.routeInfoCache&&o.routeInfoCache.clear(),window.dispatchEvent(new CustomEvent(`rari:app-router-rerender`,{detail:{routePath:e.routePath,affectedRoutes:e.affectedRoutes||[e.routePath],currentPath:window.location.pathname,preserveParams:!0}}))}catch(e){console.error(`[rari] HMR: App router update failed:`,e)}}),s(`rari:server-action-updated`,async e=>{e?.filePath&&window.dispatchEvent(new CustomEvent(`rari:rsc-invalidate`,{detail:{filePath:e.filePath,type:`server-action`}}))}),a.length>0?(async()=>{try{let e=[...a];a.length=0;for(let{event:t,data:n}of e){let e=o.get(t);e&&await e(n)}}catch(e){console.error(`[rari] HMR: Error during event replay:`,e)}finally{i=!0}})():i=!0}export{};
1
+ import{p as e}from"../type-guards-CTkEL8zw.mjs";import{a as t,i as n,n as r,r as i,t as a}from"../rari-global-5vGzhToD.mjs";import{n as o,r as s}from"../get-client-component-CLpyIcLJ.mjs";if(n().isDevelopment=process.env.NODE_ENV!==`production`,i(),a(),r(),typeof window<`u`&&(o(),Reflect.set(globalThis,`__rari_rsc_require__`,s)),typeof window<`u`){let e=t();e.streaming??={bufferedRows:[]}}if(import.meta.hot){function r(){return import.meta.env.RARI_SERVER_URL!=null&&import.meta.env.RARI_SERVER_URL!==``?import.meta.env.RARI_SERVER_URL:typeof window<`u`?window.location.origin:`http://localhost:3000`}function i(e){if(!e)return!1;try{return n().serverComponents?.has(e)===!0}catch{return!1}}let a=!1,o=[],s=new Map;function c(e,t,n){s.set(e,async e=>{n(e)&&await t(e)}),import.meta.hot.on(e,t=>{(async()=>{if(!a){o.push({event:e,data:t});return}try{let n=s.get(e);n&&await n(t)}catch(t){console.error(`[rari] HMR: Error in handler for '${e}':`,t)}})()})}function l(t){return e(t)&&typeof t.filePath==`string`&&t.filePath!==``}function u(t){return e(t)&&Array.isArray(t.serverComponents)}function d(t){return e(t)&&typeof t.path==`string`&&t.path!==``}function f(t){return e(t)}function p(t){return e(t)}function m(t){return e(t)&&typeof t.filePath==`string`&&t.filePath!==``}c(`rari:register-server-component`,e=>{let t=n();t.serverComponents??=new Set,t.serverComponents.add(e.filePath)},l),c(`rari:server-components-registry`,e=>{let t=n();t.serverComponents??=new Set;for(let n of e.serverComponents)t.serverComponents.add(n)},u),c(`vite:beforeFullReload`,e=>{i(e.path)&&window.dispatchEvent(new CustomEvent(`rari:rsc-invalidate`,{detail:{filePath:e.path}}))},d),c(`rari:server-component-updated`,e=>{let t=e.id!=null&&e.id!==``?e.id:e.componentId,n=e.t!=null&&e.t!==0?e.t:e.timestamp;t!=null&&t!==``?window.dispatchEvent(new CustomEvent(`rari:rsc-invalidate`,{detail:{componentId:t,filePath:e.filePath!=null&&e.filePath!==``?e.filePath:e.file,type:`server-component`,timestamp:n}})):e.path!=null&&e.path!==``&&i(e.path)&&window.dispatchEvent(new CustomEvent(`rari:rsc-invalidate`,{detail:{filePath:e.path}}))},f),c(`rari:app-router-updated`,async n=>{if(!((n.routePath==null||n.routePath===``)&&(n.affectedRoutes==null||n.affectedRoutes.length===0)))try{let i=r(),a=await fetch(`${i}/_rari/hmr`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`register`,file_path:n.filePath})});if(!a.ok)throw Error(`Component reload failed: ${a.status}`);let o=await a.json(),s=e(o)&&o.success===!0,c=e(o)&&o.reloaded===!0,l=e(o)&&typeof o.error==`string`?o.error:`Component reload unsuccessful`;if(!s&&!c)throw Error(l);if(await fetch(`${i}/_rari/hmr`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`invalidate`,componentId:n.routePath!=null&&n.routePath!==``?n.routePath:n.filePath,filePath:n.filePath})}),n.metadataChanged&&n.metadata&&(n.metadata.title!=null&&n.metadata.title!==``&&(document.title=n.metadata.title),n.metadata.description!=null&&n.metadata.description!==``)){let e=document.querySelector(`meta[name="description"]`);e||(e=document.createElement(`meta`),e.setAttribute(`name`,`description`),document.head.appendChild(e)),e.setAttribute(`content`,n.metadata.description)}let u=t();n.manifestUpdated&&u?.routeInfoCache&&u.routeInfoCache.clear(),window.dispatchEvent(new CustomEvent(`rari:app-router-rerender`,{detail:{routePath:n.routePath,affectedRoutes:n.affectedRoutes??(n.routePath==null?[]:[n.routePath]),currentPath:window.location.pathname,preserveParams:!0}}))}catch(e){console.error(`[rari] HMR: App router update failed:`,e)}},p),c(`rari:server-action-updated`,e=>{window.dispatchEvent(new CustomEvent(`rari:rsc-invalidate`,{detail:{filePath:e.filePath,type:`server-action`}}))},m),o.length>0?(async()=>{try{let e=[...o];o.length=0;for(let{event:t,data:n}of e){let e=s.get(t);e&&await e(n)}}catch(e){console.error(`[rari] HMR: Error during event replay:`,e)}finally{a=!0}})():a=!0}export{};
@@ -1,5 +1,5 @@
1
+ import "../types-_vPM8QuJ.mjs";
1
2
  import { createClientModuleProxy as createClientModuleProxy$1, registerServerReference } from "react-server-dom-webpack/server";
2
-
3
3
  //#region src/runtime/rsc/references.d.ts
4
4
  declare const createClientModuleProxy: typeof createClientModuleProxy$1;
5
5
  declare function registerClientReference<T>(clientReference: T, id: string, exportName: string): T;
@@ -1 +1 @@
1
- import{createClientModuleProxy as e,registerClientReference as t,registerServerReference as n}from"react-server-dom-webpack/server";const r=e;function i(e,n,r){let i=`${n}#${r}`,a=t(e??(()=>{}),n,r);try{let e=globalThis.registerClientComponent;typeof e==`function`&&e(i,n,a)}catch(e){console.error(`[rari] Failed to register client reference:`,e)}return a}export{r as createClientModuleProxy,i as registerClientReference,n as registerServerReference};
1
+ import{createClientModuleProxy as e,registerClientReference as t,registerServerReference as n}from"react-server-dom-webpack/server";const r=e;function i(e,n,r){let i=`${n}#${r}`,a=t(e??(()=>{}),n,r);try{let e=Reflect.get(globalThis,`registerClientComponent`);typeof e==`function`&&Reflect.apply(e,void 0,[i,n,a])}catch(e){console.error(`[rari] Failed to register client reference:`,e)}return a}export{r as createClientModuleProxy,i as registerClientReference,n as registerServerReference};
@@ -0,0 +1,7 @@
1
+ import{p as e}from"./type-guards-CTkEL8zw.mjs";import{o as t,t as n}from"./alias-resolver-Cigam7Y7.mjs";import{t as r}from"./xml-N8OZmN7u.mjs";import{Buffer as i}from"node:buffer";import{promises as a}from"node:fs";import o from"node:path";const s=/[^\w-]/g,c=`\0virtual:sitemap`;function l(e){return(typeof e==`string`?new Date(e):e).toISOString()}function u(e){return[` <image:image>`,` <image:loc>${r(e)}</image:loc>`,` </image:image>`].join(`
2
+ `)}function d(e){let t=[` <image:image>`,` <image:loc>${r(e.loc)}</image:loc>`];return e.title!=null&&e.title!==``&&t.push(` <image:title>${r(e.title)}</image:title>`),e.caption!=null&&e.caption!==``&&t.push(` <image:caption>${r(e.caption)}</image:caption>`),e.geoLocation!=null&&e.geoLocation!==``&&t.push(` <image:geo_location>${r(e.geoLocation)}</image:geo_location>`),e.license!=null&&e.license!==``&&t.push(` <image:license>${r(e.license)}</image:license>`),t.push(` </image:image>`),t.join(`
3
+ `)}function f(e){let t=[];for(let n of e)typeof n==`string`?t.push(u(n)):t.push(d(n));return t.join(`
4
+ `)}function p(e){let t=[];if(t.push(` <video:video>`),t.push(` <video:title>${r(e.title)}</video:title>`),t.push(` <video:thumbnail_loc>${r(e.thumbnail_loc)}</video:thumbnail_loc>`),t.push(` <video:description>${r(e.description)}</video:description>`),e.content_loc!=null&&e.content_loc!==``&&t.push(` <video:content_loc>${r(e.content_loc)}</video:content_loc>`),e.player_loc!=null&&e.player_loc!==``&&t.push(` <video:player_loc>${r(e.player_loc)}</video:player_loc>`),e.duration!==void 0&&t.push(` <video:duration>${e.duration}</video:duration>`),e.expiration_date!=null&&e.expiration_date!==``&&t.push(` <video:expiration_date>${r(e.expiration_date)}</video:expiration_date>`),e.rating!==void 0&&t.push(` <video:rating>${e.rating}</video:rating>`),e.view_count!==void 0&&t.push(` <video:view_count>${e.view_count}</video:view_count>`),e.publication_date!=null&&e.publication_date!==``&&t.push(` <video:publication_date>${r(e.publication_date)}</video:publication_date>`),e.family_friendly!==void 0&&t.push(` <video:family_friendly>${e.family_friendly?`yes`:`no`}</video:family_friendly>`),e.requires_subscription!==void 0&&t.push(` <video:requires_subscription>${e.requires_subscription?`yes`:`no`}</video:requires_subscription>`),e.live!==void 0&&t.push(` <video:live>${e.live?`yes`:`no`}</video:live>`),e.restriction&&t.push(` <video:restriction relationship="${r(e.restriction.relationship)}">${r(e.restriction.content)}</video:restriction>`),e.platform&&t.push(` <video:platform relationship="${r(e.platform.relationship)}">${r(e.platform.content)}</video:platform>`),e.uploader){let n=e.uploader.info!=null&&e.uploader.info!==``?` info="${r(e.uploader.info)}"`:``;t.push(` <video:uploader${n}>${r(e.uploader.name)}</video:uploader>`)}if(e.tag)for(let n of e.tag)t.push(` <video:tag>${r(n)}</video:tag>`);return t.push(` </video:video>`),t.join(`
5
+ `)}function m(e){return e.map(e=>p(e)).join(`
6
+ `)}function h(e){let t=e.some(e=>e.images&&e.images.length>0),n=e.some(e=>e.videos&&e.videos.length>0),r=e.some(e=>e.alternates?.languages),i=[`xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"`];return t&&i.push(`xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"`),n&&i.push(`xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"`),r&&i.push(`xmlns:xhtml="http://www.w3.org/1999/xhtml"`),i}function g(e,t){e.push(` <url>`),e.push(` <loc>${r(t.url)}</loc>`),t.lastModified!=null&&e.push(` <lastmod>${l(t.lastModified)}</lastmod>`),t.changeFrequency&&e.push(` <changefreq>${t.changeFrequency}</changefreq>`),t.priority!==void 0&&e.push(` <priority>${t.priority}</priority>`)}function _(e,t){if(t.alternates?.languages)for(let[n,i]of Object.entries(t.alternates.languages))e.push(` <xhtml:link rel="alternate" hreflang="${r(n)}" href="${r(i)}" />`)}function v(e,t){t.images&&t.images.length>0&&e.push(f(t.images)),t.videos&&t.videos.length>0&&e.push(m(t.videos))}function y(e){let t=[`<?xml version="1.0" encoding="UTF-8"?>`,`<urlset ${h(e).join(` `)}>`];for(let n of e)g(t,n),_(t,n),v(t,n),t.push(` </url>`);return t.push(`</urlset>`),t.join(`
7
+ `)}async function b(e,t=[`.ts`,`.tsx`,`.js`,`.jsx`,`.mjs`,`.json`]){let n=[],r=o.join(e,`sitemap.xml`);try{return await a.access(r),n.push({type:`static`,path:r}),n}catch{}for(let r of t){let t=o.join(e,`sitemap${r}`);try{return await a.access(t),n.push({type:`dynamic`,path:t}),n}catch{}}return n}function x(e){switch(e){case`ts`:return`ts`;case`tsx`:return`tsx`;case`js`:case`mjs`:return`js`;case`jsx`:return`jsx`;case`json`:return`json`;default:throw Error(`Unsupported sitemap file extension: ".${e}". Allowed extensions are: .ts, .tsx, .js, .jsx, .mjs, .json`)}}function S(e,r,i={},s){return{name:`virtual-sitemap`,resolveId(r,a){if(r===c)return r;if(Object.keys(i).length>0){let e=n(r,i,s);if(e!=null&&e!==``){let n=t(e);return n!=null&&n!==``?n:e}}if(r.startsWith(`.`)){let n=a==null||a===``||a.startsWith(`\0`)?e.path:a,i=o.resolve(o.dirname(n),r),s=t(i);return s!=null&&s!==``?s:i}return null},async load(t){if(t===c)return{code:r,moduleType:x(o.extname(e.path).slice(1))};if(t&&!t.startsWith(`\0`))try{return{code:await a.readFile(t,`utf-8`),moduleType:x(o.extname(t).slice(1))}}catch{return null}return null}}}function C(e){if(e.output.length===0)throw Error(`Failed to build sitemap module`);let t=e.output.find(e=>e.type===`chunk`&&e.isEntry)??e.output.find(e=>e.type===`chunk`);if(t?.type!==`chunk`)throw Error(`No chunk output found in sitemap build result`);return t.code}function w(e){return typeof e==`function`||Array.isArray(e)}function T(t){return e(t)?w(t.default):!1}async function E(e,t,n={},r){let{build:a}=await import(`rolldown`),o=C(await a({input:c,external:[`rari`],platform:`node`,write:!1,output:{format:`esm`,codeSplitting:!1},plugins:[S(e,t,n,r)]})),s=await import(`data:text/javascript;base64,${i.from(o).toString(`base64`)}`);if(!T(s))throw Error(`Sitemap module must export a default sitemap array or sitemap generator function`);return s}async function D(e,t){let n=await e.generateSitemaps(),r=o.join(t,`sitemap`);await a.mkdir(r,{recursive:!0});let i=new Map;for(let{id:t}of n)try{let n=t.replace(s,`_`);(!n||n.length===0)&&(n=`_`);let c=i.get(n);if(c!==void 0)throw Error(`Duplicate sanitized sitemap ID "${n}": original IDs "${c}" and "${t}" collide`);i.set(n,t);let l=typeof e.default==`function`?await e.default({id:t}):e.default;if(!Array.isArray(l))throw Error(`Sitemap default export must resolve to a sitemap entry array`);let u=y(l),d=o.join(r,`${n}.xml`);await a.writeFile(d,u)}catch(e){throw Error(`Failed to generate sitemap for id "${t}"`,{cause:e})}}async function O(e,t){let n=typeof e.default==`function`?await e.default():e.default;if(!Array.isArray(n))throw Error(`Sitemap default export must resolve to a sitemap entry array`);let r=y(n),i=o.join(t,`sitemap.xml`);await a.writeFile(i,r)}async function k(e){let{appDir:t,extensions:n,outDir:r,aliases:i={}}=e,s=await b(t,n);if(s.length===0)return!1;await a.mkdir(r,{recursive:!0});let c=s[0];if(c.type===`static`){let e=o.join(r,`sitemap.xml`);return await a.copyFile(c.path,e),!0}try{let e=await E(c,await a.readFile(c.path,`utf-8`),i,o.dirname(o.dirname(t)));return typeof e.generateSitemaps==`function`?await D(e,r):await O(e,r),!0}catch(e){return console.error(`[rari] Failed to build/execute sitemap file:`,e),!1}}export{k as generateSitemapFiles};