rari 0.17.10 → 0.17.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.d.mts +4 -3
- package/dist/cli.mjs +49 -40
- package/dist/fly-BZsz03bn.mjs +59 -0
- package/dist/image.mjs +1 -1
- package/dist/railway-DUCTAuA9.mjs +10 -0
- package/dist/render-DawwdqvN.mjs +14 -0
- package/dist/runtime/AppRouterProvider.mjs +1 -1
- package/dist/runtime/entry-client.mjs +2 -2
- package/dist/{utils-YdvPzSET-Cbo6Ofmz.mjs → utils-DZWuxUA--BobVI1xy.mjs} +1 -37
- package/dist/vite.mjs +5 -5
- package/package.json +11 -11
- package/dist/railway-CE3nqaKt.mjs +0 -67
- package/dist/render-D0eMtn5L.mjs +0 -73
package/dist/cli.d.mts
CHANGED
|
@@ -9,11 +9,12 @@ export declare function findImageConfigPath(packageRoot: string): string | null;
|
|
|
9
9
|
export declare function outDirFromImageConfigPath(imageConfigPath: string, packageRoot: string): string;
|
|
10
10
|
type PackageManager = 'pnpm' | 'yarn' | 'bun' | 'npm';
|
|
11
11
|
declare function detectPackageManager(): PackageManager;
|
|
12
|
-
declare
|
|
13
|
-
declare
|
|
12
|
+
declare const isRailwayEnvironment: () => boolean;
|
|
13
|
+
declare const isRenderEnvironment: () => boolean;
|
|
14
|
+
declare const isFlyEnvironment: () => boolean;
|
|
14
15
|
declare function getDeploymentConfig(): {
|
|
15
16
|
port: string;
|
|
16
17
|
mode: string;
|
|
17
18
|
host: string;
|
|
18
19
|
};
|
|
19
|
-
export { detectPackageManager, getDeploymentConfig, isRailwayEnvironment, isRenderEnvironment };
|
|
20
|
+
export { detectPackageManager, getDeploymentConfig, isFlyEnvironment, isRailwayEnvironment, isRenderEnvironment };
|
package/dist/cli.mjs
CHANGED
|
@@ -1,64 +1,73 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{b as e,d as t,x as n,y as r}from"./type-guards-BLY2PlGR.mjs";import{n as i,t as a}from"./dist-paths-C4EV064W.mjs";import{getBinaryPath as o,getInstallationInstructions as s}from"./platform.mjs";import{spawn as c}from"node:child_process";import{existsSync as l,readFileSync as u,readdirSync as d,realpathSync as f,rmSync as p}from"node:fs";import{basename as m,dirname as h,isAbsolute as g,join as _,resolve as v}from"node:path";import y from"node:process";import{fileURLToPath as
|
|
2
|
+
import{b as e,d as t,x as n,y as r}from"./type-guards-BLY2PlGR.mjs";import{n as i,t as a}from"./dist-paths-C4EV064W.mjs";import{getBinaryPath as o,getInstallationInstructions as s}from"./platform.mjs";import{spawn as c}from"node:child_process";import{existsSync as l,readFileSync as u,readdirSync as d,realpathSync as f,rmSync as p}from"node:fs";import{basename as m,dirname as h,isAbsolute as g,join as _,resolve as v}from"node:path";import y from"node:process";import{fileURLToPath as ee}from"node:url";import{once as b}from"node:events";import{parseArgs as te,styleText as x}from"node:util";function S(e){console.warn(`${x(`blue`,`info`)} ${e}`)}function C(e){console.warn(`${x(`green`,`✓`)} ${e}`)}function w(e){console.error(`${x(`red`,`✗`)} ${e}`)}function T(e){console.warn(`${x(`yellow`,`⚠`)} ${e}`)}const E=[`vite.config.ts`];function D(e,t=`build`){let n=/(?:^|[,{\s])defaultPackage\s*:\s*['"]([^'"]+)['"]/.exec(e);if(n?.[1]!=null&&n[1]!==``)return n[1];let r=/(?:^|[,{\s])defaultPackage\s*:\s*\{([^}]*)\}/.exec(e);if(r?.[1]==null)return null;let i=RegExp(`(?:^|[,\\s])${t}\\s*:\\s*['"]([^'"]+)['"]`).exec(r[1])?.[1];return i!=null&&i!==``?i:null}function O(e){let t=/(?:^|[,{\s])outDir\s*:\s*['"]([^'"]+)['"]/.exec(e)?.[1];return t!=null&&t!==``?t:null}function k(e){let t=/(?:^|[,{\s])root\s*:\s*['"]([^'"]+)['"]/.exec(e)?.[1];return t!=null&&t!==``?t:null}function A(e){for(let t of E){let n=v(e,t);if(l(n))try{return u(n,`utf8`)}catch{return null}}return null}function j(e,t){return g(t)?t:v(e,t)}function M(e,t){let n=t==null?null:k(t);return n==null||n===``?e:j(e,n)}function N(e,t=`vp`,n=`build`){if(t!==`vp`)return e;let r=A(e);if(r==null)return e;let i=D(r,n);if(i==null||i===``)return e;let a=v(e,i);return l(a)?a:e}function P(e){let t=A(e),n=M(e,t),r=t==null?null:O(t);return r==null||r===``?v(n,a):j(n,r)}function F(e){return m(e)===`client`?h(e):e}function I(e){let t=P(e),n=[_(F(t),`server`,`image.json`),_(t,`server`,`image.json`),_(e,i,`server`,`image.json`)];for(let e of n)if(l(e))return e;let r;try{r=d(e)}catch{return null}for(let t of r){if(t===`node_modules`||t===`dist`||t.startsWith(`.`))continue;let n=_(e,t,`server`,`image.json`);if(l(n))return n}return null}function L(e,t){let n=h(e),i=h(n),a=M(t,A(t)),o=r(u(e,`utf8`))?.outDir;return typeof o==`string`&&o!==``?g(o)?o:v(a,o):_(i,`client`)}let R=null;function ne(e){let t=l(e)?new Set(re(e)):/* @__PURE__ */ new Set;return t.has(`pnpm-lock.yaml`)?`pnpm`:t.has(`yarn.lock`)?`yarn`:t.has(`bun.lockb`)||t.has(`bun.lock`)?`bun`:t.has(`package-lock.json`)?`npm`:ie(e)}function re(e){try{return d(e)}catch{return[]}}function ie(t){try{let n=v(t,`package.json`);if(!l(n))return null;let i=r(u(n,`utf-8`));return i?e(i):null}catch{}return null}function ae(e){try{let t=v(e,`package.json`);if(!l(t))return null;let i=r(u(t,`utf-8`));return i?n(i):null}catch{}return null}function oe(e){let t=e,n=null,r=null;for(;t!==v(t,`..`)&&(n??=ne(t),r??=ae(t),!(n&&r));)t=v(t,`..`);return{cwd:e,packageManager:n??`npm`,viteBin:r??`vite`}}function z(){let e=y.cwd();return R?.cwd===e||(R=oe(e)),R}function se(){return z().packageManager}function B(){let e=z().packageManager,t=y.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`;case`npm`:return t?`npx.cmd`:`npx`;default:return t?`npx.cmd`:`npx`}}function V(e,t=y.cwd()){let n=y.platform===`win32`,r=t;for(;r!==v(r,`..`);){let t=v(r,`node_modules`,`.bin`),i=n?[v(t,`${e}.cmd`),v(t,`${e}.exe`),v(t,e)]:[v(t,e)];for(let e of i)if(l(e))return e;r=v(r,`..`)}return null}function H(e,t,n={}){let r=y.platform===`win32`;if(e===`npx`){let e=B();if(e.includes(`bun`))return c(r?`bunx.cmd`:`bunx`,t,{...n,shell:r});if(e.includes(`pnpm`))return c(e,[`exec`,...t],{...n,shell:r});if(e.includes(`yarn`)){let[i,...a]=t,o=i===`vp`?[`dlx`,`-p`,`vite-plus`,`vp`,...a]:[`dlx`,...t];return c(e,o,{...n,shell:r})}}return r&&e===`npx`?c(`npx.cmd`,t,{...n,shell:!0}):c(e,t,n)}function U(e,t,n={}){let r=V(e);if(r!=null&&r!==``){let e=y.platform===`win32`&&r.endsWith(`.cmd`);return c(r,t,e?{...n,shell:!0}:n)}return H(`npx`,[e,...t],n)}async function W(e,t={}){try{let[t]=await b(e,`close`);return t}catch(e){if(t.tolerateErrors)return T(G(e)),1;throw e}}function G(e){if(t(e))return e.message;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function ce(){let e=v(y.cwd(),`.env`);l(e)&&y.loadEnvFile(e)}function le(e){let{values:t,positionals:n}=te({args:e,options:{help:{type:`boolean`,short:`h`,default:!1}},allowPositionals:!0,strict:!1});if(t.help===!0)return{command:`help`,args:[]};let[r=`help`,...i]=n;return{command:r,args:i}}function K(e){let t=y.env[e];return t!=null&&t!==``?t:void 0}function q(e){return K(e)!==void 0}const J=[{id:`railway`,name:`Railway`,envVars:[`RAILWAY_ENVIRONMENT`,`RAILWAY_PROJECT_ID`,`RAILWAY_SERVICE_ID`],setup:async()=>{let{createRailwayDeployment:e}=await import(`./railway-DUCTAuA9.mjs`);e()}},{id:`render`,name:`Render`,envVars:[`RENDER`,`RENDER_SERVICE_ID`,`RENDER_SERVICE_NAME`],setup:async()=>{let{createRenderDeployment:e}=await import(`./render-DawwdqvN.mjs`);e()}},{id:`fly`,name:`Fly.io`,envVars:[`FLY_APP_NAME`,`FLY_MACHINE_ID`,`FLY_ALLOC_ID`],setup:async()=>{let{createFlyDeployment:e}=await import(`./fly-BZsz03bn.mjs`);e()}}];function Y(e){return J.find(t=>t.id===e)?.envVars.some(q)??!1}function X(){return J.find(e=>e.envVars.some(q))}const ue=()=>Y(`railway`),de=()=>Y(`render`),fe=()=>Y(`fly`);function Z(){return{port:K(`PORT`)??K(`RSC_PORT`)??`3000`,mode:K(`NODE_ENV`)??`production`,host:K(`RARI_HOST`)??(X()?`0.0.0.0`:`127.0.0.1`)}}async function pe(){$();let e=z().viteBin;S(`Type checking...`);let t=await W(U(`tsc`,[],{stdio:`inherit`,cwd:y.cwd()}));if(t===0)C(`Type check passed`);else throw w(`Type check failed with code ${t}`),Error(`Type check failed with code ${t}`);S(`Building for production...`);let n=await W(U(e,[`build`],{stdio:`inherit`,cwd:y.cwd()}));if(n===0)C(`Build complete`);else throw w(`Build failed with code ${n}`),Error(`Build failed with code ${n}`);await me()}async function me(){let e=y.cwd(),{viteBin:t}=z(),n=N(e,t),i=I(n);if(i==null)return;let a=L(i,n),s=h(i),d=`assets`;try{let e=r(u(i,`utf-8`));e&&typeof e.assetsDir==`string`&&e.assetsDir.length>0&&(d=e.assetsDir.replaceAll(/^\/+|\/+$/g,``))}catch{}let f=v(n,`public`),p=v(a,d),m=v(s,`static-image-sources.json`);if(l(f)||l(p)||l(m))try{let e=o(),t=await W(c(e,[`optimize-images`,`--config`,i],{stdio:`inherit`,cwd:n,shell:!1}),{tolerateErrors:!0});t!==0&&T(`Image pre-optimization exited with code ${t}`)}catch(e){T(`Could not pre-optimize images: ${G(e)}`)}}async function he(){let e=z().viteBin,t=v(y.cwd(),`dist`);if(!l(t)){S(`First run detected - building project...`);let t=await W(U(e,[`build`,`--mode`,`development`],{stdio:`inherit`,cwd:y.cwd()}));if(t===0)C(`Initial build complete`);else throw w(`Build failed with code ${t}`),Error(`Build failed with code ${t}`)}S(`Starting Vite${e===`vp`?`+`:``} dev server...`);let n=U(e,[`dev`],{stdio:`inherit`,cwd:y.cwd()}),r=()=>{S(`Shutting down dev server...`),n.kill(`SIGTERM`)};return y.on(`SIGINT`,r),y.on(`SIGTERM`,r),n.on(`error`,e=>{w(`Failed to start Vite: ${e.message}`),y.exit(1)}),n.on(`exit`,e=>{e!==0&&e!==null&&(w(`Vite exited with code ${e}`),y.exit(e))}),new Promise(()=>{})}async function ge(){let e;try{e=o()}catch{w(`Failed to obtain rari binary`),w(s()),y.exit(1)}let{port:t,mode:n,host:r}=Z(),i=X();if(i){let a=i.name;S(`${a} environment detected`),S(`Starting rari server for ${a} deployment...`),S(`Mode: ${n}, Host: ${r}, Port: ${t}`),S(`using binary: ${e}`)}let a=[`--mode`,n,`--port`,t,`--host`,r],l=y.platform!==`win32`&&y.stdin.isTTY,u=c(e,a,{stdio:`inherit`,cwd:y.cwd(),detached:l,env:{...y.env,RUST_LOG:y.env.RUST_LOG!=null&&y.env.RUST_LOG!==``?y.env.RUST_LOG:`error`}}),d=!1,f,p=()=>{d||(d=!0,S(`shutting down...`),u.kill(`SIGTERM`),f=setTimeout(()=>{u.kill(`SIGKILL`),y.exit(1)},5e3),f.unref())};return y.on(`SIGINT`,p),y.on(`SIGTERM`,p),y.on(`exit`,()=>{try{u.kill(`SIGKILL`)}catch{}}),u.on(`error`,e=>{w(`Failed to start rari server: ${e.message}`),e.message.includes(`ENOENT`)&&w(`Binary not found. Please ensure rari is properly installed.`),y.exit(1)}),u.on(`exit`,(e,t)=>{f&&clearTimeout(f),t!=null&&t!==``?(d&&(S(`server stopped by signal ${t}`),y.exit(0)),w(`server stopped unexpectedly by signal ${t}`),y.exit(1)):e===0?(C(`server stopped successfully`),y.exit(0)):(w(`server exited with code ${e}`),y.exit(e!=null&&e!==0?e:1))}),new Promise(()=>{})}async function Q(e){let t=J.find(t=>t.id===e);t||(w(`Unknown deployment target. Available: ${J.map(e=>e.id).join(`, `)}`),y.exit(1)),S(`Setting up ${t.name} deployment...`);let n=X();n&&(w(`Already running in ${n.name} environment. Use "rari start" instead.`),y.exit(1)),await t.setup()}function $(){let e=v(y.cwd(),`dist`);l(e)?(S(`Cleaning dist folder...`),p(e,{recursive:!0,force:!0}),C(`Cleaned dist folder`)):S(`No dist folder to clean`)}function _e(){console.warn(`${x(`bold`,`rari CLI`)}
|
|
3
3
|
|
|
4
|
-
${
|
|
5
|
-
${
|
|
6
|
-
${
|
|
7
|
-
${
|
|
8
|
-
${
|
|
9
|
-
${
|
|
10
|
-
${
|
|
11
|
-
${
|
|
4
|
+
${x(`bold`,`Usage:`)}
|
|
5
|
+
${x(`cyan`,`rari dev`)} Start the development server with Vite
|
|
6
|
+
${x(`cyan`,`rari build`)} Build for production
|
|
7
|
+
${x(`cyan`,`rari start`)} Start the rari server (defaults to production)
|
|
8
|
+
${x(`cyan`,`rari clean`)} Remove the dist folder
|
|
9
|
+
${x(`cyan`,`rari deploy railway`)} Setup Railway deployment
|
|
10
|
+
${x(`cyan`,`rari deploy render`)} Setup Render deployment
|
|
11
|
+
${x(`cyan`,`rari deploy fly`)} Setup Fly.io deployment
|
|
12
|
+
${x(`cyan`,`rari help`)} Show this help message
|
|
12
13
|
|
|
13
|
-
${
|
|
14
|
-
${
|
|
15
|
-
${
|
|
16
|
-
${
|
|
17
|
-
${
|
|
14
|
+
${x(`bold`,`Environment Variables:`)}
|
|
15
|
+
${x(`yellow`,`PORT`)} Server port (default: 3000)
|
|
16
|
+
${x(`yellow`,`RSC_PORT`)} Alternative server port
|
|
17
|
+
${x(`yellow`,`RARI_HOST`)} Address the server binds to (default: 0.0.0.0 on platforms, 127.0.0.1 locally)
|
|
18
|
+
${x(`yellow`,`NODE_ENV`)} Environment (default: production for start, development for dev)
|
|
19
|
+
${x(`yellow`,`RUST_LOG`)} Rust logging level (default: info)
|
|
18
20
|
|
|
19
|
-
${
|
|
20
|
-
${
|
|
21
|
-
${
|
|
21
|
+
${x(`bold`,`Examples:`)}
|
|
22
|
+
${x(`gray`,`# Start development server with Vite`)}
|
|
23
|
+
${x(`cyan`,`rari dev`)}
|
|
22
24
|
|
|
23
|
-
${
|
|
24
|
-
${
|
|
25
|
+
${x(`gray`,`# Build for production`)}
|
|
26
|
+
${x(`cyan`,`rari build`)}
|
|
25
27
|
|
|
26
|
-
${
|
|
27
|
-
${
|
|
28
|
+
${x(`gray`,`# Clean dist folder`)}
|
|
29
|
+
${x(`cyan`,`rari clean`)}
|
|
28
30
|
|
|
29
|
-
${
|
|
30
|
-
${
|
|
31
|
+
${x(`gray`,`# Start production server (default)`)}
|
|
32
|
+
${x(`cyan`,`rari start`)}
|
|
31
33
|
|
|
32
|
-
${
|
|
33
|
-
${
|
|
34
|
+
${x(`gray`,`# Start in development mode`)}
|
|
35
|
+
${x(`cyan`,`NODE_ENV=development rari start`)}
|
|
34
36
|
|
|
35
|
-
${
|
|
36
|
-
${
|
|
37
|
+
${x(`gray`,`# Start production server on port 8080`)}
|
|
38
|
+
${x(`cyan`,`PORT=8080 rari start`)}
|
|
37
39
|
|
|
38
|
-
${
|
|
39
|
-
${
|
|
40
|
+
${x(`gray`,`# Start production server reachable from other hosts (e.g. Docker)`)}
|
|
41
|
+
${x(`cyan`,`RARI_HOST=0.0.0.0 rari start`)}
|
|
40
42
|
|
|
41
|
-
${
|
|
42
|
-
${
|
|
43
|
+
${x(`gray`,`# Setup Railway deployment`)}
|
|
44
|
+
${x(`cyan`,`rari deploy railway`)}
|
|
43
45
|
|
|
44
|
-
${
|
|
45
|
-
${
|
|
46
|
+
${x(`gray`,`# Setup Render deployment`)}
|
|
47
|
+
${x(`cyan`,`rari deploy render`)}
|
|
46
48
|
|
|
47
|
-
${
|
|
48
|
-
${
|
|
49
|
-
|
|
49
|
+
${x(`gray`,`# Setup Fly.io deployment`)}
|
|
50
|
+
${x(`cyan`,`rari deploy fly`)}
|
|
51
|
+
|
|
52
|
+
${x(`gray`,`# Start with debug logging`)}
|
|
53
|
+
${x(`cyan`,`RUST_LOG=debug rari start`)}
|
|
54
|
+
|
|
55
|
+
${x(`bold`,`Deployment:`)}
|
|
56
|
+
${x(`cyan`,`rari deploy railway`)} Creates Railway deployment files
|
|
57
|
+
${x(`cyan`,`rari deploy render`)} Creates Render deployment files
|
|
58
|
+
${x(`cyan`,`rari deploy fly`)} Creates Fly.io deployment files
|
|
50
59
|
|
|
51
60
|
Platform deployment automatically detects the environment and configures:
|
|
52
|
-
- Host binding (0.0.0.0 for platforms, 127.0.0.1 for local)
|
|
61
|
+
- Host binding (0.0.0.0 for platforms, 127.0.0.1 for local, or RARI_HOST if set)
|
|
53
62
|
- Port from platform's PORT environment variable
|
|
54
63
|
- Production mode optimization
|
|
55
64
|
|
|
56
|
-
${
|
|
65
|
+
${x(`bold`,`Binary Resolution:`)}
|
|
57
66
|
1. Platform-specific package (rari-{platform}-{arch})
|
|
58
67
|
2. Global binary in PATH
|
|
59
68
|
3. Install from source with Cargo
|
|
60
69
|
|
|
61
|
-
${
|
|
70
|
+
${x(`bold`,`Notes:`)}
|
|
62
71
|
- 'rari start' defaults to production mode unless NODE_ENV is set
|
|
63
72
|
- 'rari dev' runs in development mode with Vite hot reload
|
|
64
73
|
- 'rari build' cleans, type checks, and builds for production
|
|
@@ -66,4 +75,4 @@ ${S(`bold`,`Notes:`)}
|
|
|
66
75
|
- Platform deployment is automatically detected and configured
|
|
67
76
|
- Use Ctrl+C to stop the server gracefully
|
|
68
77
|
|
|
69
|
-
`)}async function
|
|
78
|
+
`)}async function ve(){ce();let{command:e,args:t}=le(y.argv.slice(2));if(e==null||e===`help`)_e();else switch(e){case`dev`:await he();break;case`build`:await pe();break;case`start`:await ge();break;case`clean`:$();break;case`deploy`:await Q(t[0]);break;default:console.error(`${x(`bold`,`Unknown command:`)} ${e}`),console.warn(`Run "${x(`cyan`,`rari help`)}" for available commands`),y.exit(1)}}function ye(){let e=y.argv[1]?f(v(y.argv[1])):``,t=f(ee(import.meta.url));return!!e&&t===e}ye()&&ve().catch(e=>{w(`CLI Error: ${G(e)}`),console.error(e),y.exit(1)});export{se as detectPackageManager,I as findImageConfigPath,Z as getDeploymentConfig,fe as isFlyEnvironment,ue as isRailwayEnvironment,de as isRenderEnvironment,L as outDirFromImageConfigPath,O as readBuildOutDir,D as readDefaultPackageTarget,k as readViteRoot,P as resolveConfiguredBuildOutDir,M as resolveEffectiveViteRoot,N as resolveViteBuildPackageRoot};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import{i as e,n as t,o as n,r,s as i,t as a}from"./utils-DZWuxUA--BobVI1xy.mjs";import{appendFileSync as o,existsSync as s,readFileSync as c,writeFileSync as l}from"node:fs";import{join as u}from"node:path";import d from"node:process";import{styleText as f}from"node:util";function p(){let r=d.cwd();n(`Creating Fly.io deployment configuration...`);let i=a(r,{providerName:`Fly`,deployScript:`fly deploy`}),o=h(r);m(r),g(r,o),v(r,o.copy.split(` `)),t(`Fly.io`,[...i?[`${f(`cyan`,e(r))} (updates your lockfile for rari)`]:[],`Install the Fly CLI: ${f(`cyan`,`https://fly.io/docs/flyctl/install/`)}`,f(`cyan`,`fly auth login`),f(`cyan`,`fly launch --no-deploy`),f(`cyan`,`fly deploy`)],[`Run in a Node 24 Docker container`,`Bind to 0.0.0.0 on port 8080`,`Health check on /_rari/health`])}function m(e){r(e,`fly.toml`,`app = "rari-app"
|
|
2
|
+
primary_region = "iad"
|
|
3
|
+
|
|
4
|
+
[build]
|
|
5
|
+
|
|
6
|
+
[http_service]
|
|
7
|
+
internal_port = 8080
|
|
8
|
+
force_https = true
|
|
9
|
+
auto_stop_machines = "stop"
|
|
10
|
+
auto_start_machines = true
|
|
11
|
+
min_machines_running = 0
|
|
12
|
+
|
|
13
|
+
[[http_service.checks]]
|
|
14
|
+
grace_period = "30s"
|
|
15
|
+
interval = "15s"
|
|
16
|
+
method = "GET"
|
|
17
|
+
path = "/_rari/health"
|
|
18
|
+
timeout = "5s"
|
|
19
|
+
|
|
20
|
+
[[vm]]
|
|
21
|
+
memory = "512mb"
|
|
22
|
+
cpu_kind = "shared"
|
|
23
|
+
cpus = 1
|
|
24
|
+
`)}function h(e){let t=t=>s(u(e,t));return t(`pnpm-lock.yaml`)?{copy:t(`pnpm-workspace.yaml`)?`package.json pnpm-lock.yaml pnpm-workspace.yaml`:`package.json pnpm-lock.yaml`,install:[`ENV COREPACK_ENABLE_DOWNLOAD_PROMPT=0`,`RUN corepack enable`,`RUN pnpm install --frozen-lockfile`]}:t(`yarn.lock`)?{copy:`package.json yarn.lock`,install:[`ENV COREPACK_ENABLE_DOWNLOAD_PROMPT=0`,`ENV YARN_NODE_LINKER=node-modules`,`RUN corepack enable`,`RUN yarn install`]}:t(`bun.lock`)||t(`bun.lockb`)?{copy:`package.json ${t(`bun.lock`)?`bun.lock`:`bun.lockb`}`,install:[`RUN npm install -g bun`,`RUN bun install --frozen-lockfile`]}:t(`package-lock.json`)?{copy:`package.json package-lock.json`,install:[`RUN npm ci`]}:{copy:`package.json`,install:[`RUN npm install`]}}function g(e,{copy:t,install:n}){let i=`FROM node:24-slim
|
|
25
|
+
|
|
26
|
+
RUN apt-get update && apt-get install -y libfontconfig1 && rm -rf /var/lib/apt/lists/*
|
|
27
|
+
|
|
28
|
+
WORKDIR /app
|
|
29
|
+
|
|
30
|
+
COPY ${t} ./
|
|
31
|
+
${n.join(`
|
|
32
|
+
`)}
|
|
33
|
+
|
|
34
|
+
COPY . .
|
|
35
|
+
RUN npx rari build
|
|
36
|
+
|
|
37
|
+
ENV NODE_ENV=production
|
|
38
|
+
ENV PORT=8080
|
|
39
|
+
ENV RARI_HOST=0.0.0.0
|
|
40
|
+
ENV RUST_LOG=info
|
|
41
|
+
|
|
42
|
+
EXPOSE 8080
|
|
43
|
+
|
|
44
|
+
CMD ["npm", "start"]
|
|
45
|
+
`;r(e,`Dockerfile`,i)}function _(e,t){let n=c(e,`utf-8`),r=new Set(n.split(`
|
|
46
|
+
`).map(e=>e.trim())),a=t.filter(e=>!r.has(`!${e}`));if(a.length===0)return;let s=n===``||n.endsWith(`
|
|
47
|
+
`)?``:`
|
|
48
|
+
`;o(e,`${s}${a.map(e=>`!${e}`).join(`
|
|
49
|
+
`)}\n`),i(`Updated .dockerignore so the Docker build can copy ${a.join(`, `)}`)}function v(e,t){let n=u(e,`.dockerignore`);s(n)?_(n,t):(l(n,`node_modules
|
|
50
|
+
.git
|
|
51
|
+
.env
|
|
52
|
+
.env.*
|
|
53
|
+
!.env.example
|
|
54
|
+
dist
|
|
55
|
+
*.log
|
|
56
|
+
.DS_Store
|
|
57
|
+
.vscode
|
|
58
|
+
.idea
|
|
59
|
+
`),i(`Created .dockerignore configuration`))}export{p as createFlyDeployment};
|
package/dist/image.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,c as t,i as n,n as r,o as i,r as a,s as o,t as s}from"./constants-C6nBL5YX.mjs";import{configureImageSizes as c}from"./image/runtime-config.mjs";import{c as l}from"react/compiler-runtime";import{useEffect as u,useLayoutEffect as d,useRef as f,useState as p}from"react";import{jsx as m,jsxs as h}from"react/jsx-runtime";import{preload as g}from"react-dom";import{getAllImageSizes as _,getImageDeviceSizes as v,getMaxOptimizedWidth as y}from"rari/image/runtime-config";import"virtual:rari-image-config";function b(e){return Math.min(Math.max(e,1),y())}function x(e){let t=_(),n=b(e);return t.find(e=>e>=n)??t[t.length-1]}function S(e){let t=/(^|[,\s])(1?\d?\d)vw/g,n=[];for(let r=t.exec(e);r!=null;r=t.exec(e))n.push(Number.parseInt(r[2],10));let r=_();if(n.length===0)return[...r];let i=Math.min(...n)*.01,a=v()[0]*i;return r.filter(e=>e>=a)}function C(e){let{fill:t,width:n,intrinsicWidth:r,sizes:i}=e,a=v();if(t)return{defaultWidth:y(),widths:a};let o=n!=null&&n!==0?n:r!=null&&r!==0?r:void 0;if(i!=null&&i!==``){let e=S(i);return{defaultWidth:o==null?e.at(-1)??1920:x(o),widths:e}}if(o==null)return{defaultWidth:1920,widths:a};let s=[...new Set([o,o*2].map(e=>x(e)))];return s.sort((e,t)=>e-t),{defaultWidth:s[0],widths:s}}function w(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 T(e,t,n,r,i){return e==null?w(t,n,r,i):e({src:t,width:n,quality:r})}function ee(e,t,n=!1,r){if(e!=null&&e!==``)return e;if(n)return`100vw`;if(t)return r!=null&&r!==0?`${r}px`:`100vw`}function te(e){if(e==null&&n.length===1&&n[0]===`avif`)return`avif`}function ne(e){if(!e.enabled)return;let{finalSrc:t,defaultWidth:n,widths:r,quality:i,sizes:a,loader:o,unoptimized:s,shouldUseSrcSet:c,format:l}=e;if(s){g(o==null?t:o({src:t,width:n,quality:i}),{as:`image`,fetchPriority:`high`});return}let u=T(o,t,n,i,l);c?g(u,{as:`image`,fetchPriority:`high`,imageSrcSet:A(o,t,r,i,l),...a==null?{}:{imageSizes:a},...l===`avif`?{type:`image/avif`}:{}}):g(u,{as:`image`,fetchPriority:`high`,...l===`avif`?{type:`image/avif`}:{}})}function E(e,t,n){if(e!=null&&e!==0)return e;if(!t&&n!=null&&n!==0)return n}function re(e){let{src:t,width:n,height:r,fill:i,placeholder:a,blurDataURL:o,loader:s}=e,c=typeof t==`string`?t:t.src,l=typeof t==`string`?void 0:t.width,u=typeof t==`string`?void 0:t.height,d=o!=null&&o!==``?o:typeof t==`string`?void 0:t.blurDataURL,f=d!=null&&d!==``?d:void 0,p=a===`blur`&&f==null?T(s,c,16,25,`jpeg`):void 0;return{imgSrc:c,imgWidth:E(n,i,l),imgHeight:E(r,i,u),inlineBlurDataURL:f,optimizerBlurUrl:p}}function D(e){return{position:`absolute`,inset:0,width:`100%`,height:`100%`,objectFit:e?.objectFit??`cover`}}function O(e){return{backgroundImage:`url("${e}")`,backgroundSize:`cover`,backgroundPosition:`center`,filter:`blur(20px)`,transition:`filter 0.3s ease-out`}}function k(e){return e.complete&&e.naturalWidth>0}function ie(e){let{style:t,fill:n,placeholder:r,imgBlurDataURL:i,blurComplete:a}=e,o=r===`blur`&&i!=null&&i!==``&&!a,s=r===`blur`&&a;return{...t,...n?D(t):null,...o?O(i):null,...s?{filter:`none`,transition:`filter 0.3s ease-out`}:null}}function A(e,t,n,r,i){return n.map(n=>`${T(e,t,n,r,i)} ${n}w`).join(`, `)}function ae(e){let{unoptimized:t,loader:n,finalSrc:r,width:i,quality:a,format:o}=e;return t?n==null?r:n({src:r,width:i,quality:a}):T(n,r,i,a,o)}function j(e,t,n){if(!t||e==null)return;let r=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&(n(),r.disconnect())},{rootMargin:`200px`});return r.observe(e),()=>{r.disconnect()}}function
|
|
1
|
+
import{a as e,c as t,i as n,n as r,o as i,r as a,s as o,t as s}from"./constants-C6nBL5YX.mjs";import{configureImageSizes as c}from"./image/runtime-config.mjs";import{c as l}from"react/compiler-runtime";import{useEffect as u,useLayoutEffect as d,useRef as f,useState as p}from"react";import{jsx as m,jsxs as h}from"react/jsx-runtime";import{preload as g}from"react-dom";import{getAllImageSizes as _,getImageDeviceSizes as v,getMaxOptimizedWidth as y}from"rari/image/runtime-config";import"virtual:rari-image-config";function b(e){return Math.min(Math.max(e,1),y())}function x(e){let t=_(),n=b(e);return t.find(e=>e>=n)??t[t.length-1]}function S(e){let t=/(^|[,\s])(1?\d?\d)vw/g,n=[];for(let r=t.exec(e);r!=null;r=t.exec(e))n.push(Number.parseInt(r[2],10));let r=_();if(n.length===0)return[...r];let i=Math.min(...n)*.01,a=v()[0]*i;return r.filter(e=>e>=a)}function C(e){let{fill:t,width:n,intrinsicWidth:r,sizes:i}=e,a=v();if(t)return{defaultWidth:y(),widths:a};let o=n!=null&&n!==0?n:r!=null&&r!==0?r:void 0;if(i!=null&&i!==``){let e=S(i);return{defaultWidth:o==null?e.at(-1)??1920:x(o),widths:e}}if(o==null)return{defaultWidth:1920,widths:a};let s=[...new Set([o,o*2].map(e=>x(e)))];return s.sort((e,t)=>e-t),{defaultWidth:s[0],widths:s}}function w(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 T(e,t,n,r,i){return e==null?w(t,n,r,i):e({src:t,width:n,quality:r})}function ee(e,t,n=!1,r){if(e!=null&&e!==``)return e;if(n)return`100vw`;if(t)return r!=null&&r!==0?`${r}px`:`100vw`}function te(e){if(e==null&&n.length===1&&n[0]===`avif`)return`avif`}function ne(e){if(!e.enabled)return;let{finalSrc:t,defaultWidth:n,widths:r,quality:i,sizes:a,loader:o,unoptimized:s,shouldUseSrcSet:c,format:l}=e;if(s){g(o==null?t:o({src:t,width:n,quality:i}),{as:`image`,fetchPriority:`high`});return}let u=T(o,t,n,i,l);c?g(u,{as:`image`,fetchPriority:`high`,imageSrcSet:A(o,t,r,i,l),...a==null?{}:{imageSizes:a},...l===`avif`?{type:`image/avif`}:{}}):g(u,{as:`image`,fetchPriority:`high`,...l===`avif`?{type:`image/avif`}:{}})}function E(e,t,n){if(e!=null&&e!==0)return e;if(!t&&n!=null&&n!==0)return n}function re(e){let{src:t,width:n,height:r,fill:i,placeholder:a,blurDataURL:o,loader:s}=e,c=typeof t==`string`?t:t.src,l=typeof t==`string`?void 0:t.width,u=typeof t==`string`?void 0:t.height,d=o!=null&&o!==``?o:typeof t==`string`?void 0:t.blurDataURL,f=d!=null&&d!==``?d:void 0,p=a===`blur`&&f==null?T(s,c,16,25,`jpeg`):void 0;return{imgSrc:c,imgWidth:E(n,i,l),imgHeight:E(r,i,u),inlineBlurDataURL:f,optimizerBlurUrl:p}}function D(e){return{position:`absolute`,inset:0,width:`100%`,height:`100%`,objectFit:e?.objectFit??`cover`}}function O(e){return{backgroundImage:`url("${e}")`,backgroundSize:`cover`,backgroundPosition:`center`,filter:`blur(20px)`,transition:`filter 0.3s ease-out`}}function k(e){return e.complete&&e.naturalWidth>0}function ie(e){let{style:t,fill:n,placeholder:r,imgBlurDataURL:i,blurComplete:a}=e,o=r===`blur`&&i!=null&&i!==``&&!a,s=r===`blur`&&a;return{...t,...n?D(t):null,...o?O(i):null,...s?{filter:`none`,transition:`filter 0.3s ease-out`}:null}}function A(e,t,n,r,i){return n.map(n=>`${T(e,t,n,r,i)} ${n}w`).join(`, `)}function ae(e){let{unoptimized:t,loader:n,finalSrc:r,width:i,quality:a,format:o}=e;return t?n==null?r:n({src:r,width:i,quality:a}):T(n,r,i,a,o)}function j(e,t,n){if(!t||e==null)return;let r=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&(n(),r.disconnect())},{rootMargin:`200px`});return r.observe(e),()=>{r.disconnect()}}function oe(e){let{imgElement:t,loader:r,finalSrc:i,widths:a,quality:o,sizes:s}=e;return/* @__PURE__ */ h(`picture`,{children:[n.includes(`avif`)&&/* @__PURE__ */ m(`source`,{type:`image/avif`,srcSet:A(r,i,a,o,`avif`),sizes:s}),n.includes(`webp`)&&/* @__PURE__ */ m(`source`,{type:`image/webp`,srcSet:A(r,i,a,o,`webp`),sizes:s}),t]})}function se(e){let t=l(19),{finalSrc:n,shouldEagerBlur:r,inlineBlurDataURL:i,optimizerBlurUrl:a,placeholder:o}=e,[s,c]=p(!1),[m,h]=p(n),[g,_]=p(r),v=f(null);m!==n&&(h(n),_(r),c(!1));let y;t[0]===o?y=t[1]:(y=()=>{if(o!==`blur`)return;let e=v.current;e!=null&&k(e)&&c(!0)},t[0]=o,t[1]=y);let b;t[2]!==n||t[3]!==o?(b=[o,n],t[2]=n,t[3]=o,t[4]=b):b=t[4],d(y,b);let x;t[5]!==g||t[6]!==a||t[7]!==o||t[8]!==r?(x=()=>j(v.current,!r&&!g&&a!=null&&o===`blur`,()=>{_(!0)}),t[5]=g,t[6]=a,t[7]=o,t[8]=r,t[9]=x):x=t[9];let S;t[10]!==n||t[11]!==g||t[12]!==a||t[13]!==o||t[14]!==r?(S=[r,g,a,o,n],t[10]=n,t[11]=g,t[12]=a,t[13]=o,t[14]=r,t[15]=S):S=t[15],u(x,S);let C=i??(r||g?a:void 0),w;return t[16]!==s||t[17]!==C?(w={imgRef:v,blurComplete:s,setBlurComplete:c,activeBlurUrl:C},t[16]=s,t[17]=C,t[18]=w):w=t[18],w}function M(e){let t=l(16),{src:n,alt:r,width:i,height:a,quality:o,preload:s,loading:c,placeholder:d,blurDataURL:p,fill:h,sizes:g,style:_,className:v,onLoad:y,onError:b,unoptimized:x,loader:S,overrideSrc:w,decoding:T}=e,E=o===void 0?75:o,D=s!==void 0&&s,O=c===void 0?`lazy`:c,k=d===void 0?`empty`:d,j=h!==void 0&&h,M=x!==void 0&&x,{imgSrc:N,imgWidth:P,imgHeight:F,inlineBlurDataURL:I,optimizerBlurUrl:L}=re({src:n,width:i,height:a,fill:j,placeholder:k,blurDataURL:p,loader:S}),R=w!=null&&w!==``?w:N,ce=T??(D?`sync`:`async`),z=C({fill:j,width:i,intrinsicWidth:typeof n==`string`?void 0:n.width,sizes:g}),B=z.widths.length>1||z.widths[0]!==z.defaultWidth,le=D||O===`eager`,V=te(S),H=f(y),{imgRef:ue,blurComplete:U,setBlurComplete:W,activeBlurUrl:G}=se({finalSrc:R,shouldEagerBlur:le,inlineBlurDataURL:I,optimizerBlurUrl:L,placeholder:k}),K,q;t[0]===y?(K=t[1],q=t[2]):(K=()=>{H.current=y},q=[y],t[0]=y,t[1]=K,t[2]=q),u(K,q);let J;t[3]!==k||t[4]!==W?(J=e=>{let t=e.currentTarget;(t.currentSrc===``?t.src:t.currentSrc)!==``&&t.complete&&(k===`blur`&&W(!0),H.current&&H.current(e))},t[3]=k,t[4]=W,t[5]=J):J=t[5];let de=J,Y;t[6]!==b||t[7]!==k||t[8]!==W?(Y=e=>{k===`blur`&&W(!0),b&&b(e)},t[6]=b,t[7]=k,t[8]=W,t[9]=Y):Y=t[9];let fe=Y,X;t[10]!==G||t[11]!==U||t[12]!==j||t[13]!==k||t[14]!==_?(X=ie({style:_,fill:j,placeholder:k,imgBlurDataURL:G,blurComplete:U}),t[10]=G,t[11]=U,t[12]=j,t[13]=k,t[14]=_,t[15]=X):X=t[15];let pe=X,me=ae({unoptimized:M,loader:S,finalSrc:R,width:z.defaultWidth,quality:E,format:V}),Z=ee(g,B,j,i??P??z.defaultWidth),Q=!M&&B?A(S,R,z.widths,E,V):void 0;ne({enabled:D,finalSrc:R,defaultWidth:z.defaultWidth,widths:z.widths,quality:E,sizes:Z,loader:S,unoptimized:M,shouldUseSrcSet:B,format:V});let $=/* @__PURE__ */ m(`img`,{ref:ue,src:me,srcSet:Q,sizes:Q==null?void 0:Z,alt:r,width:j?void 0:P,height:j?void 0:F,loading:D?`eager`:O,fetchPriority:D?`high`:void 0,decoding:ce,onLoad:k===`blur`||y!=null?de:void 0,onError:fe,style:pe,className:v});return M||!B?$:oe({imgElement:$,loader:S,finalSrc:R,widths:z.widths,quality:E,sizes:Z})}const N=typeof window>`u`,P=M;N&&(P.$$typeof=Symbol.for(`react.client.reference`),P.$$id=`rari/image#Image`);export{s as BLUR_PLACEHOLDER_QUALITY,r as BLUR_PLACEHOLDER_WIDTH,a as DEFAULT_DEVICE_SIZES,n as DEFAULT_FORMATS,e as DEFAULT_IMAGE_SIZES,i as DEFAULT_MINIMUM_CACHE_TTL,o as DEFAULT_QUALITY_LEVELS,P as Image,t as MAX_OPTIMIZED_OUTPUT_WIDTH,c as configureImageSizes};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"./utils-DZWuxUA--BobVI1xy.mjs";import{existsSync as s,readFileSync as c,writeFileSync as l}from"node:fs";import{join as u}from"node:path";import d from"node:process";import{styleText as f}from"node:util";function p(){let e=d.cwd();r(`Creating Railway deployment configuration...`);let i=o(e,{providerName:`Railway`});m(e);let a=_(e);n(`Railway`,[...i?[`${f(`cyan`,t(e))} (updates your lockfile for rari)`]:[],f(`cyan`,`git add .`),f(`cyan`,`git commit -m "Add Railway deployment"`),f(`cyan`,`git push origin main`),`Go to ${f(`cyan`,`https://railway.app`)} and deploy from GitHub`],[...a?[`Install libfontconfig1 (required by the Rust runtime)`]:[],`Bind to 0.0.0.0 (Railway requirement)`,`Use Railway's PORT environment variable`])}function m(e){i(e,`railway.toml`,`[build]
|
|
2
|
+
builder = "RAILPACK"
|
|
3
|
+
|
|
4
|
+
[deploy]
|
|
5
|
+
startCommand = "npm start"
|
|
6
|
+
healthcheckPath = "/_rari/health"
|
|
7
|
+
healthcheckTimeout = 300
|
|
8
|
+
restartPolicyType = "ON_FAILURE"
|
|
9
|
+
restartPolicyMaxRetries = 3
|
|
10
|
+
`)}const h=[`libfontconfig1`];function g(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function _(t){let n=u(t,`railpack.json`);if(!s(n)){let e={$schema:`https://schema.railpack.com`,deploy:{aptPackages:[`...`,...h]}};return l(n,`${JSON.stringify(e,null,2)}\n`),a(`Created railpack.json configuration`),!0}let r;try{r=JSON.parse(c(n,`utf-8`))}catch{r=null}if(!g(r)||r.deploy!==void 0&&!g(r.deploy))return e(`Could not update railpack.json. Add ${h.join(`, `)} to deploy.aptPackages manually.`),!1;let i=g(r.deploy)?r.deploy:{},o=Array.isArray(i.aptPackages)?i.aptPackages.filter(e=>typeof e==`string`):[`...`],d=h.filter(e=>!o.includes(e));return d.length===0||(r.deploy={...i,aptPackages:[...o,...d]},l(n,`${JSON.stringify(r,null,2)}\n`),a(`Added ${d.join(`, `)} to railpack.json deploy.aptPackages`)),!0}export{p as createRailwayDeployment};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import{i as e,n as t,o as n,r,t as i}from"./utils-DZWuxUA--BobVI1xy.mjs";import a from"node:process";import{styleText as o}from"node:util";function s(){let r=a.cwd();n(`Creating Render deployment configuration...`);let s=i(r,{providerName:`Render`});c(r),t(`Render`,[...s?[`${o(`cyan`,e(r))} (updates your lockfile for rari)`]:[],o(`cyan`,`git add .`),o(`cyan`,`git commit -m "Add Render deployment"`),o(`cyan`,`git push origin main`),`Go to ${o(`cyan`,`https://render.com`)} and create a Web Service`],[`Bind to 0.0.0.0 (Render requirement)`,`Use Render's PORT environment variable`])}function c(e){r(e,`render.yaml`,`services:
|
|
2
|
+
- type: web
|
|
3
|
+
name: rari-app
|
|
4
|
+
runtime: node
|
|
5
|
+
plan: free
|
|
6
|
+
buildCommand: npm install --include=dev && npx rari build
|
|
7
|
+
startCommand: npm start
|
|
8
|
+
healthCheckPath: /_rari/health
|
|
9
|
+
envVars:
|
|
10
|
+
- key: NODE_ENV
|
|
11
|
+
value: production
|
|
12
|
+
- key: RUST_LOG
|
|
13
|
+
value: info
|
|
14
|
+
`)}export{s as createRenderDeployment};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"../navigation-transition-store-dfNJmkIX.mjs";import{n as t,r as n}from"../form-state-C9jn086j.mjs";import{S as r,d as i,g as a,i as o,p as s,r as c,s as l}from"../type-guards-BLY2PlGR.mjs";import"./action-revalidation-kind.mjs";import{n as u,t as d}from"../preload-modules-0iyuP4Vs.mjs";import{isLayoutReuseMarker as f,layoutPathOf as p,mergeFlightRefresh as m,unwrapFulfilledFlightNode as h}from"./merge-flight-refresh.mjs";import{a as g,i as _,n as v,r as y,t as b}from"../react-helpers-duOBWuYF.mjs";import{i as x,n as S,r as C,t as w}from"../route-cache-BfEqTT9i.mjs";import{c as ee}from"react/compiler-runtime";import{Suspense as T,addTransitionType as te,cloneElement as ne,createContext as E,createElement as D,isValidElement as O,startTransition as re,use as k,useCallback as ie,useEffect as A,useLayoutEffect as ae,useRef as j,useState as M,useSyncExternalStore as N}from"react";import{jsx as P,jsxs as F}from"react/jsx-runtime";import{createFromFetch as oe,createFromReadableStream as se}from"virtual:react-flight-client";const ce={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)`},I={padding:`8px 16px`,background:`white`,color:`#dc2626`,border:`none`,borderRadius:`4px`,cursor:`pointer`,fontWeight:`bold`,fontSize:`14px`},L={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`},le={fetch:`Failed to fetch updated content from server.`,parse:`Failed to parse server response.`,stale:`Server returned stale content.`,network:`Network error occurred.`};function R(e){return le[e]}function ue(e){let t=ee(27),{failure:n,maxRetries:r,onRefresh:i,onDismiss:a}=e,o,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=/* @__PURE__ */ P(`div`,{style:{marginBottom:`16px`,fontWeight:`bold`,fontSize:`16px`},children:`⚠️ HMR Update Failed`}),s={marginBottom:`12px`,opacity:.9},t[0]=o,t[1]=s):(o=t[0],s=t[1]);let c;t[2]===n.type?c=t[3]:(c=R(n.type),t[2]=n.type,t[3]=c);let l;t[4]===c?l=t[5]:(l=/* @__PURE__ */ P(`div`,{style:s,children:c}),t[4]=c,t[5]=l);let u;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(u={marginBottom:`16px`,fontSize:`12px`,opacity:.8,fontFamily:`monospace`},t[6]=u):u=t[6];let d;t[7]===n.details?d=t[8]:(d=/* @__PURE__ */ P(`div`,{style:u,children:n.details}),t[7]=n.details,t[8]=d);let f;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(f={marginBottom:`12px`,fontSize:`12px`,opacity:.7},t[9]=f):f=t[9];let p;t[10]!==n.consecutiveFailures||t[11]!==r?(p=/* @__PURE__ */ F(`div`,{style:f,children:[`Consecutive failures: `,n.consecutiveFailures,` / `,r]}),t[10]=n.consecutiveFailures,t[11]=r,t[12]=p):p=t[12];let m;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(m={display:`flex`,gap:`8px`},t[13]=m):m=t[13];let h;t[14]===i?h=t[15]:(h=/* @__PURE__ */ P(`button`,{onClick:i,type:`button`,style:I,children:`Refresh Page`}),t[14]=i,t[15]=h);let g;t[16]===a?g=t[17]:(g=/* @__PURE__ */ P(`button`,{onClick:a,type:`button`,style:L,children:`Dismiss`}),t[16]=a,t[17]=g);let _;t[18]!==h||t[19]!==g?(_=/* @__PURE__ */ F(`div`,{style:m,children:[h,g]}),t[18]=h,t[19]=g,t[20]=_):_=t[20];let v;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(v=/* @__PURE__ */ P(`div`,{style:{marginTop:`12px`,fontSize:`11px`,opacity:.6},children:`Check the console for detailed error logs.`}),t[21]=v):v=t[21];let y;return t[22]!==_||t[23]!==l||t[24]!==d||t[25]!==p?(y=/* @__PURE__ */ F(`div`,{style:ce,children:[o,l,d,p,_,v]}),t[22]=_,t[23]=l,t[24]=d,t[25]=p,t[26]=y):y=t[26],y}function z(e,t,n){C.getShell()??C.ingest(e,t,n)}function B(e){if(e.fromPathname!==`/`&&(e.fromPathname!==e.toPathname||e.fromSearch!==e.search))return{pathname:e.fromPathname,search:e.fromSearch}}function V(e){if(z(e.previousDocument,e.fromPathname,e.fromSearch),y(e.refresh)){if(!C.ingest(e.refresh,e.toPathname,e.search))return{kind:`hard-nav`}}else if(O(e.refresh)){if(!C.ingestSegment(e.refresh,e.toPathname,e.search))return{kind:`hard-nav`}}else return{kind:`hard-nav`};if(C.getShell()==null||!C.hasRoute(e.toPathname,e.search))return{kind:`hard-nav`};let t=C.readLeaf(e.toPathname,e.search),n=v(e.refresh)||t!=null&&v(t),r=t!=null&&_(t)||_(e.refresh),i=B(e);return y(e.refresh)?{kind:`merged`,element:e.refresh,maySuspend:n,hasLoadingFallback:r,pendingEvictLeaf:i}:{kind:`merged`,element:e.previousDocument,maySuspend:n,hasLoadingFallback:r,pendingEvictLeaf:i}}function H(e,t,n,r){if(y(t))return C.ingest(t,n,r);if(O(t)&&C.getShell()!=null)return C.ingestSegment(t,n,r);let i=m(e,t);return O(t)&&f(t)&&i===e||!y(i)?!1:C.ingest(i,n,r)}function U(e,t){let n=v(e),r=_(e);return y(e)?{kind:`merged`,element:e,maySuspend:n,hasLoadingFallback:r}:y(t)?{kind:`merged`,element:t,maySuspend:n,hasLoadingFallback:r}:{kind:`hard-nav`}}function de(e){return y(e.previousDocument)&&C.getShell()==null&&!C.ingest(e.previousDocument,e.pathname,e.search)||!H(e.previousDocument,e.refresh,e.pathname,e.search)||C.getShell()==null||!C.hasRoute(e.pathname,e.search)?{kind:`hard-nav`}:U(e.refresh,e.previousDocument)}function fe(e){return e.historyKey!=null&&e.historyKey!==``?[`nav`,`nav-traverse`]:e.replace===!0?[`nav`,`nav-replace`]:[`nav`,`nav-forward`]}function pe(e,t){if(e==null||e.url===``)return t;try{let t=`http://localhost/`;if(typeof window<`u`)try{t=window.location.href}catch{}let n=new URL(e.url,t);return{pathname:n.pathname,search:n.search}}catch{return t}}function W(e){e!=null&&typeof window<`u`&&(e.replace===!0?window.history.replaceState(e.state,``,e.url):window.history.pushState(e.state,``,e.url))}function me(e){let{parsedPayload:t,shouldScrollToTop:n,navigationId:r,transitionTypes:i,maySuspend:a=!1,hasLoadingFallback:o=!1,pendingHistory:s,routeLocation:c,startTransition:l=re,currentNavigationIdRef:u,pendingScrollPayloadRef:d,setRenderKey:f,setRscPayload:p,setRouteLocation:m,setPendingLoadingLeaf:h,clearHmrError:g,pendingNavigateCommittedIdRef:_,pendingEvictLeaf:v}=e;if(u.current!==r)return;let y=a&&o;a&&W(s),y&&c!=null&&(m?.(c),h?.(c));let b=()=>{u.current===r&&(h?.(null),a||W(s),c!=null&&m?.(c),v!=null&&C.evictLeaf(v.pathname,v.search),f(e=>{let r=e+1;return d.current=n?{payload:t,commitKey:r}:null,r}),p(t),g(),_.current=r)};l(()=>{if(i!=null)for(let e of i)te(e);b()})}const he=E(null);function G(){return k(he)}function K(e,t,n){return n?.pathname===e&&n.search===t}function ge(){return N(C.subscribe,C.getVersion,C.getVersion)}function _e(e){return p(e)!=null&&!x(e)&&!f(e)}function q(e,t,n){if(e==null||e===!1||e===!0)return e;if(Array.isArray(e))return b(e).map(e=>q(e,t,n));if(!O(e))return e;if(x(e)||_e(e)){let r=p(e);return r==null?null:D(Y,{key:r,layoutPath:r,pathname:t,search:n})}let r=e.props,i=r.children;if(i==null)return e;let a=q(i,t,n);if(Object.is(a,i))return e;let o=b(a),s={...r};return delete s.children,ne(e,s,...o.length===0?[null]:o)}function J({layoutPath:e,pathname:t,search:n},r,i=null){let a=C.readSegmentSnapshot(e,{pathname:t,search:n});if(a==null||O(a)&&x(a))return null;if(C.isDeepestLayout(e,t)){let{fallback:e,content:r}=g(a);return K(t,n,i)&&e!=null?e:D(T,{fallback:e},r)}return q(a,t,n)}function Y(e){let t=ee(4),n=ge(),r=G(),i;return t[0]!==n||t[1]!==r||t[2]!==e?(i=J(e,n,r),t[0]=n,t[1]=r,t[2]=e,t[3]=i):i=t[3],i}function ve({fallback:e=null,pathname:t,search:n},r){let i=C.getShell();if(i!=null){let e=q(i,t,n);return O(e)?e:null}return e!=null&&w(e)?null:e}function ye(e){let t=ee(3),n=ge(),r;return t[0]!==n||t[1]!==e?(r=ve(e,n),t[0]=n,t[1]=e,t[2]=r):r=t[2],r}function be(e,t,n){return e==null||e.commitKey!==n?{shouldScroll:!1,nextPending:null}:t===e.payload?{shouldScroll:!0,nextPending:null}:{shouldScroll:!1,nextPending:e}}function xe(e){if(e==null)return null;if(s(e)){let t=h(e);return t===e||!y(t)?null:t}return y(e)?e:null}const Se=/"timestamp":(\d+)/;function Ce(e){if(!i(e)||l(e))return!1;let t=e.message;return t===`Failed to fetch`||t.includes(`NetworkError`)||t.includes(`network error`)||t.includes(`Load failed`)}async function we(e){await new Promise(t=>{setTimeout(t,e)})}async function X(e,t,n){if(e.maySuspend!==!0||e.hasLoadingFallback!==!0)return e;if(e.bodyComplete==null){await Promise.resolve();let r=C.readLeaf(t,n);return r!=null&&!v(r)?{...e,maySuspend:!1}:e}if(await Promise.race([e.bodyComplete.then(e=>e?`body`:`failed`),we(100).then(()=>`timeout`)])===`body`)return{...e,maySuspend:!1};let r=C.readLeaf(t,n);return r!=null&&!v(r)?{...e,maySuspend:!1}:e}function Te(e){return e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`||O(e)||Array.isArray(e)}function Ee(e){return a(e)&&typeof e.from==`string`&&typeof e.to==`string`&&typeof e.navigationId==`number`&&a(e.options)}function De(e){return a(e)&&`element`in e}function Oe(e){return a(e)&&typeof e.navigationId==`number`&&typeof e.targetPath==`string`}function ke(e){if(!s(e))return e;if(a(e)&&e.status===`fulfilled`)return Te(e.value)?e.value:void 0}function Ae(e){return y(e)||O(e)&&f(e)}function je(e){let t=e.pendingHistory?.url;if(t!=null&&t!==``)try{return new URL(t,window.location.origin).search}catch{}return S().search}function Me(e,t){console.error(`[rari] AppRouter: Navigation failed:`,t),window.dispatchEvent(new CustomEvent(`rari:navigate-error`,{detail:{from:e.from,to:e.to,error:t,navigationId:e.navigationId}}))}function Ne(e){let t=e.pendingHistory?.url,n=t!=null&&t!==``?new URL(t,window.location.origin).hash.length>0:window.location.hash.length>0;return(e.options.historyKey==null||e.options.historyKey===``)&&!n&&e.options.scroll!==!1}async function Pe(e,t,n,r,i,a,o,s){let c=await Fe(e.element);if(r!==n)return{kind:`superseded`};if(!Ae(c))return{kind:`error`,error:/* @__PURE__ */ Error(`[rari] AppRouter: navigated Flight content did not resolve to an <html> document root`)};let l=xe(t);if(O(c)&&f(c)&&l==null)return{kind:`error`,error:/* @__PURE__ */ Error(`[rari] AppRouter: layout-reuse Flight marker requires a previous <html> document`)};if(l==null)return y(c)?(C.set(a,o,c),{kind:`payload`,payload:await X({...e,element:c,maySuspend:v(c),hasLoadingFallback:_(c)},a,o)}):{kind:`error`,error:/* @__PURE__ */ Error(`[rari] AppRouter: navigated Flight content did not resolve to an <html> document root`)};let u=V({previousDocument:l,refresh:c,fromPathname:i,toPathname:a,fromSearch:s,search:o});return u.kind===`hard-nav`?{kind:`hard-nav`}:{kind:`payload`,payload:await X({...e,element:u.element,maySuspend:u.maySuspend,hasLoadingFallback:u.hasLoadingFallback===!0,pendingEvictLeaf:u.pendingEvictLeaf},a,o)}}async function Fe(e){let t=u(e);for(let e=0;e<10&&s(t);e+=1)t=u(await t);if(s(t))throw Error(`[rari] AppRouter: Flight content did not resolve to a React node`);return t}function Ie({children:f,initialPayload:p,onNavigate:m}){let[h,g]=M(p),_=j(p),[v,b]=M(0),[x,ee]=M(()=>S()),[T,te]=M(null),ne=j(x),E=j({x:0,y:0}),D=j(null),k=j(/* @__PURE__ */ new Map),N=j(/* @__PURE__ */ new Set),ce=j(m),I=j(0),L=j(0),le=j(/* @__PURE__ */ new Map),R=j(null),z=j(null),B=j(/* @__PURE__ */ new Map),V=j([]),H=j(null),U=j(0),[W,G]=M(null);A(()=>{ne.current=x},[x]),A(()=>{ce.current=m},[m]),ae(()=>{let{shouldScroll:e,nextPending:t}=be(D.current,h,v);D.current=t,e&&window.scrollTo(0,0);let n=z.current;n!=null&&(z.current=null,window.dispatchEvent(new CustomEvent(`rari:navigate-committed`,{detail:{navigationId:n}})))},[h,v]),A(()=>{e()},[v]);let K=ie(e=>{if(e==null||s(e)||!O(e)||e.type!==`html`&&e.type!==`HTML`||w(e))return;let{pathname:t,search:n}=x;C.getShell()!=null&&C.hasRoute(t,n)||C.set(t,n,e)},[x]),ge=j(K);A(()=>{ge.current=K},[K]),A(()=>{_.current=h,h?.element!=null&&K(h.element)},[h,K]),A(()=>{if(h?.element!=null){let e=h.element;if(a(e)&&`status`in e&&e.status===`rejected`){let t=e.reason;t!=null&&t!==``&&console.error(`[rari] AppRouter: Flight payload rejected:`,t)}}},[h]);let _e=()=>{k.current=t()},q=()=>{n(k.current)};ae(()=>{let e=R.current;e!=null&&h===e&&(R.current=null,window.scrollTo(E.current.x,E.current.y),q())},[h,v]);let J=(e,t,n,r)=>{U.current+=1;let i={timestamp:Date.now(),error:e,type:t,details:n,filePath:r,consecutiveFailures:U.current};V.current.push(i),V.current.length>10&&V.current.shift(),U.current>=2&&G(i),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`rari:hmr-failure`,{detail:i}))},Y=()=>{setTimeout(()=>{window.location.reload()},1e3)},ve=()=>{U.current>0&&(U.current=0)},xe=e=>{if(H.current==null||H.current===``)return!1;if(e===H.current)return!0;let t=Se.exec(e);if(t){let e=Number.parseInt(t[1],10);if(Date.now()-e>5e3)return!0}return!1},X=e=>{d(e,N.current);let t=new ReadableStream({start(t){t.enqueue(new TextEncoder().encode(e)),t.close()}});return{element:se(t),flightProtocol:e}},Ae=async e=>{let t=await e;if(!t.body)throw Error(`Response has no body stream`);let n=t.clone();return{element:oe(Promise.resolve(t)),flightProtocol:``,bodyComplete:n.text().then(async e=>(await d(e,N.current),e!==``&&(H.current=e),!0)).catch(()=>!1)}},Ie=async(e,t)=>{try{let n=await e.text();if(xe(n))return B.current.delete(t),`stale`;let r=await Fe(X(n).element);if(!y(r))throw Error(`[rari] AppRouter: refetched Flight content did not resolve to an <html> document root`);return{element:r,flightProtocol:n}}catch(e){if(l(e))throw e;let t=r(e),n=Error(`Failed to parse RSC Flight protocol: ${t.message}`,{cause:t});return J(n,`parse`,n.message,window.location.pathname),n}},Le=async(e,t,n)=>{let a=e!=null&&e!==``?e:window.location.pathname,o=I.current,s=n?.commit!==!1,c=n?.expectedRoute!=null&&n.expectedSeq!=null?`:hmr:${n.expectedRoute}:${n.expectedSeq}`:``,u=`${o}:${a}${window.location.search}:${s?`commit`:`defer`}${c}`,d=B.current.get(u);if(d)return d;let f=n?.expectedRoute,p=n?.expectedSeq,m=(async()=>{try{let e=a+window.location.search,n=await fetch(e,{headers:{Accept:`text/x-component`,"rari-navigation-id":String(I.current)},cache:`no-store`,signal:t});if(!n.ok){let t=/* @__PURE__ */ Error(`Failed to fetch RSC data: ${n.status} ${n.statusText}`);throw J(t,`fetch`,`HTTP ${n.status} when fetching ${e}`,window.location.pathname),t}let r=await Ie(n,u);if(r===`stale`)return;if(r instanceof Error)throw r;let i=f==null||p==null||le.current.get(f)===p;return I.current===o&&i&&(s&&g(r),r.flightProtocol!=null&&r.flightProtocol!==``&&(H.current=r.flightProtocol),ve()),B.current.delete(u),r}catch(e){throw B.current.delete(u),i(e)&&!l(e)&&!e.message.includes(`Failed to fetch RSC data`)&&!e.message.includes(`Failed to parse`)&&J(e,`network`,`Network error: ${e.message}`,window.location.pathname),r(e)}})();return B.current.set(u,m),m},Re=j(X),ze=j(Ae),Be=j(Le);A(()=>{Re.current=X,ze.current=Ae,Be.current=Le}),A(()=>{if(typeof window>`u`)return;let e=async e=>{if(e.rscResponsePromise){let t=await e.rscResponsePromise;if(I.current!==e.navigationId)return;let n=await ze.current(Promise.resolve(t));return I.current===e.navigationId?n:void 0}if(e.rscResponse){let t=await ze.current(Promise.resolve(e.rscResponse));return I.current===e.navigationId?t:void 0}if(e.rscFlightProtocol!=null&&e.rscFlightProtocol!==``)return Re.current(e.rscFlightProtocol);if(!e.isStreaming)return Be.current(e.to,e.abortSignal,{commit:!1})},t=async(e,t)=>{try{let n=await Pe(t,_.current?.element,e.navigationId,I.current,e.from,e.to,je(e),ne.current.search);if(n.kind===`superseded`)return null;if(n.kind===`hard-nav`){if(I.current!==e.navigationId)return null;let t=e.pendingHistory?.url!=null&&e.pendingHistory.url!==``?e.pendingHistory.url:e.to;return window.dispatchEvent(new CustomEvent(`rari:navigate-committed`,{detail:{navigationId:e.navigationId}})),window.location.assign(t),null}return n.kind===`error`?(Me(e,n.error),null):I.current===e.navigationId?n.payload:null}catch(t){return Me(e,r(t)),null}},n=(e,t)=>{let n=pe(e.pendingHistory,{pathname:e.to,search:je(e)});me({parsedPayload:t,shouldScrollToTop:Ne(e),navigationId:e.navigationId,transitionTypes:fe({historyKey:e.options.historyKey,replace:e.options.replace}),maySuspend:t.maySuspend===!0,hasLoadingFallback:t.hasLoadingFallback===!0,pendingHistory:e.pendingHistory,routeLocation:n,pendingEvictLeaf:t.pendingEvictLeaf,startTransition:re,currentNavigationIdRef:I,pendingScrollPayloadRef:D,setRenderKey:b,setRscPayload:g,setRouteLocation:ee,setPendingLoadingLeaf:te,clearHmrError:()=>{G(null)},pendingNavigateCommittedIdRef:z}),t.flightProtocol!=null&&t.flightProtocol!==``&&(H.current=t.flightProtocol),ve(),ce.current&&ce.current(e)},i=async t=>{try{return{kind:`payload`,payload:await e(t)}}catch(e){return l(e)?{kind:`aborted`}:{kind:`error`,error:r(e)}}},a=async e=>{let r=o(e,Ee);if(!r||r.navigationId!==I.current)return;E.current={x:window.scrollX,y:window.scrollY},_e();let a=await i(r);if(a.kind===`aborted`)return;if(a.kind===`error`){Me(r,a.error),U.current>=3&&Y();return}let s=a.payload;if(s==null&&r.isStreaming&&I.current===r.navigationId||s==null||I.current!==r.navigationId)return;let c=await t(r,s);c!=null&&n(r,c)},u=async e=>{let t;for(let n=0;n<3;n+=1)try{return await Be.current(void 0,void 0,{commit:!0,expectedRoute:e.expectedRoute,expectedSeq:e.expectedSeq})}catch(e){if(t=e,!Ce(e)||n===2)throw e;await we(150*(n+1))}throw r(t)},d=async()=>{let e=I.current,{pathname:t,search:n}=S(),r=`${t}${n}`,i=le.current,a=(i.get(r)??0)+1;i.set(r,a);let o=await u({expectedRoute:r,expectedSeq:a});if(I.current!==e)return!1;let{pathname:c,search:l}=S();if(`${c}${l}`!==r||i.get(r)!==a)return!1;let d=o?.element;return d==null||s(d)||!O(d)||d.type!==`html`&&d.type!==`HTML`||w(d)||C.set(t,n,d),!0},f=async()=>{E.current={x:window.scrollX,y:window.scrollY},_e();try{if(!await d())return;let e=I.current,{pathname:t,search:n}=S(),r=`${t}${n}`,i={x:E.current.x,y:E.current.y};b(e=>e+1),G(null),requestAnimationFrame(()=>{if(I.current!==e)return;let{pathname:t,search:n}=S();`${t}${n}`===r&&(window.scrollTo(i.x,i.y),q())})}catch(e){console.error(`HMR refetch error:`,c(e,String(e))),U.current>=3&&Y()}},p=e=>{let t=o(e,De);if(t?.element==null||!Te(t.element)&&!s(t.element))return;let{pathname:n,search:i}=S(),a=++L.current,c=I.current,l=`${n}${i}`;E.current={x:window.scrollX,y:window.scrollY},_e();try{t.revalidationKind===1?C.clear():t.revalidatedPath!=null&&t.revalidatedPath!==``?C.invalidate(t.revalidatedPath,i):C.invalidate(n,i);let e=_.current?.element,o=C.getElement(n,i)??(e!=null&&s(e)?null:e??null),u=t.element;(async()=>{try{let e=await Fe(u);if(a!==L.current||I.current!==c)return;let{pathname:t,search:r}=S();if(`${t}${r}`!==l)return;let s=de({previousDocument:o??null,refresh:e,pathname:n,search:i});if(s.kind===`hard-nav`){window.location.reload();return}let d=s.element;if(a!==L.current||I.current!==c)return;let f=S();if(`${f.pathname}${f.search}`!==l)return;let p={element:d};R.current=p,re(()=>{g(p),G(null)}),ge.current(d),ve()}catch(e){if(a!==L.current||I.current!==c)return;let t=r(e);J(t,`parse`,`Action flight refresh failed: ${t.message}`,window.location.pathname),U.current>=3&&Y()}})()}catch(e){let t=r(e);J(t,`parse`,`Action flight refresh failed: ${t.message}`,window.location.pathname),U.current>=3&&Y()}},m=async()=>{try{if(!await d())return;b(e=>e+1),G(null)}catch(e){console.error(`RSC invalidate error:`,c(e,String(e))),U.current>=3&&Y()}},h=e=>{let t=o(e,Oe);t&&(N.current.clear(),I.current=t.navigationId,L.current+=1,D.current=null,R.current=null,te(null))},v=async()=>{try{if(!await d())return;G(null)}catch(e){console.error(`Manifest update error:`,c(e,String(e))),U.current>=3&&Y()}},y=e=>{a(e)},x=()=>{f()},T=()=>{m()},k=()=>{v()};return window.addEventListener(`rari:navigation-start`,h),window.addEventListener(`rari:navigate`,y),window.addEventListener(`rari:app-router-rerender`,x),window.addEventListener(`rari:action-flight-refresh`,p),window.addEventListener(`rari:rsc-invalidate`,T),window.addEventListener(`rari:app-router-manifest-updated`,k),()=>{window.removeEventListener(`rari:navigation-start`,h),window.removeEventListener(`rari:navigate`,y),window.removeEventListener(`rari:app-router-rerender`,x),window.removeEventListener(`rari:action-flight-refresh`,p),window.removeEventListener(`rari:rsc-invalidate`,T),window.removeEventListener(`rari:app-router-manifest-updated`,k)}},[]),A(()=>{if(typeof window<`u`&&window.location.hash&&h){let e=window.location.hash.slice(1);requestAnimationFrame(()=>{requestAnimationFrame(()=>{let t=document.getElementById(e);t&&t.scrollIntoView({behavior:`instant`,block:`start`})})})}},[h]);let Ve=h?.element??f,He=u(Ve),[Z,Ue]=M(null),We=ke(He),Ge=s(He)&&We===void 0,Ke=We===void 0?s(He)?null:He:u(We),Q=Ke!=null&&!s(Ke)&&y(Ke)?Ke:null;Q!=null&&!Object.is(Q,Z)&&!w(Q)&&Ue(Q);let $=Ge?Z:Q,qe=$!=null&&y($)&&!w($)?$:Z!=null&&y(Z)&&!w(Z)?Z:null;if(qe==null&&!C.hasRoute(x.pathname,x.search))throw Error(`[rari] AppRouter: expected a resolved <html> document root`);return/* @__PURE__ */ F(he,{value:T,children:[W!=null&&/* @__PURE__ */ P(ue,{failure:W,maxRetries:3,onRefresh:()=>{window.location.reload()},onDismiss:()=>{G(null)}}),/* @__PURE__ */ P(ye,{fallback:qe,pathname:x.pathname,search:x.search})]})}export{Ie as AppRouterProvider};
|
|
1
|
+
import{i as e}from"../navigation-transition-store-dfNJmkIX.mjs";import{n as t,r as n}from"../form-state-C9jn086j.mjs";import{S as r,d as i,g as a,i as o,p as s,r as c,s as l}from"../type-guards-BLY2PlGR.mjs";import"./action-revalidation-kind.mjs";import{n as u,t as d}from"../preload-modules-0iyuP4Vs.mjs";import{isLayoutReuseMarker as f,layoutPathOf as p,mergeFlightRefresh as m,unwrapFulfilledFlightNode as h}from"./merge-flight-refresh.mjs";import{a as g,i as _,n as v,r as y,t as b}from"../react-helpers-duOBWuYF.mjs";import{i as x,n as S,r as C,t as w}from"../route-cache-BfEqTT9i.mjs";import{c as T}from"react/compiler-runtime";import{Suspense as ee,addTransitionType as te,cloneElement as ne,createContext as E,createElement as D,isValidElement as O,startTransition as re,use as k,useCallback as ie,useEffect as A,useLayoutEffect as ae,useRef as j,useState as M,useSyncExternalStore as N}from"react";import{jsx as P,jsxs as F}from"react/jsx-runtime";import{createFromFetch as oe,createFromReadableStream as se}from"virtual:react-flight-client";const I={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)`},L={padding:`8px 16px`,background:`white`,color:`#dc2626`,border:`none`,borderRadius:`4px`,cursor:`pointer`,fontWeight:`bold`,fontSize:`14px`},R={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`},ce={fetch:`Failed to fetch updated content from server.`,parse:`Failed to parse server response.`,stale:`Server returned stale content.`,network:`Network error occurred.`};function z(e){return ce[e]}function le(e){let t=T(27),{failure:n,maxRetries:r,onRefresh:i,onDismiss:a}=e,o,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=/* @__PURE__ */ P(`div`,{style:{marginBottom:`16px`,fontWeight:`bold`,fontSize:`16px`},children:`⚠️ HMR Update Failed`}),s={marginBottom:`12px`,opacity:.9},t[0]=o,t[1]=s):(o=t[0],s=t[1]);let c;t[2]===n.type?c=t[3]:(c=z(n.type),t[2]=n.type,t[3]=c);let l;t[4]===c?l=t[5]:(l=/* @__PURE__ */ P(`div`,{style:s,children:c}),t[4]=c,t[5]=l);let u;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(u={marginBottom:`16px`,fontSize:`12px`,opacity:.8,fontFamily:`monospace`},t[6]=u):u=t[6];let d;t[7]===n.details?d=t[8]:(d=/* @__PURE__ */ P(`div`,{style:u,children:n.details}),t[7]=n.details,t[8]=d);let f;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(f={marginBottom:`12px`,fontSize:`12px`,opacity:.7},t[9]=f):f=t[9];let p;t[10]!==n.consecutiveFailures||t[11]!==r?(p=/* @__PURE__ */ F(`div`,{style:f,children:[`Consecutive failures: `,n.consecutiveFailures,` / `,r]}),t[10]=n.consecutiveFailures,t[11]=r,t[12]=p):p=t[12];let m;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(m={display:`flex`,gap:`8px`},t[13]=m):m=t[13];let h;t[14]===i?h=t[15]:(h=/* @__PURE__ */ P(`button`,{onClick:i,type:`button`,style:L,children:`Refresh Page`}),t[14]=i,t[15]=h);let g;t[16]===a?g=t[17]:(g=/* @__PURE__ */ P(`button`,{onClick:a,type:`button`,style:R,children:`Dismiss`}),t[16]=a,t[17]=g);let _;t[18]!==h||t[19]!==g?(_=/* @__PURE__ */ F(`div`,{style:m,children:[h,g]}),t[18]=h,t[19]=g,t[20]=_):_=t[20];let v;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(v=/* @__PURE__ */ P(`div`,{style:{marginTop:`12px`,fontSize:`11px`,opacity:.6},children:`Check the console for detailed error logs.`}),t[21]=v):v=t[21];let y;return t[22]!==_||t[23]!==l||t[24]!==d||t[25]!==p?(y=/* @__PURE__ */ F(`div`,{style:I,children:[o,l,d,p,_,v]}),t[22]=_,t[23]=l,t[24]=d,t[25]=p,t[26]=y):y=t[26],y}function ue(e,t,n){C.getShell()??C.ingest(e,t,n)}function de(e){if(e.fromPathname!==`/`&&(e.fromPathname!==e.toPathname||e.fromSearch!==e.search))return{pathname:e.fromPathname,search:e.fromSearch}}function fe(e){if(ue(e.previousDocument,e.fromPathname,e.fromSearch),y(e.refresh)){if(!C.ingest(e.refresh,e.toPathname,e.search))return{kind:`hard-nav`}}else if(O(e.refresh)){if(!C.ingestSegment(e.refresh,e.toPathname,e.search))return{kind:`hard-nav`}}else return{kind:`hard-nav`};if(C.getShell()==null||!C.hasRoute(e.toPathname,e.search))return{kind:`hard-nav`};let t=C.readLeaf(e.toPathname,e.search),n=v(e.refresh)||t!=null&&v(t),r=t!=null&&_(t)||_(e.refresh),i=de(e);return y(e.refresh)?{kind:`merged`,element:e.refresh,maySuspend:n,hasLoadingFallback:r,pendingEvictLeaf:i}:{kind:`merged`,element:e.previousDocument,maySuspend:n,hasLoadingFallback:r,pendingEvictLeaf:i}}function B(e,t,n,r){if(y(t))return C.ingest(t,n,r);if(O(t)&&C.getShell()!=null)return C.ingestSegment(t,n,r);let i=m(e,t);return O(t)&&f(t)&&i===e||!y(i)?!1:C.ingest(i,n,r)}function V(e,t){let n=v(e),r=_(e);return y(e)?{kind:`merged`,element:e,maySuspend:n,hasLoadingFallback:r}:y(t)?{kind:`merged`,element:t,maySuspend:n,hasLoadingFallback:r}:{kind:`hard-nav`}}function pe(e){return y(e.previousDocument)&&C.getShell()==null&&!C.ingest(e.previousDocument,e.pathname,e.search)||!B(e.previousDocument,e.refresh,e.pathname,e.search)||C.getShell()==null||!C.hasRoute(e.pathname,e.search)?{kind:`hard-nav`}:V(e.refresh,e.previousDocument)}function me(e){return e.historyKey!=null&&e.historyKey!==``?[`nav`,`nav-traverse`]:e.replace===!0?[`nav`,`nav-replace`]:[`nav`,`nav-forward`]}function he(e,t){if(e==null||e.url===``)return t;try{let t=`http://localhost/`;if(typeof window<`u`)try{t=window.location.href}catch{}let n=new URL(e.url,t);return{pathname:n.pathname,search:n.search}}catch{return t}}function H(e){e!=null&&typeof window<`u`&&(e.replace===!0?window.history.replaceState(e.state,``,e.url):window.history.pushState(e.state,``,e.url))}function ge(e){let{parsedPayload:t,shouldScrollToTop:n,navigationId:r,transitionTypes:i,maySuspend:a=!1,hasLoadingFallback:o=!1,pendingHistory:s,routeLocation:c,startTransition:l=re,currentNavigationIdRef:u,pendingScrollPayloadRef:d,setRenderKey:f,setRscPayload:p,setRouteLocation:m,setPendingLoadingLeaf:h,clearHmrError:g,pendingNavigateCommittedIdRef:_,setCommittedNavigationId:v,pendingEvictLeaf:y,pendingEvictLeavesRef:b}=e;if(u.current!==r)return;let x=a&&o;a&&H(s),x&&c!=null&&(m?.(c),h?.(c));let S=()=>{u.current===r&&(h?.(null),a||H(s),c!=null&&m?.(c),y!=null&&b?.current.push(y),f(e=>{let r=e+1;return d.current=n?{payload:t,commitKey:r}:null,r}),p(t),g(),_.current=r,v?.(r))};l(()=>{if(i!=null)for(let e of i)te(e);S()})}const _e=E(null);function U(){return k(_e)}function W(e,t,n){return n?.pathname===e&&n.search===t}function G(){return N(C.subscribe,C.getVersion,C.getVersion)}function K(e){return p(e)!=null&&!x(e)&&!f(e)}function q(e,t,n){if(e==null||e===!1||e===!0)return e;if(Array.isArray(e))return b(e).map(e=>q(e,t,n));if(!O(e))return e;if(x(e)||K(e)){let r=p(e);return r==null?null:D(J,{key:r,layoutPath:r,pathname:t,search:n})}let r=e.props,i=r.children;if(i==null)return e;let a=q(i,t,n);if(Object.is(a,i))return e;let o=b(a),s={...r};return delete s.children,ne(e,s,...o.length===0?[null]:o)}function ve({layoutPath:e,pathname:t,search:n},r,i=null){let a=C.readSegmentSnapshot(e,{pathname:t,search:n});if(a==null||O(a)&&x(a))return null;if(C.isDeepestLayout(e,t)){let{fallback:e,content:r}=g(a);return W(t,n,i)&&e!=null?e:D(ee,{fallback:e},r)}return q(a,t,n)}function J(e){let t=T(4),n=G(),r=U(),i;return t[0]!==n||t[1]!==r||t[2]!==e?(i=ve(e,n,r),t[0]=n,t[1]=r,t[2]=e,t[3]=i):i=t[3],i}function ye({fallback:e=null,pathname:t,search:n},r){let i=C.getShell();if(i!=null){let e=q(i,t,n);return O(e)?e:null}return e!=null&&w(e)?null:e}function be(e){let t=T(3),n=G(),r;return t[0]!==n||t[1]!==e?(r=ye(e,n),t[0]=n,t[1]=e,t[2]=r):r=t[2],r}function xe(e,t,n){return e==null||e.commitKey!==n?{shouldScroll:!1,nextPending:null}:t===e.payload?{shouldScroll:!0,nextPending:null}:{shouldScroll:!1,nextPending:e}}function Y(e){if(e==null)return null;if(s(e)){let t=h(e);return t===e||!y(t)?null:t}return y(e)?e:null}const Se=/"timestamp":(\d+)/;function Ce(e){if(!i(e)||l(e))return!1;let t=e.message;return t===`Failed to fetch`||t.includes(`NetworkError`)||t.includes(`network error`)||t.includes(`Load failed`)}async function we(e){await new Promise(t=>{setTimeout(t,e)})}async function X(e,t,n){if(e.maySuspend!==!0||e.hasLoadingFallback!==!0)return e;if(e.bodyComplete==null){await Promise.resolve();let r=C.readLeaf(t,n);return r!=null&&!v(r)?{...e,maySuspend:!1}:e}if(await Promise.race([e.bodyComplete.then(e=>e?`body`:`failed`),we(100).then(()=>`timeout`)])===`body`)return{...e,maySuspend:!1};let r=C.readLeaf(t,n);return r!=null&&!v(r)?{...e,maySuspend:!1}:e}function Te(e){return e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`||O(e)||Array.isArray(e)}function Ee(e){return a(e)&&typeof e.from==`string`&&typeof e.to==`string`&&typeof e.navigationId==`number`&&a(e.options)}function De(e){return a(e)&&`element`in e}function Oe(e){return a(e)&&typeof e.navigationId==`number`&&typeof e.targetPath==`string`}function ke(e){if(!s(e))return e;if(a(e)&&e.status===`fulfilled`)return Te(e.value)?e.value:void 0}function Z(e){return y(e)||O(e)&&f(e)}function Ae(e){let t=e.pendingHistory?.url;if(t!=null&&t!==``)try{return new URL(t,window.location.origin).search}catch{}return S().search}function je(e,t){console.error(`[rari] AppRouter: Navigation failed:`,t),window.dispatchEvent(new CustomEvent(`rari:navigate-error`,{detail:{from:e.from,to:e.to,error:t,navigationId:e.navigationId}}))}function Me(e){let t=e.pendingHistory?.url,n=t!=null&&t!==``?new URL(t,window.location.origin).hash.length>0:window.location.hash.length>0;return(e.options.historyKey==null||e.options.historyKey===``)&&!n&&e.options.scroll!==!1}async function Ne(e,t,n,r,i,a,o,s){let c=await Pe(e.element);if(r!==n)return{kind:`superseded`};if(!Z(c))return{kind:`error`,error:/* @__PURE__ */ Error(`[rari] AppRouter: navigated Flight content did not resolve to an <html> document root`)};let l=Y(t);if(O(c)&&f(c)&&l==null)return{kind:`error`,error:/* @__PURE__ */ Error(`[rari] AppRouter: layout-reuse Flight marker requires a previous <html> document`)};if(l==null)return y(c)?(C.set(a,o,c),{kind:`payload`,payload:await X({...e,element:c,maySuspend:v(c),hasLoadingFallback:_(c)},a,o)}):{kind:`error`,error:/* @__PURE__ */ Error(`[rari] AppRouter: navigated Flight content did not resolve to an <html> document root`)};let u=fe({previousDocument:l,refresh:c,fromPathname:i,toPathname:a,fromSearch:s,search:o});return u.kind===`hard-nav`?{kind:`hard-nav`}:{kind:`payload`,payload:await X({...e,element:u.element,maySuspend:u.maySuspend,hasLoadingFallback:u.hasLoadingFallback===!0,pendingEvictLeaf:u.pendingEvictLeaf},a,o)}}async function Pe(e){let t=u(e);for(let e=0;e<10&&s(t);e+=1)t=u(await t);if(s(t))throw Error(`[rari] AppRouter: Flight content did not resolve to a React node`);return t}function Fe({children:f,initialPayload:p,onNavigate:m}){let[h,g]=M(p),_=j(p),[v,b]=M(0),[x,T]=M(()=>S()),[ee,te]=M(null),ne=j(x),E=j({x:0,y:0}),D=j(null),k=j(/* @__PURE__ */ new Map),N=j(/* @__PURE__ */ new Set),I=j(m),L=j(0),R=j(0),ce=j(/* @__PURE__ */ new Map),z=j(null),ue=j(null),[de,fe]=M(null),B=j([]),V=j(/* @__PURE__ */ new Map),H=j([]),U=j(null),W=j(0),[G,K]=M(null);A(()=>{ne.current=x},[x]),A(()=>{I.current=m},[m]),ae(()=>{let{shouldScroll:e,nextPending:t}=xe(D.current,h,v);D.current=t,e&&window.scrollTo(0,0);let n=ue.current;if(n==null||de!==n)return;ue.current=null;let r=B.current;if(r.length>0){B.current=[];let e=S();for(let t of r)(t.pathname!==e.pathname||t.search!==e.search)&&C.evictLeaf(t.pathname,t.search)}window.dispatchEvent(new CustomEvent(`rari:navigate-committed`,{detail:{navigationId:n}}))},[h,v,de]),A(()=>{e()},[v]);let q=ie(e=>{if(e==null||s(e)||!O(e)||e.type!==`html`&&e.type!==`HTML`||w(e))return;let{pathname:t,search:n}=x;C.getShell()!=null&&C.hasRoute(t,n)||C.set(t,n,e)},[x]),ve=j(q);A(()=>{ve.current=q},[q]),A(()=>{_.current=h,h?.element!=null&&q(h.element)},[h,q]),A(()=>{if(h?.element!=null){let e=h.element;if(a(e)&&`status`in e&&e.status===`rejected`){let t=e.reason;t!=null&&t!==``&&console.error(`[rari] AppRouter: Flight payload rejected:`,t)}}},[h]);let J=()=>{k.current=t()},ye=()=>{n(k.current)};ae(()=>{let e=z.current;e!=null&&h===e&&(z.current=null,window.scrollTo(E.current.x,E.current.y),ye())},[h,v]);let Y=(e,t,n,r)=>{W.current+=1;let i={timestamp:Date.now(),error:e,type:t,details:n,filePath:r,consecutiveFailures:W.current};H.current.push(i),H.current.length>10&&H.current.shift(),W.current>=2&&K(i),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`rari:hmr-failure`,{detail:i}))},X=()=>{setTimeout(()=>{window.location.reload()},1e3)},Z=()=>{W.current>0&&(W.current=0)},Fe=e=>{if(U.current==null||U.current===``)return!1;if(e===U.current)return!0;let t=Se.exec(e);if(t){let e=Number.parseInt(t[1],10);if(Date.now()-e>5e3)return!0}return!1},Ie=e=>{d(e,N.current);let t=new ReadableStream({start(t){t.enqueue(new TextEncoder().encode(e)),t.close()}});return{element:se(t),flightProtocol:e}},Le=async e=>{let t=await e;if(!t.body)throw Error(`Response has no body stream`);let n=t.clone();return{element:oe(Promise.resolve(t)),flightProtocol:``,bodyComplete:n.text().then(async e=>(await d(e,N.current),e!==``&&(U.current=e),!0)).catch(()=>!1)}},Re=async(e,t)=>{try{let n=await e.text();if(Fe(n))return V.current.delete(t),`stale`;let r=await Pe(Ie(n).element);if(!y(r))throw Error(`[rari] AppRouter: refetched Flight content did not resolve to an <html> document root`);return{element:r,flightProtocol:n}}catch(e){if(l(e))throw e;let t=r(e),n=Error(`Failed to parse RSC Flight protocol: ${t.message}`,{cause:t});return Y(n,`parse`,n.message,window.location.pathname),n}},ze=async(e,t,n)=>{let a=e!=null&&e!==``?e:window.location.pathname,o=L.current,s=n?.commit!==!1,c=n?.expectedRoute!=null&&n.expectedSeq!=null?`:hmr:${n.expectedRoute}:${n.expectedSeq}`:``,u=`${o}:${a}${window.location.search}:${s?`commit`:`defer`}${c}`,d=V.current.get(u);if(d)return d;let f=n?.expectedRoute,p=n?.expectedSeq,m=(async()=>{try{let e=a+window.location.search,n=await fetch(e,{headers:{Accept:`text/x-component`,"rari-navigation-id":String(L.current)},cache:`no-store`,signal:t});if(!n.ok){let t=/* @__PURE__ */ Error(`Failed to fetch RSC data: ${n.status} ${n.statusText}`);throw Y(t,`fetch`,`HTTP ${n.status} when fetching ${e}`,window.location.pathname),t}let r=await Re(n,u);if(r===`stale`)return;if(r instanceof Error)throw r;let i=f==null||p==null||ce.current.get(f)===p;return L.current===o&&i&&(s&&g(r),r.flightProtocol!=null&&r.flightProtocol!==``&&(U.current=r.flightProtocol),Z()),V.current.delete(u),r}catch(e){throw V.current.delete(u),i(e)&&!l(e)&&!e.message.includes(`Failed to fetch RSC data`)&&!e.message.includes(`Failed to parse`)&&Y(e,`network`,`Network error: ${e.message}`,window.location.pathname),r(e)}})();return V.current.set(u,m),m},Be=j(Ie),Ve=j(Le),He=j(ze);A(()=>{Be.current=Ie,Ve.current=Le,He.current=ze}),A(()=>{if(typeof window>`u`)return;let e=async e=>{if(e.rscResponsePromise){let t=await e.rscResponsePromise;if(L.current!==e.navigationId)return;let n=await Ve.current(Promise.resolve(t));return L.current===e.navigationId?n:void 0}if(e.rscResponse){let t=await Ve.current(Promise.resolve(e.rscResponse));return L.current===e.navigationId?t:void 0}if(e.rscFlightProtocol!=null&&e.rscFlightProtocol!==``)return Be.current(e.rscFlightProtocol);if(!e.isStreaming)return He.current(e.to,e.abortSignal,{commit:!1})},t=async(e,t)=>{try{let n=await Ne(t,_.current?.element,e.navigationId,L.current,e.from,e.to,Ae(e),ne.current.search);if(n.kind===`superseded`)return null;if(n.kind===`hard-nav`){if(L.current!==e.navigationId)return null;let t=e.pendingHistory?.url!=null&&e.pendingHistory.url!==``?e.pendingHistory.url:e.to;return window.dispatchEvent(new CustomEvent(`rari:navigate-committed`,{detail:{navigationId:e.navigationId,hardNavigation:!0}})),window.location.assign(t),null}return n.kind===`error`?(je(e,n.error),null):L.current===e.navigationId?n.payload:null}catch(t){return je(e,r(t)),null}},n=(e,t)=>{let n=he(e.pendingHistory,{pathname:e.to,search:Ae(e)});ge({parsedPayload:t,shouldScrollToTop:Me(e),navigationId:e.navigationId,transitionTypes:me({historyKey:e.options.historyKey,replace:e.options.replace}),maySuspend:t.maySuspend===!0,hasLoadingFallback:t.hasLoadingFallback===!0,pendingHistory:e.pendingHistory,routeLocation:n,pendingEvictLeaf:t.pendingEvictLeaf,pendingEvictLeavesRef:B,startTransition:re,currentNavigationIdRef:L,pendingScrollPayloadRef:D,setRenderKey:b,setRscPayload:g,setRouteLocation:T,setPendingLoadingLeaf:te,clearHmrError:()=>{K(null)},pendingNavigateCommittedIdRef:ue,setCommittedNavigationId:fe}),t.flightProtocol!=null&&t.flightProtocol!==``&&(U.current=t.flightProtocol),Z(),I.current&&I.current(e)},i=async t=>{try{return{kind:`payload`,payload:await e(t)}}catch(e){return l(e)?{kind:`aborted`}:{kind:`error`,error:r(e)}}},a=async e=>{let r=o(e,Ee);if(!r||r.navigationId!==L.current)return;E.current={x:window.scrollX,y:window.scrollY},J();let a=await i(r);if(a.kind===`aborted`)return;if(a.kind===`error`){je(r,a.error),W.current>=3&&X();return}let s=a.payload;if(s==null&&r.isStreaming&&L.current===r.navigationId||s==null||L.current!==r.navigationId)return;let c=await t(r,s);c!=null&&n(r,c)},u=async e=>{let t;for(let n=0;n<3;n+=1)try{return await He.current(void 0,void 0,{commit:!0,expectedRoute:e.expectedRoute,expectedSeq:e.expectedSeq})}catch(e){if(t=e,!Ce(e)||n===2)throw e;await we(150*(n+1))}throw r(t)},d=async()=>{let e=L.current,{pathname:t,search:n}=S(),r=`${t}${n}`,i=ce.current,a=(i.get(r)??0)+1;i.set(r,a);let o=await u({expectedRoute:r,expectedSeq:a});if(L.current!==e)return!1;let{pathname:c,search:l}=S();if(`${c}${l}`!==r||i.get(r)!==a)return!1;let d=o?.element;return d==null||s(d)||!O(d)||d.type!==`html`&&d.type!==`HTML`||w(d)||C.set(t,n,d),!0},f=async()=>{E.current={x:window.scrollX,y:window.scrollY},J();try{if(!await d())return;let e=L.current,{pathname:t,search:n}=S(),r=`${t}${n}`,i={x:E.current.x,y:E.current.y};b(e=>e+1),K(null),requestAnimationFrame(()=>{if(L.current!==e)return;let{pathname:t,search:n}=S();`${t}${n}`===r&&(window.scrollTo(i.x,i.y),ye())})}catch(e){console.error(`HMR refetch error:`,c(e,String(e))),W.current>=3&&X()}},p=e=>{let t=o(e,De);if(t?.element==null||!Te(t.element)&&!s(t.element))return;let{pathname:n,search:i}=S(),a=++R.current,c=L.current,l=`${n}${i}`;E.current={x:window.scrollX,y:window.scrollY},J();try{t.revalidationKind===1?C.clear():t.revalidatedPath!=null&&t.revalidatedPath!==``?C.invalidate(t.revalidatedPath,i):C.invalidate(n,i);let e=_.current?.element,o=C.getElement(n,i)??(e!=null&&s(e)?null:e??null),u=t.element;(async()=>{try{let e=await Pe(u);if(a!==R.current||L.current!==c)return;let{pathname:t,search:r}=S();if(`${t}${r}`!==l)return;let s=pe({previousDocument:o??null,refresh:e,pathname:n,search:i});if(s.kind===`hard-nav`){window.location.reload();return}let d=s.element;if(a!==R.current||L.current!==c)return;let f=S();if(`${f.pathname}${f.search}`!==l)return;let p={element:d};z.current=p,re(()=>{g(p),K(null)}),ve.current(d),Z()}catch(e){if(a!==R.current||L.current!==c)return;let t=r(e);Y(t,`parse`,`Action flight refresh failed: ${t.message}`,window.location.pathname),W.current>=3&&X()}})()}catch(e){let t=r(e);Y(t,`parse`,`Action flight refresh failed: ${t.message}`,window.location.pathname),W.current>=3&&X()}},m=async()=>{try{if(!await d())return;b(e=>e+1),K(null)}catch(e){console.error(`RSC invalidate error:`,c(e,String(e))),W.current>=3&&X()}},h=e=>{let t=o(e,Oe);t&&(N.current.clear(),L.current=t.navigationId,R.current+=1,D.current=null,z.current=null,te(null))},v=async()=>{try{if(!await d())return;K(null)}catch(e){console.error(`Manifest update error:`,c(e,String(e))),W.current>=3&&X()}},y=e=>{a(e)},x=()=>{f()},ee=()=>{m()},k=()=>{v()};return window.addEventListener(`rari:navigation-start`,h),window.addEventListener(`rari:navigate`,y),window.addEventListener(`rari:app-router-rerender`,x),window.addEventListener(`rari:action-flight-refresh`,p),window.addEventListener(`rari:rsc-invalidate`,ee),window.addEventListener(`rari:app-router-manifest-updated`,k),()=>{window.removeEventListener(`rari:navigation-start`,h),window.removeEventListener(`rari:navigate`,y),window.removeEventListener(`rari:app-router-rerender`,x),window.removeEventListener(`rari:action-flight-refresh`,p),window.removeEventListener(`rari:rsc-invalidate`,ee),window.removeEventListener(`rari:app-router-manifest-updated`,k)}},[]),A(()=>{if(typeof window<`u`&&window.location.hash&&h){let e=window.location.hash.slice(1);requestAnimationFrame(()=>{requestAnimationFrame(()=>{let t=document.getElementById(e);t&&t.scrollIntoView({behavior:`instant`,block:`start`})})})}},[h]);let Ue=h?.element??f,We=u(Ue),[Q,Ge]=M(null),Ke=ke(We),qe=s(We)&&Ke===void 0,Je=Ke===void 0?s(We)?null:We:u(Ke),$=Je!=null&&!s(Je)&&y(Je)?Je:null;$!=null&&!Object.is($,Q)&&!w($)&&Ge($);let Ye=qe?Q:$,Xe=Ye!=null&&y(Ye)&&!w(Ye)?Ye:Q!=null&&y(Q)&&!w(Q)?Q:null;if(Xe==null&&!C.hasRoute(x.pathname,x.search))throw Error(`[rari] AppRouter: expected a resolved <html> document root`);return/* @__PURE__ */ F(_e,{value:ee,children:[G!=null&&/* @__PURE__ */ P(le,{failure:G,maxRetries:3,onRefresh:()=>{window.location.reload()},onDismiss:()=>{K(null)}}),/* @__PURE__ */ P(be,{fallback:Xe,pathname:x.pathname,search:x.search})]})}export{Fe as AppRouterProvider};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{t as e}from"../router-861SNPMt.mjs";import{g as t,i as n,n as r,p as i,r as a}from"../type-guards-BLY2PlGR.mjs";import{n as o,t as s}from"../preload-modules-0iyuP4Vs.mjs";import{r as c}from"../react-helpers-duOBWuYF.mjs";import{a as l,n as u,r as d}from"../rari-global-5vGzhToD.mjs";import{createElement as f}from"react";import{createFromFetch as p,createFromReadableStream as m}from"virtual:react-flight-client";import{createRoot as h,hydrateRoot as g}from"react-dom/client";import{AppRouterProvider as _}from"virtual:app-router-provider";import{ClientRouter as v}from"virtual:client-router";import"virtual:rsc-integration.ts";function y(e,t){if(e.querySelector(`.rari-error[data-rari-hydration-failure]`))return;let n=document.createElement(`div`);n.className=`rari-error`,n.setAttribute(`data-rari-hydration-failure`,`true`),n.setAttribute(`role`,`alert`),n.style.cssText=`color:red;border:1px solid red;padding:10px;border-radius:4px;background-color:#fff5f5;margin:10px 0;`;let r=document.createElement(`strong`);r.textContent=`Failed to load page: `,n.append(r,document.createTextNode(t)),e.prepend(n)}function b(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_COMMENT);for(;t.nextNode();){let e=t.currentNode;if(e.nodeType===8&&`data`in e){let t=e.data;if(t===`$`||t===`$?`||t===`/$`)return!0}}return!!(e.querySelector(`[data-reactroot]`)||e.querySelectorAll(`template[data-rri]`).length>0)}function x(e){let t=e.tagName;if(t===`SCRIPT`||t===`STYLE`||t===`LINK`||t===`META`||t===`NOSCRIPT`)return!0;let n=typeof e.getAttribute==`function`?e.getAttribute.bind(e):null;return n==null?!1:n(`data-rari-nav-transition`)!=null||n(`aria-hidden`)===`true`}function S(e){let t=e.firstElementChild;for(;t!=null&&x(t);)t=t.nextElementSibling;return t}function C(e){if(b(e))return!0;let t=S(e);return t!==null&&!t.classList.contains(`rari-error`)}function w(e){return b(e)}function T(e){e.querySelectorAll(`.rari-error:not([data-rari-hydration-failure])`).forEach(e=>{e.remove()})}
|
|
1
|
+
import{t as e}from"../router-861SNPMt.mjs";import{g as t,i as n,n as r,p as i,r as a}from"../type-guards-BLY2PlGR.mjs";import{n as o,t as s}from"../preload-modules-0iyuP4Vs.mjs";import{r as c}from"../react-helpers-duOBWuYF.mjs";import{a as l,n as u,r as d}from"../rari-global-5vGzhToD.mjs";import{createElement as f}from"react";import{createFromFetch as p,createFromReadableStream as m}from"virtual:react-flight-client";import{createRoot as h,hydrateRoot as g}from"react-dom/client";import{AppRouterProvider as _}from"virtual:app-router-provider";import{ClientRouter as v}from"virtual:client-router";import"virtual:rsc-integration.ts";function y(e,t){if(e.querySelector(`.rari-error[data-rari-hydration-failure]`))return;let n=document.createElement(`div`);n.className=`rari-error`,n.setAttribute(`data-rari-hydration-failure`,`true`),n.setAttribute(`role`,`alert`),n.style.cssText=`color:red;border:1px solid red;padding:10px;border-radius:4px;background-color:#fff5f5;margin:10px 0;`;let r=document.createElement(`strong`);r.textContent=`Failed to load page: `,n.append(r,document.createTextNode(t)),e.prepend(n)}function b(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_COMMENT);for(;t.nextNode();){let e=t.currentNode;if(e.nodeType===8&&`data`in e){let t=e.data;if(t===`$`||t===`$?`||t===`/$`)return!0}}return!!(e.querySelector(`[data-reactroot]`)||e.querySelectorAll(`template[data-rri]`).length>0)}function x(e){let t=e.tagName;if(t===`SCRIPT`||t===`STYLE`||t===`LINK`||t===`META`||t===`NOSCRIPT`)return!0;let n=typeof e.getAttribute==`function`?e.getAttribute.bind(e):null;return n==null?!1:n(`data-rari-nav-transition`)!=null||n(`aria-hidden`)===`true`}function S(e){let t=e.firstElementChild;for(;t!=null&&x(t);)t=t.nextElementSibling;return t}function C(e){if(b(e))return!0;let t=S(e);return t!==null&&!t.classList.contains(`rari-error`)}function w(e){return b(e)}function T(e){e.querySelectorAll(`.rari-error:not([data-rari-hydration-failure])`).forEach(e=>{e.remove()})}const E=`__rari-route-announcer`;function D(){let e=document.getElementById(E);if(e)return e;let t=document.createElement(`div`);return t.id=E,t.setAttribute(`aria-live`,`polite`),t.setAttribute(`aria-atomic`,`true`),t.setAttribute(`style`,`position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0`),document.body.append(t),t}function O(){let e=document.title.trim();if(e!==``)return e;let t=document.querySelector(`h1`)?.textContent.trim()??``;return t===``?window.location.pathname:t}function k(e){if(!(e instanceof CustomEvent))return!1;let t=e.detail;return typeof t==`object`&&!!t&&Reflect.get(t,`hardNavigation`)===!0}function A(){typeof document<`u`&&(D(),window.addEventListener(`rari:navigate-committed`,e=>{if(k(e))return;let t=D();t.textContent=``,requestAnimationFrame(()=>{t.textContent=O()})}))}async function j(e){let t=o(e);for(let e=0;e<10&&i(t);e+=1)t=o(await t);if(i(t))throw Error(`[rari] Failed to resolve Flight element to a React node`);return t}function M(t){if(!c(t))return y(document.body,`RSC payload did not resolve to an <html> document root. Try refreshing the page.`),console.error(`[rari] Hydration skipped: Flight content is not a document root`),!1;let n=f(_,{initialPayload:{element:t}});return n=f(v,{initialRoute:window.location.pathname},n),n=f(e,{initialPathname:window.location.pathname},n),F(n),!0}function N(){Reflect.set(globalThis,`__rari_client_ready`,!0),window.dispatchEvent(new CustomEvent(`rari:client-ready`))}function P(e){if(e===``)return;let t=()=>{document.title.trim()===``&&(document.title=e)};t(),queueMicrotask(t),requestAnimationFrame(()=>{t(),requestAnimationFrame(t)})}function F(e){let t=document.documentElement,n=document.title.trim();w(t)?(T(t),g(document,e,{onRecoverableError(e){import.meta.env.DEV&&console.warn(`[rari] Hydration mismatch:`,e)}})):h(document).render(e),P(n),A(),N()}
|
|
2
2
|
/*! @preserve CLIENT_COMPONENT_IMPORTS_PLACEHOLDER */
|
|
3
3
|
d(),u();
|
|
4
4
|
/*! @preserve CLIENT_COMPONENT_REGISTRATIONS_PLACEHOLDER */
|
|
5
|
-
function
|
|
5
|
+
function I(){let e=Reflect.get(globalThis,`__rari_f`);if(Array.isArray(e))return e}function L(e){return t(e)&&typeof e.rscRow==`string`}function R(e){return Array.isArray(e)&&typeof e[1]==`string`}function z(){return!!I()?.some(e=>e!==0)}function B(){let e=I();if(e?.length==null||e.length===0)return null;let t=``,n=[];for(let r of e)r!==0&&(typeof r==`string`?t+=r:R(r)&&n.push(r[1]));if(n.length>0){let e=n.map(e=>Uint8Array.from(atob(e),e=>e.charCodeAt(0))),t=e.reduce((e,t)=>e+t.length,0),r=new Uint8Array(t),i=0;for(let t of e)r.set(t,i),i+=t.length;return r}return t?new TextEncoder().encode(t):null}async function V(e,t){let r=new TextDecoder().decode(e);await s(r);let i=l(),a=i.streaming,o=!!(a?.bufferedRows&&a.bufferedRows.length>0);if(t.streaming&&(a?.complete===void 0||o)){let t=new ReadableStream({start(t){let r=!1;t.enqueue(e);let a=e=>{if(r)return;let i=n(e,L);i&&t.enqueue(new TextEncoder().encode(`\n${i.rscRow}`))},o=()=>{r||(r=!0,t.close(),window.removeEventListener(`rari:html-stream-row`,a),window.removeEventListener(`rari:stream-complete`,o))};if(window.addEventListener(`rari:html-stream-row`,a),window.addEventListener(`rari:stream-complete`,o),i.streaming?.bufferedRows){let e=[...i.streaming.bufferedRows];for(let n of e)t.enqueue(new TextEncoder().encode(`\n${n}`));i.streaming.bufferedRows=[]}i.streaming?.complete&&o()}});return m(t)}let c=new ReadableStream({start(t){t.enqueue(e),t.close()}});return m(c)}async function H(e){let t=`Could not load interactive page data.`,n;try{n=await V(e,{streaming:!1})}catch(e){t=a(e,`Failed to parse embedded RSC payload.`);try{let e=window.location.pathname+window.location.search,r=await fetch(e,{headers:{Accept:`text/x-component`},cache:`no-store`});r.ok?n=await p(Promise.resolve(r)):t=`Failed to fetch RSC payload fallback: HTTP ${r.status}.`}catch(e){t=a(e,`Failed to fetch RSC payload fallback.`),console.error(`[rari] Failed to fetch RSC payload fallback:`,e)}}return n==null?(y(document.body,`${t} Try refreshing the page.`),console.error(`[rari] Hydration skipped: failed to load RSC payload`),{ok:!1,errorMessage:t}):(M(await j(n)),{ok:!0,errorMessage:t})}async function U(){try{let e=window.location.pathname+window.location.search,t=await fetch(e,{headers:{Accept:`text/x-component`},cache:`no-store`});if(!t.ok&&t.status!==404)throw Error(`Failed to fetch RSC data: ${t.status}`);if(!t.body)throw Error(`RSC response has no body`);return await p(Promise.resolve(t))}catch(e){if(e instanceof Promise)throw e;return console.error(`[rari] Failed to fetch initial RSC data:`,e),null}}function W(){return new ReadableStream({start(e){let t=t=>{let r=n(t,L);r&&e.enqueue(new TextEncoder().encode(`${r.rscRow}\n`))},r=()=>{e.close(),window.removeEventListener(`rari:html-stream-row`,t),window.removeEventListener(`rari:stream-complete`,r)};window.addEventListener(`rari:html-stream-row`,t),window.addEventListener(`rari:stream-complete`,r);let i=l();if(i.streaming?.bufferedRows){let t=[...i.streaming.bufferedRows];i.streaming.bufferedRows=[];for(let n of t)e.enqueue(new TextEncoder().encode(`${n}\n`))}i.streaming?.complete&&r()}})}async function G(){try{return await m(W())}catch(e){return console.error(`[rari] Failed to process streaming RSC payload:`,e),null}}async function K(e){try{return await V(e,{streaming:!0})}catch(e){return console.error(`[rari] Failed to parse embedded RSC payload:`,e),console.error(`[rari] Error stack:`,r(e)?.stack??`no stack`),null}}async function q(){let e=z(),t=B(),n=document.documentElement,r=C(document.body)||b(n),i=l().streaming,a=!!(i?.bufferedRows&&i.bufferedRows.length>0);try{if(r&&e&&t){await H(t);return}let n=!e&&!a&&!r,i;if(n?i=await U():e&&t?i=await K(t):a&&(i=await G()),i==null)throw Error(`No RSC data available for hydration`);M(await j(i))}catch(e){console.error(`[rari] Error rendering app:`,e)}}function J(){let e=import.meta.hot;if(!e)return{};let n=e.data;return t(n)?{hasRendered:n.hasRendered===!0}:{}}function Y(){let e=import.meta.hot;if(!e)return;let n=e.data;t(n)&&(n.hasRendered=!0)}import.meta.hot&&J().hasRendered===!0||(q().catch(e=>{console.error(`[rari] Fatal error:`,e)}),Y());export{q as renderApp};
|
|
@@ -1,37 +1 @@
|
|
|
1
|
-
import{existsSync as e,readFileSync as t,writeFileSync as n}from"node:fs";import{join as r}from"node:path";import i from"node:process";import{styleText as a}from"node:util";function o(e){console.warn(`${a(`blue`,`info`)} ${e}`)}function s(e){console.warn(`${a(`green`,`✓`)} ${e}`)}function c(e){console.error(`${a(`red`,`✗`)} ${e}`)}function l(e){console.warn(`${a(`yellow`,`⚠`)} ${e}`)}function u(e,t=`Unknown error`){return Error.isError(e)?e.message:typeof e==`string`?e:t}const d=/\s+(?:&&\s+)?/,f=/^>=?\s*(\d+)/,p=/^>=?\s*(\d+)\.(\d+)\.(\d+)/,m=/^=?\s*(\d+)\.(\d+)\.(\d+)/,h=/^\^\s*(\d+)\.(\d+)\.(\d+)/,g=/^~\s*(\d+)\.(\d+)\.(\d+)/,_=/^(?:>=?|<=?|[=~^])?\s*(\d+)\.(\d+)/,v=/^(\d+)\.(?:x|\*)/i,y=/^(?:>=?|[=~^])\s*(\d+)(?:\s|$)/,b=/^(\d+)$/;function x(e){return typeof e==`object`&&!!e}function S(e){let t=JSON.parse(e);if(!x(t))throw Error(`Invalid package.json`);return t}function C(e,t=`>=24.21.0`){if(e.engines=e.engines??{},e.engines.node){if(!w(e.engines.node,t))return l(`Current engines.node value "${e.engines.node}" may not meet the required minimum of ${t}`),l(`Updating to ${t} for deployment compatibility`),e.engines.node=t,!0}else return e.engines.node=t,!0;return!1}function w(e,t){let n=T(e),r=T(t);return!n||!r?!1:E(n,r)>=0}function T(e){let t=e.trim(),n=e=>e!==null;if(t.includes(`||`)){let e=t.split(`||`).map(e=>e.trim()).map(e=>T(e)).filter(n);return e.length===0?null:e.reduce((e,t)=>E(t,e)<0?t:e)}let r=t.split(d).filter(e=>e!==``&&e!==`&&`);if(r.length>1){let e=r.filter(e=>f.test(e)).map(e=>T(e)).filter(n);return e.length===0?null:e.reduce((e,t)=>E(t,e)>0?t:e)}let i=null;return i=p.exec(t),i||(i=m.exec(t),i)||(i=h.exec(t),i)||(i=g.exec(t),i)?{major:Number.parseInt(i[1],10),minor:Number.parseInt(i[2],10),patch:Number.parseInt(i[3],10)}:(i=_.exec(t),i?{major:Number.parseInt(i[1],10),minor:Number.parseInt(i[2],10),patch:0}:(i=v.exec(t),i||(i=y.exec(t),i)||(i=b.exec(t),i)?{major:Number.parseInt(i[1],10),minor:0,patch:0}:null))}function E(e,t){return e.major===t.major?e.minor===t.minor?e.patch-t.patch:e.minor-t.minor:e.major-t.major}function D(n=i.cwd()){let a=r(n,`node_modules/rari/package.json`);if(!e(a))return c(`rari is not installed. Please run "npm install rari" first.`),i.exit(1),``;try{let e=S(t(a,`utf-8`));return e.version!=null&&e.version!==``?`^${e.version}`:(c(`Could not determine rari version from package.json`),i.exit(1),``)}catch(e){return c(`Failed to read rari package.json: ${u(e)}`),i.exit(1),``}}function O(a,d){let f=r(a,`package.json`);e(f)
|
|
2
|
-
`);if(e(c)){let e=t(c,`utf-8`),r=e.split(`
|
|
3
|
-
`).map(e=>e.trim());r.includes(`${o}/`)||r.includes(o)||(n(c,e+l),s(`Updated .gitignore with ${a} entries`))}else{let e=`# Dependencies
|
|
4
|
-
node_modules
|
|
5
|
-
.pnpm-store
|
|
6
|
-
|
|
7
|
-
# Build outputs
|
|
8
|
-
dist
|
|
9
|
-
|
|
10
|
-
# Environment variables
|
|
11
|
-
.env
|
|
12
|
-
.env.local
|
|
13
|
-
.env.production
|
|
14
|
-
|
|
15
|
-
# ${a}
|
|
16
|
-
${o}
|
|
17
|
-
|
|
18
|
-
# Logs
|
|
19
|
-
*.log
|
|
20
|
-
npm-debug.log*
|
|
21
|
-
pnpm-debug.log*
|
|
22
|
-
|
|
23
|
-
# OS files
|
|
24
|
-
.DS_Store
|
|
25
|
-
Thumbs.db
|
|
26
|
-
|
|
27
|
-
# IDE files
|
|
28
|
-
.vscode
|
|
29
|
-
.idea
|
|
30
|
-
*.swp
|
|
31
|
-
*.swo
|
|
32
|
-
*~
|
|
33
|
-
|
|
34
|
-
# Temporary files
|
|
35
|
-
.tmp
|
|
36
|
-
tmp
|
|
37
|
-
`;n(c,e),s(`Created .gitignore with ${a} entries`)}}function A(a,o,d){let f=r(a,o);try{if(e(f)){let i=t(f,`utf-8`),s=`${o}.backup`,c=r(a,s);e(c)&&(s=`${o}.backup.${Date.now()}`,c=r(a,s)),l(`${o} already exists, backing up to ${s}`),n(c,i,{flag:`wx`})}n(f,d),s(`Created ${o} configuration`)}catch(e){c(`Failed to create or backup ${o}: ${u(e)}`),i.exit(1)}}export{o as a,O as i,A as n,s as o,D as r,k as t};
|
|
1
|
+
import{existsSync as e,readFileSync as t,writeFileSync as n}from"node:fs";import{join as r}from"node:path";import i from"node:process";import{styleText as a}from"node:util";function o(e){console.warn(`${a(`blue`,`info`)} ${e}`)}function s(e){console.warn(`${a(`green`,`✓`)} ${e}`)}function c(e){console.error(`${a(`red`,`✗`)} ${e}`)}function l(e){console.warn(`${a(`yellow`,`⚠`)} ${e}`)}function u(e,t=`Unknown error`){return Error.isError(e)?e.message:typeof e==`string`?e:t}const d=/\s+(?:&&\s+)?/,f=/^>=?\s*(\d+)/,p=/^>=?\s*(\d+)\.(\d+)\.(\d+)/,m=/^=?\s*(\d+)\.(\d+)\.(\d+)/,h=/^\^\s*(\d+)\.(\d+)\.(\d+)/,g=/^~\s*(\d+)\.(\d+)\.(\d+)/,_=/^(?:>=?|<=?|[=~^])?\s*(\d+)\.(\d+)/,v=/^(\d+)\.(?:x|\*)/i,y=/^(?:>=?|[=~^])\s*(\d+)(?:\s|$)/,b=/^(\d+)$/;function x(e){return typeof e==`object`&&!!e}function S(e){let t=JSON.parse(e);if(!x(t))throw Error(`Invalid package.json`);return t}function C(e,t=`>=24.21.0`){if(e.engines=e.engines??{},e.engines.node){if(!w(e.engines.node,t))return l(`Current engines.node value "${e.engines.node}" may not meet the required minimum of ${t}`),l(`Updating to ${t} for deployment compatibility`),e.engines.node=t,!0}else return e.engines.node=t,!0;return!1}function w(e,t){let n=T(e),r=T(t);return!n||!r?!1:E(n,r)>=0}function T(e){let t=e.trim(),n=e=>e!==null;if(t.includes(`||`)){let e=t.split(`||`).map(e=>e.trim()).map(e=>T(e)).filter(n);return e.length===0?null:e.reduce((e,t)=>E(t,e)<0?t:e)}let r=t.split(d).filter(e=>e!==``&&e!==`&&`);if(r.length>1){let e=r.filter(e=>f.test(e)).map(e=>T(e)).filter(n);return e.length===0?null:e.reduce((e,t)=>E(t,e)>0?t:e)}let i=null;return i=p.exec(t),i||(i=m.exec(t),i)||(i=h.exec(t),i)||(i=g.exec(t),i)?{major:Number.parseInt(i[1],10),minor:Number.parseInt(i[2],10),patch:Number.parseInt(i[3],10)}:(i=_.exec(t),i?{major:Number.parseInt(i[1],10),minor:Number.parseInt(i[2],10),patch:0}:(i=v.exec(t),i||(i=y.exec(t),i)||(i=b.exec(t),i)?{major:Number.parseInt(i[1],10),minor:0,patch:0}:null))}function E(e,t){return e.major===t.major?e.minor===t.minor?e.patch-t.patch:e.minor-t.minor:e.major-t.major}function D(n=i.cwd()){let a=r(n,`node_modules/rari/package.json`);if(!e(a))return c(`rari is not installed. Please run "npm install rari" first.`),i.exit(1),``;try{let e=S(t(a,`utf-8`));return e.version!=null&&e.version!==``?`^${e.version}`:(c(`Could not determine rari version from package.json`),i.exit(1),``)}catch(e){return c(`Failed to read rari package.json: ${u(e)}`),i.exit(1),``}}function O(t){return e(r(t,`pnpm-lock.yaml`))?`pnpm install`:e(r(t,`yarn.lock`))?`yarn install`:e(r(t,`bun.lock`))||e(r(t,`bun.lockb`))?`bun install`:`npm install`}function k(a,d){let f=r(a,`package.json`);if(!e(f))return c(`No package.json found. Please run this command from your project root.`),i.exit(1),!1;try{let e=S(t(f,`utf-8`));e.scripts=e.scripts??{};let r=`rari start`;e.scripts.start&&e.scripts.start!==r&&!e.scripts[`start:original`]&&(l(`Existing start script found: "${e.scripts.start}"`),l(`Backing up to start:original and replacing with "${r}"`),e.scripts[`start:original`]=e.scripts.start),e.scripts.start=r,`build`in e.scripts||(e.scripts.build=`rari build`),d.deployScript!=null&&(e.scripts[`deploy:${d.providerName.toLowerCase()}`]=d.deployScript),C(e);let i=e.dependencies?.rari==null||e.dependencies.rari===``;return i&&(o(`Adding rari dependency...`),e.dependencies=e.dependencies??{},e.dependencies.rari=D(a),l(`rari was added to dependencies. Run "${O(a)}" to update your lockfile before deploying; frozen-lockfile installs will fail otherwise.`)),n(f,`${JSON.stringify(e,null,2)}\n`),s(`Updated package.json for ${d.providerName} deployment`),i}catch(e){return c(`Failed to update package.json: ${u(e)}`),i.exit(1),!1}}function A(e,t,n){console.warn(``),s(`${e} deployment setup complete! 🎉`),console.warn(``),o(`Next steps:`);for(let[e,n]of t.entries())console.warn(` ${e+1}. ${n}`);console.warn(``),o(`Your rari app will automatically:`);for(let t of[`Detect ${e} environment`,...n,`Run in production mode`,`Download platform-specific rari binary`])console.warn(` ✅ ${t}`);console.warn(``),s(`Ready for deployment! 🚀`)}function j(a,o,d){let f=r(a,o);try{if(e(f)){let i=t(f,`utf-8`),s=`${o}.backup`,c=r(a,s);e(c)&&(s=`${o}.backup.${Date.now()}`,c=r(a,s)),l(`${o} already exists, backing up to ${s}`),n(c,i,{flag:`wx`})}n(f,d),s(`Created ${o} configuration`)}catch(e){c(`Failed to create or backup ${o}: ${u(e)}`),i.exit(1)}}export{c as a,O as i,A as n,o,j as r,s,k as t};
|
package/dist/vite.mjs
CHANGED
|
@@ -53,7 +53,7 @@ return n===r?e.path.localeCompare(t.path):n-r})}sortLayouts(e){return e.sort((e,
|
|
|
53
53
|
`,t+2);return n===-1?e.length:n+1}function no(e,t){let n=e.indexOf(`*/`,t+2);return n===-1?e.length:n+2}function ro(e,t){let n=t,r=1;for(;n<e.length&&r>0;){let t=e.charCodeAt(n);t===34||t===39||t===96?n=oo(e,n):t===47&&e.charCodeAt(n+1)===47?n=to(e,n):t===47&&e.charCodeAt(n+1)===42?n=no(e,n):(t===123?r+=1:t===125&&--r,n+=1)}return n}function io(e,t,n){let r=t+1;for(;r<e.length;){let t=e.charCodeAt(r);if(t===92)r+=2;else{if(t===n)return r+1;r+=1}}return r}function ao(e,t){let n=t+1;for(;n<e.length;){let t=e.charCodeAt(n);if(t===92)n+=2;else{if(t===96)return n+1;t===36&&e.charCodeAt(n+1)===123?n=ro(e,n+2):n+=1}}return n}function oo(e,t){let n=e.charCodeAt(t);return n===96?ao(e,t):io(e,t,n)}function so(e,t){let n=e.charCodeAt(t);return n===47&&e.charCodeAt(t+1)===47?to(e,t):n===47&&e.charCodeAt(t+1)===42?no(e,t):n===34||n===39||n===96?oo(e,t):null}function co(e,t,n){if(!$a(e.charCodeAt(n))||!e.startsWith(t,n))return null;let r=n+t.length,i=n===0?0:e.charCodeAt(n-1);if(n!==0&&eo(i)||r<e.length&&eo(e.charCodeAt(r)))return null;let a=r;for(;a<e.length&&(e[a]===` `||e[a]===` `||e[a]===`
|
|
54
54
|
`||e[a]===`\r`);)a+=1;return e[a]===`(`?{start:n,openParen:a}:null}function lo(e,t){let n=[],r=0;for(;r<e.length;){let i=so(e,r);if(i!=null){r=i;continue}let a=co(e,t,r);a==null?r+=1:(n.push(a),r=a.openParen+1)}return n}async function uo(e,t,n,r){if(!e.includes(`rari/font/`))return null;let i=Xa(e,Pa),a=Xa(e,Fa);if(Za(e,Pa)||Za(e,Fa))throw Error("rari/font only supports default imports from `rari/font/local` and named imports from `rari/font/google` (optionally with `as`). Namespace and side-effect imports are not supported.");if(i.statements.length===0&&a.statements.length===0)return null;let o=e,s=[],c=[],l=[],u=/* @__PURE__ */ new Set,d=A.dirname(t),f=A.join(n,`node_modules`,`.cache`,`rari-fonts`),p=[...i.statements,...a.statements].map(e=>({start:e.start,end:e.end})),m=(e,t,n)=>{for(let e of p)e.start>=t&&(e.start+=n,e.end+=n)},h=async(e,t)=>{let n=t=>{throw Error(`rari/font: failed to transform \`${e}()\` call: ${t}`)};for(let r of lo(o,e).sort((e,t)=>t.start-e.start)){let e=Ua(o,r.openParen);e===-1&&n(`unbalanced parentheses`);let i=fo(o,r.openParen,e,n),a=await t(i.optionsLiteral);s.push({id:a.cssId,css:a.css}),u.add(a.cssId);for(let e of a.assets)c.push(e);for(let e of a.preloadUrls)l.includes(e)||l.push(e);let d=Qa(a.font);m(r.start,i.spliceEnd,d.length-(i.spliceEnd-r.start)),o=o.slice(0,r.start)+d+o.slice(i.spliceEnd)}};for(let e of i.defaultNames)await h(e,async e=>{if(e==null)throw Error(`rari/font/local: options object required`);let t=Ea(Ba(e),d,n),i=`Rari ${A.basename(t[0].filePaths[0],A.extname(t[0].filePaths[0]))}`;return qa(t.map(e=>Object.assign({},e,{family:i})),r,i)});for(let e of a.names)await h(e.local,async t=>{let n=t==null?{}:Ha(t),i=wa(e.imported);return qa(await Ca(i,n,f),r,i)});let g=[...i.defaultNames,...a.names.map(e=>e.local)];for(let e of g)if(lo(o,e).length>0)throw Error(`rari/font: failed to transform all \`${e}()\` calls; leaving imports in place`);for(let e of p.sort((e,t)=>t.start-e.start))o=o.slice(0,e.start)+o.slice(e.end);let _=[...u].map(e=>`import ${JSON.stringify(e)};`).join(`
|
|
55
55
|
`);return _!==``&&(o=ho(o,_)),o===e?null:{code:o,cssModules:s,assets:c,preloadUrls:l}}function fo(e,t,n,r){let i=e.slice(t+1,n).trim();if(i===``)return{optionsLiteral:null,spliceEnd:n+1};i.startsWith(`{`)||r(`options must be a static object literal`);let a=Da(e,e.indexOf(`{`,t));a??r(`options must be a static object literal`);let o=a.end;for(;o<e.length&&/\s/.test(e[o]??``);)o+=1;return e[o]!==`)`&&r(`options must be a static object literal`),{optionsLiteral:a.value,spliceEnd:o+1}}function po(e,t){let n=t;for(;n<e.length;){let t=e[n];if(t===` `||t===` `||t===`\r`||t===`
|
|
56
|
-
`)n+=1;else if(t===`/`&&e[n+1]===`/`)n=to(e,n);else if(t===`/`&&e[n+1]===`*`)n=no(e,n);else break}return n}function mo(e,t){let n=e[t];if(n!==`'`&&n!==`"`||!e.startsWith(`use client`,t+1)&&!e.startsWith(`use server`,t+1)||e[t+11]!==n)return null;let r=t+12;return e[r]===`;`&&(r+=1),po(e,r)}function ho(e,t){let n=+(e.charCodeAt(0)===65279),r=0;for(;;){n=po(e,n);let t=mo(e,n);if(t==null)break;n=t,r=n}return r===0?`${t}\n${e}`:`${e.slice(0,r)}${t}\n${e.slice(r)}`}function go(e){return e===`.woff`?`font/woff`:e===`.ttf`?`font/ttf`:e===`.otf`?`font/otf`:`font/woff2`}function _o(e){return e===`.woff`?`woff`:e===`.ttf`?`truetype`:e===`.otf`?`opentype`:`woff2`}function vo(e,t){let n=A.resolve(e,t),r;try{r=O.realpathSync(e)}catch{r=A.resolve(e)}let i;try{i=O.realpathSync(n)}catch{return null}let a=A.relative(r,i);if(a.startsWith(`..`)||A.isAbsolute(a))return null;try{if(!O.statSync(i).isFile()||!La.test(i))return null}catch{return null}return i}function yo(e,t){if(typeof t==`function`)return!!t(e,void 0,!1);if(typeof t==`string`)return e===t;let{lastIndex:n}=t,r=t.test(e);return t.lastIndex=n,r}function bo(e,t,n,r){return e==null?!1:typeof e==`function`?!!e(t,n,r):typeof e==`string`||e instanceof RegExp?yo(t,e):e.some(e=>typeof e==`function`?!!e(t,n,r):yo(t,e))}function xo(e,t){e.rolldownOptions??={};let n=e.rolldownOptions.external;e.rolldownOptions.external=(e,r,i)=>wi(e,t)?!0:bo(n,e,r,i)}function So(){let e=process.cwd(),t=`assets`,n=A.join(e,`dist`,`client`),r=/* @__PURE__ */ new Map,i=/* @__PURE__ */ new Map,a=/* @__PURE__ */ new Set;return{name:`rari:font`,enforce:`pre`,configResolved(r){let i=Vt(r);e=i.projectRoot,t=i.assetsDir,n=i.outDir,xo(r.build,a);for(let e of Object.values(r.environments))xo(e.build,a)},resolveId(e){return e.startsWith(Ia)?e:null},load(e){return e.startsWith(Ia)?r.get(e)??null:null},async transform(n,o){let s=await uo(n,o,e,t);if(s==null)return null;for(let e of s.cssModules)r.set(e.id,e.css);for(let e of s.assets)i.set(e.fileName,e.source),a.add(Ci(e.fileName));for(let e of s.preloadUrls)Ir(`<link rel="preload" href="${e}" as="font" type="${Li(_o(A.extname(e).toLowerCase()))}" crossorigin />`);return{code:s.code,map:null}},generateBundle(){for(let[e,t]of i)this.emitFile({type:`asset`,fileName:e,source:t})},configureServer(e){e.middlewares.use((e,t,r)=>{let a=e.url?.split(`?`)[0];if(a==null||a===``){r();return}let o;try{o=decodeURIComponent(a.replace(/^\//,``))}catch{r();return}let s=i.get(o);if(s!=null){t.setHeader(`Content-Type`,go(A.extname(o).toLowerCase())),t.setHeader(`Cache-Control`,`no-cache`),t.end(s);return}let c=vo(n,o);c==null?r():(t.setHeader(`Content-Type`,go(A.extname(c).toLowerCase())),t.setHeader(`Cache-Control`,`no-cache`),O.createReadStream(c).pipe(t))})}}}var Co=class extends Error{status;statusText;bodyPreview;constructor(e,t,n){super(`HTTP ${e}: ${t}`),this.name=`HttpError`,this.status=e,this.statusText=t,this.bodyPreview=n}};async function wo(e){if(!e.ok){let t;try{t=await e.text()}catch{t=`<unable to read response body>`}let n=t.length>200?`${t.slice(0,200)}...`:t;throw new Co(e.status,e.statusText,n)}}var To=class{errorCount=0;maxErrors;resetTimeout;resetTimer=null;lastError=null;constructor(e={}){this.maxErrors=e.maxErrors??5,this.resetTimeout=e.resetTimeout??3e4}recordError(e){this.errorCount++,this.lastError=e,this.resetTimer=ve(this.resetTimer),this.resetTimer=setTimeout(()=>{this.reset()},this.resetTimeout),this.errorCount>=this.maxErrors&&this.handleMaxErrorsReached()}reset(){this.errorCount=0,this.lastError=null,this.resetTimer=ve(this.resetTimer)}getErrorCount(){return this.errorCount}getLastError(){return this.lastError}hasReachedMaxErrors(){return this.errorCount>=this.maxErrors}handleMaxErrorsReached(){console.error(`[rari] HMR: Maximum error count (${this.maxErrors}) reached. Consider restarting the dev server if issues persist.`)}dispose(){this.reset()}};function Eo(e,t,n){let r=new Set(t),i=/* @__PURE__ */ new Set,a=[...t];for(;a.length>0;){let t=a.pop();if(t==null)break;let o=e.get(t);if(o)for(let e of o)r.has(e)||(r.add(e),a.push(e),(n==null||n(e))&&i.add(e))}return i}function Do(e){return C(e)&&e.success===!0&&typeof e.componentId==`string`&&typeof e.filePath==`string`&&typeof e.relativePath==`string`}function Oo(e){return C(e)&&e.success===!1&&typeof e.filePath==`string`&&typeof e.relativePath==`string`&&ne(e.error)}function ko(e){return e===`info`||e===`success`||e===`warning`||e===`error`}var Ao=class{serverComponentBuilder;rustServerUrl;pendingUpdates=/* @__PURE__ */ new Map;pendingFiles=/* @__PURE__ */ new Set;batchTimer=null;DEBOUNCE_DELAY=200;errorHandler;logBatch=[];logBatchTimer=null;LOG_BATCH_DELAY=500;constructor(e,t=N()){this.serverComponentBuilder=e,this.rustServerUrl=`http://localhost:${t}`,this.errorHandler=new To({maxErrors:5,resetTimeout:3e4})}getErrorCount(){return this.errorHandler.getErrorCount()}async handleClientComponentUpdate(e,t){let n=A.relative(j.cwd(),e);try{let r=t.moduleGraph.getModuleById(e);r?(t.moduleGraph.invalidateModule(r),this.errorHandler.reset()):this.queueLog(`warning`,`Client component module not found in graph: ${n}`)}catch(e){let t=T(e,String(e));this.queueLog(`error`,`Failed to update client component: ${n} - ${t}`),this.errorHandler.recordError(x(e))}return Promise.resolve()}async rebuildAndNotifyNow(e,t){this.serverComponentBuilder.invalidateBuildCacheFor(e);let n=await this.serverComponentBuilder.rebuildComponent(e);if(!n.success)throw Error(n.error!=null&&n.error!==``?n.error:`Build failed`);return await this.notifyRustServer(n.componentId,n.bundlePath),t?.hot.send(`rari:server-component-updated`,{id:n.componentId,t:Date.now()}),n}async handleServerComponentUpdate(e,t){this.pendingFiles.add(e);let n=this.pendingUpdates.get(e);return n&&(clearTimeout(n),this.pendingUpdates.delete(e)),this.batchTimer&&clearTimeout(this.batchTimer),this.batchTimer=setTimeout(()=>{(async()=>{let e=[...this.pendingFiles];if(this.pendingFiles.clear(),this.batchTimer=null,e.length===0)return;let n=this.collectDependentPageComponents(e);for(let e of n)this.serverComponentBuilder.invalidateBuildCacheFor(e);let r=[...e,...n],i=await Promise.allSettled(r.map(async e=>{let t=A.relative(j.cwd(),e);try{let n=await this.serverComponentBuilder.rebuildComponent(e);if(!n.success)throw Error(n.error!=null&&n.error!==``?n.error:`Build failed`);return await this.notifyRustServer(n.componentId,n.bundlePath),{success:!0,componentId:n.componentId,filePath:e,relativePath:t}}catch(n){return{success:!1,filePath:e,relativePath:t,error:x(n)}}})),a=[],o=[];if(i.forEach(e=>{e.status===`fulfilled`&&Do(e.value)?a.push(e.value):e.status===`fulfilled`&&Oo(e.value)?o.push(e.value):e.status===`rejected`&&o.push({filePath:``,relativePath:`unknown`,error:Error(String(e.reason))})}),a.length>0){let e=Date.now();a.forEach(({componentId:n})=>{t.hot.send(`rari:server-component-updated`,{id:n,t:e})}),this.errorHandler.reset(),t.ws.send({type:`custom`,event:`rari:hmr-error-cleared`,data:{t:e}})}if(o.length>0){let e=Date.now();o.forEach(({relativePath:n,error:r})=>{let i=r.message,a=(r.stack!=null&&r.stack!==``?r.stack:``).substring(0,500);this.queueLog(`error`,`Failed to rebuild: ${n} - ${i}`),this.errorHandler.recordError(r),t.ws.send({type:`custom`,event:`rari:hmr-error`,data:{msg:i,stack:a,file:n,t:e,count:this.errorHandler.getErrorCount(),max:5}})}),this.errorHandler.hasReachedMaxErrors()&&this.queueLog(`error`,`Maximum error count reached (${this.errorHandler.getErrorCount()}). Consider restarting the dev server if issues persist.`)}})()},this.DEBOUNCE_DELAY),Promise.resolve()}relativeBundlePathInsideProject(e){let t=v(e);if(!A.isAbsolute(e))return t;let n=v(A.relative(this.serverComponentBuilder.getProjectRoot(),e));if(n.startsWith(`..`)||A.isAbsolute(n))throw Error(`Bundle path must be inside the project root: ${e}`);return n}assertSuccessfulHmrResponse(e,t,n){if(!C(e))throw Error(`Invalid server response (status ${n}): expected object, got ${typeof e}. Response body: ${t.substring(0,200)}${t.length>200?`...`:``}`);if(e.success===!0)return;let r=typeof e.message==`string`&&e.message!==``?e.message:typeof e.error==`string`&&e.error!==``?e.error:`Component reload failed`;throw Error(r)}async notifyRustServer(e,t){let n=this.relativeBundlePathInsideProject(t);try{let t=await fetch(`${this.rustServerUrl}/_rari/hmr`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`reload-component`,component_id:e,bundle_path:n})});await wo(t);let r=await t.text(),i;try{i=JSON.parse(r)}catch(e){throw Error(`Failed to parse server response (status ${t.status}): ${T(e,String(e))}. Response body: ${r.substring(0,200)}${r.length>200?`...`:``}`)}this.assertSuccessfulHmrResponse(i,r,t.status)}catch(e){throw console.error(`[rari] HMR: Failed to notify Rust server:`,e),e}}collectDependentPageComponents(e){return[...Eo(this.serverComponentBuilder.getImportGraph(),e,e=>e.includes(`/app/`)||e.includes(`\\app\\`))]}detectComponentType(e){try{return this.serverComponentBuilder.getModuleAnalysis(e).topLevelUseClient?`client`:`server`}catch{return`unknown`}}queueLog(e,t){this.logBatch.push({type:e,message:t,timestamp:Date.now()}),this.logBatchTimer&&clearTimeout(this.logBatchTimer),this.logBatchTimer=setTimeout(()=>{this.flushLogs()},this.LOG_BATCH_DELAY)}flushLogs(){if(this.logBatch.length===0)return;let e=this.logBatch
|
|
56
|
+
`)n+=1;else if(t===`/`&&e[n+1]===`/`)n=to(e,n);else if(t===`/`&&e[n+1]===`*`)n=no(e,n);else break}return n}function mo(e,t){let n=e[t];if(n!==`'`&&n!==`"`||!e.startsWith(`use client`,t+1)&&!e.startsWith(`use server`,t+1)||e[t+11]!==n)return null;let r=t+12;return e[r]===`;`&&(r+=1),po(e,r)}function ho(e,t){let n=+(e.charCodeAt(0)===65279),r=0;for(;;){n=po(e,n);let t=mo(e,n);if(t==null)break;n=t,r=n}return r===0?`${t}\n${e}`:`${e.slice(0,r)}${t}\n${e.slice(r)}`}function go(e){return e===`.woff`?`font/woff`:e===`.ttf`?`font/ttf`:e===`.otf`?`font/otf`:`font/woff2`}function _o(e){return e===`.woff`?`woff`:e===`.ttf`?`truetype`:e===`.otf`?`opentype`:`woff2`}function vo(e,t){let n=A.resolve(e,t),r;try{r=O.realpathSync(e)}catch{r=A.resolve(e)}let i;try{i=O.realpathSync(n)}catch{return null}let a=A.relative(r,i);if(a.startsWith(`..`)||A.isAbsolute(a))return null;try{if(!O.statSync(i).isFile()||!La.test(i))return null}catch{return null}return i}function yo(e,t){if(typeof t==`function`)return!!t(e,void 0,!1);if(typeof t==`string`)return e===t;let{lastIndex:n}=t,r=t.test(e);return t.lastIndex=n,r}function bo(e,t,n,r){return e==null?!1:typeof e==`function`?!!e(t,n,r):typeof e==`string`||e instanceof RegExp?yo(t,e):e.some(e=>typeof e==`function`?!!e(t,n,r):yo(t,e))}function xo(e,t){e.rolldownOptions??={};let n=e.rolldownOptions.external;e.rolldownOptions.external=(e,r,i)=>wi(e,t)?!0:bo(n,e,r,i)}function So(){let e=process.cwd(),t=`assets`,n=A.join(e,`dist`,`client`),r=/* @__PURE__ */ new Map,i=/* @__PURE__ */ new Map,a=/* @__PURE__ */ new Set;return{name:`rari:font`,enforce:`pre`,configResolved(r){let i=Vt(r);e=i.projectRoot,t=i.assetsDir,n=i.outDir,xo(r.build,a);for(let e of Object.values(r.environments))xo(e.build,a)},resolveId(e){return e.startsWith(Ia)?e:null},load(e){return e.startsWith(Ia)?r.get(e)??null:null},async transform(n,o){let s=await uo(n,o,e,t);if(s==null)return null;for(let e of s.cssModules)r.set(e.id,e.css);for(let e of s.assets)i.set(e.fileName,e.source),a.add(Ci(e.fileName));for(let e of s.preloadUrls)Ir(`<link rel="preload" href="${e}" as="font" type="${Li(_o(A.extname(e).toLowerCase()))}" crossorigin />`);return{code:s.code,map:null}},generateBundle(){for(let[e,t]of i)this.emitFile({type:`asset`,fileName:e,source:t})},configureServer(e){e.middlewares.use((e,t,r)=>{let a=e.url?.split(`?`)[0];if(a==null||a===``){r();return}let o;try{o=decodeURIComponent(a.replace(/^\//,``))}catch{r();return}let s=i.get(o);if(s!=null){t.setHeader(`Content-Type`,go(A.extname(o).toLowerCase())),t.setHeader(`Cache-Control`,`no-cache`),t.end(s);return}let c=vo(n,o);c==null?r():(t.setHeader(`Content-Type`,go(A.extname(c).toLowerCase())),t.setHeader(`Cache-Control`,`no-cache`),O.createReadStream(c).pipe(t))})}}}var Co=class extends Error{status;statusText;bodyPreview;constructor(e,t,n){super(`HTTP ${e}: ${t}`),this.name=`HttpError`,this.status=e,this.statusText=t,this.bodyPreview=n}};async function wo(e){if(!e.ok){let t;try{t=await e.text()}catch{t=`<unable to read response body>`}let n=t.length>200?`${t.slice(0,200)}...`:t;throw new Co(e.status,e.statusText,n)}}var To=class{errorCount=0;maxErrors;resetTimeout;resetTimer=null;lastError=null;constructor(e={}){this.maxErrors=e.maxErrors??5,this.resetTimeout=e.resetTimeout??3e4}recordError(e){this.errorCount++,this.lastError=e,this.resetTimer=ve(this.resetTimer),this.resetTimer=setTimeout(()=>{this.reset()},this.resetTimeout),this.errorCount>=this.maxErrors&&this.handleMaxErrorsReached()}reset(){this.errorCount=0,this.lastError=null,this.resetTimer=ve(this.resetTimer)}getErrorCount(){return this.errorCount}getLastError(){return this.lastError}hasReachedMaxErrors(){return this.errorCount>=this.maxErrors}handleMaxErrorsReached(){console.error(`[rari] HMR: Maximum error count (${this.maxErrors}) reached. Consider restarting the dev server if issues persist.`)}dispose(){this.reset()}};function Eo(e,t,n){let r=new Set(t),i=/* @__PURE__ */ new Set,a=[...t];for(;a.length>0;){let t=a.pop();if(t==null)break;let o=e.get(t);if(o)for(let e of o)r.has(e)||(r.add(e),a.push(e),(n==null||n(e))&&i.add(e))}return i}function Do(e){return C(e)&&e.success===!0&&typeof e.componentId==`string`&&typeof e.filePath==`string`&&typeof e.relativePath==`string`}function Oo(e){return C(e)&&e.success===!1&&typeof e.filePath==`string`&&typeof e.relativePath==`string`&&ne(e.error)}function ko(e){return e===`info`||e===`success`||e===`warning`||e===`error`}var Ao=class{serverComponentBuilder;rustServerUrl;pendingUpdates=/* @__PURE__ */ new Map;pendingFiles=/* @__PURE__ */ new Set;batchTimer=null;DEBOUNCE_DELAY=200;errorHandler;logBatch=[];logBatchTimer=null;LOG_BATCH_DELAY=500;constructor(e,t=N()){this.serverComponentBuilder=e,this.rustServerUrl=`http://localhost:${t}`,this.errorHandler=new To({maxErrors:5,resetTimeout:3e4})}getErrorCount(){return this.errorHandler.getErrorCount()}async handleClientComponentUpdate(e,t){let n=A.relative(j.cwd(),e);try{let r=t.moduleGraph.getModuleById(e);r?(t.moduleGraph.invalidateModule(r),this.errorHandler.reset()):this.queueLog(`warning`,`Client component module not found in graph: ${n}`)}catch(e){let t=T(e,String(e));this.queueLog(`error`,`Failed to update client component: ${n} - ${t}`),this.errorHandler.recordError(x(e))}return Promise.resolve()}async rebuildAndNotifyNow(e,t){this.serverComponentBuilder.invalidateBuildCacheFor(e);let n=await this.serverComponentBuilder.rebuildComponent(e);if(!n.success)throw Error(n.error!=null&&n.error!==``?n.error:`Build failed`);return await this.notifyRustServer(n.componentId,n.bundlePath),t?.hot.send(`rari:server-component-updated`,{id:n.componentId,t:Date.now()}),n}async handleServerComponentUpdate(e,t){this.pendingFiles.add(e);let n=this.pendingUpdates.get(e);return n&&(clearTimeout(n),this.pendingUpdates.delete(e)),this.batchTimer&&clearTimeout(this.batchTimer),this.batchTimer=setTimeout(()=>{(async()=>{let e=[...this.pendingFiles];if(this.pendingFiles.clear(),this.batchTimer=null,e.length===0)return;let n=this.collectDependentPageComponents(e);for(let e of n)this.serverComponentBuilder.invalidateBuildCacheFor(e);let r=[...e,...n],i=await Promise.allSettled(r.map(async e=>{let t=A.relative(j.cwd(),e);try{let n=await this.serverComponentBuilder.rebuildComponent(e);if(!n.success)throw Error(n.error!=null&&n.error!==``?n.error:`Build failed`);return await this.notifyRustServer(n.componentId,n.bundlePath),{success:!0,componentId:n.componentId,filePath:e,relativePath:t}}catch(n){return{success:!1,filePath:e,relativePath:t,error:x(n)}}})),a=[],o=[];if(i.forEach(e=>{e.status===`fulfilled`&&Do(e.value)?a.push(e.value):e.status===`fulfilled`&&Oo(e.value)?o.push(e.value):e.status===`rejected`&&o.push({filePath:``,relativePath:`unknown`,error:Error(String(e.reason))})}),a.length>0){let e=Date.now();a.forEach(({componentId:n})=>{t.hot.send(`rari:server-component-updated`,{id:n,t:e})}),this.errorHandler.reset(),t.ws.send({type:`custom`,event:`rari:hmr-error-cleared`,data:{t:e}})}if(o.length>0){let e=Date.now();o.forEach(({relativePath:n,error:r})=>{let i=r.message,a=(r.stack!=null&&r.stack!==``?r.stack:``).substring(0,500);this.queueLog(`error`,`Failed to rebuild: ${n} - ${i}`),this.errorHandler.recordError(r),t.ws.send({type:`custom`,event:`rari:hmr-error`,data:{msg:i,stack:a,file:n,t:e,count:this.errorHandler.getErrorCount(),max:5}})}),this.errorHandler.hasReachedMaxErrors()&&this.queueLog(`error`,`Maximum error count reached (${this.errorHandler.getErrorCount()}). Consider restarting the dev server if issues persist.`)}})()},this.DEBOUNCE_DELAY),Promise.resolve()}relativeBundlePathInsideProject(e){let t=v(e);if(!A.isAbsolute(e))return t;let n=v(A.relative(this.serverComponentBuilder.getProjectRoot(),e));if(n.startsWith(`..`)||A.isAbsolute(n))throw Error(`Bundle path must be inside the project root: ${e}`);return n}assertSuccessfulHmrResponse(e,t,n){if(!C(e))throw Error(`Invalid server response (status ${n}): expected object, got ${typeof e}. Response body: ${t.substring(0,200)}${t.length>200?`...`:``}`);if(e.success===!0)return;let r=typeof e.message==`string`&&e.message!==``?e.message:typeof e.error==`string`&&e.error!==``?e.error:`Component reload failed`;throw Error(r)}async notifyRustServer(e,t){let n=this.relativeBundlePathInsideProject(t);try{let t=await fetch(`${this.rustServerUrl}/_rari/hmr`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`reload-component`,component_id:e,bundle_path:n})});await wo(t);let r=await t.text(),i;try{i=JSON.parse(r)}catch(e){throw Error(`Failed to parse server response (status ${t.status}): ${T(e,String(e))}. Response body: ${r.substring(0,200)}${r.length>200?`...`:``}`)}this.assertSuccessfulHmrResponse(i,r,t.status)}catch(e){throw console.error(`[rari] HMR: Failed to notify Rust server:`,e),e}}collectDependentPageComponents(e){return[...Eo(this.serverComponentBuilder.getImportGraph(),e,e=>e.includes(`/app/`)||e.includes(`\\app\\`))]}detectComponentType(e){try{return this.serverComponentBuilder.getModuleAnalysis(e).topLevelUseClient?`client`:`server`}catch{return`unknown`}}queueLog(e,t){this.logBatch.push({type:e,message:t,timestamp:Date.now()}),this.logBatchTimer&&clearTimeout(this.logBatchTimer),this.logBatchTimer=setTimeout(()=>{this.flushLogs()},this.LOG_BATCH_DELAY)}flushLogs(){if(this.logBatch.length===0)return;let e=Object.groupBy(this.logBatch,e=>e.type);for(let[t,n]of Object.entries(e))if(ko(t)){if(n.length===1){let e=n[0];this.outputLog(t,e.message)}else{let e=n.map(e=>e.message).join(`
|
|
57
57
|
• `);this.outputLog(t,`${n.length} updates:\n • ${e}`)}}this.logBatch=[],this.logBatchTimer=null}outputLog(e,t){let n=`[rari] HMR:`;switch(e){case`success`:console.warn(`\x1B[32m${n}\x1B[0m ${t}`);break;case`warning`:console.warn(`\x1B[33m${n}\x1B[0m ${t}`);break;case`error`:console.error(`\x1B[31m${n}\x1B[0m ${t}`);break;default:console.warn(`${n} ${t}`)}}dispose(){this.logBatchTimer&&(clearTimeout(this.logBatchTimer),this.flushLogs()),this.batchTimer&&=(clearTimeout(this.batchTimer),null);for(let e of this.pendingUpdates.values())clearTimeout(e);this.pendingUpdates.clear(),this.pendingFiles.clear(),this.errorHandler.dispose()}};function K(e,t){return e.readUInt16BE(t)}function q(e,t){return e.readUInt32BE(t)}function jo(e,t){return e.readUInt32LE(t)}function Mo(e){return e.length<24||e.toString(`ascii`,1,4)!==`PNG`?null:{width:q(e,16),height:q(e,20)}}function No(e){if(e.length<10)return null;let t=e.toString(`ascii`,0,6);return t!==`GIF87a`&&t!==`GIF89a`?null:{width:e.readUInt16LE(6),height:e.readUInt16LE(8)}}function Po(e){return e>=192&&e<=195||e>=197&&e<=199||e>=201&&e<=203||e>=205&&e<=207}function Fo(e,t){if(t+7>=e.length)return null;let n=K(e,t),r=e[t+7]??0,i=8+3*r;if(r<1||n<i||t+n>e.length)return null;let a=K(e,t+3),o=K(e,t+5);return o===0||a===0?null:{height:a,width:o}}function Io(e,t){if(t+1>=e.length)return null;let n=K(e,t);return n<2?null:t+n}function Lo(e){if(e.length<4||e[0]!==255||e[1]!==216)return null;let t=2;for(;t+9<=e.length;){if(e[t]!==255){t+=1;continue}if(t+1>=e.length)return null;let n=e[t+1];if(t+=2,Po(n))return Fo(e,t);if(n===217||n===218)return null;let r=Io(e,t);if(r==null)return null;t=r}return null}function Ro(e,t){return(e[t]??0)|(e[t+1]??0)<<8|(e[t+2]??0)<<16}function zo(e){if(e.length<20||e.toString(`ascii`,0,4)!==`RIFF`||e.toString(`ascii`,8,12)!==`WEBP`)return null;let t=e.toString(`ascii`,12,16);if(t===`VP8X`&&e.length>=30)return{width:Ro(e,24)+1,height:Ro(e,27)+1};if(t===`VP8 `&&e.length>=30)return{width:e.readUInt16LE(26)&16383,height:e.readUInt16LE(28)&16383};if(t===`VP8L`&&e.length>=25){if(e[20]!==47)return null;let t=jo(e,21);return{width:(t&16383)+1,height:(t>>14&16383)+1}}return null}function Bo(e,t,n){if(t+8>n)return null;let r=q(e,t),i=e.toString(`ascii`,t+4,t+8),a=8;if(r===1){if(t+16>n)return null;r=Number(e.readBigUInt64BE(t+8)),a=16}else r===0&&(r=n-t);let o=t+r;return r<a||o>n?null:{type:i,headerSize:a,start:t,end:o}}function*Vo(e,t,n){let r=t;for(;r+8<=n;){let t=Bo(e,r,n);if(t==null)return;yield t,r=t.end}}function Ho(e,t){let n=t.start+t.headerSize;return n+4>t.end?null:{version:e[n]??0,flags:(e[n+1]??0)<<16|(e[n+2]??0)<<8|(e[n+3]??0),dataOffset:n+4}}function Uo(e,t){let n=Ho(e,t);return n==null||n.dataOffset+8>t.end?null:{width:q(e,n.dataOffset),height:q(e,n.dataOffset+4)}}function Wo(e,t){let n=Ho(e,t);return n==null?null:n.version===0?n.dataOffset+2>t.end?null:K(e,n.dataOffset):n.dataOffset+4>t.end?null:q(e,n.dataOffset)}function Go(e,t,n,r){return r<1?t+2>n?null:{itemId:K(e,t),nextOffset:t+2}:t+4>n?null:{itemId:q(e,t),nextOffset:t+4}}function Ko(e,t,n,r,i){let a=t,o=[];for(let t=0;t<r;t+=1)if(i){if(a+2>n)return null;let t=K(e,a);a+=2,o.push(t&32767)}else{if(a+1>n)return null;let t=e[a]??0;a+=1,o.push(t&127)}return{propertyIndexes:o,nextOffset:a}}function qo(e,t){let n=Ho(e,t);if(n==null||n.dataOffset+4>t.end)return null;let r=q(e,n.dataOffset),i=n.dataOffset+4,a=/* @__PURE__ */ new Map,o=!!(n.flags&1);for(let s=0;s<r;s+=1){let r=Go(e,i,t.end,n.version);if(r==null||(i=r.nextOffset,i+1>t.end))return null;let s=e[i]??0;i+=1;let c=Ko(e,i,t.end,s,o);if(c==null)return null;i=c.nextOffset,a.set(r.itemId,c.propertyIndexes)}return a}function Jo(e){for(let t of Vo(e,0,e.length))if(t.type===`meta`)return t;return null}function Yo(e,t,n){let r=1,i=null;for(let a of Vo(e,t.start+t.headerSize,t.end)){if(a.type===`ispe`){let t=Uo(e,a);t!=null&&(n.set(r,t),i??=t)}r+=1}return i}function Xo(e,t){let n=/* @__PURE__ */ new Map,r=null,i=null;for(let a of Vo(e,t.start+t.headerSize,t.end))if(a.type===`ipco`){let t=Yo(e,a,n);i??=t}else a.type===`ipma`&&(r=qo(e,a));return{ispeByIndex:n,associations:r,firstIspe:i}}function Zo(e,t,n){if(e==null||t==null)return null;let r=t.get(e);if(r==null)return null;for(let e of r){let t=n.get(e);if(t!=null)return t}return null}function Qo(e){if(e.length<12||e.toString(`ascii`,4,8)!==`ftyp`)return null;let t=Jo(e);if(t==null)return null;let n=t.start+t.headerSize+4;if(n>t.end)return null;let r=null,i=/* @__PURE__ */ new Map,a=null,o=null;for(let s of Vo(e,n,t.end)){if(s.type===`pitm`){r=Wo(e,s);continue}if(s.type!==`iprp`)continue;let t=Xo(e,s);i=t.ispeByIndex,a=t.associations,o??=t.firstIspe}return Zo(r,a,i)??o}function $o(e){return e.length<4?null:e[0]===137&&e.toString(`ascii`,1,4)===`PNG`?Mo(e):e[0]===255&&e[1]===216?Lo(e):e.toString(`ascii`,0,3)===`GIF`?No(e):e.toString(`ascii`,0,4)===`RIFF`?zo(e):Qo(e)}const es=/\.(?:avif|gif|jpe?g|png|webp)$/i,ts=`\0rari-static-image:`,ns=/* @__PURE__ */ new Set([`raw`,`url`,`inline`,`no-inline`]);function rs(e){let t=e.indexOf(`?`);return t===-1?[]:e.slice(t+1).split(`&`).map(e=>e.split(`=`)[0]??``).filter(Boolean)}function is(e){return rs(e).includes(`rari-static-bypass`)}function as(e){return rs(e).some(e=>ns.has(e))}function os(e,t,n){return bi(e,t,n,{encodeBase:!0})}function ss(e,t,n){return`const src = ${JSON.stringify(e)};\nexport default {\n src,\n width: ${t},\n height: ${n},\n};\n`}function cs(e){return es.test(h(e))&&!is(e)&&!as(e)}function ls(e,t=`assets`){let n=O.readFileSync(e),r=I(n),i=os(e,r,t),a=yi(e,r,t),o=$o(n);if(o==null)throw Error(`[rari] Unable to read dimensions for static image import: ${e}. Pass explicit width/height to <Image>, or convert the file to png/jpeg/webp/gif/avif.`);return{code:ss(i,o.width,o.height),publicPath:i,source:n,fileName:a}}const us=/* @__PURE__ */ new Map,ds=/* @__PURE__ */ new Map;function fs(e,t){let n=us.get(e);if(n!=null)return n;let r=/* @__PURE__ */ new Map;if(O.existsSync(t))try{let e=E(O.readFileSync(t,`utf8`));if(e!=null)for(let[t,n]of Object.entries(e))typeof n==`string`&&r.set(t,n)}catch{}return us.set(e,r),r}function ps(e,t,n){for(let[r,i]of e)i===n&&r!==t&&e.delete(r);e.set(t,n)}function ms(e,t){let n=new Set(t.values());for(let[r,i]of e)O.existsSync(i)?n.has(i)&&t.get(r)!==i&&e.delete(r):e.delete(r)}function hs(e){return A.basename(e)===`client`?A.dirname(e):e}function gs(e){return A.join(hs(e),`server`,`static-image-sources.json`)}function _s(e,t){let n=hs(e),r=gs(e);if(t.size===0){try{O.unlinkSync(r)}catch(e){if(S(e)!==`ENOENT`)throw e}us.delete(n);return}O.mkdirSync(A.dirname(r),{recursive:!0});let i=Object.fromEntries(t);O.writeFileSync(r,`${JSON.stringify(i,null,2)}\n`)}function vs(e){let t=hs(e);ds.has(t)||ds.set(t,/* @__PURE__ */ new Map)}function ys(e){let t=hs(e),n=ds.get(t);if(n==null)return;let r=fs(t,gs(e));r.clear();for(let[e,t]of n)O.existsSync(t)&&r.set(e,t);_s(e,r),ds.delete(t)}function bs(e,t){let n=hs(e),r=fs(n,gs(e));for(let[e,n]of t)r.set(e,n);let i=ds.get(n);if(i!=null)for(let[e,n]of t)ps(i,e,n);else ms(r,t),_s(e,r)}function xs(e,t){let n=!1;for(let[r,i]of e)i===t&&(e.delete(r),n=!0);return n}function Ss(e){switch(e){case`.png`:return`image/png`;case`.gif`:return`image/gif`;case`.webp`:return`image/webp`;case`.avif`:return`image/avif`;case`.svg`:return`image/svg+xml`;default:return`image/jpeg`}}function Cs(e){try{return decodeURIComponent(e)}catch{return e}}function ws(e,t,n,r){let i=t?.split(`?`)[0];if(i==null||i===``){r();return}let a=Cs(i),o=e.get(i)??e.get(a);o==null||o===``?r():(n.setHeader(`Content-Type`,Ss(A.extname(o).toLowerCase())),n.setHeader(`Cache-Control`,`no-cache`),O.createReadStream(o).on(`error`,()=>{n.headersSent||(n.statusCode=404),n.end()}).pipe(n))}function Ts(){let e=process.cwd(),t=A.join(e,`dist`,`client`),n=`assets`,r=!1,i=/* @__PURE__ */ new Map;return{name:`rari:static-image`,enforce:`pre`,configResolved(i){let a=Vt(i);e=a.projectRoot,t=a.outDir,n=a.assetsDir,r=i.command===`build`},buildStart(){r&&vs(t)},async resolveId(e,t){if(t==null||t===``||!cs(e))return null;let n=await this.resolve(e,t,{skipSelf:!0});if(n==null||n.id===``)return null;let r=h(n.id);return O.existsSync(r)?ts+r:null},load(e){if(!e.startsWith(ts))return null;let r=e.slice(19),a=ls(r,n);return ps(i,a.publicPath,r),bs(t,i),this.emitFile({type:`asset`,fileName:a.fileName,source:a.source}),a.code},watchChange(e,n){if(n.event!==`delete`)return;let r=h(e);if(!xs(i,r))return;let a=ds.get(hs(t));a!=null&&xs(a,r),bs(t,i)},configureServer(e){e.middlewares.use((e,t,n)=>{ws(i,e.url,t,n)})}}}function Es(e){let t=v(e);return t===`rari/mdx/registry`||t.startsWith(`rari/mdx/registry?`)?!0:t.endsWith(`/mdx/registry.ts`)||t.endsWith(`/mdx/registry.mts`)||t.endsWith(`/mdx/registry.mjs`)||t.endsWith(`/mdx/registry.js`)||t.endsWith(`/mdx/registry`)?t.includes(`/node_modules/rari/`)||t.includes(`/packages/rari/`):!1}function Ds(e,t){let n=e=>{if(O.existsSync(e))for(let r of O.readdirSync(e,{withFileTypes:!0})){let i=A.join(e,r.name);if(r.isDirectory()){if(r.name===`node_modules`||r.name===`.git`||r.name===`dist`)continue;n(i)}else r.isFile()&&r.name.endsWith(`.mdx`)&&t(i)}};for(let t of e)t&&O.existsSync(t)&&n(t)}function Os(e){let t=/* @__PURE__ */ new Set;return Ds(e,e=>{try{let n=O.readFileSync(e,`utf-8`);for(let e of ye(n))t.add(e)}catch{}}),t}function ks(e,t){try{if(t.get(e).hasDefaultExport)return A.basename(e,A.extname(e));let n=t.getSource(e).match(u);if(n?.[1]!=null&&n[1]!==``)return n[1]}catch{}return A.basename(e,A.extname(e))}function As(e){let t=Os(e.contentDirs.map(t=>A.join(e.projectRoot,t)));if(t.size===0)return[];let n=kr(e.componentScanDirs,e.cache),r=[],i=/* @__PURE__ */ new Set;for(let a of n){let n=ks(a,e.cache);if(n==null||n===``||!t.has(n))continue;let o=Ht(a,e.projectRoot),s=o.startsWith(`/`)?o:`/${o}`,c=n.replace(/[^\w$]/g,`_`);i.has(c)&&(c=`${c}_${r.length}`),i.add(c),r.push({name:n,binding:c,importPath:s,moduleId:o,client:!0})}return r.sort((e,t)=>e.name.localeCompare(t.name))}function js(e){let t=Ns(e.projectRoot,e.mdxOptions),n=e.srcDir??A.join(e.projectRoot,`src`),r=Ls(e.projectRoot,t.componentsDir,Sr(n,Object.values(e.alias??{})));return As({projectRoot:e.projectRoot,componentsDir:t.componentsDir,contentDirs:t.contentDirs,cache:e.cache,componentScanDirs:r})}function Ms(e,t={}){let n=t.importStyle??`root-absolute`,r=t.mode??`vite`;return e.length===0?`import { defineMdxComponents } from 'rari/mdx/define'
|
|
58
58
|
|
|
59
59
|
export const getMDXComponents = defineMdxComponents([])
|
|
@@ -77,7 +77,7 @@ ${e.map(e=>` { name: ${JSON.stringify(e.name)}, component: ${e.binding}, id: ${
|
|
|
77
77
|
`;case`r`:return`\r`;case`t`:return` `;case`b`:return`\b`;case`f`:return`\f`;case`v`:return`\v`;case`0`:return`\0`;case`\\`:case`'`:case`"`:case"`":case`/`:return e;default:return null}}function cc(e,t,n){if(n===`x`){let n=e.slice(t+1,t+3);return/^[\da-f]{2}$/i.test(n)?{char:String.fromCharCode(Number.parseInt(n,16)),end:t+2}:null}if(n!==`u`)return null;if(e.charAt(t+1)===`{`){let n=e.indexOf(`}`,t+2);if(n===-1)return null;let r=e.slice(t+2,n);return/^[\da-f]+$/i.test(r)?{char:String.fromCodePoint(Number.parseInt(r,16)),end:n}:null}let r=e.slice(t+1,t+5);return/^[\da-f]{4}$/i.test(r)?{char:String.fromCharCode(Number.parseInt(r,16)),end:t+4}:null}function lc(e,t,n,r){if(oc(n)){let i=t;return n===`\r`&&e.charAt(t+1)===`
|
|
78
78
|
`&&(i=t+1),{out:r,i}}let i=sc(n);if(i!=null)return{out:r+i,i:t};let a=cc(e,t,n);return a==null?n===`x`||n===`u`?null:{out:r+n,i:t}:{out:r+a.char,i:a.end}}function uc(e,t){let n=``;for(let r=0;r<e.length;r++){let i=e.charAt(r);if(t==="`"&&i===`$`&&e.charAt(r+1)===`{`)return null;if(i!==`\\`){n+=i;continue}if(r+=1,r>=e.length)return null;let a=lc(e,r,e.charAt(r),n);if(a==null)return null;n=a.out,r=a.i}return n}function dc(e,t,n){for(let r=t+1;r<e.length;r++){let t=e[r];if(t===`\\`)r+=1;else{if(n==="`"&&t===`$`&&e[r+1]===`{`)return null;if(t===n)return r+1}}return null}function fc(e,t,n,r){return n===`\\`?r+2:((t===`single`&&n===`'`||t===`double`&&n===`"`)&&e.pop(),r+1)}function pc(e,t,n,r){return t===`\\`?r+2:t==="`"?(e.pop(),r+1):t===`$`&&n===`{`?(e.push({kind:`code`,braceDepth:1}),r+2):r+1}function mc(e,t,n,r,i){if(n===`\\`)return r+2;if(n===`[`)return e.push({kind:`regex-class`}),r+1;if(n===`/`){e.pop();let n=r+1;for(;n<i&&/[a-z]/i.test(t.charAt(n));)n+=1;return n}return r+1}function hc(e,t,n){return t===`\\`?n+2:(t===`]`&&e.pop(),n+1)}function gc(e,t,n,r=t.length){let i=e.at(-1);if(i===void 0||i.kind===`code`)return null;let a=t.charAt(n),o=t.charAt(n+1);return i.kind===`line-comment`?(a===`
|
|
79
79
|
`&&e.pop(),n+1):i.kind===`block-comment`?a===`*`&&o===`/`?(e.pop(),n+2):n+1:i.kind===`single`||i.kind===`double`?fc(e,i.kind,a,n):i.kind===`template`?pc(e,a,o,n):i.kind===`regex`?mc(e,t,a,n,r):hc(e,a,n)}function _c(e,t,n){let r=t.charAt(n),i=t.charAt(n+1);return r===`/`&&i===`/`?(e.push({kind:`line-comment`}),n+2):r===`/`&&i===`*`?(e.push({kind:`block-comment`}),n+2):r===`/`&&ac(t,n)?(e.push({kind:`regex`}),n+1):r===`'`?(e.push({kind:`single`}),n+1):r===`"`?(e.push({kind:`double`}),n+1):r==="`"?(e.push({kind:`template`}),n+1):null}function vc(e,t,n){return n===`{`?(e.braceDepth+=1,!0):n===`}`&&(--e.braceDepth,e.braceDepth===0&&t.length>1&&t.pop(),!0)}function yc(e,t,n,r,i){--e.braceDepth;let a=i+1;return e.braceDepth===0?t.length===1?{i:a,done:n.slice(r,a)}:(t.pop(),{i:a,done:null}):{i:a,done:null}}function bc(e,t,n,r){let i=e.at(-1);if(i===void 0)return null;let a=gc(e,t,n);if(a!=null)return{i:a,done:null};if(i.kind!==`code`)return null;let o=_c(e,t,n);if(o!=null)return{i:o,done:null};let s=t.charAt(n);return s===`{`?(i.braceDepth+=1,{i:n+1,done:null}):s===`}`?yc(i,e,t,r,n):{i:n+1,done:null}}function xc(e,t){let n=[{kind:`code`,braceDepth:0}];for(let r=t;r<e.length;){let i=bc(n,e,r,t);if(i==null)return null;if(i.done!=null)return i.done;r=i.i}return null}function Sc(e,t,n){if(n==="`"&&dc(e,t,"`")==null)return{forceRuntime:!0,endIndex:e.length};let r=dc(e,t,n);if(r==null)return{forceRuntime:!0,endIndex:e.length};let i=e.slice(t+1,r-1);if(n==="`"&&i.includes("${"))return{forceRuntime:!0,endIndex:r};let a=uc(i,n);return a==null||a===``?{forceRuntime:!0,endIndex:r}:{matcher:a,forceRuntime:!1,endIndex:r}}function Cc(e,t,n,r){let i=n[r],a=n[r+1];return i===`\\`?{j:r+2}:t.kind===`template`&&i===`$`&&a===`{`?{j:r,forceRuntime:!0}:((t.kind===`single`&&i===`'`||t.kind===`double`&&i===`"`||t.kind===`template`&&i==="`")&&e.pop(),{j:r+1})}function wc(e,t,n){let r=e.at(-1);return r===void 0?{j:n,forceRuntime:!0}:r.kind===`line-comment`?(t[n]===`
|
|
80
|
-
`&&e.pop(),{j:n+1}):r.kind===`block-comment`?t[n]===`*`&&t[n+1]===`/`?(e.pop(),{j:n+2}):{j:n+1}:r.kind===`single`||r.kind===`double`||r.kind===`template`?Cc(e,r,t,n):null}function Tc(e,t,n){let r=t[n],i=t[n+1];return r===`/`&&i===`/`?(e.push({kind:`line-comment`}),n+2):r===`/`&&i===`*`?(e.push({kind:`block-comment`}),n+2):r===`'`?(e.push({kind:`single`}),n+1):r===`"`?(e.push({kind:`double`}),n+1):r==="`"?(e.push({kind:`template`}),n+1):null}function Ec(e,t,n){let r=e[t];return r===`[`?{j:t+1,depth:n+1}:r===`]`?{j:t+1,depth:n-1}:r===`{`?{j:t,depth:n,forceRuntime:!0}:{j:t+1,depth:n}}function Dc(e,t){let n=t+1,r=1,i=n,a=[{kind:`code`,braceDepth:0}];for(;i<e.length&&r>0;){let t=wc(a,e,i);if(t!=null){if(t.forceRuntime)return{forceRuntime:!0,endIndex:e.length};i=t.j;continue}let n=Tc(a,e,i);if(n!=null){i=n;continue}let o=Ec(e,i,r);if(o.forceRuntime)return{forceRuntime:!0,endIndex:o.j};i=o.j,r=o.depth}return r===0?{...Fc(e.slice(n,i-1)),endIndex:i}:{forceRuntime:!0,endIndex:e.length}}function Oc(e,t){let n=t+1;for(;n<e.length&&/\s/.test(e[n]);)n+=1;if(n>=e.length)return null;let r=e[n];return r===`'`||r===`"`||r==="`"?Sc(e,n,r):r===`[`?Dc(e,n):{forceRuntime:!0,endIndex:n+1}}function kc(e,t,n,r){let i=t===0?``:e.charAt(t-1),a=t===0||/[\s;{}]/.test(i);if(n.braceDepth!==0||r.length!==1||!a)return null;if(e.startsWith(`let matcher`,t)||e.startsWith(`var matcher`,t))return{nextI:t,forceRuntime:!0};if(!e.startsWith(`const matcher`,t))return null;let o=t+13;if(o<e.length&&/[\w$]/.test(e.charAt(o)))return{nextI:t+1};let s=o;for(;s<e.length&&/\s/.test(e.charAt(s));)s+=1;if(e.charAt(s)!==`=`)return{nextI:t+1};let c=Oc(e,s);return c==null||c.forceRuntime?{nextI:t,forceRuntime:!0}:{nextI:c.endIndex,binding:{matcher:c.matcher,forceRuntime:!1}}}function Ac(e,t,n,r){let i=e.at(-1);if(i===void 0)return{nextI:n,forceRuntime:!0};let a=gc(e,t,n);if(a!=null)return{nextI:a};if(i.kind!==`code`)return{nextI:n,forceRuntime:!0};let o=_c(e,t,n);if(o!=null)return{nextI:o};if(vc(i,e,t.charAt(n)))return{nextI:n+1};let s=kc(t,n,i,e);return s==null?{nextI:n+1}:s.forceRuntime?{nextI:n,forceRuntime:!0}:(s.binding&&r.push(s.binding),{nextI:s.nextI})}function jc(e){let t=[{kind:`code`,braceDepth:0}],n=[];for(let r=0;r<e.length;){let i=Ac(t,e,r,n);if(i==null||i.forceRuntime)return{forceRuntime:!0};r=i.nextI}return n.length===0?null:n.length>1?{forceRuntime:!0}:n[0]??null}function Mc(e){let t=e.trim();if(t===``||t.includes(`&&`))return null;let n=t.split(/\|\|/),r=[],i;for(let e of n){let t=Vs.exec(e.trim());if(t==null)return null;let n=t[1]||t[6]||``,a=t[3]||t[5]||``;if(n===``||a===``)return null;if(i==null)i=n;else if(i!==n)return null;r.push(a)}return r.length>0?r:null}function Nc(e){let t=[];Bs.lastIndex=0;for(let n of e.matchAll(Bs)){let e=n[1],r=n[2],i=n[4],a=Number.parseInt(n[5],10),o=Number.isFinite(a)?a:void 0;if(e===``||i===``||r!==`redirect`&&r!==`rewrite`)continue;let s=Mc(e);if(s==null)return[];for(let e of s)t.push({source:e,type:r,destination:i,...r===`redirect`?{permanent:$s(o)}:{}})}return t}function Pc(e){let t=Us.exec(e);return t==null?null:xc(e,t.index+t[0].length-1)}function Fc(e){if(e.includes(`{`))return{forceRuntime:!0};let t=[];Zs.lastIndex=0;for(let n of e.matchAll(Zs)){let e=n[1],r=n[2];if(r===``||e!==`'`&&e!==`"`&&e!=="`")continue;let i=uc(r,e);if(i==null)return{forceRuntime:!0};i!==``&&t.push(i)}return e.replace(Zs,``).replace(/[\s,]/g,``)===``&&t.length>0?{matcher:t,forceRuntime:!1}:{forceRuntime:!0}}function Ic(e,t){let n=[{kind:`code`,braceDepth:0}];for(let r=0;r<t;){let i=n.at(-1);if(i===void 0)return null;let a=gc(n,e,r,t);if(a!=null){r=a;continue}if(i.kind!==`code`)return null;let o=_c(n,e,r);o==null?(vc(i,n,e.charAt(r)),r+=1):r=o}let r=n.at(-1);return r?.kind===`code`?r.braceDepth:null}function Lc(e,t){return Ic(e,t)===1}function Rc(e){return e.startsWith(`'`)||e.startsWith(`"`)||e.startsWith("`")}function J(e,t){let n=new RegExp(t.source,t.flags.includes(`g`)?t.flags:`${t.flags}g`);for(let t of e.matchAll(n)){let n=Rc(t[0])?t.index:t.index+t[0].indexOf(`matcher`);if(n>=t.index&&Lc(e,n))return t}return null}function zc(e,t){let n=t;for(;n<e.length;){let t=Vc(e,n);if(t!=null){n=t;continue}let r=e.charAt(n);return r===`,`||r===`}`}return!0}function Bc(e,t){let n=t;for(;n<e.length;){let t=Vc(e,n);if(t==null)break;n=t}return n}function Vc(e,t){let n=e.charAt(t),r=e.charAt(t+1);if(/\s/.test(n))return t+1;if(n===`/`&&r===`/`){let n=t+2;for(;n<e.length&&!tc(e.charAt(n));)n+=1;return n}if(n===`/`&&r===`*`){let n=t+2;for(;n+1<e.length&&(e.charAt(n)!==`*`||e.charAt(n+1)!==`/`);)n+=1;return n+2}return null}function Hc(e,t){if(e.charAt(t)!==`[`)return null;let n=Bc(e,t+1);if(n>=e.length)return{endIndex:e.length,forceRuntime:!0};let r=e.charAt(n);if(r===`'`||r===`"`||r==="`"){let t=dc(e,n,r);if(t==null)return{endIndex:e.length,forceRuntime:!0};let i=e.slice(n+1,t-1);if(r==="`"&&i.includes("${"))return{endIndex:t,forceRuntime:!0};let a=uc(i,r);return n=Bc(e,t),e.charAt(n)===`]`?{endIndex:n+1,forceRuntime:a===`matcher`}:{endIndex:n,forceRuntime:!0}}return{endIndex:t+1,forceRuntime:!0}}function Uc(e,t,n,r){return n===`'`||n===`"`||n==="`"?{entered:!0,expectPropertyKey:r&&t.braceDepth===1?!1:r}:{entered:!1,expectPropertyKey:r}}function Wc(e,t,n,r){return n===`{`?(e.braceDepth+=1,{handled:!0,expectPropertyKey:e.braceDepth===1||r}):n===`}`?(--e.braceDepth,e.braceDepth===0&&t.length>1&&t.pop(),{handled:!0,expectPropertyKey:!1}):n===`,`&&e.braceDepth===1?{handled:!0,expectPropertyKey:!0}:n===`:`&&e.braceDepth===1?{handled:!0,expectPropertyKey:!1}:{handled:!1,expectPropertyKey:r}}function Gc(e,t,n,r,i,a){if(!r||n.braceDepth!==1||/\s/.test(i))return null;if(i===`.`&&a===`.`&&e.charAt(t+2)===`.`)return{unsafe:!0};if(i===`[`){let n=Hc(e,t);return n?.forceRuntime===!0||n==null?{unsafe:!0}:{unsafe:!1,nextI:n.endIndex,clearExpect:!0}}return{unsafe:!1,clearExpect:!0}}function Kc(e,t,n,r){let i=e.at(-1);if(i===void 0)return null;let a=gc(e,t,n);if(a!=null)return{nextI:a,expectPropertyKey:r};if(i.kind!==`code`)return null;let o=t.charAt(n),s=t.charAt(n+1),c=Uc(e,i,o,r);if(c.entered)return{nextI:_c(e,t,n)??n+1,expectPropertyKey:c.expectPropertyKey};let l=_c(e,t,n);if(l!=null)return{nextI:l,expectPropertyKey:r};let u=Wc(i,e,o,r);if(u.handled)return{nextI:n+1,expectPropertyKey:u.expectPropertyKey};let d=Gc(t,n,i,r,o,s);return d==null?{nextI:n+1,expectPropertyKey:r}:d.unsafe?{nextI:n,expectPropertyKey:r,unsafe:!0}:{nextI:d.nextI??n+1,expectPropertyKey:!d.clearExpect&&r}}function qc(e){let t=[{kind:`code`,braceDepth:0}],n=!1;for(let r=0;r<e.length;){let i=Kc(t,e,r,n);if(i==null)return!1;if(i.unsafe)return!0;n=i.expectPropertyKey,r=i.nextI}return!1}function Jc(e,t){let n=Rc(t[0]),r=n?t[2]:t[1],i=n?t[3]:t[2];if(r!==`'`&&r!==`"`&&r!=="`")return null;if(r==="`"&&i.includes("${")||!zc(e,t.index+t[0].length))return{forceRuntime:!0};let a=uc(i,r);return a==null||a===``?{forceRuntime:!0}:{matcher:a,forceRuntime:!1}}function Yc(e){if(!Hs.test(e)||!Us.test(e))return{forceRuntime:!1};let t=Pc(e);if(t==null||qc(t)||J(t,Ws)!=null||J(t,qs)!=null)return{forceRuntime:!0};let n=J(t,Gs)??J(t,Js);if(n!=null)return Jc(t,n)??{forceRuntime:!1};let r=J(t,Ks)??J(t,Ys);return r==null?J(t,Qs)==null?J(t,/matcher\s*:/)!=null||J(t,Xs)!=null?{forceRuntime:!0}:{forceRuntime:!1}:jc(e)??{forceRuntime:!0}:zc(t,r.index+r[0].length)?Fc(Rc(r[0])?r[2]:r[1]):{forceRuntime:!0}}function Xc(e){let{matcher:t,forceRuntime:n}=Yc(e);if(n||Rs.test(e))return{requiresRuntime:!0,rules:[],...t==null?{}:{matcher:t}};let r=zs.test(e),i=Nc(e);return r&&i.length===0?{requiresRuntime:!0,rules:[],...t==null?{}:{matcher:t}}:{requiresRuntime:!1,rules:i,...t==null?{}:{matcher:t}}}function Zc(e){let t=Xc(e.code),n=t.requiresRuntime;return{proxyFile:e.proxyFile,enabled:!0,generated:e.generated??(/* @__PURE__ */ new Date()).toISOString(),rules:t.rules,requiresRuntime:n,...n&&e.bundlePath!=null&&e.bundlePath!==``?{bundlePath:e.bundlePath}:{},...t.matcher==null?{}:{matcher:t.matcher}}}const Qc=/@import\s+(?:url\(\s*)?['"](?![a-zA-Z][a-zA-Z0-9+.-]*:|\/\/|\.\/|\.\.\/|\/)[^'"]+['"][^;]*(?:;|$)/g,$c=/@import\s+(?:url\(\s*((?:\.\/|\.\.\/)[^)\s]+)\s*\)|url\(\s*['"]((?:\.\/|\.\.\/)[^'"]+)['"]\s*\)|['"]((?:\.\/|\.\.\/)[^'"]+)['"])([^;]*)(?:;|$)/g,el=/\.css(?:\?.*)?$/,tl=/\.module\.css(?:\?.*)?$/i;function nl(e){return tl.test(e.replace(/[?#].*$/,``))}function rl(e){return e.replace(Qc,``).trim()}function il(e){if(!/^supports\s*\(/i.test(e))return{supportsCondition:null,rest:e};let t=e.indexOf(`(`),n=0,r=-1;for(let i=t;i<e.length;i++){let t=e[i];if(t===`(`)n++;else if(t===`)`&&(n--,n===0)){r=i;break}}return r===-1?{supportsCondition:null,rest:e}:{supportsCondition:e.slice(t+1,r).trim(),rest:e.slice(r+1).trim()}}function al(e){if(/^layer\s*\(/i.exec(e)){let t=e.indexOf(`(`),n=e.indexOf(`)`,t);return n===-1?{layerName:null,rest:e}:{layerName:e.slice(t+1,n).trim(),rest:e.slice(n+1).trim()}}return/^layer(?:\s|$)/i.test(e)?{layerName:``,rest:e.replace(/^layer\s*/i,``)}:{layerName:null,rest:e}}function ol(e){let t=e.trim().replace(/^\)\s*/,``),n=al(t);t=n.rest;let r=il(t);t=r.rest;let i=t.trim()===``?null:t.trim();return{layerName:n.layerName,supportsCondition:r.supportsCondition,mediaQuery:i}}function sl(e,t){let n=e.trim();return n===``?``:(t.layerName!==null&&(n=t.layerName===``?`@layer {\n${n}\n}`:`@layer ${t.layerName} {\n${n}\n}`),t.supportsCondition!=null&&t.supportsCondition!==``&&(n=`@supports (${t.supportsCondition}) {\n${n}\n}`),t.mediaQuery!=null&&t.mediaQuery!==``&&(n=`@media ${t.mediaQuery} {\n${n}\n}`),n)}function cl(e,t,n=/* @__PURE__ */ new Set){let r=A.resolve(e);return n.has(r)?``:(n.add(r),t.replace($c,(e,t,i,a,o)=>{let s=t??i??a;if(s==null||s===``)return e;let c=A.resolve(A.dirname(r),s);try{return!O.existsSync(c)||!O.statSync(c).isFile()?e:sl(ll(c,O.readFileSync(c,`utf-8`),new Set(n)),ol(o))}catch{return e}}).trim())}function ll(e,t,n=/* @__PURE__ */ new Set){return cl(e,rl(t),n)}function ul(e,t){let n=/* @__PURE__ */ new Set;for(let r of Br(e,t))if(A.isAbsolute(r))n.add(A.resolve(r));else try{n.add(D(A.join(e,`package.json`)).resolve(r))}catch{}return n}function dl(e){return O.existsSync(e)&&O.statSync(e).isFile()?e:null}function fl(e,t,n){let r=[t,A.join(n,`package.json`)];for(let t of r)try{let n=dl(D(t).resolve(e));if(n!=null)return n}catch{try{let n=dl(M(import.meta.resolve(e,De(t).href)));if(n!=null)return n}catch{}}return null}function pl(e,t,n,r){let i=e.replace(/[?#].*$/,``);if(!el.test(i))return null;if(A.isAbsolute(i))return dl(i);if(i.startsWith(`./`)||i.startsWith(`../`))return dl(A.resolve(A.dirname(t),i));let a=ge(i,r,n);if(a!=null&&a!==``){let e=dl(a);if(e!=null)return e}return fl(i,t,n)}function ml(e){let t=e.includes(`?`)?e.slice(e.indexOf(`?`)):``;return/(?:\?|&)raw(?:&|$)/.test(t)||/(?:\?|&)url(?:&|$)/.test(t)}function hl(e,t){if(nl(e)||t.has(A.resolve(e)))return null;try{let t=ll(e,O.readFileSync(e,`utf-8`));return t===``?null:t}catch{return null}}function gl(e){let t=[];for(let n of Nn(e.code)){if(!el.test(n.source)||nl(n.source)||ml(n.source))continue;let r=pl(n.source,e.filePath,e.projectRoot,e.aliases);if(r==null)continue;let i=hl(r,e.layoutCssSkip);i!=null&&t.push(i)}return t}const _l=/^proxy\.(?:tsx?|jsx?|mts|mjs)$/,vl=/^(?:robots|sitemap|feed)\.(?:tsx?|jsx?)$/,yl=/^(?:favicon|icon\d*|apple-icon\d*)\.(?:ico|png|jpe?g|svg)$/i,bl=/^layout\.(?:tsx|ts|jsx|js)$/,xl=[{componentId:`rari/image`,devSourceSegments:[`src`,`image`,`image.tsx`],publishedExport:`rari/image`,exports:[`Image`]}],Sl=A.dirname(M(import.meta.url)),Cl=A.dirname(Sl);function wl(e){return e.startsWith(Cl)}function Tl(){let e=A.join(Cl,`src`,`runtime`,`boundaries`,`error-boundary-wrapper.tsx`);if(O.existsSync(e))return e;try{let e=M(import.meta.resolve(`rari/runtime/ErrorBoundaryWrapper`));if(O.existsSync(e))return e}catch{}return null}function El(e){let t=v(e);if(t===`virtual:error-boundary-wrapper.tsx`||t.includes(`virtual:error-boundary-wrapper`))return!0;let n=Tl();return n!=null&&A.resolve(e)===A.resolve(n)||t.endsWith(`/runtime/boundaries/error-boundary-wrapper.tsx`)}function Dl(e){return C(e)&&C(e.components)}function Ol(e,t){if(El(e))return`virtual:error-boundary-wrapper.tsx`;let n=v(A.relative(t,e));return n.startsWith(`..`)||A.isAbsolute(n)?v(e):n}function kl(e,t){if(El(e))return`error_boundary_wrapper_${I(`virtual:error-boundary-wrapper.tsx`)}`;if(wl(e)){let t=v(A.relative(Cl,e));return`${Ut(t)}_${I(t)}`}return Wt(e,t)}function Al(e,t){return!e.includes(`node_modules`)&&!t.directives.hasUseClient&&!t.directives.hasUseServer}var jl=class{serverComponents=/* @__PURE__ */ new Map;serverActions=/* @__PURE__ */ new Map;options;projectRoot;buildCache=/* @__PURE__ */ new Map;useCacheBuildId=null;fileImporters=/* @__PURE__ */ new Map;moduleAnalysisCache;discoveredExternalClientComponents=/* @__PURE__ */ new Set;clientComponentFiles=/* @__PURE__ */ new Map;layoutCssSkipSet=null;viteBuilder=null;envEmitLock=Promise.resolve();getLayoutCssSkipSet(){return this.layoutCssSkipSet??=ul(this.projectRoot,this.options.alias),this.layoutCssSkipSet}resolveServerCssSources(e,t){return gl({filePath:e,code:t,projectRoot:this.projectRoot,aliases:this.options.alias,layoutCssSkip:this.getLayoutCssSkipSet()})}resolveExtraFileOutPath(e){let t=v(e);return t===this.options.assetsDir||t.startsWith(`${this.options.assetsDir}/`)?A.join(this.options.clientOutDir,t):A.join(this.options.outDir,this.options.rscDir,t)}setViteBuilder(e){this.viteBuilder=e}getProjectRoot(){return this.projectRoot}async getEmitBuilder(){return this.viteBuilder??=await le({root:this.projectRoot,logLevel:`error`}),this.viteBuilder}async withEnvEmitLock(e){let t=this.envEmitLock,n;this.envEmitLock=new Promise(e=>{n=e}),await t;try{return await e()}finally{n()}}async emitRscEntries(e,t){return this.withEnvEmitLock(async()=>{let n=await this.getEmitBuilder(),r=await pe({viteBuilder:n,entries:e,minify:t?.minify??this.options.minify,codeSplitting:t?.codeSplitting});if(r==null)throw Error(`Vite RSC environment build failed`);return r})}recordClientComponent(e,t){this.clientComponentFiles.set(e,t)}getClientComponentFiles(){return[...this.clientComponentFiles.entries()].map(([e,t])=>({filePath:e,code:t}))}getClientComponentPaths(){return[...this.clientComponentFiles.keys()]}getModuleAnalysisCache(){return this.moduleAnalysisCache}clearClientComponentFiles(){this.clientComponentFiles.clear()}getComponentCount(){return this.serverComponents.size+this.serverActions.size}hasComponent(e){return this.serverComponents.has(e)||this.serverActions.has(e)}removeComponent(e){this.serverComponents.delete(e),this.serverActions.delete(e),this.moduleAnalysisCache.invalidate(e)}getImportGraph(){let e=/* @__PURE__ */ new Map;for(let[t,n]of this.fileImporters)e.set(t,new Set(n));return e}async writeComponentCssAsset(e,t){if(t.length===0)return[];let n=A.join(this.options.clientOutDir,`assets`,`server`);await O.promises.mkdir(n,{recursive:!0});let r=`${t.join(`
|
|
80
|
+
`&&e.pop(),{j:n+1}):r.kind===`block-comment`?t[n]===`*`&&t[n+1]===`/`?(e.pop(),{j:n+2}):{j:n+1}:r.kind===`single`||r.kind===`double`||r.kind===`template`?Cc(e,r,t,n):null}function Tc(e,t,n){let r=t[n],i=t[n+1];return r===`/`&&i===`/`?(e.push({kind:`line-comment`}),n+2):r===`/`&&i===`*`?(e.push({kind:`block-comment`}),n+2):r===`'`?(e.push({kind:`single`}),n+1):r===`"`?(e.push({kind:`double`}),n+1):r==="`"?(e.push({kind:`template`}),n+1):null}function Ec(e,t,n){let r=e[t];return r===`[`?{j:t+1,depth:n+1}:r===`]`?{j:t+1,depth:n-1}:r===`{`?{j:t,depth:n,forceRuntime:!0}:{j:t+1,depth:n}}function Dc(e,t){let n=t+1,r=1,i=n,a=[{kind:`code`,braceDepth:0}];for(;i<e.length&&r>0;){let t=wc(a,e,i);if(t!=null){if(t.forceRuntime)return{forceRuntime:!0,endIndex:e.length};i=t.j;continue}let n=Tc(a,e,i);if(n!=null){i=n;continue}let o=Ec(e,i,r);if(o.forceRuntime)return{forceRuntime:!0,endIndex:o.j};i=o.j,r=o.depth}return r===0?{...Fc(e.slice(n,i-1)),endIndex:i}:{forceRuntime:!0,endIndex:e.length}}function Oc(e,t){let n=t+1;for(;n<e.length&&/\s/.test(e[n]);)n+=1;if(n>=e.length)return null;let r=e[n];return r===`'`||r===`"`||r==="`"?Sc(e,n,r):r===`[`?Dc(e,n):{forceRuntime:!0,endIndex:n+1}}function kc(e,t,n,r){let i=t===0?``:e.charAt(t-1),a=t===0||/[\s;{}]/.test(i);if(n.braceDepth!==0||r.length!==1||!a)return null;if(e.startsWith(`let matcher`,t)||e.startsWith(`var matcher`,t))return{nextI:t,forceRuntime:!0};if(!e.startsWith(`const matcher`,t))return null;let o=t+13;if(o<e.length&&/[\w$]/.test(e.charAt(o)))return{nextI:t+1};let s=o;for(;s<e.length&&/\s/.test(e.charAt(s));)s+=1;if(e.charAt(s)!==`=`)return{nextI:t+1};let c=Oc(e,s);return c==null||c.forceRuntime?{nextI:t,forceRuntime:!0}:{nextI:c.endIndex,binding:{matcher:c.matcher,forceRuntime:!1}}}function Ac(e,t,n,r){let i=e.at(-1);if(i===void 0)return{nextI:n,forceRuntime:!0};let a=gc(e,t,n);if(a!=null)return{nextI:a};if(i.kind!==`code`)return{nextI:n,forceRuntime:!0};let o=_c(e,t,n);if(o!=null)return{nextI:o};if(vc(i,e,t.charAt(n)))return{nextI:n+1};let s=kc(t,n,i,e);return s==null?{nextI:n+1}:s.forceRuntime?{nextI:n,forceRuntime:!0}:(s.binding&&r.push(s.binding),{nextI:s.nextI})}function jc(e){let t=[{kind:`code`,braceDepth:0}],n=[];for(let r=0;r<e.length;){let i=Ac(t,e,r,n);if(i==null||i.forceRuntime)return{forceRuntime:!0};r=i.nextI}return n.length===0?null:n.length>1?{forceRuntime:!0}:n[0]??null}function Mc(e){let t=e.trim();if(t===``||t.includes(`&&`))return null;let n=t.split(/\|\|/),r=[],i;for(let e of n){let t=Vs.exec(e.trim());if(t==null)return null;let n=t[1]||t[6]||``,a=t[3]||t[5]||``;if(n===``||a===``)return null;if(i==null)i=n;else if(i!==n)return null;r.push(a)}return r.length>0?r:null}function Nc(e){let t=[];Bs.lastIndex=0;for(let n of e.matchAll(Bs)){let e=n[1],r=n[2],i=n[4],a=Number.parseInt(n[5],10),o=Number.isFinite(a)?a:void 0;if(e===``||i===``||r!==`redirect`&&r!==`rewrite`)continue;let s=Mc(e);if(s==null)return[];for(let e of s)t.push({source:e,type:r,destination:i,...r===`redirect`?{permanent:$s(o)}:{}})}return t}function Pc(e){let t=Us.exec(e);return t==null?null:xc(e,t.index+t[0].length-1)}function Fc(e){if(e.includes(`{`))return{forceRuntime:!0};let t=[];Zs.lastIndex=0;for(let n of e.matchAll(Zs)){let e=n[1],r=n[2];if(r===``||e!==`'`&&e!==`"`&&e!=="`")continue;let i=uc(r,e);if(i==null)return{forceRuntime:!0};i!==``&&t.push(i)}return e.replace(Zs,``).replace(/[\s,]/g,``)===``&&t.length>0?{matcher:t,forceRuntime:!1}:{forceRuntime:!0}}function Ic(e,t){let n=[{kind:`code`,braceDepth:0}];for(let r=0;r<t;){let i=n.at(-1);if(i===void 0)return null;let a=gc(n,e,r,t);if(a!=null){r=a;continue}if(i.kind!==`code`)return null;let o=_c(n,e,r);o==null?(vc(i,n,e.charAt(r)),r+=1):r=o}let r=n.at(-1);return r?.kind===`code`?r.braceDepth:null}function Lc(e,t){return Ic(e,t)===1}function Rc(e){return e.startsWith(`'`)||e.startsWith(`"`)||e.startsWith("`")}function J(e,t){let n=new RegExp(t.source,t.flags.includes(`g`)?t.flags:`${t.flags}g`);for(let t of e.matchAll(n)){let n=Rc(t[0])?t.index:t.index+t[0].indexOf(`matcher`);if(n>=t.index&&Lc(e,n))return t}return null}function zc(e,t){let n=t;for(;n<e.length;){let t=Vc(e,n);if(t!=null){n=t;continue}let r=e.charAt(n);return r===`,`||r===`}`}return!0}function Bc(e,t){let n=t;for(;n<e.length;){let t=Vc(e,n);if(t==null)break;n=t}return n}function Vc(e,t){let n=e.charAt(t),r=e.charAt(t+1);if(/\s/.test(n))return t+1;if(n===`/`&&r===`/`){let n=t+2;for(;n<e.length&&!tc(e.charAt(n));)n+=1;return n}if(n===`/`&&r===`*`){let n=t+2;for(;n+1<e.length&&(e.charAt(n)!==`*`||e.charAt(n+1)!==`/`);)n+=1;return n+2}return null}function Hc(e,t){if(e.charAt(t)!==`[`)return null;let n=Bc(e,t+1);if(n>=e.length)return{endIndex:e.length,forceRuntime:!0};let r=e.charAt(n);if(r===`'`||r===`"`||r==="`"){let t=dc(e,n,r);if(t==null)return{endIndex:e.length,forceRuntime:!0};let i=e.slice(n+1,t-1);if(r==="`"&&i.includes("${"))return{endIndex:t,forceRuntime:!0};let a=uc(i,r);return n=Bc(e,t),e.charAt(n)===`]`?{endIndex:n+1,forceRuntime:a===`matcher`}:{endIndex:n,forceRuntime:!0}}return{endIndex:t+1,forceRuntime:!0}}function Uc(e,t,n,r){return n===`'`||n===`"`||n==="`"?{entered:!0,expectPropertyKey:r&&t.braceDepth===1?!1:r}:{entered:!1,expectPropertyKey:r}}function Wc(e,t,n,r){return n===`{`?(e.braceDepth+=1,{handled:!0,expectPropertyKey:e.braceDepth===1||r}):n===`}`?(--e.braceDepth,e.braceDepth===0&&t.length>1&&t.pop(),{handled:!0,expectPropertyKey:!1}):n===`,`&&e.braceDepth===1?{handled:!0,expectPropertyKey:!0}:n===`:`&&e.braceDepth===1?{handled:!0,expectPropertyKey:!1}:{handled:!1,expectPropertyKey:r}}function Gc(e,t,n,r,i,a){if(!r||n.braceDepth!==1||/\s/.test(i))return null;if(i===`.`&&a===`.`&&e.charAt(t+2)===`.`)return{unsafe:!0};if(i===`[`){let n=Hc(e,t);return n?.forceRuntime===!0||n==null?{unsafe:!0}:{unsafe:!1,nextI:n.endIndex,clearExpect:!0}}return{unsafe:!1,clearExpect:!0}}function Kc(e,t,n,r){let i=e.at(-1);if(i===void 0)return null;let a=gc(e,t,n);if(a!=null)return{nextI:a,expectPropertyKey:r};if(i.kind!==`code`)return null;let o=t.charAt(n),s=t.charAt(n+1),c=Uc(e,i,o,r);if(c.entered)return{nextI:_c(e,t,n)??n+1,expectPropertyKey:c.expectPropertyKey};let l=_c(e,t,n);if(l!=null)return{nextI:l,expectPropertyKey:r};let u=Wc(i,e,o,r);if(u.handled)return{nextI:n+1,expectPropertyKey:u.expectPropertyKey};let d=Gc(t,n,i,r,o,s);return d==null?{nextI:n+1,expectPropertyKey:r}:d.unsafe?{nextI:n,expectPropertyKey:r,unsafe:!0}:{nextI:d.nextI??n+1,expectPropertyKey:!d.clearExpect&&r}}function qc(e){let t=[{kind:`code`,braceDepth:0}],n=!1;for(let r=0;r<e.length;){let i=Kc(t,e,r,n);if(i==null)return!1;if(i.unsafe)return!0;n=i.expectPropertyKey,r=i.nextI}return!1}function Jc(e,t){let n=Rc(t[0]),r=n?t[2]:t[1],i=n?t[3]:t[2];if(r!==`'`&&r!==`"`&&r!=="`")return null;if(r==="`"&&i.includes("${")||!zc(e,t.index+t[0].length))return{forceRuntime:!0};let a=uc(i,r);return a==null||a===``?{forceRuntime:!0}:{matcher:a,forceRuntime:!1}}function Yc(e){if(!Hs.test(e)||!Us.test(e))return{forceRuntime:!1};let t=Pc(e);if(t==null||qc(t)||J(t,Ws)!=null||J(t,qs)!=null)return{forceRuntime:!0};let n=J(t,Gs)??J(t,Js);if(n!=null)return Jc(t,n)??{forceRuntime:!1};let r=J(t,Ks)??J(t,Ys);return r==null?J(t,Qs)==null?J(t,/matcher\s*:/)!=null||J(t,Xs)!=null?{forceRuntime:!0}:{forceRuntime:!1}:jc(e)??{forceRuntime:!0}:zc(t,r.index+r[0].length)?Fc(Rc(r[0])?r[2]:r[1]):{forceRuntime:!0}}function Xc(e){let{matcher:t,forceRuntime:n}=Yc(e);if(n||Rs.test(e))return{requiresRuntime:!0,rules:[],...t==null?{}:{matcher:t}};let r=zs.test(e),i=Nc(e);return r&&i.length===0?{requiresRuntime:!0,rules:[],...t==null?{}:{matcher:t}}:{requiresRuntime:!1,rules:i,...t==null?{}:{matcher:t}}}function Zc(e){let t=Xc(e.code),n=t.requiresRuntime;return{proxyFile:e.proxyFile,enabled:!0,generated:e.generated??(/* @__PURE__ */ new Date()).toISOString(),rules:t.rules,requiresRuntime:n,...n&&e.bundlePath!=null&&e.bundlePath!==``?{bundlePath:e.bundlePath}:{},...t.matcher==null?{}:{matcher:t.matcher}}}const Qc=/@import\s+(?:url\(\s*)?['"](?![a-zA-Z][a-zA-Z0-9+.-]*:|\/\/|\.\/|\.\.\/|\/)[^'"]+['"][^;]*(?:;|$)/g,$c=/@import\s+(?:url\(\s*((?:\.\/|\.\.\/)[^)\s]+)\s*\)|url\(\s*['"]((?:\.\/|\.\.\/)[^'"]+)['"]\s*\)|['"]((?:\.\/|\.\.\/)[^'"]+)['"])([^;]*)(?:;|$)/g,el=/\.css(?:\?.*)?$/,tl=/\.module\.css(?:\?.*)?$/i;function nl(e){return tl.test(e.replace(/[?#].*$/,``))}function rl(e){return e.replace(Qc,``).trim()}function il(e){if(!/^supports\s*\(/i.test(e))return{supportsCondition:null,rest:e};let t=e.indexOf(`(`),n=0,r=-1;for(let i=t;i<e.length;i++){let t=e[i];if(t===`(`)n++;else if(t===`)`&&(n--,n===0)){r=i;break}}return r===-1?{supportsCondition:null,rest:e}:{supportsCondition:e.slice(t+1,r).trim(),rest:e.slice(r+1).trim()}}function al(e){if(/^layer\s*\(/i.exec(e)){let t=e.indexOf(`(`),n=e.indexOf(`)`,t);return n===-1?{layerName:null,rest:e}:{layerName:e.slice(t+1,n).trim(),rest:e.slice(n+1).trim()}}return/^layer(?:\s|$)/i.test(e)?{layerName:``,rest:e.replace(/^layer\s*/i,``)}:{layerName:null,rest:e}}function ol(e){let t=e.trim().replace(/^\)\s*/,``),n=al(t);t=n.rest;let r=il(t);t=r.rest;let i=t.trim()===``?null:t.trim();return{layerName:n.layerName,supportsCondition:r.supportsCondition,mediaQuery:i}}function sl(e,t){let n=e.trim();return n===``?``:(t.layerName!==null&&(n=t.layerName===``?`@layer {\n${n}\n}`:`@layer ${t.layerName} {\n${n}\n}`),t.supportsCondition!=null&&t.supportsCondition!==``&&(n=`@supports (${t.supportsCondition}) {\n${n}\n}`),t.mediaQuery!=null&&t.mediaQuery!==``&&(n=`@media ${t.mediaQuery} {\n${n}\n}`),n)}function cl(e,t,n=/* @__PURE__ */ new Set){let r=A.resolve(e);return n.has(r)?``:(n.add(r),t.replace($c,(e,t,i,a,o)=>{let s=t??i??a;if(s==null||s===``)return e;let c=A.resolve(A.dirname(r),s);try{return!O.existsSync(c)||!O.statSync(c).isFile()?e:sl(ll(c,O.readFileSync(c,`utf-8`),new Set(n)),ol(o))}catch{return e}}).trim())}function ll(e,t,n=/* @__PURE__ */ new Set){return cl(e,rl(t),n)}function ul(e,t){let n=/* @__PURE__ */ new Set;for(let r of Br(e,t))if(A.isAbsolute(r))n.add(A.resolve(r));else try{n.add(D(A.join(e,`package.json`)).resolve(r))}catch{}return n}function dl(e){return O.existsSync(e)&&O.statSync(e).isFile()?e:null}function fl(e,t,n){let r=[t,A.join(n,`package.json`)];for(let t of r)try{let n=dl(D(t).resolve(e));if(n!=null)return n}catch{try{let n=dl(M(import.meta.resolve(e,De(t).href)));if(n!=null)return n}catch{}}return null}function pl(e,t,n,r){let i=e.replace(/[?#].*$/,``);if(!el.test(i))return null;if(A.isAbsolute(i))return dl(i);if(i.startsWith(`./`)||i.startsWith(`../`))return dl(A.resolve(A.dirname(t),i));let a=ge(i,r,n);if(a!=null&&a!==``){let e=dl(a);if(e!=null)return e}return fl(i,t,n)}function ml(e){let t=e.includes(`?`)?e.slice(e.indexOf(`?`)):``;return/(?:\?|&)raw(?:&|$)/.test(t)||/(?:\?|&)url(?:&|$)/.test(t)}function hl(e,t){if(nl(e)||t.has(A.resolve(e)))return null;try{let t=ll(e,O.readFileSync(e,`utf-8`));return t===``?null:t}catch{return null}}function gl(e){let t=[];for(let n of Nn(e.code)){if(!el.test(n.source)||nl(n.source)||ml(n.source))continue;let r=pl(n.source,e.filePath,e.projectRoot,e.aliases);if(r==null)continue;let i=hl(r,e.layoutCssSkip);i!=null&&t.push(i)}return t}const _l=/^proxy\.(?:tsx?|jsx?|mts|mjs)$/,vl=/^(?:robots|sitemap|feed)\.(?:tsx?|jsx?)$/,yl=/^(?:favicon|icon\d*|apple-icon\d*)\.(?:ico|png|jpe?g|svg)$/i,bl=/^layout\.(?:tsx|ts|jsx|js)$/,xl=[{componentId:`rari/image`,devSourceSegments:[`src`,`image`,`image.tsx`],publishedExport:`rari/image`,exports:[`Image`]}],Sl=A.dirname(M(import.meta.url)),Cl=A.dirname(Sl);function wl(e){return e.startsWith(Cl)}function Tl(){let e=A.join(Cl,`src`,`runtime`,`boundaries`,`error-boundary-wrapper.tsx`);if(O.existsSync(e))return e;try{let e=M(import.meta.resolve(`rari/runtime/ErrorBoundaryWrapper`));if(O.existsSync(e))return e}catch{}return null}function El(e){let t=v(e);if(t===`virtual:error-boundary-wrapper.tsx`||t.includes(`virtual:error-boundary-wrapper`))return!0;let n=Tl();return n!=null&&A.resolve(e)===A.resolve(n)||t.endsWith(`/runtime/boundaries/error-boundary-wrapper.tsx`)}function Dl(e){return C(e)&&C(e.components)}function Ol(e,t){if(El(e))return`virtual:error-boundary-wrapper.tsx`;let n=v(A.relative(t,e));return n.startsWith(`..`)||A.isAbsolute(n)?v(e):n}function kl(e,t){if(El(e))return`error_boundary_wrapper_${I(`virtual:error-boundary-wrapper.tsx`)}`;if(wl(e)){let t=v(A.relative(Cl,e));return`${Ut(t)}_${I(t)}`}return Wt(e,t)}function Al(e,t){return!e.includes(`node_modules`)&&!t.directives.hasUseClient&&!t.directives.hasUseServer}var jl=class{serverComponents=/* @__PURE__ */ new Map;serverActions=/* @__PURE__ */ new Map;options;projectRoot;buildCache=/* @__PURE__ */ new Map;useCacheBuildId=null;fileImporters=/* @__PURE__ */ new Map;moduleAnalysisCache;discoveredExternalClientComponents=/* @__PURE__ */ new Set;clientComponentFiles=/* @__PURE__ */ new Map;layoutCssSkipSet=null;viteBuilder=null;envEmitLock=Promise.resolve();getLayoutCssSkipSet(){return this.layoutCssSkipSet??=ul(this.projectRoot,this.options.alias),this.layoutCssSkipSet}resolveServerCssSources(e,t){return gl({filePath:e,code:t,projectRoot:this.projectRoot,aliases:this.options.alias,layoutCssSkip:this.getLayoutCssSkipSet()})}resolveExtraFileOutPath(e){let t=v(e);return t===this.options.assetsDir||t.startsWith(`${this.options.assetsDir}/`)?A.join(this.options.clientOutDir,t):A.join(this.options.outDir,this.options.rscDir,t)}setViteBuilder(e){this.viteBuilder=e}getProjectRoot(){return this.projectRoot}async getEmitBuilder(){return this.viteBuilder??=await le({root:this.projectRoot,logLevel:`error`}),this.viteBuilder}async withEnvEmitLock(e){let t=this.envEmitLock,{promise:n,resolve:r}=Promise.withResolvers();this.envEmitLock=n,await t;try{return await e()}finally{r()}}async emitRscEntries(e,t){return this.withEnvEmitLock(async()=>{let n=await this.getEmitBuilder(),r=await pe({viteBuilder:n,entries:e,minify:t?.minify??this.options.minify,codeSplitting:t?.codeSplitting});if(r==null)throw Error(`Vite RSC environment build failed`);return r})}recordClientComponent(e,t){this.clientComponentFiles.set(e,t)}getClientComponentFiles(){return[...this.clientComponentFiles.entries()].map(([e,t])=>({filePath:e,code:t}))}getClientComponentPaths(){return[...this.clientComponentFiles.keys()]}getModuleAnalysisCache(){return this.moduleAnalysisCache}clearClientComponentFiles(){this.clientComponentFiles.clear()}getComponentCount(){return this.serverComponents.size+this.serverActions.size}hasComponent(e){return this.serverComponents.has(e)||this.serverActions.has(e)}removeComponent(e){this.serverComponents.delete(e),this.serverActions.delete(e),this.moduleAnalysisCache.invalidate(e)}getImportGraph(){let e=/* @__PURE__ */ new Map;for(let[t,n]of this.fileImporters)e.set(t,new Set(n));return e}async writeComponentCssAsset(e,t){if(t.length===0)return[];let n=A.join(this.options.clientOutDir,`assets`,`server`);await O.promises.mkdir(n,{recursive:!0});let r=`${t.join(`
|
|
81
81
|
`)}\n`,i=`${I(e+r,12)}.css`,a=A.join(n,i);return await O.promises.writeFile(a,r,`utf-8`),[`/assets/server/${i}`]}getComponentIdFromRouteManifestPath(e){return this.getComponentId(A.join(this.projectRoot,`src`,`app`,e))}getComponentReferenceId(e){return this.getReadableComponentId(this.getProjectRelativePath(e))}async writeRouteCssEntries(e){let t=A.join(this.options.outDir,this.options.rscDir,`routes.json`);if(!O.existsSync(t))return;let n=await O.promises.readFile(t,`utf-8`),r=JSON.parse(n);if(!C(r))return;let i=r,a=t=>{if(Array.isArray(t))for(let n of t){if(!C(n))continue;let t=n.filePath;if(typeof t!=`string`||t===``)continue;let r=this.getComponentIdFromRouteManifestPath(t);n.componentId=r;let i=e.components[r]?.css??[];i.length?n.css=i:delete n.css}};a(i.routes),a(i.layouts),a(i.loading),a(i.errors),a(i.notFound),a(i.templates);let o=i.apiRoutes;if(Array.isArray(o))for(let e of o){if(!C(e))continue;let t=e.filePath;typeof t==`string`&&t!==``&&(e.componentId=this.getComponentIdFromRouteManifestPath(t))}await O.promises.writeFile(t,JSON.stringify(i),`utf-8`)}constructor(e,t={}){this.projectRoot=A.resolve(e),this.moduleAnalysisCache=t.moduleAnalysisCache??new Ar;let n=t.rscDir!=null&&t.rscDir!==``?t.rscDir:`server`,r=t.outDir!=null&&t.outDir!==``?t.outDir:se,i=ce(this.projectRoot,r),a=t.clientOutDir!=null&&t.clientOutDir!==``?ce(this.projectRoot,t.clientOutDir):A.join(i,`client`);this.options={outDir:i,clientOutDir:a,rscDir:n,manifestPath:t.manifestPath!=null&&t.manifestPath!==``?t.manifestPath:A.join(n,`manifest.json`),serverConfigPath:t.serverConfigPath!=null&&t.serverConfigPath!==``?t.serverConfigPath:A.join(n,`config.json`),minify:t.minify??j.env.NODE_ENV===`production`,alias:t.alias??{},assetsDir:t.assetsDir!=null&&t.assetsDir!==``?_(t.assetsDir):`assets`,define:t.define,csp:t.csp,cacheControl:t.cacheControl,cache:t.cache,action:t.action,jsPoolSize:t.jsPoolSize,origin:t.origin,htmlLimitedBots:t.htmlLimitedBots,experimental:t.experimental,mdx:t.mdx}}getModuleAnalysis(e,t){return this.moduleAnalysisCache.get(e,t)}isServerComponent(e,t){try{return Al(e,this.moduleAnalysisCache.get(e,t))}catch{return!1}}isClientComponent(e,t){if(El(e))return!0;try{return this.moduleAnalysisCache.get(e,t).directives.hasUseClient}catch{return!1}}resolveImportedFilePath(e,t){let n=null;if(t.startsWith(`./`)||t.startsWith(`../`)){let r=A.dirname(e);n=A.resolve(r,t)}else if(n=ge(t,this.options.alias,this.projectRoot),(n==null||n===``)&&t.startsWith(`@/`)){let e=t.slice(2);n=A.join(this.projectRoot,`src`,e)}return n==null||n===``?null:_e(n,[``,`.ts`,`.tsx`,`.js`,`.jsx`])}populateImportGraphFromFiles(e){this.fileImporters.clear();for(let{filePath:t,analysis:n}of e)for(let e of Dr(n.importSources)){let n=this.resolveImportedFilePath(t,e);n!=null&&n!==``&&(this.fileImporters.has(n)||this.fileImporters.set(n,/* @__PURE__ */ new Set),this.fileImporters.get(n).add(t))}}buildImportGraph(e){let t=Ml(this,[e]);this.populateImportGraphFromFiles(t)}isOnlyImportedByClientComponents(e){let t=this.fileImporters.get(e);if(!t||t.size===0)return!1;for(let e of t)if(!this.isClientComponent(e)&&!this.isOnlyImportedByClientComponents(e))return!1;return!0}addServerComponent(e,t,n){let r=t??O.readFileSync(e,`utf-8`),i=n??this.moduleAnalysisCache.get(e,r),a=Er(i.importSources),o=Tr(i);i.directives.hasUseServer?this.serverActions.set(e,{filePath:e,originalCode:r,dependencies:a,hasNodeImports:o}):Al(e,i)&&this.serverComponents.set(e,{filePath:e,originalCode:r,dependencies:a,hasNodeImports:o})}isServerAction(e,t){return t!=null&&t!==``?this.moduleAnalysisCache.get(t,e).directives.hasUseServer:V(e).directives.hasUseServer}extractDependencies(e,t){return Er((t!=null&&t!==``?this.moduleAnalysisCache.get(t,e):V(e)).importSources)}hasNodeImports(e,t){return Tr(t!=null&&t!==``?this.moduleAnalysisCache.get(t,e):V(e))}async getTransformedComponentsForDevelopment(e){let t=[];for(let[n]of this.serverComponents)(!e||e(n))&&t.push({componentId:this.getComponentId(n),filePath:n,isAction:!1});for(let[n]of this.serverActions)(!e||e(n))&&t.push({componentId:this.getComponentId(n),filePath:n,isAction:!0});if(t.length===0)return[];let n=await this.emitRscEntries(t.map(({componentId:e,filePath:t})=>({componentId:e,filePath:t})),{minify:this.options.minify,codeSplitting:!1});for(let e of n.extraFiles){let t=this.resolveExtraFileOutPath(e.fileName);await O.promises.mkdir(A.dirname(t),{recursive:!0}),await O.promises.writeFile(t,e.code)}return t.map(e=>{let t=n.outputs.get(e.componentId);if(t==null)throw Error(`Vite RSC environment build missed entry: ${e.componentId}`);return{id:e.componentId,code:t.code,isAction:e.isAction}})}async emitProxyManifest(e){let t=A.join(e,`proxy.json`),n=[...this.serverComponents.entries()].filter(([e])=>_l.test(A.basename(e)));if(n.length===0){try{await O.promises.unlink(t)}catch(e){S(e)!==`ENOENT`&&console.warn(`Failed to remove proxy manifest file:`,e)}return}let[r,i]=n[0],a=v(this.getProjectRelativePath(r)),o=this.getComponentId(a),s=v(A.join(this.options.rscDir,`${o}.js`)),c=Zc({proxyFile:a,code:i.originalCode,bundlePath:s});c.requiresRuntime||this.serverComponents.delete(r),await O.promises.writeFile(t,JSON.stringify(c),`utf-8`)}async buildServerComponents(){let e=A.join(this.options.outDir,this.options.rscDir);await O.promises.mkdir(e,{recursive:!0}),await this.emitProxyManifest(e);let t={components:{},buildTime:(/* @__PURE__ */ new Date()).toISOString()},n=this.options.experimental?.useCache===!0||this.options.experimental?.useCacheRemote!=null,r=[...this.serverComponents.entries(),...this.serverActions.entries()],i=await this.buildRscEntriesWithVite(r);await this.writeViteBuiltRscEntries(t,i),n&&(this.useCacheBuildId=I(JSON.stringify(t.components),16),t.useCacheBuildId=this.useCacheBuildId);let a=A.join(this.options.outDir,this.options.manifestPath);await O.promises.writeFile(a,JSON.stringify(t),`utf-8`),await this.writeRouteCssEntries(t);let o=this.buildServerConfigObject();return await this.persistServerConfig(o),t}buildServerConfigObject(){let e={};this.options.csp&&(e.csp=this.options.csp),this.options.cacheControl&&(e.cacheControl=this.options.cacheControl),this.options.cache&&(e.cache=this.options.cache),this.options.action&&(e.action=this.options.action),this.options.jsPoolSize!=null&&(e.jsPoolSize=this.options.jsPoolSize);let t=this.options.origin?.trim().replace(/\/+$/,``);return t!=null&&t!==``&&(e.origin=t),this.options.htmlLimitedBots!=null&&(e.htmlLimitedBots=this.options.htmlLimitedBots),this.applyUseCacheServerConfig(e),e}applyUseCacheServerConfig(e){(this.options.experimental?.useCacheRemote!=null||this.useCacheBuildId!=null&&this.useCacheBuildId!==``)&&(e.useCache={...this.options.experimental?.useCacheRemote?{remote:this.options.experimental.useCacheRemote}:{},...this.useCacheBuildId!=null&&this.useCacheBuildId!==``?{buildId:this.useCacheBuildId}:{}},!this.options.experimental?.useCache&&this.options.experimental?.useCacheRemote&&console.warn(`[server-build] experimental.useCacheRemote is set without experimental.useCache; the 'use cache' transform will still run because useCacheRemote is configured.`))}async persistServerConfig(e){let t=A.join(this.options.outDir,this.options.serverConfigPath);if(Object.keys(e).length===0)try{await O.promises.unlink(t)}catch(e){S(e)!==`ENOENT`&&console.warn(`Failed to remove server config file:`,e)}else await O.promises.writeFile(t,JSON.stringify(e),`utf-8`)}async writeViteBuiltRscEntries(e,t){for(let e of t.extraFiles){let t=this.resolveExtraFileOutPath(e.fileName);await O.promises.mkdir(A.dirname(t),{recursive:!0}),await O.promises.writeFile(t,e.code)}for(let[n,r]of t.entries){let t=A.relative(this.projectRoot,n),i=this.getComponentId(n),a=me(this.options.rscDir,i),o=A.join(this.options.outDir,a);await O.promises.mkdir(A.dirname(o),{recursive:!0}),await O.promises.writeFile(o,r.code,`utf-8`);let s=this.serverComponents.get(n)??this.serverActions.get(n),c=this.resolveServerCssSources(n,s?.originalCode??await O.promises.readFile(n,`utf-8`)),l=[...await this.writeComponentCssAsset(i,r.cssAssetSources.length>0?[...r.cssAssetSources]:c)];e.components[i]={id:i,filePath:n,relativePath:t,bundlePath:a,moduleSpecifier:De(A.resolve(this.projectRoot,o)).href,dependencies:[...s?.dependencies??[]],hasNodeImports:s?.hasNodeImports??!1,isServerAction:this.serverActions.has(n),css:l}}}async buildRscEntriesWithVite(e){let t={entries:/* @__PURE__ */ new Map,extraFiles:[]};if(e.length===0)return t;if(this.viteBuilder==null)throw Error(`Vite builder is required for RSC environment emit`);let n=this.viteBuilder;return this.withEnvEmitLock(async()=>{let t=e.map(([e])=>({componentId:this.getComponentId(e),filePath:e})),r=await pe({viteBuilder:n,entries:t,minify:this.options.minify});if(r==null)throw Error(`Vite RSC environment build failed`);let i=/* @__PURE__ */ new Map;for(let[t]of e){let e=this.getComponentId(t),n=r.outputs.get(e);if(n==null)throw Error(`Vite RSC environment build missed entry: ${e}`);i.set(t,n)}return{entries:i,extraFiles:[...r.extraFiles]}})}async buildMdxRegistry(e){let t=js({projectRoot:this.projectRoot,mdxOptions:e,alias:this.options.alias,cache:this.moduleAnalysisCache}),n=A.join(this.options.outDir,this.options.manifestPath),r;if(O.existsSync(n)){let e=await O.promises.readFile(n,`utf-8`),t=E(e);r=t&&Dl(t)?t:{components:{},buildTime:(/* @__PURE__ */ new Date()).toISOString()}}else r={components:{},buildTime:(/* @__PURE__ */ new Date()).toISOString()};r.mdxRegistry=t.map(e=>({name:e.name,id:e.moduleId,client:e.client})),await O.promises.writeFile(n,JSON.stringify(r),`utf-8`)}collectSsrClientFiles(){let e=[...this.getClientComponentFiles()];for(let t of this.discoveredExternalClientComponents)if(!e.some(e=>e.filePath===t))try{let n=O.readFileSync(t,`utf-8`);e.push({filePath:t,code:n})}catch{}try{let t=Tl();if(t!=null&&t!==``){let n=O.readFileSync(t,`utf-8`);e.push({filePath:t,code:n})}}catch{}return e}collectExternalSsrSources(){let e=[];for(let{componentId:t,devSourceSegments:n,publishedExport:r,exports:i}of xl){let a=this.resolveExternalClientSourcePath(n,r);if(a!=null&&a!==``)try{let n=O.readFileSync(a,`utf-8`);e.push({componentId:t,filePath:a,code:n,exports:[...i],bundleName:`external_${I(t)}`})}catch{}}return e}async buildSSRClientComponents(){let e=A.join(this.options.outDir,`ssr`);await O.promises.mkdir(e,{recursive:!0});let t=this.collectSsrClientFiles(),n=this.collectExternalSsrSources(),r={},i=await this.buildSsrEntriesWithVite(t,n);for(let t of i.extraFiles){let n=v(t.fileName),r=n===this.options.assetsDir||n.startsWith(`${this.options.assetsDir}/`)?A.join(this.options.clientOutDir,n):A.join(e,n);await O.promises.mkdir(A.dirname(r),{recursive:!0}),await O.promises.writeFile(r,t.code)}for(let[e,a]of i.entries){let i=n.find(t=>t.filePath===e),o=i?.componentId??Ol(e,this.projectRoot),s=`ssr/${i?.bundleName??kl(e,this.projectRoot)}.js`,c=A.join(this.options.outDir,s);await O.promises.mkdir(A.dirname(c),{recursive:!0}),await O.promises.writeFile(c,a.code,`utf-8`);let l=i?.code??t.find(t=>t.filePath===e)?.code??O.readFileSync(e,`utf-8`);r[o]={id:o,filePath:e,bundlePath:s,exports:i?.exports??this.extractExportNames(l)}}await this.writeClientReferenceManifest(e,r)}async buildSsrEntriesWithVite(e,t=[]){let n={entries:/* @__PURE__ */ new Map,extraFiles:[]},r=[...e.map(({filePath:e})=>({entryName:kl(e,this.projectRoot),filePath:e})),...t.map(e=>({entryName:e.bundleName,filePath:e.filePath}))];if(r.length===0)return n;if(this.viteBuilder==null)throw Error(`Vite builder is required for SSR environment emit`);let i=this.viteBuilder;return this.withEnvEmitLock(async()=>{let e=await he({viteBuilder:i,entries:r,minify:this.options.minify});if(e==null)throw Error(`Vite SSR environment build failed`);let t=/* @__PURE__ */ new Map;for(let n of r){let r=e.outputs.get(n.entryName);if(r==null)throw Error(`Vite SSR environment build missed entry: ${n.entryName}`);t.set(n.filePath,{code:r.code})}return{entries:t,extraFiles:[...e.extraFiles]}})}async writeClientReferenceManifest(e,t){let n=A.join(e,`manifest.json`);await O.promises.writeFile(n,JSON.stringify(t),`utf-8`);let r={};for(let[e,n]of Object.entries(t))for(let t of n.exports){let i=`${e}#${t}`;r[i]={id:i,chunks:`/${n.bundlePath}`,name:t}}let i=A.join(this.options.outDir,`server`);await O.promises.mkdir(i,{recursive:!0});let a=A.join(i,`client-reference-manifest.json`);await O.promises.writeFile(a,JSON.stringify(r),`utf-8`)}resolveExternalClientSourcePath(e,t){let n=A.join(Cl,...e);if(O.existsSync(n))return n;try{let e=M(import.meta.resolve(t));if(O.existsSync(e))return e}catch{}return null}extractExportNames(e){return zn(e)}getProjectRelativePath(e){return Ht(e,this.projectRoot)}getReadableComponentId(e){return Ut(e)}getComponentId(e){return Wt(e,this.projectRoot)}async rebuildComponent(e){bl.test(A.basename(e))&&(this.layoutCssSkipSet=null);let t=this.getComponentId(e),n=await O.promises.readFile(e,`utf-8`),r=this.extractDependencies(n,e),i={filePath:e,originalCode:n,dependencies:r,hasNodeImports:this.hasNodeImports(n,e)};this.isServerAction(n,e)?(this.serverActions.set(e,i),this.serverComponents.delete(e)):(this.serverComponents.set(e,i),this.serverActions.delete(e));let a=A.join(this.options.rscDir,`${t}.js`),o=A.join(this.options.outDir,a),s=this.buildCache.get(e),c=(await O.promises.stat(e)).mtimeMs;if(s&&s.timestamp>=c&&JSON.stringify(s.sourceDependencies)===JSON.stringify(r)){let n=this.serverActions.get(e)??this.serverComponents.get(e);return n&&s.bundledDependencies.length>0&&(n.dependencies=s.bundledDependencies),await O.promises.writeFile(o,s.code,`utf-8`),await this.updateManifestForComponent(t,e,a,s.css),{componentId:t,bundlePath:this.bundlePathForRuntime(o),success:!0}}let l=A.dirname(o);await O.promises.mkdir(l,{recursive:!0});let u=await this.emitRscEntries([{componentId:t,filePath:e}],{minify:this.options.minify,codeSplitting:!1}),d=u.outputs.get(t);if(d==null)throw Error(`Vite RSC environment build missed entry: ${t}`);await O.promises.writeFile(o,d.code,`utf-8`);let f=this.resolveServerCssSources(e,n),p=[...await this.writeComponentCssAsset(t,d.cssAssetSources.length>0?[...d.cssAssetSources]:f)];for(let e of u.extraFiles){let t=this.resolveExtraFileOutPath(e.fileName);await O.promises.mkdir(A.dirname(t),{recursive:!0}),await O.promises.writeFile(t,e.code)}let m=this.serverActions.get(e)??this.serverComponents.get(e);return this.buildCache.set(e,{code:d.code,css:p,timestamp:Date.now(),sourceDependencies:r,bundledDependencies:m?.dependencies??r}),await this.updateManifestForComponent(t,e,a,p),{componentId:t,bundlePath:this.bundlePathForRuntime(o),success:!0}}bundlePathForRuntime(e){return v(A.relative(this.projectRoot,e))}manifestCache=null;async updateManifestForComponent(e,t,n,r=[]){let i=A.join(this.options.outDir,this.options.manifestPath),a;if(this.manifestCache)a=this.manifestCache;else if(O.existsSync(i)){let e=await O.promises.readFile(i,`utf-8`),t=E(e);t&&Dl(t)?(a=t,this.manifestCache=a):(a={components:{},buildTime:(/* @__PURE__ */ new Date()).toISOString()},this.manifestCache=a)}else a={components:{},buildTime:(/* @__PURE__ */ new Date()).toISOString()},this.manifestCache=a;let o=this.serverComponents.get(t)??this.serverActions.get(t),s=A.join(this.options.outDir,n),c=De(A.resolve(this.projectRoot,s)).href;if(o)a.components[e]={id:e,filePath:t,relativePath:A.relative(this.projectRoot,t),bundlePath:n,moduleSpecifier:c,dependencies:[...o.dependencies],hasNodeImports:o.hasNodeImports,isServerAction:this.serverActions.has(t),css:r};else{let i=await O.promises.readFile(t,`utf-8`);a.components[e]={id:e,filePath:t,relativePath:A.relative(this.projectRoot,t),bundlePath:n,moduleSpecifier:c,dependencies:this.extractDependencies(i,t),hasNodeImports:this.hasNodeImports(i,t),isServerAction:this.isServerAction(i,t),css:r}}a.buildTime=(/* @__PURE__ */ new Date()).toISOString(),await O.promises.writeFile(i,JSON.stringify(a),`utf-8`),await this.writeRouteCssEntries(a),this.manifestCache=a}clearCache(){this.buildCache.clear(),this.manifestCache=null}invalidateBuildCacheFor(e){this.buildCache.delete(e)}};function Ml(e,t){let n=[];for(let r of xr(t))try{let t=W(r),i=O.readFileSync(r,`utf-8`),a=e.getModuleAnalysis(r,i);n.push({filePath:r,cacheKey:t,code:i,analysis:a})}catch(e){console.warn(`[server-build] Error reading ${r}:`,T(e,String(e)))}return n}function Nl(e,t){return(t??V(e)).hasComponentExport||i.test(e)||s.test(e)||f.test(e)}function Pl(e,t,n,r){let i=A.basename(e);if(vl.test(i)||yl.test(i)||i.endsWith(`.d.ts`))return!1;let a=r??n.getModuleAnalysis(e,t);return a.directives.hasUseClient?!1:a.directives.hasUseServer?!0:!n.isOnlyImportedByClientComponents(e)&&Al(e,a)&&Nl(t,a)}function Fl(e,t,n=[]){let r=Ml(t,Sr(e,n));t.clearClientComponentFiles(),t.populateImportGraphFromFiles(r);let i=[],a=[];for(let{filePath:e,code:n,analysis:o}of r)o.directives.hasUseClient&&(a.push(e),t.recordClientComponent(e,n)),Pl(e,n,t,o)&&(t.addServerComponent(e,n,o),i.push(e));return{serverComponentPaths:i,clientComponentPaths:a}}function Il(e={}){let t=null,n,r,i,a={},o=!1;async function s(){if(t){try{await t.buildMdxRegistry(e.mdx)}catch(e){console.warn(`[rari] Failed to build MDX component registry:`,e)}try{let{generateRobotsFile:e}=await import(`./robots-BdSA0wq4.mjs`);await e({appDir:A.join(n,`src`,`app`),outDir:r,aliases:a})}catch(e){console.warn(`[rari] Failed to generate robots.txt:`,e)}try{let{generateSitemapFiles:e}=await import(`./sitemap-ByPlT2YN.mjs`);await e({appDir:A.join(n,`src`,`app`),outDir:r,aliases:a})}catch(e){console.warn(`[rari] Failed to generate sitemap:`,e)}try{let{generateFeedFile:e}=await import(`./feed-DUwifKF8.mjs`);await e({appDir:A.join(n,`src`,`app`),outDir:r,aliases:a})}catch(e){console.warn(`[rari] Failed to generate feed:`,e)}try{let e=A.join(i,`server`,`routes.json`);if(O.existsSync(e)){let t=rt(O.readFileSync(e,`utf-8`));t.length>0&&await tt({appDir:A.join(n,`src`,`app`),outDir:r,icons:t})}}catch(e){console.warn(`[rari] Failed to copy app icons:`,e)}try{let t=Ns(n,e.mdx),a=[`public/content`,v(A.relative(n,A.join(i,`content`))),v(A.relative(n,A.join(r,`content`)))].filter(e=>e!==``&&!e.startsWith(`..`)&&!A.isAbsolute(e)),o=Ps(n,t.contentDirs).filter(e=>{let t=v(A.relative(n,e));return!a.some(e=>t===e||t.startsWith(`${e}/`))});o.length>0&&Is(o,A.join(i,`content`))}catch(e){console.warn(`[rari] Failed to copy MDX content:`,e)}ys(r)}}return{name:`rari-server-build`,sharedDuringBuild:!0,configResolved(s){n=s.root,r=oe(s.root,s.build.outDir),i=ae(r),o=!1;let c=Bt(s);a=c;let l=typeof s.build.assetsDir==`string`&&s.build.assetsDir!==``?_(s.build.assetsDir):`assets`;t=new jl(n,{...e,alias:c,assetsDir:l,outDir:i,clientOutDir:r,minify:e.minify??s.mode===`production`})},buildStart(){if(!t)return;let e=A.join(n,`src`);O.existsSync(e)&&Fl(e,t,Object.values(a))},async buildApp(e){if(!t||o)return;let n=e.environments.client;n.isBuilt||await e.build(n);let r=e.environments.rsc,i=e.environments.ssr;await r.init(),await i.init(),t.setViteBuilder(e),await t.buildServerComponents(),await t.buildSSRClientComponents(),o=!0,await s()}}}function Ll(e,t,n){if(n.length===0)return e;let r=Nn(e).find(e=>e.source===t&&!e.typeOnly&&!e.sideEffectOnly),i=/* @__PURE__ */ new Map;if(r!=null)for(let e of r.named)e.typeOnly||i.set(e.imported,e.local);for(let e of n)i.has(e)||i.set(e,e);let a=[...i.entries()].map(([e,t])=>e===t?e:`${e} as ${t}`);if(r?.namespaceBinding!=null||r?.named.some(e=>e.typeOnly)){let i=n.filter(e=>!r.named.some(t=>!t.typeOnly&&t.imported===e));return i.length===0?e:`${`import { ${[...new Set(i)].join(`, `)} } from ${JSON.stringify(t)};`}\n${e}`}let o=`import ${r?.defaultBinding==null?``:`${r.defaultBinding}, `}{ ${a.join(`, `)} } from ${JSON.stringify(t)};`;return r==null?`${o}\n\n${e}`:e.slice(0,r.start)+o+e.slice(r.end)}function Rl(e,t){return`const ${e} = createClientModuleProxy(${JSON.stringify(t)});`}function zl(e,t,n){return`const ${e} = registerClientReference(
|
|
82
82
|
function() {
|
|
83
83
|
throw new Error("Attempted to call ${e} from the server but it's on the client. It can only be rendered as a Component or passed to props of a Client Component.");
|
|
@@ -85,7 +85,7 @@ ${e.map(e=>` { name: ${JSON.stringify(e.name)}, component: ${e.binding}, id: ${
|
|
|
85
85
|
${JSON.stringify(t)},
|
|
86
86
|
${JSON.stringify(n)}
|
|
87
87
|
);`}function Bl(e,t){let n=[],r=/* @__PURE__ */ new Set;e.namespaceBinding!=null&&(r.add(`createClientModuleProxy`),n.push(Rl(e.namespaceBinding,t))),e.defaultBinding!=null&&(r.add(`registerClientReference`),n.push(zl(e.defaultBinding,t,`default`)));for(let i of e.named)i.typeOnly||(r.add(`registerClientReference`),n.push(zl(i.local,t,i.imported)));return n.length===0?{code:``,helpers:[]}:{code:n.join(`
|
|
88
|
-
`),helpers:[...r]}}const Vl=/(?:^|[\n\r;])\s*import\s*\{[^}]*\bregisterServerReference\b[^}]*\}\s*from\s*["'][^"'\n]+["']/;function Hl(e){return Vl.test(e)}const Ul=/* @__PURE__ */ new Set(/* @__PURE__ */ `undefined.NaN.Infinity.arguments.Object.Array.String.Number.Boolean.Symbol.BigInt.Math.Date.JSON.Promise.Error.TypeError.RangeError.Map.Set.WeakMap.WeakSet.RegExp.Proxy.Reflect.Function.console.fetch.process.Buffer.globalThis.global.window.document.navigator.location.crypto.TextEncoder.TextDecoder.URL.URLSearchParams.FormData.Headers.Request.Response.AbortController.AbortSignal.setTimeout.clearTimeout.setInterval.clearInterval.queueMicrotask.structuredClone.atob.btoa.React.jsx.jsxs.Fragment`.split(`.`)),Wl=/* @__PURE__ */ new Set(/* @__PURE__ */ `await.return.throw.if.else.for.while.do.switch.case.break.continue.new.typeof.instanceof.void.delete.yield.class.extends.super.this.try.catch.finally.with.debugger.default.of.in.from.as.import.export.async.function.const.let.var.true.false.null.static.get.set.typeof`.split(`.`));function Gl(e){return e>=97&&e<=122||e>=65&&e<=90||e===95||e===36}function Kl(e){return Gl(e)||e>=48&&e<=57}function Y(e,t){let n=e.length;for(;t<n;){let r=ql(e,t,n);if(r==null)break;t=r}return t}function ql(e,t,n){let r=e.charCodeAt(t);if(r===32||r===9||r===10||r===13||r===65279)return t+1;if(r===47&&e.charCodeAt(t+1)===47){let r=t+2;for(;r<n&&e.charCodeAt(r)!==10&&e.charCodeAt(r)!==13;)r++;return r}if(r===47&&e.charCodeAt(t+1)===42){let r=t+2;for(;r<n-1&&(e.charCodeAt(r)!==42||e.charCodeAt(r+1)!==47);)r++;return r+2}return null}function Jl(e,t,n){t++;let r=e.length;for(;t<r;){let r=e.charCodeAt(t);if(r===92)t+=2;else{if(r===n)return t+1;t++}}return t}function Yl(e,t,n,r){let i=t,a=0,o=e.length;for(;i<o;){let t=U(e,i,o);if(t!==-1){i=t;continue}let s=e.charCodeAt(i);if(s===n)a++;else if(s===r&&(a--,a===0))return i+1;i++}return i}function Xl(e,t,n){for(let r=0;r<n.length;r++)if(e.charCodeAt(t+r)!==n.charCodeAt(r))return!1;return!0}function Zl(e,t,n){let r=Y(e,t+1);if(r>=n)return!1;let i=e.charCodeAt(r);if(i!==39&&i!==34)return!1;let a=r+1,o=Jl(e,r,i);return o-1-a!=10||!Xl(e,a,`use server`)?!1:Ql(e,o,n)}function Ql(e,t,n){let r=t;for(;r<n;){let t=e.charCodeAt(r);if(t===32||t===9)r++;else return t===59||t===10||t===13||t===47&&e.charCodeAt(r+1)===47||t===47&&e.charCodeAt(r+1)===42}return!0}function $l(e,t,n){let r=Y(e,t+1),i=e.charCodeAt(r);return i!==39&&i!==34?e.slice(t+1,n):(r=Y(e,Jl(e,r,i)),e.charCodeAt(r)===59&&r++,r=Y(e,r),e.slice(r,n))}function X(e,t){if(!Gl(e.charCodeAt(t)))return null;let n=t+1;for(;n<e.length&&Kl(e.charCodeAt(n));)n++;return{name:e.slice(t,n),end:n}}function eu(e,t,n){if(!Xl(e,t,n))return!1;let r=t>0?e.charCodeAt(t-1):-1,i=t+n.length<e.length?e.charCodeAt(t+n.length):-1;return!(r!==-1&&Kl(r)||i!==-1&&Kl(i))}function tu(e,t,n){return e===0&&t===0&&n===0}function nu(e,t){return e===40?(t.paren++,null):e===41?(t.paren=Math.max(0,t.paren-1),null):e===123?(t.brace++,null):e===125?tu(t.paren,t.brace,t.bracket)?-1:(t.brace=Math.max(0,t.brace-1),null):e===91?(t.bracket++,null):e===93?tu(t.paren,t.brace,t.bracket)?-1:(t.bracket=Math.max(0,t.bracket-1),null):e===44&&tu(t.paren,t.brace,t.bracket)?-1:null}function ru(e,t,n){let r=Y(e,t+1),i={paren:0,brace:0,bracket:0};for(;r<n;){let t=U(e,r,n);if(t!==-1)r=t;else{if(nu(e.charCodeAt(r),i)===-1)return r;r++}}return r}function iu(e,t,n,r,i){let a=X(e,t);if(a==null)return t+1;let o=Y(e,a.end);if(n===123&&e.charCodeAt(o)===58)return o+1;i.add(a.name);let s=a.end,c=Y(e,s);return e.charCodeAt(c)===61&&(s=ru(e,c,r-1)),s}function au(e,t,n){let r=e.charCodeAt(t),i=Yl(e,t,r,r===123?125:93),a=t+1;for(;a<i-1&&(a=Y(e,a),!(a>=i-1));){let t=e.charCodeAt(a);a=t===123||t===91?au(e,a,n):t===46&&e.charCodeAt(a+1)===46&&e.charCodeAt(a+2)===46?ou(e,a,n):iu(e,a,r,i,n)}return i}function ou(e,t,n){t+=3,t=Y(e,t);let r=X(e,t);return r?(n.add(r.name),r.end):t}function su(e){let t=/* @__PURE__ */ new Set,n=0,r=e.length;for(;n<r&&(n=Y(e,n),!(n>=r));){let r=e.charCodeAt(n);if(r===123||r===91){n=au(e,n,t);continue}if(r===46&&e.charCodeAt(n+1)===46&&e.charCodeAt(n+2)===46){n=ou(e,n,t);continue}let i=X(e,n);i?(t.add(i.name),n=i.end):n++}return t}function cu(e){let t=/* @__PURE__ */ new Set;for(let n of e.matchAll(/\b(?:const|let|var|function|class|async\s+function)\s+([A-Za-z_$][\w$]*)/g))t.add(n[1]);return t}function lu(e,t){for(let n of e.split(`,`)){let e=n.trim();if(!e||e.startsWith(`type `))continue;let r=(e.split(/\s+as\s+/).at(-1)??``).trim();r&&t.add(r)}}function uu(e){let t=/* @__PURE__ */ new Set;for(let n of e.matchAll(/\b(?:import|export)\s+(?:type\s+)?(?:\{([^}]+)\}|(\*\s+as\s+[A-Za-z_$][\w$]*)|([A-Za-z_$][\w$]*))/g)){if(n[1]&&lu(n[1],t),n[2]){let e=/as\s+([A-Za-z_$][\w$]*)/.exec(n[2]);e&&t.add(e[1])}n[3]&&n[3]!==`type`&&n[3]!==`async`&&n[3]!==`function`&&n[3]!==`class`&&t.add(n[3])}for(let n of e.matchAll(/(?:^|\n)\s*(?:export\s+)?(?:async\s+)?(?:function|class|const|let|var)\s+([A-Za-z_$][\w$]*)/g))t.add(n[1]);return t}function du(e,t){return t<=0||e.charCodeAt(t-1)!==46?!1:t<2||e.charCodeAt(t-2)!==46}function fu(e,t,n,r,i){let a=t;for(;a<n;){let t=U(e,a,n);if(t!==-1){a=t;continue}if(!Gl(e.charCodeAt(a))){a++;continue}let o=X(e,a);o==null?a++:(du(e,a)||bu(e,a,o.end)||r.has(o.name)||i.add(o.name),a=o.end)}}function pu(e,t,n){let r=0,i=e.length;for(;r<i;){let a=U(e,r,i);if(a!==-1)r=a;else if(e.charCodeAt(r)===61){let a=e.charCodeAt(r+1);if(a===62||a===61){r++;continue}let o=ru(e,r,i);fu(e,r+1,o,t,n),r=o}else r++}}function mu(e,t,n,r){let i=/* @__PURE__ */ new Set([...su(t),...cu(e),...n,...Ul,...Wl]);r!=null&&r!==``&&i.add(r);let a=/* @__PURE__ */ new Set;return fu(e,0,e.length,i,a),pu(t,i,a),[...a]}function hu(e,t,n){if(t===n)return e;let r=``,i=0,a=0,o=e.length;for(;i<o;){let s=U(e,i,o);if(s!==-1){i=s;continue}if(!Gl(e.charCodeAt(i))){i++;continue}let c=X(e,i);c==null?i++:(c.name===t&&!du(e,i)&&!bu(e,i,c.end)&&(r+=e.slice(a,i)+n,a=c.end),i=c.end)}return r+e.slice(a)}function gu(e){return e===32||e===9||e===10||e===13||e===65279}function _u(e,t){if(t<2||e.charCodeAt(t-1)!==47||e.charCodeAt(t-2)!==42)return null;let n=-1,r=t-3;for(;r>=0;){let t=e.charCodeAt(r),i=e.charCodeAt(r+1);if(t===47&&i===42)n=r,r--;else{if(t===42&&i===47){if(r>0&&e.charCodeAt(r-1)===47){r--;continue}break}r--}}return n>=0?n:null}function Z(e,t){for(;t>0;){if(gu(e.charCodeAt(t-1))){t--;continue}let n=_u(e,t);if(n==null)break;t=n}return t}function Q(e,t,n){let r=t-n.length;return r<0||!eu(e,r,n)?null:r}const vu=/* @__PURE__ */ new Set([40,91,44,61,58,63,46,43,45,42,47,37,38,124,94,33,126,60,62]);function yu(e,t){let n=Z(e,t);if(n<=0)return!0;let r=Q(e,n,`default`);if(r!=null)return Q(e,Z(e,r),`export`)!=null;if(Q(e,n,`export`)!=null)return!0;let i=e.charCodeAt(n-1);if(i===59||i===125)return!0;if(i===123){let t=Z(e,n-1);return t<=0||e.charCodeAt(t-1)!==61}let a=!1;for(let r=n;r<t;r++){let t=e.charCodeAt(r);if(t===10||t===13){a=!0;break}}return a?!vu.has(i):!1}function bu(e,t,n){let r=Y(e,n);if(e.charCodeAt(r)!==58)return!1;let i=Z(e,t);if(i===0)return!1;let a=e.charCodeAt(i-1);return a===123||a===44}function xu(e,t,n){if(t<=0||e.charCodeAt(t-1)!==61)return null;let r=Z(e,t-1),i=r;for(;i>0&&Kl(e.charCodeAt(i-1));)i--;if(i>=r||!Gl(e.charCodeAt(i)))return null;let a=e.slice(i,r),o=Z(e,i),s=Q(e,o,`const`)??Q(e,o,`let`)??Q(e,o,`var`);return s==null?null:Q(e,Z(e,s),`export`)==null?{start:n,exportKind:null,bindingName:a}:{start:n,exportKind:`named`,bindingName:a}}function Su(e,t){let n=Z(e,t),r=Q(e,n,`default`);if(r!=null){n=Z(e,r);let t=Q(e,n,`export`);if(t!=null)return{start:t,exportKind:`default`,bindingName:null}}let i=xu(e,n,t);if(i!=null)return i;let a=Q(e,n,`export`);return a==null?{start:t,exportKind:null,bindingName:null}:{start:a,exportKind:`named`,bindingName:null}}function Cu(e,t,n,r){if(!eu(e,n,`function`))return null;n=Y(e,n+8),e.charCodeAt(n)===42&&(n=Y(e,n+1));let i=null,a=X(e,n);if(a&&(i=a.name,n=Y(e,a.end)),e.charCodeAt(n)!==40)return{action:null,nextI:t+1};let o=Yl(e,n,40,41),s=e.slice(n+1,o-1);if(n=Y(e,o),e.charCodeAt(n)!==123)return{action:null,nextI:t+1};let c=Yl(e,n,123,125)-1;if(!Zl(e,n,c))return{action:null,nextI:n+1};let l=i!=null&&yu(e,t);return{action:{start:t,end:c+1,bodyOpen:n,bodyClose:c,paramsRaw:s,isAsync:r,name:i,kind:l?`declaration`:`expression`},nextI:c+1}}function wu(e,t,n,r){let i,a;if(e.charCodeAt(n)===40)i=Yl(e,n,40,41),a=e.slice(n+1,i-1);else{let t=X(e,n);if(t==null)return null;i=t.end,a=t.name}let o=Y(e,i);if(e.charCodeAt(o)!==61||e.charCodeAt(o+1)!==62||(o=Y(e,o+2),e.charCodeAt(o)!==123))return null;let s=Yl(e,o,123,125)-1;return Zl(e,o,s)?{action:{start:t,end:s+1,bodyOpen:o,bodyClose:s,paramsRaw:a,isAsync:r,name:null,kind:`arrow`},nextI:s+1}:{action:null,nextI:o+1}}function Tu(e,t,n){if(!eu(e,t,`async`)&&!eu(e,t,`function`))return null;let r=t,i=t,a=!1;eu(e,i,`async`)&&(a=!0,i=Y(e,i+5));let o=Cu(e,r,i,a);if(o!=null)return o.action!=null&&n.push(o.action),o.nextI;if(!a)return null;let s=wu(e,r,i,!0);return s==null?null:(s.action!=null&&n.push(s.action),s.nextI)}function Eu(e,t,n){let r=e.charCodeAt(t);if(r===39||r===34||r===96)return Jl(e,t,r);if(r===47&&(e.charCodeAt(t+1)===47||e.charCodeAt(t+1)===42))return Y(e,t);let i=Tu(e,t,n);if(i!=null)return i;let a=wu(e,t,t,!1);return a==null?t+1:(a.action!=null&&n.push(a.action),a.nextI)}function Du(e){let t=[],n=e.length,r=0;for(;r<n;)r=Eu(e,r,t);return t}function Ou(e,t,n,r,i){return r==="default"?{rewrittenExport:`default`,replacement:`export default registerServerReference(${t}, ${JSON.stringify(n)}, "default")`}:r===`named`&&e.name!=null&&e.kind===`declaration`?{rewrittenExport:e.name,replacement:`export const ${e.name} = registerServerReference(${t}, ${JSON.stringify(n)}, ${JSON.stringify(e.name)})`}:r===`named`&&i!=null?{rewrittenExport:i,replacement:`registerServerReference(${t}, ${JSON.stringify(n)}, ${JSON.stringify(i)})`}:e.kind===`declaration`&&e.name!=null?{replacement:`const ${e.name} = ${t}`,rewrittenExport:null}:{replacement:t,rewrittenExport:null}}function ku(e,t,n,r,i,a,o,s){s==null?e.unshift(`${n}function ${r}(${i}) {\n${a}\n}`,`registerServerReference(${r}, ${JSON.stringify(o)}, ${JSON.stringify(r)});`):(e.unshift(`${n}function ${r}(${i}) {\n${a}\n}`),t.unshift(s))}function Au(e,t){let n=Du(e);if(n.length===0)return null;let r=uu(e),i=[],a=[],o=e,s=[],c=!1,l=[...n].sort((e,t)=>t.start-e.start),u=n.length-1;for(let e of l){let n=e.name??`anonymous_server_function`,l=`$$ACTION_${u}_${n.replace(/\W/g,`_`)}`;u--,i.unshift(l);let d=$l(o,e.bodyOpen,e.bodyClose),f=e.kind===`expression`&&e.name!=null?e.name:null,p=mu(d,e.paramsRaw,r,f),m=f==null?d:hu(d,f,l),h=[...p,e.paramsRaw.trim()].filter(e=>e!==``).join(`, `),g=e.isAsync?`async `:``,_=p.length>0?`${l}.bind(null, ${p.join(`, `)})`:l,{start:v,exportKind:y,bindingName:b}=Su(o,e.start),{replacement:x,rewrittenExport:ee}=Ou(e,_,t,y,b);ku(s,a,g,l,h,m,t,ee),c=!0,o=o.slice(0,v)+x+o.slice(e.end)}let d=c?`import { registerServerReference } from ${JSON.stringify(`react-server-dom-rari/server`)};\n`:``;return{code:`${c&&!Hl(o)?d:``}${o}\n\n${s.join(`
|
|
88
|
+
`),helpers:[...r]}}const Vl=/(?:^|[\n\r;])\s*import\s*\{[^}]*\bregisterServerReference\b[^}]*\}\s*from\s*["'][^"'\n]+["']/;function Hl(e){return Vl.test(e)}const Ul=/* @__PURE__ */ new Set(/* @__PURE__ */ `undefined.NaN.Infinity.arguments.Object.Array.String.Number.Boolean.Symbol.BigInt.Math.Date.JSON.Promise.Error.TypeError.RangeError.Map.Set.WeakMap.WeakSet.RegExp.Proxy.Reflect.Function.console.fetch.process.Buffer.globalThis.global.window.document.navigator.location.crypto.TextEncoder.TextDecoder.URL.URLSearchParams.FormData.Headers.Request.Response.AbortController.AbortSignal.setTimeout.clearTimeout.setInterval.clearInterval.queueMicrotask.structuredClone.atob.btoa.React.jsx.jsxs.Fragment`.split(`.`)),Wl=/* @__PURE__ */ new Set(/* @__PURE__ */ `await.return.throw.if.else.for.while.do.switch.case.break.continue.new.typeof.instanceof.void.delete.yield.class.extends.super.this.try.catch.finally.with.debugger.default.of.in.from.as.import.export.async.function.const.let.var.true.false.null.static.get.set.typeof`.split(`.`));function Gl(e){return e>=97&&e<=122||e>=65&&e<=90||e===95||e===36}function Kl(e){return Gl(e)||e>=48&&e<=57}function Y(e,t){let n=e.length;for(;t<n;){let r=ql(e,t,n);if(r==null)break;t=r}return t}function ql(e,t,n){let r=e.charCodeAt(t);if(r===32||r===9||r===10||r===13||r===65279)return t+1;if(r===47&&e.charCodeAt(t+1)===47){let r=t+2;for(;r<n&&e.charCodeAt(r)!==10&&e.charCodeAt(r)!==13;)r++;return r}if(r===47&&e.charCodeAt(t+1)===42){let r=t+2;for(;r<n-1&&(e.charCodeAt(r)!==42||e.charCodeAt(r+1)!==47);)r++;return r+2}return null}function Jl(e,t,n){t++;let r=e.length;for(;t<r;){let r=e.charCodeAt(t);if(r===92)t+=2;else{if(r===n)return t+1;t++}}return t}function Yl(e,t,n,r){let i=t,a=0,o=e.length;for(;i<o;){let t=U(e,i,o);if(t!==-1){i=t;continue}let s=e.charCodeAt(i);if(s===n)a++;else if(s===r&&(a--,a===0))return i+1;i++}return i}function Xl(e,t,n){for(let r=0;r<n.length;r++)if(e.charCodeAt(t+r)!==n.charCodeAt(r))return!1;return!0}function Zl(e,t,n){let r=Y(e,t+1);if(r>=n)return!1;let i=e.charCodeAt(r);if(i!==39&&i!==34)return!1;let a=r+1,o=Jl(e,r,i);return o-1-a!=10||!Xl(e,a,`use server`)?!1:Ql(e,o,n)}function Ql(e,t,n){let r=t;for(;r<n;){let t=e.charCodeAt(r);if(t===32||t===9)r++;else return t===59||t===10||t===13||t===47&&e.charCodeAt(r+1)===47||t===47&&e.charCodeAt(r+1)===42}return!0}function $l(e,t,n){let r=Y(e,t+1),i=e.charCodeAt(r);return i!==39&&i!==34?e.slice(t+1,n):(r=Y(e,Jl(e,r,i)),e.charCodeAt(r)===59&&r++,r=Y(e,r),e.slice(r,n))}function X(e,t){if(!Gl(e.charCodeAt(t)))return null;let n=t+1;for(;n<e.length&&Kl(e.charCodeAt(n));)n++;return{name:e.slice(t,n),end:n}}function eu(e,t,n){if(!Xl(e,t,n))return!1;let r=t>0?e.charCodeAt(t-1):-1,i=t+n.length<e.length?e.charCodeAt(t+n.length):-1;return!(r!==-1&&Kl(r)||i!==-1&&Kl(i))}function tu(e,t,n){return e===0&&t===0&&n===0}function nu(e,t){return e===40?(t.paren++,null):e===41?(t.paren=Math.max(0,t.paren-1),null):e===123?(t.brace++,null):e===125?tu(t.paren,t.brace,t.bracket)?-1:(t.brace=Math.max(0,t.brace-1),null):e===91?(t.bracket++,null):e===93?tu(t.paren,t.brace,t.bracket)?-1:(t.bracket=Math.max(0,t.bracket-1),null):e===44&&tu(t.paren,t.brace,t.bracket)?-1:null}function ru(e,t,n){let r=Y(e,t+1),i={paren:0,brace:0,bracket:0};for(;r<n;){let t=U(e,r,n);if(t!==-1)r=t;else{if(nu(e.charCodeAt(r),i)===-1)return r;r++}}return r}function iu(e,t,n,r,i){let a=X(e,t);if(a==null)return t+1;let o=Y(e,a.end);if(n===123&&e.charCodeAt(o)===58)return o+1;i.add(a.name);let s=a.end,c=Y(e,s);return e.charCodeAt(c)===61&&(s=ru(e,c,r-1)),s}function au(e,t,n){let r=e.charCodeAt(t),i=Yl(e,t,r,r===123?125:93),a=t+1;for(;a<i-1&&(a=Y(e,a),!(a>=i-1));){let t=e.charCodeAt(a);a=t===123||t===91?au(e,a,n):t===46&&e.charCodeAt(a+1)===46&&e.charCodeAt(a+2)===46?ou(e,a,n):iu(e,a,r,i,n)}return i}function ou(e,t,n){t+=3,t=Y(e,t);let r=X(e,t);return r?(n.add(r.name),r.end):t}function su(e){let t=/* @__PURE__ */ new Set,n=0,r=e.length;for(;n<r&&(n=Y(e,n),!(n>=r));){let r=e.charCodeAt(n);if(r===123||r===91){n=au(e,n,t);continue}if(r===46&&e.charCodeAt(n+1)===46&&e.charCodeAt(n+2)===46){n=ou(e,n,t);continue}let i=X(e,n);i?(t.add(i.name),n=i.end):n++}return t}function cu(e){let t=/* @__PURE__ */ new Set;for(let n of e.matchAll(/\b(?:const|let|var|function|class|async\s+function)\s+([A-Za-z_$][\w$]*)/g))t.add(n[1]);return t}function lu(e,t){for(let n of e.split(`,`)){let e=n.trim();if(!e||e.startsWith(`type `))continue;let r=(e.split(/\s+as\s+/).at(-1)??``).trim();r&&t.add(r)}}function uu(e){let t=/* @__PURE__ */ new Set;for(let n of e.matchAll(/\b(?:import|export)\s+(?:type\s+)?(?:\{([^}]+)\}|(\*\s+as\s+[A-Za-z_$][\w$]*)|([A-Za-z_$][\w$]*))/g)){if(n[1]&&lu(n[1],t),n[2]){let e=/as\s+([A-Za-z_$][\w$]*)/.exec(n[2]);e&&t.add(e[1])}n[3]&&n[3]!==`type`&&n[3]!==`async`&&n[3]!==`function`&&n[3]!==`class`&&t.add(n[3])}for(let n of e.matchAll(/(?:^|\n)\s*(?:export\s+)?(?:async\s+)?(?:function|class|const|let|var)\s+([A-Za-z_$][\w$]*)/g))t.add(n[1]);return t}function du(e,t){return t<=0||e.charCodeAt(t-1)!==46?!1:t<2||e.charCodeAt(t-2)!==46}function fu(e,t,n,r,i){let a=t;for(;a<n;){let t=U(e,a,n);if(t!==-1){a=t;continue}if(!Gl(e.charCodeAt(a))){a++;continue}let o=X(e,a);o==null?a++:(du(e,a)||bu(e,a,o.end)||r.has(o.name)||i.add(o.name),a=o.end)}}function pu(e,t,n){let r=0,i=e.length;for(;r<i;){let a=U(e,r,i);if(a!==-1)r=a;else if(e.charCodeAt(r)===61){let a=e.charCodeAt(r+1);if(a===62||a===61){r++;continue}let o=ru(e,r,i);fu(e,r+1,o,t,n),r=o}else r++}}function mu(e,t,n,r){let i=/* @__PURE__ */ new Set([...su(t),...cu(e),...n,...Ul,...Wl]);r!=null&&r!==``&&i.add(r);let a=/* @__PURE__ */ new Set;return fu(e,0,e.length,i,a),pu(t,i,a),[...a]}function hu(e,t,n){if(t===n)return e;let r=``,i=0,a=0,o=e.length;for(;i<o;){let s=U(e,i,o);if(s!==-1){i=s;continue}if(!Gl(e.charCodeAt(i))){i++;continue}let c=X(e,i);c==null?i++:(c.name===t&&!du(e,i)&&!bu(e,i,c.end)&&(r+=e.slice(a,i)+n,a=c.end),i=c.end)}return r+e.slice(a)}function gu(e){return e===32||e===9||e===10||e===13||e===65279}function _u(e,t){if(t<2||e.charCodeAt(t-1)!==47||e.charCodeAt(t-2)!==42)return null;let n=-1,r=t-3;for(;r>=0;){let t=e.charCodeAt(r),i=e.charCodeAt(r+1);if(t===47&&i===42)n=r,r--;else{if(t===42&&i===47){if(r>0&&e.charCodeAt(r-1)===47){r--;continue}break}r--}}return n>=0?n:null}function Z(e,t){for(;t>0;){if(gu(e.charCodeAt(t-1))){t--;continue}let n=_u(e,t);if(n==null)break;t=n}return t}function Q(e,t,n){let r=t-n.length;return r<0||!eu(e,r,n)?null:r}const vu=/* @__PURE__ */ new Set([40,91,44,61,58,63,46,43,45,42,47,37,38,124,94,33,126,60,62]);function yu(e,t){let n=Z(e,t);if(n<=0)return!0;let r=Q(e,n,`default`);if(r!=null)return Q(e,Z(e,r),`export`)!=null;if(Q(e,n,`export`)!=null)return!0;let i=e.charCodeAt(n-1);if(i===59||i===125)return!0;if(i===123){let t=Z(e,n-1);return t<=0||e.charCodeAt(t-1)!==61}let a=!1;for(let r=n;r<t;r++){let t=e.charCodeAt(r);if(t===10||t===13){a=!0;break}}return a?!vu.has(i):!1}function bu(e,t,n){let r=Y(e,n);if(e.charCodeAt(r)!==58)return!1;let i=Z(e,t);if(i===0)return!1;let a=e.charCodeAt(i-1);return a===123||a===44}function xu(e,t,n){if(t<=0||e.charCodeAt(t-1)!==61)return null;let r=Z(e,t-1),i=r;for(;i>0&&Kl(e.charCodeAt(i-1));)i--;if(i>=r||!Gl(e.charCodeAt(i)))return null;let a=e.slice(i,r),o=Z(e,i),s=Q(e,o,`const`)??Q(e,o,`let`)??Q(e,o,`var`);return s==null?null:Q(e,Z(e,s),`export`)==null?{start:n,exportKind:null,bindingName:a}:{start:n,exportKind:`named`,bindingName:a}}function Su(e,t){let n=Z(e,t),r=Q(e,n,`default`);if(r!=null){n=Z(e,r);let t=Q(e,n,`export`);if(t!=null)return{start:t,exportKind:`default`,bindingName:null}}let i=xu(e,n,t);if(i!=null)return i;let a=Q(e,n,`export`);return a==null?{start:t,exportKind:null,bindingName:null}:{start:a,exportKind:`named`,bindingName:null}}function Cu(e,t,n,r){if(!eu(e,n,`function`))return null;n=Y(e,n+8),e.charCodeAt(n)===42&&(n=Y(e,n+1));let i=null,a=X(e,n);if(a&&(i=a.name,n=Y(e,a.end)),e.charCodeAt(n)!==40)return{action:null,nextI:t+1};let o=Yl(e,n,40,41),s=e.slice(n+1,o-1);if(n=Y(e,o),e.charCodeAt(n)!==123)return{action:null,nextI:t+1};let c=Yl(e,n,123,125)-1;if(!Zl(e,n,c))return{action:null,nextI:n+1};let l=i!=null&&yu(e,t);return{action:{start:t,end:c+1,bodyOpen:n,bodyClose:c,paramsRaw:s,isAsync:r,name:i,kind:l?`declaration`:`expression`},nextI:c+1}}function wu(e,t,n,r){let i,a;if(e.charCodeAt(n)===40)i=Yl(e,n,40,41),a=e.slice(n+1,i-1);else{let t=X(e,n);if(t==null)return null;i=t.end,a=t.name}let o=Y(e,i);if(e.charCodeAt(o)!==61||e.charCodeAt(o+1)!==62||(o=Y(e,o+2),e.charCodeAt(o)!==123))return null;let s=Yl(e,o,123,125)-1;return Zl(e,o,s)?{action:{start:t,end:s+1,bodyOpen:o,bodyClose:s,paramsRaw:a,isAsync:r,name:null,kind:`arrow`},nextI:s+1}:{action:null,nextI:o+1}}function Tu(e,t,n){if(!eu(e,t,`async`)&&!eu(e,t,`function`))return null;let r=t,i=t,a=!1;eu(e,i,`async`)&&(a=!0,i=Y(e,i+5));let o=Cu(e,r,i,a);if(o!=null)return o.action!=null&&n.push(o.action),o.nextI;if(!a)return null;let s=wu(e,r,i,!0);return s==null?null:(s.action!=null&&n.push(s.action),s.nextI)}function Eu(e,t,n){let r=e.charCodeAt(t);if(r===39||r===34||r===96)return Jl(e,t,r);if(r===47&&(e.charCodeAt(t+1)===47||e.charCodeAt(t+1)===42))return Y(e,t);let i=Tu(e,t,n);if(i!=null)return i;let a=wu(e,t,t,!1);return a==null?t+1:(a.action!=null&&n.push(a.action),a.nextI)}function Du(e){let t=[],n=e.length,r=0;for(;r<n;)r=Eu(e,r,t);return t}function Ou(e,t,n,r,i){return r==="default"?{rewrittenExport:`default`,replacement:`export default registerServerReference(${t}, ${JSON.stringify(n)}, "default")`}:r===`named`&&e.name!=null&&e.kind===`declaration`?{rewrittenExport:e.name,replacement:`export const ${e.name} = registerServerReference(${t}, ${JSON.stringify(n)}, ${JSON.stringify(e.name)})`}:r===`named`&&i!=null?{rewrittenExport:i,replacement:`registerServerReference(${t}, ${JSON.stringify(n)}, ${JSON.stringify(i)})`}:e.kind===`declaration`&&e.name!=null?{replacement:`const ${e.name} = ${t}`,rewrittenExport:null}:{replacement:t,rewrittenExport:null}}function ku(e,t,n,r,i,a,o,s){s==null?e.unshift(`${n}function ${r}(${i}) {\n${a}\n}`,`registerServerReference(${r}, ${JSON.stringify(o)}, ${JSON.stringify(r)});`):(e.unshift(`${n}function ${r}(${i}) {\n${a}\n}`),t.unshift(s))}function Au(e,t){let n=Du(e);if(n.length===0)return null;let r=uu(e),i=[],a=[],o=e,s=[],c=!1,l=n.toSorted((e,t)=>t.start-e.start),u=n.length-1;for(let e of l){let n=e.name??`anonymous_server_function`,l=`$$ACTION_${u}_${n.replace(/\W/g,`_`)}`;u--,i.unshift(l);let d=$l(o,e.bodyOpen,e.bodyClose),f=e.kind===`expression`&&e.name!=null?e.name:null,p=mu(d,e.paramsRaw,r,f),m=f==null?d:hu(d,f,l),h=[...p,e.paramsRaw.trim()].filter(e=>e!==``).join(`, `),g=e.isAsync?`async `:``,_=p.length>0?`${l}.bind(null, ${p.join(`, `)})`:l,{start:v,exportKind:y,bindingName:b}=Su(o,e.start),{replacement:x,rewrittenExport:ee}=Ou(e,_,t,y,b);ku(s,a,g,l,h,m,t,ee),c=!0,o=o.slice(0,v)+x+o.slice(e.end)}let d=c?`import { registerServerReference } from ${JSON.stringify(`react-server-dom-rari/server`)};\n`:``;return{code:`${c&&!Hl(o)?d:``}${o}\n\n${s.join(`
|
|
89
89
|
`)}\n`,actionNames:i,rewrittenExportNames:a}}const ju=/import\s+(\w+)\s+from\s+['"]([^'"]+)['"]/g,Mu=/import\s+\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/g,Nu=/import\s+(\w+)\s*,\s*\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/g,Pu=/defineMdxComponents\s*\(\s*\{([\s\S]*?)\}\s*\)/;function Fu(e,t,n){for(let r of t.split(`,`)){let t=r.trim();if(!t||(t=t.replace(/^type\s+/i,``).trim(),!t))continue;let i=t.split(/\s+as\s+/i),a=(i[1]??i[0]).trim();a&&n.set(a,e)}}function Iu(e){let t=/* @__PURE__ */ new Map;for(let n of e.matchAll(Nu))t.set(n[1],n[3]),Fu(n[3],n[2],t);for(let n of e.matchAll(ju))t.set(n[1],n[2]);for(let n of e.matchAll(Mu))Fu(n[2],n[1],t);return t}function Lu(e){let t=[];for(let n of e.split(`,`)){let e=n.trim();if(!e)continue;let r=e.indexOf(`:`);if(r===-1){t.push({name:e,binding:e});continue}let i=e.slice(0,r).trim(),a=e.slice(r+1).trim();i&&a&&t.push({name:i,binding:a})}return t}function Ru(e){try{return V(O.readFileSync(e,`utf-8`)).topLevelUseClient}catch{return!1}}function zu(e){let{code:t,id:n,projectRoot:r,resolvedAlias:i}=e;if(!t.includes(`defineMdxComponents`)||t.includes(`__RARI_MDX_RESOLVED__`))return null;let a=Pu.exec(t);if(!a)return null;let o=Iu(t),s=Lu(a[1]);if(s.length===0)return null;let c=`defineMdxComponents(/* __RARI_MDX_RESOLVED__ */[\n${s.map(({name:e,binding:t})=>{let a=o.get(t);if(a==null||a===``)throw Error(`[rari/mdx] Could not resolve import for MDX component "${e}" (binding "${t}") in ${n}`);let s=fe(a,n,i),c=Ht(s,r),l=Ru(s);return` { name: ${JSON.stringify(e)}, component: ${t}, id: ${JSON.stringify(c)}, client: ${l} }`}).join(`,
|
|
90
90
|
`)},\n])`;return t.replace(Pu,c)}const Bu=/forwardRef|memo|\b(?:[A-Z]|use[A-Z0-9])/,Vu=/\.[cm]?[jt]sx?$/,Hu=/['"]use memo['"]/;function Uu(e){return{...e===!0?{}:e,target:`19`}}function Wu(e,t){return t.compilationMode===`annotation`?Hu.test(e):Bu.test(e)}function Gu(e){if(e.startsWith(`\0`)||e.includes(`virtual:`))return!1;let t=h(e);return/\.d\.[cm]?ts$/.test(t)||t.includes(`/dist/`)?!1:Vu.test(t)&&!t.includes(`/node_modules/`)}const Ku=/\.[jt]sx$/;function qu(e,t=`app`){let n=Uu(e),r,i=!0,a=!1,o=!1,s=async e=>{if(r)return r;try{return r=await import(`oxc-transform-react`),r}catch(t){let n=w(t);return e(`React Compiler requires the optional \`oxc-transform-react\` package. Install it before enabling \`rari({ compiler: true })\`.${n==null?``:`\n${n.message}`}`)}};return{name:t===`library`?`rari:react-compiler-library`:`rari:react-compiler`,enforce:`pre`,async config(e,{command:n}){return await s(e=>this.error(e)),t===`library`?(o=!1,a=!1,{}):(o=n===`serve`,{oxc:{jsx:{refresh:!1}},optimizeDeps:{include:[`react/compiler-runtime`]}})},configResolved(e){t===`library`?(i=e.build.sourcemap!==!1,a=!1,o=!1):(i=e.command!==`build`||e.build.sourcemap!==!1,a=!e.isProduction,o=!e.isProduction&&e.command===`serve`&&e.server.hmr!==!1)},async transform(e,c){if(!Gu(c))return null;let l=h(c);if(t===`library`&&!Ku.test(l)||Hn(e)||t===`app`&&this.environment.config.consumer===`server`)return null;let{transform:u}=r??await s(e=>this.error(e)),d=Wu(e,n),f=await u(l,e,{jsx:{runtime:`automatic`,development:a,importSource:`react`,refresh:o},reactCompiler:d?n:!1,sourcemap:i}),p=f.errors.map(e=>{let t=e.codeframe;return t!=null&&t!==``?`${e.message}\n${t}`:e.message});if(f.fatal){let e=p.join(`
|
|
91
91
|
|
|
@@ -777,7 +777,7 @@ export const __hmr_import = (module) => import(/* @vite-ignore */ module)
|
|
|
777
777
|
|
|
778
778
|
// For backwards compatibility with @vitejs/plugin-react.
|
|
779
779
|
export default { injectIntoGlobalHook }
|
|
780
|
-
`:null}},{name:`rari:react-refresh-wrapper`,apply:`serve`,applyToEnvironment(e){return e.config.consumer===`client`&&Ne({cwd:process.cwd(),include:[Ju],exclude:Yu,jsxImportSource:`react`,reactRefreshHost:``})}}]}let Zu;async function Qu(){return Zu??=(async()=>{try{let e=await import(`@rari/use-cache`);e.requireNativeAddon();let t=e.transformUseCacheModule;if(typeof t!=`function`)throw TypeError("`@rari/use-cache` did not export transformUseCacheModule");return t}catch(e){let t=e instanceof Error&&e.message!==``?` ${e.message}`:``;throw Error(`\`experimental.useCache\` / \`experimental.useCacheRemote\` requires a working \`@rari/use-cache\` native addon. Install the optional platform package, or run \`just build-addon-dev\` in the monorepo.${t}
|
|
780
|
+
`:null}},{name:`rari:react-refresh-wrapper`,apply:`serve`,applyToEnvironment(e){return e.config.consumer===`client`&&Ne({cwd:process.cwd(),include:[Ju],exclude:Yu,jsxImportSource:`react`,reactRefreshHost:``})}}]}let Zu;async function Qu(){return Zu??=(async()=>{try{let e=await import(`@rari/use-cache`);e.requireNativeAddon();let t=e.transformUseCacheModule;if(typeof t!=`function`)throw TypeError("`@rari/use-cache` did not export transformUseCacheModule");return t}catch(e){let t=e instanceof Error&&e.message!==``?` ${e.message}`:``;throw Error(`\`experimental.useCache\` / \`experimental.useCacheRemote\` requires a working \`@rari/use-cache\` native addon. Install the optional platform package, or run \`just build-addon-dev\` in the monorepo.${t}`,{cause:e})}})(),Zu}async function $u(e){let t=await import(
|
|
781
781
|
/* @vite-ignore */
|
|
782
782
|
e);return C(t)?t:{}}function ed(e,t){e&&(e.notFound&&(t.notFound=!0),e.redirect!=null&&(t.redirect=typeof e.redirect==`string`?e.redirect:e.redirect.destination),e.revalidate!==void 0&&(t.revalidate=e.revalidate),e.props&&(t.props={...t.props,...e.props}))}async function td(e,t){try{ed(await e(),t)}catch(e){if(be(e)){t.notFound=!0;return}throw e}}async function nd(e,t,n,r){let i=e.getData;typeof i==`function`&&await td(async()=>i({params:t,searchParams:n}),r)}async function rd(e,t,n,r){let i=e.getServerSideProps;typeof i==`function`&&await td(async()=>i({params:t,searchParams:n}),r)}async function id(e,t,n){let r=e.getStaticProps;typeof r==`function`&&await td(async()=>r({params:t}),n)}
|
|
783
783
|
/* v8 ignore start - requires dynamic imports, better tested in integration/e2e */
|
|
@@ -911,7 +911,7 @@ import {registerServerReference} from "react-server-dom-rari/server";
|
|
|
911
911
|
`;for(let e of s)if(e==="default")o=_e(o,c);else if(a?.rewrittenExportNames.includes(e))continue;else o=ve(o,e,c);return o=Gn(o,`use server`),ge(o)}function be(e,t,n,r){let i=he(e,n);if(i.length===0)return``;let a=Wt(t,r),o=`import { createServerReference } from "virtual:react-flight-client";
|
|
912
912
|
`;o+=`import { callServer } from "rari/runtime/call-server";
|
|
913
913
|
`;for(let e of i){let t=`${a}#${e}`,n=JSON.stringify(t);o+=e==="default"?`export default createServerReference(${n}, callServer);\n`:`export const ${e} = createServerReference(${n}, callServer);\n`}return o}function xe(t,n,r){let i=e.projectRoot!=null&&e.projectRoot!==``?e.projectRoot:j.cwd(),a=me(n);if(r.topLevelUseServer)return be(t,n,r,i);if(a)return console.warn(`[rari] Server component ${n} should not be imported in client bundle`),``;if(!r.topLevelUseClient)return t;let o=he(t,r);if(o.length===0)return``;let s=JSON.stringify(n),c=`import {registerClientReference} from "react-server-dom-rari/server";
|
|
914
|
-
`;for(let e of o){if(e==="default"){let e=`Attempted to call the default export of ${n} from the server but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.`;c+=`export default `,c+=`registerClientReference(function() {`,c+=`throw new Error(${JSON.stringify(e)});`}else{let t=`Attempted to call ${e}() from the server but ${e} is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.`;c+=`export const ${e} = `,c+=`registerClientReference(function() {`,c+=`throw new Error(${JSON.stringify(t)});`}c+=`},`,c+=`${s},`,c+=`${JSON.stringify(e)});\n`}return c}function Se(e,t,n){return!n.topLevelUseClient||he(e,n).length===0?e:e.replace(wd,``)}let D=!1;async function Ce(){let e=`http://localhost:${N()}`;try{let t=(await fetch(`${e}/_rari/health`,{signal:AbortSignal.timeout(1e3)})).ok;return D=t,t}catch{return D=!1,!1}}let Te=null;async function k(e){return await Ce()?!0:(Te??=(async()=>{try{let t=Date.now()+e,n=50;for(;Date.now()<t;){if(await new Promise(e=>{setTimeout(e,Math.min(n,t-Date.now()))}),await Ce())return!0;n=Math.min(n*2,500)}return!1}finally{Te=null}})(),Te)}function M(e){if(e.includes(`virtual:client-router`)||e.includes(`virtual:app-router-provider`)||e.includes(`virtual:error-boundary-wrapper`)||e.includes(`/navigation/client-router`)||e.includes(`/flight/app-router-provider`)||zd!=null&&A.resolve(e)===zd)return!0;if(!O.existsSync(e))return!1;try{return r.get(e).topLevelUseClient}catch{return!1}}function De(e,t){let n=e,r=[],i=/* @__PURE__ */ new Set;for(let e of Nn(n)){if(e.typeOnly||e.sideEffectOnly||!Td.test(e.source)&&!Ed(e.source,s))continue;let n=fe(e.source,t,s);if(!M(n))continue;w(n,`client`),ie(n);let a=Bl(e,C(n));if(a.code!==``){for(let e of a.helpers)i.add(e);r.push({start:e.start,end:e.end,replacement:a.code})}}if(r.length===0)return n;for(let{start:e,end:t,replacement:i}of
|
|
914
|
+
`;for(let e of o){if(e==="default"){let e=`Attempted to call the default export of ${n} from the server but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.`;c+=`export default `,c+=`registerClientReference(function() {`,c+=`throw new Error(${JSON.stringify(e)});`}else{let t=`Attempted to call ${e}() from the server but ${e} is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.`;c+=`export const ${e} = `,c+=`registerClientReference(function() {`,c+=`throw new Error(${JSON.stringify(t)});`}c+=`},`,c+=`${s},`,c+=`${JSON.stringify(e)});\n`}return c}function Se(e,t,n){return!n.topLevelUseClient||he(e,n).length===0?e:e.replace(wd,``)}let D=!1;async function Ce(){let e=`http://localhost:${N()}`;try{let t=(await fetch(`${e}/_rari/health`,{signal:AbortSignal.timeout(1e3)})).ok;return D=t,t}catch{return D=!1,!1}}let Te=null;async function k(e){return await Ce()?!0:(Te??=(async()=>{try{let t=Date.now()+e,n=50;for(;Date.now()<t;){if(await new Promise(e=>{setTimeout(e,Math.min(n,t-Date.now()))}),await Ce())return!0;n=Math.min(n*2,500)}return!1}finally{Te=null}})(),Te)}function M(e){if(e.includes(`virtual:client-router`)||e.includes(`virtual:app-router-provider`)||e.includes(`virtual:error-boundary-wrapper`)||e.includes(`/navigation/client-router`)||e.includes(`/flight/app-router-provider`)||zd!=null&&A.resolve(e)===zd)return!0;if(!O.existsSync(e))return!1;try{return r.get(e).topLevelUseClient}catch{return!1}}function De(e,t){let n=e,r=[],i=/* @__PURE__ */ new Set;for(let e of Nn(n)){if(e.typeOnly||e.sideEffectOnly||!Td.test(e.source)&&!Ed(e.source,s))continue;let n=fe(e.source,t,s);if(!M(n))continue;w(n,`client`),ie(n);let a=Bl(e,C(n));if(a.code!==``){for(let e of a.helpers)i.add(e);r.push({start:e.start,end:e.end,replacement:a.code})}}if(r.length===0)return n;for(let{start:e,end:t,replacement:i}of r.toSorted((e,t)=>t.start-e.start))n=n.slice(0,e)+i+n.slice(t);return i.size>0&&(n=Ll(n,`react-server-dom-rari/server`,[...i])),n}function Oe(e,t){for(let n of t.importSources){if(!Td.test(n)&&!Ed(n,s))continue;let t=fe(n,e,s);O.existsSync(t)&&(r.get(t).topLevelUseServer||(w(t,`client`),ie(t)))}}function ke(e,t,n){return e&&!t&&(n===`rsc`||n===`ssr`)}function Ae(e,t,n){let r=t.includes(`entry-client`),i=[],a=/* @__PURE__ */ new Set;for(let o of Nn(e)){if(o.typeOnly||o.sideEffectOnly||!Td.test(o.source)&&!Ed(o.source,s))continue;let e=fe(o.source,t,s),c=M(e);if(c&&(w(e,`client`),ie(e)),!ke(c,r,n))continue;let l=Bl(o,C(e));if(l.code!==``){for(let e of l.helpers)a.add(e);i.push({start:o.start,end:o.end,replacement:l.code})}}return i.length===0?null:{replacements:i,clientRefHelpers:a}}function je(e,t,n){let r=Ae(e,t,n);if(r==null)return null;let i=e;for(let{start:e,end:t,replacement:n}of r.replacements.toSorted((e,t)=>t.start-e.start))i=i.slice(0,e)+n+i.slice(t);r.clientRefHelpers.size>0&&(i=Ll(i,`react-server-dom-rari/server`,[...r.clientRefHelpers]));let a=j.env.NODE_ENV!==`production`;return(i.includes(`</`)||i.includes(`/>`)||Ad.test(i))&&a&&w(t,`client`),i}function Me(e,t,n,r){if(r===`rsc`||r===`ssr`)return De(ye(e,t,n),t);let i=xe(e,t,n);return`// HMR acceptance for server component
|
|
915
915
|
if (import.meta.hot) {
|
|
916
916
|
import.meta.hot.accept();
|
|
917
917
|
if (typeof globalThis !== 'undefined') {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rari",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.17.
|
|
4
|
+
"version": "0.17.11",
|
|
5
5
|
"description": "Runtime Accelerated Rendering Infrastructure (rari)",
|
|
6
6
|
"author": "Ryan Skinner",
|
|
7
7
|
"license": "MIT",
|
|
@@ -138,7 +138,7 @@
|
|
|
138
138
|
},
|
|
139
139
|
"peerDependencies": {
|
|
140
140
|
"@mdx-js/mdx": "^3.1.1",
|
|
141
|
-
"@rari/use-cache": "^0.17.
|
|
141
|
+
"@rari/use-cache": "^0.17.11",
|
|
142
142
|
"oxc-transform-react": "^0.158.0",
|
|
143
143
|
"react": "^19.3.1",
|
|
144
144
|
"react-dom": "^19.3.1"
|
|
@@ -155,30 +155,30 @@
|
|
|
155
155
|
}
|
|
156
156
|
},
|
|
157
157
|
"dependencies": {
|
|
158
|
-
"@capsizecss/metrics": "^4.
|
|
158
|
+
"@capsizecss/metrics": "^4.5.0",
|
|
159
159
|
"@capsizecss/unpack": "^4.0.1",
|
|
160
160
|
"react-server-dom-webpack": "^19.3.1"
|
|
161
161
|
},
|
|
162
162
|
"optionalDependencies": {
|
|
163
|
-
"rari-darwin-arm64": "0.17.
|
|
164
|
-
"rari-darwin-x64": "0.17.
|
|
165
|
-
"rari-linux-arm64": "0.17.
|
|
166
|
-
"rari-linux-x64": "0.17.
|
|
167
|
-
"rari-win32-arm64": "0.17.
|
|
168
|
-
"rari-win32-x64": "0.17.
|
|
163
|
+
"rari-darwin-arm64": "0.17.11",
|
|
164
|
+
"rari-darwin-x64": "0.17.11",
|
|
165
|
+
"rari-linux-arm64": "0.17.11",
|
|
166
|
+
"rari-linux-x64": "0.17.11",
|
|
167
|
+
"rari-win32-arm64": "0.17.11",
|
|
168
|
+
"rari-win32-x64": "0.17.11"
|
|
169
169
|
},
|
|
170
170
|
"devDependencies": {
|
|
171
171
|
"@mdx-js/mdx": "^3.1.1",
|
|
172
172
|
"@rari/deploy": "0.0.0",
|
|
173
173
|
"@rari/logger": "0.0.0",
|
|
174
|
-
"@rari/use-cache": "0.17.
|
|
174
|
+
"@rari/use-cache": "0.17.11",
|
|
175
175
|
"@types/node": "^26.6.6",
|
|
176
176
|
"@types/react": "^19.3.0",
|
|
177
177
|
"@types/react-dom": "^19.3.0",
|
|
178
178
|
"oxc-transform-react": "^0.158.0",
|
|
179
179
|
"typescript": "npm:@typescript/typescript6@^6.0.2",
|
|
180
180
|
"typescript-7": "npm:typescript@^7.0.2",
|
|
181
|
-
"vite-plus": "^1.
|
|
181
|
+
"vite-plus": "^1.7.0"
|
|
182
182
|
},
|
|
183
183
|
"scripts": {
|
|
184
184
|
"build": "pnpm typecheck && vp pack && node ./scripts/update-google-fonts.ts --types-only",
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import{a as e,i as t,n,o as r,r as i,t as a}from"./utils-YdvPzSET-Cbo6Ofmz.mjs";import{existsSync as o,readFileSync as s,writeFileSync as c}from"node:fs";import{join as l}from"node:path";import u from"node:process";import{styleText as d}from"node:util";function f(){let n=u.cwd();e(`Creating Railway deployment configuration...`),t(n,{providerName:`Railway`,deployScript:`echo "Push to GitHub and connect to Railway to deploy"`,startScript:`rari start`,dependency:i()}),p(n),a(n,`Railway`,`.railway`),m(n),h()}function p(e){n(e,`railway.toml`,`[build]
|
|
2
|
-
builder = "RAILPACK"
|
|
3
|
-
|
|
4
|
-
[deploy]
|
|
5
|
-
startCommand = "npm start"
|
|
6
|
-
healthcheckPath = "/_rari/health"
|
|
7
|
-
healthcheckTimeout = 300
|
|
8
|
-
restartPolicyType = "ON_FAILURE"
|
|
9
|
-
restartPolicyMaxRetries = 3
|
|
10
|
-
`)}function m(e){let t=l(e,`README.md`),n=`
|
|
11
|
-
## 🚂 Deploy to Railway
|
|
12
|
-
|
|
13
|
-
This rari application is configured for Railway deployment.
|
|
14
|
-
|
|
15
|
-
### Quick Deploy
|
|
16
|
-
|
|
17
|
-
1. **Push to GitHub**:
|
|
18
|
-
\`\`\`bash
|
|
19
|
-
git add .
|
|
20
|
-
git commit -m "Add Railway deployment"
|
|
21
|
-
git push origin main
|
|
22
|
-
\`\`\`
|
|
23
|
-
|
|
24
|
-
2. **Deploy to Railway**:
|
|
25
|
-
- Go to [railway.app](https://railway.app)
|
|
26
|
-
- Create new project → "Deploy from GitHub repo"
|
|
27
|
-
- Select your repository
|
|
28
|
-
- Click "Deploy Now"
|
|
29
|
-
|
|
30
|
-
3. **Generate Domain**:
|
|
31
|
-
- In Railway dashboard → Settings → Networking
|
|
32
|
-
- Click "Generate Domain"
|
|
33
|
-
- Your app will be live! 🎉
|
|
34
|
-
|
|
35
|
-
### Local Development
|
|
36
|
-
|
|
37
|
-
\`\`\`bash
|
|
38
|
-
# Development server
|
|
39
|
-
npm run start:local
|
|
40
|
-
|
|
41
|
-
# Production simulation
|
|
42
|
-
npm start
|
|
43
|
-
\`\`\`
|
|
44
|
-
|
|
45
|
-
### Environment Variables
|
|
46
|
-
|
|
47
|
-
Railway automatically provides:
|
|
48
|
-
- \`PORT\` - Server port (Railway assigns this)
|
|
49
|
-
- \`NODE_ENV=production\` - Production mode
|
|
50
|
-
|
|
51
|
-
Optional variables you can set:
|
|
52
|
-
- \`RUST_LOG=debug\` - Rust logging level
|
|
53
|
-
|
|
54
|
-
---
|
|
55
|
-
`;if(o(t)){let e=s(t,`utf-8`);e.includes(`Deploy to Railway`)||(c(t,e+n),r(`Updated README.md with Railway deployment instructions`))}else c(t,`# My rari App
|
|
56
|
-
|
|
57
|
-
A high-performance React Server Components application powered by rari.
|
|
58
|
-
${n}
|
|
59
|
-
## Getting Started
|
|
60
|
-
|
|
61
|
-
\`\`\`bash
|
|
62
|
-
npm install
|
|
63
|
-
npm start
|
|
64
|
-
\`\`\`
|
|
65
|
-
|
|
66
|
-
Visit [http://localhost:3000](http://localhost:3000) to see your app.
|
|
67
|
-
`),r(`Created README.md with Railway deployment instructions`)}function h(){console.warn(``),r(`Railway deployment setup complete! 🎉`),console.warn(``),e(`Next steps:`),console.warn(` 1. ${d(`cyan`,`git add .`)}`),console.warn(` 2. ${d(`cyan`,`git commit -m "Add Railway deployment"`)}`),console.warn(` 3. ${d(`cyan`,`git push origin main`)}`),console.warn(` 4. Go to ${d(`cyan`,`https://railway.app`)} and deploy from GitHub`),console.warn(``),e(`Your rari app will automatically:`),console.warn(` ✅ Detect Railway environment`),console.warn(` ✅ Bind to 0.0.0.0 (Railway requirement)`),console.warn(` ✅ Use Railway's PORT environment variable`),console.warn(` ✅ Run in production mode`),console.warn(` ✅ Download platform-specific rari binary`),console.warn(``),r(`Ready for deployment! 🚀`)}export{f as createRailwayDeployment};
|
package/dist/render-D0eMtn5L.mjs
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import{a as e,i as t,n,o as r,r as i,t as a}from"./utils-YdvPzSET-Cbo6Ofmz.mjs";import{existsSync as o,readFileSync as s,writeFileSync as c}from"node:fs";import{join as l}from"node:path";import u from"node:process";import{styleText as d}from"node:util";function f(){let n=u.cwd();e(`Creating Render deployment configuration...`),t(n,{providerName:`Render`,deployScript:`echo "Push to GitHub and connect to Render to deploy"`,startScript:`rari start`,dependency:i()}),p(n),a(n,`Render`,`.render`),m(n),h()}function p(e){n(e,`render.yaml`,`services:
|
|
2
|
-
- type: web
|
|
3
|
-
name: rari-app
|
|
4
|
-
runtime: node
|
|
5
|
-
env: node
|
|
6
|
-
plan: free
|
|
7
|
-
buildCommand: npm install
|
|
8
|
-
startCommand: npm start
|
|
9
|
-
healthCheckPath: /_rari/health
|
|
10
|
-
envVars:
|
|
11
|
-
- key: NODE_ENV
|
|
12
|
-
value: production
|
|
13
|
-
- key: RUST_LOG
|
|
14
|
-
value: info
|
|
15
|
-
`)}function m(e){let t=l(e,`README.md`),n=`
|
|
16
|
-
## 🎨 Deploy to Render
|
|
17
|
-
|
|
18
|
-
This rari application is configured for Render deployment.
|
|
19
|
-
|
|
20
|
-
### Quick Deploy
|
|
21
|
-
|
|
22
|
-
1. **Push to GitHub**:
|
|
23
|
-
\`\`\`bash
|
|
24
|
-
git add .
|
|
25
|
-
git commit -m "Add Render deployment"
|
|
26
|
-
git push origin main
|
|
27
|
-
\`\`\`
|
|
28
|
-
|
|
29
|
-
2. **Deploy to Render**:
|
|
30
|
-
- Go to [render.com](https://render.com)
|
|
31
|
-
- Create new "Web Service"
|
|
32
|
-
- Connect your GitHub repository
|
|
33
|
-
- Render will auto-detect Node.js and use the configuration from \`render.yaml\`
|
|
34
|
-
- Click "Create Web Service"
|
|
35
|
-
|
|
36
|
-
3. **Your app will be live!** 🎉
|
|
37
|
-
- Render provides a \`.onrender.com\` URL
|
|
38
|
-
- Optional: Add custom domain in Render dashboard
|
|
39
|
-
|
|
40
|
-
### Local Development
|
|
41
|
-
|
|
42
|
-
\`\`\`bash
|
|
43
|
-
# Development server
|
|
44
|
-
npm run start:local
|
|
45
|
-
|
|
46
|
-
# Production simulation
|
|
47
|
-
npm start
|
|
48
|
-
\`\`\`
|
|
49
|
-
|
|
50
|
-
### Environment Variables
|
|
51
|
-
|
|
52
|
-
Render automatically provides:
|
|
53
|
-
- \`PORT\` - Server port (Render assigns this)
|
|
54
|
-
- \`NODE_ENV=production\` - Production mode (from render.yaml)
|
|
55
|
-
- \`RUST_LOG=info\` - Rust logging level (from render.yaml)
|
|
56
|
-
|
|
57
|
-
Optional variables you can add in Render dashboard:
|
|
58
|
-
- \`RUST_LOG=debug\` - Enhanced logging
|
|
59
|
-
|
|
60
|
-
---
|
|
61
|
-
`;if(o(t)){let e=s(t,`utf-8`);e.includes(`Deploy to Render`)||(c(t,e+n),r(`Updated README.md with Render deployment instructions`))}else c(t,`# My rari App
|
|
62
|
-
|
|
63
|
-
A high-performance React Server Components application powered by rari.
|
|
64
|
-
${n}
|
|
65
|
-
## Getting Started
|
|
66
|
-
|
|
67
|
-
\`\`\`bash
|
|
68
|
-
npm install
|
|
69
|
-
npm start
|
|
70
|
-
\`\`\`
|
|
71
|
-
|
|
72
|
-
Visit [http://localhost:3000](http://localhost:3000) to see your app.
|
|
73
|
-
`),r(`Created README.md with Render deployment instructions`)}function h(){console.warn(``),r(`Render deployment setup complete! 🎉`),console.warn(``),e(`Next steps:`),console.warn(` 1. ${d(`cyan`,`git add .`)}`),console.warn(` 2. ${d(`cyan`,`git commit -m "Add Render deployment"`)}`),console.warn(` 3. ${d(`cyan`,`git push origin main`)}`),console.warn(` 4. Go to ${d(`cyan`,`https://render.com`)} and create a Web Service`),console.warn(``),e(`Your rari app will automatically:`),console.warn(` ✅ Detect Render environment`),console.warn(` ✅ Bind to 0.0.0.0 (Render requirement)`),console.warn(` ✅ Use Render's PORT environment variable`),console.warn(` ✅ Run in production mode`),console.warn(` ✅ Download platform-specific rari binary`),console.warn(``),r(`Ready for deployment! 🚀`)}export{f as createRenderDeployment};
|