rari 0.8.10 → 0.8.11
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/RariRequest-B_UvFfpJ.mjs +1 -0
- package/dist/RariRequest-BoO3yTuk.mjs +1 -0
- package/dist/cli.mjs +1 -1
- package/dist/client.d.mts +1 -1
- package/dist/get-client-component-D83VBqKX.mjs +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/mdx.mjs +1 -1
- package/dist/platform.mjs +2 -2
- package/dist/proxy/runtime-executor.mjs +1 -1
- package/dist/{railway-DGrtpjoy.mjs → railway-DZB8P0Gi.mjs} +6 -6
- package/dist/react-server-dom-shim-Bvsz8jKC.mjs +1 -0
- package/dist/{render-CzhTDnZi.mjs → render-vMFW4sOG.mjs} +6 -6
- package/dist/robots-generator-Bo5MHa-v.mjs +2 -0
- package/dist/runtime/actions.d.mts +12 -0
- package/dist/runtime/actions.mjs +1 -1
- package/dist/runtime/entry-client.d.mts +6 -0
- package/dist/runtime/entry-client.mjs +10 -0
- package/dist/runtime/react-server-dom-rari-client.d.mts +10 -0
- package/dist/runtime/react-server-dom-rari-client.mjs +2 -0
- package/dist/runtime/react-server-dom-shim.d.mts +21 -0
- package/dist/runtime/react-server-dom-shim.mjs +1 -0
- package/dist/runtime/rsc-client-runtime.d.mts +45 -0
- package/dist/runtime/rsc-client-runtime.mjs +2 -0
- package/dist/server-build-CJGDvVJe.mjs +1 -0
- package/dist/{server-build-9XGK2a43.mjs → server-build-D_ZNTgRx.mjs} +2 -2
- package/dist/{sitemap-generator-iJIWKu_J.mjs → sitemap-generator-BAzhkvmO.mjs} +1 -1
- package/dist/{utils-syFD3KUL.mjs → utils-CvELqhML-D2DZ7WLt.mjs} +1 -1
- package/dist/{vite-CxD9Ycig.mjs → vite-CllVeRdC.mjs} +6 -6
- package/dist/{vite-j_XfSMaD.d.mts → vite-qqjC7uLL.d.mts} +1 -1
- package/dist/vite.d.mts +2 -2
- package/dist/vite.mjs +1 -1
- package/package.json +31 -12
- package/dist/RariRequest-B7W8PASA.mjs +0 -1
- package/dist/RariRequest-Db4obWIC.mjs +0 -1
- package/dist/robots-generator-D9gshyt6.mjs +0 -2
- package/dist/server-build-lmaYwy63.mjs +0 -1
- package/src/api-routes.ts +0 -48
- package/src/cli.ts +0 -527
- package/src/client.ts +0 -68
- package/src/image/Image.tsx +0 -268
- package/src/image/constants.ts +0 -8
- package/src/image/index.ts +0 -11
- package/src/index.ts +0 -3
- package/src/logger.ts +0 -17
- package/src/mdx.ts +0 -2
- package/src/og/ImageResponse.tsx +0 -77
- package/src/og/index.ts +0 -1
- package/src/platform.ts +0 -142
- package/src/proxy/RariRequest.ts +0 -208
- package/src/proxy/RariResponse.ts +0 -137
- package/src/proxy/execute-proxy.ts +0 -141
- package/src/proxy/executor.ts +0 -172
- package/src/proxy/matcher.ts +0 -150
- package/src/proxy/runtime-executor.ts +0 -148
- package/src/proxy/types.ts +0 -121
- package/src/proxy/vite-plugin.ts +0 -151
- package/src/router/ClientRouter.tsx +0 -742
- package/src/router/LayoutErrorBoundary.tsx +0 -129
- package/src/router/NavigationErrorOverlay.tsx +0 -310
- package/src/router/StatePreserver.ts +0 -273
- package/src/router/debounce.ts +0 -122
- package/src/router/navigation-error-handler.ts +0 -234
- package/src/router/navigation-types.ts +0 -15
- package/src/router/navigation-utils.ts +0 -162
- package/src/router/props-extractor.ts +0 -309
- package/src/router/robots-generator.ts +0 -184
- package/src/router/route-info-client.ts +0 -65
- package/src/router/route-info-types.ts +0 -16
- package/src/router/routes.ts +0 -473
- package/src/router/sitemap-generator.ts +0 -306
- package/src/router/types.ts +0 -170
- package/src/router/vite-plugin.ts +0 -427
- package/src/runtime/AppRouterProvider.tsx +0 -894
- package/src/runtime/LoadingErrorBoundary.tsx +0 -18
- package/src/runtime/actions.ts +0 -213
- package/src/runtime/csrf.ts +0 -88
- package/src/runtime/entry-client.js +0 -586
- package/src/runtime/mdx-client-components.ts +0 -57
- package/src/runtime/react-server-dom-rari-client.js +0 -350
- package/src/runtime/react-server-dom-shim.d.ts +0 -26
- package/src/runtime/react-server-dom-shim.js +0 -133
- package/src/runtime/rsc-client-runtime.js +0 -1492
- package/src/runtime-client.ts +0 -482
- package/src/types/metadata-route.ts +0 -65
- package/src/types/server-config.ts +0 -26
- package/src/vite/hmr-coordinator.ts +0 -344
- package/src/vite/hmr-error-handler.ts +0 -69
- package/src/vite/hmr-types.d.ts +0 -16
- package/src/vite/image-scanner.ts +0 -218
- package/src/vite/index.ts +0 -1815
- package/src/vite/server-build.ts +0 -1760
- package/src/vite.ts +0 -86
- /package/dist/{server-config-DPOhoy43.d.mts → server-config-D9oGBzhI.d.mts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=class{cookies;pendingDeletes;pendingSets;constructor(e){this.cookies=new Map,this.pendingDeletes=new Set,this.pendingSets=new Map,e&&this.parseCookieHeader(e)}parseCookieHeader(e){let t=e.split(`;`).map(e=>e.trim());for(let e of t){let[t,...n]=e.split(`=`);if(t){let e=n.join(`=`);this.cookies.set(t,{name:t,value:e})}}}get(e){if(this.pendingDeletes.has(e))return;let t=this.pendingSets.get(e);return t?{name:t.name,value:t.value,path:t.options?.path}:this.cookies.get(e)}getAll(){let e=[];return this.cookies.forEach(t=>{this.pendingDeletes.has(t.name)||e.push(t)}),this.pendingSets.forEach(t=>{e.push({name:t.name,value:t.value,path:t.options?.path})}),e}has(e){return this.pendingDeletes.has(e)?!1:this.pendingSets.has(e)||this.cookies.has(e)}delete(e){this.pendingDeletes.add(e),this.pendingSets.delete(e)}set(e,t,n){if(typeof e==`string`)this.pendingSets.set(e,{name:e,value:t,options:n}),this.pendingDeletes.delete(e);else{let{name:t,value:n,...r}=e;this.pendingSets.set(t,{name:t,value:n,options:r}),this.pendingDeletes.delete(t)}}},t=class{url;constructor(e){this.url=typeof e==`string`?new URL(e):e}get href(){return this.url.href}get origin(){return this.url.origin}get protocol(){return this.url.protocol}get hostname(){return this.url.hostname}get port(){return this.url.port}get pathname(){return this.url.pathname}set pathname(e){this.url.pathname=e}get search(){return this.url.search}set search(e){this.url.search=e}get searchParams(){return this.url.searchParams}get hash(){return this.url.hash}set hash(e){this.url.hash=e}toString(){return this.url.toString()}},n=class n{url;method;headers;cookies;rariUrl;ip;geo;constructor(n,r){n instanceof Request?(this.url=n.url,this.method=n.method,this.headers=new Headers(n.headers)):(this.url=typeof n==`string`?n:n.toString(),this.method=r?.method||`GET`,this.headers=new Headers(r?.headers)),this.rariUrl=new t(this.url),this.cookies=new e(this.headers.get(`cookie`)||void 0),this.ip=r?.ip,this.geo=r?.geo}static fromRequest(e,t){return new n(e,t)}};export{n as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./RariRequest-B_UvFfpJ.mjs";export{e as RariRequest};
|
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-DZB8P0Gi.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-vMFW4sOG.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-D9oGBzhI.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,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/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-D9oGBzhI.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-qqjC7uLL.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-CllVeRdC.mjs";import{t as s}from"./RariRequest-B_UvFfpJ.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-D_ZNTgRx.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/dist/mdx.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{a as e,i as t}from"./react-server-dom-shim-Bvsz8jKC.mjs";function n(n,r,i=`default`){let a=`${r}#${i}`;if(t(n,r,i),typeof globalThis<`u`){let e=globalThis;e[`~clientComponents`]||={};let t=r.replace(/\.[^.]+$/,``).split(`/`).pop()||i,o={id:i===`default`?t:i,path:r,type:`client`,component:n,registered:!0};e[`~clientComponents`][a]=o,e[`~clientComponents`][t]=o,e[`~clientComponents`][r]=o}function o(){throw Error(`Attempted to call ${i}() from the server but ${i} is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.`)}return e(o,r,i)}function r(e){let t={};for(let[r,{component:i,id:a,exportName:o=`default`}]of Object.entries(e))t[r]=n(i,a,o);return t}export{n as createMDXClientReference,r as createMDXClientReferences};
|
package/dist/platform.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{existsSync as e}from"node:fs";import{join as
|
|
1
|
+
import{existsSync as e}from"node:fs";import{dirname as t,join as n,parse as r}from"node:path";import i from"node:process";import{fileURLToPath as a}from"node:url";const o={"linux-x64":`rari-linux-x64`,"linux-arm64":`rari-linux-arm64`,"darwin-x64":`rari-darwin-x64`,"darwin-arm64":`rari-darwin-arm64`,"win32-x64":`rari-win32-x64`};function s(){let e=i.platform,t=i.arch,n;switch(e){case`darwin`:n=`darwin`;break;case`linux`:n=`linux`;break;case`win32`:n=`win32`;break;default:throw Error(`Unsupported platform: ${e}. rari supports Linux, macOS, and Windows.`)}let r;switch(t){case`x64`:r=`x64`;break;case`arm64`:r=`arm64`;break;default:throw Error(`Unsupported architecture: ${t}. rari supports x64 and ARM64.`)}let a=o[`${n}-${r}`];if(!a)throw Error(`Unsupported platform combination: ${n}-${r}. Supported platforms: ${Object.keys(o).join(`, `)}`);return{platform:n,arch:r,packageName:a,binaryName:n===`win32`?`rari.exe`:`rari`}}function c(){let{packageName:o,binaryName:c}=s();try{let a=i.cwd(),s=null,l=r(a).root;for(;a!==l&&a!==``;){if(e(n(a,`packages`))){s=a;break}let r=t(a);if(r===a)break;a=r}if(s){let t=n(n(s,`packages`,o),`bin`,c);if(e(t))return t}}catch{}try{let t=import.meta.resolve(`${o}/package.json`),r=n(a(new URL(`.`,t)),`bin`,c);if(e(r))return r;throw Error(`Binary not found at ${r}`)}catch{throw Error(`Failed to locate rari binary for ${o}. Please ensure the platform package is installed: npm install ${o}`)}}function l(){let{packageName:e}=s();return`
|
|
2
2
|
To install rari for your platform, run:
|
|
3
3
|
|
|
4
4
|
npm install ${e}
|
|
@@ -14,4 +14,4 @@ Or if you're using yarn:
|
|
|
14
14
|
If you continue to have issues, you can also install from source:
|
|
15
15
|
|
|
16
16
|
cargo install --git https://github.com/rari-build/rari
|
|
17
|
-
`}export{
|
|
17
|
+
`}export{c as getBinaryPath,l as getInstallationInstructions};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
async function e(e){try{let t=await import(e);if(!t||!t.proxy)return console.error(`[rari] Proxy: proxy function not found in module`),!1;let{RariRequest:n}=await import(`../RariRequest-
|
|
1
|
+
async function e(e){try{let t=await import(e);if(!t||!t.proxy)return console.error(`[rari] Proxy: proxy function not found in module`),!1;let{RariRequest:n}=await import(`../RariRequest-BoO3yTuk.mjs`);return globalThis.__rariExecuteProxy=async function(e){try{let r=new n(e.url,{method:e.method,headers:new Headers(e.headers)}),i=[],a=await t.proxy(r,{waitUntil:e=>{i.push(e)}});if(i.length>0&&Promise.allSettled(i).catch(e=>{console.error(`[rari] Proxy: waitUntil promise failed:`,e)}),!a)return{continue:!0};let o=a.headers?.get?.(`x-rari-proxy-continue`),s=a.headers?.get?.(`x-rari-proxy-rewrite`);if(s)return{continue:!1,rewrite:s};let c=a.headers?.get?.(`location`);if(c&&a.status>=300&&a.status<400)return{continue:!1,redirect:{destination:c,permanent:a.status===301||a.status===308}};if(o===`true`){let e={},t={};return a.headers?.forEach&&a.headers.forEach((n,r)=>{if(r.startsWith(`x-rari-proxy-request-`)){let t=r.replace(`x-rari-proxy-request-`,``);e[t]=n}else r.startsWith(`x-rari-proxy-`)||(t[r]=n)}),{continue:!0,requestHeaders:Object.keys(e).length>0?e:void 0,responseHeaders:Object.keys(t).length>0?t:void 0}}if(a.status){let e={};a.headers?.forEach&&a.headers.forEach((t,n)=>{e[n]=t});let t;try{a.text&&typeof a.text==`function`?t=await a.text():a.body&&(t=String(a.body))}catch{}return{continue:!1,response:{status:a.status,headers:e,body:t}}}return{continue:!0}}catch(e){return console.error(`[rari] Proxy: Proxy execution error:`,e),{continue:!0}}},!0}catch(e){return console.error(`[rari] Proxy: Failed to initialize proxy executor:`,e),!1}}export{e as initializeProxyExecutor};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e,i as t,n,r,t as i}from"./utils-
|
|
1
|
+
import{a as e,i as t,n,r,t as i}from"./utils-CvELqhML-D2DZ7WLt.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]
|
|
@@ -7,8 +7,8 @@ healthcheckPath = "/"
|
|
|
7
7
|
healthcheckTimeout = 300
|
|
8
8
|
restartPolicyType = "ON_FAILURE"
|
|
9
9
|
restartPolicyMaxRetries = 3
|
|
10
|
-
`),
|
|
11
|
-
`);if(a(m)){let e=o(m,`utf-8`);e.includes(`.railway/`)||(s(m,e+h),
|
|
10
|
+
`),r(`Created railway.toml configuration`);let m=c(d,`.gitignore`),h=[``,`# Railway`,`.railway/`,``].join(`
|
|
11
|
+
`);if(a(m)){let e=o(m,`utf-8`);e.includes(`.railway/`)||(s(m,e+h),r(`Updated .gitignore with Railway entries`))}else s(m,`# Dependencies
|
|
12
12
|
node_modules/
|
|
13
13
|
.pnpm-store/
|
|
14
14
|
|
|
@@ -42,7 +42,7 @@ Thumbs.db
|
|
|
42
42
|
# Temporary files
|
|
43
43
|
.tmp/
|
|
44
44
|
tmp/
|
|
45
|
-
`),
|
|
45
|
+
`),r(`Created .gitignore with Railway entries`);let g=c(d,`README.md`),_=`
|
|
46
46
|
## 🚂 Deploy to Railway
|
|
47
47
|
|
|
48
48
|
This rari application is configured for Railway deployment.
|
|
@@ -87,7 +87,7 @@ Optional variables you can set:
|
|
|
87
87
|
- \`RUST_LOG=debug\` - Rust logging level
|
|
88
88
|
|
|
89
89
|
---
|
|
90
|
-
`;if(a(g)){let e=o(g,`utf-8`);e.includes(`Deploy to Railway`)||(s(g,e+_),
|
|
90
|
+
`;if(a(g)){let e=o(g,`utf-8`);e.includes(`Deploy to Railway`)||(s(g,e+_),r(`Updated README.md with Railway deployment instructions`))}else s(g,`# My rari App
|
|
91
91
|
|
|
92
92
|
A high-performance React Server Components application powered by rari.
|
|
93
93
|
${_}
|
|
@@ -99,4 +99,4 @@ npm start
|
|
|
99
99
|
\`\`\`
|
|
100
100
|
|
|
101
101
|
Visit [http://localhost:3000](http://localhost:3000) to see your app.
|
|
102
|
-
`),
|
|
102
|
+
`),r(`Created README.md with Railway deployment instructions`);console.warn(``),r(`Railway deployment setup complete! 🎉`),console.warn(``),e(`Next steps:`),console.warn(` 1. ${u(`cyan`,`git add .`)}`),console.warn(` 2. ${u(`cyan`,`git commit -m "Add Railway deployment"`)}`),console.warn(` 3. ${u(`cyan`,`git push origin main`)}`),console.warn(` 4. Go to ${u(`cyan`,`https://railway.app`)} and deploy from GitHub`),console.warn(``),e(`Your rari app will automatically:`),console.warn(` ✅ Detect Railway environment`),console.warn(` ✅ Bind to 0.0.0.0 (Railway requirement)`),console.warn(` ✅ Use Railway's PORT environment variable`),console.warn(` ✅ Run in production mode`),console.warn(` ✅ Download platform-specific rari binary`),console.warn(``),r(`Ready for deployment! 🚀`)}export{d as createRailwayDeployment};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=new Map,t=new Map;let n=null;globalThis[`~rari`]?.bridge!==void 0&&(n=globalThis[`~rari`].bridge);function r(t,r,i){let a=`${r}#${i}`;e.set(a,{id:r,exportName:i,chunks:[r],name:i,async:!1}),Object.defineProperty(t,`$$typeof`,{value:Symbol.for(`react.client.reference`),enumerable:!1}),Object.defineProperty(t,`$$id`,{value:a,enumerable:!1}),Object.defineProperty(t,`$$async`,{value:!1,enumerable:!1});try{n&&typeof n.registerClientReference==`function`&&n.registerClientReference(a,r,i)}catch(e){console.error(e)}return t}function i(t,n,r){let i=`${n}#${r}`;e.set(i,{id:n,exportName:r,chunks:[n],name:r,async:!1})}function a(e,r,i){let a=`${r}#${i}`;t.set(a,{id:r,exportName:i,bound:!1}),Object.defineProperty(e,`$$typeof`,{value:Symbol.for(`react.server.reference`),enumerable:!1}),Object.defineProperty(e,`$$id`,{value:a,enumerable:!1}),Object.defineProperty(e,`$$bound`,{value:!1,enumerable:!1});try{n&&typeof n.registerServerReference==`function`&&n.registerServerReference(a,r,i)}catch(e){console.error(e)}return e}function o(e){return new Proxy({},{get(t,n){function i(){throw Error(`Attempted to call ${String(n)}() from the server but ${String(n)} is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.`)}return r(i,e,String(n))}})}const s=e,c=t;export{r as a,i,c as n,a as o,o as r,s as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e,i as t,n,r,t as i}from"./utils-
|
|
1
|
+
import{a as e,i as t,n,r,t as i}from"./utils-CvELqhML-D2DZ7WLt.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
|
|
@@ -12,8 +12,8 @@ import{a as e,i as t,n,r,t as i}from"./utils-syFD3KUL.mjs";import{existsSync as
|
|
|
12
12
|
value: production
|
|
13
13
|
- key: RUST_LOG
|
|
14
14
|
value: info
|
|
15
|
-
`),
|
|
16
|
-
`);if(a(m)){let e=o(m,`utf-8`);e.includes(`.render/`)||(s(m,e+h),
|
|
15
|
+
`),r(`Created render.yaml configuration`);let m=c(d,`.gitignore`),h=[``,`# Render`,`.render/`,``].join(`
|
|
16
|
+
`);if(a(m)){let e=o(m,`utf-8`);e.includes(`.render/`)||(s(m,e+h),r(`Updated .gitignore with Render entries`))}else s(m,`# Dependencies
|
|
17
17
|
node_modules/
|
|
18
18
|
.pnpm-store/
|
|
19
19
|
|
|
@@ -47,7 +47,7 @@ Thumbs.db
|
|
|
47
47
|
# Temporary files
|
|
48
48
|
.tmp/
|
|
49
49
|
tmp/
|
|
50
|
-
`),
|
|
50
|
+
`),r(`Created .gitignore with Render entries`);let g=c(d,`README.md`),_=`
|
|
51
51
|
## 🎨 Deploy to Render
|
|
52
52
|
|
|
53
53
|
This rari application is configured for Render deployment.
|
|
@@ -93,7 +93,7 @@ Optional variables you can add in Render dashboard:
|
|
|
93
93
|
- \`RUST_LOG=debug\` - Enhanced logging
|
|
94
94
|
|
|
95
95
|
---
|
|
96
|
-
`;if(a(g)){let e=o(g,`utf-8`);e.includes(`Deploy to Render`)||(s(g,e+_),
|
|
96
|
+
`;if(a(g)){let e=o(g,`utf-8`);e.includes(`Deploy to Render`)||(s(g,e+_),r(`Updated README.md with Render deployment instructions`))}else s(g,`# My rari App
|
|
97
97
|
|
|
98
98
|
A high-performance React Server Components application powered by rari.
|
|
99
99
|
${_}
|
|
@@ -105,4 +105,4 @@ npm start
|
|
|
105
105
|
\`\`\`
|
|
106
106
|
|
|
107
107
|
Visit [http://localhost:3000](http://localhost:3000) to see your app.
|
|
108
|
-
`),
|
|
108
|
+
`),r(`Created README.md with Render deployment instructions`);console.warn(``),r(`Render deployment setup complete! 🎉`),console.warn(``),e(`Next steps:`),console.warn(` 1. ${u(`cyan`,`git add .`)}`),console.warn(` 2. ${u(`cyan`,`git commit -m "Add Render deployment"`)}`),console.warn(` 3. ${u(`cyan`,`git push origin main`)}`),console.warn(` 4. Go to ${u(`cyan`,`https://render.com`)} and create a Web Service`),console.warn(``),e(`Your rari app will automatically:`),console.warn(` ✅ Detect Render environment`),console.warn(` ✅ Bind to 0.0.0.0 (Render requirement)`),console.warn(` ✅ Use Render's PORT environment variable`),console.warn(` ✅ Run in production mode`),console.warn(` ✅ Download platform-specific rari binary`),console.warn(``),r(`Ready for deployment! 🚀`)}export{d as createRenderDeployment};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{promises as e}from"node:fs";import t from"node:path";import{Buffer as n}from"node:buffer";function r(e){let t=[],n=Array.isArray(e.rules)?e.rules:[e.rules];for(let e of n){let n=Array.isArray(e.userAgent)?e.userAgent:e.userAgent?[e.userAgent]:[`*`];for(let r of n){if(t.push(`User-Agent: ${r}`),e.allow){let n=Array.isArray(e.allow)?e.allow:[e.allow];for(let e of n)t.push(`Allow: ${e}`)}if(e.disallow){let n=Array.isArray(e.disallow)?e.disallow:[e.disallow];for(let e of n)t.push(`Disallow: ${e}`)}e.crawlDelay!==void 0&&t.push(`Crawl-delay: ${e.crawlDelay}`),t.push(``)}}if(e.host&&(t.push(`Host: ${e.host}`),t.push(``)),e.sitemap){let n=Array.isArray(e.sitemap)?e.sitemap:[e.sitemap];for(let e of n)t.push(`Sitemap: ${e}`)}return t.join(`
|
|
2
|
+
`)}async function i(n,r=[`.ts`,`.tsx`,`.js`,`.jsx`,`.mjs`,`.cjs`]){let i=t.join(n,`robots.txt`);try{return await e.access(i),{type:`static`,path:i}}catch(e){if(e?.code!==`ENOENT`)throw e}for(let i of r){let r=t.join(n,`robots${i}`);try{return await e.access(r),{type:`dynamic`,path:r}}catch(e){if(e?.code!==`ENOENT`)throw e}}return null}async function a(a){let{appDir:o,outDir:s,extensions:c}=a,l=await i(o,c);if(!l)return!1;let u=t.join(s,`robots.txt`);if(await e.mkdir(t.dirname(u),{recursive:!0}),l.type===`static`)return await e.copyFile(l.path,u),!0;try{let{build:i}=await import(`rolldown`),a=await e.readFile(l.path,`utf-8`),o=`\0virtual:robots`,s=await i({input:o,external:[`rari`],platform:`node`,write:!1,output:{format:`esm`,codeSplitting:!1},plugins:[{name:`virtual-robots`,resolveId(e){return e===o?e:e.startsWith(`.`)?t.resolve(t.dirname(l.path),e):null},load(e){if(e===o){let e=t.extname(l.path).slice(1),n;switch(e){case`ts`:n=`ts`;break;case`tsx`:n=`tsx`;break;case`js`:case`mjs`:case`cjs`:n=`js`;break;case`jsx`:n=`jsx`;break;default:throw Error(`Unsupported robots file extension: .${e}. Supported extensions are: .ts, .tsx, .js, .jsx, .mjs, .cjs`)}return{code:a,moduleType:n}}return null}}]});if(!s.output||s.output.length===0)throw Error(`Failed to build robots module`);let c=s.output.find(e=>e.type===`chunk`&&e.isEntry)||s.output.find(e=>e.type===`chunk`);if(!c||c.type!==`chunk`)throw Error(`No chunk output found in robots build result`);let d=c.code,f=await import(`data:text/javascript;base64,${n.from(d).toString(`base64`)}`),p;if(typeof f.default==`function`){let e=f.default();p=e instanceof Promise?await e:e}else p=f.default;let m=r(p);return await e.writeFile(u,m),!0}catch(e){return console.error(`[rari] Failed to build/execute robots file:`,e),!1}}export{a as generateRobotsFile};
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
//#region src/runtime/csrf.d.ts
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
getCsrfToken: typeof getCsrfToken;
|
|
5
|
+
fetchWithCsrf: typeof fetchWithCsrf;
|
|
6
|
+
refreshCsrfToken: typeof refreshCsrfToken;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
declare function getCsrfToken(): string | null;
|
|
10
|
+
declare function refreshCsrfToken(): Promise<boolean>;
|
|
11
|
+
declare function fetchWithCsrf(url: string, options?: RequestInit): Promise<Response>;
|
|
12
|
+
//#endregion
|
|
1
13
|
//#region src/runtime/actions.d.ts
|
|
2
14
|
interface ServerActionResponse {
|
|
3
15
|
success: boolean;
|
package/dist/runtime/actions.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(){if(typeof window>`u`)return null;let e=document.querySelector(`meta[name="csrf-token"]`);return e?e.getAttribute(`content`):null}async function t(){if(typeof window>`u`)return!1;try{let e=await fetch(`/_rari/csrf-token`);if(!e.ok)return console.error(`[rari] CSRF: Failed to refresh CSRF token:`,e.status),!1;let t=await e.json();if(t.token){let e=document.querySelector(`meta[name="csrf-token"]`);return e||(e=document.createElement(`meta`),e.setAttribute(`name`,`csrf-token`),document.head.appendChild(e)),e.setAttribute(`content`,t.token),!0}return!1}catch(e){return console.error(`[rari] CSRF: Error refreshing CSRF token:`,e),!1}}async function n(n,r={}){let i=e();i||=(await t(),e());let a=new Headers(r.headers);i&&a.set(`X-CSRF-Token`,i);let o=
|
|
1
|
+
function e(){if(typeof window>`u`)return null;let e=document.querySelector(`meta[name="csrf-token"]`);return e?e.getAttribute(`content`):null}async function t(){if(typeof window>`u`)return!1;try{let e=await fetch(`/_rari/csrf-token`);if(!e.ok)return console.error(`[rari] CSRF: Failed to refresh CSRF token:`,e.status),!1;let t=await e.json();if(t.token){let e=document.querySelector(`meta[name="csrf-token"]`);return e||(e=document.createElement(`meta`),e.setAttribute(`name`,`csrf-token`),document.head.appendChild(e)),e.setAttribute(`content`,t.token),!0}return!1}catch(e){return console.error(`[rari] CSRF: Error refreshing CSRF token:`,e),!1}}async function n(n,r={}){let i=e();i||=(await t(),e());let a=new Headers(r.headers);i&&a.set(`X-CSRF-Token`,i);let o=new Request(n,{...r,headers:a}),s=null;try{s=o.clone()}catch{s=null}let c=await fetch(o);if(c.status===403&&n.includes(`/_rari/`)&&await t()){let t=e();if(t&&s){let e=new Headers(s.headers);return e.set(`X-CSRF-Token`,t),fetch(new Request(s,{headers:e}))}}return c}typeof window<`u`&&(window.getCsrfToken=e,window.fetchWithCsrf=n,window.refreshCsrfToken=t,document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,()=>{t()}):t());function r(e,t,n){return async(...e)=>{try{let r=e.map(e=>{if(e instanceof FormData){let t={};return e.forEach((e,n)=>{t[n]=e}),t}return e}),i=await(typeof window<`u`&&window.fetchWithCsrf?window.fetchWithCsrf:fetch)(`/_rari/action`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({id:t,export_name:n,args:r})});if(!i.ok){let e=await i.text().catch(()=>i.statusText);throw console.error(`[rari] ServerAction: HTTP ${i.status} error:`,e),Error(`Server action "${n}" failed with status ${i.status}: ${e}`)}let a=await i.json();if(a.redirect){if(typeof window<`u`){let e=new URL(a.redirect,window.location.href).href;e!==window.location.href&&(window.location.href=e)}return{redirect:a.redirect}}if(!a.success){let e=a.error||`Server action failed without error message`;throw console.error(`[rari] ServerAction: Action "${n}" failed:`,e),Error(e)}return a.result}catch(e){throw console.error(`[rari] ServerAction: Error executing "${n}":`,{moduleId:t,exportName:n,error:e instanceof Error?e.message:String(e),stack:e instanceof Error?e.stack:void 0}),e}}}function i(e,t,n={}){let r=async r=>{r.preventDefault();let i=new FormData(e);try{let r=await t(i);if(r&&r.redirect){n.onRedirect&&n.onRedirect(r.redirect),typeof window<`u`&&(window.location.href=r.redirect);return}n.onSuccess&&n.onSuccess(r),e.reset()}catch(e){let t=e instanceof Error?e.message:`Unknown error`;n.onError?n.onError(t):console.error(`Server action error:`,t)}};return e.addEventListener(`submit`,r),()=>{e.removeEventListener(`submit`,r)}}function a(e,t,n){return{action:`/_rari/form-action`,enhance:(r,a={})=>{let o=document.createElement(`input`);o.type=`hidden`,o.name=`__action_id`,o.value=e,r.appendChild(o);let s=document.createElement(`input`);if(s.type=`hidden`,s.name=`__export_name`,s.value=t,r.appendChild(s),typeof window<`u`&&window.getCsrfToken){let e=window.getCsrfToken();if(e){let t=r.querySelector(`input[name="__csrf_token"]`);t||(t=document.createElement(`input`),t.type=`hidden`,t.name=`__csrf_token`,r.appendChild(t)),t.value=e}}return r.action=`/_rari/form-action`,r.method=`POST`,i(r,n,a)}}}function o(){document.querySelectorAll(`form[data-server-action]`).forEach(e=>{if(!(e instanceof HTMLFormElement))return;let t=e.dataset.serverAction;if(t)try{let{moduleId:n,exportName:a}=JSON.parse(t),o=r(`action`,n,a);i(e,async e=>await o(e))}catch(e){console.error(`Failed to bind server action to form:`,e)}})}typeof window<`u`&&(document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,o):o());export{o as bindServerActions,a as createFormAction,r as createServerReference,i as enhanceFormWithAction};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import{t as e}from"../get-client-component-D83VBqKX.mjs";import*as t from"react";import{Suspense as n}from"react";import{ClientRouter as r}from"rari/client";import{createRoot as i}from"react-dom/client";import{AppRouterProvider as a}from"virtual:app-router-provider";import{createFromReadableStream as o}from"virtual:react-server-dom-rari-client.ts";import"virtual:rsc-integration.ts";function s(){return globalThis[`~rari`]}function c(){return globalThis}function l(){return window}function u(){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(c()[`~clientComponents`]?.[i])return c()[`~clientComponents`][i].component;if(c()[`~clientComponents`]?.[e]){let t=c()[`~clientComponents`][e].component;return r===`default`?t:t?.[r]}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}}}})}})}}
|
|
2
|
+
/*! @preserve CLIENT_COMPONENT_IMPORTS_PLACEHOLDER */
|
|
3
|
+
s()===void 0&&(globalThis[`~rari`]={}),s().AppRouterProvider=a,s().ClientRouter=r,s().getClientComponent=e,c()[`~clientComponents`]===void 0&&(globalThis[`~clientComponents`]={}),c()[`~clientComponentPaths`]===void 0&&(globalThis[`~clientComponentPaths`]={});
|
|
4
|
+
/*! @preserve CLIENT_COMPONENT_REGISTRATIONS_PLACEHOLDER */
|
|
5
|
+
function d(){s().hydrateClientComponents||(s().hydrateClientComponents=function(e,n,r){let a=l()[`~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[,n,r,i]=e,s=i?{...i}:{};if(i?.children&&(s.children=o(i.children)),s[`~boundaryId`]&&delete s[`~boundaryId`],typeof n==`string`){if(n.startsWith(`$L`)){let e=a.get(n);if(e){let n=`${e.id}#${e.name||`default`}`,i=null;return c()[`~clientComponents`][n]?i=c()[`~clientComponents`][n].component:c()[`~clientComponents`][e.id]&&(i=c()[`~clientComponents`][e.id].component),i?t.createElement(i,r?{...s,key:r}:s):s.children||null}return s.children||null}return t.createElement(n,r?{...s,key:r}:s)}return null}return e.map((e,n)=>{let r=o(e);return t.isValidElement(r)&&!r.key?t.cloneElement(r,{key:n}):r})}return e}try{let e=o(n);e&&(i(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 f(){let e=l()[`~rari`].pendingBoundaryHydrations;if(!(!e||e.size===0)){for(let[t,n]of e.entries())s().hydrateClientComponents&&s().hydrateClientComponents(t,n.content,n.element);e.clear()}}d();async function p(){let n=document.getElementById(`root`);if(!n){console.error(`[rari] Root element not found`);return}let s=document.getElementById(`__RARI_RSC_PAYLOAD__`),c=n.children.length>0,p=l()[`~rari`]?.bufferedRows&&l()[`~rari`].bufferedRows.length>0;if(d(),c&&!s&&!p){let n=document.querySelectorAll(`[data-client-component]`);n.length>0&&n.forEach(n=>{let r=n.getAttribute(`data-client-component`),a=n.getAttribute(`data-props`);if(r)try{let o=e(r);if(!o)return;let s=a?JSON.parse(a):{};n.innerHTML=``,i(n).render(t.createElement(o,s))}catch(e){console.error(`[rari] Failed to hydrate client component ${r}:`,e)}});return}if(c&&p&&!s&&document.querySelectorAll(`[data-boundary-id]`).length>0){l()[`~rari`].pendingBoundaryHydrations&&l()[`~rari`].pendingBoundaryHydrations.size>0&&f();return}try{let e;if(!s&&!p&&!c)try{let t=window.location.pathname+window.location.search,n=await fetch(t,{headers:{Accept:`text/x-component`}});if(!n.ok)throw Error(`Failed to fetch RSC data: ${n.status}`);let r=n.body;e=await o(r,u())}catch(t){console.error(`[rari] Failed to fetch initial RSC data:`,t),e=null}else if(s&&s.textContent)try{let t=s.textContent,n=l()[`~rari`]?.bufferedRows&&l()[`~rari`].bufferedRows.length>0;e=l()[`~rari`]?.streamComplete===void 0||n?await o(new ReadableStream({start(e){if(e.enqueue(new TextEncoder().encode(t)),l()[`~rari`]?.bufferedRows){for(let t of l()[`~rari`].bufferedRows)e.enqueue(new TextEncoder().encode(`\n${t}`));l()[`~rari`].bufferedRows=[]}let n=t=>{let n=t;n.detail?.rscRow&&e.enqueue(new TextEncoder().encode(`\n${n.detail.rscRow}`))},r=()=>{e.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),l()[`~rari`]?.streamComplete&&r()}}),u()):await o(new ReadableStream({start(e){e.enqueue(new TextEncoder().encode(t)),e.close()}}),u())}catch(t){console.error(`[rari] Failed to parse embedded RSC payload:`,t),e=null}else if(p)try{e=await o(new ReadableStream({start(e){if(l()[`~rari`]?.bufferedRows){for(let t of l()[`~rari`].bufferedRows)e.enqueue(new TextEncoder().encode(`${t}\n`));l()[`~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),l()[`~rari`]?.streamComplete&&n()}}),u())}catch(t){console.error(`[rari] Failed to process streaming RSC payload:`,t),e=null}if(!e)throw Error(`No RSC data available for hydration`);let d;d=e;let f;f=t.createElement(a,{initialPayload:{element:e}},d),f=t.createElement(r,{initialRoute:window.location.pathname},f),i(n).render(f)}catch(e){console.error(`[rari] Error rendering app:`,e),n.innerHTML=`
|
|
6
|
+
<div style="padding: 20px; background: #fee; border: 2px solid #f00; margin: 20px;">
|
|
7
|
+
<h2>Error Loading App</h2>
|
|
8
|
+
<p></p>
|
|
9
|
+
</div>
|
|
10
|
+
`;let t=n.querySelector(`p`);t&&(t.textContent=e instanceof Error?e.message:String(e))}}import.meta.hot&&import.meta.hot.data.hasRendered||(p().catch(e=>{console.error(`[rari] Fatal error:`,e)}),import.meta.hot&&(import.meta.hot.data.hasRendered=!0));export{p as renderApp};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/runtime/react-server-dom-rari-client.d.ts
|
|
2
|
+
interface CreateFromStreamOptions {
|
|
3
|
+
moduleMap?: Record<string, any>;
|
|
4
|
+
}
|
|
5
|
+
declare function createFromReadableStream(stream: ReadableStream<Uint8Array>, options?: CreateFromStreamOptions): Promise<any>;
|
|
6
|
+
declare function createFromFetch(fetchPromise: Promise<Response>, options?: CreateFromStreamOptions): Promise<any>;
|
|
7
|
+
declare function encodeReply(value: any): string;
|
|
8
|
+
declare function decodeReply(text: string): any;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { createFromFetch, createFromReadableStream, decodeReply, encodeReply };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import*as e from"react";async function t(e,t={}){let{moduleMap:n={}}=t,i=e.getReader(),o=[];for(;;){let{done:e,value:t}=await i.read();if(e)break;o.push(t)}let s=new Uint8Array(o.reduce((e,t)=>e+t.length,0)),c=0;for(let e of o)s.set(e,c),c+=e.length;let l=r(new TextDecoder().decode(s));return a(l.rootElement,l.modules,n,l.symbols,l.chunks)}async function n(e,t={}){let n=r(await(await e).text());return a(n.rootElement,n.modules,t.moduleMap||{},n.symbols,n.chunks)}function r(e){let t=new Map,n=new Map,r=new Map,a=0,o=0,s=0,c=0,l=``,u=null;for(;a<e.length;){let d=e[a],f=e.charCodeAt(a);switch(o){case 0:d===`:`?(o=1,a++):(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),a++);break;case 1:f===73||f===69||f===84||f===72||f===68||f===87||f===67?(c=f,o=2,a++):(c=0,o=2);break;case 2:d===`
|
|
2
|
+
`?(i(s,c,l,t,n,r),u===null&&c!==73&&l.trim()&&!(l.startsWith(`"$S`)&&l.endsWith(`"`))&&n.has(s.toString())&&(u=s.toString()),o=0,s=0,c=0,l=``):l+=d,a++;break}}return l.trim()&&(i(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 i(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 a(t,n,r,i,c){if(!t)return null;if(typeof t==`string`||typeof t==`number`||typeof t==`boolean`){if(typeof t==`string`&&t.startsWith(`$`)&&t.length>1){if(t[1]===`L`){let e=t.slice(2),o=c?.get(e);if(!o){let e=new Promise(()=>{});throw e._rscLazyRef=t,e}return a(o,n,r,i,c)}let e=t.slice(1),o=c?.get(e);return o?a(o,n,r,i,c):null}return t}if(Array.isArray(t)){if(t.length>=4&&t[0]===`$`){let[,l,u,d]=t;if(typeof l==`string`&&l.startsWith(`$`)&&l.length>1&&/^\d+$/.test(l.slice(1))){let t=l.slice(1),a=i?.get(t);if(a&&a.startsWith(`$S`)&&a.slice(2)===`react.suspense`){let t=s(d,n,r,i,c);return e.createElement(e.Suspense,u?{...t,key:u}:t)}}if(typeof l==`string`&&l.startsWith(`$S`)){if(l.slice(2)===`react.suspense`){let t=s(d,n,r,i,c);return e.createElement(e.Suspense,u?{...t,key:u}:t)}return null}if(typeof l==`string`&&l.startsWith(`$L`)){let t=l.substring(2);if(t===`ClientRouter`&&(!d||!d.manifest))return d&&d.children?a(d.children,n,r,i,c):null;let f=o(t,n,r);if(f){let t=s(d,n,r,i,c);return e.createElement(f,u?{...t,key:u}:t)}return null}let f=s(d,n,r,i,c);return e.createElement(l,u?{...f,key:u}:f)}return t.map(e=>a(e,n,r,i,c))}return t}function o(e,t,n){if(e===`AppRouterProvider`){let e=globalThis[`~rari`]?.AppRouterProvider;if(e)return e}if(e===`ClientRouter`){let e=globalThis[`~rari`]?.ClientRouter;if(e)return e}if(t&&t.size>0){let n=`$L${e}`,r=t.get(n);if(r){let e=globalThis[`~clientComponents`]||{};if(e[r.id])return e[r.id].component}}if(n[e])return n[e];let r=globalThis[`~clientComponents`]||{};for(let[t,n]of Object.entries(r))if(t.includes(e)||n.name===e)return n.component;return null}function s(e,t,n,r,i){if(!e||typeof e!=`object`)return e;let o={};for(let s in e)if(Object.hasOwn(e,s)){if(s.startsWith(`~`)||s===`ref`)continue;s===`children`?o[s]=e.children?a(e.children,t,n,r,i):void 0:o[s]=e[s]}return o}function c(e){return JSON.stringify(e)}function l(e){return JSON.parse(e)}export{n as createFromFetch,t as createFromReadableStream,l as decodeReply,c as encodeReply};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/runtime/react-server-dom-shim.d.ts
|
|
2
|
+
interface ClientReferenceData {
|
|
3
|
+
id: string;
|
|
4
|
+
exportName: string;
|
|
5
|
+
chunks: string[];
|
|
6
|
+
name: string;
|
|
7
|
+
async: boolean;
|
|
8
|
+
}
|
|
9
|
+
interface ServerReferenceData {
|
|
10
|
+
id: string;
|
|
11
|
+
exportName: string;
|
|
12
|
+
bound: boolean;
|
|
13
|
+
}
|
|
14
|
+
declare function registerClientReference(clientReference: any, id: string, exportName: string): any;
|
|
15
|
+
declare function registerClientComponent(componentFunction: any, id: string, exportName: string): void;
|
|
16
|
+
declare function registerServerReference(serverReference: any, id: string, exportName: string): any;
|
|
17
|
+
declare function createClientModuleProxy(id: string): any;
|
|
18
|
+
declare const __CLIENT_REFERENCE_REGISTRY__: Map<string, ClientReferenceData>;
|
|
19
|
+
declare const __SERVER_REFERENCE_REGISTRY__: Map<string, ServerReferenceData>;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { __CLIENT_REFERENCE_REGISTRY__, __SERVER_REFERENCE_REGISTRY__, createClientModuleProxy, registerClientComponent, registerClientReference, registerServerReference };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,i as t,n,o as r,r as i,t as a}from"../react-server-dom-shim-Bvsz8jKC.mjs";export{a as __CLIENT_REFERENCE_REGISTRY__,n as __SERVER_REFERENCE_REGISTRY__,i as createClientModuleProxy,t as registerClientComponent,e as registerClientReference,r as registerServerReference};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
//#region src/runtime/shared/types.d.ts
|
|
2
|
+
interface ModuleData {
|
|
3
|
+
id: string;
|
|
4
|
+
chunks: string[];
|
|
5
|
+
name: string;
|
|
6
|
+
}
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/runtime/rsc-client-runtime.d.ts
|
|
9
|
+
declare function registerClientComponent(componentFunction: any, id: string, exportName: string): void;
|
|
10
|
+
declare function getClientComponent(id: string): any;
|
|
11
|
+
declare function createClientModuleMap(): Record<string, any>;
|
|
12
|
+
declare class RscClient {
|
|
13
|
+
componentCache: Map<string, any>;
|
|
14
|
+
moduleCache: Map<string, any>;
|
|
15
|
+
inflightRequests: Map<string, Promise<any>>;
|
|
16
|
+
config: {
|
|
17
|
+
maxRetries: number;
|
|
18
|
+
retryDelay: number;
|
|
19
|
+
timeout: number;
|
|
20
|
+
};
|
|
21
|
+
constructor();
|
|
22
|
+
configure(config: Partial<RscClient['config']>): void;
|
|
23
|
+
clearCache(): void;
|
|
24
|
+
fetchServerComponent(componentId: string, props?: any): Promise<any>;
|
|
25
|
+
fetchServerComponentStream(componentId: string, props?: any): Promise<any>;
|
|
26
|
+
buildRequestHeaders(): Record<string, string>;
|
|
27
|
+
fetchWithTimeout(url: string, options: RequestInit): Promise<Response>;
|
|
28
|
+
processRscResponse(response: Response): Promise<any>;
|
|
29
|
+
processRscResponseManually(response: Response): Promise<any>;
|
|
30
|
+
parseRscResponse(rscPayload: string): any;
|
|
31
|
+
reconstructElementFromRscData(elementData: any, modules: Map<string, ModuleData>): any;
|
|
32
|
+
processPropsRecursively(props: any, modules: Map<string, ModuleData>): any;
|
|
33
|
+
}
|
|
34
|
+
declare const rscClient: RscClient;
|
|
35
|
+
declare function RscErrorComponent({
|
|
36
|
+
error,
|
|
37
|
+
details
|
|
38
|
+
}: {
|
|
39
|
+
error: string;
|
|
40
|
+
details?: any;
|
|
41
|
+
}): any;
|
|
42
|
+
declare function createServerComponentWrapper(componentName: string): (props: any) => any;
|
|
43
|
+
declare function fetchServerComponent(componentId: string, props: any): Promise<any>;
|
|
44
|
+
//#endregion
|
|
45
|
+
export { RscErrorComponent, createClientModuleMap, createServerComponentWrapper, fetchServerComponent, getClientComponent, registerClientComponent, rscClient };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{t as e}from"../get-client-component-D83VBqKX.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
|
+
`),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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,r as t,t as n}from"./server-build-D_ZNTgRx.mjs";export{n as ServerComponentBuilder,t as scanDirectory};
|
|
@@ -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(n,r){let i=n,a=this.options.alias||{};for(let[e,r]of Object.entries(a))if(n.startsWith(`${e}/`)||n===e){let a=n.slice(e.length);i=t.join(r,a);break}t.isAbsolute(i)||(i=t.resolve(t.dirname(r),i));let o=[`.tsx`,`.jsx`,`.ts`,`.js`];for(let t of o){let n=`${i}${t}`;if(e.existsSync(n))return n}if(e.existsSync(i))for(let n of o){let r=t.join(i,`index${n}`);if(e.existsSync(r))return r}return`${i}.tsx`}getComponentId(e){return e.replace(/\\/g,`/`).replace(/\.(tsx?|jsx?)$/,``).replace(/[^\w/-]/g,`_`).replace(/^src\//,``)}async rebuildComponent(n){let r=this.getComponentId(t.relative(this.projectRoot,n)),i=await e.promises.readFile(n,`utf-8`),a=this.extractDependencies(i),o={filePath:n,originalCode:i,dependencies:a,hasNodeImports:this.hasNodeImports(i)};this.isServerAction(i)?this.serverActions.set(n,o):this.serverComponents.set(n,o);let s=t.join(this.options.rscDir,`${r}.js`),c=t.join(this.options.outDir,s),l=this.buildCache.get(n),u=(await e.promises.stat(n)).mtimeMs;if(l&&l.timestamp>=u&&JSON.stringify(l.dependencies)===JSON.stringify(a))return await e.promises.writeFile(c,l.code,`utf-8`),await this.updateManifestForComponent(r,n,s),{componentId:r,bundlePath:t.join(this.options.outDir,s),success:!0};let d=t.dirname(c);await e.promises.mkdir(d,{recursive:!0});let f=await this.buildSingleComponent(n,c,!0);return this.buildCache.set(n,{code:f,timestamp:Date.now(),dependencies:a}),await this.updateManifestForComponent(r,n,s),{componentId:r,bundlePath:t.join(this.options.outDir,s),success:!0}}manifestCache=null;async updateManifestForComponent(n,r,i){let a=t.join(this.options.outDir,this.options.manifestPath),o;if(this.manifestCache)o=this.manifestCache;else if(e.existsSync(a)){let t=await e.promises.readFile(a,`utf-8`);o=JSON.parse(t),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=t.join(this.options.outDir,i),l=`file://${t.resolve(this.projectRoot,c)}`;if(s)o.components[n]={id:n,filePath:r,relativePath:t.relative(this.projectRoot,r),bundlePath:i,moduleSpecifier:l,dependencies:s.dependencies,hasNodeImports:s.hasNodeImports};else{let a=await e.promises.readFile(r,`utf-8`);o.components[n]={id:n,filePath:r,relativePath:t.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 e.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 a(n,r){let i=e.readdirSync(n,{withFileTypes:!0});for(let o of i){let i=t.join(n,o.name);if(o.isDirectory())a(i,r);else if(o.isFile()&&/\.(?:tsx?|jsx?)$/.test(o.name)){if(/^(?:robots|sitemap)\.(?:tsx?|jsx?)$/.test(o.name))continue;try{if(r.isServerComponent(i))r.addServerComponent(i);else{let t=e.readFileSync(i,`utf-8`).split(`
|
|
177
|
-
`),n=!1;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";`){n=!0;break}if(t)break}}n&&r.addServerComponent(i)}}catch(e){console.warn(`[server-build] Error checking ${i}:`,e instanceof Error?e.message:e)}}}}function o(r={}){let o=null,s,c=!1;return{name:`rari-server-build`,configResolved(e){s=e.root,c=e.command===`serve`;let t={};if(e.resolve?.alias){let n=e.resolve.alias;Array.isArray(n)?n.forEach(e=>{typeof e.find==`string`&&typeof e.replacement==`string`&&(t[e.find]=e.replacement)}):typeof n==`object`&&Object.entries(n).forEach(([e,n])=>{typeof n==`string`&&(t[e]=n)})}o=new i(s,{...r,alias:t})},buildStart(){if(!o)return;let r=n.env.NODE_ENV===`production`,i=[t.join(s,`dist`,`cache`,`og`),t.join(s,`dist`,`cache`,`images`)];r&&i.push(`/tmp/rari-og-cache`,`/tmp/rari-image-cache`);for(let t of i)try{e.existsSync(t)&&e.rmSync(t,{recursive:!0,force:!0})}catch(e){console.warn(`[rari] Failed to clear cache ${t}:`,e)}let c=t.join(s,`src`);e.existsSync(c)&&a(c,o)},async closeBundle(){if(o){await o.buildServerComponents();try{let{generateRobotsFile:e}=await import(`./robots-generator-
|
|
176
|
+
`+r);for(let{original:e,replacement:t}of o)r=r.replace(e,t);return r}resolveImportPath(n,r){let i=n,a=this.options.alias||{};for(let[e,r]of Object.entries(a))if(n.startsWith(`${e}/`)||n===e){let a=n.slice(e.length);i=t.join(r,a);break}t.isAbsolute(i)||(i=t.resolve(t.dirname(r),i));let o=[`.tsx`,`.jsx`,`.ts`,`.js`];for(let t of o){let n=`${i}${t}`;if(e.existsSync(n))return n}if(e.existsSync(i))for(let n of o){let r=t.join(i,`index${n}`);if(e.existsSync(r))return r}return`${i}.tsx`}getComponentId(e){return e.replace(/\\/g,`/`).replace(/\.(tsx?|jsx?)$/,``).replace(/[^\w/-]/g,`_`).replace(/^src\//,``)}async rebuildComponent(n){let r=this.getComponentId(t.relative(this.projectRoot,n)),i=await e.promises.readFile(n,`utf-8`),a=this.extractDependencies(i),o={filePath:n,originalCode:i,dependencies:a,hasNodeImports:this.hasNodeImports(i)};this.isServerAction(i)?this.serverActions.set(n,o):this.serverComponents.set(n,o);let s=t.join(this.options.rscDir,`${r}.js`),c=t.join(this.options.outDir,s),l=this.buildCache.get(n),u=(await e.promises.stat(n)).mtimeMs;if(l&&l.timestamp>=u&&JSON.stringify(l.dependencies)===JSON.stringify(a))return await e.promises.writeFile(c,l.code,`utf-8`),await this.updateManifestForComponent(r,n,s),{componentId:r,bundlePath:t.join(this.options.outDir,s),success:!0};let d=t.dirname(c);await e.promises.mkdir(d,{recursive:!0});let f=await this.buildSingleComponent(n,c,!0);return this.buildCache.set(n,{code:f,timestamp:Date.now(),dependencies:a}),await this.updateManifestForComponent(r,n,s),{componentId:r,bundlePath:t.join(this.options.outDir,s),success:!0}}manifestCache=null;async updateManifestForComponent(n,r,i){let a=t.join(this.options.outDir,this.options.manifestPath),o;if(this.manifestCache)o=this.manifestCache;else if(e.existsSync(a)){let t=await e.promises.readFile(a,`utf-8`);o=JSON.parse(t),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=t.join(this.options.outDir,i),l=`file://${t.resolve(this.projectRoot,c)}`;if(s)o.components[n]={id:n,filePath:r,relativePath:t.relative(this.projectRoot,r),bundlePath:i,moduleSpecifier:l,dependencies:s.dependencies,hasNodeImports:s.hasNodeImports};else{let a=await e.promises.readFile(r,`utf-8`);o.components[n]={id:n,filePath:r,relativePath:t.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 e.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 a(n,r){let i=e.readdirSync(n,{withFileTypes:!0});for(let o of i){let i=t.join(n,o.name);if(o.isDirectory())a(i,r);else if(o.isFile()&&/\.(?:tsx?|jsx?)$/.test(o.name)){if(/^(?:robots|sitemap)\.(?:tsx?|jsx?)$/.test(o.name)||o.name.endsWith(`.d.ts`))continue;try{if(r.isServerComponent(i))r.addServerComponent(i);else{let t=e.readFileSync(i,`utf-8`).split(`
|
|
177
|
+
`),n=!1;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";`){n=!0;break}if(t)break}}n&&r.addServerComponent(i)}}catch(e){console.warn(`[server-build] Error checking ${i}:`,e instanceof Error?e.message:e)}}}}function o(r={}){let o=null,s,c=!1;return{name:`rari-server-build`,configResolved(e){s=e.root,c=e.command===`serve`;let t={};if(e.resolve?.alias){let n=e.resolve.alias;Array.isArray(n)?n.forEach(e=>{typeof e.find==`string`&&typeof e.replacement==`string`&&(t[e.find]=e.replacement)}):typeof n==`object`&&Object.entries(n).forEach(([e,n])=>{typeof n==`string`&&(t[e]=n)})}o=new i(s,{...r,alias:t})},buildStart(){if(!o)return;let r=n.env.NODE_ENV===`production`,i=[t.join(s,`dist`,`cache`,`og`),t.join(s,`dist`,`cache`,`images`)];r&&i.push(`/tmp/rari-og-cache`,`/tmp/rari-image-cache`);for(let t of i)try{e.existsSync(t)&&e.rmSync(t,{recursive:!0,force:!0})}catch(e){console.warn(`[rari] Failed to clear cache ${t}:`,e)}let c=t.join(s,`src`);e.existsSync(c)&&a(c,o)},async closeBundle(){if(o){await o.buildServerComponents();try{let{generateRobotsFile:e}=await import(`./robots-generator-Bo5MHa-v.mjs`);await e({appDir:t.join(s,`src`,`app`),outDir:t.join(s,`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-BAzhkvmO.mjs`);await e({appDir:t.join(s,`src`,`app`),outDir:t.join(s,`dist`),extensions:[`.ts`,`.tsx`,`.js`,`.jsx`]})}catch(e){console.warn(`[rari] Failed to generate sitemap:`,e)}}},async handleHotUpdate({file:n}){if(!o||!c)return;let r=t.relative(s,n).replace(/\\/g,`/`);if(!(!r.startsWith(`src/`)||!/\.(?:tsx?|jsx?)$/.test(r)))try{if((await e.promises.readFile(n,`utf-8`)).includes(`use client`))return;await o.buildServerComponents()}catch(e){console.error(`[rari] Build: Error rebuilding ${r}:`,e)}}}}export{o as n,a as r,i as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import{promises as e}from"node:fs";import t from"node:path";import{Buffer as n}from"node:buffer";function r(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function i(e){return(typeof e==`string`?new Date(e):e).toISOString()}function a(e){let t=[];for(let n of e)typeof n==`string`?(t.push(` <image:image>`),t.push(` <image:loc>${r(n)}</image:loc>`),t.push(` </image:image>`)):(t.push(` <image:image>`),t.push(` <image:loc>${r(n.loc)}</image:loc>`),n.title&&t.push(` <image:title>${r(n.title)}</image:title>`),n.caption&&t.push(` <image:caption>${r(n.caption)}</image:caption>`),n.geoLocation&&t.push(` <image:geo_location>${r(n.geoLocation)}</image:geo_location>`),n.license&&t.push(` <image:license>${r(n.license)}</image:license>`),t.push(` </image:image>`));return t.join(`
|
|
2
2
|
`)}function o(e){let t=[];for(let n of e){if(t.push(` <video:video>`),t.push(` <video:title>${r(n.title)}</video:title>`),t.push(` <video:thumbnail_loc>${r(n.thumbnail_loc)}</video:thumbnail_loc>`),t.push(` <video:description>${r(n.description)}</video:description>`),n.content_loc&&t.push(` <video:content_loc>${r(n.content_loc)}</video:content_loc>`),n.player_loc&&t.push(` <video:player_loc>${r(n.player_loc)}</video:player_loc>`),n.duration!==void 0&&t.push(` <video:duration>${n.duration}</video:duration>`),n.expiration_date&&t.push(` <video:expiration_date>${r(n.expiration_date)}</video:expiration_date>`),n.rating!==void 0&&t.push(` <video:rating>${n.rating}</video:rating>`),n.view_count!==void 0&&t.push(` <video:view_count>${n.view_count}</video:view_count>`),n.publication_date&&t.push(` <video:publication_date>${r(n.publication_date)}</video:publication_date>`),n.family_friendly!==void 0&&t.push(` <video:family_friendly>${n.family_friendly?`yes`:`no`}</video:family_friendly>`),n.restriction&&t.push(` <video:restriction relationship="${n.restriction.relationship}">${r(n.restriction.content)}</video:restriction>`),n.platform&&t.push(` <video:platform relationship="${n.platform.relationship}">${r(n.platform.content)}</video:platform>`),n.requires_subscription!==void 0&&t.push(` <video:requires_subscription>${n.requires_subscription?`yes`:`no`}</video:requires_subscription>`),n.uploader){let e=n.uploader.info?` info="${r(n.uploader.info)}"`:``;t.push(` <video:uploader${e}>${r(n.uploader.name)}</video:uploader>`)}if(n.live!==void 0&&t.push(` <video:live>${n.live?`yes`:`no`}</video:live>`),n.tag)for(let e of n.tag)t.push(` <video:tag>${r(e)}</video:tag>`);t.push(` </video:video>`)}return t.join(`
|
|
3
3
|
`)}function s(e){let t=e.some(e=>e.images&&e.images.length>0),n=e.some(e=>e.videos&&e.videos.length>0),s=e.some(e=>e.alternates?.languages),c=[`xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"`];t&&c.push(`xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"`),n&&c.push(`xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"`),s&&c.push(`xmlns:xhtml="http://www.w3.org/1999/xhtml"`);let l=[`<?xml version="1.0" encoding="UTF-8"?>`,`<urlset ${c.join(` `)}>`];for(let t of e){if(l.push(` <url>`),l.push(` <loc>${r(t.url)}</loc>`),t.lastModified&&l.push(` <lastmod>${i(t.lastModified)}</lastmod>`),t.changeFrequency&&l.push(` <changefreq>${t.changeFrequency}</changefreq>`),t.priority!==void 0&&l.push(` <priority>${t.priority}</priority>`),t.alternates?.languages)for(let[e,n]of Object.entries(t.alternates.languages))l.push(` <xhtml:link rel="alternate" hreflang="${r(e)}" href="${r(n)}" />`);t.images&&t.images.length>0&&l.push(a(t.images)),t.videos&&t.videos.length>0&&l.push(o(t.videos)),l.push(` </url>`)}return l.push(`</urlset>`),l.join(`
|
|
4
|
-
`)}async function c(n,r=[`.ts`,`.tsx`,`.js`,`.jsx`]){let i=[],a=t.join(n,`sitemap.xml`);try{return await e.access(a),i.push({type:`static`,path:a}),i}catch{}for(let a of r){let r=t.join(n,`sitemap${a}`);try{return await e.access(r),i.push({type:`dynamic`,path:r}),i}catch{}}return i}async function l(r){let{appDir:i,extensions:a}=r,o=await c(i,a);if(o.length===0)return!1;await e.mkdir(r.outDir,{recursive:!0});let l=
|
|
4
|
+
`)}async function c(n,r=[`.ts`,`.tsx`,`.js`,`.jsx`]){let i=[],a=t.join(n,`sitemap.xml`);try{return await e.access(a),i.push({type:`static`,path:a}),i}catch{}for(let a of r){let r=t.join(n,`sitemap${a}`);try{return await e.access(r),i.push({type:`dynamic`,path:r}),i}catch{}}return i}async function l(r){let{appDir:i,extensions:a}=r,o=await c(i,a);if(o.length===0)return!1;await e.mkdir(r.outDir,{recursive:!0});let l=o[0];if(l.type===`static`){let n=t.join(r.outDir,`sitemap.xml`);return await e.copyFile(l.path,n),!0}try{let{build:i}=await import(`rolldown`),a=await e.readFile(l.path,`utf-8`),o=`\0virtual:sitemap`,c=await i({input:o,external:[`rari`],platform:`node`,write:!1,output:{format:`esm`,codeSplitting:!1},plugins:[{name:`virtual-sitemap`,resolveId(e){return e===o?e:e.startsWith(`.`)?t.resolve(t.dirname(l.path),e):null},load(e){if(e===o){let e=t.extname(l.path).slice(1),n;switch(e){case`ts`:n=`ts`;break;case`tsx`:n=`tsx`;break;case`js`:case`mjs`:case`cjs`:n=`js`;break;case`jsx`:n=`jsx`;break;case`json`:n=`json`;break;default:throw Error(`Unsupported sitemap file extension: ".${e}". Allowed extensions are: .ts, .tsx, .js, .jsx, .mjs, .cjs, .json`)}return{code:a,moduleType:n}}return null}}]});if(!c.output||c.output.length===0)throw Error(`Failed to build sitemap module`);let u=c.output.find(e=>e.type===`chunk`&&e.isEntry)||c.output.find(e=>e.type===`chunk`);if(!u||u.type!==`chunk`)throw Error(`No chunk output found in sitemap build result`);let d=u.code,f=await import(`data:text/javascript;base64,${n.from(d).toString(`base64`)}`);if(typeof f.generateSitemaps==`function`){let n=await f.generateSitemaps(),i=t.join(r.outDir,`sitemap`);await e.mkdir(i,{recursive:!0});for(let{id:i}of n){let n;n=typeof f.default==`function`?await f.default({id:String(i)}):f.default;let a=s(n),o=t.join(r.outDir,`sitemap/${i}.xml`);await e.writeFile(o,a)}}else{let n=s(typeof f.default==`function`?await f.default():f.default),i=t.join(r.outDir,`sitemap.xml`);await e.writeFile(i,n)}return!0}catch(e){return console.error(`[rari] Failed to build/execute sitemap file:`,e),!1}}export{l as generateSitemapFiles};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{styleText as e}from"node:util";function t(t){console.warn(`${e(`blue`,`info`)} ${t}`)}function n(t){console.warn(`${e(`green`,`✓`)} ${t}`)}function r(t){console.error(`${e(`red`,`✗`)} ${t}`)}function i(t){console.warn(`${e(`yellow`,`⚠`)} ${t}`)}function a(e,t=22){let n=e.trim();if(n.includes(`||`))return n.split(`||`).map(e=>e.trim()).some(e=>a(e,t));let r=n.split(/\s+(?:&&\s+)?/).filter(e=>e&&e!==`&&`);if(r.length>1){for(let e of r){let n=o(e);if(n!==null&&n>=t)return!0}return r.every(e=>s(e,t))}return c(n,t)}function o(e){let t=e.match(/^>=?\s*(\d+)/);return t?Number.parseInt(t[1],10):null}function s(e,t){let n=null;return n=e.match(/^<=?\s*(\d+)/),n?t<=Number.parseInt(n[1],10):c(e,t)}function c(e,t){let n=null;return/^<=?\s*\d+/.test(e)?!1:(n=e.match(/^>=?\s*(\d+)\.(\d+)\.(\d+)/),n||(n=e.match(/^=?\s*(\d+)\.(\d+)\.(\d+)/),n)||(n=e.match(/^\^\s*(\d+)\.(\d+)\.(\d+)/),n)||(n=e.match(/^~\s*(\d+)\.(\d+)\.(\d+)/),n)||(n=e.match(/^(?:>=?|<=?|[=~^])?\s*(\d+)\.(\d+)/),n)||(n=e.match(/^(\d+)\.(?:x|\*)/i),n)||(n=e.match(/^(?:>=?|[=~^])\s*(\d+)(?:\s|$)/),n)||(n=e.match(/^(\d+)$/),n)?Number.parseInt(n[1],10)>=t:!1)}export{
|
|
1
|
+
import{styleText as e}from"node:util";function t(t){console.warn(`${e(`blue`,`info`)} ${t}`)}function n(t){console.warn(`${e(`green`,`✓`)} ${t}`)}function r(t){console.error(`${e(`red`,`✗`)} ${t}`)}function i(t){console.warn(`${e(`yellow`,`⚠`)} ${t}`)}function a(e,t=22){let n=e.trim();if(n.includes(`||`))return n.split(`||`).map(e=>e.trim()).some(e=>a(e,t));let r=n.split(/\s+(?:&&\s+)?/).filter(e=>e&&e!==`&&`);if(r.length>1){for(let e of r){let n=o(e);if(n!==null&&n>=t)return!0}return r.every(e=>s(e,t))}return c(n,t)}function o(e){let t=e.match(/^>=?\s*(\d+)/);return t?Number.parseInt(t[1],10):null}function s(e,t){let n=null;return n=e.match(/^<=?\s*(\d+)/),n?t<=Number.parseInt(n[1],10):c(e,t)}function c(e,t){let n=null;return/^<=?\s*\d+/.test(e)?!1:(n=e.match(/^>=?\s*(\d+)\.(\d+)\.(\d+)/),n||(n=e.match(/^=?\s*(\d+)\.(\d+)\.(\d+)/),n)||(n=e.match(/^\^\s*(\d+)\.(\d+)\.(\d+)/),n)||(n=e.match(/^~\s*(\d+)\.(\d+)\.(\d+)/),n)||(n=e.match(/^(?:>=?|<=?|[=~^])?\s*(\d+)\.(\d+)/),n)||(n=e.match(/^(\d+)\.(?:x|\*)/i),n)||(n=e.match(/^(?:>=?|[=~^])\s*(\d+)(?:\s|$)/),n)||(n=e.match(/^(\d+)$/),n)?Number.parseInt(n[1],10)>=t:!1)}export{t as a,r as i,i as n,n as r,a as t};
|