rari 0.17.9 → 0.17.11
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/cli.d.mts +4 -7
- package/dist/cli.mjs +49 -40
- package/dist/define-BIL9PMLh.mjs +1 -0
- package/dist/{define-BafO1-XT.d.mts → define-DCZgXfOp.d.mts} +0 -2
- package/dist/fly-BZsz03bn.mjs +59 -0
- package/dist/font/google-catalog.d.mts +15 -0
- package/dist/font/google.d.mts +1 -3
- package/dist/font/local.d.mts +2 -4
- package/dist/font.d.mts +1 -1
- package/dist/get-client-component-DVAbynLr.mjs +1 -0
- package/dist/headers.d.mts +1 -3
- package/dist/image/runtime-config.d.mts +1 -3
- package/dist/image/static.d.mts +1 -1
- package/dist/image.d.mts +1 -5
- package/dist/image.mjs +1 -1
- package/dist/index.d.mts +2 -4
- package/dist/mdx/define.d.mts +1 -1
- package/dist/mdx/define.mjs +1 -1
- package/dist/mdx/registry.d.mts +1 -3
- package/dist/mdx.d.mts +1 -5
- package/dist/mdx.mjs +1 -1
- package/dist/og.d.mts +0 -2
- package/dist/platform.d.mts +1 -3
- package/dist/{preload-modules-BDQFWAlZ.mjs → preload-modules-0iyuP4Vs.mjs} +2 -2
- package/dist/proxy/RariRequest.d.mts +2 -4
- package/dist/proxy/RariResponse.d.mts +1 -1
- package/dist/proxy/executor.d.mts +1 -3
- package/dist/railway-DUCTAuA9.mjs +10 -0
- package/dist/{react-helpers-GTRYJwF2.d.mts → react-helpers-CZtKqfS6.d.mts} +0 -2
- package/dist/render-DawwdqvN.mjs +14 -0
- package/dist/{router-kf_rLP_F.mjs → router-861SNPMt.mjs} +1 -1
- package/dist/router.d.mts +0 -8
- package/dist/router.mjs +1 -1
- package/dist/runtime/AppRouterProvider.d.mts +1 -5
- package/dist/runtime/AppRouterProvider.mjs +1 -1
- package/dist/runtime/ClientRouter.d.mts +1 -3
- package/dist/runtime/ClientRouter.mjs +3 -3
- package/dist/runtime/ErrorBoundaryWrapper.d.mts +0 -2
- package/dist/runtime/ErrorBoundaryWrapper.mjs +1 -1
- package/dist/runtime/action-flight-refresh.d.mts +0 -2
- package/dist/runtime/action-revalidation-kind.d.mts +1 -3
- package/dist/runtime/call-server.d.mts +1 -3
- package/dist/runtime/entry-client.d.mts +2 -4
- package/dist/runtime/entry-client.mjs +3 -3
- package/dist/runtime/merge-flight-refresh.d.mts +2 -4
- package/dist/runtime/rsc-client-runtime.d.mts +1 -5
- package/dist/runtime/rsc-client-runtime.mjs +1 -1
- package/dist/runtime/rsc-references.d.mts +0 -2
- package/dist/{sitemap-DIL-PFSt.mjs → sitemap-ByPlT2YN.mjs} +1 -1
- package/dist/{static-modules-BnpA9S9v.d.mts → static-modules-DmO7M_cF.d.mts} +0 -4
- package/dist/{types-DAdRjhuk.d.mts → types-CSDt4P_t.d.mts} +0 -4
- package/dist/{types-C8N3Hc8I.d.mts → types-Cw2SI7r7.d.mts} +0 -2
- package/dist/{types-yeW6ju9Y.d.mts → types-DNk27dqJ.d.mts} +0 -10
- package/dist/{types-CkZPEEdi.d.mts → types-DeWes1rB.d.mts} +0 -2
- package/dist/{utils-YdvPzSET-Cbo6Ofmz.mjs → utils-DZWuxUA--BobVI1xy.mjs} +1 -37
- package/dist/vite.d.mts +2 -26
- package/dist/vite.mjs +77 -75
- package/package.json +14 -14
- package/dist/define-Dsj1lR4C.mjs +0 -1
- package/dist/get-client-component-D2K213pV.mjs +0 -1
- package/dist/railway-CE3nqaKt.mjs +0 -67
- package/dist/render-D0eMtn5L.mjs +0 -73
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import{i as e,n as t,o as n,r,t as i}from"./utils-DZWuxUA--BobVI1xy.mjs";import a from"node:process";import{styleText as o}from"node:util";function s(){let r=a.cwd();n(`Creating Render deployment configuration...`);let s=i(r,{providerName:`Render`});c(r),t(`Render`,[...s?[`${o(`cyan`,e(r))} (updates your lockfile for rari)`]:[],o(`cyan`,`git add .`),o(`cyan`,`git commit -m "Add Render deployment"`),o(`cyan`,`git push origin main`),`Go to ${o(`cyan`,`https://render.com`)} and create a Web Service`],[`Bind to 0.0.0.0 (Render requirement)`,`Use Render's PORT environment variable`])}function c(e){r(e,`render.yaml`,`services:
|
|
2
|
+
- type: web
|
|
3
|
+
name: rari-app
|
|
4
|
+
runtime: node
|
|
5
|
+
plan: free
|
|
6
|
+
buildCommand: npm install --include=dev && npx rari build
|
|
7
|
+
startCommand: npm start
|
|
8
|
+
healthCheckPath: /_rari/health
|
|
9
|
+
envVars:
|
|
10
|
+
- key: NODE_ENV
|
|
11
|
+
value: production
|
|
12
|
+
- key: RUST_LOG
|
|
13
|
+
value: info
|
|
14
|
+
`)}export{s as createRenderDeployment};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./navigate-CSQP4q53.mjs";import{g as t,i as n}from"./type-guards-BLY2PlGR.mjs";import{i as r,n as i,r as a,t as o}from"./navigation-transition-store-dfNJmkIX.mjs";import{c as s}from"react/compiler-runtime";import{createContext as c,use as l,useEffect as u,useRef as d,useSyncExternalStore as f}from"react";import{jsx as p}from"react/jsx-runtime";const m=c(null);function h(){let e=l(m);if(!e)throw Error(`useRouter must be used within a RouterProvider`);return e}function g(){return h().pathname}function _(){return h().searchParams}function v(){return f(a,b,y)}function y(){return o().generation}function b(){return i().generation}function x(e){return t(e)&&typeof e.navigate==`function`}function S(t){let r=s(
|
|
1
|
+
import{n as e}from"./navigate-CSQP4q53.mjs";import{g as t,i as n}from"./type-guards-BLY2PlGR.mjs";import{i as r,n as i,r as a,t as o}from"./navigation-transition-store-dfNJmkIX.mjs";import{c as s}from"react/compiler-runtime";import{createContext as c,use as l,useEffect as u,useRef as d,useSyncExternalStore as f}from"react";import{jsx as p}from"react/jsx-runtime";const m=c(null);function h(){let e=l(m);if(!e)throw Error(`useRouter must be used within a RouterProvider`);return e}function g(){return h().pathname}function _(){return h().searchParams}function v(){return f(a,b,y)}function y(){return o().generation}function b(){return i().generation}function x(e){return t(e)&&typeof e.navigate==`function`}function S(t){let r=s(15),{children:c,initialPathname:l}=t,h;r[0]===l?h=r[1]:(h=()=>o(l),r[0]=l,r[1]=h);let g=f(a,i,h),_=d(null),v;r[2]===Symbol.for(`react.memo_cache_sentinel`)?(v=[],r[2]=v):v=r[2],u(D,v);let y,b;r[3]===Symbol.for(`react.memo_cache_sentinel`)?(y=()=>{let t=e();t&&(_.current=t);let r=e=>{let t=n(e,x);t&&(_.current=t.navigate)},i=()=>{_.current=null};return window.addEventListener(`rari:register-navigate`,r),window.addEventListener(`rari:deregister-navigate`,i),()=>{window.removeEventListener(`rari:register-navigate`,r),window.removeEventListener(`rari:deregister-navigate`,i)}},b=[],r[3]=y,r[4]=b):(y=r[3],b=r[4]),u(y,b);let S;r[5]===g.search?S=r[6]:(S=g.search.startsWith(`?`)?g.search.slice(1):g.search,r[5]=g.search,r[6]=S);let O;r[7]===S?O=r[8]:(O=new URLSearchParams(S),r[7]=S,r[8]=O);let k=O,A;r[9]!==k||r[10]!==g.pathname?(A={pathname:g.pathname,searchParams:k,push:async(e,t)=>{_.current?await _.current(e,t):(console.warn(`[rari] Router not ready, falling back to window.location`),window.location.href=e)},replace:async(e,t)=>{_.current?await _.current(e,{...t,replace:!0}):(console.warn(`[rari] Router not ready, falling back to window.location`),window.location.replace(e))},back:E,forward:T,refresh:w,prefetch:C},r[9]=k,r[10]=g.pathname,r[11]=A):A=r[11];let j=A,M;return r[12]!==c||r[13]!==j?(M=/* @__PURE__ */ p(m,{value:j,children:c}),r[12]=c,r[13]=j,r[14]=M):M=r[14],M}async function C(e){try{let t=new URL(e,window.location.origin);await fetch(t.pathname+t.search,{headers:{Accept:`text/x-component`},priority:`low`})}catch(e){console.warn(`[rari] Prefetch failed:`,e)}}function w(){window.dispatchEvent(new CustomEvent(`rari:app-router-rerender`))}function T(){window.history.forward()}function E(){window.history.back()}function D(){r()}export{v as a,_ as i,g as n,h as r,S as t};
|
package/dist/router.d.mts
CHANGED
|
@@ -1,22 +1,15 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
|
-
//#region src/router/navigation/types.d.ts
|
|
3
2
|
interface NavigationOptions {
|
|
4
3
|
readonly replace?: boolean;
|
|
5
4
|
readonly scroll?: boolean;
|
|
6
5
|
readonly historyKey?: string;
|
|
7
6
|
}
|
|
8
|
-
//#endregion
|
|
9
|
-
//#region src/router/navigation/navigate.d.ts
|
|
10
7
|
export declare function navigate(href: string, options?: NavigationOptions): Promise<void>;
|
|
11
|
-
//#endregion
|
|
12
|
-
//#region src/router/navigation/router-provider.d.ts
|
|
13
8
|
interface RouterProviderProps {
|
|
14
9
|
readonly children: ReactNode;
|
|
15
10
|
readonly initialPathname: string;
|
|
16
11
|
}
|
|
17
12
|
export declare function RouterProvider({ children, initialPathname }: RouterProviderProps): import("react").JSX.Element;
|
|
18
|
-
//#endregion
|
|
19
|
-
//#region src/router/navigation/use-router.d.ts
|
|
20
13
|
interface RouterContextValue {
|
|
21
14
|
pathname: string;
|
|
22
15
|
searchParams: URLSearchParams;
|
|
@@ -31,5 +24,4 @@ export declare function useRouter(): RouterContextValue;
|
|
|
31
24
|
export declare function usePathname(): string;
|
|
32
25
|
export declare function useSearchParams(): URLSearchParams;
|
|
33
26
|
export declare function useViewTransitionKey(): number;
|
|
34
|
-
//#endregion
|
|
35
27
|
export type { NavigationOptions, RouterContextValue, RouterProviderProps };
|
package/dist/router.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./navigate-CSQP4q53.mjs";import{a as t,i as n,n as r,r as i,t as a}from"./router-
|
|
1
|
+
import{r as e}from"./navigate-CSQP4q53.mjs";import{a as t,i as n,n as r,r as i,t as a}from"./router-861SNPMt.mjs";export{a as RouterProvider,e as navigate,r as usePathname,i as useRouter,n as useSearchParams,t as useViewTransitionKey};
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import { t as FlightContent } from "../react-helpers-
|
|
1
|
+
import { t as FlightContent } from "../react-helpers-CZtKqfS6.mjs";
|
|
2
2
|
import { ReactElement, ReactNode } from "react";
|
|
3
|
-
//#region src/runtime/flight/apply-flight-patch.d.ts
|
|
4
3
|
interface PendingLeafEviction {
|
|
5
4
|
readonly pathname: string;
|
|
6
5
|
readonly search: string;
|
|
7
6
|
}
|
|
8
|
-
//#endregion
|
|
9
|
-
//#region src/runtime/flight/app-router-provider.d.ts
|
|
10
7
|
interface RscPayload {
|
|
11
8
|
readonly element: FlightContent;
|
|
12
9
|
readonly flightProtocol?: string;
|
|
@@ -43,5 +40,4 @@ interface NavigationDetail {
|
|
|
43
40
|
};
|
|
44
41
|
}
|
|
45
42
|
export declare function AppRouterProvider({ children, initialPayload, onNavigate }: AppRouterProviderProps): import("react").JSX.Element;
|
|
46
|
-
//#endregion
|
|
47
43
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{S as e,d as t,g as n,i as r,p as i,r as a,s as o}from"../type-guards-BLY2PlGR.mjs";import{i as s}from"../navigation-transition-store-dfNJmkIX.mjs";import{isLayoutReuseMarker as c,layoutPathOf as l,mergeFlightRefresh as u,unwrapFulfilledFlightNode as d}from"./merge-flight-refresh.mjs";import{a as f,i as p,n as m,r as h,t as g}from"../react-helpers-duOBWuYF.mjs";import{i as _,n as v,r as y,t as b}from"../route-cache-BfEqTT9i.mjs";import"./action-revalidation-kind.mjs";import{n as x,t as ee}from"../preload-modules-BDQFWAlZ.mjs";import{n as te,r as ne}from"../form-state-C9jn086j.mjs";import{c as S}from"react/compiler-runtime";import{Suspense as C,addTransitionType as re,cloneElement as ie,createContext as w,createElement as T,isValidElement as E,startTransition as ae,use as D,useCallback as oe,useEffect as O,useLayoutEffect as se,useRef as k,useState as A,useSyncExternalStore as j}from"react";import{jsx as M,jsxs as N}from"react/jsx-runtime";import{createFromFetch as ce,createFromReadableStream as le}from"virtual:react-flight-client";const ue={position:`fixed`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,padding:`24px`,background:`rgba(220, 38, 38, 0.95)`,color:`white`,borderRadius:`8px`,fontSize:`14px`,zIndex:1e4,maxWidth:`500px`,boxShadow:`0 4px 6px rgba(0, 0, 0, 0.3)`},P={padding:`8px 16px`,background:`white`,color:`#dc2626`,border:`none`,borderRadius:`4px`,cursor:`pointer`,fontWeight:`bold`,fontSize:`14px`},F={padding:`8px 16px`,background:`rgba(255, 255, 255, 0.2)`,color:`white`,border:`1px solid rgba(255, 255, 255, 0.3)`,borderRadius:`4px`,cursor:`pointer`,fontSize:`14px`},de={fetch:`Failed to fetch updated content from server.`,parse:`Failed to parse server response.`,stale:`Server returned stale content.`,network:`Network error occurred.`};function I(e){return de[e]}function fe(e){let t=S(27),{failure:n,maxRetries:r,onRefresh:i,onDismiss:a}=e,o,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=/* @__PURE__ */ M(`div`,{style:{marginBottom:`16px`,fontWeight:`bold`,fontSize:`16px`},children:`⚠️ HMR Update Failed`}),s={marginBottom:`12px`,opacity:.9},t[0]=o,t[1]=s):(o=t[0],s=t[1]);let c;t[2]===n.type?c=t[3]:(c=I(n.type),t[2]=n.type,t[3]=c);let l;t[4]===c?l=t[5]:(l=/* @__PURE__ */ M(`div`,{style:s,children:c}),t[4]=c,t[5]=l);let u;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(u={marginBottom:`16px`,fontSize:`12px`,opacity:.8,fontFamily:`monospace`},t[6]=u):u=t[6];let d;t[7]===n.details?d=t[8]:(d=/* @__PURE__ */ M(`div`,{style:u,children:n.details}),t[7]=n.details,t[8]=d);let f;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(f={marginBottom:`12px`,fontSize:`12px`,opacity:.7},t[9]=f):f=t[9];let p;t[10]!==n.consecutiveFailures||t[11]!==r?(p=/* @__PURE__ */ N(`div`,{style:f,children:[`Consecutive failures: `,n.consecutiveFailures,` / `,r]}),t[10]=n.consecutiveFailures,t[11]=r,t[12]=p):p=t[12];let m;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(m={display:`flex`,gap:`8px`},t[13]=m):m=t[13];let h;t[14]===i?h=t[15]:(h=/* @__PURE__ */ M(`button`,{onClick:i,type:`button`,style:P,children:`Refresh Page`}),t[14]=i,t[15]=h);let g;t[16]===a?g=t[17]:(g=/* @__PURE__ */ M(`button`,{onClick:a,type:`button`,style:F,children:`Dismiss`}),t[16]=a,t[17]=g);let _;t[18]!==h||t[19]!==g?(_=/* @__PURE__ */ N(`div`,{style:m,children:[h,g]}),t[18]=h,t[19]=g,t[20]=_):_=t[20];let v;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(v=/* @__PURE__ */ M(`div`,{style:{marginTop:`12px`,fontSize:`11px`,opacity:.6},children:`Check the console for detailed error logs.`}),t[21]=v):v=t[21];let y;return t[22]!==_||t[23]!==l||t[24]!==d||t[25]!==p?(y=/* @__PURE__ */ N(`div`,{style:ue,children:[o,l,d,p,_,v]}),t[22]=_,t[23]=l,t[24]=d,t[25]=p,t[26]=y):y=t[26],y}function L(e,t,n){y.getShell()??y.ingest(e,t,n)}function R(e){if(e.fromPathname!==`/`&&(e.fromPathname!==e.toPathname||e.fromSearch!==e.search))return{pathname:e.fromPathname,search:e.fromSearch}}function z(e){if(L(e.previousDocument,e.fromPathname,e.fromSearch),h(e.refresh)){if(!y.ingest(e.refresh,e.toPathname,e.search))return{kind:`hard-nav`}}else if(E(e.refresh)){if(!y.ingestSegment(e.refresh,e.toPathname,e.search))return{kind:`hard-nav`}}else return{kind:`hard-nav`};if(y.getShell()==null||!y.hasRoute(e.toPathname,e.search))return{kind:`hard-nav`};let t=y.readLeaf(e.toPathname,e.search),n=m(e.refresh)||t!=null&&m(t),r=t!=null&&p(t)||p(e.refresh),i=R(e);return h(e.refresh)?{kind:`merged`,element:e.refresh,maySuspend:n,hasLoadingFallback:r,pendingEvictLeaf:i}:{kind:`merged`,element:e.previousDocument,maySuspend:n,hasLoadingFallback:r,pendingEvictLeaf:i}}function B(e,t,n,r){if(h(t))return y.ingest(t,n,r);if(E(t)&&y.getShell()!=null)return y.ingestSegment(t,n,r);let i=u(e,t);return E(t)&&c(t)&&i===e||!h(i)?!1:y.ingest(i,n,r)}function V(e,t){let n=m(e),r=p(e);return h(e)?{kind:`merged`,element:e,maySuspend:n,hasLoadingFallback:r}:h(t)?{kind:`merged`,element:t,maySuspend:n,hasLoadingFallback:r}:{kind:`hard-nav`}}function pe(e){return h(e.previousDocument)&&y.getShell()==null&&!y.ingest(e.previousDocument,e.pathname,e.search)||!B(e.previousDocument,e.refresh,e.pathname,e.search)||y.getShell()==null||!y.hasRoute(e.pathname,e.search)?{kind:`hard-nav`}:V(e.refresh,e.previousDocument)}function me(e){return e.historyKey!=null&&e.historyKey!==``?[`nav`,`nav-traverse`]:e.replace===!0?[`nav`,`nav-replace`]:[`nav`,`nav-forward`]}function he(e,t){if(e==null||e.url===``)return t;try{let t=`http://localhost/`;if(typeof window<`u`)try{t=window.location.href}catch{}let n=new URL(e.url,t);return{pathname:n.pathname,search:n.search}}catch{return t}}function H(e){e!=null&&typeof window<`u`&&(e.replace===!0?window.history.replaceState(e.state,``,e.url):window.history.pushState(e.state,``,e.url))}function ge(e){let{parsedPayload:t,shouldScrollToTop:n,navigationId:r,transitionTypes:i,maySuspend:a=!1,hasLoadingFallback:o=!1,pendingHistory:s,routeLocation:c,startTransition:l=ae,currentNavigationIdRef:u,pendingScrollPayloadRef:d,setRenderKey:f,setRscPayload:p,setRouteLocation:m,setPendingLoadingLeaf:h,clearHmrError:g,pendingNavigateCommittedIdRef:_,pendingEvictLeaf:v}=e;if(u.current!==r)return;let b=a&&o;a&&H(s),b&&c!=null&&(m?.(c),h?.(c));let x=()=>{u.current===r&&(h?.(null),a||H(s),c!=null&&m?.(c),v!=null&&y.evictLeaf(v.pathname,v.search),f(e=>{let r=e+1;return d.current=n?{payload:t,commitKey:r}:null,r}),p(t),g(),_.current=r)};l(()=>{if(i!=null)for(let e of i)re(e);x()})}const _e=w(null);function U(){return D(_e)}function W(e,t,n){return n?.pathname===e&&n.search===t}function G(){return j(y.subscribe,y.getVersion,y.getVersion)}function K(e){return l(e)!=null&&!_(e)&&!c(e)}function q(e,t,n){if(e==null||e===!1||e===!0)return e;if(Array.isArray(e))return g(e).map(e=>q(e,t,n));if(!E(e))return e;if(_(e)||K(e)){let r=l(e);return r==null?null:T(Y,{key:r,layoutPath:r,pathname:t,search:n})}let r=e.props,i=r.children;if(i==null)return e;let a=q(i,t,n);if(Object.is(a,i))return e;let o=g(a),s={...r};return delete s.children,ie(e,s,...o.length===0?[null]:o)}function J({layoutPath:e,pathname:t,search:n},r,i=null){let a=y.readSegmentSnapshot(e,{pathname:t,search:n});if(a==null||E(a)&&_(a))return null;if(y.isDeepestLayout(e,t)){let{fallback:e,content:r}=f(a);return W(t,n,i)&&e!=null?e:T(C,{fallback:e},r)}return q(a,t,n)}function Y(e){let t=S(4),n=G(),r=U(),i;return t[0]!==n||t[1]!==r||t[2]!==e?(i=J(e,n,r),t[0]=n,t[1]=r,t[2]=e,t[3]=i):i=t[3],i}function ve({fallback:e=null,pathname:t,search:n},r){let i=y.getShell();if(i!=null){let e=q(i,t,n);return E(e)?e:null}return e!=null&&b(e)?null:e}function ye(e){let t=S(3),n=G(),r;return t[0]!==n||t[1]!==e?(r=ve(e,n),t[0]=n,t[1]=e,t[2]=r):r=t[2],r}function be(e,t,n){return e==null||e.commitKey!==n?{shouldScroll:!1,nextPending:null}:t===e.payload?{shouldScroll:!0,nextPending:null}:{shouldScroll:!1,nextPending:e}}function xe(e){if(e==null)return null;if(i(e)){let t=d(e);return t===e||!h(t)?null:t}return h(e)?e:null}const Se=/"timestamp":(\d+)/;function Ce(e){if(!t(e)||o(e))return!1;let n=e.message;return n===`Failed to fetch`||n.includes(`NetworkError`)||n.includes(`network error`)||n.includes(`Load failed`)}async function we(e){await new Promise(t=>{setTimeout(t,e)})}async function X(e,t,n){if(e.maySuspend!==!0||e.hasLoadingFallback!==!0)return e;if(e.bodyComplete==null){await Promise.resolve();let r=y.readLeaf(t,n);return r!=null&&!m(r)?{...e,maySuspend:!1}:e}if(await Promise.race([e.bodyComplete.then(e=>e?`body`:`failed`),we(100).then(()=>`timeout`)])===`body`)return{...e,maySuspend:!1};let r=y.readLeaf(t,n);return r!=null&&!m(r)?{...e,maySuspend:!1}:e}function Te(e){return e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`||E(e)||Array.isArray(e)}function Ee(e){return n(e)&&typeof e.from==`string`&&typeof e.to==`string`&&typeof e.navigationId==`number`&&n(e.options)}function De(e){return n(e)&&`element`in e}function Oe(e){return n(e)&&typeof e.navigationId==`number`&&typeof e.targetPath==`string`}function ke(e){if(!i(e))return e;if(n(e)&&e.status===`fulfilled`)return Te(e.value)?e.value:void 0}function Ae(e){return h(e)||E(e)&&c(e)}function je(e){let t=e.pendingHistory?.url;if(t!=null&&t!==``)try{return new URL(t,window.location.origin).search}catch{}return v().search}function Me(e,t){console.error(`[rari] AppRouter: Navigation failed:`,t),window.dispatchEvent(new CustomEvent(`rari:navigate-error`,{detail:{from:e.from,to:e.to,error:t,navigationId:e.navigationId}}))}function Ne(e){let t=e.pendingHistory?.url,n=t!=null&&t!==``?new URL(t,window.location.origin).hash.length>0:window.location.hash.length>0;return(e.options.historyKey==null||e.options.historyKey===``)&&!n&&e.options.scroll!==!1}async function Pe(e,t,n,r,i,a,o,s){let l=await Fe(e.element);if(r!==n)return{kind:`superseded`};if(!Ae(l))return{kind:`error`,error:/* @__PURE__ */ Error(`[rari] AppRouter: navigated Flight content did not resolve to an <html> document root`)};let u=xe(t);if(E(l)&&c(l)&&u==null)return{kind:`error`,error:/* @__PURE__ */ Error(`[rari] AppRouter: layout-reuse Flight marker requires a previous <html> document`)};if(u==null)return h(l)?(y.set(a,o,l),{kind:`payload`,payload:await X({...e,element:l,maySuspend:m(l),hasLoadingFallback:p(l)},a,o)}):{kind:`error`,error:/* @__PURE__ */ Error(`[rari] AppRouter: navigated Flight content did not resolve to an <html> document root`)};let d=z({previousDocument:u,refresh:l,fromPathname:i,toPathname:a,fromSearch:s,search:o});return d.kind===`hard-nav`?{kind:`hard-nav`}:{kind:`payload`,payload:await X({...e,element:d.element,maySuspend:d.maySuspend,hasLoadingFallback:d.hasLoadingFallback===!0,pendingEvictLeaf:d.pendingEvictLeaf},a,o)}}async function Fe(e){let t=x(e);for(let e=0;e<10&&i(t);e+=1)t=x(await t);if(i(t))throw Error(`[rari] AppRouter: Flight content did not resolve to a React node`);return t}function Ie({children:c,initialPayload:l,onNavigate:u}){let[d,f]=A(l),p=k(l),[m,g]=A(0),[_,S]=A(()=>v()),[C,re]=A(null),ie=k(_),w=k({x:0,y:0}),T=k(null),D=k(/* @__PURE__ */ new Map),j=k(/* @__PURE__ */ new Set),ue=k(u),P=k(0),F=k(0),de=k(/* @__PURE__ */ new Map),I=k(null),L=k(null),R=k(/* @__PURE__ */ new Map),z=k([]),B=k(null),V=k(0),[H,U]=A(null);O(()=>{ie.current=_},[_]),O(()=>{ue.current=u},[u]),se(()=>{let{shouldScroll:e,nextPending:t}=be(T.current,d,m);T.current=t,e&&window.scrollTo(0,0);let n=L.current;n!=null&&(L.current=null,window.dispatchEvent(new CustomEvent(`rari:navigate-committed`,{detail:{navigationId:n}})))},[d,m]),O(()=>{s()},[m]);let W=oe(e=>{if(e==null||i(e)||!E(e)||e.type!==`html`&&e.type!==`HTML`||b(e))return;let{pathname:t,search:n}=_;y.getShell()!=null&&y.hasRoute(t,n)||y.set(t,n,e)},[_]),G=k(W);O(()=>{G.current=W},[W]),O(()=>{p.current=d,d?.element!=null&&W(d.element)},[d,W]),O(()=>{if(d?.element!=null){let e=d.element;if(n(e)&&`status`in e&&e.status===`rejected`){let t=e.reason;t!=null&&t!==``&&console.error(`[rari] AppRouter: Flight payload rejected:`,t)}}},[d]);let K=()=>{D.current=te()},q=()=>{ne(D.current)};se(()=>{let e=I.current;e!=null&&d===e&&(I.current=null,window.scrollTo(w.current.x,w.current.y),q())},[d,m]);let J=(e,t,n,r)=>{V.current+=1;let i={timestamp:Date.now(),error:e,type:t,details:n,filePath:r,consecutiveFailures:V.current};z.current.push(i),z.current.length>10&&z.current.shift(),V.current>=2&&U(i),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`rari:hmr-failure`,{detail:i}))},Y=()=>{setTimeout(()=>{window.location.reload()},1e3)},ve=()=>{V.current>0&&(V.current=0)},xe=e=>{if(B.current==null||B.current===``)return!1;if(e===B.current)return!0;let t=Se.exec(e);if(t){let e=Number.parseInt(t[1],10);if(Date.now()-e>5e3)return!0}return!1},X=e=>{ee(e,j.current);let t=new ReadableStream({start(t){t.enqueue(new TextEncoder().encode(e)),t.close()}});return{element:le(t),flightProtocol:e}},Ae=async e=>{let t=await e;if(!t.body)throw Error(`Response has no body stream`);let n=t.clone();return{element:ce(Promise.resolve(t)),flightProtocol:``,bodyComplete:n.text().then(async e=>(await ee(e,j.current),e!==``&&(B.current=e),!0)).catch(()=>!1)}},Ie=async(t,n)=>{try{let e=await t.text();if(xe(e))return R.current.delete(n),`stale`;let r=await Fe(X(e).element);if(!h(r))throw Error(`[rari] AppRouter: refetched Flight content did not resolve to an <html> document root`);return{element:r,flightProtocol:e}}catch(t){if(o(t))throw t;let n=e(t),r=Error(`Failed to parse RSC Flight protocol: ${n.message}`,{cause:n});return J(r,`parse`,r.message,window.location.pathname),r}},Le=async(n,r,i)=>{let a=n!=null&&n!==``?n:window.location.pathname,s=P.current,c=i?.commit!==!1,l=i?.expectedRoute!=null&&i.expectedSeq!=null?`:hmr:${i.expectedRoute}:${i.expectedSeq}`:``,u=`${s}:${a}${window.location.search}:${c?`commit`:`defer`}${l}`,d=R.current.get(u);if(d)return d;let p=i?.expectedRoute,m=i?.expectedSeq,h=(async()=>{try{let e=a+window.location.search,t=await fetch(e,{headers:{Accept:`text/x-component`,"rari-navigation-id":String(P.current)},cache:`no-store`,signal:r});if(!t.ok){let n=/* @__PURE__ */ Error(`Failed to fetch RSC data: ${t.status} ${t.statusText}`);throw J(n,`fetch`,`HTTP ${t.status} when fetching ${e}`,window.location.pathname),n}let n=await Ie(t,u);if(n===`stale`)return;if(n instanceof Error)throw n;let i=p==null||m==null||de.current.get(p)===m;return P.current===s&&i&&(c&&f(n),n.flightProtocol!=null&&n.flightProtocol!==``&&(B.current=n.flightProtocol),ve()),R.current.delete(u),n}catch(n){throw R.current.delete(u),t(n)&&!o(n)&&!n.message.includes(`Failed to fetch RSC data`)&&!n.message.includes(`Failed to parse`)&&J(n,`network`,`Network error: ${n.message}`,window.location.pathname),e(n)}})();return R.current.set(u,h),h},Re=k(X),ze=k(Ae),Be=k(Le);O(()=>{Re.current=X,ze.current=Ae,Be.current=Le}),O(()=>{if(typeof window>`u`)return;let t=async e=>{if(e.rscResponsePromise){let t=await e.rscResponsePromise;if(P.current!==e.navigationId)return;let n=await ze.current(Promise.resolve(t));return P.current===e.navigationId?n:void 0}if(e.rscResponse){let t=await ze.current(Promise.resolve(e.rscResponse));return P.current===e.navigationId?t:void 0}if(e.rscFlightProtocol!=null&&e.rscFlightProtocol!==``)return Re.current(e.rscFlightProtocol);if(!e.isStreaming)return Be.current(e.to,e.abortSignal,{commit:!1})},n=async(t,n)=>{try{let e=await Pe(n,p.current?.element,t.navigationId,P.current,t.from,t.to,je(t),ie.current.search);if(e.kind===`superseded`)return null;if(e.kind===`hard-nav`){if(P.current!==t.navigationId)return null;let e=t.pendingHistory?.url!=null&&t.pendingHistory.url!==``?t.pendingHistory.url:t.to;return window.dispatchEvent(new CustomEvent(`rari:navigate-committed`,{detail:{navigationId:t.navigationId}})),window.location.assign(e),null}return e.kind===`error`?(Me(t,e.error),null):P.current===t.navigationId?e.payload:null}catch(n){return Me(t,e(n)),null}},s=(e,t)=>{let n=he(e.pendingHistory,{pathname:e.to,search:je(e)});ge({parsedPayload:t,shouldScrollToTop:Ne(e),navigationId:e.navigationId,transitionTypes:me({historyKey:e.options.historyKey,replace:e.options.replace}),maySuspend:t.maySuspend===!0,hasLoadingFallback:t.hasLoadingFallback===!0,pendingHistory:e.pendingHistory,routeLocation:n,pendingEvictLeaf:t.pendingEvictLeaf,startTransition:ae,currentNavigationIdRef:P,pendingScrollPayloadRef:T,setRenderKey:g,setRscPayload:f,setRouteLocation:S,setPendingLoadingLeaf:re,clearHmrError:()=>{U(null)},pendingNavigateCommittedIdRef:L}),t.flightProtocol!=null&&t.flightProtocol!==``&&(B.current=t.flightProtocol),ve(),ue.current&&ue.current(e)},c=async n=>{try{return{kind:`payload`,payload:await t(n)}}catch(t){return o(t)?{kind:`aborted`}:{kind:`error`,error:e(t)}}},l=async e=>{let t=r(e,Ee);if(!t||t.navigationId!==P.current)return;w.current={x:window.scrollX,y:window.scrollY},K();let i=await c(t);if(i.kind===`aborted`)return;if(i.kind===`error`){Me(t,i.error),V.current>=3&&Y();return}let a=i.payload;if(a==null&&t.isStreaming&&P.current===t.navigationId||a==null||P.current!==t.navigationId)return;let o=await n(t,a);o!=null&&s(t,o)},u=async t=>{let n;for(let e=0;e<3;e+=1)try{return await Be.current(void 0,void 0,{commit:!0,expectedRoute:t.expectedRoute,expectedSeq:t.expectedSeq})}catch(t){if(n=t,!Ce(t)||e===2)throw t;await we(150*(e+1))}throw e(n)},d=async()=>{let e=P.current,{pathname:t,search:n}=v(),r=`${t}${n}`,a=de.current,o=(a.get(r)??0)+1;a.set(r,o);let s=await u({expectedRoute:r,expectedSeq:o});if(P.current!==e)return!1;let{pathname:c,search:l}=v();if(`${c}${l}`!==r||a.get(r)!==o)return!1;let d=s?.element;return d!=null&&!i(d)&&E(d)&&(d.type===`html`||d.type===`HTML`)&&!b(d)&&y.set(t,n,d),!0},m=async()=>{w.current={x:window.scrollX,y:window.scrollY},K();try{if(!await d())return;let e=P.current,{pathname:t,search:n}=v(),r=`${t}${n}`,i={x:w.current.x,y:w.current.y};g(e=>e+1),U(null),requestAnimationFrame(()=>{if(P.current!==e)return;let{pathname:t,search:n}=v();`${t}${n}`===r&&(window.scrollTo(i.x,i.y),q())})}catch(e){console.error(`HMR refetch error:`,a(e,String(e))),V.current>=3&&Y()}},h=t=>{let n=r(t,De);if(n?.element==null||!Te(n.element)&&!i(n.element))return;let{pathname:a,search:o}=v(),s=++F.current,c=P.current,l=`${a}${o}`;w.current={x:window.scrollX,y:window.scrollY},K();try{n.revalidationKind===1?y.clear():n.revalidatedPath!=null&&n.revalidatedPath!==``?y.invalidate(n.revalidatedPath,o):y.invalidate(a,o);let t=p.current?.element,r=y.getElement(a,o)??(t!=null&&i(t)?null:t??null),u=n.element;(async()=>{try{let e=await Fe(u);if(s!==F.current||P.current!==c)return;let{pathname:t,search:n}=v();if(`${t}${n}`!==l)return;let i=pe({previousDocument:r??null,refresh:e,pathname:a,search:o});if(i.kind===`hard-nav`){window.location.reload();return}let d=i.element;if(s!==F.current||P.current!==c)return;let p=v();if(`${p.pathname}${p.search}`!==l)return;let m={element:d};I.current=m,ae(()=>{f(m),U(null)}),G.current(d),ve()}catch(t){if(s!==F.current||P.current!==c)return;let n=e(t);J(n,`parse`,`Action flight refresh failed: ${n.message}`,window.location.pathname),V.current>=3&&Y()}})()}catch(t){let n=e(t);J(n,`parse`,`Action flight refresh failed: ${n.message}`,window.location.pathname),V.current>=3&&Y()}},_=async()=>{try{if(!await d())return;g(e=>e+1),U(null)}catch(e){console.error(`RSC invalidate error:`,a(e,String(e))),V.current>=3&&Y()}},x=e=>{let t=r(e,Oe);t&&(j.current.clear(),P.current=t.navigationId,F.current+=1,T.current=null,I.current=null,re(null))},ee=async()=>{try{if(!await d())return;U(null)}catch(e){console.error(`Manifest update error:`,a(e,String(e))),V.current>=3&&Y()}},te=e=>{l(e)},ne=()=>{m()},C=()=>{_()},D=()=>{ee()};return window.addEventListener(`rari:navigation-start`,x),window.addEventListener(`rari:navigate`,te),window.addEventListener(`rari:app-router-rerender`,ne),window.addEventListener(`rari:action-flight-refresh`,h),window.addEventListener(`rari:rsc-invalidate`,C),window.addEventListener(`rari:app-router-manifest-updated`,D),()=>{window.removeEventListener(`rari:navigation-start`,x),window.removeEventListener(`rari:navigate`,te),window.removeEventListener(`rari:app-router-rerender`,ne),window.removeEventListener(`rari:action-flight-refresh`,h),window.removeEventListener(`rari:rsc-invalidate`,C),window.removeEventListener(`rari:app-router-manifest-updated`,D)}},[]),O(()=>{if(typeof window<`u`&&window.location.hash&&d){let e=window.location.hash.slice(1);requestAnimationFrame(()=>{requestAnimationFrame(()=>{let t=document.getElementById(e);t&&t.scrollIntoView({behavior:`instant`,block:`start`})})})}},[d]);let Ve=d?.element??c,He=x(Ve),[Z,Ue]=A(null),We=ke(He),Ge=i(He)&&We===void 0,Ke=We===void 0?i(He)?null:He:x(We),Q=Ke!=null&&!i(Ke)&&h(Ke)?Ke:null;Q!=null&&!Object.is(Q,Z)&&!b(Q)&&Ue(Q);let $=Ge?Z:Q,qe=$!=null&&h($)&&!b($)?$:Z!=null&&h(Z)&&!b(Z)?Z:null;if(qe==null&&!y.hasRoute(_.pathname,_.search))throw Error(`[rari] AppRouter: expected a resolved <html> document root`);return/* @__PURE__ */ N(_e,{value:C,children:[H!=null&&/* @__PURE__ */ M(fe,{failure:H,maxRetries:3,onRefresh:()=>{window.location.reload()},onDismiss:()=>{U(null)}}),/* @__PURE__ */ M(ye,{fallback:qe,pathname:_.pathname,search:_.search})]})}export{Ie as AppRouterProvider};
|
|
1
|
+
import{i as e}from"../navigation-transition-store-dfNJmkIX.mjs";import{n as t,r as n}from"../form-state-C9jn086j.mjs";import{S as r,d as i,g as a,i as o,p as s,r as c,s as l}from"../type-guards-BLY2PlGR.mjs";import"./action-revalidation-kind.mjs";import{n as u,t as d}from"../preload-modules-0iyuP4Vs.mjs";import{isLayoutReuseMarker as f,layoutPathOf as p,mergeFlightRefresh as m,unwrapFulfilledFlightNode as h}from"./merge-flight-refresh.mjs";import{a as g,i as _,n as v,r as y,t as b}from"../react-helpers-duOBWuYF.mjs";import{i as x,n as S,r as C,t as w}from"../route-cache-BfEqTT9i.mjs";import{c as T}from"react/compiler-runtime";import{Suspense as ee,addTransitionType as te,cloneElement as ne,createContext as E,createElement as D,isValidElement as O,startTransition as re,use as k,useCallback as ie,useEffect as A,useLayoutEffect as ae,useRef as j,useState as M,useSyncExternalStore as N}from"react";import{jsx as P,jsxs as F}from"react/jsx-runtime";import{createFromFetch as oe,createFromReadableStream as se}from"virtual:react-flight-client";const I={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)`},L={padding:`8px 16px`,background:`white`,color:`#dc2626`,border:`none`,borderRadius:`4px`,cursor:`pointer`,fontWeight:`bold`,fontSize:`14px`},R={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`},ce={fetch:`Failed to fetch updated content from server.`,parse:`Failed to parse server response.`,stale:`Server returned stale content.`,network:`Network error occurred.`};function z(e){return ce[e]}function le(e){let t=T(27),{failure:n,maxRetries:r,onRefresh:i,onDismiss:a}=e,o,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=/* @__PURE__ */ P(`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=z(n.type),t[2]=n.type,t[3]=c);let l;t[4]===c?l=t[5]:(l=/* @__PURE__ */ P(`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__ */ P(`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__ */ F(`div`,{style:f,children:[`Consecutive failures: `,n.consecutiveFailures,` / `,r]}),t[10]=n.consecutiveFailures,t[11]=r,t[12]=p):p=t[12];let m;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(m={display:`flex`,gap:`8px`},t[13]=m):m=t[13];let h;t[14]===i?h=t[15]:(h=/* @__PURE__ */ P(`button`,{onClick:i,type:`button`,style:L,children:`Refresh Page`}),t[14]=i,t[15]=h);let g;t[16]===a?g=t[17]:(g=/* @__PURE__ */ P(`button`,{onClick:a,type:`button`,style:R,children:`Dismiss`}),t[16]=a,t[17]=g);let _;t[18]!==h||t[19]!==g?(_=/* @__PURE__ */ F(`div`,{style:m,children:[h,g]}),t[18]=h,t[19]=g,t[20]=_):_=t[20];let v;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(v=/* @__PURE__ */ P(`div`,{style:{marginTop:`12px`,fontSize:`11px`,opacity:.6},children:`Check the console for detailed error logs.`}),t[21]=v):v=t[21];let y;return t[22]!==_||t[23]!==l||t[24]!==d||t[25]!==p?(y=/* @__PURE__ */ F(`div`,{style:I,children:[o,l,d,p,_,v]}),t[22]=_,t[23]=l,t[24]=d,t[25]=p,t[26]=y):y=t[26],y}function ue(e,t,n){C.getShell()??C.ingest(e,t,n)}function de(e){if(e.fromPathname!==`/`&&(e.fromPathname!==e.toPathname||e.fromSearch!==e.search))return{pathname:e.fromPathname,search:e.fromSearch}}function fe(e){if(ue(e.previousDocument,e.fromPathname,e.fromSearch),y(e.refresh)){if(!C.ingest(e.refresh,e.toPathname,e.search))return{kind:`hard-nav`}}else if(O(e.refresh)){if(!C.ingestSegment(e.refresh,e.toPathname,e.search))return{kind:`hard-nav`}}else return{kind:`hard-nav`};if(C.getShell()==null||!C.hasRoute(e.toPathname,e.search))return{kind:`hard-nav`};let t=C.readLeaf(e.toPathname,e.search),n=v(e.refresh)||t!=null&&v(t),r=t!=null&&_(t)||_(e.refresh),i=de(e);return y(e.refresh)?{kind:`merged`,element:e.refresh,maySuspend:n,hasLoadingFallback:r,pendingEvictLeaf:i}:{kind:`merged`,element:e.previousDocument,maySuspend:n,hasLoadingFallback:r,pendingEvictLeaf:i}}function B(e,t,n,r){if(y(t))return C.ingest(t,n,r);if(O(t)&&C.getShell()!=null)return C.ingestSegment(t,n,r);let i=m(e,t);return O(t)&&f(t)&&i===e||!y(i)?!1:C.ingest(i,n,r)}function V(e,t){let n=v(e),r=_(e);return y(e)?{kind:`merged`,element:e,maySuspend:n,hasLoadingFallback:r}:y(t)?{kind:`merged`,element:t,maySuspend:n,hasLoadingFallback:r}:{kind:`hard-nav`}}function pe(e){return y(e.previousDocument)&&C.getShell()==null&&!C.ingest(e.previousDocument,e.pathname,e.search)||!B(e.previousDocument,e.refresh,e.pathname,e.search)||C.getShell()==null||!C.hasRoute(e.pathname,e.search)?{kind:`hard-nav`}:V(e.refresh,e.previousDocument)}function me(e){return e.historyKey!=null&&e.historyKey!==``?[`nav`,`nav-traverse`]:e.replace===!0?[`nav`,`nav-replace`]:[`nav`,`nav-forward`]}function he(e,t){if(e==null||e.url===``)return t;try{let t=`http://localhost/`;if(typeof window<`u`)try{t=window.location.href}catch{}let n=new URL(e.url,t);return{pathname:n.pathname,search:n.search}}catch{return t}}function H(e){e!=null&&typeof window<`u`&&(e.replace===!0?window.history.replaceState(e.state,``,e.url):window.history.pushState(e.state,``,e.url))}function ge(e){let{parsedPayload:t,shouldScrollToTop:n,navigationId:r,transitionTypes:i,maySuspend:a=!1,hasLoadingFallback:o=!1,pendingHistory:s,routeLocation:c,startTransition:l=re,currentNavigationIdRef:u,pendingScrollPayloadRef:d,setRenderKey:f,setRscPayload:p,setRouteLocation:m,setPendingLoadingLeaf:h,clearHmrError:g,pendingNavigateCommittedIdRef:_,setCommittedNavigationId:v,pendingEvictLeaf:y,pendingEvictLeavesRef:b}=e;if(u.current!==r)return;let x=a&&o;a&&H(s),x&&c!=null&&(m?.(c),h?.(c));let S=()=>{u.current===r&&(h?.(null),a||H(s),c!=null&&m?.(c),y!=null&&b?.current.push(y),f(e=>{let r=e+1;return d.current=n?{payload:t,commitKey:r}:null,r}),p(t),g(),_.current=r,v?.(r))};l(()=>{if(i!=null)for(let e of i)te(e);S()})}const _e=E(null);function U(){return k(_e)}function W(e,t,n){return n?.pathname===e&&n.search===t}function G(){return N(C.subscribe,C.getVersion,C.getVersion)}function K(e){return p(e)!=null&&!x(e)&&!f(e)}function q(e,t,n){if(e==null||e===!1||e===!0)return e;if(Array.isArray(e))return b(e).map(e=>q(e,t,n));if(!O(e))return e;if(x(e)||K(e)){let r=p(e);return r==null?null:D(J,{key:r,layoutPath:r,pathname:t,search:n})}let r=e.props,i=r.children;if(i==null)return e;let a=q(i,t,n);if(Object.is(a,i))return e;let o=b(a),s={...r};return delete s.children,ne(e,s,...o.length===0?[null]:o)}function ve({layoutPath:e,pathname:t,search:n},r,i=null){let a=C.readSegmentSnapshot(e,{pathname:t,search:n});if(a==null||O(a)&&x(a))return null;if(C.isDeepestLayout(e,t)){let{fallback:e,content:r}=g(a);return W(t,n,i)&&e!=null?e:D(ee,{fallback:e},r)}return q(a,t,n)}function J(e){let t=T(4),n=G(),r=U(),i;return t[0]!==n||t[1]!==r||t[2]!==e?(i=ve(e,n,r),t[0]=n,t[1]=r,t[2]=e,t[3]=i):i=t[3],i}function ye({fallback:e=null,pathname:t,search:n},r){let i=C.getShell();if(i!=null){let e=q(i,t,n);return O(e)?e:null}return e!=null&&w(e)?null:e}function be(e){let t=T(3),n=G(),r;return t[0]!==n||t[1]!==e?(r=ye(e,n),t[0]=n,t[1]=e,t[2]=r):r=t[2],r}function xe(e,t,n){return e==null||e.commitKey!==n?{shouldScroll:!1,nextPending:null}:t===e.payload?{shouldScroll:!0,nextPending:null}:{shouldScroll:!1,nextPending:e}}function Y(e){if(e==null)return null;if(s(e)){let t=h(e);return t===e||!y(t)?null:t}return y(e)?e:null}const Se=/"timestamp":(\d+)/;function Ce(e){if(!i(e)||l(e))return!1;let t=e.message;return t===`Failed to fetch`||t.includes(`NetworkError`)||t.includes(`network error`)||t.includes(`Load failed`)}async function we(e){await new Promise(t=>{setTimeout(t,e)})}async function X(e,t,n){if(e.maySuspend!==!0||e.hasLoadingFallback!==!0)return e;if(e.bodyComplete==null){await Promise.resolve();let r=C.readLeaf(t,n);return r!=null&&!v(r)?{...e,maySuspend:!1}:e}if(await Promise.race([e.bodyComplete.then(e=>e?`body`:`failed`),we(100).then(()=>`timeout`)])===`body`)return{...e,maySuspend:!1};let r=C.readLeaf(t,n);return r!=null&&!v(r)?{...e,maySuspend:!1}:e}function Te(e){return e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`||O(e)||Array.isArray(e)}function Ee(e){return a(e)&&typeof e.from==`string`&&typeof e.to==`string`&&typeof e.navigationId==`number`&&a(e.options)}function De(e){return a(e)&&`element`in e}function Oe(e){return a(e)&&typeof e.navigationId==`number`&&typeof e.targetPath==`string`}function ke(e){if(!s(e))return e;if(a(e)&&e.status===`fulfilled`)return Te(e.value)?e.value:void 0}function Z(e){return y(e)||O(e)&&f(e)}function Ae(e){let t=e.pendingHistory?.url;if(t!=null&&t!==``)try{return new URL(t,window.location.origin).search}catch{}return S().search}function je(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 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 Ne(e,t,n,r,i,a,o,s){let c=await Pe(e.element);if(r!==n)return{kind:`superseded`};if(!Z(c))return{kind:`error`,error:/* @__PURE__ */ Error(`[rari] AppRouter: navigated Flight content did not resolve to an <html> document root`)};let l=Y(t);if(O(c)&&f(c)&&l==null)return{kind:`error`,error:/* @__PURE__ */ Error(`[rari] AppRouter: layout-reuse Flight marker requires a previous <html> document`)};if(l==null)return y(c)?(C.set(a,o,c),{kind:`payload`,payload:await X({...e,element:c,maySuspend:v(c),hasLoadingFallback:_(c)},a,o)}):{kind:`error`,error:/* @__PURE__ */ Error(`[rari] AppRouter: navigated Flight content did not resolve to an <html> document root`)};let u=fe({previousDocument:l,refresh:c,fromPathname:i,toPathname:a,fromSearch:s,search:o});return u.kind===`hard-nav`?{kind:`hard-nav`}:{kind:`payload`,payload:await X({...e,element:u.element,maySuspend:u.maySuspend,hasLoadingFallback:u.hasLoadingFallback===!0,pendingEvictLeaf:u.pendingEvictLeaf},a,o)}}async function Pe(e){let t=u(e);for(let e=0;e<10&&s(t);e+=1)t=u(await t);if(s(t))throw Error(`[rari] AppRouter: Flight content did not resolve to a React node`);return t}function Fe({children:f,initialPayload:p,onNavigate:m}){let[h,g]=M(p),_=j(p),[v,b]=M(0),[x,T]=M(()=>S()),[ee,te]=M(null),ne=j(x),E=j({x:0,y:0}),D=j(null),k=j(/* @__PURE__ */ new Map),N=j(/* @__PURE__ */ new Set),I=j(m),L=j(0),R=j(0),ce=j(/* @__PURE__ */ new Map),z=j(null),ue=j(null),[de,fe]=M(null),B=j([]),V=j(/* @__PURE__ */ new Map),H=j([]),U=j(null),W=j(0),[G,K]=M(null);A(()=>{ne.current=x},[x]),A(()=>{I.current=m},[m]),ae(()=>{let{shouldScroll:e,nextPending:t}=xe(D.current,h,v);D.current=t,e&&window.scrollTo(0,0);let n=ue.current;if(n==null||de!==n)return;ue.current=null;let r=B.current;if(r.length>0){B.current=[];let e=S();for(let t of r)(t.pathname!==e.pathname||t.search!==e.search)&&C.evictLeaf(t.pathname,t.search)}window.dispatchEvent(new CustomEvent(`rari:navigate-committed`,{detail:{navigationId:n}}))},[h,v,de]),A(()=>{e()},[v]);let q=ie(e=>{if(e==null||s(e)||!O(e)||e.type!==`html`&&e.type!==`HTML`||w(e))return;let{pathname:t,search:n}=x;C.getShell()!=null&&C.hasRoute(t,n)||C.set(t,n,e)},[x]),ve=j(q);A(()=>{ve.current=q},[q]),A(()=>{_.current=h,h?.element!=null&&q(h.element)},[h,q]),A(()=>{if(h?.element!=null){let e=h.element;if(a(e)&&`status`in e&&e.status===`rejected`){let t=e.reason;t!=null&&t!==``&&console.error(`[rari] AppRouter: Flight payload rejected:`,t)}}},[h]);let J=()=>{k.current=t()},ye=()=>{n(k.current)};ae(()=>{let e=z.current;e!=null&&h===e&&(z.current=null,window.scrollTo(E.current.x,E.current.y),ye())},[h,v]);let Y=(e,t,n,r)=>{W.current+=1;let i={timestamp:Date.now(),error:e,type:t,details:n,filePath:r,consecutiveFailures:W.current};H.current.push(i),H.current.length>10&&H.current.shift(),W.current>=2&&K(i),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`rari:hmr-failure`,{detail:i}))},X=()=>{setTimeout(()=>{window.location.reload()},1e3)},Z=()=>{W.current>0&&(W.current=0)},Fe=e=>{if(U.current==null||U.current===``)return!1;if(e===U.current)return!0;let t=Se.exec(e);if(t){let e=Number.parseInt(t[1],10);if(Date.now()-e>5e3)return!0}return!1},Ie=e=>{d(e,N.current);let t=new ReadableStream({start(t){t.enqueue(new TextEncoder().encode(e)),t.close()}});return{element:se(t),flightProtocol:e}},Le=async e=>{let t=await e;if(!t.body)throw Error(`Response has no body stream`);let n=t.clone();return{element:oe(Promise.resolve(t)),flightProtocol:``,bodyComplete:n.text().then(async e=>(await d(e,N.current),e!==``&&(U.current=e),!0)).catch(()=>!1)}},Re=async(e,t)=>{try{let n=await e.text();if(Fe(n))return V.current.delete(t),`stale`;let r=await Pe(Ie(n).element);if(!y(r))throw Error(`[rari] AppRouter: refetched Flight content did not resolve to an <html> document root`);return{element:r,flightProtocol:n}}catch(e){if(l(e))throw e;let t=r(e),n=Error(`Failed to parse RSC Flight protocol: ${t.message}`,{cause:t});return Y(n,`parse`,n.message,window.location.pathname),n}},ze=async(e,t,n)=>{let a=e!=null&&e!==``?e:window.location.pathname,o=L.current,s=n?.commit!==!1,c=n?.expectedRoute!=null&&n.expectedSeq!=null?`:hmr:${n.expectedRoute}:${n.expectedSeq}`:``,u=`${o}:${a}${window.location.search}:${s?`commit`:`defer`}${c}`,d=V.current.get(u);if(d)return d;let f=n?.expectedRoute,p=n?.expectedSeq,m=(async()=>{try{let e=a+window.location.search,n=await fetch(e,{headers:{Accept:`text/x-component`,"rari-navigation-id":String(L.current)},cache:`no-store`,signal:t});if(!n.ok){let t=/* @__PURE__ */ Error(`Failed to fetch RSC data: ${n.status} ${n.statusText}`);throw Y(t,`fetch`,`HTTP ${n.status} when fetching ${e}`,window.location.pathname),t}let r=await Re(n,u);if(r===`stale`)return;if(r instanceof Error)throw r;let i=f==null||p==null||ce.current.get(f)===p;return L.current===o&&i&&(s&&g(r),r.flightProtocol!=null&&r.flightProtocol!==``&&(U.current=r.flightProtocol),Z()),V.current.delete(u),r}catch(e){throw V.current.delete(u),i(e)&&!l(e)&&!e.message.includes(`Failed to fetch RSC data`)&&!e.message.includes(`Failed to parse`)&&Y(e,`network`,`Network error: ${e.message}`,window.location.pathname),r(e)}})();return V.current.set(u,m),m},Be=j(Ie),Ve=j(Le),He=j(ze);A(()=>{Be.current=Ie,Ve.current=Le,He.current=ze}),A(()=>{if(typeof window>`u`)return;let e=async e=>{if(e.rscResponsePromise){let t=await e.rscResponsePromise;if(L.current!==e.navigationId)return;let n=await Ve.current(Promise.resolve(t));return L.current===e.navigationId?n:void 0}if(e.rscResponse){let t=await Ve.current(Promise.resolve(e.rscResponse));return L.current===e.navigationId?t:void 0}if(e.rscFlightProtocol!=null&&e.rscFlightProtocol!==``)return Be.current(e.rscFlightProtocol);if(!e.isStreaming)return He.current(e.to,e.abortSignal,{commit:!1})},t=async(e,t)=>{try{let n=await Ne(t,_.current?.element,e.navigationId,L.current,e.from,e.to,Ae(e),ne.current.search);if(n.kind===`superseded`)return null;if(n.kind===`hard-nav`){if(L.current!==e.navigationId)return null;let t=e.pendingHistory?.url!=null&&e.pendingHistory.url!==``?e.pendingHistory.url:e.to;return window.dispatchEvent(new CustomEvent(`rari:navigate-committed`,{detail:{navigationId:e.navigationId,hardNavigation:!0}})),window.location.assign(t),null}return n.kind===`error`?(je(e,n.error),null):L.current===e.navigationId?n.payload:null}catch(t){return je(e,r(t)),null}},n=(e,t)=>{let n=he(e.pendingHistory,{pathname:e.to,search:Ae(e)});ge({parsedPayload:t,shouldScrollToTop:Me(e),navigationId:e.navigationId,transitionTypes:me({historyKey:e.options.historyKey,replace:e.options.replace}),maySuspend:t.maySuspend===!0,hasLoadingFallback:t.hasLoadingFallback===!0,pendingHistory:e.pendingHistory,routeLocation:n,pendingEvictLeaf:t.pendingEvictLeaf,pendingEvictLeavesRef:B,startTransition:re,currentNavigationIdRef:L,pendingScrollPayloadRef:D,setRenderKey:b,setRscPayload:g,setRouteLocation:T,setPendingLoadingLeaf:te,clearHmrError:()=>{K(null)},pendingNavigateCommittedIdRef:ue,setCommittedNavigationId:fe}),t.flightProtocol!=null&&t.flightProtocol!==``&&(U.current=t.flightProtocol),Z(),I.current&&I.current(e)},i=async t=>{try{return{kind:`payload`,payload:await e(t)}}catch(e){return l(e)?{kind:`aborted`}:{kind:`error`,error:r(e)}}},a=async e=>{let r=o(e,Ee);if(!r||r.navigationId!==L.current)return;E.current={x:window.scrollX,y:window.scrollY},J();let a=await i(r);if(a.kind===`aborted`)return;if(a.kind===`error`){je(r,a.error),W.current>=3&&X();return}let s=a.payload;if(s==null&&r.isStreaming&&L.current===r.navigationId||s==null||L.current!==r.navigationId)return;let c=await t(r,s);c!=null&&n(r,c)},u=async e=>{let t;for(let n=0;n<3;n+=1)try{return await He.current(void 0,void 0,{commit:!0,expectedRoute:e.expectedRoute,expectedSeq:e.expectedSeq})}catch(e){if(t=e,!Ce(e)||n===2)throw e;await we(150*(n+1))}throw r(t)},d=async()=>{let e=L.current,{pathname:t,search:n}=S(),r=`${t}${n}`,i=ce.current,a=(i.get(r)??0)+1;i.set(r,a);let o=await u({expectedRoute:r,expectedSeq:a});if(L.current!==e)return!1;let{pathname:c,search:l}=S();if(`${c}${l}`!==r||i.get(r)!==a)return!1;let d=o?.element;return d==null||s(d)||!O(d)||d.type!==`html`&&d.type!==`HTML`||w(d)||C.set(t,n,d),!0},f=async()=>{E.current={x:window.scrollX,y:window.scrollY},J();try{if(!await d())return;let e=L.current,{pathname:t,search:n}=S(),r=`${t}${n}`,i={x:E.current.x,y:E.current.y};b(e=>e+1),K(null),requestAnimationFrame(()=>{if(L.current!==e)return;let{pathname:t,search:n}=S();`${t}${n}`===r&&(window.scrollTo(i.x,i.y),ye())})}catch(e){console.error(`HMR refetch error:`,c(e,String(e))),W.current>=3&&X()}},p=e=>{let t=o(e,De);if(t?.element==null||!Te(t.element)&&!s(t.element))return;let{pathname:n,search:i}=S(),a=++R.current,c=L.current,l=`${n}${i}`;E.current={x:window.scrollX,y:window.scrollY},J();try{t.revalidationKind===1?C.clear():t.revalidatedPath!=null&&t.revalidatedPath!==``?C.invalidate(t.revalidatedPath,i):C.invalidate(n,i);let e=_.current?.element,o=C.getElement(n,i)??(e!=null&&s(e)?null:e??null),u=t.element;(async()=>{try{let e=await Pe(u);if(a!==R.current||L.current!==c)return;let{pathname:t,search:r}=S();if(`${t}${r}`!==l)return;let s=pe({previousDocument:o??null,refresh:e,pathname:n,search:i});if(s.kind===`hard-nav`){window.location.reload();return}let d=s.element;if(a!==R.current||L.current!==c)return;let f=S();if(`${f.pathname}${f.search}`!==l)return;let p={element:d};z.current=p,re(()=>{g(p),K(null)}),ve.current(d),Z()}catch(e){if(a!==R.current||L.current!==c)return;let t=r(e);Y(t,`parse`,`Action flight refresh failed: ${t.message}`,window.location.pathname),W.current>=3&&X()}})()}catch(e){let t=r(e);Y(t,`parse`,`Action flight refresh failed: ${t.message}`,window.location.pathname),W.current>=3&&X()}},m=async()=>{try{if(!await d())return;b(e=>e+1),K(null)}catch(e){console.error(`RSC invalidate error:`,c(e,String(e))),W.current>=3&&X()}},h=e=>{let t=o(e,Oe);t&&(N.current.clear(),L.current=t.navigationId,R.current+=1,D.current=null,z.current=null,te(null))},v=async()=>{try{if(!await d())return;K(null)}catch(e){console.error(`Manifest update error:`,c(e,String(e))),W.current>=3&&X()}},y=e=>{a(e)},x=()=>{f()},ee=()=>{m()},k=()=>{v()};return window.addEventListener(`rari:navigation-start`,h),window.addEventListener(`rari:navigate`,y),window.addEventListener(`rari:app-router-rerender`,x),window.addEventListener(`rari:action-flight-refresh`,p),window.addEventListener(`rari:rsc-invalidate`,ee),window.addEventListener(`rari:app-router-manifest-updated`,k),()=>{window.removeEventListener(`rari:navigation-start`,h),window.removeEventListener(`rari:navigate`,y),window.removeEventListener(`rari:app-router-rerender`,x),window.removeEventListener(`rari:action-flight-refresh`,p),window.removeEventListener(`rari:rsc-invalidate`,ee),window.removeEventListener(`rari:app-router-manifest-updated`,k)}},[]),A(()=>{if(typeof window<`u`&&window.location.hash&&h){let e=window.location.hash.slice(1);requestAnimationFrame(()=>{requestAnimationFrame(()=>{let t=document.getElementById(e);t&&t.scrollIntoView({behavior:`instant`,block:`start`})})})}},[h]);let Ue=h?.element??f,We=u(Ue),[Q,Ge]=M(null),Ke=ke(We),qe=s(We)&&Ke===void 0,Je=Ke===void 0?s(We)?null:We:u(Ke),$=Je!=null&&!s(Je)&&y(Je)?Je:null;$!=null&&!Object.is($,Q)&&!w($)&&Ge($);let Ye=qe?Q:$,Xe=Ye!=null&&y(Ye)&&!w(Ye)?Ye:Q!=null&&y(Q)&&!w(Q)?Q:null;if(Xe==null&&!C.hasRoute(x.pathname,x.search))throw Error(`[rari] AppRouter: expected a resolved <html> document root`);return/* @__PURE__ */ F(_e,{value:ee,children:[G!=null&&/* @__PURE__ */ P(le,{failure:G,maxRetries:3,onRefresh:()=>{window.location.reload()},onDismiss:()=>{K(null)}}),/* @__PURE__ */ P(be,{fallback:Xe,pathname:x.pathname,search:x.search})]})}export{Fe as AppRouterProvider};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
|
-
//#region src/router/navigation/client-router.d.ts
|
|
3
2
|
export interface ClientRouterProps {
|
|
4
3
|
readonly children: ReactNode;
|
|
5
4
|
readonly initialRoute: string;
|
|
6
5
|
}
|
|
7
|
-
export declare function ClientRouter({ children, initialRoute }: ClientRouterProps): ReactNode;
|
|
8
|
-
//#endregion
|
|
6
|
+
export declare function ClientRouter({ children, initialRoute }: ClientRouterProps): ReactNode;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{a as e}from"../route-cache-BfEqTT9i.mjs";import{r as t}from"../path-CTEC1xmy.mjs";import{d as n,g as r,h as i,i as a,n as o,s}from"../type-guards-BLY2PlGR.mjs";import{i as c,t as l}from"../navigate-CSQP4q53.mjs";import{t as u}from"../form-state-C9jn086j.mjs";import{c as d}from"react/compiler-runtime";import{useEffect as f,useLayoutEffect as p,useRef as m,useState as h}from"react";function ee(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){r=null,l&&o?d(e):(o=null,s=null)}function ee(){r!==null&&clearTimeout(r),a=0,o=null,i=0,s=null,r=null}function g(){r!==null&&h(Date.now())}function _(){return r!==null}function v(...e){let n=Date.now(),a=f(n);if(o=e,s=this,i=n,a){if(r===null){m(i);return}
|
|
2
2
|
/* v8 ignore start - edge case: isInvoking true with existing timeout and maxWait defined */
|
|
3
|
-
if(
|
|
3
|
+
if(u!==void 0){r=setTimeout(p,t),d(i);return}}r??=setTimeout(p,t)}return v.cancel=ee,v.flush=g,v.pending=_,v}const g=/fetch|networkerror|load failed/i;function _(e,t){return{type:`abort`,message:`Navigation was cancelled`,originalError:e,url:t,timestamp:Date.now(),retryable:!1}}function v(e,t){return{type:`timeout`,message:`Navigation request timed out`,originalError:e,url:t,timestamp:Date.now(),retryable:!0}}function y(e,t,n){if(t===404)return{type:`not-found`,message:`Page not found`,originalError:e,statusCode:t,url:n,timestamp:Date.now(),retryable:!1};if(t>=500)return{type:`server-error`,message:`Server error: ${t}`,originalError:e,statusCode:t,url:n,timestamp:Date.now(),retryable:!0};let r=t===408||t===429;return{type:`fetch-error`,message:`HTTP error: ${t}`,originalError:e,statusCode:t,url:n,timestamp:Date.now(),retryable:r}}function b(e,t){return{type:`network-error`,message:`Network error - check your connection`,originalError:e,url:t,timestamp:Date.now(),retryable:!0}}function x(e,t){return{type:`parse-error`,message:`Failed to parse server response`,
|
|
4
4
|
/* v8 ignore next - defensive check for non-Error values from parse-related condition */
|
|
5
5
|
originalError:o(e),url:t,timestamp:Date.now(),retryable:!1}}function S(e,t){return{type:`fetch-error`,message:o(e)?.message??`Unknown error occurred`,originalError:o(e),url:t,timestamp:Date.now(),retryable:!1}}function C(e,t){if(s(e))return _(o(e)??/* @__PURE__ */ Error(`Aborted`),t);if(n(e)&&(e.name===`TimeoutError`||e.message.includes(`timeout`)))return v(e,t);if(n(e)&&`status`in e){let n=e.status;return typeof n==`number`?y(e,n,t):S(e,t)}return e instanceof TypeError&&g.test(e.message)?b(e,t):e instanceof SyntaxError||n(e)&&e.message.includes(`parse`)?x(e,t):S(e,t)}var te=class{onError;constructor(e={}){
|
|
6
6
|
/* v8 ignore next - default no-op callback */
|
|
7
|
-
this.onError=e.onError??(()=>{})}handleError(e,t){let n=C(e,t);return this.onError(n),console.error(`[rari] Navigation:`,n.type,n.message,{url:n.url,statusCode:n.statusCode,retryable:n.retryable}),n}};function ne(e,t){try{let n=t!=null&&t!==``?t:window.location.origin,r=typeof URL.parse==`function`?URL.parse(e,n):new URL(e,n);return r!=null&&r.origin!==n}catch{return!1}}function re(e){try{let t=typeof URL.parse==`function`?URL.parse(e,window.location.origin):new URL(e,window.location.origin);return t==null?e:`${t.pathname}${t.search}${t.hash}`}catch{return e}}var ie=class{stateHistory;routeAccessOrder;maxHistorySize;scrollableSelector;constructor(e={}){this.stateHistory=/* @__PURE__ */ new Map,this.routeAccessOrder=[],this.maxHistorySize=e.maxHistorySize!=null&&e.maxHistorySize!==0?e.maxHistorySize:50,this.scrollableSelector=e.scrollableSelector!=null&&e.scrollableSelector!==``?e.scrollableSelector:`[data-scrollable], .scrollable, [style*="overflow"]`}captureState(e){let t={scrollPositions:this.captureScrollPositions(),formData:this.captureFormData(),focusedElement:this.captureFocusedElement()};return this.storeState(e,t),t}captureScrollPositions(){let e=/* @__PURE__ */ new Map;try{e.set(`window`,{x:window.scrollX,y:window.scrollY,element:`window`}),document.querySelectorAll(this.scrollableSelector).forEach((t,n)=>{if(t instanceof HTMLElement){let r=t.id||`scrollable-${n}`;(t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth)&&e.set(r,{x:t.scrollLeft,y:t.scrollTop,element:r})}})}catch{}return e}captureFormData(){let e=/* @__PURE__ */ new Map;try{document.querySelectorAll(`form`).forEach((t,n)=>{let r=t.id||t.name||`form-${n}`,i=new FormData(t);i.entries().next().done||e.set(r,i)})}catch{}return e}captureFocusedElement(){try{let e=document.activeElement;if(e&&e!==document.body){if(e.id)return`#${e.id}`;if((e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&e.name)return`[name="${e.name}"]`}}catch{}return null}storeState(e,t){let n=this.routeAccessOrder.indexOf(e);for(n!==-1&&this.routeAccessOrder.splice(n,1),this.routeAccessOrder.push(e),this.stateHistory.set(e,t);this.routeAccessOrder.length>this.maxHistorySize;){let e=this.routeAccessOrder.shift();e!=null&&e!==``&&this.stateHistory.delete(e)}}restoreState(e){let t=this.stateHistory.get(e);if(!t)return!1;let n=!0;return this.restoreScrollPositions(t.scrollPositions)||(n=!1),this.restoreFormData(t.formData)||(n=!1),t.focusedElement!=null&&t.focusedElement!==``&&this.restoreFocus(t.focusedElement),n}restoreScrollPositions(e){let t=!0;try{e.forEach((e,n)=>{try{if(n===`window`)window.scrollTo(e.x,e.y);else{let r=document.getElementById(n)??document.querySelector(`[data-scrollable-id="${n}"]`);r instanceof HTMLElement?(r.scrollLeft=e.x,r.scrollTop=e.y):t=!1}}catch{t=!1}})}catch(e){console.error(`[rari] Router: Failed to restore scroll positions:`,e),t=!1}return t}restoreFormData(e){let t=!0;try{e.forEach((e,n)=>{try{let r=document.getElementById(n),i=r instanceof HTMLFormElement?r:document.querySelector(`form[name="${n}"]`)??document.querySelectorAll(`form`)[Number.parseInt(n.replace(`form-`,``),10)];i instanceof HTMLFormElement&&l(i,e)||(t=!1)}catch{t=!1}})}catch(e){console.error(`[rari] Router: Failed to restore form data:`,e),t=!1}return t}restoreFocus(e){try{let t=document.querySelector(e);t instanceof HTMLElement&&requestAnimationFrame(()=>{try{t.focus()}catch{}})}catch{}}};function w(e){return r(e)&&typeof e.navigationId==`number`}function T(e){return r(e)&&typeof e.navigationId==`number`&&`error`in e}function ae(e){let t=e.headers.get(`x-rari-metadata`);if(t!=null&&t!==``)try{let e=JSON.parse(decodeURIComponent(t));if(!r(e))return;if(typeof e.title==`string`&&e.title!==``&&(document.title=e.title),typeof e.description==`string`&&e.description!==``){let t=document.querySelector(`meta[name="description"]`);t||(t=document.createElement(`meta`),t.setAttribute(`name`,`description`),document.head.appendChild(t)),t.setAttribute(`content`,e.description)}}catch{}}async function oe(e,t){return t.aborted?{error:new DOMException(`Aborted`,`AbortError`)}:new Promise(n=>{function r(){window.removeEventListener(`rari:navigate-committed`,i),window.removeEventListener(`rari:navigate-error`,o),t.removeEventListener(`abort`,s)}function i(t){a(t,w)?.navigationId===e&&(r(),n(`committed`))}function o(t){let i=a(t,T);i?.navigationId===e&&(r(),n({error:i.error}))}function s(){r(),n({error:new DOMException(`Aborted`,`AbortError`)})}window.addEventListener(`rari:navigate-committed`,i),window.addEventListener(`rari:navigate-error`,o),t.addEventListener(`abort`,s,{once:!0})})}function se(n){let r=u(35),{children:a,initialRoute:o}=n,l;r[0]===o?l=r[1]:(l=()=>({currentRoute:typeof window<`u`?`${window.location.pathname}${window.location.search}`:c(o),navigationId:0,error:null}),r[0]=o,r[1]=l);let[g,_]=m(l),v=p(null),y=p(!0),b;r[2]===o?b=r[3]:(b=typeof window<`u`?`${window.location.pathname}${window.location.search}`:c(o),r[2]=o,r[3]=b);let x=p(b),S;r[4]===o?S=r[5]:(S=typeof window<`u`?`${window.location.pathname}${window.location.search}${window.location.hash}`:c(o),r[4]=o,r[5]=S);let C=p(S),w=p(0),T;r[6]===Symbol.for(`react.memo_cache_sentinel`)?(T=new te({onError:ue}),r[6]=T):T=r[6];let se=p(T),E;r[7]===Symbol.for(`react.memo_cache_sentinel`)?(E=/* @__PURE__ */ new Map,r[7]=E):E=r[7];let D=p(E),O;r[8]===Symbol.for(`react.memo_cache_sentinel`)?(O=new ie({maxHistorySize:50}),r[8]=O):O=r[8];let k=p(O),de=le,A;r[9]===Symbol.for(`react.memo_cache_sentinel`)?(A=()=>{v.current&&=(v.current.abort(),null)},r[9]=A):A=r[9];let fe=A,j;r[10]===Symbol.for(`react.memo_cache_sentinel`)?(j=()=>{for(let[,e]of D.current.entries())e.bodyHandedOff?window.dispatchEvent(new CustomEvent(`rari:navigate-error`,{detail:{navigationId:e.navigationId,error:new DOMException(`Aborted`,`AbortError`)}})):e.abortController.abort();D.current.clear()},r[10]=j):j=r[10];let pe=j,M;r[11]===g?M=r[12]:(M=(e,t)=>{D.current.delete(e),y.current&&g.navigationId===t&&_(ce)},r[11]=g,r[12]=M);let N=M,P;r[13]===Symbol.for(`react.memo_cache_sentinel`)?(P=(e,t)=>{let n=t===void 0?{}:t,r=`${window.location.pathname}${window.location.search}`,i=e?`${r}#${e}`:r;if(e){let t=document.getElementById(e);t&&t.scrollIntoView({behavior:`smooth`,block:`start`})}i!==`${window.location.pathname}${window.location.search}${window.location.hash}`&&(n.replace?window.history.replaceState(window.history.state,``,i):window.history.pushState(window.history.state,``,i)),C.current=i},r[13]=P):P=r[13];let me=P,F;if(r[14]===Symbol.for(`react.memo_cache_sentinel`)){let e=(e,t,n)=>{n.historyKey!=null&&n.historyKey!==``?requestAnimationFrame(()=>{k.current.restoreState(e)}):t&&requestAnimationFrame(()=>{let e=n=>{let r=n===void 0?0:n,i=document.getElementById(t);i?i.scrollIntoView({behavior:`smooth`,block:`start`}):r<10&&setTimeout(e,50,r+1)};e()})};F=(t,n,r,i,a)=>{y.current&&w.current===i&&(x.current=t,C.current=a,_(e=>({...e,currentRoute:t,navigationId:i,error:null})),e(t,n,r))},r[14]=F}else F=r[14];let he=F,I;r[15]===N?I=r[16]:(I=(e,t,n,r,i)=>{let a=i===void 0?{}:i;if(s(e)){N(t,n);return}let o=se.current.handleError(e,t);y.current&&(_(e=>({...e,error:o})),window.history.replaceState(window.history.state,``,r)),D.current.delete(t),a.emitEvent!==!1&&window.dispatchEvent(new CustomEvent(`rari:navigate-error`,{detail:{from:r,to:t,error:o,navigationId:n}}))},r[15]=N,r[16]=I);let L=I,R;r[17]!==N||r[18]!==L?(R=async(e,t)=>{let n=t===void 0?{}:t;if(!e||typeof e!=`string`)return;let[r,i]=e.includes(`#`)?e.split(`#`):[e,``],a=c(r);if(a===x.current){me(i,{replace:n.replace===!0});return}let o=D.current.get(a);if(o)return o.promise;pe(),fe();let s=new AbortController;v.current=s,w.current+=1;let l=w.current;window.dispatchEvent(new CustomEvent(`rari:navigation-start`,{detail:{navigationId:l,targetPath:a}}));let u=(async()=>{let e=C.current;try{(n.historyKey==null||n.historyKey===``)&&k.current.captureState(x.current);let t=n.historyKey!=null&&n.historyKey!==``?n.historyKey:de(),r=window.location.origin+a,o={route:a,navigationId:l,scrollPosition:{x:window.scrollX,y:window.scrollY},timestamp:Date.now(),key:t},c=await fetch(r,{headers:{Accept:`text/x-component`,"rari-navigation-id":String(l),"rari-router-state":ee()},cache:`no-store`,signal:s.signal});if(!c.ok&&c.status!==404){L(/* @__PURE__ */ Error(`Failed to fetch: ${c.status}`),a,l,e);return}if(s.signal.aborted){N(a,l);return}let u=new URL(c.url),d=u.pathname,f=`${u.pathname}${u.search}`,p={...o,route:f},m=`${f}${i?`#${i}`:``}`;if(w.current!==l)return;let h=oe(l,s.signal),g=D.current.get(a);if(g!=null&&(g.bodyHandedOff=!0),v.current===s&&(v.current=null),window.dispatchEvent(new CustomEvent(`rari:navigate`,{detail:{from:new URL(e,window.location.origin).pathname,to:d,navigationId:l,options:n,abortSignal:s.signal,rscResponse:c,pendingHistory:{url:m,state:p,replace:n.replace===!0}}})),w.current!==l){window.dispatchEvent(new CustomEvent(`rari:navigate-error`,{detail:{navigationId:l,error:new DOMException(`Aborted`,`AbortError`)}}));return}let _=await h;if(w.current!==l)return;if(_!==`committed`){L(_.error,a,l,e,{emitEvent:!1});return}he(f,i,n,l,m),ae(c),D.current.delete(a)}catch(t){L(t,a,l,e)}})();return D.current.set(a,{targetPath:a,navigationId:l,promise:u,abortController:s,bodyHandedOff:!1}),u},r[17]=N,r[18]=L,r[19]=R):R=r[19];let z=R,B=p(z),V;r[20]===z?V=r[21]:(V=()=>(B.current=z,()=>{B.current=null}),r[20]=z,r[21]=V),f(V);let ge=p(null),H,U;r[22]===Symbol.for(`react.memo_cache_sentinel`)?(H=()=>{ge.current??=h((e,t)=>{B.current?.(e,t)},50,{leading:!0,trailing:!0,maxWait:200})},U=[],r[22]=H,r[23]=U):(H=r[22],U=r[23]),f(H,U);let W;r[24]===Symbol.for(`react.memo_cache_sentinel`)?(W=e=>{if(e.button!==0||e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)return;let t=e.target instanceof Element?e.target:null;for(;t&&!(t instanceof HTMLAnchorElement);)t=t.parentElement;if(!(t instanceof HTMLAnchorElement))return;let n=t;if(n.target&&n.target!==`_self`||n.hasAttribute(`download`))return;let r=n.getAttribute(`href`);if(r==null||r===``||ne(r))return;if(r.startsWith(`#`)){e.preventDefault();let t=r.slice(1),n=document.getElementById(t);if(n){n.scrollIntoView({behavior:`smooth`,block:`start`});let e=`${window.location.pathname}${window.location.search}#${t}`;window.history.pushState(window.history.state,``,e),C.current=e}return}e.preventDefault();let i=re(r);ge.current?.(i,{replace:!1})},r[24]=W):W=r[24];let _e=W,G;r[25]===Symbol.for(`react.memo_cache_sentinel`)?(G=e=>{let t=`${window.location.pathname}${window.location.search}${window.location.hash}`,n=i(e.state)?e.state:null;B.current&&B.current(t,{replace:!0,scroll:!1,historyKey:n?.key})},r[25]=G):G=r[25];let ve=G,K;r[26]===Symbol.for(`react.memo_cache_sentinel`)?(K=()=>{let e=i(window.history.state)?window.history.state:null;if(e?.key==null||e.key===``){let e={route:`${window.location.pathname}${window.location.search}`,navigationId:0,scrollPosition:{x:window.scrollX,y:window.scrollY},timestamp:Date.now(),key:de()};window.history.replaceState(e,``,window.location.pathname+window.location.search+window.location.hash)}},r[26]=K):K=r[26];let q;r[27]===o?q=r[28]:(q=[o],r[27]=o,r[28]=q),d(K,q);let J;r[29]===Symbol.for(`react.memo_cache_sentinel`)?(J=e=>{if(e.persisted){let e=window.location.pathname;k.current.captureState(e)}},r[29]=J):J=r[29];let ye=J,Y;r[30]===Symbol.for(`react.memo_cache_sentinel`)?(Y=e=>{if(e.persisted){let e=window.location.pathname,t=i(window.history.state)?window.history.state:null;requestAnimationFrame(()=>{k.current.restoreState(e),t?.scrollPosition&&window.scrollTo(t.scrollPosition.x,t.scrollPosition.y)})}},r[30]=Y):Y=r[30];let be=Y,X,Z;r[31]===Symbol.for(`react.memo_cache_sentinel`)?(X=()=>(document.addEventListener(`click`,_e),window.addEventListener(`popstate`,ve),window.addEventListener(`pagehide`,ye),window.addEventListener(`pageshow`,be),()=>{document.removeEventListener(`click`,_e),window.removeEventListener(`popstate`,ve),window.removeEventListener(`pagehide`,ye),window.removeEventListener(`pageshow`,be)}),Z=[],r[31]=X,r[32]=Z):(X=r[31],Z=r[32]),d(X,Z);let Q,$;return r[33]===Symbol.for(`react.memo_cache_sentinel`)?(Q=()=>(y.current=!0,e(async(e,t)=>B.current?.(e,t)??Promise.resolve()),()=>{y.current=!1,t(),fe(),pe(),ge.current?.cancel()}),$=[],r[33]=Q,r[34]=$):(Q=r[33],$=r[34]),d(Q,$),a}function ce(e){return{...e}}function le(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`hk-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,11)}`}function ue(e){console.error(`[rari] Router: Navigation error:`,e)}export{se as ClientRouter};
|
|
7
|
+
this.onError=e.onError??(()=>{})}handleError(e,t){let n=C(e,t);return this.onError(n),console.error(`[rari] Navigation:`,n.type,n.message,{url:n.url,statusCode:n.statusCode,retryable:n.retryable}),n}};function ne(e,t){try{let n=t!=null&&t!==``?t:window.location.origin,r=typeof URL.parse==`function`?URL.parse(e,n):new URL(e,n);return r!=null&&r.origin!==n}catch{return!1}}function re(e){try{let t=typeof URL.parse==`function`?URL.parse(e,window.location.origin):new URL(e,window.location.origin);return t==null?e:`${t.pathname}${t.search}${t.hash}`}catch{return e}}var ie=class{stateHistory;routeAccessOrder;maxHistorySize;scrollableSelector;constructor(e={}){this.stateHistory=/* @__PURE__ */ new Map,this.routeAccessOrder=[],this.maxHistorySize=e.maxHistorySize!=null&&e.maxHistorySize!==0?e.maxHistorySize:50,this.scrollableSelector=e.scrollableSelector!=null&&e.scrollableSelector!==``?e.scrollableSelector:`[data-scrollable], .scrollable, [style*="overflow"]`}captureState(e){let t={scrollPositions:this.captureScrollPositions(),formData:this.captureFormData(),focusedElement:this.captureFocusedElement()};return this.storeState(e,t),t}captureScrollPositions(){let e=/* @__PURE__ */ new Map;try{e.set(`window`,{x:window.scrollX,y:window.scrollY,element:`window`}),document.querySelectorAll(this.scrollableSelector).forEach((t,n)=>{if(t instanceof HTMLElement){let r=t.id||`scrollable-${n}`;(t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth)&&e.set(r,{x:t.scrollLeft,y:t.scrollTop,element:r})}})}catch{}return e}captureFormData(){let e=/* @__PURE__ */ new Map;try{document.querySelectorAll(`form`).forEach((t,n)=>{let r=t.id||t.name||`form-${n}`,i=new FormData(t);i.entries().next().done||e.set(r,i)})}catch{}return e}captureFocusedElement(){try{let e=document.activeElement;if(e&&e!==document.body){if(e.id)return`#${e.id}`;if((e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&e.name)return`[name="${e.name}"]`}}catch{}return null}storeState(e,t){let n=this.routeAccessOrder.indexOf(e);for(n!==-1&&this.routeAccessOrder.splice(n,1),this.routeAccessOrder.push(e),this.stateHistory.set(e,t);this.routeAccessOrder.length>this.maxHistorySize;){let e=this.routeAccessOrder.shift();e!=null&&e!==``&&this.stateHistory.delete(e)}}restoreState(e){let t=this.stateHistory.get(e);if(!t)return!1;let n=!0;return this.restoreScrollPositions(t.scrollPositions)||(n=!1),this.restoreFormData(t.formData)||(n=!1),t.focusedElement!=null&&t.focusedElement!==``&&this.restoreFocus(t.focusedElement),n}restoreScrollPositions(e){let t=!0;try{e.forEach((e,n)=>{try{if(n===`window`)window.scrollTo(e.x,e.y);else{let r=document.getElementById(n)??document.querySelector(`[data-scrollable-id="${n}"]`);r instanceof HTMLElement?(r.scrollLeft=e.x,r.scrollTop=e.y):t=!1}}catch{t=!1}})}catch(e){console.error(`[rari] Router: Failed to restore scroll positions:`,e),t=!1}return t}restoreFormData(e){let t=!0;try{e.forEach((e,n)=>{try{let r=document.getElementById(n),i=r instanceof HTMLFormElement?r:document.querySelector(`form[name="${n}"]`)??document.querySelectorAll(`form`)[Number.parseInt(n.replace(`form-`,``),10)];i instanceof HTMLFormElement&&u(i,e)||(t=!1)}catch{t=!1}})}catch(e){console.error(`[rari] Router: Failed to restore form data:`,e),t=!1}return t}restoreFocus(e){try{let t=document.querySelector(e);t instanceof HTMLElement&&requestAnimationFrame(()=>{try{t.focus()}catch{}})}catch{}}};function w(e){return r(e)&&typeof e.navigationId==`number`}function T(e){return r(e)&&typeof e.navigationId==`number`&&`error`in e}function ae(e){let t=e.headers.get(`x-rari-metadata`);if(t!=null&&t!==``)try{let e=JSON.parse(decodeURIComponent(t));if(!r(e))return;if(typeof e.title==`string`&&e.title!==``&&(document.title=e.title),typeof e.description==`string`&&e.description!==``){let t=document.querySelector(`meta[name="description"]`);t||(t=document.createElement(`meta`),t.setAttribute(`name`,`description`),document.head.appendChild(t)),t.setAttribute(`content`,e.description)}}catch{}}async function oe(e,t){return t.aborted?{error:new DOMException(`Aborted`,`AbortError`)}:new Promise(n=>{function r(){window.removeEventListener(`rari:navigate-committed`,i),window.removeEventListener(`rari:navigate-error`,o),t.removeEventListener(`abort`,s)}function i(t){a(t,w)?.navigationId===e&&(r(),n(`committed`))}function o(t){let i=a(t,T);i?.navigationId===e&&(r(),n({error:i.error}))}function s(){r(),n({error:new DOMException(`Aborted`,`AbortError`)})}window.addEventListener(`rari:navigate-committed`,i),window.addEventListener(`rari:navigate-error`,o),t.addEventListener(`abort`,s,{once:!0})})}function se(n){let r=d(35),{children:a,initialRoute:o}=n,u;r[0]===o?u=r[1]:(u=()=>({currentRoute:typeof window<`u`?`${window.location.pathname}${window.location.search}`:t(o),navigationId:0,error:null}),r[0]=o,r[1]=u);let[g,_]=h(u),v=m(null),y=m(!0),b;r[2]===o?b=r[3]:(b=typeof window<`u`?`${window.location.pathname}${window.location.search}`:t(o),r[2]=o,r[3]=b);let x=m(b),S;r[4]===o?S=r[5]:(S=typeof window<`u`?`${window.location.pathname}${window.location.search}${window.location.hash}`:t(o),r[4]=o,r[5]=S);let C=m(S),w=m(0),T;r[6]===Symbol.for(`react.memo_cache_sentinel`)?(T=new te({onError:ue}),r[6]=T):T=r[6];let se=m(T),E;r[7]===Symbol.for(`react.memo_cache_sentinel`)?(E=/* @__PURE__ */ new Map,r[7]=E):E=r[7];let D=m(E),O;r[8]===Symbol.for(`react.memo_cache_sentinel`)?(O=new ie({maxHistorySize:50}),r[8]=O):O=r[8];let k=m(O),de=le,A;r[9]===Symbol.for(`react.memo_cache_sentinel`)?(A=()=>{v.current&&=(v.current.abort(),null)},r[9]=A):A=r[9];let fe=A,j;r[10]===Symbol.for(`react.memo_cache_sentinel`)?(j=()=>{for(let[,e]of D.current.entries())e.bodyHandedOff?window.dispatchEvent(new CustomEvent(`rari:navigate-error`,{detail:{navigationId:e.navigationId,error:new DOMException(`Aborted`,`AbortError`)}})):e.abortController.abort();D.current.clear()},r[10]=j):j=r[10];let pe=j,M;r[11]===g?M=r[12]:(M=(e,t)=>{D.current.delete(e),y.current&&g.navigationId===t&&_(ce)},r[11]=g,r[12]=M);let N=M,P;r[13]===Symbol.for(`react.memo_cache_sentinel`)?(P=(e,t)=>{let n=t===void 0?{}:t,r=`${window.location.pathname}${window.location.search}`,i=e?`${r}#${e}`:r;if(e){let t=document.getElementById(e);t&&t.scrollIntoView({behavior:`smooth`,block:`start`})}i!==`${window.location.pathname}${window.location.search}${window.location.hash}`&&(n.replace?window.history.replaceState(window.history.state,``,i):window.history.pushState(window.history.state,``,i)),C.current=i},r[13]=P):P=r[13];let me=P,F;if(r[14]===Symbol.for(`react.memo_cache_sentinel`)){let e=(e,t,n)=>{n.historyKey!=null&&n.historyKey!==``?requestAnimationFrame(()=>{k.current.restoreState(e)}):t&&requestAnimationFrame(()=>{let e=n=>{let r=n===void 0?0:n,i=document.getElementById(t);i?i.scrollIntoView({behavior:`smooth`,block:`start`}):r<10&&setTimeout(e,50,r+1)};e()})};F=(t,n,r,i,a)=>{y.current&&w.current===i&&(x.current=t,C.current=a,_(e=>({...e,currentRoute:t,navigationId:i,error:null})),e(t,n,r))},r[14]=F}else F=r[14];let he=F,I;r[15]===N?I=r[16]:(I=(e,t,n,r,i)=>{let a=i===void 0?{}:i;if(s(e)){N(t,n);return}let o=se.current.handleError(e,t);y.current&&(_(e=>({...e,error:o})),window.history.replaceState(window.history.state,``,r)),D.current.delete(t),a.emitEvent!==!1&&window.dispatchEvent(new CustomEvent(`rari:navigate-error`,{detail:{from:r,to:t,error:o,navigationId:n}}))},r[15]=N,r[16]=I);let L=I,R;r[17]!==N||r[18]!==L?(R=async(n,r)=>{let i=r===void 0?{}:r;if(!n||typeof n!=`string`)return;let[a,o]=n.includes(`#`)?n.split(`#`):[n,``],s=t(a);if(s===x.current){me(o,{replace:i.replace===!0});return}let c=D.current.get(s);if(c)return c.promise;pe(),fe();let l=new AbortController;v.current=l,w.current+=1;let u=w.current;window.dispatchEvent(new CustomEvent(`rari:navigation-start`,{detail:{navigationId:u,targetPath:s}}));let d=(async()=>{let t=C.current;try{(i.historyKey==null||i.historyKey===``)&&k.current.captureState(x.current);let n=i.historyKey!=null&&i.historyKey!==``?i.historyKey:de(),r=window.location.origin+s,a={route:s,navigationId:u,scrollPosition:{x:window.scrollX,y:window.scrollY},timestamp:Date.now(),key:n},c=await fetch(r,{headers:{Accept:`text/x-component`,"rari-navigation-id":String(u),"rari-router-state":e()},cache:`no-store`,signal:l.signal});if(!c.ok&&c.status!==404){L(/* @__PURE__ */ Error(`Failed to fetch: ${c.status}`),s,u,t);return}if(l.signal.aborted){N(s,u);return}let d=new URL(c.url),f=d.pathname,p=`${d.pathname}${d.search}`,m={...a,route:p},h=`${p}${o?`#${o}`:``}`;if(w.current!==u)return;let ee=oe(u,l.signal),g=D.current.get(s);if(g!=null&&(g.bodyHandedOff=!0),v.current===l&&(v.current=null),window.dispatchEvent(new CustomEvent(`rari:navigate`,{detail:{from:new URL(t,window.location.origin).pathname,to:f,navigationId:u,options:i,abortSignal:l.signal,rscResponse:c,pendingHistory:{url:h,state:m,replace:i.replace===!0}}})),w.current!==u){window.dispatchEvent(new CustomEvent(`rari:navigate-error`,{detail:{navigationId:u,error:new DOMException(`Aborted`,`AbortError`)}}));return}let _=await ee;if(w.current!==u)return;if(_!==`committed`){L(_.error,s,u,t,{emitEvent:!1});return}he(p,o,i,u,h),ae(c),D.current.delete(s)}catch(e){L(e,s,u,t)}})();return D.current.set(s,{targetPath:s,navigationId:u,promise:d,abortController:l,bodyHandedOff:!1}),d},r[17]=N,r[18]=L,r[19]=R):R=r[19];let z=R,B=m(z),V;r[20]===z?V=r[21]:(V=()=>(B.current=z,()=>{B.current=null}),r[20]=z,r[21]=V),p(V);let ge=m(null),H,U;r[22]===Symbol.for(`react.memo_cache_sentinel`)?(H=()=>{ge.current??=ee((e,t)=>{B.current?.(e,t)},50,{leading:!0,trailing:!0,maxWait:200})},U=[],r[22]=H,r[23]=U):(H=r[22],U=r[23]),p(H,U);let W;r[24]===Symbol.for(`react.memo_cache_sentinel`)?(W=e=>{if(e.button!==0||e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)return;let t=e.target instanceof Element?e.target:null;for(;t&&!(t instanceof HTMLAnchorElement);)t=t.parentElement;if(!(t instanceof HTMLAnchorElement))return;let n=t;if(n.target&&n.target!==`_self`||n.hasAttribute(`download`))return;let r=n.getAttribute(`href`);if(r==null||r===``||ne(r))return;if(r.startsWith(`#`)){e.preventDefault();let t=r.slice(1),n=document.getElementById(t);if(n){n.scrollIntoView({behavior:`smooth`,block:`start`});let e=`${window.location.pathname}${window.location.search}#${t}`;window.history.pushState(window.history.state,``,e),C.current=e}return}e.preventDefault();let i=re(r);ge.current?.(i,{replace:!1})},r[24]=W):W=r[24];let _e=W,G;r[25]===Symbol.for(`react.memo_cache_sentinel`)?(G=e=>{let t=`${window.location.pathname}${window.location.search}${window.location.hash}`,n=i(e.state)?e.state:null;B.current&&B.current(t,{replace:!0,scroll:!1,historyKey:n?.key})},r[25]=G):G=r[25];let ve=G,K;r[26]===Symbol.for(`react.memo_cache_sentinel`)?(K=()=>{let e=i(window.history.state)?window.history.state:null;if(e?.key==null||e.key===``){let e={route:`${window.location.pathname}${window.location.search}`,navigationId:0,scrollPosition:{x:window.scrollX,y:window.scrollY},timestamp:Date.now(),key:de()};window.history.replaceState(e,``,window.location.pathname+window.location.search+window.location.hash)}},r[26]=K):K=r[26];let q;r[27]===o?q=r[28]:(q=[o],r[27]=o,r[28]=q),f(K,q);let J;r[29]===Symbol.for(`react.memo_cache_sentinel`)?(J=e=>{if(e.persisted){let e=window.location.pathname;k.current.captureState(e)}},r[29]=J):J=r[29];let ye=J,Y;r[30]===Symbol.for(`react.memo_cache_sentinel`)?(Y=e=>{if(e.persisted){let e=window.location.pathname,t=i(window.history.state)?window.history.state:null;requestAnimationFrame(()=>{k.current.restoreState(e),t?.scrollPosition&&window.scrollTo(t.scrollPosition.x,t.scrollPosition.y)})}},r[30]=Y):Y=r[30];let be=Y,X,Z;r[31]===Symbol.for(`react.memo_cache_sentinel`)?(X=()=>(document.addEventListener(`click`,_e),window.addEventListener(`popstate`,ve),window.addEventListener(`pagehide`,ye),window.addEventListener(`pageshow`,be),()=>{document.removeEventListener(`click`,_e),window.removeEventListener(`popstate`,ve),window.removeEventListener(`pagehide`,ye),window.removeEventListener(`pageshow`,be)}),Z=[],r[31]=X,r[32]=Z):(X=r[31],Z=r[32]),f(X,Z);let Q,$;return r[33]===Symbol.for(`react.memo_cache_sentinel`)?(Q=()=>(y.current=!0,c(async(e,t)=>B.current?.(e,t)??Promise.resolve()),()=>{y.current=!1,l(),fe(),pe(),ge.current?.cancel()}),$=[],r[33]=Q,r[34]=$):(Q=r[33],$=r[34]),f(Q,$),a}function ce(e){return{...e}}function le(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`hk-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,11)}`}function ue(e){console.error(`[rari] Router: Navigation error:`,e)}export{se as ClientRouter};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Component, ComponentType, ErrorInfo, ReactNode } from "react";
|
|
2
|
-
//#region src/runtime/boundaries/error-boundary-wrapper.d.ts
|
|
3
2
|
interface ErrorBoundaryWrapperProps {
|
|
4
3
|
readonly errorComponentId: string;
|
|
5
4
|
readonly children: ReactNode;
|
|
@@ -23,5 +22,4 @@ export declare class ErrorBoundaryWrapper extends Component<ErrorBoundaryWrapper
|
|
|
23
22
|
reset: () => void;
|
|
24
23
|
render(): ReactNode;
|
|
25
24
|
}
|
|
26
|
-
//#endregion
|
|
27
25
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{t as e}from"../timer-Duul5JHq.mjs";import{g as t,s as n,u as r}from"../type-guards-BLY2PlGR.mjs";import{r as i}from"../rari-global-5vGzhToD.mjs";import{Component as a}from"react";import{jsx as o,jsxs as s}from"react/jsx-runtime";function c(e){if(r(e))return e;if(t(e)){let t=e.default??e;return r(t)?t:null}return null}var l=class extends a{_isMounted=!1;_pendingTimer=null;constructor(e){super(e),this.state={hasError:!1,error:null,ErrorComponent:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidMount(){this._isMounted=!0}componentWillUnmount(){this._isMounted=!1,this._pendingTimer=e(this._pendingTimer)}componentDidCatch(e,t){if(n(e))return;console.error(`[rari] Error boundary caught error:`,e,t);let r=this.props.errorComponentId;if(r!==``){let e=i();if(r in e){let t=e[r],n=c(t.component);n?this.setState({ErrorComponent:n}):t.loader&&!t.loading&&(t.loading=!0,t.loader().then(e=>{let n=c(e);n&&(t.component=n,t.registered=!0,this.setState({ErrorComponent:n})),t.loading=!1}).catch(e=>{t.loading=!1,console.error(`[rari] Failed to load error component ${r}:`,e)}))}}}reset=()=>{this._pendingTimer=e(this._pendingTimer),this._pendingTimer=setTimeout(()=>{this._isMounted&&this.setState({hasError:!1,error:null,ErrorComponent:null}),this._pendingTimer=null},50)};render(){if(this.state.hasError&&this.state.error){if(n(this.state.error))return null;let{ErrorComponent:e}=this.state;return e?/* @__PURE__ */ o(e,{error:this.state.error,reset:this.reset}):/* @__PURE__ */ s(`div`,{className:`rari-error`,role:`alert`,style:{color:`red`,border:`1px solid red`,padding:`10px`,borderRadius:`4px`,backgroundColor:`#fff5f5`},children:[/* @__PURE__ */ o(`strong`,{children:`Error loading content: `}),this.state.error.message]})}return this.props.children}};export{l as ErrorBoundaryWrapper};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ActionDidNotRevalidate, ActionDidRevalidateDynamicOnly, ActionDidRevalidateStaticAndDynamic, ActionRevalidationKind } from "./action-revalidation-kind.mjs";
|
|
2
|
-
//#region src/runtime/actions/flight-refresh.d.ts
|
|
3
2
|
export interface ActionFlightRefreshDetail {
|
|
4
3
|
element: unknown;
|
|
5
4
|
revalidationKind: ActionRevalidationKind;
|
|
@@ -10,5 +9,4 @@ export interface ActionFlightResponseShape {
|
|
|
10
9
|
readonly f?: unknown;
|
|
11
10
|
}
|
|
12
11
|
export declare function scheduleActionFlightRefresh(response: Response, flightResponse: ActionFlightResponseShape, actionResult: unknown): void;
|
|
13
|
-
//#endregion
|
|
14
12
|
export { ActionDidNotRevalidate, ActionDidRevalidateDynamicOnly, ActionDidRevalidateStaticAndDynamic };
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
//#region src/runtime/actions/revalidation-kind.d.ts
|
|
2
1
|
export type ActionRevalidationKind = 0 | 1 | 2;
|
|
3
2
|
export declare const ActionDidNotRevalidate: 0;
|
|
4
3
|
export declare const ActionDidRevalidateStaticAndDynamic: 1;
|
|
5
4
|
export declare const ActionDidRevalidateDynamicOnly: 2;
|
|
6
|
-
export declare function parseActionRevalidationKind(header: string | null): ActionRevalidationKind;
|
|
7
|
-
//#endregion
|
|
5
|
+
export declare function parseActionRevalidationKind(header: string | null): ActionRevalidationKind;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import "../types-
|
|
1
|
+
import "../types-Cw2SI7r7.mjs";
|
|
2
2
|
import "virtual:rsc-integration.ts";
|
|
3
|
-
|
|
4
|
-
export declare function renderApp(): Promise<void>;
|
|
5
|
-
//#endregion
|
|
3
|
+
export declare function renderApp(): Promise<void>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{g as
|
|
1
|
+
import{t as e}from"../router-861SNPMt.mjs";import{g as t,i as n,n as r,p as i,r as a}from"../type-guards-BLY2PlGR.mjs";import{n as o,t as s}from"../preload-modules-0iyuP4Vs.mjs";import{r as c}from"../react-helpers-duOBWuYF.mjs";import{a as l,n as u,r as d}from"../rari-global-5vGzhToD.mjs";import{createElement as f}from"react";import{createFromFetch as p,createFromReadableStream as m}from"virtual:react-flight-client";import{createRoot as h,hydrateRoot as g}from"react-dom/client";import{AppRouterProvider as _}from"virtual:app-router-provider";import{ClientRouter as v}from"virtual:client-router";import"virtual:rsc-integration.ts";function y(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 b(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 x(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 S(e){let t=e.firstElementChild;for(;t!=null&&x(t);)t=t.nextElementSibling;return t}function C(e){if(b(e))return!0;let t=S(e);return t!==null&&!t.classList.contains(`rari-error`)}function w(e){return b(e)}function T(e){e.querySelectorAll(`.rari-error:not([data-rari-hydration-failure])`).forEach(e=>{e.remove()})}const E=`__rari-route-announcer`;function D(){let e=document.getElementById(E);if(e)return e;let t=document.createElement(`div`);return t.id=E,t.setAttribute(`aria-live`,`polite`),t.setAttribute(`aria-atomic`,`true`),t.setAttribute(`style`,`position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0`),document.body.append(t),t}function O(){let e=document.title.trim();if(e!==``)return e;let t=document.querySelector(`h1`)?.textContent.trim()??``;return t===``?window.location.pathname:t}function k(e){if(!(e instanceof CustomEvent))return!1;let t=e.detail;return typeof t==`object`&&!!t&&Reflect.get(t,`hardNavigation`)===!0}function A(){typeof document<`u`&&(D(),window.addEventListener(`rari:navigate-committed`,e=>{if(k(e))return;let t=D();t.textContent=``,requestAnimationFrame(()=>{t.textContent=O()})}))}async function j(e){let t=o(e);for(let e=0;e<10&&i(t);e+=1)t=o(await t);if(i(t))throw Error(`[rari] Failed to resolve Flight element to a React node`);return t}function M(t){if(!c(t))return y(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 n=f(_,{initialPayload:{element:t}});return n=f(v,{initialRoute:window.location.pathname},n),n=f(e,{initialPathname:window.location.pathname},n),F(n),!0}function N(){Reflect.set(globalThis,`__rari_client_ready`,!0),window.dispatchEvent(new CustomEvent(`rari:client-ready`))}function P(e){if(e===``)return;let t=()=>{document.title.trim()===``&&(document.title=e)};t(),queueMicrotask(t),requestAnimationFrame(()=>{t(),requestAnimationFrame(t)})}function F(e){let t=document.documentElement,n=document.title.trim();w(t)?(T(t),g(document,e,{onRecoverableError(e){import.meta.env.DEV&&console.warn(`[rari] Hydration mismatch:`,e)}})):h(document).render(e),P(n),A(),N()}
|
|
2
2
|
/*! @preserve CLIENT_COMPONENT_IMPORTS_PLACEHOLDER */
|
|
3
|
-
|
|
3
|
+
d(),u();
|
|
4
4
|
/*! @preserve CLIENT_COMPONENT_REGISTRATIONS_PLACEHOLDER */
|
|
5
|
-
function
|
|
5
|
+
function I(){let e=Reflect.get(globalThis,`__rari_f`);if(Array.isArray(e))return e}function L(e){return t(e)&&typeof e.rscRow==`string`}function R(e){return Array.isArray(e)&&typeof e[1]==`string`}function z(){return!!I()?.some(e=>e!==0)}function B(){let e=I();if(e?.length==null||e.length===0)return null;let t=``,n=[];for(let r of e)r!==0&&(typeof r==`string`?t+=r:R(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 V(e,t){let r=new TextDecoder().decode(e);await s(r);let i=l(),a=i.streaming,o=!!(a?.bufferedRows&&a.bufferedRows.length>0);if(t.streaming&&(a?.complete===void 0||o)){let t=new ReadableStream({start(t){let r=!1;t.enqueue(e);let a=e=>{if(r)return;let i=n(e,L);i&&t.enqueue(new TextEncoder().encode(`\n${i.rscRow}`))},o=()=>{r||(r=!0,t.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 n of e)t.enqueue(new TextEncoder().encode(`\n${n}`));i.streaming.bufferedRows=[]}i.streaming?.complete&&o()}});return m(t)}let c=new ReadableStream({start(t){t.enqueue(e),t.close()}});return m(c)}async function H(e){let t=`Could not load interactive page data.`,n;try{n=await V(e,{streaming:!1})}catch(e){t=a(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 p(Promise.resolve(r)):t=`Failed to fetch RSC payload fallback: HTTP ${r.status}.`}catch(e){t=a(e,`Failed to fetch RSC payload fallback.`),console.error(`[rari] Failed to fetch RSC payload fallback:`,e)}}return n==null?(y(document.body,`${t} Try refreshing the page.`),console.error(`[rari] Hydration skipped: failed to load RSC payload`),{ok:!1,errorMessage:t}):(M(await j(n)),{ok:!0,errorMessage:t})}async function U(){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 p(Promise.resolve(t))}catch(e){if(e instanceof Promise)throw e;return console.error(`[rari] Failed to fetch initial RSC data:`,e),null}}function W(){return new ReadableStream({start(e){let t=t=>{let r=n(t,L);r&&e.enqueue(new TextEncoder().encode(`${r.rscRow}\n`))},r=()=>{e.close(),window.removeEventListener(`rari:html-stream-row`,t),window.removeEventListener(`rari:stream-complete`,r)};window.addEventListener(`rari:html-stream-row`,t),window.addEventListener(`rari:stream-complete`,r);let i=l();if(i.streaming?.bufferedRows){let t=[...i.streaming.bufferedRows];i.streaming.bufferedRows=[];for(let n of t)e.enqueue(new TextEncoder().encode(`${n}\n`))}i.streaming?.complete&&r()}})}async function G(){try{return await m(W())}catch(e){return console.error(`[rari] Failed to process streaming RSC payload:`,e),null}}async function K(e){try{return await V(e,{streaming:!0})}catch(e){return console.error(`[rari] Failed to parse embedded RSC payload:`,e),console.error(`[rari] Error stack:`,r(e)?.stack??`no stack`),null}}async function q(){let e=z(),t=B(),n=document.documentElement,r=C(document.body)||b(n),i=l().streaming,a=!!(i?.bufferedRows&&i.bufferedRows.length>0);try{if(r&&e&&t){await H(t);return}let n=!e&&!a&&!r,i;if(n?i=await U():e&&t?i=await K(t):a&&(i=await G()),i==null)throw Error(`No RSC data available for hydration`);M(await j(i))}catch(e){console.error(`[rari] Error rendering app:`,e)}}function J(){let e=import.meta.hot;if(!e)return{};let n=e.data;return t(n)?{hasRendered:n.hasRendered===!0}:{}}function Y(){let e=import.meta.hot;if(!e)return;let n=e.data;t(n)&&(n.hasRendered=!0)}import.meta.hot&&J().hasRendered===!0||(q().catch(e=>{console.error(`[rari] Fatal error:`,e)}),Y());export{q as renderApp};
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { t as FlightContent } from "../react-helpers-
|
|
1
|
+
import { t as FlightContent } from "../react-helpers-CZtKqfS6.mjs";
|
|
2
2
|
import { ReactElement, ReactNode } from "react";
|
|
3
|
-
//#region src/runtime/flight/merge-refresh.d.ts
|
|
4
3
|
export declare function isLayoutReuseMarker(element: ReactElement): boolean;
|
|
5
4
|
export declare function layoutPathOf(element: ReactElement): string | undefined;
|
|
6
5
|
export declare function setChildrenAtLayoutPath(document: ReactElement, layoutPath: string, nextChildren: ReactNode): ReactElement | null;
|
|
7
6
|
export declare function unwrapFulfilledFlightNode(node: FlightContent): ReactNode;
|
|
8
|
-
export declare function mergeFlightRefresh(current: ReactNode, refresh: ReactNode): ReactNode;
|
|
9
|
-
//#endregion
|
|
7
|
+
export declare function mergeFlightRefresh(current: ReactNode, refresh: ReactNode): ReactNode;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import "../types-
|
|
2
|
-
//#region src/runtime/shared/get-client-component.d.ts
|
|
1
|
+
import "../types-Cw2SI7r7.mjs";
|
|
3
2
|
declare function requireClientComponent(id: string): any;
|
|
4
|
-
//#endregion
|
|
5
|
-
//#region src/runtime/rsc/client-runtime.d.ts
|
|
6
3
|
declare global {
|
|
7
4
|
var __rari_rsc_require__: typeof requireClientComponent | undefined;
|
|
8
5
|
}
|
|
9
|
-
//#endregion
|
|
10
6
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as e}from"../type-guards-BLY2PlGR.mjs";import{
|
|
1
|
+
import{g as e}from"../type-guards-BLY2PlGR.mjs";import{n as t,r as n}from"../get-client-component-DVAbynLr.mjs";import{a as r,i,n as a,r as o,t as s}from"../rari-global-5vGzhToD.mjs";if(i().isDevelopment=process.env.NODE_ENV!==`production`,o(),s(),a(),typeof window<`u`&&(t(),Reflect.set(globalThis,`__rari_rsc_require__`,n)),typeof window<`u`){let e=r();e.streaming??={bufferedRows:[]}}if(import.meta.hot){function t(e){if(!e)return!1;try{return i().serverComponents?.has(e)===!0}catch{return!1}}let n=!1,r=[],a=/* @__PURE__ */ new Map;function o(e,t,i){a.set(e,async e=>{i(e)&&await t(e)}),import.meta.hot.on(e,t=>{(async()=>{if(!n)r.push({event:e,data:t});else 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=i();t.serverComponents??=/* @__PURE__ */ new Set,t.serverComponents.add(e.filePath)},s),o(`rari:server-components-registry`,e=>{let t=i();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),r.length>0?(async()=>{try{let e=[...r];r.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{n=!0}})():n=!0}export{};
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { createClientModuleProxy as createClientModuleProxy$1, registerServerReference } from "react-server-dom-webpack/server";
|
|
2
|
-
//#region src/runtime/rsc/references.d.ts
|
|
3
2
|
export declare const createClientModuleProxy: typeof createClientModuleProxy$1;
|
|
4
3
|
export declare function registerClientReference<T>(clientReference: T, id: string, exportName: string): T;
|
|
5
|
-
//#endregion
|
|
6
4
|
export { registerServerReference };
|
|
@@ -6,7 +6,7 @@ import{g as e}from"./type-guards-BLY2PlGR.mjs";import{t}from"./xml-DPsk9WTz.mjs"
|
|
|
6
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
7
|
`)}
|
|
8
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,`_`);
|
|
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 TypeError(`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 TypeError(`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
10
|
/* v8 ignore start - file system operations and dynamic imports, better tested in integration/e2e */
|
|
11
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
12
|
/* v8 ignore stop */
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { CSSProperties, SyntheticEvent } from "react";
|
|
2
2
|
import "virtual:rari-image-config";
|
|
3
|
-
//#region src/image/image.d.ts
|
|
4
3
|
interface ImageProps {
|
|
5
4
|
readonly src: string | StaticImageData;
|
|
6
5
|
readonly alt: string;
|
|
@@ -33,8 +32,6 @@ interface StaticImageData {
|
|
|
33
32
|
readonly blurDataURL?: string;
|
|
34
33
|
}
|
|
35
34
|
declare function Image({ src, alt, width, height, quality, preload, loading, placeholder, blurDataURL, fill, sizes, style, className, onLoad, onError, unoptimized, loader, overrideSrc, decoding }: ImageProps): import("react").JSX.Element;
|
|
36
|
-
//#endregion
|
|
37
|
-
//#region src/image/static-modules.d.ts
|
|
38
35
|
declare module '*.avif' {
|
|
39
36
|
const image: StaticImageData;
|
|
40
37
|
export default image;
|
|
@@ -59,5 +56,4 @@ declare module '*.webp' {
|
|
|
59
56
|
const image: StaticImageData;
|
|
60
57
|
export default image;
|
|
61
58
|
}
|
|
62
|
-
//#endregion
|
|
63
59
|
export { ImageProps as n, StaticImageData as r, Image as t };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/proxy/http/response.d.ts
|
|
2
1
|
declare class RariResponse extends Response {
|
|
3
2
|
readonly cookies: ResponseCookies;
|
|
4
3
|
constructor(body?: BodyInit | null, init?: ResponseInit);
|
|
@@ -13,8 +12,6 @@ declare class RariResponse extends Response {
|
|
|
13
12
|
static rewrite(destination: string | URL): RariResponse;
|
|
14
13
|
static json(data: unknown, init?: ResponseInit): RariResponse;
|
|
15
14
|
}
|
|
16
|
-
//#endregion
|
|
17
|
-
//#region src/proxy/http/types.d.ts
|
|
18
15
|
interface RariRequest {
|
|
19
16
|
readonly url: string;
|
|
20
17
|
readonly method: string;
|
|
@@ -126,5 +123,4 @@ interface ProxyResult {
|
|
|
126
123
|
readonly permanent: boolean;
|
|
127
124
|
};
|
|
128
125
|
}
|
|
129
|
-
//#endregion
|
|
130
126
|
export { ProxyModule as a, RariURL as c, RariResponse as d, ProxyMatcher as i, RequestCookies as l, ProxyConfig as n, ProxyResult as o, ProxyFunction as r, RariFetchEvent as s, CookieOptions as t, ResponseCookies as u };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/runtime/shared/types.d.ts
|
|
2
1
|
interface CookieOptions {
|
|
3
2
|
readonly path?: string;
|
|
4
3
|
readonly domain?: string;
|
|
@@ -113,5 +112,4 @@ declare global {
|
|
|
113
112
|
'~clientComponentNames'?: GlobalWithRari['~clientComponentNames'];
|
|
114
113
|
}
|
|
115
114
|
}
|
|
116
|
-
//#endregion
|
|
117
115
|
export { ReadonlyHeaders as i, CookieStore as n, ReadonlyCookie as r, CookieOptions as t };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/// <reference types="vite-plus/client" />
|
|
2
2
|
import { ReactNode as ReactNode$1 } from "react";
|
|
3
|
-
//#region src/ambient.d.ts
|
|
4
3
|
declare module 'virtual:react-flight-client' {
|
|
5
4
|
import type { ReactPromise } from 'react';
|
|
6
5
|
export type Thenable<T> = ReactPromise<T> & Promise<T>;
|
|
@@ -84,8 +83,6 @@ declare global {
|
|
|
84
83
|
}>;
|
|
85
84
|
}
|
|
86
85
|
}
|
|
87
|
-
//#endregion
|
|
88
|
-
//#region src/router/build/api-routes.d.ts
|
|
89
86
|
interface RouteContext<TParams extends Record<string, string> = Record<string, string>> {
|
|
90
87
|
readonly params: TParams;
|
|
91
88
|
}
|
|
@@ -104,8 +101,6 @@ declare class ApiResponse extends Response {
|
|
|
104
101
|
static redirect(url: string, status?: number): Response;
|
|
105
102
|
static noContent(init?: ResponseInit): Response;
|
|
106
103
|
}
|
|
107
|
-
//#endregion
|
|
108
|
-
//#region src/router/metadata/app-icons.d.ts
|
|
109
104
|
type AppIconKind = 'favicon' | 'icon' | 'apple-icon';
|
|
110
105
|
interface AppIconEntry {
|
|
111
106
|
readonly path: string;
|
|
@@ -117,8 +112,6 @@ interface AppIconEntry {
|
|
|
117
112
|
readonly width?: number;
|
|
118
113
|
readonly height?: number;
|
|
119
114
|
}
|
|
120
|
-
//#endregion
|
|
121
|
-
//#region src/router/build/types.d.ts
|
|
122
115
|
type RouteSegmentType = 'static' | 'dynamic' | 'catch-all' | 'optional-catch-all';
|
|
123
116
|
interface RouteSegment {
|
|
124
117
|
type: RouteSegmentType;
|
|
@@ -338,8 +331,6 @@ type GenerateMetadata<TParams extends RouteParams = RouteParams, TSearchParams e
|
|
|
338
331
|
searchParams: TSearchParams;
|
|
339
332
|
}>) => RouteMetadata | Promise<RouteMetadata>;
|
|
340
333
|
type GenerateStaticParams<TParams extends RouteParams = RouteParams> = () => TParams[] | Promise<TParams[]>;
|
|
341
|
-
//#endregion
|
|
342
|
-
//#region src/router/metadata/types.d.ts
|
|
343
334
|
interface RobotsRule {
|
|
344
335
|
readonly userAgent?: string | readonly string[];
|
|
345
336
|
readonly allow?: string | readonly string[];
|
|
@@ -436,5 +427,4 @@ interface Feed {
|
|
|
436
427
|
};
|
|
437
428
|
readonly items: readonly FeedEntry[];
|
|
438
429
|
}
|
|
439
|
-
//#endregion
|
|
440
430
|
export { RouteSegmentType as C, RouteContext as D, ApiRouteHandlers as E, RouteHandler as O, RouteSegment as S, ApiResponse as T, LayoutProps as _, Sitemap as a, NotFoundEntry as b, SitemapVideo as c, AppRouteMatch as d, ErrorEntry as f, LayoutEntry as g, GenerateStaticParams as h, RobotsRule as i, AppRouteEntry as l, GenerateMetadata as m, FeedEntry as n, SitemapEntry as o, ErrorProps as p, Robots as r, SitemapImage as s, Feed as t, AppRouteManifest as u, LoadingEntry as v, TemplateEntry as w, PageProps as x, Metadata as y };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/font/types.d.ts
|
|
2
1
|
type FontDisplay = 'auto' | 'block' | 'swap' | 'fallback' | 'optional';
|
|
3
2
|
type LocalFontSrc = string | ReadonlyArray<{
|
|
4
3
|
readonly path: string;
|
|
@@ -39,5 +38,4 @@ interface Font {
|
|
|
39
38
|
};
|
|
40
39
|
readonly variable?: string;
|
|
41
40
|
}
|
|
42
|
-
//#endregion
|
|
43
41
|
export { LocalFontSrc as a, LocalFontOptions as i, FontDisplay as n, GoogleFontOptions as r, Font as t };
|