rari 0.8.11 → 0.8.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +1 -1
- package/dist/client.d.mts +1 -1
- package/dist/client.mjs +1 -1
- package/dist/image/index.mjs +1 -1
- package/dist/{vite-qqjC7uLL.d.mts → index-Ek-rRSpB.d.mts} +3 -139
- package/dist/index.d.mts +5 -2
- package/dist/index.mjs +1 -1
- package/dist/mdx.mjs +1 -1
- package/dist/proxy/RariRequest.d.mts +40 -0
- package/dist/{RariRequest-B_UvFfpJ.mjs → proxy/RariRequest.mjs} +1 -1
- package/dist/proxy/runtime-executor.d.mts +1 -1
- package/dist/proxy/runtime-executor.mjs +1 -1
- package/dist/{railway-DZB8P0Gi.mjs → railway-B__dJ7bJ.mjs} +1 -1
- package/dist/{render-vMFW4sOG.mjs → render-LdidKjWk.mjs} +1 -1
- package/dist/rolldown-runtime-DR3Ue2cl.mjs +1 -0
- package/dist/routes-DbsqVAaM.mjs +1 -0
- package/dist/runtime/AppRouterProvider.d.mts +26 -0
- package/dist/runtime/AppRouterProvider.mjs +7 -0
- package/dist/runtime/LoadingErrorBoundary.d.mts +12 -0
- package/dist/runtime/LoadingErrorBoundary.mjs +1 -0
- package/dist/runtime/entry-client.mjs +1 -1
- package/dist/runtime/react-server-dom-shim.mjs +1 -1
- package/dist/runtime/rsc-client-runtime.mjs +1 -1
- package/dist/{server-build-D_ZNTgRx.mjs → server-build-C64b2Z-d.mjs} +10 -10
- package/dist/{server-config-D9oGBzhI.d.mts → server-config-5RHHggaf.d.mts} +1 -1
- package/dist/types-BIZmYbNs.d.mts +97 -0
- package/dist/vite-CfH7EIl7.mjs +72 -0
- package/dist/vite.d.mts +10 -3
- package/dist/vite.mjs +1 -1
- package/package.json +7 -7
- package/dist/RariRequest-BoO3yTuk.mjs +0 -1
- package/dist/react-server-dom-shim-Bvsz8jKC.mjs +0 -1
- package/dist/routes-9ltViohI.mjs +0 -1
- package/dist/routes-KDxjyeNA.mjs +0 -1
- package/dist/server-build-CJGDvVJe.mjs +0 -1
- package/dist/vite-CllVeRdC.mjs +0 -72
- /package/dist/{constants-DZAg-dr0.mjs → constants-CmqZuM5B.mjs} +0 -0
- /package/dist/{get-client-component-D83VBqKX.mjs → get-client-component-B2SS0Ben.mjs} +0 -0
- /package/dist/{robots-generator-Bo5MHa-v.mjs → robots-generator-CuKrsgKO.mjs} +0 -0
- /package/dist/{runtime-client-Jllyf7Ly.mjs → runtime-client-Bg4V1Ksp.mjs} +0 -0
- /package/dist/{sitemap-generator-BAzhkvmO.mjs → sitemap-generator-B6H3XwXt.mjs} +0 -0
- /package/dist/{utils-CvELqhML-D2DZ7WLt.mjs → utils-CvELqhML-CLd5cK7j.mjs} +0 -0
package/dist/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import{getBinaryPath as e,getInstallationInstructions as t}from"./platform.mjs";import{existsSync as n,readFileSync as r}from"node:fs";import{resolve as i}from"node:path";import a from"node:process";import{spawn as o}from"node:child_process";import{styleText as s}from"node:util";function c(e){console.warn(`${s(`blue`,`info`)} ${e}`)}function l(e){console.warn(`${s(`green`,`✓`)} ${e}`)}function u(e){console.error(`${s(`red`,`✗`)} ${e}`)}function d(e){console.warn(`${s(`yellow`,`⚠`)} ${e}`)}function f(){let e=i(a.cwd(),`.env`);if(n(e)){let t=r(e,`utf-8`);for(let e of t.split(`
|
|
3
|
-
`)){let t=e.trim();if(!t||t.startsWith(`#`))continue;let n=t.match(/^([^=]+)=(.*)$/);if(n){let[,e,t]=n,r=e.trim(),i=t.trim();(i.startsWith(`"`)&&i.endsWith(`"`)||i.startsWith(`'`)&&i.endsWith(`'`))&&(i=i.slice(1,-1)),a.env[r]||(a.env[r]=i)}}}}f();const[,,p,...m]=a.argv;function h(){let e=a.cwd(),t=i(`/`),o=0;for(;e!==t&&o<20;){if(o++,n(i(e,`pnpm-lock.yaml`)))return`pnpm`;if(n(i(e,`yarn.lock`)))return`yarn`;if(n(i(e,`bun.lockb`)))return`bun`;if(n(i(e,`package-lock.json`)))return`npm`;try{let t=i(e,`package.json`);if(n(t)){let e=JSON.parse(r(t,`utf-8`));if(e.packageManager?.startsWith(`pnpm`))return`pnpm`;if(e.packageManager?.startsWith(`yarn`))return`yarn`;if(e.packageManager?.startsWith(`bun`))return`bun`;if(e.packageManager?.startsWith(`npm`))return`npm`}}catch{}let t=i(e,`..`);if(t===e)break;e=t}return`npm`}function g(){let e=h(),t=a.platform===`win32`;switch(e){case`bun`:return t?`bun.cmd`:`bun`;case`pnpm`:return t?`pnpm.cmd`:`pnpm`;case`yarn`:return t?`yarn.cmd`:`yarn`;default:return t?`npx.cmd`:`npx`}}function _(e,t,n={}){if(e===`npx`){let e=g();if(e.includes(`bun`))return o(e,[`x`,...t],n);if(e.includes(`pnpm`))return o(e,[`exec`,...t],n);if(e.includes(`yarn`))return o(e,[`dlx`,...t],n)}return a.platform===`win32`&&e===`npx`?o(`npx.cmd`,t,n):o(e,t,n)}function v(e){if(e instanceof Error)return e.message;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function y(){return!!(a.env.RAILWAY_ENVIRONMENT||a.env.RAILWAY_PROJECT_ID||a.env.RAILWAY_SERVICE_ID)}function b(){return!!(a.env.RENDER||a.env.RENDER_SERVICE_ID||a.env.RENDER_SERVICE_NAME)}function x(){return y()||b()}function S(){return y()?`Railway`:b()?`Render`:`local`}function C(){return{port:a.env.PORT||a.env.RSC_PORT||`3000`,mode:a.env.NODE_ENV||`production`,host:x()?`0.0.0.0`:`127.0.0.1`}}async function w(){let{existsSync:e,rmSync:t}=await import(`node:fs`),{resolve:n}=await import(`node:path`),r=n(a.cwd(),`dist`);e(r)&&(c(`Cleaning dist folder...`),t(r,{recursive:!0,force:!0})),c(`Type checking...`);let i=_(`npx`,[`tsgo`],{stdio:`inherit`,cwd:a.cwd()});await new Promise((e,t)=>{i.on(`exit`,n=>{n===0?(l(`Type check passed`),e()):(u(`Type check failed with code ${n}`),t(Error(`Type check failed with code ${n}`)))}),i.on(`error`,t)}),c(`Building for production...`);let o=_(`npx`,[`vite`,`build`],{stdio:`inherit`,cwd:a.cwd()});await new Promise((e,t)=>{o.on(`exit`,n=>{n===0?(l(`Build complete`),e()):(u(`Build failed with code ${n}`),t(Error(`Build failed with code ${n}`)))}),o.on(`error`,t)}),await T()}async function T(){if(n(i(a.cwd(),`dist`,`server`,`image.json`))&&n(i(a.cwd(),`public`)))try{let t=o(e(),[`optimize-images`],{stdio:`inherit`,cwd:a.cwd(),shell:!1});await new Promise(e=>{t.on(`exit`,t=>{t===0||d(`Image pre-optimization exited with code ${t}`),e()}),t.on(`error`,t=>{d(`Image pre-optimization error: ${v(t)}`),e()})})}catch(e){d(`Could not pre-optimize images: ${v(e)}`)}}async function E(){let{existsSync:e}=await import(`node:fs`),{resolve:t}=await import(`node:path`);if(!e(t(a.cwd(),`dist`))){c(`First run detected - building project...`);let e=_(`npx`,[`vite`,`build`,`--mode`,`development`],{stdio:`inherit`,cwd:a.cwd()});await new Promise((t,n)=>{e.on(`exit`,e=>{e===0?(l(`Initial build complete`),t()):(u(`Build failed with code ${e}`),n(Error(`Build failed with code ${e}`)))}),e.on(`error`,n)})}c(`Starting Vite dev server...`);let n=_(`npx`,[`vite`],{stdio:`inherit`,cwd:a.cwd()}),r=()=>{c(`Shutting down dev server...`),n.kill(`SIGTERM`)};return a.on(`SIGINT`,r),a.on(`SIGTERM`,r),n.on(`error`,e=>{u(`Failed to start Vite: ${e.message}`),a.exit(1)}),n.on(`exit`,e=>{e!==0&&e!==null&&(u(`Vite exited with code ${e}`),a.exit(e))}),new Promise(()=>{})}async function D(){let n;try{n=e()}catch{u(`Failed to obtain rari binary`),u(t()),a.exit(1)}let{port:r,mode:i,host:s}=C();if(x()){let e=S();c(`${e} environment detected`),c(`Starting rari server for ${e} deployment...`),c(`Mode: ${i}, Host: ${s}, Port: ${r}`),c(`using binary: ${n}`)}let d=o(n,[`--mode`,i,`--port`,r,`--host`,s],{stdio:`inherit`,cwd:a.cwd(),env:{...a.env,RUST_LOG:a.env.RUST_LOG||`error`}}),f=()=>{c(`shutting down...`),d.kill(`SIGTERM`)};return a.on(`SIGINT`,f),a.on(`SIGTERM`,f),d.on(`error`,e=>{u(`Failed to start rari server: ${e.message}`),e.message.includes(`ENOENT`)&&u(`Binary not found. Please ensure rari is properly installed.`),a.exit(1)}),d.on(`exit`,(e,t)=>{t?c(`server stopped by signal ${t}`):e===0?l(`server stopped successfully`):(u(`server exited with code ${e}`),a.exit(e||1))}),new Promise(()=>{})}async function O(){c(`Setting up Railway deployment...`),x()&&(u(`Already running in ${S()} environment. Use "rari start" instead.`),a.exit(1));let{createRailwayDeployment:e}=await import(`./railway-
|
|
3
|
+
`)){let t=e.trim();if(!t||t.startsWith(`#`))continue;let n=t.match(/^([^=]+)=(.*)$/);if(n){let[,e,t]=n,r=e.trim(),i=t.trim();(i.startsWith(`"`)&&i.endsWith(`"`)||i.startsWith(`'`)&&i.endsWith(`'`))&&(i=i.slice(1,-1)),a.env[r]||(a.env[r]=i)}}}}f();const[,,p,...m]=a.argv;function h(){let e=a.cwd(),t=i(`/`),o=0;for(;e!==t&&o<20;){if(o++,n(i(e,`pnpm-lock.yaml`)))return`pnpm`;if(n(i(e,`yarn.lock`)))return`yarn`;if(n(i(e,`bun.lockb`)))return`bun`;if(n(i(e,`package-lock.json`)))return`npm`;try{let t=i(e,`package.json`);if(n(t)){let e=JSON.parse(r(t,`utf-8`));if(e.packageManager?.startsWith(`pnpm`))return`pnpm`;if(e.packageManager?.startsWith(`yarn`))return`yarn`;if(e.packageManager?.startsWith(`bun`))return`bun`;if(e.packageManager?.startsWith(`npm`))return`npm`}}catch{}let t=i(e,`..`);if(t===e)break;e=t}return`npm`}function g(){let e=h(),t=a.platform===`win32`;switch(e){case`bun`:return t?`bun.cmd`:`bun`;case`pnpm`:return t?`pnpm.cmd`:`pnpm`;case`yarn`:return t?`yarn.cmd`:`yarn`;default:return t?`npx.cmd`:`npx`}}function _(e,t,n={}){if(e===`npx`){let e=g();if(e.includes(`bun`))return o(e,[`x`,...t],n);if(e.includes(`pnpm`))return o(e,[`exec`,...t],n);if(e.includes(`yarn`))return o(e,[`dlx`,...t],n)}return a.platform===`win32`&&e===`npx`?o(`npx.cmd`,t,n):o(e,t,n)}function v(e){if(e instanceof Error)return e.message;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function y(){return!!(a.env.RAILWAY_ENVIRONMENT||a.env.RAILWAY_PROJECT_ID||a.env.RAILWAY_SERVICE_ID)}function b(){return!!(a.env.RENDER||a.env.RENDER_SERVICE_ID||a.env.RENDER_SERVICE_NAME)}function x(){return y()||b()}function S(){return y()?`Railway`:b()?`Render`:`local`}function C(){return{port:a.env.PORT||a.env.RSC_PORT||`3000`,mode:a.env.NODE_ENV||`production`,host:x()?`0.0.0.0`:`127.0.0.1`}}async function w(){let{existsSync:e,rmSync:t}=await import(`node:fs`),{resolve:n}=await import(`node:path`),r=n(a.cwd(),`dist`);e(r)&&(c(`Cleaning dist folder...`),t(r,{recursive:!0,force:!0})),c(`Type checking...`);let i=_(`npx`,[`tsgo`],{stdio:`inherit`,cwd:a.cwd()});await new Promise((e,t)=>{i.on(`exit`,n=>{n===0?(l(`Type check passed`),e()):(u(`Type check failed with code ${n}`),t(Error(`Type check failed with code ${n}`)))}),i.on(`error`,t)}),c(`Building for production...`);let o=_(`npx`,[`vite`,`build`],{stdio:`inherit`,cwd:a.cwd()});await new Promise((e,t)=>{o.on(`exit`,n=>{n===0?(l(`Build complete`),e()):(u(`Build failed with code ${n}`),t(Error(`Build failed with code ${n}`)))}),o.on(`error`,t)}),await T()}async function T(){if(n(i(a.cwd(),`dist`,`server`,`image.json`))&&n(i(a.cwd(),`public`)))try{let t=o(e(),[`optimize-images`],{stdio:`inherit`,cwd:a.cwd(),shell:!1});await new Promise(e=>{t.on(`exit`,t=>{t===0||d(`Image pre-optimization exited with code ${t}`),e()}),t.on(`error`,t=>{d(`Image pre-optimization error: ${v(t)}`),e()})})}catch(e){d(`Could not pre-optimize images: ${v(e)}`)}}async function E(){let{existsSync:e}=await import(`node:fs`),{resolve:t}=await import(`node:path`);if(!e(t(a.cwd(),`dist`))){c(`First run detected - building project...`);let e=_(`npx`,[`vite`,`build`,`--mode`,`development`],{stdio:`inherit`,cwd:a.cwd()});await new Promise((t,n)=>{e.on(`exit`,e=>{e===0?(l(`Initial build complete`),t()):(u(`Build failed with code ${e}`),n(Error(`Build failed with code ${e}`)))}),e.on(`error`,n)})}c(`Starting Vite dev server...`);let n=_(`npx`,[`vite`],{stdio:`inherit`,cwd:a.cwd()}),r=()=>{c(`Shutting down dev server...`),n.kill(`SIGTERM`)};return a.on(`SIGINT`,r),a.on(`SIGTERM`,r),n.on(`error`,e=>{u(`Failed to start Vite: ${e.message}`),a.exit(1)}),n.on(`exit`,e=>{e!==0&&e!==null&&(u(`Vite exited with code ${e}`),a.exit(e))}),new Promise(()=>{})}async function D(){let n;try{n=e()}catch{u(`Failed to obtain rari binary`),u(t()),a.exit(1)}let{port:r,mode:i,host:s}=C();if(x()){let e=S();c(`${e} environment detected`),c(`Starting rari server for ${e} deployment...`),c(`Mode: ${i}, Host: ${s}, Port: ${r}`),c(`using binary: ${n}`)}let d=o(n,[`--mode`,i,`--port`,r,`--host`,s],{stdio:`inherit`,cwd:a.cwd(),env:{...a.env,RUST_LOG:a.env.RUST_LOG||`error`}}),f=()=>{c(`shutting down...`),d.kill(`SIGTERM`)};return a.on(`SIGINT`,f),a.on(`SIGTERM`,f),d.on(`error`,e=>{u(`Failed to start rari server: ${e.message}`),e.message.includes(`ENOENT`)&&u(`Binary not found. Please ensure rari is properly installed.`),a.exit(1)}),d.on(`exit`,(e,t)=>{t?c(`server stopped by signal ${t}`):e===0?l(`server stopped successfully`):(u(`server exited with code ${e}`),a.exit(e||1))}),new Promise(()=>{})}async function O(){c(`Setting up Railway deployment...`),x()&&(u(`Already running in ${S()} environment. Use "rari start" instead.`),a.exit(1));let{createRailwayDeployment:e}=await import(`./railway-B__dJ7bJ.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-LdidKjWk.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-5RHHggaf.mjs";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { Component, ErrorInfo, ReactNode } from "react";
|
|
4
4
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
package/dist/client.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as e,c as t,d as n,f as r,g as i,h as a,i as o,l as s,m as c,n as l,o as u,p as d,r as f,s as p,t as m,u as h}from"./runtime-client-Jllyf7Ly.mjs";import{Component as g,useEffect as _,useRef as v,useState as y}from"react";import{Fragment as b,jsx as x,jsxs as S}from"react/jsx-runtime";function C(e,t,n={}){let r=null,i=0,a=0,o=null,s=null,{leading:c=!1,trailing:l=!0,maxWait:u}=n;function d(t){let n=o,r=s;return o=null,s=null,a=t,e.apply(r,n)}function f(e){let n=e-i,r=e-a;return i===0||n>=t||n<0||u!==void 0&&r>=u}function p(){let e=Date.now();if(f(e))return h(e);let n=e-i,o=e-a,s=t-n,c=u===void 0?1/0:u-o,l=Math.min(s,c);r=setTimeout(p,l)}function m(e){return a=e,r=setTimeout(p,t),c?d(e):void 0}function h(e){if(r=null,l&&o)return d(e);o=null,s=null}function g(){r!==null&&clearTimeout(r),a=0,o=null,i=0,s=null,r=null}function _(){return r===null?void 0:h(Date.now())}function v(){return r!==null}function y(...e){let n=Date.now(),a=f(n);if(o=e,s=this,i=n,a){if(r===null)return m(i);if(u!==void 0)return r=setTimeout(p,t),d(i)}r===null&&(r=setTimeout(p,t))}return y.cancel=g,y.flush=_,y.pending=v,y}function w(e,t){if(e instanceof Error&&e.name===`AbortError`)return{type:`abort`,message:`Navigation was cancelled`,originalError:e,url:t,timestamp:Date.now(),retryable:!1};if(e instanceof Error&&e.message.includes(`timeout`))return{type:`timeout`,message:`Navigation request timed out`,originalError:e,url:t,timestamp:Date.now(),retryable:!0};if(e instanceof Error&&`status`in e){let n=e.status;return n===404?{type:`not-found`,message:`Page not found`,originalError:e,statusCode:n,url:t,timestamp:Date.now(),retryable:!1}:n>=500?{type:`server-error`,message:`Server error: ${n}`,originalError:e,statusCode:n,url:t,timestamp:Date.now(),retryable:!0}:{type:`fetch-error`,message:`HTTP error: ${n}`,originalError:e,statusCode:n,url:t,timestamp:Date.now(),retryable:n>=500}}return e instanceof TypeError&&e.message.includes(`fetch`)?{type:`network-error`,message:`Network error - check your connection`,originalError:e,url:t,timestamp:Date.now(),retryable:!0}:e instanceof SyntaxError||e instanceof Error&&e.message.includes(`parse`)?{type:`parse-error`,message:`Failed to parse server response`,originalError:e instanceof Error?e:void 0,url:t,timestamp:Date.now(),retryable:!1}:{type:`fetch-error`,message:e instanceof Error?e.message:`Unknown error occurred`,originalError:e instanceof Error?e:void 0,url:t,timestamp:Date.now(),retryable:!1}}var T=class{options;retryCount;constructor(e={}){this.options={timeout:e.timeout??1e4,maxRetries:e.maxRetries??3,onError:e.onError??(()=>{}),onRetry:e.onRetry??(()=>{})},this.retryCount=new Map}handleError(e,t){let n=w(e,t);return this.options.onError(n),console.error(`[rari] Navigation:`,n.type,n.message,{url:n.url,statusCode:n.statusCode,retryable:n.retryable}),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`rari:navigation-error`,{detail:n})),n}canRetry(e,t){return e.retryable?(this.retryCount.get(t)??0)<this.options.maxRetries:!1}incrementRetry(e){let t=(this.retryCount.get(e)??0)+1;return this.retryCount.set(e,t),this.options.onRetry(t,{type:`fetch-error`,message:`Retry attempt ${t}`,url:e,timestamp:Date.now(),retryable:!0}),t}resetRetry(e){this.retryCount.delete(e)}getRetryCount(e){return this.retryCount.get(e)??0}clearRetries(){this.retryCount.clear()}};function E(e){if(!e||e===`/`)return`/`;let t=e;for(;t.endsWith(`/`)&&t.length>1;)t=t.slice(0,-1);return t.startsWith(`/`)||(t=`/${t}`),t}function D(e,t){try{return new URL(e,t||window.location.origin).origin!==(t||window.location.origin)}catch{return!1}}function O(e){try{let t=new URL(e,window.location.origin);return t.pathname+t.hash}catch{return e}}function k({error:e,onRetry:t,onReload:n,onDismiss:r,retryCount:i=0,maxRetries:a=3}){let o=e.retryable&&i<a;return x(`div`,{style:{position:`fixed`,top:0,left:0,right:0,bottom:0,background:`rgba(0, 0, 0, 0.5)`,display:`flex`,alignItems:`center`,justifyContent:`center`,zIndex:1e4,padding:`20px`},onClick:e=>{e.target===e.currentTarget&&r&&r()},children:S(`div`,{style:{background:`white`,borderRadius:`8px`,padding:`24px`,maxWidth:`500px`,width:`100%`,boxShadow:`0 4px 12px rgba(0, 0, 0, 0.15)`},onClick:e=>e.stopPropagation(),children:[S(`div`,{style:{display:`flex`,alignItems:`center`,gap:`12px`,marginBottom:`16px`},children:[x(`span`,{style:{fontSize:`32px`},children:(()=>{switch(e.type){case`timeout`:return`⏱️`;case`network-error`:return`📡`;case`not-found`:return`🔍`;case`server-error`:return`⚠️`;case`parse-error`:return`📄`;case`abort`:return`🚫`;default:return`❌`}})()}),x(`h2`,{style:{margin:0,fontSize:`20px`,fontWeight:`600`,color:`#1f2937`},children:`Navigation Error`})]}),x(`p`,{style:{margin:`0 0 16px 0`,fontSize:`15px`,lineHeight:`1.5`,color:`#4b5563`},children:(()=>{switch(e.type){case`timeout`:return`The page took too long to load. Please try again.`;case`network-error`:return`Unable to connect to the server. Please check your internet connection.`;case`not-found`:return`The page you're looking for doesn't exist.`;case`server-error`:return`The server encountered an error. Please try again in a moment.`;case`parse-error`:return`Unable to load the page content. Please try reloading.`;case`abort`:return`Navigation was cancelled.`;default:return e.message||`An unexpected error occurred.`}})()}),e.url&&S(`details`,{style:{marginBottom:`16px`,fontSize:`13px`,color:`#6b7280`},children:[x(`summary`,{style:{cursor:`pointer`,userSelect:`none`,marginBottom:`8px`},children:`Technical details`}),S(`div`,{style:{padding:`12px`,background:`#f9fafb`,borderRadius:`4px`,fontFamily:`monospace`,fontSize:`12px`,wordBreak:`break-all`},children:[S(`div`,{style:{marginBottom:`4px`},children:[x(`strong`,{children:`URL:`}),` `,e.url]}),e.statusCode&&S(`div`,{style:{marginBottom:`4px`},children:[x(`strong`,{children:`Status:`}),` `,e.statusCode]}),S(`div`,{style:{marginBottom:`4px`},children:[x(`strong`,{children:`Type:`}),` `,e.type]}),e.originalError&&S(`div`,{children:[x(`strong`,{children:`Error:`}),` `,e.originalError.message]})]})]}),o&&i>0&&S(`div`,{style:{marginBottom:`16px`,padding:`8px 12px`,background:`#fef3c7`,border:`1px solid #fbbf24`,borderRadius:`4px`,fontSize:`13px`,color:`#92400e`},children:[`Retry attempt`,` `,i,` `,`of`,` `,a]}),S(`div`,{style:{display:`flex`,gap:`8px`,flexWrap:`wrap`},children:[o&&t&&x(`button`,{onClick:t,type:`button`,style:{flex:1,minWidth:`120px`,padding:`10px 16px`,background:`#3b82f6`,color:`white`,border:`none`,borderRadius:`6px`,fontSize:`14px`,fontWeight:`500`,cursor:`pointer`,transition:`background 0.2s`},onMouseEnter:e=>{e.currentTarget.style.background=`#2563eb`},onMouseLeave:e=>{e.currentTarget.style.background=`#3b82f6`},children:`Try Again`}),n&&x(`button`,{onClick:n,type:`button`,style:{flex:1,minWidth:`120px`,padding:`10px 16px`,background:`#6b7280`,color:`white`,border:`none`,borderRadius:`6px`,fontSize:`14px`,fontWeight:`500`,cursor:`pointer`,transition:`background 0.2s`},onMouseEnter:e=>{e.currentTarget.style.background=`#4b5563`},onMouseLeave:e=>{e.currentTarget.style.background=`#6b7280`},children:`Reload Page`}),r&&x(`button`,{onClick:r,type:`button`,style:{flex:1,minWidth:`120px`,padding:`10px 16px`,background:`transparent`,color:`#6b7280`,border:`1px solid #d1d5db`,borderRadius:`6px`,fontSize:`14px`,fontWeight:`500`,cursor:`pointer`,transition:`all 0.2s`},onMouseEnter:e=>{e.currentTarget.style.background=`#f9fafb`,e.currentTarget.style.borderColor=`#9ca3af`},onMouseLeave:e=>{e.currentTarget.style.background=`transparent`,e.currentTarget.style.borderColor=`#d1d5db`},children:`Dismiss`})]}),x(`p`,{style:{marginTop:`16px`,marginBottom:0,fontSize:`12px`,color:`#9ca3af`,textAlign:`center`},children:`Your current page is still available below this message`})]})})}const A=new class{cache=new Map;pendingRequests=new Map;async get(e){let t=this.cache.get(e);if(t)return t;let n=this.pendingRequests.get(e);if(n)return n;let r=this.fetchRouteInfo(e);this.pendingRequests.set(e,r);try{let t=await r;return this.cache.set(e,t),t}finally{this.pendingRequests.delete(e)}}async fetchRouteInfo(e){let t={path:e},n=await fetch(`/_rari/route-info`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json();throw Error(e.error||`Failed to fetch route info`)}return n.json()}clear(){this.cache.clear(),this.pendingRequests.clear()}invalidate(e){this.cache.delete(e)}};if(typeof window<`u`){let e=window[`~rari`]||{};window[`~rari`]||(window[`~rari`]=e),e.routeInfoCache=A}var j=class{stateHistory;routeAccessOrder;maxHistorySize;scrollableSelector;constructor(e={}){this.stateHistory=new Map,this.routeAccessOrder=[],this.maxHistorySize=e.maxHistorySize||50,this.scrollableSelector=e.scrollableSelector||`[data-scrollable], .scrollable, [style*="overflow"]`}captureState(e){let t={scrollPositions:this.captureScrollPositions(),formData:this.captureFormData(),focusedElement:this.captureFocusedElement()};return this.storeState(e,t),t}captureScrollPositions(){let e=new Map;try{e.set(`window`,{x:window.scrollX,y:window.scrollY,element:`window`}),document.querySelectorAll(this.scrollableSelector).forEach((t,n)=>{if(t instanceof HTMLElement){let r=t.id||`scrollable-${n}`;(t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth)&&e.set(r,{x:t.scrollLeft,y:t.scrollTop,element:r})}})}catch{}return e}captureFormData(){let e=new Map;try{document.querySelectorAll(`form`).forEach((t,n)=>{let r=t.id||t.name||`form-${n}`,i=new FormData(t);i.entries().next().done||e.set(r,i)})}catch{}return e}captureFocusedElement(){try{let e=document.activeElement;if(e&&e!==document.body){if(e.id)return`#${e.id}`;if((e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&e.name)return`[name="${e.name}"]`}}catch{}return null}storeState(e,t){let n=this.routeAccessOrder.indexOf(e);for(n!==-1&&this.routeAccessOrder.splice(n,1),this.routeAccessOrder.push(e),this.stateHistory.set(e,t);this.routeAccessOrder.length>this.maxHistorySize;){let e=this.routeAccessOrder.shift();e&&this.stateHistory.delete(e)}}getHistorySize(){return this.stateHistory.size}hasState(e){return this.stateHistory.has(e)}getState(e){return this.stateHistory.get(e)}clearAll(){this.stateHistory.clear(),this.routeAccessOrder=[]}clearState(e){this.stateHistory.delete(e);let t=this.routeAccessOrder.indexOf(e);t!==-1&&this.routeAccessOrder.splice(t,1)}restoreState(e){let t=this.stateHistory.get(e);if(!t)return!1;let n=!0;return this.restoreScrollPositions(t.scrollPositions)||(n=!1),this.restoreFormData(t.formData)||(n=!1),t.focusedElement&&this.restoreFocus(t.focusedElement),n}restoreScrollPositions(e){let t=!0;try{e.forEach((e,n)=>{try{if(n===`window`)window.scrollTo(e.x,e.y);else{let r=document.getElementById(n)||document.querySelector(`[data-scrollable-id="${n}"]`);r instanceof HTMLElement?(r.scrollLeft=e.x,r.scrollTop=e.y):t=!1}}catch{t=!1}})}catch(e){console.error(`[rari] Router: Failed to restore scroll positions:`,e),t=!1}return t}restoreFormData(e){let t=!0;try{e.forEach((e,n)=>{try{let r=document.getElementById(n)||document.querySelector(`form[name="${n}"]`)||document.querySelectorAll(`form`)[Number.parseInt(n.replace(`form-`,``),10)];r instanceof HTMLFormElement?e.forEach((e,n)=>{try{let t=r.elements.namedItem(n);t instanceof RadioNodeList?t.forEach(t=>{t instanceof HTMLInputElement&&(t.type===`radio`||t.type===`checkbox`?t.checked=t.value===e:t.value=e)}):(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)&&(t instanceof HTMLInputElement&&(t.type===`checkbox`||t.type===`radio`)?t.checked=t.value===e:t.value=e)}catch{t=!1}}):t=!1}catch{t=!1}})}catch(e){console.error(`[rari] Router: Failed to restore form data:`,e),t=!1}return t}restoreFocus(e){try{let t=document.querySelector(e);t instanceof HTMLElement&&requestAnimationFrame(()=>{try{t.focus()}catch{}})}catch{}}};function M(e){e.title&&(document.title=e.title);let t=(e,t)=>{let n=document.querySelector(e);if(n)t.content&&n.setAttribute(`content`,t.content);else{n=document.createElement(`meta`);for(let[e,r]of Object.entries(t))n.setAttribute(e,r);document.head.appendChild(n)}};if(e.description&&t(`meta[name="description"]`,{name:`description`,content:e.description}),e.keywords&&e.keywords.length>0&&t(`meta[name="keywords"]`,{name:`keywords`,content:e.keywords.join(`, `)}),e.viewport&&t(`meta[name="viewport"]`,{name:`viewport`,content:e.viewport}),e.canonical){let t=document.querySelector(`link[rel="canonical"]`);t||(t=document.createElement(`link`),t.setAttribute(`rel`,`canonical`),document.head.appendChild(t)),t.setAttribute(`href`,e.canonical)}if(e.robots){let n=[];e.robots.index!==void 0&&n.push(e.robots.index?`index`:`noindex`),e.robots.follow!==void 0&&n.push(e.robots.follow?`follow`:`nofollow`),e.robots.nocache&&n.push(`nocache`),n.length>0&&t(`meta[name="robots"]`,{name:`robots`,content:n.join(`, `)})}if(e.openGraph){let n=e.openGraph;if(n.title&&t(`meta[property="og:title"]`,{property:`og:title`,content:n.title}),n.description&&t(`meta[property="og:description"]`,{property:`og:description`,content:n.description}),n.url&&t(`meta[property="og:url"]`,{property:`og:url`,content:n.url}),n.siteName&&t(`meta[property="og:site_name"]`,{property:`og:site_name`,content:n.siteName}),n.type&&t(`meta[property="og:type"]`,{property:`og:type`,content:n.type}),n.images&&n.images.length>0){document.querySelectorAll(`meta[property="og:image"]`).forEach(e=>e.remove());for(let e of n.images){let t=document.createElement(`meta`);t.setAttribute(`property`,`og:image`),t.setAttribute(`content`,e),document.head.appendChild(t)}}}if(e.twitter){let n=e.twitter;if(n.card&&t(`meta[name="twitter:card"]`,{name:`twitter:card`,content:n.card}),n.site&&t(`meta[name="twitter:site"]`,{name:`twitter:site`,content:n.site}),n.creator&&t(`meta[name="twitter:creator"]`,{name:`twitter:creator`,content:n.creator}),n.title&&t(`meta[name="twitter:title"]`,{name:`twitter:title`,content:n.title}),n.description&&t(`meta[name="twitter:description"]`,{name:`twitter:description`,content:n.description}),n.images&&n.images.length>0){document.querySelectorAll(`meta[name="twitter:image"]`).forEach(e=>e.remove());for(let e of n.images){let t=document.createElement(`meta`);t.setAttribute(`name`,`twitter:image`),t.setAttribute(`content`,e),document.head.appendChild(t)}}}}function N({children:e,initialRoute:t}){let[n,r]=y(()=>({currentRoute:E(t),navigationId:0,error:null})),i=v(null),a=v(!0),o=v(E(t)),s=v(new T({timeout:1e4,maxRetries:3,onError:e=>{console.error(`[rari] Router: Navigation error:`,e)},onRetry:()=>{}})),c=v(new Map),l=v([]),u=v(new j({maxHistorySize:50})),d=()=>`${Date.now()}-${Math.random().toString(36).substring(2,9)}`,f=()=>{i.current&&=(i.current.abort(),null)},p=()=>{for(let[,e]of c.current.entries())e.abortController.abort();c.current.clear()},m=(e,t)=>{c.current.delete(e),a.current&&n.navigationId===t&&r(e=>({...e}))},h=async e=>A.get(e),g=v(null),w=async(e,t={})=>{if(!e||typeof e!=`string`){console.error(`[rari] Router: Invalid navigation target:`,e);return}let[l,_]=e.includes(`#`)?e.split(`#`):[e,``],v=E(l);if(v===o.current&&!t.replace){if(_){let e=document.getElementById(_);e&&(e.scrollIntoView({behavior:`smooth`,block:`start`}),window.history.pushState(window.history.state,``,`${v}#${_}`))}return}let y=c.current.get(v);if(y)return y.promise;let b=await h(v);p(),f();let x=new AbortController;i.current=x;let S=n.navigationId+1,C=(async()=>{let e=o.current;try{t.historyKey||u.current.captureState(e);let n=t.historyKey||d(),i={route:v,navigationId:S,scrollPosition:{x:window.scrollX,y:window.scrollY},timestamp:Date.now(),key:n},l=_?`${v}#${_}`:v;t.replace?window.history.replaceState(i,``,l):window.history.pushState(i,``,l);let f=window.location.origin+v,p=await fetch(f,{headers:{Accept:`text/x-component`},signal:x.signal});if(!p.ok)throw Error(`Failed to fetch: ${p.status}`);let h=new URL(p.url).pathname,y=h===v?v:h;if(h!==v){let e=_?`${h}#${_}`:h;window.history.replaceState({route:h,navigationId:S,scrollPosition:{x:window.scrollX,y:window.scrollY},timestamp:Date.now(),key:t.historyKey||d()},``,e)}if(x.signal.aborted){m(y,S);return}try{let e=p.headers.get(`x-rari-metadata`);if(e){let t=decodeURIComponent(e);M(JSON.parse(t))}}catch{}if(p.headers.get(`x-render-mode`)===`streaming`&&p.body){let n=p.body.getReader(),r=new TextDecoder,i=``;try{for(;;){let{done:e,value:t}=await n.read();if(e)break;if(x.signal.aborted){await n.cancel(),m(y,S);return}i+=r.decode(t,{stream:!0});let a=i.split(`
|
|
1
|
+
import{a as e,c as t,d as n,f as r,g as i,h as a,i as o,l as s,m as c,n as l,o as u,p as d,r as f,s as p,t as m,u as h}from"./runtime-client-Bg4V1Ksp.mjs";import{Component as g,useEffect as _,useRef as v,useState as y}from"react";import{Fragment as b,jsx as x,jsxs as S}from"react/jsx-runtime";function C(e,t,n={}){let r=null,i=0,a=0,o=null,s=null,{leading:c=!1,trailing:l=!0,maxWait:u}=n;function d(t){let n=o,r=s;return o=null,s=null,a=t,e.apply(r,n)}function f(e){let n=e-i,r=e-a;return i===0||n>=t||n<0||u!==void 0&&r>=u}function p(){let e=Date.now();if(f(e))return h(e);let n=e-i,o=e-a,s=t-n,c=u===void 0?1/0:u-o,l=Math.min(s,c);r=setTimeout(p,l)}function m(e){return a=e,r=setTimeout(p,t),c?d(e):void 0}function h(e){if(r=null,l&&o)return d(e);o=null,s=null}function g(){r!==null&&clearTimeout(r),a=0,o=null,i=0,s=null,r=null}function _(){return r===null?void 0:h(Date.now())}function v(){return r!==null}function y(...e){let n=Date.now(),a=f(n);if(o=e,s=this,i=n,a){if(r===null)return m(i);if(u!==void 0)return r=setTimeout(p,t),d(i)}r===null&&(r=setTimeout(p,t))}return y.cancel=g,y.flush=_,y.pending=v,y}function w(e,t){if(e instanceof Error&&e.name===`AbortError`)return{type:`abort`,message:`Navigation was cancelled`,originalError:e,url:t,timestamp:Date.now(),retryable:!1};if(e instanceof Error&&e.message.includes(`timeout`))return{type:`timeout`,message:`Navigation request timed out`,originalError:e,url:t,timestamp:Date.now(),retryable:!0};if(e instanceof Error&&`status`in e){let n=e.status;return n===404?{type:`not-found`,message:`Page not found`,originalError:e,statusCode:n,url:t,timestamp:Date.now(),retryable:!1}:n>=500?{type:`server-error`,message:`Server error: ${n}`,originalError:e,statusCode:n,url:t,timestamp:Date.now(),retryable:!0}:{type:`fetch-error`,message:`HTTP error: ${n}`,originalError:e,statusCode:n,url:t,timestamp:Date.now(),retryable:n>=500}}return e instanceof TypeError&&e.message.includes(`fetch`)?{type:`network-error`,message:`Network error - check your connection`,originalError:e,url:t,timestamp:Date.now(),retryable:!0}:e instanceof SyntaxError||e instanceof Error&&e.message.includes(`parse`)?{type:`parse-error`,message:`Failed to parse server response`,originalError:e instanceof Error?e:void 0,url:t,timestamp:Date.now(),retryable:!1}:{type:`fetch-error`,message:e instanceof Error?e.message:`Unknown error occurred`,originalError:e instanceof Error?e:void 0,url:t,timestamp:Date.now(),retryable:!1}}var T=class{options;retryCount;constructor(e={}){this.options={timeout:e.timeout??1e4,maxRetries:e.maxRetries??3,onError:e.onError??(()=>{}),onRetry:e.onRetry??(()=>{})},this.retryCount=new Map}handleError(e,t){let n=w(e,t);return this.options.onError(n),console.error(`[rari] Navigation:`,n.type,n.message,{url:n.url,statusCode:n.statusCode,retryable:n.retryable}),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`rari:navigation-error`,{detail:n})),n}canRetry(e,t){return e.retryable?(this.retryCount.get(t)??0)<this.options.maxRetries:!1}incrementRetry(e){let t=(this.retryCount.get(e)??0)+1;return this.retryCount.set(e,t),this.options.onRetry(t,{type:`fetch-error`,message:`Retry attempt ${t}`,url:e,timestamp:Date.now(),retryable:!0}),t}resetRetry(e){this.retryCount.delete(e)}getRetryCount(e){return this.retryCount.get(e)??0}clearRetries(){this.retryCount.clear()}};function E(e){if(!e||e===`/`)return`/`;let t=e;for(;t.endsWith(`/`)&&t.length>1;)t=t.slice(0,-1);return t.startsWith(`/`)||(t=`/${t}`),t}function D(e,t){try{return new URL(e,t||window.location.origin).origin!==(t||window.location.origin)}catch{return!1}}function O(e){try{let t=new URL(e,window.location.origin);return t.pathname+t.hash}catch{return e}}function k({error:e,onRetry:t,onReload:n,onDismiss:r,retryCount:i=0,maxRetries:a=3}){let o=e.retryable&&i<a;return x(`div`,{style:{position:`fixed`,top:0,left:0,right:0,bottom:0,background:`rgba(0, 0, 0, 0.5)`,display:`flex`,alignItems:`center`,justifyContent:`center`,zIndex:1e4,padding:`20px`},onClick:e=>{e.target===e.currentTarget&&r&&r()},children:S(`div`,{style:{background:`white`,borderRadius:`8px`,padding:`24px`,maxWidth:`500px`,width:`100%`,boxShadow:`0 4px 12px rgba(0, 0, 0, 0.15)`},onClick:e=>e.stopPropagation(),children:[S(`div`,{style:{display:`flex`,alignItems:`center`,gap:`12px`,marginBottom:`16px`},children:[x(`span`,{style:{fontSize:`32px`},children:(()=>{switch(e.type){case`timeout`:return`⏱️`;case`network-error`:return`📡`;case`not-found`:return`🔍`;case`server-error`:return`⚠️`;case`parse-error`:return`📄`;case`abort`:return`🚫`;default:return`❌`}})()}),x(`h2`,{style:{margin:0,fontSize:`20px`,fontWeight:`600`,color:`#1f2937`},children:`Navigation Error`})]}),x(`p`,{style:{margin:`0 0 16px 0`,fontSize:`15px`,lineHeight:`1.5`,color:`#4b5563`},children:(()=>{switch(e.type){case`timeout`:return`The page took too long to load. Please try again.`;case`network-error`:return`Unable to connect to the server. Please check your internet connection.`;case`not-found`:return`The page you're looking for doesn't exist.`;case`server-error`:return`The server encountered an error. Please try again in a moment.`;case`parse-error`:return`Unable to load the page content. Please try reloading.`;case`abort`:return`Navigation was cancelled.`;default:return e.message||`An unexpected error occurred.`}})()}),e.url&&S(`details`,{style:{marginBottom:`16px`,fontSize:`13px`,color:`#6b7280`},children:[x(`summary`,{style:{cursor:`pointer`,userSelect:`none`,marginBottom:`8px`},children:`Technical details`}),S(`div`,{style:{padding:`12px`,background:`#f9fafb`,borderRadius:`4px`,fontFamily:`monospace`,fontSize:`12px`,wordBreak:`break-all`},children:[S(`div`,{style:{marginBottom:`4px`},children:[x(`strong`,{children:`URL:`}),` `,e.url]}),e.statusCode&&S(`div`,{style:{marginBottom:`4px`},children:[x(`strong`,{children:`Status:`}),` `,e.statusCode]}),S(`div`,{style:{marginBottom:`4px`},children:[x(`strong`,{children:`Type:`}),` `,e.type]}),e.originalError&&S(`div`,{children:[x(`strong`,{children:`Error:`}),` `,e.originalError.message]})]})]}),o&&i>0&&S(`div`,{style:{marginBottom:`16px`,padding:`8px 12px`,background:`#fef3c7`,border:`1px solid #fbbf24`,borderRadius:`4px`,fontSize:`13px`,color:`#92400e`},children:[`Retry attempt`,` `,i,` `,`of`,` `,a]}),S(`div`,{style:{display:`flex`,gap:`8px`,flexWrap:`wrap`},children:[o&&t&&x(`button`,{onClick:t,type:`button`,style:{flex:1,minWidth:`120px`,padding:`10px 16px`,background:`#3b82f6`,color:`white`,border:`none`,borderRadius:`6px`,fontSize:`14px`,fontWeight:`500`,cursor:`pointer`,transition:`background 0.2s`},onMouseEnter:e=>{e.currentTarget.style.background=`#2563eb`},onMouseLeave:e=>{e.currentTarget.style.background=`#3b82f6`},children:`Try Again`}),n&&x(`button`,{onClick:n,type:`button`,style:{flex:1,minWidth:`120px`,padding:`10px 16px`,background:`#6b7280`,color:`white`,border:`none`,borderRadius:`6px`,fontSize:`14px`,fontWeight:`500`,cursor:`pointer`,transition:`background 0.2s`},onMouseEnter:e=>{e.currentTarget.style.background=`#4b5563`},onMouseLeave:e=>{e.currentTarget.style.background=`#6b7280`},children:`Reload Page`}),r&&x(`button`,{onClick:r,type:`button`,style:{flex:1,minWidth:`120px`,padding:`10px 16px`,background:`transparent`,color:`#6b7280`,border:`1px solid #d1d5db`,borderRadius:`6px`,fontSize:`14px`,fontWeight:`500`,cursor:`pointer`,transition:`all 0.2s`},onMouseEnter:e=>{e.currentTarget.style.background=`#f9fafb`,e.currentTarget.style.borderColor=`#9ca3af`},onMouseLeave:e=>{e.currentTarget.style.background=`transparent`,e.currentTarget.style.borderColor=`#d1d5db`},children:`Dismiss`})]}),x(`p`,{style:{marginTop:`16px`,marginBottom:0,fontSize:`12px`,color:`#9ca3af`,textAlign:`center`},children:`Your current page is still available below this message`})]})})}const A=new class{cache=new Map;pendingRequests=new Map;async get(e){let t=this.cache.get(e);if(t)return t;let n=this.pendingRequests.get(e);if(n)return n;let r=this.fetchRouteInfo(e);this.pendingRequests.set(e,r);try{let t=await r;return this.cache.set(e,t),t}finally{this.pendingRequests.delete(e)}}async fetchRouteInfo(e){let t={path:e},n=await fetch(`/_rari/route-info`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json();throw Error(e.error||`Failed to fetch route info`)}return n.json()}clear(){this.cache.clear(),this.pendingRequests.clear()}invalidate(e){this.cache.delete(e)}};if(typeof window<`u`){let e=window[`~rari`]||{};window[`~rari`]||(window[`~rari`]=e),e.routeInfoCache=A}var j=class{stateHistory;routeAccessOrder;maxHistorySize;scrollableSelector;constructor(e={}){this.stateHistory=new Map,this.routeAccessOrder=[],this.maxHistorySize=e.maxHistorySize||50,this.scrollableSelector=e.scrollableSelector||`[data-scrollable], .scrollable, [style*="overflow"]`}captureState(e){let t={scrollPositions:this.captureScrollPositions(),formData:this.captureFormData(),focusedElement:this.captureFocusedElement()};return this.storeState(e,t),t}captureScrollPositions(){let e=new Map;try{e.set(`window`,{x:window.scrollX,y:window.scrollY,element:`window`}),document.querySelectorAll(this.scrollableSelector).forEach((t,n)=>{if(t instanceof HTMLElement){let r=t.id||`scrollable-${n}`;(t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth)&&e.set(r,{x:t.scrollLeft,y:t.scrollTop,element:r})}})}catch{}return e}captureFormData(){let e=new Map;try{document.querySelectorAll(`form`).forEach((t,n)=>{let r=t.id||t.name||`form-${n}`,i=new FormData(t);i.entries().next().done||e.set(r,i)})}catch{}return e}captureFocusedElement(){try{let e=document.activeElement;if(e&&e!==document.body){if(e.id)return`#${e.id}`;if((e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&e.name)return`[name="${e.name}"]`}}catch{}return null}storeState(e,t){let n=this.routeAccessOrder.indexOf(e);for(n!==-1&&this.routeAccessOrder.splice(n,1),this.routeAccessOrder.push(e),this.stateHistory.set(e,t);this.routeAccessOrder.length>this.maxHistorySize;){let e=this.routeAccessOrder.shift();e&&this.stateHistory.delete(e)}}getHistorySize(){return this.stateHistory.size}hasState(e){return this.stateHistory.has(e)}getState(e){return this.stateHistory.get(e)}clearAll(){this.stateHistory.clear(),this.routeAccessOrder=[]}clearState(e){this.stateHistory.delete(e);let t=this.routeAccessOrder.indexOf(e);t!==-1&&this.routeAccessOrder.splice(t,1)}restoreState(e){let t=this.stateHistory.get(e);if(!t)return!1;let n=!0;return this.restoreScrollPositions(t.scrollPositions)||(n=!1),this.restoreFormData(t.formData)||(n=!1),t.focusedElement&&this.restoreFocus(t.focusedElement),n}restoreScrollPositions(e){let t=!0;try{e.forEach((e,n)=>{try{if(n===`window`)window.scrollTo(e.x,e.y);else{let r=document.getElementById(n)||document.querySelector(`[data-scrollable-id="${n}"]`);r instanceof HTMLElement?(r.scrollLeft=e.x,r.scrollTop=e.y):t=!1}}catch{t=!1}})}catch(e){console.error(`[rari] Router: Failed to restore scroll positions:`,e),t=!1}return t}restoreFormData(e){let t=!0;try{e.forEach((e,n)=>{try{let r=document.getElementById(n)||document.querySelector(`form[name="${n}"]`)||document.querySelectorAll(`form`)[Number.parseInt(n.replace(`form-`,``),10)];r instanceof HTMLFormElement?e.forEach((e,n)=>{try{let t=r.elements.namedItem(n);t instanceof RadioNodeList?t.forEach(t=>{t instanceof HTMLInputElement&&(t.type===`radio`||t.type===`checkbox`?t.checked=t.value===e:t.value=e)}):(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)&&(t instanceof HTMLInputElement&&(t.type===`checkbox`||t.type===`radio`)?t.checked=t.value===e:t.value=e)}catch{t=!1}}):t=!1}catch{t=!1}})}catch(e){console.error(`[rari] Router: Failed to restore form data:`,e),t=!1}return t}restoreFocus(e){try{let t=document.querySelector(e);t instanceof HTMLElement&&requestAnimationFrame(()=>{try{t.focus()}catch{}})}catch{}}};function M(e){e.title&&(document.title=e.title);let t=(e,t)=>{let n=document.querySelector(e);if(n)t.content&&n.setAttribute(`content`,t.content);else{n=document.createElement(`meta`);for(let[e,r]of Object.entries(t))n.setAttribute(e,r);document.head.appendChild(n)}};if(e.description&&t(`meta[name="description"]`,{name:`description`,content:e.description}),e.keywords&&e.keywords.length>0&&t(`meta[name="keywords"]`,{name:`keywords`,content:e.keywords.join(`, `)}),e.viewport&&t(`meta[name="viewport"]`,{name:`viewport`,content:e.viewport}),e.canonical){let t=document.querySelector(`link[rel="canonical"]`);t||(t=document.createElement(`link`),t.setAttribute(`rel`,`canonical`),document.head.appendChild(t)),t.setAttribute(`href`,e.canonical)}if(e.robots){let n=[];e.robots.index!==void 0&&n.push(e.robots.index?`index`:`noindex`),e.robots.follow!==void 0&&n.push(e.robots.follow?`follow`:`nofollow`),e.robots.nocache&&n.push(`nocache`),n.length>0&&t(`meta[name="robots"]`,{name:`robots`,content:n.join(`, `)})}if(e.openGraph){let n=e.openGraph;if(n.title&&t(`meta[property="og:title"]`,{property:`og:title`,content:n.title}),n.description&&t(`meta[property="og:description"]`,{property:`og:description`,content:n.description}),n.url&&t(`meta[property="og:url"]`,{property:`og:url`,content:n.url}),n.siteName&&t(`meta[property="og:site_name"]`,{property:`og:site_name`,content:n.siteName}),n.type&&t(`meta[property="og:type"]`,{property:`og:type`,content:n.type}),n.images&&n.images.length>0){document.querySelectorAll(`meta[property="og:image"]`).forEach(e=>e.remove());for(let e of n.images){let t=document.createElement(`meta`);t.setAttribute(`property`,`og:image`),t.setAttribute(`content`,e),document.head.appendChild(t)}}}if(e.twitter){let n=e.twitter;if(n.card&&t(`meta[name="twitter:card"]`,{name:`twitter:card`,content:n.card}),n.site&&t(`meta[name="twitter:site"]`,{name:`twitter:site`,content:n.site}),n.creator&&t(`meta[name="twitter:creator"]`,{name:`twitter:creator`,content:n.creator}),n.title&&t(`meta[name="twitter:title"]`,{name:`twitter:title`,content:n.title}),n.description&&t(`meta[name="twitter:description"]`,{name:`twitter:description`,content:n.description}),n.images&&n.images.length>0){document.querySelectorAll(`meta[name="twitter:image"]`).forEach(e=>e.remove());for(let e of n.images){let t=document.createElement(`meta`);t.setAttribute(`name`,`twitter:image`),t.setAttribute(`content`,e),document.head.appendChild(t)}}}}function N({children:e,initialRoute:t}){let[n,r]=y(()=>({currentRoute:E(t),navigationId:0,error:null})),i=v(null),a=v(!0),o=v(E(t)),s=v(new T({timeout:1e4,maxRetries:3,onError:e=>{console.error(`[rari] Router: Navigation error:`,e)},onRetry:()=>{}})),c=v(new Map),l=v([]),u=v(new j({maxHistorySize:50})),d=()=>`${Date.now()}-${Math.random().toString(36).substring(2,9)}`,f=()=>{i.current&&=(i.current.abort(),null)},p=()=>{for(let[,e]of c.current.entries())e.abortController.abort();c.current.clear()},m=(e,t)=>{c.current.delete(e),a.current&&n.navigationId===t&&r(e=>({...e}))},h=async e=>A.get(e),g=v(null),w=async(e,t={})=>{if(!e||typeof e!=`string`){console.error(`[rari] Router: Invalid navigation target:`,e);return}let[l,_]=e.includes(`#`)?e.split(`#`):[e,``],v=E(l);if(v===o.current&&!t.replace){if(_){let e=document.getElementById(_);e&&(e.scrollIntoView({behavior:`smooth`,block:`start`}),window.history.pushState(window.history.state,``,`${v}#${_}`))}return}let y=c.current.get(v);if(y)return y.promise;let b=await h(v);p(),f();let x=new AbortController;i.current=x;let S=n.navigationId+1,C=(async()=>{let e=o.current;try{t.historyKey||u.current.captureState(e);let n=t.historyKey||d(),i={route:v,navigationId:S,scrollPosition:{x:window.scrollX,y:window.scrollY},timestamp:Date.now(),key:n},l=_?`${v}#${_}`:v;t.replace?window.history.replaceState(i,``,l):window.history.pushState(i,``,l);let f=window.location.origin+v,p=await fetch(f,{headers:{Accept:`text/x-component`},signal:x.signal});if(!p.ok)throw Error(`Failed to fetch: ${p.status}`);let h=new URL(p.url).pathname,y=h===v?v:h;if(h!==v){let e=_?`${h}#${_}`:h;window.history.replaceState({route:h,navigationId:S,scrollPosition:{x:window.scrollX,y:window.scrollY},timestamp:Date.now(),key:t.historyKey||d()},``,e)}if(x.signal.aborted){m(y,S);return}try{let e=p.headers.get(`x-rari-metadata`);if(e){let t=decodeURIComponent(e);M(JSON.parse(t))}}catch{}if(p.headers.get(`x-render-mode`)===`streaming`&&p.body){let n=p.body.getReader(),r=new TextDecoder,i=``;try{for(;;){let{done:e,value:t}=await n.read();if(e)break;if(x.signal.aborted){await n.cancel(),m(y,S);return}i+=r.decode(t,{stream:!0});let a=i.split(`
|
|
2
2
|
`);i=a.pop()||``;for(let e of a)e.trim()&&window.dispatchEvent(new CustomEvent(`rari:rsc-row`,{detail:{rscRow:e}}))}i.trim()&&window.dispatchEvent(new CustomEvent(`rari:rsc-row`,{detail:{rscRow:i}})),window.dispatchEvent(new CustomEvent(`rari:navigate`,{detail:{from:e,to:y,navigationId:S,options:t,routeInfo:b,abortSignal:x.signal,isStreaming:!0}}))}catch(e){throw console.error(`[rari] Router: Streaming error:`,e),e}}else{let n=await p.text();window.dispatchEvent(new CustomEvent(`rari:navigate`,{detail:{from:e,to:y,navigationId:S,options:t,routeInfo:b,abortSignal:x.signal,rscWireFormat:n}}))}if(x.signal.aborted){m(y,S);return}a.current&&(o.current=y,r(e=>({...e,currentRoute:y,error:null})),s.current.resetRetry(y),t.historyKey?requestAnimationFrame(()=>{u.current.restoreState(y)}):_&&requestAnimationFrame(()=>{let e=(t=0)=>{let n=document.getElementById(_);n?n.scrollIntoView({behavior:`smooth`,block:`start`}):t<10&&setTimeout(e,50,t+1)};e()})),c.current.delete(v),g.current?.()}catch(t){if(t instanceof Error&&t.name===`AbortError`){m(v,S);return}let n=s.current.handleError(t,v);a.current&&r(e=>({...e,error:n})),c.current.delete(v),window.dispatchEvent(new CustomEvent(`rari:navigate-error`,{detail:{from:e,to:v,error:n,navigationId:S}})),g.current?.()}})();return c.current.set(v,{targetPath:v,navigationId:S,promise:C,abortController:x}),C};g.current=async()=>{if(l.current.length===0)return;let e=l.current.at(-1);e&&(l.current=[],await w(e.path,e.options))};let N=v(null);N.current||=C((e,t)=>{w(e,t)},50,{leading:!1,trailing:!0,maxWait:200});let P=N.current,F=e=>{if(e.button!==0||e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)return;let t=e.target;for(;t&&t.tagName!==`A`;)t=t.parentElement;if(!t||t.tagName!==`A`)return;let n=t;if(n.target&&n.target!==`_self`||n.hasAttribute(`download`))return;let r=n.getAttribute(`href`);if(r&&!D(r)){if(r.startsWith(`#`)){e.preventDefault();let t=r.slice(1),n=document.getElementById(t);n&&(n.scrollIntoView({behavior:`smooth`,block:`start`}),window.history.pushState(window.history.state,``,r));return}e.preventDefault(),P(O(r),{replace:!1})}},I=e=>{let t=window.location.pathname,n=e.state;w(t,{replace:!0,scroll:!1,historyKey:n?.key})},L=()=>{if(n.error&&n.error.url){let e=n.error.url;s.current.incrementRetry(e),w(e,{replace:!1})}},R=()=>{window.location.reload()},z=()=>{r(e=>({...e,error:null}))};_(()=>{let e=window.history.state;if(!e||!e.key){let e={route:n.currentRoute,navigationId:n.navigationId,scrollPosition:{x:window.scrollX,y:window.scrollY},timestamp:Date.now(),key:d()};window.history.replaceState(e,``,window.location.pathname+window.location.search)}},[]);let B=e=>{if(e.persisted){let e=window.location.pathname;u.current.captureState(e)}},V=e=>{if(e.persisted){let e=window.location.pathname,t=window.history.state;requestAnimationFrame(()=>{u.current.restoreState(e),t?.scrollPosition&&window.scrollTo(t.scrollPosition.x,t.scrollPosition.y)})}};return _(()=>(document.addEventListener(`click`,F),window.addEventListener(`popstate`,I),window.addEventListener(`pagehide`,B),window.addEventListener(`pageshow`,V),()=>{document.removeEventListener(`click`,F),window.removeEventListener(`popstate`,I),window.removeEventListener(`pagehide`,B),window.removeEventListener(`pageshow`,V),a.current=!1,f(),p(),P.cancel&&P.cancel()}),[]),S(b,{children:[e,n.error&&x(k,{error:n.error,onRetry:L,onReload:R,onDismiss:z,retryCount:s.current.getRetryCount(n.error.url||``),maxRetries:3})]})}var P=class extends g{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`[rari] Layout: Error in layout "${this.props.layoutPath}":`,e,t),this.props.onError&&this.props.onError(e,t),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`rari:layout-error`,{detail:{layoutPath:this.props.layoutPath,error:e,errorInfo:t,timestamp:Date.now()}}))}reset=()=>{this.setState({hasError:!1,error:null})};render(){return this.state.hasError&&this.state.error?this.props.fallback?this.props.fallback(this.state.error,this.reset):S(`div`,{style:{padding:`16px`,margin:`16px 0`,background:`#fee`,border:`1px solid #fcc`,borderRadius:`4px`},children:[x(`h3`,{style:{margin:`0 0 8px 0`,color:`#c00`},children:`Layout Error`}),S(`p`,{style:{margin:`0 0 8px 0`,fontSize:`14px`},children:[`An error occurred in layout:`,` `,x(`code`,{children:this.props.layoutPath})]}),S(`details`,{style:{fontSize:`12px`,marginBottom:`8px`},children:[x(`summary`,{style:{cursor:`pointer`},children:`Error details`}),S(`pre`,{style:{marginTop:`8px`,padding:`8px`,background:`#fff`,border:`1px solid #ddd`,borderRadius:`2px`,overflow:`auto`},children:[this.state.error.message,`
|
|
3
3
|
`,this.state.error.stack]})]}),x(`button`,{onClick:this.reset,type:`button`,style:{padding:`6px 12px`,background:`#c00`,color:`white`,border:`none`,borderRadius:`4px`,cursor:`pointer`,fontSize:`14px`},children:`Try Again`})]}):this.props.children}};export{N as ClientRouter,m as DefaultError,l as DefaultLoading,f as ErrorBoundary,o as HttpRuntimeClient,P as LayoutErrorBoundary,e as LoadingSpinner,T as NavigationErrorHandler,k as NavigationErrorOverlay,u as NotFound,j as StatePreserver,h as clearPropsCache,n as clearPropsCacheForComponent,p as createErrorBoundary,t as createHttpRuntimeClient,s as createLoadingBoundary,r as extractMetadata,d as extractServerProps,c as extractServerPropsWithCache,a as extractStaticParams,i as hasServerSideDataFetching};
|
package/dist/image/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,i as t,n,o as r,r as i,t as a}from"../constants-
|
|
1
|
+
import{a as e,i as t,n,o as r,r as i,t as a}from"../constants-CmqZuM5B.mjs";import{useCallback as o,useEffect as s,useRef as c,useState as l}from"react";import{jsx as u,jsxs as d}from"react/jsx-runtime";function f(e,t,n,r){let i=new URLSearchParams;return i.set(`url`,e),i.set(`w`,t.toString()),i.set(`q`,n.toString()),r&&i.set(`f`,r),`/_rari/image?${i}`}function p({src:e,alt:t,width:r,height:i,quality:p=75,preload:m=!1,loading:h=`lazy`,placeholder:g=`empty`,blurDataURL:_,fill:v=!1,sizes:y,style:b,className:x,onLoad:S,onError:C,unoptimized:w=!1,loader:T,overrideSrc:E,decoding:D}){let O=typeof e==`string`?e:e.src,k=r||(typeof e==`string`?void 0:e.width),A=i||(typeof e==`string`?void 0:e.height),j=_||(typeof e==`string`?void 0:e.blurDataURL),M=E||O,N=m,P=D||(m?`sync`:`async`),[F,I]=l(!1),[L,R]=l(!1),z=c(null),B=c(S),V=c(null);s(()=>{B.current=S},[S]);let H=o(e=>{let t=e.currentTarget;t.src&&t.complete&&(g===`blur`&&I(!0),B.current&&B.current(e))},[g]),U=o(e=>{R(!0),g===`blur`&&I(!0),C&&C(e)},[g,C]);s(()=>{if(N){let e=document.createElement(`link`);return e.rel=`preload`,e.as=`image`,T?e.href=T({src:M,width:k||1920,quality:p}):w?e.href=M:e.href=f(M,k||1920,p),y&&e.setAttribute(`imagesizes`,y),document.head.appendChild(e),()=>{document.head.removeChild(e)}}},[N,M,k,p,y,T,w]),s(()=>{if(N||w||h===`eager`)return;let e=z.current;if(!e)return;let t=new IntersectionObserver(n=>{n.forEach(n=>{n.isIntersecting&&t.unobserve(e)})},{rootMargin:`50px`});return t.observe(e),()=>{t.disconnect()}},[N,w,h]);let W={...b,...v&&{position:`absolute`,inset:0,width:`100%`,height:`100%`,objectFit:`cover`},...g===`blur`&&j&&!F&&{backgroundImage:`url(${j})`,backgroundSize:`cover`,backgroundPosition:`center`,filter:`blur(20px)`,transition:`filter 0.3s ease-out`},...g===`blur`&&F&&{filter:`none`,transition:`filter 0.3s ease-out`}};if(w)return u(`img`,{ref:z,src:T?T({src:M,width:k||1920,quality:p}):M,alt:L?t:``,width:v?void 0:k,height:v?void 0:A,loading:N?`eager`:h,fetchPriority:N?`high`:`auto`,decoding:P,onLoad:H,onError:U,style:W,className:x});let G=k||1920,K=k?[k]:a,q=e=>T?K.map(e=>`${T({src:M,width:e,quality:p})} ${e}w`).join(`, `):K.map(t=>`${f(M,t,p,e)} ${t}w`).join(`, `),J=T?T({src:M,width:G,quality:p}):f(M,G,p),Y=K.length>1||K[0]!==G,X=u(`img`,{ref:z,src:J,srcSet:Y?q():void 0,sizes:Y?y:void 0,alt:L?t:``,width:v?void 0:k,height:v?void 0:A,loading:N?`eager`:h,fetchPriority:N?`high`:`auto`,decoding:P,onLoad:H,onError:U,style:W,className:x});return Y?d(`picture`,{ref:V,children:[n.includes(`avif`)&&u(`source`,{type:`image/avif`,srcSet:q(`avif`),sizes:y}),n.includes(`webp`)&&u(`source`,{type:`image/webp`,srcSet:q(`webp`),sizes:y}),X]}):X}export{a as DEFAULT_DEVICE_SIZES,n as DEFAULT_FORMATS,i as DEFAULT_IMAGE_SIZES,t as DEFAULT_MAX_CACHE_SIZE,e as DEFAULT_MINIMUM_CACHE_TTL,r as DEFAULT_QUALITY_LEVELS,p as Image};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { g as AppRouteManifest, i as ServerSpamBlockerConfig, r as ServerRateLimitConfig, t as ServerCSPConfig } from "./server-config-
|
|
1
|
+
import { g as AppRouteManifest, i as ServerSpamBlockerConfig, r as ServerRateLimitConfig, t as ServerCSPConfig } from "./server-config-5RHHggaf.mjs";
|
|
2
|
+
import { u as ResponseCookies } from "./types-BIZmYbNs.mjs";
|
|
2
3
|
import { Plugin, UserConfig } from "rolldown-vite";
|
|
3
4
|
|
|
4
5
|
//#region src/types/metadata-route.d.ts
|
|
@@ -81,139 +82,6 @@ declare class ApiResponse extends Response {
|
|
|
81
82
|
static noContent(init?: ResponseInit): Response;
|
|
82
83
|
}
|
|
83
84
|
//#endregion
|
|
84
|
-
//#region src/proxy/types.d.ts
|
|
85
|
-
interface RariURL {
|
|
86
|
-
href: string;
|
|
87
|
-
origin: string;
|
|
88
|
-
protocol: string;
|
|
89
|
-
hostname: string;
|
|
90
|
-
port: string;
|
|
91
|
-
pathname: string;
|
|
92
|
-
search: string;
|
|
93
|
-
searchParams: URLSearchParams;
|
|
94
|
-
hash: string;
|
|
95
|
-
}
|
|
96
|
-
interface RequestCookies {
|
|
97
|
-
get: (name: string) => {
|
|
98
|
-
name: string;
|
|
99
|
-
value: string;
|
|
100
|
-
path?: string;
|
|
101
|
-
} | undefined;
|
|
102
|
-
getAll: () => Array<{
|
|
103
|
-
name: string;
|
|
104
|
-
value: string;
|
|
105
|
-
path?: string;
|
|
106
|
-
}>;
|
|
107
|
-
has: (name: string) => boolean;
|
|
108
|
-
delete: (name: string) => void;
|
|
109
|
-
set: ((name: string, value: string, options?: CookieOptions) => void) & ((options: {
|
|
110
|
-
name: string;
|
|
111
|
-
value: string;
|
|
112
|
-
} & CookieOptions) => void);
|
|
113
|
-
}
|
|
114
|
-
interface ResponseCookies {
|
|
115
|
-
get: (name: string) => {
|
|
116
|
-
name: string;
|
|
117
|
-
value: string;
|
|
118
|
-
path?: string;
|
|
119
|
-
} | undefined;
|
|
120
|
-
getAll: () => Array<{
|
|
121
|
-
name: string;
|
|
122
|
-
value: string;
|
|
123
|
-
path?: string;
|
|
124
|
-
}>;
|
|
125
|
-
set: ((name: string, value: string, options?: CookieOptions) => void) & ((options: {
|
|
126
|
-
name: string;
|
|
127
|
-
value: string;
|
|
128
|
-
} & CookieOptions) => void);
|
|
129
|
-
delete: (name: string) => void;
|
|
130
|
-
}
|
|
131
|
-
interface CookieOptions {
|
|
132
|
-
path?: string;
|
|
133
|
-
domain?: string;
|
|
134
|
-
maxAge?: number;
|
|
135
|
-
expires?: Date;
|
|
136
|
-
httpOnly?: boolean;
|
|
137
|
-
secure?: boolean;
|
|
138
|
-
sameSite?: 'strict' | 'lax' | 'none';
|
|
139
|
-
}
|
|
140
|
-
interface RariFetchEvent {
|
|
141
|
-
waitUntil: (promise: Promise<unknown>) => void;
|
|
142
|
-
}
|
|
143
|
-
type ProxyFunction = (request: any, event?: RariFetchEvent) => Promise<any> | any;
|
|
144
|
-
type ProxyCondition = {
|
|
145
|
-
type: 'header' | 'query' | 'cookie';
|
|
146
|
-
key: string;
|
|
147
|
-
value?: string;
|
|
148
|
-
};
|
|
149
|
-
type ProxyRuleCondition = ProxyCondition | {
|
|
150
|
-
type: 'host';
|
|
151
|
-
key: string;
|
|
152
|
-
value?: string;
|
|
153
|
-
};
|
|
154
|
-
interface ProxyMatcher {
|
|
155
|
-
source: string;
|
|
156
|
-
locale?: boolean;
|
|
157
|
-
has?: Array<ProxyRuleCondition>;
|
|
158
|
-
missing?: Array<ProxyRuleCondition>;
|
|
159
|
-
}
|
|
160
|
-
interface ProxyConfig {
|
|
161
|
-
matcher?: string | string[] | ProxyMatcher | ProxyMatcher[];
|
|
162
|
-
}
|
|
163
|
-
interface ProxyModule {
|
|
164
|
-
proxy?: ProxyFunction;
|
|
165
|
-
default?: ProxyFunction;
|
|
166
|
-
config?: ProxyConfig;
|
|
167
|
-
}
|
|
168
|
-
interface ProxyResult {
|
|
169
|
-
continue: boolean;
|
|
170
|
-
response?: Response;
|
|
171
|
-
requestHeaders?: Record<string, string>;
|
|
172
|
-
responseHeaders?: Record<string, string>;
|
|
173
|
-
rewrite?: string;
|
|
174
|
-
redirect?: {
|
|
175
|
-
destination: string;
|
|
176
|
-
permanent: boolean;
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
//#endregion
|
|
180
|
-
//#region src/proxy/RariRequest.d.ts
|
|
181
|
-
declare class RariRequest {
|
|
182
|
-
url: string;
|
|
183
|
-
method: string;
|
|
184
|
-
headers: Headers;
|
|
185
|
-
cookies: RequestCookies;
|
|
186
|
-
rariUrl: RariURL;
|
|
187
|
-
ip?: string;
|
|
188
|
-
geo?: {
|
|
189
|
-
city?: string;
|
|
190
|
-
country?: string;
|
|
191
|
-
region?: string;
|
|
192
|
-
latitude?: string;
|
|
193
|
-
longitude?: string;
|
|
194
|
-
};
|
|
195
|
-
constructor(input: string | URL | Request, init?: RequestInit & {
|
|
196
|
-
ip?: string;
|
|
197
|
-
geo?: {
|
|
198
|
-
city?: string;
|
|
199
|
-
country?: string;
|
|
200
|
-
region?: string;
|
|
201
|
-
latitude?: string;
|
|
202
|
-
longitude?: string;
|
|
203
|
-
};
|
|
204
|
-
});
|
|
205
|
-
static fromRequest(request: Request, options?: {
|
|
206
|
-
ip?: string;
|
|
207
|
-
geo?: {
|
|
208
|
-
city?: string;
|
|
209
|
-
country?: string;
|
|
210
|
-
region?: string;
|
|
211
|
-
latitude?: string;
|
|
212
|
-
longitude?: string;
|
|
213
|
-
};
|
|
214
|
-
}): RariRequest;
|
|
215
|
-
}
|
|
216
|
-
//#endregion
|
|
217
85
|
//#region src/proxy/RariResponse.d.ts
|
|
218
86
|
declare class RariResponse extends Response {
|
|
219
87
|
cookies: ResponseCookies;
|
|
@@ -323,8 +191,4 @@ declare function defineRariConfig(config: UserConfig & {
|
|
|
323
191
|
plugins?: Plugin[];
|
|
324
192
|
}): UserConfig;
|
|
325
193
|
//#endregion
|
|
326
|
-
|
|
327
|
-
type Request$1 = globalThis.Request;
|
|
328
|
-
type Response$1 = globalThis.Response;
|
|
329
|
-
//#endregion
|
|
330
|
-
export { SitemapImage as A, ApiRouteHandlers as C, RobotsRule as D, Robots as E, Sitemap as O, ApiResponse as S, RouteHandler as T, ProxyResult as _, rari as a, RequestCookies as b, ProxyPluginOptions as c, RariRequest as d, CookieOptions as f, ProxyModule as g, ProxyMatcher as h, defineRariOptions as i, SitemapVideo as j, SitemapEntry as k, rariProxy as l, ProxyFunction as m, Response$1 as n, rariRouter as o, ProxyConfig as p, defineRariConfig as r, generateAppRouteManifest as s, Request$1 as t, RariResponse as u, RariFetchEvent as v, RouteContext as w, ResponseCookies as x, RariURL as y };
|
|
194
|
+
export { SitemapImage as _, generateAppRouteManifest as a, RariResponse as c, RouteContext as d, RouteHandler as f, SitemapEntry as g, Sitemap as h, rariRouter as i, ApiResponse as l, RobotsRule as m, defineRariOptions as n, ProxyPluginOptions as o, Robots as p, rari as r, rariProxy as s, defineRariConfig as t, ApiRouteHandlers as u, SitemapVideo as v };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
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 {
|
|
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-5RHHggaf.mjs";
|
|
2
|
+
import { _ as SitemapImage, a as generateAppRouteManifest, c as RariResponse, d as RouteContext, f as RouteHandler, g as SitemapEntry, h as Sitemap, i as rariRouter, l as ApiResponse, m as RobotsRule, n as defineRariOptions, o as ProxyPluginOptions, p as Robots, r as rari, s as rariProxy, t as defineRariConfig, u as ApiRouteHandlers, v as SitemapVideo } from "./index-Ek-rRSpB.mjs";
|
|
3
|
+
import { a as ProxyModule, c as RariURL, i as ProxyMatcher, l as RequestCookies, n as ProxyConfig, o as ProxyResult, r as ProxyFunction, s as RariFetchEvent, t as CookieOptions, u as ResponseCookies } from "./types-BIZmYbNs.mjs";
|
|
4
|
+
import { RariRequest } from "./proxy/RariRequest.mjs";
|
|
5
|
+
import { Request, Response } from "./vite.mjs";
|
|
3
6
|
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-CfH7EIl7.mjs";import{RariRequest as s}from"./proxy/RariRequest.mjs";import{c,d as l,f as u,g as d,h as f,i as p,m,p as h,u as g}from"./runtime-client-Bg4V1Ksp.mjs";import{t as _}from"./routes-DbsqVAaM.mjs";import"./constants-CmqZuM5B.mjs";import"./server-build-C64b2Z-d.mjs";import"./vite.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
|
-
import{
|
|
1
|
+
import{registerClientComponent as e,registerClientReference as t}from"./runtime/react-server-dom-shim.mjs";function n(n,r,i=`default`){let a=`${r}#${i}`;if(e(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 t(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};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { c as RariURL, l as RequestCookies } from "../types-BIZmYbNs.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/proxy/RariRequest.d.ts
|
|
4
|
+
declare class RariRequest {
|
|
5
|
+
url: string;
|
|
6
|
+
method: string;
|
|
7
|
+
headers: Headers;
|
|
8
|
+
cookies: RequestCookies;
|
|
9
|
+
rariUrl: RariURL;
|
|
10
|
+
ip?: string;
|
|
11
|
+
geo?: {
|
|
12
|
+
city?: string;
|
|
13
|
+
country?: string;
|
|
14
|
+
region?: string;
|
|
15
|
+
latitude?: string;
|
|
16
|
+
longitude?: string;
|
|
17
|
+
};
|
|
18
|
+
constructor(input: string | URL | Request, init?: RequestInit & {
|
|
19
|
+
ip?: string;
|
|
20
|
+
geo?: {
|
|
21
|
+
city?: string;
|
|
22
|
+
country?: string;
|
|
23
|
+
region?: string;
|
|
24
|
+
latitude?: string;
|
|
25
|
+
longitude?: string;
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
static fromRequest(request: Request, options?: {
|
|
29
|
+
ip?: string;
|
|
30
|
+
geo?: {
|
|
31
|
+
city?: string;
|
|
32
|
+
country?: string;
|
|
33
|
+
region?: string;
|
|
34
|
+
latitude?: string;
|
|
35
|
+
longitude?: string;
|
|
36
|
+
};
|
|
37
|
+
}): RariRequest;
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { RariRequest };
|
|
@@ -1 +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
|
|
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 RariRequest};
|
|
@@ -22,6 +22,6 @@ interface SimpleProxyResult {
|
|
|
22
22
|
declare global {
|
|
23
23
|
var __rariExecuteProxy: ((request: SimpleRequest) => Promise<SimpleProxyResult>) | undefined;
|
|
24
24
|
}
|
|
25
|
-
declare function initializeProxyExecutor(proxyModulePath: string): Promise<boolean>;
|
|
25
|
+
declare function initializeProxyExecutor(proxyModulePath: string, rariRequestPath: string): Promise<boolean>;
|
|
26
26
|
//#endregion
|
|
27
27
|
export { initializeProxyExecutor };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
async function e(e){try{let
|
|
1
|
+
async function e(e,t){try{let n=await import(e);if(!n||!n.proxy)return console.error(`[rari] Proxy: proxy function not found in module`),!1;let{RariRequest:r}=await import(t);return globalThis.__rariExecuteProxy=async function(e){try{let t=new r(e.url,{method:e.method,headers:new Headers(e.headers)}),i=[],a=await n.proxy(t,{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-CvELqhML-
|
|
1
|
+
import{a as e,i as t,n,r,t as i}from"./utils-CvELqhML-CLd5cK7j.mjs";import{existsSync as a,readFileSync as o,writeFileSync as s}from"node:fs";import{join as c}from"node:path";import l from"node:process";import{styleText as u}from"node:util";async function d(){let d=l.cwd();e(`Creating Railway deployment configuration...`);let f=c(d,`package.json`);a(f)||(t(`No package.json found. Please run this command from your project root.`),l.exit(1));try{let t=JSON.parse(o(f,`utf-8`));t.scripts=t.scripts||{},t.scripts.start&&t.scripts.start!==`rari start`&&(n(`Existing start script found: "${t.scripts.start}"`),n(`Backing up to start:original and replacing with "rari start"`),t.scripts[`start:original`]=t.scripts.start),t.scripts.start=`rari start`,t.scripts[`start:local`]=`rari start`,t.scripts[`deploy:railway`]=`echo "Push to GitHub and connect to Railway to deploy"`,t.engines=t.engines||{},t.engines.node?i(t.engines.node)||(n(`Current engines.node value "${t.engines.node}" may not meet the required minimum of >=22.0.0`),n(`Updating to >=22.0.0 for Railway deployment compatibility`),t.engines.node=`>=22.0.0`):t.engines.node=`>=22.0.0`,(!t.dependencies||!t.dependencies.rari)&&(e(`Adding rari dependency...`),t.dependencies=t.dependencies||{},t.dependencies.rari=`^0.1.0`),s(f,`${JSON.stringify(t,null,2)}\n`),r(`Updated package.json for Railway deployment`)}catch(e){t(`Failed to update package.json: ${e instanceof Error?e.message:`Unknown error`}`),l.exit(1)}let p=c(d,`railway.toml`);if(a(p)){n(`railway.toml already exists, backing up to railway.toml.backup`);let e=o(p,`utf-8`);s(c(d,`railway.toml.backup`),e)}s(p,`[build]
|
|
2
2
|
builder = "RAILPACK"
|
|
3
3
|
|
|
4
4
|
[deploy]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e,i as t,n,r,t as i}from"./utils-CvELqhML-
|
|
1
|
+
import{a as e,i as t,n,r,t as i}from"./utils-CvELqhML-CLd5cK7j.mjs";import{existsSync as a,readFileSync as o,writeFileSync as s}from"node:fs";import{join as c}from"node:path";import l from"node:process";import{styleText as u}from"node:util";async function d(){let d=l.cwd();e(`Creating Render deployment configuration...`);let f=c(d,`package.json`);a(f)||(t(`No package.json found. Please run this command from your project root.`),l.exit(1));try{let t=JSON.parse(o(f,`utf-8`));t.scripts=t.scripts||{},t.scripts.start&&t.scripts.start!==`rari start`&&(n(`Existing start script found: "${t.scripts.start}"`),n(`Backing up to start:original and replacing with "rari start"`),t.scripts[`start:original`]=t.scripts.start),t.scripts.start=`rari start`,t.scripts[`start:local`]=`rari start`,t.scripts[`deploy:render`]=`echo "Push to GitHub and connect to Render to deploy"`,t.engines=t.engines||{},t.engines.node?i(t.engines.node)||(n(`Current engines.node value "${t.engines.node}" may not meet the required minimum of >=22.0.0`),n(`Updating to >=22.0.0 for Render deployment compatibility`),t.engines.node=`>=22.0.0`):t.engines.node=`>=22.0.0`,(!t.dependencies||!t.dependencies.rari)&&(e(`Adding rari dependency...`),t.dependencies=t.dependencies||{},t.dependencies.rari=`^0.1.0`),s(f,`${JSON.stringify(t,null,2)}\n`),r(`Updated package.json for Render deployment`)}catch(e){t(`Failed to update package.json: ${e instanceof Error?e.message:`Unknown error`}`),l.exit(1)}let p=c(d,`render.yaml`);if(a(p)){n(`render.yaml already exists, backing up to render.yaml.backup`);let e=o(p,`utf-8`);s(c(d,`render.yaml.backup`),e)}s(p,`services:
|
|
2
2
|
- type: web
|
|
3
3
|
name: rari-app
|
|
4
4
|
runtime: node
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};export{t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./rolldown-runtime-DR3Ue2cl.mjs";import{promises as t}from"node:fs";import n from"node:path";var r=e({generateAppRouteManifest:()=>c});const i={PAGE:`page`,LAYOUT:`layout`,LOADING:`loading`,ERROR:`error`,NOT_FOUND:`not-found`,TEMPLATE:`template`,DEFAULT:`default`,ROUTE:`route`,OG_IMAGE:`opengraph-image`,TWITTER_IMAGE:`twitter-image`,ICON:`icon`,APPLE_ICON:`apple-icon`},a={DYNAMIC:/^\[([^\]]+)\]$/,CATCH_ALL:/^\[\.\.\.([^\]]+)\]$/,OPTIONAL_CATCH_ALL:/^\[\[\.\.\.([^\]]+)\]\]$/},o=[`GET`,`POST`,`PUT`,`DELETE`,`PATCH`,`HEAD`,`OPTIONS`];var s=class{appDir;extensions;verbose;constructor(e){this.appDir=n.resolve(e.appDir),this.extensions=e.extensions||[`.tsx`,`.jsx`,`.ts`,`.js`],this.verbose=e.verbose||!1}async generateManifest(){this.verbose&&console.warn(`[rari] Router: Scanning app directory: ${this.appDir}`);let e=[],t=[],n=[],r=[],i=[],a=[],o=[];return await this.scanDirectory(``,e,t,n,r,i,a,o),this.verbose&&(console.warn(`[rari] Router: Found ${e.length} routes`),console.warn(`[rari] Router: Found ${t.length} layouts`),console.warn(`[rari] Router: Found ${n.length} loading components`),console.warn(`[rari] Router: Found ${r.length} error boundaries`),console.warn(`[rari] Router: Found ${a.length} API routes`),console.warn(`[rari] Router: Found ${o.length} OG images`)),{routes:this.sortRoutes(e),layouts:this.sortLayouts(t),loading:n,errors:r,notFound:i,apiRoutes:this.sortApiRoutes(a),ogImages:o,generated:new Date().toISOString()}}async scanDirectory(e,r,i,a,o,s,c,l){let u=n.join(this.appDir,e),d;try{d=await t.readdir(u)}catch{return}let f=[],p=[];for(let e of d){let r=n.join(u,e),i=await t.stat(r);i.isDirectory()?this.shouldScanDirectory(e)&&p.push(e):i.isFile()&&f.push(e)}await this.processSpecialFiles(e,f,r,i,a,o,s,c,l);for(let t of p){let u=e?n.join(e,t):t;await this.scanDirectory(u,r,i,a,o,s,c,l)}}async processSpecialFiles(e,r,a,o,s,c,l,u,d){let f=this.pathToRoute(e),p=this.findFile(r,i.PAGE);if(p){let t=this.parseRouteSegments(e),r=this.extractParams(t);a.push({path:f,filePath:n.join(e,p),segments:t,params:r,isDynamic:r.length>0})}let m=this.findFile(r,i.LAYOUT);if(m){let t=this.getParentPath(e);o.push({path:f,filePath:n.join(e,m),parentPath:t?this.pathToRoute(t):void 0})}let h=this.findFile(r,i.LOADING);if(h){let t=this.generateComponentId(f,`loading`);s.push({path:f,filePath:n.join(e,h),componentId:t})}let g=this.findFile(r,i.ERROR);g&&c.push({path:f,filePath:n.join(e,g)});let _=this.findFile(r,i.NOT_FOUND);_&&l.push({path:f,filePath:n.join(e,_)});let v=this.findFile(r,i.OG_IMAGE);if(v){let r=n.join(e,v),i=n.join(this.appDir,r),a,o,s;try{let e=await t.readFile(i,`utf-8`),n=e.match(/export\s+const\s+size\s*=\s*\{\s*width\s*:\s*(\d+)\s*,\s*height\s*:\s*(\d+)\s*[,}]/);n&&(a=Number.parseInt(n[1],10),o=Number.parseInt(n[2],10));let r=e.match(/export\s+const\s+contentType\s*=\s*['"]([^'"]+)['"]/);r&&(s=r[1])}catch{}d.push({path:f,filePath:r,width:a,height:o,contentType:s})}let y=this.findFile(r,i.ROUTE);if(y){let t=await this.processApiRouteFile(e,y);u.push(t)}}findFile(e,t){for(let n of this.extensions){let r=`${t}${n}`;if(e.includes(r))return r}}pathToRoute(e){return e?`/${e.replace(/\\/g,`/`).split(`/`).filter(Boolean).map(e=>a.OPTIONAL_CATCH_ALL.test(e)?`[[...${e.match(a.OPTIONAL_CATCH_ALL)[1]}]]`:a.CATCH_ALL.test(e)?`[...${e.match(a.CATCH_ALL)[1]}]`:a.DYNAMIC.test(e)?`[${e.match(a.DYNAMIC)[1]}]`:e).join(`/`)}`:`/`}parseRouteSegments(e){return e?e.split(/[/\\]/).filter(Boolean).map(e=>a.OPTIONAL_CATCH_ALL.test(e)?{type:`optional-catch-all`,value:e,param:e.match(a.OPTIONAL_CATCH_ALL)[1]}:a.CATCH_ALL.test(e)?{type:`catch-all`,value:e,param:e.match(a.CATCH_ALL)[1]}:a.DYNAMIC.test(e)?{type:`dynamic`,value:e,param:e.match(a.DYNAMIC)[1]}:{type:`static`,value:e}):[]}extractParams(e){return e.filter(e=>e.param!==void 0).map(e=>e.param)}getParentPath(e){if(!e)return null;let t=e.split(/[/\\]/).filter(Boolean);return t.length===0?null:t.slice(0,-1).join(`/`)}generateComponentId(e,t){return`${t}:${e}`}shouldScanDirectory(e){return![`node_modules`,`.git`,`dist`,`build`,`__tests__`,`test`,`tests`,`coverage`].includes(e)&&!e.startsWith(`.`)}sortRoutes(e){return e.sort((e,t)=>{let n=e=>{if(!e.isDynamic)return 0;let t=e.segments.some(e=>e.type===`catch-all`);return e.segments.some(e=>e.type===`optional-catch-all`)?3:t?2:1},r=n(e),i=n(t);if(r!==i)return r-i;let a=e.path.split(`/`).length,o=t.path.split(`/`).length;return a===o?e.path.localeCompare(t.path):o-a})}sortApiRoutes(e){return e.sort((e,t)=>{if(!e.isDynamic&&t.isDynamic)return-1;if(e.isDynamic&&!t.isDynamic)return 1;let n=e.path.split(`/`).length,r=t.path.split(`/`).length;return n===r?e.path.localeCompare(t.path):n-r})}sortLayouts(e){return e.sort((e,t)=>e.path===`/`&&t.path!==`/`?-1:t.path===`/`&&e.path!==`/`?1:e.path.split(`/`).length-t.path.split(`/`).length)}async detectHttpMethods(e){let r=n.join(this.appDir,e),i=await t.readFile(r,`utf-8`),a=[];for(let e of o){let t=RegExp(`export\\s+(?:async\\s+)?function\\s+${e}\\s*\\(`),n=RegExp(`export\\s+(?:async\\s+)?(?:const|let|var)\\s+${e}\\s*=`);(t.test(i)||n.test(i))&&a.push(e)}return a}async processApiRouteFile(e,t){let r=n.join(e,t),i=this.pathToRoute(e),a=this.parseRouteSegments(e),o=this.extractParams(a),s=await this.detectHttpMethods(r);return{path:i,filePath:r,segments:a,params:o,isDynamic:o.length>0,methods:s}}};async function c(e,t={}){return new s({appDir:e,...t}).generateManifest()}export{r as n,c as t};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
//#region src/runtime/AppRouterProvider.d.ts
|
|
5
|
+
interface AppRouterProviderProps {
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
initialPayload?: any;
|
|
8
|
+
onNavigate?: (detail: NavigationDetail) => void;
|
|
9
|
+
}
|
|
10
|
+
interface NavigationDetail {
|
|
11
|
+
from: string;
|
|
12
|
+
to: string;
|
|
13
|
+
navigationId: number;
|
|
14
|
+
options: any;
|
|
15
|
+
routeInfo?: any;
|
|
16
|
+
abortSignal?: AbortSignal;
|
|
17
|
+
rscWireFormat?: string;
|
|
18
|
+
isStreaming?: boolean;
|
|
19
|
+
}
|
|
20
|
+
declare function AppRouterProvider({
|
|
21
|
+
children,
|
|
22
|
+
initialPayload,
|
|
23
|
+
onNavigate
|
|
24
|
+
}: AppRouterProviderProps): react_jsx_runtime0.JSX.Element;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { AppRouterProvider };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use client";import*as e from"react";import{Suspense as t,useEffect as n,useRef as r,useState as i,useTransition as a}from"react";import{Fragment as o,jsx as s,jsxs as c}from"react/jsx-runtime";function l(){return c(`div`,{style:{position:`fixed`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,display:`flex`,alignItems:`center`,justifyContent:`center`,zIndex:9999},children:[s(`div`,{style:{width:`40px`,height:`40px`,border:`4px solid rgba(0, 0, 0, 0.1)`,borderTopColor:`#3b82f6`,borderRadius:`50%`,animation:`spin 1s linear infinite`}}),s(`style`,{children:`
|
|
2
|
+
@keyframes spin {
|
|
3
|
+
to { transform: rotate(360deg); }
|
|
4
|
+
}
|
|
5
|
+
`})]})}function u({children:u,initialPayload:d,onNavigate:f}){let[p,m]=i(d),[,h]=i(0),g=r({x:0,y:0}),_=r(new Map),v=r(null),[,y]=a(),b=r(0),x=r(new Map),S=r([]),C=r(null),w=r(0),[T,E]=i(null),D=()=>{if(typeof document>`u`)return;let e=document.querySelectorAll(`form`);_.current.clear(),e.forEach((e,t)=>{let n=new FormData(e);_.current.set(`form-${t}`,n)})},O=()=>{typeof document>`u`||document.querySelectorAll(`form`).forEach((e,t)=>{let n=_.current.get(`form-${t}`);n&&n.forEach((t,n)=>{let r=e.elements.namedItem(n);r&&(r.type===`checkbox`||r.type===`radio`?r.checked=t===`on`:r.value=t)})})},k=(e,t,n,r)=>{let i={timestamp:Date.now(),error:e,type:t,details:n,filePath:r};S.current.push(i),w.current+=1,S.current.length>10&&S.current.shift(),console.error(`[rari] HMR: Failure detected`,{type:t,details:n,filePath:r,consecutiveFailures:w.current,error:e.message,stack:e.stack,timestamp:new Date(i.timestamp).toISOString()}),w.current>=2&&E(i),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`rari:hmr-failure`,{detail:i}))},A=()=>{setTimeout(()=>{window.location.reload()},1e3)},j=()=>{w.current>0&&(w.current=0)},M=e=>{if(!C.current)return!1;if(e===C.current)return!0;let t=e.match(/"timestamp":(\d+)/);if(t){let e=Number.parseInt(t[1],10);if(Date.now()-e>5e3)return!0}return!1};function N(t,n,r,i,a){if(!t)return null;if(typeof t==`string`||typeof t==`number`||typeof t==`boolean`)return t;if(Array.isArray(t)){if(t.length>=4&&t[0]===`$`){let[,o,s,c]=t,l=o;if(typeof o==`string`&&o.startsWith(`$`)&&i){let e=o.substring(1);if(/^\d+$/.test(e)){let e=i.get(o);e&&(e===`$Sreact.suspense`||e===`react.suspense`?l=`Suspense`:console.warn(`[rari] AppRouter: Unknown symbol:`,e))}}if(l===`Suspense`||o===`Suspense`){let t=V(c,n,r,i,a);return e.createElement(e.Suspense,s?{...t,key:s}:t)}if(typeof l==`string`&&l.startsWith(`$L`)){let t=n.get(l);if(!t)return null;let o=globalThis[`~clientComponents`]?.[t.id]?.component;if(!o||typeof o!=`function`)return null;let u=s||`fallback-${Math.random()}`,d={...c,children:c.children?N(c.children,n,r,i,a):void 0};return e.createElement(o,{key:u,...d})}if(!l||typeof l!=`string`&&typeof l!=`function`)return console.error(`[rari] AppRouter: Invalid component type:`,{type:l,typeOf:typeof l,serverKey:s,props:c,rscData:t}),null;let u=V(c,n,r,i,a);return e.createElement(l,s?{...u,key:s}:u)}return t.map((t,o)=>{let s=N(t,n,r,i,a);return s?typeof s==`object`&&e.isValidElement(s)&&!s.key?e.cloneElement(s,{key:o}):s:null}).filter(Boolean)}return t}let P=r(new Set),F=r(new Map),I=r(new Map),L=r(new Map),R=r(new Map);function z(e){if(!R.current.has(e)){let t=new Promise(()=>{});R.current.set(e,t)}return R.current.get(e)}function B({contentRef:e}){let t=F.current,n=I.current,r=L.current;if(t.has(e))return R.current.delete(e),N(t.get(e),n,void 0,r,t);throw z(e)}function V(t,n,r,i,a){if(!t||typeof t!=`object`)return t;a&&(F.current=a),n&&(I.current=n),i&&(L.current=i);let o={};for(let s in t)if(Object.hasOwn(t,s))if(s===`children`){let c=t.children;if(typeof c==`string`&&c.startsWith(`$L`))if(a&&a.has(c)){let e=a.get(c);P.current.delete(c),o[s]=N(e,n,r,i,a)}else P.current.add(c),o[s]=e.createElement(B,{key:`lazy-${c}`,contentRef:c});else o[s]=c?N(c,n,r,i,a):void 0}else s===`dangerouslySetInnerHTML`?o[s]=t[s]:o[s]=N(t[s],n,r,i,a);return o}let H=(t,n=!1)=>{try{let r=t.trim().split(`
|
|
6
|
+
`),i=new Map,a=new Map,o=new Map,s=null,c=[],l=null,u=null;for(let e=0;e<r.length;e++){let t=r[e],d=t.indexOf(`:`);if(d===-1)continue;let f=t.substring(0,d),p=t.substring(d+1);try{if(p.startsWith(`"$S`)){let e=p.slice(1,-1);a.set(`$${f}`,e);continue}if(p.startsWith(`I[`)){let t=JSON.parse(p.substring(1));if(Array.isArray(t)&&t.length>=3){let[r,a,o]=t;i.set(`$L${f}`,{id:r,chunks:Array.isArray(a)?a:[a],name:o||`default`}),n&&r.includes(`layout`)&&(l!==null&&u!==null&&c.push({layoutPath:l,startLine:u,endLine:e-1,props:{}}),l=r,u=e)}}else if(p.startsWith(`[`)){let e=JSON.parse(p);if(o.set(`$L${f}`,e),n&&Array.isArray(e)&&e.length>=4&&typeof e[1]==`string`&&e[1].startsWith(`$L`)){let t=e[1],n=i.get(t);if(n&&n.id.includes(`layout`)){let t=e[3]||{};if(l&&u!==null){let e=c.find(e=>e.layoutPath===l&&e.startLine===u);e&&(e.props=t)}}}!s&&Array.isArray(e)&&(e[0]===`$`?s=e:Array.isArray(e[0])&&e[0][0]===`$`&&(s=e.length===1?e[0]:e))}}catch(e){console.error(`[rari] AppRouter: Failed to parse RSC line:`,t,e)}}if(n&&l!==null&&u!==null&&c.push({layoutPath:l,startLine:u,endLine:r.length-1,props:{}}),s&&Array.isArray(s)){if(s[0]===`$`)s=N(s,i,void 0,a,o);else if(Array.isArray(s[0])){let t=s.map(e=>Array.isArray(e)&&e[0]===`$`?N(e,i,void 0,a,o):e).filter(t=>t==null||typeof t==`string`||typeof t==`number`||typeof t==`boolean`||e.isValidElement(t));s=t.length===1?t[0]:t}}return{element:s,modules:i,symbols:a,wireFormat:t,layoutBoundaries:n?c:void 0}}catch(e){throw console.error(`[rari] AppRouter: Failed to parse RSC wire format:`,e),e}},U=async(e,t)=>{let n=e||window.location.pathname,r=x.current.get(n);if(r)return r;let i=(async()=>{try{let e=(window.location.origin.includes(`:5173`)?`http://localhost:3000`:window.location.origin)+n+window.location.search,r=await fetch(e,{headers:{Accept:`text/x-component`,"Cache-Control":`no-cache`,Pragma:`no-cache`},cache:`no-store`,signal:t});if(!r.ok){let t=Error(`Failed to fetch RSC data: ${r.status} ${r.statusText}`);throw k(t,`fetch`,`HTTP ${r.status} when fetching ${e}`,window.location.pathname),t}let i=await r.text();if(M(i)&&p)return p;let a;try{a=H(i,!1)}catch(e){let t=e instanceof Error?e:Error(String(e));throw k(t,`parse`,`Failed to parse RSC wire format: ${t.message}`,window.location.pathname),t}return m(a),C.current=i,j(),a}catch(e){throw e instanceof Error&&!e.message.includes(`Failed to fetch RSC data`)&&!e.message.includes(`Failed to parse`)&&k(e,`network`,`Network error: ${e.message}`,window.location.pathname),console.error(`[rari] AppRouter: Error fetching RSC payload:`,e),e}finally{x.current.delete(n)}})();return x.current.set(n,i),i};n(()=>{if(typeof window>`u`)return;let e=async e=>{let t=e.detail;b.current=t.navigationId,v.current=null,g.current={x:window.scrollX,y:window.scrollY},D(),y(async()=>{try{t.rscWireFormat?(m(H(t.rscWireFormat,!1)),C.current=t.rscWireFormat,j()):t.isStreaming?v.current=[]:await U(t.to,t.abortSignal),b.current===t.navigationId&&(h(e=>e+1),E(null),f&&f(t))}catch(e){if(e instanceof Error&&e.name===`AbortError`)return;console.error(`[rari] AppRouter: Navigation failed:`,e),window.dispatchEvent(new CustomEvent(`rari:navigate-error`,{detail:{from:t.from,to:t.to,error:e,navigationId:t.navigationId}})),w.current>=3&&A()}finally{t.options?.historyKey||requestAnimationFrame(()=>{t.options?.scroll!==!1&&window.scrollTo(0,0)})}})},t=async()=>{g.current={x:window.scrollX,y:window.scrollY},D();try{await U(),h(e=>e+1),E(null)}catch(e){console.error(`[rari] AppRouter: HMR update failed:`,e),w.current>=3&&A()}finally{requestAnimationFrame(()=>{window.scrollTo(g.current.x,g.current.y),O()})}},n=async()=>{try{await U(),h(e=>e+1),E(null)}catch(e){console.error(`[rari] AppRouter: RSC invalidation failed:`,e),w.current>=3&&A()}},r=async()=>{try{await U(),E(null)}catch(e){console.error(`[rari] AppRouter: Manifest update failed:`,e),w.current>=3&&A()}},i=e=>{let t=e.detail.rscRow;if(!(!t||!t.trim())){v.current||=[],v.current.push(t);try{let e=v.current.join(`
|
|
7
|
+
`),t=H(e,!1);v.current.length<=2&&e.includes(`~boundaryId`)?(m(t),h(e=>e+1)):y(()=>{m(t),h(e=>e+1)})}catch(e){console.error(`[rari] AppRouter: Failed to parse streaming RSC row:`,e)}}};return window.addEventListener(`rari:navigate`,e),window.addEventListener(`rari:app-router-rerender`,t),window.addEventListener(`rari:rsc-invalidate`,n),window.addEventListener(`rari:app-router-manifest-updated`,r),window.addEventListener(`rari:rsc-row`,i),()=>{window.removeEventListener(`rari:navigate`,e),window.removeEventListener(`rari:app-router-rerender`,t),window.removeEventListener(`rari:rsc-invalidate`,n),window.removeEventListener(`rari:app-router-manifest-updated`,r),window.removeEventListener(`rari:rsc-row`,i)}},[f]);let W=()=>{window.location.reload()},G=()=>{E(null)},K=e=>{if(!e||typeof e!=`object`)return null;if(e.type===`html`&&e.props?.children){let t=Array.isArray(e.props.children)?e.props.children:[e.props.children];for(let e of t)if(e&&typeof e==`object`&&e.type===`body`)return e.props?.children||null}return e},q=u;return p?.element&&(q=K(p.element)||p.element),Array.isArray(q)&&q.length===1&&e.isValidElement(q[0])&&(q=q[0]),q&&typeof q==`object`&&!e.isValidElement(q)&&(console.error(`[rari] AppRouter: Invalid content to render:`,q),q=u),c(o,{children:[T&&c(`div`,{style:{position:`fixed`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,padding:`24px`,background:`rgba(220, 38, 38, 0.95)`,color:`white`,borderRadius:`8px`,fontSize:`14px`,zIndex:1e4,maxWidth:`500px`,boxShadow:`0 4px 6px rgba(0, 0, 0, 0.3)`},children:[s(`div`,{style:{marginBottom:`16px`,fontWeight:`bold`,fontSize:`16px`},children:`⚠️ HMR Update Failed`}),c(`div`,{style:{marginBottom:`12px`,opacity:.9},children:[T.type===`fetch`&&`Failed to fetch updated content from server.`,T.type===`parse`&&`Failed to parse server response.`,T.type===`stale`&&`Server returned stale content.`,T.type===`network`&&`Network error occurred.`]}),s(`div`,{style:{marginBottom:`16px`,fontSize:`12px`,opacity:.8,fontFamily:`monospace`},children:T.details}),c(`div`,{style:{marginBottom:`12px`,fontSize:`12px`,opacity:.7},children:[`Consecutive failures:`,` `,w.current,` `,`/`,` `,3]}),c(`div`,{style:{display:`flex`,gap:`8px`},children:[s(`button`,{onClick:W,type:`button`,style:{padding:`8px 16px`,background:`white`,color:`#dc2626`,border:`none`,borderRadius:`4px`,cursor:`pointer`,fontWeight:`bold`,fontSize:`14px`},children:`Refresh Page`}),s(`button`,{onClick:G,type:`button`,style:{padding:`8px 16px`,background:`rgba(255, 255, 255, 0.2)`,color:`white`,border:`1px solid rgba(255, 255, 255, 0.3)`,borderRadius:`4px`,cursor:`pointer`,fontSize:`14px`},children:`Dismiss`})]}),s(`div`,{style:{marginTop:`12px`,fontSize:`11px`,opacity:.6},children:`Check the console for detailed error logs.`})]}),s(t,{fallback:s(l,{}),children:q})]})}export{u as AppRouterProvider};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/runtime/LoadingErrorBoundary.d.ts
|
|
4
|
+
interface LoadingErrorBoundaryProps {
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
}
|
|
7
|
+
declare class LoadingErrorBoundary extends React.Component<LoadingErrorBoundaryProps> {
|
|
8
|
+
componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void;
|
|
9
|
+
render(): React.ReactNode;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { LoadingErrorBoundary };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import*as e from"react";var t=class extends e.Component{componentDidCatch(e,t){console.error(`[rari] Loading: Loading component failed to render:`,e),console.error(`[rari] Loading: Error info:`,t)}render(){return this.props.children}};export{t as LoadingErrorBoundary};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{t as e}from"../get-client-component-
|
|
1
|
+
import{t as e}from"../get-client-component-B2SS0Ben.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
2
|
/*! @preserve CLIENT_COMPONENT_IMPORTS_PLACEHOLDER */
|
|
3
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
4
|
/*! @preserve CLIENT_COMPONENT_REGISTRATIONS_PLACEHOLDER */
|
|
@@ -1 +1 @@
|
|
|
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{s as __CLIENT_REFERENCE_REGISTRY__,c as __SERVER_REFERENCE_REGISTRY__,o as createClientModuleProxy,i as registerClientComponent,r as registerClientReference,a as registerServerReference};
|