rari 0.10.7 → 0.10.8
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 +1 -1
- package/dist/client.d.mts +7 -1
- package/dist/client.mjs +3 -3
- package/dist/{index-Dc4oQSkA.d.mts → index-tSrOMrRG.d.mts} +2 -1
- package/dist/index.d.mts +4 -3
- package/dist/index.mjs +1 -1
- package/dist/navigate-BTY-aYi_.mjs +1 -0
- package/dist/proxy/RariRequest.d.mts +1 -1
- package/dist/proxy/RariResponse.d.mts +1 -1
- package/dist/{railway-BlR0qYfX.mjs → railway-UP19UVM3.mjs} +1 -1
- package/dist/{render-Cn2qdfZI.mjs → render-CL95kAwR.mjs} +1 -1
- package/dist/router.d.mts +40 -0
- package/dist/router.mjs +1 -0
- package/dist/runtime/AppRouterProvider.mjs +4 -4
- package/dist/runtime/entry-client.mjs +4 -4
- package/dist/runtime/react-server-dom-rari-client.mjs +1 -1
- package/dist/runtime/rsc-client-runtime.mjs +1 -1
- package/dist/{server-build-BaEm53O_.mjs → server-build-BbPx0SOe.mjs} +1 -1
- package/dist/{server-config-Bi4AvErE.d.mts → server-config-CDW6dUXy.d.mts} +1 -164
- package/dist/types-DYoUsyof.d.mts +166 -0
- package/dist/{vite-Dm2UZbFt.mjs → vite-B-jD5pXc.mjs} +2 -2
- package/dist/vite.d.mts +4 -3
- package/dist/vite.mjs +1 -1
- package/package.json +10 -6
- /package/dist/{get-client-component-CpMI09nb.mjs → get-client-component-DuyG4UOi.mjs} +0 -0
- /package/dist/{preload-components-5Y8ZOaFG.mjs → preload-components-RxFu9xLE.mjs} +0 -0
- /package/dist/{robots-generator-Bo5MHa-v.mjs → robots-generator-CA3pR8ZY.mjs} +0 -0
- /package/dist/{sitemap-generator-D_gTjklw.mjs → sitemap-generator-yW1rcKZr.mjs} +0 -0
- /package/dist/{types-BQ-op_Tc.d.mts → types-BV0iON-q.d.mts} +0 -0
- /package/dist/{utils-BTyXoHUx-Cp3JPZPF.mjs → utils-BTyXoHUx-BVw3bTZu.mjs} +0 -0
package/dist/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
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-
|
|
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-UP19UVM3.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-CL95kAwR.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
|
package/dist/client.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as extractServerPropsWithCache, S as extractServerProps, T as hasServerSideDataFetching, _ as ServerSidePropsResult, a as ServerSpamBlockerConfig, b as clearPropsCacheForComponent, c as ErrorBoundary, d as NotFound, f as RuntimeClient, g as MetadataResult, h as createLoadingBoundary, i as ServerRateLimitConfig, l as HttpRuntimeClient, m as createHttpRuntimeClient, o as DefaultError, p as createErrorBoundary, r as ServerConfig, s as DefaultLoading, t as ServerCSPConfig, u as LoadingSpinner, v as StaticParamsResult, w as extractStaticParams, x as extractMetadata, y as clearPropsCache } from "./server-config-CDW6dUXy.mjs";
|
|
2
|
+
import { a as ErrorProps, c as LayoutEntry, f as NotFoundEntry, h as RouteSegmentType, i as ErrorEntry, m as RouteSegment, n as AppRouteManifest, o as GenerateMetadata, r as AppRouteMatch, s as GenerateStaticParams, t as AppRouteEntry, u as LoadingEntry } from "./types-DYoUsyof.mjs";
|
|
2
3
|
import * as React from "react";
|
|
3
4
|
import { Component, ErrorInfo, ReactNode } from "react";
|
|
4
5
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
@@ -91,6 +92,11 @@ interface RouteInfoResponse {
|
|
|
91
92
|
loading: string | null;
|
|
92
93
|
isDynamic: boolean;
|
|
93
94
|
params?: string[];
|
|
95
|
+
segments?: Array<{
|
|
96
|
+
type: 'static' | 'dynamic' | 'catch-all' | 'optional-catch-all';
|
|
97
|
+
value: string;
|
|
98
|
+
param?: string;
|
|
99
|
+
}>;
|
|
94
100
|
}
|
|
95
101
|
interface RouteInfoError {
|
|
96
102
|
error: string;
|
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 _,useLayoutEffect as v,useRef as y,useState as b}from"react";import{Fragment as x,jsx as S,jsxs as C}from"react/jsx-runtime";function w(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 T(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 E=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=T(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 D(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 O(e,t){try{return new URL(e,t||window.location.origin).origin!==(t||window.location.origin)}catch{return!1}}function k(e){try{let t=new URL(e,window.location.origin);return t.pathname+t.hash}catch{return e}}function A({error:e,onRetry:t,onReload:n,onDismiss:r,retryCount:i=0,maxRetries:a=3}){let o=e.retryable&&i<a;return S(`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:C(`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:[C(`div`,{style:{display:`flex`,alignItems:`center`,gap:`12px`,marginBottom:`16px`},children:[S(`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`❌`}})()}),S(`h2`,{style:{margin:0,fontSize:`20px`,fontWeight:`600`,color:`#1f2937`},children:`Navigation Error`})]}),S(`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&&C(`details`,{style:{marginBottom:`16px`,fontSize:`13px`,color:`#6b7280`},children:[S(`summary`,{style:{cursor:`pointer`,userSelect:`none`,marginBottom:`8px`},children:`Technical details`}),C(`div`,{style:{padding:`12px`,background:`#f9fafb`,borderRadius:`4px`,fontFamily:`monospace`,fontSize:`12px`,wordBreak:`break-all`},children:[C(`div`,{style:{marginBottom:`4px`},children:[S(`strong`,{children:`URL:`}),` `,e.url]}),e.statusCode&&C(`div`,{style:{marginBottom:`4px`},children:[S(`strong`,{children:`Status:`}),` `,e.statusCode]}),C(`div`,{style:{marginBottom:`4px`},children:[S(`strong`,{children:`Type:`}),` `,e.type]}),e.originalError&&C(`div`,{children:[S(`strong`,{children:`Error:`}),` `,e.originalError.message]})]})]}),o&&i>0&&C(`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]}),C(`div`,{style:{display:`flex`,gap:`8px`,flexWrap:`wrap`},children:[o&&t&&S(`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&&S(`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&&S(`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`})]}),S(`p`,{style:{marginTop:`16px`,marginBottom:0,fontSize:`12px`,color:`#9ca3af`,textAlign:`center`},children:`Your current page is still available below this message`})]})})}const j=new class{cache=new Map;pendingRequests=new Map;async get(e){let t=this.cache.get(e);if(t)return t;let n=this.pendingRequests.get(e);if(n)return n;let r=this.fetchRouteInfo(e);this.pendingRequests.set(e,r);try{let t=await r;return this.cache.set(e,t),t}finally{this.pendingRequests.delete(e)}}async fetchRouteInfo(e){let t={path:e},n=await fetch(`/_rari/route-info`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=null;try{e=await n.json()}catch{}throw e?.error?Error(e.error):Error(`Failed to fetch route info: ${n.status} ${n.statusText}`)}let r=n.clone();try{return await n.json()}catch(t){try{let e=await r.text();return JSON.parse(e)}catch(n){throw console.error(`[RouteInfo] Failed to parse response:`,{error:t,parseError:n,path:e}),Error(`Failed to parse route info response`)}}}clear(){this.cache.clear(),this.pendingRequests.clear()}invalidate(e){this.cache.delete(e)}};if(typeof window<`u`){let e=window[`~rari`]||{};window[`~rari`]||(window[`~rari`]=e),e.routeInfoCache=j}var M=class{stateHistory;routeAccessOrder;maxHistorySize;scrollableSelector;constructor(e={}){this.stateHistory=new Map,this.routeAccessOrder=[],this.maxHistorySize=e.maxHistorySize||50,this.scrollableSelector=e.scrollableSelector||`[data-scrollable], .scrollable, [style*="overflow"]`}captureState(e){let t={scrollPositions:this.captureScrollPositions(),formData:this.captureFormData(),focusedElement:this.captureFocusedElement()};return this.storeState(e,t),t}captureScrollPositions(){let e=new Map;try{e.set(`window`,{x:window.scrollX,y:window.scrollY,element:`window`}),document.querySelectorAll(this.scrollableSelector).forEach((t,n)=>{if(t instanceof HTMLElement){let r=t.id||`scrollable-${n}`;(t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth)&&e.set(r,{x:t.scrollLeft,y:t.scrollTop,element:r})}})}catch{}return e}captureFormData(){let e=new Map;try{document.querySelectorAll(`form`).forEach((t,n)=>{let r=t.id||t.name||`form-${n}`,i=new FormData(t);i.entries().next().done||e.set(r,i)})}catch{}return e}captureFocusedElement(){try{let e=document.activeElement;if(e&&e!==document.body){if(e.id)return`#${e.id}`;if((e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&e.name)return`[name="${e.name}"]`}}catch{}return null}storeState(e,t){let n=this.routeAccessOrder.indexOf(e);for(n!==-1&&this.routeAccessOrder.splice(n,1),this.routeAccessOrder.push(e),this.stateHistory.set(e,t);this.routeAccessOrder.length>this.maxHistorySize;){let e=this.routeAccessOrder.shift();e&&this.stateHistory.delete(e)}}getHistorySize(){return this.stateHistory.size}hasState(e){return this.stateHistory.has(e)}getState(e){return this.stateHistory.get(e)}clearAll(){this.stateHistory.clear(),this.routeAccessOrder=[]}clearState(e){this.stateHistory.delete(e);let t=this.routeAccessOrder.indexOf(e);t!==-1&&this.routeAccessOrder.splice(t,1)}restoreState(e){let t=this.stateHistory.get(e);if(!t)return!1;let n=!0;return this.restoreScrollPositions(t.scrollPositions)||(n=!1),this.restoreFormData(t.formData)||(n=!1),t.focusedElement&&this.restoreFocus(t.focusedElement),n}restoreScrollPositions(e){let t=!0;try{e.forEach((e,n)=>{try{if(n===`window`)window.scrollTo(e.x,e.y);else{let r=document.getElementById(n)||document.querySelector(`[data-scrollable-id="${n}"]`);r instanceof HTMLElement?(r.scrollLeft=e.x,r.scrollTop=e.y):t=!1}}catch{t=!1}})}catch(e){console.error(`[rari] Router: Failed to restore scroll positions:`,e),t=!1}return t}restoreFormData(e){let t=!0;try{e.forEach((e,n)=>{try{let r=document.getElementById(n)||document.querySelector(`form[name="${n}"]`)||document.querySelectorAll(`form`)[Number.parseInt(n.replace(`form-`,``),10)];r instanceof HTMLFormElement?e.forEach((e,n)=>{try{let t=r.elements.namedItem(n);t instanceof RadioNodeList?t.forEach(t=>{t instanceof HTMLInputElement&&(t.type===`radio`||t.type===`checkbox`?t.checked=t.value===e:t.value=e)}):(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)&&(t instanceof HTMLInputElement&&(t.type===`checkbox`||t.type===`radio`)?t.checked=t.value===e:t.value=e)}catch{t=!1}}):t=!1}catch{t=!1}})}catch(e){console.error(`[rari] Router: Failed to restore form data:`,e),t=!1}return t}restoreFocus(e){try{let t=document.querySelector(e);t instanceof HTMLElement&&requestAnimationFrame(()=>{try{t.focus()}catch{}})}catch{}}};function N(e){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 P({children:e,initialRoute:t,staleWindowMs:n=3e4}){let[r,i]=b(()=>({currentRoute:D(t),navigationId:0,error:null})),a=y(null),o=y(!0),s=y(D(t)),c=y(new E({timeout:1e4,maxRetries:3,onError:e=>{console.error(`[rari] Router: Navigation error:`,e)},onRetry:()=>{}})),l=y(new Map),u=y([]),d=y(new M({maxHistorySize:50})),f=y(null),p=y(n),m=()=>`${Date.now()}-${Math.random().toString(36).substring(2,9)}`,h=()=>{a.current&&=(a.current.abort(),null)},g=()=>{for(let[,e]of l.current.entries())e.abortController.abort();l.current.clear()},T=(e,t)=>{l.current.delete(e),o.current&&r.navigationId===t&&i(e=>({...e}))},P=async e=>j.get(e),F=y(null),I=async(e,t={})=>{if(!e||typeof e!=`string`){console.error(`[rari] Router: Invalid navigation target:`,e);return}let[n,u]=e.includes(`#`)?e.split(`#`):[e,``],f=D(n);if(f===s.current&&!t.replace){if(u){let e=document.getElementById(u);e&&(e.scrollIntoView({behavior:`smooth`,block:`start`}),window.history.pushState(window.history.state,``,`${f}#${u}`))}return}let p=l.current.get(f);if(p)return p.promise;let _=await P(f);g(),h();let v=new AbortController;a.current=v;let y=r.navigationId+1,b=(async()=>{let e=s.current;try{t.historyKey||d.current.captureState(e);let n=t.historyKey||m(),r={route:f,navigationId:y,scrollPosition:{x:window.scrollX,y:window.scrollY},timestamp:Date.now(),key:n},a=u?`${f}#${u}`:f;t.replace?window.history.replaceState(r,``,a):window.history.pushState(r,``,a);let p=window.location.origin+f,h=await fetch(p,{headers:{Accept:`text/x-component`},signal:v.signal});if(!h.ok&&h.status!==404)throw Error(`Failed to fetch: ${h.status}`);let g=new URL(h.url).pathname,b=g===f?f:g;if(g!==f){let e=u?`${g}#${u}`:g;window.history.replaceState({route:g,navigationId:y,scrollPosition:{x:window.scrollX,y:window.scrollY},timestamp:Date.now(),key:t.historyKey||m()},``,e)}if(v.signal.aborted){T(b,y);return}try{let e=h.headers.get(`x-rari-metadata`);if(e){let t=decodeURIComponent(e);N(JSON.parse(t))}}catch{}if(h.headers.get(`x-render-mode`)===`streaming`&&h.body){let n=h.body.getReader(),r=new TextDecoder,i=``;try{for(;;){let{done:e,value:t}=await n.read();if(e)break;if(v.signal.aborted){await n.cancel(),T(b,y);return}i+=r.decode(t,{stream:!0});let a=i.split(`
|
|
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:b,navigationId:y,options:t,routeInfo:
|
|
3
|
-
`,this.state.error.stack]})]}),
|
|
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{i as g,t as _}from"./navigate-BTY-aYi_.mjs";import{Component as v,useEffect as y,useLayoutEffect as b,useRef as x,useState as S}from"react";import{Fragment as C,jsx as w,jsxs as T}from"react/jsx-runtime";function E(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 D(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 O=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=D(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()}};const k=/(^\/+)|(\/+$)/g;function A(e){let t=e.replace(k,``);return t?t.split(`/`):[]}function j(e,t,n){let r=A(n),i={},a=0;for(let e=0;e<t.length;e++){let n=t[e];if(a>=r.length){if(n.type===`optional-catch-all`){n.param&&(i[n.param]=[]);continue}return null}switch(n.type){case`static`:if(r[a]!==n.value)return null;a++;break;case`dynamic`:n.param&&(i[n.param]=r[a]),a++;break;case`catch-all`:case`optional-catch-all`:n.param&&(i[n.param]=r.slice(a)),a=r.length;break}}return a===r.length?i:null}function M(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 N(e,t){try{return new URL(e,t||window.location.origin).origin!==(t||window.location.origin)}catch{return!1}}function P(e){try{let t=new URL(e,window.location.origin);return t.pathname+t.hash}catch{return e}}function F({error:e,onRetry:t,onReload:n,onDismiss:r,retryCount:i=0,maxRetries:a=3}){let o=e.retryable&&i<a;return w(`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:T(`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:[T(`div`,{style:{display:`flex`,alignItems:`center`,gap:`12px`,marginBottom:`16px`},children:[w(`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`❌`}})()}),w(`h2`,{style:{margin:0,fontSize:`20px`,fontWeight:`600`,color:`#1f2937`},children:`Navigation Error`})]}),w(`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&&T(`details`,{style:{marginBottom:`16px`,fontSize:`13px`,color:`#6b7280`},children:[w(`summary`,{style:{cursor:`pointer`,userSelect:`none`,marginBottom:`8px`},children:`Technical details`}),T(`div`,{style:{padding:`12px`,background:`#f9fafb`,borderRadius:`4px`,fontFamily:`monospace`,fontSize:`12px`,wordBreak:`break-all`},children:[T(`div`,{style:{marginBottom:`4px`},children:[w(`strong`,{children:`URL:`}),` `,e.url]}),e.statusCode&&T(`div`,{style:{marginBottom:`4px`},children:[w(`strong`,{children:`Status:`}),` `,e.statusCode]}),T(`div`,{style:{marginBottom:`4px`},children:[w(`strong`,{children:`Type:`}),` `,e.type]}),e.originalError&&T(`div`,{children:[w(`strong`,{children:`Error:`}),` `,e.originalError.message]})]})]}),o&&i>0&&T(`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]}),T(`div`,{style:{display:`flex`,gap:`8px`,flexWrap:`wrap`},children:[o&&t&&w(`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&&w(`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&&w(`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`})]}),w(`p`,{style:{marginTop:`16px`,marginBottom:0,fontSize:`12px`,color:`#9ca3af`,textAlign:`center`},children:`Your current page is still available below this message`})]})})}const I=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=null;try{e=await n.json()}catch{}throw e?.error?Error(e.error):Error(`Failed to fetch route info: ${n.status} ${n.statusText}`)}let r=n.clone();try{return await n.json()}catch(t){try{let e=await r.text();return JSON.parse(e)}catch(n){throw console.error(`[RouteInfo] Failed to parse response:`,{error:t,parseError:n,path:e}),Error(`Failed to parse route info response`)}}}clear(){this.cache.clear(),this.pendingRequests.clear()}invalidate(e){this.cache.delete(e)}};if(typeof window<`u`){let e=window[`~rari`]||{};window[`~rari`]||(window[`~rari`]=e),e.routeInfoCache=I}var L=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 R(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 z({children:e,initialRoute:t,staleWindowMs:n=3e4}){let[r,i]=S(()=>({currentRoute:M(t),navigationId:0,error:null})),a=x(null),o=x(!0),s=x(M(t)),c=x(new O({timeout:1e4,maxRetries:3,onError:e=>{console.error(`[rari] Router: Navigation error:`,e)},onRetry:()=>{}})),l=x(new Map),u=x([]),d=x(new L({maxHistorySize:50})),f=x(null),p=x(n),m=()=>`${Date.now()}-${Math.random().toString(36).substring(2,9)}`,h=()=>{a.current&&=(a.current.abort(),null)},v=()=>{for(let[,e]of l.current.entries())e.abortController.abort();l.current.clear()},D=(e,t)=>{l.current.delete(e),o.current&&r.navigationId===t&&i(e=>({...e}))},k=async e=>I.get(e),A=x(null),z=async(e,t={})=>{if(!e||typeof e!=`string`){console.error(`[rari] Router: Invalid navigation target:`,e);return}let[n,u]=e.includes(`#`)?e.split(`#`):[e,``],f=M(n);if(f===s.current&&!t.replace){if(u){let e=document.getElementById(u);e&&(e.scrollIntoView({behavior:`smooth`,block:`start`}),window.history.pushState(window.history.state,``,`${f}#${u}`))}return}let p=l.current.get(f);if(p)return p.promise;let g=await k(f);v(),h();let _=new AbortController;a.current=_;let y=r.navigationId+1,b=(async()=>{let e=s.current;try{t.historyKey||d.current.captureState(e);let n=t.historyKey||m(),r={route:f,navigationId:y,scrollPosition:{x:window.scrollX,y:window.scrollY},timestamp:Date.now(),key:n},a=u?`${f}#${u}`:f;t.replace?window.history.replaceState(r,``,a):window.history.pushState(r,``,a);let p=window.location.origin+f,h=await fetch(p,{headers:{Accept:`text/x-component`},signal:_.signal});if(!h.ok&&h.status!==404)throw Error(`Failed to fetch: ${h.status}`);let v=new URL(h.url).pathname,b=v===f?f:v;if(v!==f){let e=u?`${v}#${u}`:v;window.history.replaceState({route:v,navigationId:y,scrollPosition:{x:window.scrollX,y:window.scrollY},timestamp:Date.now(),key:t.historyKey||m()},``,e)}if(_.signal.aborted){D(b,y);return}try{let e=h.headers.get(`x-rari-metadata`);if(e){let t=decodeURIComponent(e);R(JSON.parse(t))}}catch{}let x=h.headers.get(`x-render-mode`)===`streaming`,S=g?.segments&&j(``,g.segments,b)||{};if(x&&h.body){let n=h.body.getReader(),r=new TextDecoder,i=``;try{for(;;){let{done:e,value:t}=await n.read();if(e)break;if(_.signal.aborted){await n.cancel(),D(b,y);return}i+=r.decode(t,{stream:!0});let a=i.split(`
|
|
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:b,navigationId:y,options:t,routeInfo:{...g,extractedParams:S},abortSignal:_.signal,isStreaming:!0}}))}catch(e){throw console.error(`[rari] Router: Streaming error:`,e),e}}else{let n=await h.text();window.dispatchEvent(new CustomEvent(`rari:navigate`,{detail:{from:e,to:b,navigationId:y,options:t,routeInfo:{...g,extractedParams:S},abortSignal:_.signal,rscWireFormat:n}}))}if(_.signal.aborted){D(b,y);return}o.current&&(s.current=b,i(e=>({...e,currentRoute:b,error:null})),c.current.resetRetry(b),t.historyKey?requestAnimationFrame(()=>{d.current.restoreState(b)}):u&&requestAnimationFrame(()=>{let e=(t=0)=>{let n=document.getElementById(u);n?n.scrollIntoView({behavior:`smooth`,block:`start`}):t<10&&setTimeout(e,50,t+1)};e()})),l.current.delete(f),A.current?.()}catch(t){if(t instanceof Error&&t.name===`AbortError`){D(f,y);return}let n=c.current.handleError(t,f);o.current&&i(e=>({...e,error:n})),l.current.delete(f),window.dispatchEvent(new CustomEvent(`rari:navigate-error`,{detail:{from:e,to:f,error:n,navigationId:y}})),A.current?.()}})();return l.current.set(f,{targetPath:f,navigationId:y,promise:b,abortController:_}),b},B=async()=>{if(u.current.length===0)return;let e=u.current.at(-1);e&&(u.current=[],await z(e.path,e.options))},V=x(z);b(()=>(A.current=B,V.current=z,()=>{A.current=null,V.current=null}));let H=x(null);H.current||=E((e,t)=>{V.current?.(e,t)},50,{leading:!1,trailing:!0,maxWait:200});let U=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||N(r))return;if(r.startsWith(`#`)){e.preventDefault();let t=r.slice(1),n=document.getElementById(t);n&&(n.scrollIntoView({behavior:`smooth`,block:`start`}),window.history.pushState(window.history.state,``,r));return}e.preventDefault();let i=P(r);H.current&&H.current(i,{replace:!1})},W=e=>{let t=window.location.pathname,n=e.state;V.current&&V.current(t,{replace:!0,scroll:!1,historyKey:n?.key})},G=()=>{if(r.error&&r.error.url){let e=r.error.url;c.current.incrementRetry(e),z(e,{replace:!1})}},K=()=>{window.location.reload()},q=()=>{i(e=>({...e,error:null}))};y(()=>{let e=window.history.state;if(!e||!e.key){let e={route:r.currentRoute,navigationId:r.navigationId,scrollPosition:{x:window.scrollX,y:window.scrollY},timestamp:Date.now(),key:m()};window.history.replaceState(e,``,window.location.pathname+window.location.search+window.location.hash)}},[]);let J=e=>{if(e.persisted){let e=window.location.pathname;d.current.captureState(e)}},Y=e=>{if(e.persisted){let e=window.location.pathname,t=window.history.state;requestAnimationFrame(()=>{d.current.restoreState(e),t?.scrollPosition&&window.scrollTo(t.scrollPosition.x,t.scrollPosition.y)})}};return y(()=>(document.addEventListener(`click`,U),window.addEventListener(`popstate`,W),window.addEventListener(`pagehide`,J),window.addEventListener(`pageshow`,Y),()=>{document.removeEventListener(`click`,U),window.removeEventListener(`popstate`,W),window.removeEventListener(`pagehide`,J),window.removeEventListener(`pageshow`,Y)}),[]),y(()=>{p.current=n;let e=()=>{document.hidden?f.current=Date.now():f.current!==null&&Date.now()-f.current>p.current&&I.clear()};return document.addEventListener(`visibilitychange`,e),()=>{document.removeEventListener(`visibilitychange`,e)}},[n]),y(()=>(o.current=!0,g((e,t)=>V.current?.(e,t)??Promise.resolve()),()=>{o.current=!1,_(),h(),v(),H.current?.cancel&&H.current.cancel()}),[]),T(C,{children:[e,r.error&&w(F,{error:r.error,onRetry:G,onReload:K,onDismiss:q,retryCount:c.current.getRetryCount(r.error.url||``),maxRetries:3})]})}var B=class extends v{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):T(`div`,{style:{padding:`16px`,margin:`16px 0`,background:`#fee`,border:`1px solid #fcc`,borderRadius:`4px`},children:[w(`h3`,{style:{margin:`0 0 8px 0`,color:`#c00`},children:`Layout Error`}),T(`p`,{style:{margin:`0 0 8px 0`,fontSize:`14px`},children:[`An error occurred in layout:`,` `,w(`code`,{children:this.props.layoutPath})]}),T(`details`,{style:{fontSize:`12px`,marginBottom:`8px`},children:[w(`summary`,{style:{cursor:`pointer`},children:`Error details`}),T(`pre`,{style:{marginTop:`8px`,padding:`8px`,background:`#fff`,border:`1px solid #ddd`,borderRadius:`2px`,overflow:`auto`},children:[this.state.error.message,`
|
|
3
|
+
`,this.state.error.stack]})]}),w(`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{z as ClientRouter,m as DefaultError,l as DefaultLoading,f as ErrorBoundary,o as HttpRuntimeClient,B as LayoutErrorBoundary,e as LoadingSpinner,O as NavigationErrorHandler,F as NavigationErrorOverlay,u as NotFound,L 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};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as ServerSpamBlockerConfig, i as ServerRateLimitConfig, n as ServerCacheControlConfig, t as ServerCSPConfig } from "./server-config-CDW6dUXy.mjs";
|
|
2
|
+
import { n as AppRouteManifest } from "./types-DYoUsyof.mjs";
|
|
2
3
|
import { Plugin, UserConfig } from "rolldown-vite";
|
|
3
4
|
|
|
4
5
|
//#region src/fetch-cache.d.ts
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { a as
|
|
1
|
+
import { C as extractServerPropsWithCache, S as extractServerProps, T as hasServerSideDataFetching, _ as ServerSidePropsResult, a as ServerSpamBlockerConfig, b as clearPropsCacheForComponent, f as RuntimeClient, g as MetadataResult, i as ServerRateLimitConfig, l as HttpRuntimeClient, m as createHttpRuntimeClient, r as ServerConfig, t as ServerCSPConfig, v as StaticParamsResult, w as extractStaticParams, x as extractMetadata, y as clearPropsCache } from "./server-config-CDW6dUXy.mjs";
|
|
2
|
+
import { a as ErrorProps, c as LayoutEntry, d as Metadata, f as NotFoundEntry, h as RouteSegmentType, i as ErrorEntry, l as LayoutProps, m as RouteSegment, n as AppRouteManifest, o as GenerateMetadata, p as PageProps, r as AppRouteMatch, s as GenerateStaticParams, t as AppRouteEntry, u as LoadingEntry } from "./types-DYoUsyof.mjs";
|
|
3
|
+
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-tSrOMrRG.mjs";
|
|
4
|
+
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-BV0iON-q.mjs";
|
|
4
5
|
import { RariRequest } from "./proxy/RariRequest.mjs";
|
|
5
6
|
import { RariResponse } from "./proxy/RariResponse.mjs";
|
|
6
7
|
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-B-jD5pXc.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-DMuIAFub.mjs";import{t as _}from"./routes-DXBE0bwy.mjs";import"./constants-DZAg-dr0.mjs";import"./server-build-BbPx0SOe.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
let e=null;function t(){return e}function n(t){if(typeof window>`u`){console.warn(`[rari] Router cannot register navigate in non-browser environment`);return}e&&typeof process<`u`&&process.env.NODE_ENV!==`production`&&console.warn(`[rari] Router: registerNavigate called multiple times, overwriting existing navigate function`,{previous:e,new:t}),e=t,window.dispatchEvent(new CustomEvent(`rari:register-navigate`,{detail:{navigate:t}}))}function r(){if(typeof window>`u`){console.warn(`[rari] Router cannot deregister navigate in non-browser environment`);return}e=null,window.dispatchEvent(new CustomEvent(`rari:deregister-navigate`))}async function i(t,n){if(typeof window>`u`){console.warn(`[rari] Router cannot navigate in non-browser environment`);return}if(!e){console.warn(`[rari] Router not initialized, falling back to window.location`),n?.replace?window.location.replace(t):window.location.href=t;return}return e(t,n)}export{n as i,t as n,i as r,r as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e,i as t,n,r,t as i}from"./utils-BTyXoHUx-
|
|
1
|
+
import{a as e,i as t,n,r,t as i}from"./utils-BTyXoHUx-BVw3bTZu.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]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e,i as t,n,r,t as i}from"./utils-BTyXoHUx-
|
|
1
|
+
import{a as e,i as t,n,r,t as i}from"./utils-BTyXoHUx-BVw3bTZu.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,40 @@
|
|
|
1
|
+
import "./types-DYoUsyof.mjs";
|
|
2
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
//#region src/router/navigation-types.d.ts
|
|
5
|
+
interface NavigationOptions {
|
|
6
|
+
replace?: boolean;
|
|
7
|
+
scroll?: boolean;
|
|
8
|
+
shallow?: boolean;
|
|
9
|
+
historyKey?: string;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/router/navigate.d.ts
|
|
13
|
+
declare function navigate(href: string, options?: NavigationOptions): Promise<void>;
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/router/use-router.d.ts
|
|
16
|
+
interface RouterContextValue {
|
|
17
|
+
pathname: string;
|
|
18
|
+
params: Record<string, string | string[]>;
|
|
19
|
+
searchParams: URLSearchParams;
|
|
20
|
+
push: (href: string, options?: NavigationOptions) => Promise<void>;
|
|
21
|
+
replace: (href: string, options?: NavigationOptions) => Promise<void>;
|
|
22
|
+
back: () => void;
|
|
23
|
+
forward: () => void;
|
|
24
|
+
refresh: () => void;
|
|
25
|
+
prefetch: (href: string) => Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
interface RouterProviderProps {
|
|
28
|
+
children: React.ReactNode;
|
|
29
|
+
initialPathname: string;
|
|
30
|
+
}
|
|
31
|
+
declare function RouterProvider({
|
|
32
|
+
children,
|
|
33
|
+
initialPathname
|
|
34
|
+
}: RouterProviderProps): react_jsx_runtime0.JSX.Element;
|
|
35
|
+
declare function useRouter(): RouterContextValue;
|
|
36
|
+
declare function usePathname(): string;
|
|
37
|
+
declare function useParams(): Record<string, string | string[]>;
|
|
38
|
+
declare function useSearchParams(): URLSearchParams;
|
|
39
|
+
//#endregion
|
|
40
|
+
export { type NavigationOptions, type RouterContextValue, RouterProvider, type RouterProviderProps, navigate, useParams, usePathname, useRouter, useSearchParams };
|
package/dist/router.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,r as t}from"./navigate-BTY-aYi_.mjs";import{createContext as n,use as r,useEffect as i,useMemo as a,useRef as o,useState as s}from"react";import{jsx as c}from"react/jsx-runtime";const l=n(null);function u({children:t,initialPathname:n}){let[r,u]=s(n),[d,f]=s(()=>typeof window<`u`?new URLSearchParams(window.location.search):new URLSearchParams),[p,m]=s({}),h=o(null);return i(()=>{let e=e=>{let t=e.detail;t?.to&&(u(t.to),f(new URLSearchParams(window.location.search)),t?.routeInfo?.extractedParams?m(t.routeInfo.extractedParams):m({}))};return window.addEventListener(`rari:navigate`,e),()=>{window.removeEventListener(`rari:navigate`,e)}},[]),i(()=>{let t=e();t&&(h.current=t);let n=e=>{h.current=e.detail.navigate},r=()=>{h.current=null};return window.addEventListener(`rari:register-navigate`,n),window.addEventListener(`rari:deregister-navigate`,r),()=>{window.removeEventListener(`rari:register-navigate`,n),window.removeEventListener(`rari:deregister-navigate`,r)}},[]),c(l,{value:a(()=>({pathname:r,params:p,searchParams:d,push:async(e,t)=>{h.current?await h.current(e,t):(console.warn(`[rari] Router not ready, falling back to window.location`),window.location.href=e)},replace:async(e,t)=>{h.current?await h.current(e,{...t,replace:!0}):(console.warn(`[rari] Router not ready, falling back to window.location`),window.location.replace(e))},back:()=>{window.history.back()},forward:()=>{window.history.forward()},refresh:()=>{window.dispatchEvent(new CustomEvent(`rari:app-router-rerender`))},prefetch:async e=>{try{let t=new URL(e,window.location.origin);await fetch(t.pathname+t.search,{headers:{Accept:`text/x-component`},priority:`low`})}catch(e){console.warn(`[rari] Prefetch failed:`,e)}}}),[r,p,d]),children:t})}function d(){let e=r(l);if(!e)throw Error(`useRouter must be used within a RouterProvider`);return e}function f(){return d().pathname}function p(){return d().params}function m(){return d().searchParams}export{u as RouterProvider,t as navigate,p as useParams,f as usePathname,d as useRouter,m as useSearchParams};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use client";import{S as e,b as t}from"../regex-constants-DMuIAFub.mjs";import{t as n}from"../preload-components-
|
|
1
|
+
"use client";import{S as e,b as t}from"../regex-constants-DMuIAFub.mjs";import{t as n}from"../preload-components-RxFu9xLE.mjs";import*as r from"react";import{Suspense as i,useEffect as a,useRef as o,useState as s,useTransition as c}from"react";import{Fragment as l,jsx as u,jsxs as d}from"react/jsx-runtime";const f=/"timestamp":(\d+)/,p=/^[;\s]*$/;function m(){return d(`div`,{style:{position:`fixed`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,display:`flex`,alignItems:`center`,justifyContent:`center`,zIndex:9999},children:[u(`div`,{style:{width:`40px`,height:`40px`,border:`4px solid rgba(0, 0, 0, 0.1)`,borderTopColor:`#3b82f6`,borderRadius:`50%`,animation:`spin 1s linear infinite`}}),u(`style`,{children:`
|
|
2
2
|
@keyframes spin {
|
|
3
3
|
to { transform: rotate(360deg); }
|
|
4
4
|
}
|
|
5
|
-
`})]})}function h({children:h,initialPayload:g,onNavigate:_}){let[v,y]=s(g),[,b]=s(0),x=o({x:0,y:0}),S=o(new Map),C=o(null),[,w]=c(),T=o(0),E=o(new Map),D=o([]),O=o(null),k=o(0),[A,j]=s(null),M=()=>{if(typeof document>`u`)return;let e=document.querySelectorAll(`form`);S.current.clear(),e.forEach((e,t)=>{let n=new FormData(e);S.current.set(`form-${t}`,n)})},
|
|
6
|
-
`),o=new Map,s=new Map,c=new Map,l=null,u=[],d=null,f=null;for(let e=0;e<a.length;e++){let n=a[e].trim();if(!n)continue;let r=n.indexOf(`:`);if(r===-1)continue;let p=n.substring(0,r);if(!t.test(p)){console.warn(`[rari] AppRouter: Invalid row ID (non-numeric), skipping line:`,n.substring(0,50));continue}let m=n.substring(r+1);try{if(m.startsWith(`"$S`)){let e=m.slice(1,-1);s.set(`$${p}`,e);continue}if(m.startsWith(`I[`)){let t=
|
|
7
|
-
`),t=await
|
|
5
|
+
`})]})}function h({children:h,initialPayload:g,onNavigate:_}){let[v,y]=s(g),[,b]=s(0),x=o({x:0,y:0}),S=o(new Map),C=o(null),[,w]=c(),T=o(0),E=o(new Map),D=o([]),O=o(null),k=o(0),[A,j]=s(null),M=o(typeof window<`u`&&window.location.hash.length>0),N=()=>{if(typeof document>`u`)return;let e=document.querySelectorAll(`form`);S.current.clear(),e.forEach((e,t)=>{let n=new FormData(e);S.current.set(`form-${t}`,n)})},P=()=>{typeof document>`u`||document.querySelectorAll(`form`).forEach((e,t)=>{let n=S.current.get(`form-${t}`);n&&n.forEach((t,n)=>{let r=e.elements.namedItem(n);r&&(r.type===`checkbox`||r.type===`radio`?r.checked=t===`on`:r.value=t)})})},F=(e,t,n,r)=>{let i={timestamp:Date.now(),error:e,type:t,details:n,filePath:r};D.current.push(i),k.current+=1,D.current.length>10&&D.current.shift(),console.error(`[rari] HMR: Failure detected`,{type:t,details:n,filePath:r,consecutiveFailures:k.current,error:e.message,stack:e.stack,timestamp:new Date(i.timestamp).toISOString()}),k.current>=2&&j(i),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`rari:hmr-failure`,{detail:i}))},I=()=>{setTimeout(()=>{window.location.reload()},1e3)},L=()=>{k.current>0&&(k.current=0)},R=e=>{if(!O.current)return!1;if(e===O.current)return!0;let t=e.match(f);if(t){let e=Number.parseInt(t[1],10);if(Date.now()-e>5e3)return!0}return!1};function z(e,n,i,a,o){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[,s,c,l]=e,u=s;if(typeof s==`string`&&s.startsWith(`$`)&&a){let e=s.substring(1);if(t.test(e)){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=q(l,n,i,a,o);return r.createElement(r.Suspense,c?{...e,key:c}:e)}if(typeof u==`string`&&u.startsWith(`$L`)){let e=n.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?z(l.children,n,i,a,o):void 0};return r.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:e}),null;let d=q(l,n,i,a,o);return r.createElement(u,c?{...d,key:c}:d)}return e.map((e,t)=>{let s=z(e,n,i,a,o);return s?typeof s==`object`&&r.isValidElement(s)&&!s.key?r.cloneElement(s,{key:t}):s:null}).filter(Boolean)}return e}let B=o(new Set),V=o(new Map),H=o(new Map),U=o(new Map),W=o(new Map);function G(e){if(!W.current.has(e)){let t=new Promise(()=>{});W.current.set(e,t)}return W.current.get(e)}function K({contentRef:e}){let t=V.current,n=H.current,r=U.current;if(t.has(e))return W.current.delete(e),z(t.get(e),n,void 0,r,t);throw G(e)}function q(e,t,n,i,a){if(!e||typeof e!=`object`)return e;a&&(V.current=a),t&&(H.current=t),i&&(U.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);B.current.delete(c),o[s]=z(e,t,n,i,a)}else B.current.add(c),o[s]=r.createElement(K,{key:`lazy-${c}`,contentRef:c});else o[s]=c?z(c,t,n,i,a):void 0}else s===`dangerouslySetInnerHTML`?o[s]=e[s]:o[s]=z(e[s],t,n,i,a);return o}let J=(e,t)=>{try{let n=t===`array`?`[`:`{`,r=t===`array`?`]`:`}`,i=0,a=-1,o=!1,s=!1;for(let t=0;t<e.length;t++){let c=e[t];if(s){s=!1;continue}if(c===`\\`){s=!0;continue}if(c===`"`&&!s){o=!o;continue}if(!o){if(c===n)i++;else if(c===r&&(i--,i===0)){a=t+1;break}}}if(a===-1)return null;let c=e.substring(0,a),l=e.substring(a).trim();return l.length>0&&!p.test(l)&&console.warn(`[rari] Sanitized corrupted JSON (possible userscript injection):`,{extracted:c.substring(0,100),discarded:l.substring(0,50)}),c}catch(e){return console.error(`[rari] Failed to sanitize JSON:`,e),null}},Y=async(e,i=!1)=>{try{let a=e.trim().split(`
|
|
6
|
+
`),o=new Map,s=new Map,c=new Map,l=null,u=[],d=null,f=null;for(let e=0;e<a.length;e++){let n=a[e].trim();if(!n)continue;let r=n.indexOf(`:`);if(r===-1)continue;let p=n.substring(0,r);if(!t.test(p)){console.warn(`[rari] AppRouter: Invalid row ID (non-numeric), skipping line:`,n.substring(0,50));continue}let m=n.substring(r+1);try{if(m.startsWith(`"$S`)){let e=m.slice(1,-1);s.set(`$${p}`,e);continue}if(m.startsWith(`I[`)){let t=J(m.substring(1),`array`);if(!t){console.warn(`[rari] AppRouter: Could not sanitize import line, skipping:`,n.substring(0,80));continue}let r=JSON.parse(t);if(Array.isArray(r)&&r.length>=3){let[t,n,a]=r;o.set(`$L${p}`,{id:t,chunks:Array.isArray(n)?n:[n],name:a||`default`}),i&&t.includes(`layout`)&&(d!==null&&f!==null&&u.push({layoutPath:d,startLine:f,endLine:e-1,props:{}}),d=t,f=e)}}else if(m.startsWith(`[`)){let e=JSON.parse(m);if(c.set(`$L${p}`,e),i&&Array.isArray(e)&&e.length>=4&&typeof e[1]==`string`&&e[1].startsWith(`$L`)){let t=e[1],n=o.get(t);if(n&&n.id.includes(`layout`)){let t=e[3]||{};if(d&&f!==null){let e=u.find(e=>e.layoutPath===d&&e.startLine===f);e&&(e.props=t)}}}!l&&Array.isArray(e)&&(e[0]===`$`?l=e:Array.isArray(e[0])&&e[0][0]===`$`&&(l=e.length===1?e[0]:e))}}catch(e){console.error(`[rari] AppRouter: Failed to parse RSC line:`,n,e)}}if(await n(o),i&&d!==null&&f!==null&&u.push({layoutPath:d,startLine:f,endLine:a.length-1,props:{}}),l&&Array.isArray(l)){if(l[0]===`$`)l=z(l,o,void 0,s,c);else if(Array.isArray(l[0])){let e=l.map(e=>Array.isArray(e)&&e[0]===`$`?z(e,o,void 0,s,c):e).filter(e=>e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||r.isValidElement(e));l=e.length===1?e[0]:e}}return{element:l,modules:o,symbols:s,wireFormat:e,layoutBoundaries:i?u:void 0}}catch(e){throw console.error(`[rari] AppRouter: Failed to parse RSC wire format:`,e),e}},X=async(t,n)=>{let r=t||window.location.pathname,i=E.current.get(r);if(i)return i;let a=(async()=>{try{let t=(import.meta.env.RARI_SERVER_URL||window.location.origin).replace(e,``)+r+window.location.search,i=await fetch(t,{headers:{Accept:`text/x-component`},cache:`no-store`,signal:n});if(!i.ok){let e=Error(`Failed to fetch RSC data: ${i.status} ${i.statusText}`);throw F(e,`fetch`,`HTTP ${i.status} when fetching ${t}`,window.location.pathname),e}let a=await i.text();if(R(a)&&v)return v;let o;try{o=await Y(a,!1)}catch(e){let t=e instanceof Error?e:Error(String(e));throw F(t,`parse`,`Failed to parse RSC wire format: ${t.message}`,window.location.pathname),t}return y(o),O.current=a,L(),o}catch(e){throw e instanceof Error&&!e.message.includes(`Failed to fetch RSC data`)&&!e.message.includes(`Failed to parse`)&&F(e,`network`,`Network error: ${e.message}`,window.location.pathname),console.error(`[rari] AppRouter: Error fetching RSC payload:`,e),e}finally{E.current.delete(r)}})();return E.current.set(r,a),a};a(()=>{if(typeof window>`u`)return;let e=async e=>{let t=e.detail;T.current=t.navigationId,C.current=null,M.current=!0,x.current={x:window.scrollX,y:window.scrollY},N(),w(async()=>{try{t.rscWireFormat?(y(await Y(t.rscWireFormat,!1)),O.current=t.rscWireFormat,L()):t.isStreaming?C.current=[]:await X(t.to,t.abortSignal),T.current===t.navigationId&&(b(e=>e+1),j(null),_&&_(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}})),k.current>=3&&I()}finally{let e=typeof window<`u`&&window.location.hash.length>0;!t.options?.historyKey&&!e&&requestAnimationFrame(()=>{t.options?.scroll!==!1&&window.scrollTo(0,0)})}})},t=async()=>{x.current={x:window.scrollX,y:window.scrollY},N();try{await X(),b(e=>e+1),j(null)}catch(e){console.error(`[rari] AppRouter: HMR update failed:`,e),k.current>=3&&I()}finally{requestAnimationFrame(()=>{window.scrollTo(x.current.x,x.current.y),P()})}},n=async()=>{try{await X(),b(e=>e+1),j(null)}catch(e){console.error(`[rari] AppRouter: RSC invalidation failed:`,e),k.current>=3&&I()}},r=async()=>{try{await X(),j(null)}catch(e){console.error(`[rari] AppRouter: Manifest update failed:`,e),k.current>=3&&I()}},i=async e=>{let t=e.detail.rscRow;if(!(!t||!t.trim())){C.current||=[],C.current.push(t);try{let e=C.current.join(`
|
|
7
|
+
`),t=await Y(e,!1);C.current.length<=2&&e.includes(`~boundaryId`)?(y(t),b(e=>e+1)):w(()=>{y(t),b(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)}},[_]),a(()=>{if(!(typeof window>`u`)&&window.location.hash&&v&&M.current){let e=window.location.hash.slice(1);requestAnimationFrame(()=>{requestAnimationFrame(()=>{let t=document.getElementById(e);t&&(t.scrollIntoView({behavior:`instant`,block:`start`}),M.current=!1)})})}},[v]);let Z=()=>{window.location.reload()},Q=()=>{j(null)},ee=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},$=h;return v?.element&&($=ee(v.element)||v.element),Array.isArray($)&&$.length===1&&r.isValidElement($[0])?$=$[0]:Array.isArray($)&&$.length>0&&$.every(e=>r.isValidElement(e)||e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`)&&($=r.createElement(r.Fragment,null,...$)),$&&typeof $==`object`&&!r.isValidElement($)&&(console.error(`[rari] AppRouter: Invalid content to render:`,$),$=h),d(l,{children:[A&&d(`div`,{style:{position:`fixed`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,padding:`24px`,background:`rgba(220, 38, 38, 0.95)`,color:`white`,borderRadius:`8px`,fontSize:`14px`,zIndex:1e4,maxWidth:`500px`,boxShadow:`0 4px 6px rgba(0, 0, 0, 0.3)`},children:[u(`div`,{style:{marginBottom:`16px`,fontWeight:`bold`,fontSize:`16px`},children:`⚠️ HMR Update Failed`}),d(`div`,{style:{marginBottom:`12px`,opacity:.9},children:[A.type===`fetch`&&`Failed to fetch updated content from server.`,A.type===`parse`&&`Failed to parse server response.`,A.type===`stale`&&`Server returned stale content.`,A.type===`network`&&`Network error occurred.`]}),u(`div`,{style:{marginBottom:`16px`,fontSize:`12px`,opacity:.8,fontFamily:`monospace`},children:A.details}),d(`div`,{style:{marginBottom:`12px`,fontSize:`12px`,opacity:.7},children:[`Consecutive failures:`,` `,k.current,` `,`/`,` `,3]}),d(`div`,{style:{display:`flex`,gap:`8px`},children:[u(`button`,{onClick:Z,type:`button`,style:{padding:`8px 16px`,background:`white`,color:`#dc2626`,border:`none`,borderRadius:`4px`,cursor:`pointer`,fontWeight:`bold`,fontSize:`14px`},children:`Refresh Page`}),u(`button`,{onClick:Q,type:`button`,style:{padding:`8px 16px`,background:`rgba(255, 255, 255, 0.2)`,color:`white`,border:`1px solid rgba(255, 255, 255, 0.3)`,borderRadius:`4px`,cursor:`pointer`,fontSize:`14px`},children:`Dismiss`})]}),u(`div`,{style:{marginTop:`12px`,fontSize:`11px`,opacity:.6},children:`Check the console for detailed error logs.`})]}),u(i,{fallback:u(m,{}),children:$})]})}export{h as AppRouterProvider};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import"../regex-constants-DMuIAFub.mjs";import{n as e,t}from"../get-client-component-
|
|
1
|
+
import"../regex-constants-DMuIAFub.mjs";import{n as e,t}from"../get-client-component-DuyG4UOi.mjs";import*as n from"react";import{Suspense as r}from"react";import{ClientRouter as i}from"rari/client";import{RouterProvider as a}from"rari/router";import{createRoot as o}from"react-dom/client";import{AppRouterProvider as s}from"virtual:app-router-provider";import{createFromReadableStream as c}from"virtual:react-server-dom-rari-client.ts";import"virtual:rsc-integration.ts";function l(){return globalThis[`~rari`]}function u(){return globalThis}function d(){return window}function f(){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(u()[`~clientComponents`]?.[i]?.component)return u()[`~clientComponents`][i].component;if(u()[`~clientComponents`]?.[e]?.component){let t=u()[`~clientComponents`][e].component;return r===`default`?t:t?.[r]}let a=u()[`~clientComponents`]?.[i]||u()[`~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}}}})}})}}l()===void 0&&(globalThis[`~rari`]={}),l().AppRouterProvider=s,l().ClientRouter=i,l().getClientComponent=t;async function p(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
|
+
l().preloadClientComponent=p,u()[`~clientComponents`]===void 0&&(globalThis[`~clientComponents`]={}),u()[`~clientComponentPaths`]===void 0&&(globalThis[`~clientComponentPaths`]={});
|
|
4
4
|
/*! @preserve CLIENT_COMPONENT_REGISTRATIONS_PLACEHOLDER */
|
|
5
|
-
function
|
|
5
|
+
function m(){l().hydrateClientComponents||(l().hydrateClientComponents=function(e,t,r){let i=d()[`~rari`].boundaryModules||new Map;function a(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,o]=e,s=o?{...o}:{};if(o?.children&&(s.children=a(o.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=u()[`~clientComponents`][t]||u()[`~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=a(e);return n.isValidElement(r)&&!r.key?n.cloneElement(r,{key:t}):r})}return e}try{let e=a(t);e&&(o(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 h(){let e=d()[`~rari`].pendingBoundaryHydrations;if(!(!e||e.size===0)){for(let[t,n]of e.entries())l().hydrateClientComponents&&l().hydrateClientComponents(t,n.content,n.element);e.clear()}}m();async function g(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 _(){let e=document.getElementById(`root`);if(!e){console.error(`[rari] Root element not found`);return}let r=document.getElementById(`__RARI_RSC_PAYLOAD__`),l=e.children.length>0,u=d()[`~rari`]?.bufferedRows&&d()[`~rari`].bufferedRows.length>0;if(m(),l&&!r&&!u){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 g(r),e.forEach(e=>{let r=e.getAttribute(`data-client-component`),i=e.getAttribute(`data-props`);if(r)try{let a=t(r);if(!a)return;let s=i?JSON.parse(i):{};requestAnimationFrame(()=>{try{document.contains(e)&&(e.replaceChildren(),o(e).render(n.createElement(a,s)))}catch(e){console.error(`[rari] Failed to hydrate client component ${r}:`,e)}})}catch(e){console.error(`[rari] Failed to hydrate client component ${r}:`,e)}})}return}if(l&&u&&!r&&document.querySelectorAll(`[data-boundary-id]`).length>0){d()[`~rari`].pendingBoundaryHydrations&&d()[`~rari`].pendingBoundaryHydrations.size>0&&h();return}try{let t;if(!r&&!u&&!l)try{let e=window.location.pathname+window.location.search,n=(import.meta.env.DEV?import.meta.env.RARI_SERVER_URL||`http://localhost:${import.meta.env.VITE_RSC_PORT||`3000`}`:window.location.origin)+e,r=await fetch(n,{headers:{Accept:`text/x-component`},cache:`no-store`});if(!r.ok&&r.status!==404)throw Error(`Failed to fetch RSC data: ${r.status}`);let i=r.body;t=await c(i,f())}catch(e){if(e instanceof Promise)throw e;if(console.error(`[rari] Failed to fetch initial RSC data:`,e),e instanceof Error)console.error(`[rari] Error name:`,e.name),console.error(`[rari] Error message:`,e.message),e.stack&&console.error(`[rari] Error stack:`,e.stack);else if(typeof e==`string`)console.error(`[rari] Error details:`,e);else if(e&&typeof e==`object`)try{let t={};for(let n of Object.getOwnPropertyNames(e))t[n]=e[n];console.error(`[rari] Error details:`,JSON.stringify(t,null,2))}catch{console.error(`[rari] Error details:`,String(e))}else console.error(`[rari] Error details:`,String(e));t=null}else if(r&&r.textContent)try{let e=r.textContent,n=d()[`~rari`]?.bufferedRows&&d()[`~rari`].bufferedRows.length>0;t=d()[`~rari`]?.streamComplete===void 0||n?await c(new ReadableStream({start(t){if(t.enqueue(new TextEncoder().encode(e)),d()[`~rari`]?.bufferedRows){for(let e of d()[`~rari`].bufferedRows)t.enqueue(new TextEncoder().encode(`\n${e}`));d()[`~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),d()[`~rari`]?.streamComplete&&r()}}),f()):await c(new ReadableStream({start(t){t.enqueue(new TextEncoder().encode(e)),t.close()}}),f())}catch(e){console.error(`[rari] Failed to parse embedded RSC payload:`,e),t=null}else if(u)try{t=await c(new ReadableStream({start(e){if(d()[`~rari`]?.bufferedRows){for(let t of d()[`~rari`].bufferedRows)e.enqueue(new TextEncoder().encode(`${t}\n`));d()[`~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),d()[`~rari`]?.streamComplete&&n()}}),f())}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 p;p=t;let m;m=n.createElement(s,{initialPayload:{element:t}},p),m=n.createElement(i,{initialRoute:window.location.pathname},m),m=n.createElement(a,{initialPathname:window.location.pathname},m),o(e).render(m)}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>
|
|
9
9
|
</div>
|
|
10
|
-
`;let n=e.querySelector(`p`);n&&(n.textContent=t instanceof Error?t.message:String(t))}}import.meta.hot&&import.meta.hot.data.hasRendered||(
|
|
10
|
+
`;let n=e.querySelector(`p`);n&&(n.textContent=t instanceof Error?t.message:String(t))}}import.meta.hot&&import.meta.hot.data.hasRendered||(_().catch(e=>{console.error(`[rari] Fatal error:`,e)}),import.meta.hot&&(import.meta.hot.data.hasRendered=!0));export{p as preloadClientComponent,_ as renderApp};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as e,t,w as n}from"../regex-constants-DMuIAFub.mjs";import{r}from"../get-client-component-
|
|
1
|
+
import{b as e,t,w as n}from"../regex-constants-DMuIAFub.mjs";import{r}from"../get-client-component-DuyG4UOi.mjs";import{t as i}from"../preload-components-RxFu9xLE.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
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(t,n,r,i,o){if(!t)return null;if(typeof t==`string`||typeof t==`number`||typeof t==`boolean`){if(typeof t==`string`&&t.startsWith(`$`)&&t.length>1){if(t[1]===`L`){let e=t.slice(2),a=o?.get(e);if(!a){let e=new Promise(()=>{});throw e._rscLazyRef=t,e}return u(a,n,r,i,o)}let e=t.slice(1),a=o?.get(e);return a?u(a,n,r,i,o):null}return t}if(Array.isArray(t)){if(t.length>=4&&t[0]===`$`){let[,s,c,l]=t;if(typeof s==`string`&&s.startsWith(`$`)&&s.length>1&&e.test(s.slice(1))){let e=s.slice(1),t=i?.get(e);if(t&&t.startsWith(`$S`)&&t.slice(2)===`react.suspense`){let e=f(l,n,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,n,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,n,r,i,o):null;let t=d(e,n,r);if(t){let e=f(l,n,r,i,o);return a.createElement(t,c?{...e,key:c}:e)}return null}let p=f(l,n,r,i,o);return a.createElement(s,c?{...p,key:c}:p)}return t.map(e=>u(e,n,r,i,o))}return t}function d(e,i,a){if(e===`AppRouterProvider`){let e=globalThis[`~rari`]?.AppRouterProvider;if(e)return e}if(e===`ClientRouter`){let e=globalThis[`~rari`]?.ClientRouter;if(e)return e}if(i&&i.size>0){let a=`$L${e}`,o=i.get(a);if(o){let e=globalThis[`~clientComponents`]||{},i=[o.id,`${o.id}#${o.name||`default`}`,o.id.replace(n,``),o.id.replace(t,`/`)];for(let t of i){let n=e[t];if(n){if(n.component)return n.component;if(n.loader&&!n.loading)return r(n,o.id);if(n.loading)return null}}console.warn(`[rari] Component not found in registry:`,{moduleId:o.id,moduleName:o.name,triedKeys:i,availableKeys:Object.keys(e).slice(0,10)})}}if(a[e])return a[e];let o=globalThis[`~clientComponents`]||{};for(let[t,n]of Object.entries(o)){let i=t===e,a=t.endsWith(`/${e}`)||t.endsWith(`\\${e}`),o=t.endsWith(`#${e}`),s=n.name===e;if(i||a||o||s){if(n.component)return n.component;if(n.loader&&!n.loading)return r(n,t)}}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{_ as e,d as t,g as n,h as r,m as i,n as a,p as o,y as s}from"../regex-constants-DMuIAFub.mjs";import{t as c}from"../get-client-component-
|
|
1
|
+
import{_ as e,d as t,g as n,h as r,m as i,n as a,p as o,y as s}from"../regex-constants-DMuIAFub.mjs";import{t as c}from"../get-client-component-DuyG4UOi.mjs";import"../preload-components-RxFu9xLE.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";function y(){return import.meta.env?.RARI_SERVER_URL?import.meta.env.RARI_SERVER_URL:typeof window<`u`?window.location.origin:`http://localhost:3000`}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,`'`),c=new Set(`div.span.p.ul.ol.li.a.img.section.article.header.footer.nav.main.aside.strong.em.b.i.button.input.label.form.select.option.textarea.h1.h2.h3.h4.h5.h6.table.thead.tbody.tr.td.th.code.pre.blockquote.hr.br.small.mark.del.ins.sub.sup.abbr.time.figure.figcaption.details.summary.dialog.menu.menuitem.canvas.svg.path.circle.rect.line.polygon.polyline.ellipse.text.g.defs.use.symbol.clippath.mask.pattern.lineargradient.radialgradient.stop.image.video.audio.source.track.picture.dl.dt.dd.fieldset.legend`.split(`.`));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=typeof e==`string`&&c.has(e.toLowerCase())?e.toLowerCase():`div`,i=null,o=``,l=``;if(n){for(let[e,t]of Object.entries(n))if(e===`dangerouslySetInnerHTML`&&t&&typeof t==`object`&&`__html`in t)i=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(`;`);l+=` style="${s(e)}"`}else typeof t==`string`||typeof t==`number`?l+=` ${n}="${s(String(t))}"`:typeof t==`boolean`&&t&&(l+=` ${n}`)}i===null&&n.children&&(o=h(n.children))}return`<${r}${l}>${i===null?o:i}</${r}>`}return t.map(h).join(``)}return``}let g=h(p);g&&requestAnimationFrame(()=>{let e=document.contains(l);e&&(l.innerHTML=g,l.classList.add(`rari-boundary-resolved`)),window.dispatchEvent(new CustomEvent(`rari:boundary-resolved`,{detail:{boundaryId:t,rscRow:s,rowId:c,element:l,wasAttached:e}}))})}catch(e){console.error(`[rari] Error processing boundary update:`,e)}};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 b(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 x(e){return c(e)}function S(){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 C=l,w=u,T=null;async function E(){return T||(T=(async()=>{try{return C=l,w=u,typeof w!=`function`&&(w=null),typeof C!=`function`&&(C=null),v}catch(e){return console.error(`Failed to load react-dom/client RSC functions:`,e),C=null,w=null,null}})(),T)}const D=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 E();let n=(()=>{let e=[`/_rari/stream`];try{if(typeof window<`u`&&(window.location.hostname===`localhost`||window.location.hostname===`127.0.0.1`)){let t=y();t&&e.push(`${t}/_rari/stream`)}}catch{}return e})(),r=null,i=null,a=async()=>{for(let r of n)try{let n=await this.fetchWithTimeout(r,{method:`POST`,headers:{"Content-Type":`application/json`,...this.buildRequestHeaders()},body:JSON.stringify({component_id:e,props:t})});if(n.ok)return n;i=Error(`HTTP ${n.status}: ${await n.text()}`)}catch(e){i=e}return null};if(r=await a(),r||=(await new Promise(e=>setTimeout(e,this.config.retryDelay)),await a()),!r)throw i||Error(`Failed to reach stream endpoint`);if(!r.ok){let e=await r.text();throw Error(`Server responded with ${r.status}: ${e}`)}let o=r.body;if(!o)throw Error(`No ReadableStream from stream response`);let s=o.getReader(),c=new TextDecoder,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=x(`${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=x(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,b=new Map,S=``,C=null,w=async()=>{try{for(;;){let{value:e,done:t}=await s.read();if(t)break;let n=c.decode(e,{stream:!0});S+=n;let r=S.split(`
|
|
2
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;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);b.set(e,t),C&&C.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),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]=_(0);h(()=>(C={updateBoundary:(t,n)=>{b.set(t,n),e(e=>e+1)},updateRoot:()=>{e(e=>e+1)}},()=>{C=null}),[]);let t=e=>{if(!e)return null;if(m(e)){let n=e.props,r=n?.[`~boundaryId`];if(n&&r){let e=b.get(r);if(e)return e}if(n&&n.children){let r=t(n.children);if(r!==n.children)return f(e,{...n,children:r})}return e}return Array.isArray(e)?e.map(e=>t(e)):e};return t(v)};return w(),{"~isRscResponse":!0,"~rscPromise":Promise.resolve(p(T)),readRoot(){return Promise.resolve(p(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 E(),C)try{let t=C(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=x(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=x(`${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 O({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 k({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),D.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(O,{error:`Error loading component`,details:{message:l.message,componentId:e}}):s?s[`~isRscResponse`]?p(d,{fallback:n||null},s.readRoot()):s:p(O,{error:`No data received for component: ${e}`,details:{componentId:e,dataType:typeof s,hasData:!!s}})}function A(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&&M(n.filePath)&&(D.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(k,{key:`${e}-${r}`,componentId:e,props:n,fallback:null}))};return n.displayName=`ServerComponent(${e})`,function(e){return p(n,e)}}function j(e,t){return D.fetchServerComponent(e,t)}function M(e){if(!e)return!1;try{return typeof globalThis<`u`&&globalThis[`~rari`].serverComponents?globalThis[`~rari`].serverComponents.has(e):!1}catch(e){return console.error(`Error checking if file is server component:`,e),!1}}if(import.meta.hot){let e=!1,t=[],n=new Map;function r(r,i){n.set(r,i),import.meta.hot.on(r,async n=>{if(!e){t.push({event:r,data:n});return}try{await i(n)}catch(e){console.error(`[rari] HMR: Error in handler for '${r}':`,e)}})}r(`rari:register-server-component`,e=>{e?.filePath&&typeof globalThis<`u`&&(globalThis[`~rari`].serverComponents=globalThis[`~rari`].serverComponents||new Set,globalThis[`~rari`].serverComponents.add(e.filePath))}),r(`rari:server-components-registry`,e=>{e?.serverComponents&&Array.isArray(e.serverComponents)&&typeof globalThis<`u`&&(globalThis[`~rari`].serverComponents=globalThis[`~rari`].serverComponents||new Set,e.serverComponents.forEach(e=>{globalThis[`~rari`].serverComponents?.add(e)}))}),r(`vite:beforeFullReload`,async e=>{e?.path&&M(e.path)&&await u({filePath:e.path,forceReload:!0})}),r(`rari:server-component-updated`,async e=>{let t=e?.id||e?.componentId,n=e?.t||e?.timestamp;if(t){if(typeof window<`u`){let r=new CustomEvent(`rari:rsc-invalidate`,{detail:{componentId:t,filePath:e.filePath||e.file,type:`server-component`,timestamp:n}});window.dispatchEvent(r)}}else e?.path&&M(e.path)&&await u({filePath:e.path,forceReload:!1})}),r(`rari:app-router-updated`,async e=>{try{if(!e||!e.routePath&&(!e.affectedRoutes||e.affectedRoutes.length===0))return;await i(e)}catch(e){console.error(`[rari] HMR: App router update failed:`,e)}}),r(`rari:server-action-updated`,async e=>{if(e?.filePath&&(D.clearCache(),typeof window<`u`)){let t=new CustomEvent(`rari:rsc-invalidate`,{detail:{filePath:e.filePath,type:`server-action`}});window.dispatchEvent(t)}});async function i(e){let t=e.fileType,n=e.filePath,r=e.routePath,i=e.affectedRoutes,o=e.manifestUpdated,u=e.metadata;e.metadataChanged&&u&&a(u);try{let e=`${y()}/_rari/hmr`,t=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`register`,file_path:n})});if(!t.ok){let e=await t.text(),n=`Component reload failed with status ${t.status}: ${e}`;throw console.error(`[rari] HMR:`,n),Error(n)}let r=await t.json();if(typeof r!=`object`||!r){let e=`Invalid reload response: null or non-object`;throw console.error(`[rari] HMR:`,e,r),Error(e)}if(r.success!==!0&&r.reloaded!==!0){let e=`Component reload unsuccessful: ${r.error||`unknown error`}`;throw console.error(`[rari] HMR:`,e,r),Error(e)}}catch(e){console.error(`[rari] HMR: Failed to reload component:`,e);return}let d=[r];switch(t){case`page`:d=[r];break;case`layout`:case`loading`:case`error`:case`not-found`:d=i;break;default:break}await s({routes:d,fileType:t,filePath:n,componentId:r}),o&&await l(),await c({routePath:r,affectedRoutes:i})}function a(e){if(!(typeof document>`u`)&&(e.title&&(document.title=e.title),e.description)){let t=document.querySelector(`meta[name="description"]`);t||(t=document.createElement(`meta`),t.setAttribute(`name`,`description`),document.head.appendChild(t)),t.setAttribute(`content`,e.description)}}function o(e){if(!e||e.length===0){D.clearCache();return}let t=[];for(let n of D.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)D.componentCache.delete(e)}async function s(e){let t=e.routes||[],n=e.fileType,r=e.filePath,i=e.componentId;if(i||r)try{let e=`${y()}/_rari/hmr`,t=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`invalidate`,componentId:i||r,filePath:r})}),n=await t.text();t.ok||console.error(`[rari] HMR: Server cache invalidation failed:`,t.status,n)}catch(e){console.error(`[rari] HMR: Failed to call server invalidation endpoint:`,e)}if(o(t),typeof window<`u`){let e=new CustomEvent(`rari:rsc-invalidate`,{detail:{routes:t,fileType:n}});window.dispatchEvent(e)}}async function c(e){let t=e.routePath,n=e.affectedRoutes||[t];if(!(typeof window>`u`))try{let e=window.location.pathname,r=new CustomEvent(`rari:app-router-rerender`,{detail:{routePath:t,affectedRoutes:n,currentPath:e,preserveParams:!0}});window.dispatchEvent(r)}catch(e){throw console.error(`[rari] HMR: Failed to trigger re-render:`,e),e}}async function l(){typeof window<`u`&&window[`~rari`]?.routeInfoCache&&window[`~rari`].routeInfoCache.clear()}async function u(e){let t=e?.filePath||e;if(D.clearCache(),typeof window<`u`){let e=new CustomEvent(`rari:rsc-invalidate`,{detail:{filePath:t}});window.dispatchEvent(e)}}t.length>0?(async()=>{try{for(;t.length>0;){let e=[...t];t.length=0;for(let{event:t,data:r}of e){let e=n.get(t);if(e)try{await e(r)}catch(e){console.error(`[rari] HMR: Error replaying buffered event '${t}':`,e)}}}}catch(e){console.error(`[rari] HMR: Error during event replay:`,e)}finally{e=!0}})():e=!0}var N=class{overlay;currentError;escapeKeyHandler;constructor(){this.overlay=null,this.currentError=null,this.escapeKeyHandler=null}show(e){this.currentError=e,this.overlay?this.updateOverlay(e):this.createOverlay(e)}hide(){this.overlay&&(this.overlay.remove(),this.overlay=null,this.currentError=null),this.escapeKeyHandler&&=(document.removeEventListener(`keydown`,this.escapeKeyHandler),null)}isVisible(){return this.overlay!==null}createOverlay(e){this.overlay=document.createElement(`div`),this.overlay.id=`rari-hmr-error-overlay`,this.updateOverlay(e),document.body.appendChild(this.overlay),this.escapeKeyHandler=e=>{e.key===`Escape`&&this.hide()},document.addEventListener(`keydown`,this.escapeKeyHandler)}updateOverlay(e){if(!this.overlay)return;this.overlay.replaceChildren();let t=document.createElement(`div`);t.style.cssText=`position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.85); z-index: 999999; display: flex; align-items: center; justify-content: center; padding: 2rem; backdrop-filter: blur(4px);`;let n=document.createElement(`div`);n.style.cssText=`background: #1e1e1e; color: #e0e0e0; border-radius: 0.5rem; padding: 2rem; max-width: 50rem; width: 100%; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.4); border: 1px solid #ef4444;`;let r=document.createElement(`div`);r.style.cssText=`display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem;`;let i=document.createElement(`div`);i.style.cssText=`display: flex; align-items: center; gap: 0.75rem;`;let a=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);a.style.cssText=`width: 2rem; height: 2rem; color: #ef4444;`,a.setAttribute(`fill`,`none`),a.setAttribute(`stroke`,`currentColor`),a.setAttribute(`viewBox`,`0 0 24 24`);let o=document.createElementNS(`http://www.w3.org/2000/svg`,`path`);o.setAttribute(`stroke-linecap`,`round`),o.setAttribute(`stroke-linejoin`,`round`),o.setAttribute(`stroke-width`,`2`),o.setAttribute(`d`,`M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z`),a.appendChild(o);let s=document.createElement(`h1`);s.style.cssText=`margin: 0; font-size: 1.5rem; font-weight: 700; color: #ef4444;`,s.textContent=`Build Error`,i.appendChild(a),i.appendChild(s);let c=document.createElement(`button`);if(c.style.cssText=`background: transparent; border: none; color: #9ca3af; cursor: pointer; padding: 0.5rem; border-radius: 0.25rem; transition: all 0.2s; font-size: 1.5rem; line-height: 1; width: 2rem; height: 2rem; display: flex; align-items: center; justify-content: center;`,c.textContent=`×`,c.setAttribute(`aria-label`,`Close overlay`),c.onclick=()=>this.hide(),c.onmouseover=()=>{c.style.background=`rgba(255,255,255,0.1)`,c.style.color=`#e0e0e0`},c.onmouseout=()=>{c.style.background=`transparent`,c.style.color=`#9ca3af`},c.onfocus=()=>{c.style.background=`rgba(255,255,255,0.1)`,c.style.color=`#e0e0e0`},c.onblur=()=>{c.style.background=`transparent`,c.style.color=`#9ca3af`},r.appendChild(i),r.appendChild(c),n.appendChild(r),e.filePath){let t=document.createElement(`div`);t.style.cssText=`margin-bottom: 1rem; padding: 0.75rem; background: rgba(0, 0, 0, 0.2); border-radius: 0.375rem; font-family: monospace; font-size: 0.875rem;`;let r=document.createElement(`strong`);r.textContent=`File: `,t.appendChild(r),t.appendChild(document.createTextNode(e.filePath)),n.appendChild(t)}let l=document.createElement(`div`);l.style.cssText=`margin-bottom: 1.5rem;`;let u=document.createElement(`h2`);u.style.cssText=`margin: 0 0 0.75rem 0; font-size: 1rem; font-weight: 600; color: #fca5a5;`,u.textContent=`Error Message:`;let d=document.createElement(`pre`);if(d.style.cssText=`margin: 0; padding: 1rem; background: rgba(239, 68, 68, 0.1); border-left: 4px solid #ef4444; border-radius: 0.375rem; overflow-x: auto; font-family: monospace; font-size: 0.875rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word; color: #fca5a5;`,d.textContent=e.message??`An error occurred`,l.appendChild(u),l.appendChild(d),n.appendChild(l),e.stack){let t=document.createElement(`details`);t.style.cssText=`margin-top: 1rem; cursor: pointer;`;let r=document.createElement(`summary`);r.style.cssText=`font-weight: 600; margin-bottom: 0.5rem; user-select: none;`,r.textContent=`Stack Trace`;let i=document.createElement(`pre`);i.style.cssText=`margin: 0; padding: 0.75rem; background: rgba(0, 0, 0, 0.2); border-radius: 0.375rem; overflow-x: auto; font-size: 0.875rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word;`,i.textContent=e.stack,t.appendChild(r),t.appendChild(i),n.appendChild(t)}let f=document.createElement(`div`);f.style.cssText=`margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid #374151; display: flex; gap: 0.75rem; align-items: center;`;let p=document.createElement(`button`);p.style.cssText=`padding: 0.625rem 1.25rem; background: #ef4444; color: white; border: none; border-radius: 0.375rem; cursor: pointer; font-weight: 600; font-size: 0.875rem; transition: all 0.2s;`,p.textContent=`Reload Page`,p.onclick=()=>window.location.reload(),p.onmouseover=()=>{p.style.background=`#dc2626`},p.onmouseout=()=>{p.style.background=`#ef4444`},p.onfocus=()=>{p.style.background=`#dc2626`},p.onblur=()=>{p.style.background=`#ef4444`};let m=document.createElement(`button`);m.style.cssText=`padding: 0.625rem 1.25rem; background: #374151; color: #e0e0e0; border: none; border-radius: 0.375rem; cursor: pointer; font-weight: 600; font-size: 0.875rem; transition: all 0.2s;`,m.textContent=`Dismiss`,m.onclick=()=>this.hide(),m.onmouseover=()=>{m.style.background=`#4b5563`},m.onmouseout=()=>{m.style.background=`#374151`},m.onfocus=()=>{m.style.background=`#4b5563`},m.onblur=()=>{m.style.background=`#374151`};let h=document.createElement(`span`);h.style.cssText=`margin-left: auto; font-size: 0.75rem; color: #9ca3af;`;let g=new Date(e.timestamp);h.textContent=Number.isNaN(g.valueOf())?``:g.toLocaleTimeString(),f.appendChild(p),f.appendChild(m),f.appendChild(h),n.appendChild(f),t.appendChild(n),this.overlay.appendChild(t)}};let P=null;function F(){return P||=new N,P}if(import.meta.hot){let e=F();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{O as RscErrorComponent,S as createClientModuleMap,A as createServerComponentWrapper,j as fetchServerComponent,x as getClientComponent,b as registerClientComponent,D as rscClient};
|
|
@@ -174,4 +174,4 @@ function registerClientReference(clientReference, id, exportName) {
|
|
|
174
174
|
}
|
|
175
175
|
|
|
176
176
|
`+n);for(let{original:e,replacement:t}of i)n=n.replace(e,t);return n}resolveImportPath(e,t){let n=e,r=this.options.alias||{};for(let[t,i]of Object.entries(r))if(e.startsWith(`${t}/`)||e===t){let r=e.slice(t.length);n=d.join(i,r);break}d.isAbsolute(n)||(n=d.resolve(d.dirname(t),n));let i=[`.tsx`,`.jsx`,`.ts`,`.js`];for(let e of i){let t=`${n}${e}`;if(u.existsSync(t))return t}if(u.existsSync(n))for(let e of i){let t=d.join(n,`index${e}`);if(u.existsSync(t))return t}return`${n}.tsx`}getComponentId(e){return e.replace(x,`/`).replace(S,``).replace(s,`_`).replace(l,``)}async rebuildComponent(e){let t=this.getComponentId(d.relative(this.projectRoot,e)),n=await u.promises.readFile(e,`utf-8`),r=this.extractDependencies(n),i={filePath:e,originalCode:n,dependencies:r,hasNodeImports:this.hasNodeImports(n)};this.isServerAction(n)?this.serverActions.set(e,i):this.serverComponents.set(e,i);let a=d.join(this.options.rscDir,`${t}.js`),o=d.join(this.options.outDir,a),s=this.buildCache.get(e),c=(await u.promises.stat(e)).mtimeMs;if(s&&s.timestamp>=c&&JSON.stringify(s.dependencies)===JSON.stringify(r))return await u.promises.writeFile(o,s.code,`utf-8`),await this.updateManifestForComponent(t,e,a),{componentId:t,bundlePath:d.join(this.options.outDir,a),success:!0};let l=d.dirname(o);await u.promises.mkdir(l,{recursive:!0});let f=await this.buildSingleComponent(e,o,!0);return this.buildCache.set(e,{code:f,timestamp:Date.now(),dependencies:r}),await this.updateManifestForComponent(t,e,a),{componentId:t,bundlePath:d.join(this.options.outDir,a),success:!0}}manifestCache=null;async updateManifestForComponent(e,t,n){let r=d.join(this.options.outDir,this.options.manifestPath),i;if(this.manifestCache)i=this.manifestCache;else if(u.existsSync(r)){let e=await u.promises.readFile(r,`utf-8`);i=JSON.parse(e),this.manifestCache=i}else i={components:{},importMap:{imports:{react:`npm:react@19`,"react-dom":`npm:react-dom@19`,"react/jsx-runtime":`npm:react@19/jsx-runtime`,"react/jsx-dev-runtime":`npm:react@19/jsx-dev-runtime`}},version:`1.0.0`,buildTime:new Date().toISOString()},this.manifestCache=i;let a=this.serverComponents.get(t)||this.serverActions.get(t),o=d.join(this.options.outDir,n),s=`file://${d.resolve(this.projectRoot,o)}`;if(a)i.components[e]={id:e,filePath:t,relativePath:d.relative(this.projectRoot,t),bundlePath:n,moduleSpecifier:s,dependencies:a.dependencies,hasNodeImports:a.hasNodeImports};else{let r=await u.promises.readFile(t,`utf-8`);i.components[e]={id:e,filePath:t,relativePath:d.relative(this.projectRoot,t),bundlePath:n,moduleSpecifier:s,dependencies:this.extractDependencies(r),hasNodeImports:this.hasNodeImports(r)}}i.importMap||={imports:{react:`npm:react@19`,"react-dom":`npm:react-dom@19`,"react/jsx-runtime":`npm:react@19/jsx-runtime`,"react/jsx-dev-runtime":`npm:react@19/jsx-dev-runtime`}},i.buildTime=new Date().toISOString(),await u.promises.writeFile(r,JSON.stringify(i,null,2),`utf-8`),this.manifestCache=i}clearCache(){this.buildCache.clear(),this.manifestCache=null}async getTransformedComponentCode(e){return await this.buildComponentCodeOnly(e)}};function k(e,n,r=!0){r&&n.buildImportGraph(e);let i=u.readdirSync(e,{withFileTypes:!0});for(let r of i){let i=d.join(e,r.name);if(r.isDirectory())k(i,n,!1);else if(r.isFile()&&t.test(r.name)){if(D.test(r.name)||r.name.endsWith(`.d.ts`)||n.isOnlyImportedByClientComponents(i))continue;try{if(n.isServerComponent(i))n.addServerComponent(i);else{let e=u.readFileSync(i,`utf-8`).split(`
|
|
177
|
-
`),t=!1;for(let n of e){let e=n.trim();if(!(e.startsWith(`//`)||e.startsWith(`/*`)||!e)){if(e===`'use server'`||e===`"use server"`||e===`'use server';`||e===`"use server";`){t=!0;break}if(e)break}}t&&n.addServerComponent(i)}}catch(e){console.warn(`[server-build] Error checking ${i}:`,e instanceof Error?e.message:e)}}}}function A(e={}){let n=null,r,i=!1;return{name:`rari-server-build`,configResolved(t){r=t.root,i=t.command===`serve`;let a={};if(t.resolve?.alias){let e=t.resolve.alias;Array.isArray(e)?e.forEach(e=>{typeof e.find==`string`&&typeof e.replacement==`string`&&(a[e.find]=e.replacement)}):typeof e==`object`&&Object.entries(e).forEach(([e,t])=>{typeof t==`string`&&(a[e]=t)})}n=new O(r,{...e,alias:a})},buildStart(){if(!n)return;let e=f.env.NODE_ENV===`production`,t=[d.join(r,`dist`,`cache`,`og`),d.join(r,`dist`,`cache`,`images`)];e&&t.push(`/tmp/rari-og-cache`,`/tmp/rari-image-cache`);for(let e of t)try{u.existsSync(e)&&u.rmSync(e,{recursive:!0,force:!0})}catch(t){console.warn(`[rari] Failed to clear cache ${e}:`,t)}let i=d.join(r,`src`);u.existsSync(i)&&k(i,n)},async closeBundle(){if(n){await n.buildServerComponents();try{let{generateRobotsFile:e}=await import(`./robots-generator-
|
|
177
|
+
`),t=!1;for(let n of e){let e=n.trim();if(!(e.startsWith(`//`)||e.startsWith(`/*`)||!e)){if(e===`'use server'`||e===`"use server"`||e===`'use server';`||e===`"use server";`){t=!0;break}if(e)break}}t&&n.addServerComponent(i)}}catch(e){console.warn(`[server-build] Error checking ${i}:`,e instanceof Error?e.message:e)}}}}function A(e={}){let n=null,r,i=!1;return{name:`rari-server-build`,configResolved(t){r=t.root,i=t.command===`serve`;let a={};if(t.resolve?.alias){let e=t.resolve.alias;Array.isArray(e)?e.forEach(e=>{typeof e.find==`string`&&typeof e.replacement==`string`&&(a[e.find]=e.replacement)}):typeof e==`object`&&Object.entries(e).forEach(([e,t])=>{typeof t==`string`&&(a[e]=t)})}n=new O(r,{...e,alias:a})},buildStart(){if(!n)return;let e=f.env.NODE_ENV===`production`,t=[d.join(r,`dist`,`cache`,`og`),d.join(r,`dist`,`cache`,`images`)];e&&t.push(`/tmp/rari-og-cache`,`/tmp/rari-image-cache`);for(let e of t)try{u.existsSync(e)&&u.rmSync(e,{recursive:!0,force:!0})}catch(t){console.warn(`[rari] Failed to clear cache ${e}:`,t)}let i=d.join(r,`src`);u.existsSync(i)&&k(i,n)},async closeBundle(){if(n){await n.buildServerComponents();try{let{generateRobotsFile:e}=await import(`./robots-generator-CA3pR8ZY.mjs`);await e({appDir:d.join(r,`src`,`app`),outDir:d.join(r,`dist`),extensions:[`.ts`,`.tsx`,`.js`,`.jsx`]})}catch(e){console.warn(`[rari] Failed to generate robots.txt:`,e)}try{let{generateSitemapFiles:e}=await import(`./sitemap-generator-yW1rcKZr.mjs`);await e({appDir:d.join(r,`src`,`app`),outDir:d.join(r,`dist`),extensions:[`.ts`,`.tsx`,`.js`,`.jsx`]})}catch(e){console.warn(`[rari] Failed to generate sitemap:`,e)}}},async handleHotUpdate({file:e}){if(!n||!i)return;let a=d.relative(r,e).replace(x,`/`);if(!(!a.startsWith(`src/`)||!t.test(a)))try{if((await u.promises.readFile(e,`utf-8`)).includes(`use client`))return;await n.buildServerComponents()}catch(e){console.error(`[rari] Build: Error rebuilding ${a}:`,e)}}}}export{m as n,A as t};
|
|
@@ -84,169 +84,6 @@ declare function extractServerPropsWithCache(componentPath: string, params: Reco
|
|
|
84
84
|
declare function clearPropsCache(): void;
|
|
85
85
|
declare function clearPropsCacheForComponent(componentPath: string): void;
|
|
86
86
|
//#endregion
|
|
87
|
-
//#region src/router/types.d.ts
|
|
88
|
-
type RouteSegmentType = 'static' | 'dynamic' | 'catch-all' | 'optional-catch-all';
|
|
89
|
-
interface RouteSegment {
|
|
90
|
-
type: RouteSegmentType;
|
|
91
|
-
value: string;
|
|
92
|
-
param?: string;
|
|
93
|
-
}
|
|
94
|
-
interface AppRouteEntry {
|
|
95
|
-
path: string;
|
|
96
|
-
filePath: string;
|
|
97
|
-
segments: RouteSegment[];
|
|
98
|
-
params: string[];
|
|
99
|
-
isDynamic: boolean;
|
|
100
|
-
metadata?: RouteMetadata;
|
|
101
|
-
}
|
|
102
|
-
interface LayoutEntry {
|
|
103
|
-
path: string;
|
|
104
|
-
filePath: string;
|
|
105
|
-
parentPath?: string;
|
|
106
|
-
}
|
|
107
|
-
interface LoadingEntry {
|
|
108
|
-
path: string;
|
|
109
|
-
filePath: string;
|
|
110
|
-
componentId: string;
|
|
111
|
-
}
|
|
112
|
-
interface ErrorEntry {
|
|
113
|
-
path: string;
|
|
114
|
-
filePath: string;
|
|
115
|
-
}
|
|
116
|
-
interface NotFoundEntry {
|
|
117
|
-
path: string;
|
|
118
|
-
filePath: string;
|
|
119
|
-
}
|
|
120
|
-
interface OgImageEntry {
|
|
121
|
-
path: string;
|
|
122
|
-
filePath: string;
|
|
123
|
-
width?: number;
|
|
124
|
-
height?: number;
|
|
125
|
-
contentType?: string;
|
|
126
|
-
}
|
|
127
|
-
interface ApiRouteEntry {
|
|
128
|
-
path: string;
|
|
129
|
-
filePath: string;
|
|
130
|
-
segments: RouteSegment[];
|
|
131
|
-
params: string[];
|
|
132
|
-
isDynamic: boolean;
|
|
133
|
-
methods: string[];
|
|
134
|
-
}
|
|
135
|
-
interface AppRouteManifest {
|
|
136
|
-
routes: AppRouteEntry[];
|
|
137
|
-
layouts: LayoutEntry[];
|
|
138
|
-
loading: LoadingEntry[];
|
|
139
|
-
errors: ErrorEntry[];
|
|
140
|
-
notFound: NotFoundEntry[];
|
|
141
|
-
apiRoutes: ApiRouteEntry[];
|
|
142
|
-
ogImages: OgImageEntry[];
|
|
143
|
-
generated: string;
|
|
144
|
-
}
|
|
145
|
-
interface RouteMetadata {
|
|
146
|
-
title?: string | {
|
|
147
|
-
default?: string;
|
|
148
|
-
template?: string;
|
|
149
|
-
absolute?: string;
|
|
150
|
-
};
|
|
151
|
-
description?: string;
|
|
152
|
-
keywords?: string | string[];
|
|
153
|
-
openGraph?: {
|
|
154
|
-
title?: string;
|
|
155
|
-
description?: string;
|
|
156
|
-
images?: string[] | Array<{
|
|
157
|
-
url: string;
|
|
158
|
-
width?: number;
|
|
159
|
-
height?: number;
|
|
160
|
-
alt?: string;
|
|
161
|
-
}>;
|
|
162
|
-
url?: string;
|
|
163
|
-
siteName?: string;
|
|
164
|
-
locale?: string;
|
|
165
|
-
type?: string;
|
|
166
|
-
};
|
|
167
|
-
twitter?: {
|
|
168
|
-
card?: 'summary' | 'summary_large_image' | 'app' | 'player';
|
|
169
|
-
title?: string;
|
|
170
|
-
description?: string;
|
|
171
|
-
images?: string[] | Array<{
|
|
172
|
-
url: string;
|
|
173
|
-
alt?: string;
|
|
174
|
-
}>;
|
|
175
|
-
site?: string;
|
|
176
|
-
creator?: string;
|
|
177
|
-
};
|
|
178
|
-
robots?: {
|
|
179
|
-
index?: boolean;
|
|
180
|
-
follow?: boolean;
|
|
181
|
-
noarchive?: boolean;
|
|
182
|
-
nosnippet?: boolean;
|
|
183
|
-
noimageindex?: boolean;
|
|
184
|
-
nocache?: boolean;
|
|
185
|
-
} | string;
|
|
186
|
-
icons?: {
|
|
187
|
-
icon?: string | Array<{
|
|
188
|
-
url: string;
|
|
189
|
-
type?: string;
|
|
190
|
-
sizes?: string;
|
|
191
|
-
}>;
|
|
192
|
-
shortcut?: string;
|
|
193
|
-
apple?: string | Array<{
|
|
194
|
-
url: string;
|
|
195
|
-
sizes?: string;
|
|
196
|
-
type?: string;
|
|
197
|
-
}>;
|
|
198
|
-
};
|
|
199
|
-
manifest?: string;
|
|
200
|
-
themeColor?: string | Array<{
|
|
201
|
-
media?: string;
|
|
202
|
-
color: string;
|
|
203
|
-
}>;
|
|
204
|
-
viewport?: string | {
|
|
205
|
-
width?: string | number;
|
|
206
|
-
height?: string | number;
|
|
207
|
-
initialScale?: number;
|
|
208
|
-
minimumScale?: number;
|
|
209
|
-
maximumScale?: number;
|
|
210
|
-
userScalable?: boolean;
|
|
211
|
-
};
|
|
212
|
-
appleWebApp?: {
|
|
213
|
-
capable?: boolean;
|
|
214
|
-
title?: string;
|
|
215
|
-
statusBarStyle?: 'default' | 'black' | 'black-translucent';
|
|
216
|
-
};
|
|
217
|
-
canonical?: string;
|
|
218
|
-
}
|
|
219
|
-
type Metadata = RouteMetadata;
|
|
220
|
-
type RouteParams = Record<string, string | string[]>;
|
|
221
|
-
type SearchParams = Record<string, string | string[] | undefined>;
|
|
222
|
-
interface PageProps<TParams extends RouteParams = RouteParams, TSearchParams extends SearchParams = SearchParams> {
|
|
223
|
-
params: TParams;
|
|
224
|
-
searchParams: TSearchParams;
|
|
225
|
-
}
|
|
226
|
-
interface LayoutProps<TParams extends RouteParams = RouteParams> {
|
|
227
|
-
children: ReactNode;
|
|
228
|
-
params?: TParams;
|
|
229
|
-
pathname?: string;
|
|
230
|
-
}
|
|
231
|
-
interface ErrorProps {
|
|
232
|
-
error: Error;
|
|
233
|
-
reset: () => void;
|
|
234
|
-
}
|
|
235
|
-
interface AppRouteMatch {
|
|
236
|
-
route: AppRouteEntry;
|
|
237
|
-
params: RouteParams;
|
|
238
|
-
searchParams: SearchParams;
|
|
239
|
-
layouts: LayoutEntry[];
|
|
240
|
-
loading?: LoadingEntry;
|
|
241
|
-
error?: ErrorEntry;
|
|
242
|
-
pathname: string;
|
|
243
|
-
}
|
|
244
|
-
type GenerateMetadata<TParams extends RouteParams = RouteParams, TSearchParams extends SearchParams = SearchParams> = (props: {
|
|
245
|
-
params: TParams;
|
|
246
|
-
searchParams: TSearchParams;
|
|
247
|
-
}) => RouteMetadata | Promise<RouteMetadata>;
|
|
248
|
-
type GenerateStaticParams<TParams extends RouteParams = RouteParams> = () => TParams[] | Promise<TParams[]>;
|
|
249
|
-
//#endregion
|
|
250
87
|
//#region src/runtime-client.d.ts
|
|
251
88
|
interface RuntimeClient {
|
|
252
89
|
initialize: () => Promise<void>;
|
|
@@ -401,4 +238,4 @@ interface ServerConfig {
|
|
|
401
238
|
cacheControl?: ServerCacheControlConfig;
|
|
402
239
|
}
|
|
403
240
|
//#endregion
|
|
404
|
-
export {
|
|
241
|
+
export { extractServerPropsWithCache as C, extractServerProps as S, hasServerSideDataFetching as T, ServerSidePropsResult as _, ServerSpamBlockerConfig as a, clearPropsCacheForComponent as b, ErrorBoundary as c, NotFound as d, RuntimeClient as f, MetadataResult as g, createLoadingBoundary as h, ServerRateLimitConfig as i, HttpRuntimeClient as l, createHttpRuntimeClient as m, ServerCacheControlConfig as n, DefaultError as o, createErrorBoundary as p, ServerConfig as r, DefaultLoading as s, ServerCSPConfig as t, LoadingSpinner as u, StaticParamsResult as v, extractStaticParams as w, extractMetadata as x, clearPropsCache as y };
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/router/types.d.ts
|
|
4
|
+
type RouteSegmentType = 'static' | 'dynamic' | 'catch-all' | 'optional-catch-all';
|
|
5
|
+
interface RouteSegment {
|
|
6
|
+
type: RouteSegmentType;
|
|
7
|
+
value: string;
|
|
8
|
+
param?: string;
|
|
9
|
+
}
|
|
10
|
+
interface AppRouteEntry {
|
|
11
|
+
path: string;
|
|
12
|
+
filePath: string;
|
|
13
|
+
segments: RouteSegment[];
|
|
14
|
+
params: string[];
|
|
15
|
+
isDynamic: boolean;
|
|
16
|
+
metadata?: RouteMetadata;
|
|
17
|
+
}
|
|
18
|
+
interface LayoutEntry {
|
|
19
|
+
path: string;
|
|
20
|
+
filePath: string;
|
|
21
|
+
parentPath?: string;
|
|
22
|
+
}
|
|
23
|
+
interface LoadingEntry {
|
|
24
|
+
path: string;
|
|
25
|
+
filePath: string;
|
|
26
|
+
componentId: string;
|
|
27
|
+
}
|
|
28
|
+
interface ErrorEntry {
|
|
29
|
+
path: string;
|
|
30
|
+
filePath: string;
|
|
31
|
+
}
|
|
32
|
+
interface NotFoundEntry {
|
|
33
|
+
path: string;
|
|
34
|
+
filePath: string;
|
|
35
|
+
}
|
|
36
|
+
interface OgImageEntry {
|
|
37
|
+
path: string;
|
|
38
|
+
filePath: string;
|
|
39
|
+
width?: number;
|
|
40
|
+
height?: number;
|
|
41
|
+
contentType?: string;
|
|
42
|
+
}
|
|
43
|
+
interface ApiRouteEntry {
|
|
44
|
+
path: string;
|
|
45
|
+
filePath: string;
|
|
46
|
+
segments: RouteSegment[];
|
|
47
|
+
params: string[];
|
|
48
|
+
isDynamic: boolean;
|
|
49
|
+
methods: string[];
|
|
50
|
+
}
|
|
51
|
+
interface AppRouteManifest {
|
|
52
|
+
routes: AppRouteEntry[];
|
|
53
|
+
layouts: LayoutEntry[];
|
|
54
|
+
loading: LoadingEntry[];
|
|
55
|
+
errors: ErrorEntry[];
|
|
56
|
+
notFound: NotFoundEntry[];
|
|
57
|
+
apiRoutes: ApiRouteEntry[];
|
|
58
|
+
ogImages: OgImageEntry[];
|
|
59
|
+
generated: string;
|
|
60
|
+
}
|
|
61
|
+
interface RouteMetadata {
|
|
62
|
+
title?: string | {
|
|
63
|
+
default?: string;
|
|
64
|
+
template?: string;
|
|
65
|
+
absolute?: string;
|
|
66
|
+
};
|
|
67
|
+
description?: string;
|
|
68
|
+
keywords?: string | string[];
|
|
69
|
+
openGraph?: {
|
|
70
|
+
title?: string;
|
|
71
|
+
description?: string;
|
|
72
|
+
images?: string[] | Array<{
|
|
73
|
+
url: string;
|
|
74
|
+
width?: number;
|
|
75
|
+
height?: number;
|
|
76
|
+
alt?: string;
|
|
77
|
+
}>;
|
|
78
|
+
url?: string;
|
|
79
|
+
siteName?: string;
|
|
80
|
+
locale?: string;
|
|
81
|
+
type?: string;
|
|
82
|
+
};
|
|
83
|
+
twitter?: {
|
|
84
|
+
card?: 'summary' | 'summary_large_image' | 'app' | 'player';
|
|
85
|
+
title?: string;
|
|
86
|
+
description?: string;
|
|
87
|
+
images?: string[] | Array<{
|
|
88
|
+
url: string;
|
|
89
|
+
alt?: string;
|
|
90
|
+
}>;
|
|
91
|
+
site?: string;
|
|
92
|
+
creator?: string;
|
|
93
|
+
};
|
|
94
|
+
robots?: {
|
|
95
|
+
index?: boolean;
|
|
96
|
+
follow?: boolean;
|
|
97
|
+
noarchive?: boolean;
|
|
98
|
+
nosnippet?: boolean;
|
|
99
|
+
noimageindex?: boolean;
|
|
100
|
+
nocache?: boolean;
|
|
101
|
+
} | string;
|
|
102
|
+
icons?: {
|
|
103
|
+
icon?: string | Array<{
|
|
104
|
+
url: string;
|
|
105
|
+
type?: string;
|
|
106
|
+
sizes?: string;
|
|
107
|
+
}>;
|
|
108
|
+
shortcut?: string;
|
|
109
|
+
apple?: string | Array<{
|
|
110
|
+
url: string;
|
|
111
|
+
sizes?: string;
|
|
112
|
+
type?: string;
|
|
113
|
+
}>;
|
|
114
|
+
};
|
|
115
|
+
manifest?: string;
|
|
116
|
+
themeColor?: string | Array<{
|
|
117
|
+
media?: string;
|
|
118
|
+
color: string;
|
|
119
|
+
}>;
|
|
120
|
+
viewport?: string | {
|
|
121
|
+
width?: string | number;
|
|
122
|
+
height?: string | number;
|
|
123
|
+
initialScale?: number;
|
|
124
|
+
minimumScale?: number;
|
|
125
|
+
maximumScale?: number;
|
|
126
|
+
userScalable?: boolean;
|
|
127
|
+
};
|
|
128
|
+
appleWebApp?: {
|
|
129
|
+
capable?: boolean;
|
|
130
|
+
title?: string;
|
|
131
|
+
statusBarStyle?: 'default' | 'black' | 'black-translucent';
|
|
132
|
+
};
|
|
133
|
+
canonical?: string;
|
|
134
|
+
}
|
|
135
|
+
type Metadata = RouteMetadata;
|
|
136
|
+
type RouteParams = Record<string, string | string[]>;
|
|
137
|
+
type SearchParams = Record<string, string | string[] | undefined>;
|
|
138
|
+
interface PageProps<TParams extends RouteParams = RouteParams, TSearchParams extends SearchParams = SearchParams> {
|
|
139
|
+
params: TParams;
|
|
140
|
+
searchParams: TSearchParams;
|
|
141
|
+
}
|
|
142
|
+
interface LayoutProps<TParams extends RouteParams = RouteParams> {
|
|
143
|
+
children: ReactNode;
|
|
144
|
+
params?: TParams;
|
|
145
|
+
pathname?: string;
|
|
146
|
+
}
|
|
147
|
+
interface ErrorProps {
|
|
148
|
+
error: Error;
|
|
149
|
+
reset: () => void;
|
|
150
|
+
}
|
|
151
|
+
interface AppRouteMatch {
|
|
152
|
+
route: AppRouteEntry;
|
|
153
|
+
params: RouteParams;
|
|
154
|
+
searchParams: SearchParams;
|
|
155
|
+
layouts: LayoutEntry[];
|
|
156
|
+
loading?: LoadingEntry;
|
|
157
|
+
error?: ErrorEntry;
|
|
158
|
+
pathname: string;
|
|
159
|
+
}
|
|
160
|
+
type GenerateMetadata<TParams extends RouteParams = RouteParams, TSearchParams extends SearchParams = SearchParams> = (props: {
|
|
161
|
+
params: TParams;
|
|
162
|
+
searchParams: TSearchParams;
|
|
163
|
+
}) => RouteMetadata | Promise<RouteMetadata>;
|
|
164
|
+
type GenerateStaticParams<TParams extends RouteParams = RouteParams> = () => TParams[] | Promise<TParams[]>;
|
|
165
|
+
//#endregion
|
|
166
|
+
export { ErrorProps as a, LayoutEntry as c, Metadata as d, NotFoundEntry as f, RouteSegmentType as h, ErrorEntry as i, LayoutProps as l, RouteSegment as m, AppRouteManifest as n, GenerateMetadata as o, PageProps as p, AppRouteMatch as r, GenerateStaticParams as s, AppRouteEntry as t, LoadingEntry as u };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{C as e,E as t,T as n,c as r,d as i,r as a,t as o,u as s,v as c,w as l}from"./regex-constants-DMuIAFub.mjs";import{a as u,i as d,n as f,o as p,r as m,t as h}from"./constants-DZAg-dr0.mjs";import{t as g}from"./server-build-BaEm53O_.mjs";import _,{promises as v}from"node:fs";import y from"node:path";import b from"node:process";import{Buffer as ee}from"node:buffer";import{spawn as te}from"node:child_process";import{fileURLToPath as x}from"node:url";import{build as S}from"rolldown";var C=class extends Response{static json(e,t){let n=new Headers(t?.headers);return n.has(`content-type`)||n.set(`content-type`,`application/json`),new Response(JSON.stringify(e),{...t,headers:n})}static redirect(e,t=307){return new Response(null,{status:t,headers:{location:e}})}static noContent(e){return new Response(null,{...e,status:204})}};function w(e={}){let{root:t=b.cwd(),srcDir:n=`src`,proxyFileName:r=`proxy`,extensions:i=[`.ts`,`.tsx`,`.js`,`.jsx`,`.mts`,`.mjs`],verbose:a=!1}=e,o=null,s=e=>{a&&console.warn(`[rari] Proxy: ${e}`)};async function c(){for(let e of i){let n=`${r}${e}`,i=y.join(t,n);try{return await v.access(i),s(`Found proxy file: ${n}`),{filePath:i,exists:!0,relativePath:n}}catch{}}let e=y.join(t,n);try{await v.access(e);for(let t of i){let i=`${r}${t}`,a=y.join(e,i);try{return await v.access(a),s(`Found proxy file: ${y.join(n,i)}`),{filePath:a,exists:!0,relativePath:y.join(n,i)}}catch{}}}catch{}return null}return{name:`rari:proxy`,async buildStart(){o=await c(),s(o?`Proxy enabled: ${o.relativePath}`:`No proxy file found`)},configureServer(e){o&&(e.watcher.add(o.filePath),e.watcher.on(`change`,t=>{t===o?.filePath&&(s(`Proxy file changed, reloading...`),e.ws.send({type:`custom`,event:`rari:proxy-reload`}))}))},async handleHotUpdate({file:e,server:t}){if(o&&e===o.filePath)return s(`Hot reloading proxy...`),t.ws.send({type:`custom`,event:`rari:proxy-reload`,data:{file:o.relativePath}}),[]}}}const T=/export\s+const\s+metadata\s*(?::\s*\w+\s*)?=\s*(\{[\s\S]*?\n\})/,E=/title\s*:\s*['"]([^'"]+)['"]/,D=/description\s*:\s*['"]([^'"]+)['"]/,O=/keywords\s*:\s*\[([\s\S]*?)\]/,k={appDir:`src/app`,extensions:[`.tsx`,`.jsx`,`.ts`,`.js`],outDir:`dist`};function A(e){switch(y.basename(e).replace(n,``)){case`page`:return`page`;case`layout`:return`layout`;case`loading`:return`loading`;case`error`:return`error`;case`not-found`:return`not-found`;case`route`:return`route`;default:return null}}function j(e,t){let n=y.relative(t,y.dirname(e));return!n||n===`.`?`/`:`/${n.replace(o,`/`).split(`/`).filter(Boolean).join(`/`)}`}function M(e,t,n){if(t===`page`)return[e];let r=n.filter(t=>t===e||t.startsWith(`${e}/`));return r.length>0?r:[e]}function N(t){try{let n=t.match(T);if(!n)return null;let r=n[1],i={},a=r.match(E);a&&(i.title=a[1]);let o=r.match(D);o&&(i.description=o[1]);let s=r.match(O);s&&(i.keywords=s[1].split(`,`).map(t=>t.trim().replace(e,``)).filter(Boolean));for(let e of[`author`,`viewport`,`themeColor`,`robots`,`openGraph`,`twitter`]){let t=RegExp(`${e}\\s*:\\s*['"]([^'"]+)['"]`,`m`),n=r.match(t);n&&(i[e]=n[1])}return Object.keys(i).length>0?i:null}catch(e){return console.error(`[rari] Router: Failed to extract metadata:`,e),null}}function ne(e){let t=[];for(let n of[`GET`,`POST`,`PUT`,`DELETE`,`PATCH`,`HEAD`,`OPTIONS`]){let r=RegExp(`export\\s+(?:async\\s+)?function\\s+${n}\\s*\\(`),i=RegExp(`export\\s+(?:async\\s+)?(?:const|let|var)\\s+${n}\\s*=`);(r.test(e)||i.test(e))&&t.push(n)}return t}async function re(e){try{let t=await fetch(`http://localhost:3000/_rari/hmr`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`invalidate-api-route`,filePath:e})});if(!t.ok){console.error(`[rari] Router: Failed to invalidate API route cache: ${t.statusText}`);return}let n=await t.json();n.success||console.error(`[rari] HMR: Failed to invalidate API route cache: ${n.error||`Unknown error`}`)}catch(e){console.error(`[rari] Router: Failed to notify API route invalidation:`,e)}}function P(e={}){let t={...k,...e},n=null,r=new Map,i=null,a=new Set,o=e=>[...e].toSorted().join(`|`),s=async e=>{let n=new Set,r=async e=>{try{let i=await v.readdir(e,{withFileTypes:!0});for(let a of i){let i=y.join(e,a.name);a.isDirectory()?await r(i):a.isFile()&&t.extensions.some(e=>a.name.endsWith(e))&&A(i)&&n.add(i)}}catch{}};return await r(e),n},c=async(e,r=!1)=>{let c=y.resolve(e,t.appDir);try{await v.access(c)}catch{return null}try{let l=await s(c),u=o(l);if(!r&&i===u&&n)return n;let{generateAppRouteManifest:d}=await import(`./routes-DXBE0bwy.mjs`).then(e=>e.n),f=await d(c,{extensions:t.extensions}),p=JSON.stringify(f,null,2),m=y.resolve(e,t.outDir);await v.mkdir(m,{recursive:!0});let h=y.join(m,`server`);return await v.mkdir(h,{recursive:!0}),await v.writeFile(y.join(h,`routes.json`),p,`utf-8`),i=u,a.clear(),l.forEach(e=>a.add(e)),p}catch(e){return console.error(`[rari] Router: Failed to generate app routes:`,e),null}},l=e=>{let n=y.resolve(e.config.root,t.appDir);e.watcher.on(`all`,async(r,i)=>{if(i.startsWith(n)&&t.extensions.some(e=>i.endsWith(e)))try{let n=A(i)!==null,o=r===`add`||r===`unlink`,s=n&&!a.has(i);(o||s)&&(await c(e.config.root,!0),i.includes(t.appDir)&&e.ws.send({type:`full-reload`,path:`*`}))}catch(e){console.error(`[rari] Router: Failed to regenerate app routes:`,e)}})},u;return{name:`rari-router`,configResolved(e){u=e.root;let t=e.logger.warn;e.logger.warn=(e,n)=>{typeof e==`string`&&e.includes(`runtime-client`)&&e.includes(`The above dynamic import cannot be analyzed`)||t(e,n)}},async writeBundle(){n=await c(u||b.cwd(),!0)},configureServer(e){l(e)},async handleHotUpdate(e){let{file:i,server:o}=e,s=y.resolve(o.config.root,t.appDir);if(i.startsWith(s)&&t.extensions.some(e=>i.endsWith(e))){let e=A(i);if(e){let t=r.get(i);t&&clearTimeout(t);let l=setTimeout(async()=>{r.delete(i);let t=!a.has(i),l=n;n=await c(o.config.root,t);let u=l!==n,d=j(i,s),f=[d];if(n)try{f=JSON.parse(n).routes.map(e=>e.path)}catch(e){console.error(`[rari] Router: Failed to parse manifest for affected routes:`,e)}let p=M(d,e,f),m,h=!1,g;if(e===`page`||e===`layout`)try{let e=N(await v.readFile(i,`utf-8`));e&&(m=e,h=!0)}catch(e){console.error(`[rari] Router: Failed to extract metadata:`,e)}if(e===`route`)try{g=ne(await v.readFile(i,`utf-8`)),await re(y.relative(s,i))}catch(e){console.error(`[rari] Router: Failed to detect HTTP methods:`,e)}let _={fileType:e,filePath:y.relative(o.config.root,i),routePath:d,affectedRoutes:p,manifestUpdated:u,timestamp:Date.now(),metadata:m,metadataChanged:h,methods:g};o.ws.send({type:`custom`,event:`rari:app-router-updated`,data:_})},200);return r.set(i,l),[]}return n=await c(o.config.root),[]}},async closeBundle(){for(let e of r.values())clearTimeout(e);r.clear()}}}var ie=class{errorCount=0;maxErrors;resetTimeout;resetTimer=null;lastError=null;constructor(e={}){this.maxErrors=e.maxErrors??5,this.resetTimeout=e.resetTimeout??3e4}recordError(e){this.errorCount++,this.lastError=e,this.resetTimer&&clearTimeout(this.resetTimer),this.resetTimer=setTimeout(()=>{this.reset()},this.resetTimeout),this.errorCount>=this.maxErrors&&this.handleMaxErrorsReached()}reset(){this.errorCount=0,this.lastError=null,this.resetTimer&&=(clearTimeout(this.resetTimer),null)}getErrorCount(){return this.errorCount}getLastError(){return this.lastError}hasReachedMaxErrors(){return this.errorCount>=this.maxErrors}handleMaxErrorsReached(){console.error(`[rari] HMR: Maximum error count (${this.maxErrors}) reached. Consider restarting the dev server if issues persist.`)}dispose(){this.resetTimer&&=(clearTimeout(this.resetTimer),null),this.reset()}},ae=class{serverComponentBuilder;rustServerUrl;pendingUpdates=new Map;pendingFiles=new Set;batchTimer=null;DEBOUNCE_DELAY=200;errorHandler;logBatch=[];logBatchTimer=null;LOG_BATCH_DELAY=500;constructor(e,t=3e3){this.serverComponentBuilder=e,this.rustServerUrl=`http://localhost:${t}`,this.errorHandler=new ie({maxErrors:5,resetTimeout:3e4})}async handleClientComponentUpdate(e,t){let n=y.relative(b.cwd(),e);try{let r=t.moduleGraph.getModuleById(e);r?(t.moduleGraph.invalidateModule(r),this.errorHandler.reset()):this.queueLog(`warning`,`Client component module not found in graph: ${n}`)}catch(e){let t=e instanceof Error?e.message:String(e);this.queueLog(`error`,`Failed to update client component: ${n} - ${t}`),this.errorHandler.recordError(e instanceof Error?e:Error(t))}}async handleServerComponentUpdate(e,t){this.pendingFiles.add(e);let n=this.pendingUpdates.get(e);n&&(clearTimeout(n),this.pendingUpdates.delete(e)),this.batchTimer&&clearTimeout(this.batchTimer),this.batchTimer=setTimeout(async()=>{let e=[...this.pendingFiles];if(this.pendingFiles.clear(),this.batchTimer=null,e.length===0)return;let n=await Promise.allSettled(e.map(async e=>{let t=y.relative(b.cwd(),e);try{let n=await this.serverComponentBuilder.rebuildComponent(e);if(!n.success)throw Error(n.error||`Build failed`);return await this.notifyRustServer(n.componentId,n.bundlePath),{success:!0,componentId:n.componentId,filePath:e,relativePath:t}}catch(n){return{success:!1,filePath:e,relativePath:t,error:n instanceof Error?n:Error(String(n))}}})),r=[],i=[];if(n.forEach(e=>{e.status===`fulfilled`&&e.value.success?r.push(e.value):e.status===`fulfilled`&&!e.value.success?i.push(e.value):e.status===`rejected`&&i.push({filePath:``,relativePath:`unknown`,error:Error(String(e.reason))})}),r.length>0){let e=Date.now();r.forEach(({componentId:n})=>{t.hot.send(`rari:server-component-updated`,{id:n,t:e})}),this.errorHandler.reset(),t.ws.send({type:`custom`,event:`rari:hmr-error-cleared`,data:{t:e}})}if(i.length>0){let e=Date.now();i.forEach(({relativePath:n,error:r})=>{let i=r.message,a=(r.stack||``).substring(0,500);this.queueLog(`error`,`Failed to rebuild: ${n} - ${i}`),this.errorHandler.recordError(r),t.ws.send({type:`custom`,event:`rari:hmr-error`,data:{msg:i,stack:a,file:n,t:e,count:this.errorHandler.getErrorCount(),max:5}})}),this.errorHandler.hasReachedMaxErrors()&&this.queueLog(`error`,`Maximum error count reached (${this.errorHandler.getErrorCount()}). Consider restarting the dev server if issues persist.`)}},this.DEBOUNCE_DELAY)}async notifyRustServer(e,t){try{let n=await fetch(`${this.rustServerUrl}/_rari/hmr`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`reload-component`,component_id:e,bundle_path:t})});if(!n.ok){let e=await n.text();throw Error(`HTTP ${n.status}: ${e}`)}let r=await n.text(),i;try{i=JSON.parse(r)}catch(e){throw Error(`Failed to parse server response (status ${n.status}): ${e instanceof Error?e.message:String(e)}. Response body: ${r.substring(0,200)}${r.length>200?`...`:``}`)}if(!i||typeof i!=`object`)throw Error(`Invalid server response (status ${n.status}): expected object, got ${typeof i}. Response body: ${r.substring(0,200)}${r.length>200?`...`:``}`);let a=i;if(!a.success)throw Error(a.message||a.error||`Component reload failed`)}catch(e){throw console.error(`[rari] HMR: Failed to notify Rust server:`,e),e}}detectComponentType(e){try{let t=_.readFileSync(e,`utf-8`).split(`
|
|
1
|
+
import{C as e,E as t,T as n,c as r,d as i,r as a,t as o,u as s,v as c,w as l}from"./regex-constants-DMuIAFub.mjs";import{a as u,i as d,n as f,o as p,r as m,t as h}from"./constants-DZAg-dr0.mjs";import{t as g}from"./server-build-BbPx0SOe.mjs";import _,{promises as v}from"node:fs";import y from"node:path";import b from"node:process";import{Buffer as ee}from"node:buffer";import{spawn as te}from"node:child_process";import{fileURLToPath as x}from"node:url";import{build as S}from"rolldown";var C=class extends Response{static json(e,t){let n=new Headers(t?.headers);return n.has(`content-type`)||n.set(`content-type`,`application/json`),new Response(JSON.stringify(e),{...t,headers:n})}static redirect(e,t=307){return new Response(null,{status:t,headers:{location:e}})}static noContent(e){return new Response(null,{...e,status:204})}};function w(e={}){let{root:t=b.cwd(),srcDir:n=`src`,proxyFileName:r=`proxy`,extensions:i=[`.ts`,`.tsx`,`.js`,`.jsx`,`.mts`,`.mjs`],verbose:a=!1}=e,o=null,s=e=>{a&&console.warn(`[rari] Proxy: ${e}`)};async function c(){for(let e of i){let n=`${r}${e}`,i=y.join(t,n);try{return await v.access(i),s(`Found proxy file: ${n}`),{filePath:i,exists:!0,relativePath:n}}catch{}}let e=y.join(t,n);try{await v.access(e);for(let t of i){let i=`${r}${t}`,a=y.join(e,i);try{return await v.access(a),s(`Found proxy file: ${y.join(n,i)}`),{filePath:a,exists:!0,relativePath:y.join(n,i)}}catch{}}}catch{}return null}return{name:`rari:proxy`,async buildStart(){o=await c(),s(o?`Proxy enabled: ${o.relativePath}`:`No proxy file found`)},configureServer(e){o&&(e.watcher.add(o.filePath),e.watcher.on(`change`,t=>{t===o?.filePath&&(s(`Proxy file changed, reloading...`),e.ws.send({type:`custom`,event:`rari:proxy-reload`}))}))},async handleHotUpdate({file:e,server:t}){if(o&&e===o.filePath)return s(`Hot reloading proxy...`),t.ws.send({type:`custom`,event:`rari:proxy-reload`,data:{file:o.relativePath}}),[]}}}const T=/export\s+const\s+metadata\s*(?::\s*\w+\s*)?=\s*(\{[\s\S]*?\n\})/,E=/title\s*:\s*['"]([^'"]+)['"]/,D=/description\s*:\s*['"]([^'"]+)['"]/,O=/keywords\s*:\s*\[([\s\S]*?)\]/,k={appDir:`src/app`,extensions:[`.tsx`,`.jsx`,`.ts`,`.js`],outDir:`dist`};function A(e){switch(y.basename(e).replace(n,``)){case`page`:return`page`;case`layout`:return`layout`;case`loading`:return`loading`;case`error`:return`error`;case`not-found`:return`not-found`;case`route`:return`route`;default:return null}}function j(e,t){let n=y.relative(t,y.dirname(e));return!n||n===`.`?`/`:`/${n.replace(o,`/`).split(`/`).filter(Boolean).join(`/`)}`}function M(e,t,n){if(t===`page`)return[e];let r=n.filter(t=>t===e||t.startsWith(`${e}/`));return r.length>0?r:[e]}function N(t){try{let n=t.match(T);if(!n)return null;let r=n[1],i={},a=r.match(E);a&&(i.title=a[1]);let o=r.match(D);o&&(i.description=o[1]);let s=r.match(O);s&&(i.keywords=s[1].split(`,`).map(t=>t.trim().replace(e,``)).filter(Boolean));for(let e of[`author`,`viewport`,`themeColor`,`robots`,`openGraph`,`twitter`]){let t=RegExp(`${e}\\s*:\\s*['"]([^'"]+)['"]`,`m`),n=r.match(t);n&&(i[e]=n[1])}return Object.keys(i).length>0?i:null}catch(e){return console.error(`[rari] Router: Failed to extract metadata:`,e),null}}function ne(e){let t=[];for(let n of[`GET`,`POST`,`PUT`,`DELETE`,`PATCH`,`HEAD`,`OPTIONS`]){let r=RegExp(`export\\s+(?:async\\s+)?function\\s+${n}\\s*\\(`),i=RegExp(`export\\s+(?:async\\s+)?(?:const|let|var)\\s+${n}\\s*=`);(r.test(e)||i.test(e))&&t.push(n)}return t}async function re(e){try{let t=await fetch(`http://localhost:3000/_rari/hmr`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`invalidate-api-route`,filePath:e})});if(!t.ok){console.error(`[rari] Router: Failed to invalidate API route cache: ${t.statusText}`);return}let n=await t.json();n.success||console.error(`[rari] HMR: Failed to invalidate API route cache: ${n.error||`Unknown error`}`)}catch(e){console.error(`[rari] Router: Failed to notify API route invalidation:`,e)}}function P(e={}){let t={...k,...e},n=null,r=new Map,i=null,a=new Set,o=e=>[...e].toSorted().join(`|`),s=async e=>{let n=new Set,r=async e=>{try{let i=await v.readdir(e,{withFileTypes:!0});for(let a of i){let i=y.join(e,a.name);a.isDirectory()?await r(i):a.isFile()&&t.extensions.some(e=>a.name.endsWith(e))&&A(i)&&n.add(i)}}catch{}};return await r(e),n},c=async(e,r=!1)=>{let c=y.resolve(e,t.appDir);try{await v.access(c)}catch{return null}try{let l=await s(c),u=o(l);if(!r&&i===u&&n)return n;let{generateAppRouteManifest:d}=await import(`./routes-DXBE0bwy.mjs`).then(e=>e.n),f=await d(c,{extensions:t.extensions}),p=JSON.stringify(f,null,2),m=y.resolve(e,t.outDir);await v.mkdir(m,{recursive:!0});let h=y.join(m,`server`);return await v.mkdir(h,{recursive:!0}),await v.writeFile(y.join(h,`routes.json`),p,`utf-8`),i=u,a.clear(),l.forEach(e=>a.add(e)),p}catch(e){return console.error(`[rari] Router: Failed to generate app routes:`,e),null}},l=e=>{let n=y.resolve(e.config.root,t.appDir);e.watcher.on(`all`,async(r,i)=>{if(i.startsWith(n)&&t.extensions.some(e=>i.endsWith(e)))try{let n=A(i)!==null,o=r===`add`||r===`unlink`,s=n&&!a.has(i);(o||s)&&(await c(e.config.root,!0),i.includes(t.appDir)&&e.ws.send({type:`full-reload`,path:`*`}))}catch(e){console.error(`[rari] Router: Failed to regenerate app routes:`,e)}})},u;return{name:`rari-router`,configResolved(e){u=e.root;let t=e.logger.warn;e.logger.warn=(e,n)=>{typeof e==`string`&&e.includes(`runtime-client`)&&e.includes(`The above dynamic import cannot be analyzed`)||t(e,n)}},async writeBundle(){n=await c(u||b.cwd(),!0)},configureServer(e){l(e)},async handleHotUpdate(e){let{file:i,server:o}=e,s=y.resolve(o.config.root,t.appDir);if(i.startsWith(s)&&t.extensions.some(e=>i.endsWith(e))){let e=A(i);if(e){let t=r.get(i);t&&clearTimeout(t);let l=setTimeout(async()=>{r.delete(i);let t=!a.has(i),l=n;n=await c(o.config.root,t);let u=l!==n,d=j(i,s),f=[d];if(n)try{f=JSON.parse(n).routes.map(e=>e.path)}catch(e){console.error(`[rari] Router: Failed to parse manifest for affected routes:`,e)}let p=M(d,e,f),m,h=!1,g;if(e===`page`||e===`layout`)try{let e=N(await v.readFile(i,`utf-8`));e&&(m=e,h=!0)}catch(e){console.error(`[rari] Router: Failed to extract metadata:`,e)}if(e===`route`)try{g=ne(await v.readFile(i,`utf-8`)),await re(y.relative(s,i))}catch(e){console.error(`[rari] Router: Failed to detect HTTP methods:`,e)}let _={fileType:e,filePath:y.relative(o.config.root,i),routePath:d,affectedRoutes:p,manifestUpdated:u,timestamp:Date.now(),metadata:m,metadataChanged:h,methods:g};o.ws.send({type:`custom`,event:`rari:app-router-updated`,data:_})},200);return r.set(i,l),[]}return n=await c(o.config.root),[]}},async closeBundle(){for(let e of r.values())clearTimeout(e);r.clear()}}}var ie=class{errorCount=0;maxErrors;resetTimeout;resetTimer=null;lastError=null;constructor(e={}){this.maxErrors=e.maxErrors??5,this.resetTimeout=e.resetTimeout??3e4}recordError(e){this.errorCount++,this.lastError=e,this.resetTimer&&clearTimeout(this.resetTimer),this.resetTimer=setTimeout(()=>{this.reset()},this.resetTimeout),this.errorCount>=this.maxErrors&&this.handleMaxErrorsReached()}reset(){this.errorCount=0,this.lastError=null,this.resetTimer&&=(clearTimeout(this.resetTimer),null)}getErrorCount(){return this.errorCount}getLastError(){return this.lastError}hasReachedMaxErrors(){return this.errorCount>=this.maxErrors}handleMaxErrorsReached(){console.error(`[rari] HMR: Maximum error count (${this.maxErrors}) reached. Consider restarting the dev server if issues persist.`)}dispose(){this.resetTimer&&=(clearTimeout(this.resetTimer),null),this.reset()}},ae=class{serverComponentBuilder;rustServerUrl;pendingUpdates=new Map;pendingFiles=new Set;batchTimer=null;DEBOUNCE_DELAY=200;errorHandler;logBatch=[];logBatchTimer=null;LOG_BATCH_DELAY=500;constructor(e,t=3e3){this.serverComponentBuilder=e,this.rustServerUrl=`http://localhost:${t}`,this.errorHandler=new ie({maxErrors:5,resetTimeout:3e4})}async handleClientComponentUpdate(e,t){let n=y.relative(b.cwd(),e);try{let r=t.moduleGraph.getModuleById(e);r?(t.moduleGraph.invalidateModule(r),this.errorHandler.reset()):this.queueLog(`warning`,`Client component module not found in graph: ${n}`)}catch(e){let t=e instanceof Error?e.message:String(e);this.queueLog(`error`,`Failed to update client component: ${n} - ${t}`),this.errorHandler.recordError(e instanceof Error?e:Error(t))}}async handleServerComponentUpdate(e,t){this.pendingFiles.add(e);let n=this.pendingUpdates.get(e);n&&(clearTimeout(n),this.pendingUpdates.delete(e)),this.batchTimer&&clearTimeout(this.batchTimer),this.batchTimer=setTimeout(async()=>{let e=[...this.pendingFiles];if(this.pendingFiles.clear(),this.batchTimer=null,e.length===0)return;let n=await Promise.allSettled(e.map(async e=>{let t=y.relative(b.cwd(),e);try{let n=await this.serverComponentBuilder.rebuildComponent(e);if(!n.success)throw Error(n.error||`Build failed`);return await this.notifyRustServer(n.componentId,n.bundlePath),{success:!0,componentId:n.componentId,filePath:e,relativePath:t}}catch(n){return{success:!1,filePath:e,relativePath:t,error:n instanceof Error?n:Error(String(n))}}})),r=[],i=[];if(n.forEach(e=>{e.status===`fulfilled`&&e.value.success?r.push(e.value):e.status===`fulfilled`&&!e.value.success?i.push(e.value):e.status===`rejected`&&i.push({filePath:``,relativePath:`unknown`,error:Error(String(e.reason))})}),r.length>0){let e=Date.now();r.forEach(({componentId:n})=>{t.hot.send(`rari:server-component-updated`,{id:n,t:e})}),this.errorHandler.reset(),t.ws.send({type:`custom`,event:`rari:hmr-error-cleared`,data:{t:e}})}if(i.length>0){let e=Date.now();i.forEach(({relativePath:n,error:r})=>{let i=r.message,a=(r.stack||``).substring(0,500);this.queueLog(`error`,`Failed to rebuild: ${n} - ${i}`),this.errorHandler.recordError(r),t.ws.send({type:`custom`,event:`rari:hmr-error`,data:{msg:i,stack:a,file:n,t:e,count:this.errorHandler.getErrorCount(),max:5}})}),this.errorHandler.hasReachedMaxErrors()&&this.queueLog(`error`,`Maximum error count reached (${this.errorHandler.getErrorCount()}). Consider restarting the dev server if issues persist.`)}},this.DEBOUNCE_DELAY)}async notifyRustServer(e,t){try{let n=await fetch(`${this.rustServerUrl}/_rari/hmr`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`reload-component`,component_id:e,bundle_path:t})});if(!n.ok){let e=await n.text();throw Error(`HTTP ${n.status}: ${e}`)}let r=await n.text(),i;try{i=JSON.parse(r)}catch(e){throw Error(`Failed to parse server response (status ${n.status}): ${e instanceof Error?e.message:String(e)}. Response body: ${r.substring(0,200)}${r.length>200?`...`:``}`)}if(!i||typeof i!=`object`)throw Error(`Invalid server response (status ${n.status}): expected object, got ${typeof i}. Response body: ${r.substring(0,200)}${r.length>200?`...`:``}`);let a=i;if(!a.success)throw Error(a.message||a.error||`Component reload failed`)}catch(e){throw console.error(`[rari] HMR: Failed to notify Rust server:`,e),e}}detectComponentType(e){try{let t=_.readFileSync(e,`utf-8`).split(`
|
|
2
2
|
`);for(let e of t){let t=e.trim();if(!(!t||t.startsWith(`//`)||t.startsWith(`/*`))){if(t===`'use client'`||t===`"use client"`)return`client`;break}}return`server`}catch{return`unknown`}}queueLog(e,t){this.logBatch.push({type:e,message:t,timestamp:Date.now()}),this.logBatchTimer&&clearTimeout(this.logBatchTimer),this.logBatchTimer=setTimeout(()=>{this.flushLogs()},this.LOG_BATCH_DELAY)}flushLogs(){if(this.logBatch.length===0)return;let e=this.logBatch.reduce((e,t)=>(e[t.type]||(e[t.type]=[]),e[t.type].push(t),e),{});for(let[t,n]of Object.entries(e))if(n.length===1){let e=n[0];this.outputLog(t,e.message)}else{let e=n.map(e=>e.message).join(`
|
|
3
3
|
• `);this.outputLog(t,`${n.length} updates:\n • ${e}`)}this.logBatch=[],this.logBatchTimer=null}outputLog(e,t){let n=`[rari] HMR:`;switch(e){case`success`:console.warn(`\x1B[32m${n}\x1B[0m ${t}`);break;case`warning`:console.warn(`\x1B[33m${n}\x1B[0m ${t}`);break;case`error`:console.error(`\x1B[31m${n}\x1B[0m ${t}`);break;default:console.warn(`${n} ${t}`);break}}dispose(){this.logBatchTimer&&(clearTimeout(this.logBatchTimer),this.flushLogs()),this.batchTimer&&=(clearTimeout(this.batchTimer),null);for(let e of this.pendingUpdates.values())clearTimeout(e);this.pendingUpdates.clear(),this.pendingFiles.clear(),this.errorHandler.dispose()}};const oe=/import\s+(\w+)\s+from\s+['"]rari\/image['"]/g,se=/import\s+\{[^}]*\b(?:Image\s+as\s+(\w+)|Image)\b[^}]*\}\s+from\s+['"]rari\/image['"]/g,ce=/src:\s*["']([^"']+)["']/,F=/[.*+?^${}()|[\]\\]/g,I=/width:\s*(\d+)/,L=/quality:\s*(\d+)/,R=/preload:\s*(true|!0)/,z=/preload:\s*(false|!1)/,B=/<Image\s([^/>]+)\/>/g,V=/<Image\s([^>]+)>/g,H=/src=\{?["']([^"']+)["']\}?|src=\{([^}]+)\}/,U=/width=\{?(\d+)\}?/,W=/quality=\{?(\d+)\}?/,G=/preload(?:=\{?true\}?)?/,le=/preload=\{?false\}?/;async function ue(e,t=[]){let r=new Map;async function i(e){if(!_.existsSync(e))return;let t=_.readdirSync(e,{withFileTypes:!0});for(let a of t){let t=y.join(e,a.name);if(a.isDirectory()){if(a.name===`node_modules`||a.name===`dist`)continue;await i(t)}else if(a.isFile()&&n.test(a.name))try{let e=_.readFileSync(t,`utf8`);if(!e.includes(`from 'rari/image'`)&&!e.includes(`from "rari/image"`))continue;await de(e,t,r)}catch(e){console.warn(`Failed to read or process file ${t}:`,e)}}}await i(e);for(let e of t)_.existsSync(e)&&await i(e);return{images:[...r.values()]}}async function de(e,t,n){try{let r;r=t.endsWith(`.tsx`)?`tsx`:t.endsWith(`.jsx`)?`jsx`:t.endsWith(`.ts`)?`ts`:`js`;let i=`\0virtual:${t}`,a=await S({input:i,platform:`browser`,write:!1,output:{format:`esm`},moduleTypes:{[`.${r}`]:r},transform:{jsx:`react`},plugins:[{name:`virtual-module`,resolveId(e){return e===i?e:null},load(t){return t===i?{code:e,moduleType:r}:null}}]});if(!a.output||a.output.length===0)throw Error(`Transform produced no output`);let o=a.output[0].code,s=new Set;for(let e of o.matchAll(oe))s.add(e[1]);for(let e of o.matchAll(se))e[1]?s.add(e[1]):s.add(`Image`);if(s.size===0)return;for(let e of s){let t=e.replace(F,`\\$&`),r=RegExp(`React\\.createElement\\(\\s*${t}\\s*,\\s*\\{([^}]+)\\}`,`g`);for(let e of o.matchAll(r)){let t=e[1],r=t.match(ce);if(!r)continue;let i=r[1];if(!i.startsWith(`/`)&&!i.startsWith(`http`))continue;let a=t.match(I),o=a?Number.parseInt(a[1],10):void 0,s=t.match(L),c=s?Number.parseInt(s[1],10):void 0,l=t.match(R),u=t.match(z),d=!!l&&!u,f=`${i}:${o||`auto`}:${c||75}`;(!n.has(f)||d)&&n.set(f,{src:i,width:o,quality:c,preload:d})}}}catch{fe(e,n)}}function fe(e,t){for(let n of e.matchAll(B))K(n[1],t);for(let n of e.matchAll(V))K(n[1],t)}function K(e,t){let n=e.match(H);if(!n)return;let r=n[1]||n[2];if(!r||r.includes(`{`)||!r.startsWith(`/`)&&!r.startsWith(`http`))return;let i=e.match(U),a=i?Number.parseInt(i[1],10):void 0,o=e.match(W),s=o?Number.parseInt(o[1],10):void 0,c=G.test(e)&&!le.test(e),l=`${r}:${a||`auto`}:${s||75}`;(!t.has(l)||c)&&t.set(l,{src:r,width:a,quality:s,preload:c})}const pe=/import\s+type\s+(\{[^}]+\})\s+from\s+["']\.\.?\/([^"']+)["'];?/g,me=/import\s+type\s+(\*\s+as\s+\w+)\s+from\s+["']\.\.?\/([^"']+)["'];?/g,he=/import\s+type\s+(\w+)\s+from\s+["']\.\.?\/([^"']+)["'];?/g,ge=/import\s+(\{[^}]+\})\s+from\s+["']\.\.?\/([^"']+)["'];?/g,_e=/import\s+(\*\s+as\s+\w+)\s+from\s+["']\.\.?\/([^"']+)["'];?/g,ve=/import\s+(\w+)\s+from\s+["']\.\.?\/([^"']+)["'];?/g,ye=/import\s+["']\.\.?\/([^"']+)["'];?/g,be=/import\s*(?:\(\s*)?["']([^"']+)["']\)?/g,xe=/export\s*\{([^}]+)\}/g,Se=/\s+as\s+/,Ce=/export\s+default\s+(?:function|class)\s+\w+/,we=/export\s+default\s+(?:async\s+)?function\s+(\w+)/,q=/export\s+default\s+([^;]+)/,Te=/export\s+(?:async\s+)?(?:const|let|var|function|class)\s+(\w+)/g,Ee=/^['"]use client['"];?\s*$/gm,De=/import\s+["']([^"']+)["']/g,J=/^\s*import\s+(?:(\w+)(?:\s*,\s*\{\s*(?:(\w+(?:\s*,\s*\w+)*)\s*)?\})?|\{\s*(\w+(?:\s*,\s*\w+)*)\s*\})\s+from\s+['"]([./@][^'"]+)['"].*$/,Oe=/import\s+\{[^}]*\}\s+from\s+['"]react['"]/,ke=/import\s+[^,\s]+\s*,\s*\{[^}]*\}\s+from\s+['"]react['"]/,Ae=/import React(,\s*\{([^}]*)\})?\s+from\s+['"]react['"];?/,je=/import\s+["']([^"']+)["']/g,Y=/from(\s*)(['"])(?:\.\/|rari\/)react-server-dom-rari-client\.mjs\2/g,Me=/\bJSX\b/,Ne=/^components\//,Pe=/\{([^}]*)\}/,Fe={remotePatterns:[],localPatterns:[],deviceSizes:h,imageSizes:m,formats:f,qualityAllowlist:p,minimumCacheTTL:u,maxCacheSize:d};async function X(e){let t=import.meta.url,n=x(t),r=y.dirname(n),i=[y.join(r,`runtime`,e),y.join(r,`../runtime`,e)];for(let e of i)try{let t=await _.promises.readFile(e,`utf-8`);return e.endsWith(`.ts`)&&(t=t.replace(pe,(e,t,n)=>`import type ${t} from "rari/${n}";`),t=t.replace(me,(e,t,n)=>`import type ${t} from "rari/${n}";`),t=t.replace(he,(e,t,n)=>`import type ${t} from "rari/${n}";`),t=t.replace(ge,(e,t,n)=>`import ${t} from "rari/${n}";`),t=t.replace(_e,(e,t,n)=>`import ${t} from "rari/${n}";`),t=t.replace(ve,(e,t,n)=>`import ${t} from "rari/${n}";`),t=t.replace(ye,(e,t)=>`import "rari/${t}";`)),t}catch(t){t.code!==`ENOENT`&&t.code!==`EISDIR`&&console.warn(`[rari] Unexpected error reading ${e}:`,t)}throw Error(`Could not find ${e}. Tried: ${i.join(`, `)}`)}async function Ie(){return X(`rsc-client-runtime.mjs`)}async function Le(e,t){return(await X(`entry-client.mjs`)).replace(`/*! @preserve CLIENT_COMPONENT_IMPORTS_PLACEHOLDER */`,e).replace(`/*! @preserve CLIENT_COMPONENT_REGISTRATIONS_PLACEHOLDER */`,t)}async function Re(){return X(`react-server-dom-shim.mjs`)}async function Z(e,t){let n=await ue(y.join(e,`src`)),r={...Fe,...t.images,preoptimizeManifest:n.images},i=y.join(e,`dist`),a=y.join(i,`server`);_.existsSync(a)||_.mkdirSync(a,{recursive:!0});let o=y.join(a,`image.json`);_.writeFileSync(o,JSON.stringify(r,null,2))}function Q(e,t=[]){let r=new Set;function i(e){if(!_.existsSync(e))return;let t=_.readdirSync(e,{withFileTypes:!0});for(let a of t){let t=y.join(e,a.name);if(a.isDirectory()){if(a.name===`node_modules`)continue;i(t)}else if(a.isFile()&&n.test(a.name))try{let e=_.readFileSync(t,`utf8`);(e.includes(`'use client'`)||e.includes(`"use client"`))&&r.add(t)}catch(e){e?.code!==`ENOENT`&&console.warn(`[rari] Unexpected error during file scan:`,t,e)}}}i(e);for(let e of t)_.existsSync(e)&&i(e);return r}function ze(e){return e}function $(e={}){let u=new Map,d=new Set,f=new Map,p=null,m=null,h={};function v(e){if(f.has(e))return f.get(e);let t={hasUseServer:!1,hasUseClient:!1},r=e.replace(o,`/`);if(!n.test(r)||!r.includes(`/src/`))return f.set(e,t),t;try{let n=_.readFileSync(e,`utf-8`);t.hasUseServer=n.includes(`'use server'`)||n.includes(`"use server"`),t.hasUseClient=n.includes(`'use client'`)||n.includes(`"use client"`),f.set(e,t)}catch{f.set(e,t)}return t}function S(t){if(t.includes(`node_modules`)||t.includes(`/rari/dist/`)||t.includes(`\\rari\\dist\\`))return!1;let n=e.projectRoot||b.cwd(),r=y.join(n,`index.html`);if(_.existsSync(r))try{let e=_.readFileSync(r,`utf-8`);for(let r of e.matchAll(be)){let e=r[1];if(e.startsWith(`/src/`)&&y.join(n,e.slice(1))===t)return!1}}catch(e){e?.code!==`ENOENT`&&console.warn(`[rari] Unexpected error reading index.html:`,e)}let i;try{i=_.realpathSync(t)}catch{return!1}try{if(!_.existsSync(i))return!1;let e=_.readFileSync(i,`utf-8`),t=T(e,`use client`);return T(e,`use server`)?!1:!t}catch{return!1}}function C(e){try{let t=[],n=e.matchAll(xe);for(let e of n){let n=e[1].split(`,`);for(let e of n){let n=e.trim().split(Se).at(-1)?.trim();n&&t.push(n)}}(Ce.test(e)||r.test(e))&&t.push(`default`);let i=e.matchAll(Te);for(let e of i)e[1]&&t.push(e[1]);return[...new Set(t)]}catch{return[]}}function T(e,t){try{let n=e.split(`
|
|
4
4
|
`);for(let e of n){let n=e.trim();if(!(!n||n.startsWith(`//`)||n.startsWith(`/*`))){if(n===`'${t}'`||n===`"${t}"`||n===`'${t}';`||n===`"${t}";`)return!0;break}}return!1}catch{return!1}}function E(e,t){if(!T(e,`use server`))return e;let n=C(e);if(n.length===0)return e;let r=e;r+=`
|
|
@@ -42,7 +42,7 @@ const ${t} = registerClientReference(
|
|
|
42
42
|
);`;o=o.replace(e,r),s=!0,c=!0}}else if(!g&&S(h)){s=!0,c=!0,l=!0;let e=n;a&&a!==`_`&&f.push(`const ${a} = createServerComponentWrapper('${m}', '${p}');`),o=o.replace(e,``)}}if(s){let e=o.includes(`import React`)||o.match(Oe)||o.match(ke),n=o.includes(`createServerComponentWrapper`),r=``;if(c&&!e&&(r+=`import React from 'react';
|
|
43
43
|
`),l&&!n&&(r+=`import { createServerComponentWrapper } from 'virtual:rsc-integration.ts';
|
|
44
44
|
`),f.length>0&&(r+=`${f.join(`
|
|
45
|
-
`)}\n`),r&&(o=r+o),!o.includes(`Suspense`)){let e=o.match(Ae);e&&(e[1]&&!e[2].includes(`Suspense`)?o=o.replace(e[0],e[0].replace(Pe,`{ Suspense, $1 }`)):e[1]||(o=o.replace(e[0],`import React, { Suspense } from 'react';`)))}let i=b.env.NODE_ENV!==`production`,a=o.includes(`</`)||o.includes(`/>`)||Me.test(o);return!o.includes(`'use client'`)&&!o.includes(`"use client"`)&&a&&i&&(o=`'use client';\n\n${o}`,u.set(t,`client`)),o}return null},async configureServer(t){let r=e.projectRoot||b.cwd(),a=y.join(r,`src`);await Z(r,e);let o=null,s=async()=>{try{let{ServerComponentBuilder:i,scanDirectory:a}=await import(`./server-build-
|
|
45
|
+
`)}\n`),r&&(o=r+o),!o.includes(`Suspense`)){let e=o.match(Ae);e&&(e[1]&&!e[2].includes(`Suspense`)?o=o.replace(e[0],e[0].replace(Pe,`{ Suspense, $1 }`)):e[1]||(o=o.replace(e[0],`import React, { Suspense } from 'react';`)))}let i=b.env.NODE_ENV!==`production`,a=o.includes(`</`)||o.includes(`/>`)||Me.test(o);return!o.includes(`'use client'`)&&!o.includes(`"use client"`)&&a&&i&&(o=`'use client';\n\n${o}`,u.set(t,`client`)),o}return null},async configureServer(t){let r=e.projectRoot||b.cwd(),a=y.join(r,`src`);await Z(r,e);let o=null,s=async()=>{try{let{ServerComponentBuilder:i,scanDirectory:a}=await import(`./server-build-BbPx0SOe.mjs`).then(e=>e.n),s=new i(r,{outDir:`dist`,rscDir:`server`,manifestPath:`server/manifest.json`,serverConfigPath:`server/config.json`,alias:h,csp:e.csp,rateLimit:e.rateLimit,spamBlocker:e.spamBlocker,cacheControl:e.cacheControl});if(o=s,!m&&o){let e=b.env.SERVER_PORT?Number(b.env.SERVER_PORT):Number(b.env.PORT||b.env.RSC_PORT||3e3);m=new ae(o,e)}let c=y.join(r,`src`),l=[];if(_.existsSync(c)){let e=t=>{let r=_.readdirSync(t,{withFileTypes:!0});for(let i of r){let r=y.join(t,i.name);if(i.isDirectory())e(r);else if(i.isFile()&&n.test(i.name))try{S(r)&&l.push(r)}catch(e){console.error(`[rari] Error checking ${r}:`,e)}}};e(c),a(c,s)}l.length>0&&t.ws.send({type:`custom`,event:`rari:server-components-registry`,data:{serverComponents:l}});let u=await s.getTransformedComponentsForDevelopment(),d=`http://localhost:${b.env.SERVER_PORT?Number(b.env.SERVER_PORT):Number(b.env.PORT||b.env.RSC_PORT||3e3)}`;for(let e of u)try{if(e.id.startsWith(`app/`)||e.code.includes(`"use server"`)||e.code.includes(`'use server'`))continue;let t=await fetch(`${d}/_rari/register`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({component_id:e.id,component_code:e.code})});if(!t.ok){let e=await t.text();throw Error(`HTTP ${t.status}: ${e}`)}}catch(t){console.error(`[rari] Runtime: Failed to register component ${e.id}:`,t instanceof Error?t.message:String(t))}}catch(e){console.error(`[rari] Runtime: Component discovery failed:`,e instanceof Error?e.message:String(e))}},c=async()=>{try{let e=`http://localhost:${b.env.SERVER_PORT?Number(b.env.SERVER_PORT):Number(b.env.PORT||b.env.RSC_PORT||3e3)}`,t=Q(a,Object.values(h));for(let n of t){let t=y.relative(b.cwd(),n),r=y.basename(n).replace(i,``);try{await fetch(`${e}/_rari/register-client`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({component_id:r,file_path:t,export_name:`default`})})}catch(e){console.error(`[rari] Runtime: Failed to pre-register client component ${r}:`,e)}}}catch(e){console.error(`[rari] Runtime: Failed to pre-register client components:`,e)}},l=async()=>{if(p)return;let{getBinaryPath:e,getInstallationInstructions:n}=await import(`./platform.mjs`),r;try{r=e()}catch(e){console.error(`rari binary not found`),console.error(` ${e.message}`),console.error(n());return}let i=b.env.SERVER_PORT?Number(b.env.SERVER_PORT):Number(b.env.PORT||b.env.RSC_PORT||3e3),a=b.env.NODE_ENV===`production`?`production`:`development`,o=t.config.server.port||5173,l=[`--mode`,a,`--port`,i.toString(),`--host`,`127.0.0.1`];p=te(r,l,{stdio:[`ignore`,`pipe`,`pipe`],cwd:b.cwd(),env:{...b.env,RUST_LOG:b.env.RUST_LOG||`error`,RARI_VITE_PORT:o.toString()}}),p.stdout?.on(`data`,e=>{let t=e.toString().trim();t&&console.error(`${t}`)}),p.stderr?.on(`data`,e=>{let t=e.toString().trim();t&&!t.includes(`warning`)&&console.error(`${t}`)}),p.on(`error`,e=>{j=!1,console.error(`Failed to start rari server:`,e.message),e.message.includes(`ENOENT`)&&console.error(` Binary not found. Please ensure rari is properly installed.`)}),p.on(`exit`,(e,t)=>{p=null,j=!1,t?console.error(`rari server stopped by signal ${t}`):e===0?console.error(`rari server stopped successfully`):e&&console.error(`rari server exited with code ${e}`)});let u=!1;for(let e=0;e<20&&(u=await M(),!u);e++)await new Promise(e=>setTimeout(e,500));u?(await c(),await s()):console.error(`Server failed to become ready for component registration`)},d=async t=>{try{if(!S(t))return;let{ServerComponentBuilder:n}=await import(`./server-build-BbPx0SOe.mjs`).then(e=>e.n),i=new n(r,{outDir:`dist`,rscDir:`server`,manifestPath:`server/manifest.json`,serverConfigPath:`server/config.json`,alias:h,csp:e.csp,rateLimit:e.rateLimit,spamBlocker:e.spamBlocker,cacheControl:e.cacheControl});i.addServerComponent(t);let a=await i.getTransformedComponentsForDevelopment();if(a.length===0)return;let o=`http://localhost:${b.env.SERVER_PORT?Number(b.env.SERVER_PORT):Number(b.env.PORT||b.env.RSC_PORT||3e3)}`;for(let e of a)try{let t=await fetch(`${o}/_rari/register`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({component_id:e.id,component_code:e.code})});if(!t.ok){let e=await t.text();throw Error(`HTTP ${t.status}: ${e}`)}}catch(t){console.error(`[rari] Failed to register component`,`${e.id}:`,t instanceof Error?t.message:String(t))}}catch(e){console.error(`[rari] Targeted HMR failed for`,`${t}:`,e instanceof Error?e.message:String(e)),setTimeout(s,1e3)}};l().catch(e=>{console.error(`[rari] Failed to start Rust server:`,e)}),t.middlewares.use(async(e,t,n)=>{let r=e.headers.accept;if(r&&r.includes(`text/x-component`)&&e.url&&!e.url.startsWith(`/api`)&&!e.url.startsWith(`/rsc`)&&!e.url.includes(`.`)){if(!j&&!await M()){let e=Date.now();for(;Date.now()-e<1e4&&!await M();)await new Promise(e=>setTimeout(e,100));if(!j){console.error(`[rari] Rust server not ready, cannot proxy RSC request`),t.headersSent||(t.statusCode=503,t.end(`Server not ready`));return}}let n=b.env.SERVER_PORT?Number(b.env.SERVER_PORT):Number(b.env.PORT||b.env.RSC_PORT||3e3),r=`http://localhost:${n}${e.url}`;try{let i={};for(let[t,n]of Object.entries(e.headers))typeof n==`string`?i[t]=n:Array.isArray(n)&&(i[t]=n.join(`,`));i.host=`localhost:${n}`,i[`accept-encoding`]=`identity`;let a=await fetch(r,{method:e.method,headers:i});if(t.statusCode=a.status,a.headers.forEach((e,n)=>{n.toLowerCase()!==`content-encoding`&&t.setHeader(n,e)}),a.body){let e=a.body.getReader();try{for(;;){let{done:n,value:r}=await e.read();if(n)break;t.write(ee.from(r))}t.end()}catch(e){console.error(`[rari] Stream error:`,e),t.headersSent||(t.statusCode=500),t.end()}}else t.end();return}catch(e){console.error(`[rari] Failed to proxy RSC request:`,e),t.headersSent||(t.statusCode=500,t.end(`Internal Server Error`));return}}n()}),t.watcher.on(`change`,async e=>{n.test(e)&&u.delete(e),n.test(e)&&e.includes(a)&&(S(e)?(t.ws.send({type:`custom`,event:`rari:register-server-component`,data:{filePath:e}}),await d(e)):setTimeout(s,1e3))}),t.middlewares.use(`/api/vite/hmr-transform`,async(e,t)=>{if(e.method!==`POST`){t.statusCode=405,t.end(`Method Not Allowed`);return}let n=``;e.on(`data`,e=>{n+=e.toString()}),e.on(`end`,async()=>{try{let{filePath:e}=JSON.parse(n);if(!e){t.statusCode=400,t.end(JSON.stringify({error:`filePath is required`}));return}await d(e),t.statusCode=200,t.setHeader(`Content-Type`,`application/json`),t.end(JSON.stringify({success:!0,filePath:e,message:`Component transformation completed`}))}catch(e){t.statusCode=500,t.setHeader(`Content-Type`,`application/json`),t.end(JSON.stringify({success:!1,error:e instanceof Error?e.message:String(e)}))}})}),t.httpServer?.on(`close`,()=>{m&&=(m.dispose(),null),p&&=(p.kill(`SIGTERM`),null),j=!1})},resolveId(e,t){if(e===`virtual:rsc-integration`||e===`virtual:rsc-integration.ts`)return`virtual:rsc-integration.ts`;if(e===`virtual:rari-entry-client`||e===`virtual:rari-entry-client.ts`)return`virtual:rari-entry-client.ts`;if(e===`virtual:react-server-dom-rari-client`||e===`virtual:react-server-dom-rari-client.ts`)return`virtual:react-server-dom-rari-client.ts`;if(e===`virtual:app-router-provider`||e===`virtual:app-router-provider.tsx`)return`virtual:app-router-provider.tsx`;if(e===`./DefaultLoadingIndicator`||e===`./DefaultLoadingIndicator.tsx`)return`virtual:default-loading-indicator.tsx`;if(e===`./LoadingErrorBoundary`||e===`./LoadingErrorBoundary.tsx`)return`virtual:loading-error-boundary.tsx`;if(e===`react-server-dom-rari/server`)return e;if(t&&t.startsWith(`virtual:`)&&e.startsWith(`../`)){let n=import.meta.url,r=x(n),i=y.dirname(r),a=null,o=[y.join(i,`runtime`),y.join(i,`../runtime`)];for(let e of o)if(_.existsSync(e)){a=e;break}if(a){let t=y.join(a,e);if(_.existsSync(t))return t;let n=y.join(a,`../dist`,y.basename(e));if(_.existsSync(n))return n}else console.warn(`[rari] Runtime directory not found, attempting fallback resolution for virtual import.\n Importer: ${t}\n ID: ${e}\n Current Dir: ${i}\n Hint: Runtime lookup failed, trying currentDir as fallback`);let s=y.join(i,e);if(_.existsSync(s))return s;let c=y.join(i,`../dist`,y.basename(e));if(_.existsSync(c))return c}if(b.env.NODE_ENV===`production`)try{let t=y.resolve(e);if(_.existsSync(t)&&S(t))return{id:e,external:!0}}catch(t){t?.code!==`ENOENT`&&console.warn(`[rari] Unexpected error resolving server component:`,e,t)}return null},async load(i){if(n.test(i)){let e=this.environment;if(e&&e.name===`client`)try{let e=_.readFileSync(i,`utf-8`);if(T(e,`use server`))return D(e,i)}catch{}}if(i===`virtual:rari-entry-client.ts`){let e=Q(y.join(b.cwd(),`src`),Object.values(h)),i=new Set([...d,...e]),a=[{path:`rari/image`,exports:[`Image`]}],c=[...i].filter(e=>{try{return T(_.readFileSync(e,`utf-8`),`use client`)}catch{return!1}}).map(e=>{let i=y.relative(b.cwd(),e).replace(o,`/`),a=i.replace(n,``),c=i.startsWith(`..`)?e.replace(o,`/`):i,l=!1,u=``;try{let t=_.readFileSync(e,`utf-8`),n=r.test(t),i=t.match(s);!n&&i&&(l=!0,u=i[1])}catch(t){t?.code!==`ENOENT`&&console.warn(`[rari] Unexpected error reading component for export detection:`,e,t)}let d=c.replace(o,`/`),f=d.startsWith(`/`)||t.test(d)?d:`/${d}`;return` "${c}": {
|
|
46
46
|
id: "${a}",
|
|
47
47
|
path: "${c}",
|
|
48
48
|
type: "client",
|
package/dist/vite.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { a as
|
|
1
|
+
import { C as extractServerPropsWithCache, S as extractServerProps, T as hasServerSideDataFetching, _ as ServerSidePropsResult, a as ServerSpamBlockerConfig, b as clearPropsCacheForComponent, f as RuntimeClient, g as MetadataResult, i as ServerRateLimitConfig, l as HttpRuntimeClient, m as createHttpRuntimeClient, r as ServerConfig, t as ServerCSPConfig, v as StaticParamsResult, w as extractStaticParams, x as extractMetadata, y as clearPropsCache } from "./server-config-CDW6dUXy.mjs";
|
|
2
|
+
import { a as ErrorProps, c as LayoutEntry, d as Metadata, f as NotFoundEntry, h as RouteSegmentType, i as ErrorEntry, l as LayoutProps, m as RouteSegment, n as AppRouteManifest, o as GenerateMetadata, p as PageProps, r as AppRouteMatch, s as GenerateStaticParams, t as AppRouteEntry, u as LoadingEntry } from "./types-DYoUsyof.mjs";
|
|
3
|
+
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-tSrOMrRG.mjs";
|
|
4
|
+
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-BV0iON-q.mjs";
|
|
4
5
|
import { RariRequest } from "./proxy/RariRequest.mjs";
|
|
5
6
|
import { RariResponse } from "./proxy/RariResponse.mjs";
|
|
6
7
|
|
package/dist/vite.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-B-jD5pXc.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-DMuIAFub.mjs";import{t as _}from"./routes-DXBE0bwy.mjs";import"./constants-DZAg-dr0.mjs";import"./server-build-BbPx0SOe.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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rari",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.10.
|
|
4
|
+
"version": "0.10.8",
|
|
5
5
|
"description": "Runtime Accelerated Rendering Infrastructure (rari)",
|
|
6
6
|
"author": "Ryan Skinner",
|
|
7
7
|
"license": "MIT",
|
|
@@ -56,6 +56,10 @@
|
|
|
56
56
|
"default": "./dist/og/index.mjs"
|
|
57
57
|
},
|
|
58
58
|
"./package.json": "./package.json",
|
|
59
|
+
"./router": {
|
|
60
|
+
"types": "./dist/router.d.mts",
|
|
61
|
+
"default": "./dist/router.mjs"
|
|
62
|
+
},
|
|
59
63
|
"./runtime/actions": {
|
|
60
64
|
"types": "./dist/runtime/actions.d.mts",
|
|
61
65
|
"default": "./dist/runtime/actions.mjs"
|
|
@@ -102,11 +106,11 @@
|
|
|
102
106
|
"rolldown": "1.0.0-rc.5"
|
|
103
107
|
},
|
|
104
108
|
"optionalDependencies": {
|
|
105
|
-
"rari-darwin-arm64": "0.10.
|
|
106
|
-
"rari-darwin-x64": "0.10.
|
|
107
|
-
"rari-linux-arm64": "0.10.
|
|
108
|
-
"rari-linux-x64": "0.10.
|
|
109
|
-
"rari-win32-x64": "0.10.
|
|
109
|
+
"rari-darwin-arm64": "0.10.8",
|
|
110
|
+
"rari-darwin-x64": "0.10.8",
|
|
111
|
+
"rari-linux-arm64": "0.10.8",
|
|
112
|
+
"rari-linux-x64": "0.10.8",
|
|
113
|
+
"rari-win32-x64": "0.10.8"
|
|
110
114
|
},
|
|
111
115
|
"devDependencies": {
|
|
112
116
|
"@types/node": "^25.3.0",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|