rari 0.14.12 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/README.md +8 -44
  2. package/dist/alias-resolver-CHTPYtdq.mjs +1 -0
  3. package/dist/api-routes-ChRr3O5-.mjs +1 -0
  4. package/dist/cli.d.mts +3 -2
  5. package/dist/cli.mjs +39 -41
  6. package/dist/define-CRFUKkcA.d.mts +14 -0
  7. package/dist/define-rCXgNOOk.mjs +1 -0
  8. package/dist/feed-B3mYPCnT.mjs +3 -0
  9. package/dist/get-client-component-CDaY3lOP.mjs +1 -0
  10. package/dist/headers.d.mts +38 -3
  11. package/dist/headers.mjs +1 -1
  12. package/dist/http-C5Y9ZrK9.mjs +1 -0
  13. package/dist/{image/index.d.mts → image.d.mts} +1 -1
  14. package/dist/image.mjs +1 -0
  15. package/dist/index.d.mts +4 -4
  16. package/dist/index.mjs +1 -1
  17. package/dist/mdx/define.d.mts +2 -0
  18. package/dist/mdx/define.mjs +1 -0
  19. package/dist/mdx/registry.d.mts +4 -0
  20. package/dist/mdx/registry.mjs +1 -0
  21. package/dist/mdx.d.mts +30 -8
  22. package/dist/mdx.mjs +1 -1
  23. package/dist/names-N6JRDeT1.mjs +1 -0
  24. package/dist/{og/index.d.mts → og.d.mts} +1 -1
  25. package/dist/platform.d.mts +1 -1
  26. package/dist/platform.mjs +2 -2
  27. package/dist/preload-modules-CJQ_IouX.mjs +2 -0
  28. package/dist/proxy/RariRequest.d.mts +2 -2
  29. package/dist/proxy/RariResponse.d.mts +2 -2
  30. package/dist/proxy/RariResponse.mjs +1 -1
  31. package/dist/proxy/runtime-executor.d.mts +2 -2
  32. package/dist/proxy/runtime-executor.mjs +1 -1
  33. package/dist/{railway--nFNI3h8.mjs → railway-fmDbDigI.mjs} +1 -1
  34. package/dist/rari-global-Dygfa818.mjs +1 -0
  35. package/dist/regex-constants-Wm7xRA3u.mjs +1 -0
  36. package/dist/{render-EieI0V5b.mjs → render-2I7-kFd_.mjs} +1 -1
  37. package/dist/router-Ctpd1kcp.mjs +1 -0
  38. package/dist/router.d.mts +3 -3
  39. package/dist/router.mjs +1 -1
  40. package/dist/runtime/AppRouterProvider.d.mts +2 -2
  41. package/dist/runtime/AppRouterProvider.mjs +1 -5
  42. package/dist/runtime/ErrorBoundaryWrapper.d.mts +1 -1
  43. package/dist/runtime/ErrorBoundaryWrapper.mjs +1 -1
  44. package/dist/runtime/LoadingErrorBoundary.d.mts +1 -1
  45. package/dist/runtime/action-flight-refresh.d.mts +17 -0
  46. package/dist/runtime/action-flight-refresh.mjs +1 -0
  47. package/dist/runtime/action-revalidation-kind.d.mts +8 -0
  48. package/dist/runtime/action-revalidation-kind.mjs +1 -0
  49. package/dist/runtime/call-server.d.mts +4 -0
  50. package/dist/runtime/call-server.mjs +1 -0
  51. package/dist/runtime/entry-client.mjs +3 -3
  52. package/dist/runtime/flight-route-cache.d.mts +34 -0
  53. package/dist/runtime/flight-route-cache.mjs +1 -0
  54. package/dist/runtime/flight-router-state.d.mts +11 -0
  55. package/dist/runtime/flight-router-state.mjs +1 -0
  56. package/dist/runtime/merge-flight-refresh.d.mts +6 -0
  57. package/dist/runtime/merge-flight-refresh.mjs +1 -0
  58. package/dist/runtime/rsc-client-runtime.d.mts +1 -40
  59. package/dist/runtime/rsc-client-runtime.mjs +1 -2
  60. package/dist/runtime/rsc-references.d.mts +7 -0
  61. package/dist/runtime/rsc-references.mjs +1 -0
  62. package/dist/sitemap-BekxZtgA.mjs +7 -0
  63. package/dist/{types-3dq9RGI5.d.mts → types-BC33STEP.d.mts} +1 -1
  64. package/dist/types-DJQFFYSj.d.mts +160 -0
  65. package/dist/{types-BwhW3M72.d.mts → types-DlF9FHQc.d.mts} +1 -1
  66. package/dist/utils-CW4FEV95-DI7wf2Fu.mjs +37 -0
  67. package/dist/vite.d.mts +211 -106
  68. package/dist/vite.mjs +117 -96
  69. package/dist/xml-N8OZmN7u.mjs +1 -0
  70. package/package.json +65 -32
  71. package/dist/ReactFlightClientConfig-C_nD8rsi.d.mts +0 -35
  72. package/dist/alias-resolver-BIWqeQml.mjs +0 -1
  73. package/dist/client.d.mts +0 -104
  74. package/dist/client.mjs +0 -1
  75. package/dist/feed-generator-CM9mK131.mjs +0 -3
  76. package/dist/get-client-component-B4Y2T40R.mjs +0 -1
  77. package/dist/image/index.mjs +0 -1
  78. package/dist/metadata-route-_d5FkjlL.d.mts +0 -108
  79. package/dist/navigate-DuyUa6qD.mjs +0 -1
  80. package/dist/preload-modules-xvnJ_8eh.mjs +0 -2
  81. package/dist/props-extractor-C8FRV5vW.mjs +0 -1
  82. package/dist/regex-constants-DQ2vkSU5.mjs +0 -1
  83. package/dist/resolve-R6nLL3qq.mjs +0 -1
  84. package/dist/runtime/actions.d.mts +0 -21
  85. package/dist/runtime/actions.mjs +0 -1
  86. package/dist/runtime/react-server-dom-shim.d.mts +0 -21
  87. package/dist/runtime/react-server-dom-shim.mjs +0 -1
  88. package/dist/runtime/vendor/react-flight-client/ReactFlightClient.d.mts +0 -71
  89. package/dist/runtime/vendor/react-flight-client/ReactFlightClient.mjs +0 -2
  90. package/dist/runtime/vendor/react-flight-client/ReactFlightClientConfig.d.mts +0 -2
  91. package/dist/runtime/vendor/react-flight-client/ReactFlightClientConfig.mjs +0 -1
  92. package/dist/runtime/vendor/react-flight-client/index.d.mts +0 -12
  93. package/dist/runtime/vendor/react-flight-client/index.mjs +0 -1
  94. package/dist/server-config-D7_4Hk9w.d.mts +0 -107
  95. package/dist/sitemap-generator-DWgqfKQu.mjs +0 -7
  96. package/dist/suspense-CsIYuC_l.mjs +0 -1
  97. package/dist/types-zPQ3RHgH.d.mts +0 -34
  98. package/dist/utils-DtilLmFs-CiitZqwE.mjs +0 -37
  99. /package/dist/{og/index.mjs → og.mjs} +0 -0
  100. /package/dist/{robots-generator-CsTVq3Jp.mjs → robots-CsTVq3Jp.mjs} +0 -0
package/dist/router.mjs CHANGED
@@ -1 +1 @@
1
- import{n as e,r as t}from"./navigate-DuyUa6qD.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";const l=n(null);function u({children:t,initialPathname:n}){let[r,u]=s(n),[d,f]=s(()=>typeof window<`u`?new URLSearchParams(window.location.search):new URLSearchParams),p=o(null);return i(()=>{let e=e=>{let t=e.detail;t?.to&&(u(t.to),f(new URLSearchParams(window.location.search)))};return window.addEventListener(`rari:navigate`,e),()=>{window.removeEventListener(`rari:navigate`,e)}},[]),i(()=>{let t=e();t&&(p.current=t);let n=e=>{p.current=e.detail.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)}},[]),c(l,{value: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]),children:t})}function d(){let e=r(l);if(!e)throw Error(`useRouter must be used within a RouterProvider`);return e}function f(){return d().pathname}function p(){return d().params}function m(){return d().searchParams}export{u as RouterProvider,t as navigate,p as useParams,f as usePathname,d as useRouter,m as useSearchParams};
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,6 +1,6 @@
1
1
  import * as React from "react";
2
2
 
3
- //#region src/runtime/AppRouterProvider.d.ts
3
+ //#region src/runtime/flight/app-router-provider.d.ts
4
4
  interface AppRouterProviderProps {
5
5
  children: React.ReactNode;
6
6
  initialPayload?: any;
@@ -13,7 +13,7 @@ interface NavigationDetail {
13
13
  options: any;
14
14
  routeInfo?: any;
15
15
  abortSignal?: AbortSignal;
16
- rscWireFormat?: string;
16
+ rscFlightProtocol?: string;
17
17
  rscResponse?: Response;
18
18
  rscResponsePromise?: Promise<Response>;
19
19
  isStreaming?: boolean;
@@ -1,5 +1 @@
1
- "use client";import{g as e,v as t}from"../regex-constants-DQ2vkSU5.mjs";import{t as n}from"../preload-modules-xvnJ_8eh.mjs";import{t as r}from"../suspense-CsIYuC_l.mjs";import*as i from"react";import{Suspense as a,useEffect as o,useRef as s,useState as c}from"react";import{Fragment as l,jsx as u,jsxs as d}from"react/jsx-runtime";import{createFromFetch as f,createFromReadableStream as ee}from"virtual:react-flight-client";const te=/"timestamp":(\d+)/,p=/^(?:-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?|true|false|null)$/,m=/^[0-9a-f]+$/i,ne=/^\$L?[0-9a-f]+$/i;function re(e){return new Promise(t=>{setTimeout(t,e)})}function h(e){if(!e||e.length===0)return!1;let t=e.charAt(0),n=e.charCodeAt(0);return e.startsWith(`I[`)||e.startsWith(`I{`)||e.startsWith(`"$S`)?!1:!!(n===84||t===`[`||t===`{`||e.startsWith(`E{`)||t===`"`||p.test(e))}function ie(e){return!e||e.length===0?!1:!!(e.includes(`"fallback"`)||e.includes(`$Lfallback`)||e.startsWith(`E{`))}function ae({contentRef:e,rowsDataRef:t,modulesDataRef:n,symbolsDataRef:r,suspendingPromisesRef:a,getSuspendingPromise:o,rscToReact:s}){let c=t.current,l=n.current,u=r.current,d=a.current,f=c.has(e);if(i.useEffect(()=>{f&&d.has(e)&&d.delete(e)},[e,f,d]),f)return s(c.get(e),l,void 0,u,c);throw o(e)}function g({children:p,initialPayload:g,onNavigate:_}){let[v,y]=c(g),b=c(0)[1],x=s({x:0,y:0}),S=s(new Map),C=s(null),w=s(new Set),T=s(_),E=s(0),D=s(new Map),O=s([]),k=s(null),A=s(0),[j,M]=c(null),N=s(typeof window<`u`&&window.location.hash.length>0),oe=s(0),P=s(!1),F=s(!1),I=s(!1),L=s(Promise.resolve()),se=s(!1),R=s(!!g),z=s(null);o(()=>{T.current=_},[_]),o(()=>{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 B=()=>{if(typeof document>`u`)return;let e=document.querySelectorAll(`form`);S.current.clear(),e.forEach((e,t)=>{let n=new FormData(e);S.current.set(`form-${t}`,n)})},ce=()=>{typeof document>`u`||document.querySelectorAll(`form`).forEach((e,t)=>{let n=S.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)})})},V=(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}))},H=()=>{setTimeout(()=>{window.location.reload()},1e3)},U=()=>{A.current>0&&(A.current=0)},le=e=>{if(!k.current)return!1;if(e===k.current)return!0;let t=e.match(te);if(t){let e=Number.parseInt(t[1],10);if(Date.now()-e>5e3)return!0}return!1};function ue(e){let t;try{t=JSON.stringify(e)}catch{try{let n=new WeakSet;t=JSON.stringify(e,(e,t)=>{if(typeof t==`object`&&t){if(n.has(t))return`[Circular]`;n.add(t)}return t})}catch{t=`[Unstringifiable:${typeof e}:${String(e).substring(0,50)}]`}}let n=0;for(let e=0;e<t.length;e++){let r=t.charCodeAt(e);n=(n<<5)-n+r,n&=n}return Math.abs(n).toString(36)}function W(t,n,a,o,s,c){if(t==null)return null;if(typeof t==`string`&&t.startsWith(`$`)&&t.length>1&&m.test(t.substring(1))&&s&&s.has(t)){let e=c??new Set;return e.has(t)?(console.warn(`[rari] AppRouter: Circular $ reference detected:`,t),null):(e.add(t),W(s.get(t),n,a,o,s,e))}if(typeof t==`string`||typeof t==`number`||typeof t==`boolean`)return t;if(Array.isArray(t)){if(t.length>=4&&t[0]===`$`){let[,c,l,u]=t,d=c;if(typeof c==`string`&&c.startsWith(`$`)&&o){let t=c.substring(1);if(e.test(t)){let e=o.get(c);e&&(r(e)?d=`Suspense`:console.warn(`[rari] AppRouter: Unknown symbol:`,e))}}if(typeof d==`string`&&r(d)||typeof c==`string`&&r(c)){let e=he(u,n,a,o,s);return i.createElement(i.Suspense,l?{...e,key:l}:e)}if(typeof d==`string`&&d.startsWith(`$`)&&ne.test(d)){let e=n.get(d);if(!e)return console.warn(`[rari] AppRouter: Module not found for reference:`,d,`Available modules:`,Array.from(n.keys())),null;let t=globalThis[`~clientComponents`]?.[e.id]?.component;if(!t)return console.warn(`[rari] AppRouter: Component not loaded:`,e.id),null;if(typeof t!=`function`)return null;let r=l||`fallback-${d}-${oe.current++}`,c={...u,children:u.children===void 0?void 0:W(u.children,n,a,o,s)};return i.createElement(t,{key:r,...c})}if(!d||typeof d!=`string`&&typeof d!=`function`||typeof d==`string`&&d.startsWith(`$`))return null;let f=he(u,n,a,o,s);return i.createElement(d,l?{...f,key:l}:f)}return t.map((e,t)=>{let r=W(e,n,a,o,s);if(r==null)return null;if(typeof r==`object`&&i.isValidElement(r)&&!r.key){let n=typeof e==`object`&&e?ue(e):`primitive`,a=`rsc-${Array.isArray(e)&&e[0]===`$`&&e[1]?String(e[1]):`unknown`}-${n}-${t}`;return i.createElement(i.Fragment,{key:a},r)}return r}).filter(e=>e!=null)}return t}let G=s(new Set),K=s(new Map),q=s(new Map),de=s(new Map),J=s(new Map);function fe(e){if(!J.current.has(e)){let t=new Promise(()=>{});J.current.set(e,{promise:t,timestamp:Date.now()})}return J.current.get(e).promise}function pe(){J.current.clear(),G.current.clear()}function me(){let e=Date.now(),t=[];J.current.forEach((n,r)=>{e-n.timestamp>3e4&&t.push(r)}),t.forEach(e=>{J.current.delete(e),G.current.delete(e)})}function he(e,t,n,r,a){if(!e||typeof e!=`object`)return e;a&&(K.current=a),t&&(q.current=t),r&&(de.current=r);let o={};for(let s in e)if(Object.hasOwn(e,s))if(s===`children`){let c=e.children;if(typeof c==`string`&&c.startsWith(`$`)&&c.length>1&&m.test(c.substring(1)))if(a&&a.has(c)){let e=a.get(c);G.current.delete(c),o[s]=W(e,t,n,r,a)}else G.current.add(c),o[s]=i.createElement(ae,{key:`lazy-${c}`,contentRef:c,rowsDataRef:K,modulesDataRef:q,symbolsDataRef:de,suspendingPromisesRef:J,getSuspendingPromise:fe,rscToReact:W});else o[s]=c===void 0?void 0:W(c,t,n,r,a)}else s===`dangerouslySetInnerHTML`?o[s]=e[s]:o[s]=W(e[s],t,n,r,a);return o}let Y=async e=>{await n(e,w.current);let t=await ee(new ReadableStream({start(t){t.enqueue(new TextEncoder().encode(e)),t.close()}}));return{element:t,rawElement:t,wireFormat:e}},ge=e=>({element:f(e)}),_e=async(e,n)=>{let r=e||window.location.pathname,i=E.current,a=`${i}:${r}${window.location.search}`,o=D.current.get(a);if(o)return o;let s=(async()=>{try{let e=(import.meta.env.RARI_SERVER_URL||window.location.origin).replace(t,``)+r+window.location.search,a=await fetch(e,{headers:{Accept:`text/x-component`},cache:`no-store`,signal:n});if(!a.ok){let t=Error(`Failed to fetch RSC data: ${a.status} ${a.statusText}`);throw V(t,`fetch`,`HTTP ${a.status} when fetching ${e}`,window.location.pathname),t}let o=await a.text();if(le(o)&&v)return v;let s;try{s=await Y(o)}catch(e){let t=e instanceof Error?e:Error(String(e));throw V(t,`parse`,`Failed to parse RSC wire format: ${t.message}`,window.location.pathname),t}return E.current===i&&(y(s),k.current=o,U()),s}catch(e){throw e instanceof Error&&!e.message.includes(`Failed to fetch RSC data`)&&!e.message.includes(`Failed to parse`)&&V(e,`network`,`Network error: ${e.message}`,window.location.pathname),e}finally{D.current.delete(a)}})();return D.current.set(a,s),s},X=s(Y),Z=s(ge),Q=s(_e);o(()=>{X.current=Y,Z.current=ge,Q.current=_e}),o(()=>{if(typeof window>`u`)return;let e=setInterval(()=>{me()},3e4),t=async e=>{let t=e.detail;if(t.navigationId!==E.current)return;N.current=!0,t.isStreaming||(C.current=null),pe(),x.current={x:window.scrollX,y:window.scrollY},B();let n=null,r=null,a=!1;try{if(t.rscResponsePromise){let e=await t.rscResponsePromise;if(E.current!==t.navigationId)return;a=e.headers.get(`x-render-mode`)===`streaming`;let{element:r}=Z.current(Promise.resolve(e));if(a)n={element:r};else{let e=await r;if(E.current!==t.navigationId)return;n={element:e}}}else if(t.rscResponse){a=t.rscResponse.headers.get(`x-render-mode`)===`streaming`;let{element:e}=Z.current(Promise.resolve(t.rscResponse));if(a)n={element:e};else{let r=await e;if(E.current!==t.navigationId)return;n={element:r}}}else t.rscWireFormat?n=await X.current(t.rscWireFormat):t.isStreaming||(n=await Q.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&&H();return}if(!n&&t.isStreaming&&E.current===t.navigationId){z.current=t;return}n&&E.current===t.navigationId&&(a?(y(n),b(e=>e+1),M(null)):i.startTransition(()=>{y(n),b(e=>e+1),M(null)}),t.rscWireFormat&&(k.current=t.rscWireFormat),U(),T.current&&T.current(t));let o=typeof window<`u`&&window.location.hash.length>0;!t.options?.historyKey&&!o&&requestAnimationFrame(()=>{t.options?.scroll!==!1&&window.scrollTo(0,0)})},n=async()=>{x.current={x:window.scrollX,y:window.scrollY},B();try{await Q.current(),b(e=>e+1),M(null)}catch(e){console.error(`HMR refetch error:`,e instanceof Error?e.message:String(e)),A.current>=3&&H()}finally{requestAnimationFrame(()=>{window.scrollTo(x.current.x,x.current.y),ce()})}},r=async()=>{try{await Q.current(),b(e=>e+1),M(null)}catch(e){console.error(`RSC invalidate error:`,e instanceof Error?e.message:String(e)),A.current>=3&&H()}},a=e=>{let t=e;if(C.current=[],w.current.clear(),E.current=t.detail.navigationId,typeof window<`u`){let e=window;e[`~rari`]||={},e[`~rari`].navigationId=t.detail.navigationId}P.current=!1,F.current=!1,I.current=!1,L.current=Promise.resolve(),se.current=!0,R.current=!1,z.current=null},o=async()=>{try{await Q.current(),M(null)}catch(e){console.error(`Manifest update error:`,e instanceof Error?e.message:String(e)),A.current>=3&&H()}},s=async()=>{if(!C.current||C.current.length===0||R.current)return;let e=E.current,t=[...C.current],n=t.some(e=>{let t=e.indexOf(`:`),n=t>0?e.substring(0,t).trim():``,r=t>0?e.substring(t+1):``;return m.test(n)&&h(r)}),r=t.some(e=>{let n=e.indexOf(`:`),r=n>0?e.substring(0,n).trim():``,i=n>0?e.substring(n+1):``;return!m.test(r)||!h(i)?!1:t.some(e=>{let t=e.indexOf(`:`),n=t>0?e.substring(0,t).trim():``,i=t>0?e.substring(t+1):``;return!m.test(n)||!h(i)||ie(i)?!1:RegExp(`"?\\$L?${r}"?(?![0-9a-fA-F])`).test(i)})});if(!n&&!r)return;if(!P.current&&n&&!r&&(P.current=!0,t.some(e=>e.includes(`"$Sreact.suspense"`)||e.includes(`react.suspense`)))){try{let n=t.filter(e=>{let n=e.indexOf(`:`),i=n>0?e.substring(0,n).trim():``,a=RegExp(`"\\$L?${i}"(?![0-9a-fA-F])`);return!r||!t.some(e=>a.test(e))}),i=await X.current(n.join(`
2
- `));E.current===e&&(y(i),b(e=>e+1))}catch(e){console.error(`[rari] Failed to parse shell payload:`,e),P.current=!1,L.current=Promise.resolve()}return}let i=t.some(e=>e.includes(`"$Sreact.suspense"`)||e.includes(`react.suspense`));if(!(!r&&i&&!I.current)&&!F.current){P.current=!0;try{let n=await X.current(t.join(`
3
- `));if((i||r)&&(await re(50),E.current===e&&!F.current)){let n=C.current?[...C.current]:t,r=await X.current(n.join(`
4
- `));E.current===e&&(F.current=!0,y(r),b(e=>e+1),z.current&&T.current&&(T.current(z.current),z.current=null),I.current&&(C.current=null))}if(E.current!==e||F.current)return;let a=C.current?[...C.current]:t;if(n=await X.current(a.join(`
5
- `)),E.current!==e||F.current)return;y(n),b(e=>e+1),z.current&&T.current&&(T.current(z.current),z.current=null),I.current&&(F.current=!0,C.current=null)}catch(e){console.error(`Process rows error:`,e instanceof Error?e.message:String(e))}}},c=e=>{let t=e,n=t.detail.rscRow,r=t.detail.navigationId;if(!n||!n.trim()||!C.current)return;let i=E.current;if(!(r==null||r!==i)){if(n.trim()===`STREAM_COMPLETE`){I.current=!0,L.current=L.current.then(()=>{if(E.current===i)return s()});return}C.current.push(n),L.current=L.current.then(()=>{if(E.current===i)return s()})}};return window.addEventListener(`rari:navigation-start`,a),window.addEventListener(`rari:navigate`,t),window.addEventListener(`rari:app-router-rerender`,n),window.addEventListener(`rari:rsc-invalidate`,r),window.addEventListener(`rari:app-router-manifest-updated`,o),window.addEventListener(`rari:rsc-row`,c),()=>{clearInterval(e),pe(),window.removeEventListener(`rari:navigation-start`,a),window.removeEventListener(`rari:navigate`,t),window.removeEventListener(`rari:app-router-rerender`,n),window.removeEventListener(`rari:rsc-invalidate`,r),window.removeEventListener(`rari:app-router-manifest-updated`,o),window.removeEventListener(`rari:rsc-row`,c)}},[]),o(()=>{if(!(typeof window>`u`)&&window.location.hash&&v&&N.current){let e=window.location.hash.slice(1);requestAnimationFrame(()=>{requestAnimationFrame(()=>{let t=document.getElementById(e);t&&(t.scrollIntoView({behavior:`instant`,block:`start`}),N.current=!1)})})}},[v]);let ve=()=>{window.location.reload()},ye=()=>{M(null)},be=e=>{if(!e||typeof e!=`object`)return null;if(e.type===`html`&&e.props?.children){let t=Array.isArray(e.props.children)?e.props.children:[e.props.children];for(let e of t)if(e&&typeof e==`object`&&e.type===`body`)return e.props?.children??null}return e},$=p;if(v?.element!=null)if(v.element&&typeof v.element==`object`&&`status`in v.element){let e=v.element.status;$=e===`fulfilled`?v.element.value:e===`rejected`?p:i.use(v.element)}else $=be(v.element)??v.element;return Array.isArray($)&&$.length===1&&i.isValidElement($[0])?$=$[0]:Array.isArray($)&&$.length>0&&$.every(e=>i.isValidElement(e)||e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`)&&($=i.createElement(i.Fragment,null,...$)),d(l,{children:[j&&d(`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:[u(`div`,{style:{marginBottom:`16px`,fontWeight:`bold`,fontSize:`16px`},children:`⚠️ HMR Update Failed`}),d(`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.`]}),u(`div`,{style:{marginBottom:`16px`,fontSize:`12px`,opacity:.8,fontFamily:`monospace`},children:j.details}),d(`div`,{style:{marginBottom:`12px`,fontSize:`12px`,opacity:.7},children:[`Consecutive failures:`,` `,A.current,` `,`/`,` `,3]}),d(`div`,{style:{display:`flex`,gap:`8px`},children:[u(`button`,{onClick:ve,type:`button`,style:{padding:`8px 16px`,background:`white`,color:`#dc2626`,border:`none`,borderRadius:`4px`,cursor:`pointer`,fontWeight:`bold`,fontSize:`14px`},children:`Refresh Page`}),u(`button`,{onClick:ye,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`})]}),u(`div`,{style:{marginTop:`12px`,fontSize:`11px`,opacity:.6},children:`Check the console for detailed error logs.`})]}),u(a,{fallback:null,children:$})]})}export{g as AppRouterProvider};
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,7 +1,7 @@
1
1
  import * as React from "react";
2
2
  import { Component, ReactNode } from "react";
3
3
 
4
- //#region src/runtime/ErrorBoundaryWrapper.d.ts
4
+ //#region src/runtime/boundaries/error-boundary-wrapper.d.ts
5
5
  interface ErrorBoundaryWrapperProps {
6
6
  errorComponentId: string;
7
7
  children: ReactNode;
@@ -1 +1 @@
1
- "use client";import{t as e}from"../timer-Duul5JHq.mjs";import{Component as t}from"react";import{jsx as n}from"react/jsx-runtime";var r=class extends t{_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,t){console.error(`[rari] Error boundary caught error:`,e,t);let n=this.props.errorComponentId;if(n&&typeof window<`u`){let e=window[`~clientComponents`]?.[n];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 ${n}:`,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?n(e,{error:this.state.error,reset:this.reset}):null}return this.props.children}};export{r as ErrorBoundaryWrapper};
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,6 +1,6 @@
1
1
  import * as React from "react";
2
2
 
3
- //#region src/runtime/LoadingErrorBoundary.d.ts
3
+ //#region src/runtime/boundaries/loading-error-boundary.d.ts
4
4
  interface LoadingErrorBoundaryProps {
5
5
  children: React.ReactNode;
6
6
  }
@@ -0,0 +1,17 @@
1
+ import { ActionDidNotRevalidate, ActionDidRevalidateDynamicOnly, ActionDidRevalidateStaticAndDynamic, ActionRevalidationKind } from "./action-revalidation-kind.mjs";
2
+
3
+ //#region src/runtime/actions/flight-refresh.d.ts
4
+ interface ActionFlightRefreshDetail {
5
+ element: unknown;
6
+ revalidationKind: ActionRevalidationKind;
7
+ revalidatedPath?: string;
8
+ }
9
+ /** Flight action response: `a` is the action result, `f` is the optional refresh tree. */
10
+ interface ActionFlightResponseShape {
11
+ a?: unknown;
12
+ f?: unknown;
13
+ }
14
+ declare function scheduleActionFlightRefresh(response: Response, flightResponse: ActionFlightResponseShape, actionResult: unknown): void;
15
+ declare function refreshRouter(): void;
16
+ //#endregion
17
+ export { ActionDidNotRevalidate, ActionDidRevalidateDynamicOnly, ActionDidRevalidateStaticAndDynamic, ActionFlightRefreshDetail, ActionFlightResponseShape, refreshRouter, scheduleActionFlightRefresh };
@@ -0,0 +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};
@@ -0,0 +1,8 @@
1
+ //#region src/runtime/actions/revalidation-kind.d.ts
2
+ type ActionRevalidationKind = 0 | 1 | 2;
3
+ declare const ActionDidNotRevalidate: 0;
4
+ declare const ActionDidRevalidateStaticAndDynamic: 1;
5
+ declare const ActionDidRevalidateDynamicOnly: 2;
6
+ declare function parseActionRevalidationKind(header: string | null): ActionRevalidationKind;
7
+ //#endregion
8
+ export { ActionDidNotRevalidate, ActionDidRevalidateDynamicOnly, ActionDidRevalidateStaticAndDynamic, ActionRevalidationKind, parseActionRevalidationKind };
@@ -0,0 +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};
@@ -0,0 +1,4 @@
1
+ //#region src/runtime/actions/call-server.d.ts
2
+ declare function callServer(id: string, args: unknown[]): Promise<unknown>;
3
+ //#endregion
4
+ export { callServer };
@@ -0,0 +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,5 +1,5 @@
1
- import{n as e,r as t,t as n}from"../get-client-component-B4Y2T40R.mjs";import{t as r}from"../preload-modules-xvnJ_8eh.mjs";import*as i from"react";import"react";import{ClientRouter as a}from"rari/client";import{RouterProvider as o}from"rari/router";import{createRoot as s}from"react-dom/client";import{AppRouterProvider as c}from"virtual:app-router-provider";import{createFromReadableStream as l}from"virtual:react-flight-client";import"virtual:rsc-integration.ts";const u=/^\$L?[0-9a-f]+$/i;function d(e,t){let n=e.get(t);if(n)return n;let r=t.startsWith(`$L`)?`$${t.slice(2)}`:`$L${t.slice(1)}`;return e.get(r)}function f(){return globalThis[`~rari`]}function p(){return globalThis}function m(){return window}f()===void 0&&(globalThis[`~rari`]={}),f().AppRouterProvider=c,f().ClientRouter=a,f().getClientComponent=n;async function h(t){try{await e(t)}catch(e){console.error(`[rari] Failed to preload component ${t}:`,e)}}
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)}}
2
2
  /*! @preserve CLIENT_COMPONENT_IMPORTS_PLACEHOLDER */
3
- f().preloadClientComponent=h,p()[`~clientComponents`]===void 0&&(globalThis[`~clientComponents`]={}),p()[`~clientComponentPaths`]===void 0&&(globalThis[`~clientComponentPaths`]={});
3
+ Y.preloadClientComponent=X,o(),i();
4
4
  /*! @preserve CLIENT_COMPONENT_REGISTRATIONS_PLACEHOLDER */
5
- function g(){f().hydrateClientComponents||(f().hydrateClientComponents=function(e,n,r){let a=m()[`~rari`].boundaryModules||new Map;function o(e){if(!e)return null;if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return e;if(Array.isArray(e)){if(e.length>=4&&e[0]===`$`){let[,n,r,s]=e,c=s?{...s}:{};if(s?.children&&(c.children=o(s.children)),c[`~boundaryId`]&&delete c[`~boundaryId`],typeof n==`string`){if(n.startsWith(`$`)&&u.test(n)){let e=d(a,n);if(e){let n=`${e.id}#${e.name||`default`}`,a=n.replace(/\\/g,`/`),o=e.id.replace(/\\/g,`/`),s=null,l=!e.name||e.name==="default",u=p()[`~clientComponents`][a]||p()[`~clientComponents`][n]||l&&(p()[`~clientComponents`][o]||p()[`~clientComponents`][e.id]);return u&&(u.component?s=t(u,e.name):u.loader&&!u.loading&&(u.loading=!0,u.loadPromise=u.loader().then(e=>(u.component=e,u.registered=!0,u.loading=!1,e)).catch(t=>{throw u.loading=!1,u.loadPromise=void 0,console.error(`[rari] Failed to load component ${e.id}:`,t),t})),u.loadPromise&&!u.component)?i.createElement(i.Suspense,{fallback:null},i.createElement(b,{key:r,componentInfo:u,exportName:e.name,childProps:c})):s?i.createElement(s,r?{...c,key:r}:c):c.children||null}return c.children||null}return i.createElement(n,r?{...c,key:r}:c)}return null}return e.map((e,t)=>{let n=null;if(Array.isArray(e)&&e.length>=4&&e[0]===`$`){let t=e[2];(typeof t==`string`||typeof t==`number`)&&(n=String(t))}n||=`rsc-${t}-${typeof e==`string`?e:JSON.stringify(e).slice(0,20)}`;let r=o(e);return i.isValidElement(r)&&!r.key?i.createElement(i.Fragment,{key:n},r):r})}return e}try{let e=o(n);e&&(s(r).render(e),r.classList.add(`rari-boundary-hydrated`))}catch(e){console.error(`[rari] Failed to hydrate client components:`,e),console.error(`[rari] Error stack:`,e.stack)}})}function _(){let e=m()[`~rari`].pendingBoundaryHydrations;if(!(!e||e.size===0)){for(let[t,n]of e.entries())f().hydrateClientComponents&&f().hydrateClientComponents(t,n.content,n.element);e.clear()}}g();async function v(t){let n=[];for(let r of t){let t=e(r).catch(e=>{console.error(`[rari] Failed to preload component ${r}:`,e)});n.push(t)}n.length>0&&await Promise.all(n)}async function y(){let e=document.getElementById(`root`);if(!e){console.error(`[rari] Root element not found`);return}let t=document.getElementById(`__RARI_RSC_PAYLOAD__`),u=e.children.length>0,d=m()[`~rari`]?.streaming?.bufferedRows&&m()[`~rari`].streaming.bufferedRows.length>0;if(g(),u&&!t&&!d){let e=document.querySelectorAll(`[data-client-component]`);if(e.length>0){let t=new Set;e.forEach(e=>{let n=e.getAttribute(`data-client-component`);n&&t.add(n)}),await v(t),e.forEach(e=>{let t=e.getAttribute(`data-client-component`),r=e.getAttribute(`data-props`);if(t)try{let a=n(t);if(!a)return;let o=r?JSON.parse(r):{};requestAnimationFrame(()=>{try{document.contains(e)&&(e.replaceChildren(),s(e).render(i.createElement(a,o)))}catch(e){console.error(`[rari] Failed to hydrate client component ${t}:`,e)}})}catch(e){console.error(`[rari] Failed to hydrate client component ${t}:`,e)}})}return}if(u&&d&&!t&&document.querySelectorAll(`[data-boundary-id]`).length>0){m()[`~rari`].pendingBoundaryHydrations&&m()[`~rari`].pendingBoundaryHydrations.size>0&&_();return}try{let n;if(!t&&!d&&!u)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,r=await fetch(t,{headers:{Accept:`text/x-component`},cache:`no-store`});if(!r.ok&&r.status!==404)throw Error(`Failed to fetch RSC data: ${r.status}`);if(!r.body)throw Error(`RSC response has no body`);n=await l(r.body)}catch(e){if(e instanceof Promise)throw e;if(console.error(`[rari] Failed to fetch initial RSC data:`,e),e instanceof Error)console.error(`[rari] Error name:`,e.name),console.error(`[rari] Error message:`,e.message),e.stack&&console.error(`[rari] Error stack:`,e.stack);else if(typeof e==`string`)console.error(`[rari] Error details:`,e);else if(e&&typeof e==`object`)try{let t={};for(let n of Object.getOwnPropertyNames(e))t[n]=e[n];console.error(`[rari] Error details:`,JSON.stringify(t,null,2))}catch{console.error(`[rari] Error details:`,String(e))}else console.error(`[rari] Error details:`,String(e));n=null}else if(t&&t.textContent)try{let e=t.textContent;await r(e);let i=m()[`~rari`]?.streaming?.bufferedRows&&m()[`~rari`].streaming.bufferedRows.length>0;n=m()[`~rari`]?.streaming?.complete===void 0||i?await l(new ReadableStream({start(t){t.enqueue(new TextEncoder().encode(e));let n=e=>{let n=e;n.detail?.rscRow&&t.enqueue(new TextEncoder().encode(`\n${n.detail.rscRow}`))},r=()=>{t.close(),window.removeEventListener(`rari:html-stream-row`,n),window.removeEventListener(`rari:stream-complete`,r)};if(window.addEventListener(`rari:html-stream-row`,n),window.addEventListener(`rari:stream-complete`,r),m()[`~rari`]?.streaming?.bufferedRows){let e=[...m()[`~rari`].streaming.bufferedRows];for(let n of e)t.enqueue(new TextEncoder().encode(`\n${n}`));m()[`~rari`].streaming.bufferedRows=[]}m()[`~rari`]?.streaming?.complete&&r()}})):await l(new ReadableStream({start(t){t.enqueue(new TextEncoder().encode(e)),t.close()}}))}catch(e){console.error(`[rari] Failed to parse embedded RSC payload:`,e),console.error(`[rari] Error stack:`,e instanceof Error?e.stack:`no stack`),n=null}else if(d)try{n=await l(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)};if(window.addEventListener(`rari:html-stream-row`,t),window.addEventListener(`rari:stream-complete`,n),m()[`~rari`]?.streaming?.bufferedRows){let t=[...m()[`~rari`].streaming.bufferedRows];m()[`~rari`].streaming.bufferedRows=[];for(let n of t)e.enqueue(new TextEncoder().encode(`${n}\n`))}m()[`~rari`]?.streaming?.complete&&n()}}))}catch(e){console.error(`[rari] Failed to process streaming RSC payload:`,e),n=null}if(!n)throw Error(`No RSC data available for hydration`);let f;f=n;let p;p=i.createElement(c,{initialPayload:{element:n}},f),p=i.createElement(a,{initialRoute:window.location.pathname,children:p}),p=i.createElement(o,{initialPathname:window.location.pathname,children:p}),s(e).render(p)}catch(e){console.error(`[rari] Error rendering app:`,e)}}function b({componentInfo:e,exportName:n,childProps:r}){if(!e.loadPromise)return null;if(i.use(e.loadPromise),e.component){let a=t(e,n);return a?i.createElement(a,r):null}return null}import.meta.hot&&import.meta.hot.data.hasRendered||(y().catch(e=>{console.error(`[rari] Fatal error:`,e)}),import.meta.hot&&(import.meta.hot.data.hasRendered=!0));export{h as preloadClientComponent,y as renderApp};
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};
@@ -0,0 +1,34 @@
1
+ import { FlightRouterState, SegmentPath, pathnameFromSegmentPath } from "./flight-router-state.mjs";
2
+ import { ReactNode } from "react";
3
+
4
+ //#region src/runtime/flight/route-cache.d.ts
5
+ interface CacheNode {
6
+ rsc: ReactNode;
7
+ slots: Record<string, CacheNode> | null;
8
+ }
9
+ interface FlightRouteCacheEntry {
10
+ pathname: string;
11
+ search: string;
12
+ segmentPath: SegmentPath;
13
+ node: CacheNode;
14
+ }
15
+ declare class FlightRouteCache {
16
+ private root;
17
+ private renderedSearch;
18
+ get(pathname: string, search: string): FlightRouteCacheEntry | undefined;
19
+ getElement(pathname: string, search: string): ReactNode | undefined;
20
+ set(pathname: string, search: string, element: ReactNode): void;
21
+ invalidate(pathname: string, search?: string): void;
22
+ invalidateSegmentPath(segmentPath: SegmentPath): void;
23
+ getRenderedSearch(): string;
24
+ getRouterTree(pathname: string): FlightRouterState;
25
+ clear(): void;
26
+ }
27
+ declare const flightRouteCache: FlightRouteCache;
28
+ declare function currentRouteLocation(): {
29
+ pathname: string;
30
+ search: string;
31
+ };
32
+ declare function currentSegmentPath(): SegmentPath;
33
+ //#endregion
34
+ export { CacheNode, FlightRouteCache, FlightRouteCacheEntry, currentRouteLocation, currentSegmentPath, flightRouteCache, pathnameFromSegmentPath };
@@ -0,0 +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};
@@ -0,0 +1,11 @@
1
+ //#region src/runtime/flight/router-state.d.ts
2
+ type FlightRouterState = [segment: string, parallelRoutes: {
3
+ children?: FlightRouterState;
4
+ }];
5
+ type SegmentPath = string[];
6
+ declare function buildFlightRouterState(pathname: string): FlightRouterState;
7
+ declare function segmentPathFromRouterState(tree: FlightRouterState): SegmentPath;
8
+ declare function segmentPathFromPathname(pathname: string): SegmentPath;
9
+ declare function pathnameFromSegmentPath(segmentPath: SegmentPath): string;
10
+ //#endregion
11
+ export { FlightRouterState, SegmentPath, buildFlightRouterState, pathnameFromSegmentPath, segmentPathFromPathname, segmentPathFromRouterState };
@@ -0,0 +1 @@
1
+ const e=`children`;function t(e){let t=e.length;for(;t>1&&e[t-1]===`/`;)--t;return e.slice(0,t)}function n(n){let r=n===`/`||n===``?`/`:t(n)||`/`,i=r===`/`?[]:r.slice(1).split(`/`).filter(Boolean),a=[``,{}];for(let t=i.length-1;t>=0;--t)a=[i[t],{[e]:a}];return[``,{[e]:a}]}function r(e){let t=[],n=e;for(;n;){let e=n[0],r=n[1];e&&t.push(e),n=r.children}return t}function i(e){return r(n(e))}function a(e){return e.length===0?`/`:`/${e.join(`/`)}`}export{n as buildFlightRouterState,a as pathnameFromSegmentPath,i as segmentPathFromPathname,r as segmentPathFromRouterState};
@@ -0,0 +1,6 @@
1
+ import * as React from "react";
2
+
3
+ //#region src/runtime/flight/merge-refresh.d.ts
4
+ declare function mergeFlightRefresh(current: React.ReactNode, refresh: React.ReactNode): React.ReactNode;
5
+ //#endregion
6
+ export { mergeFlightRefresh };
@@ -0,0 +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,40 +1 @@
1
- import { r as ModuleData } from "../types-zPQ3RHgH.mjs";
2
-
3
- //#region src/runtime/rsc-client-runtime.d.ts
4
- declare function registerClientComponent(componentFunction: any, id: string, exportName: string): void;
5
- declare function getClientComponent(id: string): any;
6
- declare function createClientModuleMap(): Record<string, any>;
7
- declare class RscClient {
8
- componentCache: Map<string, any>;
9
- moduleCache: Map<string, any>;
10
- inflightRequests: Map<string, Promise<any>>;
11
- config: {
12
- maxRetries: number;
13
- retryDelay: number;
14
- timeout: number;
15
- };
16
- constructor();
17
- configure(config: Partial<RscClient['config']>): void;
18
- clearCache(): void;
19
- fetchServerComponent(componentId: string, props?: any): Promise<any>;
20
- fetchServerComponentStream(componentId: string, props?: any): Promise<any>;
21
- buildRequestHeaders(): Record<string, string>;
22
- fetchWithTimeout(url: string, options: RequestInit): Promise<Response>;
23
- processRscResponse(response: Response): Promise<any>;
24
- processRscResponseManually(response: Response): Promise<any>;
25
- parseRscResponse(rscPayload: string): any;
26
- reconstructElementFromRscData(elementData: any, modules: Map<string, ModuleData>, symbols?: Map<string, string>): any;
27
- processPropsRecursively(props: any, modules: Map<string, ModuleData>, symbols?: Map<string, string>): any;
28
- }
29
- declare const rscClient: RscClient;
30
- declare function RscErrorComponent({
31
- error,
32
- details
33
- }: {
34
- error: string;
35
- details?: any;
36
- }): any;
37
- declare function createServerComponentWrapper(componentName: string): (props: any) => any;
38
- declare function fetchServerComponent(componentId: string, props: any): Promise<any>;
39
- //#endregion
40
- export { RscErrorComponent, createClientModuleMap, createServerComponentWrapper, fetchServerComponent, getClientComponent, registerClientComponent, rscClient };
1
+ export { };
@@ -1,2 +1 @@
1
- import{d as e,f as t,h as n,l as r,n as i,p as a,s as o,u as s}from"../regex-constants-DQ2vkSU5.mjs";import{t as c}from"../get-client-component-B4Y2T40R.mjs";import{t as l}from"../suspense-CsIYuC_l.mjs";import{createFromFetch as u,createFromReadableStream as d}from"./vendor/react-flight-client/index.mjs";import*as f from"react";import{Suspense as p,cloneElement as m,createElement as h,isValidElement as g,use as _,useEffect as v,useState as y}from"react";import*as b from"react-dom/client";const x=new Set(`div,span,p,ul,ol,li,a,img,section,article,header,footer,nav,main,aside,strong,em,b,i,button,input,label,form,select,option,textarea,h1,h2,h3,h4,h5,h6,table,thead,tbody,tr,td,th,code,pre,blockquote,hr,br,small,mark,del,ins,sub,sup,abbr,time,figure,figcaption,details,summary,dialog,menu,menuitem,canvas,svg,path,circle,rect,line,polygon,polyline,ellipse,text,g,defs,use,symbol,clippath,mask,pattern,lineargradient,radialgradient,stop,image,video,audio,source,track,picture,dl,dt,dd,fieldset,legend`.split(`,`)),S=({children:e})=>e??null;function C(){return import.meta.env?.RARI_SERVER_URL?import.meta.env.RARI_SERVER_URL:typeof window<`u`?window.location.origin:`http://localhost:3000`}globalThis[`~rari`]===void 0&&(globalThis[`~rari`]={}),globalThis[`~rari`].isDevelopment=process.env.NODE_ENV!==`production`,globalThis[`~clientComponents`]===void 0&&(globalThis[`~clientComponents`]={}),globalThis[`~clientComponentNames`]===void 0&&(globalThis[`~clientComponentNames`]={}),globalThis[`~clientComponentPaths`]===void 0&&(globalThis[`~clientComponentPaths`]={}),typeof window<`u`&&(window[`~rari`]||(window[`~rari`]=globalThis[`~rari`]),window[`~rari`].streaming||(window[`~rari`].streaming={bufferedRows:[],bufferedEvents:[]}),window[`~rari`].streaming.bufferedEvents||(window[`~rari`].streaming.bufferedEvents=[]),window[`~rari`].boundaryModules||(window[`~rari`].boundaryModules=new Map),window[`~rari`].pendingBoundaryHydrations||(window[`~rari`].pendingBoundaryHydrations=new Map));function w(e){if(!e.startsWith(`I{`))return null;try{let t=JSON.parse(e.substring(1));if(typeof t==`object`&&t&&!Array.isArray(t)){if(typeof t.id!=`string`)return console.error(`[rari] Invalid import data: id must be a string:`,t),null;let e;if(typeof t.chunks==`string`)e=[t.chunks];else if(Array.isArray(t.chunks))e=t.chunks.filter(e=>typeof e==`string`);else return console.error(`[rari] Invalid import data: chunks must be a string or array:`,t),null;return e.length===0?(console.error(`[rari] Invalid import data: chunks array is empty:`,t),null):{id:t.id,chunks:e,name:t.name||`default`}}console.error(`[rari] Invalid import data format, expected object:`,t)}catch(t){console.error(`[rari] Failed to parse import row:`,e,t)}return null}if(typeof window<`u`){globalThis[`~rari`].processBoundaryUpdate=function(n,o,c){let l=document.querySelector(`[data-boundary-id="${n}"]`);if(l)try{let u=o.indexOf(`:`);if(u===-1){console.warn(`[rari] Invalid RSC row format (no colon):`,o);return}let d=o.substring(0,u),f=o.substring(u+1),p=w(f);if(p){let e=`$L${d}`;window[`~rari`].boundaryModules?.set(e,p);return}let m;try{m=JSON.parse(f)}catch(e){console.error(`[rari] Failed to parse RSC content:`,f,e);return}function h(e){if(!e)return!1;if(typeof e==`string`)return e.startsWith(`$L`);if(Array.isArray(e)){if(e.length>=4&&e[0]===`$`){let[,t]=e;if(typeof t==`string`&&t.startsWith(`$L`))return!0;let n=e[3];if(n&&n.children)return h(n.children)}return e.some(e=>h(e))}return!1}if(h(m)){if(window[`~rari`].pendingBoundaryHydrations?.set(n,{content:m,element:l,rowId:c}),globalThis[`~rari`].hydrateClientComponents){let e=globalThis[`~rari`].hydrateClientComponents;e(n,m,l)}return}function g(n){let o=n=>n.replace(r,`&amp;`).replace(t,`&lt;`).replace(e,`&gt;`).replace(a,`&quot;`).replace(s,`&#39;`);if(!n)return``;if(typeof n==`string`||typeof n==`number`)return o(String(n));if(Array.isArray(n)){if(n.length>=4&&n[0]===`$`){let[,e,,t]=n,r=typeof e==`string`&&x.has(e.toLowerCase())?e.toLowerCase():`div`,a=null,s=``,c=``;if(t){for(let[e,n]of Object.entries(t))if(e===`dangerouslySetInnerHTML`&&n&&typeof n==`object`&&`__html`in n)a=n.__html;else if(e!==`children`&&e!==`~boundaryId`){let t=e===`className`?`class`:e;if(e===`style`&&typeof n==`object`&&n){let e=Object.entries(n).map(([e,t])=>`${e.replace(i,`$1-$2`).toLowerCase()}:${String(t)}`).join(`;`);c+=` style="${o(e)}"`}else typeof n==`string`||typeof n==`number`?c+=` ${t}="${o(String(n))}"`:typeof n==`boolean`&&n&&(c+=` ${t}`)}a===null&&t.children&&(s=g(t.children))}return`<${r}${c}>${a===null?s:a}</${r}>`}return n.map(g).join(``)}return``}let _=g(m);if(_){let e=document.contains(l);e&&(l.innerHTML=_,l.classList.add(`rari-boundary-resolved`)),window.dispatchEvent(new CustomEvent(`rari:boundary-resolved`,{detail:{boundaryId:n,rscRow:o,rowId:c,element:l,wasAttached:e}}))}}catch(e){console.error(`[rari] Error processing boundary update:`,e)}};let n=window,o=globalThis;n[`~rari`].streaming?.bufferedEvents&&n[`~rari`].streaming.bufferedEvents.length>0&&(n[`~rari`].streaming.bufferedEvents.forEach(e=>{let{boundaryId:t,rscRow:n,rowId:r}=e;o[`~rari`].processBoundaryUpdate?.(t,n,r)}),n[`~rari`].streaming.bufferedEvents=[]),window.addEventListener(`rari:boundary-update`,e=>{let{boundaryId:t,rscRow:n,rowId:r}=e.detail;o[`~rari`].processBoundaryUpdate&&o[`~rari`].processBoundaryUpdate(t,n,r)})}function T(e,t,n){let r=n==="default"?e.name||t.split(`/`).pop()?.replace(o,``)||`DefaultComponent`:n,i=r,a={id:i,path:t,type:`client`,component:e,registered:!0};globalThis[`~clientComponents`]===void 0&&(globalThis[`~clientComponents`]={});let s=`${t}#${n}`;globalThis[`~clientComponents`][i]=a,globalThis[`~clientComponents`][t]=a,globalThis[`~clientComponents`][s]=a,globalThis[`~clientComponentPaths`][t]=i,globalThis[`~clientComponentNames`][r]=i,e&&(e[`~isClientComponent`]=!0,e[`~clientComponentId`]=i),typeof window<`u`&&fetch(`/_rari/register-client`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({component_id:i,file_path:t,export_name:n})}).catch(e=>{console.error(`[rari] Failed to register client component with server:`,e)})}function E(e){return c(e)}function D(){let e={};for(let[t,n]of Object.entries(globalThis[`~clientComponents`]))e[t]={id:t,chunks:[n.path],name:t,async:!1,default:n.component};return e}let O=u,k=d,A=null;async function j(){return A||(A=(async()=>{try{return O=u,k=d,typeof k!=`function`&&(k=null),typeof O!=`function`&&(O=null),b}catch(e){return console.error(`Failed to load react-dom/client RSC functions:`,e),O=null,k=null,null}})(),A)}const M=new Map,N=new class{componentCache;moduleCache;inflightRequests;config;constructor(){this.componentCache=new Map,this.moduleCache=new Map,this.inflightRequests=new Map,this.config={maxRetries:5,retryDelay:500,timeout:1e4}}configure(e){this.config={...this.config,...e}}clearCache(){this.componentCache.clear(),this.moduleCache.clear(),M.clear()}async fetchServerComponent(e,t={}){let n=typeof window<`u`&&window[`~rari`]?.hmr?.refreshCounters?.[e]||0,r=`${e}:${JSON.stringify(t)}:hmr:${n}`;if(this.componentCache.has(r))return this.componentCache.get(r);if(this.inflightRequests.has(r))return this.inflightRequests.get(r);let i=this.fetchServerComponentStream(e,t);this.inflightRequests.set(r,i);try{let e=await i;return this.componentCache.set(r,e),e}finally{this.inflightRequests.delete(r)}}async fetchServerComponentStream(e,t={}){await j();let n=(()=>{let e=[`/_rari/stream`];try{if(typeof window<`u`&&(window.location.hostname===`localhost`||window.location.hostname===`127.0.0.1`)){let t=C();t&&e.push(`${t}/_rari/stream`)}}catch{}return e})(),r=null,i=null,a=async()=>{for(let r of n)try{let n=await this.fetchWithTimeout(r,{method:`POST`,headers:{"Content-Type":`application/json`,...this.buildRequestHeaders()},body:JSON.stringify({component_id:e,props:t})});if(n.ok)return n;i=Error(`HTTP ${n.status}: ${await n.text()}`)}catch(e){i=e}return null};if(r=await a(),r||=(await new Promise(e=>setTimeout(e,this.config.retryDelay)),await a()),!r)throw i||Error(`Failed to reach stream endpoint`);if(!r.ok){let e=await r.text();throw Error(`Server responded with ${r.status}: ${e}`)}let o=r.body;if(!o)throw Error(`No ReadableStream from stream response`);let s=o.getReader(),c=new TextDecoder,u=new Map,d=new Map,f=e=>{if(!h)return console.error(`React not available for RSC conversion`),null;if(!e)return null;if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return e;if(Array.isArray(e)){if(e.length>=4&&e[0]===`$`){let[,t,n,r]=e;if(l(t))return h(p,{fallback:r?.fallback?f(r.fallback):null},r?.children?f(r.children):null);let i=r?{...r}:{};if(r?.children){let e=f(r.children);Array.isArray(e)?i.children=e.map((e,t)=>g(e)&&e.key==null?m(e,{key:t}):e):i.children=e}if(typeof t==`string`){if(t.startsWith(`$L`)){let e=u.get(t);if(e){let t=E(`${e.id}#${e.name||`default`}`);if(t)return h(t,n?{...i,key:n}:i)}return i&&i.children?i.children:null}if(t.includes(`.tsx#`)||t.includes(`.jsx#`)){let e=E(t);return e?h(e,n?{...i,key:n}:i):(console.error(`Failed to resolve client component:`,t),null)}else return i&&Object.hasOwn(i,`~boundaryId`)&&(i={...i},delete i[`~boundaryId`]),h(t,n?{...i,key:n}:i)}else console.error(`Unknown RSC element type:`,t)}return e.map(e=>f(e))}return typeof e==`object`?(console.error(`Unexpected object in RSC conversion:`,e),null):e},_=null,b=new Map,x=``,S=null,T=async()=>{try{for(;;){let{value:e,done:t}=await s.read();if(t)break;let n=c.decode(e,{stream:!0});x+=n;let r=x.split(`
2
- `),i=r.slice(0,-1);x=r.at(-1)||``;for(let e of i)if(e.trim())try{let t=e.indexOf(`:`);if(t===-1)continue;let n=e.substring(0,t),r=e.substring(t+1),i=w(r);if(i)u.set(`$L${n}`,i);else if(r.startsWith(`E{`))try{let e=JSON.parse(r.substring(1)),t=e?.error??e?.message??JSON.stringify(e);console.error(`RSC stream error:`,t)}catch(e){console.error(`Failed to parse error row:`,r,e)}else if(r.startsWith(`Symbol.for(`))continue;else if(r.startsWith(`[`)){let e=JSON.parse(r);if(Array.isArray(e)&&e.length>=4){let[t,r,i]=e,a=i?.[`~boundaryId`];if(t===`$`&&l(r)&&i&&a&&d.set(`$L${n}`,a),t===`$`&&i&&Object.hasOwn(i,`children`)&&typeof r==`string`&&r.startsWith(`$L`)){let e=d.get(r)||null;if(e){let t=f(i.children);b.set(e,t),S&&S.updateBoundary(e,t);continue}}}if(!_){let t=!0;if(Array.isArray(e)&&e.length>=4&&e[0]===`$`){let n=e[1],r=e[3],i=r?.[`~boundaryId`];typeof n==`string`&&l(n)&&r&&i&&(t=!1)}t&&(_=f(e),S&&typeof S.updateRoot==`function`&&S.updateRoot())}}}catch(t){console.error(`Failed to parse stream line:`,e,t)}}}catch(e){console.error(`Error processing stream:`,e)}},D=()=>{let[,e]=y(0);v(()=>(S={updateBoundary:(t,n)=>{b.set(t,n),e(e=>e+1)},updateRoot:()=>{e(e=>e+1)}},()=>{S=null}),[e]);let t=e=>{if(!e)return null;if(g(e)){let n=e.props,r=n?.[`~boundaryId`];if(n&&r){let e=b.get(r);if(e)return e}if(n&&n.children){let r=t(n.children);if(r!==n.children){let t={...n};return e.key!==null&&e.key!==void 0&&(t.key=e.key),h(e.type,t,r)}}return e}return Array.isArray(e)?e.map(e=>t(e)):e};return t(_)};T();let O=Promise.resolve(h(D));return{"~isRscResponse":!0,"~rscPromise":O,readRoot(){return O}}}buildRequestHeaders(){return{Accept:`text/x-component`,"Cache-Control":`no-cache, no-transform`}}async fetchWithTimeout(e,t){let n=new AbortController,r=setTimeout(()=>n.abort(),this.config.timeout);try{let i=await fetch(e,{...t,signal:n.signal});return clearTimeout(r),i}catch(e){throw clearTimeout(r),e}}async processRscResponse(e){if(await j(),O)try{let t=O(Promise.resolve(e));return{"~isRscResponse":!0,"~rscPromise":t,readRoot(){return t}}}catch{throw Error(`React Server DOM client not available`)}else throw Error(`React Server DOM client not available`)}async processRscResponseManually(e){let t=await e.text();return this.parseRscResponse(t)}parseRscResponse(e){let t=e.trim().split(n),r=new Map,i=new Map,a=new Map,o=[];for(let e of t){let t=e.indexOf(`:`);if(t===-1)continue;let n=e.substring(0,t),s=e.substring(t+1);if(s)try{let t=w(s);if(t)r.set(`$L${n}`,t);else if(s.startsWith(`E{`)){let e=s.substring(1),t=JSON.parse(e),n=t?.error??t?.message??JSON.stringify(t);o.push(n),console.error(`RSC: Server error`,n)}else if(s.startsWith(`[`)){let e=JSON.parse(s);i.set(n,e)}else if(s.startsWith(`Symbol.for(`))continue;else if(s.startsWith(`"$S`)){let e=JSON.parse(s);typeof e==`string`&&a.set(`$${n}`,e)}else console.error(`Unknown RSC row format:`,e)}catch(t){console.error(`Failed to parse RSC row:`,e,t)}}if(o.length>0)throw Error(`RSC Server Error: ${o.map(e=>e?.error??e?.message??e).join(`, `)}`);let s=null,c=Array.from(i.keys()).sort((e,t)=>Number.parseInt(e,16)-Number.parseInt(t,16));for(let e of c){let t=i.get(e);if(Array.isArray(t)&&t.length>=2&&t[0]===`$`){let[,e,,n]=t,r=n?.[`~boundaryId`],i=typeof e==`string`&&e.startsWith(`$`)?a.get(e):void 0;if((l(e)||l(i))&&n&&r)continue;s=t;break}}return s?this.reconstructElementFromRscData(s,r,a):(console.error(`No valid root element found in RSC payload`,{elements:i,modules:r}),null)}reconstructElementFromRscData(e,t,n){if(e==null)return null;if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return e;if(Array.isArray(e))if(e.length>=4&&e[0]===`$`){let[,r,i,a]=e,o=r;if(typeof r==`string`&&r.includes(`#`)){let e=E(r);e?o=e:(process.env.NODE_ENV!==`production`&&console.warn(`[rari] Missing client component: ${r}`),o=S)}else if(typeof r==`string`&&r.startsWith(`$L`)&&t.has(r)){let e=t.get(r);if(e){let t=E(`${e.id}#${e.name}`);t?o=t:(process.env.NODE_ENV!==`production`&&console.warn(`[rari] Missing client component: ${e.name} (${e.id})`),o=S)}}let s=a?this.processPropsRecursively(a,t,n):{},c=typeof r==`string`&&r.startsWith(`$`)&&!r.startsWith(`$L`)?n?.get(r):void 0;return(l(r)||l(c))&&(o=p),h(o,{key:i,...s})}else return e.map(e=>this.reconstructElementFromRscData(e,t,n));return typeof e==`object`?null:e}processPropsRecursively(e,t,n){if(!e||typeof e!=`object`)return e;let r={};for(let[i,a]of Object.entries(e))if(i===`children`)if(Array.isArray(a))if(a.length>=2&&a[0]===`$`)r[i]=this.reconstructElementFromRscData(a,t,n);else{let e=a.map(e=>this.reconstructElementFromRscData(e,t,n)).filter(e=>e!=null);e.length===0?r[i]=null:e.length===1?r[i]=e[0]:r[i]=e}else r[i]=this.reconstructElementFromRscData(a,t,n);else i===`dangerouslySetInnerHTML`?r[i]=a:r[i]=this.reconstructElementFromRscData(a,t,n);return r}};function P({error:e,details:t}){return process.env.NODE_ENV===`production`?null:h(`div`,{"data-rsc-error":``},h(`p`,null,e),t&&h(`pre`,null,JSON.stringify(t,null,2)))}function F({rootPromise:e}){return _(e)}function I({componentId:e,props:t,fallback:n}){let r=typeof window<`u`&&window[`~rari`]?.hmr?.refreshCounters?.[e]||0,i=`${e}:${JSON.stringify(t)}:hmr:${r}`;if(!M.has(i)){let n=N.fetchServerComponent(e,t).catch(e=>{throw M.delete(i),e});M.set(i,n)}let a=_(M.get(i));if(a?.[`~isRscResponse`]){let e=a.readRoot();return h(p,{fallback:n??null},h(F,{rootPromise:e}))}return a??null}var L=class extends f.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidUpdate(e){e.mountKey!==this.props.mountKey&&this.state.hasError&&this.setState({hasError:!1,error:null})}componentDidCatch(e,t){console.error(`[rari] ServerComponentErrorBoundary: Error in component ${this.props.componentId}:`,e,t)}render(){return this.state.hasError?h(P,{error:this.state.error?.message||`Unknown error`,details:{componentId:this.props.componentId}}):this.props.children}};function R(e){let t=0;if(typeof window<`u`){let n=window;n[`~rari`].hmr||(n[`~rari`].hmr={refreshCounters:{}}),n[`~rari`].hmr.refreshCounters[e]===void 0&&(n[`~rari`].hmr.refreshCounters[e]=0),t=n[`~rari`].hmr.refreshCounters[e]}let n=n=>{let[r,i]=y(t);return v(()=>{let t=t=>{let n=t.detail;if(n&&n.filePath&&B(n.filePath)&&(N.clearCache(),typeof window<`u`)){let t=window;t[`~rari`].hmr||(t[`~rari`].hmr={refreshCounters:{}}),t[`~rari`].hmr.refreshCounters[e]=(t[`~rari`].hmr.refreshCounters[e]||0)+1,i(t[`~rari`].hmr.refreshCounters[e])}};return typeof window<`u`&&window.addEventListener(`rari:rsc-invalidate`,t),()=>{typeof window<`u`&&window.removeEventListener(`rari:rsc-invalidate`,t)}},[]),h(p,{fallback:null},h(L,{componentId:e,mountKey:r},h(I,{key:`${e}-${r}`,componentId:e,props:n,fallback:null})))};return n.displayName=`ServerComponent(${e})`,function(e){return h(n,e)}}function z(e,t){return N.fetchServerComponent(e,t)}function B(e){if(!e)return!1;try{return typeof globalThis<`u`&&globalThis[`~rari`].serverComponents?globalThis[`~rari`].serverComponents.has(e):!1}catch(e){return console.error(`Error checking if file is server component:`,e),!1}}if(import.meta.hot){let e=!1,t=[],n=new Map;function r(r,i){n.set(r,i),import.meta.hot.on(r,async n=>{if(!e){t.push({event:r,data:n});return}try{await i(n)}catch(e){console.error(`[rari] HMR: Error in handler for '${r}':`,e)}})}r(`rari:register-server-component`,e=>{e?.filePath&&typeof globalThis<`u`&&(globalThis[`~rari`].serverComponents=globalThis[`~rari`].serverComponents||new Set,globalThis[`~rari`].serverComponents.add(e.filePath))}),r(`rari:server-components-registry`,e=>{e?.serverComponents&&Array.isArray(e.serverComponents)&&typeof globalThis<`u`&&(globalThis[`~rari`].serverComponents=globalThis[`~rari`].serverComponents||new Set,e.serverComponents.forEach(e=>{globalThis[`~rari`].serverComponents?.add(e)}))}),r(`vite:beforeFullReload`,async e=>{e?.path&&B(e.path)&&await u({filePath:e.path,forceReload:!0})}),r(`rari:server-component-updated`,async e=>{let t=e?.id||e?.componentId,n=e?.t||e?.timestamp;if(t){if(typeof window<`u`){let r=new CustomEvent(`rari:rsc-invalidate`,{detail:{componentId:t,filePath:e.filePath||e.file,type:`server-component`,timestamp:n}});window.dispatchEvent(r)}}else e?.path&&B(e.path)&&await u({filePath:e.path,forceReload:!1})}),r(`rari:app-router-updated`,async e=>{try{if(!e||!e.routePath&&(!e.affectedRoutes||e.affectedRoutes.length===0))return;await i(e)}catch(e){console.error(`[rari] HMR: App router update failed:`,e)}}),r(`rari:server-action-updated`,async e=>{if(e?.filePath&&(N.clearCache(),typeof window<`u`)){let t=new CustomEvent(`rari:rsc-invalidate`,{detail:{filePath:e.filePath,type:`server-action`}});window.dispatchEvent(t)}});async function i(e){let t=e.fileType,n=e.filePath,r=e.routePath,i=e.affectedRoutes,o=e.manifestUpdated,u=e.metadata;e.metadataChanged&&u&&a(u);try{let e=`${C()}/_rari/hmr`,t=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`register`,file_path:n})});if(!t.ok){let e=await t.text(),n=`Component reload failed with status ${t.status}: ${e}`;throw console.error(`[rari] HMR:`,n),Error(n)}let r=await t.json();if(typeof r!=`object`||!r){let e=`Invalid reload response: null or non-object`;throw console.error(`[rari] HMR:`,e,r),Error(e)}if(r.success!==!0&&r.reloaded!==!0){let e=`Component reload unsuccessful: ${r.error||`unknown error`}`;throw console.error(`[rari] HMR:`,e,r),Error(e)}}catch(e){console.error(`[rari] HMR: Failed to reload component:`,e);return}let d=[r];switch(t){case`page`:d=[r];break;case`layout`:case`template`:case`loading`:case`error`:case`not-found`:d=i;break;default:break}await s({routes:d,fileType:t,filePath:n,componentId:r}),o&&await l(),await c({routePath:r,affectedRoutes:i})}function a(e){if(!(typeof document>`u`)&&(e.title&&(document.title=e.title),e.description)){let t=document.querySelector(`meta[name="description"]`);t||(t=document.createElement(`meta`),t.setAttribute(`name`,`description`),document.head.appendChild(t)),t.setAttribute(`content`,e.description)}}function o(e){if(!e||e.length===0){N.clearCache();return}let t=[];for(let n of N.componentCache.keys())for(let r of e){if(n.includes(`route:${r}:`)||n.startsWith(`${r}:`)){t.push(n);break}if(r!==`/`&&n.includes(`route:${r}/`)){t.push(n);break}}for(let e of t)N.componentCache.delete(e),M.delete(e);let n=[];for(let t of M.keys())for(let r of e){if(t.includes(`route:${r}:`)||t.startsWith(`${r}:`)){n.push(t);break}if(r!==`/`&&t.includes(`route:${r}/`)){n.push(t);break}}for(let e of n)M.delete(e)}async function s(e){let t=e.routes||[],n=e.fileType,r=e.filePath,i=e.componentId;if(i||r)try{let e=`${C()}/_rari/hmr`,t=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`invalidate`,componentId:i||r,filePath:r})}),n=await t.text();t.ok||console.error(`[rari] HMR: Server cache invalidation failed:`,t.status,n)}catch(e){console.error(`[rari] HMR: Failed to call server invalidation endpoint:`,e)}if(o(t),typeof window<`u`){let e=new CustomEvent(`rari:rsc-invalidate`,{detail:{routes:t,fileType:n}});window.dispatchEvent(e)}}async function c(e){let t=e.routePath,n=e.affectedRoutes||[t];if(!(typeof window>`u`))try{let e=window.location.pathname,r=new CustomEvent(`rari:app-router-rerender`,{detail:{routePath:t,affectedRoutes:n,currentPath:e,preserveParams:!0}});window.dispatchEvent(r)}catch(e){throw console.error(`[rari] HMR: Failed to trigger re-render:`,e),e}}async function l(){typeof window<`u`&&window[`~rari`]?.routeInfoCache&&window[`~rari`].routeInfoCache.clear()}async function u(e){let t=e?.filePath||e;if(N.clearCache(),typeof window<`u`){let e=new CustomEvent(`rari:rsc-invalidate`,{detail:{filePath:t}});window.dispatchEvent(e)}}t.length>0?(async()=>{try{for(;t.length>0;){let e=[...t];t.length=0;for(let{event:t,data:r}of e){let e=n.get(t);if(e)try{await e(r)}catch(e){console.error(`[rari] HMR: Error replaying buffered event '${t}':`,e)}}}}catch(e){console.error(`[rari] HMR: Error during event replay:`,e)}finally{e=!0}})():e=!0}var V=class{overlay;currentError;escapeKeyHandler;constructor(){this.overlay=null,this.currentError=null,this.escapeKeyHandler=null}show(e){this.currentError=e,this.overlay?this.updateOverlay(e):this.createOverlay(e)}hide(){this.overlay&&(this.overlay.remove(),this.overlay=null,this.currentError=null),this.escapeKeyHandler&&=(document.removeEventListener(`keydown`,this.escapeKeyHandler),null)}isVisible(){return this.overlay!==null}createOverlay(e){this.overlay=document.createElement(`div`),this.overlay.id=`rari-hmr-error-overlay`,this.updateOverlay(e),document.body.appendChild(this.overlay),this.escapeKeyHandler=e=>{e.key===`Escape`&&this.hide()},document.addEventListener(`keydown`,this.escapeKeyHandler)}updateOverlay(e){if(!this.overlay)return;this.overlay.replaceChildren();let t=document.createElement(`div`);t.style.cssText=`position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.85); z-index: 999999; display: flex; align-items: center; justify-content: center; padding: 2rem; backdrop-filter: blur(4px);`;let n=document.createElement(`div`);n.style.cssText=`background: #1e1e1e; color: #e0e0e0; border-radius: 0.5rem; padding: 2rem; max-width: 50rem; width: 100%; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.4); border: 1px solid #ef4444;`;let r=document.createElement(`div`);r.style.cssText=`display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem;`;let i=document.createElement(`div`);i.style.cssText=`display: flex; align-items: center; gap: 0.75rem;`;let a=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);a.style.cssText=`width: 2rem; height: 2rem; color: #ef4444;`,a.setAttribute(`fill`,`none`),a.setAttribute(`stroke`,`currentColor`),a.setAttribute(`viewBox`,`0 0 24 24`);let o=document.createElementNS(`http://www.w3.org/2000/svg`,`path`);o.setAttribute(`stroke-linecap`,`round`),o.setAttribute(`stroke-linejoin`,`round`),o.setAttribute(`stroke-width`,`2`),o.setAttribute(`d`,`M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z`),a.appendChild(o);let s=document.createElement(`h1`);s.style.cssText=`margin: 0; font-size: 1.5rem; font-weight: 700; color: #ef4444;`,s.textContent=`Build Error`,i.appendChild(a),i.appendChild(s);let c=document.createElement(`button`);if(c.style.cssText=`background: transparent; border: none; color: #9ca3af; cursor: pointer; padding: 0.5rem; border-radius: 0.25rem; transition: all 0.2s; font-size: 1.5rem; line-height: 1; width: 2rem; height: 2rem; display: flex; align-items: center; justify-content: center;`,c.textContent=`×`,c.setAttribute(`aria-label`,`Close overlay`),c.onclick=()=>this.hide(),c.onmouseover=()=>{c.style.background=`rgba(255,255,255,0.1)`,c.style.color=`#e0e0e0`},c.onmouseout=()=>{c.style.background=`transparent`,c.style.color=`#9ca3af`},c.onfocus=()=>{c.style.background=`rgba(255,255,255,0.1)`,c.style.color=`#e0e0e0`},c.onblur=()=>{c.style.background=`transparent`,c.style.color=`#9ca3af`},r.appendChild(i),r.appendChild(c),n.appendChild(r),e.filePath){let t=document.createElement(`div`);t.style.cssText=`margin-bottom: 1rem; padding: 0.75rem; background: rgba(0, 0, 0, 0.2); border-radius: 0.375rem; font-family: monospace; font-size: 0.875rem;`;let r=document.createElement(`strong`);r.textContent=`File: `,t.appendChild(r),t.appendChild(document.createTextNode(e.filePath)),n.appendChild(t)}let l=document.createElement(`div`);l.style.cssText=`margin-bottom: 1.5rem;`;let u=document.createElement(`h2`);u.style.cssText=`margin: 0 0 0.75rem 0; font-size: 1rem; font-weight: 600; color: #fca5a5;`,u.textContent=`Error Message:`;let d=document.createElement(`pre`);if(d.style.cssText=`margin: 0; padding: 1rem; background: rgba(239, 68, 68, 0.1); border-left: 4px solid #ef4444; border-radius: 0.375rem; overflow-x: auto; font-family: monospace; font-size: 0.875rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word; color: #fca5a5;`,d.textContent=e.message??`An error occurred`,l.appendChild(u),l.appendChild(d),n.appendChild(l),e.stack){let t=document.createElement(`details`);t.style.cssText=`margin-top: 1rem; cursor: pointer;`;let r=document.createElement(`summary`);r.style.cssText=`font-weight: 600; margin-bottom: 0.5rem; user-select: none;`,r.textContent=`Stack Trace`;let i=document.createElement(`pre`);i.style.cssText=`margin: 0; padding: 0.75rem; background: rgba(0, 0, 0, 0.2); border-radius: 0.375rem; overflow-x: auto; font-size: 0.875rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word;`,i.textContent=e.stack,t.appendChild(r),t.appendChild(i),n.appendChild(t)}let f=document.createElement(`div`);f.style.cssText=`margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid #374151; display: flex; gap: 0.75rem; align-items: center;`;let p=document.createElement(`button`);p.style.cssText=`padding: 0.625rem 1.25rem; background: #ef4444; color: white; border: none; border-radius: 0.375rem; cursor: pointer; font-weight: 600; font-size: 0.875rem; transition: all 0.2s;`,p.textContent=`Reload Page`,p.onclick=()=>window.location.reload(),p.onmouseover=()=>{p.style.background=`#dc2626`},p.onmouseout=()=>{p.style.background=`#ef4444`},p.onfocus=()=>{p.style.background=`#dc2626`},p.onblur=()=>{p.style.background=`#ef4444`};let m=document.createElement(`button`);m.style.cssText=`padding: 0.625rem 1.25rem; background: #374151; color: #e0e0e0; border: none; border-radius: 0.375rem; cursor: pointer; font-weight: 600; font-size: 0.875rem; transition: all 0.2s;`,m.textContent=`Dismiss`,m.onclick=()=>this.hide(),m.onmouseover=()=>{m.style.background=`#4b5563`},m.onmouseout=()=>{m.style.background=`#374151`},m.onfocus=()=>{m.style.background=`#4b5563`},m.onblur=()=>{m.style.background=`#374151`};let h=document.createElement(`span`);h.style.cssText=`margin-left: auto; font-size: 0.75rem; color: #9ca3af;`;let g=new Date(e.timestamp);h.textContent=Number.isNaN(g.valueOf())?``:g.toLocaleTimeString(),f.appendChild(p),f.appendChild(m),f.appendChild(h),n.appendChild(f),t.appendChild(n),this.overlay.appendChild(t)}};let H=null;function U(){return H||=new V,H}if(import.meta.hot){let e=U();import.meta.hot.on(`rari:hmr-error`,t=>{let n=t.msg||t.message,r=t.file||t.filePath,i=t.t||t.timestamp,a=t.count||t.errorCount,o=t.max||t.maxErrors;console.error(`[rari] HMR: Build error:`,n),r&&console.error(`[rari] HMR: File:`,r),t.stack&&console.error(`[rari] HMR: Stack:`,t.stack),e.show({message:n,stack:t.stack,filePath:r,timestamp:i}),a&&o&&(a>=o?console.error(`[rari] HMR: Maximum error count (${o}) reached. Consider restarting the dev server if issues persist.`):a>=o-2&&console.warn(`[rari] HMR: Error count: ${a}/${o}. Approaching maximum error threshold.`))}),import.meta.hot.on(`rari:hmr-error-cleared`,()=>{e.hide()}),import.meta.hot.on(`vite:error`,t=>{e.show({message:t.err?.message||`Unknown Vite error`,stack:t.err?.stack,filePath:t.err?.file,timestamp:Date.now()})})}export{P as RscErrorComponent,D as createClientModuleMap,R as createServerComponentWrapper,z as fetchServerComponent,E as getClientComponent,T as registerClientComponent,N as rscClient};
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{};
@@ -0,0 +1,7 @@
1
+ import { createClientModuleProxy as createClientModuleProxy$1, registerServerReference } from "react-server-dom-webpack/server";
2
+
3
+ //#region src/runtime/rsc/references.d.ts
4
+ declare const createClientModuleProxy: typeof createClientModuleProxy$1;
5
+ declare function registerClientReference<T>(clientReference: T, id: string, exportName: string): T;
6
+ //#endregion
7
+ export { createClientModuleProxy, registerClientReference, registerServerReference };
@@ -0,0 +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};
@@ -0,0 +1,7 @@
1
+ import{o as e,t}from"./alias-resolver-CHTPYtdq.mjs";import{t as n}from"./xml-N8OZmN7u.mjs";import{Buffer as r}from"node:buffer";import{promises as i}from"node:fs";import a from"node:path";const o=/[^\w-]/g,s=`\0virtual:sitemap`;function c(e){return(typeof e==`string`?new Date(e):e).toISOString()}function l(e){return[` <image:image>`,` <image:loc>${n(e)}</image:loc>`,` </image:image>`].join(`
2
+ `)}function u(e){let t=[` <image:image>`,` <image:loc>${n(e.loc)}</image:loc>`];return e.title&&t.push(` <image:title>${n(e.title)}</image:title>`),e.caption&&t.push(` <image:caption>${n(e.caption)}</image:caption>`),e.geoLocation&&t.push(` <image:geo_location>${n(e.geoLocation)}</image:geo_location>`),e.license&&t.push(` <image:license>${n(e.license)}</image:license>`),t.push(` </image:image>`),t.join(`
3
+ `)}function d(e){let t=[];for(let n of e)typeof n==`string`?t.push(l(n)):t.push(u(n));return t.join(`
4
+ `)}function f(e){let t=[];if(t.push(` <video:video>`),t.push(` <video:title>${n(e.title)}</video:title>`),t.push(` <video:thumbnail_loc>${n(e.thumbnail_loc)}</video:thumbnail_loc>`),t.push(` <video:description>${n(e.description)}</video:description>`),e.content_loc&&t.push(` <video:content_loc>${n(e.content_loc)}</video:content_loc>`),e.player_loc&&t.push(` <video:player_loc>${n(e.player_loc)}</video:player_loc>`),e.duration!==void 0&&t.push(` <video:duration>${e.duration}</video:duration>`),e.expiration_date&&t.push(` <video:expiration_date>${n(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&&t.push(` <video:publication_date>${n(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="${n(e.restriction.relationship)}">${n(e.restriction.content)}</video:restriction>`),e.platform&&t.push(` <video:platform relationship="${n(e.platform.relationship)}">${n(e.platform.content)}</video:platform>`),e.uploader){let r=e.uploader.info?` info="${n(e.uploader.info)}"`:``;t.push(` <video:uploader${r}>${n(e.uploader.name)}</video:uploader>`)}if(e.tag)for(let r of e.tag)t.push(` <video:tag>${n(r)}</video:tag>`);return t.push(` </video:video>`),t.join(`
5
+ `)}function p(e){return e.map(e=>f(e)).join(`
6
+ `)}function m(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 h(e,t){e.push(` <url>`),e.push(` <loc>${n(t.url)}</loc>`),t.lastModified&&e.push(` <lastmod>${c(t.lastModified)}</lastmod>`),t.changeFrequency&&e.push(` <changefreq>${t.changeFrequency}</changefreq>`),t.priority!==void 0&&e.push(` <priority>${t.priority}</priority>`)}function g(e,t){if(t.alternates?.languages)for(let[r,i]of Object.entries(t.alternates.languages))e.push(` <xhtml:link rel="alternate" hreflang="${n(r)}" href="${n(String(i))}" />`)}function _(e,t){t.images&&t.images.length>0&&e.push(d(t.images)),t.videos&&t.videos.length>0&&e.push(p(t.videos))}function v(e){let t=[`<?xml version="1.0" encoding="UTF-8"?>`,`<urlset ${m(e).join(` `)}>`];for(let n of e)h(t,n),g(t,n),_(t,n),t.push(` </url>`);return t.push(`</urlset>`),t.join(`
7
+ `)}async function y(e,t=[`.ts`,`.tsx`,`.js`,`.jsx`,`.mjs`,`.json`]){let n=[],r=a.join(e,`sitemap.xml`);try{return await i.access(r),n.push({type:`static`,path:r}),n}catch{}for(let r of t){let t=a.join(e,`sitemap${r}`);try{return await i.access(t),n.push({type:`dynamic`,path:t}),n}catch{}}return n}function b(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 x(n,r,o={},c){return{name:`virtual-sitemap`,resolveId(r,i){if(r===s)return r;if(Object.keys(o).length>0){let n=t(r,o,c);if(n)return e(n)||n}if(r.startsWith(`.`)){let t=!i||i.startsWith(`\0`)?n.path:i,o=a.resolve(a.dirname(t),r);return e(o)||o}return null},async load(e){if(e===s)return{code:r,moduleType:b(a.extname(n.path).slice(1))};if(e&&!e.startsWith(`\0`))try{return{code:await i.readFile(e,`utf-8`),moduleType:b(a.extname(e).slice(1))}}catch{return null}return null}}}function S(e){if(!e.output||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||t.type!==`chunk`)throw Error(`No chunk output found in sitemap build result`);return t.code}async function C(e,t,n={},i){let{build:a}=await import(`rolldown`),o=S(await a({input:s,external:[`rari`],platform:`node`,write:!1,output:{format:`esm`,codeSplitting:!1},plugins:[x(e,t,n,i)]}));return await import(`data:text/javascript;base64,${r.from(o).toString(`base64`)}`)}async function w(e,t){let n=await e.generateSitemaps(),r=a.join(t,`sitemap`);await i.mkdir(r,{recursive:!0});let s=new Map;for(let{id:t}of n)try{let n=String(t).replace(o,`_`);(!n||n.length===0)&&(n=`_`);let c=s.get(n);if(c!==void 0)throw Error(`Duplicate sanitized sitemap ID "${n}": original IDs "${c}" and "${t}" collide`);s.set(n,String(t));let l=v(typeof e.default==`function`?await e.default({id:t}):e.default),u=a.join(r,`${n}.xml`);await i.writeFile(u,l)}catch(e){throw Error(`Failed to generate sitemap for id "${t}"`,{cause:e})}}async function T(e,t){let n=v(typeof e.default==`function`?await e.default():e.default),r=a.join(t,`sitemap.xml`);await i.writeFile(r,n)}async function E(e){let{appDir:t,extensions:n,outDir:r,aliases:o={}}=e,s=await y(t,n);if(s.length===0)return!1;await i.mkdir(r,{recursive:!0});let c=s[0];if(c.type===`static`){let e=a.join(r,`sitemap.xml`);return await i.copyFile(c.path,e),!0}try{let e=await C(c,await i.readFile(c.path,`utf-8`),o,a.dirname(a.dirname(t)));return typeof e.generateSitemaps==`function`?await w(e,r):await T(e,r),!0}catch(e){return console.error(`[rari] Failed to build/execute sitemap file:`,e),!1}}export{E as generateSitemapFiles};
@@ -1,4 +1,4 @@
1
- //#region src/proxy/types.d.ts
1
+ //#region src/proxy/http/types.d.ts
2
2
  interface RariURL {
3
3
  href: string;
4
4
  origin: string;