rari 0.8.13 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +1 -1
- package/dist/client.d.mts +1 -1
- package/dist/get-client-component-CR5zDUvd.mjs +1 -0
- package/dist/{index-Ek-rRSpB.d.mts → index-WODoeA3e.d.mts} +2 -17
- package/dist/index.d.mts +4 -3
- package/dist/index.mjs +1 -1
- package/dist/preload-components-CwqehMyC.mjs +1 -0
- package/dist/proxy/RariRequest.d.mts +1 -1
- package/dist/proxy/RariResponse.d.mts +17 -0
- package/dist/proxy/RariResponse.mjs +1 -0
- package/dist/{railway-B__dJ7bJ.mjs → railway-C_RKUxHY.mjs} +1 -1
- package/dist/{render-LdidKjWk.mjs → render-D25Vkzyw.mjs} +1 -1
- package/dist/runtime/AppRouterProvider.mjs +4 -4
- package/dist/runtime/entry-client.d.mts +2 -1
- package/dist/runtime/entry-client.mjs +4 -4
- package/dist/runtime/react-server-dom-rari-client.mjs +2 -2
- package/dist/runtime/rsc-client-runtime.mjs +1 -1
- package/dist/{server-build-C64b2Z-d.mjs → server-build-DM-rQz-k.mjs} +4 -4
- package/dist/vite-C4gs8tq5.mjs +79 -0
- package/dist/vite.d.mts +4 -3
- package/dist/vite.mjs +1 -1
- package/package.json +13 -13
- package/dist/get-client-component-B2SS0Ben.mjs +0 -1
- package/dist/vite-CfH7EIl7.mjs +0 -72
- /package/dist/{robots-generator-CuKrsgKO.mjs → robots-generator-DlnLLn5V.mjs} +0 -0
- /package/dist/{server-config-5RHHggaf.d.mts → server-config-B0xinLcw.d.mts} +0 -0
- /package/dist/{sitemap-generator-B6H3XwXt.mjs → sitemap-generator-D3T5zkl3.mjs} +0 -0
- /package/dist/{types-BIZmYbNs.d.mts → types-FjFDidgJ.d.mts} +0 -0
- /package/dist/{utils-CvELqhML-CLd5cK7j.mjs → utils-CvELqhML-BOdGyCyF.mjs} +0 -0
package/dist/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import{getBinaryPath as e,getInstallationInstructions as t}from"./platform.mjs";import{existsSync as n,readFileSync as r}from"node:fs";import{resolve as i}from"node:path";import a from"node:process";import{spawn as o}from"node:child_process";import{styleText as s}from"node:util";function c(e){console.warn(`${s(`blue`,`info`)} ${e}`)}function l(e){console.warn(`${s(`green`,`✓`)} ${e}`)}function u(e){console.error(`${s(`red`,`✗`)} ${e}`)}function d(e){console.warn(`${s(`yellow`,`⚠`)} ${e}`)}function f(){let e=i(a.cwd(),`.env`);if(n(e)){let t=r(e,`utf-8`);for(let e of t.split(`
|
|
3
|
-
`)){let t=e.trim();if(!t||t.startsWith(`#`))continue;let n=t.match(/^([^=]+)=(.*)$/);if(n){let[,e,t]=n,r=e.trim(),i=t.trim();(i.startsWith(`"`)&&i.endsWith(`"`)||i.startsWith(`'`)&&i.endsWith(`'`))&&(i=i.slice(1,-1)),a.env[r]||(a.env[r]=i)}}}}f();const[,,p,...m]=a.argv;function h(){let e=a.cwd(),t=i(`/`),o=0;for(;e!==t&&o<20;){if(o++,n(i(e,`pnpm-lock.yaml`)))return`pnpm`;if(n(i(e,`yarn.lock`)))return`yarn`;if(n(i(e,`bun.lockb`)))return`bun`;if(n(i(e,`package-lock.json`)))return`npm`;try{let t=i(e,`package.json`);if(n(t)){let e=JSON.parse(r(t,`utf-8`));if(e.packageManager?.startsWith(`pnpm`))return`pnpm`;if(e.packageManager?.startsWith(`yarn`))return`yarn`;if(e.packageManager?.startsWith(`bun`))return`bun`;if(e.packageManager?.startsWith(`npm`))return`npm`}}catch{}let t=i(e,`..`);if(t===e)break;e=t}return`npm`}function g(){let e=h(),t=a.platform===`win32`;switch(e){case`bun`:return t?`bun.cmd`:`bun`;case`pnpm`:return t?`pnpm.cmd`:`pnpm`;case`yarn`:return t?`yarn.cmd`:`yarn`;default:return t?`npx.cmd`:`npx`}}function _(e,t,n={}){if(e===`npx`){let e=g();if(e.includes(`bun`))return o(e,[`x`,...t],n);if(e.includes(`pnpm`))return o(e,[`exec`,...t],n);if(e.includes(`yarn`))return o(e,[`dlx`,...t],n)}return a.platform===`win32`&&e===`npx`?o(`npx.cmd`,t,n):o(e,t,n)}function v(e){if(e instanceof Error)return e.message;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function y(){return!!(a.env.RAILWAY_ENVIRONMENT||a.env.RAILWAY_PROJECT_ID||a.env.RAILWAY_SERVICE_ID)}function b(){return!!(a.env.RENDER||a.env.RENDER_SERVICE_ID||a.env.RENDER_SERVICE_NAME)}function x(){return y()||b()}function S(){return y()?`Railway`:b()?`Render`:`local`}function C(){return{port:a.env.PORT||a.env.RSC_PORT||`3000`,mode:a.env.NODE_ENV||`production`,host:x()?`0.0.0.0`:`127.0.0.1`}}async function w(){let{existsSync:e,rmSync:t}=await import(`node:fs`),{resolve:n}=await import(`node:path`),r=n(a.cwd(),`dist`);e(r)&&(c(`Cleaning dist folder...`),t(r,{recursive:!0,force:!0})),c(`Type checking...`);let i=_(`npx`,[`tsgo`],{stdio:`inherit`,cwd:a.cwd()});await new Promise((e,t)=>{i.on(`exit`,n=>{n===0?(l(`Type check passed`),e()):(u(`Type check failed with code ${n}`),t(Error(`Type check failed with code ${n}`)))}),i.on(`error`,t)}),c(`Building for production...`);let o=_(`npx`,[`vite`,`build`],{stdio:`inherit`,cwd:a.cwd()});await new Promise((e,t)=>{o.on(`exit`,n=>{n===0?(l(`Build complete`),e()):(u(`Build failed with code ${n}`),t(Error(`Build failed with code ${n}`)))}),o.on(`error`,t)}),await T()}async function T(){if(n(i(a.cwd(),`dist`,`server`,`image.json`))&&n(i(a.cwd(),`public`)))try{let t=o(e(),[`optimize-images`],{stdio:`inherit`,cwd:a.cwd(),shell:!1});await new Promise(e=>{t.on(`exit`,t=>{t===0||d(`Image pre-optimization exited with code ${t}`),e()}),t.on(`error`,t=>{d(`Image pre-optimization error: ${v(t)}`),e()})})}catch(e){d(`Could not pre-optimize images: ${v(e)}`)}}async function E(){let{existsSync:e}=await import(`node:fs`),{resolve:t}=await import(`node:path`);if(!e(t(a.cwd(),`dist`))){c(`First run detected - building project...`);let e=_(`npx`,[`vite`,`build`,`--mode`,`development`],{stdio:`inherit`,cwd:a.cwd()});await new Promise((t,n)=>{e.on(`exit`,e=>{e===0?(l(`Initial build complete`),t()):(u(`Build failed with code ${e}`),n(Error(`Build failed with code ${e}`)))}),e.on(`error`,n)})}c(`Starting Vite dev server...`);let n=_(`npx`,[`vite`],{stdio:`inherit`,cwd:a.cwd()}),r=()=>{c(`Shutting down dev server...`),n.kill(`SIGTERM`)};return a.on(`SIGINT`,r),a.on(`SIGTERM`,r),n.on(`error`,e=>{u(`Failed to start Vite: ${e.message}`),a.exit(1)}),n.on(`exit`,e=>{e!==0&&e!==null&&(u(`Vite exited with code ${e}`),a.exit(e))}),new Promise(()=>{})}async function D(){let n;try{n=e()}catch{u(`Failed to obtain rari binary`),u(t()),a.exit(1)}let{port:r,mode:i,host:s}=C();if(x()){let e=S();c(`${e} environment detected`),c(`Starting rari server for ${e} deployment...`),c(`Mode: ${i}, Host: ${s}, Port: ${r}`),c(`using binary: ${n}`)}let d=o(n,[`--mode`,i,`--port`,r,`--host`,s],{stdio:`inherit`,cwd:a.cwd(),env:{...a.env,RUST_LOG:a.env.RUST_LOG||`error`}}),f=()=>{c(`shutting down...`),d.kill(`SIGTERM`)};return a.on(`SIGINT`,f),a.on(`SIGTERM`,f),d.on(`error`,e=>{u(`Failed to start rari server: ${e.message}`),e.message.includes(`ENOENT`)&&u(`Binary not found. Please ensure rari is properly installed.`),a.exit(1)}),d.on(`exit`,(e,t)=>{t?c(`server stopped by signal ${t}`):e===0?l(`server stopped successfully`):(u(`server exited with code ${e}`),a.exit(e||1))}),new Promise(()=>{})}async function O(){c(`Setting up Railway deployment...`),x()&&(u(`Already running in ${S()} environment. Use "rari start" instead.`),a.exit(1));let{createRailwayDeployment:e}=await import(`./railway-
|
|
3
|
+
`)){let t=e.trim();if(!t||t.startsWith(`#`))continue;let n=t.match(/^([^=]+)=(.*)$/);if(n){let[,e,t]=n,r=e.trim(),i=t.trim();(i.startsWith(`"`)&&i.endsWith(`"`)||i.startsWith(`'`)&&i.endsWith(`'`))&&(i=i.slice(1,-1)),a.env[r]||(a.env[r]=i)}}}}f();const[,,p,...m]=a.argv;function h(){let e=a.cwd(),t=i(`/`),o=0;for(;e!==t&&o<20;){if(o++,n(i(e,`pnpm-lock.yaml`)))return`pnpm`;if(n(i(e,`yarn.lock`)))return`yarn`;if(n(i(e,`bun.lockb`)))return`bun`;if(n(i(e,`package-lock.json`)))return`npm`;try{let t=i(e,`package.json`);if(n(t)){let e=JSON.parse(r(t,`utf-8`));if(e.packageManager?.startsWith(`pnpm`))return`pnpm`;if(e.packageManager?.startsWith(`yarn`))return`yarn`;if(e.packageManager?.startsWith(`bun`))return`bun`;if(e.packageManager?.startsWith(`npm`))return`npm`}}catch{}let t=i(e,`..`);if(t===e)break;e=t}return`npm`}function g(){let e=h(),t=a.platform===`win32`;switch(e){case`bun`:return t?`bun.cmd`:`bun`;case`pnpm`:return t?`pnpm.cmd`:`pnpm`;case`yarn`:return t?`yarn.cmd`:`yarn`;default:return t?`npx.cmd`:`npx`}}function _(e,t,n={}){if(e===`npx`){let e=g();if(e.includes(`bun`))return o(e,[`x`,...t],n);if(e.includes(`pnpm`))return o(e,[`exec`,...t],n);if(e.includes(`yarn`))return o(e,[`dlx`,...t],n)}return a.platform===`win32`&&e===`npx`?o(`npx.cmd`,t,n):o(e,t,n)}function v(e){if(e instanceof Error)return e.message;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function y(){return!!(a.env.RAILWAY_ENVIRONMENT||a.env.RAILWAY_PROJECT_ID||a.env.RAILWAY_SERVICE_ID)}function b(){return!!(a.env.RENDER||a.env.RENDER_SERVICE_ID||a.env.RENDER_SERVICE_NAME)}function x(){return y()||b()}function S(){return y()?`Railway`:b()?`Render`:`local`}function C(){return{port:a.env.PORT||a.env.RSC_PORT||`3000`,mode:a.env.NODE_ENV||`production`,host:x()?`0.0.0.0`:`127.0.0.1`}}async function w(){let{existsSync:e,rmSync:t}=await import(`node:fs`),{resolve:n}=await import(`node:path`),r=n(a.cwd(),`dist`);e(r)&&(c(`Cleaning dist folder...`),t(r,{recursive:!0,force:!0})),c(`Type checking...`);let i=_(`npx`,[`tsgo`],{stdio:`inherit`,cwd:a.cwd()});await new Promise((e,t)=>{i.on(`exit`,n=>{n===0?(l(`Type check passed`),e()):(u(`Type check failed with code ${n}`),t(Error(`Type check failed with code ${n}`)))}),i.on(`error`,t)}),c(`Building for production...`);let o=_(`npx`,[`vite`,`build`],{stdio:`inherit`,cwd:a.cwd()});await new Promise((e,t)=>{o.on(`exit`,n=>{n===0?(l(`Build complete`),e()):(u(`Build failed with code ${n}`),t(Error(`Build failed with code ${n}`)))}),o.on(`error`,t)}),await T()}async function T(){if(n(i(a.cwd(),`dist`,`server`,`image.json`))&&n(i(a.cwd(),`public`)))try{let t=o(e(),[`optimize-images`],{stdio:`inherit`,cwd:a.cwd(),shell:!1});await new Promise(e=>{t.on(`exit`,t=>{t===0||d(`Image pre-optimization exited with code ${t}`),e()}),t.on(`error`,t=>{d(`Image pre-optimization error: ${v(t)}`),e()})})}catch(e){d(`Could not pre-optimize images: ${v(e)}`)}}async function E(){let{existsSync:e}=await import(`node:fs`),{resolve:t}=await import(`node:path`);if(!e(t(a.cwd(),`dist`))){c(`First run detected - building project...`);let e=_(`npx`,[`vite`,`build`,`--mode`,`development`],{stdio:`inherit`,cwd:a.cwd()});await new Promise((t,n)=>{e.on(`exit`,e=>{e===0?(l(`Initial build complete`),t()):(u(`Build failed with code ${e}`),n(Error(`Build failed with code ${e}`)))}),e.on(`error`,n)})}c(`Starting Vite dev server...`);let n=_(`npx`,[`vite`],{stdio:`inherit`,cwd:a.cwd()}),r=()=>{c(`Shutting down dev server...`),n.kill(`SIGTERM`)};return a.on(`SIGINT`,r),a.on(`SIGTERM`,r),n.on(`error`,e=>{u(`Failed to start Vite: ${e.message}`),a.exit(1)}),n.on(`exit`,e=>{e!==0&&e!==null&&(u(`Vite exited with code ${e}`),a.exit(e))}),new Promise(()=>{})}async function D(){let n;try{n=e()}catch{u(`Failed to obtain rari binary`),u(t()),a.exit(1)}let{port:r,mode:i,host:s}=C();if(x()){let e=S();c(`${e} environment detected`),c(`Starting rari server for ${e} deployment...`),c(`Mode: ${i}, Host: ${s}, Port: ${r}`),c(`using binary: ${n}`)}let d=o(n,[`--mode`,i,`--port`,r,`--host`,s],{stdio:`inherit`,cwd:a.cwd(),env:{...a.env,RUST_LOG:a.env.RUST_LOG||`error`}}),f=()=>{c(`shutting down...`),d.kill(`SIGTERM`)};return a.on(`SIGINT`,f),a.on(`SIGTERM`,f),d.on(`error`,e=>{u(`Failed to start rari server: ${e.message}`),e.message.includes(`ENOENT`)&&u(`Binary not found. Please ensure rari is properly installed.`),a.exit(1)}),d.on(`exit`,(e,t)=>{t?c(`server stopped by signal ${t}`):e===0?l(`server stopped successfully`):(u(`server exited with code ${e}`),a.exit(e||1))}),new Promise(()=>{})}async function O(){c(`Setting up Railway deployment...`),x()&&(u(`Already running in ${S()} environment. Use "rari start" instead.`),a.exit(1));let{createRailwayDeployment:e}=await import(`./railway-C_RKUxHY.mjs`);await e()}async function k(){c(`Setting up Render deployment...`),x()&&(u(`Already running in ${S()} environment. Use "rari start" instead.`),a.exit(1));let{createRenderDeployment:e}=await import(`./render-D25Vkzyw.mjs`);await e()}async function A(){switch(p){case void 0:case`help`:case`--help`:case`-h`:console.warn(`${s(`bold`,`rari CLI`)}
|
|
4
4
|
|
|
5
5
|
${s(`bold`,`Usage:`)}
|
|
6
6
|
${s(`cyan`,`rari dev`)} Start the development server with Vite
|
package/dist/client.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as MetadataResult, E as NotFoundEntry, F as extractMetadata, I as extractServerProps, L as extractServerPropsWithCache, M as StaticParamsResult, N as clearPropsCache, O as RouteSegment, P as clearPropsCacheForComponent, R as extractStaticParams, S as LayoutEntry, _ as AppRouteMatch, a as DefaultError, b as GenerateMetadata, c as HttpRuntimeClient, d as RuntimeClient, f as createErrorBoundary, g as AppRouteManifest, h as AppRouteEntry, i as ServerSpamBlockerConfig, j as ServerSidePropsResult, k as RouteSegmentType, l as LoadingSpinner, m as createLoadingBoundary, n as ServerConfig, o as DefaultLoading, p as createHttpRuntimeClient, r as ServerRateLimitConfig, s as ErrorBoundary, t as ServerCSPConfig, u as NotFound, v as ErrorEntry, w as LoadingEntry, x as GenerateStaticParams, y as ErrorProps, z as hasServerSideDataFetching } from "./server-config-
|
|
1
|
+
import { A as MetadataResult, E as NotFoundEntry, F as extractMetadata, I as extractServerProps, L as extractServerPropsWithCache, M as StaticParamsResult, N as clearPropsCache, O as RouteSegment, P as clearPropsCacheForComponent, R as extractStaticParams, S as LayoutEntry, _ as AppRouteMatch, a as DefaultError, b as GenerateMetadata, c as HttpRuntimeClient, d as RuntimeClient, f as createErrorBoundary, g as AppRouteManifest, h as AppRouteEntry, i as ServerSpamBlockerConfig, j as ServerSidePropsResult, k as RouteSegmentType, l as LoadingSpinner, m as createLoadingBoundary, n as ServerConfig, o as DefaultLoading, p as createHttpRuntimeClient, r as ServerRateLimitConfig, s as ErrorBoundary, t as ServerCSPConfig, u as NotFound, v as ErrorEntry, w as LoadingEntry, x as GenerateStaticParams, y as ErrorProps, z as hasServerSideDataFetching } from "./server-config-B0xinLcw.mjs";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { Component, ErrorInfo, ReactNode } from "react";
|
|
4
4
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e){return e.loading=!0,e.loadPromise=e.loader().then(t=>{let n=t.default||t;return e.component=n,e.registered=!0,e.loading=!1,n}).catch(t=>{throw console.error(`[rari] Failed to load component ${e.id}:`,t),e.loading=!1,e.loadPromise=void 0,t}),e.loadPromise}async function t(t,n){if(t.component)return n&&n!==`default`?t.component[n]:t.component;if(t.loadPromise)return await t.loadPromise,n&&n!==`default`?t.component[n]:t.component;if(t.loader){let r=await e(t);return n&&n!==`default`?r[n]:r}return null}function n(t){!t.loader||t.loading||t.component||t.loadPromise||e(t)}function r(e,t){return e.component||e.loader&&!e.loading&&(e.loading=!0,e.loadPromise=e.loader().then(t=>(e.component=t.default||t,e.registered=!0,e.loading=!1,e.component)).catch(n=>{e.loading=!1,e.loadPromise=void 0,console.error(`[rari] Failed to load component ${t}:`,n)})),null}function i(e,t){let r=t[`~clientComponents`]||{},i=t[`~clientComponentPaths`]||{},a=t[`~clientComponentNames`]||{};if(r[e]){let t=r[e];return t.component?t.component:(t.loader&&!t.loading&&!t.loadPromise&&n(t),null)}if(e.includes(`#`)){let[t,a]=e.split(`#`),o=i[t];if(o&&r[o]){let e=r[o];return e.component?a===`default`||!a?e.component:e.component[a]:(e.loader&&!e.loading&&!e.loadPromise&&n(e),null)}let s=i[t.startsWith(`./`)?t.slice(2):t];if(s&&r[s]){let e=r[s];return e.component?a===`default`||!a?e.component:e.component[a]:(e.loader&&!e.loading&&!e.loadPromise&&n(e),null)}}let o=a[e];if(o&&r[o]){let e=r[o];return e.component?e.component:(e.loader&&!e.loading&&!e.loadPromise&&n(e),null)}return null}function a(e){return i(e,globalThis)}async function o(e){let n=globalThis[`~clientComponents`]||{},r=globalThis[`~clientComponentPaths`]||{},i=n[e];if(!i&&e.includes(`#`)){let[t]=e.split(`#`),a=r[t];a&&(i=n[a])}return i?await t(i,e.includes(`#`)?e.split(`#`)[1]:void 0):null}export{o as n,r,a as t};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { g as AppRouteManifest, i as ServerSpamBlockerConfig, r as ServerRateLimitConfig, t as ServerCSPConfig } from "./server-config-
|
|
2
|
-
import { u as ResponseCookies } from "./types-BIZmYbNs.mjs";
|
|
1
|
+
import { g as AppRouteManifest, i as ServerSpamBlockerConfig, r as ServerRateLimitConfig, t as ServerCSPConfig } from "./server-config-B0xinLcw.mjs";
|
|
3
2
|
import { Plugin, UserConfig } from "rolldown-vite";
|
|
4
3
|
|
|
5
4
|
//#region src/types/metadata-route.d.ts
|
|
@@ -82,20 +81,6 @@ declare class ApiResponse extends Response {
|
|
|
82
81
|
static noContent(init?: ResponseInit): Response;
|
|
83
82
|
}
|
|
84
83
|
//#endregion
|
|
85
|
-
//#region src/proxy/RariResponse.d.ts
|
|
86
|
-
declare class RariResponse extends Response {
|
|
87
|
-
cookies: ResponseCookies;
|
|
88
|
-
constructor(body?: BodyInit | null, init?: ResponseInit);
|
|
89
|
-
static next(init?: {
|
|
90
|
-
request?: {
|
|
91
|
-
headers?: Headers | Record<string, string>;
|
|
92
|
-
};
|
|
93
|
-
}): RariResponse;
|
|
94
|
-
static redirect(url: string | URL, status?: number): RariResponse;
|
|
95
|
-
static rewrite(destination: string | URL): RariResponse;
|
|
96
|
-
static json(data: unknown, init?: ResponseInit): RariResponse;
|
|
97
|
-
}
|
|
98
|
-
//#endregion
|
|
99
84
|
//#region src/proxy/vite-plugin.d.ts
|
|
100
85
|
interface ProxyPluginOptions {
|
|
101
86
|
root?: string;
|
|
@@ -191,4 +176,4 @@ declare function defineRariConfig(config: UserConfig & {
|
|
|
191
176
|
plugins?: Plugin[];
|
|
192
177
|
}): UserConfig;
|
|
193
178
|
//#endregion
|
|
194
|
-
export {
|
|
179
|
+
export { SitemapVideo as _, generateAppRouteManifest as a, ApiResponse as c, RouteHandler as d, Robots as f, SitemapImage as g, SitemapEntry as h, rariRouter as i, ApiRouteHandlers as l, Sitemap as m, defineRariOptions as n, ProxyPluginOptions as o, RobotsRule as p, rari as r, rariProxy as s, defineRariConfig as t, RouteContext as u };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { A as MetadataResult, C as LayoutProps, D as PageProps, E as NotFoundEntry, F as extractMetadata, I as extractServerProps, L as extractServerPropsWithCache, M as StaticParamsResult, N as clearPropsCache, O as RouteSegment, P as clearPropsCacheForComponent, R as extractStaticParams, S as LayoutEntry, T as Metadata, _ as AppRouteMatch, b as GenerateMetadata, c as HttpRuntimeClient, d as RuntimeClient, g as AppRouteManifest, h as AppRouteEntry, i as ServerSpamBlockerConfig, j as ServerSidePropsResult, k as RouteSegmentType, n as ServerConfig, p as createHttpRuntimeClient, r as ServerRateLimitConfig, t as ServerCSPConfig, v as ErrorEntry, w as LoadingEntry, x as GenerateStaticParams, y as ErrorProps, z as hasServerSideDataFetching } from "./server-config-
|
|
2
|
-
import { _ as
|
|
3
|
-
import { a as ProxyModule, c as RariURL, i as ProxyMatcher, l as RequestCookies, n as ProxyConfig, o as ProxyResult, r as ProxyFunction, s as RariFetchEvent, t as CookieOptions, u as ResponseCookies } from "./types-
|
|
1
|
+
import { A as MetadataResult, C as LayoutProps, D as PageProps, E as NotFoundEntry, F as extractMetadata, I as extractServerProps, L as extractServerPropsWithCache, M as StaticParamsResult, N as clearPropsCache, O as RouteSegment, P as clearPropsCacheForComponent, R as extractStaticParams, S as LayoutEntry, T as Metadata, _ as AppRouteMatch, b as GenerateMetadata, c as HttpRuntimeClient, d as RuntimeClient, g as AppRouteManifest, h as AppRouteEntry, i as ServerSpamBlockerConfig, j as ServerSidePropsResult, k as RouteSegmentType, n as ServerConfig, p as createHttpRuntimeClient, r as ServerRateLimitConfig, t as ServerCSPConfig, v as ErrorEntry, w as LoadingEntry, x as GenerateStaticParams, y as ErrorProps, z as hasServerSideDataFetching } from "./server-config-B0xinLcw.mjs";
|
|
2
|
+
import { _ as SitemapVideo, a as generateAppRouteManifest, c as ApiResponse, d as RouteHandler, f as Robots, g as SitemapImage, h as SitemapEntry, i as rariRouter, l as ApiRouteHandlers, m as Sitemap, n as defineRariOptions, o as ProxyPluginOptions, p as RobotsRule, r as rari, s as rariProxy, t as defineRariConfig, u as RouteContext } from "./index-WODoeA3e.mjs";
|
|
3
|
+
import { a as ProxyModule, c as RariURL, i as ProxyMatcher, l as RequestCookies, n as ProxyConfig, o as ProxyResult, r as ProxyFunction, s as RariFetchEvent, t as CookieOptions, u as ResponseCookies } from "./types-FjFDidgJ.mjs";
|
|
4
4
|
import { RariRequest } from "./proxy/RariRequest.mjs";
|
|
5
|
+
import { RariResponse } from "./proxy/RariResponse.mjs";
|
|
5
6
|
import { Request, Response } from "./vite.mjs";
|
|
6
7
|
export { ApiResponse, ApiRouteHandlers, AppRouteEntry, AppRouteManifest, AppRouteMatch, CookieOptions, ErrorEntry, ErrorProps, GenerateMetadata, GenerateStaticParams, HttpRuntimeClient, LayoutEntry, LayoutProps, LoadingEntry, type Metadata, MetadataResult, NotFoundEntry, PageProps, ProxyConfig, ProxyFunction, ProxyMatcher, ProxyModule, ProxyPluginOptions, ProxyResult, RariFetchEvent, RariRequest, RariResponse, RariURL, Request, RequestCookies, Response, ResponseCookies, type Robots, type RobotsRule, RouteContext, RouteHandler, RouteSegment, RouteSegmentType, RuntimeClient, ServerCSPConfig, ServerConfig, ServerRateLimitConfig, ServerSidePropsResult, ServerSpamBlockerConfig, type Sitemap, type SitemapEntry, type SitemapImage, type SitemapVideo, StaticParamsResult, clearPropsCache, clearPropsCacheForComponent, createHttpRuntimeClient, defineRariConfig, defineRariOptions, extractMetadata, extractServerProps, extractServerPropsWithCache, extractStaticParams, generateAppRouteManifest, hasServerSideDataFetching, rari, rariProxy, rariRouter };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,i as t,n,o as r,r as i,
|
|
1
|
+
import{a as e,i as t,n,o as r,r as i,t as a}from"./vite-C4gs8tq5.mjs";import{RariRequest as o}from"./proxy/RariRequest.mjs";import{RariResponse as s}from"./proxy/RariResponse.mjs";import{c,d as l,f as u,g as d,h as f,i as p,m,p as h,u as g}from"./runtime-client-Bg4V1Ksp.mjs";import{t as _}from"./routes-DbsqVAaM.mjs";import"./constants-CmqZuM5B.mjs";import"./server-build-DM-rQz-k.mjs";import"./vite.mjs";export{r as ApiResponse,p as HttpRuntimeClient,o as RariRequest,s as RariResponse,g as clearPropsCache,l as clearPropsCacheForComponent,c as createHttpRuntimeClient,a as defineRariConfig,n as defineRariOptions,u as extractMetadata,h as extractServerProps,m as extractServerPropsWithCache,f as extractStaticParams,_ as generateAppRouteManifest,d as hasServerSideDataFetching,i as rari,e as rariProxy,t as rariRouter};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
async function e(e){let t=globalThis[`~clientComponents`]||{},n=[];for(let[,r]of e){let e=[r.id,`${r.id}#${r.name||`default`}`,r.id.replace(/^src\//,``),r.id.replace(/\\/g,`/`)];for(let r of e){let e=t[r];if(e?.loader&&!e.component&&!e.loading){e.loading=!0,e.loadPromise=e.loader().then(t=>{e.component=t.default||t,e.registered=!0,e.loading=!1}).catch(t=>{e.loading=!1,e.loadPromise=void 0,console.error(`[rari] Failed to preload component ${r}:`,t)}),n.push(e.loadPromise);break}}}n.length>0&&await Promise.all(n)}export{e as t};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { u as ResponseCookies } from "../types-FjFDidgJ.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/proxy/RariResponse.d.ts
|
|
4
|
+
declare class RariResponse extends Response {
|
|
5
|
+
cookies: ResponseCookies;
|
|
6
|
+
constructor(body?: BodyInit | null, init?: ResponseInit);
|
|
7
|
+
static next(init?: {
|
|
8
|
+
request?: {
|
|
9
|
+
headers?: Headers | Record<string, string>;
|
|
10
|
+
};
|
|
11
|
+
}): RariResponse;
|
|
12
|
+
static redirect(url: string | URL, status?: number): RariResponse;
|
|
13
|
+
static rewrite(destination: string | URL): RariResponse;
|
|
14
|
+
static json(data: unknown, init?: ResponseInit): RariResponse;
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { RariResponse };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=class{cookies;constructor(){this.cookies=new Map}get(e){let t=this.cookies.get(e);if(t)return{name:t.name,value:t.value,path:t.options?.path}}getAll(){return Array.from(this.cookies.values(),e=>({name:e.name,value:e.value,path:e.options?.path}))}set(e,t,n){if(typeof e==`string`)this.cookies.set(e,{name:e,value:t,options:n});else{let{name:t,value:n,...r}=e;this.cookies.set(t,{name:t,value:n,options:r})}}delete(e){this.cookies.delete(e)}toSetCookieHeaders(){return Array.from(this.cookies.values(),e=>{let t=`${e.name}=${e.value}`;return e.options&&(e.options.path&&(t+=`; Path=${e.options.path}`),e.options.domain&&(t+=`; Domain=${e.options.domain}`),e.options.maxAge&&(t+=`; Max-Age=${e.options.maxAge}`),e.options.expires&&(t+=`; Expires=${e.options.expires.toUTCString()}`),e.options.httpOnly&&(t+=`; HttpOnly`),e.options.secure&&(t+=`; Secure`),e.options.sameSite&&(t+=`; SameSite=${e.options.sameSite}`)),t})}},t=class t extends Response{cookies;constructor(t,n){super(t,n),this.cookies=new e}static next(e){let n=new t(null,{status:200,headers:{"x-rari-proxy-continue":`true`}});return e?.request?.headers&&(e.request.headers instanceof Headers?e.request.headers:new Headers(e.request.headers)).forEach((e,t)=>{n.headers.set(`x-rari-proxy-request-${t}`,e)}),n}static redirect(e,n){return new t(null,{status:n||307,headers:{Location:e.toString()}})}static rewrite(e){return new t(null,{status:200,headers:{"x-rari-proxy-rewrite":e.toString()}})}static json(e,n){return new t(JSON.stringify(e),{...n,headers:{"Content-Type":`application/json`,...n?.headers}})}};export{t as RariResponse};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e,i as t,n,r,t as i}from"./utils-CvELqhML-
|
|
1
|
+
import{a as e,i as t,n,r,t as i}from"./utils-CvELqhML-BOdGyCyF.mjs";import{existsSync as a,readFileSync as o,writeFileSync as s}from"node:fs";import{join as c}from"node:path";import l from"node:process";import{styleText as u}from"node:util";async function d(){let d=l.cwd();e(`Creating Railway deployment configuration...`);let f=c(d,`package.json`);a(f)||(t(`No package.json found. Please run this command from your project root.`),l.exit(1));try{let t=JSON.parse(o(f,`utf-8`));t.scripts=t.scripts||{},t.scripts.start&&t.scripts.start!==`rari start`&&(n(`Existing start script found: "${t.scripts.start}"`),n(`Backing up to start:original and replacing with "rari start"`),t.scripts[`start:original`]=t.scripts.start),t.scripts.start=`rari start`,t.scripts[`start:local`]=`rari start`,t.scripts[`deploy:railway`]=`echo "Push to GitHub and connect to Railway to deploy"`,t.engines=t.engines||{},t.engines.node?i(t.engines.node)||(n(`Current engines.node value "${t.engines.node}" may not meet the required minimum of >=22.0.0`),n(`Updating to >=22.0.0 for Railway deployment compatibility`),t.engines.node=`>=22.0.0`):t.engines.node=`>=22.0.0`,(!t.dependencies||!t.dependencies.rari)&&(e(`Adding rari dependency...`),t.dependencies=t.dependencies||{},t.dependencies.rari=`^0.1.0`),s(f,`${JSON.stringify(t,null,2)}\n`),r(`Updated package.json for Railway deployment`)}catch(e){t(`Failed to update package.json: ${e instanceof Error?e.message:`Unknown error`}`),l.exit(1)}let p=c(d,`railway.toml`);if(a(p)){n(`railway.toml already exists, backing up to railway.toml.backup`);let e=o(p,`utf-8`);s(c(d,`railway.toml.backup`),e)}s(p,`[build]
|
|
2
2
|
builder = "RAILPACK"
|
|
3
3
|
|
|
4
4
|
[deploy]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e,i as t,n,r,t as i}from"./utils-CvELqhML-
|
|
1
|
+
import{a as e,i as t,n,r,t as i}from"./utils-CvELqhML-BOdGyCyF.mjs";import{existsSync as a,readFileSync as o,writeFileSync as s}from"node:fs";import{join as c}from"node:path";import l from"node:process";import{styleText as u}from"node:util";async function d(){let d=l.cwd();e(`Creating Render deployment configuration...`);let f=c(d,`package.json`);a(f)||(t(`No package.json found. Please run this command from your project root.`),l.exit(1));try{let t=JSON.parse(o(f,`utf-8`));t.scripts=t.scripts||{},t.scripts.start&&t.scripts.start!==`rari start`&&(n(`Existing start script found: "${t.scripts.start}"`),n(`Backing up to start:original and replacing with "rari start"`),t.scripts[`start:original`]=t.scripts.start),t.scripts.start=`rari start`,t.scripts[`start:local`]=`rari start`,t.scripts[`deploy:render`]=`echo "Push to GitHub and connect to Render to deploy"`,t.engines=t.engines||{},t.engines.node?i(t.engines.node)||(n(`Current engines.node value "${t.engines.node}" may not meet the required minimum of >=22.0.0`),n(`Updating to >=22.0.0 for Render deployment compatibility`),t.engines.node=`>=22.0.0`):t.engines.node=`>=22.0.0`,(!t.dependencies||!t.dependencies.rari)&&(e(`Adding rari dependency...`),t.dependencies=t.dependencies||{},t.dependencies.rari=`^0.1.0`),s(f,`${JSON.stringify(t,null,2)}\n`),r(`Updated package.json for Render deployment`)}catch(e){t(`Failed to update package.json: ${e instanceof Error?e.message:`Unknown error`}`),l.exit(1)}let p=c(d,`render.yaml`);if(a(p)){n(`render.yaml already exists, backing up to render.yaml.backup`);let e=o(p,`utf-8`);s(c(d,`render.yaml.backup`),e)}s(p,`services:
|
|
2
2
|
- type: web
|
|
3
3
|
name: rari-app
|
|
4
4
|
runtime: node
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use client";import
|
|
1
|
+
"use client";import{t as e}from"../preload-components-CwqehMyC.mjs";import*as t from"react";import{Suspense as n,useEffect as r,useRef as i,useState as a,useTransition as o}from"react";import{Fragment as s,jsx as c,jsxs as l}from"react/jsx-runtime";function u(){return l(`div`,{style:{position:`fixed`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,display:`flex`,alignItems:`center`,justifyContent:`center`,zIndex:9999},children:[c(`div`,{style:{width:`40px`,height:`40px`,border:`4px solid rgba(0, 0, 0, 0.1)`,borderTopColor:`#3b82f6`,borderRadius:`50%`,animation:`spin 1s linear infinite`}}),c(`style`,{children:`
|
|
2
2
|
@keyframes spin {
|
|
3
3
|
to { transform: rotate(360deg); }
|
|
4
4
|
}
|
|
5
|
-
`})]})}function
|
|
6
|
-
`),
|
|
7
|
-
`),t=
|
|
5
|
+
`})]})}function d({children:d,initialPayload:f,onNavigate:p}){let[m,h]=a(f),[,g]=a(0),_=i({x:0,y:0}),v=i(new Map),y=i(null),[,b]=o(),x=i(0),S=i(new Map),C=i([]),w=i(null),T=i(0),[E,D]=a(null),O=()=>{if(typeof document>`u`)return;let e=document.querySelectorAll(`form`);v.current.clear(),e.forEach((e,t)=>{let n=new FormData(e);v.current.set(`form-${t}`,n)})},k=()=>{typeof document>`u`||document.querySelectorAll(`form`).forEach((e,t)=>{let n=v.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)})})},A=(e,t,n,r)=>{let i={timestamp:Date.now(),error:e,type:t,details:n,filePath:r};C.current.push(i),T.current+=1,C.current.length>10&&C.current.shift(),console.error(`[rari] HMR: Failure detected`,{type:t,details:n,filePath:r,consecutiveFailures:T.current,error:e.message,stack:e.stack,timestamp:new Date(i.timestamp).toISOString()}),T.current>=2&&D(i),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`rari:hmr-failure`,{detail:i}))},j=()=>{setTimeout(()=>{window.location.reload()},1e3)},M=()=>{T.current>0&&(T.current=0)},N=e=>{if(!w.current)return!1;if(e===w.current)return!0;let t=e.match(/"timestamp":(\d+)/);if(t){let e=Number.parseInt(t[1],10);if(Date.now()-e>5e3)return!0}return!1};function P(e,n,r,i,a){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[,o,s,c]=e,l=o;if(typeof o==`string`&&o.startsWith(`$`)&&i){let e=o.substring(1);if(/^\d+$/.test(e)){let e=i.get(o);e&&(e===`$Sreact.suspense`||e===`react.suspense`?l=`Suspense`:console.warn(`[rari] AppRouter: Unknown symbol:`,e))}}if(l===`Suspense`||o===`Suspense`){let e=H(c,n,r,i,a);return t.createElement(t.Suspense,s?{...e,key:s}:e)}if(typeof l==`string`&&l.startsWith(`$L`)){let e=n.get(l);if(!e)return null;let o=globalThis[`~clientComponents`]?.[e.id]?.component;if(!o||typeof o!=`function`)return null;let u=s||`fallback-${Math.random()}`,d={...c,children:c.children?P(c.children,n,r,i,a):void 0};return t.createElement(o,{key:u,...d})}if(!l||typeof l!=`string`&&typeof l!=`function`)return console.error(`[rari] AppRouter: Invalid component type:`,{type:l,typeOf:typeof l,serverKey:s,props:c,rscData:e}),null;let u=H(c,n,r,i,a);return t.createElement(l,s?{...u,key:s}:u)}return e.map((e,o)=>{let s=P(e,n,r,i,a);return s?typeof s==`object`&&t.isValidElement(s)&&!s.key?t.cloneElement(s,{key:o}):s:null}).filter(Boolean)}return e}let F=i(new Set),I=i(new Map),L=i(new Map),R=i(new Map),z=i(new Map);function B(e){if(!z.current.has(e)){let t=new Promise(()=>{});z.current.set(e,t)}return z.current.get(e)}function V({contentRef:e}){let t=I.current,n=L.current,r=R.current;if(t.has(e))return z.current.delete(e),P(t.get(e),n,void 0,r,t);throw B(e)}function H(e,n,r,i,a){if(!e||typeof e!=`object`)return e;a&&(I.current=a),n&&(L.current=n),i&&(R.current=i);let o={};for(let s in e)if(Object.hasOwn(e,s))if(s===`children`){let c=e.children;if(typeof c==`string`&&c.startsWith(`$L`))if(a&&a.has(c)){let e=a.get(c);F.current.delete(c),o[s]=P(e,n,r,i,a)}else F.current.add(c),o[s]=t.createElement(V,{key:`lazy-${c}`,contentRef:c});else o[s]=c?P(c,n,r,i,a):void 0}else s===`dangerouslySetInnerHTML`?o[s]=e[s]:o[s]=P(e[s],n,r,i,a);return o}let U=async(n,r=!1)=>{try{let i=n.trim().split(`
|
|
6
|
+
`),a=new Map,o=new Map,s=new Map,c=null,l=[],u=null,d=null;for(let e=0;e<i.length;e++){let t=i[e],n=t.indexOf(`:`);if(n===-1)continue;let f=t.substring(0,n),p=t.substring(n+1);try{if(p.startsWith(`"$S`)){let e=p.slice(1,-1);o.set(`$${f}`,e);continue}if(p.startsWith(`I[`)){let t=JSON.parse(p.substring(1));if(Array.isArray(t)&&t.length>=3){let[n,i,o]=t;a.set(`$L${f}`,{id:n,chunks:Array.isArray(i)?i:[i],name:o||`default`}),r&&n.includes(`layout`)&&(u!==null&&d!==null&&l.push({layoutPath:u,startLine:d,endLine:e-1,props:{}}),u=n,d=e)}}else if(p.startsWith(`[`)){let e=JSON.parse(p);if(s.set(`$L${f}`,e),r&&Array.isArray(e)&&e.length>=4&&typeof e[1]==`string`&&e[1].startsWith(`$L`)){let t=e[1],n=a.get(t);if(n&&n.id.includes(`layout`)){let t=e[3]||{};if(u&&d!==null){let e=l.find(e=>e.layoutPath===u&&e.startLine===d);e&&(e.props=t)}}}!c&&Array.isArray(e)&&(e[0]===`$`?c=e:Array.isArray(e[0])&&e[0][0]===`$`&&(c=e.length===1?e[0]:e))}}catch(e){console.error(`[rari] AppRouter: Failed to parse RSC line:`,t,e)}}if(await e(a),r&&u!==null&&d!==null&&l.push({layoutPath:u,startLine:d,endLine:i.length-1,props:{}}),c&&Array.isArray(c)){if(c[0]===`$`)c=P(c,a,void 0,o,s);else if(Array.isArray(c[0])){let e=c.map(e=>Array.isArray(e)&&e[0]===`$`?P(e,a,void 0,o,s):e).filter(e=>e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||t.isValidElement(e));c=e.length===1?e[0]:e}}return{element:c,modules:a,symbols:o,wireFormat:n,layoutBoundaries:r?l:void 0}}catch(e){throw console.error(`[rari] AppRouter: Failed to parse RSC wire format:`,e),e}},W=async(e,t)=>{let n=e||window.location.pathname,r=S.current.get(n);if(r)return r;let i=(async()=>{try{let e=(window.location.origin.includes(`:5173`)?`http://localhost:3000`:window.location.origin)+n+window.location.search,r=await fetch(e,{headers:{Accept:`text/x-component`,"Cache-Control":`no-cache`,Pragma:`no-cache`},cache:`no-store`,signal:t});if(!r.ok){let t=Error(`Failed to fetch RSC data: ${r.status} ${r.statusText}`);throw A(t,`fetch`,`HTTP ${r.status} when fetching ${e}`,window.location.pathname),t}let i=await r.text();if(N(i)&&m)return m;let a;try{a=await U(i,!1)}catch(e){let t=e instanceof Error?e:Error(String(e));throw A(t,`parse`,`Failed to parse RSC wire format: ${t.message}`,window.location.pathname),t}return h(a),w.current=i,M(),a}catch(e){throw e instanceof Error&&!e.message.includes(`Failed to fetch RSC data`)&&!e.message.includes(`Failed to parse`)&&A(e,`network`,`Network error: ${e.message}`,window.location.pathname),console.error(`[rari] AppRouter: Error fetching RSC payload:`,e),e}finally{S.current.delete(n)}})();return S.current.set(n,i),i};r(()=>{if(typeof window>`u`)return;let e=async e=>{let t=e.detail;x.current=t.navigationId,y.current=null,_.current={x:window.scrollX,y:window.scrollY},O(),b(async()=>{try{t.rscWireFormat?(h(await U(t.rscWireFormat,!1)),w.current=t.rscWireFormat,M()):t.isStreaming?y.current=[]:await W(t.to,t.abortSignal),x.current===t.navigationId&&(g(e=>e+1),D(null),p&&p(t))}catch(e){if(e instanceof Error&&e.name===`AbortError`)return;console.error(`[rari] AppRouter: Navigation failed:`,e),window.dispatchEvent(new CustomEvent(`rari:navigate-error`,{detail:{from:t.from,to:t.to,error:e,navigationId:t.navigationId}})),T.current>=3&&j()}finally{t.options?.historyKey||requestAnimationFrame(()=>{t.options?.scroll!==!1&&window.scrollTo(0,0)})}})},t=async()=>{_.current={x:window.scrollX,y:window.scrollY},O();try{await W(),g(e=>e+1),D(null)}catch(e){console.error(`[rari] AppRouter: HMR update failed:`,e),T.current>=3&&j()}finally{requestAnimationFrame(()=>{window.scrollTo(_.current.x,_.current.y),k()})}},n=async()=>{try{await W(),g(e=>e+1),D(null)}catch(e){console.error(`[rari] AppRouter: RSC invalidation failed:`,e),T.current>=3&&j()}},r=async()=>{try{await W(),D(null)}catch(e){console.error(`[rari] AppRouter: Manifest update failed:`,e),T.current>=3&&j()}},i=async e=>{let t=e.detail.rscRow;if(!(!t||!t.trim())){y.current||=[],y.current.push(t);try{let e=y.current.join(`
|
|
7
|
+
`),t=await U(e,!1);y.current.length<=2&&e.includes(`~boundaryId`)?(h(t),g(e=>e+1)):b(()=>{h(t),g(e=>e+1)})}catch(e){console.error(`[rari] AppRouter: Failed to parse streaming RSC row:`,e)}}};return window.addEventListener(`rari:navigate`,e),window.addEventListener(`rari:app-router-rerender`,t),window.addEventListener(`rari:rsc-invalidate`,n),window.addEventListener(`rari:app-router-manifest-updated`,r),window.addEventListener(`rari:rsc-row`,i),()=>{window.removeEventListener(`rari:navigate`,e),window.removeEventListener(`rari:app-router-rerender`,t),window.removeEventListener(`rari:rsc-invalidate`,n),window.removeEventListener(`rari:app-router-manifest-updated`,r),window.removeEventListener(`rari:rsc-row`,i)}},[p]);let G=()=>{window.location.reload()},K=()=>{D(null)},q=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},J=d;return m?.element&&(J=q(m.element)||m.element),Array.isArray(J)&&J.length===1&&t.isValidElement(J[0])&&(J=J[0]),J&&typeof J==`object`&&!t.isValidElement(J)&&(console.error(`[rari] AppRouter: Invalid content to render:`,J),J=d),l(s,{children:[E&&l(`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:[c(`div`,{style:{marginBottom:`16px`,fontWeight:`bold`,fontSize:`16px`},children:`⚠️ HMR Update Failed`}),l(`div`,{style:{marginBottom:`12px`,opacity:.9},children:[E.type===`fetch`&&`Failed to fetch updated content from server.`,E.type===`parse`&&`Failed to parse server response.`,E.type===`stale`&&`Server returned stale content.`,E.type===`network`&&`Network error occurred.`]}),c(`div`,{style:{marginBottom:`16px`,fontSize:`12px`,opacity:.8,fontFamily:`monospace`},children:E.details}),l(`div`,{style:{marginBottom:`12px`,fontSize:`12px`,opacity:.7},children:[`Consecutive failures:`,` `,T.current,` `,`/`,` `,3]}),l(`div`,{style:{display:`flex`,gap:`8px`},children:[c(`button`,{onClick:G,type:`button`,style:{padding:`8px 16px`,background:`white`,color:`#dc2626`,border:`none`,borderRadius:`4px`,cursor:`pointer`,fontWeight:`bold`,fontSize:`14px`},children:`Refresh Page`}),c(`button`,{onClick:K,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`})]}),c(`div`,{style:{marginTop:`12px`,fontSize:`11px`,opacity:.6},children:`Check the console for detailed error logs.`})]}),c(n,{fallback:c(u,{}),children:J})]})}export{d as AppRouterProvider};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import "virtual:rsc-integration.ts";
|
|
2
2
|
|
|
3
3
|
//#region src/runtime/entry-client.d.ts
|
|
4
|
+
declare function preloadClientComponent(id: string): Promise<void>;
|
|
4
5
|
declare function renderApp(): Promise<void>;
|
|
5
6
|
//#endregion
|
|
6
|
-
export { renderApp };
|
|
7
|
+
export { preloadClientComponent, renderApp };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{n as e,t}from"../get-client-component-CR5zDUvd.mjs";import*as n from"react";import{Suspense as r}from"react";import{ClientRouter as i}from"rari/client";import{createRoot as a}from"react-dom/client";import{AppRouterProvider as o}from"virtual:app-router-provider";import{createFromReadableStream as s}from"virtual:react-server-dom-rari-client.ts";import"virtual:rsc-integration.ts";function c(){return globalThis[`~rari`]}function l(){return globalThis}function u(){return window}function d(){return{moduleMap:new Proxy({},{get(e,t){return new Proxy({},{get(e,n){return{id:`${String(t)}#${String(n)}`,chunks:[],name:String(n)}}})}}),moduleLoading:new Proxy({},{get(e,t){return new Proxy({},{get(e,n){return async()=>{try{let e=String(t),r=String(n),i=`${e}#${r}`;if(l()[`~clientComponents`]?.[i]?.component)return l()[`~clientComponents`][i].component;if(l()[`~clientComponents`]?.[e]?.component){let t=l()[`~clientComponents`][e].component;return r===`default`?t:t?.[r]}let a=l()[`~clientComponents`]?.[i]||l()[`~clientComponents`]?.[e];if(a?.loader){a.loadPromise||=(a.loading=!0,a.loader().then(e=>(a.component=e.default||e,a.registered=!0,a.loading=!1,e)).catch(t=>{throw a.loading=!1,a.loadPromise=void 0,console.error(`[rari] Failed to lazy load ${e}#${r}:`,t),t}));let t=await a.loadPromise,n=t.default||t;return r===`default`?n:n?.[r]??n}return console.warn(`[rari] Module ${e}#${r} not found in client components registry`),null}catch(e){return console.error(`[rari] Failed to load ${String(t)}#${String(n)}:`,e),null}}}})}})}}c()===void 0&&(globalThis[`~rari`]={}),c().AppRouterProvider=o,c().ClientRouter=i,c().getClientComponent=t;async function f(t){try{await e(t)}catch(e){console.error(`[rari] Failed to preload component ${t}:`,e)}}
|
|
2
2
|
/*! @preserve CLIENT_COMPONENT_IMPORTS_PLACEHOLDER */
|
|
3
|
-
|
|
3
|
+
c().preloadClientComponent=f,l()[`~clientComponents`]===void 0&&(globalThis[`~clientComponents`]={}),l()[`~clientComponentPaths`]===void 0&&(globalThis[`~clientComponentPaths`]={});
|
|
4
4
|
/*! @preserve CLIENT_COMPONENT_REGISTRATIONS_PLACEHOLDER */
|
|
5
|
-
function
|
|
5
|
+
function p(){c().hydrateClientComponents||(c().hydrateClientComponents=function(e,t,r){let i=u()[`~rari`].boundaryModules||new Map;function o(e){if(!e)return null;if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return e;if(Array.isArray(e)){if(e.length>=4&&e[0]===`$`){let[,t,r,a]=e,s=a?{...a}:{};if(a?.children&&(s.children=o(a.children)),s[`~boundaryId`]&&delete s[`~boundaryId`],typeof t==`string`){if(t.startsWith(`$L`)){let e=i.get(t);if(e){let t=`${e.id}#${e.name||`default`}`,i=null,a=l()[`~clientComponents`][t]||l()[`~clientComponents`][e.id];return a&&(a.component?i=a.component:a.loader&&!a.loading&&(a.loading=!0,a.loadPromise=a.loader().then(e=>(a.component=e.default||e,a.registered=!0,a.loading=!1,a.component)).catch(t=>{throw a.loading=!1,a.loadPromise=void 0,console.error(`[rari] Failed to load component ${e.id}:`,t),t})),a.loadPromise&&!a.component&&n.use(a.loadPromise)),i?n.createElement(i,r?{...s,key:r}:s):s.children||null}return s.children||null}return n.createElement(t,r?{...s,key:r}:s)}return null}return e.map((e,t)=>{let r=o(e);return n.isValidElement(r)&&!r.key?n.cloneElement(r,{key:t}):r})}return e}try{let e=o(t);e&&(a(r).render(e),r.classList.add(`rari-boundary-hydrated`))}catch(e){console.error(`[rari] Failed to hydrate client components:`,e),console.error(`[rari] Error stack:`,e.stack)}})}function m(){let e=u()[`~rari`].pendingBoundaryHydrations;if(!(!e||e.size===0)){for(let[t,n]of e.entries())c().hydrateClientComponents&&c().hydrateClientComponents(t,n.content,n.element);e.clear()}}p();async function h(t){let n=[];for(let r of t){let t=e(r).catch(e=>{console.error(`[rari] Failed to preload component ${r}:`,e)});n.push(t)}n.length>0&&await Promise.all(n)}async function g(){let e=document.getElementById(`root`);if(!e){console.error(`[rari] Root element not found`);return}let r=document.getElementById(`__RARI_RSC_PAYLOAD__`),c=e.children.length>0,l=u()[`~rari`]?.bufferedRows&&u()[`~rari`].bufferedRows.length>0;if(p(),c&&!r&&!l){let e=document.querySelectorAll(`[data-client-component]`);if(e.length>0){let r=new Set;e.forEach(e=>{let t=e.getAttribute(`data-client-component`);t&&r.add(t)}),await h(r),e.forEach(e=>{let r=e.getAttribute(`data-client-component`),i=e.getAttribute(`data-props`);if(r)try{let o=t(r);if(!o)return;let s=i?JSON.parse(i):{};e.innerHTML=``,a(e).render(n.createElement(o,s))}catch(e){console.error(`[rari] Failed to hydrate client component ${r}:`,e)}})}return}if(c&&l&&!r&&document.querySelectorAll(`[data-boundary-id]`).length>0){u()[`~rari`].pendingBoundaryHydrations&&u()[`~rari`].pendingBoundaryHydrations.size>0&&m();return}try{let t;if(!r&&!l&&!c)try{let e=window.location.pathname+window.location.search,n=await fetch(e,{headers:{Accept:`text/x-component`}});if(!n.ok)throw Error(`Failed to fetch RSC data: ${n.status}`);let r=n.body;t=await s(r,d())}catch(e){console.error(`[rari] Failed to fetch initial RSC data:`,e),t=null}else if(r&&r.textContent)try{let e=r.textContent,n=u()[`~rari`]?.bufferedRows&&u()[`~rari`].bufferedRows.length>0;t=u()[`~rari`]?.streamComplete===void 0||n?await s(new ReadableStream({start(t){if(t.enqueue(new TextEncoder().encode(e)),u()[`~rari`]?.bufferedRows){for(let e of u()[`~rari`].bufferedRows)t.enqueue(new TextEncoder().encode(`\n${e}`));u()[`~rari`].bufferedRows=[]}let n=e=>{let n=e;n.detail?.rscRow&&t.enqueue(new TextEncoder().encode(`\n${n.detail.rscRow}`))},r=()=>{t.close(),window.removeEventListener(`rari:rsc-row`,n),window.removeEventListener(`rari:stream-complete`,r)};window.addEventListener(`rari:rsc-row`,n),window.addEventListener(`rari:stream-complete`,r),u()[`~rari`]?.streamComplete&&r()}}),d()):await s(new ReadableStream({start(t){t.enqueue(new TextEncoder().encode(e)),t.close()}}),d())}catch(e){console.error(`[rari] Failed to parse embedded RSC payload:`,e),t=null}else if(l)try{t=await s(new ReadableStream({start(e){if(u()[`~rari`]?.bufferedRows){for(let t of u()[`~rari`].bufferedRows)e.enqueue(new TextEncoder().encode(`${t}\n`));u()[`~rari`].bufferedRows=[]}let t=t=>{let n=t;n.detail?.rscRow&&e.enqueue(new TextEncoder().encode(`${n.detail.rscRow}\n`))},n=()=>{e.close(),window.removeEventListener(`rari:rsc-row`,t),window.removeEventListener(`rari:stream-complete`,n)};window.addEventListener(`rari:rsc-row`,t),window.addEventListener(`rari:stream-complete`,n),u()[`~rari`]?.streamComplete&&n()}}),d())}catch(e){console.error(`[rari] Failed to process streaming RSC payload:`,e),t=null}if(!t)throw Error(`No RSC data available for hydration`);let f;f=t;let p;p=n.createElement(o,{initialPayload:{element:t}},f),p=n.createElement(i,{initialRoute:window.location.pathname},p),a(e).render(p)}catch(t){console.error(`[rari] Error rendering app:`,t),e.innerHTML=`
|
|
6
6
|
<div style="padding: 20px; background: #fee; border: 2px solid #f00; margin: 20px;">
|
|
7
7
|
<h2>Error Loading App</h2>
|
|
8
8
|
<p></p>
|
|
9
9
|
</div>
|
|
10
|
-
`;let
|
|
10
|
+
`;let n=e.querySelector(`p`);n&&(n.textContent=t instanceof Error?t.message:String(t))}}import.meta.hot&&import.meta.hot.data.hasRendered||(g().catch(e=>{console.error(`[rari] Fatal error:`,e)}),import.meta.hot&&(import.meta.hot.data.hasRendered=!0));export{f as preloadClientComponent,g as renderApp};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
`?(
|
|
1
|
+
import{r as e}from"../get-client-component-CR5zDUvd.mjs";import{t}from"../preload-components-CwqehMyC.mjs";import*as n from"react";async function r(e,n={}){let{moduleMap:r={}}=n,i=e.getReader(),o=[];for(;;){let{done:e,value:t}=await i.read();if(e)break;o.push(t)}let c=new Uint8Array(o.reduce((e,t)=>e+t.length,0)),l=0;for(let e of o)c.set(e,l),l+=e.length;let u=a(new TextDecoder().decode(c));return await t(u.modules),s(u.rootElement,u.modules,r,u.symbols,u.chunks)}async function i(e,n={}){let r=a(await(await e).text());return await t(r.modules),s(r.rootElement,r.modules,n.moduleMap||{},r.symbols,r.chunks)}function a(e){let t=new Map,n=new Map,r=new Map,i=0,a=0,s=0,c=0,l=``,u=null;for(;i<e.length;){let d=e[i],f=e.charCodeAt(i);switch(a){case 0:d===`:`?(a=1,i++):(f>=48&&f<=57?s=s<<4|f-48:f>=97&&f<=102?s=s<<4|f-87:f>=65&&f<=70&&(s=s<<4|f-55),i++);break;case 1:f===73||f===69||f===84||f===72||f===68||f===87||f===67?(c=f,a=2,i++):(c=0,a=2);break;case 2:d===`
|
|
2
|
+
`?(o(s,c,l,t,n,r),u===null&&c!==73&&l.trim()&&!(l.startsWith(`"$S`)&&l.endsWith(`"`))&&n.has(s.toString())&&(u=s.toString()),a=0,s=0,c=0,l=``):l+=d,i++;break}}return l.trim()&&(o(s,c,l,t,n,r),u===null&&c!==73&&!(l.startsWith(`"$S`)&&l.endsWith(`"`))&&n.has(s.toString())&&(u=s.toString())),{modules:t,chunks:n,symbols:r,rootElement:u===null?null:n.get(u)}}function o(e,t,n,r,i,a){let o=e.toString();try{switch(t){case 73:{let e=JSON.parse(n);Array.isArray(e)&&e.length>=3&&r.set(`$L${o}`,{id:e[0],chunks:e[1]||[],name:e[2]||`default`});break}case 69:{console.error(`[rari] RSC: Error chunk:`,n);let e=JSON.parse(n);i.set(o,{error:e});break}case 84:i.set(o,n);break;case 72:case 68:case 87:break;case 67:break;default:{if(!n.trim())break;if(n.startsWith(`"$S`)&&n.endsWith(`"`)){let e=n.slice(1,-1);a.set(o,e);break}let e=JSON.parse(n);i.set(o,e);break}}}catch(e){console.error(`[rari] RSC: Failed to parse row:`,{id:o,tag:t,data:n},e)}}function s(e,t,r,i,a){if(!e)return null;if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`){if(typeof e==`string`&&e.startsWith(`$`)&&e.length>1){if(e[1]===`L`){let n=e.slice(2),o=a?.get(n);if(!o){let t=new Promise(()=>{});throw t._rscLazyRef=e,t}return s(o,t,r,i,a)}let n=e.slice(1),o=a?.get(n);return o?s(o,t,r,i,a):null}return e}if(Array.isArray(e)){if(e.length>=4&&e[0]===`$`){let[,o,u,d]=e;if(typeof o==`string`&&o.startsWith(`$`)&&o.length>1&&/^\d+$/.test(o.slice(1))){let e=o.slice(1),s=i?.get(e);if(s&&s.startsWith(`$S`)&&s.slice(2)===`react.suspense`){let e=l(d,t,r,i,a);return n.createElement(n.Suspense,u?{...e,key:u}:e)}}if(typeof o==`string`&&o.startsWith(`$S`)){if(o.slice(2)===`react.suspense`){let e=l(d,t,r,i,a);return n.createElement(n.Suspense,u?{...e,key:u}:e)}return null}if(typeof o==`string`&&o.startsWith(`$L`)){let e=o.substring(2);if(e===`ClientRouter`&&(!d||!d.manifest))return d&&d.children?s(d.children,t,r,i,a):null;let f=c(e,t,r);if(f){let e=l(d,t,r,i,a);return n.createElement(f,u?{...e,key:u}:e)}return null}let f=l(d,t,r,i,a);return n.createElement(o,u?{...f,key:u}:f)}return e.map(e=>s(e,t,r,i,a))}return e}function c(t,n,r){if(t===`AppRouterProvider`){let e=globalThis[`~rari`]?.AppRouterProvider;if(e)return e}if(t===`ClientRouter`){let e=globalThis[`~rari`]?.ClientRouter;if(e)return e}if(n&&n.size>0){let r=`$L${t}`,i=n.get(r);if(i){let t=globalThis[`~clientComponents`]||{},n=[i.id,`${i.id}#${i.name||`default`}`,i.id.replace(/^src\//,``),i.id.replace(/\\/g,`/`)];for(let r of n){let n=t[r];if(n){if(n.component)return n.component;if(n.loader&&!n.loading)return e(n,i.id);if(n.loading)return null}}console.warn(`[rari] Component not found in registry:`,{moduleId:i.id,moduleName:i.name,triedKeys:n,availableKeys:Object.keys(t).slice(0,10)})}}if(r[t])return r[t];let i=globalThis[`~clientComponents`]||{};for(let[n,r]of Object.entries(i)){let i=n===t,a=n.endsWith(`/${t}`)||n.endsWith(`\\${t}`),o=n.endsWith(`#${t}`),s=r.name===t;if(i||a||o||s){if(r.component)return r.component;if(r.loader&&!r.loading)return e(r,n)}}return null}function l(e,t,n,r,i){if(!e||typeof e!=`object`)return e;let a={};for(let o in e)if(Object.hasOwn(e,o)){if(o.startsWith(`~`)||o===`ref`)continue;o===`children`?a[o]=e.children?s(e.children,t,n,r,i):void 0:a[o]=e[o]}return a}function u(e){return JSON.stringify(e)}function d(e){return JSON.parse(e)}export{i as createFromFetch,r as createFromReadableStream,d as decodeReply,u as encodeReply};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{t as e}from"../get-client-component-
|
|
1
|
+
import{t as e}from"../get-client-component-CR5zDUvd.mjs";import{createFromFetch as t,createFromReadableStream as n}from"./react-server-dom-rari-client.mjs";import{Suspense as r,cloneElement as i,createElement as a,isValidElement as o,useEffect as s,useRef as c,useState as l}from"react";import*as u from"react-dom/client";if(globalThis[`~rari`]===void 0&&(globalThis[`~rari`]={}),globalThis[`~rari`].isDevelopment=process.env.NODE_ENV!==`production`,globalThis[`~clientComponents`]===void 0&&(globalThis[`~clientComponents`]={}),globalThis[`~clientComponentNames`]===void 0&&(globalThis[`~clientComponentNames`]={}),globalThis[`~clientComponentPaths`]===void 0&&(globalThis[`~clientComponentPaths`]={}),typeof window<`u`){window[`~rari`]||(window[`~rari`]=globalThis[`~rari`]),window[`~rari`].bufferedEvents||(window[`~rari`].bufferedEvents=[]),window[`~rari`].boundaryModules||(window[`~rari`].boundaryModules=new Map),window[`~rari`].pendingBoundaryHydrations||(window[`~rari`].pendingBoundaryHydrations=new Map),globalThis[`~rari`].processBoundaryUpdate=function(e,t,n){let r=document.querySelector(`[data-boundary-id="${e}"]`);if(r){try{let i=t.indexOf(`:`);if(i===-1){console.warn(`[rari] Invalid RSC row format (no colon):`,t);return}let a=t.substring(0,i),o=t.substring(i+1);if(o.startsWith(`I[`)){try{let e=JSON.parse(o.substring(1));if(Array.isArray(e)&&e.length>=3){let[t,n,r]=e,i=`$L${a}`;window[`~rari`].boundaryModules?.set(i,{id:t,chunks:Array.isArray(n)?n:[n],name:r||`default`})}}catch(e){console.error(`[rari] Failed to parse import row:`,o,e)}return}let s;try{s=JSON.parse(o)}catch(e){console.error(`[rari] Failed to parse RSC content:`,o,e);return}function c(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 c(n.children)}return e.some(e=>c(e))}return!1}if(c(s)){if(window[`~rari`].pendingBoundaryHydrations?.set(e,{content:s,element:r,rowId:n}),globalThis[`~rari`].hydrateClientComponents){let t=globalThis[`~rari`].hydrateClientComponents;t(e,s,r)}return}function l(e){let t=e=>e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`);if(!e)return``;if(typeof e==`string`||typeof e==`number`)return t(String(e));if(Array.isArray(e)){if(e.length>=4&&e[0]===`$`){let[,n,,r]=e,i=null,a=``,o=``;if(r){for(let[e,n]of Object.entries(r))if(e===`dangerouslySetInnerHTML`&&n&&typeof n==`object`&&`__html`in n)i=n.__html;else if(e!==`children`&&e!==`~boundaryId`){let r=e===`className`?`class`:e;if(e===`style`&&typeof n==`object`&&n){let e=Object.entries(n).map(([e,t])=>`${e.replace(/([A-Z])/g,`-$1`).toLowerCase()}:${String(t)}`).join(`;`);o+=` style="${t(e)}"`}else typeof n==`string`||typeof n==`number`?o+=` ${r}="${t(String(n))}"`:typeof n==`boolean`&&n&&(o+=` ${r}`)}i===null&&r.children&&(a=l(r.children))}return`<${n}${o}>${i===null?a:i}</${n}>`}return e.map(l).join(``)}return``}let u=l(s);u&&(r.innerHTML=u,r.classList.add(`rari-boundary-resolved`))}catch(e){console.error(`[rari] Error processing boundary update:`,e)}window.dispatchEvent(new CustomEvent(`rari:boundary-resolved`,{detail:{boundaryId:e,rscRow:t,rowId:n,element:r}}))}};let e=window,t=globalThis;e[`~rari`].bufferedEvents&&e[`~rari`].bufferedEvents.length>0&&(e[`~rari`].bufferedEvents.forEach(e=>{let{boundaryId:n,rscRow:r,rowId:i}=e;t[`~rari`].processBoundaryUpdate?.(n,r,i)}),e[`~rari`].bufferedEvents=[]),window.addEventListener(`rari:boundary-update`,e=>{let{boundaryId:n,rscRow:r,rowId:i}=e.detail;t[`~rari`].processBoundaryUpdate&&t[`~rari`].processBoundaryUpdate(n,r,i)})}function d(e,t,n){let r=n===`default`?e.name||t.split(`/`).pop()?.replace(/\.[^/.]+$/,``)||`DefaultComponent`:n,i=r,a={id:i,path:t,type:`client`,component:e,registered:!0};globalThis[`~clientComponents`][i]=a,globalThis[`~clientComponents`][t]=a,globalThis[`~clientComponentPaths`][t]=i,globalThis[`~clientComponentNames`][r]=i,e&&(e[`~isClientComponent`]=!0,e[`~clientComponentId`]=i),typeof window<`u`&&fetch(`/_rari/register-client`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({component_id:i,file_path:t,export_name:n})}).catch(e=>{console.error(`[rari] Failed to register client component with server:`,e)})}function f(t){return e(t)}function p(){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 m=t,h=n,g=null;async function _(){return g||(g=(async()=>{try{return m=t,h=n,typeof h!=`function`&&(h=null),typeof m!=`function`&&(m=null),u}catch(e){return console.error(`Failed to load react-dom/client RSC functions:`,e),m=null,h=null,null}})(),g)}const v=new class{componentCache;moduleCache;inflightRequests;config;constructor(){this.componentCache=new Map,this.moduleCache=new Map,this.inflightRequests=new Map,this.config={maxRetries:5,retryDelay:500,timeout:1e4}}configure(e){this.config={...this.config,...e}}clearCache(){this.componentCache.clear(),this.moduleCache.clear()}async fetchServerComponent(e,t={}){let n=typeof window<`u`&&window[`~rscRefreshCounters`]&&window[`~rscRefreshCounters`][e]||0,r=`${e}:${JSON.stringify(t)}:hmr:${n}`;if(this.componentCache.has(r))return this.componentCache.get(r);if(this.inflightRequests.has(r))return this.inflightRequests.get(r);let i=this.fetchServerComponentStream(e,t);this.inflightRequests.set(r,i);try{let e=await i;return this.componentCache.set(r,e),e}finally{this.inflightRequests.delete(r)}}async fetchServerComponentStream(e,t={}){await _();let n=(()=>{let e=[`/_rari/stream`];try{typeof window<`u`&&(window.location.hostname===`localhost`||window.location.hostname===`127.0.0.1`)&&e.push(`http://127.0.0.1:3000/_rari/stream`,`http://localhost:3000/_rari/stream`)}catch{}return e})(),c=null,u=null,d=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;u=Error(`HTTP ${n.status}: ${await n.text()}`)}catch(e){u=e}return null};if(c=await d(),c||=(await new Promise(e=>setTimeout(e,this.config.retryDelay)),await d()),!c)throw u||Error(`Failed to reach stream endpoint`);if(!c.ok){let e=await c.text();throw Error(`Server responded with ${c.status}: ${e}`)}let p=c.body;if(!p)throw Error(`No ReadableStream from stream response`);let m=p.getReader(),h=new TextDecoder,g=new Map,v=new Map,y=e=>{if(!a)return console.error(`React not available for RSC conversion`),null;if(!e)return null;if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return e;if(Array.isArray(e)){if(e.length>=3&&e[0]===`$`){let[,t,n,s]=e;if(t===`react.suspense`||t===`suspense`)return a(r,{fallback:y(s?.fallback)||null},s?.children?y(s.children):null);let c=s?{...s}:{};if(s?.children){let e=y(s.children);Array.isArray(e)?c.children=e.map((e,t)=>o(e)?i(e,{key:e.key??t}):e):c.children=e}if(typeof t==`string`){if(t.startsWith(`$L`)){let e=g.get(t);if(e){let t=f(`${e.id}#${e.name||`default`}`);if(t)return a(t,n?{...c,key:n}:c)}return c&&c.children?c.children:null}if(t.includes(`.tsx#`)||t.includes(`.jsx#`)){let e=f(t);return e?a(e,n?{...c,key:n}:c):(console.error(`Failed to resolve client component:`,t),null)}else return c&&Object.hasOwn(c,`~boundaryId`)&&(c={...c},delete c[`~boundaryId`]),a(t,n?{...c,key:n}:c)}else console.error(`Unknown RSC element type:`,t)}return e.map(e=>y(e))}return typeof e==`object`?(console.error(`Unexpected object in RSC conversion:`,e),null):e},b=null,x=new Map,S=``,C=null,w=async()=>{try{for(;;){let{value:e,done:t}=await m.read();if(t)break;let n=h.decode(e,{stream:!0});S+=n;let r=S.split(`
|
|
2
2
|
`),i=r.slice(0,-1);S=r.at(-1)||``;for(let e of i)if(e.trim())try{let t=e.indexOf(`:`);if(t===-1)continue;let n=e.substring(0,t),r=e.substring(t+1);if(r.startsWith(`I[`))try{let e=JSON.parse(r.substring(1));if(Array.isArray(e)&&e.length>=3){let[t,r,i]=e;g.set(`$L${n}`,{id:t,chunks:Array.isArray(r)?r:[r],name:i||`default`})}}catch(e){console.error(`Failed to parse import row:`,r,e)}else if(r.startsWith(`E{`))try{let e=JSON.parse(r.substring(1));console.error(`RSC stream error:`,e)}catch(e){console.error(`Failed to parse error row:`,r,e)}else if(r.startsWith(`Symbol.for(`))continue;else if(r.startsWith(`[`)){let e=JSON.parse(r);if(Array.isArray(e)&&e.length>=4){let[t,r,i]=e,a=i?.[`~boundaryId`];if(t===`$`&&(r===`react.suspense`||r===`suspense`)&&i&&a&&v.set(`$L${n}`,a),t===`$`&&i&&Object.hasOwn(i,`children`)&&typeof r==`string`&&r.startsWith(`$L`)){let e=v.get(r)||null;if(e){let t=y(i.children);x.set(e,t),C&&C.updateBoundary(e,t);continue}}}if(!b){let t=!0;if(Array.isArray(e)&&e.length>=4&&e[0]===`$`){let n=e[1],r=e[3],i=r?.[`~boundaryId`];typeof n==`string`&&(n===`react.suspense`||n===`suspense`)&&r&&i&&(t=!1)}t&&(b=y(e),C&&typeof C.updateRoot==`function`&&C.updateRoot())}}}catch(t){console.error(`Failed to parse stream line:`,e,t)}}}catch(e){console.error(`Error processing stream:`,e)}},T=()=>{let[,e]=l(0);s(()=>(C={updateBoundary:(t,n)=>{x.set(t,n),e(e=>e+1)},updateRoot:()=>{e(e=>e+1)}},()=>{C=null}),[]);let t=e=>{if(!e)return null;if(o(e)){let n=e.props,r=n?.[`~boundaryId`];if(n&&r){let e=x.get(r);if(e)return e}if(n&&n.children){let r=t(n.children);if(r!==n.children)return i(e,{...n,children:r})}return e}return Array.isArray(e)?e.map(e=>t(e)):e};return t(b)};return w(),{"~isRscResponse":!0,"~rscPromise":Promise.resolve(a(T)),readRoot(){return Promise.resolve(a(T))}}}buildRequestHeaders(){return{Accept:`text/x-component`,"Cache-Control":`no-cache, no-transform`}}async fetchWithTimeout(e,t){let n=new AbortController,r=setTimeout(()=>n.abort(),this.config.timeout);try{let i=await fetch(e,{...t,signal:n.signal});return clearTimeout(r),i}catch(e){throw clearTimeout(r),e}}async processRscResponse(e){if(await _(),m)try{let t=m(Promise.resolve(e));return{"~isRscResponse":!0,"~rscPromise":t,readRoot(){return t}}}catch{throw Error(`React Server DOM client not available`)}else throw Error(`React Server DOM client not available`)}async processRscResponseManually(e){let t=await e.text();return this.parseRscResponse(t)}parseRscResponse(e){let t=e.trim().split(/\r?\n/),n=new Map,r=new Map,i=[];for(let e of t){let t=e.indexOf(`:`);if(t===-1)continue;let a=e.substring(0,t),o=e.substring(t+1);if(o)try{if(o.startsWith(`I[`)){let e=o.substring(1),t=JSON.parse(e);if(Array.isArray(t)&&t.length>=3){let[e,r,i]=t;n.set(`$L${a}`,{id:e,chunks:Array.isArray(r)?r:[r],name:i||`default`})}}else if(o.startsWith(`E{`)){let e=o.substring(1),t=JSON.parse(e);i.push(t),console.error(`RSC: Server error`,t)}else if(o.startsWith(`[`)){let e=JSON.parse(o);r.set(a,e)}else if(o.startsWith(`Symbol.for(`))continue;else console.error(`Unknown RSC row format:`,e)}catch(t){console.error(`Failed to parse RSC row:`,e,t)}}if(i.length>0)throw Error(`RSC Server Error: ${i.map(e=>e.message||e).join(`, `)}`);let a=null,o=r.keys().toSorted((e,t)=>Number.parseInt(e)-Number.parseInt(t));for(let e of o){let t=r.get(e);if(Array.isArray(t)&&t.length>=2&&t[0]===`$`){let[,e,,n]=t,r=n?.[`~boundaryId`];if(e===`react.suspense`&&n&&r)continue;a=t;break}}return a?this.reconstructElementFromRscData(a,n):(console.error(`No valid root element found in RSC payload`,{elements:r,modules:n}),null)}reconstructElementFromRscData(e,t){if(e==null)return null;if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return e;if(Array.isArray(e))if(e.length>=4&&e[0]===`$`){let[,n,r,i]=e,o=n;if(typeof n==`string`&&n.includes(`#`))o=f(n)||(({children:e,...t})=>a(`div`,{...t,"data-client-component":n,style:{border:`2px dashed #f00`,padding:`8px`,margin:`4px`,backgroundColor:`#fff0f0`}},a(`small`,{style:{color:`#c00`}},`Missing Client Component: ${n}`),e));else if(typeof n==`string`&&n.startsWith(`$L`)&&t.has(n)){let e=t.get(n);e&&(o=f(`${e.id}#${e.name}`)||(({children:t,...r})=>a(`div`,{...r,"data-client-component":n,style:{border:`2px dashed #f00`,padding:`8px`,margin:`4px`,backgroundColor:`#fff0f0`}},a(`small`,{style:{color:`#c00`}},`Missing Client Component: ${e.name} (${e.id})`),t)))}let s=i?this.processPropsRecursively(i,t):{};return a(o,{key:r,...s})}else return e.map(e=>this.reconstructElementFromRscData(e,t));return typeof e==`object`?null:e}processPropsRecursively(e,t){if(!e||typeof e!=`object`)return e;let n={};for(let[r,i]of Object.entries(e))if(r===`children`)if(Array.isArray(i))if(i.length>=2&&i[0]===`$`)n[r]=this.reconstructElementFromRscData(i,t);else{let e=i.map(e=>this.reconstructElementFromRscData(e,t)).filter(e=>e!=null);e.length===0?n[r]=null:e.length===1?n[r]=e[0]:n[r]=e}else n[r]=this.reconstructElementFromRscData(i,t);else r===`dangerouslySetInnerHTML`?n[r]=i:n[r]=this.reconstructElementFromRscData(i,t);return n}};function y({error:e,details:t}){return a(`div`,{className:`rsc-error`,style:{padding:`16px`,backgroundColor:`#fee`,border:`1px solid #fcc`,borderRadius:`4px`,margin:`8px 0`,fontFamily:`monospace`}},a(`h3`,{style:{margin:`0 0 8px 0`,color:`#c00`}},`RSC Error`),a(`p`,{style:{margin:`0 0 8px 0`}},e),t&&a(`details`,{style:{marginTop:`8px`}},a(`summary`,{style:{cursor:`pointer`}},`Error Details`),a(`pre`,{style:{fontSize:`12px`,overflow:`auto`,backgroundColor:`#f5f5f5`,padding:`8px`}},JSON.stringify(t,null,2))))}function b({componentId:e,props:t,fallback:n}){let[i,o]=l({data:null,loading:!0,error:null}),u=JSON.stringify(t),d=c(u);s(()=>{let n=!0;return d.current!==u&&(o({data:null,loading:!0,error:null}),d.current=u),v.fetchServerComponent(e,t).then(e=>{n&&o({data:e,loading:!1,error:null})}).catch(e=>{n&&o({data:null,loading:!1,error:e})}),()=>{n=!1}},[e,u]);let{data:f,loading:p,error:m}=i;return p?n||null:m?a(y,{error:`Error loading component`,details:{message:m.message,componentId:e}}):f?f[`~isRscResponse`]?a(r,{fallback:n||null},f.readRoot()):f:a(y,{error:`No data received for component: ${e}`,details:{componentId:e,dataType:typeof f,hasData:!!f}})}function x(e){let t=0;if(typeof window<`u`){let n=window;n[`~rscRefreshCounters`]=n[`~rscRefreshCounters`]||{},n[`~rscRefreshCounters`][e]===void 0&&(n[`~rscRefreshCounters`][e]=0),t=n[`~rscRefreshCounters`][e]}let n=n=>{let[i,o]=l(t);return s(()=>{let t=t=>{let n=t.detail;if(n&&n.filePath&&C(n.filePath)&&(v.clearCache(),typeof window<`u`)){let t=window;t[`~rscRefreshCounters`]||={},t[`~rscRefreshCounters`][e]=(t[`~rscRefreshCounters`][e]||0)+1,o(t[`~rscRefreshCounters`][e])}};return typeof window<`u`&&window.addEventListener(`rari:rsc-invalidate`,t),()=>{typeof window<`u`&&window.removeEventListener(`rari:rsc-invalidate`,t)}},[]),a(r,{fallback:null},a(b,{key:`${e}-${i}`,componentId:e,props:n,fallback:null}))};return n.displayName=`ServerComponent(${e})`,function(e){return a(n,e)}}function S(e,t){return v.fetchServerComponent(e,t)}function C(e){if(!e)return!1;try{return typeof globalThis<`u`&&globalThis[`~rari`].serverComponents?globalThis[`~rari`].serverComponents.has(e):!1}catch(e){return console.error(`Error checking if file is server component:`,e),!1}}if(import.meta.hot){import.meta.hot.on(`rari:register-server-component`,e=>{e?.filePath&&typeof globalThis<`u`&&(globalThis[`~rari`].serverComponents=globalThis[`~rari`].serverComponents||new Set,globalThis[`~rari`].serverComponents.add(e.filePath))}),import.meta.hot.on(`rari:server-components-registry`,e=>{e?.serverComponents&&Array.isArray(e.serverComponents)&&typeof globalThis<`u`&&(globalThis[`~rari`].serverComponents=globalThis[`~rari`].serverComponents||new Set,e.serverComponents.forEach(e=>{globalThis[`~rari`].serverComponents?.add(e)}))}),import.meta.hot.on(`vite:beforeFullReload`,async e=>{e?.path&&C(e.path)&&await o({filePath:e.path,forceReload:!0})}),import.meta.hot.on(`rari:server-component-updated`,async e=>{let t=e?.id||e?.componentId,n=e?.t||e?.timestamp;if(t){if(typeof window<`u`){let r=new CustomEvent(`rari:rsc-invalidate`,{detail:{componentId:t,filePath:e.filePath||e.file,type:`server-component`,timestamp:n}});window.dispatchEvent(r)}}else e?.path&&C(e.path)&&await o({filePath:e.path,forceReload:!1})}),import.meta.hot.on(`rari:app-router-updated`,async t=>{try{if(!t)return;await e(t)}catch(e){console.error(`[rari] HMR: App router update failed:`,e)}}),import.meta.hot.on(`rari:server-action-updated`,async e=>{if(e?.filePath&&(v.clearCache(),typeof window<`u`)){let t=new CustomEvent(`rari:rsc-invalidate`,{detail:{filePath:e.filePath,type:`server-action`}});window.dispatchEvent(t)}});async function e(e){let n=e.fileType,o=e.filePath,s=e.routePath,c=e.affectedRoutes,l=e.manifestUpdated,u=e.metadata;e.metadataChanged&&u&&t(u);try{let e=`${window.location.origin}/_rari/hmr`,t=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`register`,file_path:o})});t.ok||console.error(`[rari] HMR: Component reload failed:`,t.status),await new Promise(e=>setTimeout(e,100))}catch(e){console.error(`[rari] HMR: Failed to reload component:`,e)}let d=[s];switch(n){case`page`:d=[s];break;case`layout`:case`loading`:case`error`:case`not-found`:d=c;break;default:break}await r({routes:d,fileType:n,filePath:o,componentId:s}),l&&await a(),await i({routePath:s,affectedRoutes:c})}function t(e){if(!(typeof document>`u`)&&(e.title&&(document.title=e.title),e.description)){let t=document.querySelector(`meta[name="description"]`);t||(t=document.createElement(`meta`),t.setAttribute(`name`,`description`),document.head.appendChild(t)),t.setAttribute(`content`,e.description)}}function n(e){if(!e||e.length===0){v.clearCache();return}let t=[];for(let n of v.componentCache.keys())for(let r of e){if(n.includes(`route:${r}:`)||n.startsWith(`${r}:`)){t.push(n);break}if(r!==`/`&&n.includes(`route:${r}/`)){t.push(n);break}}for(let e of t)v.componentCache.delete(e)}async function r(e){let t=e.routes||[],r=e.fileType,i=e.filePath,a=e.componentId;if(a||i)try{let e=`${window.location.origin.includes(`:5173`)?`http://localhost:3000`:window.location.origin}/_rari/hmr`,t=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`invalidate`,componentId:a||i,filePath:i})});t.ok||console.error(`[rari] HMR: Server cache invalidation failed:`,t.status)}catch(e){console.error(`[rari] HMR: Failed to call server invalidation endpoint:`,e)}if(n(t),typeof window<`u`){let e=new CustomEvent(`rari:rsc-invalidate`,{detail:{routes:t,fileType:r}});window.dispatchEvent(e);let n=window.location.pathname;if(t.includes(n)||t.includes(`/`))try{let e=(window.location.origin.includes(`:5173`)?`http://localhost:3000`:window.location.origin)+n+window.location.search,t=await fetch(e,{headers:{Accept:`text/x-component`},cache:`no-cache`});t.ok||console.error(`[rari] HMR: Failed to re-fetch route:`,t.status)}catch(e){console.error(`[rari] HMR: Failed to re-fetch route:`,e)}}}async function i(e){let t=e.routePath,n=e.affectedRoutes||[t];if(!(typeof window>`u`))try{let e=window.location.pathname,r=new CustomEvent(`rari:app-router-rerender`,{detail:{routePath:t,affectedRoutes:n,currentPath:e,preserveParams:!0}});window.dispatchEvent(r)}catch(e){throw console.error(`[rari] HMR: Failed to trigger re-render:`,e),e}}async function a(){typeof window<`u`&&window[`~rari`]?.routeInfoCache&&window[`~rari`].routeInfoCache.clear()}async function o(e){let t=e?.filePath||e;if(v.clearCache(),typeof window<`u`){let e=new CustomEvent(`rari:rsc-invalidate`,{detail:{filePath:t}});window.dispatchEvent(e)}}}var w=class{overlay;currentError;constructor(){this.overlay=null,this.currentError=null}show(e){this.currentError=e,this.overlay?this.updateOverlay(e):this.createOverlay(e)}hide(){this.overlay&&(this.overlay.remove(),this.overlay=null,this.currentError=null)}isVisible(){return this.overlay!==null}createOverlay(e){this.overlay=document.createElement(`div`),this.overlay.id=`rari-hmr-error-overlay`,this.updateOverlay(e),document.body.appendChild(this.overlay)}updateOverlay(e){if(!this.overlay)return;let t=e.filePath?`<div style="margin-bottom: 1rem; padding: 0.75rem; background: rgba(0, 0, 0, 0.2); border-radius: 0.375rem; font-family: monospace; font-size: 0.875rem;"><strong>File:</strong> ${this.escapeHtml(e.filePath)}</div>`:``,n=e.stack?`<details style="margin-top: 1rem; cursor: pointer;"><summary style="font-weight: 600; margin-bottom: 0.5rem; user-select: none;">Stack Trace</summary><pre style="margin: 0; padding: 0.75rem; background: rgba(0, 0, 0, 0.2); border-radius: 0.375rem; overflow-x: auto; font-size: 0.875rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word;">${this.escapeHtml(e.stack)}</pre></details>`:``;this.overlay.innerHTML=`<div style="position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.85); z-index: 999999; display: flex; align-items: center; justify-content: center; padding: 2rem; backdrop-filter: blur(4px);"><div style="background: #1e1e1e; color: #e0e0e0; border-radius: 0.5rem; padding: 2rem; max-width: 50rem; width: 100%; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.4); border: 1px solid #ef4444;"><div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem;"><div style="display: flex; align-items: center; gap: 0.75rem;"><svg style="width: 2rem; height: 2rem; color: #ef4444;" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"></path></svg><h1 style="margin: 0; font-size: 1.5rem; font-weight: 700; color: #ef4444;">Build Error</h1></div><button onclick="document.getElementById('rari-hmr-error-overlay').remove()" style="background: transparent; border: none; color: #9ca3af; cursor: pointer; padding: 0.5rem; border-radius: 0.25rem; transition: all 0.2s; font-size: 1.5rem; line-height: 1; width: 2rem; height: 2rem; display: flex; align-items: center; justify-content: center;" onmouseover="this.style.background='rgba(255,255,255,0.1)'; this.style.color='#e0e0e0'" onmouseout="this.style.background='transparent'; this.style.color='#9ca3af'">×</button></div>${t}<div style="margin-bottom: 1.5rem;"><h2 style="margin: 0 0 0.75rem 0; font-size: 1rem; font-weight: 600; color: #fca5a5;">Error Message:</h2><pre style="margin: 0; padding: 1rem; background: rgba(239, 68, 68, 0.1); border-left: 4px solid #ef4444; border-radius: 0.375rem; overflow-x: auto; font-family: monospace; font-size: 0.875rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word; color: #fca5a5;">${this.escapeHtml(e.message)}</pre></div>${n}<div style="margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid #374151; display: flex; gap: 0.75rem; align-items: center;"><button onclick="window.location.reload()" style="padding: 0.625rem 1.25rem; background: #ef4444; color: white; border: none; border-radius: 0.375rem; cursor: pointer; font-weight: 600; font-size: 0.875rem; transition: all 0.2s;" onmouseover="this.style.background='#dc2626'" onmouseout="this.style.background='#ef4444'">Reload Page</button><button onclick="document.getElementById('rari-hmr-error-overlay').remove()" style="padding: 0.625rem 1.25rem; background: #374151; color: #e0e0e0; border: none; border-radius: 0.375rem; cursor: pointer; font-weight: 600; font-size: 0.875rem; transition: all 0.2s;" onmouseover="this.style.background='#4b5563'" onmouseout="this.style.background='#374151'">Dismiss</button><span style="margin-left: auto; font-size: 0.75rem; color: #9ca3af;">${new Date(e.timestamp).toLocaleTimeString()}</span></div></div></div>`}escapeHtml(e){let t=document.createElement(`div`);return t.textContent=e,t.innerHTML}};let T=null;function E(){return T||=new w,T}if(import.meta.hot){let e=E();import.meta.hot.on(`rari:hmr-error`,t=>{let n=t.msg||t.message,r=t.file||t.filePath,i=t.t||t.timestamp,a=t.count||t.errorCount,o=t.max||t.maxErrors;console.error(`[rari] HMR: Build error:`,n),r&&console.error(`[rari] HMR: File:`,r),t.stack&&console.error(`[rari] HMR: Stack:`,t.stack),e.show({message:n,stack:t.stack,filePath:r,timestamp:i}),a&&o&&(a>=o?console.error(`[rari] HMR: Maximum error count (${o}) reached. Consider restarting the dev server if issues persist.`):a>=o-2&&console.warn(`[rari] HMR: Error count: ${a}/${o}. Approaching maximum error threshold.`))}),import.meta.hot.on(`rari:hmr-error-cleared`,()=>{e.hide()}),import.meta.hot.on(`vite:error`,t=>{e.show({message:t.err?.message||`Unknown Vite error`,stack:t.err?.stack,filePath:t.err?.file,timestamp:Date.now()})})}export{y as RscErrorComponent,p as createClientModuleMap,x as createServerComponentWrapper,S as fetchServerComponent,f as getClientComponent,d as registerClientComponent,v as rscClient};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{t as e}from"./rolldown-runtime-DR3Ue2cl.mjs";import t from"node:fs";import n from"node:path";import r from"node:process";import{build as i}from"rolldown";var a=e({ServerComponentBuilder:()=>o,createServerBuildPlugin:()=>c,scanDirectory:()=>s}),o=class{serverComponents=new Map;serverActions=new Map;options;projectRoot;buildCache=new Map;htmlOnlyImports=new Set;getComponentCount(){return this.serverComponents.size+this.serverActions.size}constructor(e,t={}){this.projectRoot=e;let i=t.rscDir||`server`;this.options={outDir:t.outDir||n.join(e,`dist`),rscDir:i,manifestPath:t.manifestPath||n.join(i,`manifest.json`),serverConfigPath:t.serverConfigPath||n.join(i,`config.json`),minify:t.minify??r.env.NODE_ENV===`production`,alias:t.alias||{},define:t.define,csp:t.csp,rateLimit:t.rateLimit,spamBlocker:t.spamBlocker},this.parseHtmlImports()}parseHtmlImports(){let e=n.join(this.projectRoot,`index.html`);if(t.existsSync(e))try{let r=t.readFileSync(e,`utf-8`);for(let e of r.matchAll(/import\s+["']([^"']+)["']/g)){let t=e[1];if(t.startsWith(`/src/`)){let e=n.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){if(e.includes(`node_modules`)||this.isHtmlOnlyImport(e))return!1;try{if(!t.existsSync(e))return!1;let n=t.readFileSync(e,`utf-8`).split(`
|
|
2
|
-
`),r=!1,i=!1;for(let e of n){let t=e.trim();if(!(t.startsWith(`//`)||t.startsWith(`/*`)||!t)){if(t===`'use client'`||t===`"use client"`||t===`'use client';`||t===`"use client";`){r=!0;break}if(t===`'use server'`||t===`"use server"`||t===`'use server';`||t===`"use server";`){i=!0;break}if(t)break}}return!r&&!i}catch{return!1}}isClientComponent(e){try{if(!t.existsSync(e))return!1;let n=t.readFileSync(e,`utf-8`),r=[`'use client'`,`"use client"`,`/* @client */`,`// @client`],i=n.trim();return r.some(e=>i.startsWith(e)||n.includes(e))}catch{return!1}}addServerComponent(e){let n=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))return;let r=this.extractDependencies(n),i=this.hasNodeImports(n);this.serverComponents.set(e,{filePath:e,originalCode:n,dependencies:r,hasNodeImports:i})}isServerAction(e){let t=e.split(`
|
|
1
|
+
import{t as e}from"./rolldown-runtime-DR3Ue2cl.mjs";import t from"node:fs";import n from"node:path";import r from"node:process";import{build as i}from"rolldown";var a=e({ServerComponentBuilder:()=>o,createServerBuildPlugin:()=>c,scanDirectory:()=>s}),o=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}constructor(e,t={}){this.projectRoot=e;let i=t.rscDir||`server`;this.options={outDir:t.outDir||n.join(e,`dist`),rscDir:i,manifestPath:t.manifestPath||n.join(i,`manifest.json`),serverConfigPath:t.serverConfigPath||n.join(i,`config.json`),minify:t.minify??r.env.NODE_ENV===`production`,alias:t.alias||{},define:t.define,csp:t.csp,rateLimit:t.rateLimit,spamBlocker:t.spamBlocker},this.parseHtmlImports()}parseHtmlImports(){let e=n.join(this.projectRoot,`index.html`);if(t.existsSync(e))try{let r=t.readFileSync(e,`utf-8`);for(let e of r.matchAll(/import\s*\(\s*["']([^"']+)["']\s*\)|import\s+["']([^"']+)["']/g)){let t=e[1]||e[2];if(t.startsWith(`/src/`)){let e=n.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){if(e.includes(`node_modules`)||this.isHtmlOnlyImport(e))return!1;try{if(!t.existsSync(e))return!1;let n=t.readFileSync(e,`utf-8`).split(`
|
|
2
|
+
`),r=!1,i=!1;for(let e of n){let t=e.trim();if(!(t.startsWith(`//`)||t.startsWith(`/*`)||!t)){if(t===`'use client'`||t===`"use client"`||t===`'use client';`||t===`"use client";`){r=!0;break}if(t===`'use server'`||t===`"use server"`||t===`'use server';`||t===`"use server";`){i=!0;break}if(t)break}}return!r&&!i}catch{return!1}}isClientComponent(e){try{if(!t.existsSync(e))return!1;let n=t.readFileSync(e,`utf-8`),r=[`'use client'`,`"use client"`,`/* @client */`,`// @client`],i=n.trim();return r.some(e=>i.startsWith(e)||n.includes(e))}catch{return!1}}buildImportGraph(e){this.fileImporters.clear();let r=e=>{if(!t.existsSync(e))return;let i=t.readdirSync(e,{withFileTypes:!0});for(let a of i){let i=n.join(e,a.name);if(a.isDirectory()){if(a.name===`node_modules`)continue;r(i)}else if(a.isFile()&&/\.(?:tsx?|jsx?)$/.test(a.name))try{let e=t.readFileSync(i,`utf-8`),r=/from\s+['"]([^'"]+)['"]|import\s*\(\s*['"]([^'"]+)['"]\s*\)|import\s+['"]([^'"]+)['"]/g,a;for(a=r.exec(e);a!==null;){let o=a[1]||a[2]||a[3],s=null;if(o.startsWith(`./`)||o.startsWith(`../`)){let e=n.dirname(i);s=n.resolve(e,o)}else if(o.startsWith(`@/`)){let e=o.slice(2);s=n.join(this.projectRoot,`src`,e)}if(s){let e=[``,`.ts`,`.tsx`,`.js`,`.jsx`],n=null;for(let r of e){let e=s+r;if(t.existsSync(e)&&t.statSync(e).isFile()){n=e;break}}n&&(this.fileImporters.has(n)||this.fileImporters.set(n,new Set),this.fileImporters.get(n).add(i))}a=r.exec(e)}}catch(e){e?.code!==`ENOENT`&&console.warn(`[rari] Unexpected error building import graph:`,i,e)}}};r(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){let n=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))return;let r=this.extractDependencies(n),i=this.hasNodeImports(n);this.serverComponents.set(e,{filePath:e,originalCode:n,dependencies:r,hasNodeImports:i})}isServerAction(e){let t=e.split(`
|
|
3
3
|
`);for(let e of t){let t=e.trim();if(!(t.startsWith(`//`)||t.startsWith(`/*`)||!t)){if(t===`'use server'`||t===`"use server"`||t===`'use server';`||t===`"use server";`)return!0;if(t)break}}return!1}extractDependencies(e){let t=[],n=/import(?:\s+(?:\w+|\{[^}]*\}|\*\s+as\s+\w+)(?:\s*,\s*(?:\w+|\{[^}]*\}|\*\s+as\s+\w+))*\s+from\s+)?['"]([^'"]+)['"]/g,r;for(;r=n.exec(e),r!==null;){let e=r[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 r=n.relative(this.projectRoot,t),i=this.getComponentId(r),a=await this.buildComponentCodeOnly(t);e.push({id:i,code:a})}for(let[t]of this.serverActions){let r=n.relative(this.projectRoot,t),i=this.getComponentId(r),a=await this.buildComponentCodeOnly(t);e.push({id:i,code:a})}return e}transformComponentImportsToGlobal(e){let r=/import\s+(\w+)\s+from\s+['"]([^'"]+)['"]/g,i=[];for(let a of e.matchAll(r)){let[e,r,o]=a;if(!o.startsWith(`.`)&&!o.startsWith(`@`)&&!o.startsWith(`~`)&&!o.startsWith(`#`))continue;let s=null;if(o.startsWith(`.`)){if(o.includes(`/components/`)){let a=o.match(/\/components\/(\w+)(?:\.tsx?|\.jsx?)?$/);if(a){let o=a[1],s=[n.resolve(this.projectRoot,`src`,`components`,`${o}.tsx`),n.resolve(this.projectRoot,`src`,`components`,`${o}.ts`),n.resolve(this.projectRoot,`src`,`components`,`${o}.jsx`),n.resolve(this.projectRoot,`src`,`components`,`${o}.js`)],c=!1;for(let e of s)if(t.existsSync(e)&&this.isClientComponent(e)){c=!0;break}if(!c)continue;let l=`// Component reference: ${o}
|
|
4
4
|
const ${r} = (props) => {
|
|
5
5
|
let Component = globalThis['~rsc']?.components?.['components/${o}']
|
|
@@ -173,5 +173,5 @@ function registerClientReference(clientReference, id, exportName) {
|
|
|
173
173
|
return clientProxy;
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
`+r);for(let{original:e,replacement:t}of o)r=r.replace(e,t);return r}resolveImportPath(e,r){let i=e,a=this.options.alias||{};for(let[t,r]of Object.entries(a))if(e.startsWith(`${t}/`)||e===t){let a=e.slice(t.length);i=n.join(r,a);break}n.isAbsolute(i)||(i=n.resolve(n.dirname(r),i));let o=[`.tsx`,`.jsx`,`.ts`,`.js`];for(let e of o){let n=`${i}${e}`;if(t.existsSync(n))return n}if(t.existsSync(i))for(let e of o){let r=n.join(i,`index${e}`);if(t.existsSync(r))return r}return`${i}.tsx`}getComponentId(e){return e.replace(/\\/g,`/`).replace(/\.(tsx?|jsx?)$/,``).replace(/[^\w/-]/g,`_`).replace(/^src\//,``)}async rebuildComponent(e){let r=this.getComponentId(n.relative(this.projectRoot,e)),i=await t.promises.readFile(e,`utf-8`),a=this.extractDependencies(i),o={filePath:e,originalCode:i,dependencies:a,hasNodeImports:this.hasNodeImports(i)};this.isServerAction(i)?this.serverActions.set(e,o):this.serverComponents.set(e,o);let s=n.join(this.options.rscDir,`${r}.js`),c=n.join(this.options.outDir,s),l=this.buildCache.get(e),u=(await t.promises.stat(e)).mtimeMs;if(l&&l.timestamp>=u&&JSON.stringify(l.dependencies)===JSON.stringify(a))return await t.promises.writeFile(c,l.code,`utf-8`),await this.updateManifestForComponent(r,e,s),{componentId:r,bundlePath:n.join(this.options.outDir,s),success:!0};let d=n.dirname(c);await t.promises.mkdir(d,{recursive:!0});let f=await this.buildSingleComponent(e,c,!0);return this.buildCache.set(e,{code:f,timestamp:Date.now(),dependencies:a}),await this.updateManifestForComponent(r,e,s),{componentId:r,bundlePath:n.join(this.options.outDir,s),success:!0}}manifestCache=null;async updateManifestForComponent(e,r,i){let a=n.join(this.options.outDir,this.options.manifestPath),o;if(this.manifestCache)o=this.manifestCache;else if(t.existsSync(a)){let e=await t.promises.readFile(a,`utf-8`);o=JSON.parse(e),this.manifestCache=o}else o={components:{},importMap:{imports:{react:`npm:react@19`,"react-dom":`npm:react-dom@19`,"react/jsx-runtime":`npm:react@19/jsx-runtime`,"react/jsx-dev-runtime":`npm:react@19/jsx-dev-runtime`}},version:`1.0.0`,buildTime:new Date().toISOString()},this.manifestCache=o;let s=this.serverComponents.get(r)||this.serverActions.get(r),c=n.join(this.options.outDir,i),l=`file://${n.resolve(this.projectRoot,c)}`;if(s)o.components[e]={id:e,filePath:r,relativePath:n.relative(this.projectRoot,r),bundlePath:i,moduleSpecifier:l,dependencies:s.dependencies,hasNodeImports:s.hasNodeImports};else{let a=await t.promises.readFile(r,`utf-8`);o.components[e]={id:e,filePath:r,relativePath:n.relative(this.projectRoot,r),bundlePath:i,moduleSpecifier:l,dependencies:this.extractDependencies(a),hasNodeImports:this.hasNodeImports(a)}}o.importMap||={imports:{react:`npm:react@19`,"react-dom":`npm:react-dom@19`,"react/jsx-runtime":`npm:react@19/jsx-runtime`,"react/jsx-dev-runtime":`npm:react@19/jsx-dev-runtime`}},o.buildTime=new Date().toISOString(),await t.promises.writeFile(a,JSON.stringify(o,null,2),`utf-8`),this.manifestCache=o}clearCache(){this.buildCache.clear(),this.manifestCache=null}async getTransformedComponentCode(e){return await this.buildComponentCodeOnly(e)}};function s(e,r){let
|
|
177
|
-
`),n=!1;for(let t of e){let e=t.trim();if(!(e.startsWith(`//`)||e.startsWith(`/*`)||!e)){if(e===`'use server'`||e===`"use server"`||e===`'use server';`||e===`"use server";`){n=!0;break}if(e)break}}n&&r.addServerComponent(
|
|
176
|
+
`+r);for(let{original:e,replacement:t}of o)r=r.replace(e,t);return r}resolveImportPath(e,r){let i=e,a=this.options.alias||{};for(let[t,r]of Object.entries(a))if(e.startsWith(`${t}/`)||e===t){let a=e.slice(t.length);i=n.join(r,a);break}n.isAbsolute(i)||(i=n.resolve(n.dirname(r),i));let o=[`.tsx`,`.jsx`,`.ts`,`.js`];for(let e of o){let n=`${i}${e}`;if(t.existsSync(n))return n}if(t.existsSync(i))for(let e of o){let r=n.join(i,`index${e}`);if(t.existsSync(r))return r}return`${i}.tsx`}getComponentId(e){return e.replace(/\\/g,`/`).replace(/\.(tsx?|jsx?)$/,``).replace(/[^\w/-]/g,`_`).replace(/^src\//,``)}async rebuildComponent(e){let r=this.getComponentId(n.relative(this.projectRoot,e)),i=await t.promises.readFile(e,`utf-8`),a=this.extractDependencies(i),o={filePath:e,originalCode:i,dependencies:a,hasNodeImports:this.hasNodeImports(i)};this.isServerAction(i)?this.serverActions.set(e,o):this.serverComponents.set(e,o);let s=n.join(this.options.rscDir,`${r}.js`),c=n.join(this.options.outDir,s),l=this.buildCache.get(e),u=(await t.promises.stat(e)).mtimeMs;if(l&&l.timestamp>=u&&JSON.stringify(l.dependencies)===JSON.stringify(a))return await t.promises.writeFile(c,l.code,`utf-8`),await this.updateManifestForComponent(r,e,s),{componentId:r,bundlePath:n.join(this.options.outDir,s),success:!0};let d=n.dirname(c);await t.promises.mkdir(d,{recursive:!0});let f=await this.buildSingleComponent(e,c,!0);return this.buildCache.set(e,{code:f,timestamp:Date.now(),dependencies:a}),await this.updateManifestForComponent(r,e,s),{componentId:r,bundlePath:n.join(this.options.outDir,s),success:!0}}manifestCache=null;async updateManifestForComponent(e,r,i){let a=n.join(this.options.outDir,this.options.manifestPath),o;if(this.manifestCache)o=this.manifestCache;else if(t.existsSync(a)){let e=await t.promises.readFile(a,`utf-8`);o=JSON.parse(e),this.manifestCache=o}else o={components:{},importMap:{imports:{react:`npm:react@19`,"react-dom":`npm:react-dom@19`,"react/jsx-runtime":`npm:react@19/jsx-runtime`,"react/jsx-dev-runtime":`npm:react@19/jsx-dev-runtime`}},version:`1.0.0`,buildTime:new Date().toISOString()},this.manifestCache=o;let s=this.serverComponents.get(r)||this.serverActions.get(r),c=n.join(this.options.outDir,i),l=`file://${n.resolve(this.projectRoot,c)}`;if(s)o.components[e]={id:e,filePath:r,relativePath:n.relative(this.projectRoot,r),bundlePath:i,moduleSpecifier:l,dependencies:s.dependencies,hasNodeImports:s.hasNodeImports};else{let a=await t.promises.readFile(r,`utf-8`);o.components[e]={id:e,filePath:r,relativePath:n.relative(this.projectRoot,r),bundlePath:i,moduleSpecifier:l,dependencies:this.extractDependencies(a),hasNodeImports:this.hasNodeImports(a)}}o.importMap||={imports:{react:`npm:react@19`,"react-dom":`npm:react-dom@19`,"react/jsx-runtime":`npm:react@19/jsx-runtime`,"react/jsx-dev-runtime":`npm:react@19/jsx-dev-runtime`}},o.buildTime=new Date().toISOString(),await t.promises.writeFile(a,JSON.stringify(o,null,2),`utf-8`),this.manifestCache=o}clearCache(){this.buildCache.clear(),this.manifestCache=null}async getTransformedComponentCode(e){return await this.buildComponentCodeOnly(e)}};function s(e,r,i=!0){i&&r.buildImportGraph(e);let a=t.readdirSync(e,{withFileTypes:!0});for(let i of a){let a=n.join(e,i.name);if(i.isDirectory())s(a,r,!1);else if(i.isFile()&&/\.(?:tsx?|jsx?)$/.test(i.name)){if(/^(?:robots|sitemap)\.(?:tsx?|jsx?)$/.test(i.name)||i.name.endsWith(`.d.ts`)||r.isOnlyImportedByClientComponents(a))continue;try{if(r.isServerComponent(a))r.addServerComponent(a);else{let e=t.readFileSync(a,`utf-8`).split(`
|
|
177
|
+
`),n=!1;for(let t of e){let e=t.trim();if(!(e.startsWith(`//`)||e.startsWith(`/*`)||!e)){if(e===`'use server'`||e===`"use server"`||e===`'use server';`||e===`"use server";`){n=!0;break}if(e)break}}n&&r.addServerComponent(a)}}catch(e){console.warn(`[server-build] Error checking ${a}:`,e instanceof Error?e.message:e)}}}}function c(e={}){let i=null,a,c=!1;return{name:`rari-server-build`,configResolved(t){a=t.root,c=t.command===`serve`;let n={};if(t.resolve?.alias){let e=t.resolve.alias;Array.isArray(e)?e.forEach(e=>{typeof e.find==`string`&&typeof e.replacement==`string`&&(n[e.find]=e.replacement)}):typeof e==`object`&&Object.entries(e).forEach(([e,t])=>{typeof t==`string`&&(n[e]=t)})}i=new o(a,{...e,alias:n})},buildStart(){if(!i)return;let e=r.env.NODE_ENV===`production`,o=[n.join(a,`dist`,`cache`,`og`),n.join(a,`dist`,`cache`,`images`)];e&&o.push(`/tmp/rari-og-cache`,`/tmp/rari-image-cache`);for(let e of o)try{t.existsSync(e)&&t.rmSync(e,{recursive:!0,force:!0})}catch(t){console.warn(`[rari] Failed to clear cache ${e}:`,t)}let c=n.join(a,`src`);t.existsSync(c)&&s(c,i)},async closeBundle(){if(i){await i.buildServerComponents();try{let{generateRobotsFile:e}=await import(`./robots-generator-DlnLLn5V.mjs`);await e({appDir:n.join(a,`src`,`app`),outDir:n.join(a,`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-D3T5zkl3.mjs`);await e({appDir:n.join(a,`src`,`app`),outDir:n.join(a,`dist`),extensions:[`.ts`,`.tsx`,`.js`,`.jsx`]})}catch(e){console.warn(`[rari] Failed to generate sitemap:`,e)}}},async handleHotUpdate({file:e}){if(!i||!c)return;let r=n.relative(a,e).replace(/\\/g,`/`);if(!(!r.startsWith(`src/`)||!/\.(?:tsx?|jsx?)$/.test(r)))try{if((await t.promises.readFile(e,`utf-8`)).includes(`use client`))return;await i.buildServerComponents()}catch(e){console.error(`[rari] Build: Error rebuilding ${r}:`,e)}}}}export{a as n,c as t};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import{a as e,i as t,n,o as r,r as i,t as a}from"./constants-CmqZuM5B.mjs";import{t as o}from"./server-build-DM-rQz-k.mjs";import s,{promises as c}from"node:fs";import l from"node:path";import u from"node:process";import{Buffer as d}from"node:buffer";import{spawn as f}from"node:child_process";import{fileURLToPath as p}from"node:url";import{build as m}from"rolldown";var h=class extends Response{static json(e,t){let n=new Headers(t?.headers);return n.has(`content-type`)||n.set(`content-type`,`application/json`),new Response(JSON.stringify(e),{...t,headers:n})}static redirect(e,t=307){return new Response(null,{status:t,headers:{location:e}})}static noContent(e){return new Response(null,{...e,status:204})}};function g(e={}){let{root:t=u.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 d(){for(let e of i){let n=`${r}${e}`,i=l.join(t,n);try{return await c.access(i),s(`Found proxy file: ${n}`),{filePath:i,exists:!0,relativePath:n}}catch{}}let e=l.join(t,n);try{await c.access(e);for(let t of i){let i=`${r}${t}`,a=l.join(e,i);try{return await c.access(a),s(`Found proxy file: ${l.join(n,i)}`),{filePath:a,exists:!0,relativePath:l.join(n,i)}}catch{}}}catch{}return null}return{name:`rari:proxy`,async buildStart(){o=await d(),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 _={appDir:`src/app`,extensions:[`.tsx`,`.jsx`,`.ts`,`.js`],outDir:`dist`};function v(e){switch(l.basename(e).replace(/\.(tsx?|jsx?)$/,``)){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 y(e,t){let n=l.relative(t,l.dirname(e));return!n||n===`.`?`/`:`/${n.replace(/\\/g,`/`).split(`/`).filter(Boolean).join(`/`)}`}function b(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 x(e){try{let t=e.match(/export\s+const\s+metadata\s*(?::\s*\w+\s*)?=\s*(\{[\s\S]*?\n\})/);if(!t)return null;let n=t[1],r={},i=n.match(/title\s*:\s*['"]([^'"]+)['"]/);i&&(r.title=i[1]);let a=n.match(/description\s*:\s*['"]([^'"]+)['"]/);a&&(r.description=a[1]);let o=n.match(/keywords\s*:\s*\[([\s\S]*?)\]/);o&&(r.keywords=o[1].split(`,`).map(e=>e.trim().replace(/['"]/g,``)).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 S(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 C(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 w(e={}){let t={..._,...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 c.readdir(e,{withFileTypes:!0});for(let a of i){let i=l.join(e,a.name);a.isDirectory()?await r(i):a.isFile()&&t.extensions.some(e=>a.name.endsWith(e))&&v(i)&&n.add(i)}}catch{}};return await r(e),n},d=async(e,r=!1)=>{let u=l.resolve(e,t.appDir);try{await c.access(u)}catch{return null}try{let d=await s(u),f=o(d);if(!r&&i===f&&n)return n;let{generateAppRouteManifest:p}=await import(`./routes-DbsqVAaM.mjs`).then(e=>e.n),m=await p(u,{extensions:t.extensions}),h=JSON.stringify(m,null,2),g=l.resolve(e,t.outDir);await c.mkdir(g,{recursive:!0});let _=l.join(g,`server`);return await c.mkdir(_,{recursive:!0}),await c.writeFile(l.join(_,`routes.json`),h,`utf-8`),i=f,a.clear(),d.forEach(e=>a.add(e)),h}catch(e){return console.error(`[rari] Router: Failed to generate app routes:`,e),null}},f=e=>{let n=l.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=v(i)!==null,o=r===`add`||r===`unlink`,s=n&&!a.has(i);(o||s)&&(await d(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)}})},p;return{name:`rari-router`,configResolved(e){p=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 d(p||u.cwd(),!0)},configureServer(e){f(e)},async handleHotUpdate(e){let{file:i,server:o}=e,s=l.resolve(o.config.root,t.appDir);if(i.startsWith(s)&&t.extensions.some(e=>i.endsWith(e))){let e=v(i);if(e){let t=r.get(i);t&&clearTimeout(t);let u=setTimeout(async()=>{r.delete(i);let t=!a.has(i),u=n;n=await d(o.config.root,t);let f=u!==n,p=y(i,s),m=[p];if(n)try{m=JSON.parse(n).routes.map(e=>e.path)}catch(e){console.error(`[rari] Router: Failed to parse manifest for affected routes:`,e)}let h=b(p,e,m),g,_=!1,v;if(e===`page`||e===`layout`)try{let e=x(await c.readFile(i,`utf-8`));e&&(g=e,_=!0)}catch(e){console.error(`[rari] Router: Failed to extract metadata:`,e)}if(e===`route`)try{v=S(await c.readFile(i,`utf-8`)),await C(l.relative(s,i))}catch(e){console.error(`[rari] Router: Failed to detect HTTP methods:`,e)}let w={fileType:e,filePath:l.relative(o.config.root,i),routePath:p,affectedRoutes:h,manifestUpdated:f,timestamp:Date.now(),metadata:g,metadataChanged:_,methods:v};o.ws.send({type:`custom`,event:`rari:app-router-updated`,data:w})},200);return r.set(i,u),[]}return n=await d(o.config.root),[]}},async closeBundle(){for(let e of r.values())clearTimeout(e);r.clear()}}}var T=class{errorCount=0;maxErrors;resetTimeout;resetTimer=null;lastError=null;constructor(e={}){this.maxErrors=e.maxErrors??5,this.resetTimeout=e.resetTimeout??3e4}recordError(e){this.errorCount++,this.lastError=e,this.resetTimer&&clearTimeout(this.resetTimer),this.resetTimer=setTimeout(()=>{this.reset()},this.resetTimeout),this.errorCount>=this.maxErrors&&this.handleMaxErrorsReached()}reset(){this.errorCount=0,this.lastError=null,this.resetTimer&&=(clearTimeout(this.resetTimer),null)}getErrorCount(){return this.errorCount}getLastError(){return this.lastError}hasReachedMaxErrors(){return this.errorCount>=this.maxErrors}handleMaxErrorsReached(){console.error(`[rari] HMR: Maximum error count (${this.maxErrors}) reached. Consider restarting the dev server if issues persist.`)}dispose(){this.resetTimer&&=(clearTimeout(this.resetTimer),null),this.reset()}},E=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 T({maxErrors:5,resetTimeout:3e4})}async handleClientComponentUpdate(e,t){let n=l.relative(u.cwd(),e),r=Date.now();this.queueLog(`info`,`Client component changed: ${n}`);try{let i=t.moduleGraph.getModuleById(e);if(i){t.moduleGraph.invalidateModule(i);let e=Date.now()-r;this.queueLog(`success`,`Client component updated: ${n} (${e}ms)`),this.errorHandler.reset()}else 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=Date.now();if(e.length===1){let t=l.relative(u.cwd(),e[0]);this.queueLog(`info`,`Rebuilding server component: ${t}`)}else this.queueLog(`info`,`Rebuilding ${e.length} server components in batch`);let r=await Promise.allSettled(e.map(async e=>{let t=l.relative(u.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))}}})),i=[],a=[];r.forEach(e=>{e.status===`fulfilled`&&e.value.success?i.push(e.value):e.status===`fulfilled`&&!e.value.success?a.push(e.value):e.status===`rejected`&&a.push({filePath:``,relativePath:`unknown`,error:Error(String(e.reason))})});let o=Date.now()-n;if(i.length>0){let e=Date.now();i.forEach(({componentId:n})=>{t.hot.send(`rari:server-component-updated`,{id:n,t:e})}),i.length===1?this.queueLog(`success`,`Server component updated: ${i[0].relativePath} (${o}ms)`):this.queueLog(`success`,`${i.length} server components updated (${o}ms)`),this.errorHandler.reset(),t.ws.send({type:`custom`,event:`rari:hmr-error-cleared`,data:{t:e}})}if(a.length>0){let e=Date.now();a.forEach(({relativePath:n,error:r})=>{let i=r.message,a=(r.stack||``).substring(0,500);this.queueLog(`error`,`Failed to rebuild: ${n} - ${i}`),this.errorHandler.recordError(r),t.ws.send({type:`custom`,event:`rari:hmr-error`,data:{msg:i,stack:a,file:n,t:e,count:this.errorHandler.getErrorCount(),max:5}})}),this.errorHandler.hasReachedMaxErrors()&&this.queueLog(`error`,`Maximum error count reached (${this.errorHandler.getErrorCount()}). Consider restarting the dev server if issues persist.`)}},this.DEBOUNCE_DELAY)}async notifyRustServer(e,t){try{let n=await fetch(`${this.rustServerUrl}/_rari/hmr`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`reload-component`,component_id:e,bundle_path:t})});if(!n.ok){let e=await n.text();throw Error(`HTTP ${n.status}: ${e}`)}}catch(e){throw console.error(`[rari] HMR: Failed to notify Rust server:`,e),e}}detectComponentType(e){try{let t=s.readFileSync(e,`utf-8`).split(`
|
|
2
|
+
`);for(let e of t){let t=e.trim();if(!(!t||t.startsWith(`//`)||t.startsWith(`/*`))){if(t===`'use client'`||t===`"use client"`)return`client`;break}}return`server`}catch{return`unknown`}}queueLog(e,t){this.logBatch.push({type:e,message:t,timestamp:Date.now()}),this.logBatchTimer&&clearTimeout(this.logBatchTimer),this.logBatchTimer=setTimeout(()=>{this.flushLogs()},this.LOG_BATCH_DELAY)}flushLogs(){if(this.logBatch.length===0)return;let e=this.logBatch.reduce((e,t)=>(e[t.type]||(e[t.type]=[]),e[t.type].push(t),e),{});for(let[t,n]of Object.entries(e))if(n.length===1){let e=n[0];this.outputLog(t,e.message)}else{let e=n.map(e=>e.message).join(`
|
|
3
|
+
• `);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()}};async function D(e,t=[]){let n=new Map;async function r(e){if(!s.existsSync(e))return;let t=s.readdirSync(e,{withFileTypes:!0});for(let i of t){let t=l.join(e,i.name);if(i.isDirectory()){if(i.name===`node_modules`||i.name===`dist`)continue;await r(t)}else if(i.isFile()&&/\.(?:tsx?|jsx?)$/.test(i.name))try{let e=s.readFileSync(t,`utf8`);if(!e.includes(`from 'rari/image'`)&&!e.includes(`from "rari/image"`))continue;await O(e,t,n)}catch(e){console.warn(`Failed to read or process file ${t}:`,e)}}}await r(e);for(let e of t)s.existsSync(e)&&await r(e);return{images:[...n.values()]}}async function O(e,t,n){try{let r;r=t.endsWith(`.tsx`)?`tsx`:t.endsWith(`.jsx`)?`jsx`:t.endsWith(`.ts`)?`ts`:`js`;let i=`\0virtual:${t}`,a=await m({input:i,platform:`browser`,write:!1,output:{format:`esm`},moduleTypes:{[`.${r}`]:r},transform:{jsx:`react`},plugins:[{name:`virtual-module`,resolveId(e){return e===i?e:null},load(t){return t===i?{code:e,moduleType:r}:null}}]});if(!a.output||a.output.length===0)throw Error(`Transform produced no output`);let o=a.output[0].code,s=new Set;for(let e of o.matchAll(/import\s+(\w+)\s+from\s+['"]rari\/image['"]/g))s.add(e[1]);for(let e of o.matchAll(/import\s+\{[^}]*\b(?:Image\s+as\s+(\w+)|Image)\b[^}]*\}\s+from\s+['"]rari\/image['"]/g))e[1]?s.add(e[1]):s.add(`Image`);if(s.size===0)return;for(let e of s){let t=e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),r=RegExp(`React\\.createElement\\(\\s*${t}\\s*,\\s*\\{([^}]+)\\}`,`g`);for(let e of o.matchAll(r)){let t=e[1],r=t.match(/src:\s*["']([^"']+)["']/);if(!r)continue;let i=r[1];if(!i.startsWith(`/`)&&!i.startsWith(`http`))continue;let a=t.match(/width:\s*(\d+)/),o=a?Number.parseInt(a[1],10):void 0,s=t.match(/quality:\s*(\d+)/),c=s?Number.parseInt(s[1],10):void 0,l=t.match(/preload:\s*(true|!0)/),u=t.match(/preload:\s*(false|!1)/),d=!!l&&!u,f=`${i}:${o||`auto`}:${c||75}`;(!n.has(f)||d)&&n.set(f,{src:i,width:o,quality:c,preload:d})}}}catch{k(e,n)}}function k(e,t){let n=/<Image\s([^/>]+)\/>/g,r=/<Image\s([^>]+)>/g;for(let r of e.matchAll(n))A(r[1],t);for(let n of e.matchAll(r))A(n[1],t)}function A(e,t){let n=e.match(/src=\{?["']([^"']+)["']\}?|src=\{([^}]+)\}/);if(!n)return;let r=n[1]||n[2];if(!r||r.includes(`{`)||!r.startsWith(`/`)&&!r.startsWith(`http`))return;let i=e.match(/width=\{?(\d+)\}?/),a=i?Number.parseInt(i[1],10):void 0,o=e.match(/quality=\{?(\d+)\}?/),s=o?Number.parseInt(o[1],10):void 0,c=/preload(?:=\{?true\}?)?/.test(e)&&!/preload=\{?false\}?/.test(e),l=`${r}:${a||`auto`}:${s||75}`;(!t.has(l)||c)&&t.set(l,{src:r,width:a,quality:s,preload:c})}const j={remotePatterns:[],localPatterns:[],deviceSizes:a,imageSizes:i,formats:n,qualityAllowlist:r,minimumCacheTTL:e,maxCacheSize:t};async function M(e){let t=import.meta.url,n=p(t),r=l.dirname(n),i=[l.join(r,`runtime`,e),l.join(r,`../runtime`,e)];for(let e of i)try{let t=await s.promises.readFile(e,`utf-8`);return e.endsWith(`.ts`)&&(t=t.replace(/import\s+type\s+(\{[^}]+\})\s+from\s+["']\.\.?\/([^"']+)["'];?/g,(e,t,n)=>`import type ${t} from "rari/${n}";`),t=t.replace(/import\s+type\s+(\*\s+as\s+\w+)\s+from\s+["']\.\.?\/([^"']+)["'];?/g,(e,t,n)=>`import type ${t} from "rari/${n}";`),t=t.replace(/import\s+type\s+(\w+)\s+from\s+["']\.\.?\/([^"']+)["'];?/g,(e,t,n)=>`import type ${t} from "rari/${n}";`),t=t.replace(/import\s+(\{[^}]+\})\s+from\s+["']\.\.?\/([^"']+)["'];?/g,(e,t,n)=>`import ${t} from "rari/${n}";`),t=t.replace(/import\s+(\*\s+as\s+\w+)\s+from\s+["']\.\.?\/([^"']+)["'];?/g,(e,t,n)=>`import ${t} from "rari/${n}";`),t=t.replace(/import\s+(\w+)\s+from\s+["']\.\.?\/([^"']+)["'];?/g,(e,t,n)=>`import ${t} from "rari/${n}";`),t=t.replace(/import\s+["']\.\.?\/([^"']+)["'];?/g,(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 N(){return M(`rsc-client-runtime.mjs`)}async function P(e,t){return(await M(`entry-client.mjs`)).replace(`/*! @preserve CLIENT_COMPONENT_IMPORTS_PLACEHOLDER */`,e).replace(`/*! @preserve CLIENT_COMPONENT_REGISTRATIONS_PLACEHOLDER */`,t)}async function F(){return M(`react-server-dom-shim.mjs`)}async function I(e,t){let n=await D(l.join(e,`src`)),r={...j,...t.images,preoptimizeManifest:n.images},i=l.join(e,`dist`),a=l.join(i,`server`);s.existsSync(a)||s.mkdirSync(a,{recursive:!0});let o=l.join(a,`image.json`);s.writeFileSync(o,JSON.stringify(r,null,2))}function L(e,t=[]){let n=new Set;function r(e){if(!s.existsSync(e))return;let t=s.readdirSync(e,{withFileTypes:!0});for(let i of t){let t=l.join(e,i.name);if(i.isDirectory()){if(i.name===`node_modules`)continue;r(t)}else if(i.isFile()&&/\.(?:tsx?|jsx?)$/.test(i.name))try{let e=s.readFileSync(t,`utf8`);(e.includes(`'use client'`)||e.includes(`"use client"`))&&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)s.existsSync(e)&&r(e);return n}function R(e){return e}function z(e={}){let t=new Map,n=new Set,r=new Map,i=null,a=null,c={};function m(e){if(r.has(e))return r.get(e);let t={hasUseServer:!1,hasUseClient:!1},n=e.replace(/\\/g,`/`);if(!/\.(?:tsx?|jsx?)$/.test(n)||!n.includes(`/src/`))return r.set(e,t),t;try{let n=s.readFileSync(e,`utf-8`);t.hasUseServer=n.includes(`'use server'`)||n.includes(`"use server"`),t.hasUseClient=n.includes(`'use client'`)||n.includes(`"use client"`),r.set(e,t)}catch{r.set(e,t)}return t}function h(t){if(t.includes(`node_modules`)||t.includes(`/rari/dist/`)||t.includes(`\\rari\\dist\\`))return!1;let n=e.projectRoot||u.cwd(),r=l.join(n,`index.html`);if(s.existsSync(r))try{let e=s.readFileSync(r,`utf-8`);for(let r of e.matchAll(/import\s*(?:\(\s*)?["']([^"']+)["']\)?/g)){let e=r[1];if(e.startsWith(`/src/`)&&l.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=s.realpathSync(t)}catch{return!1}try{if(!s.existsSync(i))return!1;let e=s.readFileSync(i,`utf-8`),t=v(e,`use client`);return v(e,`use server`)?!1:!t}catch{return!1}}function _(e){try{let t=[],n=e.matchAll(/export\s*\{([^}]+)\}/g);for(let e of n){let n=e[1].split(`,`);for(let e of n){let n=e.trim().split(/\s+as\s+/).at(-1)?.trim();n&&t.push(n)}}(/export\s+default\s+(?:function|class)\s+\w+/.test(e)||/export\s+default\s+/.test(e))&&t.push(`default`);let r=e.matchAll(/export\s+(?:async\s+)?(?:const|let|var|function|class)\s+(\w+)/g);for(let e of r)e[1]&&t.push(e[1]);return[...new Set(t)]}catch{return[]}}function v(e,t){try{let n=e.split(`
|
|
4
|
+
`);for(let e of n){let n=e.trim();if(!(!n||n.startsWith(`//`)||n.startsWith(`/*`))){if(n===`'${t}'`||n===`"${t}"`||n===`'${t}';`||n===`"${t}";`)return!0;break}}return!1}catch{return!1}}function y(e,t){if(!v(e,`use server`))return e;let n=_(e);if(n.length===0)return e;let r=e;r+=`
|
|
5
|
+
|
|
6
|
+
import {registerServerReference} from "react-server-dom-rari/server";
|
|
7
|
+
`;for(let i of n)if(i===`default`){let n=e.match(/export\s+default\s+(?:async\s+)?function\s+(\w+)/);if(n){let e=n[1];r+=`
|
|
8
|
+
// Register server reference for default export
|
|
9
|
+
`,r+=`registerServerReference(${e}, ${JSON.stringify(t)}, ${JSON.stringify(i)});\n`}else{let n=/export\s+default\s+([^;]+)/,a=e.match(n);if(a){let e=a[1].trim(),o=`__default_export__`;r=r.replace(n,`const ${o} = ${e};\nexport default ${o}`),r+=`
|
|
10
|
+
// Register server reference for default export
|
|
11
|
+
`,r+=`if (typeof ${o} === "function") {\n`,r+=` registerServerReference(${o}, ${JSON.stringify(t)}, ${JSON.stringify(i)});\n`,r+=`}
|
|
12
|
+
`}}}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+=`}
|
|
13
|
+
`;return r+=`
|
|
14
|
+
|
|
15
|
+
if (import.meta.hot) {
|
|
16
|
+
import.meta.hot.accept(() => {
|
|
17
|
+
});
|
|
18
|
+
}`,r}function b(e,t){let n=v(e,`use server`),r=h(t);if(n){let n=_(e);if(n.length===0)return``;let r=l.relative(u.cwd(),t).replace(/\\/g,`/`).replace(/\.(tsx?|jsx?)$/,``).replace(/[^\w/-]/g,`_`).replace(/^src\//,``),i=`import { createServerReference } from "rari/runtime/actions";
|
|
19
|
+
`;for(let e of n)e===`default`?i+=`export default createServerReference("default", ${JSON.stringify(r)}, "default");\n`:i+=`export const ${e} = createServerReference("${e}", ${JSON.stringify(r)}, "${e}");\n`;return i}if(r){let n=_(e);if(n.length===0)return``;let r=l.relative(u.cwd(),t).replace(/\\/g,`/`).replace(/\.(tsx?|jsx?)$/,``).replace(/[^\w/-]/g,`_`).replace(/^src\//,``).replace(/^components\//,``),i=`import { createServerComponentWrapper } from "virtual:rsc-integration.ts";
|
|
20
|
+
`;for(let e of n)e===`default`?i+=`export default createServerComponentWrapper("${r}", ${JSON.stringify(t)});\n`:i+=`export const ${e} = createServerComponentWrapper("${r}_${e}", ${JSON.stringify(t)});\n`;return i}if(!v(e,`use client`))return e;let i=_(e);if(i.length===0)return``;let a=`import {registerClientReference} from "react-server-dom-rari/server";
|
|
21
|
+
`;for(let e of i){if(e===`default`){let e=`Attempted to call the default export of ${t} 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.`;a+=`export default `,a+=`registerClientReference(function() {`,a+=`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.`;a+=`export const ${e} = `,a+=`registerClientReference(function() {`,a+=`throw new Error(${JSON.stringify(t)});`}a+=`},`,a+=`${JSON.stringify(t)},`,a+=`${JSON.stringify(e)});\n`}return a}function x(e,t){return!v(e,`use client`)||_(e).length===0?e:e.replace(/^['"]use client['"];?\s*$/gm,``)}function S(e,t){let n=e;for(let[t,r]of Object.entries(c))if(e.startsWith(`${t}/`)){n=e.replace(t,r);break}else if(e===t){n=r;break}let r=l.resolve(l.dirname(t),n),i=[`.tsx`,`.jsx`,`.ts`,`.js`];for(let e of i){let t=`${r}${e}`;if(s.existsSync(t))return t}if(s.existsSync(r))for(let e of i){let t=l.join(r,`index${e}`);if(s.existsSync(t))return t}return`${r}.tsx`}function C(e){return(e.split(`/`).pop()||e).replace(/\.[^.]*$/,``)}let T=!1;async function D(){let e=`http://localhost:${u.env.SERVER_PORT?Number(u.env.SERVER_PORT):Number(u.env.PORT||u.env.RSC_PORT||3e3)}`;try{let t=(await fetch(`${e}/_rari/health`,{signal:AbortSignal.timeout(1e3)})).ok;return T=t,t}catch{return T=!1,!1}}let O=[{name:`rari`,config(t,{command:n}){if(n===`build`){let n=e.projectRoot||u.cwd(),r=l.join(n,`index.html`);if(s.existsSync(r))try{let e=s.readFileSync(r,`utf-8`),n=/import\s+["']([^"']+)["']/g,i=[];for(let t of e.matchAll(n)){let e=t[1];if(e.startsWith(`/src/`)&&/\.(?:tsx?|jsx?)$/.test(e)){let t=e.slice(1),n=l.basename(t,l.extname(t));i.push({path:t,name:n})}}if(i.length>0){t.build=t.build||{},t.build.rolldownOptions=t.build.rolldownOptions||{};let e=t.build.rolldownOptions.input||{main:`./index.html`},n;n=typeof e==`string`?{main:e}:Array.isArray(e)?{main:e[0]||`./index.html`}:{...e},i.forEach(({path:e,name:t})=>{n[t]=`./${e}`}),t.build.rolldownOptions.input=n}}catch(e){console.warn(`[rari] Error parsing index.html for build inputs:`,e)}}t.resolve=t.resolve||{};let r=Array.isArray(t.resolve.dedupe)?t.resolve.dedupe:[],i=[`react`,`react-dom`];t.resolve.dedupe=[...new Set([...r||[],...i])];let a=[];Array.isArray(t.resolve.alias)?a=t.resolve.alias:t.resolve.alias&&typeof t.resolve.alias==`object`&&(a=Object.entries(t.resolve.alias).map(([e,t])=>({find:e,replacement:t})));let o=new Set(a.map(e=>String(e.find)));try{let e=p(import.meta.resolve(`react`)),n=p(import.meta.resolve(`react-dom/client`)),r=p(import.meta.resolve(`react/jsx-runtime`)),i=[];o.has(`react/jsx-runtime`)||i.push({find:`react/jsx-runtime`,replacement:r});try{let e=p(import.meta.resolve(`react/jsx-dev-runtime`));o.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)}o.has(`react`)||i.push({find:`react`,replacement:e}),o.has(`react-dom/client`)||i.push({find:`react-dom/client`,replacement:n}),i.length>0&&(t.resolve.alias=[...a,...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 c=u.env.SERVER_PORT?Number(u.env.SERVER_PORT):Number(u.env.PORT||u.env.RSC_PORT||3e3);if(t.server.proxy[`/api`]={target:`http://localhost:${c}`,changeOrigin:!0,secure:!1,ws:!0},t.server.proxy[`/_rari`]={target:`http://localhost:${c}`,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)t.advancedChunks=t.advancedChunks||{},t.advancedChunks.groups=t.advancedChunks.groups||[],t.advancedChunks.groups.push({name(e){return e.includes(`node_modules`)?e.includes(`node_modules/react-dom`)?`react-dom`:e.includes(`node_modules/react`)?`react`:`vendor`:null}}),t.chunkFileNames||=e=>e.moduleIds?.some(e=>m(e).hasUseServer)?`client/actions/[name]-[hash].js`:e.moduleIds?.some(e=>m(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)&&(c[e.find]=e.replacement)}):typeof n==`object`&&Object.entries(n).forEach(([e,n])=>{typeof n==`string`&&!t.has(e)&&(c[e]=n)})}},transform(e,r){if(!/\.(?:tsx?|jsx?)$/.test(r))return null;let i=this.environment;if(v(e,`use client`)){t.set(r,`client`),n.add(r);let i=/^\s*import\s+(?:(\w+)(?:\s*,\s*\{\s*(?:(\w+(?:\s*,\s*\w+)*)\s*)?\})?|\{\s*(\w+(?:\s*,\s*\w+)*)\s*\})\s+from\s+['"]([./@][^'"]+)['"].*$/,a=e.split(`
|
|
22
|
+
`);for(let e of a){let a=e.match(i);if(!a)continue;let o=a[4];if(!o)continue;let c=S(o,r);s.existsSync(c)&&(t.set(c,`client`),n.add(c))}return x(e,r)}if(t.get(r)===`client`||n.has(r))return x(e,r);if(h(r)){if(t.set(r,`server`),i&&(i.name===`rsc`||i.name===`ssr`))return y(e,r);{let t=b(e,r);return t=`// HMR acceptance for server component
|
|
23
|
+
if (import.meta.hot) {
|
|
24
|
+
import.meta.hot.accept();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (typeof globalThis !== 'undefined') {
|
|
28
|
+
if (!globalThis['~rari']) globalThis['~rari'] = {};
|
|
29
|
+
globalThis['~rari'].serverComponents = globalThis['~rari'].serverComponents || new Set();
|
|
30
|
+
globalThis['~rari'].serverComponents.add(${JSON.stringify(r)});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
${t}`,t}}if(v(e,`use server`))return t.set(r,`server`),i&&(i.name===`rsc`||i.name===`ssr`)?y(e,r):b(e,r);let a=t.get(r);if(a===`server`)return i&&(i.name===`rsc`||i.name===`ssr`)?y(e,r):b(e,r);if(a===`client`)return x(e,r);t.set(r,`unknown`);let o=e.split(`
|
|
34
|
+
`),c=e,l=!1,d=!1,f=!1,p=[],m=/^\s*import\s+(\w+)(?:\s*,\s*\{\s*(?:(\w+(?:\s*,\s*\w+)*)\s*)?\})?\s+from\s+['"]([./@][^'"]+)['"].*$/;for(let a of o){let o=a.match(m);if(!o)continue;let u=o[1],g=o[3],_=C(g),y=S(g,r),b=v(e,`use client`)||t.get(r)===`client`||r.includes(`entry-client`),x=t.get(y)===`client`||s.existsSync(y)&&s.readFileSync(y,`utf-8`).includes(`'use client'`);if(x&&(t.set(y,`client`),n.add(y)),x&&i&&(i.name===`rsc`||i.name===`ssr`)){if(!b){let e=a,t=u||`default`,n=`
|
|
35
|
+
import { registerClientReference } from "react-server-dom-rari/server";
|
|
36
|
+
const ${t} = registerClientReference(
|
|
37
|
+
function() {
|
|
38
|
+
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.");
|
|
39
|
+
},
|
|
40
|
+
${JSON.stringify(y)},
|
|
41
|
+
${JSON.stringify(u||`default`)}
|
|
42
|
+
);`;c=c.replace(e,n),l=!0,d=!0}}else if(!b&&h(y)){l=!0,d=!0,f=!0;let e=a;u&&u!==`_`&&p.push(`const ${u} = createServerComponentWrapper('${_}', '${g}');`),c=c.replace(e,``)}}if(l){let e=c.includes(`import React`)||c.match(/import\s+\{[^}]*\}\s+from\s+['"]react['"]/)||c.match(/import\s+[^,\s]+\s*,\s*\{[^}]*\}\s+from\s+['"]react['"]/),n=c.includes(`createServerComponentWrapper`),i=``;if(d&&!e&&(i+=`import React from 'react';
|
|
43
|
+
`),f&&!n&&(i+=`import { createServerComponentWrapper } from 'virtual:rsc-integration.ts';
|
|
44
|
+
`),p.length>0&&(i+=`${p.join(`
|
|
45
|
+
`)}\n`),i&&(c=i+c),!c.includes(`Suspense`)){let e=c.match(/import React(,\s*\{([^}]*)\})?\s+from\s+['"]react['"];?/);e&&(e[1]&&!e[2].includes(`Suspense`)?c=c.replace(e[0],e[0].replace(/\{([^}]*)\}/,`{ Suspense, $1 }`)):e[1]||(c=c.replace(e[0],`import React, { Suspense } from 'react';`)))}let a=u.env.NODE_ENV!==`production`,o=c.includes(`</`)||c.includes(`/>`)||/\bJSX\b/.test(c);return!c.includes(`'use client'`)&&!c.includes(`"use client"`)&&o&&a&&(c=`'use client';\n\n${c}`,t.set(r,`client`)),c}return null},async configureServer(n){let r=e.projectRoot||u.cwd(),o=l.join(r,`src`);await I(r,e);let p=null,m=async()=>{try{let{ServerComponentBuilder:t,scanDirectory:i}=await import(`./server-build-DM-rQz-k.mjs`).then(e=>e.n),o=new t(r,{outDir:`dist`,rscDir:`server`,manifestPath:`server/manifest.json`,serverConfigPath:`server/config.json`,alias:c,csp:e.csp,rateLimit:e.rateLimit,spamBlocker:e.spamBlocker});if(p=o,!a&&p){let e=u.env.SERVER_PORT?Number(u.env.SERVER_PORT):Number(u.env.PORT||u.env.RSC_PORT||3e3);a=new E(p,e)}let d=l.join(r,`src`),f=[];if(s.existsSync(d)){let e=t=>{let n=s.readdirSync(t,{withFileTypes:!0});for(let r of n){let n=l.join(t,r.name);if(r.isDirectory())e(n);else if(r.isFile()&&/\.(?:tsx?|jsx?)$/.test(r.name))try{h(n)&&f.push(n)}catch(e){console.error(`[rari] Error checking ${n}:`,e)}}};e(d),i(d,o)}f.length>0&&n.ws.send({type:`custom`,event:`rari:server-components-registry`,data:{serverComponents:f}});let m=await o.getTransformedComponentsForDevelopment(),g=`http://localhost:${u.env.SERVER_PORT?Number(u.env.SERVER_PORT):Number(u.env.PORT||u.env.RSC_PORT||3e3)}`;for(let e of m)try{if(e.id.startsWith(`app/`)||e.code.includes(`"use server"`)||e.code.includes(`'use server'`))continue;let t=await fetch(`${g}/_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))}},g=async()=>{try{let e=`http://localhost:${u.env.SERVER_PORT?Number(u.env.SERVER_PORT):Number(u.env.PORT||u.env.RSC_PORT||3e3)}`,t=L(o,Object.values(c));for(let n of t){let t=l.relative(u.cwd(),n),r=l.basename(n).replace(/\.[^.]+$/,``);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)}},_=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=u.env.SERVER_PORT?Number(u.env.SERVER_PORT):Number(u.env.PORT||u.env.RSC_PORT||3e3),o=u.env.NODE_ENV===`production`?`production`:`development`,s=n.config.server.port||5173,c=[`--mode`,o,`--port`,a.toString(),`--host`,`127.0.0.1`];i=f(r,c,{stdio:[`ignore`,`pipe`,`pipe`],cwd:u.cwd(),env:{...u.env,RUST_LOG:u.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=>{T=!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,T=!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 D(),!l);e++)await new Promise(e=>setTimeout(e,500));l?(await g(),await m()):console.error(`Server failed to become ready for component registration`)},v=async t=>{try{if(!h(t))return;let{ServerComponentBuilder:n}=await import(`./server-build-DM-rQz-k.mjs`).then(e=>e.n),i=new n(r,{outDir:`dist`,rscDir:`server`,manifestPath:`server/manifest.json`,serverConfigPath:`server/config.json`,alias:c,csp:e.csp,rateLimit:e.rateLimit,spamBlocker:e.spamBlocker});i.addServerComponent(t);let a=await i.getTransformedComponentsForDevelopment();if(a.length===0)return;let o=`http://localhost:${u.env.SERVER_PORT?Number(u.env.SERVER_PORT):Number(u.env.PORT||u.env.RSC_PORT||3e3)}`;for(let e of a)try{let t=await fetch(`${o}/_rari/register`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({component_id:e.id,component_code:e.code})});if(!t.ok){let e=await t.text();throw Error(`HTTP ${t.status}: ${e}`)}}catch(t){console.error(`[rari] Failed to register component`,`${e.id}:`,t instanceof Error?t.message:String(t))}}catch(e){console.error(`[rari] Targeted HMR failed for`,`${t}:`,e instanceof Error?e.message:String(e)),setTimeout(m,1e3)}};_().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(!T&&!await D()){let e=Date.now();for(;Date.now()-e<1e4&&!await D();)await new Promise(e=>setTimeout(e,100));if(!T){console.error(`[rari] Rust server not ready, cannot proxy RSC request`),t.headersSent||(t.statusCode=503,t.end(`Server not ready`));return}}let n=u.env.SERVER_PORT?Number(u.env.SERVER_PORT):Number(u.env.PORT||u.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(d.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=>{/\.(?:tsx?|jsx?)$/.test(e)&&t.delete(e),/\.(?:tsx?|jsx?)$/.test(e)&&e.includes(o)&&(h(e)?(n.ws.send({type:`custom`,event:`rari:register-server-component`,data:{filePath:e}}),await v(e)):setTimeout(m,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 v(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),T=!1})},resolveId(e,t){if(e===`virtual:rsc-integration`||e===`virtual:rsc-integration.ts`)return`virtual:rsc-integration.ts`;if(e===`virtual:rari-entry-client`||e===`virtual:rari-entry-client.ts`)return`virtual:rari-entry-client.ts`;if(e===`virtual:react-server-dom-rari-client`||e===`virtual:react-server-dom-rari-client.ts`)return`virtual:react-server-dom-rari-client.ts`;if(e===`virtual:app-router-provider`||e===`virtual:app-router-provider.tsx`)return`virtual:app-router-provider.tsx`;if(e===`./DefaultLoadingIndicator`||e===`./DefaultLoadingIndicator.tsx`)return`virtual:default-loading-indicator.tsx`;if(e===`./LoadingErrorBoundary`||e===`./LoadingErrorBoundary.tsx`)return`virtual:loading-error-boundary.tsx`;if(e===`react-server-dom-rari/server`)return e;if(t&&t.startsWith(`virtual:`)&&e.startsWith(`../`)){let n=import.meta.url,r=p(n),i=l.dirname(r),a=null,o=[l.join(i,`runtime`),l.join(i,`../runtime`)];for(let e of o)if(s.existsSync(e)){a=e;break}if(a){let t=l.join(a,e);if(s.existsSync(t))return t;let n=l.join(a,`../dist`,l.basename(e));if(s.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 c=l.join(i,e);if(s.existsSync(c))return c;let u=l.join(i,`../dist`,l.basename(e));if(s.existsSync(u))return u}if(u.env.NODE_ENV===`production`)try{let t=l.resolve(e);if(s.existsSync(t)&&h(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(/\.(?:tsx?|jsx?)$/.test(t)){let e=this.environment;if(e&&e.name===`client`)try{let e=s.readFileSync(t,`utf-8`);if(v(e,`use server`))return b(e,t)}catch{}}if(t===`virtual:rari-entry-client.ts`){let e=L(l.join(u.cwd(),`src`),Object.values(c)),t=new Set([...n,...e]),r=[{path:`rari/image`,exports:[`Image`]}],i=[...t].filter(e=>{try{return v(s.readFileSync(e,`utf-8`),`use client`)}catch{return!1}}).map(e=>{let t=l.relative(u.cwd(),e).replace(/\\/g,`/`),n=t.replace(/\.(tsx?|jsx?)$/,``),r=t.startsWith(`..`)?e.replace(/\\/g,`/`):t,i=!1,a=``;try{let t=s.readFileSync(e,`utf-8`),n=/export\s+default\s+/.test(t),r=t.match(/export\s+(?:function|const|class)\s+(\w+)/);!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=r.replace(/\\/g,`/`),c=o.startsWith(`/`)||/^[A-Z]:\//i.test(o)?o:`/${o}`;return` "${r}": {
|
|
46
|
+
id: "${n}",
|
|
47
|
+
path: "${r}",
|
|
48
|
+
type: "client",
|
|
49
|
+
loader: () => ${i?`import(${JSON.stringify(c)}).then(m => m.${a} || m.default || m)`:`import(${JSON.stringify(c)}).then(m => m.default || m)`},
|
|
50
|
+
component: null,
|
|
51
|
+
loading: false,
|
|
52
|
+
registered: false
|
|
53
|
+
}`}).join(`,
|
|
54
|
+
`),a=r.map((e,t)=>`import { ${e.exports.map(e=>`${e} as External${t}_${e}`).join(`, `)} } from '${e.path}';`).join(`
|
|
55
|
+
`),o=r.flatMap((e,t)=>e.exports.map(n=>{let r=`External${t}_${n}`;return`
|
|
56
|
+
globalThis['~clientComponents'] = globalThis['~clientComponents'] || {};
|
|
57
|
+
globalThis['~clientComponents']["${`${e.path}#${n}`}"] = {
|
|
58
|
+
id: "${n}",
|
|
59
|
+
path: "${e.path}",
|
|
60
|
+
type: "client",
|
|
61
|
+
component: ${r},
|
|
62
|
+
registered: true
|
|
63
|
+
};
|
|
64
|
+
globalThis['~clientComponents']["${e.path}"] = globalThis['~clientComponents']["${e.path}"] || {};
|
|
65
|
+
globalThis['~clientComponents']["${e.path}"].component = ${r};
|
|
66
|
+
globalThis['~clientComponentPaths'] = globalThis['~clientComponentPaths'] || {};
|
|
67
|
+
globalThis['~clientComponentPaths']["${e.path}"] = "${n}";`})).join(`
|
|
68
|
+
`);return await P(a,[`
|
|
69
|
+
const lazyComponentRegistry = {
|
|
70
|
+
${i}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
for (const [path, config] of Object.entries(lazyComponentRegistry)) {
|
|
74
|
+
globalThis['~clientComponents'][path] = config;
|
|
75
|
+
globalThis['~clientComponents'][config.id] = config;
|
|
76
|
+
globalThis['~clientComponentPaths'][path] = config.id;
|
|
77
|
+
}
|
|
78
|
+
`,o].filter(Boolean).join(`
|
|
79
|
+
`))}if(t===`react-server-dom-rari/server`)return await F();if(t===`virtual:app-router-provider.tsx`){let e=[l.join(u.cwd(),`packages/rari/dist/runtime/AppRouterProvider.mjs`),l.join(u.cwd(),`node_modules/rari/dist/runtime/AppRouterProvider.mjs`)];for(let t of e)if(s.existsSync(t))return s.readFileSync(t,`utf-8`);return`export function AppRouterProvider({ children }) { return children; }`}if(t===`virtual:default-loading-indicator.tsx`){let e=[l.join(u.cwd(),`packages/rari/dist/runtime/DefaultLoadingIndicator.mjs`),l.join(u.cwd(),`node_modules/rari/dist/runtime/DefaultLoadingIndicator.mjs`)];for(let t of e)if(s.existsSync(t))return s.readFileSync(t,`utf-8`);return`export function DefaultLoadingIndicator() { return null; }`}if(t===`virtual:loading-error-boundary.tsx`){let e=[l.join(u.cwd(),`packages/rari/dist/runtime/LoadingErrorBoundary.mjs`),l.join(u.cwd(),`node_modules/rari/dist/runtime/LoadingErrorBoundary.mjs`)];for(let t of e)if(s.existsSync(t))return s.readFileSync(t,`utf-8`);return`export class LoadingErrorBoundary extends React.Component { render() { return this.props.children; } }`}if(t===`virtual:rsc-integration.ts`)return(await N()).replace(/from(\s*)(['"])(?:\.\/|rari\/)react-server-dom-rari-client\.mjs\2/g,(e,t,n)=>`from${t}${n}virtual:react-server-dom-rari-client.ts${n}`);if(t===`virtual:react-server-dom-rari-client.ts`)return await M(`react-server-dom-rari-client.mjs`);if(t.endsWith(`.mjs`)&&s.existsSync(t))try{let n=e.projectRoot||u.cwd(),r=s.realpathSync(t),i=l.relative(n,r),a=!i.startsWith(`..`)&&!l.isAbsolute(i),o=r.includes(`${l.sep}node_modules${l.sep}`),c=r.includes(`${l.sep}packages${l.sep}rari${l.sep}`)||r.includes(`${l.sep}node_modules${l.sep}rari${l.sep}`);return a||o||c?s.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(!/\.(?:tsx?|jsx?)$/.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)){let n=`page`;o?n=`layout`:s?n=`loading`:c?n=`error`:l&&(n=`not-found`),t.hot.send(`rari:app-router-updated`,{type:`rari-hmr`,filePath:e,fileType:n});return}if(n!==`client`&&n===`server`)return a&&await a.handleServerComponentUpdate(e,t),[]},transformIndexHtml:{order:`pre`,handler(e){let t=/import\s+["']([^"']+)["']/g,n=[];for(let r of e.matchAll(t)){let e=r[1];e.startsWith(`/src/`)&&n.push(e)}return n.length>0?{html:e,tags:n.map(e=>({tag:`script`,attrs:{type:`module`,src:e},injectTo:`head-prepend`}))}:e}},async writeBundle(){await I(e.projectRoot||u.cwd(),e)}},o({...e.serverBuild,csp:e.csp,rateLimit:e.rateLimit,spamBlocker:e.spamBlocker})];return e.proxy!==!1&&O.push(g(e.proxy||{})),e.router!==!1&&O.push(w(e.router||{})),O}function B(e){return{plugins:[z(),...e.plugins||[]],...e}}export{g as a,w as i,R as n,h as o,z as r,B as t};
|
package/dist/vite.d.mts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { A as MetadataResult, C as LayoutProps, D as PageProps, E as NotFoundEntry, F as extractMetadata, I as extractServerProps, L as extractServerPropsWithCache, M as StaticParamsResult, N as clearPropsCache, O as RouteSegment, P as clearPropsCacheForComponent, R as extractStaticParams, S as LayoutEntry, T as Metadata, _ as AppRouteMatch, b as GenerateMetadata, c as HttpRuntimeClient, d as RuntimeClient, g as AppRouteManifest, h as AppRouteEntry, i as ServerSpamBlockerConfig, j as ServerSidePropsResult, k as RouteSegmentType, n as ServerConfig, p as createHttpRuntimeClient, r as ServerRateLimitConfig, t as ServerCSPConfig, v as ErrorEntry, w as LoadingEntry, x as GenerateStaticParams, y as ErrorProps, z as hasServerSideDataFetching } from "./server-config-
|
|
2
|
-
import { _ as
|
|
3
|
-
import { a as ProxyModule, c as RariURL, i as ProxyMatcher, l as RequestCookies, n as ProxyConfig, o as ProxyResult, r as ProxyFunction, s as RariFetchEvent, t as CookieOptions, u as ResponseCookies } from "./types-
|
|
1
|
+
import { A as MetadataResult, C as LayoutProps, D as PageProps, E as NotFoundEntry, F as extractMetadata, I as extractServerProps, L as extractServerPropsWithCache, M as StaticParamsResult, N as clearPropsCache, O as RouteSegment, P as clearPropsCacheForComponent, R as extractStaticParams, S as LayoutEntry, T as Metadata, _ as AppRouteMatch, b as GenerateMetadata, c as HttpRuntimeClient, d as RuntimeClient, g as AppRouteManifest, h as AppRouteEntry, i as ServerSpamBlockerConfig, j as ServerSidePropsResult, k as RouteSegmentType, n as ServerConfig, p as createHttpRuntimeClient, r as ServerRateLimitConfig, t as ServerCSPConfig, v as ErrorEntry, w as LoadingEntry, x as GenerateStaticParams, y as ErrorProps, z as hasServerSideDataFetching } from "./server-config-B0xinLcw.mjs";
|
|
2
|
+
import { _ as SitemapVideo, a as generateAppRouteManifest, c as ApiResponse, d as RouteHandler, f as Robots, g as SitemapImage, h as SitemapEntry, i as rariRouter, l as ApiRouteHandlers, m as Sitemap, n as defineRariOptions, o as ProxyPluginOptions, p as RobotsRule, r as rari, s as rariProxy, t as defineRariConfig, u as RouteContext } from "./index-WODoeA3e.mjs";
|
|
3
|
+
import { a as ProxyModule, c as RariURL, i as ProxyMatcher, l as RequestCookies, n as ProxyConfig, o as ProxyResult, r as ProxyFunction, s as RariFetchEvent, t as CookieOptions, u as ResponseCookies } from "./types-FjFDidgJ.mjs";
|
|
4
4
|
import { RariRequest } from "./proxy/RariRequest.mjs";
|
|
5
|
+
import { RariResponse } from "./proxy/RariResponse.mjs";
|
|
5
6
|
|
|
6
7
|
//#region src/vite.d.ts
|
|
7
8
|
type Request = globalThis.Request;
|
package/dist/vite.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,i as t,n,o as r,r as i,
|
|
1
|
+
import{a as e,i as t,n,o as r,r as i,t as a}from"./vite-C4gs8tq5.mjs";import{RariRequest as o}from"./proxy/RariRequest.mjs";import{RariResponse as s}from"./proxy/RariResponse.mjs";import{c,d as l,f as u,g as d,h as f,i as p,m,p as h,u as g}from"./runtime-client-Bg4V1Ksp.mjs";import{t as _}from"./routes-DbsqVAaM.mjs";import"./constants-CmqZuM5B.mjs";import"./server-build-DM-rQz-k.mjs";export{r as ApiResponse,p as HttpRuntimeClient,o as RariRequest,s as RariResponse,g as clearPropsCache,l as clearPropsCacheForComponent,c as createHttpRuntimeClient,a as defineRariConfig,n as defineRariOptions,u as extractMetadata,h as extractServerProps,m as extractServerPropsWithCache,f as extractStaticParams,_ as generateAppRouteManifest,d as hasServerSideDataFetching,i as rari,e as rariProxy,t as rariRouter};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rari",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.9.0",
|
|
5
5
|
"description": "Runtime Accelerated Rendering Infrastructure (rari)",
|
|
6
6
|
"author": "Ryan Skinner",
|
|
7
7
|
"license": "MIT",
|
|
@@ -95,27 +95,27 @@
|
|
|
95
95
|
"node": ">=22.0.0"
|
|
96
96
|
},
|
|
97
97
|
"peerDependencies": {
|
|
98
|
-
"react": "^19.
|
|
99
|
-
"react-dom": "^19.
|
|
98
|
+
"react": "^19.2.4",
|
|
99
|
+
"react-dom": "^19.2.4"
|
|
100
100
|
},
|
|
101
101
|
"dependencies": {
|
|
102
102
|
"rolldown": "1.0.0-rc.2"
|
|
103
103
|
},
|
|
104
104
|
"optionalDependencies": {
|
|
105
|
-
"rari-darwin-arm64": "0.
|
|
106
|
-
"rari-darwin-x64": "0.
|
|
107
|
-
"rari-linux-arm64": "0.
|
|
108
|
-
"rari-linux-x64": "0.
|
|
109
|
-
"rari-win32-x64": "0.
|
|
105
|
+
"rari-darwin-arm64": "0.9.0",
|
|
106
|
+
"rari-darwin-x64": "0.9.0",
|
|
107
|
+
"rari-linux-arm64": "0.9.0",
|
|
108
|
+
"rari-linux-x64": "0.9.0",
|
|
109
|
+
"rari-win32-x64": "0.9.0"
|
|
110
110
|
},
|
|
111
111
|
"devDependencies": {
|
|
112
|
-
"@types/node": "^25.2.
|
|
113
|
-
"@types/react": "^19.2.
|
|
112
|
+
"@types/node": "^25.2.3",
|
|
113
|
+
"@types/react": "^19.2.14",
|
|
114
114
|
"@types/react-dom": "^19.2.3",
|
|
115
|
-
"@typescript/native-preview": "^7.0.0-dev.
|
|
116
|
-
"oxlint": "^1.
|
|
115
|
+
"@typescript/native-preview": "^7.0.0-dev.20260211.1",
|
|
116
|
+
"oxlint": "^1.46.0",
|
|
117
117
|
"rolldown-vite": "^7.3.1",
|
|
118
|
-
"tsdown": "^0.20.
|
|
118
|
+
"tsdown": "^0.20.3",
|
|
119
119
|
"@rari/deploy": "0.1.0",
|
|
120
120
|
"@rari/logger": "0.1.0"
|
|
121
121
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function e(e,t){let n=t[`~clientComponents`]||{},r=t[`~clientComponentPaths`]||{},i=t[`~clientComponentNames`]||{};if(n[e]?.component)return n[e].component;if(e.includes(`#`)){let[t,i]=e.split(`#`),a=r[t];if(a&&n[a]){let e=n[a];if(i===`default`||!i)return e.component}let o=r[t.startsWith(`./`)?t.slice(2):t];if(o&&n[o])return n[o].component}let a=i[e];return a&&n[a]?n[a].component:null}function t(t){return e(t,globalThis)}export{t};
|
package/dist/vite-CfH7EIl7.mjs
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import{a as e,i as t,n,o as r,r as i,t as a}from"./constants-CmqZuM5B.mjs";import{t as o}from"./server-build-C64b2Z-d.mjs";import s,{promises as c}from"node:fs";import l from"node:path";import u from"node:process";import{Buffer as d}from"node:buffer";import{spawn as f}from"node:child_process";import{fileURLToPath as p}from"node:url";import{build as m}from"rolldown";var h=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})}},g=class{cookies;constructor(){this.cookies=new Map}get(e){let t=this.cookies.get(e);if(t)return{name:t.name,value:t.value,path:t.options?.path}}getAll(){return Array.from(this.cookies.values(),e=>({name:e.name,value:e.value,path:e.options?.path}))}set(e,t,n){if(typeof e==`string`)this.cookies.set(e,{name:e,value:t,options:n});else{let{name:t,value:n,...r}=e;this.cookies.set(t,{name:t,value:n,options:r})}}delete(e){this.cookies.delete(e)}toSetCookieHeaders(){return Array.from(this.cookies.values(),e=>{let t=`${e.name}=${e.value}`;return e.options&&(e.options.path&&(t+=`; Path=${e.options.path}`),e.options.domain&&(t+=`; Domain=${e.options.domain}`),e.options.maxAge&&(t+=`; Max-Age=${e.options.maxAge}`),e.options.expires&&(t+=`; Expires=${e.options.expires.toUTCString()}`),e.options.httpOnly&&(t+=`; HttpOnly`),e.options.secure&&(t+=`; Secure`),e.options.sameSite&&(t+=`; SameSite=${e.options.sameSite}`)),t})}},_=class e extends Response{cookies;constructor(e,t){super(e,t),this.cookies=new g}static next(t){let n=new e(null,{status:200,headers:{"x-rari-proxy-continue":`true`}});return t?.request?.headers&&(t.request.headers instanceof Headers?t.request.headers:new Headers(t.request.headers)).forEach((e,t)=>{n.headers.set(`x-rari-proxy-request-${t}`,e)}),n}static redirect(t,n){return new e(null,{status:n||307,headers:{Location:t.toString()}})}static rewrite(t){return new e(null,{status:200,headers:{"x-rari-proxy-rewrite":t.toString()}})}static json(t,n){return new e(JSON.stringify(t),{...n,headers:{"Content-Type":`application/json`,...n?.headers}})}};function v(e={}){let{root:t=u.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 d(){for(let e of i){let n=`${r}${e}`,i=l.join(t,n);try{return await c.access(i),s(`Found proxy file: ${n}`),{filePath:i,exists:!0,relativePath:n}}catch{}}let e=l.join(t,n);try{await c.access(e);for(let t of i){let i=`${r}${t}`,a=l.join(e,i);try{return await c.access(a),s(`Found proxy file: ${l.join(n,i)}`),{filePath:a,exists:!0,relativePath:l.join(n,i)}}catch{}}}catch{}return null}return{name:`rari:proxy`,async buildStart(){o=await d(),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 y={appDir:`src/app`,extensions:[`.tsx`,`.jsx`,`.ts`,`.js`],outDir:`dist`};function b(e){switch(l.basename(e).replace(/\.(tsx?|jsx?)$/,``)){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 x(e,t){let n=l.relative(t,l.dirname(e));return!n||n===`.`?`/`:`/${n.replace(/\\/g,`/`).split(`/`).filter(Boolean).join(`/`)}`}function S(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 C(e){try{let t=e.match(/export\s+const\s+metadata\s*(?::\s*\w+\s*)?=\s*(\{[\s\S]*?\n\})/);if(!t)return null;let n=t[1],r={},i=n.match(/title\s*:\s*['"]([^'"]+)['"]/);i&&(r.title=i[1]);let a=n.match(/description\s*:\s*['"]([^'"]+)['"]/);a&&(r.description=a[1]);let o=n.match(/keywords\s*:\s*\[([\s\S]*?)\]/);o&&(r.keywords=o[1].split(`,`).map(e=>e.trim().replace(/['"]/g,``)).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 w(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 T(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 E(e={}){let t={...y,...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 c.readdir(e,{withFileTypes:!0});for(let a of i){let i=l.join(e,a.name);a.isDirectory()?await r(i):a.isFile()&&t.extensions.some(e=>a.name.endsWith(e))&&b(i)&&n.add(i)}}catch{}};return await r(e),n},d=async(e,r=!1)=>{let u=l.resolve(e,t.appDir);try{await c.access(u)}catch{return null}try{let d=await s(u),f=o(d);if(!r&&i===f&&n)return n;let{generateAppRouteManifest:p}=await import(`./routes-DbsqVAaM.mjs`).then(e=>e.n),m=await p(u,{extensions:t.extensions}),h=JSON.stringify(m,null,2),g=l.resolve(e,t.outDir);await c.mkdir(g,{recursive:!0});let _=l.join(g,`server`);return await c.mkdir(_,{recursive:!0}),await c.writeFile(l.join(_,`routes.json`),h,`utf-8`),i=f,a.clear(),d.forEach(e=>a.add(e)),h}catch(e){return console.error(`[rari] Router: Failed to generate app routes:`,e),null}},f=e=>{let n=l.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=b(i)!==null,o=r===`add`||r===`unlink`,s=n&&!a.has(i);(o||s)&&(await d(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)}})},p;return{name:`rari-router`,configResolved(e){p=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 d(p||u.cwd(),!0)},configureServer(e){f(e)},async handleHotUpdate(e){let{file:i,server:o}=e,s=l.resolve(o.config.root,t.appDir);if(i.startsWith(s)&&t.extensions.some(e=>i.endsWith(e))){let e=b(i);if(e){let t=r.get(i);t&&clearTimeout(t);let u=setTimeout(async()=>{r.delete(i);let t=!a.has(i),u=n;n=await d(o.config.root,t);let f=u!==n,p=x(i,s),m=[p];if(n)try{m=JSON.parse(n).routes.map(e=>e.path)}catch(e){console.error(`[rari] Router: Failed to parse manifest for affected routes:`,e)}let h=S(p,e,m),g,_=!1,v;if(e===`page`||e===`layout`)try{let e=C(await c.readFile(i,`utf-8`));e&&(g=e,_=!0)}catch(e){console.error(`[rari] Router: Failed to extract metadata:`,e)}if(e===`route`)try{v=w(await c.readFile(i,`utf-8`)),await T(l.relative(s,i))}catch(e){console.error(`[rari] Router: Failed to detect HTTP methods:`,e)}let y={fileType:e,filePath:l.relative(o.config.root,i),routePath:p,affectedRoutes:h,manifestUpdated:f,timestamp:Date.now(),metadata:g,metadataChanged:_,methods:v};o.ws.send({type:`custom`,event:`rari:app-router-updated`,data:y})},200);return r.set(i,u),[]}return n=await d(o.config.root),[]}},async closeBundle(){for(let e of r.values())clearTimeout(e);r.clear()}}}var D=class{errorCount=0;maxErrors;resetTimeout;resetTimer=null;lastError=null;constructor(e={}){this.maxErrors=e.maxErrors??5,this.resetTimeout=e.resetTimeout??3e4}recordError(e){this.errorCount++,this.lastError=e,this.resetTimer&&clearTimeout(this.resetTimer),this.resetTimer=setTimeout(()=>{this.reset()},this.resetTimeout),this.errorCount>=this.maxErrors&&this.handleMaxErrorsReached()}reset(){this.errorCount=0,this.lastError=null,this.resetTimer&&=(clearTimeout(this.resetTimer),null)}getErrorCount(){return this.errorCount}getLastError(){return this.lastError}hasReachedMaxErrors(){return this.errorCount>=this.maxErrors}handleMaxErrorsReached(){console.error(`[rari] HMR: Maximum error count (${this.maxErrors}) reached. Consider restarting the dev server if issues persist.`)}dispose(){this.resetTimer&&=(clearTimeout(this.resetTimer),null),this.reset()}},O=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 D({maxErrors:5,resetTimeout:3e4})}async handleClientComponentUpdate(e,t){let n=l.relative(u.cwd(),e),r=Date.now();this.queueLog(`info`,`Client component changed: ${n}`);try{let i=t.moduleGraph.getModuleById(e);if(i){t.moduleGraph.invalidateModule(i);let e=Date.now()-r;this.queueLog(`success`,`Client component updated: ${n} (${e}ms)`),this.errorHandler.reset()}else 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=Date.now();if(e.length===1){let t=l.relative(u.cwd(),e[0]);this.queueLog(`info`,`Rebuilding server component: ${t}`)}else this.queueLog(`info`,`Rebuilding ${e.length} server components in batch`);let r=await Promise.allSettled(e.map(async e=>{let t=l.relative(u.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))}}})),i=[],a=[];r.forEach(e=>{e.status===`fulfilled`&&e.value.success?i.push(e.value):e.status===`fulfilled`&&!e.value.success?a.push(e.value):e.status===`rejected`&&a.push({filePath:``,relativePath:`unknown`,error:Error(String(e.reason))})});let o=Date.now()-n;if(i.length>0){let e=Date.now();i.forEach(({componentId:n})=>{t.hot.send(`rari:server-component-updated`,{id:n,t:e})}),i.length===1?this.queueLog(`success`,`Server component updated: ${i[0].relativePath} (${o}ms)`):this.queueLog(`success`,`${i.length} server components updated (${o}ms)`),this.errorHandler.reset(),t.ws.send({type:`custom`,event:`rari:hmr-error-cleared`,data:{t:e}})}if(a.length>0){let e=Date.now();a.forEach(({relativePath:n,error:r})=>{let i=r.message,a=(r.stack||``).substring(0,500);this.queueLog(`error`,`Failed to rebuild: ${n} - ${i}`),this.errorHandler.recordError(r),t.ws.send({type:`custom`,event:`rari:hmr-error`,data:{msg:i,stack:a,file:n,t:e,count:this.errorHandler.getErrorCount(),max:5}})}),this.errorHandler.hasReachedMaxErrors()&&this.queueLog(`error`,`Maximum error count reached (${this.errorHandler.getErrorCount()}). Consider restarting the dev server if issues persist.`)}},this.DEBOUNCE_DELAY)}async notifyRustServer(e,t){try{let n=await fetch(`${this.rustServerUrl}/_rari/hmr`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`reload-component`,component_id:e,bundle_path:t})});if(!n.ok){let e=await n.text();throw Error(`HTTP ${n.status}: ${e}`)}}catch(e){throw console.error(`[rari] HMR: Failed to notify Rust server:`,e),e}}detectComponentType(e){try{let t=s.readFileSync(e,`utf-8`).split(`
|
|
2
|
-
`);for(let e of t){let t=e.trim();if(!(!t||t.startsWith(`//`)||t.startsWith(`/*`))){if(t===`'use client'`||t===`"use client"`)return`client`;break}}return`server`}catch{return`unknown`}}queueLog(e,t){this.logBatch.push({type:e,message:t,timestamp:Date.now()}),this.logBatchTimer&&clearTimeout(this.logBatchTimer),this.logBatchTimer=setTimeout(()=>{this.flushLogs()},this.LOG_BATCH_DELAY)}flushLogs(){if(this.logBatch.length===0)return;let e=this.logBatch.reduce((e,t)=>(e[t.type]||(e[t.type]=[]),e[t.type].push(t),e),{});for(let[t,n]of Object.entries(e))if(n.length===1){let e=n[0];this.outputLog(t,e.message)}else{let e=n.map(e=>e.message).join(`
|
|
3
|
-
• `);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()}};async function k(e,t=[]){let n=new Map;async function r(e){if(!s.existsSync(e))return;let t=s.readdirSync(e,{withFileTypes:!0});for(let i of t){let t=l.join(e,i.name);if(i.isDirectory()){if(i.name===`node_modules`||i.name===`dist`)continue;await r(t)}else if(i.isFile()&&/\.(?:tsx?|jsx?)$/.test(i.name))try{let e=s.readFileSync(t,`utf8`);if(!e.includes(`from 'rari/image'`)&&!e.includes(`from "rari/image"`))continue;await A(e,t,n)}catch(e){console.warn(`Failed to read or process file ${t}:`,e)}}}await r(e);for(let e of t)s.existsSync(e)&&await r(e);return{images:[...n.values()]}}async function A(e,t,n){try{let r;r=t.endsWith(`.tsx`)?`tsx`:t.endsWith(`.jsx`)?`jsx`:t.endsWith(`.ts`)?`ts`:`js`;let i=`\0virtual:${t}`,a=await m({input:i,platform:`browser`,write:!1,output:{format:`esm`},moduleTypes:{[`.${r}`]:r},transform:{jsx:`react`},plugins:[{name:`virtual-module`,resolveId(e){return e===i?e:null},load(t){return t===i?{code:e,moduleType:r}:null}}]});if(!a.output||a.output.length===0)throw Error(`Transform produced no output`);let o=a.output[0].code,s=new Set;for(let e of o.matchAll(/import\s+(\w+)\s+from\s+['"]rari\/image['"]/g))s.add(e[1]);for(let e of o.matchAll(/import\s+\{[^}]*\b(?:Image\s+as\s+(\w+)|Image)\b[^}]*\}\s+from\s+['"]rari\/image['"]/g))e[1]?s.add(e[1]):s.add(`Image`);if(s.size===0)return;for(let e of s){let t=e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),r=RegExp(`React\\.createElement\\(\\s*${t}\\s*,\\s*\\{([^}]+)\\}`,`g`);for(let e of o.matchAll(r)){let t=e[1],r=t.match(/src:\s*["']([^"']+)["']/);if(!r)continue;let i=r[1];if(!i.startsWith(`/`)&&!i.startsWith(`http`))continue;let a=t.match(/width:\s*(\d+)/),o=a?Number.parseInt(a[1],10):void 0,s=t.match(/quality:\s*(\d+)/),c=s?Number.parseInt(s[1],10):void 0,l=t.match(/preload:\s*(true|!0)/),u=t.match(/preload:\s*(false|!1)/),d=!!l&&!u,f=`${i}:${o||`auto`}:${c||75}`;(!n.has(f)||d)&&n.set(f,{src:i,width:o,quality:c,preload:d})}}}catch{j(e,n)}}function j(e,t){let n=/<Image\s([^/>]+)\/>/g,r=/<Image\s([^>]+)>/g;for(let r of e.matchAll(n))M(r[1],t);for(let n of e.matchAll(r))M(n[1],t)}function M(e,t){let n=e.match(/src=\{?["']([^"']+)["']\}?|src=\{([^}]+)\}/);if(!n)return;let r=n[1]||n[2];if(!r||r.includes(`{`)||!r.startsWith(`/`)&&!r.startsWith(`http`))return;let i=e.match(/width=\{?(\d+)\}?/),a=i?Number.parseInt(i[1],10):void 0,o=e.match(/quality=\{?(\d+)\}?/),s=o?Number.parseInt(o[1],10):void 0,c=/preload(?:=\{?true\}?)?/.test(e)&&!/preload=\{?false\}?/.test(e),l=`${r}:${a||`auto`}:${s||75}`;(!t.has(l)||c)&&t.set(l,{src:r,width:a,quality:s,preload:c})}const N={remotePatterns:[],localPatterns:[],deviceSizes:a,imageSizes:i,formats:n,qualityAllowlist:r,minimumCacheTTL:e,maxCacheSize:t};async function P(e){let t=import.meta.url,n=p(t),r=l.dirname(n),i=[l.join(r,`runtime`,e),l.join(r,`../runtime`,e)];for(let e of i)try{let t=await s.promises.readFile(e,`utf-8`);return e.endsWith(`.ts`)&&(t=t.replace(/import\s+type\s+(\{[^}]+\})\s+from\s+["']\.\.?\/([^"']+)["'];?/g,(e,t,n)=>`import type ${t} from "rari/${n}";`),t=t.replace(/import\s+type\s+(\*\s+as\s+\w+)\s+from\s+["']\.\.?\/([^"']+)["'];?/g,(e,t,n)=>`import type ${t} from "rari/${n}";`),t=t.replace(/import\s+type\s+(\w+)\s+from\s+["']\.\.?\/([^"']+)["'];?/g,(e,t,n)=>`import type ${t} from "rari/${n}";`),t=t.replace(/import\s+(\{[^}]+\})\s+from\s+["']\.\.?\/([^"']+)["'];?/g,(e,t,n)=>`import ${t} from "rari/${n}";`),t=t.replace(/import\s+(\*\s+as\s+\w+)\s+from\s+["']\.\.?\/([^"']+)["'];?/g,(e,t,n)=>`import ${t} from "rari/${n}";`),t=t.replace(/import\s+(\w+)\s+from\s+["']\.\.?\/([^"']+)["'];?/g,(e,t,n)=>`import ${t} from "rari/${n}";`),t=t.replace(/import\s+["']\.\.?\/([^"']+)["'];?/g,(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 F(){return P(`rsc-client-runtime.mjs`)}async function I(e,t){return(await P(`entry-client.mjs`)).replace(`/*! @preserve CLIENT_COMPONENT_IMPORTS_PLACEHOLDER */`,e).replace(`/*! @preserve CLIENT_COMPONENT_REGISTRATIONS_PLACEHOLDER */`,t)}async function L(){return P(`react-server-dom-shim.mjs`)}async function R(e,t){let n=await k(l.join(e,`src`)),r={...N,...t.images,preoptimizeManifest:n.images},i=l.join(e,`dist`),a=l.join(i,`server`);s.existsSync(a)||s.mkdirSync(a,{recursive:!0});let o=l.join(a,`image.json`);s.writeFileSync(o,JSON.stringify(r,null,2))}function z(e,t=[]){let n=new Set;function r(e){if(!s.existsSync(e))return;let t=s.readdirSync(e,{withFileTypes:!0});for(let i of t){let t=l.join(e,i.name);if(i.isDirectory()){if(i.name===`node_modules`)continue;r(t)}else if(i.isFile()&&/\.(?:tsx?|jsx?)$/.test(i.name))try{let e=s.readFileSync(t,`utf8`);(e.includes(`'use client'`)||e.includes(`"use client"`))&&n.add(t)}catch{}}}r(e);for(let e of t)s.existsSync(e)&&r(e);return n}function B(e){return e}function V(e={}){let t=new Map,n=new Set,r=null,i=null,a={};function c(t){if(t.includes(`node_modules`)||t.includes(`/rari/dist/`)||t.includes(`\\rari\\dist\\`))return!1;let n=e.projectRoot||u.cwd(),r=l.join(n,`index.html`);if(s.existsSync(r))try{let e=s.readFileSync(r,`utf-8`);for(let r of e.matchAll(/import\s*(?:\(\s*)?["']([^"']+)["']\)?/g)){let e=r[1];if(e.startsWith(`/src/`)&&l.join(n,e.slice(1))===t)return!1}}catch{}let i;try{i=s.realpathSync(t)}catch{return!1}try{if(!s.existsSync(i))return!1;let e=s.readFileSync(i,`utf-8`),t=h(e,`use client`);return h(e,`use server`)?!1:!t}catch{return!1}}function m(e){try{let t=[],n=e.matchAll(/export\s*\{([^}]+)\}/g);for(let e of n){let n=e[1].split(`,`);for(let e of n){let n=e.trim().split(/\s+as\s+/).at(-1)?.trim();n&&t.push(n)}}(/export\s+default\s+(?:function|class)\s+\w+/.test(e)||/export\s+default\s+/.test(e))&&t.push(`default`);let r=e.matchAll(/export\s+(?:const|let|var|function|class)\s+(\w+)/g);for(let e of r)e[1]&&t.push(e[1]);return[...new Set(t)]}catch{return[]}}function h(e,t){try{let n=e.split(`
|
|
4
|
-
`);for(let e of n){let n=e.trim();if(!(!n||n.startsWith(`//`)||n.startsWith(`/*`))){if(n===`'${t}'`||n===`"${t}"`||n===`'${t}';`||n===`"${t}";`)return!0;break}}return!1}catch{return!1}}function g(e,t){if(!h(e,`use server`))return e;let n=m(e);if(n.length===0)return e;let r=e;r+=`
|
|
5
|
-
|
|
6
|
-
import {registerServerReference} from "react-server-dom-rari/server";
|
|
7
|
-
`;for(let i of n)if(i===`default`){let n=e.match(/export\s+default\s+(?:async\s+)?function\s+(\w+)/);if(n){let e=n[1];r+=`
|
|
8
|
-
// Register server reference for default export
|
|
9
|
-
`,r+=`registerServerReference(${e}, ${JSON.stringify(t)}, ${JSON.stringify(i)});\n`}else{let n=/export\s+default\s+([^;]+)/,a=e.match(n);if(a){let e=a[1].trim(),o=`__default_export__`;r=r.replace(n,`const ${o} = ${e};\nexport default ${o}`),r+=`
|
|
10
|
-
// Register server reference for default export
|
|
11
|
-
`,r+=`if (typeof ${o} === "function") {\n`,r+=` registerServerReference(${o}, ${JSON.stringify(t)}, ${JSON.stringify(i)});\n`,r+=`}
|
|
12
|
-
`}}}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+=`}
|
|
13
|
-
`;return r+=`
|
|
14
|
-
|
|
15
|
-
if (import.meta.hot) {
|
|
16
|
-
import.meta.hot.accept(() => {
|
|
17
|
-
});
|
|
18
|
-
}`,r}function _(e,t){let n=h(e,`use server`),r=c(t);if(n){let n=m(e);if(n.length===0)return``;let r=l.relative(u.cwd(),t).replace(/\\/g,`/`).replace(/\.(tsx?|jsx?)$/,``).replace(/[^\w/-]/g,`_`).replace(/^src\//,``),i=`import { createServerReference } from "rari/runtime/actions";
|
|
19
|
-
`;for(let e of n)e===`default`?i+=`export default createServerReference("default", ${JSON.stringify(r)}, "default");\n`:i+=`export const ${e} = createServerReference("${e}", ${JSON.stringify(r)}, "${e}");\n`;return i}if(r){let n=m(e);if(n.length===0)return``;let r=l.relative(u.cwd(),t).replace(/\\/g,`/`).replace(/\.(tsx?|jsx?)$/,``).replace(/[^\w/-]/g,`_`).replace(/^src\//,``).replace(/^components\//,``),i=`import { createServerComponentWrapper } from "virtual:rsc-integration.ts";
|
|
20
|
-
`;for(let e of n)e===`default`?i+=`export default createServerComponentWrapper("${r}", ${JSON.stringify(t)});\n`:i+=`export const ${e} = createServerComponentWrapper("${r}_${e}", ${JSON.stringify(t)});\n`;return i}if(!h(e,`use client`))return e;let i=m(e);if(i.length===0)return``;let a=`import {registerClientReference} from "react-server-dom-rari/server";
|
|
21
|
-
`;for(let e of i){if(e===`default`){let e=`Attempted to call the default export of ${t} 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.`;a+=`export default `,a+=`registerClientReference(function() {`,a+=`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.`;a+=`export const ${e} = `,a+=`registerClientReference(function() {`,a+=`throw new Error(${JSON.stringify(t)});`}a+=`},`,a+=`${JSON.stringify(t)},`,a+=`${JSON.stringify(e)});\n`}return a}function y(e,t){return!h(e,`use client`)||m(e).length===0?e:e.replace(/^['"]use client['"];?\s*$/gm,``)}function b(e,t){let n=e;for(let[t,r]of Object.entries(a))if(e.startsWith(`${t}/`)){n=e.replace(t,r);break}else if(e===t){n=r;break}let r=l.resolve(l.dirname(t),n),i=[`.tsx`,`.jsx`,`.ts`,`.js`];for(let e of i){let t=`${r}${e}`;if(s.existsSync(t))return t}if(s.existsSync(r))for(let e of i){let t=l.join(r,`index${e}`);if(s.existsSync(t))return t}return`${r}.tsx`}function x(e){return(e.split(`/`).pop()||e).replace(/\.[^.]*$/,``)}let S=!1;async function C(){let e=`http://localhost:${u.env.SERVER_PORT?Number(u.env.SERVER_PORT):Number(u.env.PORT||u.env.RSC_PORT||3e3)}`;try{let t=(await fetch(`${e}/_rari/health`,{signal:AbortSignal.timeout(1e3)})).ok;return S=t,t}catch{return S=!1,!1}}let w=[{name:`rari`,config(t,{command:n}){if(n===`build`){let n=e.projectRoot||u.cwd(),r=l.join(n,`index.html`);if(s.existsSync(r))try{let e=s.readFileSync(r,`utf-8`),n=/import\s+["']([^"']+)["']/g,i=[];for(let t of e.matchAll(n)){let e=t[1];if(e.startsWith(`/src/`)&&/\.(?:tsx?|jsx?)$/.test(e)){let t=e.slice(1),n=l.basename(t,l.extname(t));i.push({path:t,name:n})}}if(i.length>0){t.build=t.build||{},t.build.rolldownOptions=t.build.rolldownOptions||{};let e=t.build.rolldownOptions.input||{main:`./index.html`},n;n=typeof e==`string`?{main:e}:Array.isArray(e)?{main:e[0]||`./index.html`}:{...e},i.forEach(({path:e,name:t})=>{n[t]=`./${e}`}),t.build.rolldownOptions.input=n}}catch(e){console.warn(`[rari] Error parsing index.html for build inputs:`,e)}}t.resolve=t.resolve||{};let r=Array.isArray(t.resolve.dedupe)?t.resolve.dedupe:[],i=[`react`,`react-dom`];t.resolve.dedupe=[...new Set([...r||[],...i])];let a=[];Array.isArray(t.resolve.alias)?a=t.resolve.alias:t.resolve.alias&&typeof t.resolve.alias==`object`&&(a=Object.entries(t.resolve.alias).map(([e,t])=>({find:e,replacement:t})));let o=new Set(a.map(e=>String(e.find)));try{let e=p(import.meta.resolve(`react`)),n=p(import.meta.resolve(`react-dom/client`)),r=p(import.meta.resolve(`react/jsx-runtime`)),i=[];o.has(`react/jsx-runtime`)||i.push({find:`react/jsx-runtime`,replacement:r});try{let e=p(import.meta.resolve(`react/jsx-dev-runtime`));o.has(`react/jsx-dev-runtime`)||i.push({find:`react/jsx-dev-runtime`,replacement:e})}catch{}o.has(`react`)||i.push({find:`react`,replacement:e}),o.has(`react-dom/client`)||i.push({find:`react-dom/client`,replacement:n}),i.length>0&&(t.resolve.alias=[...a,...i])}catch{}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 c=u.env.SERVER_PORT?Number(u.env.SERVER_PORT):Number(u.env.PORT||u.env.RSC_PORT||3e3);return t.server.proxy[`/api`]={target:`http://localhost:${c}`,changeOrigin:!0,secure:!1,ws:!0},t.server.proxy[`/_rari`]={target:`http://localhost:${c}`,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.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)&&(a[e.find]=e.replacement)}):typeof n==`object`&&Object.entries(n).forEach(([e,n])=>{typeof n==`string`&&!t.has(e)&&(a[e]=n)})}},transform(e,r){if(!/\.(?:tsx?|jsx?)$/.test(r))return null;let i=this.environment;if(h(e,`use client`)){t.set(r,`client`),n.add(r);let i=/^\s*import\s+(?:(\w+)(?:\s*,\s*\{\s*(?:(\w+(?:\s*,\s*\w+)*)\s*)?\})?|\{\s*(\w+(?:\s*,\s*\w+)*)\s*\})\s+from\s+['"]([./@][^'"]+)['"].*$/,a=e.split(`
|
|
22
|
-
`);for(let e of a){let a=e.match(i);if(!a)continue;let o=a[4];if(!o)continue;let c=b(o,r);s.existsSync(c)&&(t.set(c,`client`),n.add(c))}return y(e,r)}if(t.get(r)===`client`||n.has(r))return y(e,r);if(c(r)){if(t.set(r,`server`),i&&(i.name===`rsc`||i.name===`ssr`))return g(e,r);{let t=_(e,r);return t=`// HMR acceptance for server component
|
|
23
|
-
if (import.meta.hot) {
|
|
24
|
-
import.meta.hot.accept();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (typeof globalThis !== 'undefined') {
|
|
28
|
-
if (!globalThis['~rari']) globalThis['~rari'] = {};
|
|
29
|
-
globalThis['~rari'].serverComponents = globalThis['~rari'].serverComponents || new Set();
|
|
30
|
-
globalThis['~rari'].serverComponents.add(${JSON.stringify(r)});
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
${t}`,t}}if(h(e,`use server`))return t.set(r,`server`),i&&(i.name===`rsc`||i.name===`ssr`)?g(e,r):_(e,r);let a=t.get(r);if(a===`server`)return g(e,r);if(a===`client`)return y(e,r);t.set(r,`unknown`);let o=e.split(`
|
|
34
|
-
`),l=e,d=!1,f=!1,p=!1,m=[],v=/^\s*import\s+(\w+)(?:\s*,\s*\{\s*(?:(\w+(?:\s*,\s*\w+)*)\s*)?\})?\s+from\s+['"]([./@][^'"]+)['"].*$/;for(let a of o){let o=a.match(v);if(!o)continue;let u=o[1],g=o[3],_=x(g),y=b(g,r),S=h(e,`use client`)||t.get(r)===`client`||r.includes(`entry-client`),C=t.get(y)===`client`||s.existsSync(y)&&s.readFileSync(y,`utf-8`).includes(`'use client'`);if(C&&(t.set(y,`client`),n.add(y)),C&&i&&(i.name===`rsc`||i.name===`ssr`)){if(!S){let e=a,t=u||`default`,n=`
|
|
35
|
-
import { registerClientReference } from "react-server-dom-rari/server";
|
|
36
|
-
const ${t} = registerClientReference(
|
|
37
|
-
function() {
|
|
38
|
-
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.");
|
|
39
|
-
},
|
|
40
|
-
${JSON.stringify(y)},
|
|
41
|
-
${JSON.stringify(u||`default`)}
|
|
42
|
-
);`;l=l.replace(e,n),d=!0,f=!0}}else if(!S&&c(y)){d=!0,f=!0,p=!0;let e=a;u&&u!==`_`&&m.push(`const ${u} = createServerComponentWrapper('${_}', '${g}');`),l=l.replace(e,``)}}if(d){let e=l.includes(`import React`)||l.match(/import\s+\{[^}]*\}\s+from\s+['"]react['"]/)||l.match(/import\s+[^,\s]+\s*,\s*\{[^}]*\}\s+from\s+['"]react['"]/),n=l.includes(`createServerComponentWrapper`),i=``;if(f&&!e&&(i+=`import React from 'react';
|
|
43
|
-
`),p&&!n&&(i+=`import { createServerComponentWrapper } from 'virtual:rsc-integration.ts';
|
|
44
|
-
`),m.length>0&&(i+=`${m.join(`
|
|
45
|
-
`)}\n`),i&&(l=i+l),!l.includes(`Suspense`)){let e=l.match(/import React(,\s*\{([^}]*)\})?\s+from\s+['"]react['"];?/);e&&(e[1]&&!e[2].includes(`Suspense`)?l=l.replace(e[0],e[0].replace(/\{([^}]*)\}/,`{ Suspense, $1 }`)):e[1]||(l=l.replace(e[0],`import React, { Suspense } from 'react';`)))}let a=u.env.NODE_ENV!==`production`,o=l.includes(`</`)||l.includes(`/>`)||/\bJSX\b/.test(l);return!l.includes(`'use client'`)&&!l.includes(`"use client"`)&&o&&a&&(l=`'use client';\n\n${l}`,t.set(r,`client`)),l}return null},async configureServer(n){let o=e.projectRoot||u.cwd(),p=l.join(o,`src`);await R(o,e);let m=null,h=async()=>{try{let{ServerComponentBuilder:t,scanDirectory:r}=await import(`./server-build-C64b2Z-d.mjs`).then(e=>e.n),d=new t(o,{outDir:`dist`,rscDir:`server`,manifestPath:`server/manifest.json`,serverConfigPath:`server/config.json`,alias:a,csp:e.csp,rateLimit:e.rateLimit,spamBlocker:e.spamBlocker});if(m=d,!i&&m){let e=u.env.SERVER_PORT?Number(u.env.SERVER_PORT):Number(u.env.PORT||u.env.RSC_PORT||3e3);i=new O(m,e)}let f=l.join(o,`src`),p=[];if(s.existsSync(f)){let e=t=>{let n=s.readdirSync(t,{withFileTypes:!0});for(let r of n){let n=l.join(t,r.name);if(r.isDirectory())e(n);else if(r.isFile()&&/\.(?:tsx?|jsx?)$/.test(r.name))try{c(n)&&p.push(n)}catch(e){console.error(`[rari] Error checking ${n}:`,e)}}};e(f),r(f,d)}p.length>0&&n.ws.send({type:`custom`,event:`rari:server-components-registry`,data:{serverComponents:p}});let h=await d.getTransformedComponentsForDevelopment(),g=`http://localhost:${u.env.SERVER_PORT?Number(u.env.SERVER_PORT):Number(u.env.PORT||u.env.RSC_PORT||3e3)}`;for(let e of h)try{if(e.id.startsWith(`app/`)||e.code.includes(`"use server"`)||e.code.includes(`'use server'`))continue;let t=await fetch(`${g}/_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))}},g=async()=>{try{let e=`http://localhost:${u.env.SERVER_PORT?Number(u.env.SERVER_PORT):Number(u.env.PORT||u.env.RSC_PORT||3e3)}`,t=z(p,Object.values(a));for(let n of t){let t=l.relative(u.cwd(),n),r=l.basename(n).replace(/\.[^.]+$/,``);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)}},_=async()=>{if(r)return;let{getBinaryPath:e,getInstallationInstructions:t}=await import(`./platform.mjs`),i;try{i=e()}catch(e){console.error(`rari binary not found`),console.error(` ${e.message}`),console.error(t());return}let a=u.env.SERVER_PORT?Number(u.env.SERVER_PORT):Number(u.env.PORT||u.env.RSC_PORT||3e3),o=u.env.NODE_ENV===`production`?`production`:`development`,s=n.config.server.port||5173,c=[`--mode`,o,`--port`,a.toString(),`--host`,`127.0.0.1`];r=f(i,c,{stdio:[`ignore`,`pipe`,`pipe`],cwd:u.cwd(),env:{...u.env,RUST_LOG:u.env.RUST_LOG||`error`,RARI_VITE_PORT:s.toString()}}),r.stdout?.on(`data`,e=>{let t=e.toString().trim();t&&console.error(`${t}`)}),r.stderr?.on(`data`,e=>{let t=e.toString().trim();t&&!t.includes(`warning`)&&console.error(`${t}`)}),r.on(`error`,e=>{S=!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.`)}),r.on(`exit`,(e,t)=>{r=null,S=!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 C(),!l);e++)await new Promise(e=>setTimeout(e,500));l?(await g(),await h()):console.error(`Server failed to become ready for component registration`)},v=async t=>{try{if(!c(t))return;let{ServerComponentBuilder:n}=await import(`./server-build-C64b2Z-d.mjs`).then(e=>e.n),r=new n(o,{outDir:`dist`,rscDir:`server`,manifestPath:`server/manifest.json`,serverConfigPath:`server/config.json`,alias:a,csp:e.csp,rateLimit:e.rateLimit,spamBlocker:e.spamBlocker});r.addServerComponent(t);let i=await r.getTransformedComponentsForDevelopment();if(i.length===0)return;let s=`http://localhost:${u.env.SERVER_PORT?Number(u.env.SERVER_PORT):Number(u.env.PORT||u.env.RSC_PORT||3e3)}`;for(let e of i)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(h,1e3)}};_().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(!S&&!await C()){let e=Date.now();for(;Date.now()-e<1e4&&!await C();)await new Promise(e=>setTimeout(e,100));if(!S){console.error(`[rari] Rust server not ready, cannot proxy RSC request`),t.headersSent||(t.statusCode=503,t.end(`Server not ready`));return}}let n=u.env.SERVER_PORT?Number(u.env.SERVER_PORT):Number(u.env.PORT||u.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(d.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=>{/\.(?:tsx?|jsx?)$/.test(e)&&t.delete(e),/\.(?:tsx?|jsx?)$/.test(e)&&e.includes(p)&&(c(e)?(n.ws.send({type:`custom`,event:`rari:register-server-component`,data:{filePath:e}}),await v(e)):setTimeout(h,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 v(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`,()=>{i&&=(i.dispose(),null),r&&=(r.kill(`SIGTERM`),null),S=!1})},resolveId(e,t){if(e===`virtual:rsc-integration`||e===`virtual:rsc-integration.ts`)return`virtual:rsc-integration.ts`;if(e===`virtual:rari-entry-client`||e===`virtual:rari-entry-client.ts`)return`virtual:rari-entry-client.ts`;if(e===`virtual:react-server-dom-rari-client`||e===`virtual:react-server-dom-rari-client.ts`)return`virtual:react-server-dom-rari-client.ts`;if(e===`virtual:app-router-provider`||e===`virtual:app-router-provider.tsx`)return`virtual:app-router-provider.tsx`;if(e===`./DefaultLoadingIndicator`||e===`./DefaultLoadingIndicator.tsx`)return`virtual:default-loading-indicator.tsx`;if(e===`./LoadingErrorBoundary`||e===`./LoadingErrorBoundary.tsx`)return`virtual:loading-error-boundary.tsx`;if(e===`react-server-dom-rari/server`)return e;if(t&&t.startsWith(`virtual:`)&&e.startsWith(`../`)){let n=import.meta.url,r=p(n),i=l.dirname(r),a=null,o=[l.join(i,`runtime`),l.join(i,`../runtime`)];for(let e of o)if(s.existsSync(e)){a=e;break}if(a){let t=l.join(a,e);if(s.existsSync(t))return t;let n=l.join(a,`../dist`,l.basename(e));if(s.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 c=l.join(i,e);if(s.existsSync(c))return c;let u=l.join(i,`../dist`,l.basename(e));if(s.existsSync(u))return u}if(u.env.NODE_ENV===`production`)try{let t=l.resolve(e);if(s.existsSync(t)&&c(t))return{id:e,external:!0}}catch{}return null},async load(t){if(t===`virtual:rari-entry-client.ts`){let e=z(l.join(u.cwd(),`src`),Object.values(a)),t=new Set([...n,...e]),r=[{path:`rari/image`,exports:[`Image`]}],i=[...t].filter(e=>{try{return h(s.readFileSync(e,`utf-8`),`use client`)}catch{return!1}}),o=i.map((e,t)=>{let n=l.relative(u.cwd(),e).replace(/\\/g,`/`),r=`ClientComponent${t}`;try{let t=s.readFileSync(e,`utf-8`),i=/export\s+default\s+/.test(t),a=t.match(/export\s+(?:function|const|class)\s+(\w+)/);if(!i&&a)return`import { ${a[1]} as ${r} } from '/${n}';`}catch{}return`import ${r} from '/${n}';`}).join(`
|
|
46
|
-
`),c=i.map((e,t)=>{let n=l.relative(u.cwd(),e).replace(/\\/g,`/`),r=l.basename(e,l.extname(e)),i=n.startsWith(`..`)?e.replace(/\\/g,`/`):n;return`
|
|
47
|
-
globalThis['~clientComponents']["${i}"] = {
|
|
48
|
-
id: "${r}",
|
|
49
|
-
path: "${i}",
|
|
50
|
-
type: "client",
|
|
51
|
-
component: ${`ClientComponent${t}`},
|
|
52
|
-
registered: true
|
|
53
|
-
};
|
|
54
|
-
globalThis['~clientComponents']["${r}"] = globalThis['~clientComponents']["${i}"];
|
|
55
|
-
globalThis['~clientComponentPaths']["${i}"] = "${r}";`}).join(`
|
|
56
|
-
`),d=r.map((e,t)=>`import { ${e.exports.map(e=>`${e} as External${t}_${e}`).join(`, `)} } from '${e.path}';`).join(`
|
|
57
|
-
`),f=r.flatMap((e,t)=>e.exports.map(n=>{let r=`External${t}_${n}`;return`
|
|
58
|
-
globalThis['~clientComponents'] = globalThis['~clientComponents'] || {};
|
|
59
|
-
globalThis['~clientComponents']["${`${e.path}#${n}`}"] = {
|
|
60
|
-
id: "${n}",
|
|
61
|
-
path: "${e.path}",
|
|
62
|
-
type: "client",
|
|
63
|
-
component: ${r},
|
|
64
|
-
registered: true
|
|
65
|
-
};
|
|
66
|
-
globalThis['~clientComponents']["${e.path}"] = globalThis['~clientComponents']["${e.path}"] || {};
|
|
67
|
-
globalThis['~clientComponents']["${e.path}"].component = ${r};
|
|
68
|
-
globalThis['~clientComponentPaths'] = globalThis['~clientComponentPaths'] || {};
|
|
69
|
-
globalThis['~clientComponentPaths']["${e.path}"] = "${n}";`})).join(`
|
|
70
|
-
`);return await I([o,d].filter(Boolean).join(`
|
|
71
|
-
`),[c,f].filter(Boolean).join(`
|
|
72
|
-
`))}if(t===`react-server-dom-rari/server`)return await L();if(t===`virtual:app-router-provider.tsx`){let e=[l.join(u.cwd(),`packages/rari/dist/runtime/AppRouterProvider.mjs`),l.join(u.cwd(),`node_modules/rari/dist/runtime/AppRouterProvider.mjs`)];for(let t of e)if(s.existsSync(t))return s.readFileSync(t,`utf-8`);return`export function AppRouterProvider({ children }) { return children; }`}if(t===`virtual:default-loading-indicator.tsx`){let e=[l.join(u.cwd(),`packages/rari/dist/runtime/DefaultLoadingIndicator.mjs`),l.join(u.cwd(),`node_modules/rari/dist/runtime/DefaultLoadingIndicator.mjs`)];for(let t of e)if(s.existsSync(t))return s.readFileSync(t,`utf-8`);return`export function DefaultLoadingIndicator() { return null; }`}if(t===`virtual:loading-error-boundary.tsx`){let e=[l.join(u.cwd(),`packages/rari/dist/runtime/LoadingErrorBoundary.mjs`),l.join(u.cwd(),`node_modules/rari/dist/runtime/LoadingErrorBoundary.mjs`)];for(let t of e)if(s.existsSync(t))return s.readFileSync(t,`utf-8`);return`export class LoadingErrorBoundary extends React.Component { render() { return this.props.children; } }`}if(t===`virtual:rsc-integration.ts`)return(await F()).replace(/from(\s*)(['"])(?:\.\/|rari\/)react-server-dom-rari-client\.mjs\2/g,(e,t,n)=>`from${t}${n}virtual:react-server-dom-rari-client.ts${n}`);if(t===`virtual:react-server-dom-rari-client.ts`)return await P(`react-server-dom-rari-client.mjs`);if(t.endsWith(`.mjs`)&&s.existsSync(t))try{let n=e.projectRoot||u.cwd(),r=s.realpathSync(t),i=l.relative(n,r),a=!i.startsWith(`..`)&&!l.isAbsolute(i),o=r.includes(`${l.sep}node_modules${l.sep}`),c=r.includes(`${l.sep}packages${l.sep}rari${l.sep}`)||r.includes(`${l.sep}node_modules${l.sep}rari${l.sep}`);return a||o||c?s.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(!/\.(?:tsx?|jsx?)$/.test(e))return;if(e.includes(`/dist/`)||e.includes(`\\dist\\`))return[];let n=i?.detectComponentType(e)||`unknown`,r=e.includes(`/app/`)||e.includes(`\\app\\`),a=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&&(a||o||s||c||l)){let n=`page`;o?n=`layout`:s?n=`loading`:c?n=`error`:l&&(n=`not-found`),t.hot.send(`rari:app-router-updated`,{type:`rari-hmr`,filePath:e,fileType:n});return}if(n!==`client`&&n===`server`)return i&&await i.handleServerComponentUpdate(e,t),[]},transformIndexHtml:{order:`pre`,handler(e){let t=/import\s+["']([^"']+)["']/g,n=[];for(let r of e.matchAll(t)){let e=r[1];e.startsWith(`/src/`)&&n.push(e)}return n.length>0?{html:e,tags:n.map(e=>({tag:`script`,attrs:{type:`module`,src:e},injectTo:`head-prepend`}))}:e}},async writeBundle(){await R(e.projectRoot||u.cwd(),e)}},o({...e.serverBuild,csp:e.csp,rateLimit:e.rateLimit,spamBlocker:e.spamBlocker})];return e.proxy!==!1&&w.push(v(e.proxy||{})),e.router!==!1&&w.push(E(e.router||{})),w}function H(e){return{plugins:[V(),...e.plugins||[]],...e}}export{v as a,E as i,B as n,_ as o,V as r,h as s,H as t};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|