rari 0.7.10 → 0.7.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/RariRequest-Bd8ha4ba.mjs +1 -0
- package/dist/cli.mjs +37 -53
- package/dist/client.d.mts +1 -1
- package/dist/client.mjs +1 -1
- package/dist/image/index.mjs +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/platform.d.mts +5 -0
- package/dist/platform.mjs +17 -0
- package/dist/proxy/runtime-executor.mjs +1 -1
- package/dist/routes-VWQ7KgNh.mjs +1 -0
- package/dist/server-build-CPWsut0H.mjs +1 -0
- package/dist/{server-build-D9KCO66Y.mjs → server-build-Dcu2KENc.mjs} +1 -1
- package/dist/vite-BSlOEZF0.d.mts +7689 -0
- package/dist/vite-CnkUNT-E.mjs +72 -0
- package/dist/vite.d.mts +2 -2
- package/dist/vite.mjs +1 -1
- package/package.json +11 -12
- package/src/router/vite-plugin.ts +20 -24
- package/dist/RariRequest-DvF3tBO7.mjs +0 -1
- package/dist/platform-iVwv_Z06.mjs +0 -1
- package/dist/routes-DxBzqo4i.mjs +0 -1
- package/dist/server-build-tqzWSQbG.mjs +0 -1
- package/dist/vite-BrjcNDVC.d.mts +0 -293
- package/dist/vite-CYAYYRQ5.mjs +0 -74
- /package/dist/{RariRequest-D2LI2Fku.mjs → RariRequest-CW-JhbGM.mjs} +0 -0
- /package/dist/{chunk-C7YniUGR.mjs → chunk-TmZEKRxo.mjs} +0 -0
- /package/dist/{constants-DCDaPbFM.mjs → constants-CD3aqqK8.mjs} +0 -0
- /package/dist/{railway-hYu3gNGo.mjs → railway-BkeFMLcc.mjs} +0 -0
- /package/dist/{render-sqptvp3C.mjs → render-B2YpwDlB.mjs} +0 -0
- /package/dist/{robots-generator-BalXAHqI.mjs → robots-generator-AcmtuCNy.mjs} +0 -0
- /package/dist/{routes-2L4UuyND.mjs → routes-Bq7zysPc.mjs} +0 -0
- /package/dist/{runtime-client-r4vTOC5x.mjs → runtime-client-B15ZQXrE.mjs} +0 -0
- /package/dist/{runtime-client-BV3qaQrj.d.mts → runtime-client-BbLFFlfZ.d.mts} +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-present Ryan Skinner
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./RariRequest-CW-JhbGM.mjs";export{e as RariRequest};
|
package/dist/cli.mjs
CHANGED
|
@@ -1,77 +1,61 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{
|
|
3
|
-
|
|
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";const s=!(a.env.NO_COLOR||a.argv.includes(`--no-color`))&&(a.env.FORCE_COLOR||a.argv.includes(`--color`)||a.platform===`win32`||a.stdout?.isTTY&&a.env.TERM!==`dumb`||a.env.CI);function c(e,t,n=e){return r=>{let i=String(r),a=i.indexOf(t,e.length);return~a?e+l(i,t,n,a)+t:e+i+t}}function l(e,t,n,r){let i=``,a=0;do i+=e.substring(a,r)+n,a=r+t.length,r=e.indexOf(t,a);while(~r);return i+e.substring(a)}const u=s?c:()=>String;var d={isColorSupported:s,bold:u(`\x1B[1m`,`\x1B[22m`,`\x1B[22m\x1B[1m`),red:u(`\x1B[31m`,`\x1B[39m`),green:u(`\x1B[32m`,`\x1B[39m`),yellow:u(`\x1B[33m`,`\x1B[39m`),blue:u(`\x1B[34m`,`\x1B[39m`),cyan:u(`\x1B[36m`,`\x1B[39m`),gray:u(`\x1B[90m`,`\x1B[39m`)};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(e){console.warn(`${d.blue(`info`)} ${e}`)}function g(e){console.warn(`${d.green(`✓`)} ${e}`)}function _(e){console.error(`${d.red(`✗`)} ${e}`)}function v(){return!!(a.env.RAILWAY_ENVIRONMENT||a.env.RAILWAY_PROJECT_ID||a.env.RAILWAY_SERVICE_ID)}function y(){return!!(a.env.RENDER||a.env.RENDER_SERVICE_ID||a.env.RENDER_SERVICE_NAME)}function b(){return v()||y()}function x(){return v()?`Railway`:y()?`Render`:`local`}function S(){return{port:a.env.PORT||a.env.RSC_PORT||`3000`,mode:a.env.NODE_ENV||`production`,host:b()?`0.0.0.0`:`127.0.0.1`}}async function C(){let{existsSync:e,rmSync:t}=await import(`node:fs`),{resolve:n}=await import(`node:path`),{spawn:r}=await import(`node:child_process`),i=n(a.cwd(),`dist`);e(i)&&(h(`Cleaning dist folder...`),t(i,{recursive:!0,force:!0})),h(`Type checking...`);let o=r(`npx`,[`tsgo`],{stdio:`inherit`,cwd:a.cwd(),shell:!0});await new Promise((e,t)=>{o.on(`exit`,n=>{n===0?(g(`Type check passed`),e()):(_(`Type check failed with code ${n}`),t(Error(`Type check failed with code ${n}`)))}),o.on(`error`,t)}),h(`Building for production...`);let s=r(`npx`,[`vite`,`build`],{stdio:`inherit`,cwd:a.cwd(),shell:!0});await new Promise((e,t)=>{s.on(`exit`,n=>{n===0?(g(`Build complete`),e()):(_(`Build failed with code ${n}`),t(Error(`Build failed with code ${n}`)))}),s.on(`error`,t)})}async function w(){let{existsSync:e}=await import(`node:fs`),{resolve:t}=await import(`node:path`),{spawn:n}=await import(`node:child_process`);if(!e(t(a.cwd(),`dist`))){h(`First run detected - building project...`);let e=n(`npx`,[`vite`,`build`,`--mode`,`development`],{stdio:`inherit`,cwd:a.cwd(),shell:!0});await new Promise((t,n)=>{e.on(`exit`,e=>{e===0?(g(`Initial build complete`),t()):(_(`Build failed with code ${e}`),n(Error(`Build failed with code ${e}`)))}),e.on(`error`,n)})}h(`Starting Vite dev server...`);let r=n(`npx`,[`vite`],{stdio:`inherit`,cwd:a.cwd(),shell:!0}),i=()=>{h(`Shutting down dev server...`),r.kill(`SIGTERM`)};return a.on(`SIGINT`,i),a.on(`SIGTERM`,i),r.on(`error`,e=>{_(`Failed to start Vite: ${e.message}`),a.exit(1)}),r.on(`exit`,e=>{e!==0&&e!==null&&(_(`Vite exited with code ${e}`),a.exit(e))}),new Promise(()=>{})}async function T(){let n;try{n=e()}catch{_(`Failed to obtain rari binary`),_(t()),a.exit(1)}let{port:r,mode:i,host:s}=S();if(b()){let e=x();h(`${e} environment detected`),h(`Starting rari server for ${e} deployment...`),h(`Mode: ${i}, Host: ${s}, Port: ${r}`),h(`using binary: ${n}`)}let c=o(n,[`--mode`,i,`--port`,r,`--host`,s],{stdio:`inherit`,cwd:a.cwd(),env:{...a.env,RUST_LOG:a.env.RUST_LOG||`error`}}),l=()=>{h(`shutting down...`),c.kill(`SIGTERM`)};return a.on(`SIGINT`,l),a.on(`SIGTERM`,l),c.on(`error`,e=>{_(`Failed to start rari server: ${e.message}`),e.message.includes(`ENOENT`)&&_(`Binary not found. Please ensure rari is properly installed.`),a.exit(1)}),c.on(`exit`,(e,t)=>{t?h(`server stopped by signal ${t}`):e===0?g(`server stopped successfully`):(_(`server exited with code ${e}`),a.exit(e||1))}),new Promise(()=>{})}async function E(){h(`Setting up Railway deployment...`),b()&&(_(`Already running in ${x()} environment. Use "rari start" instead.`),a.exit(1));let{createRailwayDeployment:e}=await import(`./railway-BkeFMLcc.mjs`);await e()}async function D(){h(`Setting up Render deployment...`),b()&&(_(`Already running in ${x()} environment. Use "rari start" instead.`),a.exit(1));let{createRenderDeployment:e}=await import(`./render-B2YpwDlB.mjs`);await e()}async function O(){switch(p){case void 0:case`help`:case`--help`:case`-h`:console.warn(`${d.bold(`rari CLI`)}
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
${d.bold(`Usage:`)}
|
|
6
|
+
${d.cyan(`rari dev`)} Start the development server with Vite
|
|
7
|
+
${d.cyan(`rari build`)} Build for production
|
|
8
|
+
${d.cyan(`rari start`)} Start the rari server (defaults to production)
|
|
9
|
+
${d.cyan(`rari deploy railway`)} Setup Railway deployment
|
|
10
|
+
${d.cyan(`rari deploy render`)} Setup Render deployment
|
|
11
|
+
${d.cyan(`rari help`)} Show this help message
|
|
6
12
|
|
|
7
|
-
|
|
13
|
+
${d.bold(`Environment Variables:`)}
|
|
14
|
+
${d.yellow(`PORT`)} Server port (default: 3000)
|
|
15
|
+
${d.yellow(`RSC_PORT`)} Alternative server port
|
|
16
|
+
${d.yellow(`NODE_ENV`)} Environment (default: production for start, development for dev)
|
|
17
|
+
${d.yellow(`RUST_LOG`)} Rust logging level (default: info)
|
|
8
18
|
|
|
9
|
-
|
|
19
|
+
${d.bold(`Examples:`)}
|
|
20
|
+
${d.gray(`# Start development server with Vite`)}
|
|
21
|
+
${d.cyan(`rari dev`)}
|
|
10
22
|
|
|
11
|
-
|
|
23
|
+
${d.gray(`# Build for production`)}
|
|
24
|
+
${d.cyan(`rari build`)}
|
|
12
25
|
|
|
13
|
-
|
|
26
|
+
${d.gray(`# Start production server (default)`)}
|
|
27
|
+
${d.cyan(`rari start`)}
|
|
14
28
|
|
|
15
|
-
|
|
29
|
+
${d.gray(`# Start in development mode`)}
|
|
30
|
+
${d.cyan(`NODE_ENV=development rari start`)}
|
|
16
31
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
`)){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)}}}}g();const[,,_,...v]=a.argv;function y(e){console.warn(`${h.blue(`info`)} ${e}`)}function b(e){console.warn(`${h.green(`✓`)} ${e}`)}function x(e){console.error(`${h.red(`✗`)} ${e}`)}function S(){return!!(a.env.RAILWAY_ENVIRONMENT||a.env.RAILWAY_PROJECT_ID||a.env.RAILWAY_SERVICE_ID)}function C(){return!!(a.env.RENDER||a.env.RENDER_SERVICE_ID||a.env.RENDER_SERVICE_NAME)}function w(){return S()||C()}function T(){return S()?`Railway`:C()?`Render`:`local`}function E(){return{port:a.env.PORT||a.env.RSC_PORT||`3000`,mode:a.env.NODE_ENV||`production`,host:w()?`0.0.0.0`:`127.0.0.1`}}async function D(){let{existsSync:e,rmSync:t}=await import(`node:fs`),{resolve:n}=await import(`node:path`),{spawn:r}=await import(`node:child_process`),i=n(a.cwd(),`dist`);e(i)&&(y(`Cleaning dist folder...`),t(i,{recursive:!0,force:!0})),y(`Type checking...`);let o=r(`npx`,[`tsgo`],{stdio:`inherit`,cwd:a.cwd(),shell:!0});await new Promise((e,t)=>{o.on(`exit`,n=>{n===0?(b(`Type check passed`),e()):(x(`Type check failed with code ${n}`),t(Error(`Type check failed with code ${n}`)))}),o.on(`error`,t)}),y(`Building for production...`);let s=r(`npx`,[`vite`,`build`],{stdio:`inherit`,cwd:a.cwd(),shell:!0});await new Promise((e,t)=>{s.on(`exit`,n=>{n===0?(b(`Build complete`),e()):(x(`Build failed with code ${n}`),t(Error(`Build failed with code ${n}`)))}),s.on(`error`,t)})}async function O(){let{existsSync:e}=await import(`node:fs`),{resolve:t}=await import(`node:path`),{spawn:n}=await import(`node:child_process`);if(!e(t(a.cwd(),`dist`))){y(`First run detected - building project...`);let e=n(`npx`,[`vite`,`build`,`--mode`,`development`],{stdio:`inherit`,cwd:a.cwd(),shell:!0});await new Promise((t,n)=>{e.on(`exit`,e=>{e===0?(b(`Initial build complete`),t()):(x(`Build failed with code ${e}`),n(Error(`Build failed with code ${e}`)))}),e.on(`error`,n)})}y(`Starting Vite dev server...`);let r=n(`npx`,[`vite`],{stdio:`inherit`,cwd:a.cwd(),shell:!0}),i=()=>{y(`Shutting down dev server...`),r.kill(`SIGTERM`)};return a.on(`SIGINT`,i),a.on(`SIGTERM`,i),r.on(`error`,e=>{x(`Failed to start Vite: ${e.message}`),a.exit(1)}),r.on(`exit`,e=>{e!==0&&e!==null&&(x(`Vite exited with code ${e}`),a.exit(e))}),new Promise(()=>{})}async function k(){let e;try{e=l()}catch{x(`Failed to obtain rari binary`),x(u()),a.exit(1)}let{port:t,mode:n,host:r}=E();if(w()){let i=T();y(`${i} environment detected`),y(`Starting rari server for ${i} deployment...`),y(`Mode: ${n}, Host: ${r}, Port: ${t}`),y(`using binary: ${e}`)}let i=o(e,[`--mode`,n,`--port`,t,`--host`,r],{stdio:`inherit`,cwd:a.cwd(),env:{...a.env,RUST_LOG:a.env.RUST_LOG||`error`}}),s=()=>{y(`shutting down...`),i.kill(`SIGTERM`)};return a.on(`SIGINT`,s),a.on(`SIGTERM`,s),i.on(`error`,e=>{x(`Failed to start rari server: ${e.message}`),e.message.includes(`ENOENT`)&&x(`Binary not found. Please ensure rari is properly installed.`),a.exit(1)}),i.on(`exit`,(e,t)=>{t?y(`server stopped by signal ${t}`):e===0?b(`server stopped successfully`):(x(`server exited with code ${e}`),a.exit(e||1))}),new Promise(()=>{})}async function A(){y(`Setting up Railway deployment...`),w()&&(x(`Already running in ${T()} environment. Use "rari start" instead.`),a.exit(1));let{createRailwayDeployment:e}=await import(`./railway-hYu3gNGo.mjs`);await e()}async function j(){y(`Setting up Render deployment...`),w()&&(x(`Already running in ${T()} environment. Use "rari start" instead.`),a.exit(1));let{createRenderDeployment:e}=await import(`./render-sqptvp3C.mjs`);await e()}async function M(){switch(_){case void 0:case`help`:case`--help`:case`-h`:console.warn(`${h.bold(`rari CLI`)}
|
|
32
|
+
${d.gray(`# Start production server on port 8080`)}
|
|
33
|
+
${d.cyan(`PORT=8080 rari start`)}
|
|
20
34
|
|
|
21
|
-
${
|
|
22
|
-
${
|
|
23
|
-
${h.cyan(`rari build`)} Build for production
|
|
24
|
-
${h.cyan(`rari start`)} Start the rari server (defaults to production)
|
|
25
|
-
${h.cyan(`rari deploy railway`)} Setup Railway deployment
|
|
26
|
-
${h.cyan(`rari deploy render`)} Setup Render deployment
|
|
27
|
-
${h.cyan(`rari help`)} Show this help message
|
|
35
|
+
${d.gray(`# Setup Railway deployment`)}
|
|
36
|
+
${d.cyan(`rari deploy railway`)}
|
|
28
37
|
|
|
29
|
-
${
|
|
30
|
-
${
|
|
31
|
-
${h.yellow(`RSC_PORT`)} Alternative server port
|
|
32
|
-
${h.yellow(`NODE_ENV`)} Environment (default: production for start, development for dev)
|
|
33
|
-
${h.yellow(`RUST_LOG`)} Rust logging level (default: info)
|
|
38
|
+
${d.gray(`# Setup Render deployment`)}
|
|
39
|
+
${d.cyan(`rari deploy render`)}
|
|
34
40
|
|
|
35
|
-
${
|
|
36
|
-
${
|
|
37
|
-
${h.cyan(`rari dev`)}
|
|
41
|
+
${d.gray(`# Start with debug logging`)}
|
|
42
|
+
${d.cyan(`RUST_LOG=debug rari start`)}
|
|
38
43
|
|
|
39
|
-
|
|
40
|
-
${
|
|
41
|
-
|
|
42
|
-
${h.gray(`# Start production server (default)`)}
|
|
43
|
-
${h.cyan(`rari start`)}
|
|
44
|
-
|
|
45
|
-
${h.gray(`# Start in development mode`)}
|
|
46
|
-
${h.cyan(`NODE_ENV=development rari start`)}
|
|
47
|
-
|
|
48
|
-
${h.gray(`# Start production server on port 8080`)}
|
|
49
|
-
${h.cyan(`PORT=8080 rari start`)}
|
|
50
|
-
|
|
51
|
-
${h.gray(`# Setup Railway deployment`)}
|
|
52
|
-
${h.cyan(`rari deploy railway`)}
|
|
53
|
-
|
|
54
|
-
${h.gray(`# Setup Render deployment`)}
|
|
55
|
-
${h.cyan(`rari deploy render`)}
|
|
56
|
-
|
|
57
|
-
${h.gray(`# Start with debug logging`)}
|
|
58
|
-
${h.cyan(`RUST_LOG=debug rari start`)}
|
|
59
|
-
|
|
60
|
-
${h.bold(`Deployment:`)}
|
|
61
|
-
${h.cyan(`rari deploy railway`)} Creates Railway deployment files
|
|
62
|
-
${h.cyan(`rari deploy render`)} Creates Render deployment files
|
|
44
|
+
${d.bold(`Deployment:`)}
|
|
45
|
+
${d.cyan(`rari deploy railway`)} Creates Railway deployment files
|
|
46
|
+
${d.cyan(`rari deploy render`)} Creates Render deployment files
|
|
63
47
|
|
|
64
48
|
Platform deployment automatically detects the environment and configures:
|
|
65
49
|
- Host binding (0.0.0.0 for platforms, 127.0.0.1 for local)
|
|
66
50
|
- Port from platform's PORT environment variable
|
|
67
51
|
- Production mode optimization
|
|
68
52
|
|
|
69
|
-
${
|
|
53
|
+
${d.bold(`Binary Resolution:`)}
|
|
70
54
|
1. Platform-specific package (rari-{platform}-{arch})
|
|
71
55
|
2. Global binary in PATH
|
|
72
56
|
3. Install from source with Cargo
|
|
73
57
|
|
|
74
|
-
${
|
|
58
|
+
${d.bold(`Notes:`)}
|
|
75
59
|
- 'rari start' defaults to production mode unless NODE_ENV is set
|
|
76
60
|
- 'rari dev' runs in development mode with Vite hot reload
|
|
77
61
|
- 'rari build' cleans, type checks, and builds for production
|
|
@@ -79,4 +63,4 @@ ${h.bold(`Notes:`)}
|
|
|
79
63
|
- Platform deployment is automatically detected and configured
|
|
80
64
|
- Use Ctrl+C to stop the server gracefully
|
|
81
65
|
|
|
82
|
-
`);break;case`dev`:await
|
|
66
|
+
`);break;case`dev`:await w();break;case`build`:await C();break;case`start`:await T();break;case`deploy`:m[0]===`railway`?await E():m[0]===`render`?await D():(_(`Unknown deployment target. Available: railway, render`),a.exit(1));break;default:console.error(`${d.bold(`Unknown command:`)} ${p}`),console.warn(`Run "${d.cyan(`rari help`)}" for available commands`),a.exit(1)}}a.argv[1]&&(import.meta.url===`file://${a.argv[1]}`||import.meta.url.endsWith(`/dist/cli.mjs`)&&a.argv[1].includes(`cli.mjs`))&&O().catch(e=>{_(`CLI Error: ${e.message}`),console.error(e),a.exit(1)});export{d as t};
|
package/dist/client.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as extractMetadata, C as RouteSegment, D as StaticParamsResult, E as ServerPropsResult, M as extractServerPropsWithCache, N as extractStaticParams, O as clearPropsCache, P as hasServerSideDataFetching, T as MetadataResult, _ as GenerateStaticParams, a as LoadingSpinner, b as LoadingEntry, c as createErrorBoundary, d as AppRouteEntry, f as AppRouteManifest, g as GenerateMetadata, h as ErrorProps, i as HttpRuntimeClient, j as extractServerProps, k as clearPropsCacheForComponent, l as createHttpRuntimeClient, m as ErrorEntry, n as DefaultLoading, o as NotFound, p as AppRouteMatch, r as ErrorBoundary, s as RuntimeClient, t as DefaultError, u as createLoadingBoundary, v as LayoutEntry, w as RouteSegmentType, x as NotFoundEntry } from "./runtime-client-
|
|
1
|
+
import { A as extractMetadata, C as RouteSegment, D as StaticParamsResult, E as ServerPropsResult, M as extractServerPropsWithCache, N as extractStaticParams, O as clearPropsCache, P as hasServerSideDataFetching, T as MetadataResult, _ as GenerateStaticParams, a as LoadingSpinner, b as LoadingEntry, c as createErrorBoundary, d as AppRouteEntry, f as AppRouteManifest, g as GenerateMetadata, h as ErrorProps, i as HttpRuntimeClient, j as extractServerProps, k as clearPropsCacheForComponent, l as createHttpRuntimeClient, m as ErrorEntry, n as DefaultLoading, o as NotFound, p as AppRouteMatch, r as ErrorBoundary, s as RuntimeClient, t as DefaultError, u as createLoadingBoundary, v as LayoutEntry, w as RouteSegmentType, x as NotFoundEntry } from "./runtime-client-BbLFFlfZ.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-r4vTOC5x.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.replace(/\/+$/,``);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);Array.from(i.entries()).length>0&&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.includes(`:5173`)?`http://localhost:3000`: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-B15ZQXrE.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.replace(/\/+$/,``);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);Array.from(i.entries()).length>0&&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.includes(`:5173`)?`http://localhost:3000`: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(t+1),50)};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[l.current.length-1];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-CD3aqqK8.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:p,quality:m=75,preload:h=!1,loading:g=`lazy`,placeholder:_=`empty`,blurDataURL:v,fill:y=!1,sizes:b,style:x,className:S,onLoad:C,onError:w,unoptimized:T=!1,loader:E,overrideSrc:D,decoding:O}){let k=typeof e==`string`?e:e.src,A=r||(typeof e==`string`?void 0:e.width),j=p||(typeof e==`string`?void 0:e.height),M=v||(typeof e==`string`?void 0:e.blurDataURL),N=D||k,P=h,F=O||(h?`sync`:`async`),[I,L]=l(!1),[R,z]=l(!1),B=c(null),V=c(C),H=c(null);s(()=>{V.current=C},[C]);let U=o(e=>{let t=e.currentTarget;t.src&&t.complete&&(_===`blur`&&L(!0),V.current&&V.current(e))},[_]),W=o(e=>{z(!0),_===`blur`&&L(!0),w&&w(e)},[_,w]);s(()=>{if(P){let e=document.createElement(`link`);return e.rel=`preload`,e.as=`image`,e.href=E?E({src:N,width:A||1920,quality:m}):T?N:f(N,A||1920,m),b&&e.setAttribute(`imagesizes`,b),document.head.appendChild(e),()=>{document.head.removeChild(e)}}},[P,N,A,m,b,E,T]),s(()=>{if(P||T||g===`eager`)return;let e=B.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()}},[P,T,g]);let G={...x,...y&&{position:`absolute`,inset:0,width:`100%`,height:`100%`,objectFit:`cover`},..._===`blur`&&M&&!I&&{backgroundImage:`url(${M})`,backgroundSize:`cover`,backgroundPosition:`center`,filter:`blur(20px)`,transition:`filter 0.3s ease-out`},..._===`blur`&&I&&{filter:`none`,transition:`filter 0.3s ease-out`}};if(T)return u(`img`,{ref:B,src:E?E({src:N,width:A||1920,quality:m}):N,alt:R?t:``,width:y?void 0:A,height:y?void 0:j,loading:P?`eager`:g,fetchPriority:P?`high`:`auto`,decoding:F,onLoad:U,onError:W,style:G,className:S});let K=y?i:a,q=A||1920,J=e=>E?K.map(e=>`${E({src:N,width:e,quality:m})} ${e}w`).join(`, `):K.map(t=>`${f(N,t,m,e)} ${t}w`).join(`, `),Y=u(`img`,{ref:B,src:E?E({src:N,width:q,quality:m}):f(N,q,m),srcSet:J(),sizes:b,alt:R?t:``,width:y?void 0:A,height:y?void 0:j,loading:P?`eager`:g,fetchPriority:P?`high`:`auto`,decoding:F,onLoad:U,onError:W,style:G,className:S});return d(`picture`,{ref:H,children:[n.includes(`avif`)&&u(`source`,{type:`image/avif`,srcSet:J(`avif`),sizes:b}),n.includes(`webp`)&&u(`source`,{type:`image/webp`,srcSet:J(`webp`),sizes:b}),Y]})}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};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { A as extractMetadata, C as RouteSegment, D as StaticParamsResult, E as ServerPropsResult, M as extractServerPropsWithCache, N as extractStaticParams, O as clearPropsCache, P as hasServerSideDataFetching, S as PageProps, T as MetadataResult, _ as GenerateStaticParams, b as LoadingEntry, d as AppRouteEntry, f as AppRouteManifest, g as GenerateMetadata, h as ErrorProps, i as HttpRuntimeClient, j as extractServerProps, k as clearPropsCacheForComponent, l as createHttpRuntimeClient, m as ErrorEntry, p as AppRouteMatch, s as RuntimeClient, v as LayoutEntry, w as RouteSegmentType, x as NotFoundEntry, y as LayoutProps } from "./runtime-client-
|
|
2
|
-
import { C as ApiRouteHandlers, D as RobotsRule, E as Robots, S as ApiResponse, T as RouteHandler, _ as ProxyResult, a as rari, b as RequestCookies, c as ProxyPluginOptions, d as RariRequest, f as CookieOptions, g as ProxyModule, h as ProxyMatcher, i as defineRariOptions, l as rariProxy, m as ProxyFunction, n as Response, o as rariRouter, p as ProxyConfig, r as defineRariConfig, s as generateAppRouteManifest, t as Request, u as RariResponse, v as RariFetchEvent, w as RouteContext, x as ResponseCookies, y as RariURL } from "./vite-
|
|
1
|
+
import { A as extractMetadata, C as RouteSegment, D as StaticParamsResult, E as ServerPropsResult, M as extractServerPropsWithCache, N as extractStaticParams, O as clearPropsCache, P as hasServerSideDataFetching, S as PageProps, T as MetadataResult, _ as GenerateStaticParams, b as LoadingEntry, d as AppRouteEntry, f as AppRouteManifest, g as GenerateMetadata, h as ErrorProps, i as HttpRuntimeClient, j as extractServerProps, k as clearPropsCacheForComponent, l as createHttpRuntimeClient, m as ErrorEntry, p as AppRouteMatch, s as RuntimeClient, v as LayoutEntry, w as RouteSegmentType, x as NotFoundEntry, y as LayoutProps } from "./runtime-client-BbLFFlfZ.mjs";
|
|
2
|
+
import { C as ApiRouteHandlers, D as RobotsRule, E as Robots, S as ApiResponse, T as RouteHandler, _ as ProxyResult, a as rari, b as RequestCookies, c as ProxyPluginOptions, d as RariRequest, f as CookieOptions, g as ProxyModule, h as ProxyMatcher, i as defineRariOptions, l as rariProxy, m as ProxyFunction, n as Response, o as rariRouter, p as ProxyConfig, r as defineRariConfig, s as generateAppRouteManifest, t as Request, u as RariResponse, v as RariFetchEvent, w as RouteContext, x as ResponseCookies, y as RariURL } from "./vite-BSlOEZF0.mjs";
|
|
3
3
|
export { ApiResponse, ApiRouteHandlers, AppRouteEntry, AppRouteManifest, AppRouteMatch, CookieOptions, ErrorEntry, ErrorProps, GenerateMetadata, GenerateStaticParams, HttpRuntimeClient, LayoutEntry, LayoutProps, LoadingEntry, 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, ServerPropsResult, 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-CnkUNT-E.mjs";import{t as s}from"./RariRequest-CW-JhbGM.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-B15ZQXrE.mjs";import{t as _}from"./routes-Bq7zysPc.mjs";import"./constants-CD3aqqK8.mjs";import"./server-build-Dcu2KENc.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};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import{t as e}from"./chunk-TmZEKRxo.mjs";import{existsSync as t}from"node:fs";import{join as n}from"node:path";import r from"node:process";const i={"linux-x64":`rari-linux-x64`,"linux-arm64":`rari-linux-arm64`,"darwin-x64":`rari-darwin-x64`,"darwin-arm64":`rari-darwin-arm64`,"win32-x64":`rari-win32-x64`};function a(){let e=r.platform,t=r.arch,n;switch(e){case`darwin`:n=`darwin`;break;case`linux`:n=`linux`;break;case`win32`:n=`win32`;break;default:throw Error(`Unsupported platform: ${e}. rari supports Linux, macOS, and Windows.`)}let a;switch(t){case`x64`:a=`x64`;break;case`arm64`:a=`arm64`;break;default:throw Error(`Unsupported architecture: ${t}. rari supports x64 and ARM64.`)}let o=i[`${n}-${a}`];if(!o)throw Error(`Unsupported platform combination: ${n}-${a}. Supported platforms: ${Object.keys(i).join(`, `)}`);return{platform:n,arch:a,packageName:o,binaryName:n===`win32`?`rari.exe`:`rari`}}function o(){let{packageName:i,binaryName:o}=a();try{let e=r.cwd(),a=null;for(;e!==`/`&&e!==``;){if(t(n(e,`packages`))){a=e;break}e=n(e,`..`)}if(a){let e=n(n(a,`packages`,i),`bin`,o);if(t(e))return e}}catch{}try{let r=n(e.resolve(`${i}/package.json`).replace(`/package.json`,``),`bin`,o);if(t(r))return r;throw Error(`Binary not found at ${r}`)}catch{throw Error(`Failed to locate rari binary for ${i}. Please ensure the platform package is installed: npm install ${i}`)}}function s(){let{packageName:e}=a();return`
|
|
2
|
+
To install rari for your platform, run:
|
|
3
|
+
|
|
4
|
+
npm install ${e}
|
|
5
|
+
|
|
6
|
+
Or if you're using pnpm:
|
|
7
|
+
|
|
8
|
+
pnpm add ${e}
|
|
9
|
+
|
|
10
|
+
Or if you're using yarn:
|
|
11
|
+
|
|
12
|
+
yarn add ${e}
|
|
13
|
+
|
|
14
|
+
If you continue to have issues, you can also install from source:
|
|
15
|
+
|
|
16
|
+
cargo install --git https://github.com/rari-build/rari
|
|
17
|
+
`}export{o as getBinaryPath,s as getInstallationInstructions};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
async function e(e){try{let t=await import(e);if(!t||!t.proxy)return console.error(`[rari] Proxy: proxy function not found in module`),!1;let{RariRequest:n}=await import(`../RariRequest-
|
|
1
|
+
async function e(e){try{let t=await import(e);if(!t||!t.proxy)return console.error(`[rari] Proxy: proxy function not found in module`),!1;let{RariRequest:n}=await import(`../RariRequest-Bd8ha4ba.mjs`);return globalThis.__rariExecuteProxy=async function(e){try{let r=new n(e.url,{method:e.method,headers:new Headers(e.headers)}),i=[],a=await t.proxy(r,{waitUntil:e=>{i.push(e)}});if(i.length>0&&Promise.allSettled(i).catch(e=>{console.error(`[rari] Proxy: waitUntil promise failed:`,e)}),!a)return{continue:!0};let o=a.headers?.get?.(`x-rari-proxy-continue`),s=a.headers?.get?.(`x-rari-proxy-rewrite`);if(s)return{continue:!1,rewrite:s};let c=a.headers?.get?.(`location`);if(c&&a.status>=300&&a.status<400)return{continue:!1,redirect:{destination:c,permanent:a.status===301||a.status===308}};if(o===`true`){let e={},t={};return a.headers?.forEach&&a.headers.forEach((n,r)=>{if(r.startsWith(`x-rari-proxy-request-`)){let t=r.replace(`x-rari-proxy-request-`,``);e[t]=n}else r.startsWith(`x-rari-proxy-`)||(t[r]=n)}),{continue:!0,requestHeaders:Object.keys(e).length>0?e:void 0,responseHeaders:Object.keys(t).length>0?t:void 0}}if(a.status){let e={};a.headers?.forEach&&a.headers.forEach((t,n)=>{e[n]=t});let t;try{a.text&&typeof a.text==`function`?t=await a.text():a.body&&(t=String(a.body))}catch{}return{continue:!1,response:{status:a.status,headers:e,body:t}}}return{continue:!0}}catch(e){return console.error(`[rari] Proxy: Proxy execution error:`,e),{continue:!0}}},!0}catch(e){return console.error(`[rari] Proxy: Failed to initialize proxy executor:`,e),!1}}export{e as initializeProxyExecutor};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./routes-Bq7zysPc.mjs";export{e as generateAppRouteManifest};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,r as t,t as n}from"./server-build-Dcu2KENc.mjs";export{n as ServerComponentBuilder,t as scanDirectory};
|
|
@@ -121,4 +121,4 @@ function registerClientReference(clientReference, id, exportName) {
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
`+r);for(let{original:e,replacement:t}of o)r=r.replace(e,t);return r}resolveImportPath(n,r){let i=n,a=this.options.alias||{};for(let[e,r]of Object.entries(a))if(n.startsWith(`${e}/`)||n===e){let a=n.slice(e.length);i=t.join(r,a);break}t.isAbsolute(i)||(i=t.resolve(t.dirname(r),i));let o=[`.tsx`,`.jsx`,`.ts`,`.js`];for(let t of o){let n=`${i}${t}`;if(e.existsSync(n))return n}if(e.existsSync(i))for(let n of o){let r=t.join(i,`index${n}`);if(e.existsSync(r))return r}return`${i}.tsx`}getComponentId(e){return e.replace(/\\/g,`/`).replace(/\.(tsx?|jsx?)$/,``).replace(/[^\w/-]/g,`_`).replace(/^src\//,``).replace(/^components\//,`components/`)}async rebuildComponent(n){let r=this.getComponentId(t.relative(this.projectRoot,n)),i=await e.promises.readFile(n,`utf-8`),a=this.extractDependencies(i),o={filePath:n,originalCode:i,dependencies:a,hasNodeImports:this.hasNodeImports(i)};this.isServerAction(i)?this.serverActions.set(n,o):this.serverComponents.set(n,o);let s=t.join(this.options.serverDir,`${r}.js`),c=t.join(this.options.outDir,s),l=this.buildCache.get(n),u=(await e.promises.stat(n)).mtimeMs;if(l&&l.timestamp>=u&&JSON.stringify(l.dependencies)===JSON.stringify(a))return await e.promises.writeFile(c,l.code,`utf-8`),await this.updateManifestForComponent(r,n,s),{componentId:r,bundlePath:t.join(this.options.outDir,s),success:!0};let d=t.dirname(c);await e.promises.mkdir(d,{recursive:!0});let f=await this.buildSingleComponent(n,c,o,!0);return this.buildCache.set(n,{code:f,timestamp:Date.now(),dependencies:a}),await this.updateManifestForComponent(r,n,s),{componentId:r,bundlePath:t.join(this.options.outDir,s),success:!0}}manifestCache=null;manifestDirty=!1;async updateManifestForComponent(n,r,i){let a=t.join(this.options.outDir,this.options.manifestPath),o;if(this.manifestCache)o=this.manifestCache;else if(e.existsSync(a)){let t=await e.promises.readFile(a,`utf-8`);o=JSON.parse(t),this.manifestCache=o}else o={components:{},importMap:{imports:{react:`npm:react@19`,"react-dom":`npm:react-dom@19`,"react/jsx-runtime":`npm:react@19/jsx-runtime`,"react/jsx-dev-runtime":`npm:react@19/jsx-dev-runtime`}},version:`1.0.0`,buildTime:new Date().toISOString(),csp:this.options.csp,rateLimit:this.options.rateLimit,spamBlocker:this.options.spamBlocker},this.manifestCache=o;let s=this.serverComponents.get(r)||this.serverActions.get(r),c=t.join(this.options.outDir,i),l=`file://${t.resolve(this.projectRoot,c)}`;if(s)o.components[n]={id:n,filePath:r,relativePath:t.relative(this.projectRoot,r),bundlePath:i,moduleSpecifier:l,dependencies:s.dependencies,hasNodeImports:s.hasNodeImports};else{let a=await e.promises.readFile(r,`utf-8`);o.components[n]={id:n,filePath:r,relativePath:t.relative(this.projectRoot,r),bundlePath:i,moduleSpecifier:l,dependencies:this.extractDependencies(a),hasNodeImports:this.hasNodeImports(a)}}o.importMap||={imports:{react:`npm:react@19`,"react-dom":`npm:react-dom@19`,"react/jsx-runtime":`npm:react@19/jsx-runtime`,"react/jsx-dev-runtime":`npm:react@19/jsx-dev-runtime`}},o.buildTime=new Date().toISOString(),await e.promises.writeFile(a,JSON.stringify(o,null,2),`utf-8`),this.manifestCache=o}clearCache(){this.buildCache.clear(),this.manifestCache=null}async getTransformedComponentCode(n){let r=t.relative(this.projectRoot,n),i=this.getComponentId(r),a=await e.promises.readFile(n,`utf-8`),o={dependencies:this.extractDependencies(a),hasNodeImports:this.hasNodeImports(a)};return await this.buildComponentCodeOnly(n,i,o)}};function o(n,r){let i=e.readdirSync(n,{withFileTypes:!0});for(let a of i){let i=t.join(n,a.name);if(a.isDirectory())o(i,r);else if(a.isFile()&&/\.(?:tsx?|jsx?)$/.test(a.name)){if(/^(?:robots|sitemap)\.(?:tsx?|jsx?)$/.test(a.name))continue;try{if(r.isServerComponent(i))r.addServerComponent(i);else{let t=e.readFileSync(i,`utf-8`).split(`
|
|
124
|
-
`),n=!1;for(let e of t){let t=e.trim();if(!(t.startsWith(`//`)||t.startsWith(`/*`)||!t)){if(t===`'use server'`||t===`"use server"`||t===`'use server';`||t===`"use server";`){n=!0;break}if(t)break}}n&&r.addServerComponent(i)}}catch(e){console.warn(`[server-build] Error checking ${i}:`,e instanceof Error?e.message:e)}}}}function s(r={}){let i=null,s,c=!1;return{name:`rari-server-build`,configResolved(e){s=e.root,c=e.command===`serve`;let t={};if(e.resolve?.alias){let n=e.resolve.alias;Array.isArray(n)?n.forEach(e=>{typeof e.find==`string`&&typeof e.replacement==`string`&&(t[e.find]=e.replacement)}):typeof n==`object`&&Object.entries(n).forEach(([e,n])=>{typeof n==`string`&&(t[e]=n)})}i=new a(s,{...r,alias:t})},buildStart(){if(!i)return;let r=n.env.NODE_ENV===`production`,a=[t.join(s,`dist`,`cache`,`og`),t.join(s,`dist`,`cache`,`images`)];r&&a.push(`/tmp/rari-og-cache`,`/tmp/rari-image-cache`);for(let t of a)try{e.existsSync(t)&&e.rmSync(t,{recursive:!0,force:!0})}catch(e){console.warn(`[rari] Failed to clear cache ${t}:`,e)}let c=t.join(s,`src`);e.existsSync(c)&&o(c,i)},async closeBundle(){if(i){await i.buildServerComponents();try{let{generateRobotsFile:e}=await import(`./robots-generator-
|
|
124
|
+
`),n=!1;for(let e of t){let t=e.trim();if(!(t.startsWith(`//`)||t.startsWith(`/*`)||!t)){if(t===`'use server'`||t===`"use server"`||t===`'use server';`||t===`"use server";`){n=!0;break}if(t)break}}n&&r.addServerComponent(i)}}catch(e){console.warn(`[server-build] Error checking ${i}:`,e instanceof Error?e.message:e)}}}}function s(r={}){let i=null,s,c=!1;return{name:`rari-server-build`,configResolved(e){s=e.root,c=e.command===`serve`;let t={};if(e.resolve?.alias){let n=e.resolve.alias;Array.isArray(n)?n.forEach(e=>{typeof e.find==`string`&&typeof e.replacement==`string`&&(t[e.find]=e.replacement)}):typeof n==`object`&&Object.entries(n).forEach(([e,n])=>{typeof n==`string`&&(t[e]=n)})}i=new a(s,{...r,alias:t})},buildStart(){if(!i)return;let r=n.env.NODE_ENV===`production`,a=[t.join(s,`dist`,`cache`,`og`),t.join(s,`dist`,`cache`,`images`)];r&&a.push(`/tmp/rari-og-cache`,`/tmp/rari-image-cache`);for(let t of a)try{e.existsSync(t)&&e.rmSync(t,{recursive:!0,force:!0})}catch(e){console.warn(`[rari] Failed to clear cache ${t}:`,e)}let c=t.join(s,`src`);e.existsSync(c)&&o(c,i)},async closeBundle(){if(i){await i.buildServerComponents();try{let{generateRobotsFile:e}=await import(`./robots-generator-AcmtuCNy.mjs`);await e({appDir:t.join(s,`src`,`app`),outDir:t.join(s,`dist`),extensions:[`.ts`,`.tsx`,`.js`,`.jsx`]})}catch(e){console.warn(`[rari] Failed to generate robots.txt:`,e)}}},async handleHotUpdate({file:n}){if(!i||!c)return;let r=t.relative(s,n);if(!(!r.startsWith(`src/`)||!r.match(/\.(tsx?|jsx?)$/)))try{if((await e.promises.readFile(n,`utf-8`)).includes(`use client`))return;await i.buildServerComponents()}catch(e){console.error(`[rari] Build: Error rebuilding ${r}:`,e)}}}}export{s as n,o as r,a as t};
|