rari 0.17.2 → 0.17.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +1 -1
- package/dist/{define-B_ozIapW.mjs → define-B5IGgRrU.mjs} +1 -1
- package/dist/{execute-CbhDMAQ3.mjs → execute-D_MjcLUi.mjs} +1 -1
- package/dist/{feed-NrJzjZyg.mjs → feed-0uhXs0oQ.mjs} +1 -1
- package/dist/get-client-component-DFAmn8Ey.mjs +1 -0
- package/dist/image/static.d.mts +1 -1
- package/dist/image.d.mts +1 -1
- package/dist/image.mjs +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/mdx/define.mjs +1 -1
- package/dist/mdx.mjs +1 -1
- package/dist/navigation-transition-store-dfNJmkIX.mjs +1 -0
- package/dist/og.mjs +1 -1
- package/dist/preload-modules-D_bnDKi8.mjs +2 -0
- package/dist/proxy/{runtime-executor.d.mts → executor.d.mts} +1 -1
- package/dist/proxy/{runtime-executor.mjs → executor.mjs} +2 -2
- package/dist/react-helpers-BKmKvCbj.mjs +1 -0
- package/dist/react-helpers-GTRYJwF2.d.mts +5 -0
- package/dist/{robots-BOPIkPcN.mjs → robots-D3a0R_Ni.mjs} +1 -1
- package/dist/route-cache-Cgh5HhiB.mjs +1 -0
- package/dist/router-6mdxF_x7.mjs +1 -0
- package/dist/router.d.mts +2 -1
- package/dist/router.mjs +1 -1
- package/dist/{rsc-vite-build-CSnu8C3P.mjs → rsc-vite-build-Btih-0Tu.mjs} +1 -1
- package/dist/runtime/AppRouterProvider.d.mts +13 -5
- package/dist/runtime/AppRouterProvider.mjs +1 -1
- package/dist/runtime/ClientRouter.d.mts +3 -3
- package/dist/runtime/ClientRouter.mjs +3 -3
- package/dist/runtime/ErrorBoundaryWrapper.d.mts +3 -4
- package/dist/runtime/ErrorBoundaryWrapper.mjs +1 -1
- package/dist/runtime/action-flight-refresh.mjs +1 -1
- package/dist/runtime/call-server.mjs +1 -1
- package/dist/runtime/entry-client.mjs +2 -2
- package/dist/runtime/merge-flight-refresh.d.mts +7 -7
- package/dist/runtime/merge-flight-refresh.mjs +1 -1
- package/dist/runtime/rsc-client-runtime.mjs +1 -1
- package/dist/{sitemap--bdIkWl5.mjs → sitemap-WDyhpXk3.mjs} +1 -1
- package/dist/{static-modules-DBL6iFbg.d.mts → static-modules-e8GEN_C9.d.mts} +4 -3
- package/dist/type-guards-BozK2q2n.mjs +1 -0
- package/dist/{types-CkJ_86mo.d.mts → types-Cp7dbLe7.d.mts} +10 -14
- package/dist/vite.d.mts +1 -1
- package/dist/vite.mjs +56 -56
- package/package.json +11 -19
- package/dist/get-client-component-s7qprTUa.mjs +0 -1
- package/dist/navigation-transition-store-CSKrbtbK.mjs +0 -1
- package/dist/preload-modules-Dv_GzGCm.mjs +0 -2
- package/dist/router-Cl4J7j1A.mjs +0 -1
- package/dist/runtime/flight-route-cache.d.mts +0 -27
- package/dist/runtime/flight-route-cache.mjs +0 -1
- package/dist/runtime/flight-router-state.d.mts +0 -11
- package/dist/runtime/flight-router-state.mjs +0 -1
- package/dist/serialize-router-state-uOGGpmBr.mjs +0 -1
- package/dist/type-guards-BJXKlA6x.mjs +0 -1
package/dist/cli.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{b as e,u as t,v as n,y as r}from"./type-guards-BozK2q2n.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 b}from"node:url";import{once as ee}from"node:events";import{parseArgs as x,styleText as S}from"node:util";function C(e){console.warn(`${S(`blue`,`info`)} ${e}`)}function w(e){console.warn(`${S(`green`,`✓`)} ${e}`)}function T(e){console.error(`${S(`red`,`✗`)} ${e}`)}function E(e){console.warn(`${S(`yellow`,`⚠`)} ${e}`)}const te=[`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 te){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 ne(e){return m(e)===`client`?h(e):e}function F(e){let t=P(e),n=[_(ne(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 I(e,t){let r=h(e),i=h(r),a=M(t,A(t)),o=n(u(e,`utf8`))?.outDir;return typeof o==`string`&&o!==``?g(o)?o:v(a,o):_(i,`client`)}let L=null;function R(e){let t=l(e)?new Set(z(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`:re(e)}function z(e){try{return d(e)}catch{return[]}}function re(e){try{let t=v(e,`package.json`);if(!l(t))return null;let i=n(u(t,`utf-8`));return i?r(i):null}catch{}return null}function ie(t){try{let r=v(t,`package.json`);if(!l(r))return null;let i=n(u(r,`utf-8`));return i?e(i):null}catch{}return null}function ae(e){let t=e,n=null,r=null;for(;t!==v(t,`..`)&&(n??=R(t),r??=ie(t),!(n&&r));)t=v(t,`..`);return{cwd:e,packageManager:n??`npm`,viteBin:r??`vite`}}function B(){let e=y.cwd();return L?.cwd===e||(L=ae(e)),L}function oe(){return B().packageManager}function V(){let e=B().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 H(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 U(e,t,n={}){let r=y.platform===`win32`;if(e===`npx`){let e=V();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 W(e,t,n={}){let r=H(e);if(r!=null&&r!==``){let e=y.platform===`win32`&&r.endsWith(`.cmd`);return c(r,t,e?{...n,shell:!0}:n)}return U(`npx`,[e,...t],n)}async function G(e,t={}){try{let[t]=await ee(e,`close`);return t}catch(e){if(t.tolerateErrors)return E(K(e)),1;throw e}}function K(e){if(t(e))return e.message;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function se(){let e=v(y.cwd(),`.env`);l(e)&&y.loadEnvFile(e)}function ce(e){let{values:t,positionals:n}=x({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 q(){return y.env.RAILWAY_ENVIRONMENT!=null&&y.env.RAILWAY_ENVIRONMENT!==``||y.env.RAILWAY_PROJECT_ID!=null&&y.env.RAILWAY_PROJECT_ID!==``||y.env.RAILWAY_SERVICE_ID!=null&&y.env.RAILWAY_SERVICE_ID!==``}function J(){return y.env.RENDER!=null&&y.env.RENDER!==``||y.env.RENDER_SERVICE_ID!=null&&y.env.RENDER_SERVICE_ID!==``||y.env.RENDER_SERVICE_NAME!=null&&y.env.RENDER_SERVICE_NAME!==``}function Y(){return q()||J()}function X(){return q()?`Railway`:J()?`Render`:`local`}function Z(){return{port:y.env.PORT!=null&&y.env.PORT!==``?y.env.PORT:y.env.RSC_PORT!=null&&y.env.RSC_PORT!==``?y.env.RSC_PORT:`3000`,mode:y.env.NODE_ENV!=null&&y.env.NODE_ENV!==``?y.env.NODE_ENV:`production`,host:Y()?`0.0.0.0`:`127.0.0.1`}}async function Q(){$();let e=B().viteBin;C(`Type checking...`);let t=await G(W(`tsc`,[],{stdio:`inherit`,cwd:y.cwd()}));if(t===0)w(`Type check passed`);else throw T(`Type check failed with code ${t}`),Error(`Type check failed with code ${t}`);C(`Building for production...`);let n=await G(W(e,[`build`],{stdio:`inherit`,cwd:y.cwd()}));if(n===0)w(`Build complete`);else throw T(`Build failed with code ${n}`),Error(`Build failed with code ${n}`);await le()}async function le(){let e=y.cwd(),{viteBin:t}=B(),r=N(e,t),i=F(r);if(i==null)return;let a=I(i,r),s=h(i),d=`assets`;try{let e=n(u(i,`utf-8`));e&&typeof e.assetsDir==`string`&&e.assetsDir.length>0&&(d=e.assetsDir.replaceAll(/^\/+|\/+$/g,``))}catch{}let f=v(r,`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 G(c(e,[`optimize-images`,`--config`,i],{stdio:`inherit`,cwd:r,shell:!1}),{tolerateErrors:!0});t!==0&&E(`Image pre-optimization exited with code ${t}`)}catch(e){E(`Could not pre-optimize images: ${K(e)}`)}}async function ue(){let e=B().viteBin,t=v(y.cwd(),`dist`);if(!l(t)){C(`First run detected - building project...`);let t=await G(W(e,[`build`,`--mode`,`development`],{stdio:`inherit`,cwd:y.cwd()}));if(t===0)w(`Initial build complete`);else throw T(`Build failed with code ${t}`),Error(`Build failed with code ${t}`)}C(`Starting Vite${e===`vp`?`+`:``} dev server...`);let n=W(e,[`dev`],{stdio:`inherit`,cwd:y.cwd()}),r=()=>{C(`Shutting down dev server...`),n.kill(`SIGTERM`)};return y.on(`SIGINT`,r),y.on(`SIGTERM`,r),n.on(`error`,e=>{T(`Failed to start Vite: ${e.message}`),y.exit(1)}),n.on(`exit`,e=>{e!==0&&e!==null&&(T(`Vite exited with code ${e}`),y.exit(e))}),new Promise(()=>{})}async function de(){let e;try{e=o()}catch{T(`Failed to obtain rari binary`),T(s()),y.exit(1)}let{port:t,mode:n,host:r}=Z();if(Y()){let i=X();C(`${i} environment detected`),C(`Starting rari server for ${i} deployment...`),C(`Mode: ${n}, Host: ${r}, Port: ${t}`),C(`using binary: ${e}`)}let i=[`--mode`,n,`--port`,t,`--host`,r],a=y.platform!==`win32`&&y.stdin.isTTY,l=c(e,i,{stdio:`inherit`,cwd:y.cwd(),detached:a,env:{...y.env,RUST_LOG:y.env.RUST_LOG!=null&&y.env.RUST_LOG!==``?y.env.RUST_LOG:`error`}}),u=!1,d,f=()=>{u||(u=!0,C(`shutting down...`),l.kill(`SIGTERM`),d=setTimeout(()=>{l.kill(`SIGKILL`),y.exit(1)},5e3),d.unref())};return y.on(`SIGINT`,f),y.on(`SIGTERM`,f),y.on(`exit`,()=>{try{l.kill(`SIGKILL`)}catch{}}),l.on(`error`,e=>{T(`Failed to start rari server: ${e.message}`),e.message.includes(`ENOENT`)&&T(`Binary not found. Please ensure rari is properly installed.`),y.exit(1)}),l.on(`exit`,(e,t)=>{d&&clearTimeout(d),t!=null&&t!==``?(u&&(C(`server stopped by signal ${t}`),y.exit(0)),T(`server stopped unexpectedly by signal ${t}`),y.exit(1)):e===0?(w(`server stopped successfully`),y.exit(0)):(T(`server exited with code ${e}`),y.exit(e!=null&&e!==0?e:1))}),new Promise(()=>{})}async function fe(){C(`Setting up Railway deployment...`),Y()&&(T(`Already running in ${X()} environment. Use "rari start" instead.`),y.exit(1));let{createRailwayDeployment:e}=await import(`./railway-CE3nqaKt.mjs`);e()}async function pe(){C(`Setting up Render deployment...`),Y()&&(T(`Already running in ${X()} environment. Use "rari start" instead.`),y.exit(1));let{createRenderDeployment:e}=await import(`./render-D0eMtn5L.mjs`);e()}function $(){let e=v(y.cwd(),`dist`);l(e)?(C(`Cleaning dist folder...`),p(e,{recursive:!0,force:!0}),w(`Cleaned dist folder`)):C(`No dist folder to clean`)}function me(){console.warn(`${S(`bold`,`rari CLI`)}
|
|
2
2
|
|
|
3
3
|
${S(`bold`,`Usage:`)}
|
|
4
4
|
${S(`cyan`,`rari dev`)} Start the development server with Vite
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{h as e}from"./type-guards-BozK2q2n.mjs";import{s as t}from"./regex-constants-DzXwNGh2.mjs";import{t as n}from"./names-CLmM0CPi.mjs";import{registerClientReference as r}from"./runtime/rsc-references.mjs";import{r as i}from"./rari-global-5vGzhToD.mjs";function a(e,n,a=`default`){let o=`${n}#${a}`;if(typeof globalThis<`u`){let r=i(),s=n.replace(t,``).split(`/`).pop(),c=s!=null&&s!==``?s:a,l={id:a==="default"?c:a,path:n,type:`client`,component:e,registered:!0};r[o]=l,r[c]=l,r[n]=l}function s(){throw Error(`Attempted to call ${a}() from the server but ${a} is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.`)}return r(s,n,a)}function o(e){let t={};for(let[n,{component:r,id:i,exportName:o=`default`}]of Object.entries(e))t[n]=a(r,i,o);return t}function s(t){return e(t)&&typeof t.id==`string`&&`component`in t}function c(e){return Array.isArray(e)?[...e]:Object.entries(e).map(([e,t])=>{if(s(t))return{component:t.component,id:t.id,exportName:t.exportName,name:e,client:t.client??!0};throw Error(`[rari/mdx] Component "${e}" is missing module metadata. Pass components to defineMdxComponents({ ... }) in a file processed by the rari vite plugin.`)})}function l(e){let t=c(e);return e=>{let r={},i={},a=new Set(n(e));for(let e of t)if(a.has(e.name)){if(e.client===!1){r[e.name]=e.component;continue}i[e.name]={component:e.component,id:e.id,exportName:e.exportName}}return{...r,...o(i)}}}export{l as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,
|
|
1
|
+
import{a as e,h as t}from"./type-guards-BozK2q2n.mjs";import{s as n,t as r,u as i}from"./rsc-vite-build-Btih-0Tu.mjs";import{promises as a}from"node:fs";import o from"node:path";import{pathToFileURL as s}from"node:url";import{randomUUID as c}from"node:crypto";const l=[`.ts`,`.tsx`,`.js`,`.jsx`,`.mjs`];async function u(t){let{appDir:n,staticFileName:r,dynamicBaseName:i,extensions:s=l,rethrowNonEnoent:c=!1}=t,u=o.join(n,r);try{return await a.access(u),{type:`static`,path:u}}catch(t){if(c&&e(t)!==`ENOENT`)throw t}for(let t of s){let r=o.join(n,`${i}${t}`);try{return await a.access(r),{type:`dynamic`,path:r}}catch(t){if(c&&e(t)!==`ENOENT`)throw t}}return null}function d(e,t){switch(e){case`ts`:return`ts`;case`tsx`:return`tsx`;case`js`:case`mjs`:return`js`;case`jsx`:return`jsx`;case`json`:if(t===`sitemap`)return`json`}throw Error(`Unsupported ${t} file extension: ".${e}". Allowed extensions are: ${t===`sitemap`?`.ts, .tsx, .js, .jsx, .mjs, .json`:`.ts, .tsx, .js, .jsx, .mjs`}`)}function f(e){let{name:t,virtualId:r,sourcePath:s,sourceCode:c,aliases:l={},projectRoot:u,kind:f}=e;return{name:t,resolveId(e,t){if(e===r)return e;if(Object.keys(l).length>0){let t=n(e,l,u);if(t!=null&&t!==``){let e=i(t);return e!=null&&e!==``?e:t}}if(e.startsWith(`.`)){let n=t==null||t===``||t.startsWith(`\0`)?s:t,r=o.resolve(o.dirname(n),e),a=i(r);return a!=null&&a!==``?a:r}return null},async load(e){if(e===r){let e=o.extname(s).slice(1);return{code:c,moduleType:d(e,f)}}if(e&&!e.startsWith(`\0`))try{return{code:await a.readFile(e,`utf-8`),moduleType:d(o.extname(e).slice(1),f)}}catch{return null}return null}}}function p(e){return e===`rari`||e.startsWith(`rari/`)}async function m(e){let{virtualId:t,sourcePath:n,sourceCode:i,aliases:l={},projectRoot:u,kind:d,pluginName:m,label:h}=e,g=await r({root:u,virtualId:t,external:p,plugins:[f({name:m,virtualId:t,sourcePath:n,sourceCode:i,aliases:l,projectRoot:u,kind:d})]});if(g==null)throw Error(`Failed to build ${h} module`);let _=o.join(u,`node_modules`,`.cache`,`rari-metadata`);await a.mkdir(_,{recursive:!0});let v=o.join(_,`${h}-${c()}.mjs`);await using y=new AsyncDisposableStack;return y.defer(async()=>{await a.rm(v,{force:!0})}),await a.writeFile(v,g.code,`utf8`),await import(s(v).href)}function h(e,n){if(!t(e))throw Error(`${n} file must export a default export (either an object or a function)`);let r=e.default;if(r==null)throw Error(`${n} file must export a default export (either an object or a function)`);return r}function g(e){return o.resolve(e,`..`,`..`)}export{u as i,g as n,h as r,m as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{h as e}from"./type-guards-BozK2q2n.mjs";import{t}from"./xml-DPsk9WTz.mjs";import{i as n,n as r,r as i,t as a}from"./execute-D_MjcLUi.mjs";import{promises as o}from"node:fs";import s from"node:path";function c(t){return e(t)&&typeof t.title==`string`&&typeof t.description==`string`&&typeof t.link==`string`&&Array.isArray(t.items)}async function l(e){if(typeof e==`function`){let t=e(),n=t instanceof Promise?await t:t;if(!c(n))throw Error(`Feed default export must resolve to a feed object`);return n}if(!c(e))throw Error(`Feed default export must be a feed object`);return e}function u(e){return(typeof e==`string`?new Date(e):e).toUTCString()}function d(e){return e==null||e===``?``:typeof e==`string`?` <dc:creator>${t(e)}</dc:creator>`:e.email!=null&&e.email!==``?` <author>${t(`${e.email} (${e.name})`)}</author>`:` <dc:creator>${t(e.name)}</dc:creator>`}function f(e){let n=[` <item>`,` <title>${t(e.title)}</title>`,` <link>${t(e.url)}</link>`];return e.description!=null&&e.description!==``&&n.push(` <description>${t(e.description)}</description>`),n.push(...p(e),...m(e),...h(e)),n.push(` </item>`),n.join(`
|
|
2
2
|
`)}function p(e){let t=[];e.content!=null&&e.content!==``&&t.push(` <content:encoded><![CDATA[${e.content.replace(/\]\]>/g,`]]]]><![CDATA[>`)}]]></content:encoded>`);let n=d(e.author);return n&&t.push(n),t}function m(e){let n=[];if(e.pubDate!=null&&n.push(` <pubDate>${u(e.pubDate)}</pubDate>`),n.push(` <guid isPermaLink="${e.guid!=null&&e.guid!==``?`false`:`true`}">${t(e.guid!=null&&e.guid!==``?e.guid:e.url)}</guid>`),e.categories)for(let r of e.categories)n.push(` <category>${t(r)}</category>`);return n}function h(e){if(!e.enclosure)return[];let n=[`url="${t(e.enclosure.url)}"`];return e.enclosure.length!==void 0&&n.push(`length="${e.enclosure.length}"`),n.push(`type="${t(e.enclosure.type!=null&&e.enclosure.type!==``?e.enclosure.type:`application/octet-stream`)}"`),[` <enclosure ${n.join(` `)} />`]}function g(e){let n=e.items.some(e=>e.content!=null&&e.content!==``),r=e.items.some(e=>{let t=e.author;return t==null||t===``?!1:typeof t==`string`||t.email==null||t.email===``}),i=[];n&&i.push(`xmlns:content="http://purl.org/rss/1.0/modules/content/"`),r&&i.push(`xmlns:dc="http://purl.org/dc/elements/1.1/"`),i.push(`xmlns:atom="http://www.w3.org/2005/Atom"`);let a=[`<?xml version="1.0" encoding="UTF-8"?>`,`<rss version="2.0"${i.length>0?` ${i.join(` `)}`:``}>`,` <channel>`,` <title>${t(e.title)}</title>`,` <link>${t(e.link)}</link>`,` <description>${t(e.description)}</description>`,` <atom:link href="${t(`${e.link.replace(/\/+$/,``)}/feed.xml`)}" rel="self" type="application/rss+xml" />`];e.language!=null&&e.language!==``&&a.push(` <language>${t(e.language)}</language>`),e.copyright!=null&&e.copyright!==``&&a.push(` <copyright>${t(e.copyright)}</copyright>`),e.lastBuildDate!=null&&a.push(` <lastBuildDate>${u(e.lastBuildDate)}</lastBuildDate>`),e.ttl!==void 0&&a.push(` <ttl>${e.ttl}</ttl>`),e.image&&(a.push(` <image>`),a.push(` <url>${t(e.image.url)}</url>`),a.push(` <title>${t(e.image.title)}</title>`),a.push(` <link>${t(e.image.link)}</link>`),e.image.width!==void 0&&a.push(` <width>${e.image.width}</width>`),e.image.height!==void 0&&a.push(` <height>${e.image.height}</height>`),a.push(` </image>`));for(let t of e.items)a.push(f(t));return a.push(` </channel>`),a.push(`</rss>`),a.join(`
|
|
3
3
|
`)}
|
|
4
4
|
/* v8 ignore start - file system operations, better tested in integration/e2e */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{h as e,l as t,p as n,x as r}from"./type-guards-BozK2q2n.mjs";import{o as i}from"./path-CTEC1xmy.mjs";import{n as a,r as o,t as s}from"./rari-global-5vGzhToD.mjs";import{createElement as c}from"react";function l(e){return e.startsWith(`./`)?[e,e.slice(2)]:[e,`./${e}`]}function u(e){let t=i(e),n=/* @__PURE__ */ new Set([t]),r=t.indexOf(`/src/`);r!==-1&&n.add(t.slice(r+1));let a=t.indexOf(`/components/`);return a!==-1&&n.add(t.slice(a+1)),[...n]}function d(e,t){if(t!==void 0)return t;let n=e.exportName;if(n!=null&&n!==``)return n}function f(e,t){let n=i(e),r=i(t);return!!(n===r||r.includes(`/`)&&n.endsWith(`/${r}`)||n.includes(`/`)&&r.endsWith(`/${n}`))}function p(e,t,n){for(let r of u(e))for(let e of l(r)){let r=Object.values(n).find(t=>typeof t.path!=`string`||t.path===``?!1:f(t.path,e));if(r)return{info:r,exportName:d(r,t)}}return null}function m(e){return e.loading=!0,e.loadPromise=e.loader().then(t=>(e.component=t,e.registered=!0,e.loading=!1,t)).catch(t=>{throw console.error(`[rari] Failed to load component ${e.id}:`,t),e.loading=!1,e.loadError=t,e.loadPromise=void 0,t}),e.loadPromise}async function h(e,t){return e.component==null?e.loadPromise?(await e.loadPromise,g(e,t)):e.loader?await m(e)==null?null:g(e,t):null:g(e,t)}function g(t,r){let i=t.component;if(i==null)return null;if(n(i))return i;if(!e(i))return null;if(r==null||r===``||r==="default")return i.default??i;if(r in i)return i[r];let a=i.default;return e(a)&&r in a?a[r]:null}function _(e){let t=i(e);return t===e?[t]:[t,e]}function v(e){let t=o(),n=a(),r=s(),c=i(e),l=y(e,t);if(l!=null)return l;let u=c.indexOf(`#`),d=u===-1?c:c.slice(0,u),f=u===-1?void 0:c.slice(u+1);return b(e,f,t)??x(e,d,f,t,n,r)??p(d,f,t)}function y(e,t){for(let n of _(e)){if(!(n in t))continue;let e=t[n],r=n.indexOf(`#`);return{info:e,exportName:d(e,r===-1?void 0:n.slice(r+1))}}return null}function b(e,t,n){for(let r of _(e)){let e=r.indexOf(`#`),i=e===-1?r:r.slice(0,e);if(i in n)return{info:n[i],exportName:d(n[i],t)}}return null}function x(e,t,n,r,a,o){let s=i(e)===e?[t]:[t,e.includes(`#`)?e.slice(0,e.indexOf(`#`)):e];for(let e of s){let t=S(e,n,r,a);if(t!=null)return t;let i=C(e,n,r,o);if(i!=null)return i}return null}function S(e,t,n,r){for(let i of l(e)){if(!(i in r))continue;let e=r[i];if(e!==``&&e in n)return{info:n[e],exportName:d(n[e],t)}}return null}function C(e,t,n,r){if(!(e in r))return null;let i=r[e];return i===``||!(i in n)?null:{info:n[i],exportName:d(n[i],t)}}function w(e){return e.component!=null||e.loader==null?e.loadPromise:e.loadError==null?e.loadPromise?e.loadPromise:m(e):Promise.reject(r(e.loadError))}function T(t,r,i){let a=d(t,i),o=g({...t,component:r},a);if(o==null)return e(r)&&(`default`in r||`__esModule`in r)?r:n(r)?{default:r,[a!=null&&a!==``?a:`default`]:r,__esModule:!0}:r;let s=a!=null&&a!==``?a:`default`;return{...e(r)?r:{},default:o,[s]:o,__esModule:!0}}function E(e,n,i,a){let o=d(e,a),s=o!=null&&o!==``?o:`default`,l=a=>{if(e.loadError!=null)throw r(e.loadError);if(e.component!=null){let r=g(e,o);if(r==null)throw Error(`[rari] Lazy component "${n}" loaded but export "${s}" is missing`);if(!t(r))throw Error(`[rari] Lazy component "${n}" export "${s}" is not a component`);return c(r,a)}throw i};return l.displayName=`Lazy(${e.displayName??e.exportName??n})`,{default:l,[s]:l,__esModule:!0}}function D(e){let t=v(e);if(!t)return import.meta.env.DEV&&console.warn(`[rari] __rari_rsc_require__: component "${e}" not found in registry`),{};let{info:n,exportName:r}=t;if(n.component!=null)return T(n,n.component,r);if(n.loader){if(n.loadError!=null)return E(n,e,Promise.resolve(),r);let t=w(n);if(t)return E(n,e,t,r)}return{}}async function O(e){let t=v(e);return t?h(t.info,t.exportName):null}function k(){if(typeof window>`u`)return;let e=e=>{let t=o(),n=i(e);return e in t?t[e]:n in t?t[n]:Object.values(t).find(t=>t.path===e||t.path===n)};Reflect.set(globalThis,`__rari_get_script_filename__`,t=>{let n=e(t)?.path??i(t),r=i(n);if(r.startsWith(`http://`)||r.startsWith(`https://`))return r;let a=r.indexOf(`/src/`);return a===-1?r.startsWith(`src/`)?`/${r}`:r.startsWith(`/`)?r:`/${r}`:r.slice(a)}),Reflect.set(globalThis,`__rari_chunk_load__`,async t=>{let n=e(t);if(n&&n.component==null&&n.loader!=null){let e=w(n);if(e)return e.then(()=>void 0)}return n?.loadPromise==null?Promise.resolve():n.loadPromise.then(()=>void 0)})}export{k as n,D as r,O as t};
|
package/dist/image/static.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import "../static-modules-
|
|
1
|
+
import "../static-modules-e8GEN_C9.mjs";
|
package/dist/image.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as ImageProps, r as StaticImageData, t as Image$1 } from "./static-modules-
|
|
1
|
+
import { n as ImageProps, r as StaticImageData, t as Image$1 } from "./static-modules-e8GEN_C9.mjs";
|
|
2
2
|
//#region src/image/constants.d.ts
|
|
3
3
|
type ImageFormat = 'avif' | 'webp' | 'jpeg';
|
|
4
4
|
export declare const DEFAULT_DEVICE_SIZES: number[];
|
package/dist/image.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"./constants-CRK2JRKf.mjs";import{
|
|
1
|
+
import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"./constants-CRK2JRKf.mjs";import{c as s}from"react/compiler-runtime";import{useEffect as c,useLayoutEffect as l,useRef as u,useState as d}from"react";import{jsx as f,jsxs as p}from"react/jsx-runtime";const m=Math.max(...i);function h(e){return Math.min(Math.max(e,1),m)}function g(e){let{fill:t,width:n,intrinsicWidth:r}=e;if(t)return{defaultWidth:m,widths:i};let a=n!=null&&n!==0?n:r!=null&&r!==0?r:void 0;if(a==null)return{defaultWidth:1920,widths:i};let o=h(a);return{defaultWidth:o,widths:[o]}}function _(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 v(e,t,n,r,i){return e==null?_(t,n,r,i):e({src:t,width:n,quality:r})}function y(e,t,n=!1){return e!=null&&e!==``?e:t||n?`100vw`:void 0}function b(e){let{link:n,finalSrc:r,defaultWidth:a,quality:o,sizes:s,loader:c,unoptimized:l,fill:u,shouldUseSrcSet:d}=e,f=d&&!l,p=y(s,f,u),m=c==null&&t.length===1&&t[0]===`avif`,h=m?`avif`:void 0;if(l){n.setAttribute(`href`,c==null?r:c({src:r,width:a,quality:o}));return}if(f){let e=i.map(e=>`${v(c,r,e,o,h)} ${e}w`).join(`, `);n.setAttribute(`href`,v(c,r,a,o,h)),n.setAttribute(`imagesrcset`,e),p!=null&&n.setAttribute(`imagesizes`,p),m&&n.setAttribute(`type`,`image/avif`);return}n.setAttribute(`href`,v(c,r,a,o)),p!=null&&n.setAttribute(`imagesizes`,p)}function x(e,t,n){if(e!=null&&e!==0)return e;if(!t&&n!=null&&n!==0)return n}function S(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?v(s,c,16,25,`jpeg`):void 0;return{imgSrc:c,imgWidth:x(n,i,l),imgHeight:x(r,i,u),inlineBlurDataURL:f,optimizerBlurUrl:p}}function C(e){return{position:`absolute`,inset:0,width:`100%`,height:`100%`,objectFit:e?.objectFit??`cover`}}function w(e){return{backgroundImage:`url("${e}")`,backgroundSize:`cover`,backgroundPosition:`center`,filter:`blur(20px)`,transition:`filter 0.3s ease-out`}}function ee(e){return e.complete&&e.naturalWidth>0}function te(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?C(t):null,...o?w(i):null,...s?{filter:`none`,transition:`filter 0.3s ease-out`}:null}}function ne(e,t,n,r,i){return n.map(n=>`${v(e,t,n,r,i)} ${n}w`).join(`, `)}function re(e){let{unoptimized:t,loader:n,finalSrc:r,width:i,quality:a}=e;return t?n==null?r:n({src:r,width:i,quality:a}):v(n,r,i,a)}function ie(e){if(!e.enabled)return;let t=document.createElement(`link`);return t.rel=`preload`,t.as=`image`,b({link:t,finalSrc:e.finalSrc,defaultWidth:e.defaultWidth,quality:e.quality,sizes:e.sizes,loader:e.loader,unoptimized:e.unoptimized,fill:e.fill,shouldUseSrcSet:e.shouldUseSrcSet}),document.head.appendChild(t),()=>{t.parentNode===document.head&&document.head.removeChild(t)}}function T(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 ae(e){let{imgElement:n,loader:r,finalSrc:i,widths:a,quality:o,sizes:s}=e;return/* @__PURE__ */ p(`picture`,{children:[t.includes(`avif`)&&/* @__PURE__ */ f(`source`,{type:`image/avif`,srcSet:ne(r,i,a,o,`avif`),sizes:s}),t.includes(`webp`)&&/* @__PURE__ */ f(`source`,{type:`image/webp`,srcSet:ne(r,i,a,o,`webp`),sizes:s}),n]})}function oe(e){let t=s(19),{finalSrc:n,shouldEagerBlur:r,inlineBlurDataURL:i,optimizerBlurUrl:a,placeholder:o}=e,[f,p]=d(!1),[m,h]=d(n),[g,_]=d(r),v=u(null);m!==n&&(h(n),_(r),p(!1));let y;t[0]===o?y=t[1]:(y=()=>{if(o!==`blur`)return;let e=v.current;e!=null&&ee(e)&&p(!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],l(y,b);let x;t[5]!==g||t[6]!==a||t[7]!==o||t[8]!==r?(x=()=>T(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],c(x,S);let C=i??(r||g?a:void 0),w;return t[16]!==f||t[17]!==C?(w={imgRef:v,blurComplete:f,setBlurComplete:p,activeBlurUrl:C},t[16]=f,t[17]=C,t[18]=w):w=t[18],w}function E(e){let t=s(83),{src:n,alt:r,width:i,height:a,quality:o,preload:l,loading:p,placeholder:m,blurDataURL:h,fill:_,sizes:v,style:b,className:x,onLoad:C,onError:w,unoptimized:ee,loader:T,overrideSrc:E,decoding:se}=e,D=o===void 0?75:o,O=l!==void 0&&l,ce=p===void 0?`lazy`:p,k=m===void 0?`empty`:m,A=_!==void 0&&_,j=ee!==void 0&&ee,M;t[0]!==h||t[1]!==A||t[2]!==a||t[3]!==T||t[4]!==k||t[5]!==n||t[6]!==i?(M=S({src:n,width:i,height:a,fill:A,placeholder:k,blurDataURL:h,loader:T}),t[0]=h,t[1]=A,t[2]=a,t[3]=T,t[4]=k,t[5]=n,t[6]=i,t[7]=M):M=t[7];let{imgSrc:le,imgWidth:ue,imgHeight:de,inlineBlurDataURL:fe,optimizerBlurUrl:pe}=M,N=E!=null&&E!==``?E:le,me=se??(O?`sync`:`async`),he=typeof n==`string`?void 0:n.width,P;t[8]!==A||t[9]!==he||t[10]!==i?(P=g({fill:A,width:i,intrinsicWidth:he}),t[8]=A,t[9]=he,t[10]=i,t[11]=P):P=t[11];let F=P,I=F.widths.length>1||F.widths[0]!==F.defaultWidth,ge=O||ce===`eager`,[_e,ve]=d(!1),ye=u(C),L;t[12]!==N||t[13]!==fe||t[14]!==pe||t[15]!==k||t[16]!==ge?(L={finalSrc:N,shouldEagerBlur:ge,inlineBlurDataURL:fe,optimizerBlurUrl:pe,placeholder:k},t[12]=N,t[13]=fe,t[14]=pe,t[15]=k,t[16]=ge,t[17]=L):L=t[17];let{imgRef:be,blurComplete:xe,setBlurComplete:R,activeBlurUrl:Se}=oe(L),z,B;t[18]===C?(z=t[19],B=t[20]):(z=()=>{ye.current=C},B=[C],t[18]=C,t[19]=z,t[20]=B),c(z,B);let V;t[21]!==k||t[22]!==R?(V=e=>{let t=e.currentTarget;(t.currentSrc===``?t.src:t.currentSrc)!==``&&t.complete&&(k===`blur`&&R(!0),ye.current&&ye.current(e))},t[21]=k,t[22]=R,t[23]=V):V=t[23];let Ce=V,H;t[24]!==w||t[25]!==k||t[26]!==R?(H=e=>{ve(!0),k===`blur`&&R(!0),w&&w(e)},t[24]=w,t[25]=k,t[26]=R,t[27]=H):H=t[27];let we=H,U,W;t[28]!==A||t[29]!==N||t[30]!==T||t[31]!==O||t[32]!==D||t[33]!==I||t[34]!==F.defaultWidth||t[35]!==v||t[36]!==j?(U=()=>ie({enabled:O,finalSrc:N,defaultWidth:F.defaultWidth,quality:D,sizes:v,loader:T,unoptimized:j,fill:A,shouldUseSrcSet:I}),W=[O,N,F.defaultWidth,D,v,T,j,A,I],t[28]=A,t[29]=N,t[30]=T,t[31]=O,t[32]=D,t[33]=I,t[34]=F.defaultWidth,t[35]=v,t[36]=j,t[37]=U,t[38]=W):(U=t[37],W=t[38]),c(U,W);let G;t[39]!==Se||t[40]!==xe||t[41]!==A||t[42]!==k||t[43]!==b?(G=te({style:b,fill:A,placeholder:k,imgBlurDataURL:Se,blurComplete:xe}),t[39]=Se,t[40]=xe,t[41]=A,t[42]=k,t[43]=b,t[44]=G):G=t[44];let Te=G,K;t[45]!==N||t[46]!==T||t[47]!==D||t[48]!==F.defaultWidth||t[49]!==j?(K=re({unoptimized:j,loader:T,finalSrc:N,width:F.defaultWidth,quality:D}),t[45]=N,t[46]=T,t[47]=D,t[48]=F.defaultWidth,t[49]=j,t[50]=K):K=t[50];let Ee=K,q;t[51]!==I||t[52]!==v?(q=y(v,I),t[51]=I,t[52]=v,t[53]=q):q=t[53];let J=q,Y;t[54]!==N||t[55]!==T||t[56]!==D||t[57]!==I||t[58]!==F.widths||t[59]!==j?(Y=!j&&I?ne(T,N,F.widths,D):void 0,t[54]=N,t[55]=T,t[56]=D,t[57]=I,t[58]=F.widths,t[59]=j,t[60]=Y):Y=t[60];let X=Y,De=X==null?void 0:J,Oe=_e?r:``,ke=A?void 0:ue,Ae=A?void 0:de,je=O?`eager`:ce,Me=O?`high`:`auto`,Ne=k===`blur`||C!=null?Ce:void 0,Z;t[61]!==x||t[62]!==we||t[63]!==me||t[64]!==be||t[65]!==Te||t[66]!==Ee||t[67]!==X||t[68]!==De||t[69]!==Oe||t[70]!==ke||t[71]!==Ae||t[72]!==je||t[73]!==Me||t[74]!==Ne?(Z=/* @__PURE__ */ f(`img`,{ref:be,src:Ee,srcSet:X,sizes:De,alt:Oe,width:ke,height:Ae,loading:je,fetchPriority:Me,decoding:me,onLoad:Ne,onError:we,style:Te,className:x}),t[61]=x,t[62]=we,t[63]=me,t[64]=be,t[65]=Te,t[66]=Ee,t[67]=X,t[68]=De,t[69]=Oe,t[70]=ke,t[71]=Ae,t[72]=je,t[73]=Me,t[74]=Ne,t[75]=Z):Z=t[75];let Q=Z;if(j||!I)return Q;let $;return t[76]!==N||t[77]!==Q||t[78]!==T||t[79]!==D||t[80]!==J||t[81]!==F.widths?($=ae({imgElement:Q,loader:T,finalSrc:N,widths:F.widths,quality:D,sizes:J}),t[76]=N,t[77]=Q,t[78]=T,t[79]=D,t[80]=J,t[81]=F.widths,t[82]=$):$=t[82],$}const se=typeof window>`u`,D=E;se&&(D.$$typeof=Symbol.for(`react.client.reference`),D.$$id=`rari/image#Image`);export{o as BLUR_PLACEHOLDER_QUALITY,n as BLUR_PLACEHOLDER_WIDTH,i as DEFAULT_DEVICE_SIZES,t as DEFAULT_FORMATS,e as DEFAULT_IMAGE_SIZES,r as DEFAULT_MINIMUM_CACHE_TTL,a as DEFAULT_QUALITY_LEVELS,D as Image};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as RouteContext, E as ApiRouteHandlers, O as RouteHandler, T as ApiResponse, _ as LayoutProps, a as Sitemap, c as SitemapVideo, i as RobotsRule, n as FeedEntry, o as SitemapEntry, p as ErrorProps, r as Robots, s as SitemapImage, t as Feed, x as PageProps, y as Metadata } from "./types-
|
|
1
|
+
import { D as RouteContext, E as ApiRouteHandlers, O as RouteHandler, T as ApiResponse, _ as LayoutProps, a as Sitemap, c as SitemapVideo, i as RobotsRule, n as FeedEntry, o as SitemapEntry, p as ErrorProps, r as Robots, s as SitemapImage, t as Feed, x as PageProps, y as Metadata } from "./types-Cp7dbLe7.mjs";
|
|
2
2
|
import { c as RariURL, d as RariResponse, n as ProxyConfig, r as ProxyFunction, s as RariFetchEvent } from "./types-DAdRjhuk.mjs";
|
|
3
3
|
import { RariRequest } from "./proxy/RariRequest.mjs";
|
|
4
4
|
//#region src/navigation/not-found.d.ts
|
package/dist/mdx/define.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"../define-
|
|
1
|
+
import{t as e}from"../define-B5IGgRrU.mjs";export{e as defineMdxComponents};
|
package/dist/mdx.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./names-CLmM0CPi.mjs";import{t}from"./define-
|
|
1
|
+
import{t as e}from"./names-CLmM0CPi.mjs";import{t}from"./define-B5IGgRrU.mjs";import{createElement as n}from"react";import{evaluate as r}from"@mdx-js/mdx";import{getMDXComponents as i}from"rari/mdx/registry";async function a(e,t){let{components:a={},...o}=t,s=await r(e,o),c=s.default,l=i(e);function u(e){let t={...l,...a,...e.components};return n(c,{...e,components:t})}return{...s,default:u}}export{t as defineMdxComponents,a as evaluate,e as scanMdxComponentNames};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
let e=`/`,t=``,n=!1,r={generation:0,pathname:e,search:t},i=null;const a=/* @__PURE__ */ new Set;function o(){r={generation:0,pathname:e,search:t}}function s(){o();for(let e of a)e()}function c(){n||typeof window>`u`||(n=!0,e=window.location.pathname,t=window.location.search,o())}function l(){return c(),r}function u(e=`/`){return i?.pathname===e&&i.search===``&&i.generation===0||(i={generation:0,pathname:e,search:``}),i}function d(e){return a.add(e),()=>{a.delete(e)}}function f(){if(typeof window>`u`)return;n=!0;let r=window.location.pathname,i=window.location.search;(r!==e||i!==t)&&(e=r,t=i,s())}export{f as i,l as n,d as r,u as t};
|
package/dist/og.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{f as e,h as t}from"./type-guards-BozK2q2n.mjs";import{isValidElement as n}from"react";const r=Symbol.for(`react.memo`),i=Symbol.for(`react.forward_ref`);function a(e){return t(e)&&typeof e.toString==`function`}function o(e){let t=e;for(;a(t);)if(t.$$typeof===r&&t.type!==void 0)t=t.type;else if(t.$$typeof===i&&t.render!==void 0)t=t.render;else break;return typeof t==`function`||a(t)?t:null}var s=class{element;options;constructor(e,t={}){this.element=e,this.options={width:t.width!=null&&t.width!==0?t.width:1200,height:t.height!=null&&t.height!==0?t.height:630}}toJSON(){return{type:`ImageResponse`,element:this.serializeElement(this.element),options:this.options}}resolveAndInvoke(t,n){let r=o(t);if(r==null||typeof r!=`function`)return null;try{let t=r(n);return t!==null&&e(t)?(console.warn(`[ImageResponse] async/server component "${r.name||r.toString()}" is not supported; skipping`),null):this.serializeElement(t)}catch(e){return console.error(`[ImageResponse] failed to render component "${r.name||r.toString()}":`,e),null}}serializeElement(e){if(typeof e==`string`||typeof e==`number`)return{type:`text`,value:String(e)};if(!n(e))return null;let{type:r}=e,i=t(e.props)?e.props:{},s=o(r);if(typeof s==`function`||s!=null&&a(s))return this.resolveAndInvoke(r,i);let c=this.serializeChildren(i.children);return{type:`element`,elementType:r,props:this.serializeProps(i),children:c}}serializeChildren(e){if(e==null)return[];if(Array.isArray(e))return e.flatMap(e=>{let t=this.serializeElement(e);return t?[t]:[]});let t=this.serializeElement(e);return t?[t]:[]}serializeProps(e){let t={};for(let[n,r]of Object.entries(e)){if(n===`children`)continue;let e=this.serializePropValue(r);e!==void 0&&(t[n]=e)}return t}serializePropValue(e,n=/* @__PURE__ */ new Set){if(e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return e;if(Array.isArray(e)){if(n.has(e))return;n.add(e);try{return e.map(e=>this.serializePropValue(e,n)).filter(e=>e!==void 0)}finally{n.delete(e)}}if(t(e)){if(n.has(e))return;n.add(e);try{let t={};for(let[r,i]of Object.entries(e)){let e=this.serializePropValue(i,n);e!==void 0&&(t[r]=e)}return t}finally{n.delete(e)}}}};export{s as ImageResponse};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{d as e}from"./type-guards-BozK2q2n.mjs";import{o as t}from"./path-CTEC1xmy.mjs";import{t as n}from"./get-client-component-DFAmn8Ey.mjs";import{Fragment as r,createElement as i,isValidElement as a}from"react";function o(e){return a(e)||e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`}function s(e){if(!Array.isArray(e))return e;let t=e;return t.length===1&&a(t[0])?t[0]:t.length>0&&t.every(o)?i(r,null,...t):e}async function c(e,t){let r=l(e,t);r.size!==0&&await Promise.all(Array.from(r,async e=>{try{if(await n(e)==null){console.warn(`[rari] Failed to preload component: ${e}`);return}t?.add(e)}catch(t){console.error(`[rari] Error preloading component ${e}:`,t)}}))}function l(e,t){let n=/* @__PURE__ */ new Set;for(let r of e.split(`
|
|
2
|
+
`)){let e=u(r);e!=null&&(!t||!t.has(e))&&n.add(e)}return n}function u(n){let r=n.trim();if(!r)return null;let i=r.indexOf(`:`);if(i===-1)return null;let a=r.substring(i+1);if(!a.startsWith(`I`))return null;try{let n=JSON.parse(a.substring(1));if(!e(n))return null;let r=n[0];if(!r.includes(`/`)&&r.startsWith(`$`))return null;let i=typeof n[2]==`string`?n[2]:void 0,o=t(r);return o.includes(`#`)?o:i!=null&&i!==``&&i!=="default"?`${o}#${i}`:o}catch{return null}}export{s as n,c as t};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{h as e,p as t}from"../type-guards-BozK2q2n.mjs";import{r as n}from"../path-CTEC1xmy.mjs";const r={collapseSlashes:!0,ensureLeadingSlash:!1},i=/:(\w+)([?*+]?)|\*/g,a=/[\\+?(){}]/g,o=/[?#]/g,s=/* @__PURE__ */ new Map;function c(e){return e.replace(o,e=>encodeURIComponent(e))}function l(e){return c(e).replace(a,`\\$&`)}function u(e){let t=[],n=``,r=0;for(let a of e.matchAll(i)){let i=a.index;n+=l(e.slice(r,i));let o=a[0];if(o===`*`)n+=`*`;else{let e=a[1],r=a[2];t.push(e),n+=`:${e}${r}`}r=i+o.length}return n+=l(e.slice(r)),{pathname:n,paramNames:t}}function d(e){let t=n(e,r),i=s.get(t);if(i)return i;let{pathname:a,paramNames:o}=u(t),c={urlPattern:new URLPattern({pathname:a}),paramNames:o};return s.set(t,c),c}function f(e,t){let i=c(n(e,r));return d(t).urlPattern.exec({pathname:i})}
|
|
2
2
|
/* v8 ignore start - requires complex RariRequest mocking */
|
|
3
3
|
function p(e,t){return e.headers.get(t)}function m(e,t){return e.rariUrl.searchParams.get(t)}function h(e,t){let n=e.cookies.get(t);return n?n.value:null}function g(e,t){return e.rariUrl.hostname===t?e.rariUrl.hostname:null}function _(e,t){switch(t.type){case`header`:return p(e,t.key);case`query`:return m(e,t.key);case`cookie`:return h(e,t.key);case`host`:return g(e,t.key);default:throw Error(`Unknown condition type: ${t.type}`)}}function v(e,t){let n=_(e,t);return!(n===null||t.value!==void 0&&n!==t.value)}function y(e,t){let n=_(e,t);return n===null||t.value!==void 0&&n!==t.value}function b(e,t){if(t.has){for(let n of t.has)if(!v(e,n))return!1}if(t.missing){for(let n of t.missing)if(!y(e,n))return!1}return!0}
|
|
4
4
|
/* v8 ignore stop */
|
|
5
5
|
function x(e,t){return f(e,t)!=null}
|
|
6
6
|
/* v8 ignore start - requires complex RariRequest mocking */
|
|
7
|
-
function S(e,t,n){return typeof n==`string`?x(t,n):x(t,n.source)?b(e,n):!1}function C(e,t){let n=t?.matcher;if(n==null||n===``||Array.isArray(n)&&n.length===0)return!0;let r=e.rariUrl.pathname;return(Array.isArray(n)?n:[n]).some(t=>S(e,r,t))}function w(e,t,n){if(Object.hasOwn(e,t)){let r=e[t];e[t]=Array.isArray(r)?[...r,n]:[r,n]}else e[t]=n}function T(e){if(!e)return[];if(typeof e.getSetCookie==`function`)return e.getSetCookie();let t=[];return e.forEach&&e.forEach((e,n)=>{n.toLowerCase()===`set-cookie`&&t.push(e)}),t}function E(e,t){let n=e.cookies;if(n&&typeof n.toSetCookieHeaders==`function`)for(let e of n.toSetCookieHeaders())w(t,`set-cookie`,e)}function D(e){let t={},n={};e?.forEach&&e.forEach((e,r)=>{let i=r.toLowerCase();if(i!==`set-cookie`){if(i.startsWith(`x-rari-proxy-request-`)){let n=i.replace(`x-rari-proxy-request-`,``);w(t,n,e)}else i.startsWith(`x-rari-proxy-`)||w(n,i,e)}});for(let t of T(e))w(n,`set-cookie`,t);return{requestHeaders:Object.keys(t).length>0?t:void 0,responseHeaders:Object.keys(n).length>0?n:void 0}}function O(e){let t={};e?.forEach&&e.forEach((e,n)=>{n.toLowerCase()!==`set-cookie`&&w(t,n.toLowerCase(),e)});for(let n of T(e))w(t,`set-cookie`,n);return t}function k(e){if(!e)return null;let t=e.headers?.get?.(`x-rari-proxy-rewrite`);return t!=null&&t!==``?{continue:!1,rewrite:t}:null}function A(e){if(e?.status==null)return null;let t=e.headers?.get?.(`location`);return t!=null&&t!==``&&e.status>=300&&e.status<400?{continue:!1,redirect:{destination:t,permanent:e.status===301||e.status===308}}:null}function j(e){let{requestHeaders:t,responseHeaders:n={}}=D(e.headers);return E(e,n),{continue:!0,requestHeaders:t,responseHeaders:Object.keys(n).length>0?n:void 0}}async function M(e){let t=O(e.headers);E(e,t);let n;try{e.text&&typeof e.text==`function`?n=await e.text():e.body!=null&&typeof e.body==`string`?n=e.body:e.body!=null&&console.warn(`[rari] Proxy: Response body is not extractable as text`)}catch(e){console.error(`[rari] Proxy: Failed to extract response body:`,e)}return{continue:!1,response:{status:e.status??200,headers:t,body:n}}}async function N(e){return e?k(e)||A(e)||(e.headers?.get?.(`x-rari-proxy-continue`)===`true`?j(e):e.status==null?{continue:!0}:M(e)):{continue:!0}}function P(
|
|
7
|
+
function S(e,t,n){return typeof n==`string`?x(t,n):x(t,n.source)?b(e,n):!1}function C(e,t){let n=t?.matcher;if(n==null||n===``||Array.isArray(n)&&n.length===0)return!0;let r=e.rariUrl.pathname;return(Array.isArray(n)?n:[n]).some(t=>S(e,r,t))}function w(e,t,n){if(Object.hasOwn(e,t)){let r=e[t];e[t]=Array.isArray(r)?[...r,n]:[r,n]}else e[t]=n}function T(e){if(!e)return[];if(typeof e.getSetCookie==`function`)return e.getSetCookie();let t=[];return e.forEach&&e.forEach((e,n)=>{n.toLowerCase()===`set-cookie`&&t.push(e)}),t}function E(e,t){let n=e.cookies;if(n&&typeof n.toSetCookieHeaders==`function`)for(let e of n.toSetCookieHeaders())w(t,`set-cookie`,e)}function D(e){let t={},n={};e?.forEach&&e.forEach((e,r)=>{let i=r.toLowerCase();if(i!==`set-cookie`){if(i.startsWith(`x-rari-proxy-request-`)){let n=i.replace(`x-rari-proxy-request-`,``);w(t,n,e)}else i.startsWith(`x-rari-proxy-`)||w(n,i,e)}});for(let t of T(e))w(n,`set-cookie`,t);return{requestHeaders:Object.keys(t).length>0?t:void 0,responseHeaders:Object.keys(n).length>0?n:void 0}}function O(e){let t={};e?.forEach&&e.forEach((e,n)=>{n.toLowerCase()!==`set-cookie`&&w(t,n.toLowerCase(),e)});for(let n of T(e))w(t,`set-cookie`,n);return t}function k(e){if(!e)return null;let t=e.headers?.get?.(`x-rari-proxy-rewrite`);return t!=null&&t!==``?{continue:!1,rewrite:t}:null}function A(e){if(e?.status==null)return null;let t=e.headers?.get?.(`location`);return t!=null&&t!==``&&e.status>=300&&e.status<400?{continue:!1,redirect:{destination:t,permanent:e.status===301||e.status===308}}:null}function j(e){let{requestHeaders:t,responseHeaders:n={}}=D(e.headers);return E(e,n),{continue:!0,requestHeaders:t,responseHeaders:Object.keys(n).length>0?n:void 0}}async function M(e){let t=O(e.headers);E(e,t);let n;try{e.text&&typeof e.text==`function`?n=await e.text():e.body!=null&&typeof e.body==`string`?n=e.body:e.body!=null&&console.warn(`[rari] Proxy: Response body is not extractable as text`)}catch(e){console.error(`[rari] Proxy: Failed to extract response body:`,e)}return{continue:!1,response:{status:e.status??200,headers:t,body:n}}}async function N(e){return e?k(e)||A(e)||(e.headers?.get?.(`x-rari-proxy-continue`)===`true`?j(e):e.status==null?{continue:!0}:M(e)):{continue:!0}}function P(t){if(e(t.config))return t.config}async function F(n,r){try{let i=await import(n);if(!e(i)||!t(i.proxy))return console.error(`[rari] Proxy: proxy function not found in module`),!1;let a=i.proxy,o=P(i),s=await import(r);if(!e(s)||!t(s.RariRequest))return console.error(`[rari] Proxy: RariRequest constructor not found`),!1;let c=s.RariRequest;return Reflect.set(globalThis,`~rariExecuteProxy`,async e=>{try{let t=new c(e.url,{method:e.method,headers:new Headers(e.headers)});if(!C(t,o))return{continue:!0};let n=[],r=await a(t,{waitUntil:e=>{e.catch(()=>{}),n.push(e)}});return n.length>0&&Promise.allSettled(n).then(e=>{e.forEach((e,t)=>{e.status===`rejected`&&console.error(`[rari] Proxy: waitUntil promise ${t} failed:`,e.reason)})}),await N(r)}catch(e){return console.error(`[rari] Proxy: Proxy execution error:`,e),{continue:!0}}}),!0}catch(e){return console.error(`[rari] Proxy: Failed to initialize proxy executor:`,e),!1}}export{F as initializeProxyExecutor};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{f as e,h as t}from"./type-guards-BozK2q2n.mjs";import{isValidElement as n}from"react";const r=Symbol.for(`react.lazy`);function i(e){return n(e)&&(e.type===`html`||e.type===`HTML`)}function a(e){if(e==null||e===!1||e===!0)return[];if(!Array.isArray(e))return[e];let t=[];for(let n=0;n<e.length;n+=1){let r=e[n];t.push(r)}return t}function o(e){let n=e.type;return n===r||t(n)&&n.$$typeof===r}function s(e){if(e==null||e===!1||e===!0)return!1;if(c(e))return!0;if(Array.isArray(e)){for(let t of a(e))if(s(t))return!0;return!1}return n(e)?(o(e),s(e.props.children)):!1}function c(n){return e(n)?!t(n)||n.status!==`fulfilled`&&n.status!==`rejected`:!1}export{s as n,i as r,a as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{h as e}from"./type-guards-BozK2q2n.mjs";import{i as t,n,r,t as i}from"./execute-D_MjcLUi.mjs";import{promises as a}from"node:fs";import o from"node:path";function s(t){return e(t)&&t.rules!=null}async function c(e){if(typeof e==`function`){let t=e(),n=t instanceof Promise?await t:t;if(!s(n))throw Error(`Robots default export must resolve to a robots object`);return n}if(!s(e))throw Error(`Robots default export must be a robots object`);return e}function l(e){return typeof e==`string`?e===``?[`*`]:[e]:e==null?[`*`]:[...e]}function u(e){return e===void 0?[]:typeof e==`string`?e===``?[]:[e]:[...e].filter(e=>e!==``)}function d(e){let t=[],n=l(e.userAgent);for(let r of n){t.push(`User-Agent: ${r}`);let n=u(e.allow);for(let e of n)t.push(`Allow: ${e}`);let i=u(e.disallow);for(let e of i)t.push(`Disallow: ${e}`);e.crawlDelay!==void 0&&t.push(`Crawl-delay: ${e.crawlDelay}`),t.push(``)}return t}function f(e){return e==null||e===``?[]:[`Host: ${e}`,``]}function p(e){return u(e).map(e=>`Sitemap: ${e}`)}function m(e){let t=[],n=Array.isArray(e.rules)?e.rules:[e.rules];for(let e of n)t.push(...d(e));return t.push(...f(e.host)),t.push(...p(e.sitemap)),t.join(`
|
|
2
2
|
`)}
|
|
3
3
|
/* v8 ignore start - file system operations, better tested in integration/e2e */
|
|
4
4
|
async function h(e,n=[`.ts`,`.tsx`,`.js`,`.jsx`,`.mjs`]){return t({appDir:e,staticFileName:`robots.txt`,dynamicBaseName:`robots`,extensions:n,rethrowNonEnoent:!0})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isLayoutReuseMarker as e,layoutPathOf as t}from"./runtime/merge-flight-refresh.mjs";import{r as n,t as r}from"./react-helpers-BKmKvCbj.mjs";import{cloneElement as i,createElement as a,isValidElement as o}from"react";const s=`children`;function c(e){let t=e.length;for(;t>1&&e[t-1]===`/`;)--t;return e.slice(0,t)}function l(e){let t=e===`/`||e===``?`/`:c(e)||`/`,n=t===`/`?[]:t.slice(1).split(`/`).filter(Boolean),r=[``,{}];for(let e=n.length-1;e>=0;--e)r=[n[e],{[s]:r}];return[``,{[s]:r}]}function u(e){let t=[],n=e;for(;n;){let e=n[0],r=n[1];e&&t.push(e),n=r.children}return t}function d(e){return u(l(e))}const f=`rari-layout-slot`;function p(){return{rsc:null,data:/* @__PURE__ */ new Map,slots:null}}function m(e,t){e.slots??=/* @__PURE__ */ new Map;let n=e.slots.get(t);return n??(n=p(),e.slots.set(t,n)),n}function h(e,t){let n=e;for(let e of t)n=m(n,e);return n}function g(e,t){let n=e;for(let e of t){let t=n.slots?.get(e);if(t==null)return null;n=t}return n}function _(e,t){if(t.length===0){e.rsc=null,e.data.clear(),e.slots=null;return}let n=e;for(let e=0;e<t.length-1;e+=1){let r=t[e],i=n.slots?.get(r);if(i==null)return;n=i}let r=t[t.length-1];n.slots!=null&&n.slots.has(r)&&(n.slots.delete(r),n.slots.size===0&&(n.slots=null))}function v(e){return e===`/`||e===``?[]:e.replace(/^\//,``).split(`/`).filter(Boolean)}function y(e){return e.props.children}function b(e){let t={...e.props};return delete t.children,t}function x(e,t){let n=r(t);return i(e,b(e),...n.length===0?[null]:n)}function S(e){return e.type===f}function C(e){if(Array.isArray(e)){for(let t of r(e))if(C(t))return!0;return!1}return o(e)?S(e)?!0:C(y(e)):!1}function w(e){return a(f,{"data-rari-layout-path":e,style:{display:`contents`}})}function T(e,t){return e===`/`?t!==`/`:t.startsWith(`${e}/`)}function E(e,n){if(Array.isArray(e)){for(let t of r(e))E(t,n);return}if(!o(e))return;let i=t(e);i!=null&&!n.includes(i)&&n.push(i);for(let t of r(y(e)))E(t,n)}function D(e,n){let i=[];function a(e){if(e==null||e===!1||e===!0)return e;if(Array.isArray(e))return r(e).map(a);if(!o(e))return e;let s=t(e);if(s!=null&&s!==n&&T(n,s)&&!S(e))return i.push({path:s,content:y(e)}),w(s);let c=y(e);if(c==null)return e;let l=a(c);return Object.is(l,c)?e:x(e,l)}return{chrome:a(e),nested:i}}function O(e,n){if(t(e)===n)return e;for(let t of r(y(e))){if(!o(t))continue;let e=O(t,n);if(e!=null)return e}return null}function k(e,t){if(Array.isArray(e)){for(let n of r(e)){let e=k(n,t);if(e!=null)return e}return null}return o(e)?O(e,t):null}function A(e){return e.length===0?`/`:`/${e.join(`/`)}`}function j(e){return e.rsc==null&&e.data.size===0&&(e.slots==null||e.slots.size===0)}function M(n){let i=[];function a(n){if(n==null||n===!1||n===!0)return n;if(Array.isArray(n))return r(n).map(a);if(!o(n))return n;let s=t(n);if(s!=null&&!S(n)&&!e(n))return i.push({path:s,content:y(n)}),x(n,w(s));let c=y(n);if(c==null)return n;let l=a(c);return Object.is(l,c)?n:x(n,l)}let s=a(n);return o(s)?{shell:s,entries:i}:{shell:n,entries:i}}function N(n){let r=n,i=null;for(;o(r)&&e(r);){let e=t(r);if(e==null)return{targetPath:null,content:n};i=e,r=y(r)}return{targetPath:i,content:r}}const P=new class{shell=null;root=p();version=0;listeners=/* @__PURE__ */ new Set;documentSnapshot=null;subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getVersion=()=>this.version;bump(){this.version+=1;for(let e of this.listeners)e()}notify(){this.documentSnapshot=null,this.bump()}getShell(){return this.shell}getDocumentSnapshot=()=>{let{pathname:e,search:t}=F(),n=`${e}${t}`,r=this.hasRoute(e,t);return this.documentSnapshot!=null&&this.documentSnapshot.shell===this.shell&&this.documentSnapshot.routeKey===n&&this.documentSnapshot.ok===r||(this.documentSnapshot={shell:this.shell,routeKey:n,ok:r}),this.documentSnapshot};hasRoute(e,t){return g(this.root,d(e))?.data.has(t)===!0}readChrome(e){return g(this.root,v(e))?.rsc??null}readLeaf(e,t){let n=g(this.root,d(e));return n==null||!n.data.has(t)?null:n.data.get(t)??null}readSegmentSnapshot(e,t){let{pathname:n,search:r}=t??F();return this.isDeepestLayout(e,n)?this.readLeaf(n,r):this.readChrome(e)}isDeepestLayout(e,t){let n=this.readChrome(e);if(n==null)return!0;let r=[];E(n,r);let i=t===`/`||t===``?`/`:t.replace(/\/$/,``)||`/`;return!r.some(t=>T(e,t)?t===`/`||i===t||i.startsWith(`${t}/`):!1)}ingest(e,t,r){if(!n(e)||C(e))return!1;let{shell:i,entries:a}=M(e);if(this.shell=i,a.length===0)return h(this.root,d(t)).data.set(r,e),this.bump(),!0;for(let e of a)this.writeStampContent(e.path,e.content,t,r);return this.bump(),!0}ingestSegment(e,n,r){if(this.shell==null||!o(e))return!1;let{targetPath:i,content:a}=N(e);return i==null?!o(a)||t(a)==null||!this.ingestStampTree(a,n,r)?!1:(this.bump(),!0):this.isAddressableLayoutPath(i)?(this.writeStampContent(i,a,n,r),this.bump(),!0):!1}ingestStampTree(e,t,n){let r=[];if(E(e,r),r.length===0)return!1;for(let i of r){let r=O(e,i);r==null||S(r)||this.writeStampContent(i,y(r),t,n)}return!0}isAddressableLayoutPath(e){if(this.shell!=null&&O(this.shell,e)!=null)return!0;let t=v(e);for(let n=0;n<t.length;n+=1){let r=A(t.slice(0,n)),i=this.readChrome(r);if(i!=null&&k(i,e)!=null)return!0}return!1}writeStampContent(e,t,n,r){if(o(t)&&S(t))return;let{chrome:i,nested:a}=D(t,e===``?`/`:e);if(o(i)&&S(i)&&a.length===0)return;let s=h(this.root,v(e));if(s.rsc=i,a.length===0){h(this.root,d(n)).data.set(r,t);return}for(let e of a)this.writeStampContent(e.path,e.content,n,r)}getElement(e,t){if(this.hasRoute(e,t))return this.shell??void 0}set(e,t,r){n(r)&&this.ingest(r,e,t)}invalidate(e,t){let n=d(e);if(n.length===0){this.shell=null,this.root=p(),this.bump();return}let r=g(this.root,n);r!=null&&(r.data.delete(t),r.rsc=null,r.slots=null,j(r)&&_(this.root,n),this.bump())}evictLeaf(e,t){let n=d(e),r=g(this.root,n);r!=null&&(r.data.delete(t),j(r)&&_(this.root,n),this.bump())}clear(){this.shell=null,this.root=p(),this.documentSnapshot=null,this.bump()}};function F(){return typeof window>`u`?{pathname:`/`,search:``}:{pathname:window.location.pathname,search:window.location.search}}function I(){let{pathname:e,search:t}=F();return JSON.stringify({pathname:e,search:t,tree:l(e)})}export{I as a,S as i,F as n,P as r,C as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./navigate-DuyUa6qD.mjs";import{h as t,i as n}from"./type-guards-BozK2q2n.mjs";import{i as r,n as i,r as a,t as o}from"./navigation-transition-store-dfNJmkIX.mjs";import{c as s}from"react/compiler-runtime";import{createContext as c,use as l,useEffect as u,useRef as d,useSyncExternalStore as f}from"react";import{jsx as p}from"react/jsx-runtime";const m=c(null);function h(){let e=l(m);if(!e)throw Error(`useRouter must be used within a RouterProvider`);return e}function g(){return h().pathname}function _(){return h().searchParams}function v(){return f(a,b,y)}function y(){return o().generation}function b(){return i().generation}function x(e){return t(e)&&typeof e.navigate==`function`}function S(t){let r=s(17),{children:c,initialPathname:l}=t,h;r[0]===l?h=r[1]:(h=()=>o(l),r[0]=l,r[1]=h);let g=f(a,i,h),_=d(null),v;r[2]===Symbol.for(`react.memo_cache_sentinel`)?(v=[],r[2]=v):v=r[2],u(D,v);let y,b;r[3]===Symbol.for(`react.memo_cache_sentinel`)?(y=()=>{let t=e();t&&(_.current=t);let r=e=>{let t=n(e,x);t&&(_.current=t.navigate)},i=()=>{_.current=null};return window.addEventListener(`rari:register-navigate`,r),window.addEventListener(`rari:deregister-navigate`,i),()=>{window.removeEventListener(`rari:register-navigate`,r),window.removeEventListener(`rari:deregister-navigate`,i)}},b=[],r[3]=y,r[4]=b):(y=r[3],b=r[4]),u(y,b);let S;r[5]===g.search?S=r[6]:(S=g.search.startsWith(`?`)?g.search.slice(1):g.search,r[5]=g.search,r[6]=S);let O;r[7]===S?O=r[8]:(O=new URLSearchParams(S),r[7]=S,r[8]=O);let k=O,A,j;r[9]===Symbol.for(`react.memo_cache_sentinel`)?(A=async(e,t)=>{_.current?await _.current(e,t):(console.warn(`[rari] Router not ready, falling back to window.location`),window.location.href=e)},j=async(e,t)=>{_.current?await _.current(e,{...t,replace:!0}):(console.warn(`[rari] Router not ready, falling back to window.location`),window.location.replace(e))},r[9]=A,r[10]=j):(A=r[9],j=r[10]);let M;r[11]!==k||r[12]!==g.pathname?(M={pathname:g.pathname,searchParams:k,push:A,replace:j,back:E,forward:T,refresh:w,prefetch:C},r[11]=k,r[12]=g.pathname,r[13]=M):M=r[13];let N=M,P;return r[14]!==c||r[15]!==N?(P=/* @__PURE__ */ p(m,{value:N,children:c}),r[14]=c,r[15]=N,r[16]=P):P=r[16],P}async function C(e){try{let t=new URL(e,window.location.origin);await fetch(t.pathname+t.search,{headers:{Accept:`text/x-component`},priority:`low`})}catch(e){console.warn(`[rari] Prefetch failed:`,e)}}function w(){window.dispatchEvent(new CustomEvent(`rari:app-router-rerender`))}function T(){window.history.forward()}function E(){window.history.back()}function D(){r()}export{v as a,_ as i,g as n,h as r,S as t};
|
package/dist/router.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
1
2
|
//#region src/router/navigation/types.d.ts
|
|
2
3
|
interface NavigationOptions {
|
|
3
4
|
readonly replace?: boolean;
|
|
@@ -10,7 +11,7 @@ export declare function navigate(href: string, options?: NavigationOptions): Pro
|
|
|
10
11
|
//#endregion
|
|
11
12
|
//#region src/router/navigation/router-provider.d.ts
|
|
12
13
|
interface RouterProviderProps {
|
|
13
|
-
readonly children:
|
|
14
|
+
readonly children: ReactNode;
|
|
14
15
|
readonly initialPathname: string;
|
|
15
16
|
}
|
|
16
17
|
export declare function RouterProvider({ children, initialPathname }: RouterProviderProps): import("react").JSX.Element;
|
package/dist/router.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./navigate-DuyUa6qD.mjs";import{a as t,i as n,n as r,r as i,t as a}from"./router-
|
|
1
|
+
import{r as e}from"./navigate-DuyUa6qD.mjs";import{a as t,i as n,n as r,r as i,t as a}from"./router-6mdxF_x7.mjs";export{a as RouterProvider,e as navigate,r as usePathname,i as useRouter,n as useSearchParams,t as useViewTransitionKey};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{h as e}from"./type-guards-BozK2q2n.mjs";import{o as t}from"./path-CTEC1xmy.mjs";import{Buffer as n}from"node:buffer";import r from"node:fs";import i from"node:path";import{createBuilder as a}from"vite-plus";const o=/* @__PURE__ */ new Map,s=/* @__PURE__ */ new Map;function c(e){let t=o.get(e);return t===void 0?(t=r.existsSync(e),o.set(e,t),t):t}function l(e){let t=s.get(e);if(t!==void 0)return t;try{t=r.statSync(e).isDirectory()}catch{t=!1}return s.set(e,t),t}function u(){o.clear(),s.clear()}function d(e,t){let n=null;for(let r of t)if(r!==``&&e.endsWith(r)&&(n??=c(e),n&&!l(e)))return e;for(let n of t){let t=`${e}${n}`;if(c(t)&&!l(t))return t}return null}function f(e,t){if(c(e)){if(!l(e))return null;for(let n of t){let t=i.join(e,`index${n}`);if(c(t))return t}}return null}const p=[`.tsx`,`.jsx`,`.ts`,`.js`];function m(e,t,n={},r=p){let a=e;for(let[t,r]of Object.entries(n))if(e.startsWith(`${t}/`)){a=e.replace(t,r);break}else if(e===t){a=r;break}let o=i.resolve(i.dirname(t),a),s=d(o,r);if(s!=null&&s!==``)return s;let c=f(o,r);return c!=null&&c!==``?c:`${o}.tsx`}const h=[`.ts`,`.tsx`,`.js`,`.jsx`,`.mjs`];function g(e,t=h){return d(e,t)??f(e,t)}const _=/* @__PURE__ */ new WeakMap;function v(e){let t=_.get(e);return t||(t=Object.entries(e).sort((e,t)=>t[0].length-e[0].length),_.set(e,t),t)}function y(e,t,n){if(typeof e!=`string`)throw TypeError(`Expected source to be a string, but received ${typeof e}`);if(typeof t!=`object`||Array.isArray(t))throw TypeError(`Expected aliases to be a plain object, but received ${Array.isArray(t)?`array`:typeof t}`);if(Object.getPrototypeOf(t)!==Object.prototype&&Object.getPrototypeOf(t)!==null)throw TypeError(`Expected aliases to be a plain object, but received ${t.constructor.name||`object with custom prototype`}`);if(typeof n!=`string`)throw TypeError(`Expected projectRoot to be a string, but received ${typeof n}`);let r=v(t);for(let[t,a]of r)if(e.startsWith(`${t}/`)||e===t){let r=e.slice(t.length).replace(/^\/+/,``),o=i.join(a,r);return i.isAbsolute(o)?o:i.resolve(n,o)}return null}const b=/^node:/,x=/* @__PURE__ */ new Map;function S(e){let t=i.resolve(e.root);return JSON.stringify({root:t,configFile:e.configFile??null,logLevel:e.logLevel??null})}async function C(e){let t=typeof e==`string`?{root:e}:e,n=i.resolve(t.root),r=S(t),o=x.get(r);return o??(o=a({root:n,...t.configFile===void 0?{}:{configFile:t.configFile},...t.logLevel==null?{}:{logLevel:t.logLevel},oxc:{jsx:{development:!1}}}).catch(e=>{throw x.delete(r),e}),x.set(r,o)),o}function w(t){let n=i.resolve(t);for(let t of x.keys()){let r=JSON.parse(t);e(r)&&r.root===n&&x.delete(t)}}function T(e){return typeof e==`object`&&!!e&&`type`in e}function E(e){let t=Array.isArray(e)?e:[e],n=[];for(let e of t){if(typeof e!=`object`||!e)continue;let t=e.output;if(Array.isArray(t))for(let e of t)T(e)&&n.push(e)}return n}function D(e){return typeof e==`string`?e:n.from(e).toString(`utf8`)}function O(e){return e==null?[]:e instanceof Set?[...e].map(e=>t(String(e))):Array.isArray(e)?e.map(e=>t(String(e))):[]}const k=[b,`react`,`react-dom`,`react/jsx-runtime`,`react/jsx-dev-runtime`,`react/compiler-runtime`,/^rari(?:\/|$)/,`react-server-dom-rari/server`],A=[b,`react`,`react-dom`,`react/jsx-runtime`,`react/jsx-dev-runtime`,`react/compiler-runtime`,/^rari(?:\/|$)/,`react-server-dom-webpack/client`,/^react-server-dom-webpack\//];function j(e){return{write:e.write,emptyOutDir:e.emptyOutDir,copyPublicDir:e.copyPublicDir,minify:e.minify,emitAssets:e.emitAssets,rolldownOptions:e.rolldownOptions}}function M(e,t){e.write=t.write,e.emptyOutDir=t.emptyOutDir,e.copyPublicDir=t.copyPublicDir,e.minify=t.minify,e.emitAssets=t.emitAssets,e.rolldownOptions=t.rolldownOptions}function N(e){let n=/* @__PURE__ */ new Map,r=[],i=/* @__PURE__ */ new Map,a=/* @__PURE__ */ new Map;for(let o of e){if(o.type===`asset`){let e=t(o.fileName);e.endsWith(`.css`)?n.set(e,D(o.source)):r.push({fileName:e,code:o.source});continue}let e=t(o.fileName);if(o.isEntry){let e=o.name;if(e==null||e===``)continue;i.set(e,{code:o.code,cssAssetSources:[]}),a.set(e,O(o.viteMetadata?.importedCss));continue}r.push({fileName:e,code:o.code})}return{cssByFileName:n,extraFiles:r,entryOutputs:i,entryCssFiles:a}}function P(e,t,n){for(let[r,i]of e){let a=(t.get(r)??[]).map(e=>n.get(e)).filter(e=>e!=null);if(a.length===0&&e.size===1&&n.size>0){e.set(r,{...i,cssAssetSources:[...n.values()]});continue}e.set(r,{...i,cssAssetSources:a})}}async function F(e){let t=/* @__PURE__ */ new Map,n=[];for(let r of e.entries){let i=await L({...e,entries:[r]});if(i==null)return null;for(let[e,n]of i.outputs)t.set(e,n);n.push(...i.extraFiles)}return{outputs:t,extraFiles:n}}function I(e,t,n,r){e.write=!1,e.emptyOutDir=!1,e.copyPublicDir=!1,e.emitAssets=!0,e.minify=t.minify===!0&&`oxc`,e.rolldownOptions={...r,input:n,platform:`node`,output:{format:`es`,entryFileNames:`[name].js`,chunkFileNames:`chunks/[name]-[hash].js`,assetFileNames:`assets/[name]-[hash][extname]`,...t.codeSplitting===!1?{codeSplitting:!1}:{}},external:[...t.environmentName===`ssr`?A:k]}}async function L(t){if(t.entries.length===0)return{outputs:/* @__PURE__ */ new Map,extraFiles:[]};if(t.codeSplitting===!1&&t.entries.length>1)return F(t);let n=t.viteBuilder.environments[t.environmentName];if(n==null)return null;await n.init();let r={};for(let e of t.entries)r[e.entryName]=e.filePath;let i=n.config.build,a=j(i),o=e(a.rolldownOptions)?{...a.rolldownOptions}:{},s=t.label??t.environmentName.toUpperCase();try{I(i,t,r,o);let e=E(await t.viteBuilder.build(n));if(e.length===0)return null;let a=N(e);P(a.entryOutputs,a.entryCssFiles,a.cssByFileName);for(let e of t.entries)if(!a.entryOutputs.has(e.entryName))return null;return{outputs:a.entryOutputs,extraFiles:a.extraFiles}}catch(e){return console.warn(`[rari] Vite ${s} environment build failed:`,e),null}finally{M(i,a)}}async function R(e){return L({viteBuilder:e.viteBuilder,environmentName:`rsc`,entries:e.entries.map(e=>({entryName:e.componentId,filePath:e.filePath})),minify:e.minify,codeSplitting:e.codeSplitting,label:`RSC`})}async function z(e){return L({viteBuilder:e.viteBuilder,environmentName:`ssr`,entries:e.entries,minify:e.minify??!1,label:`SSR`})}function B(e,n){return t(i.join(e,`${n}.js`))}async function V(e){let t=await a({configFile:!1,root:e.root,logLevel:`error`,plugins:[...e.plugins],define:{global:`globalThis`},resolve:{conditions:[`import`,`module`,`default`],extensions:[`.mjs`,`.js`,`.ts`,`.tsx`,`.jsx`],mainFields:[`module`,`main`]},environments:{ssr:{consumer:`server`,build:{write:!1,emptyOutDir:!1,copyPublicDir:!1,emitAssets:!1,minify:!1,cssMinify:!1,target:`esnext`,rolldownOptions:{input:{entry:e.virtualId},platform:`node`,external:e.external,output:{format:`es`,codeSplitting:!1,entryFileNames:`[name].js`}}}}},builder:{sharedPlugins:!0},css:{transformer:`lightningcss`}}),n=t.environments.ssr;await n.init();let r=E(await t.build(n)),i=r.find(e=>e.type===`chunk`&&e.isEntry)??r.find(e=>e.type===`chunk`);return i?.type===`chunk`?{code:i.code}:null}export{C as a,u as c,w as i,m as l,R as n,B as o,z as r,y as s,V as t,g as u};
|
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { t as FlightContent } from "../react-helpers-GTRYJwF2.mjs";
|
|
2
|
+
import { ReactElement, ReactNode } from "react";
|
|
3
|
+
//#region src/runtime/flight/apply-flight-patch.d.ts
|
|
4
|
+
interface PendingLeafEviction {
|
|
5
|
+
readonly pathname: string;
|
|
6
|
+
readonly search: string;
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
2
9
|
//#region src/runtime/flight/app-router-provider.d.ts
|
|
3
10
|
interface RscPayload {
|
|
4
|
-
readonly element:
|
|
5
|
-
readonly rawElement?: React.ReactNode | PromiseLike<React.ReactNode>;
|
|
11
|
+
readonly element: FlightContent;
|
|
6
12
|
readonly flightProtocol?: string;
|
|
13
|
+
readonly maySuspend?: boolean;
|
|
14
|
+
readonly pendingEvictLeaf?: PendingLeafEviction;
|
|
7
15
|
}
|
|
8
16
|
interface NavigationOptions {
|
|
9
17
|
readonly historyKey?: string;
|
|
@@ -12,7 +20,7 @@ interface NavigationOptions {
|
|
|
12
20
|
readonly [key: string]: unknown;
|
|
13
21
|
}
|
|
14
22
|
interface AppRouterProviderProps {
|
|
15
|
-
readonly children:
|
|
23
|
+
readonly children: ReactNode;
|
|
16
24
|
readonly initialPayload?: RscPayload;
|
|
17
25
|
readonly onNavigate?: (detail: Readonly<NavigationDetail>) => void;
|
|
18
26
|
}
|
|
@@ -32,5 +40,5 @@ interface NavigationDetail {
|
|
|
32
40
|
readonly replace?: boolean;
|
|
33
41
|
};
|
|
34
42
|
}
|
|
35
|
-
export declare function AppRouterProvider({ children, initialPayload, onNavigate }: AppRouterProviderProps):
|
|
43
|
+
export declare function AppRouterProvider({ children, initialPayload, onNavigate }: AppRouterProviderProps): import("react").JSX.Element;
|
|
36
44
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as e,i as t,p as n,r,v as i,w as a}from"../type-guards-BJXKlA6x.mjs";import{r as o}from"../navigation-transition-store-CSKrbtbK.mjs";import"./action-revalidation-kind.mjs";import{isLayoutReuseMarker as s,mergeFlightRefresh as c,unwrapFulfilledFlightNode as l}from"./merge-flight-refresh.mjs";import{currentRouteLocation as u,flightRouteCache as d}from"./flight-route-cache.mjs";import{n as f,t as p}from"../preload-modules-Dv_GzGCm.mjs";import{n as m,r as h}from"../form-state-DAygOjc8.mjs";import{c as g}from"react/compiler-runtime";import*as _ from"react";import{addTransitionType as v,startTransition as y,useEffect as b,useLayoutEffect as x,useRef as S,useState as C,useTransition as w}from"react";import{Fragment as ee,jsx as T,jsxs as E}from"react/jsx-runtime";import{createFromFetch as te,createFromReadableStream as ne}from"virtual:react-flight-client";const D={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)`},O={padding:`8px 16px`,background:`white`,color:`#dc2626`,border:`none`,borderRadius:`4px`,cursor:`pointer`,fontWeight:`bold`,fontSize:`14px`},k={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`},A={fetch:`Failed to fetch updated content from server.`,parse:`Failed to parse server response.`,stale:`Server returned stale content.`,network:`Network error occurred.`};function j(e){return A[e]}function re(e){let t=g(27),{failure:n,maxRetries:r,onRefresh:i,onDismiss:a}=e,o,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=/* @__PURE__ */ T(`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=j(n.type),t[2]=n.type,t[3]=c);let l;t[4]===c?l=t[5]:(l=/* @__PURE__ */ T(`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__ */ T(`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__ */ E(`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__ */ T(`button`,{onClick:i,type:`button`,style:O,children:`Refresh Page`}),t[14]=i,t[15]=h);let _;t[16]===a?_=t[17]:(_=/* @__PURE__ */ T(`button`,{onClick:a,type:`button`,style:k,children:`Dismiss`}),t[16]=a,t[17]=_);let v;t[18]!==h||t[19]!==_?(v=/* @__PURE__ */ E(`div`,{style:m,children:[h,_]}),t[18]=h,t[19]=_,t[20]=v):v=t[20];let y;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(y=/* @__PURE__ */ T(`div`,{style:{marginTop:`12px`,fontSize:`11px`,opacity:.6},children:`Check the console for detailed error logs.`}),t[21]=y):y=t[21];let b;return t[22]!==v||t[23]!==l||t[24]!==d||t[25]!==p?(b=/* @__PURE__ */ E(`div`,{style:D,children:[o,l,d,p,v,y]}),t[22]=v,t[23]=l,t[24]=d,t[25]=p,t[26]=b):b=t[26],b}function ie(e){return e.historyKey!=null&&e.historyKey!==``?[`nav`,`nav-traverse`]:e.replace===!0?[`nav`,`nav-replace`]:[`nav`,`nav-forward`]}function M(e){e!=null&&typeof window<`u`&&(e.replace===!0?window.history.replaceState(e.state,``,e.url):window.history.pushState(e.state,``,e.url))}function N(e){if(e!=null&&e.url!==``)try{let t=`http://localhost/`;if(typeof window<`u`)try{t=window.location.href}catch{}let n=new URL(e.url,t);o({pathname:n.pathname,search:n.search})}catch{}}function ae(e){let{parsedPayload:t,shouldScrollToTop:n,navigationId:r,transitionTypes:i,pendingHistory:a,startTransition:o=y,currentNavigationIdRef:s,pendingScrollPayloadRef:c,setRenderKey:l,setRscPayload:u,clearHmrError:d,pendingNavigateCommittedIdRef:f}=e;o(()=>{if(s.current===r){if(i!=null)for(let e of i)v(e);M(a),N(a),l(e=>{let r=e+1;return c.current=n?{payload:t,commitKey:r}:null,r}),u(t),d(),f.current=r}})}function oe(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 P(e){return _.isValidElement(e)&&(e.type===`html`||e.type===`HTML`)}function F(e){if(e==null)return null;if(n(e)){let t=l(e);return t===e||!P(t)?null:t}return P(e)?e:null}const se=/"timestamp":(\d+)/;function ce(e){return e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`||_.isValidElement(e)||Array.isArray(e)}function le(e){return i(e)&&typeof e.from==`string`&&typeof e.to==`string`&&typeof e.navigationId==`number`&&i(e.options)}function ue(e){return i(e)&&`element`in e}function de(e){return i(e)&&typeof e.navigationId==`number`&&typeof e.targetPath==`string`}function fe(e){if(!n(e))return e;if(i(e)&&e.status===`fulfilled`)return ce(e.value)?e.value:void 0}function I(e){return _.isValidElement(e)&&(e.type===`html`||e.type===`HTML`)}function L(e){return I(e)||_.isValidElement(e)&&s(e)}function pe(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 he(e,t,n,r){let i=await R(e.element);if(r!==n)return{kind:`superseded`};if(!L(i))return{kind:`error`,error:/* @__PURE__ */ Error(`[rari] AppRouter: navigated Flight content did not resolve to an <html> document root`)};let a=F(t);if(_.isValidElement(i)&&s(i)&&a==null)return{kind:`error`,error:/* @__PURE__ */ Error(`[rari] AppRouter: layout-reuse Flight marker requires a previous <html> document`)};let o=a==null?i:c(a,i);return I(o)?{kind:`payload`,payload:{...e,element:o,rawElement:o}}:{kind:`error`,error:/* @__PURE__ */ Error(`[rari] AppRouter: layout-merged Flight content did not resolve to an <html> document root`)}}async function R(e){let t=f(e);for(let e=0;e<10&&n(t);e+=1)t=f(await t);if(n(t))throw Error(`[rari] AppRouter: Flight content did not resolve to a React node`);return t}function z({children:o,initialPayload:s,onNavigate:l}){let[g,v]=C(s),y=S(s),[D,O]=C(0),[,k]=w(),A=S(k),j=S({x:0,y:0}),M=S(null),N=S(/* @__PURE__ */ new Map),P=S(/* @__PURE__ */ new Set),F=S(l),L=S(0),z=S(0),B=S(null),V=S(null),H=S(/* @__PURE__ */ new Map),U=S([]),W=S(null),G=S(0),[ge,K]=C(null);b(()=>{F.current=l},[l]),b(()=>{A.current=k},[k]),x(()=>{let{shouldScroll:e,nextPending:t}=oe(M.current,g,D);M.current=t,e&&window.scrollTo(0,0);let n=V.current;n!=null&&(V.current=null,window.dispatchEvent(new CustomEvent(`rari:navigate-committed`,{detail:{navigationId:n}})))},[g,D]);let _e=e=>{if(e==null||n(e))return;let{pathname:t,search:r}=u();d.set(t,r,e)};b(()=>{y.current=g,g?.element!=null&&_e(g.element)},[g]),b(()=>{if(g?.element!=null){let e=g.element;if(i(e)&&`status`in e&&e.status===`rejected`){let t=e.reason;t!=null&&t!==``&&console.error(`[rari] AppRouter: Flight payload rejected:`,t)}}},[g]);let q=()=>{N.current=m()},ve=()=>{h(N.current)};x(()=>{let e=B.current;e!=null&&g===e&&(B.current=null,window.scrollTo(j.current.x,j.current.y),ve())},[g,D]);let J=(e,t,n,r)=>{G.current+=1;let i={timestamp:Date.now(),error:e,type:t,details:n,filePath:r,consecutiveFailures:G.current};U.current.push(i),U.current.length>10&&U.current.shift(),G.current>=2&&K(i),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`rari:hmr-failure`,{detail:i}))},Y=()=>{setTimeout(()=>{window.location.reload()},1e3)},ye=()=>{G.current>0&&(G.current=0)},be=e=>{if(W.current==null||W.current===``)return!1;if(e===W.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},xe=e=>{p(e,P.current);let t=new ReadableStream({start(t){t.enqueue(new TextEncoder().encode(e)),t.close()}}),n=ne(t);return{element:n,rawElement:n,flightProtocol:e}},Se=async e=>{let t=await e;if(!t.body)throw Error(`Response has no body stream`);let n=t.clone(),r=te(Promise.resolve(t));return n.text().then(async e=>{await p(e,P.current),e!==``&&(W.current=e)}).catch(()=>{}),{element:r,rawElement:r,flightProtocol:``}},Ce=async(t,n)=>{try{let e=await t.clone().text();if(be(e))return H.current.delete(n),`stale`;await p(e,P.current);let r=await R(te(Promise.resolve(t)));if(!I(r))throw Error(`[rari] AppRouter: refetched Flight content did not resolve to an <html> document root`);return{element:r,rawElement:r,flightProtocol:e}}catch(t){if(e(t)&&t.name===`AbortError`)throw t;let n=a(t),r=Error(`Failed to parse RSC Flight protocol: ${n.message}`,{cause:n});return J(r,`parse`,r.message,window.location.pathname),r}},we=async(t,n,r)=>{let i=t!=null&&t!==``?t:window.location.pathname,o=L.current,s=r?.commit!==!1,c=`${o}:${i}${window.location.search}:${s?`commit`:`defer`}`,l=H.current.get(c);if(l)return l;let u=(async()=>{try{let e=i+window.location.search,t=await fetch(e,{headers:{Accept:`text/x-component`,"rari-navigation-id":String(L.current)},cache:`no-store`,signal:n});if(!t.ok){let n=/* @__PURE__ */ Error(`Failed to fetch RSC data: ${t.status} ${t.statusText}`);throw J(n,`fetch`,`HTTP ${t.status} when fetching ${e}`,window.location.pathname),n}let r=await Ce(t,c);if(r===`stale`)return;if(r instanceof Error)throw r;return L.current===o&&(s&&v(r),r.flightProtocol!=null&&r.flightProtocol!==``&&(W.current=r.flightProtocol),ye()),H.current.delete(c),r}catch(t){throw H.current.delete(c),e(t)&&t.name!==`AbortError`&&!t.message.includes(`Failed to fetch RSC data`)&&!t.message.includes(`Failed to parse`)&&J(t,`network`,`Network error: ${t.message}`,window.location.pathname),a(t)}})();return H.current.set(c,u),u},Te=S(xe),Ee=S(Se),X=S(we);b(()=>{Te.current=xe,Ee.current=Se,X.current=we}),b(()=>{if(typeof window>`u`)return;let i=async e=>{if(e.rscResponsePromise){let t=await e.rscResponsePromise;if(L.current!==e.navigationId)return;let n=await Ee.current(Promise.resolve(t));return L.current===e.navigationId?n:void 0}if(e.rscResponse){let t=await Ee.current(Promise.resolve(e.rscResponse));return L.current===e.navigationId?t:void 0}if(e.rscFlightProtocol!=null&&e.rscFlightProtocol!==``)return Te.current(e.rscFlightProtocol);if(!e.isStreaming)return X.current(e.to,e.abortSignal,{commit:!1})},o=async(e,t)=>{try{let n=await he(t,y.current?.element,e.navigationId,L.current);return n.kind===`superseded`?null:n.kind===`error`?(pe(e,n.error),null):L.current===e.navigationId?n.payload:null}catch(t){return pe(e,a(t)),null}},s=(e,t)=>{ae({parsedPayload:t,shouldScrollToTop:me(e),navigationId:e.navigationId,transitionTypes:ie({historyKey:e.options.historyKey,replace:e.options.replace}),pendingHistory:e.pendingHistory,startTransition:A.current,currentNavigationIdRef:L,pendingScrollPayloadRef:M,setRenderKey:O,setRscPayload:v,clearHmrError:()=>{K(null)},pendingNavigateCommittedIdRef:V}),t.flightProtocol!=null&&t.flightProtocol!==``&&(W.current=t.flightProtocol),ye(),F.current&&F.current(e)},l=async t=>{try{return{kind:`payload`,payload:await i(t)}}catch(t){return e(t)&&t.name===`AbortError`?{kind:`aborted`}:{kind:`error`,error:a(t)}}},f=async e=>{let n=t(e,le);if(!n||n.navigationId!==L.current)return;j.current={x:window.scrollX,y:window.scrollY},q();let r=await l(n);if(r.kind===`aborted`)return;if(r.kind===`error`){pe(n,r.error),G.current>=3&&Y();return}let i=r.payload;if(i==null&&n.isStreaming&&L.current===n.navigationId||i==null||L.current!==n.navigationId)return;let a=await o(n,i);a!=null&&s(n,a)},p=async()=>{j.current={x:window.scrollX,y:window.scrollY},q();try{await X.current(),O(e=>e+1),K(null)}catch(e){console.error(`HMR refetch error:`,r(e,String(e))),G.current>=3&&Y()}requestAnimationFrame(()=>{window.scrollTo(j.current.x,j.current.y),ve()})},m=e=>{let r=t(e,ue);if(r?.element==null||!ce(r.element)&&!n(r.element))return;let{pathname:i,search:o}=u(),s=++z.current,l=L.current,f=`${i}${o}`;j.current={x:window.scrollX,y:window.scrollY},q();try{r.revalidationKind===1?d.clear():r.revalidatedPath!=null&&r.revalidatedPath!==``?d.invalidate(r.revalidatedPath,o):d.invalidate(i,o);let e=y.current?.element,t=d.getElement(i,o)??(e!=null&&n(e)?null:e??null),p=r.element;(async()=>{try{let e=await R(p);if(s!==z.current||L.current!==l)return;let{pathname:n,search:r}=u();if(`${n}${r}`!==f)return;let i=await R(c(t,e));if(s!==z.current||L.current!==l)return;let a=u();if(`${a.pathname}${a.search}`!==f)return;if(!I(i)){let e=/* @__PURE__ */ Error(`[rari] AppRouter: action flight refresh did not resolve to an <html> document root`);J(e,`parse`,`Action flight refresh failed: ${e.message}`,window.location.pathname),G.current>=3&&Y();return}let o={element:i,rawElement:i};B.current=o,_.startTransition(()=>{v(o),K(null)}),_e(i),ye()}catch(e){if(s!==z.current||L.current!==l)return;let t=a(e);J(t,`parse`,`Action flight refresh failed: ${t.message}`,window.location.pathname),G.current>=3&&Y()}})()}catch(e){let t=a(e);J(t,`parse`,`Action flight refresh failed: ${t.message}`,window.location.pathname),G.current>=3&&Y()}},h=async()=>{try{await X.current(),O(e=>e+1),K(null)}catch(e){console.error(`RSC invalidate error:`,r(e,String(e))),G.current>=3&&Y()}},g=e=>{let n=t(e,de);n&&(P.current.clear(),L.current=n.navigationId,z.current+=1,M.current=null,B.current=null)},b=async()=>{try{await X.current(),K(null)}catch(e){console.error(`Manifest update error:`,r(e,String(e))),G.current>=3&&Y()}},x=e=>{f(e)},S=()=>{p()},C=()=>{h()},w=()=>{b()};return window.addEventListener(`rari:navigation-start`,g),window.addEventListener(`rari:navigate`,x),window.addEventListener(`rari:app-router-rerender`,S),window.addEventListener(`rari:action-flight-refresh`,m),window.addEventListener(`rari:rsc-invalidate`,C),window.addEventListener(`rari:app-router-manifest-updated`,w),()=>{window.removeEventListener(`rari:navigation-start`,g),window.removeEventListener(`rari:navigate`,x),window.removeEventListener(`rari:app-router-rerender`,S),window.removeEventListener(`rari:action-flight-refresh`,m),window.removeEventListener(`rari:rsc-invalidate`,C),window.removeEventListener(`rari:app-router-manifest-updated`,w)}},[]),b(()=>{if(typeof window<`u`&&window.location.hash&&g){let e=window.location.hash.slice(1);requestAnimationFrame(()=>{requestAnimationFrame(()=>{let t=document.getElementById(e);t&&t.scrollIntoView({behavior:`instant`,block:`start`})})})}},[g]);let De=g?.element??o,Z=f(De),[Oe,ke]=C(null),Ae=fe(Z),je=n(Z)&&Ae===void 0,Q=Ae===void 0?n(Z)?null:Z:f(Ae),$=Q!=null&&!n(Q)&&I(Q)?Q:null;if($!=null&&!Object.is($,Oe)&&ke($),je){if(Oe==null)throw Error(`[rari] AppRouter: expected a resolved <html> document root`)}else if($==null)throw Error(`[rari] AppRouter: expected a resolved <html> document root`);return/* @__PURE__ */ E(ee,{children:[ge!=null&&/* @__PURE__ */ T(re,{failure:ge,maxRetries:3,onRefresh:()=>{window.location.reload()},onDismiss:()=>{K(null)}}),je?Oe:$]})}export{z as AppRouterProvider};
|
|
1
|
+
import{f as e,h as t,i as n,r,u as i,x as a}from"../type-guards-BozK2q2n.mjs";import{i as o}from"../navigation-transition-store-dfNJmkIX.mjs";import{isLayoutReuseMarker as s,layoutPathOf as c,mergeFlightRefresh as l,unwrapFulfilledFlightNode as u}from"./merge-flight-refresh.mjs";import{n as d,r as f,t as p}from"../react-helpers-BKmKvCbj.mjs";import{i as m,n as h,r as g,t as _}from"../route-cache-Cgh5HhiB.mjs";import"./action-revalidation-kind.mjs";import{n as v,t as y}from"../preload-modules-D_bnDKi8.mjs";import{n as ee,r as te}from"../form-state-DAygOjc8.mjs";import{c as b}from"react/compiler-runtime";import{Fragment as x,addTransitionType as ne,cloneElement as re,createElement as S,isValidElement as C,startTransition as ie,useCallback as ae,useEffect as w,useLayoutEffect as oe,useRef as T,useState as E,useSyncExternalStore as D}from"react";import{Fragment as se,jsx as O,jsxs as k}from"react/jsx-runtime";import{createFromFetch as ce,createFromReadableStream as le}from"virtual:react-flight-client";const A={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)`},j={padding:`8px 16px`,background:`white`,color:`#dc2626`,border:`none`,borderRadius:`4px`,cursor:`pointer`,fontWeight:`bold`,fontSize:`14px`},M={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`},N={fetch:`Failed to fetch updated content from server.`,parse:`Failed to parse server response.`,stale:`Server returned stale content.`,network:`Network error occurred.`};function P(e){return N[e]}function ue(e){let t=b(27),{failure:n,maxRetries:r,onRefresh:i,onDismiss:a}=e,o,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=/* @__PURE__ */ O(`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=P(n.type),t[2]=n.type,t[3]=c);let l;t[4]===c?l=t[5]:(l=/* @__PURE__ */ O(`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__ */ O(`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__ */ k(`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__ */ O(`button`,{onClick:i,type:`button`,style:j,children:`Refresh Page`}),t[14]=i,t[15]=h);let g;t[16]===a?g=t[17]:(g=/* @__PURE__ */ O(`button`,{onClick:a,type:`button`,style:M,children:`Dismiss`}),t[16]=a,t[17]=g);let _;t[18]!==h||t[19]!==g?(_=/* @__PURE__ */ k(`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__ */ O(`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__ */ k(`div`,{style:A,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 de(e,t,n){g.getShell()??g.ingest(e,t,n)}function F(e){if(e.fromPathname!==`/`&&(e.fromPathname!==e.toPathname||e.fromSearch!==e.search))return{pathname:e.fromPathname,search:e.fromSearch}}function I(e){if(de(e.previousDocument,e.fromPathname,e.fromSearch),f(e.refresh)){if(!g.ingest(e.refresh,e.toPathname,e.search))return{kind:`hard-nav`}}else if(C(e.refresh)){if(!g.ingestSegment(e.refresh,e.toPathname,e.search))return{kind:`hard-nav`}}else return{kind:`hard-nav`};if(g.getShell()==null||!g.hasRoute(e.toPathname,e.search))return{kind:`hard-nav`};let t=d(e.refresh),n=F(e);return f(e.refresh)?{kind:`merged`,element:e.refresh,maySuspend:t,pendingEvictLeaf:n}:{kind:`merged`,element:e.previousDocument,maySuspend:t,pendingEvictLeaf:n}}function L(e,t,n,r){if(f(t))return g.ingest(t,n,r);if(C(t)&&g.getShell()!=null)return g.ingestSegment(t,n,r);let i=l(e,t);return C(t)&&s(t)&&i===e||!f(i)?!1:g.ingest(i,n,r)}function R(e,t){let n=d(e);return f(e)?{kind:`merged`,element:e,maySuspend:n}:f(t)?{kind:`merged`,element:t,maySuspend:n}:{kind:`hard-nav`}}function fe(e){return f(e.previousDocument)&&g.getShell()==null&&!g.ingest(e.previousDocument,e.pathname,e.search)||!L(e.previousDocument,e.refresh,e.pathname,e.search)||g.getShell()==null||!g.hasRoute(e.pathname,e.search)?{kind:`hard-nav`}:R(e.refresh,e.previousDocument)}function pe(e){return e.historyKey!=null&&e.historyKey!==``?[`nav`,`nav-traverse`]:e.replace===!0?[`nav`,`nav-replace`]:[`nav`,`nav-forward`]}function me(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 z(e){e!=null&&typeof window<`u`&&(e.replace===!0?window.history.replaceState(e.state,``,e.url):window.history.pushState(e.state,``,e.url))}function he(e){let{parsedPayload:t,shouldScrollToTop:n,navigationId:r,transitionTypes:i,maySuspend:a=!1,pendingHistory:o,routeLocation:s,startTransition:c=ie,currentNavigationIdRef:l,pendingScrollPayloadRef:u,setRenderKey:d,setRscPayload:f,setRouteLocation:p,clearHmrError:m,pendingNavigateCommittedIdRef:h,pendingEvictLeaf:_}=e;l.current===r&&(a&&z(o),c(()=>{if(l.current===r){if(i!=null)for(let e of i)ne(e);a||z(o),s!=null&&p?.(s),_!=null&&g.evictLeaf(_.pathname,_.search),d(e=>{let r=e+1;return u.current=n?{payload:t,commitKey:r}:null,r}),f(t),m(),h.current=r}}))}function B(){return D(g.subscribe,g.getVersion,g.getVersion)}function V(e){return c(e)!=null&&!m(e)&&!s(e)}function H(e,t,n){if(e==null||e===!1||e===!0)return e;if(Array.isArray(e))return p(e).map(e=>H(e,t,n));if(!C(e))return e;if(m(e)||V(e)){let r=c(e);return r==null?null:S(W,{key:r,layoutPath:r,pathname:t,search:n})}let r=e.props,i=r.children;if(i==null)return e;let a=H(i,t,n);if(Object.is(a,i))return e;let o=p(a),s={...r};return delete s.children,re(e,s,...o.length===0?[null]:o)}function U({layoutPath:e,pathname:t,search:n}){let r=g.readSegmentSnapshot(e,{pathname:t,search:n});return r==null||C(r)&&m(r)?null:g.isDeepestLayout(e,t)?S(x,{key:`${t}${n}`},r):H(r,t,n)}function W(e){let t=b(2);B();let n;return t[0]===e?n=t[1]:(n=U(e),t[0]=e,t[1]=n),n}function G({fallback:e=null,pathname:t,search:n}){let r=g.getShell();if(r!=null){let e=H(r,t,n);return C(e)?e:null}return e!=null&&_(e)?null:e}function ge(e){let t=b(2);B();let n;return t[0]===e?n=t[1]:(n=G(e),t[0]=e,t[1]=n),n}function _e(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 ve(t){if(t==null)return null;if(e(t)){let e=u(t);return e===t||!f(e)?null:e}return f(t)?t:null}const ye=/"timestamp":(\d+)/;function be(e){if(!i(e)||e.name===`AbortError`)return!1;let t=e.message;return t===`Failed to fetch`||t.includes(`NetworkError`)||t.includes(`network error`)||t.includes(`Load failed`)}async function xe(e){await new Promise(t=>{setTimeout(t,e)})}function Se(e){return e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`||C(e)||Array.isArray(e)}function Ce(e){return t(e)&&typeof e.from==`string`&&typeof e.to==`string`&&typeof e.navigationId==`number`&&t(e.options)}function we(e){return t(e)&&`element`in e}function Te(e){return t(e)&&typeof e.navigationId==`number`&&typeof e.targetPath==`string`}function Ee(n){if(!e(n))return n;if(t(n)&&n.status===`fulfilled`)return Se(n.value)?n.value:void 0}function K(e){return f(e)||C(e)&&s(e)}function De(e){let t=e.pendingHistory?.url;if(t!=null&&t!==``)try{return new URL(t,window.location.origin).search}catch{}return h().search}function Oe(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 ke(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 Ae(e,t,n,r,i,a,o,c){let l=await je(e.element);if(r!==n)return{kind:`superseded`};if(!K(l))return{kind:`error`,error:/* @__PURE__ */ Error(`[rari] AppRouter: navigated Flight content did not resolve to an <html> document root`)};let u=ve(t);if(C(l)&&s(l)&&u==null)return{kind:`error`,error:/* @__PURE__ */ Error(`[rari] AppRouter: layout-reuse Flight marker requires a previous <html> document`)};if(u==null)return f(l)?(g.set(a,o,l),{kind:`payload`,payload:{...e,element:l,maySuspend:d(l)}}):{kind:`error`,error:/* @__PURE__ */ Error(`[rari] AppRouter: navigated Flight content did not resolve to an <html> document root`)};let p=I({previousDocument:u,refresh:l,fromPathname:i,toPathname:a,fromSearch:c,search:o});return p.kind===`hard-nav`?{kind:`hard-nav`}:{kind:`payload`,payload:{...e,element:p.element,maySuspend:p.maySuspend,pendingEvictLeaf:p.pendingEvictLeaf}}}async function je(t){let n=v(t);for(let t=0;t<10&&e(n);t+=1)n=v(await n);if(e(n))throw Error(`[rari] AppRouter: Flight content did not resolve to a React node`);return n}function q({children:s,initialPayload:c,onNavigate:l}){let[u,d]=E(c),p=T(c),[m,b]=E(0),[x,ne]=E(()=>h()),re=T(x),S=T({x:0,y:0}),D=T(null),A=T(/* @__PURE__ */ new Map),j=T(/* @__PURE__ */ new Set),M=T(l),N=T(0),P=T(0),de=T(/* @__PURE__ */ new Map),F=T(null),I=T(null),L=T(/* @__PURE__ */ new Map),R=T([]),z=T(null),B=T(0),[V,H]=E(null);w(()=>{re.current=x},[x]),w(()=>{M.current=l},[l]),oe(()=>{let{shouldScroll:e,nextPending:t}=_e(D.current,u,m);D.current=t,e&&window.scrollTo(0,0);let n=I.current;n!=null&&(I.current=null,window.dispatchEvent(new CustomEvent(`rari:navigate-committed`,{detail:{navigationId:n}})))},[u,m]),w(()=>{o()},[m]);let U=ae(t=>{if(t==null||e(t)||!C(t)||t.type!==`html`&&t.type!==`HTML`||_(t))return;let{pathname:n,search:r}=x;g.set(n,r,t)},[x]),W=T(U);w(()=>{W.current=U},[U]),w(()=>{p.current=u,u?.element!=null&&U(u.element)},[u,U]),w(()=>{if(u?.element!=null){let e=u.element;if(t(e)&&`status`in e&&e.status===`rejected`){let t=e.reason;t!=null&&t!==``&&console.error(`[rari] AppRouter: Flight payload rejected:`,t)}}},[u]);let G=()=>{A.current=ee()},ve=()=>{te(A.current)};oe(()=>{let e=F.current;e!=null&&u===e&&(F.current=null,window.scrollTo(S.current.x,S.current.y),ve())},[u,m]);let K=(e,t,n,r)=>{B.current+=1;let i={timestamp:Date.now(),error:e,type:t,details:n,filePath:r,consecutiveFailures:B.current};R.current.push(i),R.current.length>10&&R.current.shift(),B.current>=2&&H(i),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`rari:hmr-failure`,{detail:i}))},q=()=>{setTimeout(()=>{window.location.reload()},1e3)},Me=()=>{B.current>0&&(B.current=0)},Ne=e=>{if(z.current==null||z.current===``)return!1;if(e===z.current)return!0;let t=ye.exec(e);if(t){let e=Number.parseInt(t[1],10);if(Date.now()-e>5e3)return!0}return!1},Pe=e=>{y(e,j.current);let t=new ReadableStream({start(t){t.enqueue(new TextEncoder().encode(e)),t.close()}});return{element:le(t),flightProtocol:e}},Fe=async e=>{let t=await e;if(!t.body)throw Error(`Response has no body stream`);let n=t.clone(),r=ce(Promise.resolve(t));return n.text().then(async e=>{await y(e,j.current),e!==``&&(z.current=e)}).catch(()=>{}),{element:r,flightProtocol:``}},Ie=async(e,t)=>{try{let n=await e.clone().text();if(Ne(n))return L.current.delete(t),`stale`;await y(n,j.current);let r=await je(ce(Promise.resolve(e)));if(!f(r))throw Error(`[rari] AppRouter: refetched Flight content did not resolve to an <html> document root`);return{element:r,flightProtocol:n}}catch(e){if(i(e)&&e.name===`AbortError`)throw e;let t=a(e),n=Error(`Failed to parse RSC Flight protocol: ${t.message}`,{cause:t});return K(n,`parse`,n.message,window.location.pathname),n}},Le=async(e,t,n)=>{let r=e!=null&&e!==``?e:window.location.pathname,o=N.current,s=n?.commit!==!1,c=n?.expectedRoute!=null&&n.expectedSeq!=null?`:hmr:${n.expectedRoute}:${n.expectedSeq}`:``,l=`${o}:${r}${window.location.search}:${s?`commit`:`defer`}${c}`,u=L.current.get(l);if(u)return u;let f=n?.expectedRoute,p=n?.expectedSeq,m=(async()=>{try{let e=r+window.location.search,n=await fetch(e,{headers:{Accept:`text/x-component`,"rari-navigation-id":String(N.current)},cache:`no-store`,signal:t});if(!n.ok){let t=/* @__PURE__ */ Error(`Failed to fetch RSC data: ${n.status} ${n.statusText}`);throw K(t,`fetch`,`HTTP ${n.status} when fetching ${e}`,window.location.pathname),t}let i=await Ie(n,l);if(i===`stale`)return;if(i instanceof Error)throw i;let a=f==null||p==null||de.current.get(f)===p;return N.current===o&&a&&(s&&d(i),i.flightProtocol!=null&&i.flightProtocol!==``&&(z.current=i.flightProtocol),Me()),L.current.delete(l),i}catch(e){throw L.current.delete(l),i(e)&&e.name!==`AbortError`&&!e.message.includes(`Failed to fetch RSC data`)&&!e.message.includes(`Failed to parse`)&&K(e,`network`,`Network error: ${e.message}`,window.location.pathname),a(e)}})();return L.current.set(l,m),m},Re=T(Pe),ze=T(Fe),J=T(Le);w(()=>{Re.current=Pe,ze.current=Fe,J.current=Le}),w(()=>{if(typeof window>`u`)return;let t=async e=>{if(e.rscResponsePromise){let t=await e.rscResponsePromise;if(N.current!==e.navigationId)return;let n=await ze.current(Promise.resolve(t));return N.current===e.navigationId?n:void 0}if(e.rscResponse){let t=await ze.current(Promise.resolve(e.rscResponse));return N.current===e.navigationId?t:void 0}if(e.rscFlightProtocol!=null&&e.rscFlightProtocol!==``)return Re.current(e.rscFlightProtocol);if(!e.isStreaming)return J.current(e.to,e.abortSignal,{commit:!1})},o=async(e,t)=>{try{let n=await Ae(t,p.current?.element,e.navigationId,N.current,e.from,e.to,De(e),re.current.search);if(n.kind===`superseded`)return null;if(n.kind===`hard-nav`){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`?(Oe(e,n.error),null):N.current===e.navigationId?n.payload:null}catch(t){return Oe(e,a(t)),null}},s=(e,t)=>{let n=me(e.pendingHistory,{pathname:e.to,search:De(e)});he({parsedPayload:t,shouldScrollToTop:ke(e),navigationId:e.navigationId,transitionTypes:pe({historyKey:e.options.historyKey,replace:e.options.replace}),maySuspend:t.maySuspend===!0,pendingHistory:e.pendingHistory,routeLocation:n,pendingEvictLeaf:t.pendingEvictLeaf,startTransition:ie,currentNavigationIdRef:N,pendingScrollPayloadRef:D,setRenderKey:b,setRscPayload:d,setRouteLocation:ne,clearHmrError:()=>{H(null)},pendingNavigateCommittedIdRef:I}),t.flightProtocol!=null&&t.flightProtocol!==``&&(z.current=t.flightProtocol),Me(),M.current&&M.current(e)},c=async e=>{try{return{kind:`payload`,payload:await t(e)}}catch(e){return i(e)&&e.name===`AbortError`?{kind:`aborted`}:{kind:`error`,error:a(e)}}},l=async e=>{let t=n(e,Ce);if(!t||t.navigationId!==N.current)return;S.current={x:window.scrollX,y:window.scrollY},G();let r=await c(t);if(r.kind===`aborted`)return;if(r.kind===`error`){Oe(t,r.error),B.current>=3&&q();return}let i=r.payload;if(i==null&&t.isStreaming&&N.current===t.navigationId||i==null||N.current!==t.navigationId)return;let a=await o(t,i);a!=null&&s(t,a)},u=async e=>{let t;for(let n=0;n<3;n+=1)try{return await J.current(void 0,void 0,{commit:!0,expectedRoute:e.expectedRoute,expectedSeq:e.expectedSeq})}catch(e){if(t=e,!be(e)||n===2)throw e;await xe(150*(n+1))}throw a(t)},f=async()=>{let e=N.current,{pathname:t,search:n}=h(),r=`${t}${n}`,i=de.current,a=(i.get(r)??0)+1;i.set(r,a);let o=await u({expectedRoute:r,expectedSeq:a});if(N.current!==e)return!1;let{pathname:s,search:c}=h();return`${s}${c}`!==r||i.get(r)!==a?!1:(o?.element!=null&&W.current(o.element),!0)},m=async()=>{S.current={x:window.scrollX,y:window.scrollY},G();try{if(!await f())return;let e=N.current,{pathname:t,search:n}=h(),r=`${t}${n}`,i={x:S.current.x,y:S.current.y};b(e=>e+1),H(null),requestAnimationFrame(()=>{if(N.current!==e)return;let{pathname:t,search:n}=h();`${t}${n}`===r&&(window.scrollTo(i.x,i.y),ve())})}catch(e){console.error(`HMR refetch error:`,r(e,String(e))),B.current>=3&&q()}},_=t=>{let r=n(t,we);if(r?.element==null||!Se(r.element)&&!e(r.element))return;let{pathname:i,search:o}=h(),s=++P.current,c=N.current,l=`${i}${o}`;S.current={x:window.scrollX,y:window.scrollY},G();try{r.revalidationKind===1?g.clear():r.revalidatedPath!=null&&r.revalidatedPath!==``?g.invalidate(r.revalidatedPath,o):g.invalidate(i,o);let t=p.current?.element,n=g.getElement(i,o)??(t!=null&&e(t)?null:t??null),u=r.element;(async()=>{try{let e=await je(u);if(s!==P.current||N.current!==c)return;let{pathname:t,search:r}=h();if(`${t}${r}`!==l)return;let a=fe({previousDocument:n??null,refresh:e,pathname:i,search:o});if(a.kind===`hard-nav`){window.location.reload();return}let f=a.element;if(s!==P.current||N.current!==c)return;let p=h();if(`${p.pathname}${p.search}`!==l)return;let m={element:f};F.current=m,ie(()=>{d(m),H(null)}),W.current(f),Me()}catch(e){if(s!==P.current||N.current!==c)return;let t=a(e);K(t,`parse`,`Action flight refresh failed: ${t.message}`,window.location.pathname),B.current>=3&&q()}})()}catch(e){let t=a(e);K(t,`parse`,`Action flight refresh failed: ${t.message}`,window.location.pathname),B.current>=3&&q()}},v=async()=>{try{if(!await f())return;b(e=>e+1),H(null)}catch(e){console.error(`RSC invalidate error:`,r(e,String(e))),B.current>=3&&q()}},y=e=>{let t=n(e,Te);t&&(j.current.clear(),N.current=t.navigationId,P.current+=1,D.current=null,F.current=null)},ee=async()=>{try{if(!await f())return;H(null)}catch(e){console.error(`Manifest update error:`,r(e,String(e))),B.current>=3&&q()}},te=e=>{l(e)},x=()=>{m()},C=()=>{v()},ae=()=>{ee()};return window.addEventListener(`rari:navigation-start`,y),window.addEventListener(`rari:navigate`,te),window.addEventListener(`rari:app-router-rerender`,x),window.addEventListener(`rari:action-flight-refresh`,_),window.addEventListener(`rari:rsc-invalidate`,C),window.addEventListener(`rari:app-router-manifest-updated`,ae),()=>{window.removeEventListener(`rari:navigation-start`,y),window.removeEventListener(`rari:navigate`,te),window.removeEventListener(`rari:app-router-rerender`,x),window.removeEventListener(`rari:action-flight-refresh`,_),window.removeEventListener(`rari:rsc-invalidate`,C),window.removeEventListener(`rari:app-router-manifest-updated`,ae)}},[]),w(()=>{if(typeof window<`u`&&window.location.hash&&u){let e=window.location.hash.slice(1);requestAnimationFrame(()=>{requestAnimationFrame(()=>{let t=document.getElementById(e);t&&t.scrollIntoView({behavior:`instant`,block:`start`})})})}},[u]);let Be=u?.element??s,Y=v(Be),[X,Ve]=E(null),He=Ee(Y),Ue=e(Y)&&He===void 0,Z=He===void 0?e(Y)?null:Y:v(He),Q=Z!=null&&!e(Z)&&f(Z)?Z:null;Q!=null&&!Object.is(Q,X)&&!_(Q)&&Ve(Q);let $=Ue?X:Q,We=$!=null&&f($)&&!_($)?$:X!=null&&f(X)&&!_(X)?X:null;if(We==null&&!g.hasRoute(x.pathname,x.search))throw Error(`[rari] AppRouter: expected a resolved <html> document root`);return/* @__PURE__ */ k(se,{children:[V!=null&&/* @__PURE__ */ O(ue,{failure:V,maxRetries:3,onRefresh:()=>{window.location.reload()},onDismiss:()=>{H(null)}}),/* @__PURE__ */ O(ge,{fallback:We,pathname:x.pathname,search:x.search})]})}export{q as AppRouterProvider};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
2
|
//#region src/router/navigation/client-router.d.ts
|
|
3
3
|
export interface ClientRouterProps {
|
|
4
|
-
readonly children:
|
|
4
|
+
readonly children: ReactNode;
|
|
5
5
|
readonly initialRoute: string;
|
|
6
6
|
}
|
|
7
|
-
export declare function ClientRouter({ children, initialRoute }: ClientRouterProps):
|
|
7
|
+
export declare function ClientRouter({ children, initialRoute }: ClientRouterProps): ReactNode;
|
|
8
8
|
//#endregion
|