rari 0.15.17 → 0.17.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.
- package/dist/api-routes-Dc2tv31o.mjs +1 -0
- package/dist/cli.d.mts +11 -0
- package/dist/cli.mjs +39 -39
- package/dist/constants-CRK2JRKf.mjs +1 -0
- package/dist/define-B_ozIapW.mjs +1 -0
- package/dist/dist-paths-C4EV064W.mjs +1 -0
- package/dist/execute-CbhDMAQ3.mjs +1 -0
- package/dist/feed-NrJzjZyg.mjs +10 -0
- package/dist/font/google.d.mts +1951 -0
- package/dist/font/google.mjs +1 -0
- package/dist/font/local.d.mts +4 -0
- package/dist/font/local.mjs +1 -0
- package/dist/font.d.mts +3 -0
- package/dist/font.mjs +1 -0
- package/dist/form-state-DAygOjc8.mjs +1 -0
- package/dist/get-client-component-s7qprTUa.mjs +1 -0
- package/dist/headers.d.mts +4 -4
- package/dist/image/static.d.mts +1 -0
- package/dist/image/static.mjs +1 -0
- package/dist/image.d.mts +10 -41
- package/dist/image.mjs +1 -1
- package/dist/index.d.mts +6 -2
- package/dist/index.mjs +1 -1
- package/dist/mdx/define.mjs +1 -1
- package/dist/mdx/registry.d.mts +2 -3
- package/dist/mdx.d.mts +3 -3
- package/dist/mdx.mjs +1 -1
- package/dist/names-CLmM0CPi.mjs +1 -0
- package/dist/navigation-transition-store-CSKrbtbK.mjs +1 -0
- package/dist/og.d.mts +2 -2
- package/dist/og.mjs +1 -1
- package/dist/path-CTEC1xmy.mjs +1 -0
- package/dist/platform.d.mts +3 -4
- package/dist/preload-modules-Dv_GzGCm.mjs +2 -0
- package/dist/proxy/RariRequest.d.mts +2 -3
- package/dist/proxy/RariRequest.mjs +1 -1
- package/dist/proxy/RariResponse.mjs +1 -1
- package/dist/proxy/runtime-executor.d.mts +2 -4
- package/dist/proxy/runtime-executor.mjs +7 -1
- package/dist/{railway-dlVtU472.mjs → railway-CE3nqaKt.mjs} +1 -1
- package/dist/regex-constants-DzXwNGh2.mjs +1 -0
- package/dist/{render-Dipra0HL.mjs → render-D0eMtn5L.mjs} +1 -1
- package/dist/robots-BOPIkPcN.mjs +9 -0
- package/dist/router-Cl4J7j1A.mjs +1 -0
- package/dist/router.d.mts +13 -14
- package/dist/router.mjs +1 -1
- package/dist/rsc-vite-build-CSnu8C3P.mjs +1 -0
- package/dist/runtime/AppRouterProvider.d.mts +10 -7
- package/dist/runtime/AppRouterProvider.mjs +1 -1
- package/dist/runtime/ClientRouter.d.mts +3 -5
- package/dist/runtime/ClientRouter.mjs +7 -1
- package/dist/runtime/ErrorBoundaryWrapper.d.mts +2 -3
- package/dist/runtime/ErrorBoundaryWrapper.mjs +1 -1
- package/dist/runtime/action-flight-refresh.d.mts +4 -5
- package/dist/runtime/action-flight-refresh.mjs +1 -1
- package/dist/runtime/action-revalidation-kind.d.mts +6 -7
- package/dist/runtime/call-server.d.mts +2 -3
- package/dist/runtime/call-server.mjs +1 -1
- package/dist/runtime/entry-client.d.mts +3 -5
- package/dist/runtime/entry-client.mjs +3 -3
- package/dist/runtime/flight-route-cache.d.mts +7 -13
- package/dist/runtime/flight-route-cache.mjs +1 -1
- package/dist/runtime/flight-router-state.d.mts +8 -8
- package/dist/runtime/flight-router-state.mjs +1 -1
- package/dist/runtime/merge-flight-refresh.d.mts +6 -3
- package/dist/runtime/merge-flight-refresh.mjs +1 -1
- package/dist/runtime/rsc-client-runtime.d.mts +3 -2
- package/dist/runtime/rsc-client-runtime.mjs +1 -1
- package/dist/runtime/rsc-references.d.mts +3 -4
- package/dist/serialize-router-state-uOGGpmBr.mjs +1 -0
- package/dist/sitemap--bdIkWl5.mjs +13 -0
- package/dist/static-modules-DBL6iFbg.d.mts +61 -0
- package/dist/type-guards-BJXKlA6x.mjs +1 -0
- package/dist/{types-_vPM8QuJ.d.mts → types-C8N3Hc8I.d.mts} +1 -9
- package/dist/types-CkZPEEdi.d.mts +43 -0
- package/dist/{types-0350HUwk.d.mts → types-DfSnnFaF.d.mts} +240 -4
- package/dist/utils-YdvPzSET-Cbo6Ofmz.mjs +37 -0
- package/dist/vite.d.mts +40 -23
- package/dist/vite.mjs +841 -132
- package/dist/{xml-N8OZmN7u.mjs → xml-DPsk9WTz.mjs} +1 -1
- package/package.json +46 -33
- package/dist/alias-resolver-Cigam7Y7.mjs +0 -1
- package/dist/api-routes-ChRr3O5-.mjs +0 -1
- package/dist/constants-BFdy-wPN.mjs +0 -1
- package/dist/define-CzFpVAjt.mjs +0 -1
- package/dist/feed-Ixvy9L12.mjs +0 -3
- package/dist/get-client-component-CLpyIcLJ.mjs +0 -1
- package/dist/names-N6JRDeT1.mjs +0 -1
- package/dist/preload-modules-QmSvKk0Q.mjs +0 -2
- package/dist/regex-constants-Wm7xRA3u.mjs +0 -1
- package/dist/robots-BGCTYwKN.mjs +0 -2
- package/dist/router-D84JWQz7.mjs +0 -1
- package/dist/runtime/LoadingErrorBoundary.d.mts +0 -11
- package/dist/runtime/LoadingErrorBoundary.mjs +0 -1
- package/dist/sitemap-1n5BIACA.mjs +0 -7
- package/dist/type-guards-CTkEL8zw.mjs +0 -1
- package/dist/types-DCEyvFz7.d.mts +0 -199
- package/dist/utils-BLSRP4f6-8hVIII5T.mjs +0 -37
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { Thenable } from "virtual:react-flight-client";
|
|
3
2
|
//#region src/runtime/flight/app-router-provider.d.ts
|
|
4
3
|
interface RscPayload {
|
|
5
|
-
readonly element: React.ReactNode |
|
|
6
|
-
readonly rawElement?: React.ReactNode |
|
|
4
|
+
readonly element: React.ReactNode | PromiseLike<React.ReactNode>;
|
|
5
|
+
readonly rawElement?: React.ReactNode | PromiseLike<React.ReactNode>;
|
|
7
6
|
readonly flightProtocol?: string;
|
|
8
7
|
}
|
|
9
8
|
interface NavigationOptions {
|
|
10
9
|
readonly historyKey?: string;
|
|
11
10
|
readonly scroll?: boolean;
|
|
11
|
+
readonly replace?: boolean;
|
|
12
12
|
readonly [key: string]: unknown;
|
|
13
13
|
}
|
|
14
14
|
interface AppRouterProviderProps {
|
|
@@ -21,13 +21,16 @@ interface NavigationDetail {
|
|
|
21
21
|
readonly to: string;
|
|
22
22
|
readonly navigationId: number;
|
|
23
23
|
readonly options: NavigationOptions;
|
|
24
|
-
readonly routeInfo?: any;
|
|
25
24
|
readonly abortSignal?: AbortSignal;
|
|
26
25
|
readonly rscFlightProtocol?: string;
|
|
27
26
|
readonly rscResponse?: Response;
|
|
28
27
|
readonly rscResponsePromise?: Promise<Response>;
|
|
29
28
|
readonly isStreaming?: boolean;
|
|
29
|
+
readonly pendingHistory?: {
|
|
30
|
+
readonly url: string;
|
|
31
|
+
readonly state: object;
|
|
32
|
+
readonly replace?: boolean;
|
|
33
|
+
};
|
|
30
34
|
}
|
|
31
|
-
declare function AppRouterProvider({ children, initialPayload, onNavigate }: AppRouterProviderProps): React.JSX.Element;
|
|
32
|
-
//#endregion
|
|
33
|
-
export { AppRouterProvider };
|
|
35
|
+
export declare function AppRouterProvider({ children, initialPayload, onNavigate }: AppRouterProviderProps): React.JSX.Element;
|
|
36
|
+
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{n as e,p as t}from"../type-guards-CTkEL8zw.mjs";import{f as n}from"../regex-constants-Wm7xRA3u.mjs";import{a as r}from"../rari-global-5vGzhToD.mjs";import"./action-revalidation-kind.mjs";import{mergeFlightRefresh as i}from"./merge-flight-refresh.mjs";import{currentRouteLocation as a,flightRouteCache as o}from"./flight-route-cache.mjs";import{t as s}from"../preload-modules-QmSvKk0Q.mjs";import{c}from"react/compiler-runtime";import*as l from"react";import{useEffect as u,useLayoutEffect as d,useRef as f,useState as p}from"react";import{Fragment as m,jsx as h,jsxs as g}from"react/jsx-runtime";import{createFromReadableStream as _}from"virtual:react-flight-client";const ee={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)`},v={padding:`8px 16px`,background:`white`,color:`#dc2626`,border:`none`,borderRadius:`4px`,cursor:`pointer`,fontWeight:`bold`,fontSize:`14px`},te={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`},y={fetch:`Failed to fetch updated content from server.`,parse:`Failed to parse server response.`,stale:`Server returned stale content.`,network:`Network error occurred.`};function b(e){return y[e]}function x(e){let t=c(27),{failure:n,maxRetries:r,onRefresh:i,onDismiss:a}=e,o,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=h(`div`,{style:{marginBottom:`16px`,fontWeight:`bold`,fontSize:`16px`},children:`⚠️ HMR Update Failed`}),s={marginBottom:`12px`,opacity:.9},t[0]=o,t[1]=s):(o=t[0],s=t[1]);let l;t[2]===n.type?l=t[3]:(l=b(n.type),t[2]=n.type,t[3]=l);let u;t[4]===l?u=t[5]:(u=h(`div`,{style:s,children:l}),t[4]=l,t[5]=u);let d;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(d={marginBottom:`16px`,fontSize:`12px`,opacity:.8,fontFamily:`monospace`},t[6]=d):d=t[6];let f;t[7]===n.details?f=t[8]:(f=h(`div`,{style:d,children:n.details}),t[7]=n.details,t[8]=f);let p;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(p={marginBottom:`12px`,fontSize:`12px`,opacity:.7},t[9]=p):p=t[9];let m;t[10]!==n.consecutiveFailures||t[11]!==r?(m=g(`div`,{style:p,children:[`Consecutive failures: `,n.consecutiveFailures,` / `,r]}),t[10]=n.consecutiveFailures,t[11]=r,t[12]=m):m=t[12];let _;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(_={display:`flex`,gap:`8px`},t[13]=_):_=t[13];let y;t[14]===i?y=t[15]:(y=h(`button`,{onClick:i,type:`button`,style:v,children:`Refresh Page`}),t[14]=i,t[15]=y);let x;t[16]===a?x=t[17]:(x=h(`button`,{onClick:a,type:`button`,style:te,children:`Dismiss`}),t[16]=a,t[17]=x);let S;t[18]!==y||t[19]!==x?(S=g(`div`,{style:_,children:[y,x]}),t[18]=y,t[19]=x,t[20]=S):S=t[20];let C;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(C=h(`div`,{style:{marginTop:`12px`,fontSize:`11px`,opacity:.6},children:`Check the console for detailed error logs.`}),t[21]=C):C=t[21];let w;return t[22]!==S||t[23]!==u||t[24]!==f||t[25]!==m?(w=g(`div`,{style:ee,children:[o,u,f,m,S,C]}),t[22]=S,t[23]=u,t[24]=f,t[25]=m,t[26]=w):w=t[26],w}function S(e){let{parsedPayload:t,shouldScrollToTop:n,navigationId:r,useTransition:i,currentNavigationIdRef:a,pendingScrollPayloadRef:o,setRenderKey:s,setRscPayload:c,clearHmrError:u}=e,d=()=>{s(e=>{let r=e+1;return o.current=n?{payload:t,commitKey:r}:null,r}),c(t),u()};i?l.startTransition(()=>{a.current===r&&d()}):d()}function C(e){return l.isValidElement(e)||e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`}function w(e){if(!Array.isArray(e))return e;let t=e;return t.length===1&&l.isValidElement(t[0])?t[0]:t.length>0&&t.every(C)?l.createElement(l.Fragment,null,...t):e}function ne(e,t,n){return e==null||e.commitKey!==n?{shouldScroll:!1,nextPending:null}:t===e.payload?{shouldScroll:!0,nextPending:null}:{shouldScroll:!1,nextPending:e}}const re=/"timestamp":(\d+)/;function T(e){return t(e)&&typeof e.then==`function`}function ie(e){return e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`||l.isValidElement(e)||Array.isArray(e)}function ae(e){return t(e)&&typeof e.from==`string`&&typeof e.to==`string`&&typeof e.navigationId==`number`&&t(e.options)}function oe(e){return t(e)&&`element`in e}function se(e){return t(e)&&typeof e.navigationId==`number`&&typeof e.targetPath==`string`}function ce(ee){let v=c(41),{children:te,initialPayload:y,onNavigate:b}=ee,[C,ce]=p(y),pe=f(y),[E,he]=p(0),D;v[0]===Symbol.for(`react.memo_cache_sentinel`)?(D={x:0,y:0},v[0]=D):D=v[0];let O=f(D),k=f(null),A;v[1]===Symbol.for(`react.memo_cache_sentinel`)?(A=new Map,v[1]=A):A=v[1];let ge=f(A),j;v[2]===Symbol.for(`react.memo_cache_sentinel`)?(j=new Set,v[2]=j):j=v[2];let M=f(j),_e=f(b),N=f(0),P;v[3]===Symbol.for(`react.memo_cache_sentinel`)?(P=new Map,v[3]=P):P=v[3];let F=f(P),I;v[4]===Symbol.for(`react.memo_cache_sentinel`)?(I=[],v[4]=I):I=v[4];let ve=f(I),L=f(null),R=f(0),[z,B]=p(null),V,H;v[5]===b?(V=v[6],H=v[7]):(V=()=>{_e.current=b},H=[b],v[5]=b,v[6]=V,v[7]=H),u(V,H);let U,W;v[8]!==E||v[9]!==C?(U=()=>{let{shouldScroll:e,nextPending:t}=ne(k.current,C,E);k.current=t,e&&window.scrollTo(0,0)},W=[C,E],v[8]=E,v[9]=C,v[10]=U,v[11]=W):(U=v[10],W=v[11]),d(U,W);let ye=me,G,K;v[12]===C?(G=v[13],K=v[14]):(G=()=>{pe.current=C,C?.element!=null&&ye(C.element)},K=[C],v[12]=C,v[13]=G,v[14]=K),u(G,K);let q,J;v[15]===C?(q=v[16],J=v[17]):(q=()=>{if(C?.element!=null){let e=C.element;if(t(e)&&`status`in e&&e.status===`rejected`){let t=e.reason;t!=null&&t!==``&&console.error(`[rari] AppRouter: Flight payload rejected:`,t)}}},J=[C],v[15]=C,v[16]=q,v[17]=J),u(q,J);let be;v[18]===Symbol.for(`react.memo_cache_sentinel`)?(be=()=>{if(typeof document>`u`)return;let e=document.querySelectorAll(`form`);ge.current.clear(),e.forEach((e,t)=>{let n=new FormData(e);ge.current.set(`form-${t}`,n)})},v[18]=be):be=v[18];let xe=be,Se;v[19]===Symbol.for(`react.memo_cache_sentinel`)?(Se=()=>{typeof document>`u`||document.querySelectorAll(`form`).forEach((e,t)=>{let n=ge.current.get(`form-${t}`);n&&n.forEach((t,n)=>{let r=e.elements.namedItem(n);r instanceof HTMLInputElement&&(r.type===`checkbox`||r.type===`radio`?r.checked=t===`on`:typeof t==`string`&&(r.value=t))})})},v[19]=Se):Se=v[19];let Ce=Se,we;v[20]===Symbol.for(`react.memo_cache_sentinel`)?(we=(e,t,n,r)=>{R.current+=1;let i={timestamp:Date.now(),error:e,type:t,details:n,filePath:r,consecutiveFailures:R.current};ve.current.push(i),ve.current.length>10&&ve.current.shift(),R.current>=2&&B(i),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`rari:hmr-failure`,{detail:i}))},v[20]=we):we=v[20];let Te=we,Y=fe,Ee;v[21]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=()=>{R.current>0&&(R.current=0)},v[21]=Ee):Ee=v[21];let De=Ee,Oe;v[22]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=e=>{if(L.current==null||L.current===``)return!1;if(e===L.current)return!0;let t=re.exec(e);if(t){let e=Number.parseInt(t[1],10);if(Date.now()-e>5e3)return!0}return!1},v[22]=Oe):Oe=v[22];let ke=Oe,Ae;v[23]===Symbol.for(`react.memo_cache_sentinel`)?(Ae=async e=>{await s(e,M.current);let t=new ReadableStream({start(t){t.enqueue(new TextEncoder().encode(e)),t.close()}}),n=await _(t);return{element:n,rawElement:n,flightProtocol:e}},v[23]=Ae):Ae=v[23];let je=Ae,Me;v[24]===Symbol.for(`react.memo_cache_sentinel`)?(Me=async(e,t)=>{let n=t!==void 0&&t,r=await e;if(!r.body)throw Error(`Response has no body stream`);if(n){let e=_(r.body);return{element:e,rawElement:e,flightProtocol:``}}let i=await r.clone().text();await s(i,M.current);let a=new Uint8Array(await r.arrayBuffer()),o=new ReadableStream({start(e){e.enqueue(a),e.close()}}),c=await _(o);return{element:c,rawElement:c,flightProtocol:i}},v[24]=Me):Me=v[24];let Ne=Me,Pe;v[25]===C?Pe=v[26]:(Pe=async(e,t)=>{let r=e!=null&&e!==``?e:window.location.pathname,i=N.current,a=`${i}:${r}${window.location.search}`,o=F.current.get(a);if(o)return o;let c=(async()=>{let e;try{let o=(import.meta.env.RARI_SERVER_URL!=null&&import.meta.env.RARI_SERVER_URL!==``?import.meta.env.RARI_SERVER_URL:window.location.origin).replace(n,``)+r+window.location.search,c=await fetch(o,{headers:{Accept:`text/x-component`,"rari-navigation-id":String(N.current)},cache:`no-store`,signal:t});if(c.ok){let t,n=``;try{if(n=await c.clone().text(),ke(n)&&C)return F.current.delete(a),C;await s(n,M.current);let e=new Uint8Array(await c.arrayBuffer()),r=new ReadableStream({start(t){t.enqueue(e),t.close()}}),i=await _(r);t={element:i,rawElement:i,flightProtocol:n}}catch(t){let n=t,r=n instanceof Error?n:Error(String(n));Te(r,`parse`,`Failed to parse RSC Flight protocol: ${r.message}`,window.location.pathname),e=r}if(e==null)return N.current===i&&(ce(t),L.current=n,De()),F.current.delete(a),t}else{let t=Error(`Failed to fetch RSC data: ${c.status} ${c.statusText}`);Te(t,`fetch`,`HTTP ${c.status} when fetching ${o}`,window.location.pathname),e=t}}catch(t){let n=t;n instanceof Error&&!n.message.includes(`Failed to fetch RSC data`)&&!n.message.includes(`Failed to parse`)&&Te(n,`network`,`Network error: ${n.message}`,window.location.pathname),e=n}if(F.current.delete(a),e!=null)throw e instanceof Error?e:Error(typeof e==`string`?e:`Failed to fetch RSC payload`)})();return F.current.set(a,c),c},v[25]=C,v[26]=Pe);let Fe=Pe,Ie=f(je),Le=f(Ne),X=f(Fe),Re;v[27]===Fe?Re=v[28]:(Re=()=>{Ie.current=je,Le.current=Ne,X.current=Fe},v[27]=Fe,v[28]=Re),u(Re);let ze,Z;v[29]===Symbol.for(`react.memo_cache_sentinel`)?(ze=()=>{if(typeof window>`u`)return;let t=async t=>{let n=e(t,ae);if(!n||n.navigationId!==N.current)return;O.current={x:window.scrollX,y:window.scrollY},xe();let r,i=null,a=!1;try{if(n.rscResponsePromise){let e=await n.rscResponsePromise;if(N.current!==n.navigationId||(a=e.headers.get(`x-render-mode`)===`streaming`,r=await Le.current(Promise.resolve(e),a),N.current!==n.navigationId))return}else if(n.rscResponse){if(a=n.rscResponse.headers.get(`x-render-mode`)===`streaming`,r=await Le.current(Promise.resolve(n.rscResponse),a),N.current!==n.navigationId)return}else n.rscFlightProtocol!=null&&n.rscFlightProtocol!==``?r=await Ie.current(n.rscFlightProtocol):n.isStreaming||(r=await X.current(n.to,n.abortSignal))}catch(e){let t=e;if(t instanceof Error&&t.name===`AbortError`)return;i=t instanceof Error?t:Error(String(t))}if(i){console.error(`[rari] AppRouter: Navigation failed:`,i),window.dispatchEvent(new CustomEvent(`rari:navigate-error`,{detail:{from:n.from,to:n.to,error:i,navigationId:n.navigationId}})),R.current>=3&&Y();return}if(!(!r&&n.isStreaming&&N.current===n.navigationId)&&r&&N.current===n.navigationId){let e=window.location.hash.length>0,t=(n.options.historyKey==null||n.options.historyKey===``)&&!e&&n.options.scroll!==!1,i=n.navigationId,o=n.options.historyKey!=null&&n.options.historyKey!==``;S({parsedPayload:r,shouldScrollToTop:t,navigationId:i,useTransition:!a&&!o,currentNavigationIdRef:N,pendingScrollPayloadRef:k,setRenderKey:he,setRscPayload:ce,clearHmrError:()=>{B(null)}}),n.rscFlightProtocol!=null&&n.rscFlightProtocol!==``&&(L.current=n.rscFlightProtocol),De(),_e.current&&_e.current(n)}},n=async()=>{O.current={x:window.scrollX,y:window.scrollY},xe();try{await X.current(),he(de),B(null)}catch(e){let t=e;console.error(`HMR refetch error:`,t instanceof Error?t.message:String(t)),R.current>=3&&Y()}requestAnimationFrame(()=>{window.scrollTo(O.current.x,O.current.y),Ce()})},s=t=>{let n=e(t,oe);if(!(n?.element==null||!ie(n.element)&&!T(n.element))){O.current={x:window.scrollX,y:window.scrollY},xe();try{let{pathname:e,search:t}=a();n.revalidationKind===1?o.clear():n.revalidatedPath!=null&&n.revalidatedPath!==``?o.invalidate(n.revalidatedPath,t):o.invalidate(e,t);let r=pe.current?.element,s=o.getElement(e,t)??(r!=null&&T(r)?null:r??null),c=n.element,u=T(c)?c:i(s,c);l.startTransition(()=>{ce({element:u,rawElement:u}),B(null)}),ye(u),De()}catch(e){let t=e,n=t instanceof Error?t:Error(String(t));Te(n,`parse`,`Action flight refresh failed: ${n.message}`,window.location.pathname),R.current>=3&&Y()}requestAnimationFrame(()=>{window.scrollTo(O.current.x,O.current.y),Ce()})}},c=async()=>{try{await X.current(),he(ue),B(null)}catch(e){let t=e;console.error(`RSC invalidate error:`,t instanceof Error?t.message:String(t)),R.current>=3&&Y()}},u=t=>{let n=e(t,se);if(n&&(M.current.clear(),N.current=n.navigationId,k.current=null,typeof window<`u`)){let e=r();e&&(e.navigationId=n.navigationId)}},d=async()=>{try{await X.current(),B(null)}catch(e){let t=e;console.error(`Manifest update error:`,t instanceof Error?t.message:String(t)),R.current>=3&&Y()}},f=e=>{t(e)},p=()=>{n()},m=()=>{c()},h=()=>{d()};return window.addEventListener(`rari:navigation-start`,u),window.addEventListener(`rari:navigate`,f),window.addEventListener(`rari:app-router-rerender`,p),window.addEventListener(`rari:action-flight-refresh`,s),window.addEventListener(`rari:rsc-invalidate`,m),window.addEventListener(`rari:app-router-manifest-updated`,h),()=>{window.removeEventListener(`rari:navigation-start`,u),window.removeEventListener(`rari:navigate`,f),window.removeEventListener(`rari:app-router-rerender`,p),window.removeEventListener(`rari:action-flight-refresh`,s),window.removeEventListener(`rari:rsc-invalidate`,m),window.removeEventListener(`rari:app-router-manifest-updated`,h)}},Z=[],v[29]=ze,v[30]=Z):(ze=v[29],Z=v[30]),u(ze,Z);let Be,Ve;v[31]===C?(Be=v[32],Ve=v[33]):(Be=()=>{if(!(typeof window>`u`)&&window.location.hash&&C){let e=window.location.hash.slice(1);requestAnimationFrame(()=>{requestAnimationFrame(()=>{let t=document.getElementById(e);t&&t.scrollIntoView({behavior:`instant`,block:`start`})})})}},Ve=[C],v[31]=C,v[32]=Be,v[33]=Ve),u(Be,Ve);let He=C?.element??te,Ue;v[34]===He?Ue=v[35]:(Ue=w(He),v[34]=He,v[35]=Ue);let We=Ue,Q;v[36]===z?Q=v[37]:(Q=z&&h(x,{failure:z,maxRetries:3,onRefresh:le,onDismiss:()=>{B(null)}}),v[36]=z,v[37]=Q);let $;return v[38]!==We||v[39]!==Q?($=g(m,{children:[Q,We]}),v[38]=We,v[39]=Q,v[40]=$):$=v[40],$}function le(){window.location.reload()}function ue(e){return e+1}function de(e){return e+1}function fe(){setTimeout(pe,1e3)}function pe(){window.location.reload()}function me(e){if(e==null||T(e))return;let{pathname:t,search:n}=a();o.set(t,n,e)}export{ce as AppRouterProvider};
|
|
1
|
+
"use client";import{d as e,i as t,p as n,r,v as i,w as a}from"../type-guards-BJXKlA6x.mjs";import{r as o}from"../navigation-transition-store-CSKrbtbK.mjs";import"./action-revalidation-kind.mjs";import{isLayoutReuseMarker as s,mergeFlightRefresh as c}from"./merge-flight-refresh.mjs";import{currentRouteLocation as l,flightRouteCache as u}from"./flight-route-cache.mjs";import{n as d,t as f}from"../preload-modules-Dv_GzGCm.mjs";import{n as p,r as m}from"../form-state-DAygOjc8.mjs";import{c as h}from"react/compiler-runtime";import*as g from"react";import{addTransitionType as _,startTransition as v,useEffect as y,useLayoutEffect as b,useRef as x,useState as S,useTransition as ee}from"react";import{Fragment as te,jsx as C,jsxs as w}from"react/jsx-runtime";import{createFromFetch as ne,createFromReadableStream as re}from"virtual:react-flight-client";const T={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)`},E={padding:`8px 16px`,background:`white`,color:`#dc2626`,border:`none`,borderRadius:`4px`,cursor:`pointer`,fontWeight:`bold`,fontSize:`14px`},D={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`},O={fetch:`Failed to fetch updated content from server.`,parse:`Failed to parse server response.`,stale:`Server returned stale content.`,network:`Network error occurred.`};function k(e){return O[e]}function ie(e){let t=h(27),{failure:n,maxRetries:r,onRefresh:i,onDismiss:a}=e,o,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=/* @__PURE__ */ C(`div`,{style:{marginBottom:`16px`,fontWeight:`bold`,fontSize:`16px`},children:`⚠️ HMR Update Failed`}),s={marginBottom:`12px`,opacity:.9},t[0]=o,t[1]=s):(o=t[0],s=t[1]);let c;t[2]===n.type?c=t[3]:(c=k(n.type),t[2]=n.type,t[3]=c);let l;t[4]===c?l=t[5]:(l=/* @__PURE__ */ C(`div`,{style:s,children:c}),t[4]=c,t[5]=l);let u;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(u={marginBottom:`16px`,fontSize:`12px`,opacity:.8,fontFamily:`monospace`},t[6]=u):u=t[6];let d;t[7]===n.details?d=t[8]:(d=/* @__PURE__ */ C(`div`,{style:u,children:n.details}),t[7]=n.details,t[8]=d);let f;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(f={marginBottom:`12px`,fontSize:`12px`,opacity:.7},t[9]=f):f=t[9];let p;t[10]!==n.consecutiveFailures||t[11]!==r?(p=/* @__PURE__ */ w(`div`,{style:f,children:[`Consecutive failures: `,n.consecutiveFailures,` / `,r]}),t[10]=n.consecutiveFailures,t[11]=r,t[12]=p):p=t[12];let m;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(m={display:`flex`,gap:`8px`},t[13]=m):m=t[13];let g;t[14]===i?g=t[15]:(g=/* @__PURE__ */ C(`button`,{onClick:i,type:`button`,style:E,children:`Refresh Page`}),t[14]=i,t[15]=g);let _;t[16]===a?_=t[17]:(_=/* @__PURE__ */ C(`button`,{onClick:a,type:`button`,style:D,children:`Dismiss`}),t[16]=a,t[17]=_);let v;t[18]!==g||t[19]!==_?(v=/* @__PURE__ */ w(`div`,{style:m,children:[g,_]}),t[18]=g,t[19]=_,t[20]=v):v=t[20];let y;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(y=/* @__PURE__ */ C(`div`,{style:{marginTop:`12px`,fontSize:`11px`,opacity:.6},children:`Check the console for detailed error logs.`}),t[21]=y):y=t[21];let b;return t[22]!==v||t[23]!==l||t[24]!==d||t[25]!==p?(b=/* @__PURE__ */ w(`div`,{style:T,children:[o,l,d,p,v,y]}),t[22]=v,t[23]=l,t[24]=d,t[25]=p,t[26]=b):b=t[26],b}function ae(e){return e.historyKey!=null&&e.historyKey!==``?[`nav`,`nav-traverse`]:e.replace===!0?[`nav`,`nav-replace`]:[`nav`,`nav-forward`]}function A(e){e!=null&&typeof window<`u`&&(e.replace===!0?window.history.replaceState(e.state,``,e.url):window.history.pushState(e.state,``,e.url))}function j(e){if(e!=null&&e.url!==``)try{let t=`http://localhost/`;if(typeof window<`u`)try{t=window.location.href}catch{}let n=new URL(e.url,t);o({pathname:n.pathname,search:n.search})}catch{}}function oe(e){let{parsedPayload:t,shouldScrollToTop:n,navigationId:r,transitionTypes:i,pendingHistory:a,startTransition:o=v,currentNavigationIdRef:s,pendingScrollPayloadRef:c,setRenderKey:l,setRscPayload:u,clearHmrError:d,pendingNavigateCommittedIdRef:f}=e;o(()=>{if(s.current===r){if(i!=null)for(let e of i)_(e);A(a),j(a),l(e=>{let r=e+1;return c.current=n?{payload:t,commitKey:r}:null,r}),u(t),d(),f.current=r}})}function se(e,t,n){return e==null||e.commitKey!==n?{shouldScroll:!1,nextPending:null}:t===e.payload?{shouldScroll:!0,nextPending:null}:{shouldScroll:!1,nextPending:e}}const ce=/"timestamp":(\d+)/;function le(e){return e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`||g.isValidElement(e)||Array.isArray(e)}function ue(e){return i(e)&&typeof e.from==`string`&&typeof e.to==`string`&&typeof e.navigationId==`number`&&i(e.options)}function de(e){return i(e)&&`element`in e}function fe(e){return i(e)&&typeof e.navigationId==`number`&&typeof e.targetPath==`string`}function pe(e){if(!n(e))return e;if(i(e)&&e.status===`fulfilled`)return le(e.value)?e.value:void 0}function M(e){return g.isValidElement(e)&&(e.type===`html`||e.type===`HTML`)}function N(e){return M(e)||g.isValidElement(e)&&s(e)}function P(e,t){console.error(`[rari] AppRouter: Navigation failed:`,t),window.dispatchEvent(new CustomEvent(`rari:navigate-error`,{detail:{from:e.from,to:e.to,error:t,navigationId:e.navigationId}}))}function F(e){return e!=null&&!n(e)&&M(e)?e:null}function me(e){let t=e.pendingHistory?.url,n=t!=null&&t!==``?new URL(t,window.location.origin).hash.length>0:window.location.hash.length>0;return(e.options.historyKey==null||e.options.historyKey===``)&&!n&&e.options.scroll!==!1}async function he(e,t,n,r){let i=await I(e.element);if(r!==n)return{kind:`superseded`};if(!N(i))return{kind:`error`,error:/* @__PURE__ */ Error(`[rari] AppRouter: navigated Flight content did not resolve to an <html> document root`)};let a=F(t);if(g.isValidElement(i)&&s(i)&&a==null)return{kind:`error`,error:/* @__PURE__ */ Error(`[rari] AppRouter: layout-reuse Flight marker requires a previous <html> document`)};let o=a==null?i:c(a,i);return M(o)?{kind:`payload`,payload:{...e,element:o,rawElement:o}}:{kind:`error`,error:/* @__PURE__ */ Error(`[rari] AppRouter: layout-merged Flight content did not resolve to an <html> document root`)}}async function I(e){let t=d(e);for(let e=0;e<10&&n(t);e+=1)t=d(await t);if(n(t))throw Error(`[rari] AppRouter: Flight content did not resolve to a React node`);return t}function L({children:o,initialPayload:s,onNavigate:h}){let[_,v]=S(s),T=x(s),[E,D]=S(0),[,O]=ee(),k=x(O),A=x({x:0,y:0}),j=x(null),N=x(/* @__PURE__ */ new Map),F=x(/* @__PURE__ */ new Set),L=x(h),R=x(0),z=x(0),B=x(null),V=x(null),H=x(/* @__PURE__ */ new Map),U=x([]),W=x(null),G=x(0),[ge,K]=S(null);y(()=>{L.current=h},[h]),y(()=>{k.current=O},[O]),b(()=>{let{shouldScroll:e,nextPending:t}=se(j.current,_,E);j.current=t,e&&window.scrollTo(0,0);let n=V.current;n!=null&&(V.current=null,window.dispatchEvent(new CustomEvent(`rari:navigate-committed`,{detail:{navigationId:n}})))},[_,E]);let _e=e=>{if(e==null||n(e))return;let{pathname:t,search:r}=l();u.set(t,r,e)};y(()=>{T.current=_,_?.element!=null&&_e(_.element)},[_]),y(()=>{if(_?.element!=null){let e=_.element;if(i(e)&&`status`in e&&e.status===`rejected`){let t=e.reason;t!=null&&t!==``&&console.error(`[rari] AppRouter: Flight payload rejected:`,t)}}},[_]);let q=()=>{N.current=p()},ve=()=>{m(N.current)};b(()=>{let e=B.current;e!=null&&_===e&&(B.current=null,window.scrollTo(A.current.x,A.current.y),ve())},[_,E]);let J=(e,t,n,r)=>{G.current+=1;let i={timestamp:Date.now(),error:e,type:t,details:n,filePath:r,consecutiveFailures:G.current};U.current.push(i),U.current.length>10&&U.current.shift(),G.current>=2&&K(i),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`rari:hmr-failure`,{detail:i}))},Y=()=>{setTimeout(()=>{window.location.reload()},1e3)},ye=()=>{G.current>0&&(G.current=0)},be=e=>{if(W.current==null||W.current===``)return!1;if(e===W.current)return!0;let t=ce.exec(e);if(t){let e=Number.parseInt(t[1],10);if(Date.now()-e>5e3)return!0}return!1},xe=e=>{f(e,F.current);let t=new ReadableStream({start(t){t.enqueue(new TextEncoder().encode(e)),t.close()}}),n=re(t);return{element:n,rawElement:n,flightProtocol:e}},Se=async e=>{let t=await e;if(!t.body)throw Error(`Response has no body stream`);let n=t.clone(),r=ne(Promise.resolve(t));return n.text().then(async e=>{await f(e,F.current),e!==``&&(W.current=e)}).catch(()=>{}),{element:r,rawElement:r,flightProtocol:``}},Ce=async(t,n)=>{try{let e=await t.clone().text();if(be(e))return H.current.delete(n),`stale`;await f(e,F.current);let r=await I(ne(Promise.resolve(t)));if(!M(r))throw Error(`[rari] AppRouter: refetched Flight content did not resolve to an <html> document root`);return{element:r,rawElement:r,flightProtocol:e}}catch(t){if(e(t)&&t.name===`AbortError`)throw t;let n=a(t),r=Error(`Failed to parse RSC Flight protocol: ${n.message}`,{cause:n});return J(r,`parse`,r.message,window.location.pathname),r}},we=async(t,n,r)=>{let i=t!=null&&t!==``?t:window.location.pathname,o=R.current,s=r?.commit!==!1,c=`${o}:${i}${window.location.search}:${s?`commit`:`defer`}`,l=H.current.get(c);if(l)return l;let u=(async()=>{try{let e=i+window.location.search,t=await fetch(e,{headers:{Accept:`text/x-component`,"rari-navigation-id":String(R.current)},cache:`no-store`,signal:n});if(!t.ok){let n=/* @__PURE__ */ Error(`Failed to fetch RSC data: ${t.status} ${t.statusText}`);throw J(n,`fetch`,`HTTP ${t.status} when fetching ${e}`,window.location.pathname),n}let r=await Ce(t,c);if(r===`stale`)return;if(r instanceof Error)throw r;return R.current===o&&(s&&v(r),r.flightProtocol!=null&&r.flightProtocol!==``&&(W.current=r.flightProtocol),ye()),H.current.delete(c),r}catch(t){throw H.current.delete(c),e(t)&&t.name!==`AbortError`&&!t.message.includes(`Failed to fetch RSC data`)&&!t.message.includes(`Failed to parse`)&&J(t,`network`,`Network error: ${t.message}`,window.location.pathname),a(t)}})();return H.current.set(c,u),u},Te=x(xe),Ee=x(Se),X=x(we);y(()=>{Te.current=xe,Ee.current=Se,X.current=we}),y(()=>{if(typeof window>`u`)return;let i=async e=>{if(e.rscResponsePromise){let t=await e.rscResponsePromise;if(R.current!==e.navigationId)return;let n=await Ee.current(Promise.resolve(t));return R.current===e.navigationId?n:void 0}if(e.rscResponse){let t=await Ee.current(Promise.resolve(e.rscResponse));return R.current===e.navigationId?t:void 0}if(e.rscFlightProtocol!=null&&e.rscFlightProtocol!==``)return Te.current(e.rscFlightProtocol);if(!e.isStreaming)return X.current(e.to,e.abortSignal,{commit:!1})},o=async(e,t)=>{try{let n=await he(t,T.current?.element,e.navigationId,R.current);return n.kind===`superseded`?null:n.kind===`error`?(P(e,n.error),null):R.current===e.navigationId?n.payload:null}catch(t){return P(e,a(t)),null}},s=(e,t)=>{oe({parsedPayload:t,shouldScrollToTop:me(e),navigationId:e.navigationId,transitionTypes:ae({historyKey:e.options.historyKey,replace:e.options.replace}),pendingHistory:e.pendingHistory,startTransition:k.current,currentNavigationIdRef:R,pendingScrollPayloadRef:j,setRenderKey:D,setRscPayload:v,clearHmrError:()=>{K(null)},pendingNavigateCommittedIdRef:V}),t.flightProtocol!=null&&t.flightProtocol!==``&&(W.current=t.flightProtocol),ye(),L.current&&L.current(e)},d=async t=>{try{return{kind:`payload`,payload:await i(t)}}catch(t){return e(t)&&t.name===`AbortError`?{kind:`aborted`}:{kind:`error`,error:a(t)}}},f=async e=>{let n=t(e,ue);if(!n||n.navigationId!==R.current)return;A.current={x:window.scrollX,y:window.scrollY},q();let r=await d(n);if(r.kind===`aborted`)return;if(r.kind===`error`){P(n,r.error),G.current>=3&&Y();return}let i=r.payload;if(i==null&&n.isStreaming&&R.current===n.navigationId||i==null||R.current!==n.navigationId)return;let a=await o(n,i);a!=null&&s(n,a)},p=async()=>{A.current={x:window.scrollX,y:window.scrollY},q();try{await X.current(),D(e=>e+1),K(null)}catch(e){console.error(`HMR refetch error:`,r(e,String(e))),G.current>=3&&Y()}requestAnimationFrame(()=>{window.scrollTo(A.current.x,A.current.y),ve()})},m=e=>{let r=t(e,de);if(r?.element==null||!le(r.element)&&!n(r.element))return;let{pathname:i,search:o}=l(),s=++z.current,d=R.current,f=`${i}${o}`;A.current={x:window.scrollX,y:window.scrollY},q();try{r.revalidationKind===1?u.clear():r.revalidatedPath!=null&&r.revalidatedPath!==``?u.invalidate(r.revalidatedPath,o):u.invalidate(i,o);let e=T.current?.element,t=u.getElement(i,o)??(e!=null&&n(e)?null:e??null),p=r.element;(async()=>{try{let e=await I(p);if(s!==z.current||R.current!==d)return;let{pathname:n,search:r}=l();if(`${n}${r}`!==f)return;let i=await I(c(t,e));if(s!==z.current||R.current!==d)return;let a=l();if(`${a.pathname}${a.search}`!==f)return;if(!M(i)){let e=/* @__PURE__ */ Error(`[rari] AppRouter: action flight refresh did not resolve to an <html> document root`);J(e,`parse`,`Action flight refresh failed: ${e.message}`,window.location.pathname),G.current>=3&&Y();return}let o={element:i,rawElement:i};B.current=o,g.startTransition(()=>{v(o),K(null)}),_e(i),ye()}catch(e){if(s!==z.current||R.current!==d)return;let t=a(e);J(t,`parse`,`Action flight refresh failed: ${t.message}`,window.location.pathname),G.current>=3&&Y()}})()}catch(e){let t=a(e);J(t,`parse`,`Action flight refresh failed: ${t.message}`,window.location.pathname),G.current>=3&&Y()}},h=async()=>{try{await X.current(),D(e=>e+1),K(null)}catch(e){console.error(`RSC invalidate error:`,r(e,String(e))),G.current>=3&&Y()}},_=e=>{let n=t(e,fe);n&&(F.current.clear(),R.current=n.navigationId,z.current+=1,j.current=null,B.current=null)},y=async()=>{try{await X.current(),K(null)}catch(e){console.error(`Manifest update error:`,r(e,String(e))),G.current>=3&&Y()}},b=e=>{f(e)},x=()=>{p()},S=()=>{h()},ee=()=>{y()};return window.addEventListener(`rari:navigation-start`,_),window.addEventListener(`rari:navigate`,b),window.addEventListener(`rari:app-router-rerender`,x),window.addEventListener(`rari:action-flight-refresh`,m),window.addEventListener(`rari:rsc-invalidate`,S),window.addEventListener(`rari:app-router-manifest-updated`,ee),()=>{window.removeEventListener(`rari:navigation-start`,_),window.removeEventListener(`rari:navigate`,b),window.removeEventListener(`rari:app-router-rerender`,x),window.removeEventListener(`rari:action-flight-refresh`,m),window.removeEventListener(`rari:rsc-invalidate`,S),window.removeEventListener(`rari:app-router-manifest-updated`,ee)}},[]),y(()=>{if(typeof window<`u`&&window.location.hash&&_){let e=window.location.hash.slice(1);requestAnimationFrame(()=>{requestAnimationFrame(()=>{let t=document.getElementById(e);t&&t.scrollIntoView({behavior:`instant`,block:`start`})})})}},[_]);let De=_?.element??o,Z=d(De),[Oe,ke]=S(null),Ae=pe(Z),je=n(Z)&&Ae===void 0,Q=Ae===void 0?n(Z)?null:Z:d(Ae),$=Q!=null&&!n(Q)&&M(Q)?Q:null;if($!=null&&!Object.is($,Oe)&&ke($),je){if(Oe==null)throw Error(`[rari] AppRouter: expected a resolved <html> document root`)}else if($==null)throw Error(`[rari] AppRouter: expected a resolved <html> document root`);return/* @__PURE__ */ w(te,{children:[ge!=null&&/* @__PURE__ */ C(ie,{failure:ge,maxRetries:3,onRefresh:()=>{window.location.reload()},onDismiss:()=>{K(null)}}),je?Oe:$]})}export{L as AppRouterProvider};
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
//#region src/router/navigation/client-router.d.ts
|
|
3
|
-
interface ClientRouterProps {
|
|
3
|
+
export interface ClientRouterProps {
|
|
4
4
|
readonly children: React.ReactNode;
|
|
5
5
|
readonly initialRoute: string;
|
|
6
|
-
readonly staleWindowMs?: number;
|
|
7
6
|
}
|
|
8
|
-
declare function ClientRouter({ children, initialRoute
|
|
9
|
-
//#endregion
|
|
10
|
-
export { ClientRouter, ClientRouterProps };
|
|
7
|
+
export declare function ClientRouter({ children, initialRoute }: ClientRouterProps): React.ReactNode;
|
|
8
|
+
//#endregion
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
"use client";import{i as e,t}from"../navigate-DuyUa6qD.mjs";import{d as n,g as r,p as i}from"../type-guards-CTkEL8zw.mjs";import{a}from"../rari-global-5vGzhToD.mjs";import{c as o}from"react/compiler-runtime";import{useEffect as s,useLayoutEffect as c,useRef as l,useState as u}from"react";function d(e,t,n={}){let r=null,i=0,a=0,o=null,s=null,{leading:c=!1,trailing:l=!0,maxWait:u}=n;function d(t){let n=o,r=s;o=null,s=null,a=t,e.apply(r,n)}function f(e){let n=e-i,r=e-a;return i===0||n>=t||n<0||u!==void 0&&r>=u}function p(){let e=Date.now();if(f(e)){h(e);return}let n=e-i,o=e-a,s=t-n,c=u===void 0?1/0:u-o;r=setTimeout(p,Math.min(s,c))}function m(e){a=e,r=setTimeout(p,t),c&&d(e)}function h(e){if(r=null,l&&o){d(e);return}o=null,s=null}function g(){r!==null&&clearTimeout(r),a=0,o=null,i=0,s=null,r=null}function _(){r!==null&&h(Date.now())}function v(){return r!==null}function y(...e){let n=Date.now(),a=f(n);if(o=e,s=this,i=n,a){if(r===null){m(i);return}if(u!==void 0){r=setTimeout(p,t),d(i);return}}r??=setTimeout(p,t)}return y.cancel=g,y.flush=_,y.pending=v,y}const f=/fetch|networkerror|load failed/i;function p(e,t){return{type:`abort`,message:`Navigation was cancelled`,originalError:e,url:t,timestamp:Date.now(),retryable:!1}}function m(e,t){return{type:`timeout`,message:`Navigation request timed out`,originalError:e,url:t,timestamp:Date.now(),retryable:!0}}function h(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 g(e,t){return{type:`network-error`,message:`Network error - check your connection`,originalError:e,url:t,timestamp:Date.now(),retryable:!0}}function _(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 v(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 y(e,t){if(e instanceof Error&&e.name===`AbortError`)return p(e,t);if(e instanceof Error&&(e.name===`TimeoutError`||e.message.includes(`timeout`)))return m(e,t);if(e instanceof Error&&`status`in e){let n=e.status;return typeof n==`number`?h(e,n,t):v(e,t)}return e instanceof TypeError&&f.test(e.message)?g(e,t):e instanceof SyntaxError||e instanceof Error&&e.message.includes(`parse`)?_(e,t):v(e,t)}var ee=class{options;retryCount;constructor(e={}){this.options={timeout:e.timeout??1e4,maxRetries:e.maxRetries??3,onError:e.onError??(()=>{}),onRetry:e.onRetry??(()=>{})},this.retryCount=new Map}handleError(e,t){let n=y(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 b(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 te(e,t){try{return new URL(e,t!=null&&t!==``?t:window.location.origin).origin!==(t!=null&&t!==``?t:window.location.origin)}catch{return!1}}function ne(e){try{let t=new URL(e,window.location.origin);return t.pathname+t.hash}catch{return e}}const re=new class{cache=new Map;pendingRequests=new Map;async get(e){let t=this.cache.get(e);if(t)return t;let n=this.pendingRequests.get(e);if(n)return n;let r=this.fetchRouteInfo(e);this.pendingRequests.set(e,r);try{let t=await r;return this.cache.set(e,t),t}finally{this.pendingRequests.delete(e)}}parseRouteInfoResponse(e){let t=r(e);if(!t||!this.isRouteInfoResponse(t))throw Error(`Failed to parse route info response`);return t}isRouteInfoResponse(e){return i(e)&&typeof e.exists==`boolean`&&Array.isArray(e.layouts)&&(e.loading===null||typeof e.loading==`string`)&&typeof e.isDynamic==`boolean`}async fetchRouteInfo(e){let t=await fetch(`/_rari/route-info`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:e})});if(!t.ok){let e;try{let n=await t.text(),i=r(n);i&&typeof i.error==`string`&&i.error!==``&&(e=i.error)}catch{}throw Error(e!=null&&e!==``?e:`Failed to fetch route info: ${t.status} ${t.statusText}`)}let n=t.clone();try{let e=await t.text();return this.parseRouteInfoResponse(e)}catch(t){try{let e=await n.text();return this.parseRouteInfoResponse(e)}catch(n){throw console.error(`[RouteInfo] Failed to parse response:`,{error:t,parseError:n,path:e}),Error(`Failed to parse route info response`)}}}clear(){this.cache.clear(),this.pendingRequests.clear()}invalidate(e){this.cache.delete(e)}};if(typeof window<`u`){let e=a();e.routeInfoCache=re}var ie=class{stateHistory;routeAccessOrder;maxHistorySize;scrollableSelector;constructor(e={}){this.stateHistory=new Map,this.routeAccessOrder=[],this.maxHistorySize=e.maxHistorySize!=null&&e.maxHistorySize!==0?e.maxHistorySize:50,this.scrollableSelector=e.scrollableSelector!=null&&e.scrollableSelector!==``?e.scrollableSelector:`[data-scrollable], .scrollable, [style*="overflow"]`}captureState(e){let t={scrollPositions:this.captureScrollPositions(),formData:this.captureFormData(),focusedElement:this.captureFocusedElement()};return this.storeState(e,t),t}captureScrollPositions(){let e=new Map;try{e.set(`window`,{x:window.scrollX,y:window.scrollY,element:`window`}),document.querySelectorAll(this.scrollableSelector).forEach((t,n)=>{if(t instanceof HTMLElement){let r=t.id||`scrollable-${n}`;(t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth)&&e.set(r,{x:t.scrollLeft,y:t.scrollTop,element:r})}})}catch{}return e}captureFormData(){let e=new Map;try{document.querySelectorAll(`form`).forEach((t,n)=>{let r=t.id||t.name||`form-${n}`,i=new FormData(t);i.entries().next().done||e.set(r,i)})}catch{}return e}captureFocusedElement(){try{let e=document.activeElement;if(e&&e!==document.body){if(e.id)return`#${e.id}`;if((e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&e.name)return`[name="${e.name}"]`}}catch{}return null}storeState(e,t){let n=this.routeAccessOrder.indexOf(e);for(n!==-1&&this.routeAccessOrder.splice(n,1),this.routeAccessOrder.push(e),this.stateHistory.set(e,t);this.routeAccessOrder.length>this.maxHistorySize;){let e=this.routeAccessOrder.shift();e!=null&&e!==``&&this.stateHistory.delete(e)}}getHistorySize(){return this.stateHistory.size}hasState(e){return this.stateHistory.has(e)}getState(e){return this.stateHistory.get(e)}clearAll(){this.stateHistory.clear(),this.routeAccessOrder=[]}clearState(e){this.stateHistory.delete(e);let t=this.routeAccessOrder.indexOf(e);t!==-1&&this.routeAccessOrder.splice(t,1)}restoreState(e){let t=this.stateHistory.get(e);if(!t)return!1;let n=!0;return this.restoreScrollPositions(t.scrollPositions)||(n=!1),this.restoreFormData(t.formData)||(n=!1),t.focusedElement!=null&&t.focusedElement!==``&&this.restoreFocus(t.focusedElement),n}restoreScrollPositions(e){let t=!0;try{e.forEach((e,n)=>{try{if(n===`window`)window.scrollTo(e.x,e.y);else{let r=document.getElementById(n)??document.querySelector(`[data-scrollable-id="${n}"]`);r instanceof HTMLElement?(r.scrollLeft=e.x,r.scrollTop=e.y):t=!1}}catch{t=!1}})}catch(e){console.error(`[rari] Router: Failed to restore scroll positions:`,e),t=!1}return t}restoreFormData(e){let t=!0;try{e.forEach((e,n)=>{try{let r=document.getElementById(n),i=r instanceof HTMLFormElement?r:document.querySelector(`form[name="${n}"]`)??document.querySelectorAll(`form`)[Number.parseInt(n.replace(`form-`,``),10)];i instanceof HTMLFormElement?e.forEach((e,n)=>{try{let t=i.elements.namedItem(n);t instanceof RadioNodeList?t.forEach(t=>{t instanceof HTMLInputElement&&(t.type===`radio`||t.type===`checkbox`?t.checked=t.value===e:typeof e==`string`&&(t.value=e))}):(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)&&(t instanceof HTMLInputElement&&(t.type===`checkbox`||t.type===`radio`)?t.checked=t.value===e:typeof e==`string`&&(t.value=e))}catch{t=!1}}):t=!1}catch{t=!1}})}catch(e){console.error(`[rari] Router: Failed to restore form data:`,e),t=!1}return t}restoreFocus(e){try{let t=document.querySelector(e);t instanceof HTMLElement&&requestAnimationFrame(()=>{try{t.focus()}catch{}})}catch{}}};function x(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 S(e){let t=document.querySelector(e);t&&t.remove()}function C(e){e.title!=null&&e.title!==``&&(document.title=e.title),e.description!=null&&e.description!==``?x(`meta[name="description"]`,{name:`description`,content:e.description}):S(`meta[name="description"]`),e.keywords&&e.keywords.length>0?x(`meta[name="keywords"]`,{name:`keywords`,content:e.keywords.join(`, `)}):S(`meta[name="keywords"]`),e.viewport!=null&&e.viewport!==``&&x(`meta[name="viewport"]`,{name:`viewport`,content:e.viewport})}function w(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 ae(e){if(e===void 0){S(`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?x(`meta[name="robots"]`,{name:`robots`,content:t.join(`, `)}):S(`meta[name="robots"]`)}function T(e){if(e===void 0){S(`meta[property="og:title"]`),S(`meta[property="og:description"]`),S(`meta[property="og:url"]`),S(`meta[property="og:site_name"]`),S(`meta[property="og:type"]`),document.querySelectorAll(`meta[property="og:image"]`).forEach(e=>{e.remove()});return}if(e.title!=null&&e.title!==``?x(`meta[property="og:title"]`,{property:`og:title`,content:e.title}):S(`meta[property="og:title"]`),e.description!=null&&e.description!==``?x(`meta[property="og:description"]`,{property:`og:description`,content:e.description}):S(`meta[property="og:description"]`),e.url!=null&&e.url!==``?x(`meta[property="og:url"]`,{property:`og:url`,content:e.url}):S(`meta[property="og:url"]`),e.siteName!=null&&e.siteName!==``?x(`meta[property="og:site_name"]`,{property:`og:site_name`,content:e.siteName}):S(`meta[property="og:site_name"]`),e.type!=null&&e.type!==``?x(`meta[property="og:type"]`,{property:`og:type`,content:e.type}):S(`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 E(e){if(e===void 0){S(`meta[name="twitter:card"]`),S(`meta[name="twitter:site"]`),S(`meta[name="twitter:creator"]`),S(`meta[name="twitter:title"]`),S(`meta[name="twitter:description"]`),document.querySelectorAll(`meta[name="twitter:image"]`).forEach(e=>{e.remove()});return}if(e.card!=null&&e.card!==``?x(`meta[name="twitter:card"]`,{name:`twitter:card`,content:e.card}):S(`meta[name="twitter:card"]`),e.site!=null&&e.site!==``?x(`meta[name="twitter:site"]`,{name:`twitter:site`,content:e.site}):S(`meta[name="twitter:site"]`),e.creator!=null&&e.creator!==``?x(`meta[name="twitter:creator"]`,{name:`twitter:creator`,content:e.creator}):S(`meta[name="twitter:creator"]`),e.title!=null&&e.title!==``?x(`meta[name="twitter:title"]`,{name:`twitter:title`,content:e.title}):S(`meta[name="twitter:title"]`),e.description!=null&&e.description!==``?x(`meta[name="twitter:description"]`,{name:`twitter:description`,content:e.description}):S(`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 D(e){C(e),w(e.canonical),ae(e.robots),T(e.openGraph),E(e.twitter)}function O(e){return i(e)}function k(r){let i=o(40),{children:a,initialRoute:f,staleWindowMs:p}=r,m=p===void 0?3e4:p,h;i[0]===f?h=i[1]:(h=()=>({currentRoute:b(f),navigationId:0,error:null}),i[0]=f,i[1]=h);let[g,_]=u(h),v=l(null),y=l(!0),x;i[2]===f?x=i[3]:(x=b(f),i[2]=f,i[3]=x);let S=l(x),C=l(0),w;i[4]===Symbol.for(`react.memo_cache_sentinel`)?(w=new ee({timeout:1e4,maxRetries:3,onError:fe,onRetry:de}),i[4]=w):w=i[4];let ae=l(w),T;i[5]===Symbol.for(`react.memo_cache_sentinel`)?(T=new Map,i[5]=T):T=i[5];let E=l(T),D;i[6]===Symbol.for(`react.memo_cache_sentinel`)?(D=[],i[6]=D):D=i[6];let O=l(D),k;i[7]===Symbol.for(`react.memo_cache_sentinel`)?(k=new ie({maxHistorySize:50}),i[7]=k):k=i[7];let A=l(k),pe=l(null),me=l(m),he=ue,j;i[8]===Symbol.for(`react.memo_cache_sentinel`)?(j=()=>{v.current&&=(v.current.abort(),null)},i[8]=j):j=i[8];let ge=j,M;i[9]===Symbol.for(`react.memo_cache_sentinel`)?(M=()=>{for(let[,e]of E.current.entries())e.abortController.abort();E.current.clear()},i[9]=M):M=i[9];let _e=M,N;i[10]===g?N=i[11]:(N=(e,t)=>{E.current.delete(e),y.current&&g.navigationId===t&&_(le)},i[10]=g,i[11]=N);let P=N,F=l(null),ve=ce,ye=se,I;i[12]===Symbol.for(`react.memo_cache_sentinel`)?(I=(e,t,n,r,i,a)=>{C.current===r&&window.dispatchEvent(new CustomEvent(`rari:navigate`,{detail:{from:t,to:n,navigationId:r,options:i,abortSignal:a.signal,rscResponsePromise:e}}))},i[12]=I):I=i[12];let be=I,L;if(i[13]===Symbol.for(`react.memo_cache_sentinel`)){let e=(e,t,n)=>{n.historyKey!=null&&n.historyKey!==``?requestAnimationFrame(()=>{A.current.restoreState(e)}):t&&requestAnimationFrame(()=>{let e=n=>{let r=n===void 0?0:n,i=document.getElementById(t);i?i.scrollIntoView({behavior:`smooth`,block:`start`}):r<10&&setTimeout(e,50,r+1)};e()})};L=(t,n,r,i)=>{y.current&&C.current===i&&(S.current=t,_(e=>({...e,currentRoute:t,navigationId:i,error:null})),ae.current.resetRetry(t),e(t,n,r))},i[13]=L}else L=i[13];let xe=L,R;i[14]===P?R=i[15]:(R=(e,t,n,r)=>{if(e instanceof Error&&e.name===`AbortError`){P(t,n);return}let i=ae.current.handleError(e,t);y.current&&(_(e=>({...e,error:i})),window.history.replaceState(window.history.state,``,r)),E.current.delete(t),window.dispatchEvent(new CustomEvent(`rari:navigate-error`,{detail:{from:r,to:t,error:i,navigationId:n}})),F.current?.()},i[14]=P,i[15]=R);let Se=R,z;i[16]!==P||i[17]!==Se?(z=async(e,t)=>{let n=t===void 0?{}:t;if(!e||typeof e!=`string`)return;let[r,i]=e.includes(`#`)?e.split(`#`):[e,``],a=b(r);if(a===S.current&&!n.replace){ve(a,i);return}let o=E.current.get(a);if(o)return o.promise;_e(),ge();let s=new AbortController;v.current=s,C.current+=1;let c=C.current;window.dispatchEvent(new CustomEvent(`rari:navigation-start`,{detail:{navigationId:c,targetPath:a}}));let l=(async()=>{let e=S.current;try{(n.historyKey==null||n.historyKey===``)&&A.current.captureState(e);let t=n.historyKey!=null&&n.historyKey!==``?n.historyKey:he(),r=window.location.origin+a,o=i?`${a}#${i}`:a,l={route:a,navigationId:c,scrollPosition:{x:window.scrollX,y:window.scrollY},timestamp:Date.now(),key:t};n.replace?window.history.replaceState(l,``,o):window.history.pushState(l,``,o);let u=await fetch(r,{headers:{Accept:`text/x-component`,"rari-navigation-id":String(c)},signal:s.signal}).then(oe);if(s.signal.aborted){P(a,c);return}let d=new URL(u.url).pathname;if(d!==a){let e=i?`${d}#${i}`:d;window.history.replaceState({...l,route:d},``,e)}be(Promise.resolve(u),e,d,c,n,s),ye(u),xe(d,i,n,c),E.current.delete(a),F.current?.()}catch(t){Se(t,a,c,e)}})();return E.current.set(a,{targetPath:a,navigationId:c,promise:l,abortController:s}),l},i[16]=P,i[17]=Se,i[18]=z):z=i[18];let B=z,V;i[19]===B?V=i[20]:(V=async()=>{if(O.current.length===0)return;let e=O.current.at(-1);e&&(O.current=[],await B(e.path,e.options))},i[19]=B,i[20]=V);let Ce=V,H=l(B),U;i[21]!==B||i[22]!==Ce?(U=()=>(F.current=Ce,H.current=B,()=>{F.current=null,H.current=null}),i[21]=B,i[22]=Ce,i[23]=U):U=i[23],c(U);let we=l(null),W,G;i[24]===Symbol.for(`react.memo_cache_sentinel`)?(W=()=>{we.current??=d((e,t)=>{H.current?.(e,t)},50,{leading:!0,trailing:!0,maxWait:200})},G=[],i[24]=W,i[25]=G):(W=i[24],G=i[25]),c(W,G);let K;i[26]===Symbol.for(`react.memo_cache_sentinel`)?(K=e=>{if(e.button!==0||e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)return;let t=e.target instanceof Element?e.target:null;for(;t&&!(t instanceof HTMLAnchorElement);)t=t.parentElement;if(!(t instanceof HTMLAnchorElement))return;let n=t;if(n.target&&n.target!==`_self`||n.hasAttribute(`download`))return;let r=n.getAttribute(`href`);if(r==null||r===``||te(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=ne(r);we.current?.(i,{replace:!1})},i[26]=K):K=i[26];let Te=K,q;i[27]===Symbol.for(`react.memo_cache_sentinel`)?(q=e=>{let t=window.location.pathname,r=n(e.state)?e.state:null;H.current&&H.current(t,{replace:!0,scroll:!1,historyKey:r?.key})},i[27]=q):q=i[27];let Ee=q,J,Y;i[28]===f?(J=i[29],Y=i[30]):(J=()=>{let e=n(window.history.state)?window.history.state:null;if(e?.key==null||e.key===``){let e={route:b(f),navigationId:0,scrollPosition:{x:window.scrollX,y:window.scrollY},timestamp:Date.now(),key:he()};window.history.replaceState(e,``,window.location.pathname+window.location.search+window.location.hash)}},Y=[f],i[28]=f,i[29]=J,i[30]=Y),s(J,Y);let X;i[31]===Symbol.for(`react.memo_cache_sentinel`)?(X=e=>{if(e.persisted){let e=window.location.pathname;A.current.captureState(e)}},i[31]=X):X=i[31];let De=X,Z;i[32]===Symbol.for(`react.memo_cache_sentinel`)?(Z=e=>{if(e.persisted){let e=window.location.pathname,t=n(window.history.state)?window.history.state:null;requestAnimationFrame(()=>{A.current.restoreState(e),t?.scrollPosition&&window.scrollTo(t.scrollPosition.x,t.scrollPosition.y)})}},i[32]=Z):Z=i[32];let Oe=Z,Q,ke;i[33]===Symbol.for(`react.memo_cache_sentinel`)?(Q=()=>(document.addEventListener(`click`,Te),window.addEventListener(`popstate`,Ee),window.addEventListener(`pagehide`,De),window.addEventListener(`pageshow`,Oe),()=>{document.removeEventListener(`click`,Te),window.removeEventListener(`popstate`,Ee),window.removeEventListener(`pagehide`,De),window.removeEventListener(`pageshow`,Oe)}),ke=[],i[33]=Q,i[34]=ke):(Q=i[33],ke=i[34]),s(Q,ke);let Ae,je;i[35]===m?(Ae=i[36],je=i[37]):(Ae=()=>{me.current=m;let e=()=>{document.hidden?pe.current=Date.now():pe.current!==null&&Date.now()-pe.current>me.current&&re.clear()};return document.addEventListener(`visibilitychange`,e),()=>{document.removeEventListener(`visibilitychange`,e)}},je=[m],i[35]=m,i[36]=Ae,i[37]=je),s(Ae,je);let Me,$;return i[38]===Symbol.for(`react.memo_cache_sentinel`)?(Me=()=>(y.current=!0,e(async(e,t)=>H.current?.(e,t)??Promise.resolve()),()=>{y.current=!1,t(),ge(),_e(),we.current?.cancel()}),$=[],i[38]=Me,i[39]=$):(Me=i[38],$=i[39]),s(Me,$),a}function oe(e){if(!e.ok&&e.status!==404)throw Error(`Failed to fetch: ${e.status}`);return e}function se(e){try{let t=e.headers.get(`x-rari-metadata`);if(t!=null&&t!==``){let e=r(decodeURIComponent(t));e&&O(e)&&D(e)}}catch(e){console.warn(`[rari] Router: Failed to parse x-rari-metadata header:`,e)}}function ce(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}`))}function le(e){return{...e}}function ue(){return`${Date.now()}-${Math.random().toString(36).substring(2,9)}`}function de(){}function fe(e){console.error(`[rari] Router: Navigation error:`,e)}export{k as ClientRouter};
|
|
1
|
+
"use client";import{i as e,t}from"../navigate-DuyUa6qD.mjs";import{d as n,h as r,i,n as a,v as o}from"../type-guards-BJXKlA6x.mjs";import{r as s}from"../path-CTEC1xmy.mjs";import{t as ee}from"../serialize-router-state-uOGGpmBr.mjs";import{t as c}from"../form-state-DAygOjc8.mjs";import{c as l}from"react/compiler-runtime";import{useEffect as u,useLayoutEffect as d,useRef as f,useState as te}from"react";function p(e,t,n={}){let r=null,i=0,a=0,o=null,s=null,{leading:ee=!1,trailing:c=!0,maxWait:l}=n;function u(t){let n=o,r=s;o=null,s=null,a=t,e.apply(r,n)}function d(e){let n=e-i,r=e-a;return i===0||n>=t||n<0||l!==void 0&&r>=l}function f(){let e=Date.now();if(d(e)){p(e);return}let n=e-i,o=e-a,s=t-n,ee=l===void 0?1/0:l-o;r=setTimeout(f,Math.min(s,ee))}function te(e){a=e,r=setTimeout(f,t),ee&&u(e)}function p(e){if(r=null,c&&o){u(e);return}o=null,s=null}function m(){r!==null&&clearTimeout(r),a=0,o=null,i=0,s=null,r=null}function h(){r!==null&&p(Date.now())}function g(){return r!==null}function _(...e){let n=Date.now(),a=d(n);if(o=e,s=this,i=n,a){if(r===null){te(i);return}
|
|
2
|
+
/* v8 ignore start - edge case: isInvoking true with existing timeout and maxWait defined */
|
|
3
|
+
if(l!==void 0){r=setTimeout(f,t),u(i);return}}r??=setTimeout(f,t)}return _.cancel=m,_.flush=h,_.pending=g,_}const m=/fetch|networkerror|load failed/i;function h(e,t){return{type:`abort`,message:`Navigation was cancelled`,originalError:e,url:t,timestamp:Date.now(),retryable:!1}}function g(e,t){return{type:`timeout`,message:`Navigation request timed out`,originalError:e,url:t,timestamp:Date.now(),retryable:!0}}function _(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 v(e,t){return{type:`network-error`,message:`Network error - check your connection`,originalError:e,url:t,timestamp:Date.now(),retryable:!0}}function y(e,t){return{type:`parse-error`,message:`Failed to parse server response`,
|
|
4
|
+
/* v8 ignore next - defensive check for non-Error values from parse-related condition */
|
|
5
|
+
originalError:a(e),url:t,timestamp:Date.now(),retryable:!1}}function b(e,t){return{type:`fetch-error`,message:a(e)?.message??`Unknown error occurred`,originalError:a(e),url:t,timestamp:Date.now(),retryable:!1}}function x(e,t){if(n(e)&&e.name===`AbortError`)return h(e,t);if(n(e)&&(e.name===`TimeoutError`||e.message.includes(`timeout`)))return g(e,t);if(n(e)&&`status`in e){let n=e.status;return typeof n==`number`?_(e,n,t):b(e,t)}return e instanceof TypeError&&m.test(e.message)?v(e,t):e instanceof SyntaxError||n(e)&&e.message.includes(`parse`)?y(e,t):b(e,t)}var ne=class{onError;constructor(e={}){
|
|
6
|
+
/* v8 ignore next - default no-op callback */
|
|
7
|
+
this.onError=e.onError??(()=>{})}handleError(e,t){let n=x(e,t);return this.onError(n),console.error(`[rari] Navigation:`,n.type,n.message,{url:n.url,statusCode:n.statusCode,retryable:n.retryable}),n}};function re(e,t){try{let n=t!=null&&t!==``?t:window.location.origin,r=typeof URL.parse==`function`?URL.parse(e,n):new URL(e,n);return r!=null&&r.origin!==n}catch{return!1}}function ie(e){try{let t=typeof URL.parse==`function`?URL.parse(e,window.location.origin):new URL(e,window.location.origin);return t==null?e:`${t.pathname}${t.search}${t.hash}`}catch{return e}}var ae=class{stateHistory;routeAccessOrder;maxHistorySize;scrollableSelector;constructor(e={}){this.stateHistory=/* @__PURE__ */ new Map,this.routeAccessOrder=[],this.maxHistorySize=e.maxHistorySize!=null&&e.maxHistorySize!==0?e.maxHistorySize:50,this.scrollableSelector=e.scrollableSelector!=null&&e.scrollableSelector!==``?e.scrollableSelector:`[data-scrollable], .scrollable, [style*="overflow"]`}captureState(e){let t={scrollPositions:this.captureScrollPositions(),formData:this.captureFormData(),focusedElement:this.captureFocusedElement()};return this.storeState(e,t),t}captureScrollPositions(){let e=/* @__PURE__ */ new Map;try{e.set(`window`,{x:window.scrollX,y:window.scrollY,element:`window`}),document.querySelectorAll(this.scrollableSelector).forEach((t,n)=>{if(t instanceof HTMLElement){let r=t.id||`scrollable-${n}`;(t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth)&&e.set(r,{x:t.scrollLeft,y:t.scrollTop,element:r})}})}catch{}return e}captureFormData(){let e=/* @__PURE__ */ new Map;try{document.querySelectorAll(`form`).forEach((t,n)=>{let r=t.id||t.name||`form-${n}`,i=new FormData(t);i.entries().next().done||e.set(r,i)})}catch{}return e}captureFocusedElement(){try{let e=document.activeElement;if(e&&e!==document.body){if(e.id)return`#${e.id}`;if((e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&e.name)return`[name="${e.name}"]`}}catch{}return null}storeState(e,t){let n=this.routeAccessOrder.indexOf(e);for(n!==-1&&this.routeAccessOrder.splice(n,1),this.routeAccessOrder.push(e),this.stateHistory.set(e,t);this.routeAccessOrder.length>this.maxHistorySize;){let e=this.routeAccessOrder.shift();e!=null&&e!==``&&this.stateHistory.delete(e)}}restoreState(e){let t=this.stateHistory.get(e);if(!t)return!1;let n=!0;return this.restoreScrollPositions(t.scrollPositions)||(n=!1),this.restoreFormData(t.formData)||(n=!1),t.focusedElement!=null&&t.focusedElement!==``&&this.restoreFocus(t.focusedElement),n}restoreScrollPositions(e){let t=!0;try{e.forEach((e,n)=>{try{if(n===`window`)window.scrollTo(e.x,e.y);else{let r=document.getElementById(n)??document.querySelector(`[data-scrollable-id="${n}"]`);r instanceof HTMLElement?(r.scrollLeft=e.x,r.scrollTop=e.y):t=!1}}catch{t=!1}})}catch(e){console.error(`[rari] Router: Failed to restore scroll positions:`,e),t=!1}return t}restoreFormData(e){let t=!0;try{e.forEach((e,n)=>{try{let r=document.getElementById(n),i=r instanceof HTMLFormElement?r:document.querySelector(`form[name="${n}"]`)??document.querySelectorAll(`form`)[Number.parseInt(n.replace(`form-`,``),10)];i instanceof HTMLFormElement&&c(i,e)||(t=!1)}catch{t=!1}})}catch(e){console.error(`[rari] Router: Failed to restore form data:`,e),t=!1}return t}restoreFocus(e){try{let t=document.querySelector(e);t instanceof HTMLElement&&requestAnimationFrame(()=>{try{t.focus()}catch{}})}catch{}}};function S(e){return o(e)&&typeof e.navigationId==`number`}function C(e){return o(e)&&typeof e.navigationId==`number`&&`error`in e}async function oe(e,t){return t.aborted?{error:new DOMException(`Aborted`,`AbortError`)}:new Promise(n=>{function r(){window.removeEventListener(`rari:navigate-committed`,a),window.removeEventListener(`rari:navigate-error`,o),t.removeEventListener(`abort`,s)}function a(t){i(t,S)?.navigationId===e&&(r(),n(`committed`))}function o(t){let a=i(t,C);a?.navigationId===e&&(r(),n({error:a.error}))}function s(){r(),n({error:new DOMException(`Aborted`,`AbortError`)})}window.addEventListener(`rari:navigate-committed`,a),window.addEventListener(`rari:navigate-error`,o),t.addEventListener(`abort`,s,{once:!0})})}function w(i){let a=l(35),{children:o,initialRoute:c}=i,m;a[0]===c?m=a[1]:(m=()=>({currentRoute:typeof window<`u`?`${window.location.pathname}${window.location.search}`:s(c),navigationId:0,error:null}),a[0]=c,a[1]=m);let[h,g]=te(m),_=f(null),v=f(!0),y;a[2]===c?y=a[3]:(y=typeof window<`u`?`${window.location.pathname}${window.location.search}`:s(c),a[2]=c,a[3]=y);let b=f(y),x;a[4]===c?x=a[5]:(x=typeof window<`u`?`${window.location.pathname}${window.location.search}${window.location.hash}`:s(c),a[4]=c,a[5]=x);let S=f(x),C=f(0),w;a[6]===Symbol.for(`react.memo_cache_sentinel`)?(w=new ne({onError:le}),a[6]=w):w=a[6];let ue=f(w),T;a[7]===Symbol.for(`react.memo_cache_sentinel`)?(T=/* @__PURE__ */ new Map,a[7]=T):T=a[7];let E=f(T),D;a[8]===Symbol.for(`react.memo_cache_sentinel`)?(D=new ae({maxHistorySize:50}),a[8]=D):D=a[8];let O=f(D),de=ce,k;a[9]===Symbol.for(`react.memo_cache_sentinel`)?(k=()=>{_.current&&=(_.current.abort(),null)},a[9]=k):k=a[9];let fe=k,A;a[10]===Symbol.for(`react.memo_cache_sentinel`)?(A=()=>{for(let[,e]of E.current.entries())e.abortController.abort();E.current.clear()},a[10]=A):A=a[10];let pe=A,j;a[11]===h?j=a[12]:(j=(e,t)=>{E.current.delete(e),v.current&&h.navigationId===t&&g(se)},a[11]=h,a[12]=j);let M=j,N;a[13]===Symbol.for(`react.memo_cache_sentinel`)?(N=(e,t)=>{let n=t===void 0?{}:t,r=`${window.location.pathname}${window.location.search}`,i=e?`${r}#${e}`:r;if(e){let t=document.getElementById(e);t&&t.scrollIntoView({behavior:`smooth`,block:`start`})}i!==`${window.location.pathname}${window.location.search}${window.location.hash}`&&(n.replace?window.history.replaceState(window.history.state,``,i):window.history.pushState(window.history.state,``,i)),S.current=i},a[13]=N):N=a[13];let me=N,P;if(a[14]===Symbol.for(`react.memo_cache_sentinel`)){let e=(e,t,n)=>{n.historyKey!=null&&n.historyKey!==``?requestAnimationFrame(()=>{O.current.restoreState(e)}):t&&requestAnimationFrame(()=>{let e=n=>{let r=n===void 0?0:n,i=document.getElementById(t);i?i.scrollIntoView({behavior:`smooth`,block:`start`}):r<10&&setTimeout(e,50,r+1)};e()})};P=(t,n,r,i,a)=>{v.current&&C.current===i&&(b.current=t,S.current=a,g(e=>({...e,currentRoute:t,navigationId:i,error:null})),e(t,n,r))},a[14]=P}else P=a[14];let he=P,F;a[15]===M?F=a[16]:(F=(e,t,r,i,a)=>{let o=a===void 0?{}:a;if(n(e)&&e.name===`AbortError`){M(t,r);return}let s=ue.current.handleError(e,t);v.current&&(g(e=>({...e,error:s})),window.history.replaceState(window.history.state,``,i)),E.current.delete(t),o.emitEvent!==!1&&window.dispatchEvent(new CustomEvent(`rari:navigate-error`,{detail:{from:i,to:t,error:s,navigationId:r}}))},a[15]=M,a[16]=F);let I=F,L;a[17]!==M||a[18]!==I?(L=async(e,t)=>{let n=t===void 0?{}:t;if(!e||typeof e!=`string`)return;let[r,i]=e.includes(`#`)?e.split(`#`):[e,``],a=s(r);if(a===b.current){me(i,{replace:n.replace===!0});return}let o=E.current.get(a);if(o)return o.promise;pe(),fe();let c=new AbortController;_.current=c,C.current+=1;let l=C.current;window.dispatchEvent(new CustomEvent(`rari:navigation-start`,{detail:{navigationId:l,targetPath:a}}));let u=(async()=>{let e=S.current;try{(n.historyKey==null||n.historyKey===``)&&O.current.captureState(b.current);let t=n.historyKey!=null&&n.historyKey!==``?n.historyKey:de(),r=window.location.origin+a,o={route:a,navigationId:l,scrollPosition:{x:window.scrollX,y:window.scrollY},timestamp:Date.now(),key:t},s=await fetch(r,{headers:{Accept:`text/x-component`,"rari-navigation-id":String(l),"rari-router-state":ee()},cache:`no-store`,signal:c.signal});if(!s.ok&&s.status!==404){I(/* @__PURE__ */ Error(`Failed to fetch: ${s.status}`),a,l,e);return}if(c.signal.aborted){M(a,l);return}let u=new URL(s.url),d=u.pathname,f=`${u.pathname}${u.search}`,te={...o,route:f},p=`${f}${i?`#${i}`:``}`;if(C.current!==l)return;let m=oe(l,c.signal);if(window.dispatchEvent(new CustomEvent(`rari:navigate`,{detail:{from:e,to:d,navigationId:l,options:n,abortSignal:c.signal,rscResponse:s,pendingHistory:{url:p,state:te,replace:n.replace===!0}}})),C.current!==l){c.abort();return}let h=await m;if(C.current!==l)return;if(h!==`committed`){I(h.error,a,l,e,{emitEvent:!1});return}he(f,i,n,l,p),E.current.delete(a)}catch(t){I(t,a,l,e)}})();return E.current.set(a,{targetPath:a,navigationId:l,promise:u,abortController:c}),u},a[17]=M,a[18]=I,a[19]=L):L=a[19];let R=L,z=f(R),B;a[20]===R?B=a[21]:(B=()=>(z.current=R,()=>{z.current=null}),a[20]=R,a[21]=B),d(B);let V=f(null),H,U;a[22]===Symbol.for(`react.memo_cache_sentinel`)?(H=()=>{V.current??=p((e,t)=>{z.current?.(e,t)},50,{leading:!0,trailing:!0,maxWait:200})},U=[],a[22]=H,a[23]=U):(H=a[22],U=a[23]),d(H,U);let W;a[24]===Symbol.for(`react.memo_cache_sentinel`)?(W=e=>{if(e.button!==0||e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)return;let t=e.target instanceof Element?e.target:null;for(;t&&!(t instanceof HTMLAnchorElement);)t=t.parentElement;if(!(t instanceof HTMLAnchorElement))return;let n=t;if(n.target&&n.target!==`_self`||n.hasAttribute(`download`))return;let r=n.getAttribute(`href`);if(r==null||r===``||re(r))return;if(r.startsWith(`#`)){e.preventDefault();let t=r.slice(1),n=document.getElementById(t);if(n){n.scrollIntoView({behavior:`smooth`,block:`start`});let e=`${window.location.pathname}${window.location.search}#${t}`;window.history.pushState(window.history.state,``,e),S.current=e}return}e.preventDefault();let i=ie(r);V.current?.(i,{replace:!1})},a[24]=W):W=a[24];let ge=W,G;a[25]===Symbol.for(`react.memo_cache_sentinel`)?(G=e=>{let t=`${window.location.pathname}${window.location.search}${window.location.hash}`,n=r(e.state)?e.state:null;z.current&&z.current(t,{replace:!0,scroll:!1,historyKey:n?.key})},a[25]=G):G=a[25];let _e=G,K;a[26]===Symbol.for(`react.memo_cache_sentinel`)?(K=()=>{let e=r(window.history.state)?window.history.state:null;if(e?.key==null||e.key===``){let e={route:`${window.location.pathname}${window.location.search}`,navigationId:0,scrollPosition:{x:window.scrollX,y:window.scrollY},timestamp:Date.now(),key:de()};window.history.replaceState(e,``,window.location.pathname+window.location.search+window.location.hash)}},a[26]=K):K=a[26];let q;a[27]===c?q=a[28]:(q=[c],a[27]=c,a[28]=q),u(K,q);let J;a[29]===Symbol.for(`react.memo_cache_sentinel`)?(J=e=>{if(e.persisted){let e=window.location.pathname;O.current.captureState(e)}},a[29]=J):J=a[29];let ve=J,Y;a[30]===Symbol.for(`react.memo_cache_sentinel`)?(Y=e=>{if(e.persisted){let e=window.location.pathname,t=r(window.history.state)?window.history.state:null;requestAnimationFrame(()=>{O.current.restoreState(e),t?.scrollPosition&&window.scrollTo(t.scrollPosition.x,t.scrollPosition.y)})}},a[30]=Y):Y=a[30];let ye=Y,X,Z;a[31]===Symbol.for(`react.memo_cache_sentinel`)?(X=()=>(document.addEventListener(`click`,ge),window.addEventListener(`popstate`,_e),window.addEventListener(`pagehide`,ve),window.addEventListener(`pageshow`,ye),()=>{document.removeEventListener(`click`,ge),window.removeEventListener(`popstate`,_e),window.removeEventListener(`pagehide`,ve),window.removeEventListener(`pageshow`,ye)}),Z=[],a[31]=X,a[32]=Z):(X=a[31],Z=a[32]),u(X,Z);let Q,$;return a[33]===Symbol.for(`react.memo_cache_sentinel`)?(Q=()=>(v.current=!0,e(async(e,t)=>z.current?.(e,t)??Promise.resolve()),()=>{v.current=!1,t(),fe(),pe(),V.current?.cancel()}),$=[],a[33]=Q,a[34]=$):(Q=a[33],$=a[34]),u(Q,$),o}function se(e){return{...e}}function ce(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`hk-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,11)}`}function le(e){console.error(`[rari] Router: Navigation error:`,e)}export{w as ClientRouter};
|
|
@@ -13,7 +13,7 @@ interface ErrorBoundaryWrapperState {
|
|
|
13
13
|
reset: () => void;
|
|
14
14
|
}> | null;
|
|
15
15
|
}
|
|
16
|
-
declare class ErrorBoundaryWrapper extends Component<ErrorBoundaryWrapperProps, ErrorBoundaryWrapperState> {
|
|
16
|
+
export declare class ErrorBoundaryWrapper extends Component<ErrorBoundaryWrapperProps, ErrorBoundaryWrapperState> {
|
|
17
17
|
private _isMounted;
|
|
18
18
|
private _pendingTimer;
|
|
19
19
|
constructor(props: ErrorBoundaryWrapperProps);
|
|
@@ -24,5 +24,4 @@ declare class ErrorBoundaryWrapper extends Component<ErrorBoundaryWrapperProps,
|
|
|
24
24
|
reset: () => void;
|
|
25
25
|
render(): ReactNode;
|
|
26
26
|
}
|
|
27
|
-
//#endregion
|
|
28
|
-
export { ErrorBoundaryWrapper };
|
|
27
|
+
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{
|
|
1
|
+
"use client";import{u as e,v as t}from"../type-guards-BJXKlA6x.mjs";import{t as n}from"../timer-Duul5JHq.mjs";import{r}from"../rari-global-5vGzhToD.mjs";import{Component as i}from"react";import{jsx as a,jsxs as o}from"react/jsx-runtime";function s(n){if(e(n))return n;if(t(n)){let t=n.default??n;return e(t)?t:null}return null}var c=class extends i{_isMounted=!1;_pendingTimer=null;constructor(e){super(e),this.state={hasError:!1,error:null,ErrorComponent:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidMount(){this._isMounted=!0}componentWillUnmount(){this._isMounted=!1,this._pendingTimer=n(this._pendingTimer)}componentDidCatch(e,t){console.error(`[rari] Error boundary caught error:`,e,t);let n=this.props.errorComponentId;if(n!==``){let e=r();if(n in e){let t=e[n],r=s(t.component);r?this.setState({ErrorComponent:r}):t.loader&&!t.loading&&(t.loading=!0,t.loader().then(e=>{let n=s(e);n&&(t.component=n,t.registered=!0,this.setState({ErrorComponent:n})),t.loading=!1}).catch(e=>{t.loading=!1,console.error(`[rari] Failed to load error component ${n}:`,e)}))}}}reset=()=>{this._pendingTimer=n(this._pendingTimer),this._pendingTimer=setTimeout(()=>{this._isMounted&&this.setState({hasError:!1,error:null,ErrorComponent:null}),this._pendingTimer=null},50)};render(){if(this.state.hasError&&this.state.error){let{ErrorComponent:e}=this.state;return e?/* @__PURE__ */ a(e,{error:this.state.error,reset:this.reset}):/* @__PURE__ */ o(`div`,{className:`rari-error`,role:`alert`,style:{color:`red`,border:`1px solid red`,padding:`10px`,borderRadius:`4px`,backgroundColor:`#fff5f5`},children:[/* @__PURE__ */ a(`strong`,{children:`Error loading content: `}),this.state.error.message]})}return this.props.children}};export{c as ErrorBoundaryWrapper};
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { ActionDidNotRevalidate, ActionDidRevalidateDynamicOnly, ActionDidRevalidateStaticAndDynamic, ActionRevalidationKind } from "./action-revalidation-kind.mjs";
|
|
2
2
|
//#region src/runtime/actions/flight-refresh.d.ts
|
|
3
|
-
interface ActionFlightRefreshDetail {
|
|
3
|
+
export interface ActionFlightRefreshDetail {
|
|
4
4
|
element: unknown;
|
|
5
5
|
revalidationKind: ActionRevalidationKind;
|
|
6
6
|
revalidatedPath?: string;
|
|
7
7
|
}
|
|
8
|
-
interface ActionFlightResponseShape {
|
|
8
|
+
export interface ActionFlightResponseShape {
|
|
9
9
|
readonly a?: unknown;
|
|
10
10
|
readonly f?: unknown;
|
|
11
11
|
}
|
|
12
|
-
declare function scheduleActionFlightRefresh(response: Response, flightResponse: ActionFlightResponseShape, actionResult: unknown): void;
|
|
13
|
-
declare function refreshRouter(): void;
|
|
12
|
+
export declare function scheduleActionFlightRefresh(response: Response, flightResponse: ActionFlightResponseShape, actionResult: unknown): void;
|
|
14
13
|
//#endregion
|
|
15
|
-
export { ActionDidNotRevalidate, ActionDidRevalidateDynamicOnly, ActionDidRevalidateStaticAndDynamic
|
|
14
|
+
export { ActionDidNotRevalidate, ActionDidRevalidateDynamicOnly, ActionDidRevalidateStaticAndDynamic };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as
|
|
1
|
+
import{g as e,p as t,r as n,v as r}from"../type-guards-BJXKlA6x.mjs";import{ActionDidNotRevalidate as i,ActionDidRevalidateDynamicOnly as a,ActionDidRevalidateStaticAndDynamic as o,parseActionRevalidationKind as s}from"./action-revalidation-kind.mjs";function c(e){return r(e)?`redirect`in e||`~rariSkipRefresh`in e||`~rariFormState`in e:!1}function l(n){return e(n)||t(n)}function u(e){return e==null||e===``?null:e instanceof Promise?e.then(e=>e==null||e===``?null:e):e}function d(e,t,r){typeof globalThis.dispatchEvent==`function`&&(c(r)||(async()=>{let n=u(t.f),r=n instanceof Promise?await n:n;if(r==null||!l(r))return;let i=s(e.headers.get(`x-action-revalidated`));if(i===0)return;let a=e.headers.get(`x-action-revalidated-path`)??void 0,o=()=>{globalThis.dispatchEvent(new CustomEvent(`rari:action-flight-refresh`,{detail:{element:r,revalidationKind:i,revalidatedPath:a}}))};if(typeof requestAnimationFrame==`function`){requestAnimationFrame(()=>{requestAnimationFrame(o)});return}queueMicrotask(o)})().catch(e=>{console.error(`[rari] Action flight refresh failed:`,n(e,String(e)))}))}export{i as ActionDidNotRevalidate,a as ActionDidRevalidateDynamicOnly,o as ActionDidRevalidateStaticAndDynamic,d as scheduleActionFlightRefresh};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
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 };
|
|
2
|
+
export type ActionRevalidationKind = 0 | 1 | 2;
|
|
3
|
+
export declare const ActionDidNotRevalidate: 0;
|
|
4
|
+
export declare const ActionDidRevalidateStaticAndDynamic: 1;
|
|
5
|
+
export declare const ActionDidRevalidateDynamicOnly: 2;
|
|
6
|
+
export declare function parseActionRevalidationKind(header: string | null): ActionRevalidationKind;
|
|
7
|
+
//#endregion
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
//#region src/runtime/actions/call-server.d.ts
|
|
2
|
-
declare function callServer(id: string, args: readonly unknown[]): Promise<unknown>;
|
|
3
|
-
//#endregion
|
|
4
|
-
export { callServer };
|
|
2
|
+
export declare function callServer(id: string, args: readonly unknown[]): Promise<unknown>;
|
|
3
|
+
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{d as e,v as t}from"../type-guards-BJXKlA6x.mjs";import{t as n}from"../serialize-router-state-uOGGpmBr.mjs";import{scheduleActionFlightRefresh as r}from"./action-flight-refresh.mjs";import{createFromFetch as i,createTemporaryReferenceSet as a,encodeReply as o}from"virtual:react-flight-client";const s=3e4;function c(e){if(!t(e))return e;let{"~rariSkipRefresh":n,...r}=e;return r}function l(){return typeof window<`u`?window.location.pathname+window.location.search:`/`}const u=/* @__PURE__ */ new Set([`http:`,`https:`]);function d(e){if(typeof window<`u`)try{let t=new URL(e,window.location.href);if(!u.has(t.protocol))return;t.href!==window.location.href&&(window.location.href=t.href)}catch{}}async function f(e,t){let s=a(),{headers:l,body:u}=p(await o(t,{temporaryReferences:s}));l.Accept=`text/x-component`,l[`rsc-action-id`]=e,l[`rari-router-state`]=n();let d=await m(e,l,u),_=h(d);if(_!=null)return _;await g(e,d);let v=await i(Promise.resolve(d),{callServer:f,temporaryReferences:s}),y=v.a,b=y instanceof Promise?await y:y;return r(d,v,b),c(b)}function p(e){let t={};return typeof e==`string`&&(t[`Content-Type`]=`text/plain;charset=UTF-8`),{headers:t,body:e}}async function m(t,n,r){try{return await fetch(l(),{method:`POST`,headers:n,body:r,signal:AbortSignal.timeout(s)})}catch(n){throw n instanceof DOMException&&n.name===`TimeoutError`||e(n)&&n.name===`AbortError`?Error(`Server action "${t}" timed out after ${s}ms`):n}}function h(e){let t=e.headers.get(`x-action-redirect`);if(t==null||t===``)return null;let[n=``]=t.split(`;`);return n!==``&&d(n),{redirect:n}}async function g(e,t){let n=t.headers.get(`content-type`),r=n!=null&&n!==``?n:``;if(r.startsWith(`text/x-component`))return;let i=t.status>=400&&r.startsWith(`text/plain`)?await t.text().catch(()=>t.statusText):`Server action "${e}" failed with status ${t.status}: ${t.statusText}`;throw Error(i)}export{f as callServer};
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import "../types-
|
|
1
|
+
import "../types-C8N3Hc8I.mjs";
|
|
2
2
|
import "virtual:rsc-integration.ts";
|
|
3
3
|
//#region src/runtime/entry-client.d.ts
|
|
4
|
-
declare function
|
|
5
|
-
|
|
6
|
-
//#endregion
|
|
7
|
-
export { preloadClientComponent, renderApp };
|
|
4
|
+
export declare function renderApp(): Promise<void>;
|
|
5
|
+
//#endregion
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{i as e,n as t,p as n,r,v as i}from"../type-guards-BJXKlA6x.mjs";import{t as a}from"../router-Cl4J7j1A.mjs";import{a as o,n as s,r as c}from"../rari-global-5vGzhToD.mjs";import{n as l,t as u}from"../preload-modules-Dv_GzGCm.mjs";import*as d from"react";import{createFromFetch as f,createFromReadableStream as p}from"virtual:react-flight-client";import{createRoot as m,hydrateRoot as h}from"react-dom/client";import{AppRouterProvider as g}from"virtual:app-router-provider";import{ClientRouter as _}from"virtual:client-router";import"virtual:rsc-integration.ts";function v(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 y(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_COMMENT);for(;t.nextNode();){let e=t.currentNode;if(e.nodeType===8&&`data`in e){let t=e.data;if(t===`$`||t===`$?`||t===`/$`)return!0}}return!!(e.querySelector(`[data-reactroot]`)||e.querySelectorAll(`template[data-rri]`).length>0)}function b(e){let t=e.tagName;if(t===`SCRIPT`||t===`STYLE`||t===`LINK`||t===`META`||t===`NOSCRIPT`)return!0;let n=typeof e.getAttribute==`function`?e.getAttribute.bind(e):null;return n==null?!1:n(`data-rari-nav-transition`)!=null||n(`aria-hidden`)===`true`}function x(e){let t=e.firstElementChild;for(;t!=null&&b(t);)t=t.nextElementSibling;return t}function S(e){if(y(e))return!0;let t=x(e);return t!==null&&!t.classList.contains(`rari-error`)}function C(e){return y(e)}function w(e){e.querySelectorAll(`.rari-error:not([data-rari-hydration-failure])`).forEach(e=>{e.remove()})}function T(e,t,n){return d.createElement(e,t,n)}async function E(e){let t=l(e);for(let e=0;e<10&&n(t);e+=1)t=l(await t);if(n(t))throw Error(`[rari] Failed to resolve Flight element to a React node`);return t}function D(e){return d.isValidElement(e)&&(e.type===`html`||e.type===`HTML`)}function O(e){if(!D(e))return v(document.body,`RSC payload did not resolve to an <html> document root. Try refreshing the page.`),console.error(`[rari] Hydration skipped: Flight content is not a document root`),!1;let t=d.createElement(g,{initialPayload:{element:e}});return t=T(_,{initialRoute:window.location.pathname},t),t=T(a,{initialPathname:window.location.pathname},t),j(t),!0}function k(){Reflect.set(globalThis,`__rari_client_ready`,!0),window.dispatchEvent(new CustomEvent(`rari:client-ready`))}function A(e){if(e===``)return;let t=()=>{document.title.trim()===``&&(document.title=e)};t(),queueMicrotask(t),requestAnimationFrame(()=>{t(),requestAnimationFrame(t)})}function j(e){let t=document.documentElement,n=document.title.trim();C(t)?(w(t),h(document,e,{onRecoverableError(e){import.meta.env.DEV&&console.warn(`[rari] Hydration mismatch:`,e)}})):m(document).render(e),A(n),k()}
|
|
2
2
|
/*! @preserve CLIENT_COMPONENT_IMPORTS_PLACEHOLDER */
|
|
3
|
-
|
|
3
|
+
c(),s();
|
|
4
4
|
/*! @preserve CLIENT_COMPONENT_REGISTRATIONS_PLACEHOLDER */
|
|
5
|
-
function
|
|
5
|
+
function M(){let e=Reflect.get(globalThis,`__rari_f`);if(Array.isArray(e))return e}function N(e){return i(e)&&typeof e.rscRow==`string`}function P(e){return Array.isArray(e)&&typeof e[1]==`string`}function F(){return!!M()?.some(e=>e!==0)}function I(){let e=M();if(e?.length==null||e.length===0)return null;let t=``,n=[];for(let r of e)r!==0&&(typeof r==`string`?t+=r:P(r)&&n.push(r[1]));if(n.length>0){let e=n.map(e=>Uint8Array.from(atob(e),e=>e.charCodeAt(0))),t=e.reduce((e,t)=>e+t.length,0),r=new Uint8Array(t),i=0;for(let t of e)r.set(t,i),i+=t.length;return r}return t?new TextEncoder().encode(t):null}async function L(t,n){let r=new TextDecoder().decode(t);await u(r);let i=o(),a=i.streaming,s=!!(a?.bufferedRows&&a.bufferedRows.length>0);if(n.streaming&&(a?.complete===void 0||s)){let n=new ReadableStream({start(n){let r=!1;n.enqueue(t);let a=t=>{if(r)return;let i=e(t,N);i&&n.enqueue(new TextEncoder().encode(`\n${i.rscRow}`))},o=()=>{r||(r=!0,n.close(),window.removeEventListener(`rari:html-stream-row`,a),window.removeEventListener(`rari:stream-complete`,o))};if(window.addEventListener(`rari:html-stream-row`,a),window.addEventListener(`rari:stream-complete`,o),i.streaming?.bufferedRows){let e=[...i.streaming.bufferedRows];for(let t of e)n.enqueue(new TextEncoder().encode(`\n${t}`));i.streaming.bufferedRows=[]}i.streaming?.complete&&o()}});return p(n)}let c=new ReadableStream({start(e){e.enqueue(t),e.close()}});return p(c)}async function R(e){let t=`Could not load interactive page data.`,n;try{n=await L(e,{streaming:!1})}catch(e){t=r(e,`Failed to parse embedded RSC payload.`);try{let e=window.location.pathname+window.location.search,r=await fetch(e,{headers:{Accept:`text/x-component`},cache:`no-store`});r.ok?n=await f(Promise.resolve(r)):t=`Failed to fetch RSC payload fallback: HTTP ${r.status}.`}catch(e){t=r(e,`Failed to fetch RSC payload fallback.`),console.error(`[rari] Failed to fetch RSC payload fallback:`,e)}}return n==null?(v(document.body,`${t} Try refreshing the page.`),console.error(`[rari] Hydration skipped: failed to load RSC payload`),{ok:!1,errorMessage:t}):(O(await E(n)),{ok:!0,errorMessage:t})}async function z(){try{let e=window.location.pathname+window.location.search,t=await fetch(e,{headers:{Accept:`text/x-component`},cache:`no-store`});if(!t.ok&&t.status!==404)throw Error(`Failed to fetch RSC data: ${t.status}`);if(!t.body)throw Error(`RSC response has no body`);return await f(Promise.resolve(t))}catch(e){if(e instanceof Promise)throw e;return console.error(`[rari] Failed to fetch initial RSC data:`,e),null}}function B(){return new ReadableStream({start(t){let n=n=>{let r=e(n,N);r&&t.enqueue(new TextEncoder().encode(`${r.rscRow}\n`))},r=()=>{t.close(),window.removeEventListener(`rari:html-stream-row`,n),window.removeEventListener(`rari:stream-complete`,r)};window.addEventListener(`rari:html-stream-row`,n),window.addEventListener(`rari:stream-complete`,r);let i=o();if(i.streaming?.bufferedRows){let e=[...i.streaming.bufferedRows];i.streaming.bufferedRows=[];for(let n of e)t.enqueue(new TextEncoder().encode(`${n}\n`))}i.streaming?.complete&&r()}})}async function V(){try{return await p(B())}catch(e){return console.error(`[rari] Failed to process streaming RSC payload:`,e),null}}async function H(e){try{return await L(e,{streaming:!0})}catch(e){return console.error(`[rari] Failed to parse embedded RSC payload:`,e),console.error(`[rari] Error stack:`,t(e)?.stack??`no stack`),null}}async function U(){let e=F(),t=I(),n=document.documentElement,r=S(document.body)||y(n),i=o().streaming,a=!!(i?.bufferedRows&&i.bufferedRows.length>0);try{if(r&&e&&t){await R(t);return}let n=!e&&!a&&!r,i;if(n?i=await z():e&&t?i=await H(t):a&&(i=await V()),i==null)throw Error(`No RSC data available for hydration`);O(await E(i))}catch(e){console.error(`[rari] Error rendering app:`,e)}}function W(){let e=import.meta.hot;if(!e)return{};let t=e.data;return i(t)?{hasRendered:t.hasRendered===!0}:{}}function G(){let e=import.meta.hot;if(!e)return;let t=e.data;i(t)&&(t.hasRendered=!0)}(!import.meta.hot||W().hasRendered!==!0)&&(U().catch(e=>{console.error(`[rari] Fatal error:`,e)}),G());export{U as renderApp};
|
|
@@ -1,33 +1,27 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SegmentPath } from "./flight-router-state.mjs";
|
|
2
2
|
import { ReactNode } from "react";
|
|
3
3
|
//#region src/runtime/flight/route-cache.d.ts
|
|
4
|
-
interface CacheNode {
|
|
4
|
+
export interface CacheNode {
|
|
5
5
|
rsc: ReactNode;
|
|
6
6
|
slots: Record<string, CacheNode> | null;
|
|
7
7
|
}
|
|
8
|
-
interface FlightRouteCacheEntry {
|
|
8
|
+
export interface FlightRouteCacheEntry {
|
|
9
9
|
pathname: string;
|
|
10
10
|
search: string;
|
|
11
11
|
segmentPath: SegmentPath;
|
|
12
12
|
node: CacheNode;
|
|
13
13
|
}
|
|
14
|
-
declare class FlightRouteCache {
|
|
14
|
+
export declare class FlightRouteCache {
|
|
15
15
|
private root;
|
|
16
|
-
private renderedSearch;
|
|
17
16
|
get(pathname: string, search: string): FlightRouteCacheEntry | undefined;
|
|
18
17
|
getElement(pathname: string, search: string): ReactNode | undefined;
|
|
19
18
|
set(pathname: string, search: string, element: ReactNode): void;
|
|
20
19
|
invalidate(pathname: string, search?: string): void;
|
|
21
|
-
invalidateSegmentPath(segmentPath: SegmentPath): void;
|
|
22
|
-
getRenderedSearch(): string;
|
|
23
|
-
getRouterTree(pathname: string): FlightRouterState;
|
|
24
20
|
clear(): void;
|
|
25
21
|
}
|
|
26
|
-
declare const flightRouteCache: FlightRouteCache;
|
|
27
|
-
declare function currentRouteLocation(): {
|
|
22
|
+
export declare const flightRouteCache: FlightRouteCache;
|
|
23
|
+
export declare function currentRouteLocation(): {
|
|
28
24
|
pathname: string;
|
|
29
25
|
search: string;
|
|
30
26
|
};
|
|
31
|
-
|
|
32
|
-
//#endregion
|
|
33
|
-
export { CacheNode, FlightRouteCache, FlightRouteCacheEntry, currentRouteLocation, currentSegmentPath, flightRouteCache, pathnameFromSegmentPath };
|
|
27
|
+
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{segmentPathFromPathname as e}from"./flight-router-state.mjs";function t(e=null){return{rsc:e,slots:null}}function n(e,n){return e.slots??={},e.slots[n]??=t(),e.slots[n]}function r(e,t){let r=e;for(let e of t)r=n(r,e);return r}function i(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 a=class{root=t();get(t,n){let i=e(t),a=r(this.root,i);if(a.rsc!=null)return{pathname:t,search:n,segmentPath:i,node:a}}getElement(e,t){return this.get(e,t)?.node.rsc}set(t,n,i){let a=e(t),o=r(this.root,a);o.rsc=i}invalidate(t,n=``){i(this.root,e(t))}clear(){this.root=t()}};const o=new a;function s(){return typeof window>`u`?{pathname:`/`,search:``}:{pathname:window.location.pathname,search:window.location.search}}export{a as FlightRouteCache,s as currentRouteLocation,o as flightRouteCache};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
//#region src/runtime/flight/router-state.d.ts
|
|
2
|
-
type FlightRouterState = readonly [segment: string, parallelRoutes: {
|
|
2
|
+
export type FlightRouterState = readonly [segment: string, parallelRoutes: {
|
|
3
3
|
readonly children?: FlightRouterState;
|
|
4
4
|
}];
|
|
5
|
-
type SegmentPath = readonly 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
|
-
|
|
11
|
-
|
|
5
|
+
export type SegmentPath = readonly string[];
|
|
6
|
+
export declare function buildFlightRouterState(pathname: string): FlightRouterState;
|
|
7
|
+
export declare function segmentPathFromRouterState(tree: FlightRouterState): SegmentPath;
|
|
8
|
+
export declare function segmentPathFromPathname(pathname: string): SegmentPath;
|
|
9
|
+
export declare function pathnameFromSegmentPath(segmentPath: SegmentPath): string;
|
|
10
|
+
export declare function sharedSegmentPath(fromPathname: string, toPathname: string): SegmentPath;
|
|
11
|
+
//#endregion
|
|
@@ -1 +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};
|
|
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(`/`)}`}function o(e,t){let n=i(e),r=i(t),a=[],o=Math.min(n.length,r.length);for(let e=0;e<o&&n[e]===r[e];e+=1)a.push(n[e]);return a}export{n as buildFlightRouterState,a as pathnameFromSegmentPath,i as segmentPathFromPathname,r as segmentPathFromRouterState,o as sharedSegmentPath};
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
//#region src/runtime/flight/merge-refresh.d.ts
|
|
3
|
-
declare
|
|
4
|
-
|
|
5
|
-
export
|
|
3
|
+
export declare const LAYOUT_REUSE_ELEMENT = "rari-layout-reuse";
|
|
4
|
+
export declare const LAYOUT_REUSE_PATH_PROP = "data-rari-layout-path";
|
|
5
|
+
export declare function isLayoutReuseMarker(element: React.ReactElement): boolean;
|
|
6
|
+
export declare function spliceLayoutReuseChildren(current: React.ReactNode, nextPage: React.ReactNode, layoutPath?: string): React.ReactNode;
|
|
7
|
+
export declare function mergeFlightRefresh(current: React.ReactNode, refresh: React.ReactNode): React.ReactNode;
|
|
8
|
+
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{l as e,o as t,s as n}from"../type-guards-BJXKlA6x.mjs";import*as r from"react";const i=`rari-layout-reuse`,a=`data-rari-layout-path`;function o(e){return r.isValidElement(e)}function s(t){return e(t.type)}function c(e){return e.type===`head`||e.type===`HEAD`}function l(e){return e.type===`html`||e.type===`HTML`}function u(e){return e.type===`body`||e.type===`BODY`}function d(e){return e.type===i}function f(e){let t=m(e)[a];return typeof t==`string`&&t!==``?t:void 0}function p(e){let t={...e};return delete t.children,t}function m(e){return t(e)}function h(e,t){if(!s(e)||!s(t))return!1;let r=n(e.type)?e.type.$$id:void 0,i=n(t.type)?t.type.$$id:void 0;return r==null||r===``||i==null||i===``||r!==i?!1:(e.key??null)===(t.key??null)}function g(e){return x(m(e).children)}function _(e){return Array.isArray(e)&&e.some(e=>Array.isArray(e))}function v(e,t){let n=e.key,i=typeof n==`string`&&n!==``?`${t}:${n.replace(/^\.+/,``)}`:t;return r.cloneElement(e,{key:i})}function y(e,t,n){return Array.isArray(e)?b(e,t==null?`.${n}`:`${t}:${n}`):e==null||e===!1||e===!0?[]:o(e)&&t!=null?[v(e,`${t}:${n}`)]:[e]}function b(e,t){if(!Array.isArray(e))return e==null||e===!1||e===!0?[]:o(e)&&t!=null?[v(e,t)]:[e];let n=[];for(let r=0;r<e.length;r+=1)n.push(...y(e[r],t,r));return n}function x(e){return e==null||e===!1||e===!0?[]:o(e)||typeof e==`string`||typeof e==`number`?[e]:Array.isArray(e)?b(e,null):r.Children.toArray(e)}function S(e){return o(e)?d(e)?!0:x(m(e).children).some(e=>S(e)):!1}function C(e){let t=e.type;return t===`title`||t===`TITLE`||t===`meta`||t===`META`||t===`link`||t===`LINK`}function w(e){if(e.type!==`link`&&e.type!==`LINK`)return!1;let t=m(e).rel;if(typeof t!=`string`||t===``)return!1;let n=t.toLowerCase();return n===`stylesheet`||n===`preload`||n===`modulepreload`||n===`preconnect`||n===`dns-prefetch`||n===`icon`||n===`shortcut icon`||n===`apple-touch-icon`}function T(e){return e.type===r.Fragment}function E(e){let t=[];for(let n of e){if(o(n)&&T(n)){t.push(...E(g(n)));continue}t.push(n)}return t}function D(e){if(e.type!==`meta`&&e.type!==`META`)return!1;let t=m(e);return t.charSet!=null||t.charset!=null||typeof t.httpEquiv==`string`&&t.httpEquiv.toLowerCase()===`content-type`||typeof t.name==`string`&&t.name.toLowerCase()===`viewport`}function O(e,t){let n=m(e);return E(t).some(e=>{if(!o(e)||!D(e))return!1;let t=m(e);return n.charSet!=null||n.charset!=null?t.charSet!=null||t.charset!=null:typeof n.httpEquiv==`string`&&n.httpEquiv.toLowerCase()===`content-type`?typeof t.httpEquiv==`string`&&t.httpEquiv.toLowerCase()===`content-type`:typeof t.name==`string`&&t.name.toLowerCase()===`viewport`})}function k(e,t){let n=m(e),r=E(g(e)),i=g(t),a=E(i);return I(e,n,[...r.filter(e=>{if(!o(e))return!0;if(e.type===`title`||e.type===`TITLE`)return!1;if(e.type===`meta`||e.type===`META`)return D(e)?!O(e,i):!1;if(!w(e))return!C(e);let t=m(e);return!a.some(e=>{if(!o(e)||!w(e))return!1;let n=m(e);return t.rel!=null&&t.rel===n.rel&&t.href===n.href})}),...a])}function A(e){return e.length===0?null:e.length===1?e[0]:[...e]}function j(e){let t=[];for(let n of x(e))t.push(M(n));return t}function M(e){if(Array.isArray(e))return A(j(e));if(!o(e))return e;if(d(e))return A(j(m(e).children));let t=m(e),n=x(t.children);if(n.length===0)return e;let r=j(n);return!_(t.children)&&r.every((e,t)=>e===n[t])?e:I(e,t,A(r))}function N(e,t){if(e.length===0)return[M(t)];if(e.length===1)return[Z(e[0],t)];let n=[],r=!1;for(let i of e)!r&&o(i)?(r=!0,n.push(Z(i,t))):n.push(i);return r?n:[M(t)]}function P(e,t){let n=[],r=0;for(let i of t){if(o(i)&&d(i)){n.push(...N(e.slice(r),i)),r=e.length;continue}let t=e[r];n.push(t===void 0?M(i):Z(t,i)),r+=1}return r<e.length&&n.push(...e.slice(r)),A(n)}function F(e,t){let n=x(e),r=x(t);return n.length===0?M(t):r.length===0?e:r.some(e=>o(e)&&d(e))?P(n,r):n.length===r.length?A(n.map((e,t)=>Z(e,r[t]))):M(t)}function I(e,t,n){let i=x(n);return r.cloneElement(e,p(t),...i.length===0?[null]:i)}function L(e,t){let n=g(e);for(let r=0;r<n.length;r+=1){let i=n[r];if(o(i)&&f(i)===t)return{parent:e,slotIndex:r}}for(let e=0;e<n.length;e+=1){let r=n[e];if(!o(r))continue;let i=L(r,t);if(i!=null)return i}return null}function R(e){return e.type===`main`||e.type===`MAIN`||g(e).some(e=>o(e)&&R(e))}const z=/* @__PURE__ */ new Set([.../* @__PURE__ */ new Set(/* @__PURE__ */ `area.base.br.col.embed.hr.img.input.link.meta.param.source.track.wbr.AREA.BASE.BR.COL.EMBED.HR.IMG.INPUT.LINK.META.PARAM.SOURCE.TRACK.WBR`.split(`.`)),`script`,`style`,`iframe`,`textarea`,`noscript`,`template`,`canvas`,`video`,`audio`,`object`,`embed`,`svg`,`math`,`select`,`title`,`SCRIPT`,`STYLE`,`IFRAME`,`TEXTAREA`,`NOSCRIPT`,`TEMPLATE`,`CANVAS`,`VIDEO`,`AUDIO`,`OBJECT`,`EMBED`,`SVG`,`MATH`,`SELECT`,`TITLE`]);function B(e){return typeof e.type!=`string`||z.has(e.type)?!1:g(e).length===0}function V(e,t){return h(e,t)?!0:e.type===t.type&&(e.key??null)===(t.key??null)}function H(e,t){let n=g(e);if(n.length===1&&o(n[0]))return Z(n[0],t);if(!o(t)||n.length===0)return t;let r=n.findIndex(e=>o(e)&&V(e,t));if(r<0)return t;let i=[...n];return i[r]=Z(n[r],t),i}function U(e,t,n){let r=L(e,n);if(r==null)return null;let i=m(r.parent),a=g(r.parent),s=[...a],c=a[r.slotIndex];return s[r.slotIndex]=o(c)?I(c,m(c),H(c,t)):t,q(e,r.parent,I(r.parent,i,s))}function W(e,t,n,r,i){let a=[...n];return a[r]=i,I(e,t,a)}function G(e,t,n){let r=m(e),i=g(e);if(e.type===`main`||e.type===`MAIN`)return I(e,r,H(e,t));if(i.length===1&&o(i[0]))return I(e,r,K(i[0],t,n));let a=i.findIndex(e=>o(e)&&(e.type===`main`||e.type===`MAIN`));if(a>=0)return W(e,r,i,a,K(i[a],t,n));for(let a=0;a<i.length;a+=1){let s=i[a];if(o(s)&&R(s))return W(e,r,i,a,K(s,t,n))}for(let n=0;n<i.length;n+=1){let a=i[n];if(o(a)&&B(a))return W(e,r,i,n,I(a,m(a),H(a,t)))}return I(e,r,H(e,t))}function K(e,t,n){if(!o(e))return t;if(o(t)&&d(t)){let r=f(t);return K(e,m(t).children,r??n)}if(n!=null&&n!==``){let r=U(e,t,n);if(r!=null)return r}return G(e,t,n)}function q(e,t,n){if(e===t)return n;let r=m(e),i=g(e),a=[],s=!1;for(let e of i){if(!o(e)){a.push(e);continue}if(e===t){s=!0,a.push(n);continue}let r=q(e,t,n);r!==e&&(s=!0),a.push(r)}return s?I(e,r,a):e}function J(e,t){let n=m(e),r=g(e),i=g(t),a=r.find(e=>o(e)&&c(e)),s=i.find(e=>o(e)&&c(e)),l=r.find(e=>o(e)&&u(e)),d=i.find(e=>o(e)&&u(e)),f=o(a)&&o(s)?k(a,s):o(a)?a:s,p=o(l)&&o(d)?Z(l,d):o(l)?l:d,h=[];return f!=null&&h.push(f),p!=null&&h.push(p),I(e,n,h)}function Y(e,t,n){let r=m(e),i=g(e),a=i.findIndex(e=>o(e)&&u(e)),s=a>=0?i[a]:void 0,c=o(s)?K(s,t.children,n):K(e,t.children,n);if(o(s)&&a>=0){let t=[...i];return t[a]=c,I(e,r,t)}return I(e,r,c)}function X(e,t){let n=m(e),r=m(t),i=x(r.children);if(i.length===1&&o(i[0])&&d(i[0])){let t=i[0];return K(e,m(t).children,f(t))}let a=F(n.children,r.children);return a===r.children?t:S(t)?I(e,n,a):I(t,r,a)}function Z(e,t){if(e==null)return M(t);if(t==null)return e;if(!o(e)||!o(t))return t;if(d(t)){let n=m(t),r=f(t);return l(e)?Y(e,n,r):K(e,n.children,r)}return l(e)&&l(t)&&S(t)?J(e,t):c(e)||c(t)?t:h(e,t)?S(t)?X(e,t):t:e.type===t.type?X(e,t):t}export{i as LAYOUT_REUSE_ELEMENT,a as LAYOUT_REUSE_PATH_PROP,d as isLayoutReuseMarker,Z as mergeFlightRefresh,K as spliceLayoutReuseChildren};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import "../types-
|
|
1
|
+
import "../types-C8N3Hc8I.mjs";
|
|
2
2
|
//#region src/runtime/shared/get-client-component.d.ts
|
|
3
3
|
declare function requireClientComponent(id: string): any;
|
|
4
4
|
//#endregion
|
|
5
5
|
//#region src/runtime/rsc/client-runtime.d.ts
|
|
6
6
|
declare global {
|
|
7
7
|
var __rari_rsc_require__: typeof requireClientComponent | undefined;
|
|
8
|
-
}
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{v as e}from"../type-guards-BJXKlA6x.mjs";import{a as t,i as n,n as r,r as i,t as a}from"../rari-global-5vGzhToD.mjs";import{n as o,r as s}from"../get-client-component-s7qprTUa.mjs";if(n().isDevelopment=process.env.NODE_ENV!==`production`,i(),a(),r(),typeof window<`u`&&(o(),Reflect.set(globalThis,`__rari_rsc_require__`,s)),typeof window<`u`){let e=t();e.streaming??={bufferedRows:[]}}if(import.meta.hot){function t(e){if(!e)return!1;try{return n().serverComponents?.has(e)===!0}catch{return!1}}let r=!1,i=[],a=/* @__PURE__ */ new Map;function o(e,t,n){a.set(e,async e=>{n(e)&&await t(e)}),import.meta.hot.on(e,t=>{(async()=>{if(!r){i.push({event:e,data:t});return}try{let n=a.get(e);n&&await n(t)}catch(t){console.error(`[rari] HMR: Error in handler for '${e}':`,t)}})()})}function s(t){return e(t)&&typeof t.filePath==`string`&&t.filePath!==``}function c(t){return e(t)&&Array.isArray(t.serverComponents)}function l(t){return e(t)&&typeof t.path==`string`&&t.path!==``}function u(t){return e(t)}function d(t){return e(t)&&typeof t.filePath==`string`&&t.filePath!==``}function f(t){return e(t)&&typeof t.filePath==`string`&&t.filePath!==``}o(`rari:register-server-component`,e=>{let t=n();t.serverComponents??=/* @__PURE__ */ new Set,t.serverComponents.add(e.filePath)},s),o(`rari:server-components-registry`,e=>{let t=n();t.serverComponents??=/* @__PURE__ */ new Set;for(let n of e.serverComponents)t.serverComponents.add(n)},c),o(`vite:beforeFullReload`,e=>{t(e.path)&&window.dispatchEvent(new CustomEvent(`rari:rsc-invalidate`,{detail:{filePath:e.path}}))},l),o(`rari:server-component-updated`,e=>{let n=e.id!=null&&e.id!==``?e.id:e.componentId,r=e.t!=null&&e.t!==0?e.t:e.timestamp;n!=null&&n!==``?window.dispatchEvent(new CustomEvent(`rari:rsc-invalidate`,{detail:{componentId:n,filePath:e.filePath!=null&&e.filePath!==``?e.filePath:e.file,type:`server-component`,timestamp:r}})):e.path!=null&&e.path!==``&&t(e.path)&&window.dispatchEvent(new CustomEvent(`rari:rsc-invalidate`,{detail:{filePath:e.path}}))},u);function p(e){if(e.title!=null&&e.title!==``&&(document.title=e.title),e.description==null||e.description===``)return;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 m(t){let n=e(t)&&t.success===!0,r=e(t)&&t.reloaded===!0,i=e(t)&&t.content_unchanged===!0,a=e(t)&&typeof t.error==`string`?t.error:`Component reload unsuccessful`;return{ok:n||r,contentUnchanged:i,errorMessage:a}}async function h(e){if(e.routePath!=null&&e.routePath!==``||e.affectedRoutes!=null&&e.affectedRoutes.length!==0)try{let t=await fetch(`/_rari/hmr`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`register`,file_path:e.filePath})});if(!t.ok)throw Error(`Component reload failed: ${t.status}`);let n=m(await t.json());if(!n.ok)throw Error(n.errorMessage);if(n.contentUnchanged)return;await fetch(`/_rari/hmr`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`invalidate`,componentId:e.routePath!=null&&e.routePath!==``?e.routePath:e.filePath,filePath:e.filePath})}),e.metadataChanged&&e.metadata&&p(e.metadata),window.dispatchEvent(new CustomEvent(`rari:app-router-rerender`,{detail:{routePath:e.routePath,affectedRoutes:e.affectedRoutes??(e.routePath==null?[]:[e.routePath]),currentPath:window.location.pathname,preserveParams:!0}}))}catch(e){console.error(`[rari] HMR: App router update failed:`,e)}}o(`rari:app-router-updated`,h,d),o(`rari:server-action-updated`,e=>{window.dispatchEvent(new CustomEvent(`rari:rsc-invalidate`,{detail:{filePath:e.filePath,type:`server-action`}}))},f),i.length>0?(async()=>{try{let e=[...i];i.length=0;for(let{event:t,data:n}of e){let e=a.get(t);e&&await e(n)}}catch(e){console.error(`[rari] HMR: Error during event replay:`,e)}finally{r=!0}})():r=!0}export{};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import "../types-_vPM8QuJ.mjs";
|
|
2
1
|
import { createClientModuleProxy as createClientModuleProxy$1, registerServerReference } from "react-server-dom-webpack/server";
|
|
3
2
|
//#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;
|
|
3
|
+
export declare const createClientModuleProxy: typeof createClientModuleProxy$1;
|
|
4
|
+
export declare function registerClientReference<T>(clientReference: T, id: string, exportName: string): T;
|
|
6
5
|
//#endregion
|
|
7
|
-
export {
|
|
6
|
+
export { registerServerReference };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{buildFlightRouterState as e}from"./runtime/flight-router-state.mjs";function t(){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 n(){return JSON.stringify(t())}export{n as t};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import{v as e}from"./type-guards-BJXKlA6x.mjs";import{t}from"./xml-DPsk9WTz.mjs";import{i as n,n as r,t as i}from"./execute-CbhDMAQ3.mjs";import{promises as a}from"node:fs";import o from"node:path";const s=/[^\w-]/g;function c(e){return(typeof e==`string`?new Date(e):e).toISOString()}function l(e){return[` <image:image>`,` <image:loc>${t(e)}</image:loc>`,` </image:image>`].join(`
|
|
2
|
+
`)}function u(e){let n=[` <image:image>`,` <image:loc>${t(e.loc)}</image:loc>`];return e.title!=null&&e.title!==``&&n.push(` <image:title>${t(e.title)}</image:title>`),e.caption!=null&&e.caption!==``&&n.push(` <image:caption>${t(e.caption)}</image:caption>`),e.geoLocation!=null&&e.geoLocation!==``&&n.push(` <image:geo_location>${t(e.geoLocation)}</image:geo_location>`),e.license!=null&&e.license!==``&&n.push(` <image:license>${t(e.license)}</image:license>`),n.push(` </image:image>`),n.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){return[` <video:video>`,` <video:title>${t(e.title)}</video:title>`,` <video:thumbnail_loc>${t(e.thumbnail_loc)}</video:thumbnail_loc>`,` <video:description>${t(e.description)}</video:description>`,...p(e),...m(e),...h(e),...g(e),` </video:video>`].join(`
|
|
5
|
+
`)}function p(e){let n=[];return e.content_loc!=null&&e.content_loc!==``&&n.push(` <video:content_loc>${t(e.content_loc)}</video:content_loc>`),e.player_loc!=null&&e.player_loc!==``&&n.push(` <video:player_loc>${t(e.player_loc)}</video:player_loc>`),n}function m(e){let n=[];return e.duration!==void 0&&n.push(` <video:duration>${e.duration}</video:duration>`),e.expiration_date!=null&&e.expiration_date!==``&&n.push(` <video:expiration_date>${t(e.expiration_date)}</video:expiration_date>`),e.rating!==void 0&&n.push(` <video:rating>${e.rating}</video:rating>`),e.view_count!==void 0&&n.push(` <video:view_count>${e.view_count}</video:view_count>`),e.publication_date!=null&&e.publication_date!==``&&n.push(` <video:publication_date>${t(e.publication_date)}</video:publication_date>`),n}function h(e){let t=[];return 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>`),t}function g(e){let n=[];if(e.restriction&&n.push(` <video:restriction relationship="${t(e.restriction.relationship)}">${t(e.restriction.content)}</video:restriction>`),e.platform&&n.push(` <video:platform relationship="${t(e.platform.relationship)}">${t(e.platform.content)}</video:platform>`),e.uploader){let r=e.uploader.info!=null&&e.uploader.info!==``?` info="${t(e.uploader.info)}"`:``;n.push(` <video:uploader${r}>${t(e.uploader.name)}</video:uploader>`)}if(e.tag)for(let r of e.tag)n.push(` <video:tag>${t(r)}</video:tag>`);return n}function _(e){return e.map(e=>f(e)).join(`
|
|
6
|
+
`)}function v(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 y(e,n){e.push(` <url>`),e.push(` <loc>${t(n.url)}</loc>`),n.lastModified!=null&&e.push(` <lastmod>${c(n.lastModified)}</lastmod>`),n.changeFrequency&&e.push(` <changefreq>${n.changeFrequency}</changefreq>`),n.priority!==void 0&&e.push(` <priority>${n.priority}</priority>`)}function b(e,n){if(n.alternates?.languages)for(let[r,i]of Object.entries(n.alternates.languages))e.push(` <xhtml:link rel="alternate" hreflang="${t(r)}" href="${t(i)}" />`)}function x(e,t){t.images&&t.images.length>0&&e.push(d(t.images)),t.videos&&t.videos.length>0&&e.push(_(t.videos))}function S(e){let t=[`<?xml version="1.0" encoding="UTF-8"?>`,`<urlset ${v(e).join(` `)}>`];for(let n of e)y(t,n),b(t,n),x(t,n),t.push(` </url>`);return t.push(`</urlset>`),t.join(`
|
|
7
|
+
`)}
|
|
8
|
+
/* v8 ignore start - file system operations, better tested in integration/e2e */
|
|
9
|
+
async function C(e,t=[`.ts`,`.tsx`,`.js`,`.jsx`,`.mjs`,`.json`]){let r=await n({appDir:e,staticFileName:`sitemap.xml`,dynamicBaseName:`sitemap`,extensions:t});return r?[r]:[]}function w(e){return typeof e==`function`||Array.isArray(e)}function T(t){return e(t)?w(t.default):!1}async function E(e,t,n={},r){let a=await i({virtualId:`\0virtual:sitemap`,sourcePath:e.path,sourceCode:t,aliases:n,projectRoot:r,kind:`sitemap`,pluginName:`virtual-sitemap`,label:`sitemap`});if(!T(a))throw Error(`Sitemap module must export a default sitemap array or sitemap generator function`);return a}async function D(e,t){let n=await e.generateSitemaps(),r=o.join(t,`sitemap`);await a.mkdir(r,{recursive:!0});let i=/* @__PURE__ */ new Map;for(let{id:t}of n)try{let n=t.replace(s,`_`);(!n||n.length===0)&&(n=`_`);let c=i.get(n);if(c!==void 0)throw Error(`Duplicate sanitized sitemap ID "${n}": original IDs "${c}" and "${t}" collide`);i.set(n,t);let l=typeof e.default==`function`?await e.default({id:t}):e.default;if(!Array.isArray(l))throw Error(`Sitemap default export must resolve to a sitemap entry array`);let u=S(l),d=o.join(r,`${n}.xml`);await a.writeFile(d,u)}catch(e){throw Error(`Failed to generate sitemap for id "${t}"`,{cause:e})}}async function O(e,t){let n=typeof e.default==`function`?await e.default():e.default;if(!Array.isArray(n))throw Error(`Sitemap default export must resolve to a sitemap entry array`);let r=S(n),i=o.join(t,`sitemap.xml`);await a.writeFile(i,r)}
|
|
10
|
+
/* v8 ignore start - file system operations and dynamic imports, better tested in integration/e2e */
|
|
11
|
+
async function k(e){let{appDir:t,extensions:n,outDir:i,aliases:s={}}=e,c=await C(t,n);if(c.length===0)return!1;await a.mkdir(i,{recursive:!0});let l=c[0];if(l.type===`static`){let e=o.join(i,`sitemap.xml`);return await a.copyFile(l.path,e),!0}try{let e=await E(l,await a.readFile(l.path,`utf-8`),s,r(t));return typeof e.generateSitemaps==`function`?await D(e,i):await O(e,i),!0}catch(e){return console.error(`[rari] Failed to build/execute sitemap file:`,e),!1}}
|
|
12
|
+
/* v8 ignore stop */
|
|
13
|
+
export{k as generateSitemapFiles};
|