rari 0.9.1 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +3 -3
- package/dist/client.d.mts +1 -1
- package/dist/client.mjs +1 -1
- package/dist/image/index.mjs +1 -1
- package/dist/{index-Dtbijzle.d.mts → index-DuCX6G_W.d.mts} +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +1 -1
- package/dist/mdx.mjs +1 -1
- package/dist/preload-components-TyCxVZPF.mjs +1 -0
- package/dist/proxy/RariRequest.d.mts +1 -1
- package/dist/proxy/RariResponse.d.mts +1 -1
- package/dist/{railway-C_RKUxHY.mjs → railway-BlR0qYfX.mjs} +1 -1
- package/dist/regex-constants-BM4Vd-_c.mjs +1 -0
- package/dist/{render-D25Vkzyw.mjs → render-Cn2qdfZI.mjs} +1 -1
- package/dist/routes-DEvXO96u.mjs +1 -0
- package/dist/runtime/AppRouterProvider.mjs +4 -4
- package/dist/runtime/entry-client.mjs +2 -2
- package/dist/runtime/react-server-dom-rari-client.mjs +2 -2
- package/dist/runtime/rsc-client-runtime.mjs +2 -2
- package/dist/server-build-emJwCUjS.mjs +177 -0
- package/dist/sitemap-generator-Di-7pmiz.mjs +4 -0
- package/dist/utils-BTyXoHUx-Cp3JPZPF.mjs +1 -0
- package/dist/vite-BTJjUXqs.mjs +79 -0
- package/dist/vite.d.mts +3 -3
- package/dist/vite.mjs +1 -1
- package/package.json +8 -8
- package/dist/preload-components-CwqehMyC.mjs +0 -1
- package/dist/routes-DbsqVAaM.mjs +0 -1
- package/dist/server-build-DM-rQz-k.mjs +0 -177
- package/dist/sitemap-generator-D3T5zkl3.mjs +0 -4
- package/dist/utils-CvELqhML-BOdGyCyF.mjs +0 -1
- package/dist/vite-C4gs8tq5.mjs +0 -79
- /package/dist/{constants-CmqZuM5B.mjs → constants-DZAg-dr0.mjs} +0 -0
- /package/dist/{get-client-component-CR5zDUvd.mjs → get-client-component-CpMI09nb.mjs} +0 -0
- /package/dist/{robots-generator-DlnLLn5V.mjs → robots-generator-Bo5MHa-v.mjs} +0 -0
- /package/dist/{server-config-B0xinLcw.d.mts → server-config-BLpfK714.d.mts} +0 -0
- /package/dist/{types-FjFDidgJ.d.mts → types-BQ-op_Tc.d.mts} +0 -0
package/dist/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{getBinaryPath as e,getInstallationInstructions as t}from"./platform.mjs";import{existsSync as n,readFileSync as r}from"node:fs";import{resolve as i}from"node:path";import a from"node:process";import{spawn as o}from"node:child_process";import{styleText as s}from"node:util";function c(e){console.warn(`${s(`blue`,`info`)} ${e}`)}function l(e){console.warn(`${s(`green`,`✓`)} ${e}`)}function u(e){console.error(`${s(`red`,`✗`)} ${e}`)}function d(e){console.warn(`${s(`yellow`,`⚠`)} ${e}`)}
|
|
3
|
-
`)){let t=e.trim();if(!t||t.startsWith(`#`))continue;let n=t.match(
|
|
2
|
+
import{getBinaryPath as e,getInstallationInstructions as t}from"./platform.mjs";import{existsSync as n,readFileSync as r}from"node:fs";import{resolve as i}from"node:path";import a from"node:process";import{spawn as o}from"node:child_process";import{styleText as s}from"node:util";function c(e){console.warn(`${s(`blue`,`info`)} ${e}`)}function l(e){console.warn(`${s(`green`,`✓`)} ${e}`)}function u(e){console.error(`${s(`red`,`✗`)} ${e}`)}function d(e){console.warn(`${s(`yellow`,`⚠`)} ${e}`)}const f=/^([^=]+)=(.*)$/;function p(){let e=i(a.cwd(),`.env`);if(n(e)){let t=r(e,`utf-8`);for(let e of t.split(`
|
|
3
|
+
`)){let t=e.trim();if(!t||t.startsWith(`#`))continue;let n=t.match(f);if(n){let[,e,t]=n,r=e.trim(),i=t.trim();(i.startsWith(`"`)&&i.endsWith(`"`)||i.startsWith(`'`)&&i.endsWith(`'`))&&(i=i.slice(1,-1)),a.env[r]||(a.env[r]=i)}}}}p();const[,,m,...h]=a.argv;function g(){let e=a.cwd(),t=i(`/`),o=0;for(;e!==t&&o<20;){if(o++,n(i(e,`pnpm-lock.yaml`)))return`pnpm`;if(n(i(e,`yarn.lock`)))return`yarn`;if(n(i(e,`bun.lockb`)))return`bun`;if(n(i(e,`package-lock.json`)))return`npm`;try{let t=i(e,`package.json`);if(n(t)){let e=JSON.parse(r(t,`utf-8`));if(e.packageManager?.startsWith(`pnpm`))return`pnpm`;if(e.packageManager?.startsWith(`yarn`))return`yarn`;if(e.packageManager?.startsWith(`bun`))return`bun`;if(e.packageManager?.startsWith(`npm`))return`npm`}}catch{}let t=i(e,`..`);if(t===e)break;e=t}return`npm`}function _(){let e=g(),t=a.platform===`win32`;switch(e){case`bun`:return t?`bun.cmd`:`bun`;case`pnpm`:return t?`pnpm.cmd`:`pnpm`;case`yarn`:return t?`yarn.cmd`:`yarn`;default:return t?`npx.cmd`:`npx`}}function v(e,t,n={}){if(e===`npx`){let e=_();if(e.includes(`bun`))return o(e,[`x`,...t],n);if(e.includes(`pnpm`))return o(e,[`exec`,...t],n);if(e.includes(`yarn`))return o(e,[`dlx`,...t],n)}return a.platform===`win32`&&e===`npx`?o(`npx.cmd`,t,n):o(e,t,n)}function y(e){if(e instanceof Error)return e.message;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function b(){return!!(a.env.RAILWAY_ENVIRONMENT||a.env.RAILWAY_PROJECT_ID||a.env.RAILWAY_SERVICE_ID)}function x(){return!!(a.env.RENDER||a.env.RENDER_SERVICE_ID||a.env.RENDER_SERVICE_NAME)}function S(){return b()||x()}function C(){return b()?`Railway`:x()?`Render`:`local`}function w(){return{port:a.env.PORT||a.env.RSC_PORT||`3000`,mode:a.env.NODE_ENV||`production`,host:S()?`0.0.0.0`:`127.0.0.1`}}async function T(){let{existsSync:e,rmSync:t}=await import(`node:fs`),{resolve:n}=await import(`node:path`),r=n(a.cwd(),`dist`);e(r)&&(c(`Cleaning dist folder...`),t(r,{recursive:!0,force:!0})),c(`Type checking...`);let i=v(`npx`,[`tsgo`],{stdio:`inherit`,cwd:a.cwd()});await new Promise((e,t)=>{i.on(`exit`,n=>{n===0?(l(`Type check passed`),e()):(u(`Type check failed with code ${n}`),t(Error(`Type check failed with code ${n}`)))}),i.on(`error`,t)}),c(`Building for production...`);let o=v(`npx`,[`vite`,`build`],{stdio:`inherit`,cwd:a.cwd()});await new Promise((e,t)=>{o.on(`exit`,n=>{n===0?(l(`Build complete`),e()):(u(`Build failed with code ${n}`),t(Error(`Build failed with code ${n}`)))}),o.on(`error`,t)}),await E()}async function E(){if(n(i(a.cwd(),`dist`,`server`,`image.json`))&&n(i(a.cwd(),`public`)))try{let t=o(e(),[`optimize-images`],{stdio:`inherit`,cwd:a.cwd(),shell:!1});await new Promise(e=>{t.on(`exit`,t=>{t===0||d(`Image pre-optimization exited with code ${t}`),e()}),t.on(`error`,t=>{d(`Image pre-optimization error: ${y(t)}`),e()})})}catch(e){d(`Could not pre-optimize images: ${y(e)}`)}}async function D(){let{existsSync:e}=await import(`node:fs`),{resolve:t}=await import(`node:path`);if(!e(t(a.cwd(),`dist`))){c(`First run detected - building project...`);let e=v(`npx`,[`vite`,`build`,`--mode`,`development`],{stdio:`inherit`,cwd:a.cwd()});await new Promise((t,n)=>{e.on(`exit`,e=>{e===0?(l(`Initial build complete`),t()):(u(`Build failed with code ${e}`),n(Error(`Build failed with code ${e}`)))}),e.on(`error`,n)})}c(`Starting Vite dev server...`);let n=v(`npx`,[`vite`],{stdio:`inherit`,cwd:a.cwd()}),r=()=>{c(`Shutting down dev server...`),n.kill(`SIGTERM`)};return a.on(`SIGINT`,r),a.on(`SIGTERM`,r),n.on(`error`,e=>{u(`Failed to start Vite: ${e.message}`),a.exit(1)}),n.on(`exit`,e=>{e!==0&&e!==null&&(u(`Vite exited with code ${e}`),a.exit(e))}),new Promise(()=>{})}async function O(){let n;try{n=e()}catch{u(`Failed to obtain rari binary`),u(t()),a.exit(1)}let{port:r,mode:i,host:s}=w();if(S()){let e=C();c(`${e} environment detected`),c(`Starting rari server for ${e} deployment...`),c(`Mode: ${i}, Host: ${s}, Port: ${r}`),c(`using binary: ${n}`)}let d=o(n,[`--mode`,i,`--port`,r,`--host`,s],{stdio:`inherit`,cwd:a.cwd(),env:{...a.env,RUST_LOG:a.env.RUST_LOG||`error`}}),f=()=>{c(`shutting down...`),d.kill(`SIGTERM`)};return a.on(`SIGINT`,f),a.on(`SIGTERM`,f),d.on(`error`,e=>{u(`Failed to start rari server: ${e.message}`),e.message.includes(`ENOENT`)&&u(`Binary not found. Please ensure rari is properly installed.`),a.exit(1)}),d.on(`exit`,(e,t)=>{t?c(`server stopped by signal ${t}`):e===0?l(`server stopped successfully`):(u(`server exited with code ${e}`),a.exit(e||1))}),new Promise(()=>{})}async function k(){c(`Setting up Railway deployment...`),S()&&(u(`Already running in ${C()} environment. Use "rari start" instead.`),a.exit(1));let{createRailwayDeployment:e}=await import(`./railway-BlR0qYfX.mjs`);await e()}async function A(){c(`Setting up Render deployment...`),S()&&(u(`Already running in ${C()} environment. Use "rari start" instead.`),a.exit(1));let{createRenderDeployment:e}=await import(`./render-Cn2qdfZI.mjs`);await e()}async function j(){switch(m){case void 0:case`help`:case`--help`:case`-h`:console.warn(`${s(`bold`,`rari CLI`)}
|
|
4
4
|
|
|
5
5
|
${s(`bold`,`Usage:`)}
|
|
6
6
|
${s(`cyan`,`rari dev`)} Start the development server with Vite
|
|
@@ -63,4 +63,4 @@ ${s(`bold`,`Notes:`)}
|
|
|
63
63
|
- Platform deployment is automatically detected and configured
|
|
64
64
|
- Use Ctrl+C to stop the server gracefully
|
|
65
65
|
|
|
66
|
-
`);break;case`dev`:await
|
|
66
|
+
`);break;case`dev`:await D();break;case`build`:await T();break;case`start`:await O();break;case`deploy`:h[0]===`railway`?await k():h[0]===`render`?await A():(u(`Unknown deployment target. Available: railway, render`),a.exit(1));break;default:console.error(`${s(`bold`,`Unknown command:`)} ${m}`),console.warn(`Run "${s(`cyan`,`rari help`)}" for available commands`),a.exit(1)}}a.argv[1]&&(import.meta.url===`file://${a.argv[1]}`||import.meta.url.endsWith(`/dist/cli.mjs`)&&a.argv[1].includes(`cli.mjs`))&&j().catch(e=>{u(`CLI Error: ${e.message}`),console.error(e),a.exit(1)});export{};
|
package/dist/client.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as MetadataResult, E as NotFoundEntry, F as extractMetadata, I as extractServerProps, L as extractServerPropsWithCache, M as StaticParamsResult, N as clearPropsCache, O as RouteSegment, P as clearPropsCacheForComponent, R as extractStaticParams, S as LayoutEntry, _ as AppRouteMatch, a as DefaultError, b as GenerateMetadata, c as HttpRuntimeClient, d as RuntimeClient, f as createErrorBoundary, g as AppRouteManifest, h as AppRouteEntry, i as ServerSpamBlockerConfig, j as ServerSidePropsResult, k as RouteSegmentType, l as LoadingSpinner, m as createLoadingBoundary, n as ServerConfig, o as DefaultLoading, p as createHttpRuntimeClient, r as ServerRateLimitConfig, s as ErrorBoundary, t as ServerCSPConfig, u as NotFound, v as ErrorEntry, w as LoadingEntry, x as GenerateStaticParams, y as ErrorProps, z as hasServerSideDataFetching } from "./server-config-
|
|
1
|
+
import { A as MetadataResult, E as NotFoundEntry, F as extractMetadata, I as extractServerProps, L as extractServerPropsWithCache, M as StaticParamsResult, N as clearPropsCache, O as RouteSegment, P as clearPropsCacheForComponent, R as extractStaticParams, S as LayoutEntry, _ as AppRouteMatch, a as DefaultError, b as GenerateMetadata, c as HttpRuntimeClient, d as RuntimeClient, f as createErrorBoundary, g as AppRouteManifest, h as AppRouteEntry, i as ServerSpamBlockerConfig, j as ServerSidePropsResult, k as RouteSegmentType, l as LoadingSpinner, m as createLoadingBoundary, n as ServerConfig, o as DefaultLoading, p as createHttpRuntimeClient, r as ServerRateLimitConfig, s as ErrorBoundary, t as ServerCSPConfig, u as NotFound, v as ErrorEntry, w as LoadingEntry, x as GenerateStaticParams, y as ErrorProps, z as hasServerSideDataFetching } from "./server-config-BLpfK714.mjs";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { Component, ErrorInfo, ReactNode } from "react";
|
|
4
4
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
package/dist/client.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as e,c as t,d as n,f as r,g as i,h as a,i as o,l as s,m as c,n as l,o as u,p as d,r as f,s as p,t as m,u as h}from"./runtime-client-Bg4V1Ksp.mjs";import{Component as g,useEffect as _,useRef as v,useState as y}from"react";import{Fragment as b,jsx as x,jsxs as S}from"react/jsx-runtime";function C(e,t,n={}){let r=null,i=0,a=0,o=null,s=null,{leading:c=!1,trailing:l=!0,maxWait:u}=n;function d(t){let n=o,r=s;return o=null,s=null,a=t,e.apply(r,n)}function f(e){let n=e-i,r=e-a;return i===0||n>=t||n<0||u!==void 0&&r>=u}function p(){let e=Date.now();if(f(e))return h(e);let n=e-i,o=e-a,s=t-n,c=u===void 0?1/0:u-o,l=Math.min(s,c);r=setTimeout(p,l)}function m(e){return a=e,r=setTimeout(p,t),c?d(e):void 0}function h(e){if(r=null,l&&o)return d(e);o=null,s=null}function g(){r!==null&&clearTimeout(r),a=0,o=null,i=0,s=null,r=null}function _(){return r===null?void 0:h(Date.now())}function v(){return r!==null}function y(...e){let n=Date.now(),a=f(n);if(o=e,s=this,i=n,a){if(r===null)return m(i);if(u!==void 0)return r=setTimeout(p,t),d(i)}r===null&&(r=setTimeout(p,t))}return y.cancel=g,y.flush=_,y.pending=v,y}function w(e,t){if(e instanceof Error&&e.name===`AbortError`)return{type:`abort`,message:`Navigation was cancelled`,originalError:e,url:t,timestamp:Date.now(),retryable:!1};if(e instanceof Error&&e.message.includes(`timeout`))return{type:`timeout`,message:`Navigation request timed out`,originalError:e,url:t,timestamp:Date.now(),retryable:!0};if(e instanceof Error&&`status`in e){let n=e.status;return n===404?{type:`not-found`,message:`Page not found`,originalError:e,statusCode:n,url:t,timestamp:Date.now(),retryable:!1}:n>=500?{type:`server-error`,message:`Server error: ${n}`,originalError:e,statusCode:n,url:t,timestamp:Date.now(),retryable:!0}:{type:`fetch-error`,message:`HTTP error: ${n}`,originalError:e,statusCode:n,url:t,timestamp:Date.now(),retryable:n>=500}}return e instanceof TypeError&&e.message.includes(`fetch`)?{type:`network-error`,message:`Network error - check your connection`,originalError:e,url:t,timestamp:Date.now(),retryable:!0}:e instanceof SyntaxError||e instanceof Error&&e.message.includes(`parse`)?{type:`parse-error`,message:`Failed to parse server response`,originalError:e instanceof Error?e:void 0,url:t,timestamp:Date.now(),retryable:!1}:{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}}var T=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=w(e,t);return this.options.onError(n),console.error(`[rari] Navigation:`,n.type,n.message,{url:n.url,statusCode:n.statusCode,retryable:n.retryable}),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`rari:navigation-error`,{detail:n})),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 E(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 D(e,t){try{return new URL(e,t||window.location.origin).origin!==(t||window.location.origin)}catch{return!1}}function O(e){try{let t=new URL(e,window.location.origin);return t.pathname+t.hash}catch{return e}}function k({error:e,onRetry:t,onReload:n,onDismiss:r,retryCount:i=0,maxRetries:a=3}){let o=e.retryable&&i<a;return x(`div`,{style:{position:`fixed`,top:0,left:0,right:0,bottom:0,background:`rgba(0, 0, 0, 0.5)`,display:`flex`,alignItems:`center`,justifyContent:`center`,zIndex:1e4,padding:`20px`},onClick:e=>{e.target===e.currentTarget&&r&&r()},children:S(`div`,{style:{background:`white`,borderRadius:`8px`,padding:`24px`,maxWidth:`500px`,width:`100%`,boxShadow:`0 4px 12px rgba(0, 0, 0, 0.15)`},onClick:e=>e.stopPropagation(),children:[S(`div`,{style:{display:`flex`,alignItems:`center`,gap:`12px`,marginBottom:`16px`},children:[x(`span`,{style:{fontSize:`32px`},children:(()=>{switch(e.type){case`timeout`:return`⏱️`;case`network-error`:return`📡`;case`not-found`:return`🔍`;case`server-error`:return`⚠️`;case`parse-error`:return`📄`;case`abort`:return`🚫`;default:return`❌`}})()}),x(`h2`,{style:{margin:0,fontSize:`20px`,fontWeight:`600`,color:`#1f2937`},children:`Navigation Error`})]}),x(`p`,{style:{margin:`0 0 16px 0`,fontSize:`15px`,lineHeight:`1.5`,color:`#4b5563`},children:(()=>{switch(e.type){case`timeout`:return`The page took too long to load. Please try again.`;case`network-error`:return`Unable to connect to the server. Please check your internet connection.`;case`not-found`:return`The page you're looking for doesn't exist.`;case`server-error`:return`The server encountered an error. Please try again in a moment.`;case`parse-error`:return`Unable to load the page content. Please try reloading.`;case`abort`:return`Navigation was cancelled.`;default:return e.message||`An unexpected error occurred.`}})()}),e.url&&S(`details`,{style:{marginBottom:`16px`,fontSize:`13px`,color:`#6b7280`},children:[x(`summary`,{style:{cursor:`pointer`,userSelect:`none`,marginBottom:`8px`},children:`Technical details`}),S(`div`,{style:{padding:`12px`,background:`#f9fafb`,borderRadius:`4px`,fontFamily:`monospace`,fontSize:`12px`,wordBreak:`break-all`},children:[S(`div`,{style:{marginBottom:`4px`},children:[x(`strong`,{children:`URL:`}),` `,e.url]}),e.statusCode&&S(`div`,{style:{marginBottom:`4px`},children:[x(`strong`,{children:`Status:`}),` `,e.statusCode]}),S(`div`,{style:{marginBottom:`4px`},children:[x(`strong`,{children:`Type:`}),` `,e.type]}),e.originalError&&S(`div`,{children:[x(`strong`,{children:`Error:`}),` `,e.originalError.message]})]})]}),o&&i>0&&S(`div`,{style:{marginBottom:`16px`,padding:`8px 12px`,background:`#fef3c7`,border:`1px solid #fbbf24`,borderRadius:`4px`,fontSize:`13px`,color:`#92400e`},children:[`Retry attempt`,` `,i,` `,`of`,` `,a]}),S(`div`,{style:{display:`flex`,gap:`8px`,flexWrap:`wrap`},children:[o&&t&&x(`button`,{onClick:t,type:`button`,style:{flex:1,minWidth:`120px`,padding:`10px 16px`,background:`#3b82f6`,color:`white`,border:`none`,borderRadius:`6px`,fontSize:`14px`,fontWeight:`500`,cursor:`pointer`,transition:`background 0.2s`},onMouseEnter:e=>{e.currentTarget.style.background=`#2563eb`},onMouseLeave:e=>{e.currentTarget.style.background=`#3b82f6`},children:`Try Again`}),n&&x(`button`,{onClick:n,type:`button`,style:{flex:1,minWidth:`120px`,padding:`10px 16px`,background:`#6b7280`,color:`white`,border:`none`,borderRadius:`6px`,fontSize:`14px`,fontWeight:`500`,cursor:`pointer`,transition:`background 0.2s`},onMouseEnter:e=>{e.currentTarget.style.background=`#4b5563`},onMouseLeave:e=>{e.currentTarget.style.background=`#6b7280`},children:`Reload Page`}),r&&x(`button`,{onClick:r,type:`button`,style:{flex:1,minWidth:`120px`,padding:`10px 16px`,background:`transparent`,color:`#6b7280`,border:`1px solid #d1d5db`,borderRadius:`6px`,fontSize:`14px`,fontWeight:`500`,cursor:`pointer`,transition:`all 0.2s`},onMouseEnter:e=>{e.currentTarget.style.background=`#f9fafb`,e.currentTarget.style.borderColor=`#9ca3af`},onMouseLeave:e=>{e.currentTarget.style.background=`transparent`,e.currentTarget.style.borderColor=`#d1d5db`},children:`Dismiss`})]}),x(`p`,{style:{marginTop:`16px`,marginBottom:0,fontSize:`12px`,color:`#9ca3af`,textAlign:`center`},children:`Your current page is still available below this message`})]})})}const A=new class{cache=new Map;pendingRequests=new Map;async get(e){let t=this.cache.get(e);if(t)return t;let n=this.pendingRequests.get(e);if(n)return n;let r=this.fetchRouteInfo(e);this.pendingRequests.set(e,r);try{let t=await r;return this.cache.set(e,t),t}finally{this.pendingRequests.delete(e)}}async fetchRouteInfo(e){let t={path:e},n=await fetch(`/_rari/route-info`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json();throw Error(e.error||`Failed to fetch route info`)}return n.json()}clear(){this.cache.clear(),this.pendingRequests.clear()}invalidate(e){this.cache.delete(e)}};if(typeof window<`u`){let e=window[`~rari`]||{};window[`~rari`]||(window[`~rari`]=e),e.routeInfoCache=A}var j=class{stateHistory;routeAccessOrder;maxHistorySize;scrollableSelector;constructor(e={}){this.stateHistory=new Map,this.routeAccessOrder=[],this.maxHistorySize=e.maxHistorySize||50,this.scrollableSelector=e.scrollableSelector||`[data-scrollable], .scrollable, [style*="overflow"]`}captureState(e){let t={scrollPositions:this.captureScrollPositions(),formData:this.captureFormData(),focusedElement:this.captureFocusedElement()};return this.storeState(e,t),t}captureScrollPositions(){let e=new Map;try{e.set(`window`,{x:window.scrollX,y:window.scrollY,element:`window`}),document.querySelectorAll(this.scrollableSelector).forEach((t,n)=>{if(t instanceof HTMLElement){let r=t.id||`scrollable-${n}`;(t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth)&&e.set(r,{x:t.scrollLeft,y:t.scrollTop,element:r})}})}catch{}return e}captureFormData(){let e=new Map;try{document.querySelectorAll(`form`).forEach((t,n)=>{let r=t.id||t.name||`form-${n}`,i=new FormData(t);i.entries().next().done||e.set(r,i)})}catch{}return e}captureFocusedElement(){try{let e=document.activeElement;if(e&&e!==document.body){if(e.id)return`#${e.id}`;if((e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&e.name)return`[name="${e.name}"]`}}catch{}return null}storeState(e,t){let n=this.routeAccessOrder.indexOf(e);for(n!==-1&&this.routeAccessOrder.splice(n,1),this.routeAccessOrder.push(e),this.stateHistory.set(e,t);this.routeAccessOrder.length>this.maxHistorySize;){let e=this.routeAccessOrder.shift();e&&this.stateHistory.delete(e)}}getHistorySize(){return this.stateHistory.size}hasState(e){return this.stateHistory.has(e)}getState(e){return this.stateHistory.get(e)}clearAll(){this.stateHistory.clear(),this.routeAccessOrder=[]}clearState(e){this.stateHistory.delete(e);let t=this.routeAccessOrder.indexOf(e);t!==-1&&this.routeAccessOrder.splice(t,1)}restoreState(e){let t=this.stateHistory.get(e);if(!t)return!1;let n=!0;return this.restoreScrollPositions(t.scrollPositions)||(n=!1),this.restoreFormData(t.formData)||(n=!1),t.focusedElement&&this.restoreFocus(t.focusedElement),n}restoreScrollPositions(e){let t=!0;try{e.forEach((e,n)=>{try{if(n===`window`)window.scrollTo(e.x,e.y);else{let r=document.getElementById(n)||document.querySelector(`[data-scrollable-id="${n}"]`);r instanceof HTMLElement?(r.scrollLeft=e.x,r.scrollTop=e.y):t=!1}}catch{t=!1}})}catch(e){console.error(`[rari] Router: Failed to restore scroll positions:`,e),t=!1}return t}restoreFormData(e){let t=!0;try{e.forEach((e,n)=>{try{let r=document.getElementById(n)||document.querySelector(`form[name="${n}"]`)||document.querySelectorAll(`form`)[Number.parseInt(n.replace(`form-`,``),10)];r instanceof HTMLFormElement?e.forEach((e,n)=>{try{let t=r.elements.namedItem(n);t instanceof RadioNodeList?t.forEach(t=>{t instanceof HTMLInputElement&&(t.type===`radio`||t.type===`checkbox`?t.checked=t.value===e:t.value=e)}):(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)&&(t instanceof HTMLInputElement&&(t.type===`checkbox`||t.type===`radio`)?t.checked=t.value===e:t.value=e)}catch{t=!1}}):t=!1}catch{t=!1}})}catch(e){console.error(`[rari] Router: Failed to restore form data:`,e),t=!1}return t}restoreFocus(e){try{let t=document.querySelector(e);t instanceof HTMLElement&&requestAnimationFrame(()=>{try{t.focus()}catch{}})}catch{}}};function M(e){e.title&&(document.title=e.title);let t=(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)}};if(e.description&&t(`meta[name="description"]`,{name:`description`,content:e.description}),e.keywords&&e.keywords.length>0&&t(`meta[name="keywords"]`,{name:`keywords`,content:e.keywords.join(`, `)}),e.viewport&&t(`meta[name="viewport"]`,{name:`viewport`,content:e.viewport}),e.canonical){let t=document.querySelector(`link[rel="canonical"]`);t||(t=document.createElement(`link`),t.setAttribute(`rel`,`canonical`),document.head.appendChild(t)),t.setAttribute(`href`,e.canonical)}if(e.robots){let n=[];e.robots.index!==void 0&&n.push(e.robots.index?`index`:`noindex`),e.robots.follow!==void 0&&n.push(e.robots.follow?`follow`:`nofollow`),e.robots.nocache&&n.push(`nocache`),n.length>0&&t(`meta[name="robots"]`,{name:`robots`,content:n.join(`, `)})}if(e.openGraph){let n=e.openGraph;if(n.title&&t(`meta[property="og:title"]`,{property:`og:title`,content:n.title}),n.description&&t(`meta[property="og:description"]`,{property:`og:description`,content:n.description}),n.url&&t(`meta[property="og:url"]`,{property:`og:url`,content:n.url}),n.siteName&&t(`meta[property="og:site_name"]`,{property:`og:site_name`,content:n.siteName}),n.type&&t(`meta[property="og:type"]`,{property:`og:type`,content:n.type}),n.images&&n.images.length>0){document.querySelectorAll(`meta[property="og:image"]`).forEach(e=>e.remove());for(let e of n.images){let t=document.createElement(`meta`);t.setAttribute(`property`,`og:image`),t.setAttribute(`content`,e),document.head.appendChild(t)}}}if(e.twitter){let n=e.twitter;if(n.card&&t(`meta[name="twitter:card"]`,{name:`twitter:card`,content:n.card}),n.site&&t(`meta[name="twitter:site"]`,{name:`twitter:site`,content:n.site}),n.creator&&t(`meta[name="twitter:creator"]`,{name:`twitter:creator`,content:n.creator}),n.title&&t(`meta[name="twitter:title"]`,{name:`twitter:title`,content:n.title}),n.description&&t(`meta[name="twitter:description"]`,{name:`twitter:description`,content:n.description}),n.images&&n.images.length>0){document.querySelectorAll(`meta[name="twitter:image"]`).forEach(e=>e.remove());for(let e of n.images){let t=document.createElement(`meta`);t.setAttribute(`name`,`twitter:image`),t.setAttribute(`content`,e),document.head.appendChild(t)}}}}function N({children:e,initialRoute:t}){let[n,r]=y(()=>({currentRoute:E(t),navigationId:0,error:null})),i=v(null),a=v(!0),o=v(E(t)),s=v(new T({timeout:1e4,maxRetries:3,onError:e=>{console.error(`[rari] Router: Navigation error:`,e)},onRetry:()=>{}})),c=v(new Map),l=v([]),u=v(new j({maxHistorySize:50})),d=()=>`${Date.now()}-${Math.random().toString(36).substring(2,9)}`,f=()=>{i.current&&=(i.current.abort(),null)},p=()=>{for(let[,e]of c.current.entries())e.abortController.abort();c.current.clear()},m=(e,t)=>{c.current.delete(e),a.current&&n.navigationId===t&&r(e=>({...e}))},h=async e=>A.get(e),g=v(null),w=async(e,t={})=>{if(!e||typeof e!=`string`){console.error(`[rari] Router: Invalid navigation target:`,e);return}let[l,_]=e.includes(`#`)?e.split(`#`):[e,``],v=E(l);if(v===o.current&&!t.replace){if(_){let e=document.getElementById(_);e&&(e.scrollIntoView({behavior:`smooth`,block:`start`}),window.history.pushState(window.history.state,``,`${v}#${_}`))}return}let y=c.current.get(v);if(y)return y.promise;let b=await h(v);p(),f();let x=new AbortController;i.current=x;let S=n.navigationId+1,C=(async()=>{let e=o.current;try{t.historyKey||u.current.captureState(e);let n=t.historyKey||d(),i={route:v,navigationId:S,scrollPosition:{x:window.scrollX,y:window.scrollY},timestamp:Date.now(),key:n},l=_?`${v}#${_}`:v;t.replace?window.history.replaceState(i,``,l):window.history.pushState(i,``,l);let f=window.location.origin+v,p=await fetch(f,{headers:{Accept:`text/x-component`},signal:x.signal});if(!p.ok)throw Error(`Failed to fetch: ${p.status}`);let h=new URL(p.url).pathname,y=h===v?v:h;if(h!==v){let e=_?`${h}#${_}`:h;window.history.replaceState({route:h,navigationId:S,scrollPosition:{x:window.scrollX,y:window.scrollY},timestamp:Date.now(),key:t.historyKey||d()},``,e)}if(x.signal.aborted){m(y,S);return}try{let e=p.headers.get(`x-rari-metadata`);if(e){let t=decodeURIComponent(e);M(JSON.parse(t))}}catch{}if(p.headers.get(`x-render-mode`)===`streaming`&&p.body){let n=p.body.getReader(),r=new TextDecoder,i=``;try{for(;;){let{done:e,value:t}=await n.read();if(e)break;if(x.signal.aborted){await n.cancel(),m(y,S);return}i+=r.decode(t,{stream:!0});let a=i.split(`
|
|
1
|
+
import{a as e,c as t,d as n,f as r,g as i,h as a,i as o,l as s,m as c,n as l,o as u,p as d,r as f,s as p,t as m,u as h}from"./runtime-client-Bg4V1Ksp.mjs";import{Component as g,useEffect as _,useRef as v,useState as y}from"react";import{Fragment as b,jsx as x,jsxs as S}from"react/jsx-runtime";function C(e,t,n={}){let r=null,i=0,a=0,o=null,s=null,{leading:c=!1,trailing:l=!0,maxWait:u}=n;function d(t){let n=o,r=s;return o=null,s=null,a=t,e.apply(r,n)}function f(e){let n=e-i,r=e-a;return i===0||n>=t||n<0||u!==void 0&&r>=u}function p(){let e=Date.now();if(f(e))return h(e);let n=e-i,o=e-a,s=t-n,c=u===void 0?1/0:u-o,l=Math.min(s,c);r=setTimeout(p,l)}function m(e){return a=e,r=setTimeout(p,t),c?d(e):void 0}function h(e){if(r=null,l&&o)return d(e);o=null,s=null}function g(){r!==null&&clearTimeout(r),a=0,o=null,i=0,s=null,r=null}function _(){return r===null?void 0:h(Date.now())}function v(){return r!==null}function y(...e){let n=Date.now(),a=f(n);if(o=e,s=this,i=n,a){if(r===null)return m(i);if(u!==void 0)return r=setTimeout(p,t),d(i)}r===null&&(r=setTimeout(p,t))}return y.cancel=g,y.flush=_,y.pending=v,y}function w(e,t){if(e instanceof Error&&e.name===`AbortError`)return{type:`abort`,message:`Navigation was cancelled`,originalError:e,url:t,timestamp:Date.now(),retryable:!1};if(e instanceof Error&&e.message.includes(`timeout`))return{type:`timeout`,message:`Navigation request timed out`,originalError:e,url:t,timestamp:Date.now(),retryable:!0};if(e instanceof Error&&`status`in e){let n=e.status;return n===404?{type:`not-found`,message:`Page not found`,originalError:e,statusCode:n,url:t,timestamp:Date.now(),retryable:!1}:n>=500?{type:`server-error`,message:`Server error: ${n}`,originalError:e,statusCode:n,url:t,timestamp:Date.now(),retryable:!0}:{type:`fetch-error`,message:`HTTP error: ${n}`,originalError:e,statusCode:n,url:t,timestamp:Date.now(),retryable:n>=500}}return e instanceof TypeError&&e.message.includes(`fetch`)?{type:`network-error`,message:`Network error - check your connection`,originalError:e,url:t,timestamp:Date.now(),retryable:!0}:e instanceof SyntaxError||e instanceof Error&&e.message.includes(`parse`)?{type:`parse-error`,message:`Failed to parse server response`,originalError:e instanceof Error?e:void 0,url:t,timestamp:Date.now(),retryable:!1}:{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}}var T=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=w(e,t);return this.options.onError(n),console.error(`[rari] Navigation:`,n.type,n.message,{url:n.url,statusCode:n.statusCode,retryable:n.retryable}),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`rari:navigation-error`,{detail:n})),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 E(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 D(e,t){try{return new URL(e,t||window.location.origin).origin!==(t||window.location.origin)}catch{return!1}}function O(e){try{let t=new URL(e,window.location.origin);return t.pathname+t.hash}catch{return e}}function k({error:e,onRetry:t,onReload:n,onDismiss:r,retryCount:i=0,maxRetries:a=3}){let o=e.retryable&&i<a;return x(`div`,{style:{position:`fixed`,top:0,left:0,right:0,bottom:0,background:`rgba(0, 0, 0, 0.5)`,display:`flex`,alignItems:`center`,justifyContent:`center`,zIndex:1e4,padding:`20px`},onClick:e=>{e.target===e.currentTarget&&r&&r()},children:S(`div`,{style:{background:`white`,borderRadius:`8px`,padding:`24px`,maxWidth:`500px`,width:`100%`,boxShadow:`0 4px 12px rgba(0, 0, 0, 0.15)`},onClick:e=>e.stopPropagation(),children:[S(`div`,{style:{display:`flex`,alignItems:`center`,gap:`12px`,marginBottom:`16px`},children:[x(`span`,{style:{fontSize:`32px`},children:(()=>{switch(e.type){case`timeout`:return`⏱️`;case`network-error`:return`📡`;case`not-found`:return`🔍`;case`server-error`:return`⚠️`;case`parse-error`:return`📄`;case`abort`:return`🚫`;default:return`❌`}})()}),x(`h2`,{style:{margin:0,fontSize:`20px`,fontWeight:`600`,color:`#1f2937`},children:`Navigation Error`})]}),x(`p`,{style:{margin:`0 0 16px 0`,fontSize:`15px`,lineHeight:`1.5`,color:`#4b5563`},children:(()=>{switch(e.type){case`timeout`:return`The page took too long to load. Please try again.`;case`network-error`:return`Unable to connect to the server. Please check your internet connection.`;case`not-found`:return`The page you're looking for doesn't exist.`;case`server-error`:return`The server encountered an error. Please try again in a moment.`;case`parse-error`:return`Unable to load the page content. Please try reloading.`;case`abort`:return`Navigation was cancelled.`;default:return e.message||`An unexpected error occurred.`}})()}),e.url&&S(`details`,{style:{marginBottom:`16px`,fontSize:`13px`,color:`#6b7280`},children:[x(`summary`,{style:{cursor:`pointer`,userSelect:`none`,marginBottom:`8px`},children:`Technical details`}),S(`div`,{style:{padding:`12px`,background:`#f9fafb`,borderRadius:`4px`,fontFamily:`monospace`,fontSize:`12px`,wordBreak:`break-all`},children:[S(`div`,{style:{marginBottom:`4px`},children:[x(`strong`,{children:`URL:`}),` `,e.url]}),e.statusCode&&S(`div`,{style:{marginBottom:`4px`},children:[x(`strong`,{children:`Status:`}),` `,e.statusCode]}),S(`div`,{style:{marginBottom:`4px`},children:[x(`strong`,{children:`Type:`}),` `,e.type]}),e.originalError&&S(`div`,{children:[x(`strong`,{children:`Error:`}),` `,e.originalError.message]})]})]}),o&&i>0&&S(`div`,{style:{marginBottom:`16px`,padding:`8px 12px`,background:`#fef3c7`,border:`1px solid #fbbf24`,borderRadius:`4px`,fontSize:`13px`,color:`#92400e`},children:[`Retry attempt`,` `,i,` `,`of`,` `,a]}),S(`div`,{style:{display:`flex`,gap:`8px`,flexWrap:`wrap`},children:[o&&t&&x(`button`,{onClick:t,type:`button`,style:{flex:1,minWidth:`120px`,padding:`10px 16px`,background:`#3b82f6`,color:`white`,border:`none`,borderRadius:`6px`,fontSize:`14px`,fontWeight:`500`,cursor:`pointer`,transition:`background 0.2s`},onMouseEnter:e=>{e.currentTarget.style.background=`#2563eb`},onMouseLeave:e=>{e.currentTarget.style.background=`#3b82f6`},children:`Try Again`}),n&&x(`button`,{onClick:n,type:`button`,style:{flex:1,minWidth:`120px`,padding:`10px 16px`,background:`#6b7280`,color:`white`,border:`none`,borderRadius:`6px`,fontSize:`14px`,fontWeight:`500`,cursor:`pointer`,transition:`background 0.2s`},onMouseEnter:e=>{e.currentTarget.style.background=`#4b5563`},onMouseLeave:e=>{e.currentTarget.style.background=`#6b7280`},children:`Reload Page`}),r&&x(`button`,{onClick:r,type:`button`,style:{flex:1,minWidth:`120px`,padding:`10px 16px`,background:`transparent`,color:`#6b7280`,border:`1px solid #d1d5db`,borderRadius:`6px`,fontSize:`14px`,fontWeight:`500`,cursor:`pointer`,transition:`all 0.2s`},onMouseEnter:e=>{e.currentTarget.style.background=`#f9fafb`,e.currentTarget.style.borderColor=`#9ca3af`},onMouseLeave:e=>{e.currentTarget.style.background=`transparent`,e.currentTarget.style.borderColor=`#d1d5db`},children:`Dismiss`})]}),x(`p`,{style:{marginTop:`16px`,marginBottom:0,fontSize:`12px`,color:`#9ca3af`,textAlign:`center`},children:`Your current page is still available below this message`})]})})}const A=new class{cache=new Map;pendingRequests=new Map;async get(e){let t=this.cache.get(e);if(t)return t;let n=this.pendingRequests.get(e);if(n)return n;let r=this.fetchRouteInfo(e);this.pendingRequests.set(e,r);try{let t=await r;return this.cache.set(e,t),t}finally{this.pendingRequests.delete(e)}}async fetchRouteInfo(e){let t={path:e},n=await fetch(`/_rari/route-info`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json();throw Error(e.error||`Failed to fetch route info`)}return n.json()}clear(){this.cache.clear(),this.pendingRequests.clear()}invalidate(e){this.cache.delete(e)}};if(typeof window<`u`){let e=window[`~rari`]||{};window[`~rari`]||(window[`~rari`]=e),e.routeInfoCache=A}var j=class{stateHistory;routeAccessOrder;maxHistorySize;scrollableSelector;constructor(e={}){this.stateHistory=new Map,this.routeAccessOrder=[],this.maxHistorySize=e.maxHistorySize||50,this.scrollableSelector=e.scrollableSelector||`[data-scrollable], .scrollable, [style*="overflow"]`}captureState(e){let t={scrollPositions:this.captureScrollPositions(),formData:this.captureFormData(),focusedElement:this.captureFocusedElement()};return this.storeState(e,t),t}captureScrollPositions(){let e=new Map;try{e.set(`window`,{x:window.scrollX,y:window.scrollY,element:`window`}),document.querySelectorAll(this.scrollableSelector).forEach((t,n)=>{if(t instanceof HTMLElement){let r=t.id||`scrollable-${n}`;(t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth)&&e.set(r,{x:t.scrollLeft,y:t.scrollTop,element:r})}})}catch{}return e}captureFormData(){let e=new Map;try{document.querySelectorAll(`form`).forEach((t,n)=>{let r=t.id||t.name||`form-${n}`,i=new FormData(t);i.entries().next().done||e.set(r,i)})}catch{}return e}captureFocusedElement(){try{let e=document.activeElement;if(e&&e!==document.body){if(e.id)return`#${e.id}`;if((e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&e.name)return`[name="${e.name}"]`}}catch{}return null}storeState(e,t){let n=this.routeAccessOrder.indexOf(e);for(n!==-1&&this.routeAccessOrder.splice(n,1),this.routeAccessOrder.push(e),this.stateHistory.set(e,t);this.routeAccessOrder.length>this.maxHistorySize;){let e=this.routeAccessOrder.shift();e&&this.stateHistory.delete(e)}}getHistorySize(){return this.stateHistory.size}hasState(e){return this.stateHistory.has(e)}getState(e){return this.stateHistory.get(e)}clearAll(){this.stateHistory.clear(),this.routeAccessOrder=[]}clearState(e){this.stateHistory.delete(e);let t=this.routeAccessOrder.indexOf(e);t!==-1&&this.routeAccessOrder.splice(t,1)}restoreState(e){let t=this.stateHistory.get(e);if(!t)return!1;let n=!0;return this.restoreScrollPositions(t.scrollPositions)||(n=!1),this.restoreFormData(t.formData)||(n=!1),t.focusedElement&&this.restoreFocus(t.focusedElement),n}restoreScrollPositions(e){let t=!0;try{e.forEach((e,n)=>{try{if(n===`window`)window.scrollTo(e.x,e.y);else{let r=document.getElementById(n)||document.querySelector(`[data-scrollable-id="${n}"]`);r instanceof HTMLElement?(r.scrollLeft=e.x,r.scrollTop=e.y):t=!1}}catch{t=!1}})}catch(e){console.error(`[rari] Router: Failed to restore scroll positions:`,e),t=!1}return t}restoreFormData(e){let t=!0;try{e.forEach((e,n)=>{try{let r=document.getElementById(n)||document.querySelector(`form[name="${n}"]`)||document.querySelectorAll(`form`)[Number.parseInt(n.replace(`form-`,``),10)];r instanceof HTMLFormElement?e.forEach((e,n)=>{try{let t=r.elements.namedItem(n);t instanceof RadioNodeList?t.forEach(t=>{t instanceof HTMLInputElement&&(t.type===`radio`||t.type===`checkbox`?t.checked=t.value===e:t.value=e)}):(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)&&(t instanceof HTMLInputElement&&(t.type===`checkbox`||t.type===`radio`)?t.checked=t.value===e:t.value=e)}catch{t=!1}}):t=!1}catch{t=!1}})}catch(e){console.error(`[rari] Router: Failed to restore form data:`,e),t=!1}return t}restoreFocus(e){try{let t=document.querySelector(e);t instanceof HTMLElement&&requestAnimationFrame(()=>{try{t.focus()}catch{}})}catch{}}};function M(e){e.title&&(document.title=e.title);let t=(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)}};if(e.description&&t(`meta[name="description"]`,{name:`description`,content:e.description}),e.keywords&&e.keywords.length>0&&t(`meta[name="keywords"]`,{name:`keywords`,content:e.keywords.join(`, `)}),e.viewport&&t(`meta[name="viewport"]`,{name:`viewport`,content:e.viewport}),e.canonical){let t=document.querySelector(`link[rel="canonical"]`);t||(t=document.createElement(`link`),t.setAttribute(`rel`,`canonical`),document.head.appendChild(t)),t.setAttribute(`href`,e.canonical)}if(e.robots){let n=[];e.robots.index!==void 0&&n.push(e.robots.index?`index`:`noindex`),e.robots.follow!==void 0&&n.push(e.robots.follow?`follow`:`nofollow`),e.robots.nocache&&n.push(`nocache`),n.length>0&&t(`meta[name="robots"]`,{name:`robots`,content:n.join(`, `)})}if(e.openGraph){let n=e.openGraph;if(n.title&&t(`meta[property="og:title"]`,{property:`og:title`,content:n.title}),n.description&&t(`meta[property="og:description"]`,{property:`og:description`,content:n.description}),n.url&&t(`meta[property="og:url"]`,{property:`og:url`,content:n.url}),n.siteName&&t(`meta[property="og:site_name"]`,{property:`og:site_name`,content:n.siteName}),n.type&&t(`meta[property="og:type"]`,{property:`og:type`,content:n.type}),n.images&&n.images.length>0){document.querySelectorAll(`meta[property="og:image"]`).forEach(e=>e.remove());for(let e of n.images){let t=document.createElement(`meta`);t.setAttribute(`property`,`og:image`),t.setAttribute(`content`,e),document.head.appendChild(t)}}}if(e.twitter){let n=e.twitter;if(n.card&&t(`meta[name="twitter:card"]`,{name:`twitter:card`,content:n.card}),n.site&&t(`meta[name="twitter:site"]`,{name:`twitter:site`,content:n.site}),n.creator&&t(`meta[name="twitter:creator"]`,{name:`twitter:creator`,content:n.creator}),n.title&&t(`meta[name="twitter:title"]`,{name:`twitter:title`,content:n.title}),n.description&&t(`meta[name="twitter:description"]`,{name:`twitter:description`,content:n.description}),n.images&&n.images.length>0){document.querySelectorAll(`meta[name="twitter:image"]`).forEach(e=>e.remove());for(let e of n.images){let t=document.createElement(`meta`);t.setAttribute(`name`,`twitter:image`),t.setAttribute(`content`,e),document.head.appendChild(t)}}}}function N({children:e,initialRoute:t}){let[n,r]=y(()=>({currentRoute:E(t),navigationId:0,error:null})),i=v(null),a=v(!0),o=v(E(t)),s=v(new T({timeout:1e4,maxRetries:3,onError:e=>{console.error(`[rari] Router: Navigation error:`,e)},onRetry:()=>{}})),c=v(new Map),l=v([]),u=v(new j({maxHistorySize:50})),d=()=>`${Date.now()}-${Math.random().toString(36).substring(2,9)}`,f=()=>{i.current&&=(i.current.abort(),null)},p=()=>{for(let[,e]of c.current.entries())e.abortController.abort();c.current.clear()},m=(e,t)=>{c.current.delete(e),a.current&&n.navigationId===t&&r(e=>({...e}))},h=async e=>A.get(e),g=v(null),w=async(e,t={})=>{if(!e||typeof e!=`string`){console.error(`[rari] Router: Invalid navigation target:`,e);return}let[l,_]=e.includes(`#`)?e.split(`#`):[e,``],v=E(l);if(v===o.current&&!t.replace){if(_){let e=document.getElementById(_);e&&(e.scrollIntoView({behavior:`smooth`,block:`start`}),window.history.pushState(window.history.state,``,`${v}#${_}`))}return}let y=c.current.get(v);if(y)return y.promise;let b=await h(v);p(),f();let x=new AbortController;i.current=x;let S=n.navigationId+1,C=(async()=>{let e=o.current;try{t.historyKey||u.current.captureState(e);let n=t.historyKey||d(),i={route:v,navigationId:S,scrollPosition:{x:window.scrollX,y:window.scrollY},timestamp:Date.now(),key:n},l=_?`${v}#${_}`:v;t.replace?window.history.replaceState(i,``,l):window.history.pushState(i,``,l);let f=window.location.origin+v,p=await fetch(f,{headers:{Accept:`text/x-component`},signal:x.signal});if(!p.ok&&p.status!==404)throw Error(`Failed to fetch: ${p.status}`);let h=new URL(p.url).pathname,y=h===v?v:h;if(h!==v){let e=_?`${h}#${_}`:h;window.history.replaceState({route:h,navigationId:S,scrollPosition:{x:window.scrollX,y:window.scrollY},timestamp:Date.now(),key:t.historyKey||d()},``,e)}if(x.signal.aborted){m(y,S);return}try{let e=p.headers.get(`x-rari-metadata`);if(e){let t=decodeURIComponent(e);M(JSON.parse(t))}}catch{}if(p.headers.get(`x-render-mode`)===`streaming`&&p.body){let n=p.body.getReader(),r=new TextDecoder,i=``;try{for(;;){let{done:e,value:t}=await n.read();if(e)break;if(x.signal.aborted){await n.cancel(),m(y,S);return}i+=r.decode(t,{stream:!0});let a=i.split(`
|
|
2
2
|
`);i=a.pop()||``;for(let e of a)e.trim()&&window.dispatchEvent(new CustomEvent(`rari:rsc-row`,{detail:{rscRow:e}}))}i.trim()&&window.dispatchEvent(new CustomEvent(`rari:rsc-row`,{detail:{rscRow:i}})),window.dispatchEvent(new CustomEvent(`rari:navigate`,{detail:{from:e,to:y,navigationId:S,options:t,routeInfo:b,abortSignal:x.signal,isStreaming:!0}}))}catch(e){throw console.error(`[rari] Router: Streaming error:`,e),e}}else{let n=await p.text();window.dispatchEvent(new CustomEvent(`rari:navigate`,{detail:{from:e,to:y,navigationId:S,options:t,routeInfo:b,abortSignal:x.signal,rscWireFormat:n}}))}if(x.signal.aborted){m(y,S);return}a.current&&(o.current=y,r(e=>({...e,currentRoute:y,error:null})),s.current.resetRetry(y),t.historyKey?requestAnimationFrame(()=>{u.current.restoreState(y)}):_&&requestAnimationFrame(()=>{let e=(t=0)=>{let n=document.getElementById(_);n?n.scrollIntoView({behavior:`smooth`,block:`start`}):t<10&&setTimeout(e,50,t+1)};e()})),c.current.delete(v),g.current?.()}catch(t){if(t instanceof Error&&t.name===`AbortError`){m(v,S);return}let n=s.current.handleError(t,v);a.current&&r(e=>({...e,error:n})),c.current.delete(v),window.dispatchEvent(new CustomEvent(`rari:navigate-error`,{detail:{from:e,to:v,error:n,navigationId:S}})),g.current?.()}})();return c.current.set(v,{targetPath:v,navigationId:S,promise:C,abortController:x}),C};g.current=async()=>{if(l.current.length===0)return;let e=l.current.at(-1);e&&(l.current=[],await w(e.path,e.options))};let N=v(null);N.current||=C((e,t)=>{w(e,t)},50,{leading:!1,trailing:!0,maxWait:200});let P=N.current,F=e=>{if(e.button!==0||e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)return;let t=e.target;for(;t&&t.tagName!==`A`;)t=t.parentElement;if(!t||t.tagName!==`A`)return;let n=t;if(n.target&&n.target!==`_self`||n.hasAttribute(`download`))return;let r=n.getAttribute(`href`);if(r&&!D(r)){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(),P(O(r),{replace:!1})}},I=e=>{let t=window.location.pathname,n=e.state;w(t,{replace:!0,scroll:!1,historyKey:n?.key})},L=()=>{if(n.error&&n.error.url){let e=n.error.url;s.current.incrementRetry(e),w(e,{replace:!1})}},R=()=>{window.location.reload()},z=()=>{r(e=>({...e,error:null}))};_(()=>{let e=window.history.state;if(!e||!e.key){let e={route:n.currentRoute,navigationId:n.navigationId,scrollPosition:{x:window.scrollX,y:window.scrollY},timestamp:Date.now(),key:d()};window.history.replaceState(e,``,window.location.pathname+window.location.search)}},[]);let B=e=>{if(e.persisted){let e=window.location.pathname;u.current.captureState(e)}},V=e=>{if(e.persisted){let e=window.location.pathname,t=window.history.state;requestAnimationFrame(()=>{u.current.restoreState(e),t?.scrollPosition&&window.scrollTo(t.scrollPosition.x,t.scrollPosition.y)})}};return _(()=>(document.addEventListener(`click`,F),window.addEventListener(`popstate`,I),window.addEventListener(`pagehide`,B),window.addEventListener(`pageshow`,V),()=>{document.removeEventListener(`click`,F),window.removeEventListener(`popstate`,I),window.removeEventListener(`pagehide`,B),window.removeEventListener(`pageshow`,V),a.current=!1,f(),p(),P.cancel&&P.cancel()}),[]),S(b,{children:[e,n.error&&x(k,{error:n.error,onRetry:L,onReload:R,onDismiss:z,retryCount:s.current.getRetryCount(n.error.url||``),maxRetries:3})]})}var P=class extends g{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`[rari] Layout: Error in layout "${this.props.layoutPath}":`,e,t),this.props.onError&&this.props.onError(e,t),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`rari:layout-error`,{detail:{layoutPath:this.props.layoutPath,error:e,errorInfo:t,timestamp:Date.now()}}))}reset=()=>{this.setState({hasError:!1,error:null})};render(){return this.state.hasError&&this.state.error?this.props.fallback?this.props.fallback(this.state.error,this.reset):S(`div`,{style:{padding:`16px`,margin:`16px 0`,background:`#fee`,border:`1px solid #fcc`,borderRadius:`4px`},children:[x(`h3`,{style:{margin:`0 0 8px 0`,color:`#c00`},children:`Layout Error`}),S(`p`,{style:{margin:`0 0 8px 0`,fontSize:`14px`},children:[`An error occurred in layout:`,` `,x(`code`,{children:this.props.layoutPath})]}),S(`details`,{style:{fontSize:`12px`,marginBottom:`8px`},children:[x(`summary`,{style:{cursor:`pointer`},children:`Error details`}),S(`pre`,{style:{marginTop:`8px`,padding:`8px`,background:`#fff`,border:`1px solid #ddd`,borderRadius:`2px`,overflow:`auto`},children:[this.state.error.message,`
|
|
3
3
|
`,this.state.error.stack]})]}),x(`button`,{onClick:this.reset,type:`button`,style:{padding:`6px 12px`,background:`#c00`,color:`white`,border:`none`,borderRadius:`4px`,cursor:`pointer`,fontSize:`14px`},children:`Try Again`})]}):this.props.children}};export{N as ClientRouter,m as DefaultError,l as DefaultLoading,f as ErrorBoundary,o as HttpRuntimeClient,P as LayoutErrorBoundary,e as LoadingSpinner,T as NavigationErrorHandler,k as NavigationErrorOverlay,u as NotFound,j as StatePreserver,h as clearPropsCache,n as clearPropsCacheForComponent,p as createErrorBoundary,t as createHttpRuntimeClient,s as createLoadingBoundary,r as extractMetadata,d as extractServerProps,c as extractServerPropsWithCache,a as extractStaticParams,i as hasServerSideDataFetching};
|
package/dist/image/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,i as t,n,o as r,r as i,t as a}from"../constants-
|
|
1
|
+
import{a as e,i as t,n,o as r,r as i,t as a}from"../constants-DZAg-dr0.mjs";import{useCallback as o,useEffect as s,useRef as c,useState as l}from"react";import{jsx as u,jsxs as d}from"react/jsx-runtime";function f(e,t,n,r){let i=new URLSearchParams;return i.set(`url`,e),i.set(`w`,t.toString()),i.set(`q`,n.toString()),r&&i.set(`f`,r),`/_rari/image?${i}`}function p({src:e,alt:t,width:r,height:i,quality:p=75,preload:m=!1,loading:h=`lazy`,placeholder:g=`empty`,blurDataURL:_,fill:v=!1,sizes:y,style:b,className:x,onLoad:S,onError:C,unoptimized:w=!1,loader:T,overrideSrc:E,decoding:D}){let O=typeof e==`string`?e:e.src,k=r||(typeof e==`string`?void 0:e.width),A=i||(typeof e==`string`?void 0:e.height),j=_||(typeof e==`string`?void 0:e.blurDataURL),M=E||O,N=m,P=D||(m?`sync`:`async`),[F,I]=l(!1),[L,R]=l(!1),z=c(null),B=c(S),V=c(null);s(()=>{B.current=S},[S]);let H=o(e=>{let t=e.currentTarget;t.src&&t.complete&&(g===`blur`&&I(!0),B.current&&B.current(e))},[g]),U=o(e=>{R(!0),g===`blur`&&I(!0),C&&C(e)},[g,C]);s(()=>{if(N){let e=document.createElement(`link`);return e.rel=`preload`,e.as=`image`,T?e.href=T({src:M,width:k||1920,quality:p}):w?e.href=M:e.href=f(M,k||1920,p),y&&e.setAttribute(`imagesizes`,y),document.head.appendChild(e),()=>{document.head.removeChild(e)}}},[N,M,k,p,y,T,w]),s(()=>{if(N||w||h===`eager`)return;let e=z.current;if(!e)return;let t=new IntersectionObserver(n=>{n.forEach(n=>{n.isIntersecting&&t.unobserve(e)})},{rootMargin:`50px`});return t.observe(e),()=>{t.disconnect()}},[N,w,h]);let W={...b,...v&&{position:`absolute`,inset:0,width:`100%`,height:`100%`,objectFit:`cover`},...g===`blur`&&j&&!F&&{backgroundImage:`url(${j})`,backgroundSize:`cover`,backgroundPosition:`center`,filter:`blur(20px)`,transition:`filter 0.3s ease-out`},...g===`blur`&&F&&{filter:`none`,transition:`filter 0.3s ease-out`}};if(w)return u(`img`,{ref:z,src:T?T({src:M,width:k||1920,quality:p}):M,alt:L?t:``,width:v?void 0:k,height:v?void 0:A,loading:N?`eager`:h,fetchPriority:N?`high`:`auto`,decoding:P,onLoad:H,onError:U,style:W,className:x});let G=k||1920,K=k?[k]:a,q=e=>T?K.map(e=>`${T({src:M,width:e,quality:p})} ${e}w`).join(`, `):K.map(t=>`${f(M,t,p,e)} ${t}w`).join(`, `),J=T?T({src:M,width:G,quality:p}):f(M,G,p),Y=K.length>1||K[0]!==G,X=u(`img`,{ref:z,src:J,srcSet:Y?q():void 0,sizes:Y?y:void 0,alt:L?t:``,width:v?void 0:k,height:v?void 0:A,loading:N?`eager`:h,fetchPriority:N?`high`:`auto`,decoding:P,onLoad:H,onError:U,style:W,className:x});return Y?d(`picture`,{ref:V,children:[n.includes(`avif`)&&u(`source`,{type:`image/avif`,srcSet:q(`avif`),sizes:y}),n.includes(`webp`)&&u(`source`,{type:`image/webp`,srcSet:q(`webp`),sizes:y}),X]}):X}export{a as DEFAULT_DEVICE_SIZES,n as DEFAULT_FORMATS,i as DEFAULT_IMAGE_SIZES,t as DEFAULT_MAX_CACHE_SIZE,e as DEFAULT_MINIMUM_CACHE_TTL,r as DEFAULT_QUALITY_LEVELS,p as Image};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as AppRouteManifest, i as ServerSpamBlockerConfig, r as ServerRateLimitConfig, t as ServerCSPConfig } from "./server-config-
|
|
1
|
+
import { g as AppRouteManifest, i as ServerSpamBlockerConfig, r as ServerRateLimitConfig, t as ServerCSPConfig } from "./server-config-BLpfK714.mjs";
|
|
2
2
|
import { Plugin, UserConfig } from "rolldown-vite";
|
|
3
3
|
|
|
4
4
|
//#region src/fetch-cache.d.ts
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { A as MetadataResult, C as LayoutProps, D as PageProps, E as NotFoundEntry, F as extractMetadata, I as extractServerProps, L as extractServerPropsWithCache, M as StaticParamsResult, N as clearPropsCache, O as RouteSegment, P as clearPropsCacheForComponent, R as extractStaticParams, S as LayoutEntry, T as Metadata, _ as AppRouteMatch, b as GenerateMetadata, c as HttpRuntimeClient, d as RuntimeClient, g as AppRouteManifest, h as AppRouteEntry, i as ServerSpamBlockerConfig, j as ServerSidePropsResult, k as RouteSegmentType, n as ServerConfig, p as createHttpRuntimeClient, r as ServerRateLimitConfig, t as ServerCSPConfig, v as ErrorEntry, w as LoadingEntry, x as GenerateStaticParams, y as ErrorProps, z as hasServerSideDataFetching } from "./server-config-
|
|
2
|
-
import { _ as SitemapVideo, a as generateAppRouteManifest, c as ApiResponse, d as RouteHandler, f as Robots, g as SitemapImage, h as SitemapEntry, i as rariRouter, l as ApiRouteHandlers, m as Sitemap, n as defineRariOptions, o as ProxyPluginOptions, p as RobotsRule, r as rari, s as rariProxy, t as defineRariConfig, u as RouteContext } from "./index-
|
|
3
|
-
import { a as ProxyModule, c as RariURL, i as ProxyMatcher, l as RequestCookies, n as ProxyConfig, o as ProxyResult, r as ProxyFunction, s as RariFetchEvent, t as CookieOptions, u as ResponseCookies } from "./types-
|
|
1
|
+
import { A as MetadataResult, C as LayoutProps, D as PageProps, E as NotFoundEntry, F as extractMetadata, I as extractServerProps, L as extractServerPropsWithCache, M as StaticParamsResult, N as clearPropsCache, O as RouteSegment, P as clearPropsCacheForComponent, R as extractStaticParams, S as LayoutEntry, T as Metadata, _ as AppRouteMatch, b as GenerateMetadata, c as HttpRuntimeClient, d as RuntimeClient, g as AppRouteManifest, h as AppRouteEntry, i as ServerSpamBlockerConfig, j as ServerSidePropsResult, k as RouteSegmentType, n as ServerConfig, p as createHttpRuntimeClient, r as ServerRateLimitConfig, t as ServerCSPConfig, v as ErrorEntry, w as LoadingEntry, x as GenerateStaticParams, y as ErrorProps, z as hasServerSideDataFetching } from "./server-config-BLpfK714.mjs";
|
|
2
|
+
import { _ as SitemapVideo, a as generateAppRouteManifest, c as ApiResponse, d as RouteHandler, f as Robots, g as SitemapImage, h as SitemapEntry, i as rariRouter, l as ApiRouteHandlers, m as Sitemap, n as defineRariOptions, o as ProxyPluginOptions, p as RobotsRule, r as rari, s as rariProxy, t as defineRariConfig, u as RouteContext } from "./index-DuCX6G_W.mjs";
|
|
3
|
+
import { a as ProxyModule, c as RariURL, i as ProxyMatcher, l as RequestCookies, n as ProxyConfig, o as ProxyResult, r as ProxyFunction, s as RariFetchEvent, t as CookieOptions, u as ResponseCookies } from "./types-BQ-op_Tc.mjs";
|
|
4
4
|
import { RariRequest } from "./proxy/RariRequest.mjs";
|
|
5
5
|
import { RariResponse } from "./proxy/RariResponse.mjs";
|
|
6
6
|
import { Request, Response } from "./vite.mjs";
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,i as t,n,o as r,r as i,t as a}from"./vite-
|
|
1
|
+
import{a as e,i as t,n,o as r,r as i,t as a}from"./vite-BTJjUXqs.mjs";import{RariRequest as o}from"./proxy/RariRequest.mjs";import{RariResponse as s}from"./proxy/RariResponse.mjs";import{c,d as l,f as u,g as d,h as f,i as p,m,p as h,u as g}from"./runtime-client-Bg4V1Ksp.mjs";import"./regex-constants-BM4Vd-_c.mjs";import{t as _}from"./routes-DEvXO96u.mjs";import"./constants-DZAg-dr0.mjs";import"./server-build-emJwCUjS.mjs";import"./vite.mjs";export{r as ApiResponse,p as HttpRuntimeClient,o as RariRequest,s as RariResponse,g as clearPropsCache,l as clearPropsCacheForComponent,c as createHttpRuntimeClient,a as defineRariConfig,n as defineRariOptions,u as extractMetadata,h as extractServerProps,m as extractServerPropsWithCache,f as extractStaticParams,_ as generateAppRouteManifest,d as hasServerSideDataFetching,i as rari,e as rariProxy,t as rariRouter};
|
package/dist/mdx.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{registerClientComponent as
|
|
1
|
+
import{d as e}from"./regex-constants-BM4Vd-_c.mjs";import{registerClientComponent as t,registerClientReference as n}from"./runtime/react-server-dom-shim.mjs";function r(r,i,a=`default`){let o=`${i}#${a}`;if(t(r,i,a),typeof globalThis<`u`){let t=globalThis;t[`~clientComponents`]||={};let n=i.replace(e,``).split(`/`).pop()||a,s={id:a===`default`?n:a,path:i,type:`client`,component:r,registered:!0};t[`~clientComponents`][o]=s,t[`~clientComponents`][n]=s,t[`~clientComponents`][i]=s}function s(){throw Error(`Attempted to call ${a}() from the server but ${a} is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.`)}return n(s,i,a)}function i(e){let t={};for(let[n,{component:i,id:a,exportName:o=`default`}]of Object.entries(e))t[n]=r(i,a,o);return t}export{r as createMDXClientReference,i as createMDXClientReferences};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{S as e,t}from"./regex-constants-BM4Vd-_c.mjs";async function n(n){let r=globalThis[`~clientComponents`]||{},i=[];for(let[,a]of n){let n=[a.id,`${a.id}#${a.name||`default`}`,a.id.replace(e,``),a.id.replace(t,`/`)];for(let e of n){let t=r[e];if(t?.loader&&!t.component&&!t.loading){t.loading=!0,t.loadPromise=t.loader().then(e=>{t.component=e.default||e,t.registered=!0,t.loading=!1}).catch(n=>{t.loading=!1,t.loadPromise=void 0,console.error(`[rari] Failed to preload component ${e}:`,n)}),i.push(t.loadPromise);break}}}i.length>0&&await Promise.all(i)}export{n as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e,i as t,n,r,t as i}from"./utils-
|
|
1
|
+
import{a as e,i as t,n,r,t as i}from"./utils-BTyXoHUx-Cp3JPZPF.mjs";import{existsSync as a,readFileSync as o,writeFileSync as s}from"node:fs";import{join as c}from"node:path";import l from"node:process";import{styleText as u}from"node:util";async function d(){let d=l.cwd();e(`Creating Railway deployment configuration...`);let f=c(d,`package.json`);a(f)||(t(`No package.json found. Please run this command from your project root.`),l.exit(1));try{let t=JSON.parse(o(f,`utf-8`));t.scripts=t.scripts||{},t.scripts.start&&t.scripts.start!==`rari start`&&(n(`Existing start script found: "${t.scripts.start}"`),n(`Backing up to start:original and replacing with "rari start"`),t.scripts[`start:original`]=t.scripts.start),t.scripts.start=`rari start`,t.scripts[`start:local`]=`rari start`,t.scripts[`deploy:railway`]=`echo "Push to GitHub and connect to Railway to deploy"`,t.engines=t.engines||{},t.engines.node?i(t.engines.node)||(n(`Current engines.node value "${t.engines.node}" may not meet the required minimum of >=22.0.0`),n(`Updating to >=22.0.0 for Railway deployment compatibility`),t.engines.node=`>=22.0.0`):t.engines.node=`>=22.0.0`,(!t.dependencies||!t.dependencies.rari)&&(e(`Adding rari dependency...`),t.dependencies=t.dependencies||{},t.dependencies.rari=`^0.1.0`),s(f,`${JSON.stringify(t,null,2)}\n`),r(`Updated package.json for Railway deployment`)}catch(e){t(`Failed to update package.json: ${e instanceof Error?e.message:`Unknown error`}`),l.exit(1)}let p=c(d,`railway.toml`);if(a(p)){n(`railway.toml already exists, backing up to railway.toml.backup`);let e=o(p,`utf-8`);s(c(d,`railway.toml.backup`),e)}s(p,`[build]
|
|
2
2
|
builder = "RAILPACK"
|
|
3
3
|
|
|
4
4
|
[deploy]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=/\.(?:tsx?|jsx?)$/,t=/^[A-Z]:\\/i,n=/\\/g,r=/[/\\]/,i=/^src\//,a=/^file:\/\//,o={AMPERSAND:/&/g,LT:/</g,GT:/>/g,QUOTE:/"/g,APOS:/'/g},s=o.AMPERSAND,c=o.LT,l=o.GT,u=o.QUOTE,d=o.APOS,f=s,p=c,m=l,h=u,g=d,_=s,v=c,y=l,b=u,x=d,S=/[^\w/-]/g,C=/^\d+$/,w=/([a-z])([A-Z])/g,T=/export\s+default\s+/,E=/^export\s+default\s+function\s+(\w+)/gm,D=/^export\s+default\s+async\s+function\s+(\w+)/gm,O=/^export\s+default\s+(\w+);?\s*$/gm,k=/^export\s*\{\s*(\w+)\s+as\s+default\s*\};?\s*$/gm,A=/^export\s+(?:async\s+)?function\s+(\w+)/gm,j=/export\s+(?:function|const|class)\s+(\w+)/,M=/\.[^.]*$/,N=/\r?\n/,P=/['"]/g;export{e as C,y as D,x as E,v as O,i as S,_ as T,h as _,k as a,r as b,T as c,M as d,a as f,p as g,m as h,D as i,b as k,A as l,g as m,w as n,E as o,f as p,S as r,O as s,n as t,j as u,N as v,t as w,P as x,C as y};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e,i as t,n,r,t as i}from"./utils-
|
|
1
|
+
import{a as e,i as t,n,r,t as i}from"./utils-BTyXoHUx-Cp3JPZPF.mjs";import{existsSync as a,readFileSync as o,writeFileSync as s}from"node:fs";import{join as c}from"node:path";import l from"node:process";import{styleText as u}from"node:util";async function d(){let d=l.cwd();e(`Creating Render deployment configuration...`);let f=c(d,`package.json`);a(f)||(t(`No package.json found. Please run this command from your project root.`),l.exit(1));try{let t=JSON.parse(o(f,`utf-8`));t.scripts=t.scripts||{},t.scripts.start&&t.scripts.start!==`rari start`&&(n(`Existing start script found: "${t.scripts.start}"`),n(`Backing up to start:original and replacing with "rari start"`),t.scripts[`start:original`]=t.scripts.start),t.scripts.start=`rari start`,t.scripts[`start:local`]=`rari start`,t.scripts[`deploy:render`]=`echo "Push to GitHub and connect to Render to deploy"`,t.engines=t.engines||{},t.engines.node?i(t.engines.node)||(n(`Current engines.node value "${t.engines.node}" may not meet the required minimum of >=22.0.0`),n(`Updating to >=22.0.0 for Render deployment compatibility`),t.engines.node=`>=22.0.0`):t.engines.node=`>=22.0.0`,(!t.dependencies||!t.dependencies.rari)&&(e(`Adding rari dependency...`),t.dependencies=t.dependencies||{},t.dependencies.rari=`^0.1.0`),s(f,`${JSON.stringify(t,null,2)}\n`),r(`Updated package.json for Render deployment`)}catch(e){t(`Failed to update package.json: ${e instanceof Error?e.message:`Unknown error`}`),l.exit(1)}let p=c(d,`render.yaml`);if(a(p)){n(`render.yaml already exists, backing up to render.yaml.backup`);let e=o(p,`utf-8`);s(c(d,`render.yaml.backup`),e)}s(p,`services:
|
|
2
2
|
- type: web
|
|
3
3
|
name: rari-app
|
|
4
4
|
runtime: node
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./rolldown-runtime-DR3Ue2cl.mjs";import{b as t,t as n}from"./regex-constants-BM4Vd-_c.mjs";import{promises as r}from"node:fs";import i from"node:path";var a=e({generateAppRouteManifest:()=>f});const o={PAGE:`page`,LAYOUT:`layout`,LOADING:`loading`,ERROR:`error`,NOT_FOUND:`not-found`,TEMPLATE:`template`,DEFAULT:`default`,ROUTE:`route`,OG_IMAGE:`opengraph-image`,TWITTER_IMAGE:`twitter-image`,ICON:`icon`,APPLE_ICON:`apple-icon`},s={DYNAMIC:/^\[([^\]]+)\]$/,CATCH_ALL:/^\[\.\.\.([^\]]+)\]$/,OPTIONAL_CATCH_ALL:/^\[\[\.\.\.([^\]]+)\]\]$/},c=/export\s+const\s+size\s*=\s*\{\s*width\s*:\s*(\d+)\s*,\s*height\s*:\s*(\d+)\s*[,}]/,l=/export\s+const\s+contentType\s*=\s*['"]([^'"]+)['"]/,u=[`GET`,`POST`,`PUT`,`DELETE`,`PATCH`,`HEAD`,`OPTIONS`];var d=class{appDir;extensions;verbose;constructor(e){this.appDir=i.resolve(e.appDir),this.extensions=e.extensions||[`.tsx`,`.jsx`,`.ts`,`.js`],this.verbose=e.verbose||!1}async generateManifest(){this.verbose&&console.warn(`[rari] Router: Scanning app directory: ${this.appDir}`);let e=[],t=[],n=[],r=[],i=[],a=[],o=[];return await this.scanDirectory(``,e,t,n,r,i,a,o),this.verbose&&(console.warn(`[rari] Router: Found ${e.length} routes`),console.warn(`[rari] Router: Found ${t.length} layouts`),console.warn(`[rari] Router: Found ${n.length} loading components`),console.warn(`[rari] Router: Found ${r.length} error boundaries`),console.warn(`[rari] Router: Found ${a.length} API routes`),console.warn(`[rari] Router: Found ${o.length} OG images`)),{routes:this.sortRoutes(e),layouts:this.sortLayouts(t),loading:n,errors:r,notFound:i,apiRoutes:this.sortApiRoutes(a),ogImages:o,generated:new Date().toISOString()}}async scanDirectory(e,t,n,a,o,s,c,l){let u=i.join(this.appDir,e),d;try{d=await r.readdir(u)}catch{return}let f=[],p=[];for(let e of d){let t=i.join(u,e),n=await r.stat(t);n.isDirectory()?this.shouldScanDirectory(e)&&p.push(e):n.isFile()&&f.push(e)}await this.processSpecialFiles(e,f,t,n,a,o,s,c,l);for(let r of p){let u=e?i.join(e,r):r;await this.scanDirectory(u,t,n,a,o,s,c,l)}}async processSpecialFiles(e,t,n,a,s,u,d,f,p){let m=this.pathToRoute(e),h=this.findFile(t,o.PAGE);if(h){let t=this.parseRouteSegments(e),r=this.extractParams(t);n.push({path:m,filePath:i.join(e,h),segments:t,params:r,isDynamic:r.length>0})}let g=this.findFile(t,o.LAYOUT);if(g){let t=this.getParentPath(e);a.push({path:m,filePath:i.join(e,g),parentPath:t?this.pathToRoute(t):void 0})}let _=this.findFile(t,o.LOADING);if(_){let t=this.generateComponentId(m,`loading`);s.push({path:m,filePath:i.join(e,_),componentId:t})}let v=this.findFile(t,o.ERROR);v&&u.push({path:m,filePath:i.join(e,v)});let y=this.findFile(t,o.NOT_FOUND);y&&d.push({path:m,filePath:i.join(e,y)});let b=this.findFile(t,o.OG_IMAGE);if(b){let t=i.join(e,b),n=i.join(this.appDir,t),a,o,s;try{let e=await r.readFile(n,`utf-8`),t=e.match(c);t&&(a=Number.parseInt(t[1],10),o=Number.parseInt(t[2],10));let i=e.match(l);i&&(s=i[1])}catch{}p.push({path:m,filePath:t,width:a,height:o,contentType:s})}let x=this.findFile(t,o.ROUTE);if(x){let t=await this.processApiRouteFile(e,x);f.push(t)}}findFile(e,t){for(let n of this.extensions){let r=`${t}${n}`;if(e.includes(r))return r}}pathToRoute(e){return e?`/${e.replace(n,`/`).split(`/`).filter(Boolean).map(e=>s.OPTIONAL_CATCH_ALL.test(e)?`[[...${e.match(s.OPTIONAL_CATCH_ALL)[1]}]]`:s.CATCH_ALL.test(e)?`[...${e.match(s.CATCH_ALL)[1]}]`:s.DYNAMIC.test(e)?`[${e.match(s.DYNAMIC)[1]}]`:e).join(`/`)}`:`/`}parseRouteSegments(e){return e?e.split(t).filter(Boolean).map(e=>s.OPTIONAL_CATCH_ALL.test(e)?{type:`optional-catch-all`,value:e,param:e.match(s.OPTIONAL_CATCH_ALL)[1]}:s.CATCH_ALL.test(e)?{type:`catch-all`,value:e,param:e.match(s.CATCH_ALL)[1]}:s.DYNAMIC.test(e)?{type:`dynamic`,value:e,param:e.match(s.DYNAMIC)[1]}:{type:`static`,value:e}):[]}extractParams(e){return e.filter(e=>e.param!==void 0).map(e=>e.param)}getParentPath(e){if(!e)return null;let n=e.split(t).filter(Boolean);return n.length===0?null:n.slice(0,-1).join(`/`)}generateComponentId(e,t){return`${t}:${e}`}shouldScanDirectory(e){return![`node_modules`,`.git`,`dist`,`build`,`__tests__`,`test`,`tests`,`coverage`].includes(e)&&!e.startsWith(`.`)}sortRoutes(e){return e.sort((e,t)=>{let n=e=>{if(!e.isDynamic)return 0;let t=e.segments.some(e=>e.type===`catch-all`);return e.segments.some(e=>e.type===`optional-catch-all`)?3:t?2:1},r=n(e),i=n(t);if(r!==i)return r-i;let a=e.path.split(`/`).length,o=t.path.split(`/`).length;return a===o?e.path.localeCompare(t.path):o-a})}sortApiRoutes(e){return e.sort((e,t)=>{if(!e.isDynamic&&t.isDynamic)return-1;if(e.isDynamic&&!t.isDynamic)return 1;let n=e.path.split(`/`).length,r=t.path.split(`/`).length;return n===r?e.path.localeCompare(t.path):n-r})}sortLayouts(e){return e.sort((e,t)=>e.path===`/`&&t.path!==`/`?-1:t.path===`/`&&e.path!==`/`?1:e.path.split(`/`).length-t.path.split(`/`).length)}async detectHttpMethods(e){let t=i.join(this.appDir,e),n=await r.readFile(t,`utf-8`),a=[];for(let e of u){let t=RegExp(`export\\s+(?:async\\s+)?function\\s+${e}\\s*\\(`),r=RegExp(`export\\s+(?:async\\s+)?(?:const|let|var)\\s+${e}\\s*=`);(t.test(n)||r.test(n))&&a.push(e)}return a}async processApiRouteFile(e,t){let n=i.join(e,t),r=this.pathToRoute(e),a=this.parseRouteSegments(e),o=this.extractParams(a),s=await this.detectHttpMethods(n);return{path:r,filePath:n,segments:a,params:o,isDynamic:o.length>0,methods:s}}};async function f(e,t={}){return new d({appDir:e,...t}).generateManifest()}export{a as n,f as t};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use client";import{
|
|
1
|
+
"use client";import{y as e}from"../regex-constants-BM4Vd-_c.mjs";import{t}from"../preload-components-TyCxVZPF.mjs";import*as n from"react";import{Suspense as r,useEffect as i,useRef as a,useState as o,useTransition as s}from"react";import{Fragment as c,jsx as l,jsxs as u}from"react/jsx-runtime";const d=/"timestamp":(\d+)/;function f(){return u(`div`,{style:{position:`fixed`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,display:`flex`,alignItems:`center`,justifyContent:`center`,zIndex:9999},children:[l(`div`,{style:{width:`40px`,height:`40px`,border:`4px solid rgba(0, 0, 0, 0.1)`,borderTopColor:`#3b82f6`,borderRadius:`50%`,animation:`spin 1s linear infinite`}}),l(`style`,{children:`
|
|
2
2
|
@keyframes spin {
|
|
3
3
|
to { transform: rotate(360deg); }
|
|
4
4
|
}
|
|
5
|
-
`})]})}function
|
|
6
|
-
`),a=new Map,o=new Map,s=new Map,c=null,l=[],u=null,d=null;for(let e=0;e<i.length;e++){let t=i[e],n=t.indexOf(`:`);if(n===-1)continue;let f=t.substring(0,n),p=t.substring(n+1);try{if(p.startsWith(`"$S`)){let e=p.slice(1,-1);o.set(`$${f}`,e);continue}if(p.startsWith(`I[`)){let t=JSON.parse(p.substring(1));if(Array.isArray(t)&&t.length>=3){let[n,i,o]=t;a.set(`$L${f}`,{id:n,chunks:Array.isArray(i)?i:[i],name:o||`default`}),r&&n.includes(`layout`)&&(u!==null&&d!==null&&l.push({layoutPath:u,startLine:d,endLine:e-1,props:{}}),u=n,d=e)}}else if(p.startsWith(`[`)){let e=JSON.parse(p);if(s.set(`$L${f}`,e),r&&Array.isArray(e)&&e.length>=4&&typeof e[1]==`string`&&e[1].startsWith(`$L`)){let t=e[1],n=a.get(t);if(n&&n.id.includes(`layout`)){let t=e[3]||{};if(u&&d!==null){let e=l.find(e=>e.layoutPath===u&&e.startLine===d);e&&(e.props=t)}}}!c&&Array.isArray(e)&&(e[0]===`$`?c=e:Array.isArray(e[0])&&e[0][0]===`$`&&(c=e.length===1?e[0]:e))}}catch(e){console.error(`[rari] AppRouter: Failed to parse RSC line:`,t,e)}}if(await
|
|
7
|
-
`),t=await
|
|
5
|
+
`})]})}function p({children:p,initialPayload:m,onNavigate:h}){let[g,_]=o(m),[,v]=o(0),y=a({x:0,y:0}),b=a(new Map),x=a(null),[,S]=s(),C=a(0),w=a(new Map),T=a([]),E=a(null),D=a(0),[O,k]=o(null),A=()=>{if(typeof document>`u`)return;let e=document.querySelectorAll(`form`);b.current.clear(),e.forEach((e,t)=>{let n=new FormData(e);b.current.set(`form-${t}`,n)})},j=()=>{typeof document>`u`||document.querySelectorAll(`form`).forEach((e,t)=>{let n=b.current.get(`form-${t}`);n&&n.forEach((t,n)=>{let r=e.elements.namedItem(n);r&&(r.type===`checkbox`||r.type===`radio`?r.checked=t===`on`:r.value=t)})})},M=(e,t,n,r)=>{let i={timestamp:Date.now(),error:e,type:t,details:n,filePath:r};T.current.push(i),D.current+=1,T.current.length>10&&T.current.shift(),console.error(`[rari] HMR: Failure detected`,{type:t,details:n,filePath:r,consecutiveFailures:D.current,error:e.message,stack:e.stack,timestamp:new Date(i.timestamp).toISOString()}),D.current>=2&&k(i),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`rari:hmr-failure`,{detail:i}))},N=()=>{setTimeout(()=>{window.location.reload()},1e3)},P=()=>{D.current>0&&(D.current=0)},F=e=>{if(!E.current)return!1;if(e===E.current)return!0;let t=e.match(d);if(t){let e=Number.parseInt(t[1],10);if(Date.now()-e>5e3)return!0}return!1};function I(t,r,i,a,o){if(!t)return null;if(typeof t==`string`||typeof t==`number`||typeof t==`boolean`)return t;if(Array.isArray(t)){if(t.length>=4&&t[0]===`$`){let[,s,c,l]=t,u=s;if(typeof s==`string`&&s.startsWith(`$`)&&a){let t=s.substring(1);if(e.test(t)){let e=a.get(s);e&&(e===`$Sreact.suspense`||e===`react.suspense`?u=`Suspense`:console.warn(`[rari] AppRouter: Unknown symbol:`,e))}}if(u===`Suspense`||s===`Suspense`){let e=W(l,r,i,a,o);return n.createElement(n.Suspense,c?{...e,key:c}:e)}if(typeof u==`string`&&u.startsWith(`$L`)){let e=r.get(u);if(!e)return null;let t=globalThis[`~clientComponents`]?.[e.id]?.component;if(!t||typeof t!=`function`)return null;let s=c||`fallback-${Math.random()}`,d={...l,children:l.children?I(l.children,r,i,a,o):void 0};return n.createElement(t,{key:s,...d})}if(!u||typeof u!=`string`&&typeof u!=`function`)return console.error(`[rari] AppRouter: Invalid component type:`,{type:u,typeOf:typeof u,serverKey:c,props:l,rscData:t}),null;let d=W(l,r,i,a,o);return n.createElement(u,c?{...d,key:c}:d)}return t.map((e,t)=>{let s=I(e,r,i,a,o);return s?typeof s==`object`&&n.isValidElement(s)&&!s.key?n.cloneElement(s,{key:t}):s:null}).filter(Boolean)}return t}let L=a(new Set),R=a(new Map),z=a(new Map),B=a(new Map),V=a(new Map);function H(e){if(!V.current.has(e)){let t=new Promise(()=>{});V.current.set(e,t)}return V.current.get(e)}function U({contentRef:e}){let t=R.current,n=z.current,r=B.current;if(t.has(e))return V.current.delete(e),I(t.get(e),n,void 0,r,t);throw H(e)}function W(e,t,r,i,a){if(!e||typeof e!=`object`)return e;a&&(R.current=a),t&&(z.current=t),i&&(B.current=i);let o={};for(let s in e)if(Object.hasOwn(e,s))if(s===`children`){let c=e.children;if(typeof c==`string`&&c.startsWith(`$L`))if(a&&a.has(c)){let e=a.get(c);L.current.delete(c),o[s]=I(e,t,r,i,a)}else L.current.add(c),o[s]=n.createElement(U,{key:`lazy-${c}`,contentRef:c});else o[s]=c?I(c,t,r,i,a):void 0}else s===`dangerouslySetInnerHTML`?o[s]=e[s]:o[s]=I(e[s],t,r,i,a);return o}let G=async(e,r=!1)=>{try{let i=e.trim().split(`
|
|
6
|
+
`),a=new Map,o=new Map,s=new Map,c=null,l=[],u=null,d=null;for(let e=0;e<i.length;e++){let t=i[e],n=t.indexOf(`:`);if(n===-1)continue;let f=t.substring(0,n),p=t.substring(n+1);try{if(p.startsWith(`"$S`)){let e=p.slice(1,-1);o.set(`$${f}`,e);continue}if(p.startsWith(`I[`)){let t=JSON.parse(p.substring(1));if(Array.isArray(t)&&t.length>=3){let[n,i,o]=t;a.set(`$L${f}`,{id:n,chunks:Array.isArray(i)?i:[i],name:o||`default`}),r&&n.includes(`layout`)&&(u!==null&&d!==null&&l.push({layoutPath:u,startLine:d,endLine:e-1,props:{}}),u=n,d=e)}}else if(p.startsWith(`[`)){let e=JSON.parse(p);if(s.set(`$L${f}`,e),r&&Array.isArray(e)&&e.length>=4&&typeof e[1]==`string`&&e[1].startsWith(`$L`)){let t=e[1],n=a.get(t);if(n&&n.id.includes(`layout`)){let t=e[3]||{};if(u&&d!==null){let e=l.find(e=>e.layoutPath===u&&e.startLine===d);e&&(e.props=t)}}}!c&&Array.isArray(e)&&(e[0]===`$`?c=e:Array.isArray(e[0])&&e[0][0]===`$`&&(c=e.length===1?e[0]:e))}}catch(e){console.error(`[rari] AppRouter: Failed to parse RSC line:`,t,e)}}if(await t(a),r&&u!==null&&d!==null&&l.push({layoutPath:u,startLine:d,endLine:i.length-1,props:{}}),c&&Array.isArray(c)){if(c[0]===`$`)c=I(c,a,void 0,o,s);else if(Array.isArray(c[0])){let e=c.map(e=>Array.isArray(e)&&e[0]===`$`?I(e,a,void 0,o,s):e).filter(e=>e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||n.isValidElement(e));c=e.length===1?e[0]:e}}return{element:c,modules:a,symbols:o,wireFormat:e,layoutBoundaries:r?l:void 0}}catch(e){throw console.error(`[rari] AppRouter: Failed to parse RSC wire format:`,e),e}},K=async(e,t)=>{let n=e||window.location.pathname,r=w.current.get(n);if(r)return r;let i=(async()=>{try{let e=(window.location.origin.includes(`:5173`)?`http://localhost:3000`:window.location.origin)+n+window.location.search,r=await fetch(e,{headers:{Accept:`text/x-component`,"Cache-Control":`no-cache`,Pragma:`no-cache`},cache:`no-store`,signal:t});if(!r.ok){let t=Error(`Failed to fetch RSC data: ${r.status} ${r.statusText}`);throw M(t,`fetch`,`HTTP ${r.status} when fetching ${e}`,window.location.pathname),t}let i=await r.text();if(F(i)&&g)return g;let a;try{a=await G(i,!1)}catch(e){let t=e instanceof Error?e:Error(String(e));throw M(t,`parse`,`Failed to parse RSC wire format: ${t.message}`,window.location.pathname),t}return _(a),E.current=i,P(),a}catch(e){throw e instanceof Error&&!e.message.includes(`Failed to fetch RSC data`)&&!e.message.includes(`Failed to parse`)&&M(e,`network`,`Network error: ${e.message}`,window.location.pathname),console.error(`[rari] AppRouter: Error fetching RSC payload:`,e),e}finally{w.current.delete(n)}})();return w.current.set(n,i),i};i(()=>{if(typeof window>`u`)return;let e=async e=>{let t=e.detail;C.current=t.navigationId,x.current=null,y.current={x:window.scrollX,y:window.scrollY},A(),S(async()=>{try{t.rscWireFormat?(_(await G(t.rscWireFormat,!1)),E.current=t.rscWireFormat,P()):t.isStreaming?x.current=[]:await K(t.to,t.abortSignal),C.current===t.navigationId&&(v(e=>e+1),k(null),h&&h(t))}catch(e){if(e instanceof Error&&e.name===`AbortError`)return;console.error(`[rari] AppRouter: Navigation failed:`,e),window.dispatchEvent(new CustomEvent(`rari:navigate-error`,{detail:{from:t.from,to:t.to,error:e,navigationId:t.navigationId}})),D.current>=3&&N()}finally{t.options?.historyKey||requestAnimationFrame(()=>{t.options?.scroll!==!1&&window.scrollTo(0,0)})}})},t=async()=>{y.current={x:window.scrollX,y:window.scrollY},A();try{await K(),v(e=>e+1),k(null)}catch(e){console.error(`[rari] AppRouter: HMR update failed:`,e),D.current>=3&&N()}finally{requestAnimationFrame(()=>{window.scrollTo(y.current.x,y.current.y),j()})}},n=async()=>{try{await K(),v(e=>e+1),k(null)}catch(e){console.error(`[rari] AppRouter: RSC invalidation failed:`,e),D.current>=3&&N()}},r=async()=>{try{await K(),k(null)}catch(e){console.error(`[rari] AppRouter: Manifest update failed:`,e),D.current>=3&&N()}},i=async e=>{let t=e.detail.rscRow;if(!(!t||!t.trim())){x.current||=[],x.current.push(t);try{let e=x.current.join(`
|
|
7
|
+
`),t=await G(e,!1);x.current.length<=2&&e.includes(`~boundaryId`)?(_(t),v(e=>e+1)):S(()=>{_(t),v(e=>e+1)})}catch(e){console.error(`[rari] AppRouter: Failed to parse streaming RSC row:`,e)}}};return window.addEventListener(`rari:navigate`,e),window.addEventListener(`rari:app-router-rerender`,t),window.addEventListener(`rari:rsc-invalidate`,n),window.addEventListener(`rari:app-router-manifest-updated`,r),window.addEventListener(`rari:rsc-row`,i),()=>{window.removeEventListener(`rari:navigate`,e),window.removeEventListener(`rari:app-router-rerender`,t),window.removeEventListener(`rari:rsc-invalidate`,n),window.removeEventListener(`rari:app-router-manifest-updated`,r),window.removeEventListener(`rari:rsc-row`,i)}},[h]);let q=()=>{window.location.reload()},J=()=>{k(null)},Y=e=>{if(!e||typeof e!=`object`)return null;if(e.type===`html`&&e.props?.children){let t=Array.isArray(e.props.children)?e.props.children:[e.props.children];for(let e of t)if(e&&typeof e==`object`&&e.type===`body`)return e.props?.children||null}return e},X=p;return g?.element&&(X=Y(g.element)||g.element),Array.isArray(X)&&X.length===1&&n.isValidElement(X[0])&&(X=X[0]),X&&typeof X==`object`&&!n.isValidElement(X)&&(console.error(`[rari] AppRouter: Invalid content to render:`,X),X=p),u(c,{children:[O&&u(`div`,{style:{position:`fixed`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,padding:`24px`,background:`rgba(220, 38, 38, 0.95)`,color:`white`,borderRadius:`8px`,fontSize:`14px`,zIndex:1e4,maxWidth:`500px`,boxShadow:`0 4px 6px rgba(0, 0, 0, 0.3)`},children:[l(`div`,{style:{marginBottom:`16px`,fontWeight:`bold`,fontSize:`16px`},children:`⚠️ HMR Update Failed`}),u(`div`,{style:{marginBottom:`12px`,opacity:.9},children:[O.type===`fetch`&&`Failed to fetch updated content from server.`,O.type===`parse`&&`Failed to parse server response.`,O.type===`stale`&&`Server returned stale content.`,O.type===`network`&&`Network error occurred.`]}),l(`div`,{style:{marginBottom:`16px`,fontSize:`12px`,opacity:.8,fontFamily:`monospace`},children:O.details}),u(`div`,{style:{marginBottom:`12px`,fontSize:`12px`,opacity:.7},children:[`Consecutive failures:`,` `,D.current,` `,`/`,` `,3]}),u(`div`,{style:{display:`flex`,gap:`8px`},children:[l(`button`,{onClick:q,type:`button`,style:{padding:`8px 16px`,background:`white`,color:`#dc2626`,border:`none`,borderRadius:`4px`,cursor:`pointer`,fontWeight:`bold`,fontSize:`14px`},children:`Refresh Page`}),l(`button`,{onClick:J,type:`button`,style:{padding:`8px 16px`,background:`rgba(255, 255, 255, 0.2)`,color:`white`,border:`1px solid rgba(255, 255, 255, 0.3)`,borderRadius:`4px`,cursor:`pointer`,fontSize:`14px`},children:`Dismiss`})]}),l(`div`,{style:{marginTop:`12px`,fontSize:`11px`,opacity:.6},children:`Check the console for detailed error logs.`})]}),l(r,{fallback:l(f,{}),children:X})]})}export{p as AppRouterProvider};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{n as e,t}from"../get-client-component-
|
|
1
|
+
import"../regex-constants-BM4Vd-_c.mjs";import{n as e,t}from"../get-client-component-CpMI09nb.mjs";import*as n from"react";import{Suspense as r}from"react";import{ClientRouter as i}from"rari/client";import{createRoot as a}from"react-dom/client";import{AppRouterProvider as o}from"virtual:app-router-provider";import{createFromReadableStream as s}from"virtual:react-server-dom-rari-client.ts";import"virtual:rsc-integration.ts";function c(){return globalThis[`~rari`]}function l(){return globalThis}function u(){return window}function d(){return{moduleMap:new Proxy({},{get(e,t){return new Proxy({},{get(e,n){return{id:`${String(t)}#${String(n)}`,chunks:[],name:String(n)}}})}}),moduleLoading:new Proxy({},{get(e,t){return new Proxy({},{get(e,n){return async()=>{try{let e=String(t),r=String(n),i=`${e}#${r}`;if(l()[`~clientComponents`]?.[i]?.component)return l()[`~clientComponents`][i].component;if(l()[`~clientComponents`]?.[e]?.component){let t=l()[`~clientComponents`][e].component;return r===`default`?t:t?.[r]}let a=l()[`~clientComponents`]?.[i]||l()[`~clientComponents`]?.[e];if(a?.loader){a.loadPromise||=(a.loading=!0,a.loader().then(e=>(a.component=e.default||e,a.registered=!0,a.loading=!1,e)).catch(t=>{throw a.loading=!1,a.loadPromise=void 0,console.error(`[rari] Failed to lazy load ${e}#${r}:`,t),t}));let t=await a.loadPromise,n=t.default||t;return r===`default`?n:n?.[r]??n}return console.warn(`[rari] Module ${e}#${r} not found in client components registry`),null}catch(e){return console.error(`[rari] Failed to load ${String(t)}#${String(n)}:`,e),null}}}})}})}}c()===void 0&&(globalThis[`~rari`]={}),c().AppRouterProvider=o,c().ClientRouter=i,c().getClientComponent=t;async function f(t){try{await e(t)}catch(e){console.error(`[rari] Failed to preload component ${t}:`,e)}}
|
|
2
2
|
/*! @preserve CLIENT_COMPONENT_IMPORTS_PLACEHOLDER */
|
|
3
3
|
c().preloadClientComponent=f,l()[`~clientComponents`]===void 0&&(globalThis[`~clientComponents`]={}),l()[`~clientComponentPaths`]===void 0&&(globalThis[`~clientComponentPaths`]={});
|
|
4
4
|
/*! @preserve CLIENT_COMPONENT_REGISTRATIONS_PLACEHOLDER */
|
|
5
|
-
function p(){c().hydrateClientComponents||(c().hydrateClientComponents=function(e,t,r){let i=u()[`~rari`].boundaryModules||new Map;function o(e){if(!e)return null;if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return e;if(Array.isArray(e)){if(e.length>=4&&e[0]===`$`){let[,t,r,a]=e,s=a?{...a}:{};if(a?.children&&(s.children=o(a.children)),s[`~boundaryId`]&&delete s[`~boundaryId`],typeof t==`string`){if(t.startsWith(`$L`)){let e=i.get(t);if(e){let t=`${e.id}#${e.name||`default`}`,i=null,a=l()[`~clientComponents`][t]||l()[`~clientComponents`][e.id];return a&&(a.component?i=a.component:a.loader&&!a.loading&&(a.loading=!0,a.loadPromise=a.loader().then(e=>(a.component=e.default||e,a.registered=!0,a.loading=!1,a.component)).catch(t=>{throw a.loading=!1,a.loadPromise=void 0,console.error(`[rari] Failed to load component ${e.id}:`,t),t})),a.loadPromise&&!a.component&&n.use(a.loadPromise)),i?n.createElement(i,r?{...s,key:r}:s):s.children||null}return s.children||null}return n.createElement(t,r?{...s,key:r}:s)}return null}return e.map((e,t)=>{let r=o(e);return n.isValidElement(r)&&!r.key?n.cloneElement(r,{key:t}):r})}return e}try{let e=o(t);e&&(a(r).render(e),r.classList.add(`rari-boundary-hydrated`))}catch(e){console.error(`[rari] Failed to hydrate client components:`,e),console.error(`[rari] Error stack:`,e.stack)}})}function m(){let e=u()[`~rari`].pendingBoundaryHydrations;if(!(!e||e.size===0)){for(let[t,n]of e.entries())c().hydrateClientComponents&&c().hydrateClientComponents(t,n.content,n.element);e.clear()}}p();async function h(t){let n=[];for(let r of t){let t=e(r).catch(e=>{console.error(`[rari] Failed to preload component ${r}:`,e)});n.push(t)}n.length>0&&await Promise.all(n)}async function g(){let e=document.getElementById(`root`);if(!e){console.error(`[rari] Root element not found`);return}let r=document.getElementById(`__RARI_RSC_PAYLOAD__`),c=e.children.length>0,l=u()[`~rari`]?.bufferedRows&&u()[`~rari`].bufferedRows.length>0;if(p(),c&&!r&&!l){let e=document.querySelectorAll(`[data-client-component]`);if(e.length>0){let r=new Set;e.forEach(e=>{let t=e.getAttribute(`data-client-component`);t&&r.add(t)}),await h(r),e.forEach(e=>{let r=e.getAttribute(`data-client-component`),i=e.getAttribute(`data-props`);if(r)try{let o=t(r);if(!o)return;let s=i?JSON.parse(i):{};e.innerHTML=``,a(e).render(n.createElement(o,s))}catch(e){console.error(`[rari] Failed to hydrate client component ${r}:`,e)}})}return}if(c&&l&&!r&&document.querySelectorAll(`[data-boundary-id]`).length>0){u()[`~rari`].pendingBoundaryHydrations&&u()[`~rari`].pendingBoundaryHydrations.size>0&&m();return}try{let t;if(!r&&!l&&!c)try{let e=window.location.pathname+window.location.search,n=await fetch(e,{headers:{Accept:`text/x-component`}});if(!n.ok)throw Error(`Failed to fetch RSC data: ${n.status}`);let r=n.body;t=await s(r,d())}catch(e){console.error(`[rari] Failed to fetch initial RSC data:`,e),t=null}else if(r&&r.textContent)try{let e=r.textContent,n=u()[`~rari`]?.bufferedRows&&u()[`~rari`].bufferedRows.length>0;t=u()[`~rari`]?.streamComplete===void 0||n?await s(new ReadableStream({start(t){if(t.enqueue(new TextEncoder().encode(e)),u()[`~rari`]?.bufferedRows){for(let e of u()[`~rari`].bufferedRows)t.enqueue(new TextEncoder().encode(`\n${e}`));u()[`~rari`].bufferedRows=[]}let n=e=>{let n=e;n.detail?.rscRow&&t.enqueue(new TextEncoder().encode(`\n${n.detail.rscRow}`))},r=()=>{t.close(),window.removeEventListener(`rari:rsc-row`,n),window.removeEventListener(`rari:stream-complete`,r)};window.addEventListener(`rari:rsc-row`,n),window.addEventListener(`rari:stream-complete`,r),u()[`~rari`]?.streamComplete&&r()}}),d()):await s(new ReadableStream({start(t){t.enqueue(new TextEncoder().encode(e)),t.close()}}),d())}catch(e){console.error(`[rari] Failed to parse embedded RSC payload:`,e),t=null}else if(l)try{t=await s(new ReadableStream({start(e){if(u()[`~rari`]?.bufferedRows){for(let t of u()[`~rari`].bufferedRows)e.enqueue(new TextEncoder().encode(`${t}\n`));u()[`~rari`].bufferedRows=[]}let t=t=>{let n=t;n.detail?.rscRow&&e.enqueue(new TextEncoder().encode(`${n.detail.rscRow}\n`))},n=()=>{e.close(),window.removeEventListener(`rari:rsc-row`,t),window.removeEventListener(`rari:stream-complete`,n)};window.addEventListener(`rari:rsc-row`,t),window.addEventListener(`rari:stream-complete`,n),u()[`~rari`]?.streamComplete&&n()}}),d())}catch(e){console.error(`[rari] Failed to process streaming RSC payload:`,e),t=null}if(!t)throw Error(`No RSC data available for hydration`);let f;f=t;let p;p=n.createElement(o,{initialPayload:{element:t}},f),p=n.createElement(i,{initialRoute:window.location.pathname},p),a(e).render(p)}catch(t){console.error(`[rari] Error rendering app:`,t),e.innerHTML=`
|
|
5
|
+
function p(){c().hydrateClientComponents||(c().hydrateClientComponents=function(e,t,r){let i=u()[`~rari`].boundaryModules||new Map;function o(e){if(!e)return null;if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return e;if(Array.isArray(e)){if(e.length>=4&&e[0]===`$`){let[,t,r,a]=e,s=a?{...a}:{};if(a?.children&&(s.children=o(a.children)),s[`~boundaryId`]&&delete s[`~boundaryId`],typeof t==`string`){if(t.startsWith(`$L`)){let e=i.get(t);if(e){let t=`${e.id}#${e.name||`default`}`,i=null,a=l()[`~clientComponents`][t]||l()[`~clientComponents`][e.id];return a&&(a.component?i=a.component:a.loader&&!a.loading&&(a.loading=!0,a.loadPromise=a.loader().then(e=>(a.component=e.default||e,a.registered=!0,a.loading=!1,a.component)).catch(t=>{throw a.loading=!1,a.loadPromise=void 0,console.error(`[rari] Failed to load component ${e.id}:`,t),t})),a.loadPromise&&!a.component&&n.use(a.loadPromise)),i?n.createElement(i,r?{...s,key:r}:s):s.children||null}return s.children||null}return n.createElement(t,r?{...s,key:r}:s)}return null}return e.map((e,t)=>{let r=o(e);return n.isValidElement(r)&&!r.key?n.cloneElement(r,{key:t}):r})}return e}try{let e=o(t);e&&(a(r).render(e),r.classList.add(`rari-boundary-hydrated`))}catch(e){console.error(`[rari] Failed to hydrate client components:`,e),console.error(`[rari] Error stack:`,e.stack)}})}function m(){let e=u()[`~rari`].pendingBoundaryHydrations;if(!(!e||e.size===0)){for(let[t,n]of e.entries())c().hydrateClientComponents&&c().hydrateClientComponents(t,n.content,n.element);e.clear()}}p();async function h(t){let n=[];for(let r of t){let t=e(r).catch(e=>{console.error(`[rari] Failed to preload component ${r}:`,e)});n.push(t)}n.length>0&&await Promise.all(n)}async function g(){let e=document.getElementById(`root`);if(!e){console.error(`[rari] Root element not found`);return}let r=document.getElementById(`__RARI_RSC_PAYLOAD__`),c=e.children.length>0,l=u()[`~rari`]?.bufferedRows&&u()[`~rari`].bufferedRows.length>0;if(p(),c&&!r&&!l){let e=document.querySelectorAll(`[data-client-component]`);if(e.length>0){let r=new Set;e.forEach(e=>{let t=e.getAttribute(`data-client-component`);t&&r.add(t)}),await h(r),e.forEach(e=>{let r=e.getAttribute(`data-client-component`),i=e.getAttribute(`data-props`);if(r)try{let o=t(r);if(!o)return;let s=i?JSON.parse(i):{};e.innerHTML=``,a(e).render(n.createElement(o,s))}catch(e){console.error(`[rari] Failed to hydrate client component ${r}:`,e)}})}return}if(c&&l&&!r&&document.querySelectorAll(`[data-boundary-id]`).length>0){u()[`~rari`].pendingBoundaryHydrations&&u()[`~rari`].pendingBoundaryHydrations.size>0&&m();return}try{let t;if(!r&&!l&&!c)try{let e=window.location.pathname+window.location.search,n=await fetch(e,{headers:{Accept:`text/x-component`}});if(!n.ok&&n.status!==404)throw Error(`Failed to fetch RSC data: ${n.status}`);let r=n.body;t=await s(r,d())}catch(e){console.error(`[rari] Failed to fetch initial RSC data:`,e),t=null}else if(r&&r.textContent)try{let e=r.textContent,n=u()[`~rari`]?.bufferedRows&&u()[`~rari`].bufferedRows.length>0;t=u()[`~rari`]?.streamComplete===void 0||n?await s(new ReadableStream({start(t){if(t.enqueue(new TextEncoder().encode(e)),u()[`~rari`]?.bufferedRows){for(let e of u()[`~rari`].bufferedRows)t.enqueue(new TextEncoder().encode(`\n${e}`));u()[`~rari`].bufferedRows=[]}let n=e=>{let n=e;n.detail?.rscRow&&t.enqueue(new TextEncoder().encode(`\n${n.detail.rscRow}`))},r=()=>{t.close(),window.removeEventListener(`rari:rsc-row`,n),window.removeEventListener(`rari:stream-complete`,r)};window.addEventListener(`rari:rsc-row`,n),window.addEventListener(`rari:stream-complete`,r),u()[`~rari`]?.streamComplete&&r()}}),d()):await s(new ReadableStream({start(t){t.enqueue(new TextEncoder().encode(e)),t.close()}}),d())}catch(e){console.error(`[rari] Failed to parse embedded RSC payload:`,e),t=null}else if(l)try{t=await s(new ReadableStream({start(e){if(u()[`~rari`]?.bufferedRows){for(let t of u()[`~rari`].bufferedRows)e.enqueue(new TextEncoder().encode(`${t}\n`));u()[`~rari`].bufferedRows=[]}let t=t=>{let n=t;n.detail?.rscRow&&e.enqueue(new TextEncoder().encode(`${n.detail.rscRow}\n`))},n=()=>{e.close(),window.removeEventListener(`rari:rsc-row`,t),window.removeEventListener(`rari:stream-complete`,n)};window.addEventListener(`rari:rsc-row`,t),window.addEventListener(`rari:stream-complete`,n),u()[`~rari`]?.streamComplete&&n()}}),d())}catch(e){console.error(`[rari] Failed to process streaming RSC payload:`,e),t=null}if(!t)throw Error(`No RSC data available for hydration`);let f;f=t;let p;p=n.createElement(o,{initialPayload:{element:t}},f),p=n.createElement(i,{initialRoute:window.location.pathname},p),a(e).render(p)}catch(t){console.error(`[rari] Error rendering app:`,t),e.innerHTML=`
|
|
6
6
|
<div style="padding: 20px; background: #fee; border: 2px solid #f00; margin: 20px;">
|
|
7
7
|
<h2>Error Loading App</h2>
|
|
8
8
|
<p></p>
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`?(o
|
|
1
|
+
import{S as e,t,y as n}from"../regex-constants-BM4Vd-_c.mjs";import{r}from"../get-client-component-CpMI09nb.mjs";import{t as i}from"../preload-components-TyCxVZPF.mjs";import*as a from"react";async function o(e,t={}){let{moduleMap:n={}}=t,r=e.getReader(),a=[];for(;;){let{done:e,value:t}=await r.read();if(e)break;a.push(t)}let o=new Uint8Array(a.reduce((e,t)=>e+t.length,0)),s=0;for(let e of a)o.set(e,s),s+=e.length;let l=c(new TextDecoder().decode(o));return await i(l.modules),u(l.rootElement,l.modules,n,l.symbols,l.chunks)}async function s(e,t={}){let n=c(await(await e).text());return await i(n.modules),u(n.rootElement,n.modules,t.moduleMap||{},n.symbols,n.chunks)}function c(e){let t=new Map,n=new Map,r=new Map,i=0,a=0,o=0,s=0,c=``,u=null;for(;i<e.length;){let d=e[i],f=e.charCodeAt(i);switch(a){case 0:d===`:`?(a=1,i++):(f>=48&&f<=57?o=o<<4|f-48:f>=97&&f<=102?o=o<<4|f-87:f>=65&&f<=70&&(o=o<<4|f-55),i++);break;case 1:f===73||f===69||f===84||f===72||f===68||f===87||f===67?(s=f,a=2,i++):(s=0,a=2);break;case 2:d===`
|
|
2
|
+
`?(l(o,s,c,t,n,r),u===null&&s!==73&&c.trim()&&!(c.startsWith(`"$S`)&&c.endsWith(`"`))&&n.has(o.toString())&&(u=o.toString()),a=0,o=0,s=0,c=``):c+=d,i++;break}}return c.trim()&&(l(o,s,c,t,n,r),u===null&&s!==73&&!(c.startsWith(`"$S`)&&c.endsWith(`"`))&&n.has(o.toString())&&(u=o.toString())),{modules:t,chunks:n,symbols:r,rootElement:u===null?null:n.get(u)}}function l(e,t,n,r,i,a){let o=e.toString();try{switch(t){case 73:{let e=JSON.parse(n);Array.isArray(e)&&e.length>=3&&r.set(`$L${o}`,{id:e[0],chunks:e[1]||[],name:e[2]||`default`});break}case 69:{console.error(`[rari] RSC: Error chunk:`,n);let e=JSON.parse(n);i.set(o,{error:e});break}case 84:i.set(o,n);break;case 72:case 68:case 87:break;case 67:break;default:{if(!n.trim())break;if(n.startsWith(`"$S`)&&n.endsWith(`"`)){let e=n.slice(1,-1);a.set(o,e);break}let e=JSON.parse(n);i.set(o,e);break}}}catch(e){console.error(`[rari] RSC: Failed to parse row:`,{id:o,tag:t,data:n},e)}}function u(e,t,r,i,o){if(!e)return null;if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`){if(typeof e==`string`&&e.startsWith(`$`)&&e.length>1){if(e[1]===`L`){let n=e.slice(2),a=o?.get(n);if(!a){let t=new Promise(()=>{});throw t._rscLazyRef=e,t}return u(a,t,r,i,o)}let n=e.slice(1),a=o?.get(n);return a?u(a,t,r,i,o):null}return e}if(Array.isArray(e)){if(e.length>=4&&e[0]===`$`){let[,s,c,l]=e;if(typeof s==`string`&&s.startsWith(`$`)&&s.length>1&&n.test(s.slice(1))){let e=s.slice(1),n=i?.get(e);if(n&&n.startsWith(`$S`)&&n.slice(2)===`react.suspense`){let e=f(l,t,r,i,o);return a.createElement(a.Suspense,c?{...e,key:c}:e)}}if(typeof s==`string`&&s.startsWith(`$S`)){if(s.slice(2)===`react.suspense`){let e=f(l,t,r,i,o);return a.createElement(a.Suspense,c?{...e,key:c}:e)}return null}if(typeof s==`string`&&s.startsWith(`$L`)){let e=s.substring(2);if(e===`ClientRouter`&&(!l||!l.manifest))return l&&l.children?u(l.children,t,r,i,o):null;let n=d(e,t,r);if(n){let e=f(l,t,r,i,o);return a.createElement(n,c?{...e,key:c}:e)}return null}let p=f(l,t,r,i,o);return a.createElement(s,c?{...p,key:c}:p)}return e.map(e=>u(e,t,r,i,o))}return e}function d(n,i,a){if(n===`AppRouterProvider`){let e=globalThis[`~rari`]?.AppRouterProvider;if(e)return e}if(n===`ClientRouter`){let e=globalThis[`~rari`]?.ClientRouter;if(e)return e}if(i&&i.size>0){let a=`$L${n}`,o=i.get(a);if(o){let n=globalThis[`~clientComponents`]||{},i=[o.id,`${o.id}#${o.name||`default`}`,o.id.replace(e,``),o.id.replace(t,`/`)];for(let e of i){let t=n[e];if(t){if(t.component)return t.component;if(t.loader&&!t.loading)return r(t,o.id);if(t.loading)return null}}console.warn(`[rari] Component not found in registry:`,{moduleId:o.id,moduleName:o.name,triedKeys:i,availableKeys:Object.keys(n).slice(0,10)})}}if(a[n])return a[n];let o=globalThis[`~clientComponents`]||{};for(let[e,t]of Object.entries(o)){let i=e===n,a=e.endsWith(`/${n}`)||e.endsWith(`\\${n}`),o=e.endsWith(`#${n}`),s=t.name===n;if(i||a||o||s){if(t.component)return t.component;if(t.loader&&!t.loading)return r(t,e)}}return null}function f(e,t,n,r,i){if(!e||typeof e!=`object`)return e;let a={};for(let o in e)if(Object.hasOwn(e,o)){if(o.startsWith(`~`)||o===`ref`)continue;o===`children`?a[o]=e.children?u(e.children,t,n,r,i):void 0:a[o]=e[o]}return a}function p(e){return JSON.stringify(e)}function m(e){return JSON.parse(e)}export{s as createFromFetch,o as createFromReadableStream,m as decodeReply,p as encodeReply};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{t as
|
|
2
|
-
`),i=r.slice(0,-1);S=r.at(-1)||``;for(let e of i)if(e.trim())try{let t=e.indexOf(`:`);if(t===-1)continue;let n=e.substring(0,t),r=e.substring(t+1);if(r.startsWith(`I[`))try{let e=JSON.parse(r.substring(1));if(Array.isArray(e)&&e.length>=3){let[t,r,i]=e;g.set(`$L${n}`,{id:t,chunks:Array.isArray(r)?r:[r],name:i||`default`})}}catch(e){console.error(`Failed to parse import row:`,r,e)}else if(r.startsWith(`E{`))try{let e=JSON.parse(r.substring(1));console.error(`RSC stream error:`,e)}catch(e){console.error(`Failed to parse error row:`,r,e)}else if(r.startsWith(`Symbol.for(`))continue;else if(r.startsWith(`[`)){let e=JSON.parse(r);if(Array.isArray(e)&&e.length>=4){let[t,r,i]=e,a=i?.[`~boundaryId`];if(t===`$`&&(r===`react.suspense`||r===`suspense`)&&i&&a&&v.set(`$L${n}`,a),t===`$`&&i&&Object.hasOwn(i,`children`)&&typeof r==`string`&&r.startsWith(`$L`)){let e=v.get(r)||null;if(e){let t=y(i.children);x.set(e,t),C&&C.updateBoundary(e,t);continue}}}if(!b){let t=!0;if(Array.isArray(e)&&e.length>=4&&e[0]===`$`){let n=e[1],r=e[3],i=r?.[`~boundaryId`];typeof n==`string`&&(n===`react.suspense`||n===`suspense`)&&r&&i&&(t=!1)}t&&(b=y(e),C&&typeof C.updateRoot==`function`&&C.updateRoot())}}}catch(t){console.error(`Failed to parse stream line:`,e,t)}}}catch(e){console.error(`Error processing stream:`,e)}},T=()=>{let[,e]=l(0);s(()=>(C={updateBoundary:(t,n)=>{x.set(t,n),e(e=>e+1)},updateRoot:()=>{e(e=>e+1)}},()=>{C=null}),[]);let t=e=>{if(!e)return null;if(o(e)){let n=e.props,r=n?.[`~boundaryId`];if(n&&r){let e=x.get(r);if(e)return e}if(n&&n.children){let r=t(n.children);if(r!==n.children)return i(e,{...n,children:r})}return e}return Array.isArray(e)?e.map(e=>t(e)):e};return t(b)};return w(),{"~isRscResponse":!0,"~rscPromise":Promise.resolve(a(T)),readRoot(){return Promise.resolve(a(T))}}}buildRequestHeaders(){return{Accept:`text/x-component`,"Cache-Control":`no-cache, no-transform`}}async fetchWithTimeout(e,t){let n=new AbortController,r=setTimeout(()=>n.abort(),this.config.timeout);try{let i=await fetch(e,{...t,signal:n.signal});return clearTimeout(r),i}catch(e){throw clearTimeout(r),e}}async processRscResponse(e){if(await _(),m)try{let t=m(Promise.resolve(e));return{"~isRscResponse":!0,"~rscPromise":t,readRoot(){return t}}}catch{throw Error(`React Server DOM client not available`)}else throw Error(`React Server DOM client not available`)}async processRscResponseManually(e){let t=await e.text();return this.parseRscResponse(t)}parseRscResponse(e){let t=e.trim().split(/\r?\n/),n=new Map,r=new Map,i=[];for(let e of t){let t=e.indexOf(`:`);if(t===-1)continue;let a=e.substring(0,t),o=e.substring(t+1);if(o)try{if(o.startsWith(`I[`)){let e=o.substring(1),t=JSON.parse(e);if(Array.isArray(t)&&t.length>=3){let[e,r,i]=t;n.set(`$L${a}`,{id:e,chunks:Array.isArray(r)?r:[r],name:i||`default`})}}else if(o.startsWith(`E{`)){let e=o.substring(1),t=JSON.parse(e);i.push(t),console.error(`RSC: Server error`,t)}else if(o.startsWith(`[`)){let e=JSON.parse(o);r.set(a,e)}else if(o.startsWith(`Symbol.for(`))continue;else console.error(`Unknown RSC row format:`,e)}catch(t){console.error(`Failed to parse RSC row:`,e,t)}}if(i.length>0)throw Error(`RSC Server Error: ${i.map(e=>e.message||e).join(`, `)}`);let a=null,o=r.keys().toSorted((e,t)=>Number.parseInt(e)-Number.parseInt(t));for(let e of o){let t=r.get(e);if(Array.isArray(t)&&t.length>=2&&t[0]===`$`){let[,e,,n]=t,r=n?.[`~boundaryId`];if(e===`react.suspense`&&n&&r)continue;a=t;break}}return a?this.reconstructElementFromRscData(a,n):(console.error(`No valid root element found in RSC payload`,{elements:r,modules:n}),null)}reconstructElementFromRscData(e,t){if(e==null)return null;if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return e;if(Array.isArray(e))if(e.length>=4&&e[0]===`$`){let[,n,r,i]=e,o=n;if(typeof n==`string`&&n.includes(`#`))o=f(n)||(({children:e,...t})=>a(`div`,{...t,"data-client-component":n,style:{border:`2px dashed #f00`,padding:`8px`,margin:`4px`,backgroundColor:`#fff0f0`}},a(`small`,{style:{color:`#c00`}},`Missing Client Component: ${n}`),e));else if(typeof n==`string`&&n.startsWith(`$L`)&&t.has(n)){let e=t.get(n);e&&(o=f(`${e.id}#${e.name}`)||(({children:t,...r})=>a(`div`,{...r,"data-client-component":n,style:{border:`2px dashed #f00`,padding:`8px`,margin:`4px`,backgroundColor:`#fff0f0`}},a(`small`,{style:{color:`#c00`}},`Missing Client Component: ${e.name} (${e.id})`),t)))}let s=i?this.processPropsRecursively(i,t):{};return a(o,{key:r,...s})}else return e.map(e=>this.reconstructElementFromRscData(e,t));return typeof e==`object`?null:e}processPropsRecursively(e,t){if(!e||typeof e!=`object`)return e;let n={};for(let[r,i]of Object.entries(e))if(r===`children`)if(Array.isArray(i))if(i.length>=2&&i[0]===`$`)n[r]=this.reconstructElementFromRscData(i,t);else{let e=i.map(e=>this.reconstructElementFromRscData(e,t)).filter(e=>e!=null);e.length===0?n[r]=null:e.length===1?n[r]=e[0]:n[r]=e}else n[r]=this.reconstructElementFromRscData(i,t);else r===`dangerouslySetInnerHTML`?n[r]=i:n[r]=this.reconstructElementFromRscData(i,t);return n}};function y({error:e,details:t}){return a(`div`,{className:`rsc-error`,style:{padding:`16px`,backgroundColor:`#fee`,border:`1px solid #fcc`,borderRadius:`4px`,margin:`8px 0`,fontFamily:`monospace`}},a(`h3`,{style:{margin:`0 0 8px 0`,color:`#c00`}},`RSC Error`),a(`p`,{style:{margin:`0 0 8px 0`}},e),t&&a(`details`,{style:{marginTop:`8px`}},a(`summary`,{style:{cursor:`pointer`}},`Error Details`),a(`pre`,{style:{fontSize:`12px`,overflow:`auto`,backgroundColor:`#f5f5f5`,padding:`8px`}},JSON.stringify(t,null,2))))}function b({componentId:e,props:t,fallback:n}){let[i,o]=l({data:null,loading:!0,error:null}),u=JSON.stringify(t),d=c(u);s(()=>{let n=!0;return d.current!==u&&(o({data:null,loading:!0,error:null}),d.current=u),v.fetchServerComponent(e,t).then(e=>{n&&o({data:e,loading:!1,error:null})}).catch(e=>{n&&o({data:null,loading:!1,error:e})}),()=>{n=!1}},[e,u]);let{data:f,loading:p,error:m}=i;return p?n||null:m?a(y,{error:`Error loading component`,details:{message:m.message,componentId:e}}):f?f[`~isRscResponse`]?a(r,{fallback:n||null},f.readRoot()):f:a(y,{error:`No data received for component: ${e}`,details:{componentId:e,dataType:typeof f,hasData:!!f}})}function x(e){let t=0;if(typeof window<`u`){let n=window;n[`~rscRefreshCounters`]=n[`~rscRefreshCounters`]||{},n[`~rscRefreshCounters`][e]===void 0&&(n[`~rscRefreshCounters`][e]=0),t=n[`~rscRefreshCounters`][e]}let n=n=>{let[i,o]=l(t);return s(()=>{let t=t=>{let n=t.detail;if(n&&n.filePath&&C(n.filePath)&&(v.clearCache(),typeof window<`u`)){let t=window;t[`~rscRefreshCounters`]||={},t[`~rscRefreshCounters`][e]=(t[`~rscRefreshCounters`][e]||0)+1,o(t[`~rscRefreshCounters`][e])}};return typeof window<`u`&&window.addEventListener(`rari:rsc-invalidate`,t),()=>{typeof window<`u`&&window.removeEventListener(`rari:rsc-invalidate`,t)}},[]),a(r,{fallback:null},a(b,{key:`${e}-${i}`,componentId:e,props:n,fallback:null}))};return n.displayName=`ServerComponent(${e})`,function(e){return a(n,e)}}function S(e,t){return v.fetchServerComponent(e,t)}function C(e){if(!e)return!1;try{return typeof globalThis<`u`&&globalThis[`~rari`].serverComponents?globalThis[`~rari`].serverComponents.has(e):!1}catch(e){return console.error(`Error checking if file is server component:`,e),!1}}if(import.meta.hot){import.meta.hot.on(`rari:register-server-component`,e=>{e?.filePath&&typeof globalThis<`u`&&(globalThis[`~rari`].serverComponents=globalThis[`~rari`].serverComponents||new Set,globalThis[`~rari`].serverComponents.add(e.filePath))}),import.meta.hot.on(`rari:server-components-registry`,e=>{e?.serverComponents&&Array.isArray(e.serverComponents)&&typeof globalThis<`u`&&(globalThis[`~rari`].serverComponents=globalThis[`~rari`].serverComponents||new Set,e.serverComponents.forEach(e=>{globalThis[`~rari`].serverComponents?.add(e)}))}),import.meta.hot.on(`vite:beforeFullReload`,async e=>{e?.path&&C(e.path)&&await o({filePath:e.path,forceReload:!0})}),import.meta.hot.on(`rari:server-component-updated`,async e=>{let t=e?.id||e?.componentId,n=e?.t||e?.timestamp;if(t){if(typeof window<`u`){let r=new CustomEvent(`rari:rsc-invalidate`,{detail:{componentId:t,filePath:e.filePath||e.file,type:`server-component`,timestamp:n}});window.dispatchEvent(r)}}else e?.path&&C(e.path)&&await o({filePath:e.path,forceReload:!1})}),import.meta.hot.on(`rari:app-router-updated`,async t=>{try{if(!t)return;await e(t)}catch(e){console.error(`[rari] HMR: App router update failed:`,e)}}),import.meta.hot.on(`rari:server-action-updated`,async e=>{if(e?.filePath&&(v.clearCache(),typeof window<`u`)){let t=new CustomEvent(`rari:rsc-invalidate`,{detail:{filePath:e.filePath,type:`server-action`}});window.dispatchEvent(t)}});async function e(e){let n=e.fileType,o=e.filePath,s=e.routePath,c=e.affectedRoutes,l=e.manifestUpdated,u=e.metadata;e.metadataChanged&&u&&t(u);try{let e=`${window.location.origin}/_rari/hmr`,t=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`register`,file_path:o})});t.ok||console.error(`[rari] HMR: Component reload failed:`,t.status),await new Promise(e=>setTimeout(e,100))}catch(e){console.error(`[rari] HMR: Failed to reload component:`,e)}let d=[s];switch(n){case`page`:d=[s];break;case`layout`:case`loading`:case`error`:case`not-found`:d=c;break;default:break}await r({routes:d,fileType:n,filePath:o,componentId:s}),l&&await a(),await i({routePath:s,affectedRoutes:c})}function t(e){if(!(typeof document>`u`)&&(e.title&&(document.title=e.title),e.description)){let t=document.querySelector(`meta[name="description"]`);t||(t=document.createElement(`meta`),t.setAttribute(`name`,`description`),document.head.appendChild(t)),t.setAttribute(`content`,e.description)}}function n(e){if(!e||e.length===0){v.clearCache();return}let t=[];for(let n of v.componentCache.keys())for(let r of e){if(n.includes(`route:${r}:`)||n.startsWith(`${r}:`)){t.push(n);break}if(r!==`/`&&n.includes(`route:${r}/`)){t.push(n);break}}for(let e of t)v.componentCache.delete(e)}async function r(e){let t=e.routes||[],r=e.fileType,i=e.filePath,a=e.componentId;if(a||i)try{let e=`${window.location.origin.includes(`:5173`)?`http://localhost:3000`:window.location.origin}/_rari/hmr`,t=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`invalidate`,componentId:a||i,filePath:i})});t.ok||console.error(`[rari] HMR: Server cache invalidation failed:`,t.status)}catch(e){console.error(`[rari] HMR: Failed to call server invalidation endpoint:`,e)}if(n(t),typeof window<`u`){let e=new CustomEvent(`rari:rsc-invalidate`,{detail:{routes:t,fileType:r}});window.dispatchEvent(e);let n=window.location.pathname;if(t.includes(n)||t.includes(`/`))try{let e=(window.location.origin.includes(`:5173`)?`http://localhost:3000`:window.location.origin)+n+window.location.search,t=await fetch(e,{headers:{Accept:`text/x-component`},cache:`no-cache`});t.ok||console.error(`[rari] HMR: Failed to re-fetch route:`,t.status)}catch(e){console.error(`[rari] HMR: Failed to re-fetch route:`,e)}}}async function i(e){let t=e.routePath,n=e.affectedRoutes||[t];if(!(typeof window>`u`))try{let e=window.location.pathname,r=new CustomEvent(`rari:app-router-rerender`,{detail:{routePath:t,affectedRoutes:n,currentPath:e,preserveParams:!0}});window.dispatchEvent(r)}catch(e){throw console.error(`[rari] HMR: Failed to trigger re-render:`,e),e}}async function a(){typeof window<`u`&&window[`~rari`]?.routeInfoCache&&window[`~rari`].routeInfoCache.clear()}async function o(e){let t=e?.filePath||e;if(v.clearCache(),typeof window<`u`){let e=new CustomEvent(`rari:rsc-invalidate`,{detail:{filePath:t}});window.dispatchEvent(e)}}}var w=class{overlay;currentError;constructor(){this.overlay=null,this.currentError=null}show(e){this.currentError=e,this.overlay?this.updateOverlay(e):this.createOverlay(e)}hide(){this.overlay&&(this.overlay.remove(),this.overlay=null,this.currentError=null)}isVisible(){return this.overlay!==null}createOverlay(e){this.overlay=document.createElement(`div`),this.overlay.id=`rari-hmr-error-overlay`,this.updateOverlay(e),document.body.appendChild(this.overlay)}updateOverlay(e){if(!this.overlay)return;let t=e.filePath?`<div style="margin-bottom: 1rem; padding: 0.75rem; background: rgba(0, 0, 0, 0.2); border-radius: 0.375rem; font-family: monospace; font-size: 0.875rem;"><strong>File:</strong> ${this.escapeHtml(e.filePath)}</div>`:``,n=e.stack?`<details style="margin-top: 1rem; cursor: pointer;"><summary style="font-weight: 600; margin-bottom: 0.5rem; user-select: none;">Stack Trace</summary><pre style="margin: 0; padding: 0.75rem; background: rgba(0, 0, 0, 0.2); border-radius: 0.375rem; overflow-x: auto; font-size: 0.875rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word;">${this.escapeHtml(e.stack)}</pre></details>`:``;this.overlay.innerHTML=`<div style="position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.85); z-index: 999999; display: flex; align-items: center; justify-content: center; padding: 2rem; backdrop-filter: blur(4px);"><div style="background: #1e1e1e; color: #e0e0e0; border-radius: 0.5rem; padding: 2rem; max-width: 50rem; width: 100%; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.4); border: 1px solid #ef4444;"><div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem;"><div style="display: flex; align-items: center; gap: 0.75rem;"><svg style="width: 2rem; height: 2rem; color: #ef4444;" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"></path></svg><h1 style="margin: 0; font-size: 1.5rem; font-weight: 700; color: #ef4444;">Build Error</h1></div><button onclick="document.getElementById('rari-hmr-error-overlay').remove()" style="background: transparent; border: none; color: #9ca3af; cursor: pointer; padding: 0.5rem; border-radius: 0.25rem; transition: all 0.2s; font-size: 1.5rem; line-height: 1; width: 2rem; height: 2rem; display: flex; align-items: center; justify-content: center;" onmouseover="this.style.background='rgba(255,255,255,0.1)'; this.style.color='#e0e0e0'" onmouseout="this.style.background='transparent'; this.style.color='#9ca3af'">×</button></div>${t}<div style="margin-bottom: 1.5rem;"><h2 style="margin: 0 0 0.75rem 0; font-size: 1rem; font-weight: 600; color: #fca5a5;">Error Message:</h2><pre style="margin: 0; padding: 1rem; background: rgba(239, 68, 68, 0.1); border-left: 4px solid #ef4444; border-radius: 0.375rem; overflow-x: auto; font-family: monospace; font-size: 0.875rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word; color: #fca5a5;">${this.escapeHtml(e.message)}</pre></div>${n}<div style="margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid #374151; display: flex; gap: 0.75rem; align-items: center;"><button onclick="window.location.reload()" style="padding: 0.625rem 1.25rem; background: #ef4444; color: white; border: none; border-radius: 0.375rem; cursor: pointer; font-weight: 600; font-size: 0.875rem; transition: all 0.2s;" onmouseover="this.style.background='#dc2626'" onmouseout="this.style.background='#ef4444'">Reload Page</button><button onclick="document.getElementById('rari-hmr-error-overlay').remove()" style="padding: 0.625rem 1.25rem; background: #374151; color: #e0e0e0; border: none; border-radius: 0.375rem; cursor: pointer; font-weight: 600; font-size: 0.875rem; transition: all 0.2s;" onmouseover="this.style.background='#4b5563'" onmouseout="this.style.background='#374151'">Dismiss</button><span style="margin-left: auto; font-size: 0.75rem; color: #9ca3af;">${new Date(e.timestamp).toLocaleTimeString()}</span></div></div></div>`}escapeHtml(e){let t=document.createElement(`div`);return t.textContent=e,t.innerHTML}};let T=null;function E(){return T||=new w,T}if(import.meta.hot){let e=E();import.meta.hot.on(`rari:hmr-error`,t=>{let n=t.msg||t.message,r=t.file||t.filePath,i=t.t||t.timestamp,a=t.count||t.errorCount,o=t.max||t.maxErrors;console.error(`[rari] HMR: Build error:`,n),r&&console.error(`[rari] HMR: File:`,r),t.stack&&console.error(`[rari] HMR: Stack:`,t.stack),e.show({message:n,stack:t.stack,filePath:r,timestamp:i}),a&&o&&(a>=o?console.error(`[rari] HMR: Maximum error count (${o}) reached. Consider restarting the dev server if issues persist.`):a>=o-2&&console.warn(`[rari] HMR: Error count: ${a}/${o}. Approaching maximum error threshold.`))}),import.meta.hot.on(`rari:hmr-error-cleared`,()=>{e.hide()}),import.meta.hot.on(`vite:error`,t=>{e.show({message:t.err?.message||`Unknown Vite error`,stack:t.err?.stack,filePath:t.err?.file,timestamp:Date.now()})})}export{y as RscErrorComponent,p as createClientModuleMap,x as createServerComponentWrapper,S as fetchServerComponent,f as getClientComponent,d as registerClientComponent,v as rscClient};
|
|
1
|
+
import{_ as e,d as t,g as n,h as r,m as i,n as a,p as o,v as s}from"../regex-constants-BM4Vd-_c.mjs";import{t as c}from"../get-client-component-CpMI09nb.mjs";import"../preload-components-TyCxVZPF.mjs";import{createFromFetch as l,createFromReadableStream as u}from"./react-server-dom-rari-client.mjs";import{Suspense as d,cloneElement as f,createElement as p,isValidElement as m,useEffect as h,useRef as g,useState as _}from"react";import*as v from"react-dom/client";if(globalThis[`~rari`]===void 0&&(globalThis[`~rari`]={}),globalThis[`~rari`].isDevelopment=process.env.NODE_ENV!==`production`,globalThis[`~clientComponents`]===void 0&&(globalThis[`~clientComponents`]={}),globalThis[`~clientComponentNames`]===void 0&&(globalThis[`~clientComponentNames`]={}),globalThis[`~clientComponentPaths`]===void 0&&(globalThis[`~clientComponentPaths`]={}),typeof window<`u`){window[`~rari`]||(window[`~rari`]=globalThis[`~rari`]),window[`~rari`].bufferedEvents||(window[`~rari`].bufferedEvents=[]),window[`~rari`].boundaryModules||(window[`~rari`].boundaryModules=new Map),window[`~rari`].pendingBoundaryHydrations||(window[`~rari`].pendingBoundaryHydrations=new Map),globalThis[`~rari`].processBoundaryUpdate=function(t,s,c){let l=document.querySelector(`[data-boundary-id="${t}"]`);if(l){try{let u=s.indexOf(`:`);if(u===-1){console.warn(`[rari] Invalid RSC row format (no colon):`,s);return}let d=s.substring(0,u),f=s.substring(u+1);if(f.startsWith(`I[`)){try{let e=JSON.parse(f.substring(1));if(Array.isArray(e)&&e.length>=3){let[t,n,r]=e,i=`$L${d}`;window[`~rari`].boundaryModules?.set(i,{id:t,chunks:Array.isArray(n)?n:[n],name:r||`default`})}}catch(e){console.error(`[rari] Failed to parse import row:`,f,e)}return}let p;try{p=JSON.parse(f)}catch(e){console.error(`[rari] Failed to parse RSC content:`,f,e);return}function m(e){if(!e)return!1;if(typeof e==`string`)return e.startsWith(`$L`);if(Array.isArray(e)){if(e.length>=4&&e[0]===`$`){let[,t]=e;if(typeof t==`string`&&t.startsWith(`$L`))return!0;let n=e[3];if(n&&n.children)return m(n.children)}return e.some(e=>m(e))}return!1}if(m(p)){if(window[`~rari`].pendingBoundaryHydrations?.set(t,{content:p,element:l,rowId:c}),globalThis[`~rari`].hydrateClientComponents){let e=globalThis[`~rari`].hydrateClientComponents;e(t,p,l)}return}function h(t){let s=t=>t.replace(o,`&`).replace(n,`<`).replace(r,`>`).replace(e,`"`).replace(i,`'`);if(!t)return``;if(typeof t==`string`||typeof t==`number`)return s(String(t));if(Array.isArray(t)){if(t.length>=4&&t[0]===`$`){let[,e,,n]=t,r=null,i=``,o=``;if(n){for(let[e,t]of Object.entries(n))if(e===`dangerouslySetInnerHTML`&&t&&typeof t==`object`&&`__html`in t)r=t.__html;else if(e!==`children`&&e!==`~boundaryId`){let n=e===`className`?`class`:e;if(e===`style`&&typeof t==`object`&&t){let e=Object.entries(t).map(([e,t])=>`${e.replace(a,`$1-$2`).toLowerCase()}:${String(t)}`).join(`;`);o+=` style="${s(e)}"`}else typeof t==`string`||typeof t==`number`?o+=` ${n}="${s(String(t))}"`:typeof t==`boolean`&&t&&(o+=` ${n}`)}r===null&&n.children&&(i=h(n.children))}return`<${e}${o}>${r===null?i:r}</${e}>`}return t.map(h).join(``)}return``}let g=h(p);g&&(l.innerHTML=g,l.classList.add(`rari-boundary-resolved`))}catch(e){console.error(`[rari] Error processing boundary update:`,e)}window.dispatchEvent(new CustomEvent(`rari:boundary-resolved`,{detail:{boundaryId:t,rscRow:s,rowId:c,element:l}}))}};let t=window,s=globalThis;t[`~rari`].bufferedEvents&&t[`~rari`].bufferedEvents.length>0&&(t[`~rari`].bufferedEvents.forEach(e=>{let{boundaryId:t,rscRow:n,rowId:r}=e;s[`~rari`].processBoundaryUpdate?.(t,n,r)}),t[`~rari`].bufferedEvents=[]),window.addEventListener(`rari:boundary-update`,e=>{let{boundaryId:t,rscRow:n,rowId:r}=e.detail;s[`~rari`].processBoundaryUpdate&&s[`~rari`].processBoundaryUpdate(t,n,r)})}function y(e,n,r){let i=r===`default`?e.name||n.split(`/`).pop()?.replace(t,``)||`DefaultComponent`:r,a=i,o={id:a,path:n,type:`client`,component:e,registered:!0};globalThis[`~clientComponents`][a]=o,globalThis[`~clientComponents`][n]=o,globalThis[`~clientComponentPaths`][n]=a,globalThis[`~clientComponentNames`][i]=a,e&&(e[`~isClientComponent`]=!0,e[`~clientComponentId`]=a),typeof window<`u`&&fetch(`/_rari/register-client`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({component_id:a,file_path:n,export_name:r})}).catch(e=>{console.error(`[rari] Failed to register client component with server:`,e)})}function b(e){return c(e)}function x(){let e={};for(let[t,n]of Object.entries(globalThis[`~clientComponents`]))e[t]={id:t,chunks:[n.path],name:t,async:!1,default:n.component};return e}let S=l,C=u,w=null;async function T(){return w||(w=(async()=>{try{return S=l,C=u,typeof C!=`function`&&(C=null),typeof S!=`function`&&(S=null),v}catch(e){return console.error(`Failed to load react-dom/client RSC functions:`,e),S=null,C=null,null}})(),w)}const E=new class{componentCache;moduleCache;inflightRequests;config;constructor(){this.componentCache=new Map,this.moduleCache=new Map,this.inflightRequests=new Map,this.config={maxRetries:5,retryDelay:500,timeout:1e4}}configure(e){this.config={...this.config,...e}}clearCache(){this.componentCache.clear(),this.moduleCache.clear()}async fetchServerComponent(e,t={}){let n=typeof window<`u`&&window[`~rscRefreshCounters`]&&window[`~rscRefreshCounters`][e]||0,r=`${e}:${JSON.stringify(t)}:hmr:${n}`;if(this.componentCache.has(r))return this.componentCache.get(r);if(this.inflightRequests.has(r))return this.inflightRequests.get(r);let i=this.fetchServerComponentStream(e,t);this.inflightRequests.set(r,i);try{let e=await i;return this.componentCache.set(r,e),e}finally{this.inflightRequests.delete(r)}}async fetchServerComponentStream(e,t={}){await T();let n=(()=>{let e=[`/_rari/stream`];try{typeof window<`u`&&(window.location.hostname===`localhost`||window.location.hostname===`127.0.0.1`)&&e.push(`http://127.0.0.1:3000/_rari/stream`,`http://localhost:3000/_rari/stream`)}catch{}return e})(),r=null,i=null,a=async()=>{for(let r of n)try{let n=await this.fetchWithTimeout(r,{method:`POST`,headers:{"Content-Type":`application/json`,...this.buildRequestHeaders()},body:JSON.stringify({component_id:e,props:t})});if(n.ok)return n;i=Error(`HTTP ${n.status}: ${await n.text()}`)}catch(e){i=e}return null};if(r=await a(),r||=(await new Promise(e=>setTimeout(e,this.config.retryDelay)),await a()),!r)throw i||Error(`Failed to reach stream endpoint`);if(!r.ok){let e=await r.text();throw Error(`Server responded with ${r.status}: ${e}`)}let o=r.body;if(!o)throw Error(`No ReadableStream from stream response`);let s=o.getReader(),c=new TextDecoder,l=new Map,u=new Map,g=e=>{if(!p)return console.error(`React not available for RSC conversion`),null;if(!e)return null;if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return e;if(Array.isArray(e)){if(e.length>=3&&e[0]===`$`){let[,t,n,r]=e;if(t===`react.suspense`||t===`suspense`)return p(d,{fallback:g(r?.fallback)||null},r?.children?g(r.children):null);let i=r?{...r}:{};if(r?.children){let e=g(r.children);Array.isArray(e)?i.children=e.map((e,t)=>m(e)?f(e,{key:e.key??t}):e):i.children=e}if(typeof t==`string`){if(t.startsWith(`$L`)){let e=l.get(t);if(e){let t=b(`${e.id}#${e.name||`default`}`);if(t)return p(t,n?{...i,key:n}:i)}return i&&i.children?i.children:null}if(t.includes(`.tsx#`)||t.includes(`.jsx#`)){let e=b(t);return e?p(e,n?{...i,key:n}:i):(console.error(`Failed to resolve client component:`,t),null)}else return i&&Object.hasOwn(i,`~boundaryId`)&&(i={...i},delete i[`~boundaryId`]),p(t,n?{...i,key:n}:i)}else console.error(`Unknown RSC element type:`,t)}return e.map(e=>g(e))}return typeof e==`object`?(console.error(`Unexpected object in RSC conversion:`,e),null):e},v=null,y=new Map,x=``,S=null,C=async()=>{try{for(;;){let{value:e,done:t}=await s.read();if(t)break;let n=c.decode(e,{stream:!0});x+=n;let r=x.split(`
|
|
2
|
+
`),i=r.slice(0,-1);x=r.at(-1)||``;for(let e of i)if(e.trim())try{let t=e.indexOf(`:`);if(t===-1)continue;let n=e.substring(0,t),r=e.substring(t+1);if(r.startsWith(`I[`))try{let e=JSON.parse(r.substring(1));if(Array.isArray(e)&&e.length>=3){let[t,r,i]=e;l.set(`$L${n}`,{id:t,chunks:Array.isArray(r)?r:[r],name:i||`default`})}}catch(e){console.error(`Failed to parse import row:`,r,e)}else if(r.startsWith(`E{`))try{let e=JSON.parse(r.substring(1));console.error(`RSC stream error:`,e)}catch(e){console.error(`Failed to parse error row:`,r,e)}else if(r.startsWith(`Symbol.for(`))continue;else if(r.startsWith(`[`)){let e=JSON.parse(r);if(Array.isArray(e)&&e.length>=4){let[t,r,i]=e,a=i?.[`~boundaryId`];if(t===`$`&&(r===`react.suspense`||r===`suspense`)&&i&&a&&u.set(`$L${n}`,a),t===`$`&&i&&Object.hasOwn(i,`children`)&&typeof r==`string`&&r.startsWith(`$L`)){let e=u.get(r)||null;if(e){let t=g(i.children);y.set(e,t),S&&S.updateBoundary(e,t);continue}}}if(!v){let t=!0;if(Array.isArray(e)&&e.length>=4&&e[0]===`$`){let n=e[1],r=e[3],i=r?.[`~boundaryId`];typeof n==`string`&&(n===`react.suspense`||n===`suspense`)&&r&&i&&(t=!1)}t&&(v=g(e),S&&typeof S.updateRoot==`function`&&S.updateRoot())}}}catch(t){console.error(`Failed to parse stream line:`,e,t)}}}catch(e){console.error(`Error processing stream:`,e)}},w=()=>{let[,e]=_(0);h(()=>(S={updateBoundary:(t,n)=>{y.set(t,n),e(e=>e+1)},updateRoot:()=>{e(e=>e+1)}},()=>{S=null}),[]);let t=e=>{if(!e)return null;if(m(e)){let n=e.props,r=n?.[`~boundaryId`];if(n&&r){let e=y.get(r);if(e)return e}if(n&&n.children){let r=t(n.children);if(r!==n.children)return f(e,{...n,children:r})}return e}return Array.isArray(e)?e.map(e=>t(e)):e};return t(v)};return C(),{"~isRscResponse":!0,"~rscPromise":Promise.resolve(p(w)),readRoot(){return Promise.resolve(p(w))}}}buildRequestHeaders(){return{Accept:`text/x-component`,"Cache-Control":`no-cache, no-transform`}}async fetchWithTimeout(e,t){let n=new AbortController,r=setTimeout(()=>n.abort(),this.config.timeout);try{let i=await fetch(e,{...t,signal:n.signal});return clearTimeout(r),i}catch(e){throw clearTimeout(r),e}}async processRscResponse(e){if(await T(),S)try{let t=S(Promise.resolve(e));return{"~isRscResponse":!0,"~rscPromise":t,readRoot(){return t}}}catch{throw Error(`React Server DOM client not available`)}else throw Error(`React Server DOM client not available`)}async processRscResponseManually(e){let t=await e.text();return this.parseRscResponse(t)}parseRscResponse(e){let t=e.trim().split(s),n=new Map,r=new Map,i=[];for(let e of t){let t=e.indexOf(`:`);if(t===-1)continue;let a=e.substring(0,t),o=e.substring(t+1);if(o)try{if(o.startsWith(`I[`)){let e=o.substring(1),t=JSON.parse(e);if(Array.isArray(t)&&t.length>=3){let[e,r,i]=t;n.set(`$L${a}`,{id:e,chunks:Array.isArray(r)?r:[r],name:i||`default`})}}else if(o.startsWith(`E{`)){let e=o.substring(1),t=JSON.parse(e);i.push(t),console.error(`RSC: Server error`,t)}else if(o.startsWith(`[`)){let e=JSON.parse(o);r.set(a,e)}else if(o.startsWith(`Symbol.for(`))continue;else console.error(`Unknown RSC row format:`,e)}catch(t){console.error(`Failed to parse RSC row:`,e,t)}}if(i.length>0)throw Error(`RSC Server Error: ${i.map(e=>e.message||e).join(`, `)}`);let a=null,o=r.keys().toSorted((e,t)=>Number.parseInt(e)-Number.parseInt(t));for(let e of o){let t=r.get(e);if(Array.isArray(t)&&t.length>=2&&t[0]===`$`){let[,e,,n]=t,r=n?.[`~boundaryId`];if(e===`react.suspense`&&n&&r)continue;a=t;break}}return a?this.reconstructElementFromRscData(a,n):(console.error(`No valid root element found in RSC payload`,{elements:r,modules:n}),null)}reconstructElementFromRscData(e,t){if(e==null)return null;if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return e;if(Array.isArray(e))if(e.length>=4&&e[0]===`$`){let[,n,r,i]=e,a=n;if(typeof n==`string`&&n.includes(`#`))a=b(n)||(({children:e,...t})=>p(`div`,{...t,"data-client-component":n,style:{border:`2px dashed #f00`,padding:`8px`,margin:`4px`,backgroundColor:`#fff0f0`}},p(`small`,{style:{color:`#c00`}},`Missing Client Component: ${n}`),e));else if(typeof n==`string`&&n.startsWith(`$L`)&&t.has(n)){let e=t.get(n);e&&(a=b(`${e.id}#${e.name}`)||(({children:t,...r})=>p(`div`,{...r,"data-client-component":n,style:{border:`2px dashed #f00`,padding:`8px`,margin:`4px`,backgroundColor:`#fff0f0`}},p(`small`,{style:{color:`#c00`}},`Missing Client Component: ${e.name} (${e.id})`),t)))}let o=i?this.processPropsRecursively(i,t):{};return p(a,{key:r,...o})}else return e.map(e=>this.reconstructElementFromRscData(e,t));return typeof e==`object`?null:e}processPropsRecursively(e,t){if(!e||typeof e!=`object`)return e;let n={};for(let[r,i]of Object.entries(e))if(r===`children`)if(Array.isArray(i))if(i.length>=2&&i[0]===`$`)n[r]=this.reconstructElementFromRscData(i,t);else{let e=i.map(e=>this.reconstructElementFromRscData(e,t)).filter(e=>e!=null);e.length===0?n[r]=null:e.length===1?n[r]=e[0]:n[r]=e}else n[r]=this.reconstructElementFromRscData(i,t);else r===`dangerouslySetInnerHTML`?n[r]=i:n[r]=this.reconstructElementFromRscData(i,t);return n}};function D({error:e,details:t}){return p(`div`,{className:`rsc-error`,style:{padding:`16px`,backgroundColor:`#fee`,border:`1px solid #fcc`,borderRadius:`4px`,margin:`8px 0`,fontFamily:`monospace`}},p(`h3`,{style:{margin:`0 0 8px 0`,color:`#c00`}},`RSC Error`),p(`p`,{style:{margin:`0 0 8px 0`}},e),t&&p(`details`,{style:{marginTop:`8px`}},p(`summary`,{style:{cursor:`pointer`}},`Error Details`),p(`pre`,{style:{fontSize:`12px`,overflow:`auto`,backgroundColor:`#f5f5f5`,padding:`8px`}},JSON.stringify(t,null,2))))}function O({componentId:e,props:t,fallback:n}){let[r,i]=_({data:null,loading:!0,error:null}),a=JSON.stringify(t),o=g(a);h(()=>{let n=!0;return o.current!==a&&(i({data:null,loading:!0,error:null}),o.current=a),E.fetchServerComponent(e,t).then(e=>{n&&i({data:e,loading:!1,error:null})}).catch(e=>{n&&i({data:null,loading:!1,error:e})}),()=>{n=!1}},[e,a]);let{data:s,loading:c,error:l}=r;return c?n||null:l?p(D,{error:`Error loading component`,details:{message:l.message,componentId:e}}):s?s[`~isRscResponse`]?p(d,{fallback:n||null},s.readRoot()):s:p(D,{error:`No data received for component: ${e}`,details:{componentId:e,dataType:typeof s,hasData:!!s}})}function k(e){let t=0;if(typeof window<`u`){let n=window;n[`~rscRefreshCounters`]=n[`~rscRefreshCounters`]||{},n[`~rscRefreshCounters`][e]===void 0&&(n[`~rscRefreshCounters`][e]=0),t=n[`~rscRefreshCounters`][e]}let n=n=>{let[r,i]=_(t);return h(()=>{let t=t=>{let n=t.detail;if(n&&n.filePath&&j(n.filePath)&&(E.clearCache(),typeof window<`u`)){let t=window;t[`~rscRefreshCounters`]||={},t[`~rscRefreshCounters`][e]=(t[`~rscRefreshCounters`][e]||0)+1,i(t[`~rscRefreshCounters`][e])}};return typeof window<`u`&&window.addEventListener(`rari:rsc-invalidate`,t),()=>{typeof window<`u`&&window.removeEventListener(`rari:rsc-invalidate`,t)}},[]),p(d,{fallback:null},p(O,{key:`${e}-${r}`,componentId:e,props:n,fallback:null}))};return n.displayName=`ServerComponent(${e})`,function(e){return p(n,e)}}function A(e,t){return E.fetchServerComponent(e,t)}function j(e){if(!e)return!1;try{return typeof globalThis<`u`&&globalThis[`~rari`].serverComponents?globalThis[`~rari`].serverComponents.has(e):!1}catch(e){return console.error(`Error checking if file is server component:`,e),!1}}if(import.meta.hot){import.meta.hot.on(`rari:register-server-component`,e=>{e?.filePath&&typeof globalThis<`u`&&(globalThis[`~rari`].serverComponents=globalThis[`~rari`].serverComponents||new Set,globalThis[`~rari`].serverComponents.add(e.filePath))}),import.meta.hot.on(`rari:server-components-registry`,e=>{e?.serverComponents&&Array.isArray(e.serverComponents)&&typeof globalThis<`u`&&(globalThis[`~rari`].serverComponents=globalThis[`~rari`].serverComponents||new Set,e.serverComponents.forEach(e=>{globalThis[`~rari`].serverComponents?.add(e)}))}),import.meta.hot.on(`vite:beforeFullReload`,async e=>{e?.path&&j(e.path)&&await o({filePath:e.path,forceReload:!0})}),import.meta.hot.on(`rari:server-component-updated`,async e=>{let t=e?.id||e?.componentId,n=e?.t||e?.timestamp;if(t){if(typeof window<`u`){let r=new CustomEvent(`rari:rsc-invalidate`,{detail:{componentId:t,filePath:e.filePath||e.file,type:`server-component`,timestamp:n}});window.dispatchEvent(r)}}else e?.path&&j(e.path)&&await o({filePath:e.path,forceReload:!1})}),import.meta.hot.on(`rari:app-router-updated`,async t=>{try{if(!t)return;await e(t)}catch(e){console.error(`[rari] HMR: App router update failed:`,e)}}),import.meta.hot.on(`rari:server-action-updated`,async e=>{if(e?.filePath&&(E.clearCache(),typeof window<`u`)){let t=new CustomEvent(`rari:rsc-invalidate`,{detail:{filePath:e.filePath,type:`server-action`}});window.dispatchEvent(t)}});async function e(e){let n=e.fileType,o=e.filePath,s=e.routePath,c=e.affectedRoutes,l=e.manifestUpdated,u=e.metadata;e.metadataChanged&&u&&t(u);try{let e=`${window.location.origin}/_rari/hmr`,t=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`register`,file_path:o})});t.ok||console.error(`[rari] HMR: Component reload failed:`,t.status),await new Promise(e=>setTimeout(e,100))}catch(e){console.error(`[rari] HMR: Failed to reload component:`,e)}let d=[s];switch(n){case`page`:d=[s];break;case`layout`:case`loading`:case`error`:case`not-found`:d=c;break;default:break}await r({routes:d,fileType:n,filePath:o,componentId:s}),l&&await a(),await i({routePath:s,affectedRoutes:c})}function t(e){if(!(typeof document>`u`)&&(e.title&&(document.title=e.title),e.description)){let t=document.querySelector(`meta[name="description"]`);t||(t=document.createElement(`meta`),t.setAttribute(`name`,`description`),document.head.appendChild(t)),t.setAttribute(`content`,e.description)}}function n(e){if(!e||e.length===0){E.clearCache();return}let t=[];for(let n of E.componentCache.keys())for(let r of e){if(n.includes(`route:${r}:`)||n.startsWith(`${r}:`)){t.push(n);break}if(r!==`/`&&n.includes(`route:${r}/`)){t.push(n);break}}for(let e of t)E.componentCache.delete(e)}async function r(e){let t=e.routes||[],r=e.fileType,i=e.filePath,a=e.componentId;if(a||i)try{let e=`${window.location.origin.includes(`:5173`)?`http://localhost:3000`:window.location.origin}/_rari/hmr`,t=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`invalidate`,componentId:a||i,filePath:i})});t.ok||console.error(`[rari] HMR: Server cache invalidation failed:`,t.status)}catch(e){console.error(`[rari] HMR: Failed to call server invalidation endpoint:`,e)}if(n(t),typeof window<`u`){let e=new CustomEvent(`rari:rsc-invalidate`,{detail:{routes:t,fileType:r}});window.dispatchEvent(e);let n=window.location.pathname;if(t.includes(n)||t.includes(`/`))try{let e=(window.location.origin.includes(`:5173`)?`http://localhost:3000`:window.location.origin)+n+window.location.search,t=await fetch(e,{headers:{Accept:`text/x-component`},cache:`no-cache`});t.ok||console.error(`[rari] HMR: Failed to re-fetch route:`,t.status)}catch(e){console.error(`[rari] HMR: Failed to re-fetch route:`,e)}}}async function i(e){let t=e.routePath,n=e.affectedRoutes||[t];if(!(typeof window>`u`))try{let e=window.location.pathname,r=new CustomEvent(`rari:app-router-rerender`,{detail:{routePath:t,affectedRoutes:n,currentPath:e,preserveParams:!0}});window.dispatchEvent(r)}catch(e){throw console.error(`[rari] HMR: Failed to trigger re-render:`,e),e}}async function a(){typeof window<`u`&&window[`~rari`]?.routeInfoCache&&window[`~rari`].routeInfoCache.clear()}async function o(e){let t=e?.filePath||e;if(E.clearCache(),typeof window<`u`){let e=new CustomEvent(`rari:rsc-invalidate`,{detail:{filePath:t}});window.dispatchEvent(e)}}}var M=class{overlay;currentError;constructor(){this.overlay=null,this.currentError=null}show(e){this.currentError=e,this.overlay?this.updateOverlay(e):this.createOverlay(e)}hide(){this.overlay&&(this.overlay.remove(),this.overlay=null,this.currentError=null)}isVisible(){return this.overlay!==null}createOverlay(e){this.overlay=document.createElement(`div`),this.overlay.id=`rari-hmr-error-overlay`,this.updateOverlay(e),document.body.appendChild(this.overlay)}updateOverlay(e){if(!this.overlay)return;let t=e.filePath?`<div style="margin-bottom: 1rem; padding: 0.75rem; background: rgba(0, 0, 0, 0.2); border-radius: 0.375rem; font-family: monospace; font-size: 0.875rem;"><strong>File:</strong> ${this.escapeHtml(e.filePath)}</div>`:``,n=e.stack?`<details style="margin-top: 1rem; cursor: pointer;"><summary style="font-weight: 600; margin-bottom: 0.5rem; user-select: none;">Stack Trace</summary><pre style="margin: 0; padding: 0.75rem; background: rgba(0, 0, 0, 0.2); border-radius: 0.375rem; overflow-x: auto; font-size: 0.875rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word;">${this.escapeHtml(e.stack)}</pre></details>`:``;this.overlay.innerHTML=`<div style="position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.85); z-index: 999999; display: flex; align-items: center; justify-content: center; padding: 2rem; backdrop-filter: blur(4px);"><div style="background: #1e1e1e; color: #e0e0e0; border-radius: 0.5rem; padding: 2rem; max-width: 50rem; width: 100%; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.4); border: 1px solid #ef4444;"><div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem;"><div style="display: flex; align-items: center; gap: 0.75rem;"><svg style="width: 2rem; height: 2rem; color: #ef4444;" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"></path></svg><h1 style="margin: 0; font-size: 1.5rem; font-weight: 700; color: #ef4444;">Build Error</h1></div><button onclick="document.getElementById('rari-hmr-error-overlay').remove()" style="background: transparent; border: none; color: #9ca3af; cursor: pointer; padding: 0.5rem; border-radius: 0.25rem; transition: all 0.2s; font-size: 1.5rem; line-height: 1; width: 2rem; height: 2rem; display: flex; align-items: center; justify-content: center;" onmouseover="this.style.background='rgba(255,255,255,0.1)'; this.style.color='#e0e0e0'" onmouseout="this.style.background='transparent'; this.style.color='#9ca3af'">×</button></div>${t}<div style="margin-bottom: 1.5rem;"><h2 style="margin: 0 0 0.75rem 0; font-size: 1rem; font-weight: 600; color: #fca5a5;">Error Message:</h2><pre style="margin: 0; padding: 1rem; background: rgba(239, 68, 68, 0.1); border-left: 4px solid #ef4444; border-radius: 0.375rem; overflow-x: auto; font-family: monospace; font-size: 0.875rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word; color: #fca5a5;">${this.escapeHtml(e.message)}</pre></div>${n}<div style="margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid #374151; display: flex; gap: 0.75rem; align-items: center;"><button onclick="window.location.reload()" style="padding: 0.625rem 1.25rem; background: #ef4444; color: white; border: none; border-radius: 0.375rem; cursor: pointer; font-weight: 600; font-size: 0.875rem; transition: all 0.2s;" onmouseover="this.style.background='#dc2626'" onmouseout="this.style.background='#ef4444'">Reload Page</button><button onclick="document.getElementById('rari-hmr-error-overlay').remove()" style="padding: 0.625rem 1.25rem; background: #374151; color: #e0e0e0; border: none; border-radius: 0.375rem; cursor: pointer; font-weight: 600; font-size: 0.875rem; transition: all 0.2s;" onmouseover="this.style.background='#4b5563'" onmouseout="this.style.background='#374151'">Dismiss</button><span style="margin-left: auto; font-size: 0.75rem; color: #9ca3af;">${new Date(e.timestamp).toLocaleTimeString()}</span></div></div></div>`}escapeHtml(e){let t=document.createElement(`div`);return t.textContent=e,t.innerHTML}};let N=null;function P(){return N||=new M,N}if(import.meta.hot){let e=P();import.meta.hot.on(`rari:hmr-error`,t=>{let n=t.msg||t.message,r=t.file||t.filePath,i=t.t||t.timestamp,a=t.count||t.errorCount,o=t.max||t.maxErrors;console.error(`[rari] HMR: Build error:`,n),r&&console.error(`[rari] HMR: File:`,r),t.stack&&console.error(`[rari] HMR: Stack:`,t.stack),e.show({message:n,stack:t.stack,filePath:r,timestamp:i}),a&&o&&(a>=o?console.error(`[rari] HMR: Maximum error count (${o}) reached. Consider restarting the dev server if issues persist.`):a>=o-2&&console.warn(`[rari] HMR: Error count: ${a}/${o}. Approaching maximum error threshold.`))}),import.meta.hot.on(`rari:hmr-error-cleared`,()=>{e.hide()}),import.meta.hot.on(`vite:error`,t=>{e.show({message:t.err?.message||`Unknown Vite error`,stack:t.err?.stack,filePath:t.err?.file,timestamp:Date.now()})})}export{D as RscErrorComponent,x as createClientModuleMap,k as createServerComponentWrapper,A as fetchServerComponent,b as getClientComponent,y as registerClientComponent,E as rscClient};
|