rari 0.8.6 → 0.8.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.d.mts +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/{server-build-DKiwRWzv.mjs → server-build-0OyoumT7.mjs} +3 -3
- package/dist/server-build-CyMkTI5L.mjs +1 -0
- package/dist/{server-config-5RHHggaf.d.mts → server-config-DPOhoy43.d.mts} +1 -1
- package/dist/{vite-CdA4k4ee.mjs → vite-CiAKzo4n.mjs} +2 -2
- package/dist/{vite-BLuZ5hUT.d.mts → vite-j_XfSMaD.d.mts} +1 -1
- package/dist/vite.d.mts +2 -2
- package/dist/vite.mjs +1 -1
- package/package.json +6 -6
- package/src/vite/server-build.ts +6 -3
- package/dist/server-build-CLlvgoDS.mjs +0 -1
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-DPOhoy43.mjs";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { Component, ErrorInfo, ReactNode } from "react";
|
|
4
4
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
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 { A as SitemapImage, C as ApiRouteHandlers, D as RobotsRule, E as Robots, O as Sitemap, S as ApiResponse, T as RouteHandler, _ as ProxyResult, a as rari, b as RequestCookies, c as ProxyPluginOptions, d as RariRequest, f as CookieOptions, g as ProxyModule, h as ProxyMatcher, i as defineRariOptions, j as SitemapVideo, k as SitemapEntry, l as rariProxy, m as ProxyFunction, n as Response, o as rariRouter, p as ProxyConfig, r as defineRariConfig, s as generateAppRouteManifest, t as Request, u as RariResponse, v as RariFetchEvent, w as RouteContext, x as ResponseCookies, y as RariURL } from "./vite-
|
|
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-DPOhoy43.mjs";
|
|
2
|
+
import { A as SitemapImage, C as ApiRouteHandlers, D as RobotsRule, E as Robots, O as Sitemap, S as ApiResponse, T as RouteHandler, _ as ProxyResult, a as rari, b as RequestCookies, c as ProxyPluginOptions, d as RariRequest, f as CookieOptions, g as ProxyModule, h as ProxyMatcher, i as defineRariOptions, j as SitemapVideo, k as SitemapEntry, l as rariProxy, m as ProxyFunction, n as Response, o as rariRouter, p as ProxyConfig, r as defineRariConfig, s as generateAppRouteManifest, t as Request, u as RariResponse, v as RariFetchEvent, w as RouteContext, x as ResponseCookies, y as RariURL } from "./vite-j_XfSMaD.mjs";
|
|
3
3
|
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,s as a,t as o}from"./vite-
|
|
1
|
+
import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"./vite-CiAKzo4n.mjs";import{t as s}from"./RariRequest-B7W8PASA.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-Jllyf7Ly.mjs";import{t as _}from"./routes-KDxjyeNA.mjs";import"./constants-DZAg-dr0.mjs";import"./server-build-0OyoumT7.mjs";export{a as ApiResponse,p as HttpRuntimeClient,s as RariRequest,r as RariResponse,g as clearPropsCache,l as clearPropsCacheForComponent,c as createHttpRuntimeClient,o 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};
|
|
@@ -38,8 +38,8 @@ const ${r} = (props) => {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
return Component(props);
|
|
41
|
-
}`;i.push({original:n,replacement:p})}}}let a=n;for(let{original:e,replacement:t}of i)a=a.replace(e,t);return a}isPageComponent(e){return e.includes(`/app/`)||e.includes(`\\app\\`)}createBuildPlugins(n,r,i,a,o=!1){let s=t.dirname(a),c=t.basename(a).match(/^proxy\.(?:tsx?|jsx?|mts|mjs)$/),l=this,u=new Map,d=new Map;return[{name:`virtual-module`,resolveId(r,i){if(r===n)return r;if(i===n&&(r.startsWith(`./`)||r.startsWith(`../`))){let n=t.resolve(s,r);for(let t of[`.ts`,`.tsx`,`.js`,`.jsx`,``]){let r=n+t;if(e.existsSync(r)&&e.statSync(r).isFile())return r}for(let r of[`.ts`,`.tsx`,`.js`,`.jsx`]){let i=t.join(n,`index${r}`);if(e.existsSync(i))return i}return n}return null},load(e){return e===n?{code:r,moduleType:i}:null}},{name:`resolve-client-server-boundaries`,resolveId:(r,i)=>{if(!i||i.includes(`node_modules`)||i.includes(`/packages/rari/dist`)||r.startsWith(`node:`)||l.isNodeBuiltin(r)||r===`react`||r===`react-dom`||r===`react/jsx-runtime`||r===`react/jsx-dev-runtime`)return null;let a=null,o=l.options.alias||{};for(let[e,n]of Object.entries(o))if(r.startsWith(`${e}/`)||r===e){let i=r.slice(e.length),o=t.join(n,i);a=t.isAbsolute(o)?o:t.resolve(l.projectRoot,o);break}if(!a&&(r.startsWith(`./`)||r.startsWith(`../`))){let e=i===n?s:t.dirname(i);a=t.resolve(e,r)}if(a)for(let n of[``,`.ts`,`.tsx`,`.js`,`.jsx`]){let r=a+n;if(e.existsSync(r)&&e.statSync(r).isFile()){if(l.isClientComponent(r)){let e=t.relative(l.projectRoot,r);return u.set(r,
|
|
42
|
-
`);for(let e of n){let n=e.trim();if(!(n.startsWith(`//`)||n.startsWith(`/*`)||!n)){if(n===`'use server'`||n===`"use server"`||n===`'use server';`||n===`"use server";`){let e=t.relative(l.projectRoot,r);return d.set(r,
|
|
41
|
+
}`;i.push({original:n,replacement:p})}}}let a=n;for(let{original:e,replacement:t}of i)a=a.replace(e,t);return a}isPageComponent(e){return e.includes(`/app/`)||e.includes(`\\app\\`)}createBuildPlugins(n,r,i,a,o=!1){let s=t.dirname(a),c=t.basename(a).match(/^proxy\.(?:tsx?|jsx?|mts|mjs)$/),l=this,u=new Map,d=new Map;return[{name:`virtual-module`,resolveId(r,i){if(r===n)return r;if(i===n&&(r.startsWith(`./`)||r.startsWith(`../`))){let n=t.resolve(s,r);for(let t of[`.ts`,`.tsx`,`.js`,`.jsx`,``]){let r=n+t;if(e.existsSync(r)&&e.statSync(r).isFile())return r}for(let r of[`.ts`,`.tsx`,`.js`,`.jsx`]){let i=t.join(n,`index${r}`);if(e.existsSync(i))return i}return n}return null},load(e){return e===n?{code:r,moduleType:i}:null}},{name:`resolve-client-server-boundaries`,resolveId:(r,i)=>{if(!i||i.includes(`node_modules`)||i.includes(`/packages/rari/dist`)||r.startsWith(`node:`)||l.isNodeBuiltin(r)||r===`react`||r===`react-dom`||r===`react/jsx-runtime`||r===`react/jsx-dev-runtime`)return null;let a=null,o=l.options.alias||{};for(let[e,n]of Object.entries(o))if(r.startsWith(`${e}/`)||r===e){let i=r.slice(e.length),o=t.join(n,i);a=t.isAbsolute(o)?o:t.resolve(l.projectRoot,o);break}if(!a&&(r.startsWith(`./`)||r.startsWith(`../`))){let e=i===n?s:t.dirname(i);a=t.resolve(e,r)}if(a)for(let n of[``,`.ts`,`.tsx`,`.js`,`.jsx`]){let r=a+n;if(e.existsSync(r)&&e.statSync(r).isFile()){if(l.isClientComponent(r)){let e=t.relative(l.projectRoot,r),n=e.startsWith(`..`)?r:e;return u.set(r,n),{id:`\0client-ref:${r}`}}try{let n=e.readFileSync(r,`utf-8`).split(`
|
|
42
|
+
`);for(let e of n){let n=e.trim();if(!(n.startsWith(`//`)||n.startsWith(`/*`)||!n)){if(n===`'use server'`||n===`"use server"`||n===`'use server';`||n===`"use server";`){let e=t.relative(l.projectRoot,r),n=e.startsWith(`..`)?r:e;return d.set(r,n),{id:`\0server-action:${r}`}}if(n)break}}}catch(e){console.error(`[rari] Failed to read file for server action detection: ${r}`,e)}break}}return null},load(e){if(e.startsWith(`\0client-ref:`)){let n=e.slice(12),r=t.relative(l.projectRoot,n),i=u.get(n)||(r.startsWith(`..`)?n:r);return{code:`
|
|
43
43
|
function registerClientReference(clientReference, id, exportName) {
|
|
44
44
|
const key = id + '#' + exportName;
|
|
45
45
|
const clientProxy = {};
|
|
@@ -66,7 +66,7 @@ function registerClientReference(clientReference, id, exportName) {
|
|
|
66
66
|
return clientProxy;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
export default registerClientReference(null, ${JSON.stringify(
|
|
69
|
+
export default registerClientReference(null, ${JSON.stringify(i)}, "default");
|
|
70
70
|
`,moduleType:`js`}}if(e.startsWith(`\0server-action:`)){let t=e.slice(15);return{code:`export * from ${JSON.stringify(t)};`,moduleType:`js`}}return null}},{name:`use-transformed-server-components`,resolveId:(n,r)=>{if(!o)return null;if(n.startsWith(`file://`)){let t=n.replace(/^file:\/\//,``);return e.existsSync(t)?{id:`\0transformed:${t}`}:null}let i=null,a=l.options.alias||{};for(let[e,r]of Object.entries(a))if(n.startsWith(`${e}/`)||n===e){let a=n.slice(e.length),o=t.join(r,a);i=t.isAbsolute(o)?o:t.resolve(l.projectRoot,o);break}let c=r?.startsWith(`\0`)?s:r?t.dirname(r):s;if(!i&&(n.startsWith(`./`)||n.startsWith(`../`))&&(i=t.resolve(c,n)),!i||c.includes(`node_modules`))return null;for(let n of[``,`.ts`,`.tsx`,`.js`,`.jsx`]){let r=i+n;if(e.existsSync(r)&&e.statSync(r).isFile()){if(l.isClientComponent(r))return null;let n=t.join(l.projectRoot,`src`);if(!r.startsWith(n))return null;let i=t.relative(n,r),a=t.join(l.options.outDir,l.options.rscDir,i.replace(/\.(tsx?|jsx?)$/,`.js`));if(e.existsSync(a))return{id:`\0transformed:${a}`};break}}return null},load(t){if(t.startsWith(`\0transformed:`)){let n=t.slice(13);return{code:e.readFileSync(n,`utf-8`),moduleType:`js`}}return null}},{name:`resolve-aliases`,resolveId:n=>{if(n.startsWith(`\0`))return null;let r=l.options.alias||{};for(let[i,a]of Object.entries(r))if(n.startsWith(`${i}/`)||n===i){let r=n.slice(i.length),o=t.join(a,r),s=t.isAbsolute(o)?o:t.resolve(l.projectRoot,o);for(let t of[``,`.ts`,`.tsx`,`.js`,`.jsx`]){let n=s+t;if(e.existsSync(n)&&e.statSync(n).isFile())return n}for(let n of[`.ts`,`.tsx`,`.js`,`.jsx`]){let r=t.join(s,`index${n}`);if(e.existsSync(r))return r}return s}return null}},{name:`resolve-rari-proxy`,resolveId:n=>{if(c&&n===`rari`){let n=t.resolve(l.projectRoot,`node_modules/rari/dist/proxy/RariResponse.mjs`);if(e.existsSync(n))return n;let r=t.resolve(l.projectRoot,`node_modules/rari/src/proxy/RariResponse.ts`);if(e.existsSync(r))return r}return null}},{name:`externalize-deps`,resolveId:e=>e.startsWith(`\0`)?null:e.startsWith(`node:`)||l.isNodeBuiltin(e)||[`react`,`react-dom`,`react/jsx-runtime`,`react/jsx-dev-runtime`,`rari/image`].includes(e)?{id:e,external:!0}:e===`rari`||e===`rari/client`?null:!e.startsWith(`.`)&&!e.startsWith(`/`)?{id:e,external:!0}:null}]}async buildComponentCodeOnly(i){let a=await e.promises.readFile(i,`utf-8`),o=this.transformClientImports(a,i),s=this.isPageComponent(i),c=s?this.transformComponentImportsToGlobal(o):o,l=t.extname(i),u;u=l===`.tsx`?`tsx`:l===`.ts`?`ts`:l===`.jsx`?`jsx`:`js`;let d=`\0virtual:${i}`,f=await r({input:d,platform:`node`,write:!1,output:{format:`esm`,minify:this.options.minify},moduleTypes:{[`.${u}`]:u},resolve:{mainFields:[`module`,`main`],conditionNames:[`import`,`module`,`default`],extensions:[`.ts`,`.tsx`,`.js`,`.jsx`]},transform:{jsx:`react`,define:{global:`globalThis`,"process.env.NODE_ENV":JSON.stringify(n.env.NODE_ENV||`production`),...this.options.define}},plugins:this.createBuildPlugins(d,c,u,i,s)});if(!f.output||f.output.length===0)throw Error(`No output generated from Rolldown`);let p=f.output.find(e=>e.type===`chunk`&&e.isEntry);if(!p||p.type!==`chunk`)throw Error(`No entry chunk found in Rolldown output`);let m=p.code;return m=`// Built: ${new Date().toISOString()}\n${m}`,m}async buildServerComponents(){let n=t.join(this.options.outDir,this.options.rscDir);await e.promises.mkdir(n,{recursive:!0});let r={react:`npm:react@19`,"react-dom":`npm:react-dom@19`,"react/jsx-runtime":`npm:react@19/jsx-runtime`,"react/jsx-dev-runtime":`npm:react@19/jsx-dev-runtime`},i=this.options.alias||{};for(let[e,n]of Object.entries(i)){let i=t.isAbsolute(n)?n:t.resolve(this.projectRoot,n);r[`${e}/`]=`file://${i}/`}let a={components:{},importMap:{imports:r},version:`1.0.0`,buildTime:new Date().toISOString()};for(let[n,r]of this.serverComponents){if(this.isPageComponent(n))continue;let i=t.relative(this.projectRoot,n),o=this.getComponentId(i),s=t.join(this.options.rscDir,`${o}.js`),c=t.join(this.options.outDir,s),l=t.dirname(c);await e.promises.mkdir(l,{recursive:!0}),await this.buildSingleComponent(n,c);let u=`file://${t.resolve(this.projectRoot,c)}`;a.components[o]={id:o,filePath:n,relativePath:i,bundlePath:s,moduleSpecifier:u,dependencies:r.dependencies,hasNodeImports:r.hasNodeImports}}for(let[n,r]of this.serverComponents){if(!this.isPageComponent(n))continue;let i=t.relative(this.projectRoot,n),o=this.getComponentId(i),s=t.join(this.options.rscDir,`${o}.js`),c=t.join(this.options.outDir,s),l=t.dirname(c);await e.promises.mkdir(l,{recursive:!0}),await this.buildSingleComponent(n,c);let u=`file://${t.resolve(this.projectRoot,c)}`;a.components[o]={id:o,filePath:n,relativePath:i,bundlePath:s,moduleSpecifier:u,dependencies:r.dependencies,hasNodeImports:r.hasNodeImports}}for(let[n,r]of this.serverActions){let i=t.relative(this.projectRoot,n),o=this.getComponentId(i),s=t.join(this.options.rscDir,`${o}.js`),c=t.join(this.options.outDir,s),l=t.dirname(c);await e.promises.mkdir(l,{recursive:!0}),await this.buildSingleComponent(n,c);let u=`file://${t.resolve(this.projectRoot,c)}`;a.components[o]={id:o,filePath:n,relativePath:i,bundlePath:s,moduleSpecifier:u,dependencies:r.dependencies,hasNodeImports:r.hasNodeImports}}let o=t.join(this.options.outDir,this.options.manifestPath);await e.promises.writeFile(o,JSON.stringify(a,null,2),`utf-8`);let s={};this.options.csp&&(s.csp=this.options.csp),this.options.rateLimit&&(s.rateLimit=this.options.rateLimit),this.options.spamBlocker&&(s.spamBlocker=this.options.spamBlocker);let c=t.join(this.options.outDir,this.options.serverConfigPath);if(Object.keys(s).length===0)try{await e.promises.unlink(c)}catch(e){e.code!==`ENOENT`&&console.warn(`Failed to remove server config file:`,e)}else await e.promises.writeFile(c,JSON.stringify(s,null,2),`utf-8`);return a}async buildSingleComponent(i,a,o=!1){let s=await e.promises.readFile(i,`utf-8`),c=this.transformClientImports(s,i),l=this.isPageComponent(i),u=l?this.transformComponentImportsToGlobal(c):c,d=t.extname(i),f;f=d===`.tsx`?`tsx`:d===`.ts`?`ts`:d===`.jsx`?`jsx`:`js`;let p=`\0virtual:${i}`,m=await r({input:p,platform:`node`,write:!1,output:{format:`esm`,minify:this.options.minify},moduleTypes:{[`.${f}`]:f},resolve:{mainFields:[`module`,`main`],conditionNames:[`import`,`module`,`default`],extensions:[`.ts`,`.tsx`,`.js`,`.jsx`]},transform:{jsx:`react`,define:{global:`globalThis`,"process.env.NODE_ENV":JSON.stringify(n.env.NODE_ENV||`production`),...this.options.define}},plugins:this.createBuildPlugins(p,u,f,i,l)});if(!m.output||m.output.length===0)throw Error(`No output generated from Rolldown`);let h=m.output.find(e=>e.type===`chunk`&&e.isEntry);if(!h||h.type!==`chunk`)throw Error(`No entry chunk found in Rolldown output`);let g=h.code;g=`// Built: ${new Date().toISOString()}\n${g}`,await e.promises.writeFile(a,g,`utf-8`);let _=await e.promises.open(a,`r+`);if(await _.sync(),await _.close(),o)return g}createSelfRegisteringModule(e,t){if(e.includes(`Self-registering Production Component`))return e;let n=e,r=null,i=[];if(n=n.replace(/^export\s+default\s+function\s+(\w+)/gm,(e,t)=>(r=t,`function ${t}`)),n=n.replace(/^export\s+default\s+async\s+function\s+(\w+)/gm,(e,t)=>(r=t,`async function ${t}`)),n=n.replace(/^export\s+default\s+(\w+);?\s*$/gm,(e,t)=>(r=t,`// Default export: ${t}`)),n=n.replace(/^export\s*\{\s*(\w+)\s+as\s+default\s*\};?\s*$/gm,(e,t)=>(r=t,`// Default export: ${t}`)),n=n.replace(/^export\s*\{([^}]+)\};?\s*$/gm,(e,a)=>{let o=a.split(`,`).map(e=>e.trim()),s=[];return o.forEach(e=>{if(e.includes(`as default`)){let t=e.replace(`as default`,``).trim();r=t,s.push(`${t} (default)`)}else if(e===`default`){let e=`${t}_default`;n.includes(`var ${e}`)&&(r=e),s.push(`default`)}else i.push(e),s.push(e)}),`// Exports: ${s.join(`, `)}`}),n=n.replace(/^export\s+(?:async\s+)?function\s+(\w+)/gm,(e,t)=>(i.push(t),e.replace(`export `,``))),n=n.replace(/^export\s+(const|let|var)\s+(\w+)/gm,(e,t,n)=>(i.push(n),`${t} ${n}`)),!r){let e=`${t}_default`;n.includes(`var ${e}`)&&(r=e)}return`// Self-registering Production Component: ${t}
|
|
71
71
|
|
|
72
72
|
if (!globalThis["${t}"]) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,r as t,t as n}from"./server-build-0OyoumT7.mjs";export{n as ServerComponentBuilder,t as scanDirectory};
|
|
@@ -319,7 +319,7 @@ declare class ErrorBoundary extends Component<{
|
|
|
319
319
|
error: Error;
|
|
320
320
|
};
|
|
321
321
|
componentDidCatch(error: Error, errorInfo: any): void;
|
|
322
|
-
render(): React.ReactNode;
|
|
322
|
+
render(): string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | null | undefined;
|
|
323
323
|
}
|
|
324
324
|
declare function createErrorBoundary(fallback?: (error: Error, reset: () => void) => ReactElement): ({
|
|
325
325
|
children
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e,i as t,n,o as r,r as i,t as a}from"./constants-DZAg-dr0.mjs";import{n as o}from"./server-build-DKiwRWzv.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-9ltViohI.mjs`),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(`
|
|
1
|
+
import{a as e,i as t,n,o as r,r as i,t as a}from"./constants-DZAg-dr0.mjs";import{n as o}from"./server-build-0OyoumT7.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-9ltViohI.mjs`),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
2
|
`);for(let e of t){let t=e.trim();if(!(!t||t.startsWith(`//`)||t.startsWith(`/*`))){if(t===`'use client'`||t===`"use client"`)return`client`;break}}return`server`}catch{return`unknown`}}queueLog(e,t){this.logBatch.push({type:e,message:t,timestamp:Date.now()}),this.logBatchTimer&&clearTimeout(this.logBatchTimer),this.logBatchTimer=setTimeout(()=>{this.flushLogs()},this.LOG_BATCH_DELAY)}flushLogs(){if(this.logBatch.length===0)return;let e=this.logBatch.reduce((e,t)=>(e[t.type]||(e[t.type]=[]),e[t.type].push(t),e),{});for(let[t,n]of Object.entries(e))if(n.length===1){let e=n[0];this.outputLog(t,e.message)}else{let e=n.map(e=>e.message).join(`
|
|
3
3
|
• `);this.outputLog(t,`${n.length} updates:\n • ${e}`)}this.logBatch=[],this.logBatchTimer=null}outputLog(e,t){let n=`[rari] HMR:`;switch(e){case`success`:console.warn(`\x1B[32m${n}\x1B[0m ${t}`);break;case`warning`:console.warn(`\x1B[33m${n}\x1B[0m ${t}`);break;case`error`:console.error(`\x1B[31m${n}\x1B[0m ${t}`);break;default:console.warn(`${n} ${t}`);break}}dispose(){this.logBatchTimer&&(clearTimeout(this.logBatchTimer),this.flushLogs()),this.batchTimer&&=(clearTimeout(this.batchTimer),null);for(let e of this.pendingUpdates.values())clearTimeout(e);this.pendingUpdates.clear(),this.pendingFiles.clear(),this.errorHandler.dispose()}};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,`../src/runtime`,e)];for(let e of i)try{return await s.promises.readFile(e,`utf-8`)}catch{}throw Error(`Could not find ${e}. Tried: ${i.join(`, `)}`)}async function F(){return P(`rsc-client-runtime.js`)}async function I(e,t){return(await P(`entry-client.js`)).replace(`// CLIENT_COMPONENT_IMPORTS_PLACEHOLDER`,e).replace(`// CLIENT_COMPONENT_REGISTRATIONS_PLACEHOLDER`,t)}async function L(){return P(`react-server-dom-shim.js`)}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
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+=`
|
|
@@ -42,7 +42,7 @@ const ${t} = registerClientReference(
|
|
|
42
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
43
|
`),p&&!n&&(i+=`import { createServerComponentWrapper } from 'virtual:rsc-integration';
|
|
44
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-
|
|
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-CyMkTI5L.mjs`),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-CyMkTI5L.mjs`),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){if(e===`virtual:rsc-integration`||e===`virtual:rari-entry-client`||e===`virtual:react-server-dom-rari-client`)return e;if(e===`virtual:app-router-provider`)return`${e}.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===`../router/LoadingComponentRegistry`||e===`../router/LoadingComponentRegistry.ts`)return`virtual:loading-component-registry.ts`;if(e===`react-server-dom-rari/server`)return e;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(e){if(e===`virtual:rari-entry-client`){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),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
46
|
`),c=i.map((e,t)=>{let n=l.relative(u.cwd(),e),r=`ClientComponent${t}`,i=l.basename(e,l.extname(e));return`
|
|
47
47
|
globalThis['~clientComponents']["${n}"] = {
|
|
48
48
|
id: "${i}",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as AppRouteManifest, i as ServerSpamBlockerConfig, r as ServerRateLimitConfig, t as ServerCSPConfig } from "./server-config-
|
|
1
|
+
import { g as AppRouteManifest, i as ServerSpamBlockerConfig, r as ServerRateLimitConfig, t as ServerCSPConfig } from "./server-config-DPOhoy43.mjs";
|
|
2
2
|
import { Plugin, UserConfig } from "rolldown-vite";
|
|
3
3
|
|
|
4
4
|
//#region src/types/metadata-route.d.ts
|
package/dist/vite.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
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 { A as SitemapImage, C as ApiRouteHandlers, D as RobotsRule, E as Robots, O as Sitemap, S as ApiResponse, T as RouteHandler, _ as ProxyResult, a as rari, b as RequestCookies, c as ProxyPluginOptions, d as RariRequest, f as CookieOptions, g as ProxyModule, h as ProxyMatcher, i as defineRariOptions, j as SitemapVideo, k as SitemapEntry, l as rariProxy, m as ProxyFunction, n as Response, o as rariRouter, p as ProxyConfig, r as defineRariConfig, s as generateAppRouteManifest, t as Request, u as RariResponse, v as RariFetchEvent, w as RouteContext, x as ResponseCookies, y as RariURL } from "./vite-
|
|
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-DPOhoy43.mjs";
|
|
2
|
+
import { A as SitemapImage, C as ApiRouteHandlers, D as RobotsRule, E as Robots, O as Sitemap, S as ApiResponse, T as RouteHandler, _ as ProxyResult, a as rari, b as RequestCookies, c as ProxyPluginOptions, d as RariRequest, f as CookieOptions, g as ProxyModule, h as ProxyMatcher, i as defineRariOptions, j as SitemapVideo, k as SitemapEntry, l as rariProxy, m as ProxyFunction, n as Response, o as rariRouter, p as ProxyConfig, r as defineRariConfig, s as generateAppRouteManifest, t as Request, u as RariResponse, v as RariFetchEvent, w as RouteContext, x as ResponseCookies, y as RariURL } from "./vite-j_XfSMaD.mjs";
|
|
3
3
|
export { ApiResponse, ApiRouteHandlers, AppRouteEntry, AppRouteManifest, AppRouteMatch, CookieOptions, ErrorEntry, ErrorProps, GenerateMetadata, GenerateStaticParams, HttpRuntimeClient, LayoutEntry, LayoutProps, LoadingEntry, Metadata, MetadataResult, NotFoundEntry, PageProps, ProxyConfig, ProxyFunction, ProxyMatcher, ProxyModule, ProxyPluginOptions, ProxyResult, RariFetchEvent, RariRequest, RariResponse, RariURL, Request, RequestCookies, Response, ResponseCookies, Robots, RobotsRule, RouteContext, RouteHandler, RouteSegment, RouteSegmentType, RuntimeClient, ServerCSPConfig, ServerConfig, ServerRateLimitConfig, ServerSidePropsResult, ServerSpamBlockerConfig, Sitemap, SitemapEntry, SitemapImage, SitemapVideo, StaticParamsResult, clearPropsCache, clearPropsCacheForComponent, createHttpRuntimeClient, defineRariConfig, defineRariOptions, extractMetadata, extractServerProps, extractServerPropsWithCache, extractStaticParams, generateAppRouteManifest, hasServerSideDataFetching, rari, rariProxy, rariRouter };
|
package/dist/vite.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"./vite-
|
|
1
|
+
import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"./vite-CiAKzo4n.mjs";import{t as s}from"./RariRequest-B7W8PASA.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-Jllyf7Ly.mjs";import{t as _}from"./routes-KDxjyeNA.mjs";import"./constants-DZAg-dr0.mjs";import"./server-build-0OyoumT7.mjs";export{a as ApiResponse,p as HttpRuntimeClient,s as RariRequest,r as RariResponse,g as clearPropsCache,l as clearPropsCacheForComponent,c as createHttpRuntimeClient,o 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.8.
|
|
4
|
+
"version": "0.8.8",
|
|
5
5
|
"description": "Runtime Accelerated Rendering Infrastructure (rari)",
|
|
6
6
|
"author": "Ryan Skinner",
|
|
7
7
|
"license": "MIT",
|
|
@@ -86,11 +86,11 @@
|
|
|
86
86
|
"rolldown": "1.0.0-rc.2"
|
|
87
87
|
},
|
|
88
88
|
"optionalDependencies": {
|
|
89
|
-
"rari-darwin-arm64": "0.8.
|
|
90
|
-
"rari-darwin-x64": "0.8.
|
|
91
|
-
"rari-linux-arm64": "0.8.
|
|
92
|
-
"rari-linux-x64": "0.8.
|
|
93
|
-
"rari-win32-x64": "0.8.
|
|
89
|
+
"rari-darwin-arm64": "0.8.7",
|
|
90
|
+
"rari-darwin-x64": "0.8.7",
|
|
91
|
+
"rari-linux-arm64": "0.8.7",
|
|
92
|
+
"rari-linux-x64": "0.8.7",
|
|
93
|
+
"rari-win32-x64": "0.8.7"
|
|
94
94
|
},
|
|
95
95
|
"devDependencies": {
|
|
96
96
|
"@types/node": "^25.2.0",
|
package/src/vite/server-build.ts
CHANGED
|
@@ -575,7 +575,8 @@ const ${importName} = (props) => {
|
|
|
575
575
|
const pathWithExt = resolvedPath + ext
|
|
576
576
|
if (fs.existsSync(pathWithExt) && fs.statSync(pathWithExt).isFile()) {
|
|
577
577
|
if (self.isClientComponent(pathWithExt)) {
|
|
578
|
-
const
|
|
578
|
+
const relativePath = path.relative(self.projectRoot, pathWithExt)
|
|
579
|
+
const componentId = relativePath.startsWith('..') ? pathWithExt : relativePath
|
|
579
580
|
clientComponentRefs.set(pathWithExt, componentId)
|
|
580
581
|
return { id: `\0client-ref:${pathWithExt}` }
|
|
581
582
|
}
|
|
@@ -589,7 +590,8 @@ const ${importName} = (props) => {
|
|
|
589
590
|
continue
|
|
590
591
|
if (trimmed === '\'use server\'' || trimmed === '"use server"'
|
|
591
592
|
|| trimmed === '\'use server\';' || trimmed === '"use server";') {
|
|
592
|
-
const
|
|
593
|
+
const relActionPath = path.relative(self.projectRoot, pathWithExt)
|
|
594
|
+
const actionId = relActionPath.startsWith('..') ? pathWithExt : relActionPath
|
|
593
595
|
serverActionRefs.set(pathWithExt, actionId)
|
|
594
596
|
return { id: `\0server-action:${pathWithExt}` }
|
|
595
597
|
}
|
|
@@ -610,7 +612,8 @@ const ${importName} = (props) => {
|
|
|
610
612
|
load(id: string) {
|
|
611
613
|
if (id.startsWith('\0client-ref:')) {
|
|
612
614
|
const filePath = id.slice('\0client-ref:'.length)
|
|
613
|
-
const
|
|
615
|
+
const relativePath = path.relative(self.projectRoot, filePath)
|
|
616
|
+
const componentId = clientComponentRefs.get(filePath) || (relativePath.startsWith('..') ? filePath : relativePath)
|
|
614
617
|
|
|
615
618
|
return {
|
|
616
619
|
code: `
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,r as t,t as n}from"./server-build-DKiwRWzv.mjs";export{n as ServerComponentBuilder,t as scanDirectory};
|