rari 0.14.2 → 0.14.4
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 +3 -3
- package/dist/index.d.mts +1 -1
- package/dist/mdx.mjs +1 -1
- package/dist/{railway-bxKRJ0Cg.mjs → railway-s8_vD6IQ.mjs} +1 -1
- package/dist/regex-constants-s9cBkrFv.mjs +1 -0
- package/dist/{render-CXNCiz-E.mjs → render--U1cY-wT.mjs} +1 -1
- package/dist/router.d.mts +1 -1
- package/dist/router.mjs +1 -1
- package/dist/runtime/AppRouterProvider.d.mts +1 -1
- package/dist/runtime/AppRouterProvider.mjs +3 -3
- package/dist/runtime/entry-client.mjs +1 -1
- package/dist/runtime/rsc-client-runtime.d.mts +2 -2
- package/dist/runtime/rsc-client-runtime.mjs +2 -2
- package/dist/runtime/vendor/react-flight-client/ReactFlightClient.mjs +2 -2
- package/dist/{sitemap-generator-BTG9lURQ.mjs → sitemap-generator-BbD6Q3sO.mjs} +1 -1
- package/dist/suspense-CsIYuC_l.mjs +1 -0
- package/dist/{types-m74grfbN.d.mts → types-pC5OZq29.d.mts} +10 -1
- package/dist/vite.d.mts +1 -1
- package/dist/vite.mjs +32 -31
- package/package.json +11 -10
- package/dist/regex-constants-B4P386OY.mjs +0 -1
- /package/dist/{utils-BK4N0qFr-QFbF96eD.mjs → utils-BdLqcjvq-QFbF96eD.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{spawn as n}from"node:child_process";import{existsSync as r,readFileSync as i,realpathSync as a}from"node:fs";import{resolve as o}from"node:path";import s from"node:process";import{fileURLToPath as c}from"node:url";import{styleText as l}from"node:util";function u(e){console.warn(`${l(`blue`,`info`)} ${e}`)}function d(e){console.warn(`${l(`green`,`✓`)} ${e}`)}function f(e){console.error(`${l(`red`,`✗`)} ${e}`)}function p(e){console.warn(`${l(`yellow`,`⚠`)} ${e}`)}const m=/^([^=]+)=(.*)$/;function h(e){let t=e.trim();if(!t||t.startsWith(`#`))return null;let n=t.match(m);if(!n)return null;let[,r,i]=n,a=r.trim(),o=i.trim();return(o.startsWith(`"`)&&o.endsWith(`"`)||o.startsWith(`'`)&&o.endsWith(`'`))&&(o=o.slice(1,-1)),{key:a,value:o}}function g(){let e=o(s.cwd(),`.env`);if(!r(e))return;let t=i(e,`utf-8`);for(let e of t.split(`
|
|
3
|
-
`)){let t=h(e);t&&!s.env[t.key]&&(s.env[t.key]=t.value)}}g();const[,,_,...v]=s.argv;function y(e){let t=s.cwd();for(;;){let n=e(t);if(n!==null)return n;let r=o(t,`..`);if(r===t)break;t=r}return null}function b(e){return r(o(e,`pnpm-lock.yaml`))?`pnpm`:r(o(e,`yarn.lock`))?`yarn`:r(o(e,`bun.lockb`))?`bun`:r(o(e,`package-lock.json`))?`npm`:null}function x(e){try{let t=o(e,`package.json`);if(!r(t))return null;let n=JSON.parse(i(t,`utf-8`));if(n.packageManager?.startsWith(`pnpm`))return`pnpm`;if(n.packageManager?.startsWith(`yarn`))return`yarn`;if(n.packageManager?.startsWith(`bun`))return`bun`;if(n.packageManager?.startsWith(`npm`))return`npm`}catch{}return null}function S(){return y(e=>b(e)??x(e))??`npm`}function C(){let e=S(),t=s.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 w(){return y(e=>{try{let t=o(e,`package.json`);if(r(t)){let e=JSON.parse(i(t,`utf-8`)),n={...e.dependencies,...e.devDependencies};if(n[`vite-plus`])return`vp`;if(n.vite)return`vite`}}catch{}return null})??`vite`}function T(e,t,r={}){let i=s.platform===`win32`;if(e===`npx`){let e=C();if(e.includes(`bun`))return n(i?`bunx.cmd`:`bunx`,t,{...r,shell:i});if(e.includes(`pnpm`))return n(e,[`exec`,...t],{...r,shell:i});if(e.includes(`yarn`)){let[a,...o]=t;return n(e,a===`vp`?[`dlx`,`-p`,`vite-plus`,`vp`,...o]:[`dlx`,...t],{...r,shell:i})}}return i&&e===`npx`?n(`npx.cmd`,t,{...r,shell:!0}):n(e,t,r)}function E(e){if(e instanceof Error)return e.message;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function D(){return!!(s.env.RAILWAY_ENVIRONMENT||s.env.RAILWAY_PROJECT_ID||s.env.RAILWAY_SERVICE_ID)}function O(){return!!(s.env.RENDER||s.env.RENDER_SERVICE_ID||s.env.RENDER_SERVICE_NAME)}function k(){return D()||O()}function A(){return D()?`Railway`:O()?`Render`:`local`}function j(){return{port:s.env.PORT||s.env.RSC_PORT||`3000`,mode:s.env.NODE_ENV||`production`,host:k()?`0.0.0.0`:`127.0.0.1`}}async function M(){let{existsSync:e,rmSync:t}=await import(`node:fs`),{resolve:n}=await import(`node:path`),r=n(s.cwd(),`dist`);e(r)&&(u(`Cleaning dist folder...`),t(r,{recursive:!0,force:!0})),u(`Type checking...`);let i=T(`npx`,[`tsgo`],{stdio:`inherit`,cwd:s.cwd()});await new Promise((e,t)=>{i.on(`exit`,n=>{n===0?(d(`Type check passed`),e()):(f(`Type check failed with code ${n}`),t(Error(`Type check failed with code ${n}`)))}),i.on(`error`,t)}),u(`Building for production...`);let a=T(`npx`,[w(),`build`],{stdio:`inherit`,cwd:s.cwd()});await new Promise((e,t)=>{a.on(`exit`,n=>{n===0?(d(`Build complete`),e()):(f(`Build failed with code ${n}`),t(Error(`Build failed with code ${n}`)))}),a.on(`error`,t)}),await N()}async function N(){if(r(o(s.cwd(),`dist`,`server`,`image.json`))&&r(o(s.cwd(),`public`)))try{let t=n(e(),[`optimize-images`],{stdio:`inherit`,cwd:s.cwd(),shell:!1});await new Promise(e=>{t.on(`exit`,t=>{t===0||p(`Image pre-optimization exited with code ${t}`),e()}),t.on(`error`,t=>{p(`Image pre-optimization error: ${E(t)}`),e()})})}catch(e){p(`Could not pre-optimize images: ${E(e)}`)}}async function P(){let{existsSync:e}=await import(`node:fs`),{resolve:t}=await import(`node:path`),n=w();if(!e(t(s.cwd(),`dist`))){u(`First run detected - building project...`);let e=T(`npx`,[n,`build`,`--mode`,`development`],{stdio:`inherit`,cwd:s.cwd()});await new Promise((t,n)=>{e.on(`exit`,e=>{e===0?(d(`Initial build complete`),t()):(f(`Build failed with code ${e}`),n(Error(`Build failed with code ${e}`)))}),e.on(`error`,n)})}u(`Starting Vite${n===`vp`?`+`:``} dev server...`);let r=T(`npx`,[n,`dev`],{stdio:`inherit`,cwd:s.cwd()}),i=()=>{u(`Shutting down dev server...`),r.kill(`SIGTERM`)};return s.on(`SIGINT`,i),s.on(`SIGTERM`,i),r.on(`error`,e=>{f(`Failed to start Vite: ${e.message}`),s.exit(1)}),r.on(`exit`,e=>{e!==0&&e!==null&&(f(`Vite exited with code ${e}`),s.exit(e))}),new Promise(()=>{})}async function F(){let r;try{r=e()}catch{f(`Failed to obtain rari binary`),f(t()),s.exit(1)}let{port:i,mode:a,host:o}=j();if(k()){let e=A();u(`${e} environment detected`),u(`Starting rari server for ${e} deployment...`),u(`Mode: ${a}, Host: ${o}, Port: ${i}`),u(`using binary: ${r}`)}let c=n(r,[`--mode`,a,`--port`,i,`--host`,o],{stdio:`inherit`,cwd:s.cwd(),env:{...s.env,RUST_LOG:s.env.RUST_LOG||`error`}}),l=()=>{u(`shutting down...`),c.kill(`SIGTERM`)};return s.on(`SIGINT`,l),s.on(`SIGTERM`,l),c.on(`error`,e=>{f(`Failed to start rari server: ${e.message}`),e.message.includes(`ENOENT`)&&f(`Binary not found. Please ensure rari is properly installed.`),s.exit(1)}),c.on(`exit`,(e,t)=>{t?u(`server stopped by signal ${t}`):e===0?d(`server stopped successfully`):(f(`server exited with code ${e}`),s.exit(e||1))}),new Promise(()=>{})}async function I(){u(`Setting up Railway deployment...`),k()&&(f(`Already running in ${A()} environment. Use "rari start" instead.`),s.exit(1));let{createRailwayDeployment:e}=await import(`./railway-
|
|
3
|
+
`)){let t=h(e);t&&!s.env[t.key]&&(s.env[t.key]=t.value)}}g();const[,,_,...v]=s.argv;function y(e){let t=s.cwd();for(;;){let n=e(t);if(n!==null)return n;let r=o(t,`..`);if(r===t)break;t=r}return null}function b(e){return r(o(e,`pnpm-lock.yaml`))?`pnpm`:r(o(e,`yarn.lock`))?`yarn`:r(o(e,`bun.lockb`))?`bun`:r(o(e,`package-lock.json`))?`npm`:null}function x(e){try{let t=o(e,`package.json`);if(!r(t))return null;let n=JSON.parse(i(t,`utf-8`));if(n.packageManager?.startsWith(`pnpm`))return`pnpm`;if(n.packageManager?.startsWith(`yarn`))return`yarn`;if(n.packageManager?.startsWith(`bun`))return`bun`;if(n.packageManager?.startsWith(`npm`))return`npm`}catch{}return null}function S(){return y(e=>b(e)??x(e))??`npm`}function C(){let e=S(),t=s.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 w(){return y(e=>{try{let t=o(e,`package.json`);if(r(t)){let e=JSON.parse(i(t,`utf-8`)),n={...e.dependencies,...e.devDependencies};if(n[`vite-plus`])return`vp`;if(n.vite)return`vite`}}catch{}return null})??`vite`}function T(e,t,r={}){let i=s.platform===`win32`;if(e===`npx`){let e=C();if(e.includes(`bun`))return n(i?`bunx.cmd`:`bunx`,t,{...r,shell:i});if(e.includes(`pnpm`))return n(e,[`exec`,...t],{...r,shell:i});if(e.includes(`yarn`)){let[a,...o]=t;return n(e,a===`vp`?[`dlx`,`-p`,`vite-plus`,`vp`,...o]:[`dlx`,...t],{...r,shell:i})}}return i&&e===`npx`?n(`npx.cmd`,t,{...r,shell:!0}):n(e,t,r)}function E(e){if(e instanceof Error)return e.message;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function D(){return!!(s.env.RAILWAY_ENVIRONMENT||s.env.RAILWAY_PROJECT_ID||s.env.RAILWAY_SERVICE_ID)}function O(){return!!(s.env.RENDER||s.env.RENDER_SERVICE_ID||s.env.RENDER_SERVICE_NAME)}function k(){return D()||O()}function A(){return D()?`Railway`:O()?`Render`:`local`}function j(){return{port:s.env.PORT||s.env.RSC_PORT||`3000`,mode:s.env.NODE_ENV||`production`,host:k()?`0.0.0.0`:`127.0.0.1`}}async function M(){let{existsSync:e,rmSync:t}=await import(`node:fs`),{resolve:n}=await import(`node:path`),r=n(s.cwd(),`dist`);e(r)&&(u(`Cleaning dist folder...`),t(r,{recursive:!0,force:!0})),u(`Type checking...`);let i=T(`npx`,[`tsgo`],{stdio:`inherit`,cwd:s.cwd()});await new Promise((e,t)=>{i.on(`exit`,n=>{n===0?(d(`Type check passed`),e()):(f(`Type check failed with code ${n}`),t(Error(`Type check failed with code ${n}`)))}),i.on(`error`,t)}),u(`Building for production...`);let a=T(`npx`,[w(),`build`],{stdio:`inherit`,cwd:s.cwd()});await new Promise((e,t)=>{a.on(`exit`,n=>{n===0?(d(`Build complete`),e()):(f(`Build failed with code ${n}`),t(Error(`Build failed with code ${n}`)))}),a.on(`error`,t)}),await N()}async function N(){if(r(o(s.cwd(),`dist`,`server`,`image.json`))&&r(o(s.cwd(),`public`)))try{let t=n(e(),[`optimize-images`],{stdio:`inherit`,cwd:s.cwd(),shell:!1});await new Promise(e=>{t.on(`exit`,t=>{t===0||p(`Image pre-optimization exited with code ${t}`),e()}),t.on(`error`,t=>{p(`Image pre-optimization error: ${E(t)}`),e()})})}catch(e){p(`Could not pre-optimize images: ${E(e)}`)}}async function P(){let{existsSync:e}=await import(`node:fs`),{resolve:t}=await import(`node:path`),n=w();if(!e(t(s.cwd(),`dist`))){u(`First run detected - building project...`);let e=T(`npx`,[n,`build`,`--mode`,`development`],{stdio:`inherit`,cwd:s.cwd()});await new Promise((t,n)=>{e.on(`exit`,e=>{e===0?(d(`Initial build complete`),t()):(f(`Build failed with code ${e}`),n(Error(`Build failed with code ${e}`)))}),e.on(`error`,n)})}u(`Starting Vite${n===`vp`?`+`:``} dev server...`);let r=T(`npx`,[n,`dev`],{stdio:`inherit`,cwd:s.cwd()}),i=()=>{u(`Shutting down dev server...`),r.kill(`SIGTERM`)};return s.on(`SIGINT`,i),s.on(`SIGTERM`,i),r.on(`error`,e=>{f(`Failed to start Vite: ${e.message}`),s.exit(1)}),r.on(`exit`,e=>{e!==0&&e!==null&&(f(`Vite exited with code ${e}`),s.exit(e))}),new Promise(()=>{})}async function F(){let r;try{r=e()}catch{f(`Failed to obtain rari binary`),f(t()),s.exit(1)}let{port:i,mode:a,host:o}=j();if(k()){let e=A();u(`${e} environment detected`),u(`Starting rari server for ${e} deployment...`),u(`Mode: ${a}, Host: ${o}, Port: ${i}`),u(`using binary: ${r}`)}let c=n(r,[`--mode`,a,`--port`,i,`--host`,o],{stdio:`inherit`,cwd:s.cwd(),env:{...s.env,RUST_LOG:s.env.RUST_LOG||`error`}}),l=()=>{u(`shutting down...`),c.kill(`SIGTERM`)};return s.on(`SIGINT`,l),s.on(`SIGTERM`,l),c.on(`error`,e=>{f(`Failed to start rari server: ${e.message}`),e.message.includes(`ENOENT`)&&f(`Binary not found. Please ensure rari is properly installed.`),s.exit(1)}),c.on(`exit`,(e,t)=>{t?u(`server stopped by signal ${t}`):e===0?d(`server stopped successfully`):(f(`server exited with code ${e}`),s.exit(e||1))}),new Promise(()=>{})}async function I(){u(`Setting up Railway deployment...`),k()&&(f(`Already running in ${A()} environment. Use "rari start" instead.`),s.exit(1));let{createRailwayDeployment:e}=await import(`./railway-s8_vD6IQ.mjs`);await e()}async function L(){u(`Setting up Render deployment...`),k()&&(f(`Already running in ${A()} environment. Use "rari start" instead.`),s.exit(1));let{createRenderDeployment:e}=await import(`./render--U1cY-wT.mjs`);await e()}async function R(){switch(_){case void 0:case`help`:case`--help`:case`-h`:console.warn(`${l(`bold`,`rari CLI`)}
|
|
4
4
|
|
|
5
5
|
${l(`bold`,`Usage:`)}
|
|
6
6
|
${l(`cyan`,`rari dev`)} Start the development server with Vite
|
package/dist/client.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { C as hasServerSideDataFetching, S as extractStaticParams, _ as clearPropsCache, a as DefaultLoading, b as extractServerProps, c as LoadingSpinner, d as createErrorBoundary, f as createHttpRuntimeClient, g as StaticParamsResult, h as ServerSidePropsResult, i as DefaultError, l as NotFound, m as MetadataResult, o as ErrorBoundary, p as createLoadingBoundary, r as ServerConfig, s as HttpRuntimeClient, t as ServerCSPConfig, u as RuntimeClient, v as clearPropsCacheForComponent, x as extractServerPropsWithCache, y as extractMetadata } from "./server-config-CwWYmtA0.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-
|
|
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-pC5OZq29.mjs";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { Component, ErrorInfo, ReactNode } from "react";
|
|
5
5
|
|
|
@@ -13,7 +13,7 @@ declare function ClientRouter({
|
|
|
13
13
|
children,
|
|
14
14
|
initialRoute,
|
|
15
15
|
staleWindowMs
|
|
16
|
-
}: ClientRouterProps):
|
|
16
|
+
}: ClientRouterProps): React.JSX.Element;
|
|
17
17
|
//#endregion
|
|
18
18
|
//#region src/router/LayoutErrorBoundary.d.ts
|
|
19
19
|
interface LayoutErrorBoundaryProps {
|
|
@@ -79,7 +79,7 @@ declare function NavigationErrorOverlay({
|
|
|
79
79
|
onDismiss,
|
|
80
80
|
retryCount,
|
|
81
81
|
maxRetries
|
|
82
|
-
}: NavigationErrorOverlayProps): import("react
|
|
82
|
+
}: NavigationErrorOverlayProps): import("react").JSX.Element;
|
|
83
83
|
//#endregion
|
|
84
84
|
//#region src/router/route-info-types.d.ts
|
|
85
85
|
interface RouteInfoRequest {
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as Metadata, l as LayoutProps, p as PageProps } from "./types-
|
|
1
|
+
import { d as Metadata, l as LayoutProps, p as PageProps } from "./types-pC5OZq29.mjs";
|
|
2
2
|
import { a as SitemapImage, i as SitemapEntry, n as RobotsRule, o as SitemapVideo, r as Sitemap, t as Robots } from "./metadata-route-85WvBQcW.mjs";
|
|
3
3
|
import { c as RariURL, n as ProxyConfig, r as ProxyFunction, s as RariFetchEvent } from "./types-3dq9RGI5.mjs";
|
|
4
4
|
import { RariRequest } from "./proxy/RariRequest.mjs";
|
package/dist/mdx.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{i as e}from"./regex-constants-s9cBkrFv.mjs";import{registerClientComponent as t,registerClientReference as n}from"./runtime/react-server-dom-shim.mjs";function r(r,i,a=`default`){let o=`${i}#${a}`;if(t(r,i,a),typeof globalThis<`u`){let t=globalThis;t[`~clientComponents`]||={};let n=i.replace(e,``).split(`/`).pop()||a,s={id:a==="default"?n:a,path:i,type:`client`,component:r,registered:!0};t[`~clientComponents`][o]=s,t[`~clientComponents`][n]=s,t[`~clientComponents`][i]=s}function s(){throw Error(`Attempted to call ${a}() from the server but ${a} is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.`)}return n(s,i,a)}function i(e){let t={};for(let[n,{component:i,id:a,exportName:o=`default`}]of Object.entries(e))t[n]=r(i,a,o);return t}export{r as createMDXClientReference,i as createMDXClientReferences};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e,i as t,n,o as r,r as i,t as a}from"./utils-
|
|
1
|
+
import{a as e,i as t,n,o as r,r as i,t as a}from"./utils-BdLqcjvq-QFbF96eD.mjs";import{existsSync as o,readFileSync as s,writeFileSync as c}from"node:fs";import{join as l}from"node:path";import u from"node:process";import{styleText as d}from"node:util";function f(){let r=u.cwd();e(`Creating Railway deployment configuration...`),t(r,{providerName:`Railway`,deployScript:`echo "Push to GitHub and connect to Railway to deploy"`,startScript:`rari start`,dependency:n()}),p(r),a(r,`Railway`,`.railway`),m(r),h()}function p(e){i(e,`railway.toml`,`[build]
|
|
2
2
|
builder = "RAILPACK"
|
|
3
3
|
|
|
4
4
|
[deploy]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=/\.(?:tsx?|jsx?)$/,t=/^[A-Z]:\\/i,n=/\\/g,r=/[/\\]/,i=/\/$/,a=/^file:\/\//,o=/^https?:\/\//,s={AMPERSAND:/&/g,LT:/</g,GT:/>/g,QUOTE:/"/g,APOS:/'/g},c=s.AMPERSAND,l=s.LT,u=s.GT,d=s.QUOTE,f=s.APOS,p=c,m=l,h=u,g=d,_=f,v=c,y=l,b=u,x=d,S=f,C=/^\d+$/,w=/([a-z])([A-Z])/g,T=/export\s+(?:function|const|class)\s+(\w+)/,E=/\.[^.]*$/,D=/\r?\n/,O=/['"]/g;export{x as C,y as S,e as _,a,S as b,h as c,o as d,D as f,O as g,i as h,E as i,m as l,r as m,w as n,p as o,C as p,T as r,_ as s,n as t,g as u,t as v,b as x,v as y};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e,i as t,n,o as r,r as i,t as a}from"./utils-
|
|
1
|
+
import{a as e,i as t,n,o as r,r as i,t as a}from"./utils-BdLqcjvq-QFbF96eD.mjs";import{existsSync as o,readFileSync as s,writeFileSync as c}from"node:fs";import{join as l}from"node:path";import u from"node:process";import{styleText as d}from"node:util";function f(){let r=u.cwd();e(`Creating Render deployment configuration...`),t(r,{providerName:`Render`,deployScript:`echo "Push to GitHub and connect to Render to deploy"`,startScript:`rari start`,dependency:n()}),p(r),a(r,`Render`,`.render`),m(r),h()}function p(e){i(e,`render.yaml`,`services:
|
|
2
2
|
- type: web
|
|
3
3
|
name: rari-app
|
|
4
4
|
runtime: node
|
package/dist/router.d.mts
CHANGED
|
@@ -28,7 +28,7 @@ interface RouterProviderProps {
|
|
|
28
28
|
declare function RouterProvider({
|
|
29
29
|
children,
|
|
30
30
|
initialPathname
|
|
31
|
-
}: RouterProviderProps): import("react
|
|
31
|
+
}: RouterProviderProps): import("react").JSX.Element;
|
|
32
32
|
declare function useRouter(): RouterContextValue;
|
|
33
33
|
declare function usePathname(): string;
|
|
34
34
|
declare function useParams(): Record<string, string | string[]>;
|
package/dist/router.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,r as t}from"./navigate-DuyUa6qD.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),
|
|
1
|
+
import{n as e,r as t}from"./navigate-DuyUa6qD.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=o(null);return i(()=>{let e=e=>{let t=e.detail;t?.to&&(u(t.to),f(new URLSearchParams(window.location.search)))};return window.addEventListener(`rari:navigate`,e),()=>{window.removeEventListener(`rari:navigate`,e)}},[]),i(()=>{let t=e();t&&(p.current=t);let n=e=>{p.current=e.detail.navigate},r=()=>{p.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:{},searchParams:d,push:async(e,t)=>{p.current?await p.current(e,t):(console.warn(`[rari] Router not ready, falling back to window.location`),window.location.href=e)},replace:async(e,t)=>{p.current?await p.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,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,5 +1,5 @@
|
|
|
1
|
-
"use client";import{g as e,m as t}from"../regex-constants-B4P386OY.mjs";import{t as n}from"../preload-modules-xvnJ_8eh.mjs";import*as r from"react";import{Suspense as i,useEffect as a,useRef as o,useState as s}from"react";import{Fragment as c,jsx as l,jsxs as u}from"react/jsx-runtime";import{createFromFetch as d,createFromReadableStream as f}from"virtual:react-flight-client";const ee=/"timestamp":(\d+)/,p=/^(?:-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?|true|false|null)$/,m=/^[0-9a-f]+$/i,te=/^\$L?[0-9a-f]+$/i;function ne(e){return new Promise(t=>{setTimeout(t,e)})}function h(e){if(!e||e.length===0)return!1;let t=e.charAt(0),n=e.charCodeAt(0);return e.startsWith(`I[`)||e.startsWith(`I{`)||e.startsWith(`"$S`)?!1:!!(n===84||t===`[`||t===`{`||e.startsWith(`E{`)||t===`"`||p.test(e))}function re(e){return!e||e.length===0?!1:!!(e.includes(`"fallback"`)||e.includes(`$Lfallback`)||e.startsWith(`E{`))}function ie({contentRef:e,rowsDataRef:t,modulesDataRef:n,symbolsDataRef:i,suspendingPromisesRef:a,getSuspendingPromise:o,rscToReact:s}){let c=t.current,l=n.current,u=i.current,d=a.current,f=c.has(e);if(r.useEffect(()=>{f&&d.has(e)&&d.delete(e)},[e,f,d]),f)return s(c.get(e),l,void 0,u,c);throw o(e)}function g({children:p,initialPayload:g,onNavigate:_}){let[v,y]=s(g),b=s(0)[1],x=o({x:0,y:0}),S=o(new Map),C=o(null),w=o(new Set),T=o(_),E=o(0),D=o(new Map),O=o([]),k=o(null),A=o(0),[j,M]=s(null),N=o(typeof window<`u`&&window.location.hash.length>0),ae=o(0),P=o(!1),F=o(!1),I=o(!1),L=o(Promise.resolve()),oe=o(!1),R=o(!!g),z=o(null);a(()=>{T.current=_},[_]),a(()=>{if(v?.element!=null&&v.element&&typeof v.element==`object`&&`status`in v.element&&v.element.status===`rejected`){let e=v.element.reason;e&&console.error(`[rari] AppRouter: Flight payload rejected:`,e)}},[v]);let se=()=>{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)})},ce=()=>{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)})})},B=(e,t,n,r)=>{let i={timestamp:Date.now(),error:e,type:t,details:n,filePath:r};O.current.push(i),A.current+=1,O.current.length>10&&O.current.shift(),A.current>=2&&M(i),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`rari:hmr-failure`,{detail:i}))},V=()=>{setTimeout(()=>{window.location.reload()},1e3)},H=()=>{A.current>0&&(A.current=0)},le=e=>{if(!k.current)return!1;if(e===k.current)return!0;let t=e.match(ee);if(t){let e=Number.parseInt(t[1],10);if(Date.now()-e>5e3)return!0}return!1};function ue(e){let t;try{t=JSON.stringify(e)}catch{try{let n=new WeakSet;t=JSON.stringify(e,(e,t)=>{if(typeof t==`object`&&t){if(n.has(t))return`[Circular]`;n.add(t)}return t})}catch{t=`[Unstringifiable:${typeof e}:${String(e).substring(0,50)}]`}}let n=0;for(let e=0;e<t.length;e++){let r=t.charCodeAt(e);n=(n<<5)-n+r,n&=n}return Math.abs(n).toString(36)}function U(e,n,i,a,o,s){if(e==null)return null;if(typeof e==`string`&&e.startsWith(`$`)&&e.length>1&&m.test(e.substring(1))&&o&&o.has(e)){let t=s??new Set;return t.has(e)?(console.warn(`[rari] AppRouter: Circular $ reference detected:`,e),null):(t.add(e),U(o.get(e),n,i,a,o,t))}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=me(l,n,i,a,o);return r.createElement(r.Suspense,c?{...e,key:c}:e)}if(typeof u==`string`&&u.startsWith(`$`)&&te.test(u)){let e=n.get(u);if(!e)return console.warn(`[rari] AppRouter: Module not found for reference:`,u,`Available modules:`,Array.from(n.keys())),null;let t=globalThis[`~clientComponents`]?.[e.id]?.component;if(!t)return console.warn(`[rari] AppRouter: Component not loaded:`,e.id),null;if(typeof t!=`function`)return null;let s=c||`fallback-${u}-${ae.current++}`,d={...l,children:l.children===void 0?void 0:U(l.children,n,i,a,o)};return r.createElement(t,{key:s,...d})}if(!u||typeof u!=`string`&&typeof u!=`function`||typeof u==`string`&&u.startsWith(`$`))return null;let d=me(l,n,i,a,o);return r.createElement(u,c?{...d,key:c}:d)}return e.map((e,t)=>{let s=U(e,n,i,a,o);if(s==null)return null;if(typeof s==`object`&&r.isValidElement(s)&&!s.key){let n=typeof e==`object`&&e?ue(e):`primitive`,i=`rsc-${Array.isArray(e)&&e[0]===`$`&&e[1]?String(e[1]):`unknown`}-${n}-${t}`;return r.createElement(r.Fragment,{key:i},s)}return s}).filter(e=>e!=null)}return e}let W=o(new Set),G=o(new Map),K=o(new Map),q=o(new Map),J=o(new Map);function de(e){if(!J.current.has(e)){let t=new Promise(()=>{});J.current.set(e,{promise:t,timestamp:Date.now()})}return J.current.get(e).promise}function fe(){J.current.clear(),W.current.clear()}function pe(){let e=Date.now(),t=[];J.current.forEach((n,r)=>{e-n.timestamp>3e4&&t.push(r)}),t.forEach(e=>{J.current.delete(e),W.current.delete(e)})}function me(e,t,n,i,a){if(!e||typeof e!=`object`)return e;a&&(G.current=a),t&&(K.current=t),i&&(q.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(`$`)&&c.length>1&&m.test(c.substring(1)))if(a&&a.has(c)){let e=a.get(c);W.current.delete(c),o[s]=U(e,t,n,i,a)}else W.current.add(c),o[s]=r.createElement(ie,{key:`lazy-${c}`,contentRef:c,rowsDataRef:G,modulesDataRef:K,symbolsDataRef:q,suspendingPromisesRef:J,getSuspendingPromise:de,rscToReact:U});else o[s]=c===void 0?void 0:U(c,t,n,i,a)}else s===`dangerouslySetInnerHTML`?o[s]=e[s]:o[s]=U(e[s],t,n,i,a);return o}let Y=async e=>{await n(e,w.current);let t=await f(new ReadableStream({start(t){t.enqueue(new TextEncoder().encode(e)),t.close()}}));return{element:t,rawElement:t,wireFormat:e}},he=e=>({element:d(e)}),ge=async(t,n)=>{let r=t||window.location.pathname,i=E.current,a=`${i}:${r}${window.location.search}`,o=D.current.get(a);if(o)return o;let s=(async()=>{try{let t=(import.meta.env.RARI_SERVER_URL||window.location.origin).replace(e,``)+r+window.location.search,a=await fetch(t,{headers:{Accept:`text/x-component`},cache:`no-store`,signal:n});if(!a.ok){let e=Error(`Failed to fetch RSC data: ${a.status} ${a.statusText}`);throw B(e,`fetch`,`HTTP ${a.status} when fetching ${t}`,window.location.pathname),e}let o=await a.text();if(le(o)&&v)return v;let s;try{s=await Y(o)}catch(e){let t=e instanceof Error?e:Error(String(e));throw B(t,`parse`,`Failed to parse RSC wire format: ${t.message}`,window.location.pathname),t}return E.current===i&&(y(s),k.current=o,H()),s}catch(e){throw e instanceof Error&&!e.message.includes(`Failed to fetch RSC data`)&&!e.message.includes(`Failed to parse`)&&B(e,`network`,`Network error: ${e.message}`,window.location.pathname),e}finally{D.current.delete(a)}})();return D.current.set(a,s),s},X=o(Y),Z=o(he),Q=o(ge);a(()=>{X.current=Y,Z.current=he,Q.current=ge}),a(()=>{if(typeof window>`u`)return;let e=setInterval(()=>{pe()},3e4),t=async e=>{let t=e.detail;if(t.navigationId!==E.current)return;N.current=!0,t.isStreaming||(C.current=null),fe(),x.current={x:window.scrollX,y:window.scrollY},se();let n=null,i=null,a=!1;try{if(t.rscResponsePromise){let e=await t.rscResponsePromise;if(E.current!==t.navigationId)return;a=e.headers.get(`x-render-mode`)===`streaming`;let{element:r}=Z.current(Promise.resolve(e));if(a)n={element:r};else{let e=await r;if(E.current!==t.navigationId)return;n={element:e}}}else if(t.rscResponse){a=t.rscResponse.headers.get(`x-render-mode`)===`streaming`;let{element:e}=Z.current(Promise.resolve(t.rscResponse));if(a)n={element:e};else{let r=await e;if(E.current!==t.navigationId)return;n={element:r}}}else t.rscWireFormat?n=await X.current(t.rscWireFormat):t.isStreaming||(n=await Q.current(t.to,t.abortSignal))}catch(e){if(e instanceof Error&&e.name===`AbortError`)return;i=e}if(i){console.error(`[rari] AppRouter: Navigation failed:`,i),window.dispatchEvent(new CustomEvent(`rari:navigate-error`,{detail:{from:t.from,to:t.to,error:i,navigationId:t.navigationId}})),A.current>=3&&V();return}if(!n&&t.isStreaming&&E.current===t.navigationId){z.current=t;return}n&&E.current===t.navigationId&&(a?(y(n),b(e=>e+1),M(null)):r.startTransition(()=>{y(n),b(e=>e+1),M(null)}),t.rscWireFormat&&(k.current=t.rscWireFormat),H(),T.current&&T.current(t));let o=typeof window<`u`&&window.location.hash.length>0;!t.options?.historyKey&&!o&&requestAnimationFrame(()=>{t.options?.scroll!==!1&&window.scrollTo(0,0)})},n=async()=>{x.current={x:window.scrollX,y:window.scrollY},se();try{await Q.current(),b(e=>e+1),M(null)}catch(e){console.error(`HMR refetch error:`,e instanceof Error?e.message:String(e)),A.current>=3&&V()}finally{requestAnimationFrame(()=>{window.scrollTo(x.current.x,x.current.y),ce()})}},i=async()=>{try{await Q.current(),b(e=>e+1),M(null)}catch(e){console.error(`RSC invalidate error:`,e instanceof Error?e.message:String(e)),A.current>=3&&V()}},a=e=>{let t=e;if(C.current=[],w.current.clear(),E.current=t.detail.navigationId,typeof window<`u`){let e=window;e[`~rari`]||={},e[`~rari`].navigationId=t.detail.navigationId}P.current=!1,F.current=!1,I.current=!1,L.current=Promise.resolve(),oe.current=!0,R.current=!1,z.current=null},o=async()=>{try{await Q.current(),M(null)}catch(e){console.error(`Manifest update error:`,e instanceof Error?e.message:String(e)),A.current>=3&&V()}},s=async()=>{if(!C.current||C.current.length===0||R.current)return;let e=E.current,t=[...C.current],n=t.some(e=>{let t=e.indexOf(`:`),n=t>0?e.substring(0,t).trim():``,r=t>0?e.substring(t+1):``;return m.test(n)&&h(r)}),r=t.some(e=>{let n=e.indexOf(`:`),r=n>0?e.substring(0,n).trim():``,i=n>0?e.substring(n+1):``;return!m.test(r)||!h(i)?!1:t.some(e=>{let t=e.indexOf(`:`),n=t>0?e.substring(0,t).trim():``,i=t>0?e.substring(t+1):``;return!m.test(n)||!h(i)||re(i)?!1:RegExp(`"?\\$L?${r}"?(?![0-9a-fA-F])`).test(i)})});if(!n&&!r)return;if(!P.current&&n&&!r&&(P.current=!0,t.some(e=>e.includes(`"$Sreact.suspense"`)||e.includes(`react.suspense`)))){try{let n=t.filter(e=>{let n=e.indexOf(`:`),i=n>0?e.substring(0,n).trim():``,a=RegExp(`"\\$L?${i}"(?![0-9a-fA-F])`);return!r||!t.some(e=>a.test(e))}),i=await X.current(n.join(`
|
|
1
|
+
"use client";import{h as e,p as t}from"../regex-constants-s9cBkrFv.mjs";import{t as n}from"../preload-modules-xvnJ_8eh.mjs";import{t as r}from"../suspense-CsIYuC_l.mjs";import*as i from"react";import{Suspense as a,useEffect as o,useRef as s,useState as c}from"react";import{Fragment as l,jsx as u,jsxs as d}from"react/jsx-runtime";import{createFromFetch as f,createFromReadableStream as ee}from"virtual:react-flight-client";const te=/"timestamp":(\d+)/,p=/^(?:-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?|true|false|null)$/,m=/^[0-9a-f]+$/i,ne=/^\$L?[0-9a-f]+$/i;function re(e){return new Promise(t=>{setTimeout(t,e)})}function h(e){if(!e||e.length===0)return!1;let t=e.charAt(0),n=e.charCodeAt(0);return e.startsWith(`I[`)||e.startsWith(`I{`)||e.startsWith(`"$S`)?!1:!!(n===84||t===`[`||t===`{`||e.startsWith(`E{`)||t===`"`||p.test(e))}function ie(e){return!e||e.length===0?!1:!!(e.includes(`"fallback"`)||e.includes(`$Lfallback`)||e.startsWith(`E{`))}function ae({contentRef:e,rowsDataRef:t,modulesDataRef:n,symbolsDataRef:r,suspendingPromisesRef:a,getSuspendingPromise:o,rscToReact:s}){let c=t.current,l=n.current,u=r.current,d=a.current,f=c.has(e);if(i.useEffect(()=>{f&&d.has(e)&&d.delete(e)},[e,f,d]),f)return s(c.get(e),l,void 0,u,c);throw o(e)}function g({children:p,initialPayload:g,onNavigate:_}){let[v,y]=c(g),b=c(0)[1],x=s({x:0,y:0}),S=s(new Map),C=s(null),w=s(new Set),T=s(_),E=s(0),D=s(new Map),O=s([]),k=s(null),A=s(0),[j,M]=c(null),N=s(typeof window<`u`&&window.location.hash.length>0),oe=s(0),P=s(!1),F=s(!1),I=s(!1),L=s(Promise.resolve()),se=s(!1),R=s(!!g),z=s(null);o(()=>{T.current=_},[_]),o(()=>{if(v?.element!=null&&v.element&&typeof v.element==`object`&&`status`in v.element&&v.element.status===`rejected`){let e=v.element.reason;e&&console.error(`[rari] AppRouter: Flight payload rejected:`,e)}},[v]);let B=()=>{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)})},ce=()=>{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)})})},V=(e,t,n,r)=>{let i={timestamp:Date.now(),error:e,type:t,details:n,filePath:r};O.current.push(i),A.current+=1,O.current.length>10&&O.current.shift(),A.current>=2&&M(i),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`rari:hmr-failure`,{detail:i}))},H=()=>{setTimeout(()=>{window.location.reload()},1e3)},U=()=>{A.current>0&&(A.current=0)},le=e=>{if(!k.current)return!1;if(e===k.current)return!0;let t=e.match(te);if(t){let e=Number.parseInt(t[1],10);if(Date.now()-e>5e3)return!0}return!1};function ue(e){let t;try{t=JSON.stringify(e)}catch{try{let n=new WeakSet;t=JSON.stringify(e,(e,t)=>{if(typeof t==`object`&&t){if(n.has(t))return`[Circular]`;n.add(t)}return t})}catch{t=`[Unstringifiable:${typeof e}:${String(e).substring(0,50)}]`}}let n=0;for(let e=0;e<t.length;e++){let r=t.charCodeAt(e);n=(n<<5)-n+r,n&=n}return Math.abs(n).toString(36)}function W(e,n,a,o,s,c){if(e==null)return null;if(typeof e==`string`&&e.startsWith(`$`)&&e.length>1&&m.test(e.substring(1))&&s&&s.has(e)){let t=c??new Set;return t.has(e)?(console.warn(`[rari] AppRouter: Circular $ reference detected:`,e),null):(t.add(e),W(s.get(e),n,a,o,s,t))}if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return e;if(Array.isArray(e)){if(e.length>=4&&e[0]===`$`){let[,c,l,u]=e,d=c;if(typeof c==`string`&&c.startsWith(`$`)&&o){let e=c.substring(1);if(t.test(e)){let e=o.get(c);e&&(r(e)?d=`Suspense`:console.warn(`[rari] AppRouter: Unknown symbol:`,e))}}if(typeof d==`string`&&r(d)||typeof c==`string`&&r(c)){let e=he(u,n,a,o,s);return i.createElement(i.Suspense,l?{...e,key:l}:e)}if(typeof d==`string`&&d.startsWith(`$`)&&ne.test(d)){let e=n.get(d);if(!e)return console.warn(`[rari] AppRouter: Module not found for reference:`,d,`Available modules:`,Array.from(n.keys())),null;let t=globalThis[`~clientComponents`]?.[e.id]?.component;if(!t)return console.warn(`[rari] AppRouter: Component not loaded:`,e.id),null;if(typeof t!=`function`)return null;let r=l||`fallback-${d}-${oe.current++}`,c={...u,children:u.children===void 0?void 0:W(u.children,n,a,o,s)};return i.createElement(t,{key:r,...c})}if(!d||typeof d!=`string`&&typeof d!=`function`||typeof d==`string`&&d.startsWith(`$`))return null;let f=he(u,n,a,o,s);return i.createElement(d,l?{...f,key:l}:f)}return e.map((e,t)=>{let r=W(e,n,a,o,s);if(r==null)return null;if(typeof r==`object`&&i.isValidElement(r)&&!r.key){let n=typeof e==`object`&&e?ue(e):`primitive`,a=`rsc-${Array.isArray(e)&&e[0]===`$`&&e[1]?String(e[1]):`unknown`}-${n}-${t}`;return i.createElement(i.Fragment,{key:a},r)}return r}).filter(e=>e!=null)}return e}let G=s(new Set),K=s(new Map),q=s(new Map),de=s(new Map),J=s(new Map);function fe(e){if(!J.current.has(e)){let t=new Promise(()=>{});J.current.set(e,{promise:t,timestamp:Date.now()})}return J.current.get(e).promise}function pe(){J.current.clear(),G.current.clear()}function me(){let e=Date.now(),t=[];J.current.forEach((n,r)=>{e-n.timestamp>3e4&&t.push(r)}),t.forEach(e=>{J.current.delete(e),G.current.delete(e)})}function he(e,t,n,r,a){if(!e||typeof e!=`object`)return e;a&&(K.current=a),t&&(q.current=t),r&&(de.current=r);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(`$`)&&c.length>1&&m.test(c.substring(1)))if(a&&a.has(c)){let e=a.get(c);G.current.delete(c),o[s]=W(e,t,n,r,a)}else G.current.add(c),o[s]=i.createElement(ae,{key:`lazy-${c}`,contentRef:c,rowsDataRef:K,modulesDataRef:q,symbolsDataRef:de,suspendingPromisesRef:J,getSuspendingPromise:fe,rscToReact:W});else o[s]=c===void 0?void 0:W(c,t,n,r,a)}else s===`dangerouslySetInnerHTML`?o[s]=e[s]:o[s]=W(e[s],t,n,r,a);return o}let Y=async e=>{await n(e,w.current);let t=await ee(new ReadableStream({start(t){t.enqueue(new TextEncoder().encode(e)),t.close()}}));return{element:t,rawElement:t,wireFormat:e}},ge=e=>({element:f(e)}),_e=async(t,n)=>{let r=t||window.location.pathname,i=E.current,a=`${i}:${r}${window.location.search}`,o=D.current.get(a);if(o)return o;let s=(async()=>{try{let t=(import.meta.env.RARI_SERVER_URL||window.location.origin).replace(e,``)+r+window.location.search,a=await fetch(t,{headers:{Accept:`text/x-component`},cache:`no-store`,signal:n});if(!a.ok){let e=Error(`Failed to fetch RSC data: ${a.status} ${a.statusText}`);throw V(e,`fetch`,`HTTP ${a.status} when fetching ${t}`,window.location.pathname),e}let o=await a.text();if(le(o)&&v)return v;let s;try{s=await Y(o)}catch(e){let t=e instanceof Error?e:Error(String(e));throw V(t,`parse`,`Failed to parse RSC wire format: ${t.message}`,window.location.pathname),t}return E.current===i&&(y(s),k.current=o,U()),s}catch(e){throw e instanceof Error&&!e.message.includes(`Failed to fetch RSC data`)&&!e.message.includes(`Failed to parse`)&&V(e,`network`,`Network error: ${e.message}`,window.location.pathname),e}finally{D.current.delete(a)}})();return D.current.set(a,s),s},X=s(Y),Z=s(ge),Q=s(_e);o(()=>{X.current=Y,Z.current=ge,Q.current=_e}),o(()=>{if(typeof window>`u`)return;let e=setInterval(()=>{me()},3e4),t=async e=>{let t=e.detail;if(t.navigationId!==E.current)return;N.current=!0,t.isStreaming||(C.current=null),pe(),x.current={x:window.scrollX,y:window.scrollY},B();let n=null,r=null,a=!1;try{if(t.rscResponsePromise){let e=await t.rscResponsePromise;if(E.current!==t.navigationId)return;a=e.headers.get(`x-render-mode`)===`streaming`;let{element:r}=Z.current(Promise.resolve(e));if(a)n={element:r};else{let e=await r;if(E.current!==t.navigationId)return;n={element:e}}}else if(t.rscResponse){a=t.rscResponse.headers.get(`x-render-mode`)===`streaming`;let{element:e}=Z.current(Promise.resolve(t.rscResponse));if(a)n={element:e};else{let r=await e;if(E.current!==t.navigationId)return;n={element:r}}}else t.rscWireFormat?n=await X.current(t.rscWireFormat):t.isStreaming||(n=await Q.current(t.to,t.abortSignal))}catch(e){if(e instanceof Error&&e.name===`AbortError`)return;r=e}if(r){console.error(`[rari] AppRouter: Navigation failed:`,r),window.dispatchEvent(new CustomEvent(`rari:navigate-error`,{detail:{from:t.from,to:t.to,error:r,navigationId:t.navigationId}})),A.current>=3&&H();return}if(!n&&t.isStreaming&&E.current===t.navigationId){z.current=t;return}n&&E.current===t.navigationId&&(a?(y(n),b(e=>e+1),M(null)):i.startTransition(()=>{y(n),b(e=>e+1),M(null)}),t.rscWireFormat&&(k.current=t.rscWireFormat),U(),T.current&&T.current(t));let o=typeof window<`u`&&window.location.hash.length>0;!t.options?.historyKey&&!o&&requestAnimationFrame(()=>{t.options?.scroll!==!1&&window.scrollTo(0,0)})},n=async()=>{x.current={x:window.scrollX,y:window.scrollY},B();try{await Q.current(),b(e=>e+1),M(null)}catch(e){console.error(`HMR refetch error:`,e instanceof Error?e.message:String(e)),A.current>=3&&H()}finally{requestAnimationFrame(()=>{window.scrollTo(x.current.x,x.current.y),ce()})}},r=async()=>{try{await Q.current(),b(e=>e+1),M(null)}catch(e){console.error(`RSC invalidate error:`,e instanceof Error?e.message:String(e)),A.current>=3&&H()}},a=e=>{let t=e;if(C.current=[],w.current.clear(),E.current=t.detail.navigationId,typeof window<`u`){let e=window;e[`~rari`]||={},e[`~rari`].navigationId=t.detail.navigationId}P.current=!1,F.current=!1,I.current=!1,L.current=Promise.resolve(),se.current=!0,R.current=!1,z.current=null},o=async()=>{try{await Q.current(),M(null)}catch(e){console.error(`Manifest update error:`,e instanceof Error?e.message:String(e)),A.current>=3&&H()}},s=async()=>{if(!C.current||C.current.length===0||R.current)return;let e=E.current,t=[...C.current],n=t.some(e=>{let t=e.indexOf(`:`),n=t>0?e.substring(0,t).trim():``,r=t>0?e.substring(t+1):``;return m.test(n)&&h(r)}),r=t.some(e=>{let n=e.indexOf(`:`),r=n>0?e.substring(0,n).trim():``,i=n>0?e.substring(n+1):``;return!m.test(r)||!h(i)?!1:t.some(e=>{let t=e.indexOf(`:`),n=t>0?e.substring(0,t).trim():``,i=t>0?e.substring(t+1):``;return!m.test(n)||!h(i)||ie(i)?!1:RegExp(`"?\\$L?${r}"?(?![0-9a-fA-F])`).test(i)})});if(!n&&!r)return;if(!P.current&&n&&!r&&(P.current=!0,t.some(e=>e.includes(`"$Sreact.suspense"`)||e.includes(`react.suspense`)))){try{let n=t.filter(e=>{let n=e.indexOf(`:`),i=n>0?e.substring(0,n).trim():``,a=RegExp(`"\\$L?${i}"(?![0-9a-fA-F])`);return!r||!t.some(e=>a.test(e))}),i=await X.current(n.join(`
|
|
2
2
|
`));E.current===e&&(y(i),b(e=>e+1))}catch(e){console.error(`[rari] Failed to parse shell payload:`,e),P.current=!1,L.current=Promise.resolve()}return}let i=t.some(e=>e.includes(`"$Sreact.suspense"`)||e.includes(`react.suspense`));if(!(!r&&i&&!I.current)&&!F.current){P.current=!0;try{let n=await X.current(t.join(`
|
|
3
|
-
`));if((i||r)&&(await
|
|
3
|
+
`));if((i||r)&&(await re(50),E.current===e&&!F.current)){let n=C.current?[...C.current]:t,r=await X.current(n.join(`
|
|
4
4
|
`));E.current===e&&(F.current=!0,y(r),b(e=>e+1),z.current&&T.current&&(T.current(z.current),z.current=null),I.current&&(C.current=null))}if(E.current!==e||F.current)return;let a=C.current?[...C.current]:t;if(n=await X.current(a.join(`
|
|
5
|
-
`)),E.current!==e||F.current)return;y(n),b(e=>e+1),z.current&&T.current&&(T.current(z.current),z.current=null),I.current&&(F.current=!0,C.current=null)}catch(e){console.error(`Process rows error:`,e instanceof Error?e.message:String(e))}}},c=e=>{let t=e,n=t.detail.rscRow,r=t.detail.navigationId;if(!n||!n.trim()||!C.current)return;let i=E.current;if(!(r==null||r!==i)){if(n.trim()===`STREAM_COMPLETE`){I.current=!0,L.current=L.current.then(()=>{if(E.current===i)return s()});return}C.current.push(n),L.current=L.current.then(()=>{if(E.current===i)return s()})}};return window.addEventListener(`rari:navigation-start`,a),window.addEventListener(`rari:navigate`,t),window.addEventListener(`rari:app-router-rerender`,n),window.addEventListener(`rari:rsc-invalidate`,
|
|
5
|
+
`)),E.current!==e||F.current)return;y(n),b(e=>e+1),z.current&&T.current&&(T.current(z.current),z.current=null),I.current&&(F.current=!0,C.current=null)}catch(e){console.error(`Process rows error:`,e instanceof Error?e.message:String(e))}}},c=e=>{let t=e,n=t.detail.rscRow,r=t.detail.navigationId;if(!n||!n.trim()||!C.current)return;let i=E.current;if(!(r==null||r!==i)){if(n.trim()===`STREAM_COMPLETE`){I.current=!0,L.current=L.current.then(()=>{if(E.current===i)return s()});return}C.current.push(n),L.current=L.current.then(()=>{if(E.current===i)return s()})}};return window.addEventListener(`rari:navigation-start`,a),window.addEventListener(`rari:navigate`,t),window.addEventListener(`rari:app-router-rerender`,n),window.addEventListener(`rari:rsc-invalidate`,r),window.addEventListener(`rari:app-router-manifest-updated`,o),window.addEventListener(`rari:rsc-row`,c),()=>{clearInterval(e),pe(),window.removeEventListener(`rari:navigation-start`,a),window.removeEventListener(`rari:navigate`,t),window.removeEventListener(`rari:app-router-rerender`,n),window.removeEventListener(`rari:rsc-invalidate`,r),window.removeEventListener(`rari:app-router-manifest-updated`,o),window.removeEventListener(`rari:rsc-row`,c)}},[]),o(()=>{if(!(typeof window>`u`)&&window.location.hash&&v&&N.current){let e=window.location.hash.slice(1);requestAnimationFrame(()=>{requestAnimationFrame(()=>{let t=document.getElementById(e);t&&(t.scrollIntoView({behavior:`instant`,block:`start`}),N.current=!1)})})}},[v]);let ve=()=>{window.location.reload()},ye=()=>{M(null)},be=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},$=p;if(v?.element!=null)if(v.element&&typeof v.element==`object`&&`status`in v.element){let e=v.element.status;$=e===`fulfilled`?v.element.value:e===`rejected`?p:i.use(v.element)}else $=be(v.element)??v.element;return Array.isArray($)&&$.length===1&&i.isValidElement($[0])?$=$[0]:Array.isArray($)&&$.length>0&&$.every(e=>i.isValidElement(e)||e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`)&&($=i.createElement(i.Fragment,null,...$)),d(l,{children:[j&&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:[j.type===`fetch`&&`Failed to fetch updated content from server.`,j.type===`parse`&&`Failed to parse server response.`,j.type===`stale`&&`Server returned stale content.`,j.type===`network`&&`Network error occurred.`]}),u(`div`,{style:{marginBottom:`16px`,fontSize:`12px`,opacity:.8,fontFamily:`monospace`},children:j.details}),d(`div`,{style:{marginBottom:`12px`,fontSize:`12px`,opacity:.7},children:[`Consecutive failures:`,` `,A.current,` `,`/`,` `,3]}),d(`div`,{style:{display:`flex`,gap:`8px`},children:[u(`button`,{onClick:ve,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:ye,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(a,{fallback:null,children:$})]})}export{g as AppRouterProvider};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import"../regex-constants-
|
|
1
|
+
import"../regex-constants-s9cBkrFv.mjs";import{n as e,r as t,t as n}from"../get-client-component-B4Y2T40R.mjs";import{t as r}from"../preload-modules-xvnJ_8eh.mjs";import*as i from"react";import"react";import{ClientRouter as a}from"rari/client";import{RouterProvider as o}from"rari/router";import{createRoot as s}from"react-dom/client";import{AppRouterProvider as c}from"virtual:app-router-provider";import{createFromReadableStream as l}from"virtual:react-flight-client";import"virtual:rsc-integration.ts";const u=/^\$L?[0-9a-f]+$/i;function d(e,t){let n=e.get(t);if(n)return n;let r=t.startsWith(`$L`)?`$${t.slice(2)}`:`$L${t.slice(1)}`;return e.get(r)}function f(){return globalThis[`~rari`]}function p(){return globalThis}function m(){return window}f()===void 0&&(globalThis[`~rari`]={}),f().AppRouterProvider=c,f().ClientRouter=a,f().getClientComponent=n;async function h(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
|
f().preloadClientComponent=h,p()[`~clientComponents`]===void 0&&(globalThis[`~clientComponents`]={}),p()[`~clientComponentPaths`]===void 0&&(globalThis[`~clientComponentPaths`]={});
|
|
4
4
|
/*! @preserve CLIENT_COMPONENT_REGISTRATIONS_PLACEHOLDER */
|
|
@@ -23,8 +23,8 @@ declare class RscClient {
|
|
|
23
23
|
processRscResponse(response: Response): Promise<any>;
|
|
24
24
|
processRscResponseManually(response: Response): Promise<any>;
|
|
25
25
|
parseRscResponse(rscPayload: string): any;
|
|
26
|
-
reconstructElementFromRscData(elementData: any, modules: Map<string, ModuleData>): any;
|
|
27
|
-
processPropsRecursively(props: any, modules: Map<string, ModuleData>): any;
|
|
26
|
+
reconstructElementFromRscData(elementData: any, modules: Map<string, ModuleData>, symbols?: Map<string, string>): any;
|
|
27
|
+
processPropsRecursively(props: any, modules: Map<string, ModuleData>, symbols?: Map<string, string>): any;
|
|
28
28
|
}
|
|
29
29
|
declare const rscClient: RscClient;
|
|
30
30
|
declare function RscErrorComponent({
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
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),i=x(r);if(i)l.set(`$L${n}`,i);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=d(i.children);y.set(e,t),w&&w.updateBoundary(e,t);continue}}}if(!g){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&&(g=d(e),w&&typeof w.updateRoot==`function`&&w.updateRoot())}}}catch(t){console.error(`Failed to parse stream line:`,e,t)}}}catch(e){console.error(`Error processing stream:`,e)}},E=()=>{let[,e]=v(0);_(()=>(w={updateBoundary:(t,n)=>{y.set(t,n),e(e=>e+1)},updateRoot:()=>{e(e=>e+1)}},()=>{w=null}),[e]);let t=e=>{if(!e)return null;if(h(e)){let n=e.props,r=n?.[`~boundaryId`];if(n&&r){let e=y.get(r);if(e)return e}if(n&&n.children){let r=t(n.children);if(r!==n.children){let t={...n};return e.key!==null&&e.key!==void 0&&(t.key=e.key),m(e.type,t,r)}}return e}return Array.isArray(e)?e.map(e=>t(e)):e};return t(g)};T();let D=Promise.resolve(m(E));return{"~isRscResponse":!0,"~rscPromise":D,readRoot(){return D}}}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 O(),T)try{let t=T(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(a),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{let t=x(o);if(t)n.set(`$L${a}`,t);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 o=null,s=Array.from(r.keys()).sort((e,t)=>Number.parseInt(e,16)-Number.parseInt(t,16));for(let e of s){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;o=t;break}}return o?this.reconstructElementFromRscData(o,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=C(n)||(({children:e,...t})=>m(`div`,{...t,"data-client-component":n,style:{border:`2px dashed #f00`,padding:`8px`,margin:`4px`,backgroundColor:`#fff0f0`}},m(`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=C(`${e.id}#${e.name}`)||(({children:t,...r})=>m(`div`,{...r,"data-client-component":n,style:{border:`2px dashed #f00`,padding:`8px`,margin:`4px`,backgroundColor:`#fff0f0`}},m(`small`,{style:{color:`#c00`}},`Missing Client Component: ${e.name} (${e.id})`),t)))}let o=i?this.processPropsRecursively(i,t):{};return m(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 j({error:e,details:t}){return m(`div`,{className:`rsc-error`,style:{padding:`16px`,backgroundColor:`#fee`,border:`1px solid #fcc`,borderRadius:`4px`,margin:`8px 0`,fontFamily:`monospace`}},m(`h3`,{style:{margin:`0 0 8px 0`,color:`#c00`}},`RSC Error`),m(`p`,{style:{margin:`0 0 8px 0`}},e),t&&m(`details`,{style:{marginTop:`8px`}},m(`summary`,{style:{cursor:`pointer`}},`Error Details`),m(`pre`,{style:{fontSize:`12px`,overflow:`auto`,backgroundColor:`#f5f5f5`,padding:`8px`}},JSON.stringify(t,null,2))))}function M({rootPromise:e}){return g(e)}function N({componentId:e,props:t,fallback:n}){let r=typeof window<`u`&&window[`~rari`]?.hmr?.refreshCounters?.[e]||0,i=`${e}:${JSON.stringify(t)}:hmr:${r}`;if(!k.has(i)){let n=A.fetchServerComponent(e,t).catch(e=>{throw k.delete(i),e});k.set(i,n)}let a=g(k.get(i));if(a?.[`~isRscResponse`]){let e=a.readRoot();return m(f,{fallback:n??null},m(M,{rootPromise:e}))}return a??null}var P=class extends d.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidUpdate(e){e.mountKey!==this.props.mountKey&&this.state.hasError&&this.setState({hasError:!1,error:null})}componentDidCatch(e,t){console.error(`[rari] ServerComponentErrorBoundary: Error in component ${this.props.componentId}:`,e,t)}render(){return this.state.hasError?m(j,{error:this.state.error?.message||`Unknown error`,details:{componentId:this.props.componentId}}):this.props.children}};function F(e){let t=0;if(typeof window<`u`){let n=window;n[`~rari`].hmr||(n[`~rari`].hmr={refreshCounters:{}}),n[`~rari`].hmr.refreshCounters[e]===void 0&&(n[`~rari`].hmr.refreshCounters[e]=0),t=n[`~rari`].hmr.refreshCounters[e]}let n=n=>{let[r,i]=v(t);return _(()=>{let t=t=>{let n=t.detail;if(n&&n.filePath&&L(n.filePath)&&(A.clearCache(),typeof window<`u`)){let t=window;t[`~rari`].hmr||(t[`~rari`].hmr={refreshCounters:{}}),t[`~rari`].hmr.refreshCounters[e]=(t[`~rari`].hmr.refreshCounters[e]||0)+1,i(t[`~rari`].hmr.refreshCounters[e])}};return typeof window<`u`&&window.addEventListener(`rari:rsc-invalidate`,t),()=>{typeof window<`u`&&window.removeEventListener(`rari:rsc-invalidate`,t)}},[]),m(f,{fallback:null},m(P,{componentId:e,mountKey:r},m(N,{key:`${e}-${r}`,componentId:e,props:n,fallback:null})))};return n.displayName=`ServerComponent(${e})`,function(e){return m(n,e)}}function I(e,t){return A.fetchServerComponent(e,t)}function L(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&&L(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&&L(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&&(A.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=`${b()}/_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){A.clearCache();return}let t=[];for(let n of A.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)A.componentCache.delete(e),k.delete(e);let n=[];for(let t of k.keys())for(let r of e){if(t.includes(`route:${r}:`)||t.startsWith(`${r}:`)){n.push(t);break}if(r!==`/`&&t.includes(`route:${r}/`)){n.push(t);break}}for(let e of n)k.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=`${b()}/_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(A.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 R=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 z=null;function B(){return z||=new R,z}if(import.meta.hot){let e=B();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{j as RscErrorComponent,w as createClientModuleMap,F as createServerComponentWrapper,I as fetchServerComponent,C as getClientComponent,S as registerClientComponent,A as rscClient};
|
|
1
|
+
import{c as e,f as t,i as n,l as r,n as i,o as a,s as o,u as s}from"../regex-constants-s9cBkrFv.mjs";import{t as c}from"../get-client-component-B4Y2T40R.mjs";import{t as l}from"../suspense-CsIYuC_l.mjs";import{createFromFetch as u,createFromReadableStream as d}from"./vendor/react-flight-client/index.mjs";import*as f from"react";import{Suspense as p,cloneElement as m,createElement as h,isValidElement as g,use as _,useEffect as v,useState as y}from"react";import*as b from"react-dom/client";function x(){return import.meta.env?.RARI_SERVER_URL?import.meta.env.RARI_SERVER_URL:typeof window<`u`?window.location.origin:`http://localhost:3000`}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`].streaming||(window[`~rari`].streaming={bufferedRows:[],bufferedEvents:[]}),window[`~rari`].streaming.bufferedEvents||(window[`~rari`].streaming.bufferedEvents=[]),window[`~rari`].boundaryModules||(window[`~rari`].boundaryModules=new Map),window[`~rari`].pendingBoundaryHydrations||(window[`~rari`].pendingBoundaryHydrations=new Map));function S(e){if(!e.startsWith(`I{`))return null;try{let t=JSON.parse(e.substring(1));if(typeof t==`object`&&t&&!Array.isArray(t)){if(typeof t.id!=`string`)return console.error(`[rari] Invalid import data: id must be a string:`,t),null;let e;if(typeof t.chunks==`string`)e=[t.chunks];else if(Array.isArray(t.chunks))e=t.chunks.filter(e=>typeof e==`string`);else return console.error(`[rari] Invalid import data: chunks must be a string or array:`,t),null;return e.length===0?(console.error(`[rari] Invalid import data: chunks array is empty:`,t),null):{id:t.id,chunks:e,name:t.name||`default`}}console.error(`[rari] Invalid import data format, expected object:`,t)}catch(t){console.error(`[rari] Failed to parse import row:`,e,t)}return null}if(typeof window<`u`){globalThis[`~rari`].processBoundaryUpdate=function(t,n,c){let l=document.querySelector(`[data-boundary-id="${t}"]`);if(l)try{let u=n.indexOf(`:`);if(u===-1){console.warn(`[rari] Invalid RSC row format (no colon):`,n);return}let d=n.substring(0,u),f=n.substring(u+1),p=S(f);if(p){let e=`$L${d}`;window[`~rari`].boundaryModules?.set(e,p);return}let m;try{m=JSON.parse(f)}catch(e){console.error(`[rari] Failed to parse RSC content:`,f,e);return}function h(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 h(n.children)}return e.some(e=>h(e))}return!1}if(h(m)){if(window[`~rari`].pendingBoundaryHydrations?.set(t,{content:m,element:l,rowId:c}),globalThis[`~rari`].hydrateClientComponents){let e=globalThis[`~rari`].hydrateClientComponents;e(t,m,l)}return}function g(t){let n=t=>t.replace(a,`&`).replace(r,`<`).replace(e,`>`).replace(s,`"`).replace(o,`'`),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 n(String(t));if(Array.isArray(t)){if(t.length>=4&&t[0]===`$`){let[,e,,r]=t,a=typeof e==`string`&&c.has(e.toLowerCase())?e.toLowerCase():`div`,o=null,s=``,l=``;if(r){for(let[e,t]of Object.entries(r))if(e===`dangerouslySetInnerHTML`&&t&&typeof t==`object`&&`__html`in t)o=t.__html;else if(e!==`children`&&e!==`~boundaryId`){let r=e===`className`?`class`:e;if(e===`style`&&typeof t==`object`&&t){let e=Object.entries(t).map(([e,t])=>`${e.replace(i,`$1-$2`).toLowerCase()}:${String(t)}`).join(`;`);l+=` style="${n(e)}"`}else typeof t==`string`||typeof t==`number`?l+=` ${r}="${n(String(t))}"`:typeof t==`boolean`&&t&&(l+=` ${r}`)}o===null&&r.children&&(s=g(r.children))}return`<${a}${l}>${o===null?s:o}</${a}>`}return t.map(g).join(``)}return``}let _=g(m);if(_){let e=document.contains(l);e&&(l.innerHTML=_,l.classList.add(`rari-boundary-resolved`)),window.dispatchEvent(new CustomEvent(`rari:boundary-resolved`,{detail:{boundaryId:t,rscRow:n,rowId:c,element:l,wasAttached:e}}))}}catch(e){console.error(`[rari] Error processing boundary update:`,e)}};let t=window,n=globalThis;t[`~rari`].streaming?.bufferedEvents&&t[`~rari`].streaming.bufferedEvents.length>0&&(t[`~rari`].streaming.bufferedEvents.forEach(e=>{let{boundaryId:t,rscRow:r,rowId:i}=e;n[`~rari`].processBoundaryUpdate?.(t,r,i)}),t[`~rari`].streaming.bufferedEvents=[]),window.addEventListener(`rari:boundary-update`,e=>{let{boundaryId:t,rscRow:r,rowId:i}=e.detail;n[`~rari`].processBoundaryUpdate&&n[`~rari`].processBoundaryUpdate(t,r,i)})}function C(e,t,r){let i=r==="default"?e.name||t.split(`/`).pop()?.replace(n,``)||`DefaultComponent`:r,a=i,o={id:a,path:t,type:`client`,component:e,registered:!0};globalThis[`~clientComponents`]===void 0&&(globalThis[`~clientComponents`]={});let s=`${t}#${r}`;globalThis[`~clientComponents`][a]=o,globalThis[`~clientComponents`][t]=o,globalThis[`~clientComponents`][s]=o,globalThis[`~clientComponentPaths`][t]=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:t,export_name:r})}).catch(e=>{console.error(`[rari] Failed to register client component with server:`,e)})}function w(e){return c(e)}function T(){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 E=u,D=d,O=null;async function k(){return O||(O=(async()=>{try{return E=u,D=d,typeof D!=`function`&&(D=null),typeof E!=`function`&&(E=null),b}catch(e){return console.error(`Failed to load react-dom/client RSC functions:`,e),E=null,D=null,null}})(),O)}const A=new Map,j=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(),A.clear()}async fetchServerComponent(e,t={}){let n=typeof window<`u`&&window[`~rari`]?.hmr?.refreshCounters?.[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 k();let n=(()=>{let e=[`/_rari/stream`];try{if(typeof window<`u`&&(window.location.hostname===`localhost`||window.location.hostname===`127.0.0.1`)){let t=x();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,u=new Map,d=new Map,f=e=>{if(!h)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>=4&&e[0]===`$`){let[,t,n,r]=e;if(l(t))return h(p,{fallback:r?.fallback?f(r.fallback):null},r?.children?f(r.children):null);let i=r?{...r}:{};if(r?.children){let e=f(r.children);Array.isArray(e)?i.children=e.map((e,t)=>g(e)&&e.key==null?m(e,{key:t}):e):i.children=e}if(typeof t==`string`){if(t.startsWith(`$L`)){let e=u.get(t);if(e){let t=w(`${e.id}#${e.name||`default`}`);if(t)return h(t,n?{...i,key:n}:i)}return i&&i.children?i.children:null}if(t.includes(`.tsx#`)||t.includes(`.jsx#`)){let e=w(t);return e?h(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`]),h(t,n?{...i,key:n}:i)}else console.error(`Unknown RSC element type:`,t)}return e.map(e=>f(e))}return typeof e==`object`?(console.error(`Unexpected object in RSC conversion:`,e),null):e},_=null,b=new Map,C=``,T=null,E=async()=>{try{for(;;){let{value:e,done:t}=await s.read();if(t)break;let n=c.decode(e,{stream:!0});C+=n;let r=C.split(`
|
|
2
|
+
`),i=r.slice(0,-1);C=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),i=S(r);if(i)u.set(`$L${n}`,i);else if(r.startsWith(`E{`))try{let e=JSON.parse(r.substring(1)),t=e?.error??e?.message??JSON.stringify(e);console.error(`RSC stream error:`,t)}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===`$`&&l(r)&&i&&a&&d.set(`$L${n}`,a),t===`$`&&i&&Object.hasOwn(i,`children`)&&typeof r==`string`&&r.startsWith(`$L`)){let e=d.get(r)||null;if(e){let t=f(i.children);b.set(e,t),T&&T.updateBoundary(e,t);continue}}}if(!_){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`&&l(n)&&r&&i&&(t=!1)}t&&(_=f(e),T&&typeof T.updateRoot==`function`&&T.updateRoot())}}}catch(t){console.error(`Failed to parse stream line:`,e,t)}}}catch(e){console.error(`Error processing stream:`,e)}},D=()=>{let[,e]=y(0);v(()=>(T={updateBoundary:(t,n)=>{b.set(t,n),e(e=>e+1)},updateRoot:()=>{e(e=>e+1)}},()=>{T=null}),[e]);let t=e=>{if(!e)return null;if(g(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){let t={...n};return e.key!==null&&e.key!==void 0&&(t.key=e.key),h(e.type,t,r)}}return e}return Array.isArray(e)?e.map(e=>t(e)):e};return t(_)};E();let O=Promise.resolve(h(D));return{"~isRscResponse":!0,"~rscPromise":O,readRoot(){return O}}}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 k(),E)try{let t=E(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 n=e.trim().split(t),r=new Map,i=new Map,a=new Map,o=[];for(let e of n){let t=e.indexOf(`:`);if(t===-1)continue;let n=e.substring(0,t),s=e.substring(t+1);if(s)try{let t=S(s);if(t)r.set(`$L${n}`,t);else if(s.startsWith(`E{`)){let e=s.substring(1),t=JSON.parse(e),n=t?.error??t?.message??JSON.stringify(t);o.push(n),console.error(`RSC: Server error`,n)}else if(s.startsWith(`[`)){let e=JSON.parse(s);i.set(n,e)}else if(s.startsWith(`Symbol.for(`))continue;else if(s.startsWith(`"$S`)){let e=JSON.parse(s);typeof e==`string`&&a.set(`$${n}`,e)}else console.error(`Unknown RSC row format:`,e)}catch(t){console.error(`Failed to parse RSC row:`,e,t)}}if(o.length>0)throw Error(`RSC Server Error: ${o.map(e=>e?.error??e?.message??e).join(`, `)}`);let s=null,c=Array.from(i.keys()).sort((e,t)=>Number.parseInt(e,16)-Number.parseInt(t,16));for(let e of c){let t=i.get(e);if(Array.isArray(t)&&t.length>=2&&t[0]===`$`){let[,e,,n]=t,r=n?.[`~boundaryId`],i=typeof e==`string`&&e.startsWith(`$`)?a.get(e):void 0;if((l(e)||l(i))&&n&&r)continue;s=t;break}}return s?this.reconstructElementFromRscData(s,r,a):(console.error(`No valid root element found in RSC payload`,{elements:i,modules:r}),null)}reconstructElementFromRscData(e,t,n){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[,r,i,a]=e,o=r;if(typeof r==`string`&&r.includes(`#`))o=w(r)||(({children:e,...t})=>h(`div`,{...t,"data-client-component":r,style:{border:`2px dashed #f00`,padding:`8px`,margin:`4px`,backgroundColor:`#fff0f0`}},h(`small`,{style:{color:`#c00`}},`Missing Client Component: ${r}`),e));else if(typeof r==`string`&&r.startsWith(`$L`)&&t.has(r)){let e=t.get(r);e&&(o=w(`${e.id}#${e.name}`)||(({children:t,...n})=>h(`div`,{...n,"data-client-component":r,style:{border:`2px dashed #f00`,padding:`8px`,margin:`4px`,backgroundColor:`#fff0f0`}},h(`small`,{style:{color:`#c00`}},`Missing Client Component: ${e.name} (${e.id})`),t)))}let s=a?this.processPropsRecursively(a,t,n):{},c=typeof r==`string`&&r.startsWith(`$`)&&!r.startsWith(`$L`)?n?.get(r):void 0;return(l(r)||l(c))&&(o=p),h(o,{key:i,...s})}else return e.map(e=>this.reconstructElementFromRscData(e,t,n));return typeof e==`object`?null:e}processPropsRecursively(e,t,n){if(!e||typeof e!=`object`)return e;let r={};for(let[i,a]of Object.entries(e))if(i===`children`)if(Array.isArray(a))if(a.length>=2&&a[0]===`$`)r[i]=this.reconstructElementFromRscData(a,t,n);else{let e=a.map(e=>this.reconstructElementFromRscData(e,t,n)).filter(e=>e!=null);e.length===0?r[i]=null:e.length===1?r[i]=e[0]:r[i]=e}else r[i]=this.reconstructElementFromRscData(a,t,n);else i===`dangerouslySetInnerHTML`?r[i]=a:r[i]=this.reconstructElementFromRscData(a,t,n);return r}};function M({error:e,details:t}){return h(`div`,{className:`rsc-error`,style:{padding:`16px`,backgroundColor:`#fee`,border:`1px solid #fcc`,borderRadius:`4px`,margin:`8px 0`,fontFamily:`monospace`}},h(`h3`,{style:{margin:`0 0 8px 0`,color:`#c00`}},`RSC Error`),h(`p`,{style:{margin:`0 0 8px 0`}},e),t&&h(`details`,{style:{marginTop:`8px`}},h(`summary`,{style:{cursor:`pointer`}},`Error Details`),h(`pre`,{style:{fontSize:`12px`,overflow:`auto`,backgroundColor:`#f5f5f5`,padding:`8px`}},JSON.stringify(t,null,2))))}function N({rootPromise:e}){return _(e)}function P({componentId:e,props:t,fallback:n}){let r=typeof window<`u`&&window[`~rari`]?.hmr?.refreshCounters?.[e]||0,i=`${e}:${JSON.stringify(t)}:hmr:${r}`;if(!A.has(i)){let n=j.fetchServerComponent(e,t).catch(e=>{throw A.delete(i),e});A.set(i,n)}let a=_(A.get(i));if(a?.[`~isRscResponse`]){let e=a.readRoot();return h(p,{fallback:n??null},h(N,{rootPromise:e}))}return a??null}var F=class extends f.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidUpdate(e){e.mountKey!==this.props.mountKey&&this.state.hasError&&this.setState({hasError:!1,error:null})}componentDidCatch(e,t){console.error(`[rari] ServerComponentErrorBoundary: Error in component ${this.props.componentId}:`,e,t)}render(){return this.state.hasError?h(M,{error:this.state.error?.message||`Unknown error`,details:{componentId:this.props.componentId}}):this.props.children}};function I(e){let t=0;if(typeof window<`u`){let n=window;n[`~rari`].hmr||(n[`~rari`].hmr={refreshCounters:{}}),n[`~rari`].hmr.refreshCounters[e]===void 0&&(n[`~rari`].hmr.refreshCounters[e]=0),t=n[`~rari`].hmr.refreshCounters[e]}let n=n=>{let[r,i]=y(t);return v(()=>{let t=t=>{let n=t.detail;if(n&&n.filePath&&R(n.filePath)&&(j.clearCache(),typeof window<`u`)){let t=window;t[`~rari`].hmr||(t[`~rari`].hmr={refreshCounters:{}}),t[`~rari`].hmr.refreshCounters[e]=(t[`~rari`].hmr.refreshCounters[e]||0)+1,i(t[`~rari`].hmr.refreshCounters[e])}};return typeof window<`u`&&window.addEventListener(`rari:rsc-invalidate`,t),()=>{typeof window<`u`&&window.removeEventListener(`rari:rsc-invalidate`,t)}},[]),h(p,{fallback:null},h(F,{componentId:e,mountKey:r},h(P,{key:`${e}-${r}`,componentId:e,props:n,fallback:null})))};return n.displayName=`ServerComponent(${e})`,function(e){return h(n,e)}}function L(e,t){return j.fetchServerComponent(e,t)}function R(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&&R(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&&R(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&&(j.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=`${x()}/_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){j.clearCache();return}let t=[];for(let n of j.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)j.componentCache.delete(e),A.delete(e);let n=[];for(let t of A.keys())for(let r of e){if(t.includes(`route:${r}:`)||t.startsWith(`${r}:`)){n.push(t);break}if(r!==`/`&&t.includes(`route:${r}/`)){n.push(t);break}}for(let e of n)A.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=`${x()}/_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(j.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 z=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 B=null;function V(){return B||=new z,B}if(import.meta.hot){let e=V();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{M as RscErrorComponent,T as createClientModuleMap,I as createServerComponentWrapper,L as fetchServerComponent,w as getClientComponent,C as registerClientComponent,j as rscClient};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createStringDecoder as
|
|
2
|
-
`,r);break}if(t>-1){let s=n.slice(r,t);$(e,a,o,s),r=t,i===3&&r++,i=0,o=0,a=0}else break}t._rowState=i,t._rowID=a,t._rowTag=o}function
|
|
1
|
+
import{t as e}from"../../../suspense-CsIYuC_l.mjs";import{createStringDecoder as t,preloadModule as n,readFinalStringChunk as r,readPartialStringChunk as i,requireModule as a,resolveClientReference as o}from"./ReactFlightClientConfig.mjs";const s=Symbol.for(`react.transitional.element`)||Symbol.for(`react.element`),c=Symbol.for(`react.lazy`),l=`pending`,u=`blocked`,d=`resolved_model`,f=`resolved_module`,p=`fulfilled`,m=`rejected`;function h(e,t,n){this.status=e,this.value=t,this.reason=n}h.prototype=Object.create(Promise.prototype),h.prototype.then=function(e,t){let n=this;switch(n.status){case d:j(n);break;case f:M(n);break}switch(n.status){case p:e&&e(n.value);break;case l:case u:if(e){if(n.value===null&&(n.value=[]),!Array.isArray(n.value)){e(n.value);break}n.value.push(e)}if(t){if(n.reason===null&&(n.reason=[]),!Array.isArray(n.reason))break;n.reason.push(t)}break;default:t&&t(n.reason);break}};function g(e){switch(e.status){case d:j(e);break;case f:M(e);break}switch(e.status){case p:return e.value;case l:case u:throw e;default:throw Error(String(e.reason))}}function _(e){return P(e,0)}function v(){return new h(l,null,null)}function y(){return new h(u,null,null)}function b(e){return new h(m,null,e)}function x(e,t){for(let n=0;n<e.length;n++){let r=e[n];typeof r==`function`&&r(t)}}function S(e,t,n){switch(e.status){case p:x(t,e.value);break;case l:case u:if(e.value!==null&&!Array.isArray(e.value)){e.value=t;break}if(e.value)for(let n=0;n<t.length;n++)e.value.push(t[n]);else e.value=t;if(e.reason!==null&&!Array.isArray(e.reason)){e.reason=n;break}if(e.reason){if(n)for(let t=0;t<n.length;t++)e.reason.push(n[t])}else e.reason=n;break;case m:n&&x(n,e.reason);break}}function C(e,t){if(e.status!==l&&e.status!==u)return;let n=e.reason,r=e;if(r.status=m,r.reason=t,n!==null)for(let e=0;e<n.length;e++)n[e](t)}function w(e,t){return new h(d,t,e)}function T(e){return new h(f,e,null)}function E(e){return new h(p,e,null)}function D(e,t,n){if(t.status!==l&&t.status!==u)return;let r=Array.isArray(t.value)?t.value:null,i=Array.isArray(t.reason)?t.reason:null,a=t;a.status=d,a.value=n,a.reason=e,j(a),r!==null&&S(t,r,i)}function O(e,t,n){if(t.status!==l&&t.status!==u&&t.status!==m)return;let r=Array.isArray(t.value)?t.value:null,i=Array.isArray(t.reason)?t.reason:null,a=t;a.status=f,a.value=n,a.reason=null,M(a),r!==null&&S(t,r,i)}let k=null,A=null;function j(e){let t=k,n=A;k=null,A=null;let r=e.value,i=e.reason,a=e;a.status=u,a.value=null,a.reason=null,k=a;try{let t=H(i,r);if(A!==null){let e=A;if(e.errored)throw e.reason;if(e.deps>0){e.value=t,e.chunk=a;return}}let n=e;n.status=p,n.value=t,n.reason=null}catch(t){let n=e;n.status=m,n.reason=t}finally{k=t,A=n}}function M(e){try{let t=a(e.value),n=e;n.status=p,n.value=t,n.reason=null}catch(t){let n=e;n.status=m,n.reason=t}}function N(e,t){e._closed=!0,e._closedReason=t,e._chunks.forEach(e=>{e.status===l&&C(e,t)})}function P(e,t){let n=e._chunks,r=n.get(t);return r||(r=e._closed?b(e._closedReason):v(),n.set(t,r)),r}function F(t,n,r,i){i??={},e(n)&&(n=Symbol.for(`react.suspense`));let a={$$typeof:s,type:n,key:r,ref:null,props:i};if(A!==null){let e=A;if(A=e.parent,e.errored)return I(b(e.reason));if(e.deps>0){let t=y();return e.value=a,e.chunk=t,I(t)}}return a}function I(e){return{$$typeof:c,_payload:e,_init:g}}function L(e,t,n,r,i){let a=t.split(`:`),o=P(e,Number.parseInt(a[0],16));switch(o.status){case d:j(o);break;case f:M(o);break}switch(o.status){case p:{let e=o.value;for(let t=1;t<a.length;t++)e=e[a[t]];return i(e)}case l:case u:return I(o);default:return A?(A.errored=!0,A.reason=o.reason):A={parent:null,chunk:null,value:null,deps:0,errored:!0,reason:o.reason},null}}function R(e){return e}function z(e,t,n,r){if(r[0]===`$`){if(r===`$`)return A!==null&&n===`0`&&(A={parent:A,chunk:null,value:null,deps:0,errored:!1,reason:null}),s;switch(r[1]){case`$`:return r.slice(1);case`L`:return I(P(e,Number.parseInt(r.slice(2),16)));case`@`:return P(e,Number.parseInt(r.slice(2),16));case`S`:return Symbol.for(r.slice(2));case`F`:return L(e,r.slice(2),t,n,t=>G(e,t));case`Q`:return L(e,r.slice(2),t,n,U);case`W`:return L(e,r.slice(2),t,n,W);case`I`:return 1/0;case`-`:return r===`$-0`?-0:-1/0;case`N`:return NaN;case`u`:return;case`D`:return new Date(Date.parse(r.slice(2)));case`n`:return BigInt(r.slice(2));default:return L(e,r.slice(1),t,n,R)}}return r}function B(e,t){let n=t;return n[0]===s?F(e,n[1],n[2],n[3]):t}function V(e,t,n,r){if(typeof t==`string`)return t[0]===`$`?z(e,n,r,t):t;if(typeof t!=`object`||!t)return t;if(Array.isArray(t)){for(let n=0;n<t.length;n++)t[n]=V(e,t[n],t,`${n}`);return t[0]===s?B(e,t):t}for(let n in t)if(n===`__proto__`)delete t[n];else{let r=V(e,t[n],t,n);r===void 0?delete t[n]:t[n]=r}return t}function H(e,t){let n=JSON.parse(t);return V(e,n,{"":n},``)}function U(e){return new Map(e)}function W(e){return new Set(e)}function G(e,t){let n=e._callServer,r=t.id;return function(...e){return n(r,e)}}function K(){throw Error(`Trying to call a function from "use server" but the callServer option was not implemented in your router runtime.`)}function q(e,n){let r=new Map;this._bundlerConfig=e,this._callServer=n===void 0?K:n,this._chunks=r,this._stringDecoder=t(),this._closed=!1,this._closedReason=null}function J(e,t){return new q(e,t)}function Y(){return{_rowState:0,_rowID:0,_rowTag:0,_rowLength:0,_buffer:[]}}function X(e,t,n){let r=e._chunks,i=r.get(t);i?D(e,i,n):r.set(t,w(e,n))}function Z(e,t,n){e._chunks.set(t,E(n))}function Q(e,t,r){let i=e._chunks,a=i.get(t),s=o(H(e,r)),c=n(s);if(c){let n;a?(n=a,n.status=u):(n=y(),i.set(t,n)),c.then(()=>O(e,n,s),e=>C(n,e))}else a?O(e,a,s):i.set(t,T(s))}function ee(e,t,n){let r=Error(`An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.`);r.digest=n;let i=e._chunks,a=i.get(t);a?C(a,r):i.set(t,b(r))}function $(e,t,n,r){switch(n){case 73:Q(e,t,r);return;case 69:ee(e,t,JSON.parse(r).digest);return;case 84:Z(e,t,r);return;default:X(e,t,r)}}function te(e,t,n){let a=0,o=t._rowState,s=t._rowID,c=t._rowTag,l=t._rowLength,u=t._buffer,d=n.length;for(;a<d;){let t=-1;switch(o){case 0:{let e=n[a++];e===58?o=1:s=s<<4|(e>96?e-87:e-48);continue}case 1:{let e=n[a];e===84||e>64&&e<91?(c=e,o=3,a++):(c=0,o=3);continue}case 3:t=n.indexOf(10,a);break}let d=n.byteOffset+a;if(t>-1){let f=t-a,p=new Uint8Array(n.buffer,d,f),m=e._stringDecoder,h=``;for(let e=0;e<u.length;e++)h+=i(m,u[e]);h+=r(m,p),$(e,s,c,h),a=t,o===3&&a++,o=0,c=0,s=0,l=0,u.length=0}else{let e=n.byteLength-a,t=new Uint8Array(n.buffer,d,e);u.push(t),l-=t.byteLength;break}}t._rowState=o,t._rowID=s,t._rowTag=c,t._rowLength=l}function ne(e,t,n){let r=0,i=t._rowState,a=t._rowID,o=t._rowTag,s=n.length;for(;r<s;){let t=-1;switch(i){case 0:{let e=n.charCodeAt(r++);e===58?i=1:a=a<<4|(e>96?e-87:e-48);continue}case 1:{let e=n.charCodeAt(r);e===84||e>64&&e<91?(o=e,i=3,r++):(o=0,i=3);continue}case 3:t=n.indexOf(`
|
|
2
|
+
`,r);break}if(t>-1){let s=n.slice(r,t);$(e,a,o,s),r=t,i===3&&r++,i=0,o=0,a=0}else break}t._rowState=i,t._rowID=a,t._rowTag=o}function re(e){e._closed=!0,e._chunks.forEach(e=>{e.status===l&&C(e,Error(`Connection closed.`))})}export{re as close,J as createResponse,Y as createStreamState,_ as getRoot,te as processBinaryChunk,ne as processStringChunk,N as reportGlobalError};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{C as e,S as t,
|
|
1
|
+
import{C as e,S as t,b as n,x as r,y as i}from"./regex-constants-s9cBkrFv.mjs";import{t as a}from"./alias-resolver-BintHkb_.mjs";import{Buffer as o}from"node:buffer";import{existsSync as s,promises as c}from"node:fs";import l from"node:path";const u=/[^\w-]/g,d=`\0virtual:sitemap`;function f(a){return a.replace(i,`&`).replace(t,`<`).replace(r,`>`).replace(e,`"`).replace(n,`'`)}function p(e){return(typeof e==`string`?new Date(e):e).toISOString()}function m(e){return[` <image:image>`,` <image:loc>${f(e)}</image:loc>`,` </image:image>`].join(`
|
|
2
2
|
`)}function h(e){let t=[` <image:image>`,` <image:loc>${f(e.loc)}</image:loc>`];return e.title&&t.push(` <image:title>${f(e.title)}</image:title>`),e.caption&&t.push(` <image:caption>${f(e.caption)}</image:caption>`),e.geoLocation&&t.push(` <image:geo_location>${f(e.geoLocation)}</image:geo_location>`),e.license&&t.push(` <image:license>${f(e.license)}</image:license>`),t.push(` </image:image>`),t.join(`
|
|
3
3
|
`)}function g(e){let t=[];for(let n of e)typeof n==`string`?t.push(m(n)):t.push(h(n));return t.join(`
|
|
4
4
|
`)}function _(e){let t=[];if(t.push(` <video:video>`),t.push(` <video:title>${f(e.title)}</video:title>`),t.push(` <video:thumbnail_loc>${f(e.thumbnail_loc)}</video:thumbnail_loc>`),t.push(` <video:description>${f(e.description)}</video:description>`),e.content_loc&&t.push(` <video:content_loc>${f(e.content_loc)}</video:content_loc>`),e.player_loc&&t.push(` <video:player_loc>${f(e.player_loc)}</video:player_loc>`),e.duration!==void 0&&t.push(` <video:duration>${e.duration}</video:duration>`),e.expiration_date&&t.push(` <video:expiration_date>${f(e.expiration_date)}</video:expiration_date>`),e.rating!==void 0&&t.push(` <video:rating>${e.rating}</video:rating>`),e.view_count!==void 0&&t.push(` <video:view_count>${e.view_count}</video:view_count>`),e.publication_date&&t.push(` <video:publication_date>${f(e.publication_date)}</video:publication_date>`),e.family_friendly!==void 0&&t.push(` <video:family_friendly>${e.family_friendly?`yes`:`no`}</video:family_friendly>`),e.requires_subscription!==void 0&&t.push(` <video:requires_subscription>${e.requires_subscription?`yes`:`no`}</video:requires_subscription>`),e.live!==void 0&&t.push(` <video:live>${e.live?`yes`:`no`}</video:live>`),e.restriction&&t.push(` <video:restriction relationship="${f(e.restriction.relationship)}">${f(e.restriction.content)}</video:restriction>`),e.platform&&t.push(` <video:platform relationship="${f(e.platform.relationship)}">${f(e.platform.content)}</video:platform>`),e.uploader){let n=e.uploader.info?` info="${f(e.uploader.info)}"`:``;t.push(` <video:uploader${n}>${f(e.uploader.name)}</video:uploader>`)}if(e.tag)for(let n of e.tag)t.push(` <video:tag>${f(n)}</video:tag>`);return t.push(` </video:video>`),t.join(`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=[`$Sreact.suspense`,`react.suspense`,`suspense`,`Suspense`];function t(t){return typeof t==`string`&&e.includes(t)}export{t};
|
|
@@ -10,6 +10,8 @@ interface RouteSegment {
|
|
|
10
10
|
interface AppRouteEntry {
|
|
11
11
|
path: string;
|
|
12
12
|
filePath: string;
|
|
13
|
+
css?: string[];
|
|
14
|
+
componentId?: string;
|
|
13
15
|
segments: RouteSegment[];
|
|
14
16
|
params: string[];
|
|
15
17
|
isDynamic: boolean;
|
|
@@ -19,20 +21,27 @@ interface AppRouteEntry {
|
|
|
19
21
|
interface LayoutEntry {
|
|
20
22
|
path: string;
|
|
21
23
|
filePath: string;
|
|
24
|
+
css?: string[];
|
|
25
|
+
componentId?: string;
|
|
22
26
|
parentPath?: string;
|
|
23
27
|
}
|
|
24
28
|
interface LoadingEntry {
|
|
25
29
|
path: string;
|
|
26
30
|
filePath: string;
|
|
27
|
-
|
|
31
|
+
css?: string[];
|
|
32
|
+
componentId?: string;
|
|
28
33
|
}
|
|
29
34
|
interface ErrorEntry {
|
|
30
35
|
path: string;
|
|
31
36
|
filePath: string;
|
|
37
|
+
css?: string[];
|
|
38
|
+
componentId?: string;
|
|
32
39
|
}
|
|
33
40
|
interface NotFoundEntry {
|
|
34
41
|
path: string;
|
|
35
42
|
filePath: string;
|
|
43
|
+
css?: string[];
|
|
44
|
+
componentId?: string;
|
|
36
45
|
}
|
|
37
46
|
interface OgImageEntry {
|
|
38
47
|
path: string;
|
package/dist/vite.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { C as hasServerSideDataFetching, S as extractStaticParams, _ as clearPropsCache, b as extractServerProps, f as createHttpRuntimeClient, g as StaticParamsResult, h as ServerSidePropsResult, m as MetadataResult, n as ServerCacheControlConfig, r as ServerConfig, s as HttpRuntimeClient, t as ServerCSPConfig, u as RuntimeClient, v as clearPropsCacheForComponent, x as extractServerPropsWithCache, y as extractMetadata } from "./server-config-CwWYmtA0.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-
|
|
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-pC5OZq29.mjs";
|
|
3
3
|
import { a as SitemapImage, i as SitemapEntry, n as RobotsRule, o as SitemapVideo, r as Sitemap, t as Robots } from "./metadata-route-85WvBQcW.mjs";
|
|
4
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-3dq9RGI5.mjs";
|
|
5
5
|
import { RariRequest } from "./proxy/RariRequest.mjs";
|
package/dist/vite.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import{RariRequest as e}from"./proxy/RariRequest.mjs";import{RariResponse as t}from"./proxy/RariResponse.mjs";import{_ as n,c as r,d as i,f as a,g as o,h as s,i as c,m as l,p as u,u as d}from"./runtime-client-DHeO6y_7.mjs";import{i as f,n as p,o as m,r as h,t as g}from"./constants-De7aSsCq.mjs";import{_,a as v,
|
|
2
|
-
`||e===`\u2028`||e===`\u2029`||e===``}function
|
|
3
|
-
`||e===`\u2028`||e===`\u2029`}function
|
|
4
|
-
`&&e[t]!==`\r`;)t--;let r=t+1;for(;r<n&&(e[r]===` `||e[r]===` `);)r++;if(r<n&&e[r]===`/`&&e[r+1]===`/`){n=r-1;continue}break}if(n<0||!
|
|
5
|
-
`&&e[t]!==`\r`;)t--;let r=t+1;for(;r<n&&(e[r]===` `||e[r]===` `);)r++;if(r<n&&e[r]===`/`&&e[r+1]===`/`){n=r-1;continue}return e[n]}}function W(e){let t=0,n=e.length;for(;t<n;){if(
|
|
6
|
-
`),n=!1;function r(e){return
|
|
7
|
-
• `);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 Fe=/import\s+(\w+)\s+from\s+['"]rari\/image['"]/g,Ie=/import\s+\{[^}]*\b(?:Image\s+as\s+(\w+)|Image)\b[^}]*\}\s+from\s+['"]rari\/image['"]/g,Le=/src:\s*["']([^"']+)["']/,Re=/[.*+?^${}()|[\]\\]/g,ze=/^[A-Z_$][\w$]*$/i,Be=/width:\s*(\d+)/,Ve=/quality:\s*(\d+)/,He=/preload:\s*(true|!0)/,Ue=/preload:\s*(false|!1)/,We=/src=\{?["']([^"']+)["']\}?|src=\{([^}]+)\}/,Ge=/width=\{?(\d+)\}?/,Ke=/quality=\{?(\d+)\}?/,qe=/preload(?:=\{?true\}?)?/,Je=/preload=\{?false\}?/;async function Ye(e,t){try{await st(await j.readFile(e,`utf8`),e,t)}catch(t){t.code!==`ENOENT`&&console.warn(`[rari] Image scanner: Failed to process ${e}:`,t)}}const Xe=new class{permits;queue=[];constructor(e){this.permits=e}async acquire(){if(this.permits>0){this.permits--;return}return new Promise(e=>{this.queue.push(e)})}release(){this.permits++;let e=this.queue.shift();e&&(this.permits--,e())}async run(e){await this.acquire();try{return await e()}finally{this.release()}}}(50);async function G(e,t){try{await j.access(e)}catch{return}let n=await j.readdir(e,{withFileTypes:!0}),r=[];for(let i of n){let n=D.join(e,i.name);if(i.isDirectory()){if(i.name===`node_modules`||i.name===`dist`)continue;r.push(G(n,t))}else i.isFile()&&w.test(i.name)&&r.push(Xe.run(()=>Ye(n,t)))}await Promise.all(r)}async function Ze(e,t=[]){let n=new Map;try{await j.access(e),await G(e,n)}catch(t){throw t.code===`ENOENT`?Error(`Required source directory does not exist: ${e}`):t}for(let e of t)try{await j.access(e),await G(e,n)}catch(t){t.code!==`ENOENT`&&console.warn(`[rari] Image scanner: Failed to scan directory ${e}:`,t)}return{images:[...n.values()]}}function Qe(e){return e.endsWith(`.tsx`)?`tsx`:e.endsWith(`.jsx`)?`jsx`:e.endsWith(`.ts`)?`ts`:`js`}async function $e(e,t,n){let r=`\0virtual:${t}`,i=await M({input:r,external:[`rari/image`],platform:`browser`,write:!1,output:{format:`esm`},moduleTypes:{[`.${n}`]:n},transform:{jsx:`react`},plugins:[{name:`virtual-module`,resolveId(e){return e===r?e:null},load(t){return t===r?{code:e,moduleType:n}:null}}]});if(!i.output||i.output.length===0)throw Error(`Transform produced no output`);return i.output[0].code}function et(e){let t=new Set;for(let n of e.matchAll(Fe))t.add(n[1]);for(let n of e.matchAll(Ie))n[1]?t.add(n[1]):t.add(`Image`);return t}function tt(e){return et(e)}function nt(e){let t=e.match(Le);if(!t)return null;let n=t[1];if(!n.startsWith(`/`)&&!n.startsWith(`http`))return null;let r=e.match(Be),i=r?Number.parseInt(r[1],10):void 0,a=e.match(Ve),o=a?Number.parseInt(a[1],10):void 0,s=e.match(He),c=e.match(Ue);return{src:n,width:i,quality:o,preload:!!s&&!c}}function rt(e,t){let n=`${e.src}:${e.width??`auto`}:${e.quality??75}`;(!t.has(n)||e.preload)&&t.set(n,e)}function it(e,t){let n=0,r=!1,i=``,a=!1,o=0;for(let s=t;s<e.length;s++){let c=e[s];if(a){a=!1;continue}if(c===`\\`){a=!0;continue}if(!r&&(c===`"`||c===`'`||c==="`")){r=!0,i=c,c==="`"&&(o=1);continue}if(r&&c===i){i==="`"?(o--,o===0&&(r=!1,i=``)):(r=!1,i=``);continue}if(r&&i==="`"&&c===`$`&&s+1<e.length&&e[s+1]===`{`){n++,s++;continue}if(r&&i==="`"&&n>0&&c==="`"){o++;continue}if(r&&i==="`"&&c===`}`&&n>0){n--;continue}if(!r){if(c===`{`)n++;else if(c===`}`&&(n--,n===0))return e.substring(t+1,s)}}return null}function at(e,t,n){for(let r of t){if(!ze.test(r)){console.warn(`[rari] Image scanner: Skipping unsafe identifier: ${r}`);continue}let t=r.replace(Re,`\\$&`),i=RegExp(`React\\.createElement\\(\\s*${t}\\s*,\\s*\\{`,`g`);for(let t of e.matchAll(i)){let r=it(e,t.index+t[0].length-1);if(r){let e=nt(r);e&&rt(e,n)}}}}function ot(e){return et(e)}async function st(e,t,n){let r=ot(e);if(r.size!==0)try{let r=await $e(e,t,Qe(t)),i=tt(r);if(i.size===0)return;at(r,i,n)}catch{ct(e,r,n)}}function ct(e,t,n){for(let r of t){if(!ze.test(r)){console.warn(`[rari] Image scanner: Skipping unsafe alias: ${r}`);continue}let t=r.replace(Re,`\\$&`),i=RegExp(`<${t}\\s([^/>]+)\\/>`,`g`),a=RegExp(`<${t}\\s([^>]+)>`,`g`);for(let t of e.matchAll(i))lt(t[1],n);for(let t of e.matchAll(a))lt(t[1],n)}}function lt(e,t){let n=e.match(We);if(!n)return;let r=n[1]||n[2];if(!r||r.includes(`{`)||!r.startsWith(`/`)&&!r.startsWith(`http`))return;let i=e.match(Ge),a=i?Number.parseInt(i[1],10):void 0,o=e.match(Ke),s=o?Number.parseInt(o[1],10):void 0,c=qe.test(e)&&!Je.test(e),l=`${r}:${a??`auto`}:${s??75}`;(!t.has(l)||c)&&t.set(l,{src:r,width:a,quality:s,preload:c})}var ut=se({ServerComponentBuilder:()=>xt,createServerBuildPlugin:()=>X,scanDirectory:()=>Y});const dt=/import\s*\(\s*["']([^"']+)["']\s*\)|import\s+["']([^"']+)["']/g,K=/from\s+['"]([^'"]+)['"]|import\s*\(\s*['"]([^'"]+)['"]\s*\)|import\s+['"]([^'"]+)['"]/g,ft=/import(?:\s+(?:\w+|\{[^}]*\}|\*\s+as\s+\w+)(?:\s*,\s*(?:\w+|\{[^}]*\}|\*\s+as\s+\w+))*\s+from\s+)?['"]([^'"]+)['"]/g,pt=/import\s+(\w+)\s+from\s+['"]([^'"]+)['"]/g,mt=/import\s+(?:(\w+)|\{([^}]+)\})\s+from\s+['"]([^'"]+)['"];?\s*$/gm,ht=/^proxy\.(?:tsx?|jsx?|mts|mjs)$/,gt=/\\/g,q=/\.(tsx?|jsx?)$/,_t=/\/components\/(\w+)(?:\.tsx?|\.jsx?)?$/,vt=/[/\\]components[/\\](\w+)(?:\.tsx?|\.jsx?)?$/,yt=/^(?:robots|sitemap)\.(?:tsx?|jsx?)$/,bt=/^node:/,J=/\\/g;var xt=class{serverComponents=new Map;serverActions=new Map;options;projectRoot;buildCache=new Map;htmlOnlyImports=new Set;fileImporters=new Map;getComponentCount(){return this.serverComponents.size+this.serverActions.size}getImportGraph(){let e=new Map;for(let[t,n]of this.fileImporters)e.set(t,new Set(n));return e}getHtmlOnlyImports(){return new Set(this.htmlOnlyImports)}constructor(e,t={}){this.projectRoot=e;let n=t.rscDir||`server`;this.options={outDir:t.outDir||D.join(e,`dist`),rscDir:n,manifestPath:t.manifestPath||D.join(n,`manifest.json`),serverConfigPath:t.serverConfigPath||D.join(n,`config.json`),minify:t.minify??O.env.NODE_ENV===`production`,alias:t.alias||{},define:t.define,csp:t.csp,cacheControl:t.cacheControl},this.parseHtmlImports()}parseHtmlImports(){let e=D.join(this.projectRoot,`index.html`);if(T.existsSync(e))try{let t=T.readFileSync(e,`utf-8`);for(let e of t.matchAll(dt)){let t=e[1]||e[2];if(t.startsWith(`/src/`)){let e=D.join(this.projectRoot,t.slice(1));this.htmlOnlyImports.add(e)}}}catch(e){console.warn(`[server-build] Error parsing index.html:`,e)}}isHtmlOnlyImport(e){return this.htmlOnlyImports.has(e)}isServerComponent(e,t){if(e.includes(`node_modules`)||this.isHtmlOnlyImport(e))return!1;try{let n=t??(T.existsSync(e)?T.readFileSync(e,`utf-8`):null);return n===null?!1:!H(n)&&!V(n)}catch{return!1}}isClientComponent(e,t){try{let n=t??(T.existsSync(e)?T.readFileSync(e,`utf-8`):null);return n===null?!1:H(n)}catch{return!1}}buildImportGraph(e){this.fileImporters.clear();let t=e=>{if(!T.existsSync(e))return;let n=T.readdirSync(e,{withFileTypes:!0});for(let r of n){let n=D.join(e,r.name);if(r.isDirectory()){if(r.name===`node_modules`)continue;t(n)}else if(r.isFile()&&w.test(r.name))try{let e=T.readFileSync(n,`utf-8`),t;for(K.lastIndex=0,t=K.exec(e);t!==null;){let r=t[1]||t[2]||t[3],i=null;if(r.startsWith(`./`)||r.startsWith(`../`)){let e=D.dirname(n);i=D.resolve(e,r)}else if(r.startsWith(`@/`)){let e=r.slice(2);i=D.join(this.projectRoot,`src`,e)}if(i){let e=[``,`.ts`,`.tsx`,`.js`,`.jsx`],t=null;for(let n of e){let e=i+n;if(T.existsSync(e)&&T.statSync(e).isFile()){t=e;break}}t&&(this.fileImporters.has(t)||this.fileImporters.set(t,new Set),this.fileImporters.get(t).add(n))}t=K.exec(e)}}catch(e){e?.code!==`ENOENT`&&console.warn(`[rari] Unexpected error building import graph:`,n,e)}}};t(e)}isOnlyImportedByClientComponents(e){let t=this.fileImporters.get(e);if(!t||t.size===0)return!1;for(let e of t)if(!this.isClientComponent(e)&&!this.isOnlyImportedByClientComponents(e))return!1;return!0}addServerComponent(e,t){let n=t??T.readFileSync(e,`utf-8`);if(this.isServerAction(n)){let t=this.extractDependencies(n),r=this.hasNodeImports(n);this.serverActions.set(e,{filePath:e,originalCode:n,dependencies:t,hasNodeImports:r});return}if(!this.isServerComponent(e,n))return;let r=this.extractDependencies(n),i=this.hasNodeImports(n);this.serverComponents.set(e,{filePath:e,originalCode:n,dependencies:r,hasNodeImports:i})}isServerAction(e){return V(e)}extractDependencies(e){let t=[],n;for(ft.lastIndex=0;n=ft.exec(e),n!==null;){let e=n[1];!e.startsWith(`.`)&&!e.startsWith(`/`)&&!e.startsWith(`node:`)&&!this.isNodeBuiltin(e)&&t.push(e)}return[...new Set(t)]}isNodeBuiltin(e){return[`fs`,`path`,`os`,`crypto`,`util`,`stream`,`events`,`process`,`buffer`,`url`,`querystring`,`zlib`,`http`,`https`,`net`,`tls`,`child_process`,`cluster`,`worker_threads`].includes(e)}hasNodeImports(e){return e.includes(`from 'node:`)||e.includes(`from "node:`)||e.includes(`from 'fs'`)||e.includes(`from "fs"`)||e.includes(`from 'path'`)||e.includes(`from "path"`)||e.includes(`from 'os'`)||e.includes(`from "os"`)||e.includes(`from 'crypto'`)||e.includes(`from "crypto"`)||e.includes(`from 'util'`)||e.includes(`from "util"`)||e.includes(`from 'stream'`)||e.includes(`from "stream"`)||e.includes(`from 'events'`)||e.includes(`from "events"`)}async getTransformedComponentsForDevelopment(){let e=[];for(let[t]of this.serverComponents){let n=D.relative(this.projectRoot,t),r=this.getComponentId(n),i=await this.buildComponentCodeOnly(t);e.push({id:r,code:i})}for(let[t]of this.serverActions){let n=D.relative(this.projectRoot,t),r=this.getComponentId(n),i=await this.buildComponentCodeOnly(t);e.push({id:r,code:i})}return e}transformComponentImportsToGlobal(e){let t=[];for(let n of e.matchAll(pt)){let[e,r,i]=n;if(!i.startsWith(`.`)&&!i.startsWith(`@`)&&!i.startsWith(`~`)&&!i.startsWith(`#`))continue;let a=null;if(i.startsWith(`.`)){if(i.includes(`/components/`)){let n=i.match(_t);if(n){let i=n[1],a=[D.resolve(this.projectRoot,`src`,`components`,`${i}.tsx`),D.resolve(this.projectRoot,`src`,`components`,`${i}.ts`),D.resolve(this.projectRoot,`src`,`components`,`${i}.jsx`),D.resolve(this.projectRoot,`src`,`components`,`${i}.js`)],o=!1;for(let e of a)if(T.existsSync(e)&&this.isClientComponent(e)){o=!0;break}if(!o)continue;let s=`// Component reference: ${i}
|
|
1
|
+
import{RariRequest as e}from"./proxy/RariRequest.mjs";import{RariResponse as t}from"./proxy/RariResponse.mjs";import{_ as n,c as r,d as i,f as a,g as o,h as s,i as c,m as l,p as u,u as d}from"./runtime-client-DHeO6y_7.mjs";import{i as f,n as p,o as m,r as h,t as g}from"./constants-De7aSsCq.mjs";import{_,a as v,d as y,g as b,i as x,m as S,r as ee,t as C,v as te}from"./regex-constants-s9cBkrFv.mjs";import{t as ne}from"./timer-utils-Duul5JHq.mjs";import{t as re}from"./alias-resolver-BintHkb_.mjs";import{Buffer as ie}from"node:buffer";import{spawn as ae}from"node:child_process";import w,{promises as T}from"node:fs";import E from"node:path";import D from"node:process";import{fileURLToPath as O,pathToFileURL as k}from"node:url";import oe from"node:crypto";import A from"node:fs/promises";import{build as j}from"rolldown";var se=Object.defineProperty,ce=(e,t)=>{let n={};for(var r in e)se(n,r,{get:e[r],enumerable:!0});return t||se(n,Symbol.toStringTag,{value:`Module`}),n};function le(e={}){let{root:t=D.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=E.join(t,n);try{return await T.access(i),s(`Found proxy file: ${n}`),{filePath:i,exists:!0,relativePath:n}}catch{}}let e=E.join(t,n);try{await T.access(e);for(let t of i){let i=`${r}${t}`,a=E.join(e,i);try{return await T.access(a),s(`Found proxy file: ${E.join(n,i)}`),{filePath:a,exists:!0,relativePath:E.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 ue=/export\s+const\s+metadata\s*(?::\s*\w+\s*)?=\s*(\{[\s\S]*?\n\})/,de=/title\s*:\s*['"]([^'"]+)['"]/,fe=/description\s*:\s*['"]([^'"]+)['"]/,pe=/keywords\s*:\s*\[([\s\S]*?)\]/,me={appDir:`src/app`,extensions:[`.tsx`,`.jsx`,`.ts`,`.js`],outDir:`dist`};function M(e){switch(E.basename(e).replace(_,``)){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 he(e,t){let n=E.relative(t,E.dirname(e));return!n||n===`.`?`/`:`/${n.replace(C,`/`).split(`/`).filter(Boolean).join(`/`)}`}function ge(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 _e(e){try{let t=e.match(ue);if(!t)return null;let n=t[1],r={},i=n.match(de);i&&(r.title=i[1]);let a=n.match(fe);a&&(r.description=a[1]);let o=n.match(pe);o&&(r.keywords=o[1].split(`,`).map(e=>e.trim().replace(b,``)).filter(Boolean));for(let e of[`author`,`viewport`,`themeColor`,`robots`,`openGraph`,`twitter`]){let t=RegExp(`${e}\\s*:\\s*['"]([^'"]+)['"]`,`m`),i=n.match(t);i&&(r[e]=i[1])}return Object.keys(r).length>0?r:null}catch(e){return console.error(`[rari] Router: Failed to extract metadata:`,e),null}}function ve(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 ye(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 be(e={}){let t={...me,...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 T.readdir(e,{withFileTypes:!0});for(let a of i){let i=E.join(e,a.name);a.isDirectory()?await r(i):a.isFile()&&t.extensions.some(e=>a.name.endsWith(e))&&M(i)&&n.add(i)}}catch{}};return await r(e),n},c=async(e,r=!1)=>{let c=E.resolve(e,t.appDir);try{await T.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 Promise.resolve().then(()=>fn),f=await d(c,{extensions:t.extensions}),p=JSON.stringify(f,null,2),m=E.resolve(e,t.outDir);await T.mkdir(m,{recursive:!0});let h=E.join(m,`server`);return await T.mkdir(h,{recursive:!0}),await T.writeFile(E.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=E.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=M(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||D.cwd(),!0)},configureServer(e){l(e)},async handleHotUpdate(e){let{file:i,server:o}=e,s=E.resolve(o.config.root,t.appDir);if(i.startsWith(s)&&t.extensions.some(e=>i.endsWith(e))){let e=M(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=he(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=ge(d,e,f),m,h=!1,g;if(e===`page`||e===`layout`)try{let e=_e(await T.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=ve(await T.readFile(i,`utf-8`)),await ye(E.relative(s,i))}catch(e){console.error(`[rari] Router: Failed to detect HTTP methods:`,e)}let _={fileType:e,filePath:E.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();let e=u||D.cwd(),n=E.resolve(e,t.outDir,`server`),i=E.join(n,`routes.json`);try{let t=await T.readFile(i,`utf-8`),n=JSON.parse(t),r=!1;for(let t of n.routes){if(!t.isDynamic)continue;let n=t.filePath.replace(/\[\.\.\.([^\]]+)\]/g,`____$1_`).replace(/\[([^\]]+)\]/g,`_$1_`).replace(/\.tsx?$/,`.js`),i=E.resolve(e,`dist`,`server`,`app`,n);try{let e=await import(i);if(typeof e.generateStaticParams==`function`){let n=await e.generateStaticParams();Array.isArray(n)&&n.length>0&&(t.staticParams=n,r=!0)}}catch{}}r&&await T.writeFile(i,JSON.stringify(n,null,2),`utf-8`)}catch{}}}}const xe=/\\/g,Se=/[^\w/-]/g,Ce=/^src\//,we=/\.(tsx?|jsx?)$/,Te=/^\.\.(?:[/\\]|$)/;function Ee(e,t=8){return oe.createHash(`sha256`).update(e).digest(`hex`).slice(0,t)}function De(e,t=D.cwd()){let n=E.isAbsolute(e)?e:E.resolve(t,e),r=E.relative(t,n);return(Te.test(r)||E.isAbsolute(r)?e:r).replace(xe,`/`)}function Oe(e){return e.replace(we,``).replace(Se,`_`).replace(Ce,``)}function N(e,t=D.cwd()){let n=De(e,t);return`${Oe(n)}_${Ee(n)}`}const ke=new Set([`return`,`throw`,`case`,`typeof`,`instanceof`,`new`,`delete`,`void`,`in`,`of`]);function P(e){return e===` `||e===` `||e===`\r`||e===`
|
|
2
|
+
`||e===`\u2028`||e===`\u2029`||e===``}function F(e){return e===`\r`||e===`
|
|
3
|
+
`||e===`\u2028`||e===`\u2029`}function Ae(e,t,n){for(;t<n&&P(e[t]);)t++;return t}function I(e,t,n){for(;t<n;){let r=Ae(e,t,n);if(r!==t){t=r;continue}if(e[t]===`/`&&e[t+1]===`/`){t=L(e,t,n);continue}if(e[t]===`/`&&e[t+1]===`*`){t=R(e,t,n);continue}break}return t}function L(e,t,n){for(;t<n&&!F(e[t]);)t++;return t}function R(e,t,n){for(t+=2;t<n-1&&(e[t]!==`*`||e[t+1]!==`/`);)t++;return t+2}function z(e,t,n,r){for(t++;t<n;){if(e[t]===`\\`){t+=2;continue}if(e[t]===r)return t+1;t++}return t}function je(e,t,n){t++;let r=e[t]===`/`;for(r&&t++;t<n&&(H(e[t])||e[t]===`.`||e[t]===`-`);)t++;let i=+!r;for(;t<n&&i>0;){let a=e[t]===`'`||e[t]===`"`||e[t]==="`"?e[t]:null;if(a){t=z(e,t,n,a);continue}if(e[t]===`{`){t++;let r=1;for(;t<n&&r>0;){let i=e[t]===`'`||e[t]===`"`||e[t]==="`"?e[t]:null;if(i){t=z(e,t,n,i);continue}e[t]===`{`&&r++,e[t]===`}`&&r--,t++}continue}if(e[t]===`/`&&e[t+1]===`>`){i--,t+=2;continue}if(e[t]===`>`){t++,r&&i--;continue}if(e[t]===`<`){let r=e[t+1];if(r===`/`||r===`.`||r===`>`||U(r)){for(r===`/`?(i--,t++):r!==`!`&&i++,t++;t<n&&(H(e[t])||e[t]===`.`||e[t]===`-`);)t++;continue}t++;continue}t++}return t}function Me(e,t){let n=0,r=e.length;for(;n<r;){if(P(e[n])){n++;continue}if(e[n]===`/`&&e[n+1]===`/`){n=L(e,n,r);continue}if(e[n]===`/`&&e[n+1]===`*`){n=R(e,n,r);continue}let i=e[n]===`'`||e[n]===`"`?e[n]:null;if(i){let a=n+1,o=z(e,n,r,i);if(o>a){let i=e.slice(a,o-1),s=o;for(;s<r;){if(P(e[s])&&!F(e[s])){s++;continue}if(F(e[s])||e[s]===`;`){if(i===t)return!0;n=s+1;break}if(e[s]===`/`&&e[s+1]===`/`){s=L(e,s,r);continue}if(e[s]===`/`&&e[s+1]===`*`){s=R(e,s,r);continue}return!1}if(s>=r)return i===t;if(s<r&&(F(e[s])||e[s]===`;`))continue;return!1}}return!1}return!1}function B(e){return Me(e,`use server`)}function V(e){return Me(e,`use client`)}function H(e){return!!e&&(e>=`a`&&e<=`z`||e>=`A`&&e<=`Z`||e>=`0`&&e<=`9`||e===`_`||e===`$`)}function U(e){return!!e&&(e>=`a`&&e<=`z`||e>=`A`&&e<=`Z`||e===`_`||e===`$`)}function Ne(e){return!e||e===`(`||e===`[`||e===`{`||e===`,`||e===`;`||e===`=`||e===`:`||e===`?`||e===`!`||e===`+`||e===`-`||e===`*`||e===`%`||e===`&`||e===`|`||e===`^`||e===`~`||e===`<`||e===`>`}function Pe(e,t){let n=t-1;for(;n>=0;){if(P(e[n])){n--;continue}if(n>=1&&e[n]===`/`&&e[n-1]===`*`){for(n-=2;n>=1;){if(e[n]===`*`&&e[n-1]===`/`){n-=2;break}n--}if(n<0)return;continue}if(n>=1&&e[n]===`/`&&e[n-1]===`/`){n-=2;continue}let t=n;for(;t>=0&&e[t]!==`
|
|
4
|
+
`&&e[t]!==`\r`;)t--;let r=t+1;for(;r<n&&(e[r]===` `||e[r]===` `);)r++;if(r<n&&e[r]===`/`&&e[r+1]===`/`){n=r-1;continue}break}if(n<0||!H(e[n]))return;let r=n;for(;n>=0&&H(e[n]);)n--;return e.slice(n+1,r+1)}function Fe(e,t){if(Ne(Le(e,t)))return!0;let n=Pe(e,t);return n?ke.has(n):!1}function Ie(e,t,n){t++;let r=!1;for(;t<n;){if(e[t]===`\\`){t+=2;continue}if(r){e[t]===`]`&&(r=!1),t++;continue}if(e[t]===`[`){r=!0,t++;continue}if(e[t]===`/`){for(t++;t<n&&H(e[t]);)t++;return t}if(F(e[t]))return t;t++}return t}function Le(e,t){let n=t-1;for(;n>=0;){if(P(e[n])){n--;continue}if(n>=1&&e[n]===`/`&&e[n-1]===`*`){for(n-=2;n>=1;){if(e[n]===`*`&&e[n-1]===`/`){n-=2;break}n--}if(n<0)return;continue}if(n>=1&&e[n]===`/`&&e[n-1]===`/`){n-=2;continue}let t=n;for(;t>=0&&e[t]!==`
|
|
5
|
+
`&&e[t]!==`\r`;)t--;let r=t+1;for(;r<n&&(e[r]===` `||e[r]===` `);)r++;if(r<n&&e[r]===`/`&&e[r+1]===`/`){n=r-1;continue}return e[n]}}function W(e){let t=0,n=e.length;for(;t<n;){if(P(e[t])){t++;continue}if(e[t]===`/`&&e[t+1]===`/`){t=L(e,t,n);continue}if(e[t]===`/`&&e[t+1]===`*`){t=R(e,t,n);continue}let r=e[t]===`'`||e[t]===`"`||e[t]==="`"?e[t]:null;if(r){t=z(e,t,n,r);continue}if(e[t]===`/`&&e[t+1]!==`/`&&e[t+1]!==`*`&&Fe(e,t)){t=Ie(e,t,n);continue}if(e[t]===`<`){let r=e[t+1];if(r===`/`||r===`.`||r===`>`||U(r)){t=je(e,t,n);continue}t++;continue}if(e.slice(t,t+6)===`export`){let r=t+6;if(r<n&&(P(e[r])||e[r]===`{`||e[r]===`/`&&(e[r+1]===`/`||e[r+1]===`*`))){let t=I(e,r,n);if(e.slice(t,t+7)==="default"){let r=t+7;if(r>=n||!H(e[r]))return!0}if(e[t]===`{`){let r=t+1;for(;r<n&&(r=I(e,r,n),e[r]!==`}`);){let t=r;for(;r<n&&H(e[r]);)r++;let i=e.slice(t,r);if(!i)break;r=I(e,r,n);let a=!1;if(e.slice(r,r+2)===`as`){a=!0;let t=r+2;if(t<n&&!H(e[t])){r=I(e,t,n);let i=r;for(;r<n&&H(e[r]);)r++;if(e.slice(i,r)==="default")return!0}}if(!a&&i==="default")return!0;if(e[r]===`,`){r++;continue}if(e[r]===`}`)break;r++}}}}t++}return!1}function Re(e,t){let n=null;for(let r of t)if(e.endsWith(r)&&(n??=w.existsSync(e),n))return e;for(let n of t){let t=`${e}${n}`;if(w.existsSync(t))return t}return null}function G(e,t){if(w.existsSync(e)){if(!w.statSync(e).isDirectory())return null;for(let n of t){let t=E.join(e,`index${n}`);if(w.existsSync(t))return t}}return null}var ze=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=ne(this.resetTimer),this.resetTimer=setTimeout(()=>{this.reset()},this.resetTimeout),this.errorCount>=this.maxErrors&&this.handleMaxErrorsReached()}reset(){this.errorCount=0,this.lastError=null,this.resetTimer=ne(this.resetTimer)}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.reset()}};const Be=/^(["'])use client\1\s*(?:;\s*)?(?:\/\/.*)?$/;var Ve=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 ze({maxErrors:5,resetTimeout:3e4})}getErrorCount(){return this.errorHandler.getErrorCount()}async handleClientComponentUpdate(e,t){let n=E.relative(D.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=this.collectDependentPageComponents(e);for(let e of n)this.serverComponentBuilder.invalidateBuildCacheFor(e);let r=[...e,...n],i=await Promise.allSettled(r.map(async e=>{let t=E.relative(D.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))}}})),a=[],o=[];if(i.forEach(e=>{e.status===`fulfilled`&&e.value.success?a.push(e.value):e.status===`fulfilled`&&!e.value.success?o.push(e.value):e.status===`rejected`&&o.push({filePath:``,relativePath:`unknown`,error:Error(String(e.reason))})}),a.length>0){let e=Date.now();a.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(o.length>0){let e=Date.now();o.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})});await d(n);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}}collectDependentPageComponents(e){let t=this.serverComponentBuilder.getImportGraph(),n=new Set,r=new Set,i=a=>{if(r.has(a))return;r.add(a);let o=t.get(a);if(o)for(let t of o)(t.includes(`/app/`)||t.includes(`\\app\\`))&&!e.includes(t)&&n.add(t),i(t)};for(let t of e)i(t);return[...n]}detectComponentType(e){try{let t=w.readFileSync(e,`utf-8`).split(`
|
|
6
|
+
`),n=!1;function r(e){return Be.test(e.trim())}function i(e){let t=e;for(;t.includes(`/*`)&&t.includes(`*/`);){let e=t.indexOf(`/*`),n=t.indexOf(`*/`,e);if(n===-1)break;t=t.substring(0,e)+t.substring(n+2)}if(t.includes(`/*`)){let e=t.indexOf(`/*`);t=t.substring(0,e)}return t}for(let e of t){let t=e.trim();if(n){if(t.includes(`*/`)){n=!1;let e=t.substring(t.indexOf(`*/`)+2).trim();if(!e||e.startsWith(`//`))continue;let a=i(e).trim();if(!a||a.startsWith(`//`))continue;if(r(a))return`client`;break}continue}if(!(!t||t.startsWith(`//`))){if(t.includes(`/*`))if(t.includes(`*/`)){let e=i(t).trim();if(!e||e.startsWith(`//`))continue;if(r(e))return`client`;break}else{let e=t.substring(0,t.indexOf(`/*`)).trim();if(e){if(r(e))return`client`;break}n=!0;continue}if(r(t))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(`
|
|
7
|
+
• `);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 He=/import\s+(\w+)\s+from\s+['"]rari\/image['"]/g,Ue=/import\s+\{[^}]*\b(?:Image\s+as\s+(\w+)|Image)\b[^}]*\}\s+from\s+['"]rari\/image['"]/g,We=/src:\s*["']([^"']+)["']/,Ge=/[.*+?^${}()|[\]\\]/g,Ke=/^[A-Z_$][\w$]*$/i,qe=/width:\s*(\d+)/,Je=/quality:\s*(\d+)/,Ye=/preload:\s*(true|!0)/,Xe=/preload:\s*(false|!1)/,Ze=/src=\{?["']([^"']+)["']\}?|src=\{([^}]+)\}/,Qe=/width=\{?(\d+)\}?/,$e=/quality=\{?(\d+)\}?/,et=/preload(?:=\{?true\}?)?/,tt=/preload=\{?false\}?/;async function nt(e,t){try{await mt(await A.readFile(e,`utf8`),e,t)}catch(t){t.code!==`ENOENT`&&console.warn(`[rari] Image scanner: Failed to process ${e}:`,t)}}const rt=new class{permits;queue=[];constructor(e){this.permits=e}async acquire(){if(this.permits>0){this.permits--;return}return new Promise(e=>{this.queue.push(e)})}release(){this.permits++;let e=this.queue.shift();e&&(this.permits--,e())}async run(e){await this.acquire();try{return await e()}finally{this.release()}}}(50);async function K(e,t){try{await A.access(e)}catch{return}let n=await A.readdir(e,{withFileTypes:!0}),r=[];for(let i of n){let n=E.join(e,i.name);if(i.isDirectory()){if(i.name===`node_modules`||i.name===`dist`)continue;r.push(K(n,t))}else i.isFile()&&_.test(i.name)&&r.push(rt.run(()=>nt(n,t)))}await Promise.all(r)}async function it(e,t=[]){let n=new Map;try{await A.access(e),await K(e,n)}catch(t){throw t.code===`ENOENT`?Error(`Required source directory does not exist: ${e}`):t}for(let e of t)try{await A.access(e),await K(e,n)}catch(t){t.code!==`ENOENT`&&console.warn(`[rari] Image scanner: Failed to scan directory ${e}:`,t)}return{images:[...n.values()]}}function at(e){return e.endsWith(`.tsx`)?`tsx`:e.endsWith(`.jsx`)?`jsx`:e.endsWith(`.ts`)?`ts`:`js`}async function ot(e,t,n){let r=`\0virtual:${t}`,i=await j({input:r,external:[`rari/image`],platform:`browser`,write:!1,output:{format:`esm`},moduleTypes:{[`.${n}`]:n},transform:{jsx:`react`},plugins:[{name:`virtual-module`,resolveId(e){return e===r?e:null},load(t){return t===r?{code:e,moduleType:n}:null}}]});if(!i.output||i.output.length===0)throw Error(`Transform produced no output`);return i.output[0].code}function st(e){let t=new Set;for(let n of e.matchAll(He))t.add(n[1]);for(let n of e.matchAll(Ue))n[1]?t.add(n[1]):t.add(`Image`);return t}function ct(e){return st(e)}function lt(e){let t=e.match(We);if(!t)return null;let n=t[1];if(!n.startsWith(`/`)&&!n.startsWith(`http`))return null;let r=e.match(qe),i=r?Number.parseInt(r[1],10):void 0,a=e.match(Je),o=a?Number.parseInt(a[1],10):void 0,s=e.match(Ye),c=e.match(Xe);return{src:n,width:i,quality:o,preload:!!s&&!c}}function ut(e,t){let n=`${e.src}:${e.width??`auto`}:${e.quality??75}`;(!t.has(n)||e.preload)&&t.set(n,e)}function dt(e,t){let n=0,r=!1,i=``,a=!1,o=0;for(let s=t;s<e.length;s++){let c=e[s];if(a){a=!1;continue}if(c===`\\`){a=!0;continue}if(!r&&(c===`"`||c===`'`||c==="`")){r=!0,i=c,c==="`"&&(o=1);continue}if(r&&c===i){i==="`"?(o--,o===0&&(r=!1,i=``)):(r=!1,i=``);continue}if(r&&i==="`"&&c===`$`&&s+1<e.length&&e[s+1]===`{`){n++,s++;continue}if(r&&i==="`"&&n>0&&c==="`"){o++;continue}if(r&&i==="`"&&c===`}`&&n>0){n--;continue}if(!r){if(c===`{`)n++;else if(c===`}`&&(n--,n===0))return e.substring(t+1,s)}}return null}function ft(e,t,n){for(let r of t){if(!Ke.test(r)){console.warn(`[rari] Image scanner: Skipping unsafe identifier: ${r}`);continue}let t=r.replace(Ge,`\\$&`),i=RegExp(`React\\.createElement\\(\\s*${t}\\s*,\\s*\\{`,`g`);for(let t of e.matchAll(i)){let r=dt(e,t.index+t[0].length-1);if(r){let e=lt(r);e&&ut(e,n)}}}}function pt(e){return st(e)}async function mt(e,t,n){let r=pt(e);if(r.size!==0)try{let r=await ot(e,t,at(t)),i=ct(r);if(i.size===0)return;ft(r,i,n)}catch{ht(e,r,n)}}function ht(e,t,n){for(let r of t){if(!Ke.test(r)){console.warn(`[rari] Image scanner: Skipping unsafe alias: ${r}`);continue}let t=r.replace(Ge,`\\$&`),i=RegExp(`<${t}\\s([^/>]+)\\/>`,`g`),a=RegExp(`<${t}\\s([^>]+)>`,`g`);for(let t of e.matchAll(i))gt(t[1],n);for(let t of e.matchAll(a))gt(t[1],n)}}function gt(e,t){let n=e.match(Ze);if(!n)return;let r=n[1]||n[2];if(!r||r.includes(`{`)||!r.startsWith(`/`)&&!r.startsWith(`http`))return;let i=e.match(Qe),a=i?Number.parseInt(i[1],10):void 0,o=e.match($e),s=o?Number.parseInt(o[1],10):void 0,c=et.test(e)&&!tt.test(e),l=`${r}:${a??`auto`}:${s??75}`;(!t.has(l)||c)&&t.set(l,{src:r,width:a,quality:s,preload:c})}var _t=ce({RARI_CSS_MODULES_PATTERN:()=>Y,ServerComponentBuilder:()=>Ot,createServerBuildPlugin:()=>kt,scanDirectory:()=>X});const vt=/import\s*\(\s*["']([^"']+)["']\s*\)|import\s+["']([^"']+)["']/g,q=/from\s+['"]([^'"]+)['"]|import\s*\(\s*['"]([^'"]+)['"]\s*\)|import\s+['"]([^'"]+)['"]/g,yt=/import(?:\s+(?:\w+|\{[^}]*\}|\*\s+as\s+\w+)(?:\s*,\s*(?:\w+|\{[^}]*\}|\*\s+as\s+\w+))*\s+from\s+)?['"]([^'"]+)['"]/g,bt=/import\s+(\w+)\s+from\s+['"]([^'"]+)['"]/g,xt=/import\s+(?:(\w+)|\{([^}]+)\})\s+from\s+['"]([^'"]+)['"];?\s*$/gm,St=/^proxy\.(?:tsx?|jsx?|mts|mjs)$/,Ct=/\\/g,wt=/\/components\/(\w+)(?:\.tsx?|\.jsx?)?$/,Tt=/[/\\]components[/\\](\w+)(?:\.tsx?|\.jsx?)?$/,Et=/^(?:robots|sitemap)\.(?:tsx?|jsx?)$/,Dt=/^node:/,J=/\\/g,Y=`[hash]_[local]`;var Ot=class{serverComponents=new Map;serverActions=new Map;options;projectRoot;buildCache=new Map;htmlOnlyImports=new Set;fileImporters=new Map;getComponentCount(){return this.serverComponents.size+this.serverActions.size}getImportGraph(){let e=new Map;for(let[t,n]of this.fileImporters)e.set(t,new Set(n));return e}getHtmlOnlyImports(){return new Set(this.htmlOnlyImports)}hashString(e,t=8){return Ee(e,t)}async writeComponentCssAsset(e,t){if(t.length===0)return[];let n=E.join(this.options.outDir,`assets`,`server`);await w.promises.mkdir(n,{recursive:!0});let r=`${t.join(`
|
|
8
|
+
`)}\n`,i=`${this.hashString(e+r,12)}.css`,a=E.join(n,i);return await w.promises.writeFile(a,r,`utf-8`),[`/assets/server/${i}`]}getComponentIdFromRouteManifestPath(e){return this.getComponentId(E.join(this.projectRoot,`src`,`app`,e))}getLegacyComponentReferenceId(e){return this.getReadableComponentId(this.getProjectRelativePath(e))}async writeRouteCssEntries(e){let t=E.join(this.options.outDir,this.options.rscDir,`routes.json`);if(!w.existsSync(t))return;let n=await w.promises.readFile(t,`utf-8`),r=JSON.parse(n),i=t=>{if(t)for(let n of t){if(!n.filePath)continue;let t=this.getComponentIdFromRouteManifestPath(n.filePath);n.componentId=t;let r=e.components[t]?.css??[];r.length?n.css=r:delete n.css}};if(i(r.routes),i(r.layouts),i(r.loading),i(r.errors),i(r.notFound),r.apiRoutes)for(let e of r.apiRoutes)e.filePath&&(e.componentId=this.getComponentIdFromRouteManifestPath(e.filePath));await w.promises.writeFile(t,JSON.stringify(r,null,2),`utf-8`)}constructor(e,t={}){this.projectRoot=e;let n=t.rscDir||`server`;this.options={outDir:t.outDir||E.join(e,`dist`),rscDir:n,manifestPath:t.manifestPath||E.join(n,`manifest.json`),serverConfigPath:t.serverConfigPath||E.join(n,`config.json`),minify:t.minify??D.env.NODE_ENV===`production`,alias:t.alias||{},define:t.define,csp:t.csp,cacheControl:t.cacheControl},this.parseHtmlImports()}parseHtmlImports(){let e=E.join(this.projectRoot,`index.html`);if(w.existsSync(e))try{let t=w.readFileSync(e,`utf-8`);for(let e of t.matchAll(vt)){let t=e[1]||e[2];if(t.startsWith(`/src/`)){let e=E.join(this.projectRoot,t.slice(1));this.htmlOnlyImports.add(e)}}}catch(e){console.warn(`[server-build] Error parsing index.html:`,e)}}isHtmlOnlyImport(e){return this.htmlOnlyImports.has(e)}isServerComponent(e,t){if(e.includes(`node_modules`)||this.isHtmlOnlyImport(e))return!1;try{let n=t??(w.existsSync(e)?w.readFileSync(e,`utf-8`):null);return n===null?!1:!V(n)&&!B(n)}catch{return!1}}isClientComponent(e,t){try{let n=t??(w.existsSync(e)?w.readFileSync(e,`utf-8`):null);return n===null?!1:V(n)}catch{return!1}}buildImportGraph(e){this.fileImporters.clear();let t=e=>{if(!w.existsSync(e))return;let n=w.readdirSync(e,{withFileTypes:!0});for(let r of n){let n=E.join(e,r.name);if(r.isDirectory()){if(r.name===`node_modules`)continue;t(n)}else if(r.isFile()&&_.test(r.name))try{let e=w.readFileSync(n,`utf-8`),t;for(q.lastIndex=0,t=q.exec(e);t!==null;){let r=t[1]||t[2]||t[3],i=null;if(r.startsWith(`./`)||r.startsWith(`../`)){let e=E.dirname(n);i=E.resolve(e,r)}else if(r.startsWith(`@/`)){let e=r.slice(2);i=E.join(this.projectRoot,`src`,e)}if(i){let e=[``,`.ts`,`.tsx`,`.js`,`.jsx`],t=null;for(let n of e){let e=i+n;if(w.existsSync(e)&&w.statSync(e).isFile()){t=e;break}}t&&(this.fileImporters.has(t)||this.fileImporters.set(t,new Set),this.fileImporters.get(t).add(n))}t=q.exec(e)}}catch(e){e?.code!==`ENOENT`&&console.warn(`[rari] Unexpected error building import graph:`,n,e)}}};t(e)}isOnlyImportedByClientComponents(e){let t=this.fileImporters.get(e);if(!t||t.size===0)return!1;for(let e of t)if(!this.isClientComponent(e)&&!this.isOnlyImportedByClientComponents(e))return!1;return!0}addServerComponent(e,t){let n=t??w.readFileSync(e,`utf-8`);if(this.isServerAction(n)){let t=this.extractDependencies(n),r=this.hasNodeImports(n);this.serverActions.set(e,{filePath:e,originalCode:n,dependencies:t,hasNodeImports:r});return}if(!this.isServerComponent(e,n))return;let r=this.extractDependencies(n),i=this.hasNodeImports(n);this.serverComponents.set(e,{filePath:e,originalCode:n,dependencies:r,hasNodeImports:i})}isServerAction(e){return B(e)}extractDependencies(e){let t=[],n;for(yt.lastIndex=0;n=yt.exec(e),n!==null;){let e=n[1];!e.startsWith(`.`)&&!e.startsWith(`/`)&&!e.startsWith(`node:`)&&!this.isNodeBuiltin(e)&&t.push(e)}return[...new Set(t)]}isNodeBuiltin(e){return[`fs`,`path`,`os`,`crypto`,`util`,`stream`,`events`,`process`,`buffer`,`url`,`querystring`,`zlib`,`http`,`https`,`net`,`tls`,`child_process`,`cluster`,`worker_threads`].includes(e)}hasNodeImports(e){return e.includes(`from 'node:`)||e.includes(`from "node:`)||e.includes(`from 'fs'`)||e.includes(`from "fs"`)||e.includes(`from 'path'`)||e.includes(`from "path"`)||e.includes(`from 'os'`)||e.includes(`from "os"`)||e.includes(`from 'crypto'`)||e.includes(`from "crypto"`)||e.includes(`from 'util'`)||e.includes(`from "util"`)||e.includes(`from 'stream'`)||e.includes(`from "stream"`)||e.includes(`from 'events'`)||e.includes(`from "events"`)}async getTransformedComponentsForDevelopment(){let e=[];for(let[t]of this.serverComponents){let n=E.relative(this.projectRoot,t),r=this.getComponentId(n),i=await this.buildComponentCodeOnly(t);e.push({id:r,code:i})}for(let[t]of this.serverActions){let n=E.relative(this.projectRoot,t),r=this.getComponentId(n),i=await this.buildComponentCodeOnly(t);e.push({id:r,code:i})}return e}transformComponentImportsToGlobal(e){let t=[];for(let n of e.matchAll(bt)){let[e,r,i]=n;if(!i.startsWith(`.`)&&!i.startsWith(`@`)&&!i.startsWith(`~`)&&!i.startsWith(`#`))continue;let a=null;if(i.startsWith(`.`)){if(i.includes(`/components/`)){let n=i.match(wt);if(n){let i=n[1],a=[E.resolve(this.projectRoot,`src`,`components`,`${i}.tsx`),E.resolve(this.projectRoot,`src`,`components`,`${i}.ts`),E.resolve(this.projectRoot,`src`,`components`,`${i}.jsx`),E.resolve(this.projectRoot,`src`,`components`,`${i}.js`)],o=!1;for(let e of a)if(w.existsSync(e)&&this.isClientComponent(e)){o=!0;break}if(!o)continue;let s=`// Component reference: ${i}
|
|
8
9
|
const ${r} = (props) => {
|
|
9
10
|
let Component = globalThis['~clientComponents']?.['components/${i}']?.component
|
|
10
11
|
|| globalThis['components/${i}'];
|
|
@@ -22,25 +23,25 @@ const ${r} = (props) => {
|
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
return Component(props);
|
|
25
|
-
}`;t.push({original:e,replacement:s})}}continue}let o=this.options.alias||{};for(let[e,t]of Object.entries(o))if(i.startsWith(`${e}/`)||i===e){let n=i.slice(e.length);a=
|
|
26
|
+
}`;t.push({original:e,replacement:s})}}continue}let o=this.options.alias||{};for(let[e,t]of Object.entries(o))if(i.startsWith(`${e}/`)||i===e){let n=i.slice(e.length);a=E.join(t,n);break}if(a){let n=a.match(Tt);if(n){let i=n[1],o=E.isAbsolute(a)?a:E.resolve(this.projectRoot,a),s=[o,`${o}.tsx`,`${o}.ts`,`${o}.jsx`,`${o}.js`],c=!1,l=o;for(let e of s)if(w.existsSync(e)){l=e,this.isClientComponent(e)&&(c=!0);break}if(!c)continue;let u=this.getLegacyComponentReferenceId(l),d=`// Component reference: ${i}
|
|
26
27
|
const ${r} = (props) => {
|
|
27
|
-
let Component = globalThis['~clientComponents']?.['${
|
|
28
|
-
|| globalThis['${
|
|
28
|
+
let Component = globalThis['~clientComponents']?.['${u}']?.component
|
|
29
|
+
|| globalThis['${u}'];
|
|
29
30
|
|
|
30
31
|
if (Component && typeof Component === 'object' && Component.default) {
|
|
31
32
|
Component = Component.default;
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
if (!Component) {
|
|
35
|
-
throw new Error('Component ${
|
|
36
|
+
throw new Error('Component ${u} not loaded');
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
if (typeof Component !== 'function') {
|
|
39
|
-
throw new Error('Component ${
|
|
40
|
+
throw new Error('Component ${u} is not a function, got: ' + typeof Component);
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
return Component(props);
|
|
43
|
-
}`;t.push({original:e,replacement:
|
|
44
|
+
}`;t.push({original:e,replacement:d})}}}let n=e;for(let{original:e,replacement:r}of t)n=n.replace(e,r);return n}isPageComponent(e){return e.includes(`/app/`)||e.includes(`\\app\\`)}createBuildPlugins(e,t,n,r,i=!1,a){let o=E.dirname(r),s=St.test(E.basename(r)),c=this,l=new Map,u=new Map;return[{name:`virtual-module`,resolveId(t,n){if(t===e)return t;if(n===e&&(t.startsWith(`./`)||t.startsWith(`../`))){if(t.endsWith(`.module.css`))return null;let e=E.resolve(o,t);for(let t of[`.ts`,`.tsx`,`.js`,`.jsx`,``]){let n=e+t;if(w.existsSync(n)&&w.statSync(n).isFile())return n}for(let t of[`.ts`,`.tsx`,`.js`,`.jsx`]){let n=E.join(e,`index${t}`);if(w.existsSync(n))return n}return e}return null},load(r){return r===e?{code:t,moduleType:n}:null}},{name:`resolve-client-server-boundaries`,resolveId:(t,n)=>{if(!n||n.includes(`node_modules`)||n.includes(`/packages/rari/dist`)||t.startsWith(`node:`)||c.isNodeBuiltin(t)||t===`react`||t===`react-dom`||t===`react/jsx-runtime`||t===`react/jsx-dev-runtime`)return null;let r=null;if(r=re(t,c.options.alias||{},c.projectRoot),!r&&(t.startsWith(`./`)||t.startsWith(`../`))){let i=n===e?o:E.dirname(n);r=E.resolve(i,t)}if(r)for(let e of[``,`.ts`,`.tsx`,`.js`,`.jsx`]){let t=r+e;if(w.existsSync(t)&&w.statSync(t).isFile()){if(c.isClientComponent(t)){let e=E.relative(c.projectRoot,t),n=(e.startsWith(`..`)?t:e).replace(J,`/`);return l.set(t,n),{id:`\0client-ref:${t}`}}try{let e=w.readFileSync(t,`utf-8`);if(B(e)){let n=c.getComponentId(t),r=W(e);return u.set(t,{actionId:n,hasDefaultExport:r}),{id:`\0server-action:${t}`}}}catch(e){console.error(`[rari] Failed to read file for server action detection: ${t}`,e)}break}}return null},load(e){if(e.startsWith(`\0client-ref:`)){let t=e.slice(12),n=E.relative(c.projectRoot,t),r=(l.get(t)||(n.startsWith(`..`)?t:n)).replace(J,`/`);return{code:`
|
|
44
45
|
function registerClientReference(clientReference, id, exportName) {
|
|
45
46
|
const key = id + '#' + exportName;
|
|
46
47
|
const clientProxy = {};
|
|
@@ -60,7 +61,7 @@ function registerClientReference(clientReference, id, exportName) {
|
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
export default registerClientReference(null, ${JSON.stringify(r)}, "default");
|
|
63
|
-
`,moduleType:`js`}}if(e.startsWith(`\0server-action:`)){let t=e.slice(15),n=
|
|
64
|
+
`,moduleType:`js`}}if(e.startsWith(`\0server-action:`)){let t=e.slice(15),n=u.get(t)?.actionId??c.getComponentId(t),r=E.join(c.options.outDir,c.options.rscDir,`${n}.js`),i=k(E.resolve(c.projectRoot,r)).href;return{code:u.get(t)?.hasDefaultExport??!1?`export * from ${JSON.stringify(i)};\nexport { default } from ${JSON.stringify(i)};`:`export * from ${JSON.stringify(i)};`,moduleType:`js`}}return null}},{name:`use-transformed-server-components`,resolveId:(e,t)=>{if(!i)return null;if(e.startsWith(`file://`)){let t=e.replace(v,``);return w.existsSync(t)?{id:`\0transformed:${t}`}:null}let n=null;n=re(e,c.options.alias||{},c.projectRoot);let r=t?.startsWith(`\0`)?o:t?E.dirname(t):o;if(!n&&(e.startsWith(`./`)||e.startsWith(`../`))&&(n=E.resolve(r,e)),!n||r.includes(`node_modules`))return null;for(let e of[``,`.ts`,`.tsx`,`.js`,`.jsx`]){let t=n+e;if(w.existsSync(t)&&w.statSync(t).isFile()){if(c.isClientComponent(t))return null;let e=E.join(c.projectRoot,`src`);if(!t.startsWith(e))return null;let n=c.getComponentId(t),r=E.join(c.options.outDir,c.options.rscDir,`${n}.js`);if(w.existsSync(r))return{id:`\0transformed:${r}`};break}}return null},load(e){if(e.startsWith(`\0transformed:`)){let t=e.slice(13);return{code:w.readFileSync(t,`utf-8`),moduleType:`js`}}return null}},{name:`resolve-aliases`,resolveId:e=>{if(e.startsWith(`\0`))return null;let t=c.options.alias||{};for(let[n,r]of Object.entries(t))if(e.startsWith(`${n}/`)||e===n){let t=e.slice(n.length),i=E.join(r,t),a=E.isAbsolute(i)?i:E.resolve(c.projectRoot,i);for(let e of[``,`.ts`,`.tsx`,`.js`,`.jsx`]){let t=a+e;if(w.existsSync(t)&&w.statSync(t).isFile())return t}for(let e of[`.ts`,`.tsx`,`.js`,`.jsx`]){let t=E.join(a,`index${e}`);if(w.existsSync(t))return t}return a}return null}},{name:`resolve-rari-proxy`,resolveId:e=>{if(s&&e===`rari`){let e=E.resolve(c.projectRoot,`node_modules/rari/dist/proxy/RariResponse.mjs`);if(w.existsSync(e))return e;let t=E.resolve(c.projectRoot,`node_modules/rari/src/proxy/RariResponse.ts`);if(w.existsSync(t))return t}return null}},{name:`css-modules`,resolveId:(e,t)=>{if(e.endsWith(`.module.css`)){let n=!t?.startsWith(`\0`)&&t?E.dirname(t):o,r=E.resolve(n,e);if(w.existsSync(r))return{id:`\0css-module:${r}`}}return null},load:async e=>{if(!e.startsWith(`\0css-module:`))return null;let t=e.slice(12);try{let{transform:e}=await import(`lightningcss`),n=w.readFileSync(t),r=e({filename:E.relative(this.projectRoot,t),code:n,cssModules:{pattern:Y}});a&&a.push(new TextDecoder().decode(r.code));let i={};if(r.exports)for(let[e,t]of Object.entries(r.exports))i[e]=t.name;return{code:`export default ${JSON.stringify(i)}`,moduleType:`js`}}catch(t){throw Error(`[rari] Failed to process CSS module ${e}: ${t instanceof Error?t.message:String(t)}`)}}},{name:`externalize-deps`,resolveId:e=>e.startsWith(`\0`)?null:e.startsWith(`node:`)||c.isNodeBuiltin(e)||[`react`,`react-dom`,`react/jsx-runtime`,`react/jsx-dev-runtime`,`rari/image`].includes(e)?{id:e,external:!0}:e===`rari`||e===`rari/client`?null:!e.startsWith(`.`)&&!e.startsWith(`/`)?{id:e,external:!0}:null}]}async buildComponentCodeOnly(e){let t=await w.promises.readFile(e,`utf-8`),n=this.transformClientImports(t,e),r=this.isPageComponent(e),i=r?this.transformComponentImportsToGlobal(n):n,a=E.extname(e),o;o=a===`.tsx`?`tsx`:a===`.ts`?`ts`:a===`.jsx`?`jsx`:`js`;let s=`\0virtual:${e}`,c=await j({input:s,platform:`node`,write:!1,external:[Dt,`react`,`react-dom`,`react/jsx-runtime`,`react/jsx-dev-runtime`],output:{format:`esm`,minify:this.options.minify},moduleTypes:{[`.${o}`]:o},resolve:{mainFields:[`module`,`main`],conditionNames:[`import`,`module`,`default`],extensions:[`.ts`,`.tsx`,`.js`,`.jsx`]},transform:{jsx:`react`,define:{global:`globalThis`,"process.env.NODE_ENV":JSON.stringify(D.env.NODE_ENV||`production`),...this.options.define}},plugins:this.createBuildPlugins(s,i,o,e,r,[])});if(!c.output||c.output.length===0)throw Error(`No output generated from Rolldown`);let l=c.output.find(e=>e.type===`chunk`&&e.isEntry);if(!l||l.type!==`chunk`)throw Error(`No entry chunk found in Rolldown output`);let u=l.code;return u=`// Built: ${new Date().toISOString()}\n${u}`,u}async buildServerComponents(){let e=E.join(this.options.outDir,this.options.rscDir);await w.promises.mkdir(e,{recursive:!0});let t={components:{},buildTime:new Date().toISOString()};for(let[e,n]of this.serverComponents){if(this.isPageComponent(e))continue;let r=E.relative(this.projectRoot,e),i=this.getComponentId(e),a=E.join(this.options.rscDir,`${i}.js`),o=E.join(this.options.outDir,a),s=E.dirname(o);await w.promises.mkdir(s,{recursive:!0});let c=await this.buildSingleComponent(e,o),l=await this.writeComponentCssAsset(i,c.css),u=k(E.resolve(this.projectRoot,o)).href;t.components[i]={id:i,filePath:e,relativePath:r,bundlePath:a,moduleSpecifier:u,dependencies:n.dependencies,hasNodeImports:n.hasNodeImports,css:l}}for(let[e,n]of this.serverComponents){if(!this.isPageComponent(e))continue;let r=E.relative(this.projectRoot,e),i=this.getComponentId(e),a=E.join(this.options.rscDir,`${i}.js`),o=E.join(this.options.outDir,a),s=E.dirname(o);await w.promises.mkdir(s,{recursive:!0});let c=await this.buildSingleComponent(e,o),l=await this.writeComponentCssAsset(i,c.css),u=k(E.resolve(this.projectRoot,o)).href;t.components[i]={id:i,filePath:e,relativePath:r,bundlePath:a,moduleSpecifier:u,dependencies:n.dependencies,hasNodeImports:n.hasNodeImports,css:l}}for(let[e,n]of this.serverActions){let r=E.relative(this.projectRoot,e),i=this.getComponentId(e),a=E.join(this.options.rscDir,`${i}.js`),o=E.join(this.options.outDir,a),s=E.dirname(o);await w.promises.mkdir(s,{recursive:!0});let c=await this.buildSingleComponent(e,o),l=await this.writeComponentCssAsset(i,c.css),u=k(E.resolve(this.projectRoot,o)).href;t.components[i]={id:i,filePath:e,relativePath:r,bundlePath:a,moduleSpecifier:u,dependencies:n.dependencies,hasNodeImports:n.hasNodeImports,css:l}}let n=E.join(this.options.outDir,this.options.manifestPath);await w.promises.writeFile(n,JSON.stringify(t,null,2),`utf-8`),await this.writeRouteCssEntries(t);let r={};this.options.csp&&(r.csp=this.options.csp),this.options.cacheControl&&(r.cacheControl=this.options.cacheControl);let i=E.join(this.options.outDir,this.options.serverConfigPath);if(Object.keys(r).length===0)try{await w.promises.unlink(i)}catch(e){e.code!==`ENOENT`&&console.warn(`Failed to remove server config file:`,e)}else await w.promises.writeFile(i,JSON.stringify(r,null,2),`utf-8`);return t}async buildSingleComponent(e,t){let n=await w.promises.readFile(e,`utf-8`),r=this.transformClientImports(n,e),i=this.isPageComponent(e),a=i?this.transformComponentImportsToGlobal(r):r,o=E.extname(e),s;s=o===`.tsx`?`tsx`:o===`.ts`?`ts`:o===`.jsx`?`jsx`:`js`;let c=`\0virtual:${e}`,l=[],u=await j({input:c,platform:`node`,write:!1,external:[Dt,`react`,`react-dom`,`react/jsx-runtime`,`react/jsx-dev-runtime`],output:{format:`esm`,minify:this.options.minify},moduleTypes:{[`.${s}`]:s},resolve:{mainFields:[`module`,`main`],conditionNames:[`import`,`module`,`default`],extensions:[`.ts`,`.tsx`,`.js`,`.jsx`]},transform:{jsx:`react`,define:{global:`globalThis`,"process.env.NODE_ENV":JSON.stringify(D.env.NODE_ENV||`production`),...this.options.define}},plugins:this.createBuildPlugins(c,a,s,e,i,l)});if(!u.output||u.output.length===0)throw Error(`No output generated from Rolldown`);let d=u.output.find(e=>e.type===`chunk`&&e.isEntry);if(!d||d.type!==`chunk`)throw Error(`No entry chunk found in Rolldown output`);let f=d.code;f=`// Built: ${new Date().toISOString()}\n${f}`,await w.promises.writeFile(t,f,`utf-8`);let p=await w.promises.open(t,`r+`);return await p.sync(),await p.close(),{code:f,css:l}}transformClientImports(e,t){let n=e,r,i=[],a=!1,o=[`rari/image`];for(xt.lastIndex=0;r=xt.exec(e),r!==null;){let[e,n,s,c]=r,l=!1,u=c;if(o.includes(c))l=!0;else{let e=this.resolveImportPath(c,t);this.isClientComponent(e)&&(l=!0,u=E.relative(this.projectRoot,e).replace(J,`/`))}if(l){a=!0;let t=``;n?t=`const ${n} = registerClientReference(
|
|
64
65
|
null,
|
|
65
66
|
${JSON.stringify(u)},
|
|
66
67
|
"default"
|
|
@@ -101,12 +102,12 @@ function registerClientReference(clientReference, id, exportName) {
|
|
|
101
102
|
return clientProxy;
|
|
102
103
|
}
|
|
103
104
|
|
|
104
|
-
`+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=
|
|
105
|
+
`+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=E.join(i,r);break}E.isAbsolute(n)||(n=E.resolve(E.dirname(t),n));let i=[`.tsx`,`.jsx`,`.ts`,`.js`];return Re(n,i)||G(n,i)||`${n}.tsx`}getProjectRelativePath(e){return De(e,this.projectRoot)}getReadableComponentId(e){return Oe(e)}getComponentId(e){return N(e,this.projectRoot)}async rebuildComponent(e){let t=this.getComponentId(e),n=await w.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=E.join(this.options.rscDir,`${t}.js`),o=E.join(this.options.outDir,a),s=this.buildCache.get(e),c=(await w.promises.stat(e)).mtimeMs;if(s&&s.timestamp>=c&&JSON.stringify(s.dependencies)===JSON.stringify(r))return await w.promises.writeFile(o,s.code,`utf-8`),await this.updateManifestForComponent(t,e,a,s.css),{componentId:t,bundlePath:E.join(this.options.outDir,a),success:!0};let l=E.dirname(o);await w.promises.mkdir(l,{recursive:!0});let u=await this.buildSingleComponent(e,o),d=await this.writeComponentCssAsset(t,u.css);return this.buildCache.set(e,{code:u.code,css:d,timestamp:Date.now(),dependencies:r}),await this.updateManifestForComponent(t,e,a,d),{componentId:t,bundlePath:E.join(this.options.outDir,a),success:!0}}manifestCache=null;async updateManifestForComponent(e,t,n,r=[]){let i=E.join(this.options.outDir,this.options.manifestPath),a;if(this.manifestCache)a=this.manifestCache;else if(w.existsSync(i)){let e=await w.promises.readFile(i,`utf-8`);a=JSON.parse(e),this.manifestCache=a}else a={components:{},buildTime:new Date().toISOString()},this.manifestCache=a;let o=this.serverComponents.get(t)||this.serverActions.get(t),s=E.join(this.options.outDir,n),c=k(E.resolve(this.projectRoot,s)).href;if(o)a.components[e]={id:e,filePath:t,relativePath:E.relative(this.projectRoot,t),bundlePath:n,moduleSpecifier:c,dependencies:o.dependencies,hasNodeImports:o.hasNodeImports,css:r};else{let i=await w.promises.readFile(t,`utf-8`);a.components[e]={id:e,filePath:t,relativePath:E.relative(this.projectRoot,t),bundlePath:n,moduleSpecifier:c,dependencies:this.extractDependencies(i),hasNodeImports:this.hasNodeImports(i),css:r}}a.buildTime=new Date().toISOString(),await w.promises.writeFile(i,JSON.stringify(a,null,2),`utf-8`),await this.writeRouteCssEntries(a),this.manifestCache=a}clearCache(){this.buildCache.clear(),this.manifestCache=null}invalidateBuildCacheFor(e){this.buildCache.delete(e)}async getTransformedComponentCode(e){return await this.buildComponentCodeOnly(e)}};function X(e,t,n=!0){n&&t.buildImportGraph(e);let r=w.readdirSync(e,{withFileTypes:!0});for(let n of r){let r=E.join(e,n.name);if(n.isDirectory())X(r,t,!1);else if(n.isFile()&&_.test(n.name)){if(Et.test(n.name)||n.name.endsWith(`.d.ts`))continue;try{let e=w.readFileSync(r,`utf-8`);if(B(e)){t.addServerComponent(r,e);continue}if(t.isOnlyImportedByClientComponents(r))continue;t.isServerComponent(r,e)&&t.addServerComponent(r,e)}catch(e){console.warn(`[server-build] Error checking ${r}:`,e instanceof Error?e.message:e)}}}}function kt(e={}){let t=null,n,r=!1,i={};return{name:`rari-server-build`,configResolved(a){n=a.root,r=a.command===`serve`;let o={};if(a.resolve?.alias){let e=a.resolve.alias;Array.isArray(e)?e.forEach(e=>{typeof e.find==`string`&&typeof e.replacement==`string`&&(o[e.find]=e.replacement)}):typeof e==`object`&&Object.entries(e).forEach(([e,t])=>{typeof t==`string`&&(o[e]=t)})}i=o,t=new Ot(n,{...e,alias:o})},buildStart(){if(!t)return;let e=D.env.NODE_ENV===`production`,r=[E.join(n,`dist`,`cache`,`og`),E.join(n,`dist`,`cache`,`images`)];e&&r.push(`/tmp/rari-og-cache`,`/tmp/rari-image-cache`);for(let e of r)try{w.existsSync(e)&&w.rmSync(e,{recursive:!0,force:!0})}catch(t){console.warn(`[rari] Failed to clear cache ${e}:`,t)}let i=E.join(n,`src`);w.existsSync(i)&&X(i,t)},async closeBundle(){if(t){await t.buildServerComponents();try{let{generateRobotsFile:e}=await import(`./robots-generator-l2O5neuR.mjs`);await e({appDir:E.join(n,`src`,`app`),outDir:E.join(n,`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-BbD6Q3sO.mjs`);await e({appDir:E.join(n,`src`,`app`),outDir:E.join(n,`dist`),extensions:[`.ts`,`.tsx`,`.js`,`.jsx`],aliases:i})}catch(e){console.warn(`[rari] Failed to generate sitemap:`,e)}}},async handleHotUpdate({file:e}){if(!t||!r)return;let i=E.relative(n,e).replace(Ct,`/`);if(!(!i.startsWith(`src/`)||!_.test(i)))try{if(V(await w.promises.readFile(e,`utf-8`)))return;await t.buildServerComponents()}catch(e){console.error(`[rari] Build: Error rebuilding ${i}:`,e)}}}}const At=/import\s+type\s+(\{[^}]+\})\s+from\s+["']\.\.?\/([^"']+)["'];?/g,jt=/import\s+type\s+(\*\s+as\s+\w+)\s+from\s+["']\.\.?\/([^"']+)["'];?/g,Mt=/import\s+type\s+(\w+)\s+from\s+["']\.\.?\/([^"']+)["'];?/g,Nt=/import\s+(\{[^}]+\})\s+from\s+["']\.\.?\/([^"']+)["'];?/g,Pt=/import\s+(\*\s+as\s+\w+)\s+from\s+["']\.\.?\/([^"']+)["'];?/g,Ft=/import\s+(\w+)\s+from\s+["']\.\.?\/([^"']+)["'];?/g,It=/import\s+["']\.\.?\/([^"']+)["'];?/g,Lt=/import\s*(?:\(\s*)?["']([^"']+)["']\)?/g,Rt=/export\s*\{([^}]+)\}/g,zt=/\s+as\s+/,Bt=/export\s+default\s+(?:function|class)\s+\w+/,Vt=/export\s+default\s+(?:async\s+)?function\s+(\w+)/,Ht=/export\s+default\s+([^;]+)/,Ut=/export\s+(?:async\s+)?(?:const|let|var|function|class)\s+(\w+)/g,Wt=/^['"]use client['"];?\s*$/gm,Gt=/import\s+["']([^"']+)["']/g,Kt=/^\s*import\s+(?:(\w+)(?:\s*,\s*\{\s*(?:(\w+(?:\s*,\s*\w+)*)\s*)?\})?|\{\s*(\w+(?:\s*,\s*\w+)*)\s*\})\s+from\s+['"]([./@][^'"]+)['"].*$/,qt=/import\s+\{[^}]*\}\s+from\s+['"]react['"]/,Jt=/import\s+[^,\s]+\s*,\s*\{[^}]*\}\s+from\s+['"]react['"]/,Yt=/import React(,\s*\{([^}]*)\})?\s+from\s+['"]react['"];?/,Xt=/import\s+["']([^"']+)["']/g,Zt=/from(\s*)(['"])(?:\.\/vendor\/react-flight-client\/index|rari\/runtime\/vendor\/react-flight-client\/index)\.mjs\2/g,Qt=/\bJSX\b/,$t=/\{([^}]*)\}/,en=/^['"]use client['"];?\s*\n/,tn={remotePatterns:[],localPatterns:[],deviceSizes:g,imageSizes:h,formats:p,qualityAllowlist:m,minimumCacheTTL:60,maxCacheSize:f};async function Z(e){let t=import.meta.url,n=O(t),r=E.dirname(n),i=[E.join(r,`runtime`,e),E.join(r,`../runtime`,e)];for(let e of i)try{let t=await w.promises.readFile(e,`utf-8`);return e.endsWith(`.ts`)&&(t=t.replace(At,(e,t,n)=>`import type ${t} from "rari/${n}";`),t=t.replace(jt,(e,t,n)=>`import type ${t} from "rari/${n}";`),t=t.replace(Mt,(e,t,n)=>`import type ${t} from "rari/${n}";`),t=t.replace(Nt,(e,t,n)=>`import ${t} from "rari/${n}";`),t=t.replace(Pt,(e,t,n)=>`import ${t} from "rari/${n}";`),t=t.replace(Ft,(e,t,n)=>`import ${t} from "rari/${n}";`),t=t.replace(It,(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 nn(){return Z(`rsc-client-runtime.mjs`)}async function rn(e,t){return(await Z(`entry-client.mjs`)).replace(`/*! @preserve CLIENT_COMPONENT_IMPORTS_PLACEHOLDER */`,e).replace(`/*! @preserve CLIENT_COMPONENT_REGISTRATIONS_PLACEHOLDER */`,t)}async function an(){return Z(`react-server-dom-shim.mjs`)}async function on(e,t){let n=await it(E.join(e,`src`)),r={...tn,...t.images,preoptimizeManifest:n.images},i=E.join(e,`dist`),a=E.join(i,`server`);w.existsSync(a)||w.mkdirSync(a,{recursive:!0});let o=E.join(a,`image.json`);w.writeFileSync(o,JSON.stringify(r,null,2))}function sn(e,t=[]){let n=new Set;function r(e){if(!w.existsSync(e))return;let t=w.readdirSync(e,{withFileTypes:!0});for(let i of t){let t=E.join(e,i.name);if(i.isDirectory()){if(i.name===`node_modules`)continue;r(t)}else if(i.isFile()&&_.test(i.name))try{V(w.readFileSync(t,`utf8`))&&n.add(t)}catch(e){e?.code!==`ENOENT`&&console.warn(`[rari] Unexpected error during file scan:`,t,e)}}}r(e);for(let e of t)w.existsSync(e)&&r(e);return n}function cn(e){return e}function ln(e={}){let t=new Map,n=new Set,r=new Map,i=null,a=null,o={};function s(e){if(r.has(e))return r.get(e);let t={hasUseServer:!1,hasUseClient:!1},n=e.replace(C,`/`);if(!_.test(n)||!n.includes(`/src/`))return r.set(e,t),t;try{let n=w.readFileSync(e,`utf-8`);t.hasUseServer=B(n),t.hasUseClient=V(n),r.set(e,t)}catch{r.set(e,t)}return t}function c(t){if(t.includes(`node_modules`)||t.includes(`/rari/dist/`)||t.includes(`\\rari\\dist\\`))return!1;let n=e.projectRoot||D.cwd(),r=E.join(n,`index.html`);if(w.existsSync(r))try{let e=w.readFileSync(r,`utf-8`);for(let r of e.matchAll(Lt)){let e=r[1];if(e.startsWith(`/src/`)&&E.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=w.realpathSync(t)}catch{return!1}try{if(!w.existsSync(i))return!1;let e=w.readFileSync(i,`utf-8`),t=V(e);return B(e)?!1:!t}catch{return!1}}function l(e){try{let t=[],n=e.matchAll(Rt);for(let e of n){let n=e[1].split(`,`);for(let e of n){let n=e.trim().split(zt).at(-1)?.trim();n&&t.push(n)}}(Bt.test(e)||W(e))&&t.push(`default`);let r=e.matchAll(Ut);for(let e of r)e[1]&&t.push(e[1]);return[...new Set(t)]}catch{return[]}}function u(e,t){if(!B(e))return e;let n=l(e);if(n.length===0)return e;let r=e;r+=`
|
|
105
106
|
|
|
106
107
|
import {registerServerReference} from "react-server-dom-rari/server";
|
|
107
|
-
`;for(let i of n)if(i==="default"){let n=e.match(
|
|
108
|
+
`;for(let i of n)if(i==="default"){let n=e.match(Vt);if(n){let e=n[1];r+=`
|
|
108
109
|
// Register server reference for default export
|
|
109
|
-
`,r+=`registerServerReference(${e}, ${JSON.stringify(t)}, ${JSON.stringify(i)});\n`}else{let n=e.match(
|
|
110
|
+
`,r+=`registerServerReference(${e}, ${JSON.stringify(t)}, ${JSON.stringify(i)});\n`}else{let n=e.match(Ht);if(n){let e=n[1].trim(),a=`__default_export__`;r=r.replace(Ht,`const ${a} = ${e};\nexport default ${a}`),r+=`
|
|
110
111
|
// Register server reference for default export
|
|
111
112
|
`,r+=`if (typeof ${a} === "function") {\n`,r+=` registerServerReference(${a}, ${JSON.stringify(t)}, ${JSON.stringify(i)});\n`,r+=`}
|
|
112
113
|
`}}}else r+=`\n// Register server reference for ${i}\n`,r+=`if (typeof ${i} === "function") {\n`,r+=` registerServerReference(${i}, ${JSON.stringify(t)}, ${JSON.stringify(i)});\n`,r+=`}
|
|
@@ -115,11 +116,11 @@ import {registerServerReference} from "react-server-dom-rari/server";
|
|
|
115
116
|
if (import.meta.hot) {
|
|
116
117
|
import.meta.hot.accept(() => {
|
|
117
118
|
});
|
|
118
|
-
}`,r}function d(
|
|
119
|
-
`;for(let
|
|
120
|
-
`;for(let
|
|
121
|
-
`;for(let e of
|
|
122
|
-
`);for(let e of i){let i=e.match(
|
|
119
|
+
}`,r}function d(t,n){let r=e.projectRoot||D.cwd(),i=B(t),a=c(n);if(i){let e=l(t);if(e.length===0)return``;let i=N(n,r),a=`import { createServerReference } from "rari/runtime/actions";
|
|
120
|
+
`;for(let t of e)t==="default"?a+=`export default createServerReference("default", ${JSON.stringify(i)}, "default");\n`:a+=`export const ${t} = createServerReference("${t}", ${JSON.stringify(i)}, "${t}");\n`;return a}if(a){let e=l(t);if(e.length===0)return``;let i=N(n,r),a=`import { createServerComponentWrapper } from "virtual:rsc-integration.ts";
|
|
121
|
+
`;for(let t of e)t==="default"?a+=`export default createServerComponentWrapper("${i}", ${JSON.stringify(n)});\n`:a+=`export const ${t} = createServerComponentWrapper("${i}_${t}", ${JSON.stringify(n)});\n`;return a}if(!V(t))return t;let o=l(t);if(o.length===0)return``;let s=`import {registerClientReference} from "react-server-dom-rari/server";
|
|
122
|
+
`;for(let e of o){if(e==="default"){let e=`Attempted to call the default export of ${n} from the server but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.`;s+=`export default `,s+=`registerClientReference(function() {`,s+=`throw new Error(${JSON.stringify(e)});`}else{let t=`Attempted to call ${e}() from the server but ${e} is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.`;s+=`export const ${e} = `,s+=`registerClientReference(function() {`,s+=`throw new Error(${JSON.stringify(t)});`}s+=`},`,s+=`${JSON.stringify(n)},`,s+=`${JSON.stringify(e)});\n`}return s}function f(e,t){return!V(e)||l(e).length===0?e:e.replace(Wt,``)}function p(e,t){let n=e;for(let[t,r]of Object.entries(o))if(e.startsWith(`${t}/`)){n=e.replace(t,r);break}else if(e===t){n=r;break}let r=E.resolve(E.dirname(t),n),i=[`.tsx`,`.jsx`,`.ts`,`.js`];return Re(r,i)||G(r,i)||`${r}.tsx`}function m(e){return(e.split(`/`).pop()||e).replace(x,``)}let h=!1;async function g(){let e=`http://localhost:${D.env.SERVER_PORT?Number(D.env.SERVER_PORT):Number(D.env.PORT||D.env.RSC_PORT||3e3)}`;try{let t=(await fetch(`${e}/_rari/health`,{signal:AbortSignal.timeout(1e3)})).ok;return h=t,t}catch{return h=!1,!1}}let v=[{name:`rari`,config(t,{command:n}){if(t.define=t.define||{},n===`serve`||D.env.RARI_SERVER_URL||D.env.RARI_HOST){let e=D.env.SERVER_PORT?Number(D.env.SERVER_PORT):Number(D.env.PORT||D.env.RSC_PORT||3e3),n;if(D.env.RARI_SERVER_URL)n=D.env.RARI_SERVER_URL;else if(D.env.RARI_HOST){let t=D.env.RARI_HOST.startsWith(`http`)?D.env.RARI_HOST:`http://${D.env.RARI_HOST}`;n=t.replace(y,``).includes(`:`)?t:`${t}:${e}`}else n=`http://localhost:${e}`;t.define[`import.meta.env.RARI_SERVER_URL`]=JSON.stringify(n)}let r=typeof t.css?.modules==`object`?t.css.modules:{};if(t.css={...t.css,transformer:t.css?.transformer??`lightningcss`,modules:{...r,pattern:Y}},n===`build`){let n=e.projectRoot||D.cwd(),r=E.join(n,`index.html`);if(w.existsSync(r))try{let e=w.readFileSync(r,`utf-8`),n=[];for(let t of e.matchAll(Gt)){let e=t[1];if(e.startsWith(`/src/`)&&_.test(e)){let t=e.slice(1),r=E.basename(t,E.extname(t));n.push({path:t,name:r})}}if(n.length>0){t.build=t.build||{},t.build.rolldownOptions=t.build.rolldownOptions||{};let e=t.build.rolldownOptions.input||{main:`./index.html`},r;r=typeof e==`string`?{main:e}:Array.isArray(e)?{main:e[0]||`./index.html`}:{...e},n.forEach(({path:e,name:t})=>{r[t]=`./${e}`}),t.build.rolldownOptions.input=r}}catch(e){console.warn(`[rari] Error parsing index.html for build inputs:`,e)}}t.resolve=t.resolve||{};let i=Array.isArray(t.resolve.dedupe)?t.resolve.dedupe:[],a=[`react`,`react-dom`];t.resolve.dedupe=[...new Set([...i||[],...a])];let o=[];Array.isArray(t.resolve.alias)?o=t.resolve.alias:t.resolve.alias&&typeof t.resolve.alias==`object`&&(o=Object.entries(t.resolve.alias).map(([e,t])=>({find:e,replacement:t})));let c=new Set(o.map(e=>String(e.find)));try{let e=O(import.meta.resolve(`react`)),n=O(import.meta.resolve(`react-dom/client`)),r=O(import.meta.resolve(`react/jsx-runtime`)),i=[];c.has(`react/jsx-runtime`)||i.push({find:`react/jsx-runtime`,replacement:r});try{let e=O(import.meta.resolve(`react/jsx-dev-runtime`));c.has(`react/jsx-dev-runtime`)||i.push({find:`react/jsx-dev-runtime`,replacement:e})}catch(e){e?.code!==`ENOENT`&&console.warn(`[rari] Unexpected error resolving react/jsx-dev-runtime:`,e)}c.has(`react`)||i.push({find:`react`,replacement:e}),c.has(`react-dom/client`)||i.push({find:`react-dom/client`,replacement:n}),i.length>0&&(t.resolve.alias=[...o,...i])}catch(e){e?.code!==`ENOENT`&&console.warn(`[rari] Unexpected error configuring React aliases:`,e)}t.environments=t.environments||{},t.environments.rsc={resolve:{conditions:[`react-server`,`node`,`import`]},...t.environments.rsc},t.environments.ssr={resolve:{conditions:[`node`,`import`]},...t.environments.ssr},t.environments.client={resolve:{conditions:[`browser`,`import`]},...t.environments.client},t.optimizeDeps=t.optimizeDeps||{},t.optimizeDeps.include=t.optimizeDeps.include||[];for(let e of[`react`,`react-dom`,`react-dom/client`,`react-dom/server`,`react/jsx-runtime`,`react/jsx-dev-runtime`])t.optimizeDeps.include.includes(e)||t.optimizeDeps.include.push(e);if(t.optimizeDeps.exclude=t.optimizeDeps.exclude||[],t.optimizeDeps.exclude.includes(`rari`)||t.optimizeDeps.exclude.push(`rari`),n===`build`)for(let e of[`rsc`,`ssr`,`client`]){let n=t.environments[e];n&&n.build&&(n.build.rolldownOptions=n.build.rolldownOptions||{})}t.server=t.server||{},t.server.proxy=t.server.proxy||{};let l=D.env.SERVER_PORT?Number(D.env.SERVER_PORT):Number(D.env.PORT||D.env.RSC_PORT||3e3);if(t.server.proxy[`/api`]={target:`http://localhost:${l}`,changeOrigin:!0,secure:!1,ws:!0},t.server.proxy[`/_rari`]={target:`http://localhost:${l}`,changeOrigin:!0,secure:!1,ws:!0},n===`build`){t.build=t.build||{},t.build.rolldownOptions=t.build.rolldownOptions||{},t.build.rolldownOptions.input||(t.build.rolldownOptions.input={main:`./index.html`}),t.build.rolldownOptions.output=t.build.rolldownOptions.output||{};let e=Array.isArray(t.build.rolldownOptions.output)?t.build.rolldownOptions.output:[t.build.rolldownOptions.output];for(let t of e){if(t.codeSplitting!==!1&&typeof t.codeSplitting!=`object`&&(t.codeSplitting={}),typeof t.codeSplitting==`object`){t.codeSplitting.groups=t.codeSplitting.groups||[];let e=t.codeSplitting.groups;t.codeSplitting.groups.push({name(t){if(t.includes(`node_modules`)){for(let n of e)if(n.test){let e=!1;if(typeof n.test==`function`?e=!!n.test(t):n.test instanceof RegExp?e=n.test.test(t):typeof n.test==`string`&&(e=t.includes(n.test)),e)return null}return t.includes(`node_modules/react-dom`)?`react-dom`:t.includes(`node_modules/react`)?`react`:`vendor`}return null}})}t.chunkFileNames||=e=>e.moduleIds?.some(e=>s(e).hasUseServer)?`client/actions/[name]-[hash].js`:e.moduleIds?.some(e=>s(e).hasUseClient)?`client/components/[name]-[hash].js`:`assets/[name]-[hash].js`}}return t.environments&&t.environments.client&&(t.environments.client.build||(t.environments.client.build={}),t.environments.client.build.rolldownOptions||(t.environments.client.build.rolldownOptions={}),t.environments.client.build.rolldownOptions.input||(t.environments.client.build.rolldownOptions.input={})),t},configResolved(e){let t=new Set([`react`,`react-dom`,`react/jsx-runtime`,`react/jsx-dev-runtime`,`react-dom/client`]);if(e.resolve?.alias){let n=e.resolve.alias;Array.isArray(n)?n.forEach(e=>{typeof e.find==`string`&&typeof e.replacement==`string`&&!t.has(e.find)&&(o[e.find]=e.replacement)}):typeof n==`object`&&Object.entries(n).forEach(([e,n])=>{typeof n==`string`&&!t.has(e)&&(o[e]=n)})}},transform(e,r){if(!_.test(r))return null;let i=this.environment;if(V(e)){t.set(r,`client`),n.add(r);let i=e.split(`
|
|
123
|
+
`);for(let e of i){let i=e.match(Kt);if(!i)continue;let a=i[4];if(!a)continue;let o=p(a,r);w.existsSync(o)&&(t.set(o,`client`),n.add(o))}return f(e,r)}if(t.get(r)===`client`||n.has(r))return f(e,r);if(c(r)){if(t.set(r,`server`),i&&(i.name===`rsc`||i.name===`ssr`))return u(e,r);{let t=d(e,r);return t=`// HMR acceptance for server component
|
|
123
124
|
if (import.meta.hot) {
|
|
124
125
|
import.meta.hot.accept();
|
|
125
126
|
}
|
|
@@ -130,19 +131,19 @@ if (typeof globalThis !== 'undefined') {
|
|
|
130
131
|
globalThis['~rari'].serverComponents.add(${JSON.stringify(r)});
|
|
131
132
|
}
|
|
132
133
|
|
|
133
|
-
${t}`,t}}if(
|
|
134
|
-
`),s=e,l=!1,h=!1,g=!1,
|
|
134
|
+
${t}`,t}}if(B(e))return t.set(r,`server`),i&&(i.name===`rsc`||i.name===`ssr`)?u(e,r):d(e,r);let a=t.get(r);if(a===`server`)return i&&(i.name===`rsc`||i.name===`ssr`)?u(e,r):d(e,r);if(a===`client`)return f(e,r);t.set(r,`unknown`);let o=e.split(`
|
|
135
|
+
`),s=e,l=!1,h=!1,g=!1,v=[];for(let a of o){let o=a.match(Kt);if(!o)continue;let u=o[1],d=o[4],f=m(d),_=p(d,r),y=V(e)||t.get(r)===`client`||r.includes(`entry-client`),b=t.get(_)===`client`||w.existsSync(_)&&V(w.readFileSync(_,`utf-8`));if(b&&(t.set(_,`client`),n.add(_)),b&&i&&(i.name===`rsc`||i.name===`ssr`)){if(!y){let e=a,t=u||`default`,n=`
|
|
135
136
|
import { registerClientReference } from "react-server-dom-rari/server";
|
|
136
137
|
const ${t} = registerClientReference(
|
|
137
138
|
function() {
|
|
138
139
|
throw new Error("Attempted to call ${t} from the server but it's on the client. It can only be rendered as a Component or passed to props of a Client Component.");
|
|
139
140
|
},
|
|
140
|
-
${JSON.stringify(
|
|
141
|
+
${JSON.stringify(_)},
|
|
141
142
|
${JSON.stringify(u||`default`)}
|
|
142
|
-
);`;s=s.replace(e,n),l=!0,h=!0}}else if(!y&&c(
|
|
143
|
+
);`;s=s.replace(e,n),l=!0,h=!0}}else if(!y&&c(_)){l=!0,h=!0,g=!0;let e=a;u&&u!==`_`&&v.push(`const ${u} = createServerComponentWrapper('${f}', '${d}');`),s=s.replace(e,``)}}if(l){let e=s.includes(`import React`)||s.match(qt)||s.match(Jt),n=s.includes(`createServerComponentWrapper`),i=``;if(h&&!e&&(i+=`import React from 'react';
|
|
143
144
|
`),g&&!n&&(i+=`import { createServerComponentWrapper } from 'virtual:rsc-integration.ts';
|
|
144
|
-
`),
|
|
145
|
-
`)}\n`),i&&(s=i+s),!s.includes(`Suspense`)){let e=s.match(
|
|
145
|
+
`),v.length>0&&(i+=`${v.join(`
|
|
146
|
+
`)}\n`),i&&(s=i+s),!s.includes(`Suspense`)){let e=s.match(Yt);e&&(e[1]&&!e[2].includes(`Suspense`)?s=s.replace(e[0],e[0].replace($t,`{ Suspense, $1 }`)):e[1]||(s=s.replace(e[0],`import React, { Suspense } from 'react';`)))}let a=D.env.NODE_ENV!==`production`,o=s.includes(`</`)||s.includes(`/>`)||Qt.test(s);return!V(s)&&o&&a&&(s=`'use client';\n\n${s}`,t.set(r,`client`)),s}return null},async configureServer(n){let r=e.projectRoot||D.cwd(),s=E.join(r,`src`);await on(r,e);let l=null,u=async()=>{try{let{ServerComponentBuilder:t,scanDirectory:i}=await Promise.resolve().then(()=>_t),s=new t(r,{outDir:`dist`,rscDir:`server`,manifestPath:`server/manifest.json`,serverConfigPath:`server/config.json`,alias:o,csp:e.csp,cacheControl:e.cacheControl});if(l=s,!a&&l){let e=D.env.SERVER_PORT?Number(D.env.SERVER_PORT):Number(D.env.PORT||D.env.RSC_PORT||3e3);a=new Ve(l,e)}let u=E.join(r,`src`),d=[];if(w.existsSync(u)){let e=t=>{let n=w.readdirSync(t,{withFileTypes:!0});for(let r of n){let n=E.join(t,r.name);if(r.isDirectory())e(n);else if(r.isFile()&&_.test(r.name))try{c(n)&&d.push(n)}catch(e){console.error(`[rari] Error checking ${n}:`,e)}}};e(u),i(u,s)}d.length>0&&n.ws.send({type:`custom`,event:`rari:server-components-registry`,data:{serverComponents:d}});let f=await s.getTransformedComponentsForDevelopment(),p=`http://localhost:${D.env.SERVER_PORT?Number(D.env.SERVER_PORT):Number(D.env.PORT||D.env.RSC_PORT||3e3)}`;for(let e of f)try{if(e.id.startsWith(`app/`)||B(e.code))continue;let t=await fetch(`${p}/_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))}},d=async()=>{try{let e=`http://localhost:${D.env.SERVER_PORT?Number(D.env.SERVER_PORT):Number(D.env.PORT||D.env.RSC_PORT||3e3)}`,t=sn(s,Object.values(o));for(let n of t){let t=E.relative(D.cwd(),n),r=E.basename(n).replace(x,``);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)}},f=async()=>{if(i)return;let{getBinaryPath:e,getInstallationInstructions:t}=await import(`./platform.mjs`),r;try{r=e()}catch(e){console.error(`rari binary not found`),console.error(` ${e.message}`),console.error(t());return}let a=D.env.SERVER_PORT?Number(D.env.SERVER_PORT):Number(D.env.PORT||D.env.RSC_PORT||3e3),o=D.env.NODE_ENV===`production`?`production`:`development`,s=n.config.server.port||5173,c=[`--mode`,o,`--port`,a.toString(),`--host`,`127.0.0.1`];i=ae(r,c,{stdio:[`ignore`,`pipe`,`pipe`],cwd:D.cwd(),env:{...D.env,RUST_LOG:D.env.RUST_LOG||`error`,RARI_VITE_PORT:s.toString()}}),i.stdout?.on(`data`,e=>{let t=e.toString().trim();t&&console.error(`${t}`)}),i.stderr?.on(`data`,e=>{let t=e.toString().trim();t&&!t.includes(`warning`)&&console.error(`${t}`)}),i.on(`error`,e=>{h=!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.`)}),i.on(`exit`,(e,t)=>{i=null,h=!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 l=!1;for(let e=0;e<20&&(l=await g(),!l);e++)await new Promise(e=>setTimeout(e,500));l?(await d(),await u()):console.error(`Server failed to become ready for component registration`)},p=async t=>{try{if(!c(t))return;let{ServerComponentBuilder:n}=await Promise.resolve().then(()=>_t),i=new n(r,{outDir:`dist`,rscDir:`server`,manifestPath:`server/manifest.json`,serverConfigPath:`server/config.json`,alias:o,csp:e.csp,cacheControl:e.cacheControl});i.addServerComponent(t);let a=await i.getTransformedComponentsForDevelopment();if(a.length===0)return;let s=`http://localhost:${D.env.SERVER_PORT?Number(D.env.SERVER_PORT):Number(D.env.PORT||D.env.RSC_PORT||3e3)}`;for(let e of a)try{let t=await fetch(`${s}/_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(u,1e3)}};f().catch(e=>{console.error(`[rari] Failed to start Rust server:`,e)}),n.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(!h&&!await g()){let e=Date.now();for(;Date.now()-e<1e4&&!await g();)await new Promise(e=>setTimeout(e,100));if(!h){console.error(`[rari] Rust server not ready, cannot proxy RSC request`),t.headersSent||(t.statusCode=503,t.end(`Server not ready`));return}}let n=D.env.SERVER_PORT?Number(D.env.SERVER_PORT):Number(D.env.PORT||D.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(ie.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()}),n.watcher.on(`change`,async e=>{_.test(e)&&t.delete(e),_.test(e)&&e.includes(s)&&(c(e)?(n.ws.send({type:`custom`,event:`rari:register-server-component`,data:{filePath:e}}),await p(e)):setTimeout(u,1e3))}),n.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 p(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)}))}})}),n.httpServer?.on(`close`,()=>{a&&=(a.dispose(),null),i&&=(i.kill(`SIGTERM`),null),h=!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-flight-client`||e===`virtual:react-flight-client.ts`)return`virtual:react-flight-client.ts`;if(e===`virtual:app-router-provider`||e===`virtual:app-router-provider.tsx`)return`virtual:app-router-provider.tsx`;if(e===`virtual:error-boundary-wrapper`||e===`virtual:error-boundary-wrapper.tsx`)return`virtual:error-boundary-wrapper.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=O(n),i=E.dirname(r),a=null,o=[E.join(i,`runtime`),E.join(i,`../runtime`)];for(let e of o)if(w.existsSync(e)){a=e;break}if(a){let t=E.join(a,e);if(w.existsSync(t))return t;let n=E.join(a,`../dist`,E.basename(e));if(w.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=E.join(i,e);if(w.existsSync(s))return s;let c=E.join(i,`../dist`,E.basename(e));if(w.existsSync(c))return c}if(D.env.NODE_ENV===`production`)try{let t=E.resolve(e);if(w.existsSync(t)&&c(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(t){if(_.test(t)){let e=this.environment;if(e&&e.name===`client`)try{let e=w.readFileSync(t,`utf-8`);if(B(e))return d(e,t)}catch{}}if(t===`virtual:rari-entry-client.ts`){let e=sn(E.join(D.cwd(),`src`),Object.values(o)),t=new Set([...n,...e]),r=[{path:`rari/image`,exports:[`Image`]},{path:`virtual:error-boundary-wrapper.tsx`,exports:[`ErrorBoundaryWrapper`]}],i=[...t].filter(e=>{try{return V(w.readFileSync(e,`utf-8`))}catch{return!1}}).map(e=>{let t=E.relative(D.cwd(),e).replace(C,`/`),n=t.replace(_,``),r=t.startsWith(`..`)?e.replace(C,`/`):t,i=!1,a=``;try{let t=w.readFileSync(e,`utf-8`),n=W(t),r=t.match(ee);!n&&r&&(i=!0,a=r[1])}catch(t){t?.code!==`ENOENT`&&console.warn(`[rari] Unexpected error reading component for export detection:`,e,t)}let o=i?a:E.basename(e,E.extname(e)),s=r.replace(C,`/`),c=s.startsWith(`/`)||te.test(s)?s:`/${s}`;return` "${r}": {
|
|
146
147
|
id: "${n}",
|
|
147
148
|
path: "${r}",
|
|
148
149
|
exportName: "${o}",
|
|
@@ -166,7 +167,7 @@ globalThis['~clientComponents']["${e.path}"] = globalThis['~clientComponents']["
|
|
|
166
167
|
globalThis['~clientComponents']["${e.path}"].component = ExternalModule${t};
|
|
167
168
|
globalThis['~clientComponentPaths'] = globalThis['~clientComponentPaths'] || {};
|
|
168
169
|
globalThis['~clientComponentPaths']["${e.path}"] = "${n}";`)).join(`
|
|
169
|
-
`);return await
|
|
170
|
+
`);return await rn(a,[`
|
|
170
171
|
const lazyComponentRegistry = {
|
|
171
172
|
${i}
|
|
172
173
|
};
|
|
@@ -179,7 +180,7 @@ for (const [path, config] of Object.entries(lazyComponentRegistry)) {
|
|
|
179
180
|
globalThis['~clientComponentPaths'][path] = config.id;
|
|
180
181
|
}
|
|
181
182
|
`,s].filter(Boolean).join(`
|
|
182
|
-
`))}if(t===`react-server-dom-rari/server`)return await
|
|
183
|
+
`))}if(t===`react-server-dom-rari/server`)return await an();if(t===`virtual:app-router-provider.tsx`){let e=[E.join(D.cwd(),`packages/rari/dist/runtime/AppRouterProvider.mjs`),E.join(D.cwd(),`node_modules/rari/dist/runtime/AppRouterProvider.mjs`)];for(let t of e)if(w.existsSync(t))return w.readFileSync(t,`utf-8`);return`export function AppRouterProvider({ children }) { return children; }`}if(t===`virtual:default-loading-indicator.tsx`){let e=[E.join(D.cwd(),`packages/rari/dist/runtime/DefaultLoadingIndicator.mjs`),E.join(D.cwd(),`node_modules/rari/dist/runtime/DefaultLoadingIndicator.mjs`)];for(let t of e)if(w.existsSync(t))return w.readFileSync(t,`utf-8`);return`export function DefaultLoadingIndicator() { return null; }`}if(t===`virtual:loading-error-boundary.tsx`){let e=[E.join(D.cwd(),`packages/rari/dist/runtime/LoadingErrorBoundary.mjs`),E.join(D.cwd(),`node_modules/rari/dist/runtime/LoadingErrorBoundary.mjs`)];for(let t of e)if(w.existsSync(t))return w.readFileSync(t,`utf-8`);return`export class LoadingErrorBoundary extends React.Component { render() { return this.props.children; } }`}if(t===`virtual:error-boundary-wrapper.tsx`){let e=[E.join(D.cwd(),`packages/rari/dist/runtime/ErrorBoundaryWrapper.mjs`),E.join(D.cwd(),`node_modules/rari/dist/runtime/ErrorBoundaryWrapper.mjs`),E.join(D.cwd(),`packages/rari/src/runtime/ErrorBoundaryWrapper.tsx`)];for(let t of e)if(w.existsSync(t)){let e=w.readFileSync(t,`utf-8`);if(!e.includes(`import React`)&&!e.includes(`from "react"`)&&!e.includes(`from 'react'`)){let t=e.match(en);if(t){let n=t[0];return`
|
|
183
184
|
${n}import * as React from 'react';\n${e.slice(n.length)}`}return`
|
|
184
185
|
import * as React from 'react';\n${e}`}return e}return`'use client';
|
|
185
186
|
import * as React from 'react';
|
|
@@ -253,4 +254,4 @@ export class ErrorBoundaryWrapper extends React.Component {
|
|
|
253
254
|
}
|
|
254
255
|
return this.props.children;
|
|
255
256
|
}
|
|
256
|
-
}`}if(t===`virtual:rsc-integration.ts`)return(await
|
|
257
|
+
}`}if(t===`virtual:rsc-integration.ts`)return(await nn()).replace(Zt,(e,t,n)=>`from${t}${n}virtual:react-flight-client.ts${n}`);if(t===`virtual:react-flight-client.ts`)return{code:`export * from 'rari/runtime/vendor/react-flight-client'`};if(t.endsWith(`.mjs`)&&w.existsSync(t))try{let n=e.projectRoot||D.cwd(),r=w.realpathSync(t),i=E.relative(n,r),a=!i.startsWith(`..`)&&!E.isAbsolute(i),o=r.includes(`${E.sep}node_modules${E.sep}`),s=r.includes(`${E.sep}packages${E.sep}rari${E.sep}`)||r.includes(`${E.sep}node_modules${E.sep}rari${E.sep}`);return a||o||s?w.readFileSync(t,`utf-8`):(console.warn(`[rari] Refusing to load .mjs file outside project root and node_modules: ${t}`),null)}catch(e){return console.warn(`[rari] Error validating .mjs file path: ${t}`,e),null}},async handleHotUpdate({file:e,server:t}){if(!_.test(e))return;if(e.includes(`/dist/`)||e.includes(`\\dist\\`))return[];let n=a?.detectComponentType(e)||`unknown`,r=e.includes(`/app/`)||e.includes(`\\app\\`),i=e.endsWith(`page.tsx`)||e.endsWith(`page.jsx`),o=e.endsWith(`layout.tsx`)||e.endsWith(`layout.jsx`),s=e.endsWith(`loading.tsx`)||e.endsWith(`loading.jsx`),c=e.endsWith(`error.tsx`)||e.endsWith(`error.jsx`),l=e.endsWith(`not-found.tsx`)||e.endsWith(`not-found.jsx`);if(!(r&&(i||o||s||c||l))&&n!==`client`&&n===`server`)return a&&await a.handleServerComponentUpdate(e,t),[]},transformIndexHtml:{order:`pre`,handler(e){let t=[];for(let n of e.matchAll(Xt)){let e=n[1];e.startsWith(`/src/`)&&t.push(e)}let n=[];n.push({tag:`script`,attrs:{type:`module`},children:`import 'virtual:rari-entry-client';`,injectTo:`head-prepend`}),t.length>0&&n.push(...t.map(e=>({tag:`script`,attrs:{type:`module`,src:e},injectTo:`head-prepend`})));let r=e;r=r.replace(/^\s*import\s+["']\/src\/[^"']+["'];?\s*$/gm,``),r=r.replace(/^\s*import\s+["']virtual:rari-entry-client["'];?\s*$/gm,``);let i;do i=r,r=r.replace(/<script\s+type=["']module["'][^>]*>\s*<\/script>/gi,``);while(r!==i);return{html:r,tags:n}}},async writeBundle(){await on(e.projectRoot||D.cwd(),e)}},kt({...e.serverBuild,csp:e.csp,cacheControl:e.cacheControl})];return e.proxy!==!1&&v.push(le(e.proxy||{})),e.router!==!1&&v.push(be(e.router||{})),v}function un(e){return{plugins:[ln(),...e.plugins||[]],...e}}var dn=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})}},fn=ce({generateAppRouteManifest:()=>_n});const Q={PAGE:`page`,LAYOUT:`layout`,LOADING:`loading`,ERROR:`error`,NOT_FOUND:`not-found`,TEMPLATE:`template`,DEFAULT:`default`,ROUTE:`route`,OG_IMAGE:`opengraph-image`,TWITTER_IMAGE:`twitter-image`,ICON:`icon`,APPLE_ICON:`apple-icon`},$={DYNAMIC:/^\[([^\]]+)\]$/,CATCH_ALL:/^\[\.\.\.([^\]]+)\]$/,OPTIONAL_CATCH_ALL:/^\[\[\.\.\.([^\]]+)\]\]$/},pn=/export\s+const\s+size\s*=\s*\{\s*width\s*:\s*(\d+)\s*,\s*height\s*:\s*(\d+)\s*[,}]/,mn=/export\s+const\s+contentType\s*=\s*['"]([^'"]+)['"]/,hn=[`GET`,`POST`,`PUT`,`DELETE`,`PATCH`,`HEAD`,`OPTIONS`];var gn=class{appDir;extensions;verbose;constructor(e){this.appDir=E.resolve(e.appDir),this.extensions=e.extensions||[`.tsx`,`.jsx`,`.ts`,`.js`],this.verbose=e.verbose||!1}async generateManifest(){this.verbose&&console.warn(`[rari] Router: Scanning app directory: ${this.appDir}`);let e=[],t=[],n=[],r=[],i=[],a=[],o=[];return await this.scanDirectory(``,e,t,n,r,i,a,o),this.verbose&&(console.warn(`[rari] Router: Found ${e.length} routes`),console.warn(`[rari] Router: Found ${t.length} layouts`),console.warn(`[rari] Router: Found ${n.length} loading components`),console.warn(`[rari] Router: Found ${r.length} error boundaries`),console.warn(`[rari] Router: Found ${a.length} API routes`),console.warn(`[rari] Router: Found ${o.length} OG images`)),{routes:this.sortRoutes(e),layouts:this.sortLayouts(t),loading:n,errors:r,notFound:i,apiRoutes:this.sortApiRoutes(a),ogImages:o,generated:new Date().toISOString()}}async scanDirectory(e,t,n,r,i,a,o,s){let c=E.join(this.appDir,e),l;try{l=await T.readdir(c)}catch{return}let u=[],d=[];for(let e of l){let t=E.join(c,e),n=await T.stat(t);n.isDirectory()?this.shouldScanDirectory(e)&&d.push(e):n.isFile()&&u.push(e)}await this.processSpecialFiles(e,u,t,n,r,i,a,o,s);for(let c of d){let l=e?E.join(e,c):c;await this.scanDirectory(l,t,n,r,i,a,o,s)}}async processSpecialFiles(e,t,n,r,i,a,o,s,c){let l=this.pathToRoute(e),u=this.findFile(t,Q.PAGE);if(u){let t=this.parseRouteSegments(e),r=this.extractParams(t);n.push({path:l,filePath:E.join(e,u).replace(C,`/`),segments:t,params:r,isDynamic:r.length>0})}let d=this.findFile(t,Q.LAYOUT);if(d){let t=this.getParentPath(e);r.push({path:l,filePath:E.join(e,d).replace(C,`/`),parentPath:t?this.pathToRoute(t):void 0})}let f=this.findFile(t,Q.LOADING);if(f){let t=this.generateComponentId(l,`loading`);i.push({path:l,filePath:E.join(e,f).replace(C,`/`),componentId:t})}let p=this.findFile(t,Q.ERROR);p&&a.push({path:l,filePath:E.join(e,p).replace(C,`/`)});let m=this.findFile(t,Q.NOT_FOUND);m&&o.push({path:l,filePath:E.join(e,m).replace(C,`/`)});let h=this.findFile(t,Q.OG_IMAGE);if(h){let t=E.join(e,h).replace(C,`/`),n=E.join(this.appDir,t),r,i,a;try{let e=await T.readFile(n,`utf-8`),t=e.match(pn);t&&(r=Number.parseInt(t[1],10),i=Number.parseInt(t[2],10));let o=e.match(mn);o&&(a=o[1])}catch{}c.push({path:l,filePath:t,width:r,height:i,contentType:a})}let g=this.findFile(t,Q.ROUTE);if(g){let t=await this.processApiRouteFile(e,g);s.push(t)}}findFile(e,t){for(let n of this.extensions){let r=`${t}${n}`;if(e.includes(r))return r}}pathToRoute(e){return e?`/${e.replace(C,`/`).split(`/`).filter(Boolean).map(e=>$.OPTIONAL_CATCH_ALL.test(e)?`[[...${e.match($.OPTIONAL_CATCH_ALL)[1]}]]`:$.CATCH_ALL.test(e)?`[...${e.match($.CATCH_ALL)[1]}]`:$.DYNAMIC.test(e)?`[${e.match($.DYNAMIC)[1]}]`:e).join(`/`)}`:`/`}parseRouteSegments(e){return e?e.split(S).filter(Boolean).map(e=>$.OPTIONAL_CATCH_ALL.test(e)?{type:`optional-catch-all`,value:e,param:e.match($.OPTIONAL_CATCH_ALL)[1]}:$.CATCH_ALL.test(e)?{type:`catch-all`,value:e,param:e.match($.CATCH_ALL)[1]}:$.DYNAMIC.test(e)?{type:`dynamic`,value:e,param:e.match($.DYNAMIC)[1]}:{type:`static`,value:e}):[]}extractParams(e){return e.filter(e=>e.param!==void 0).map(e=>e.param)}getParentPath(e){if(!e)return null;let t=e.split(S).filter(Boolean);return t.length===0?null:t.slice(0,-1).join(`/`)}generateComponentId(e,t){return`${t}:${e}`}shouldScanDirectory(e){return![`node_modules`,`.git`,`dist`,`build`,`__tests__`,`test`,`tests`,`coverage`].includes(e)&&!e.startsWith(`.`)}sortRoutes(e){return e.sort((e,t)=>{let n=e=>{if(!e.isDynamic)return 0;let t=e.segments.some(e=>e.type===`catch-all`);return e.segments.some(e=>e.type===`optional-catch-all`)?3:t?2:1},r=n(e),i=n(t);if(r!==i)return r-i;let a=e.path.split(`/`).length,o=t.path.split(`/`).length;return a===o?e.path.localeCompare(t.path):o-a})}sortApiRoutes(e){return e.sort((e,t)=>{if(!e.isDynamic&&t.isDynamic)return-1;if(e.isDynamic&&!t.isDynamic)return 1;let n=e.path.split(`/`).length,r=t.path.split(`/`).length;return n===r?e.path.localeCompare(t.path):n-r})}sortLayouts(e){return e.sort((e,t)=>e.path===`/`&&t.path!==`/`?-1:t.path===`/`&&e.path!==`/`?1:e.path.split(`/`).length-t.path.split(`/`).length)}async detectHttpMethods(e){let t=E.join(this.appDir,e),n=await T.readFile(t,`utf-8`),r=[];for(let e of hn){let t=RegExp(`export\\s+(?:async\\s+)?function\\s+${e}\\s*\\(`),i=RegExp(`export\\s+(?:async\\s+)?(?:const|let|var)\\s+${e}\\s*=`);(t.test(n)||i.test(n))&&r.push(e)}return r}async processApiRouteFile(e,t){let n=E.join(e,t).replace(C,`/`),r=this.pathToRoute(e),i=this.parseRouteSegments(e),a=this.extractParams(i),o=await this.detectHttpMethods(n);return{path:r,filePath:n,segments:i,params:a,isDynamic:a.length>0,methods:o}}};async function _n(e,t={}){return new gn({appDir:e,...t}).generateManifest()}function vn(e){return ln(e)}export{dn as ApiResponse,c as HttpRuntimeClient,e as RariRequest,t as RariResponse,i as clearPropsCache,a as clearPropsCacheForComponent,r as createHttpRuntimeClient,un as defineRariConfig,cn as defineRariOptions,u as extractMetadata,l as extractServerProps,s as extractServerPropsWithCache,o as extractStaticParams,_n as generateAppRouteManifest,n as hasServerSideDataFetching,vn as rari,le as rariProxy,be as rariRouter};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rari",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.14.
|
|
4
|
+
"version": "0.14.4",
|
|
5
5
|
"description": "Runtime Accelerated Rendering Infrastructure (rari)",
|
|
6
6
|
"author": "Ryan Skinner",
|
|
7
7
|
"license": "MIT",
|
|
@@ -107,22 +107,23 @@
|
|
|
107
107
|
"react-dom": "^19.2.6"
|
|
108
108
|
},
|
|
109
109
|
"dependencies": {
|
|
110
|
+
"lightningcss": "^1.32.0",
|
|
110
111
|
"rolldown": "^1.0.3"
|
|
111
112
|
},
|
|
112
113
|
"optionalDependencies": {
|
|
113
|
-
"rari-darwin-arm64": "0.14.
|
|
114
|
-
"rari-darwin-x64": "0.14.
|
|
115
|
-
"rari-linux-arm64": "0.14.
|
|
116
|
-
"rari-linux-x64": "0.14.
|
|
117
|
-
"rari-win32-arm64": "0.14.
|
|
118
|
-
"rari-win32-x64": "0.14.
|
|
114
|
+
"rari-darwin-arm64": "0.14.4",
|
|
115
|
+
"rari-darwin-x64": "0.14.4",
|
|
116
|
+
"rari-linux-arm64": "0.14.4",
|
|
117
|
+
"rari-linux-x64": "0.14.4",
|
|
118
|
+
"rari-win32-arm64": "0.14.4",
|
|
119
|
+
"rari-win32-x64": "0.14.4"
|
|
119
120
|
},
|
|
120
121
|
"devDependencies": {
|
|
121
122
|
"@types/node": "^25.9.1",
|
|
122
|
-
"@types/react": "^19.2.
|
|
123
|
+
"@types/react": "^19.2.16",
|
|
123
124
|
"@types/react-dom": "^19.2.3",
|
|
124
|
-
"@typescript/native-preview": "^7.0.0-dev.
|
|
125
|
-
"vite-plus": "^0.1.
|
|
125
|
+
"@typescript/native-preview": "^7.0.0-dev.20260602.1",
|
|
126
|
+
"vite-plus": "^0.1.24",
|
|
126
127
|
"@rari/deploy": "0.1.0",
|
|
127
128
|
"@rari/logger": "0.1.0"
|
|
128
129
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=/\.(?:tsx?|jsx?)$/,t=/^[A-Z]:\\/i,n=/\\/g,r=/[/\\]/,i=/\/$/,a=/^src\//,o=/^file:\/\//,s=/^https?:\/\//,c={AMPERSAND:/&/g,LT:/</g,GT:/>/g,QUOTE:/"/g,APOS:/'/g},l=c.AMPERSAND,u=c.LT,d=c.GT,f=c.QUOTE,p=c.APOS,m=l,h=u,g=d,_=f,v=p,y=l,b=u,x=d,S=f,C=p,w=/[^\w/-]/g,T=/^\d+$/,E=/([a-z])([A-Z])/g,D=/export\s+(?:function|const|class)\s+(\w+)/,O=/\.[^.]*$/,k=/\r?\n/,A=/['"]/g;export{x as C,C as S,S as T,A as _,O as a,t as b,v as c,_ as d,s as f,i as g,r as h,D as i,g as l,T as m,E as n,o,k as p,w as r,m as s,n as t,h as u,a as v,b as w,y as x,e as y};
|
|
File without changes
|