rari 0.15.16 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/dist/cli.d.mts +11 -0
  2. package/dist/cli.mjs +39 -39
  3. package/dist/{define-CzFpVAjt.mjs → define-CRafeveU.mjs} +1 -1
  4. package/dist/execute-B1z6YRUF.mjs +1 -0
  5. package/dist/feed-uUGeOZmR.mjs +10 -0
  6. package/dist/font/google.d.mts +1951 -0
  7. package/dist/font/google.mjs +1 -0
  8. package/dist/font/local.d.mts +4 -0
  9. package/dist/font/local.mjs +1 -0
  10. package/dist/font.d.mts +3 -0
  11. package/dist/font.mjs +1 -0
  12. package/dist/form-state-DZJs9bve.mjs +1 -0
  13. package/dist/get-client-component-DU5z65us.mjs +1 -0
  14. package/dist/headers.d.mts +4 -4
  15. package/dist/image.d.mts +6 -6
  16. package/dist/image.mjs +1 -1
  17. package/dist/index.d.mts +1 -2
  18. package/dist/mdx/define.mjs +1 -1
  19. package/dist/mdx/registry.d.mts +2 -3
  20. package/dist/mdx.d.mts +3 -3
  21. package/dist/mdx.mjs +1 -1
  22. package/dist/names-CLmM0CPi.mjs +1 -0
  23. package/dist/og.d.mts +2 -2
  24. package/dist/og.mjs +1 -1
  25. package/dist/path-C74rvUep.mjs +1 -0
  26. package/dist/platform.d.mts +3 -4
  27. package/dist/preload-modules-1i2BJqux.mjs +2 -0
  28. package/dist/prompt-uaCPq0_A-BW0EkzOD.mjs +45 -0
  29. package/dist/proxy/RariRequest.d.mts +2 -3
  30. package/dist/proxy/RariRequest.mjs +1 -1
  31. package/dist/proxy/RariResponse.mjs +1 -1
  32. package/dist/proxy/runtime-executor.d.mts +2 -4
  33. package/dist/proxy/runtime-executor.mjs +7 -1
  34. package/dist/{railway-dlVtU472.mjs → railway-CE3nqaKt.mjs} +1 -1
  35. package/dist/regex-constants-DBMCJbMw.mjs +1 -0
  36. package/dist/{render-Dipra0HL.mjs → render-D0eMtn5L.mjs} +1 -1
  37. package/dist/robots-B1bFAd4J.mjs +9 -0
  38. package/dist/router-D6X8JHst.mjs +1 -0
  39. package/dist/router.d.mts +6 -10
  40. package/dist/router.mjs +1 -1
  41. package/dist/rsc-vite-build-Cpu5suGN.mjs +1 -0
  42. package/dist/runtime/AppRouterProvider.d.mts +10 -7
  43. package/dist/runtime/AppRouterProvider.mjs +1 -1
  44. package/dist/runtime/ClientRouter.d.mts +3 -5
  45. package/dist/runtime/ClientRouter.mjs +7 -1
  46. package/dist/runtime/ErrorBoundaryWrapper.d.mts +2 -3
  47. package/dist/runtime/ErrorBoundaryWrapper.mjs +1 -1
  48. package/dist/runtime/LoadingErrorBoundary.d.mts +2 -3
  49. package/dist/runtime/action-flight-refresh.d.mts +4 -5
  50. package/dist/runtime/action-flight-refresh.mjs +1 -1
  51. package/dist/runtime/action-revalidation-kind.d.mts +6 -7
  52. package/dist/runtime/call-server.d.mts +2 -3
  53. package/dist/runtime/call-server.mjs +1 -1
  54. package/dist/runtime/entry-client.d.mts +3 -5
  55. package/dist/runtime/entry-client.mjs +3 -3
  56. package/dist/runtime/flight-route-cache.d.mts +7 -13
  57. package/dist/runtime/flight-route-cache.mjs +1 -1
  58. package/dist/runtime/flight-router-state.d.mts +7 -8
  59. package/dist/runtime/merge-flight-refresh.d.mts +2 -3
  60. package/dist/runtime/merge-flight-refresh.mjs +1 -1
  61. package/dist/runtime/rsc-client-runtime.d.mts +3 -2
  62. package/dist/runtime/rsc-client-runtime.mjs +1 -1
  63. package/dist/runtime/rsc-references.d.mts +3 -4
  64. package/dist/sitemap-DJY3OiJ0.mjs +13 -0
  65. package/dist/type-guards-BJXKlA6x.mjs +1 -0
  66. package/dist/types-CkZPEEdi.d.mts +43 -0
  67. package/dist/{types-_vPM8QuJ.d.mts → types-Q-x_0kVB.d.mts} +0 -9
  68. package/dist/{types-0350HUwk.d.mts → types-xTbuE-Js.d.mts} +237 -3
  69. package/dist/utils-YdvPzSET-Cbo6Ofmz.mjs +37 -0
  70. package/dist/vite.d.mts +38 -23
  71. package/dist/vite.mjs +836 -71
  72. package/dist/{xml-N8OZmN7u.mjs → xml-EW5iM39h.mjs} +1 -1
  73. package/package.json +42 -32
  74. package/dist/alias-resolver-Cigam7Y7.mjs +0 -1
  75. package/dist/feed-Ixvy9L12.mjs +0 -3
  76. package/dist/get-client-component-CLpyIcLJ.mjs +0 -1
  77. package/dist/names-N6JRDeT1.mjs +0 -1
  78. package/dist/preload-modules-QmSvKk0Q.mjs +0 -2
  79. package/dist/regex-constants-Wm7xRA3u.mjs +0 -1
  80. package/dist/robots-BGCTYwKN.mjs +0 -2
  81. package/dist/router-D84JWQz7.mjs +0 -1
  82. package/dist/sitemap-1n5BIACA.mjs +0 -7
  83. package/dist/type-guards-CTkEL8zw.mjs +0 -1
  84. package/dist/types-DCEyvFz7.d.mts +0 -199
  85. package/dist/utils-BLSRP4f6-8hVIII5T.mjs +0 -37
@@ -0,0 +1,9 @@
1
+ import{v as e}from"./type-guards-BJXKlA6x.mjs";import{i as t,n,r,t as i}from"./execute-B1z6YRUF.mjs";import{promises as a}from"node:fs";import o from"node:path";function s(t){return e(t)&&t.rules!=null}async function c(e){if(typeof e==`function`){let t=e(),n=t instanceof Promise?await t:t;if(!s(n))throw Error(`Robots default export must resolve to a robots object`);return n}if(!s(e))throw Error(`Robots default export must be a robots object`);return e}function l(e){return typeof e==`string`?e===``?[`*`]:[e]:e==null?[`*`]:[...e]}function u(e){return e===void 0?[]:typeof e==`string`?e===``?[]:[e]:[...e].filter(e=>e!==``)}function d(e){let t=[],n=l(e.userAgent);for(let r of n){t.push(`User-Agent: ${r}`);let n=u(e.allow);for(let e of n)t.push(`Allow: ${e}`);let i=u(e.disallow);for(let e of i)t.push(`Disallow: ${e}`);e.crawlDelay!==void 0&&t.push(`Crawl-delay: ${e.crawlDelay}`),t.push(``)}return t}function f(e){return e==null||e===``?[]:[`Host: ${e}`,``]}function p(e){return u(e).map(e=>`Sitemap: ${e}`)}function m(e){let t=[],n=Array.isArray(e.rules)?e.rules:[e.rules];for(let e of n)t.push(...d(e));return t.push(...f(e.host)),t.push(...p(e.sitemap)),t.join(`
2
+ `)}
3
+ /* v8 ignore start - file system operations, better tested in integration/e2e */
4
+ async function h(e,n=[`.ts`,`.tsx`,`.js`,`.jsx`,`.mjs`]){return t({appDir:e,staticFileName:`robots.txt`,dynamicBaseName:`robots`,extensions:n,rethrowNonEnoent:!0})}
5
+ /* v8 ignore stop */
6
+ /* v8 ignore start - file system operations and dynamic imports, better tested in integration/e2e */
7
+ async function g(e){let{appDir:t,outDir:s,extensions:l,aliases:u={}}=e,d=await h(t,l);if(!d)return!1;let f=o.join(s,`robots.txt`);if(await a.mkdir(o.dirname(f),{recursive:!0}),d.type===`static`)return await a.copyFile(d.path,f),!0;try{let e=await a.readFile(d.path,`utf-8`),o=await i({virtualId:`\0virtual:robots`,sourcePath:d.path,sourceCode:e,aliases:u,projectRoot:n(t),kind:`robots`,pluginName:`virtual-robots`,label:`robots`}),s=m(await c(r(o,`Robots`)));return await a.writeFile(f,s),!0}catch(e){return console.error(`[rari] Failed to build/execute robots file:`,e),!1}}
8
+ /* v8 ignore stop */
9
+ export{g as generateRobotsFile};
@@ -0,0 +1 @@
1
+ import{n as e}from"./navigate-DuyUa6qD.mjs";import{i as t,v as n}from"./type-guards-BJXKlA6x.mjs";import{c as r}from"react/compiler-runtime";import{createContext as i,use as a,useEffect as o,useRef as s,useState as c}from"react";import{jsx as l}from"react/jsx-runtime";function u(e){return n(e)&&typeof e.to==`string`}function d(e){return n(e)&&typeof e.navigate==`function`}const f=i(null);function p(n){let i=r(12),{children:a,initialPathname:p}=n,[y,b]=c(p),[x,S]=c(v),C=s(null),w,T;i[0]===Symbol.for(`react.memo_cache_sentinel`)?(w=()=>{let e=e=>{let n=t(e,u);n&&(b(n.to),S(new URLSearchParams(window.location.search)))};return window.addEventListener(`rari:navigate`,e),()=>{window.removeEventListener(`rari:navigate`,e)}},T=[],i[0]=w,i[1]=T):(w=i[0],T=i[1]),o(w,T);let E,D;i[2]===Symbol.for(`react.memo_cache_sentinel`)?(E=()=>{let n=e();n&&(C.current=n);let r=e=>{let n=t(e,d);n&&(C.current=n.navigate)},i=()=>{C.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)}},D=[],i[2]=E,i[3]=D):(E=i[2],D=i[3]),o(E,D);let O,k;i[4]===Symbol.for(`react.memo_cache_sentinel`)?(O=async(e,t)=>{C.current?await C.current(e,t):(console.warn(`[rari] Router not ready, falling back to window.location`),window.location.href=e)},k=async(e,t)=>{C.current?await C.current(e,{...t,replace:!0}):(console.warn(`[rari] Router not ready, falling back to window.location`),window.location.replace(e))},i[4]=O,i[5]=k):(O=i[4],k=i[5]);let A;i[6]!==y||i[7]!==x?(A={pathname:y,searchParams:x,push:O,replace:k,back:_,forward:g,refresh:h,prefetch:m},i[6]=y,i[7]=x,i[8]=A):A=i[8];let j=A,M;return i[9]!==a||i[10]!==j?(M=/* @__PURE__ */ l(f,{value:j,children:a}),i[9]=a,i[10]=j,i[11]=M):M=i[11],M}async function m(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 h(){window.dispatchEvent(new CustomEvent(`rari:app-router-rerender`))}function g(){window.history.forward()}function _(){window.history.back()}function v(){return typeof window<`u`?new URLSearchParams(window.location.search):new URLSearchParams}function y(){let e=a(f);if(!e)throw Error(`useRouter must be used within a RouterProvider`);return e}function b(){return y().pathname}function x(){return y().searchParams}export{x as i,b as n,y as r,p as t};
package/dist/router.d.mts CHANGED
@@ -1,19 +1,16 @@
1
- import "./types-DCEyvFz7.mjs";
2
1
  //#region src/router/navigation/types.d.ts
3
2
  interface NavigationOptions {
4
3
  readonly replace?: boolean;
5
4
  readonly scroll?: boolean;
6
- readonly shallow?: boolean;
7
5
  readonly historyKey?: string;
8
6
  }
9
7
  //#endregion
10
8
  //#region src/router/navigation/navigate.d.ts
11
- declare function navigate(href: string, options?: NavigationOptions): Promise<void>;
9
+ export declare function navigate(href: string, options?: NavigationOptions): Promise<void>;
12
10
  //#endregion
13
11
  //#region src/router/navigation/use-router.d.ts
14
12
  interface RouterContextValue {
15
13
  pathname: string;
16
- params: Record<string, string | string[]>;
17
14
  searchParams: URLSearchParams;
18
15
  push: (href: string, options?: NavigationOptions) => Promise<void>;
19
16
  replace: (href: string, options?: NavigationOptions) => Promise<void>;
@@ -26,10 +23,9 @@ interface RouterProviderProps {
26
23
  readonly children: React.ReactNode;
27
24
  readonly initialPathname: string;
28
25
  }
29
- declare function RouterProvider({ children, initialPathname }: RouterProviderProps): import("react").JSX.Element;
30
- declare function useRouter(): RouterContextValue;
31
- declare function usePathname(): string;
32
- declare function useParams(): Record<string, string | string[]>;
33
- declare function useSearchParams(): URLSearchParams;
26
+ export declare function RouterProvider({ children, initialPathname }: RouterProviderProps): import("react").JSX.Element;
27
+ export declare function useRouter(): RouterContextValue;
28
+ export declare function usePathname(): string;
29
+ export declare function useSearchParams(): URLSearchParams;
34
30
  //#endregion
35
- export { type NavigationOptions, type RouterContextValue, RouterProvider, type RouterProviderProps, navigate, useParams, usePathname, useRouter, useSearchParams };
31
+ export type { NavigationOptions, RouterContextValue, RouterProviderProps };
package/dist/router.mjs CHANGED
@@ -1 +1 @@
1
- import{r as e}from"./navigate-DuyUa6qD.mjs";import{a as t,i as n,n as r,r as i,t as a}from"./router-D84JWQz7.mjs";export{a as RouterProvider,e as navigate,r as useParams,i as usePathname,n as useRouter,t as useSearchParams};
1
+ import{r as e}from"./navigate-DuyUa6qD.mjs";import{i as t,n,r,t as i}from"./router-D6X8JHst.mjs";export{i as RouterProvider,e as navigate,n as usePathname,r as useRouter,t as useSearchParams};
@@ -0,0 +1 @@
1
+ import{v as e}from"./type-guards-BJXKlA6x.mjs";import{o as t}from"./path-C74rvUep.mjs";import{Buffer as n}from"node:buffer";import r from"node:fs";import i from"node:path";import{createBuilder as a}from"vite-plus";const o=/* @__PURE__ */ new Map,s=/* @__PURE__ */ new Map;function c(e){let t=o.get(e);return t===void 0?(t=r.existsSync(e),o.set(e,t),t):t}function l(e){let t=s.get(e);if(t!==void 0)return t;try{t=r.statSync(e).isDirectory()}catch{t=!1}return s.set(e,t),t}function u(){o.clear(),s.clear()}function d(e,t){let n=null;for(let r of t)if(r!==``&&e.endsWith(r)&&(n??=c(e),n&&!l(e)))return e;for(let n of t){let t=`${e}${n}`;if(c(t)&&!l(t))return t}return null}function f(e,t){if(c(e)){if(!l(e))return null;for(let n of t){let t=i.join(e,`index${n}`);if(c(t))return t}}return null}const p=[`.tsx`,`.jsx`,`.ts`,`.js`];function m(e,t,n={},r=p){let a=e;for(let[t,r]of Object.entries(n))if(e.startsWith(`${t}/`)){a=e.replace(t,r);break}else if(e===t){a=r;break}let o=i.resolve(i.dirname(t),a),s=d(o,r);if(s!=null&&s!==``)return s;let c=f(o,r);return c!=null&&c!==``?c:`${o}.tsx`}const h=[`.ts`,`.tsx`,`.js`,`.jsx`,`.mjs`];function g(e,t=h){return d(e,t)??f(e,t)}const _=/* @__PURE__ */ new WeakMap;function v(e){let t=_.get(e);return t||(t=Object.entries(e).sort((e,t)=>t[0].length-e[0].length),_.set(e,t),t)}function y(e,t,n){if(typeof e!=`string`)throw TypeError(`Expected source to be a string, but received ${typeof e}`);if(typeof t!=`object`||Array.isArray(t))throw TypeError(`Expected aliases to be a plain object, but received ${Array.isArray(t)?`array`:typeof t}`);if(Object.getPrototypeOf(t)!==Object.prototype&&Object.getPrototypeOf(t)!==null)throw TypeError(`Expected aliases to be a plain object, but received ${t.constructor.name||`object with custom prototype`}`);if(typeof n!=`string`)throw TypeError(`Expected projectRoot to be a string, but received ${typeof n}`);let r=v(t);for(let[t,a]of r)if(e.startsWith(`${t}/`)||e===t){let r=e.slice(t.length).replace(/^\/+/,``),o=i.join(a,r);return i.isAbsolute(o)?o:i.resolve(n,o)}return null}const b=/^node:/,x=/* @__PURE__ */ new Map;function S(e){let t=i.resolve(e.root);return JSON.stringify({root:t,configFile:e.configFile??null,logLevel:e.logLevel??null})}async function C(e){let t=typeof e==`string`?{root:e}:e,n=i.resolve(t.root),r=S(t),o=x.get(r);return o??(o=a({root:n,...t.configFile===void 0?{}:{configFile:t.configFile},...t.logLevel==null?{}:{logLevel:t.logLevel},oxc:{jsx:{development:!1}}}).catch(e=>{throw x.delete(r),e}),x.set(r,o)),o}function w(t){let n=i.resolve(t);for(let t of x.keys()){let r=JSON.parse(t);e(r)&&r.root===n&&x.delete(t)}}function T(e){return typeof e==`object`&&!!e&&`type`in e}function E(e){let t=Array.isArray(e)?e:[e],n=[];for(let e of t){if(typeof e!=`object`||!e)continue;let t=e.output;if(Array.isArray(t))for(let e of t)T(e)&&n.push(e)}return n}function D(e){return typeof e==`string`?e:n.from(e).toString(`utf8`)}function O(e){return e==null?[]:e instanceof Set?[...e].map(e=>t(String(e))):Array.isArray(e)?e.map(e=>t(String(e))):[]}const k=[b,`react`,`react-dom`,`react/jsx-runtime`,`react/jsx-dev-runtime`,`react/compiler-runtime`,/^rari(?:\/|$)/,`react-server-dom-rari/server`],A=[b,`react`,`react-dom`,`react/jsx-runtime`,`react/jsx-dev-runtime`,`react/compiler-runtime`,/^rari(?:\/|$)/,`react-server-dom-webpack/client`,/^react-server-dom-webpack\//];function j(e){return{write:e.write,emptyOutDir:e.emptyOutDir,copyPublicDir:e.copyPublicDir,minify:e.minify,emitAssets:e.emitAssets,rolldownOptions:e.rolldownOptions}}function M(e,t){e.write=t.write,e.emptyOutDir=t.emptyOutDir,e.copyPublicDir=t.copyPublicDir,e.minify=t.minify,e.emitAssets=t.emitAssets,e.rolldownOptions=t.rolldownOptions}async function N(n){if(n.entries.length===0)return{outputs:/* @__PURE__ */ new Map,extraFiles:[]};if(n.codeSplitting===!1&&n.entries.length>1){let e=/* @__PURE__ */ new Map,t=[];for(let r of n.entries){let i=await N({...n,entries:[r]});if(i==null)return null;for(let[t,n]of i.outputs)e.set(t,n);t.push(...i.extraFiles)}return{outputs:e,extraFiles:t}}let r=n.viteBuilder.environments[n.environmentName];if(r==null)return null;await r.init();let i={};for(let e of n.entries)i[e.entryName]=e.filePath;let a=r.config.build,o=j(a),s=e(o.rolldownOptions)?{...o.rolldownOptions}:{},c=n.label??n.environmentName.toUpperCase();try{a.write=!1,a.emptyOutDir=!1,a.copyPublicDir=!1,a.emitAssets=!0,a.minify=n.minify===!0&&`oxc`,a.rolldownOptions={...s,input:i,platform:`node`,output:{format:`es`,entryFileNames:`[name].js`,chunkFileNames:`chunks/[name]-[hash].js`,assetFileNames:`assets/[name]-[hash][extname]`,...n.codeSplitting===!1?{codeSplitting:!1}:{}},external:[...n.environmentName===`ssr`?A:k]};let e=E(await n.viteBuilder.build(r));if(e.length===0)return null;let o=/* @__PURE__ */ new Map,c=[],l=/* @__PURE__ */ new Map,u=/* @__PURE__ */ new Map;for(let n of e){if(n.type===`asset`){let e=t(n.fileName);e.endsWith(`.css`)?o.set(e,D(n.source)):c.push({fileName:e,code:n.source});continue}let e=t(n.fileName);if(n.isEntry){let e=n.name;if(e==null||e===``)continue;l.set(e,{code:n.code,cssAssetSources:[]}),u.set(e,O(n.viteMetadata?.importedCss));continue}c.push({fileName:e,code:n.code})}for(let[e,t]of l){let n=(u.get(e)??[]).map(e=>o.get(e)).filter(e=>e!=null);if(n.length===0&&l.size===1&&o.size>0){l.set(e,{...t,cssAssetSources:[...o.values()]});continue}l.set(e,{...t,cssAssetSources:n})}for(let e of n.entries)if(!l.has(e.entryName))return null;return{outputs:l,extraFiles:c}}catch(e){return console.warn(`[rari] Vite ${c} environment build failed:`,e),null}finally{M(a,o)}}async function P(e){return N({viteBuilder:e.viteBuilder,environmentName:`rsc`,entries:e.entries.map(e=>({entryName:e.componentId,filePath:e.filePath})),minify:e.minify,codeSplitting:e.codeSplitting,label:`RSC`})}async function F(e){return N({viteBuilder:e.viteBuilder,environmentName:`ssr`,entries:e.entries,minify:e.minify??!1,label:`SSR`})}function I(e,n){return t(i.join(e,`${n}.js`))}async function L(e){let t=await a({configFile:!1,root:e.root,logLevel:`error`,plugins:[...e.plugins],define:{global:`globalThis`},resolve:{conditions:[`import`,`module`,`default`],extensions:[`.mjs`,`.js`,`.ts`,`.tsx`,`.jsx`],mainFields:[`module`,`main`]},environments:{ssr:{consumer:`server`,build:{write:!1,emptyOutDir:!1,copyPublicDir:!1,emitAssets:!1,minify:!1,cssMinify:!1,target:`esnext`,rolldownOptions:{input:{entry:e.virtualId},platform:`node`,external:e.external,output:{format:`es`,codeSplitting:!1,entryFileNames:`[name].js`}}}}},builder:{sharedPlugins:!0},css:{transformer:`lightningcss`}}),n=t.environments.ssr;await n.init();let r=E(await t.build(n)),i=r.find(e=>e.type===`chunk`&&e.isEntry)??r.find(e=>e.type===`chunk`);return i?.type===`chunk`?{code:i.code}:null}export{C as a,u as c,w as i,m as l,P as n,I as o,F as r,y as s,L as t,g as u};
@@ -1,14 +1,14 @@
1
1
  import * as React from "react";
2
- import { Thenable } from "virtual:react-flight-client";
3
2
  //#region src/runtime/flight/app-router-provider.d.ts
4
3
  interface RscPayload {
5
- readonly element: React.ReactNode | Thenable<React.ReactNode>;
6
- readonly rawElement?: React.ReactNode | Thenable<React.ReactNode>;
4
+ readonly element: React.ReactNode | PromiseLike<React.ReactNode>;
5
+ readonly rawElement?: React.ReactNode | PromiseLike<React.ReactNode>;
7
6
  readonly flightProtocol?: string;
8
7
  }
9
8
  interface NavigationOptions {
10
9
  readonly historyKey?: string;
11
10
  readonly scroll?: boolean;
11
+ readonly replace?: boolean;
12
12
  readonly [key: string]: unknown;
13
13
  }
14
14
  interface AppRouterProviderProps {
@@ -21,13 +21,16 @@ interface NavigationDetail {
21
21
  readonly to: string;
22
22
  readonly navigationId: number;
23
23
  readonly options: NavigationOptions;
24
- readonly routeInfo?: any;
25
24
  readonly abortSignal?: AbortSignal;
26
25
  readonly rscFlightProtocol?: string;
27
26
  readonly rscResponse?: Response;
28
27
  readonly rscResponsePromise?: Promise<Response>;
29
28
  readonly isStreaming?: boolean;
29
+ readonly pendingHistory?: {
30
+ readonly url: string;
31
+ readonly state: object;
32
+ readonly replace?: boolean;
33
+ };
30
34
  }
31
- declare function AppRouterProvider({ children, initialPayload, onNavigate }: AppRouterProviderProps): React.JSX.Element;
32
- //#endregion
33
- export { AppRouterProvider };
35
+ export declare function AppRouterProvider({ children, initialPayload, onNavigate }: AppRouterProviderProps): React.JSX.Element;
36
+ //#endregion
@@ -1 +1 @@
1
- "use client";import{n as e,p as t}from"../type-guards-CTkEL8zw.mjs";import{f as n}from"../regex-constants-Wm7xRA3u.mjs";import{a as r}from"../rari-global-5vGzhToD.mjs";import"./action-revalidation-kind.mjs";import{mergeFlightRefresh as i}from"./merge-flight-refresh.mjs";import{currentRouteLocation as a,flightRouteCache as o}from"./flight-route-cache.mjs";import{t as s}from"../preload-modules-QmSvKk0Q.mjs";import{c}from"react/compiler-runtime";import*as l from"react";import{useEffect as u,useLayoutEffect as d,useRef as f,useState as p}from"react";import{Fragment as m,jsx as h,jsxs as g}from"react/jsx-runtime";import{createFromReadableStream as _}from"virtual:react-flight-client";const ee={position:`fixed`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,padding:`24px`,background:`rgba(220, 38, 38, 0.95)`,color:`white`,borderRadius:`8px`,fontSize:`14px`,zIndex:1e4,maxWidth:`500px`,boxShadow:`0 4px 6px rgba(0, 0, 0, 0.3)`},v={padding:`8px 16px`,background:`white`,color:`#dc2626`,border:`none`,borderRadius:`4px`,cursor:`pointer`,fontWeight:`bold`,fontSize:`14px`},te={padding:`8px 16px`,background:`rgba(255, 255, 255, 0.2)`,color:`white`,border:`1px solid rgba(255, 255, 255, 0.3)`,borderRadius:`4px`,cursor:`pointer`,fontSize:`14px`},y={fetch:`Failed to fetch updated content from server.`,parse:`Failed to parse server response.`,stale:`Server returned stale content.`,network:`Network error occurred.`};function b(e){return y[e]}function x(e){let t=c(27),{failure:n,maxRetries:r,onRefresh:i,onDismiss:a}=e,o,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=h(`div`,{style:{marginBottom:`16px`,fontWeight:`bold`,fontSize:`16px`},children:`⚠️ HMR Update Failed`}),s={marginBottom:`12px`,opacity:.9},t[0]=o,t[1]=s):(o=t[0],s=t[1]);let l;t[2]===n.type?l=t[3]:(l=b(n.type),t[2]=n.type,t[3]=l);let u;t[4]===l?u=t[5]:(u=h(`div`,{style:s,children:l}),t[4]=l,t[5]=u);let d;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(d={marginBottom:`16px`,fontSize:`12px`,opacity:.8,fontFamily:`monospace`},t[6]=d):d=t[6];let f;t[7]===n.details?f=t[8]:(f=h(`div`,{style:d,children:n.details}),t[7]=n.details,t[8]=f);let p;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(p={marginBottom:`12px`,fontSize:`12px`,opacity:.7},t[9]=p):p=t[9];let m;t[10]!==n.consecutiveFailures||t[11]!==r?(m=g(`div`,{style:p,children:[`Consecutive failures: `,n.consecutiveFailures,` / `,r]}),t[10]=n.consecutiveFailures,t[11]=r,t[12]=m):m=t[12];let _;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(_={display:`flex`,gap:`8px`},t[13]=_):_=t[13];let y;t[14]===i?y=t[15]:(y=h(`button`,{onClick:i,type:`button`,style:v,children:`Refresh Page`}),t[14]=i,t[15]=y);let x;t[16]===a?x=t[17]:(x=h(`button`,{onClick:a,type:`button`,style:te,children:`Dismiss`}),t[16]=a,t[17]=x);let S;t[18]!==y||t[19]!==x?(S=g(`div`,{style:_,children:[y,x]}),t[18]=y,t[19]=x,t[20]=S):S=t[20];let C;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(C=h(`div`,{style:{marginTop:`12px`,fontSize:`11px`,opacity:.6},children:`Check the console for detailed error logs.`}),t[21]=C):C=t[21];let w;return t[22]!==S||t[23]!==u||t[24]!==f||t[25]!==m?(w=g(`div`,{style:ee,children:[o,u,f,m,S,C]}),t[22]=S,t[23]=u,t[24]=f,t[25]=m,t[26]=w):w=t[26],w}function S(e){let{parsedPayload:t,shouldScrollToTop:n,navigationId:r,useTransition:i,currentNavigationIdRef:a,pendingScrollPayloadRef:o,setRenderKey:s,setRscPayload:c,clearHmrError:u}=e,d=()=>{s(e=>{let r=e+1;return o.current=n?{payload:t,commitKey:r}:null,r}),c(t),u()};i?l.startTransition(()=>{a.current===r&&d()}):d()}function C(e){return l.isValidElement(e)||e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`}function w(e){if(!Array.isArray(e))return e;let t=e;return t.length===1&&l.isValidElement(t[0])?t[0]:t.length>0&&t.every(C)?l.createElement(l.Fragment,null,...t):e}function ne(e,t,n){return e==null||e.commitKey!==n?{shouldScroll:!1,nextPending:null}:t===e.payload?{shouldScroll:!0,nextPending:null}:{shouldScroll:!1,nextPending:e}}const re=/"timestamp":(\d+)/;function T(e){return t(e)&&typeof e.then==`function`}function ie(e){return e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`||l.isValidElement(e)||Array.isArray(e)}function ae(e){return t(e)&&typeof e.from==`string`&&typeof e.to==`string`&&typeof e.navigationId==`number`&&t(e.options)}function oe(e){return t(e)&&`element`in e}function se(e){return t(e)&&typeof e.navigationId==`number`&&typeof e.targetPath==`string`}function ce(ee){let v=c(41),{children:te,initialPayload:y,onNavigate:b}=ee,[C,ce]=p(y),pe=f(y),[E,he]=p(0),D;v[0]===Symbol.for(`react.memo_cache_sentinel`)?(D={x:0,y:0},v[0]=D):D=v[0];let O=f(D),k=f(null),A;v[1]===Symbol.for(`react.memo_cache_sentinel`)?(A=new Map,v[1]=A):A=v[1];let ge=f(A),j;v[2]===Symbol.for(`react.memo_cache_sentinel`)?(j=new Set,v[2]=j):j=v[2];let M=f(j),_e=f(b),N=f(0),P;v[3]===Symbol.for(`react.memo_cache_sentinel`)?(P=new Map,v[3]=P):P=v[3];let F=f(P),I;v[4]===Symbol.for(`react.memo_cache_sentinel`)?(I=[],v[4]=I):I=v[4];let ve=f(I),L=f(null),R=f(0),[z,B]=p(null),V,H;v[5]===b?(V=v[6],H=v[7]):(V=()=>{_e.current=b},H=[b],v[5]=b,v[6]=V,v[7]=H),u(V,H);let U,W;v[8]!==E||v[9]!==C?(U=()=>{let{shouldScroll:e,nextPending:t}=ne(k.current,C,E);k.current=t,e&&window.scrollTo(0,0)},W=[C,E],v[8]=E,v[9]=C,v[10]=U,v[11]=W):(U=v[10],W=v[11]),d(U,W);let ye=me,G,K;v[12]===C?(G=v[13],K=v[14]):(G=()=>{pe.current=C,C?.element!=null&&ye(C.element)},K=[C],v[12]=C,v[13]=G,v[14]=K),u(G,K);let q,J;v[15]===C?(q=v[16],J=v[17]):(q=()=>{if(C?.element!=null){let e=C.element;if(t(e)&&`status`in e&&e.status===`rejected`){let t=e.reason;t!=null&&t!==``&&console.error(`[rari] AppRouter: Flight payload rejected:`,t)}}},J=[C],v[15]=C,v[16]=q,v[17]=J),u(q,J);let be;v[18]===Symbol.for(`react.memo_cache_sentinel`)?(be=()=>{if(typeof document>`u`)return;let e=document.querySelectorAll(`form`);ge.current.clear(),e.forEach((e,t)=>{let n=new FormData(e);ge.current.set(`form-${t}`,n)})},v[18]=be):be=v[18];let xe=be,Se;v[19]===Symbol.for(`react.memo_cache_sentinel`)?(Se=()=>{typeof document>`u`||document.querySelectorAll(`form`).forEach((e,t)=>{let n=ge.current.get(`form-${t}`);n&&n.forEach((t,n)=>{let r=e.elements.namedItem(n);r instanceof HTMLInputElement&&(r.type===`checkbox`||r.type===`radio`?r.checked=t===`on`:typeof t==`string`&&(r.value=t))})})},v[19]=Se):Se=v[19];let Ce=Se,we;v[20]===Symbol.for(`react.memo_cache_sentinel`)?(we=(e,t,n,r)=>{R.current+=1;let i={timestamp:Date.now(),error:e,type:t,details:n,filePath:r,consecutiveFailures:R.current};ve.current.push(i),ve.current.length>10&&ve.current.shift(),R.current>=2&&B(i),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`rari:hmr-failure`,{detail:i}))},v[20]=we):we=v[20];let Te=we,Y=fe,Ee;v[21]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=()=>{R.current>0&&(R.current=0)},v[21]=Ee):Ee=v[21];let De=Ee,Oe;v[22]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=e=>{if(L.current==null||L.current===``)return!1;if(e===L.current)return!0;let t=re.exec(e);if(t){let e=Number.parseInt(t[1],10);if(Date.now()-e>5e3)return!0}return!1},v[22]=Oe):Oe=v[22];let ke=Oe,Ae;v[23]===Symbol.for(`react.memo_cache_sentinel`)?(Ae=async e=>{await s(e,M.current);let t=new ReadableStream({start(t){t.enqueue(new TextEncoder().encode(e)),t.close()}}),n=await _(t);return{element:n,rawElement:n,flightProtocol:e}},v[23]=Ae):Ae=v[23];let je=Ae,Me;v[24]===Symbol.for(`react.memo_cache_sentinel`)?(Me=async(e,t)=>{let n=t!==void 0&&t,r=await e;if(!r.body)throw Error(`Response has no body stream`);if(n){let e=_(r.body);return{element:e,rawElement:e,flightProtocol:``}}let i=await r.clone().text();await s(i,M.current);let a=new Uint8Array(await r.arrayBuffer()),o=new ReadableStream({start(e){e.enqueue(a),e.close()}}),c=await _(o);return{element:c,rawElement:c,flightProtocol:i}},v[24]=Me):Me=v[24];let Ne=Me,Pe;v[25]===C?Pe=v[26]:(Pe=async(e,t)=>{let r=e!=null&&e!==``?e:window.location.pathname,i=N.current,a=`${i}:${r}${window.location.search}`,o=F.current.get(a);if(o)return o;let c=(async()=>{let e;try{let o=(import.meta.env.RARI_SERVER_URL!=null&&import.meta.env.RARI_SERVER_URL!==``?import.meta.env.RARI_SERVER_URL:window.location.origin).replace(n,``)+r+window.location.search,c=await fetch(o,{headers:{Accept:`text/x-component`,"rari-navigation-id":String(N.current)},cache:`no-store`,signal:t});if(c.ok){let t,n=``;try{if(n=await c.clone().text(),ke(n)&&C)return F.current.delete(a),C;await s(n,M.current);let e=new Uint8Array(await c.arrayBuffer()),r=new ReadableStream({start(t){t.enqueue(e),t.close()}}),i=await _(r);t={element:i,rawElement:i,flightProtocol:n}}catch(t){let n=t,r=n instanceof Error?n:Error(String(n));Te(r,`parse`,`Failed to parse RSC Flight protocol: ${r.message}`,window.location.pathname),e=r}if(e==null)return N.current===i&&(ce(t),L.current=n,De()),F.current.delete(a),t}else{let t=Error(`Failed to fetch RSC data: ${c.status} ${c.statusText}`);Te(t,`fetch`,`HTTP ${c.status} when fetching ${o}`,window.location.pathname),e=t}}catch(t){let n=t;n instanceof Error&&!n.message.includes(`Failed to fetch RSC data`)&&!n.message.includes(`Failed to parse`)&&Te(n,`network`,`Network error: ${n.message}`,window.location.pathname),e=n}if(F.current.delete(a),e!=null)throw e instanceof Error?e:Error(typeof e==`string`?e:`Failed to fetch RSC payload`)})();return F.current.set(a,c),c},v[25]=C,v[26]=Pe);let Fe=Pe,Ie=f(je),Le=f(Ne),X=f(Fe),Re;v[27]===Fe?Re=v[28]:(Re=()=>{Ie.current=je,Le.current=Ne,X.current=Fe},v[27]=Fe,v[28]=Re),u(Re);let ze,Z;v[29]===Symbol.for(`react.memo_cache_sentinel`)?(ze=()=>{if(typeof window>`u`)return;let t=async t=>{let n=e(t,ae);if(!n||n.navigationId!==N.current)return;O.current={x:window.scrollX,y:window.scrollY},xe();let r,i=null,a=!1;try{if(n.rscResponsePromise){let e=await n.rscResponsePromise;if(N.current!==n.navigationId||(a=e.headers.get(`x-render-mode`)===`streaming`,r=await Le.current(Promise.resolve(e),a),N.current!==n.navigationId))return}else if(n.rscResponse){if(a=n.rscResponse.headers.get(`x-render-mode`)===`streaming`,r=await Le.current(Promise.resolve(n.rscResponse),a),N.current!==n.navigationId)return}else n.rscFlightProtocol!=null&&n.rscFlightProtocol!==``?r=await Ie.current(n.rscFlightProtocol):n.isStreaming||(r=await X.current(n.to,n.abortSignal))}catch(e){let t=e;if(t instanceof Error&&t.name===`AbortError`)return;i=t instanceof Error?t:Error(String(t))}if(i){console.error(`[rari] AppRouter: Navigation failed:`,i),window.dispatchEvent(new CustomEvent(`rari:navigate-error`,{detail:{from:n.from,to:n.to,error:i,navigationId:n.navigationId}})),R.current>=3&&Y();return}if(!(!r&&n.isStreaming&&N.current===n.navigationId)&&r&&N.current===n.navigationId){let e=window.location.hash.length>0,t=(n.options.historyKey==null||n.options.historyKey===``)&&!e&&n.options.scroll!==!1,i=n.navigationId,o=n.options.historyKey!=null&&n.options.historyKey!==``;S({parsedPayload:r,shouldScrollToTop:t,navigationId:i,useTransition:!a&&!o,currentNavigationIdRef:N,pendingScrollPayloadRef:k,setRenderKey:he,setRscPayload:ce,clearHmrError:()=>{B(null)}}),n.rscFlightProtocol!=null&&n.rscFlightProtocol!==``&&(L.current=n.rscFlightProtocol),De(),_e.current&&_e.current(n)}},n=async()=>{O.current={x:window.scrollX,y:window.scrollY},xe();try{await X.current(),he(de),B(null)}catch(e){let t=e;console.error(`HMR refetch error:`,t instanceof Error?t.message:String(t)),R.current>=3&&Y()}requestAnimationFrame(()=>{window.scrollTo(O.current.x,O.current.y),Ce()})},s=t=>{let n=e(t,oe);if(!(n?.element==null||!ie(n.element)&&!T(n.element))){O.current={x:window.scrollX,y:window.scrollY},xe();try{let{pathname:e,search:t}=a();n.revalidationKind===1?o.clear():n.revalidatedPath!=null&&n.revalidatedPath!==``?o.invalidate(n.revalidatedPath,t):o.invalidate(e,t);let r=pe.current?.element,s=o.getElement(e,t)??(r!=null&&T(r)?null:r??null),c=n.element,u=T(c)?c:i(s,c);l.startTransition(()=>{ce({element:u,rawElement:u}),B(null)}),ye(u),De()}catch(e){let t=e,n=t instanceof Error?t:Error(String(t));Te(n,`parse`,`Action flight refresh failed: ${n.message}`,window.location.pathname),R.current>=3&&Y()}requestAnimationFrame(()=>{window.scrollTo(O.current.x,O.current.y),Ce()})}},c=async()=>{try{await X.current(),he(ue),B(null)}catch(e){let t=e;console.error(`RSC invalidate error:`,t instanceof Error?t.message:String(t)),R.current>=3&&Y()}},u=t=>{let n=e(t,se);if(n&&(M.current.clear(),N.current=n.navigationId,k.current=null,typeof window<`u`)){let e=r();e&&(e.navigationId=n.navigationId)}},d=async()=>{try{await X.current(),B(null)}catch(e){let t=e;console.error(`Manifest update error:`,t instanceof Error?t.message:String(t)),R.current>=3&&Y()}},f=e=>{t(e)},p=()=>{n()},m=()=>{c()},h=()=>{d()};return window.addEventListener(`rari:navigation-start`,u),window.addEventListener(`rari:navigate`,f),window.addEventListener(`rari:app-router-rerender`,p),window.addEventListener(`rari:action-flight-refresh`,s),window.addEventListener(`rari:rsc-invalidate`,m),window.addEventListener(`rari:app-router-manifest-updated`,h),()=>{window.removeEventListener(`rari:navigation-start`,u),window.removeEventListener(`rari:navigate`,f),window.removeEventListener(`rari:app-router-rerender`,p),window.removeEventListener(`rari:action-flight-refresh`,s),window.removeEventListener(`rari:rsc-invalidate`,m),window.removeEventListener(`rari:app-router-manifest-updated`,h)}},Z=[],v[29]=ze,v[30]=Z):(ze=v[29],Z=v[30]),u(ze,Z);let Be,Ve;v[31]===C?(Be=v[32],Ve=v[33]):(Be=()=>{if(!(typeof window>`u`)&&window.location.hash&&C){let e=window.location.hash.slice(1);requestAnimationFrame(()=>{requestAnimationFrame(()=>{let t=document.getElementById(e);t&&t.scrollIntoView({behavior:`instant`,block:`start`})})})}},Ve=[C],v[31]=C,v[32]=Be,v[33]=Ve),u(Be,Ve);let He=C?.element??te,Ue;v[34]===He?Ue=v[35]:(Ue=w(He),v[34]=He,v[35]=Ue);let We=Ue,Q;v[36]===z?Q=v[37]:(Q=z&&h(x,{failure:z,maxRetries:3,onRefresh:le,onDismiss:()=>{B(null)}}),v[36]=z,v[37]=Q);let $;return v[38]!==We||v[39]!==Q?($=g(m,{children:[Q,We]}),v[38]=We,v[39]=Q,v[40]=$):$=v[40],$}function le(){window.location.reload()}function ue(e){return e+1}function de(e){return e+1}function fe(){setTimeout(pe,1e3)}function pe(){window.location.reload()}function me(e){if(e==null||T(e))return;let{pathname:t,search:n}=a();o.set(t,n,e)}export{ce as AppRouterProvider};
1
+ "use client";import{d as e,i as t,p as n,r,v as i,w as a}from"../type-guards-BJXKlA6x.mjs";import{f as o}from"../regex-constants-DBMCJbMw.mjs";import"./action-revalidation-kind.mjs";import{mergeFlightRefresh as s}from"./merge-flight-refresh.mjs";import{currentRouteLocation as c,flightRouteCache as l}from"./flight-route-cache.mjs";import{t as u}from"../preload-modules-1i2BJqux.mjs";import{n as d,r as f}from"../form-state-DZJs9bve.mjs";import{c as ee}from"react/compiler-runtime";import*as p from"react";import{Suspense as m,addTransitionType as h,startTransition as g,use as _,useEffect as v,useLayoutEffect as y,useRef as b,useState as te,useTransition as ne}from"react";import{Fragment as re,jsx as x,jsxs as S}from"react/jsx-runtime";import{createFromFetch as ie,createFromReadableStream as ae}from"virtual:react-flight-client";const oe={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)`},C={padding:`8px 16px`,background:`white`,color:`#dc2626`,border:`none`,borderRadius:`4px`,cursor:`pointer`,fontWeight:`bold`,fontSize:`14px`},w={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`},T={fetch:`Failed to fetch updated content from server.`,parse:`Failed to parse server response.`,stale:`Server returned stale content.`,network:`Network error occurred.`};function se(e){return T[e]}function ce(e){let t=ee(27),{failure:n,maxRetries:r,onRefresh:i,onDismiss:a}=e,o,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=/* @__PURE__ */ x(`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=se(n.type),t[2]=n.type,t[3]=c);let l;t[4]===c?l=t[5]:(l=/* @__PURE__ */ x(`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__ */ x(`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__ */ S(`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__ */ x(`button`,{onClick:i,type:`button`,style:C,children:`Refresh Page`}),t[14]=i,t[15]=h);let g;t[16]===a?g=t[17]:(g=/* @__PURE__ */ x(`button`,{onClick:a,type:`button`,style:w,children:`Dismiss`}),t[16]=a,t[17]=g);let _;t[18]!==h||t[19]!==g?(_=/* @__PURE__ */ S(`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__ */ x(`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__ */ S(`div`,{style:oe,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 le(e){return e.historyKey!=null&&e.historyKey!==``?[`nav`,`nav-traverse`]:e.replace===!0?[`nav`,`nav-replace`]:[`nav`,`nav-forward`]}function E(e){e!=null&&typeof window<`u`&&(e.replace===!0?window.history.replaceState(e.state,``,e.url):window.history.pushState(e.state,``,e.url))}function ue(e){let{parsedPayload:t,shouldScrollToTop:n,navigationId:r,transitionTypes:i,pendingHistory:a,startTransition:o=g,currentNavigationIdRef:s,pendingScrollPayloadRef:c,setRenderKey:l,setRscPayload:u,clearHmrError:d,pendingNavigateCommittedIdRef:f}=e;o(()=>{if(s.current===r){if(i!=null)for(let e of i)h(e);E(a),l(e=>{let r=e+1;return c.current=n?{payload:t,commitKey:r}:null,r}),u(t),d(),f.current=r}})}function de(e){let t=Promise.resolve(e);return t.status=`fulfilled`,t.value=e,t}function D({thenable:e}){return _(e)}function fe(e){let t=ee(4),{content:r}=e,i;t[0]===r?i=t[1]:(i=n(r)?r:de(r),t[0]=r,t[1]=i);let a=i,o;return t[2]===a?o=t[3]:(o=/* @__PURE__ */ x(D,{thenable:a}),t[2]=a,t[3]=o),o}function pe(e){return p.isValidElement(e)||e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`}function me(e){if(!Array.isArray(e))return e;let t=e;return t.length===1&&p.isValidElement(t[0])?t[0]:t.length>0&&t.every(pe)?p.createElement(p.Fragment,null,...t):e}function he(e,t,n){return e==null||e.commitKey!==n?{shouldScroll:!1,nextPending:null}:t===e.payload?{shouldScroll:!0,nextPending:null}:{shouldScroll:!1,nextPending:e}}const ge=/"timestamp":(\d+)/;function _e(e){return e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`||p.isValidElement(e)||Array.isArray(e)}function ve(e){return i(e)&&typeof e.from==`string`&&typeof e.to==`string`&&typeof e.navigationId==`number`&&i(e.options)}function ye(e){return i(e)&&`element`in e}function be(e){return i(e)&&typeof e.navigationId==`number`&&typeof e.targetPath==`string`}function xe(e){if(!n(e))return e;if(i(e)&&e.status===`fulfilled`)return _e(e.value)?e.value:void 0}function O(h){let g=ee(44),{children:_,initialPayload:oe,onNavigate:C}=h,[w,T]=te(oe),se=b(oe),[E,de]=te(0),[,D]=ne(),pe=b(D),O;g[0]===Symbol.for(`react.memo_cache_sentinel`)?(O={x:0,y:0},g[0]=O):O=g[0];let k=b(O),A=b(null),j;g[1]===Symbol.for(`react.memo_cache_sentinel`)?(j=/* @__PURE__ */ new Map,g[1]=j):j=g[1];let Oe=b(j),M;g[2]===Symbol.for(`react.memo_cache_sentinel`)?(M=/* @__PURE__ */ new Set,g[2]=M):M=g[2];let N=b(M),ke=b(C),P=b(0),Ae=b(null),F;g[3]===Symbol.for(`react.memo_cache_sentinel`)?(F=/* @__PURE__ */ new Map,g[3]=F):F=g[3];let I=b(F),L;g[4]===Symbol.for(`react.memo_cache_sentinel`)?(L=[],g[4]=L):L=g[4];let je=b(L),R=b(null),z=b(0),[B,V]=te(null),H,U;g[5]===C?(H=g[6],U=g[7]):(H=()=>{ke.current=C},U=[C],g[5]=C,g[6]=H,g[7]=U),v(H,U);let W,G;g[8]===Symbol.for(`react.memo_cache_sentinel`)?(W=()=>{pe.current=D},G=[D],g[8]=W,g[9]=G):(W=g[8],G=g[9]),v(W,G);let K,q;g[10]!==E||g[11]!==w?(K=()=>{let{shouldScroll:e,nextPending:t}=he(A.current,w,E);A.current=t,e&&window.scrollTo(0,0);let n=Ae.current;n!=null&&(Ae.current=null,window.dispatchEvent(new CustomEvent(`rari:navigate-committed`,{detail:{navigationId:n}})))},q=[w,E],g[10]=E,g[11]=w,g[12]=K,g[13]=q):(K=g[12],q=g[13]),y(K,q);let Me=De,J,Ne;g[14]===w?(J=g[15],Ne=g[16]):(J=()=>{se.current=w,w?.element!=null&&Me(w.element)},Ne=[w],g[14]=w,g[15]=J,g[16]=Ne),v(J,Ne);let Pe,Fe;g[17]===w?(Pe=g[18],Fe=g[19]):(Pe=()=>{if(w?.element!=null){let e=w.element;if(i(e)&&`status`in e&&e.status===`rejected`){let t=e.reason;t!=null&&t!==``&&console.error(`[rari] AppRouter: Flight payload rejected:`,t)}}},Fe=[w],g[17]=w,g[18]=Pe,g[19]=Fe),v(Pe,Fe);let Ie;g[20]===Symbol.for(`react.memo_cache_sentinel`)?(Ie=()=>{Oe.current=d()},g[20]=Ie):Ie=g[20];let Le=Ie,Re;g[21]===Symbol.for(`react.memo_cache_sentinel`)?(Re=()=>{f(Oe.current)},g[21]=Re):Re=g[21];let ze=Re,Be;g[22]===Symbol.for(`react.memo_cache_sentinel`)?(Be=(e,t,n,r)=>{z.current+=1;let i={timestamp:Date.now(),error:e,type:t,details:n,filePath:r,consecutiveFailures:z.current};je.current.push(i),je.current.length>10&&je.current.shift(),z.current>=2&&V(i),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`rari:hmr-failure`,{detail:i}))},g[22]=Be):Be=g[22];let Ve=Be,Y=Ee,He;g[23]===Symbol.for(`react.memo_cache_sentinel`)?(He=()=>{z.current>0&&(z.current=0)},g[23]=He):He=g[23];let Ue=He,We;g[24]===Symbol.for(`react.memo_cache_sentinel`)?(We=e=>{if(R.current==null||R.current===``)return!1;if(e===R.current)return!0;let t=ge.exec(e);if(t){let e=Number.parseInt(t[1],10);if(Date.now()-e>5e3)return!0}return!1},g[24]=We):We=g[24];let Ge=We,Ke;g[25]===Symbol.for(`react.memo_cache_sentinel`)?(Ke=e=>{u(e,N.current);let t=new ReadableStream({start(t){t.enqueue(new TextEncoder().encode(e)),t.close()}}),n=ae(t);return{element:n,rawElement:n,flightProtocol:e}},g[25]=Ke):Ke=g[25];let qe=Ke,Je;g[26]===Symbol.for(`react.memo_cache_sentinel`)?(Je=async e=>{let t=await e;if(!t.body)throw Error(`Response has no body stream`);let n=t.clone(),r=ie(Promise.resolve(t));return n.text().then(async e=>{await u(e,N.current),e!==``&&(R.current=e)}).catch(Te),{element:r,rawElement:r,flightProtocol:``}},g[26]=Je):Je=g[26];let Ye=Je,Xe;g[27]===Symbol.for(`react.memo_cache_sentinel`)?(Xe=async(t,n)=>{let r=t!=null&&t!==``?t:window.location.pathname,i=P.current,s=`${i}:${r}${window.location.search}`,c=I.current.get(s);if(c)return c;let l=(async()=>{let t;try{let e=(import.meta.env.RARI_SERVER_URL!=null&&import.meta.env.RARI_SERVER_URL!==``?import.meta.env.RARI_SERVER_URL:window.location.origin).replace(o,``)+r+window.location.search,c=await fetch(e,{headers:{Accept:`text/x-component`,"rari-navigation-id":String(P.current)},cache:`no-store`,signal:n});if(c.ok){let e,n=``;try{if(n=await c.clone().text(),Ge(n)){I.current.delete(s);return}await u(n,N.current);let t=ie(Promise.resolve(c));e={element:t,rawElement:t,flightProtocol:n}}catch(e){let n=a(e);Ve(n,`parse`,`Failed to parse RSC Flight protocol: ${n.message}`,window.location.pathname),t=n}if(t==null)return P.current===i&&(T(e),n!==``&&(R.current=n),Ue()),I.current.delete(s),e}else{let n=/* @__PURE__ */ Error(`Failed to fetch RSC data: ${c.status} ${c.statusText}`);Ve(n,`fetch`,`HTTP ${c.status} when fetching ${e}`,window.location.pathname),t=n}}catch(n){let r=n;e(r)&&!r.message.includes(`Failed to fetch RSC data`)&&!r.message.includes(`Failed to parse`)&&Ve(r,`network`,`Network error: ${r.message}`,window.location.pathname),t=r}if(I.current.delete(s),t!=null)throw a(t)})();return I.current.set(s,l),l},g[27]=Xe):Xe=g[27];let Ze=Xe,Qe=b(qe),$e=b(Ye),X=b(Ze),et;g[28]===Symbol.for(`react.memo_cache_sentinel`)?(et=()=>{Qe.current=qe,$e.current=Ye,X.current=Ze},g[28]=et):et=g[28],v(et);let tt,nt;g[29]===Symbol.for(`react.memo_cache_sentinel`)?(tt=()=>{if(typeof window>`u`)return;let i=async n=>{let r=t(n,ve);if(!r||r.navigationId!==P.current)return;k.current={x:window.scrollX,y:window.scrollY},Le();let i,o=null;try{if(r.rscResponsePromise){let e=await r.rscResponsePromise;if(P.current!==r.navigationId||(i=await $e.current(Promise.resolve(e)),P.current!==r.navigationId))return}else if(r.rscResponse){if(i=await $e.current(Promise.resolve(r.rscResponse)),P.current!==r.navigationId)return}else r.rscFlightProtocol!=null&&r.rscFlightProtocol!==``?i=await Qe.current(r.rscFlightProtocol):r.isStreaming||(i=await X.current(r.to,r.abortSignal))}catch(t){let n=t;if(e(n)&&n.name===`AbortError`)return;o=a(n)}if(o){console.error(`[rari] AppRouter: Navigation failed:`,o),window.dispatchEvent(new CustomEvent(`rari:navigate-error`,{detail:{from:r.from,to:r.to,error:o,navigationId:r.navigationId}})),z.current>=3&&Y();return}if((i||!r.isStreaming||P.current!==r.navigationId)&&i&&P.current===r.navigationId){let e=r.pendingHistory?.url,t=e!=null&&e!==``?new URL(e,window.location.origin).hash.length>0:window.location.hash.length>0,n=(r.options.historyKey==null||r.options.historyKey===``)&&!t&&r.options.scroll!==!1,a=r.navigationId;ue({parsedPayload:i,shouldScrollToTop:n,navigationId:a,transitionTypes:le({historyKey:r.options.historyKey,replace:r.options.replace}),pendingHistory:r.pendingHistory,startTransition:pe.current,currentNavigationIdRef:P,pendingScrollPayloadRef:A,setRenderKey:de,setRscPayload:T,clearHmrError:()=>{V(null)},pendingNavigateCommittedIdRef:Ae}),i.flightProtocol!=null&&i.flightProtocol!==``&&(R.current=i.flightProtocol),Ue(),ke.current&&ke.current(r)}},o=async()=>{k.current={x:window.scrollX,y:window.scrollY},Le();try{await X.current(),de(we),V(null)}catch(e){let t=e;console.error(`HMR refetch error:`,r(t,String(t))),z.current>=3&&Y()}requestAnimationFrame(()=>{window.scrollTo(k.current.x,k.current.y),ze()})},u=e=>{let r=t(e,ye);if(r?.element!=null&&(_e(r.element)||n(r.element))){k.current={x:window.scrollX,y:window.scrollY},Le();try{let{pathname:e,search:t}=c();r.revalidationKind===1?l.clear():r.revalidatedPath!=null&&r.revalidatedPath!==``?l.invalidate(r.revalidatedPath,t):l.invalidate(e,t);let i=se.current?.element,a=l.getElement(e,t)??(i!=null&&n(i)?null:i??null),o=r.element,u=n(o)?o:s(a,o);p.startTransition(()=>{T({element:u,rawElement:u}),V(null)}),Me(u),Ue()}catch(e){let t=a(e);Ve(t,`parse`,`Action flight refresh failed: ${t.message}`,window.location.pathname),z.current>=3&&Y()}requestAnimationFrame(()=>{window.scrollTo(k.current.x,k.current.y),ze()})}},d=async()=>{try{await X.current(),de(Ce),V(null)}catch(e){let t=e;console.error(`RSC invalidate error:`,r(t,String(t))),z.current>=3&&Y()}},f=e=>{let n=t(e,be);n&&(N.current.clear(),P.current=n.navigationId,A.current=null)},ee=async()=>{try{await X.current(),V(null)}catch(e){let t=e;console.error(`Manifest update error:`,r(t,String(t))),z.current>=3&&Y()}},m=e=>{i(e)},h=()=>{o()},g=()=>{d()},_=()=>{ee()};return window.addEventListener(`rari:navigation-start`,f),window.addEventListener(`rari:navigate`,m),window.addEventListener(`rari:app-router-rerender`,h),window.addEventListener(`rari:action-flight-refresh`,u),window.addEventListener(`rari:rsc-invalidate`,g),window.addEventListener(`rari:app-router-manifest-updated`,_),()=>{window.removeEventListener(`rari:navigation-start`,f),window.removeEventListener(`rari:navigate`,m),window.removeEventListener(`rari:app-router-rerender`,h),window.removeEventListener(`rari:action-flight-refresh`,u),window.removeEventListener(`rari:rsc-invalidate`,g),window.removeEventListener(`rari:app-router-manifest-updated`,_)}},nt=[],g[29]=tt,g[30]=nt):(tt=g[29],nt=g[30]),v(tt,nt);let rt,it;g[31]===w?(rt=g[32],it=g[33]):(rt=()=>{if(typeof window<`u`&&window.location.hash&&w){let e=window.location.hash.slice(1);requestAnimationFrame(()=>{requestAnimationFrame(()=>{let t=document.getElementById(e);t&&t.scrollIntoView({behavior:`instant`,block:`start`})})})}},it=[w],g[31]=w,g[32]=rt,g[33]=it),v(rt,it);let at=w?.element??_,ot=me(at),[st,ct]=te(null),lt=xe(ot);if(lt!==void 0&&(st==null||!Object.is(at,st.raw))){let e=me(lt);n(e)||ct({raw:at,content:e})}let ut=st?.content??null,Z;g[34]===B?Z=g[35]:(Z=B&&/* @__PURE__ */ x(ce,{failure:B,maxRetries:3,onRefresh:Se,onDismiss:()=>{V(null)}}),g[34]=B,g[35]=Z);let Q;g[36]===ot?Q=g[37]:(Q=/* @__PURE__ */ x(fe,{content:ot}),g[36]=ot,g[37]=Q);let $;g[38]!==ut||g[39]!==Q?($=/* @__PURE__ */ x(m,{fallback:ut,children:Q}),g[38]=ut,g[39]=Q,g[40]=$):$=g[40];let dt;return g[41]!==Z||g[42]!==$?(dt=/* @__PURE__ */ S(re,{children:[Z,$]}),g[41]=Z,g[42]=$,g[43]=dt):dt=g[43],dt}function Se(){window.location.reload()}function Ce(e){return e+1}function we(e){return e+1}function Te(){}function Ee(){setTimeout(k,1e3)}function k(){window.location.reload()}function De(e){if(e==null||n(e))return;let{pathname:t,search:r}=c();l.set(t,r,e)}export{O as AppRouterProvider};
@@ -1,10 +1,8 @@
1
1
  import * as React from "react";
2
2
  //#region src/router/navigation/client-router.d.ts
3
- interface ClientRouterProps {
3
+ export interface ClientRouterProps {
4
4
  readonly children: React.ReactNode;
5
5
  readonly initialRoute: string;
6
- readonly staleWindowMs?: number;
7
6
  }
8
- declare function ClientRouter({ children, initialRoute, staleWindowMs }: ClientRouterProps): React.ReactNode;
9
- //#endregion
10
- export { ClientRouter, ClientRouterProps };
7
+ export declare function ClientRouter({ children, initialRoute }: ClientRouterProps): React.ReactNode;
8
+ //#endregion
@@ -1 +1,7 @@
1
- "use client";import{i as e,t}from"../navigate-DuyUa6qD.mjs";import{d as n,g as r,p as i}from"../type-guards-CTkEL8zw.mjs";import{a}from"../rari-global-5vGzhToD.mjs";import{c as o}from"react/compiler-runtime";import{useEffect as s,useLayoutEffect as c,useRef as l,useState as u}from"react";function d(e,t,n={}){let r=null,i=0,a=0,o=null,s=null,{leading:c=!1,trailing:l=!0,maxWait:u}=n;function d(t){let n=o,r=s;o=null,s=null,a=t,e.apply(r,n)}function f(e){let n=e-i,r=e-a;return i===0||n>=t||n<0||u!==void 0&&r>=u}function p(){let e=Date.now();if(f(e)){h(e);return}let n=e-i,o=e-a,s=t-n,c=u===void 0?1/0:u-o;r=setTimeout(p,Math.min(s,c))}function m(e){a=e,r=setTimeout(p,t),c&&d(e)}function h(e){if(r=null,l&&o){d(e);return}o=null,s=null}function g(){r!==null&&clearTimeout(r),a=0,o=null,i=0,s=null,r=null}function _(){r!==null&&h(Date.now())}function v(){return r!==null}function y(...e){let n=Date.now(),a=f(n);if(o=e,s=this,i=n,a){if(r===null){m(i);return}if(u!==void 0){r=setTimeout(p,t),d(i);return}}r??=setTimeout(p,t)}return y.cancel=g,y.flush=_,y.pending=v,y}const f=/fetch|networkerror|load failed/i;function p(e,t){return{type:`abort`,message:`Navigation was cancelled`,originalError:e,url:t,timestamp:Date.now(),retryable:!1}}function m(e,t){return{type:`timeout`,message:`Navigation request timed out`,originalError:e,url:t,timestamp:Date.now(),retryable:!0}}function h(e,t,n){if(t===404)return{type:`not-found`,message:`Page not found`,originalError:e,statusCode:t,url:n,timestamp:Date.now(),retryable:!1};if(t>=500)return{type:`server-error`,message:`Server error: ${t}`,originalError:e,statusCode:t,url:n,timestamp:Date.now(),retryable:!0};let r=t===408||t===429;return{type:`fetch-error`,message:`HTTP error: ${t}`,originalError:e,statusCode:t,url:n,timestamp:Date.now(),retryable:r}}function g(e,t){return{type:`network-error`,message:`Network error - check your connection`,originalError:e,url:t,timestamp:Date.now(),retryable:!0}}function _(e,t){return{type:`parse-error`,message:`Failed to parse server response`,originalError:e instanceof Error?e:void 0,url:t,timestamp:Date.now(),retryable:!1}}function v(e,t){return{type:`fetch-error`,message:e instanceof Error?e.message:`Unknown error occurred`,originalError:e instanceof Error?e:void 0,url:t,timestamp:Date.now(),retryable:!1}}function y(e,t){if(e instanceof Error&&e.name===`AbortError`)return p(e,t);if(e instanceof Error&&(e.name===`TimeoutError`||e.message.includes(`timeout`)))return m(e,t);if(e instanceof Error&&`status`in e){let n=e.status;return typeof n==`number`?h(e,n,t):v(e,t)}return e instanceof TypeError&&f.test(e.message)?g(e,t):e instanceof SyntaxError||e instanceof Error&&e.message.includes(`parse`)?_(e,t):v(e,t)}var ee=class{options;retryCount;constructor(e={}){this.options={timeout:e.timeout??1e4,maxRetries:e.maxRetries??3,onError:e.onError??(()=>{}),onRetry:e.onRetry??(()=>{})},this.retryCount=new Map}handleError(e,t){let n=y(e,t);return this.options.onError(n),console.error(`[rari] Navigation:`,n.type,n.message,{url:n.url,statusCode:n.statusCode,retryable:n.retryable}),n}canRetry(e,t){return e.retryable?(this.retryCount.get(t)??0)<this.options.maxRetries:!1}incrementRetry(e){let t=(this.retryCount.get(e)??0)+1;return this.retryCount.set(e,t),this.options.onRetry(t,{type:`fetch-error`,message:`Retry attempt ${t}`,url:e,timestamp:Date.now(),retryable:!0}),t}resetRetry(e){this.retryCount.delete(e)}getRetryCount(e){return this.retryCount.get(e)??0}clearRetries(){this.retryCount.clear()}};function b(e){if(!e||e===`/`)return`/`;let t=e;for(;t.endsWith(`/`)&&t.length>1;)t=t.slice(0,-1);return t.startsWith(`/`)||(t=`/${t}`),t}function te(e,t){try{return new URL(e,t!=null&&t!==``?t:window.location.origin).origin!==(t!=null&&t!==``?t:window.location.origin)}catch{return!1}}function ne(e){try{let t=new URL(e,window.location.origin);return t.pathname+t.hash}catch{return e}}const re=new class{cache=new Map;pendingRequests=new Map;async get(e){let t=this.cache.get(e);if(t)return t;let n=this.pendingRequests.get(e);if(n)return n;let r=this.fetchRouteInfo(e);this.pendingRequests.set(e,r);try{let t=await r;return this.cache.set(e,t),t}finally{this.pendingRequests.delete(e)}}parseRouteInfoResponse(e){let t=r(e);if(!t||!this.isRouteInfoResponse(t))throw Error(`Failed to parse route info response`);return t}isRouteInfoResponse(e){return i(e)&&typeof e.exists==`boolean`&&Array.isArray(e.layouts)&&(e.loading===null||typeof e.loading==`string`)&&typeof e.isDynamic==`boolean`}async fetchRouteInfo(e){let t=await fetch(`/_rari/route-info`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:e})});if(!t.ok){let e;try{let n=await t.text(),i=r(n);i&&typeof i.error==`string`&&i.error!==``&&(e=i.error)}catch{}throw Error(e!=null&&e!==``?e:`Failed to fetch route info: ${t.status} ${t.statusText}`)}let n=t.clone();try{let e=await t.text();return this.parseRouteInfoResponse(e)}catch(t){try{let e=await n.text();return this.parseRouteInfoResponse(e)}catch(n){throw console.error(`[RouteInfo] Failed to parse response:`,{error:t,parseError:n,path:e}),Error(`Failed to parse route info response`)}}}clear(){this.cache.clear(),this.pendingRequests.clear()}invalidate(e){this.cache.delete(e)}};if(typeof window<`u`){let e=a();e.routeInfoCache=re}var ie=class{stateHistory;routeAccessOrder;maxHistorySize;scrollableSelector;constructor(e={}){this.stateHistory=new Map,this.routeAccessOrder=[],this.maxHistorySize=e.maxHistorySize!=null&&e.maxHistorySize!==0?e.maxHistorySize:50,this.scrollableSelector=e.scrollableSelector!=null&&e.scrollableSelector!==``?e.scrollableSelector:`[data-scrollable], .scrollable, [style*="overflow"]`}captureState(e){let t={scrollPositions:this.captureScrollPositions(),formData:this.captureFormData(),focusedElement:this.captureFocusedElement()};return this.storeState(e,t),t}captureScrollPositions(){let e=new Map;try{e.set(`window`,{x:window.scrollX,y:window.scrollY,element:`window`}),document.querySelectorAll(this.scrollableSelector).forEach((t,n)=>{if(t instanceof HTMLElement){let r=t.id||`scrollable-${n}`;(t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth)&&e.set(r,{x:t.scrollLeft,y:t.scrollTop,element:r})}})}catch{}return e}captureFormData(){let e=new Map;try{document.querySelectorAll(`form`).forEach((t,n)=>{let r=t.id||t.name||`form-${n}`,i=new FormData(t);i.entries().next().done||e.set(r,i)})}catch{}return e}captureFocusedElement(){try{let e=document.activeElement;if(e&&e!==document.body){if(e.id)return`#${e.id}`;if((e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&e.name)return`[name="${e.name}"]`}}catch{}return null}storeState(e,t){let n=this.routeAccessOrder.indexOf(e);for(n!==-1&&this.routeAccessOrder.splice(n,1),this.routeAccessOrder.push(e),this.stateHistory.set(e,t);this.routeAccessOrder.length>this.maxHistorySize;){let e=this.routeAccessOrder.shift();e!=null&&e!==``&&this.stateHistory.delete(e)}}getHistorySize(){return this.stateHistory.size}hasState(e){return this.stateHistory.has(e)}getState(e){return this.stateHistory.get(e)}clearAll(){this.stateHistory.clear(),this.routeAccessOrder=[]}clearState(e){this.stateHistory.delete(e);let t=this.routeAccessOrder.indexOf(e);t!==-1&&this.routeAccessOrder.splice(t,1)}restoreState(e){let t=this.stateHistory.get(e);if(!t)return!1;let n=!0;return this.restoreScrollPositions(t.scrollPositions)||(n=!1),this.restoreFormData(t.formData)||(n=!1),t.focusedElement!=null&&t.focusedElement!==``&&this.restoreFocus(t.focusedElement),n}restoreScrollPositions(e){let t=!0;try{e.forEach((e,n)=>{try{if(n===`window`)window.scrollTo(e.x,e.y);else{let r=document.getElementById(n)??document.querySelector(`[data-scrollable-id="${n}"]`);r instanceof HTMLElement?(r.scrollLeft=e.x,r.scrollTop=e.y):t=!1}}catch{t=!1}})}catch(e){console.error(`[rari] Router: Failed to restore scroll positions:`,e),t=!1}return t}restoreFormData(e){let t=!0;try{e.forEach((e,n)=>{try{let r=document.getElementById(n),i=r instanceof HTMLFormElement?r:document.querySelector(`form[name="${n}"]`)??document.querySelectorAll(`form`)[Number.parseInt(n.replace(`form-`,``),10)];i instanceof HTMLFormElement?e.forEach((e,n)=>{try{let t=i.elements.namedItem(n);t instanceof RadioNodeList?t.forEach(t=>{t instanceof HTMLInputElement&&(t.type===`radio`||t.type===`checkbox`?t.checked=t.value===e:typeof e==`string`&&(t.value=e))}):(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)&&(t instanceof HTMLInputElement&&(t.type===`checkbox`||t.type===`radio`)?t.checked=t.value===e:typeof e==`string`&&(t.value=e))}catch{t=!1}}):t=!1}catch{t=!1}})}catch(e){console.error(`[rari] Router: Failed to restore form data:`,e),t=!1}return t}restoreFocus(e){try{let t=document.querySelector(e);t instanceof HTMLElement&&requestAnimationFrame(()=>{try{t.focus()}catch{}})}catch{}}};function x(e,t){let n=document.querySelector(e);if(n)t.content&&n.setAttribute(`content`,t.content);else{n=document.createElement(`meta`);for(let[e,r]of Object.entries(t))n.setAttribute(e,r);document.head.appendChild(n)}}function S(e){let t=document.querySelector(e);t&&t.remove()}function C(e){e.title!=null&&e.title!==``&&(document.title=e.title),e.description!=null&&e.description!==``?x(`meta[name="description"]`,{name:`description`,content:e.description}):S(`meta[name="description"]`),e.keywords&&e.keywords.length>0?x(`meta[name="keywords"]`,{name:`keywords`,content:e.keywords.join(`, `)}):S(`meta[name="keywords"]`),e.viewport!=null&&e.viewport!==``&&x(`meta[name="viewport"]`,{name:`viewport`,content:e.viewport})}function w(e){let t=document.querySelector(`link[rel="canonical"]`);if(e===void 0){t&&t.remove();return}if(t)t.setAttribute(`href`,e);else{let t=document.createElement(`link`);t.setAttribute(`rel`,`canonical`),t.setAttribute(`href`,e),document.head.appendChild(t)}}function ae(e){if(e===void 0){S(`meta[name="robots"]`);return}let t=[];e.index!==void 0&&t.push(e.index?`index`:`noindex`),e.follow!==void 0&&t.push(e.follow?`follow`:`nofollow`),e.nocache&&t.push(`nocache`),t.length>0?x(`meta[name="robots"]`,{name:`robots`,content:t.join(`, `)}):S(`meta[name="robots"]`)}function T(e){if(e===void 0){S(`meta[property="og:title"]`),S(`meta[property="og:description"]`),S(`meta[property="og:url"]`),S(`meta[property="og:site_name"]`),S(`meta[property="og:type"]`),document.querySelectorAll(`meta[property="og:image"]`).forEach(e=>{e.remove()});return}if(e.title!=null&&e.title!==``?x(`meta[property="og:title"]`,{property:`og:title`,content:e.title}):S(`meta[property="og:title"]`),e.description!=null&&e.description!==``?x(`meta[property="og:description"]`,{property:`og:description`,content:e.description}):S(`meta[property="og:description"]`),e.url!=null&&e.url!==``?x(`meta[property="og:url"]`,{property:`og:url`,content:e.url}):S(`meta[property="og:url"]`),e.siteName!=null&&e.siteName!==``?x(`meta[property="og:site_name"]`,{property:`og:site_name`,content:e.siteName}):S(`meta[property="og:site_name"]`),e.type!=null&&e.type!==``?x(`meta[property="og:type"]`,{property:`og:type`,content:e.type}):S(`meta[property="og:type"]`),e.images&&e.images.length>0){document.querySelectorAll(`meta[property="og:image"]`).forEach(e=>{e.remove()});for(let t of e.images){let e=document.createElement(`meta`);e.setAttribute(`property`,`og:image`),e.setAttribute(`content`,t),document.head.appendChild(e)}}else document.querySelectorAll(`meta[property="og:image"]`).forEach(e=>{e.remove()})}function E(e){if(e===void 0){S(`meta[name="twitter:card"]`),S(`meta[name="twitter:site"]`),S(`meta[name="twitter:creator"]`),S(`meta[name="twitter:title"]`),S(`meta[name="twitter:description"]`),document.querySelectorAll(`meta[name="twitter:image"]`).forEach(e=>{e.remove()});return}if(e.card!=null&&e.card!==``?x(`meta[name="twitter:card"]`,{name:`twitter:card`,content:e.card}):S(`meta[name="twitter:card"]`),e.site!=null&&e.site!==``?x(`meta[name="twitter:site"]`,{name:`twitter:site`,content:e.site}):S(`meta[name="twitter:site"]`),e.creator!=null&&e.creator!==``?x(`meta[name="twitter:creator"]`,{name:`twitter:creator`,content:e.creator}):S(`meta[name="twitter:creator"]`),e.title!=null&&e.title!==``?x(`meta[name="twitter:title"]`,{name:`twitter:title`,content:e.title}):S(`meta[name="twitter:title"]`),e.description!=null&&e.description!==``?x(`meta[name="twitter:description"]`,{name:`twitter:description`,content:e.description}):S(`meta[name="twitter:description"]`),e.images&&e.images.length>0){document.querySelectorAll(`meta[name="twitter:image"]`).forEach(e=>{e.remove()});for(let t of e.images){let e=document.createElement(`meta`);e.setAttribute(`name`,`twitter:image`),e.setAttribute(`content`,t),document.head.appendChild(e)}}else document.querySelectorAll(`meta[name="twitter:image"]`).forEach(e=>{e.remove()})}function D(e){C(e),w(e.canonical),ae(e.robots),T(e.openGraph),E(e.twitter)}function O(e){return i(e)}function k(r){let i=o(40),{children:a,initialRoute:f,staleWindowMs:p}=r,m=p===void 0?3e4:p,h;i[0]===f?h=i[1]:(h=()=>({currentRoute:b(f),navigationId:0,error:null}),i[0]=f,i[1]=h);let[g,_]=u(h),v=l(null),y=l(!0),x;i[2]===f?x=i[3]:(x=b(f),i[2]=f,i[3]=x);let S=l(x),C=l(0),w;i[4]===Symbol.for(`react.memo_cache_sentinel`)?(w=new ee({timeout:1e4,maxRetries:3,onError:fe,onRetry:de}),i[4]=w):w=i[4];let ae=l(w),T;i[5]===Symbol.for(`react.memo_cache_sentinel`)?(T=new Map,i[5]=T):T=i[5];let E=l(T),D;i[6]===Symbol.for(`react.memo_cache_sentinel`)?(D=[],i[6]=D):D=i[6];let O=l(D),k;i[7]===Symbol.for(`react.memo_cache_sentinel`)?(k=new ie({maxHistorySize:50}),i[7]=k):k=i[7];let A=l(k),pe=l(null),me=l(m),he=ue,j;i[8]===Symbol.for(`react.memo_cache_sentinel`)?(j=()=>{v.current&&=(v.current.abort(),null)},i[8]=j):j=i[8];let ge=j,M;i[9]===Symbol.for(`react.memo_cache_sentinel`)?(M=()=>{for(let[,e]of E.current.entries())e.abortController.abort();E.current.clear()},i[9]=M):M=i[9];let _e=M,N;i[10]===g?N=i[11]:(N=(e,t)=>{E.current.delete(e),y.current&&g.navigationId===t&&_(le)},i[10]=g,i[11]=N);let P=N,F=l(null),ve=ce,ye=se,I;i[12]===Symbol.for(`react.memo_cache_sentinel`)?(I=(e,t,n,r,i,a)=>{C.current===r&&window.dispatchEvent(new CustomEvent(`rari:navigate`,{detail:{from:t,to:n,navigationId:r,options:i,abortSignal:a.signal,rscResponsePromise:e}}))},i[12]=I):I=i[12];let be=I,L;if(i[13]===Symbol.for(`react.memo_cache_sentinel`)){let e=(e,t,n)=>{n.historyKey!=null&&n.historyKey!==``?requestAnimationFrame(()=>{A.current.restoreState(e)}):t&&requestAnimationFrame(()=>{let e=n=>{let r=n===void 0?0:n,i=document.getElementById(t);i?i.scrollIntoView({behavior:`smooth`,block:`start`}):r<10&&setTimeout(e,50,r+1)};e()})};L=(t,n,r,i)=>{y.current&&C.current===i&&(S.current=t,_(e=>({...e,currentRoute:t,navigationId:i,error:null})),ae.current.resetRetry(t),e(t,n,r))},i[13]=L}else L=i[13];let xe=L,R;i[14]===P?R=i[15]:(R=(e,t,n,r)=>{if(e instanceof Error&&e.name===`AbortError`){P(t,n);return}let i=ae.current.handleError(e,t);y.current&&(_(e=>({...e,error:i})),window.history.replaceState(window.history.state,``,r)),E.current.delete(t),window.dispatchEvent(new CustomEvent(`rari:navigate-error`,{detail:{from:r,to:t,error:i,navigationId:n}})),F.current?.()},i[14]=P,i[15]=R);let Se=R,z;i[16]!==P||i[17]!==Se?(z=async(e,t)=>{let n=t===void 0?{}:t;if(!e||typeof e!=`string`)return;let[r,i]=e.includes(`#`)?e.split(`#`):[e,``],a=b(r);if(a===S.current&&!n.replace){ve(a,i);return}let o=E.current.get(a);if(o)return o.promise;_e(),ge();let s=new AbortController;v.current=s,C.current+=1;let c=C.current;window.dispatchEvent(new CustomEvent(`rari:navigation-start`,{detail:{navigationId:c,targetPath:a}}));let l=(async()=>{let e=S.current;try{(n.historyKey==null||n.historyKey===``)&&A.current.captureState(e);let t=n.historyKey!=null&&n.historyKey!==``?n.historyKey:he(),r=window.location.origin+a,o=i?`${a}#${i}`:a,l={route:a,navigationId:c,scrollPosition:{x:window.scrollX,y:window.scrollY},timestamp:Date.now(),key:t};n.replace?window.history.replaceState(l,``,o):window.history.pushState(l,``,o);let u=await fetch(r,{headers:{Accept:`text/x-component`,"rari-navigation-id":String(c)},signal:s.signal}).then(oe);if(s.signal.aborted){P(a,c);return}let d=new URL(u.url).pathname;if(d!==a){let e=i?`${d}#${i}`:d;window.history.replaceState({...l,route:d},``,e)}be(Promise.resolve(u),e,d,c,n,s),ye(u),xe(d,i,n,c),E.current.delete(a),F.current?.()}catch(t){Se(t,a,c,e)}})();return E.current.set(a,{targetPath:a,navigationId:c,promise:l,abortController:s}),l},i[16]=P,i[17]=Se,i[18]=z):z=i[18];let B=z,V;i[19]===B?V=i[20]:(V=async()=>{if(O.current.length===0)return;let e=O.current.at(-1);e&&(O.current=[],await B(e.path,e.options))},i[19]=B,i[20]=V);let Ce=V,H=l(B),U;i[21]!==B||i[22]!==Ce?(U=()=>(F.current=Ce,H.current=B,()=>{F.current=null,H.current=null}),i[21]=B,i[22]=Ce,i[23]=U):U=i[23],c(U);let we=l(null),W,G;i[24]===Symbol.for(`react.memo_cache_sentinel`)?(W=()=>{we.current??=d((e,t)=>{H.current?.(e,t)},50,{leading:!0,trailing:!0,maxWait:200})},G=[],i[24]=W,i[25]=G):(W=i[24],G=i[25]),c(W,G);let K;i[26]===Symbol.for(`react.memo_cache_sentinel`)?(K=e=>{if(e.button!==0||e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)return;let t=e.target instanceof Element?e.target:null;for(;t&&!(t instanceof HTMLAnchorElement);)t=t.parentElement;if(!(t instanceof HTMLAnchorElement))return;let n=t;if(n.target&&n.target!==`_self`||n.hasAttribute(`download`))return;let r=n.getAttribute(`href`);if(r==null||r===``||te(r))return;if(r.startsWith(`#`)){e.preventDefault();let t=r.slice(1),n=document.getElementById(t);n&&(n.scrollIntoView({behavior:`smooth`,block:`start`}),window.history.pushState(window.history.state,``,r));return}e.preventDefault();let i=ne(r);we.current?.(i,{replace:!1})},i[26]=K):K=i[26];let Te=K,q;i[27]===Symbol.for(`react.memo_cache_sentinel`)?(q=e=>{let t=window.location.pathname,r=n(e.state)?e.state:null;H.current&&H.current(t,{replace:!0,scroll:!1,historyKey:r?.key})},i[27]=q):q=i[27];let Ee=q,J,Y;i[28]===f?(J=i[29],Y=i[30]):(J=()=>{let e=n(window.history.state)?window.history.state:null;if(e?.key==null||e.key===``){let e={route:b(f),navigationId:0,scrollPosition:{x:window.scrollX,y:window.scrollY},timestamp:Date.now(),key:he()};window.history.replaceState(e,``,window.location.pathname+window.location.search+window.location.hash)}},Y=[f],i[28]=f,i[29]=J,i[30]=Y),s(J,Y);let X;i[31]===Symbol.for(`react.memo_cache_sentinel`)?(X=e=>{if(e.persisted){let e=window.location.pathname;A.current.captureState(e)}},i[31]=X):X=i[31];let De=X,Z;i[32]===Symbol.for(`react.memo_cache_sentinel`)?(Z=e=>{if(e.persisted){let e=window.location.pathname,t=n(window.history.state)?window.history.state:null;requestAnimationFrame(()=>{A.current.restoreState(e),t?.scrollPosition&&window.scrollTo(t.scrollPosition.x,t.scrollPosition.y)})}},i[32]=Z):Z=i[32];let Oe=Z,Q,ke;i[33]===Symbol.for(`react.memo_cache_sentinel`)?(Q=()=>(document.addEventListener(`click`,Te),window.addEventListener(`popstate`,Ee),window.addEventListener(`pagehide`,De),window.addEventListener(`pageshow`,Oe),()=>{document.removeEventListener(`click`,Te),window.removeEventListener(`popstate`,Ee),window.removeEventListener(`pagehide`,De),window.removeEventListener(`pageshow`,Oe)}),ke=[],i[33]=Q,i[34]=ke):(Q=i[33],ke=i[34]),s(Q,ke);let Ae,je;i[35]===m?(Ae=i[36],je=i[37]):(Ae=()=>{me.current=m;let e=()=>{document.hidden?pe.current=Date.now():pe.current!==null&&Date.now()-pe.current>me.current&&re.clear()};return document.addEventListener(`visibilitychange`,e),()=>{document.removeEventListener(`visibilitychange`,e)}},je=[m],i[35]=m,i[36]=Ae,i[37]=je),s(Ae,je);let Me,$;return i[38]===Symbol.for(`react.memo_cache_sentinel`)?(Me=()=>(y.current=!0,e(async(e,t)=>H.current?.(e,t)??Promise.resolve()),()=>{y.current=!1,t(),ge(),_e(),we.current?.cancel()}),$=[],i[38]=Me,i[39]=$):(Me=i[38],$=i[39]),s(Me,$),a}function oe(e){if(!e.ok&&e.status!==404)throw Error(`Failed to fetch: ${e.status}`);return e}function se(e){try{let t=e.headers.get(`x-rari-metadata`);if(t!=null&&t!==``){let e=r(decodeURIComponent(t));e&&O(e)&&D(e)}}catch(e){console.warn(`[rari] Router: Failed to parse x-rari-metadata header:`,e)}}function ce(e,t){if(!t)return;let n=document.getElementById(t);n&&(n.scrollIntoView({behavior:`smooth`,block:`start`}),window.history.pushState(window.history.state,``,`${e}#${t}`))}function le(e){return{...e}}function ue(){return`${Date.now()}-${Math.random().toString(36).substring(2,9)}`}function de(){}function fe(e){console.error(`[rari] Router: Navigation error:`,e)}export{k as ClientRouter};
1
+ "use client";import{i as e,t}from"../navigate-DuyUa6qD.mjs";import{d as n,h as r,i,n as a,v as o,x as s}from"../type-guards-BJXKlA6x.mjs";import{r as c}from"../path-C74rvUep.mjs";import{t as l}from"../form-state-DZJs9bve.mjs";import{c as u}from"react/compiler-runtime";import{useEffect as d,useLayoutEffect as f,useRef as p,useState as m}from"react";function h(e,t,n={}){let r=null,i=0,a=0,o=null,s=null,{leading:c=!1,trailing:l=!0,maxWait:u}=n;function d(t){let n=o,r=s;o=null,s=null,a=t,e.apply(r,n)}function f(e){let n=e-i,r=e-a;return i===0||n>=t||n<0||u!==void 0&&r>=u}function p(){let e=Date.now();if(f(e)){h(e);return}let n=e-i,o=e-a,s=t-n,c=u===void 0?1/0:u-o;r=setTimeout(p,Math.min(s,c))}function m(e){a=e,r=setTimeout(p,t),c&&d(e)}function h(e){if(r=null,l&&o){d(e);return}o=null,s=null}function g(){r!==null&&clearTimeout(r),a=0,o=null,i=0,s=null,r=null}function _(){r!==null&&h(Date.now())}function v(){return r!==null}function y(...e){let n=Date.now(),a=f(n);if(o=e,s=this,i=n,a){if(r===null){m(i);return}
2
+ /* v8 ignore start - edge case: isInvoking true with existing timeout and maxWait defined */
3
+ if(u!==void 0){r=setTimeout(p,t),d(i);return}}r??=setTimeout(p,t)}return y.cancel=g,y.flush=_,y.pending=v,y}const 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
+ /* v8 ignore next - defensive check for non-Error values from parse-related condition */
5
+ originalError:a(e),url:t,timestamp:Date.now(),retryable:!1}}function S(e,t){return{type:`fetch-error`,message:a(e)?.message??`Unknown error occurred`,originalError:a(e),url:t,timestamp:Date.now(),retryable:!1}}function C(e,t){if(n(e)&&e.name===`AbortError`)return _(e,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 ee=class{onError;constructor(e={}){
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 te(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 ne(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 re=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 o(e)&&typeof e.navigationId==`number`}function T(e){return o(e)&&typeof e.navigationId==`number`&&`error`in e}async function ie(e,t){return t.aborted?{error:new DOMException(`Aborted`,`AbortError`)}:new Promise(n=>{function r(){window.removeEventListener(`rari:navigate-committed`,a),window.removeEventListener(`rari:navigate-error`,o),t.removeEventListener(`abort`,s)}function a(t){i(t,w)?.navigationId===e&&(r(),n(`committed`))}function o(t){let a=i(t,T);a?.navigationId===e&&(r(),n({error:a.error}))}function s(){r(),n({error:new DOMException(`Aborted`,`AbortError`)})}window.addEventListener(`rari:navigate-committed`,a),window.addEventListener(`rari:navigate-error`,o),t.addEventListener(`abort`,s,{once:!0})})}function E(e,t){let n=document.querySelector(e);if(n)t.content&&n.setAttribute(`content`,t.content);else{n=document.createElement(`meta`);for(let[e,r]of Object.entries(t))n.setAttribute(e,r);document.head.appendChild(n)}}function D(e){let t=document.querySelector(e);t&&t.remove()}function O(e){e.title!=null&&e.title!==``&&(document.title=e.title),e.description!=null&&e.description!==``?E(`meta[name="description"]`,{name:`description`,content:e.description}):D(`meta[name="description"]`),e.keywords&&e.keywords.length>0?E(`meta[name="keywords"]`,{name:`keywords`,content:e.keywords.join(`, `)}):D(`meta[name="keywords"]`),e.viewport!=null&&e.viewport!==``&&E(`meta[name="viewport"]`,{name:`viewport`,content:e.viewport})}function k(e){let t=document.querySelector(`link[rel="canonical"]`);if(e===void 0){t&&t.remove();return}if(t)t.setAttribute(`href`,e);else{let t=document.createElement(`link`);t.setAttribute(`rel`,`canonical`),t.setAttribute(`href`,e),document.head.appendChild(t)}}function A(e){if(e===void 0){D(`meta[name="robots"]`);return}let t=[];e.index!==void 0&&t.push(e.index?`index`:`noindex`),e.follow!==void 0&&t.push(e.follow?`follow`:`nofollow`),e.nocache&&t.push(`nocache`),t.length>0?E(`meta[name="robots"]`,{name:`robots`,content:t.join(`, `)}):D(`meta[name="robots"]`)}function ae(e){if(e===void 0){D(`meta[property="og:title"]`),D(`meta[property="og:description"]`),D(`meta[property="og:url"]`),D(`meta[property="og:site_name"]`),D(`meta[property="og:type"]`),document.querySelectorAll(`meta[property="og:image"]`).forEach(e=>{e.remove()});return}if(e.title!=null&&e.title!==``?E(`meta[property="og:title"]`,{property:`og:title`,content:e.title}):D(`meta[property="og:title"]`),e.description!=null&&e.description!==``?E(`meta[property="og:description"]`,{property:`og:description`,content:e.description}):D(`meta[property="og:description"]`),e.url!=null&&e.url!==``?E(`meta[property="og:url"]`,{property:`og:url`,content:e.url}):D(`meta[property="og:url"]`),e.siteName!=null&&e.siteName!==``?E(`meta[property="og:site_name"]`,{property:`og:site_name`,content:e.siteName}):D(`meta[property="og:site_name"]`),e.type!=null&&e.type!==``?E(`meta[property="og:type"]`,{property:`og:type`,content:e.type}):D(`meta[property="og:type"]`),e.images&&e.images.length>0){document.querySelectorAll(`meta[property="og:image"]`).forEach(e=>{e.remove()});for(let t of e.images){let e=document.createElement(`meta`);e.setAttribute(`property`,`og:image`),e.setAttribute(`content`,t),document.head.appendChild(e)}}else document.querySelectorAll(`meta[property="og:image"]`).forEach(e=>{e.remove()})}function j(e){if(e===void 0){D(`meta[name="twitter:card"]`),D(`meta[name="twitter:site"]`),D(`meta[name="twitter:creator"]`),D(`meta[name="twitter:title"]`),D(`meta[name="twitter:description"]`),document.querySelectorAll(`meta[name="twitter:image"]`).forEach(e=>{e.remove()});return}if(e.card!=null&&e.card!==``?E(`meta[name="twitter:card"]`,{name:`twitter:card`,content:e.card}):D(`meta[name="twitter:card"]`),e.site!=null&&e.site!==``?E(`meta[name="twitter:site"]`,{name:`twitter:site`,content:e.site}):D(`meta[name="twitter:site"]`),e.creator!=null&&e.creator!==``?E(`meta[name="twitter:creator"]`,{name:`twitter:creator`,content:e.creator}):D(`meta[name="twitter:creator"]`),e.title!=null&&e.title!==``?E(`meta[name="twitter:title"]`,{name:`twitter:title`,content:e.title}):D(`meta[name="twitter:title"]`),e.description!=null&&e.description!==``?E(`meta[name="twitter:description"]`,{name:`twitter:description`,content:e.description}):D(`meta[name="twitter:description"]`),e.images&&e.images.length>0){document.querySelectorAll(`meta[name="twitter:image"]`).forEach(e=>{e.remove()});for(let t of e.images){let e=document.createElement(`meta`);e.setAttribute(`name`,`twitter:image`),e.setAttribute(`content`,t),document.head.appendChild(e)}}else document.querySelectorAll(`meta[name="twitter:image"]`).forEach(e=>{e.remove()})}function oe(e){O(e),k(e.canonical),A(e.robots),ae(e.openGraph),j(e.twitter)}function M(e){return o(e)}function se(i){let a=u(35),{children:o,initialRoute:s}=i,l;a[0]===s?l=a[1]:(l=()=>({currentRoute:typeof window<`u`?`${window.location.pathname}${window.location.search}`:c(s),navigationId:0,error:null}),a[0]=s,a[1]=l);let[g,_]=m(l),v=p(null),y=p(!0),b;a[2]===s?b=a[3]:(b=typeof window<`u`?`${window.location.pathname}${window.location.search}`:c(s),a[2]=s,a[3]=b);let x=p(b),S;a[4]===s?S=a[5]:(S=typeof window<`u`?`${window.location.pathname}${window.location.search}${window.location.hash}`:c(s),a[4]=s,a[5]=S);let C=p(S),w=p(0),T;a[6]===Symbol.for(`react.memo_cache_sentinel`)?(T=new ee({onError:de}),a[6]=T):T=a[6];let E=p(T),D;a[7]===Symbol.for(`react.memo_cache_sentinel`)?(D=/* @__PURE__ */ new Map,a[7]=D):D=a[7];let O=p(D),k;a[8]===Symbol.for(`react.memo_cache_sentinel`)?(k=new re({maxHistorySize:50}),a[8]=k):k=a[8];let A=p(k),ae=ue,j;a[9]===Symbol.for(`react.memo_cache_sentinel`)?(j=()=>{v.current&&=(v.current.abort(),null)},a[9]=j):j=a[9];let oe=j,M;a[10]===Symbol.for(`react.memo_cache_sentinel`)?(M=()=>{for(let[,e]of O.current.entries())e.abortController.abort();O.current.clear()},a[10]=M):M=a[10];let se=M,N;a[11]===g?N=a[12]:(N=(e,t)=>{O.current.delete(e),y.current&&g.navigationId===t&&_(le)},a[11]=g,a[12]=N);let P=N,F;a[13]===Symbol.for(`react.memo_cache_sentinel`)?(F=(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},a[13]=F):F=a[13];let fe=F,pe=ce,I;if(a[14]===Symbol.for(`react.memo_cache_sentinel`)){let e=(e,t,n)=>{n.historyKey!=null&&n.historyKey!==``?requestAnimationFrame(()=>{A.current.restoreState(e)}):t&&requestAnimationFrame(()=>{let e=n=>{let r=n===void 0?0:n,i=document.getElementById(t);i?i.scrollIntoView({behavior:`smooth`,block:`start`}):r<10&&setTimeout(e,50,r+1)};e()})};I=(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))},a[14]=I}else I=a[14];let me=I,L;a[15]===P?L=a[16]:(L=(e,t,r,i,a)=>{let o=a===void 0?{}:a;if(n(e)&&e.name===`AbortError`){P(t,r);return}let s=E.current.handleError(e,t);y.current&&(_(e=>({...e,error:s})),window.history.replaceState(window.history.state,``,i)),O.current.delete(t),o.emitEvent!==!1&&window.dispatchEvent(new CustomEvent(`rari:navigate-error`,{detail:{from:i,to:t,error:s,navigationId:r}}))},a[15]=P,a[16]=L);let R=L,he;a[17]!==P||a[18]!==R?(he=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){fe(i,{replace:n.replace===!0});return}let o=O.current.get(a);if(o)return o.promise;se(),oe();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===``)&&A.current.captureState(x.current);let t=n.historyKey!=null&&n.historyKey!==``?n.historyKey:ae(),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)},cache:`no-store`,signal:s.signal});if(!c.ok&&c.status!==404){R(/* @__PURE__ */ Error(`Failed to fetch: ${c.status}`),a,l,e);return}if(s.signal.aborted){P(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=ie(l,s.signal);if(window.dispatchEvent(new CustomEvent(`rari:navigate`,{detail:{from:e,to:d,navigationId:l,options:n,abortSignal:s.signal,rscResponse:c,pendingHistory:{url:m,state:p,replace:n.replace===!0}}})),w.current!==l){s.abort();return}let g=await h;if(w.current!==l)return;if(g!==`committed`){R(g.error,a,l,e,{emitEvent:!1});return}pe(c),me(f,i,n,l,m),O.current.delete(a)}catch(t){R(t,a,l,e)}})();return O.current.set(a,{targetPath:a,navigationId:l,promise:u,abortController:s}),u},a[17]=P,a[18]=R,a[19]=he):he=a[19];let z=he,B=p(z),V;a[20]===z?V=a[21]:(V=()=>(B.current=z,()=>{B.current=null}),a[20]=z,a[21]=V),f(V);let ge=p(null),H,U;a[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=[],a[22]=H,a[23]=U):(H=a[22],U=a[23]),f(H,U);let W;a[24]===Symbol.for(`react.memo_cache_sentinel`)?(W=e=>{if(e.button!==0||e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)return;let t=e.target instanceof Element?e.target:null;for(;t&&!(t instanceof HTMLAnchorElement);)t=t.parentElement;if(!(t instanceof HTMLAnchorElement))return;let n=t;if(n.target&&n.target!==`_self`||n.hasAttribute(`download`))return;let r=n.getAttribute(`href`);if(r==null||r===``||te(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=ne(r);ge.current?.(i,{replace:!1})},a[24]=W):W=a[24];let _e=W,G;a[25]===Symbol.for(`react.memo_cache_sentinel`)?(G=e=>{let t=`${window.location.pathname}${window.location.search}${window.location.hash}`,n=r(e.state)?e.state:null;B.current&&B.current(t,{replace:!0,scroll:!1,historyKey:n?.key})},a[25]=G):G=a[25];let ve=G,K;a[26]===Symbol.for(`react.memo_cache_sentinel`)?(K=()=>{let e=r(window.history.state)?window.history.state:null;if(e?.key==null||e.key===``){let e={route:`${window.location.pathname}${window.location.search}`,navigationId:0,scrollPosition:{x:window.scrollX,y:window.scrollY},timestamp:Date.now(),key:ae()};window.history.replaceState(e,``,window.location.pathname+window.location.search+window.location.hash)}},a[26]=K):K=a[26];let q;a[27]===s?q=a[28]:(q=[s],a[27]=s,a[28]=q),d(K,q);let J;a[29]===Symbol.for(`react.memo_cache_sentinel`)?(J=e=>{if(e.persisted){let e=window.location.pathname;A.current.captureState(e)}},a[29]=J):J=a[29];let ye=J,Y;a[30]===Symbol.for(`react.memo_cache_sentinel`)?(Y=e=>{if(e.persisted){let e=window.location.pathname,t=r(window.history.state)?window.history.state:null;requestAnimationFrame(()=>{A.current.restoreState(e),t?.scrollPosition&&window.scrollTo(t.scrollPosition.x,t.scrollPosition.y)})}},a[30]=Y):Y=a[30];let be=Y,X,Z;a[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=[],a[31]=X,a[32]=Z):(X=a[31],Z=a[32]),d(X,Z);let Q,$;return a[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(),oe(),se(),ge.current?.cancel()}),$=[],a[33]=Q,a[34]=$):(Q=a[33],$=a[34]),d(Q,$),o}function ce(e){try{let t=e.headers.get(`x-rari-metadata`);if(t!=null&&t!==``){let e=s(decodeURIComponent(t));e&&M(e)&&oe(e)}}catch(e){console.warn(`[rari] Router: Failed to parse x-rari-metadata header:`,e)}}function le(e){return{...e}}function ue(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`hk-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,11)}`}function de(e){console.error(`[rari] Router: Navigation error:`,e)}export{se as ClientRouter};
@@ -13,7 +13,7 @@ interface ErrorBoundaryWrapperState {
13
13
  reset: () => void;
14
14
  }> | null;
15
15
  }
16
- declare class ErrorBoundaryWrapper extends Component<ErrorBoundaryWrapperProps, ErrorBoundaryWrapperState> {
16
+ export declare class ErrorBoundaryWrapper extends Component<ErrorBoundaryWrapperProps, ErrorBoundaryWrapperState> {
17
17
  private _isMounted;
18
18
  private _pendingTimer;
19
19
  constructor(props: ErrorBoundaryWrapperProps);
@@ -24,5 +24,4 @@ declare class ErrorBoundaryWrapper extends Component<ErrorBoundaryWrapperProps,
24
24
  reset: () => void;
25
25
  render(): ReactNode;
26
26
  }
27
- //#endregion
28
- export { ErrorBoundaryWrapper };
27
+ //#endregion
@@ -1 +1 @@
1
- "use client";import{c as e,p as t}from"../type-guards-CTkEL8zw.mjs";import{t as n}from"../timer-Duul5JHq.mjs";import{r}from"../rari-global-5vGzhToD.mjs";import{Component as i}from"react";import{jsx as a}from"react/jsx-runtime";function o(n){if(e(n))return n;if(t(n)){let t=n.default??n;return e(t)?t:null}return null}var s=class extends i{_isMounted=!1;_pendingTimer=null;constructor(e){super(e),this.state={hasError:!1,error:null,ErrorComponent:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidMount(){this._isMounted=!0}componentWillUnmount(){this._isMounted=!1,this._pendingTimer=n(this._pendingTimer)}componentDidCatch(e,t){console.error(`[rari] Error boundary caught error:`,e,t);let n=this.props.errorComponentId;if(n!==``){let e=r();if(n in e){let t=e[n],r=o(t.component);r?this.setState({ErrorComponent:r}):t.loader&&!t.loading&&(t.loading=!0,t.loader().then(e=>{let n=o(e);n&&(t.component=n,t.registered=!0,this.setState({ErrorComponent:n})),t.loading=!1}).catch(e=>{t.loading=!1,console.error(`[rari] Failed to load error component ${n}:`,e)}))}}}reset=()=>{this._pendingTimer=n(this._pendingTimer),this._pendingTimer=setTimeout(()=>{this._isMounted&&this.setState({hasError:!1,error:null,ErrorComponent:null}),this._pendingTimer=null},50)};render(){if(this.state.hasError&&this.state.error){let{ErrorComponent:e}=this.state;return e?a(e,{error:this.state.error,reset:this.reset}):null}return this.props.children}};export{s as ErrorBoundaryWrapper};
1
+ "use client";import{u as e,v as t}from"../type-guards-BJXKlA6x.mjs";import{t as n}from"../timer-Duul5JHq.mjs";import{r}from"../rari-global-5vGzhToD.mjs";import{Component as i}from"react";import{jsx as a,jsxs as o}from"react/jsx-runtime";function s(n){if(e(n))return n;if(t(n)){let t=n.default??n;return e(t)?t:null}return null}var c=class extends i{_isMounted=!1;_pendingTimer=null;constructor(e){super(e),this.state={hasError:!1,error:null,ErrorComponent:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidMount(){this._isMounted=!0}componentWillUnmount(){this._isMounted=!1,this._pendingTimer=n(this._pendingTimer)}componentDidCatch(e,t){console.error(`[rari] Error boundary caught error:`,e,t);let n=this.props.errorComponentId;if(n!==``){let e=r();if(n in e){let t=e[n],r=s(t.component);r?this.setState({ErrorComponent:r}):t.loader&&!t.loading&&(t.loading=!0,t.loader().then(e=>{let n=s(e);n&&(t.component=n,t.registered=!0,this.setState({ErrorComponent:n})),t.loading=!1}).catch(e=>{t.loading=!1,console.error(`[rari] Failed to load error component ${n}:`,e)}))}}}reset=()=>{this._pendingTimer=n(this._pendingTimer),this._pendingTimer=setTimeout(()=>{this._isMounted&&this.setState({hasError:!1,error:null,ErrorComponent:null}),this._pendingTimer=null},50)};render(){if(this.state.hasError&&this.state.error){let{ErrorComponent:e}=this.state;return e?/* @__PURE__ */ a(e,{error:this.state.error,reset:this.reset}):/* @__PURE__ */ o(`div`,{className:`rari-error`,role:`alert`,style:{color:`red`,border:`1px solid red`,padding:`10px`,borderRadius:`4px`,backgroundColor:`#fff5f5`},children:[/* @__PURE__ */ a(`strong`,{children:`Error loading content: `}),this.state.error.message]})}return this.props.children}};export{c as ErrorBoundaryWrapper};
@@ -3,9 +3,8 @@ import * as React from "react";
3
3
  interface LoadingErrorBoundaryProps {
4
4
  children: React.ReactNode;
5
5
  }
6
- declare class LoadingErrorBoundary extends React.Component<LoadingErrorBoundaryProps> {
6
+ export declare class LoadingErrorBoundary extends React.Component<LoadingErrorBoundaryProps> {
7
7
  componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void;
8
8
  render(): React.ReactNode;
9
9
  }
10
- //#endregion
11
- export { LoadingErrorBoundary };
10
+ //#endregion
@@ -1,15 +1,14 @@
1
1
  import { ActionDidNotRevalidate, ActionDidRevalidateDynamicOnly, ActionDidRevalidateStaticAndDynamic, ActionRevalidationKind } from "./action-revalidation-kind.mjs";
2
2
  //#region src/runtime/actions/flight-refresh.d.ts
3
- interface ActionFlightRefreshDetail {
3
+ export interface ActionFlightRefreshDetail {
4
4
  element: unknown;
5
5
  revalidationKind: ActionRevalidationKind;
6
6
  revalidatedPath?: string;
7
7
  }
8
- interface ActionFlightResponseShape {
8
+ export interface ActionFlightResponseShape {
9
9
  readonly a?: unknown;
10
10
  readonly f?: unknown;
11
11
  }
12
- declare function scheduleActionFlightRefresh(response: Response, flightResponse: ActionFlightResponseShape, actionResult: unknown): void;
13
- declare function refreshRouter(): void;
12
+ export declare function scheduleActionFlightRefresh(response: Response, flightResponse: ActionFlightResponseShape, actionResult: unknown): void;
14
13
  //#endregion
15
- export { ActionDidNotRevalidate, ActionDidRevalidateDynamicOnly, ActionDidRevalidateStaticAndDynamic, ActionFlightRefreshDetail, ActionFlightResponseShape, refreshRouter, scheduleActionFlightRefresh };
14
+ export { ActionDidNotRevalidate, ActionDidRevalidateDynamicOnly, ActionDidRevalidateStaticAndDynamic };
@@ -1 +1 @@
1
- import{p as e}from"../type-guards-CTkEL8zw.mjs";import{ActionDidNotRevalidate as t,ActionDidRevalidateDynamicOnly as n,ActionDidRevalidateStaticAndDynamic as r,parseActionRevalidationKind as i}from"./action-revalidation-kind.mjs";function a(t){return e(t)?`redirect`in t||`~rariSkipRefresh`in t||`~rariFormState`in t:!1}function o(e){return typeof e==`object`&&!!e&&`$$typeof`in e}function s(t){return e(t)&&typeof t.then==`function`}function c(e){return o(e)||s(e)}function l(e){return e==null||e===``?null:e instanceof Promise?e.then(e=>e==null||e===``?null:e):e}function u(e,t,n){typeof globalThis.dispatchEvent==`function`&&(a(n)||(async()=>{let n=l(t.f),r=n instanceof Promise?await n:n;if(r==null||!c(r))return;let a=i(e.headers.get(`x-action-revalidated`));if(a===0)return;let o=e.headers.get(`x-action-revalidated-path`)??void 0,s=()=>{globalThis.dispatchEvent(new CustomEvent(`rari:action-flight-refresh`,{detail:{element:r,revalidationKind:a,revalidatedPath:o}}))};if(typeof requestAnimationFrame==`function`){requestAnimationFrame(()=>{requestAnimationFrame(s)});return}queueMicrotask(s)})().catch(e=>{console.error(`[rari] Action flight refresh failed:`,e instanceof Error?e.message:String(e))}))}function d(){typeof globalThis.dispatchEvent==`function`&&globalThis.dispatchEvent(new CustomEvent(`rari:app-router-rerender`))}export{t as ActionDidNotRevalidate,n as ActionDidRevalidateDynamicOnly,r as ActionDidRevalidateStaticAndDynamic,d as refreshRouter,u as scheduleActionFlightRefresh};
1
+ import{g as e,p as t,r as n,v as r}from"../type-guards-BJXKlA6x.mjs";import{ActionDidNotRevalidate as i,ActionDidRevalidateDynamicOnly as a,ActionDidRevalidateStaticAndDynamic as o,parseActionRevalidationKind as s}from"./action-revalidation-kind.mjs";function c(e){return r(e)?`redirect`in e||`~rariSkipRefresh`in e||`~rariFormState`in e:!1}function l(n){return e(n)||t(n)}function u(e){return e==null||e===``?null:e instanceof Promise?e.then(e=>e==null||e===``?null:e):e}function d(e,t,r){typeof globalThis.dispatchEvent==`function`&&(c(r)||(async()=>{let n=u(t.f),r=n instanceof Promise?await n:n;if(r==null||!l(r))return;let i=s(e.headers.get(`x-action-revalidated`));if(i===0)return;let a=e.headers.get(`x-action-revalidated-path`)??void 0,o=()=>{globalThis.dispatchEvent(new CustomEvent(`rari:action-flight-refresh`,{detail:{element:r,revalidationKind:i,revalidatedPath:a}}))};if(typeof requestAnimationFrame==`function`){requestAnimationFrame(()=>{requestAnimationFrame(o)});return}queueMicrotask(o)})().catch(e=>{console.error(`[rari] Action flight refresh failed:`,n(e,String(e)))}))}export{i as ActionDidNotRevalidate,a as ActionDidRevalidateDynamicOnly,o as ActionDidRevalidateStaticAndDynamic,d as scheduleActionFlightRefresh};
@@ -1,8 +1,7 @@
1
1
  //#region src/runtime/actions/revalidation-kind.d.ts
2
- type ActionRevalidationKind = 0 | 1 | 2;
3
- declare const ActionDidNotRevalidate: 0;
4
- declare const ActionDidRevalidateStaticAndDynamic: 1;
5
- declare const ActionDidRevalidateDynamicOnly: 2;
6
- declare function parseActionRevalidationKind(header: string | null): ActionRevalidationKind;
7
- //#endregion
8
- export { ActionDidNotRevalidate, ActionDidRevalidateDynamicOnly, ActionDidRevalidateStaticAndDynamic, ActionRevalidationKind, parseActionRevalidationKind };
2
+ export type ActionRevalidationKind = 0 | 1 | 2;
3
+ export declare const ActionDidNotRevalidate: 0;
4
+ export declare const ActionDidRevalidateStaticAndDynamic: 1;
5
+ export declare const ActionDidRevalidateDynamicOnly: 2;
6
+ export declare function parseActionRevalidationKind(header: string | null): ActionRevalidationKind;
7
+ //#endregion
@@ -1,4 +1,3 @@
1
1
  //#region src/runtime/actions/call-server.d.ts
2
- declare function callServer(id: string, args: readonly unknown[]): Promise<unknown>;
3
- //#endregion
4
- export { callServer };
2
+ export declare function callServer(id: string, args: readonly unknown[]): Promise<unknown>;
3
+ //#endregion
@@ -1 +1 @@
1
- import{p as e}from"../type-guards-CTkEL8zw.mjs";import{buildFlightRouterState as t}from"./flight-router-state.mjs";import{scheduleActionFlightRefresh as n}from"./action-flight-refresh.mjs";import{createFromFetch as r,createTemporaryReferenceSet as i,encodeReply as a}from"virtual:react-flight-client";function o(){if(typeof window>`u`)return{pathname:`/`,search:``,tree:t(`/`)};let e=window.location.pathname;return{pathname:e,search:window.location.search,tree:t(e)}}function s(){return JSON.stringify(o())}const c=3e4;function l(t){if(!e(t))return t;let{"~rariSkipRefresh":n,...r}=t;return r}function u(){return typeof window<`u`?window.location.pathname+window.location.search:`/`}const d=new Set([`http:`,`https:`]);function f(e){if(!(typeof window>`u`))try{let t=new URL(e,window.location.href);if(!d.has(t.protocol))return;t.href!==window.location.href&&(window.location.href=t.href)}catch{}}async function p(e,t){let o=i(),d=await a(t,{temporaryReferences:o}),m={Accept:`text/x-component`,"rsc-action-id":e,"rari-router-state":s()},h;typeof d==`string`&&(m[`Content-Type`]=`text/plain;charset=UTF-8`),h=d;let g=new AbortController,_=setTimeout(()=>{g.abort()},c),v;try{v=await fetch(u(),{method:`POST`,headers:m,body:h,signal:g.signal})}catch(t){throw t instanceof Error&&t.name===`AbortError`?Error(`Server action "${e}" timed out after ${c}ms`):t}finally{clearTimeout(_)}let y=v.headers.get(`x-action-redirect`);if(y!=null&&y!==``){let[e=``]=y.split(`;`);return e!==``&&f(e),{redirect:e}}let b=v.headers.get(`content-type`),x=b!=null&&b!==``?b:``;if(!x.startsWith(`text/x-component`)){let t=v.status>=400&&x.startsWith(`text/plain`)?await v.text().catch(()=>v.statusText):`Server action "${e}" failed with status ${v.status}: ${v.statusText}`;throw Error(t)}let S=await r(Promise.resolve(v),{callServer:p,temporaryReferences:o}),C=S.a,w=C instanceof Promise?await C:C;return n(v,S,w),l(w)}export{p as callServer};
1
+ import{d as e,v as t}from"../type-guards-BJXKlA6x.mjs";import{buildFlightRouterState as n}from"./flight-router-state.mjs";import{scheduleActionFlightRefresh as r}from"./action-flight-refresh.mjs";import{createFromFetch as i,createTemporaryReferenceSet as a,encodeReply as o}from"virtual:react-flight-client";function s(){if(typeof window>`u`)return{pathname:`/`,search:``,tree:n(`/`)};let e=window.location.pathname;return{pathname:e,search:window.location.search,tree:n(e)}}function c(){return JSON.stringify(s())}const l=3e4;function u(e){if(!t(e))return e;let{"~rariSkipRefresh":n,...r}=e;return r}function d(){return typeof window<`u`?window.location.pathname+window.location.search:`/`}const f=/* @__PURE__ */ new Set([`http:`,`https:`]);function p(e){if(typeof window<`u`)try{let t=new URL(e,window.location.href);if(!f.has(t.protocol))return;t.href!==window.location.href&&(window.location.href=t.href)}catch{}}async function m(t,n){let s=a(),f=await o(n,{temporaryReferences:s}),h={Accept:`text/x-component`,"rsc-action-id":t,"rari-router-state":c()},g;typeof f==`string`&&(h[`Content-Type`]=`text/plain;charset=UTF-8`),g=f;let _;try{_=await fetch(d(),{method:`POST`,headers:h,body:g,signal:AbortSignal.timeout(l)})}catch(n){throw n instanceof DOMException&&n.name===`TimeoutError`||e(n)&&n.name===`AbortError`?Error(`Server action "${t}" timed out after ${l}ms`):n}let v=_.headers.get(`x-action-redirect`);if(v!=null&&v!==``){let[e=``]=v.split(`;`);return e!==``&&p(e),{redirect:e}}let y=_.headers.get(`content-type`),b=y!=null&&y!==``?y:``;if(!b.startsWith(`text/x-component`)){let e=_.status>=400&&b.startsWith(`text/plain`)?await _.text().catch(()=>_.statusText):`Server action "${t}" failed with status ${_.status}: ${_.statusText}`;throw Error(e)}let x=await i(Promise.resolve(_),{callServer:m,temporaryReferences:s}),S=x.a,C=S instanceof Promise?await S:S;return r(_,x,C),u(C)}export{m as callServer};
@@ -1,7 +1,5 @@
1
- import "../types-_vPM8QuJ.mjs";
1
+ import "../types-Q-x_0kVB.mjs";
2
2
  import "virtual:rsc-integration.ts";
3
3
  //#region src/runtime/entry-client.d.ts
4
- declare function preloadClientComponent(id: string): Promise<void>;
5
- declare function renderApp(): Promise<void>;
6
- //#endregion
7
- export { preloadClientComponent, renderApp };
4
+ export declare function renderApp(): Promise<void>;
5
+ //#endregion
@@ -1,5 +1,5 @@
1
- import{n as e,p as t}from"../type-guards-CTkEL8zw.mjs";import{t as n}from"../router-D84JWQz7.mjs";import{a as r,i,n as a,r as o}from"../rari-global-5vGzhToD.mjs";import{t as s}from"../get-client-component-CLpyIcLJ.mjs";import{t as c}from"../preload-modules-QmSvKk0Q.mjs";import*as l from"react";import{createFromReadableStream as u}from"virtual:react-flight-client";import{createRoot as d,hydrateRoot as f}from"react-dom/client";import{AppRouterProvider as p}from"virtual:app-router-provider";import{ClientRouter as m}from"virtual:client-router";import"virtual:rsc-integration.ts";function h(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 g(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 _(e){if(g(e))return!0;let t=e.firstElementChild;return t===null||t.tagName===`SCRIPT`?!1:!t.classList.contains(`rari-error`)}function v(e){return g(e)}function y(e){e.querySelectorAll(`.rari-error:not([data-rari-hydration-failure])`).forEach(e=>{e.remove()})}function b(e,t,n){return l.createElement(e,t,n)}function x(){Reflect.set(globalThis,`__rari_client_ready`,!0),window.dispatchEvent(new CustomEvent(`rari:client-ready`))}function S(e,t){v(e)?(y(e),f(e,t,{onRecoverableError(e){import.meta.env.DEV&&console.warn(`[rari] Hydration mismatch:`,e)}})):d(e).render(t),x()}const C=i();C.AppRouterProvider=p,C.ClientRouter=m,C.getClientComponent=s;async function w(e){try{await s(e)}catch(t){console.error(`[rari] Failed to preload component ${e}:`,t)}}
1
+ import{i as e,n as t,r as n,v as r}from"../type-guards-BJXKlA6x.mjs";import{t as i}from"../router-D6X8JHst.mjs";import{a,n as o,r as s}from"../rari-global-5vGzhToD.mjs";import{t as c}from"../preload-modules-1i2BJqux.mjs";import*as l from"react";import{createFromFetch as u,createFromReadableStream as d}from"virtual:react-flight-client";import{createRoot as f,hydrateRoot as p}from"react-dom/client";import{AppRouterProvider as m}from"virtual:app-router-provider";import{ClientRouter as h}from"virtual:client-router";import"virtual:rsc-integration.ts";function g(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 _(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 v(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 y(e){let t=e.firstElementChild;for(;t!=null&&v(t);)t=t.nextElementSibling;return t}function b(e){if(_(e))return!0;let t=y(e);return t!==null&&!t.classList.contains(`rari-error`)}function x(e){return _(e)}function S(e){e.querySelectorAll(`.rari-error:not([data-rari-hydration-failure])`).forEach(e=>{e.remove()})}function C(e,t,n){return l.createElement(e,t,n)}function w(){Reflect.set(globalThis,`__rari_client_ready`,!0),window.dispatchEvent(new CustomEvent(`rari:client-ready`))}function T(e){if(e===``)return;let t=()=>{document.title.trim()===``&&(document.title=e)};t(),queueMicrotask(t),requestAnimationFrame(()=>{t(),requestAnimationFrame(t)})}function E(e){let t=document.documentElement,n=document.title.trim();x(t)?(S(t),p(document,e,{onRecoverableError(e){import.meta.env.DEV&&console.warn(`[rari] Hydration mismatch:`,e)}})):f(document).render(e),T(n),w()}
2
2
  /*! @preserve CLIENT_COMPONENT_IMPORTS_PLACEHOLDER */
3
- C.preloadClientComponent=w,o(),a();
3
+ s(),o();
4
4
  /*! @preserve CLIENT_COMPONENT_REGISTRATIONS_PLACEHOLDER */
5
- function T(){let e=Reflect.get(globalThis,`__rari_f`);if(Array.isArray(e))return e}function E(e){return t(e)&&typeof e.rscRow==`string`}function D(e){return Array.isArray(e)&&typeof e[1]==`string`}function O(){return!!T()?.some(e=>e!==0)}function k(){let e=T();if(e?.length==null||e.length===0)return null;let t=``,n=[];for(let r of e)r!==0&&(typeof r==`string`?t+=r:D(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 A(t,n){let i=new TextDecoder().decode(t);await c(i);let a=r(),o=a.streaming,s=!!(o?.bufferedRows&&o.bufferedRows.length>0);if(n.streaming&&(o?.complete===void 0||s)){let n=new ReadableStream({start(n){let r=!1;n.enqueue(t);let i=t=>{if(r)return;let i=e(t,E);i&&n.enqueue(new TextEncoder().encode(`\n${i.rscRow}`))},o=()=>{r||(r=!0,n.close(),window.removeEventListener(`rari:html-stream-row`,i),window.removeEventListener(`rari:stream-complete`,o))};if(window.addEventListener(`rari:html-stream-row`,i),window.addEventListener(`rari:stream-complete`,o),a.streaming?.bufferedRows){let e=[...a.streaming.bufferedRows];for(let t of e)n.enqueue(new TextEncoder().encode(`\n${t}`));a.streaming.bufferedRows=[]}a.streaming?.complete&&o()}});return u(n)}let l=new ReadableStream({start(e){e.enqueue(t),e.close()}});return u(l)}async function j(){let t=document.getElementById(`root`);if(!t){console.error(`[rari] Root element not found`);return}let i=O(),a=k(),o=_(t)||g(t),s=r().streaming,c=!!(s?.bufferedRows&&s.bufferedRows.length>0);try{let s,d=!i&&!c&&!o;if(o&&i&&a){let e=`Could not load interactive page data.`;try{s=await A(a,{streaming:!1})}catch(t){e=t instanceof Error?t.message:`Failed to parse embedded RSC payload.`;try{let t=window.location.pathname+window.location.search,n=import.meta.env.DEV?import.meta.env.RARI_SERVER_URL!=null&&import.meta.env.RARI_SERVER_URL!==``?import.meta.env.RARI_SERVER_URL:`http://localhost:${import.meta.env.VITE_RSC_PORT!=null&&import.meta.env.VITE_RSC_PORT!==``?import.meta.env.VITE_RSC_PORT:`3000`}`:window.location.origin,r=await fetch(n+t,{headers:{Accept:`text/x-component`},cache:`no-store`});if(r.ok){let e=new Uint8Array(await r.arrayBuffer()),t=new ReadableStream({start(t){t.enqueue(e),t.close()}});s=await u(t)}else e=`Failed to fetch RSC payload fallback: HTTP ${r.status}.`}catch(t){e=t instanceof Error?t.message:`Failed to fetch RSC payload fallback.`,console.error(`[rari] Failed to fetch RSC payload fallback:`,t)}}if(s!=null){let e=l.createElement(p,{initialPayload:{element:s}});e=b(m,{initialRoute:window.location.pathname},e),e=b(n,{initialPathname:window.location.pathname},e),S(t,e)}else h(t,`${e} Try refreshing the page.`),console.error(`[rari] Hydration skipped: failed to load RSC payload`);return}if(d)try{let e=window.location.pathname+window.location.search,t=(import.meta.env.DEV?import.meta.env.RARI_SERVER_URL!=null&&import.meta.env.RARI_SERVER_URL!==``?import.meta.env.RARI_SERVER_URL:`http://localhost:${import.meta.env.VITE_RSC_PORT!=null&&import.meta.env.VITE_RSC_PORT!==``?import.meta.env.VITE_RSC_PORT:`3000`}`:window.location.origin)+e,n=await fetch(t,{headers:{Accept:`text/x-component`},cache:`no-store`});if(!n.ok&&n.status!==404)throw Error(`Failed to fetch RSC data: ${n.status}`);if(!n.body)throw Error(`RSC response has no body`);s=await u(n.body)}catch(e){if(e instanceof Promise)throw e;console.error(`[rari] Failed to fetch initial RSC data:`,e),s=null}else if(i&&a)try{s=await A(a,{streaming:!0})}catch(e){console.error(`[rari] Failed to parse embedded RSC payload:`,e),console.error(`[rari] Error stack:`,e instanceof Error?e.stack:`no stack`),s=null}else if(c)try{let t=new ReadableStream({start(t){let n=n=>{let r=e(n,E);r&&t.enqueue(new TextEncoder().encode(`${r.rscRow}\n`))},i=()=>{t.close(),window.removeEventListener(`rari:html-stream-row`,n),window.removeEventListener(`rari:stream-complete`,i)};window.addEventListener(`rari:html-stream-row`,n),window.addEventListener(`rari:stream-complete`,i);let a=r();if(a.streaming?.bufferedRows){let e=[...a.streaming.bufferedRows];a.streaming.bufferedRows=[];for(let n of e)t.enqueue(new TextEncoder().encode(`${n}\n`))}a.streaming?.complete&&i()}});s=await u(t)}catch(e){console.error(`[rari] Failed to process streaming RSC payload:`,e),s=null}if(s==null)throw Error(`No RSC data available for hydration`);let f=l.createElement(p,{initialPayload:{element:s}});f=b(m,{initialRoute:window.location.pathname},f),f=b(n,{initialPathname:window.location.pathname},f),S(t,f)}catch(e){console.error(`[rari] Error rendering app:`,e)}}function M(){let e=import.meta.hot;if(!e)return{};let n=e.data;return t(n)?{hasRendered:n.hasRendered===!0}:{}}function N(){let e=import.meta.hot;if(!e)return;let n=e.data;t(n)&&(n.hasRendered=!0)}(!import.meta.hot||M().hasRendered!==!0)&&(j().catch(e=>{console.error(`[rari] Fatal error:`,e)}),N());export{w as preloadClientComponent,j as renderApp};
5
+ function D(){let e=Reflect.get(globalThis,`__rari_f`);if(Array.isArray(e))return e}function O(e){return r(e)&&typeof e.rscRow==`string`}function k(e){return Array.isArray(e)&&typeof e[1]==`string`}function A(){return!!D()?.some(e=>e!==0)}function j(){let e=D();if(e?.length==null||e.length===0)return null;let t=``,n=[];for(let r of e)r!==0&&(typeof r==`string`?t+=r:k(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 M(t,n){let r=new TextDecoder().decode(t);await c(r);let i=a(),o=i.streaming,s=!!(o?.bufferedRows&&o.bufferedRows.length>0);if(n.streaming&&(o?.complete===void 0||s)){let n=new ReadableStream({start(n){let r=!1;n.enqueue(t);let a=t=>{if(r)return;let i=e(t,O);i&&n.enqueue(new TextEncoder().encode(`\n${i.rscRow}`))},o=()=>{r||(r=!0,n.close(),window.removeEventListener(`rari:html-stream-row`,a),window.removeEventListener(`rari:stream-complete`,o))};if(window.addEventListener(`rari:html-stream-row`,a),window.addEventListener(`rari:stream-complete`,o),i.streaming?.bufferedRows){let e=[...i.streaming.bufferedRows];for(let t of e)n.enqueue(new TextEncoder().encode(`\n${t}`));i.streaming.bufferedRows=[]}i.streaming?.complete&&o()}});return d(n)}let l=new ReadableStream({start(e){e.enqueue(t),e.close()}});return d(l)}async function N(){let r=A(),o=j(),s=document.documentElement,c=b(document.body)||_(s),f=a().streaming,p=!!(f?.bufferedRows&&f.bufferedRows.length>0);try{let s,f=!r&&!p&&!c;if(c&&r&&o){let e=`Could not load interactive page data.`;try{s=await M(o,{streaming:!1})}catch(t){e=n(t,`Failed to parse embedded RSC payload.`);try{let t=window.location.pathname+window.location.search,n=import.meta.env.DEV?import.meta.env.RARI_SERVER_URL!=null&&import.meta.env.RARI_SERVER_URL!==``?import.meta.env.RARI_SERVER_URL:`http://localhost:${import.meta.env.VITE_RSC_PORT!=null&&import.meta.env.VITE_RSC_PORT!==``?import.meta.env.VITE_RSC_PORT:`3000`}`:window.location.origin,r=await fetch(n+t,{headers:{Accept:`text/x-component`},cache:`no-store`});r.ok?s=await u(Promise.resolve(r)):e=`Failed to fetch RSC payload fallback: HTTP ${r.status}.`}catch(t){e=n(t,`Failed to fetch RSC payload fallback.`),console.error(`[rari] Failed to fetch RSC payload fallback:`,t)}}if(s!=null){let e=l.createElement(m,{initialPayload:{element:s}});e=C(h,{initialRoute:window.location.pathname},e),e=C(i,{initialPathname:window.location.pathname},e),E(e)}else g(document.body,`${e} Try refreshing the page.`),console.error(`[rari] Hydration skipped: failed to load RSC payload`);return}if(f)try{let e=window.location.pathname+window.location.search,t=(import.meta.env.DEV?import.meta.env.RARI_SERVER_URL!=null&&import.meta.env.RARI_SERVER_URL!==``?import.meta.env.RARI_SERVER_URL:`http://localhost:${import.meta.env.VITE_RSC_PORT!=null&&import.meta.env.VITE_RSC_PORT!==``?import.meta.env.VITE_RSC_PORT:`3000`}`:window.location.origin)+e,n=await fetch(t,{headers:{Accept:`text/x-component`},cache:`no-store`});if(!n.ok&&n.status!==404)throw Error(`Failed to fetch RSC data: ${n.status}`);if(!n.body)throw Error(`RSC response has no body`);s=await u(Promise.resolve(n))}catch(e){if(e instanceof Promise)throw e;console.error(`[rari] Failed to fetch initial RSC data:`,e),s=null}else if(r&&o)try{s=await M(o,{streaming:!0})}catch(e){console.error(`[rari] Failed to parse embedded RSC payload:`,e),console.error(`[rari] Error stack:`,t(e)?.stack??`no stack`),s=null}else if(p)try{let t=new ReadableStream({start(t){let n=n=>{let r=e(n,O);r&&t.enqueue(new TextEncoder().encode(`${r.rscRow}\n`))},r=()=>{t.close(),window.removeEventListener(`rari:html-stream-row`,n),window.removeEventListener(`rari:stream-complete`,r)};window.addEventListener(`rari:html-stream-row`,n),window.addEventListener(`rari:stream-complete`,r);let i=a();if(i.streaming?.bufferedRows){let e=[...i.streaming.bufferedRows];i.streaming.bufferedRows=[];for(let n of e)t.enqueue(new TextEncoder().encode(`${n}\n`))}i.streaming?.complete&&r()}});s=await d(t)}catch(e){console.error(`[rari] Failed to process streaming RSC payload:`,e),s=null}if(s==null)throw Error(`No RSC data available for hydration`);let _=l.createElement(m,{initialPayload:{element:s}});_=C(h,{initialRoute:window.location.pathname},_),_=C(i,{initialPathname:window.location.pathname},_),E(_)}catch(e){console.error(`[rari] Error rendering app:`,e)}}function P(){let e=import.meta.hot;if(!e)return{};let t=e.data;return r(t)?{hasRendered:t.hasRendered===!0}:{}}function F(){let e=import.meta.hot;if(!e)return;let t=e.data;r(t)&&(t.hasRendered=!0)}(!import.meta.hot||P().hasRendered!==!0)&&(N().catch(e=>{console.error(`[rari] Fatal error:`,e)}),F());export{N as renderApp};
@@ -1,33 +1,27 @@
1
- import { FlightRouterState, SegmentPath, pathnameFromSegmentPath } from "./flight-router-state.mjs";
1
+ import { SegmentPath } from "./flight-router-state.mjs";
2
2
  import { ReactNode } from "react";
3
3
  //#region src/runtime/flight/route-cache.d.ts
4
- interface CacheNode {
4
+ export interface CacheNode {
5
5
  rsc: ReactNode;
6
6
  slots: Record<string, CacheNode> | null;
7
7
  }
8
- interface FlightRouteCacheEntry {
8
+ export interface FlightRouteCacheEntry {
9
9
  pathname: string;
10
10
  search: string;
11
11
  segmentPath: SegmentPath;
12
12
  node: CacheNode;
13
13
  }
14
- declare class FlightRouteCache {
14
+ export declare class FlightRouteCache {
15
15
  private root;
16
- private renderedSearch;
17
16
  get(pathname: string, search: string): FlightRouteCacheEntry | undefined;
18
17
  getElement(pathname: string, search: string): ReactNode | undefined;
19
18
  set(pathname: string, search: string, element: ReactNode): void;
20
19
  invalidate(pathname: string, search?: string): void;
21
- invalidateSegmentPath(segmentPath: SegmentPath): void;
22
- getRenderedSearch(): string;
23
- getRouterTree(pathname: string): FlightRouterState;
24
20
  clear(): void;
25
21
  }
26
- declare const flightRouteCache: FlightRouteCache;
27
- declare function currentRouteLocation(): {
22
+ export declare const flightRouteCache: FlightRouteCache;
23
+ export declare function currentRouteLocation(): {
28
24
  pathname: string;
29
25
  search: string;
30
26
  };
31
- declare function currentSegmentPath(): SegmentPath;
32
- //#endregion
33
- export { CacheNode, FlightRouteCache, FlightRouteCacheEntry, currentRouteLocation, currentSegmentPath, flightRouteCache, pathnameFromSegmentPath };
27
+ //#endregion
@@ -1 +1 @@
1
- import{buildFlightRouterState as e,pathnameFromSegmentPath as t,segmentPathFromPathname as n}from"./flight-router-state.mjs";function r(e=null){return{rsc:e,slots:null}}function i(e,t){return e.slots??={},e.slots[t]??=r(),e.slots[t]}function a(e,t){let n=e;for(let e of t)n=i(n,e);return n}function o(e,t){if(t.length===0){e.rsc=null,e.slots=null;return}let n=e;for(let e=0;e<t.length-1;e+=1){let r=t[e];if(!n.slots?.[r])return;n=n.slots[r]}let r=t[t.length-1];if(!n.slots?.[r])return;let i=n.slots[r];i.rsc=null,i.slots=null,delete n.slots[r],Object.keys(n.slots).length===0&&(n.slots=null)}var s=class{root=r();renderedSearch=``;get(e,t){let r=n(e),i=a(this.root,r);if(i.rsc!=null)return{pathname:e,search:t,segmentPath:r,node:i}}getElement(e,t){return this.get(e,t)?.node.rsc}set(e,t,r){let i=n(e),o=a(this.root,i);o.rsc=r,this.renderedSearch=t}invalidate(e,t=``){o(this.root,n(e))}invalidateSegmentPath(e){o(this.root,e)}getRenderedSearch(){return this.renderedSearch}getRouterTree(t){return e(t)}clear(){this.root=r(),this.renderedSearch=``}};const c=new s;function l(){return typeof window>`u`?{pathname:`/`,search:``}:{pathname:window.location.pathname,search:window.location.search}}function u(){let{pathname:e}=l();return n(e)}export{s as FlightRouteCache,l as currentRouteLocation,u as currentSegmentPath,c as flightRouteCache,t as pathnameFromSegmentPath};
1
+ import{segmentPathFromPathname as e}from"./flight-router-state.mjs";function t(e=null){return{rsc:e,slots:null}}function n(e,n){return e.slots??={},e.slots[n]??=t(),e.slots[n]}function r(e,t){let r=e;for(let e of t)r=n(r,e);return r}function i(e,t){if(t.length===0){e.rsc=null,e.slots=null;return}let n=e;for(let e=0;e<t.length-1;e+=1){let r=t[e];if(!n.slots?.[r])return;n=n.slots[r]}let r=t[t.length-1];if(!n.slots?.[r])return;let i=n.slots[r];i.rsc=null,i.slots=null,delete n.slots[r],Object.keys(n.slots).length===0&&(n.slots=null)}var a=class{root=t();get(t,n){let i=e(t),a=r(this.root,i);if(a.rsc!=null)return{pathname:t,search:n,segmentPath:i,node:a}}getElement(e,t){return this.get(e,t)?.node.rsc}set(t,n,i){let a=e(t),o=r(this.root,a);o.rsc=i}invalidate(t,n=``){i(this.root,e(t))}clear(){this.root=t()}};const o=new a;function s(){return typeof window>`u`?{pathname:`/`,search:``}:{pathname:window.location.pathname,search:window.location.search}}export{a as FlightRouteCache,s as currentRouteLocation,o as flightRouteCache};
@@ -1,11 +1,10 @@
1
1
  //#region src/runtime/flight/router-state.d.ts
2
- type FlightRouterState = readonly [segment: string, parallelRoutes: {
2
+ export type FlightRouterState = readonly [segment: string, parallelRoutes: {
3
3
  readonly children?: FlightRouterState;
4
4
  }];
5
- type SegmentPath = readonly string[];
6
- declare function buildFlightRouterState(pathname: string): FlightRouterState;
7
- declare function segmentPathFromRouterState(tree: FlightRouterState): SegmentPath;
8
- declare function segmentPathFromPathname(pathname: string): SegmentPath;
9
- declare function pathnameFromSegmentPath(segmentPath: SegmentPath): string;
10
- //#endregion
11
- export { FlightRouterState, SegmentPath, buildFlightRouterState, pathnameFromSegmentPath, segmentPathFromPathname, segmentPathFromRouterState };
5
+ export type SegmentPath = readonly string[];
6
+ export declare function buildFlightRouterState(pathname: string): FlightRouterState;
7
+ export declare function segmentPathFromRouterState(tree: FlightRouterState): SegmentPath;
8
+ export declare function segmentPathFromPathname(pathname: string): SegmentPath;
9
+ export declare function pathnameFromSegmentPath(segmentPath: SegmentPath): string;
10
+ //#endregion
@@ -1,5 +1,4 @@
1
1
  import * as React from "react";
2
2
  //#region src/runtime/flight/merge-refresh.d.ts
3
- declare function mergeFlightRefresh(current: React.ReactNode, refresh: React.ReactNode): React.ReactNode;
4
- //#endregion
5
- export { mergeFlightRefresh };
3
+ export declare function mergeFlightRefresh(current: React.ReactNode, refresh: React.ReactNode): React.ReactNode;
4
+ //#endregion
@@ -1 +1 @@
1
- import{a as e,i as t,s as n}from"../type-guards-CTkEL8zw.mjs";import*as r from"react";function i(e){return r.isValidElement(e)}function a(e){return n(e.type)}function o(e,t){let n=r.Children.toArray(e),i=r.Children.toArray(t);if(n.length===0)return t;if(i.length===0)return e;if(n.length!==i.length)return t;let a=n.map((e,t)=>s(e,i[t]));return a.length===1?a[0]:a}function s(n,s){if(n==null)return s;if(s==null)return n;if(!i(n)||!i(s))return s;if(a(n)&&a(s)){let t=e(n.type)?n.type.$$id:void 0,r=e(s.type)?s.type.$$id:void 0;if(t!=null&&t!==``&&r!=null&&r!==``&&t===r&&(n.key??null)===(s.key??null))return s}if(n.type!==s.type)return s;let c=t(n),l=t(s),u=o(c.children,l.children);if(u===l.children)return s;let d=r.Children.toArray(u);return r.cloneElement(s,l,...d)}export{s as mergeFlightRefresh};
1
+ import{l as e,o as t,s as n}from"../type-guards-BJXKlA6x.mjs";import*as r from"react";function i(e){return r.isValidElement(e)}function a(t){return e(t.type)}function o(e,t){let n=r.Children.toArray(e),i=r.Children.toArray(t);if(n.length===0)return t;if(i.length===0)return e;if(n.length!==i.length)return t;let a=n.map((e,t)=>s(e,i[t]));return a.length===1?a[0]:a}function s(e,s){if(e==null)return s;if(s==null)return e;if(!i(e)||!i(s))return s;if(a(e)&&a(s)){let t=n(e.type)?e.type.$$id:void 0,r=n(s.type)?s.type.$$id:void 0;if(t!=null&&t!==``&&r!=null&&r!==``&&t===r&&(e.key??null)===(s.key??null))return s}if(e.type!==s.type)return s;let c=t(e),l=t(s),u=o(c.children,l.children);if(u===l.children)return s;let d=r.Children.toArray(u);return r.cloneElement(s,l,...d)}export{s as mergeFlightRefresh};
@@ -1,8 +1,9 @@
1
- import "../types-_vPM8QuJ.mjs";
1
+ import "../types-Q-x_0kVB.mjs";
2
2
  //#region src/runtime/shared/get-client-component.d.ts
3
3
  declare function requireClientComponent(id: string): any;
4
4
  //#endregion
5
5
  //#region src/runtime/rsc/client-runtime.d.ts
6
6
  declare global {
7
7
  var __rari_rsc_require__: typeof requireClientComponent | undefined;
8
- }
8
+ }
9
+ //#endregion