rari 0.16.0 → 0.17.1
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/api-routes-Dc2tv31o.mjs +1 -0
- package/dist/cli.d.mts +1 -1
- package/dist/cli.mjs +39 -39
- package/dist/constants-CRK2JRKf.mjs +1 -0
- package/dist/{define-CRafeveU.mjs → define-B_ozIapW.mjs} +1 -1
- package/dist/dist-paths-C4EV064W.mjs +1 -0
- package/dist/{execute-B1z6YRUF.mjs → execute-CbhDMAQ3.mjs} +1 -1
- package/dist/feed-NrJzjZyg.mjs +10 -0
- package/dist/font/google-catalog.d.mts +1952 -0
- package/dist/font/google.d.mts +1 -1946
- package/dist/font/google.mjs +1 -1
- package/dist/form-state-DAygOjc8.mjs +1 -0
- package/dist/get-client-component-s7qprTUa.mjs +1 -0
- package/dist/headers.d.mts +1 -1
- package/dist/image/static.d.mts +1 -0
- package/dist/image/static.mjs +1 -0
- package/dist/image.d.mts +4 -35
- package/dist/image.mjs +1 -1
- package/dist/index.d.mts +6 -1
- package/dist/index.mjs +1 -1
- package/dist/mdx/define.mjs +1 -1
- package/dist/mdx.mjs +1 -1
- package/dist/navigation-transition-store-CSKrbtbK.mjs +1 -0
- package/dist/path-CTEC1xmy.mjs +1 -0
- package/dist/platform.mjs +1 -1
- package/dist/preload-modules-Dv_GzGCm.mjs +2 -0
- package/dist/proxy/RariResponse.mjs +1 -1
- package/dist/proxy/runtime-executor.mjs +1 -1
- package/dist/regex-constants-DzXwNGh2.mjs +1 -0
- package/dist/{robots-B1bFAd4J.mjs → robots-BOPIkPcN.mjs} +1 -1
- package/dist/router-Cl4J7j1A.mjs +1 -0
- package/dist/router.d.mts +8 -5
- package/dist/router.mjs +1 -1
- package/dist/{rsc-vite-build-Cpu5suGN.mjs → rsc-vite-build-CSnu8C3P.mjs} +1 -1
- package/dist/runtime/AppRouterProvider.mjs +1 -1
- package/dist/runtime/ClientRouter.mjs +4 -4
- package/dist/runtime/ErrorBoundaryWrapper.mjs +1 -1
- package/dist/runtime/call-server.mjs +1 -1
- package/dist/runtime/entry-client.d.mts +1 -1
- package/dist/runtime/entry-client.mjs +3 -3
- package/dist/runtime/flight-router-state.d.mts +1 -0
- package/dist/runtime/flight-router-state.mjs +1 -1
- package/dist/runtime/merge-flight-refresh.d.mts +4 -0
- package/dist/runtime/merge-flight-refresh.mjs +1 -1
- package/dist/runtime/rsc-client-runtime.d.mts +1 -1
- package/dist/runtime/rsc-client-runtime.mjs +1 -1
- package/dist/serialize-router-state-uOGGpmBr.mjs +1 -0
- package/dist/sitemap--bdIkWl5.mjs +13 -0
- package/dist/static-modules-DBL6iFbg.d.mts +61 -0
- package/dist/{types-Q-x_0kVB.d.mts → types-C8N3Hc8I.d.mts} +1 -0
- package/dist/{types-xTbuE-Js.d.mts → types-DfSnnFaF.d.mts} +3 -1
- package/dist/vite.d.mts +3 -1
- package/dist/vite.mjs +141 -197
- package/dist/{xml-EW5iM39h.mjs → xml-DPsk9WTz.mjs} +1 -1
- package/package.json +22 -19
- package/dist/api-routes-ChRr3O5-.mjs +0 -1
- package/dist/constants-BFdy-wPN.mjs +0 -1
- package/dist/feed-uUGeOZmR.mjs +0 -10
- package/dist/form-state-DZJs9bve.mjs +0 -1
- package/dist/get-client-component-DU5z65us.mjs +0 -1
- package/dist/path-C74rvUep.mjs +0 -1
- package/dist/preload-modules-1i2BJqux.mjs +0 -2
- package/dist/prompt-uaCPq0_A-BW0EkzOD.mjs +0 -45
- package/dist/regex-constants-DBMCJbMw.mjs +0 -1
- package/dist/router-D6X8JHst.mjs +0 -1
- package/dist/runtime/LoadingErrorBoundary.d.mts +0 -10
- package/dist/runtime/LoadingErrorBoundary.mjs +0 -1
- package/dist/sitemap-DJY3OiJ0.mjs +0 -13
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import{i as e,t}from"../navigate-DuyUa6qD.mjs";import{d as n,h as r,i,n as a,v as o}from"../type-guards-BJXKlA6x.mjs";import{r as s}from"../path-CTEC1xmy.mjs";import{t as ee}from"../serialize-router-state-uOGGpmBr.mjs";import{t as c}from"../form-state-DAygOjc8.mjs";import{c as l}from"react/compiler-runtime";import{useEffect as u,useLayoutEffect as d,useRef as f,useState as p}from"react";function m(e,t,n={}){let r=null,i=0,a=0,o=null,s=null,{leading:ee=!1,trailing:c=!0,maxWait:l}=n;function u(t){let n=o,r=s;o=null,s=null,a=t,e.apply(r,n)}function d(e){let n=e-i,r=e-a;return i===0||n>=t||n<0||l!==void 0&&r>=l}function f(){let e=Date.now();if(d(e)){m(e);return}let n=e-i,o=e-a,s=t-n,ee=l===void 0?1/0:l-o;r=setTimeout(f,Math.min(s,ee))}function p(e){a=e,r=setTimeout(f,t),ee&&u(e)}function m(e){if(r=null,c&&o){u(e);return}o=null,s=null}function h(){r!==null&&clearTimeout(r),a=0,o=null,i=0,s=null,r=null}function g(){r!==null&&m(Date.now())}function _(){return r!==null}function v(...e){let n=Date.now(),a=d(n);if(o=e,s=this,i=n,a){if(r===null){p(i);return}
|
|
2
2
|
/* v8 ignore start - edge case: isInvoking true with existing timeout and maxWait defined */
|
|
3
|
-
if(
|
|
3
|
+
if(l!==void 0){r=setTimeout(f,t),u(i);return}}r??=setTimeout(f,t)}return v.cancel=h,v.flush=g,v.pending=_,v}const h=/fetch|networkerror|load failed/i;function g(e,t){return{type:`abort`,message:`Navigation was cancelled`,originalError:e,url:t,timestamp:Date.now(),retryable:!1}}function _(e,t){return{type:`timeout`,message:`Navigation request timed out`,originalError:e,url:t,timestamp:Date.now(),retryable:!0}}function v(e,t,n){if(t===404)return{type:`not-found`,message:`Page not found`,originalError:e,statusCode:t,url:n,timestamp:Date.now(),retryable:!1};if(t>=500)return{type:`server-error`,message:`Server error: ${t}`,originalError:e,statusCode:t,url:n,timestamp:Date.now(),retryable:!0};let r=t===408||t===429;return{type:`fetch-error`,message:`HTTP error: ${t}`,originalError:e,statusCode:t,url:n,timestamp:Date.now(),retryable:r}}function y(e,t){return{type:`network-error`,message:`Network error - check your connection`,originalError:e,url:t,timestamp:Date.now(),retryable:!0}}function b(e,t){return{type:`parse-error`,message:`Failed to parse server response`,
|
|
4
4
|
/* v8 ignore next - defensive check for non-Error values from parse-related condition */
|
|
5
|
-
originalError:a(e),url:t,timestamp:Date.now(),retryable:!1}}function
|
|
5
|
+
originalError:a(e),url:t,timestamp:Date.now(),retryable:!1}}function x(e,t){return{type:`fetch-error`,message:a(e)?.message??`Unknown error occurred`,originalError:a(e),url:t,timestamp:Date.now(),retryable:!1}}function S(e,t){if(n(e)&&e.name===`AbortError`)return g(e,t);if(n(e)&&(e.name===`TimeoutError`||e.message.includes(`timeout`)))return _(e,t);if(n(e)&&`status`in e){let n=e.status;return typeof n==`number`?v(e,n,t):x(e,t)}return e instanceof TypeError&&h.test(e.message)?y(e,t):e instanceof SyntaxError||n(e)&&e.message.includes(`parse`)?b(e,t):x(e,t)}var te=class{onError;constructor(e={}){
|
|
6
6
|
/* v8 ignore next - default no-op callback */
|
|
7
|
-
this.onError=e.onError??(()=>{})}handleError(e,t){let n=C(e,t);return this.onError(n),console.error(`[rari] Navigation:`,n.type,n.message,{url:n.url,statusCode:n.statusCode,retryable:n.retryable}),n}};function te(e,t){try{let n=t!=null&&t!==``?t:window.location.origin,r=typeof URL.parse==`function`?URL.parse(e,n):new URL(e,n);return r!=null&&r.origin!==n}catch{return!1}}function ne(e){try{let t=typeof URL.parse==`function`?URL.parse(e,window.location.origin):new URL(e,window.location.origin);return t==null?e:`${t.pathname}${t.search}${t.hash}`}catch{return e}}var re=class{stateHistory;routeAccessOrder;maxHistorySize;scrollableSelector;constructor(e={}){this.stateHistory=/* @__PURE__ */ new Map,this.routeAccessOrder=[],this.maxHistorySize=e.maxHistorySize!=null&&e.maxHistorySize!==0?e.maxHistorySize:50,this.scrollableSelector=e.scrollableSelector!=null&&e.scrollableSelector!==``?e.scrollableSelector:`[data-scrollable], .scrollable, [style*="overflow"]`}captureState(e){let t={scrollPositions:this.captureScrollPositions(),formData:this.captureFormData(),focusedElement:this.captureFocusedElement()};return this.storeState(e,t),t}captureScrollPositions(){let e=/* @__PURE__ */ new Map;try{e.set(`window`,{x:window.scrollX,y:window.scrollY,element:`window`}),document.querySelectorAll(this.scrollableSelector).forEach((t,n)=>{if(t instanceof HTMLElement){let r=t.id||`scrollable-${n}`;(t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth)&&e.set(r,{x:t.scrollLeft,y:t.scrollTop,element:r})}})}catch{}return e}captureFormData(){let e=/* @__PURE__ */ new Map;try{document.querySelectorAll(`form`).forEach((t,n)=>{let r=t.id||t.name||`form-${n}`,i=new FormData(t);i.entries().next().done||e.set(r,i)})}catch{}return e}captureFocusedElement(){try{let e=document.activeElement;if(e&&e!==document.body){if(e.id)return`#${e.id}`;if((e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&e.name)return`[name="${e.name}"]`}}catch{}return null}storeState(e,t){let n=this.routeAccessOrder.indexOf(e);for(n!==-1&&this.routeAccessOrder.splice(n,1),this.routeAccessOrder.push(e),this.stateHistory.set(e,t);this.routeAccessOrder.length>this.maxHistorySize;){let e=this.routeAccessOrder.shift();e!=null&&e!==``&&this.stateHistory.delete(e)}}restoreState(e){let t=this.stateHistory.get(e);if(!t)return!1;let n=!0;return this.restoreScrollPositions(t.scrollPositions)||(n=!1),this.restoreFormData(t.formData)||(n=!1),t.focusedElement!=null&&t.focusedElement!==``&&this.restoreFocus(t.focusedElement),n}restoreScrollPositions(e){let t=!0;try{e.forEach((e,n)=>{try{if(n===`window`)window.scrollTo(e.x,e.y);else{let r=document.getElementById(n)??document.querySelector(`[data-scrollable-id="${n}"]`);r instanceof HTMLElement?(r.scrollLeft=e.x,r.scrollTop=e.y):t=!1}}catch{t=!1}})}catch(e){console.error(`[rari] Router: Failed to restore scroll positions:`,e),t=!1}return t}restoreFormData(e){let t=!0;try{e.forEach((e,n)=>{try{let r=document.getElementById(n),i=r instanceof HTMLFormElement?r:document.querySelector(`form[name="${n}"]`)??document.querySelectorAll(`form`)[Number.parseInt(n.replace(`form-`,``),10)];i instanceof HTMLFormElement&&l(i,e)||(t=!1)}catch{t=!1}})}catch(e){console.error(`[rari] Router: Failed to restore form data:`,e),t=!1}return t}restoreFocus(e){try{let t=document.querySelector(e);t instanceof HTMLElement&&requestAnimationFrame(()=>{try{t.focus()}catch{}})}catch{}}};function w(e){return o(e)&&typeof e.navigationId==`number`}function T(e){return o(e)&&typeof e.navigationId==`number`&&`error`in e}async function ie(e,t){return t.aborted?{error:new DOMException(`Aborted`,`AbortError`)}:new Promise(n=>{function r(){window.removeEventListener(`rari:navigate-committed`,a),window.removeEventListener(`rari:navigate-error`,o),t.removeEventListener(`abort`,s)}function a(t){i(t,w)?.navigationId===e&&(r(),n(`committed`))}function o(t){let a=i(t,T);a?.navigationId===e&&(r(),n({error:a.error}))}function s(){r(),n({error:new DOMException(`Aborted`,`AbortError`)})}window.addEventListener(`rari:navigate-committed`,a),window.addEventListener(`rari:navigate-error`,o),t.addEventListener(`abort`,s,{once:!0})})}function E(e,t){let n=document.querySelector(e);if(n)t.content&&n.setAttribute(`content`,t.content);else{n=document.createElement(`meta`);for(let[e,r]of Object.entries(t))n.setAttribute(e,r);document.head.appendChild(n)}}function D(e){let t=document.querySelector(e);t&&t.remove()}function O(e){e.title!=null&&e.title!==``&&(document.title=e.title),e.description!=null&&e.description!==``?E(`meta[name="description"]`,{name:`description`,content:e.description}):D(`meta[name="description"]`),e.keywords&&e.keywords.length>0?E(`meta[name="keywords"]`,{name:`keywords`,content:e.keywords.join(`, `)}):D(`meta[name="keywords"]`),e.viewport!=null&&e.viewport!==``&&E(`meta[name="viewport"]`,{name:`viewport`,content:e.viewport})}function k(e){let t=document.querySelector(`link[rel="canonical"]`);if(e===void 0){t&&t.remove();return}if(t)t.setAttribute(`href`,e);else{let t=document.createElement(`link`);t.setAttribute(`rel`,`canonical`),t.setAttribute(`href`,e),document.head.appendChild(t)}}function A(e){if(e===void 0){D(`meta[name="robots"]`);return}let t=[];e.index!==void 0&&t.push(e.index?`index`:`noindex`),e.follow!==void 0&&t.push(e.follow?`follow`:`nofollow`),e.nocache&&t.push(`nocache`),t.length>0?E(`meta[name="robots"]`,{name:`robots`,content:t.join(`, `)}):D(`meta[name="robots"]`)}function ae(e){if(e===void 0){D(`meta[property="og:title"]`),D(`meta[property="og:description"]`),D(`meta[property="og:url"]`),D(`meta[property="og:site_name"]`),D(`meta[property="og:type"]`),document.querySelectorAll(`meta[property="og:image"]`).forEach(e=>{e.remove()});return}if(e.title!=null&&e.title!==``?E(`meta[property="og:title"]`,{property:`og:title`,content:e.title}):D(`meta[property="og:title"]`),e.description!=null&&e.description!==``?E(`meta[property="og:description"]`,{property:`og:description`,content:e.description}):D(`meta[property="og:description"]`),e.url!=null&&e.url!==``?E(`meta[property="og:url"]`,{property:`og:url`,content:e.url}):D(`meta[property="og:url"]`),e.siteName!=null&&e.siteName!==``?E(`meta[property="og:site_name"]`,{property:`og:site_name`,content:e.siteName}):D(`meta[property="og:site_name"]`),e.type!=null&&e.type!==``?E(`meta[property="og:type"]`,{property:`og:type`,content:e.type}):D(`meta[property="og:type"]`),e.images&&e.images.length>0){document.querySelectorAll(`meta[property="og:image"]`).forEach(e=>{e.remove()});for(let t of e.images){let e=document.createElement(`meta`);e.setAttribute(`property`,`og:image`),e.setAttribute(`content`,t),document.head.appendChild(e)}}else document.querySelectorAll(`meta[property="og:image"]`).forEach(e=>{e.remove()})}function j(e){if(e===void 0){D(`meta[name="twitter:card"]`),D(`meta[name="twitter:site"]`),D(`meta[name="twitter:creator"]`),D(`meta[name="twitter:title"]`),D(`meta[name="twitter:description"]`),document.querySelectorAll(`meta[name="twitter:image"]`).forEach(e=>{e.remove()});return}if(e.card!=null&&e.card!==``?E(`meta[name="twitter:card"]`,{name:`twitter:card`,content:e.card}):D(`meta[name="twitter:card"]`),e.site!=null&&e.site!==``?E(`meta[name="twitter:site"]`,{name:`twitter:site`,content:e.site}):D(`meta[name="twitter:site"]`),e.creator!=null&&e.creator!==``?E(`meta[name="twitter:creator"]`,{name:`twitter:creator`,content:e.creator}):D(`meta[name="twitter:creator"]`),e.title!=null&&e.title!==``?E(`meta[name="twitter:title"]`,{name:`twitter:title`,content:e.title}):D(`meta[name="twitter:title"]`),e.description!=null&&e.description!==``?E(`meta[name="twitter:description"]`,{name:`twitter:description`,content:e.description}):D(`meta[name="twitter:description"]`),e.images&&e.images.length>0){document.querySelectorAll(`meta[name="twitter:image"]`).forEach(e=>{e.remove()});for(let t of e.images){let e=document.createElement(`meta`);e.setAttribute(`name`,`twitter:image`),e.setAttribute(`content`,t),document.head.appendChild(e)}}else document.querySelectorAll(`meta[name="twitter:image"]`).forEach(e=>{e.remove()})}function oe(e){O(e),k(e.canonical),A(e.robots),ae(e.openGraph),j(e.twitter)}function M(e){return o(e)}function se(i){let a=u(35),{children:o,initialRoute:s}=i,l;a[0]===s?l=a[1]:(l=()=>({currentRoute:typeof window<`u`?`${window.location.pathname}${window.location.search}`:c(s),navigationId:0,error:null}),a[0]=s,a[1]=l);let[g,_]=m(l),v=p(null),y=p(!0),b;a[2]===s?b=a[3]:(b=typeof window<`u`?`${window.location.pathname}${window.location.search}`:c(s),a[2]=s,a[3]=b);let x=p(b),S;a[4]===s?S=a[5]:(S=typeof window<`u`?`${window.location.pathname}${window.location.search}${window.location.hash}`:c(s),a[4]=s,a[5]=S);let C=p(S),w=p(0),T;a[6]===Symbol.for(`react.memo_cache_sentinel`)?(T=new ee({onError:de}),a[6]=T):T=a[6];let E=p(T),D;a[7]===Symbol.for(`react.memo_cache_sentinel`)?(D=/* @__PURE__ */ new Map,a[7]=D):D=a[7];let O=p(D),k;a[8]===Symbol.for(`react.memo_cache_sentinel`)?(k=new re({maxHistorySize:50}),a[8]=k):k=a[8];let A=p(k),ae=ue,j;a[9]===Symbol.for(`react.memo_cache_sentinel`)?(j=()=>{v.current&&=(v.current.abort(),null)},a[9]=j):j=a[9];let oe=j,M;a[10]===Symbol.for(`react.memo_cache_sentinel`)?(M=()=>{for(let[,e]of O.current.entries())e.abortController.abort();O.current.clear()},a[10]=M):M=a[10];let se=M,N;a[11]===g?N=a[12]:(N=(e,t)=>{O.current.delete(e),y.current&&g.navigationId===t&&_(le)},a[11]=g,a[12]=N);let P=N,F;a[13]===Symbol.for(`react.memo_cache_sentinel`)?(F=(e,t)=>{let n=t===void 0?{}:t,r=`${window.location.pathname}${window.location.search}`,i=e?`${r}#${e}`:r;if(e){let t=document.getElementById(e);t&&t.scrollIntoView({behavior:`smooth`,block:`start`})}i!==`${window.location.pathname}${window.location.search}${window.location.hash}`&&(n.replace?window.history.replaceState(window.history.state,``,i):window.history.pushState(window.history.state,``,i)),C.current=i},a[13]=F):F=a[13];let fe=F,pe=ce,I;if(a[14]===Symbol.for(`react.memo_cache_sentinel`)){let e=(e,t,n)=>{n.historyKey!=null&&n.historyKey!==``?requestAnimationFrame(()=>{A.current.restoreState(e)}):t&&requestAnimationFrame(()=>{let e=n=>{let r=n===void 0?0:n,i=document.getElementById(t);i?i.scrollIntoView({behavior:`smooth`,block:`start`}):r<10&&setTimeout(e,50,r+1)};e()})};I=(t,n,r,i,a)=>{y.current&&w.current===i&&(x.current=t,C.current=a,_(e=>({...e,currentRoute:t,navigationId:i,error:null})),e(t,n,r))},a[14]=I}else I=a[14];let me=I,L;a[15]===P?L=a[16]:(L=(e,t,r,i,a)=>{let o=a===void 0?{}:a;if(n(e)&&e.name===`AbortError`){P(t,r);return}let s=E.current.handleError(e,t);y.current&&(_(e=>({...e,error:s})),window.history.replaceState(window.history.state,``,i)),O.current.delete(t),o.emitEvent!==!1&&window.dispatchEvent(new CustomEvent(`rari:navigate-error`,{detail:{from:i,to:t,error:s,navigationId:r}}))},a[15]=P,a[16]=L);let R=L,he;a[17]!==P||a[18]!==R?(he=async(e,t)=>{let n=t===void 0?{}:t;if(!e||typeof e!=`string`)return;let[r,i]=e.includes(`#`)?e.split(`#`):[e,``],a=c(r);if(a===x.current){fe(i,{replace:n.replace===!0});return}let o=O.current.get(a);if(o)return o.promise;se(),oe();let s=new AbortController;v.current=s,w.current+=1;let l=w.current;window.dispatchEvent(new CustomEvent(`rari:navigation-start`,{detail:{navigationId:l,targetPath:a}}));let u=(async()=>{let e=C.current;try{(n.historyKey==null||n.historyKey===``)&&A.current.captureState(x.current);let t=n.historyKey!=null&&n.historyKey!==``?n.historyKey:ae(),r=window.location.origin+a,o={route:a,navigationId:l,scrollPosition:{x:window.scrollX,y:window.scrollY},timestamp:Date.now(),key:t},c=await fetch(r,{headers:{Accept:`text/x-component`,"rari-navigation-id":String(l)},cache:`no-store`,signal:s.signal});if(!c.ok&&c.status!==404){R(/* @__PURE__ */ Error(`Failed to fetch: ${c.status}`),a,l,e);return}if(s.signal.aborted){P(a,l);return}let u=new URL(c.url),d=u.pathname,f=`${u.pathname}${u.search}`,p={...o,route:f},m=`${f}${i?`#${i}`:``}`;if(w.current!==l)return;let h=ie(l,s.signal);if(window.dispatchEvent(new CustomEvent(`rari:navigate`,{detail:{from:e,to:d,navigationId:l,options:n,abortSignal:s.signal,rscResponse:c,pendingHistory:{url:m,state:p,replace:n.replace===!0}}})),w.current!==l){s.abort();return}let g=await h;if(w.current!==l)return;if(g!==`committed`){R(g.error,a,l,e,{emitEvent:!1});return}pe(c),me(f,i,n,l,m),O.current.delete(a)}catch(t){R(t,a,l,e)}})();return O.current.set(a,{targetPath:a,navigationId:l,promise:u,abortController:s}),u},a[17]=P,a[18]=R,a[19]=he):he=a[19];let z=he,B=p(z),V;a[20]===z?V=a[21]:(V=()=>(B.current=z,()=>{B.current=null}),a[20]=z,a[21]=V),f(V);let ge=p(null),H,U;a[22]===Symbol.for(`react.memo_cache_sentinel`)?(H=()=>{ge.current??=h((e,t)=>{B.current?.(e,t)},50,{leading:!0,trailing:!0,maxWait:200})},U=[],a[22]=H,a[23]=U):(H=a[22],U=a[23]),f(H,U);let W;a[24]===Symbol.for(`react.memo_cache_sentinel`)?(W=e=>{if(e.button!==0||e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)return;let t=e.target instanceof Element?e.target:null;for(;t&&!(t instanceof HTMLAnchorElement);)t=t.parentElement;if(!(t instanceof HTMLAnchorElement))return;let n=t;if(n.target&&n.target!==`_self`||n.hasAttribute(`download`))return;let r=n.getAttribute(`href`);if(r==null||r===``||te(r))return;if(r.startsWith(`#`)){e.preventDefault();let t=r.slice(1),n=document.getElementById(t);if(n){n.scrollIntoView({behavior:`smooth`,block:`start`});let e=`${window.location.pathname}${window.location.search}#${t}`;window.history.pushState(window.history.state,``,e),C.current=e}return}e.preventDefault();let i=ne(r);ge.current?.(i,{replace:!1})},a[24]=W):W=a[24];let _e=W,G;a[25]===Symbol.for(`react.memo_cache_sentinel`)?(G=e=>{let t=`${window.location.pathname}${window.location.search}${window.location.hash}`,n=r(e.state)?e.state:null;B.current&&B.current(t,{replace:!0,scroll:!1,historyKey:n?.key})},a[25]=G):G=a[25];let ve=G,K;a[26]===Symbol.for(`react.memo_cache_sentinel`)?(K=()=>{let e=r(window.history.state)?window.history.state:null;if(e?.key==null||e.key===``){let e={route:`${window.location.pathname}${window.location.search}`,navigationId:0,scrollPosition:{x:window.scrollX,y:window.scrollY},timestamp:Date.now(),key:ae()};window.history.replaceState(e,``,window.location.pathname+window.location.search+window.location.hash)}},a[26]=K):K=a[26];let q;a[27]===s?q=a[28]:(q=[s],a[27]=s,a[28]=q),d(K,q);let J;a[29]===Symbol.for(`react.memo_cache_sentinel`)?(J=e=>{if(e.persisted){let e=window.location.pathname;A.current.captureState(e)}},a[29]=J):J=a[29];let ye=J,Y;a[30]===Symbol.for(`react.memo_cache_sentinel`)?(Y=e=>{if(e.persisted){let e=window.location.pathname,t=r(window.history.state)?window.history.state:null;requestAnimationFrame(()=>{A.current.restoreState(e),t?.scrollPosition&&window.scrollTo(t.scrollPosition.x,t.scrollPosition.y)})}},a[30]=Y):Y=a[30];let be=Y,X,Z;a[31]===Symbol.for(`react.memo_cache_sentinel`)?(X=()=>(document.addEventListener(`click`,_e),window.addEventListener(`popstate`,ve),window.addEventListener(`pagehide`,ye),window.addEventListener(`pageshow`,be),()=>{document.removeEventListener(`click`,_e),window.removeEventListener(`popstate`,ve),window.removeEventListener(`pagehide`,ye),window.removeEventListener(`pageshow`,be)}),Z=[],a[31]=X,a[32]=Z):(X=a[31],Z=a[32]),d(X,Z);let Q,$;return a[33]===Symbol.for(`react.memo_cache_sentinel`)?(Q=()=>(y.current=!0,e(async(e,t)=>B.current?.(e,t)??Promise.resolve()),()=>{y.current=!1,t(),oe(),se(),ge.current?.cancel()}),$=[],a[33]=Q,a[34]=$):(Q=a[33],$=a[34]),d(Q,$),o}function ce(e){try{let t=e.headers.get(`x-rari-metadata`);if(t!=null&&t!==``){let e=s(decodeURIComponent(t));e&&M(e)&&oe(e)}}catch(e){console.warn(`[rari] Router: Failed to parse x-rari-metadata header:`,e)}}function le(e){return{...e}}function ue(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`hk-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,11)}`}function de(e){console.error(`[rari] Router: Navigation error:`,e)}export{se as ClientRouter};
|
|
7
|
+
this.onError=e.onError??(()=>{})}handleError(e,t){let n=S(e,t);return this.onError(n),console.error(`[rari] Navigation:`,n.type,n.message,{url:n.url,statusCode:n.statusCode,retryable:n.retryable}),n}};function ne(e,t){try{let n=t!=null&&t!==``?t:window.location.origin,r=typeof URL.parse==`function`?URL.parse(e,n):new URL(e,n);return r!=null&&r.origin!==n}catch{return!1}}function re(e){try{let t=typeof URL.parse==`function`?URL.parse(e,window.location.origin):new URL(e,window.location.origin);return t==null?e:`${t.pathname}${t.search}${t.hash}`}catch{return e}}var ie=class{stateHistory;routeAccessOrder;maxHistorySize;scrollableSelector;constructor(e={}){this.stateHistory=/* @__PURE__ */ new Map,this.routeAccessOrder=[],this.maxHistorySize=e.maxHistorySize!=null&&e.maxHistorySize!==0?e.maxHistorySize:50,this.scrollableSelector=e.scrollableSelector!=null&&e.scrollableSelector!==``?e.scrollableSelector:`[data-scrollable], .scrollable, [style*="overflow"]`}captureState(e){let t={scrollPositions:this.captureScrollPositions(),formData:this.captureFormData(),focusedElement:this.captureFocusedElement()};return this.storeState(e,t),t}captureScrollPositions(){let e=/* @__PURE__ */ new Map;try{e.set(`window`,{x:window.scrollX,y:window.scrollY,element:`window`}),document.querySelectorAll(this.scrollableSelector).forEach((t,n)=>{if(t instanceof HTMLElement){let r=t.id||`scrollable-${n}`;(t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth)&&e.set(r,{x:t.scrollLeft,y:t.scrollTop,element:r})}})}catch{}return e}captureFormData(){let e=/* @__PURE__ */ new Map;try{document.querySelectorAll(`form`).forEach((t,n)=>{let r=t.id||t.name||`form-${n}`,i=new FormData(t);i.entries().next().done||e.set(r,i)})}catch{}return e}captureFocusedElement(){try{let e=document.activeElement;if(e&&e!==document.body){if(e.id)return`#${e.id}`;if((e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&e.name)return`[name="${e.name}"]`}}catch{}return null}storeState(e,t){let n=this.routeAccessOrder.indexOf(e);for(n!==-1&&this.routeAccessOrder.splice(n,1),this.routeAccessOrder.push(e),this.stateHistory.set(e,t);this.routeAccessOrder.length>this.maxHistorySize;){let e=this.routeAccessOrder.shift();e!=null&&e!==``&&this.stateHistory.delete(e)}}restoreState(e){let t=this.stateHistory.get(e);if(!t)return!1;let n=!0;return this.restoreScrollPositions(t.scrollPositions)||(n=!1),this.restoreFormData(t.formData)||(n=!1),t.focusedElement!=null&&t.focusedElement!==``&&this.restoreFocus(t.focusedElement),n}restoreScrollPositions(e){let t=!0;try{e.forEach((e,n)=>{try{if(n===`window`)window.scrollTo(e.x,e.y);else{let r=document.getElementById(n)??document.querySelector(`[data-scrollable-id="${n}"]`);r instanceof HTMLElement?(r.scrollLeft=e.x,r.scrollTop=e.y):t=!1}}catch{t=!1}})}catch(e){console.error(`[rari] Router: Failed to restore scroll positions:`,e),t=!1}return t}restoreFormData(e){let t=!0;try{e.forEach((e,n)=>{try{let r=document.getElementById(n),i=r instanceof HTMLFormElement?r:document.querySelector(`form[name="${n}"]`)??document.querySelectorAll(`form`)[Number.parseInt(n.replace(`form-`,``),10)];i instanceof HTMLFormElement&&c(i,e)||(t=!1)}catch{t=!1}})}catch(e){console.error(`[rari] Router: Failed to restore form data:`,e),t=!1}return t}restoreFocus(e){try{let t=document.querySelector(e);t instanceof HTMLElement&&requestAnimationFrame(()=>{try{t.focus()}catch{}})}catch{}}};function C(e){return o(e)&&typeof e.navigationId==`number`}function w(e){return o(e)&&typeof e.navigationId==`number`&&`error`in e}function ae(e){let t=e.headers.get(`x-rari-metadata`);if(t!=null&&t!==``)try{let e=JSON.parse(decodeURIComponent(t));if(!o(e))return;if(typeof e.title==`string`&&e.title!==``&&(document.title=e.title),typeof e.description==`string`&&e.description!==``){let t=document.querySelector(`meta[name="description"]`);t||(t=document.createElement(`meta`),t.setAttribute(`name`,`description`),document.head.appendChild(t)),t.setAttribute(`content`,e.description)}}catch{}}async function oe(e,t){return t.aborted?{error:new DOMException(`Aborted`,`AbortError`)}:new Promise(n=>{function r(){window.removeEventListener(`rari:navigate-committed`,a),window.removeEventListener(`rari:navigate-error`,o),t.removeEventListener(`abort`,s)}function a(t){i(t,C)?.navigationId===e&&(r(),n(`committed`))}function o(t){let a=i(t,w);a?.navigationId===e&&(r(),n({error:a.error}))}function s(){r(),n({error:new DOMException(`Aborted`,`AbortError`)})}window.addEventListener(`rari:navigate-committed`,a),window.addEventListener(`rari:navigate-error`,o),t.addEventListener(`abort`,s,{once:!0})})}function T(i){let a=l(35),{children:o,initialRoute:c}=i,h;a[0]===c?h=a[1]:(h=()=>({currentRoute:typeof window<`u`?`${window.location.pathname}${window.location.search}`:s(c),navigationId:0,error:null}),a[0]=c,a[1]=h);let[g,_]=p(h),v=f(null),y=f(!0),b;a[2]===c?b=a[3]:(b=typeof window<`u`?`${window.location.pathname}${window.location.search}`:s(c),a[2]=c,a[3]=b);let x=f(b),S;a[4]===c?S=a[5]:(S=typeof window<`u`?`${window.location.pathname}${window.location.search}${window.location.hash}`:s(c),a[4]=c,a[5]=S);let C=f(S),w=f(0),T;a[6]===Symbol.for(`react.memo_cache_sentinel`)?(T=new te({onError:le}),a[6]=T):T=a[6];let ue=f(T),E;a[7]===Symbol.for(`react.memo_cache_sentinel`)?(E=/* @__PURE__ */ new Map,a[7]=E):E=a[7];let D=f(E),O;a[8]===Symbol.for(`react.memo_cache_sentinel`)?(O=new ie({maxHistorySize:50}),a[8]=O):O=a[8];let k=f(O),de=ce,A;a[9]===Symbol.for(`react.memo_cache_sentinel`)?(A=()=>{v.current&&=(v.current.abort(),null)},a[9]=A):A=a[9];let fe=A,j;a[10]===Symbol.for(`react.memo_cache_sentinel`)?(j=()=>{for(let[,e]of D.current.entries())e.abortController.abort();D.current.clear()},a[10]=j):j=a[10];let pe=j,M;a[11]===g?M=a[12]:(M=(e,t)=>{D.current.delete(e),y.current&&g.navigationId===t&&_(se)},a[11]=g,a[12]=M);let N=M,P;a[13]===Symbol.for(`react.memo_cache_sentinel`)?(P=(e,t)=>{let n=t===void 0?{}:t,r=`${window.location.pathname}${window.location.search}`,i=e?`${r}#${e}`:r;if(e){let t=document.getElementById(e);t&&t.scrollIntoView({behavior:`smooth`,block:`start`})}i!==`${window.location.pathname}${window.location.search}${window.location.hash}`&&(n.replace?window.history.replaceState(window.history.state,``,i):window.history.pushState(window.history.state,``,i)),C.current=i},a[13]=P):P=a[13];let me=P,F;if(a[14]===Symbol.for(`react.memo_cache_sentinel`)){let e=(e,t,n)=>{n.historyKey!=null&&n.historyKey!==``?requestAnimationFrame(()=>{k.current.restoreState(e)}):t&&requestAnimationFrame(()=>{let e=n=>{let r=n===void 0?0:n,i=document.getElementById(t);i?i.scrollIntoView({behavior:`smooth`,block:`start`}):r<10&&setTimeout(e,50,r+1)};e()})};F=(t,n,r,i,a)=>{y.current&&w.current===i&&(x.current=t,C.current=a,_(e=>({...e,currentRoute:t,navigationId:i,error:null})),e(t,n,r))},a[14]=F}else F=a[14];let he=F,I;a[15]===N?I=a[16]:(I=(e,t,r,i,a)=>{let o=a===void 0?{}:a;if(n(e)&&e.name===`AbortError`){N(t,r);return}let s=ue.current.handleError(e,t);y.current&&(_(e=>({...e,error:s})),window.history.replaceState(window.history.state,``,i)),D.current.delete(t),o.emitEvent!==!1&&window.dispatchEvent(new CustomEvent(`rari:navigate-error`,{detail:{from:i,to:t,error:s,navigationId:r}}))},a[15]=N,a[16]=I);let L=I,R;a[17]!==N||a[18]!==L?(R=async(e,t)=>{let n=t===void 0?{}:t;if(!e||typeof e!=`string`)return;let[r,i]=e.includes(`#`)?e.split(`#`):[e,``],a=s(r);if(a===x.current){me(i,{replace:n.replace===!0});return}let o=D.current.get(a);if(o)return o.promise;pe(),fe();let c=new AbortController;v.current=c,w.current+=1;let l=w.current;window.dispatchEvent(new CustomEvent(`rari:navigation-start`,{detail:{navigationId:l,targetPath:a}}));let u=(async()=>{let e=C.current;try{(n.historyKey==null||n.historyKey===``)&&k.current.captureState(x.current);let t=n.historyKey!=null&&n.historyKey!==``?n.historyKey:de(),r=window.location.origin+a,o={route:a,navigationId:l,scrollPosition:{x:window.scrollX,y:window.scrollY},timestamp:Date.now(),key:t},s=await fetch(r,{headers:{Accept:`text/x-component`,"rari-navigation-id":String(l),"rari-router-state":ee()},cache:`no-store`,signal:c.signal});if(!s.ok&&s.status!==404){L(/* @__PURE__ */ Error(`Failed to fetch: ${s.status}`),a,l,e);return}if(c.signal.aborted){N(a,l);return}let u=new URL(s.url),d=u.pathname,f=`${u.pathname}${u.search}`,p={...o,route:f},m=`${f}${i?`#${i}`:``}`;if(w.current!==l)return;let h=oe(l,c.signal);if(window.dispatchEvent(new CustomEvent(`rari:navigate`,{detail:{from:e,to:d,navigationId:l,options:n,abortSignal:c.signal,rscResponse:s,pendingHistory:{url:m,state:p,replace:n.replace===!0}}})),w.current!==l){c.abort();return}let g=await h;if(w.current!==l)return;if(g!==`committed`){L(g.error,a,l,e,{emitEvent:!1});return}he(f,i,n,l,m),ae(s),D.current.delete(a)}catch(t){L(t,a,l,e)}})();return D.current.set(a,{targetPath:a,navigationId:l,promise:u,abortController:c}),u},a[17]=N,a[18]=L,a[19]=R):R=a[19];let z=R,B=f(z),V;a[20]===z?V=a[21]:(V=()=>(B.current=z,()=>{B.current=null}),a[20]=z,a[21]=V),d(V);let ge=f(null),H,U;a[22]===Symbol.for(`react.memo_cache_sentinel`)?(H=()=>{ge.current??=m((e,t)=>{B.current?.(e,t)},50,{leading:!0,trailing:!0,maxWait:200})},U=[],a[22]=H,a[23]=U):(H=a[22],U=a[23]),d(H,U);let W;a[24]===Symbol.for(`react.memo_cache_sentinel`)?(W=e=>{if(e.button!==0||e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)return;let t=e.target instanceof Element?e.target:null;for(;t&&!(t instanceof HTMLAnchorElement);)t=t.parentElement;if(!(t instanceof HTMLAnchorElement))return;let n=t;if(n.target&&n.target!==`_self`||n.hasAttribute(`download`))return;let r=n.getAttribute(`href`);if(r==null||r===``||ne(r))return;if(r.startsWith(`#`)){e.preventDefault();let t=r.slice(1),n=document.getElementById(t);if(n){n.scrollIntoView({behavior:`smooth`,block:`start`});let e=`${window.location.pathname}${window.location.search}#${t}`;window.history.pushState(window.history.state,``,e),C.current=e}return}e.preventDefault();let i=re(r);ge.current?.(i,{replace:!1})},a[24]=W):W=a[24];let _e=W,G;a[25]===Symbol.for(`react.memo_cache_sentinel`)?(G=e=>{let t=`${window.location.pathname}${window.location.search}${window.location.hash}`,n=r(e.state)?e.state:null;B.current&&B.current(t,{replace:!0,scroll:!1,historyKey:n?.key})},a[25]=G):G=a[25];let ve=G,K;a[26]===Symbol.for(`react.memo_cache_sentinel`)?(K=()=>{let e=r(window.history.state)?window.history.state:null;if(e?.key==null||e.key===``){let e={route:`${window.location.pathname}${window.location.search}`,navigationId:0,scrollPosition:{x:window.scrollX,y:window.scrollY},timestamp:Date.now(),key:de()};window.history.replaceState(e,``,window.location.pathname+window.location.search+window.location.hash)}},a[26]=K):K=a[26];let q;a[27]===c?q=a[28]:(q=[c],a[27]=c,a[28]=q),u(K,q);let J;a[29]===Symbol.for(`react.memo_cache_sentinel`)?(J=e=>{if(e.persisted){let e=window.location.pathname;k.current.captureState(e)}},a[29]=J):J=a[29];let ye=J,Y;a[30]===Symbol.for(`react.memo_cache_sentinel`)?(Y=e=>{if(e.persisted){let e=window.location.pathname,t=r(window.history.state)?window.history.state:null;requestAnimationFrame(()=>{k.current.restoreState(e),t?.scrollPosition&&window.scrollTo(t.scrollPosition.x,t.scrollPosition.y)})}},a[30]=Y):Y=a[30];let be=Y,X,Z;a[31]===Symbol.for(`react.memo_cache_sentinel`)?(X=()=>(document.addEventListener(`click`,_e),window.addEventListener(`popstate`,ve),window.addEventListener(`pagehide`,ye),window.addEventListener(`pageshow`,be),()=>{document.removeEventListener(`click`,_e),window.removeEventListener(`popstate`,ve),window.removeEventListener(`pagehide`,ye),window.removeEventListener(`pageshow`,be)}),Z=[],a[31]=X,a[32]=Z):(X=a[31],Z=a[32]),u(X,Z);let Q,$;return a[33]===Symbol.for(`react.memo_cache_sentinel`)?(Q=()=>(y.current=!0,e(async(e,t)=>B.current?.(e,t)??Promise.resolve()),()=>{y.current=!1,t(),fe(),pe(),ge.current?.cancel()}),$=[],a[33]=Q,a[34]=$):(Q=a[33],$=a[34]),u(Q,$),o}function se(e){return{...e}}function ce(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`hk-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,11)}`}function le(e){console.error(`[rari] Router: Navigation error:`,e)}export{T as ClientRouter};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{u as e,v as t}from"../type-guards-BJXKlA6x.mjs";import{t as n}from"../timer-Duul5JHq.mjs";import{r}from"../rari-global-5vGzhToD.mjs";import{Component as i}from"react";import{jsx as a,jsxs as o}from"react/jsx-runtime";function s(n){if(e(n))return n;if(t(n)){let t=n.default??n;return e(t)?t:null}return null}var c=class extends i{_isMounted=!1;_pendingTimer=null;constructor(e){super(e),this.state={hasError:!1,error:null,ErrorComponent:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidMount(){this._isMounted=!0}componentWillUnmount(){this._isMounted=!1,this._pendingTimer=n(this._pendingTimer)}componentDidCatch(e,t){console.error(`[rari] Error boundary caught error:`,e,t);let n=this.props.errorComponentId;if(n!==``){let e=r();if(n in e){let t=e[n],r=s(t.component);r?this.setState({ErrorComponent:r}):t.loader&&!t.loading&&(t.loading=!0,t.loader().then(e=>{let n=s(e);n&&(t.component=n,t.registered=!0,this.setState({ErrorComponent:n})),t.loading=!1}).catch(e=>{t.loading=!1,console.error(`[rari] Failed to load error component ${n}:`,e)}))}}}reset=()=>{this._pendingTimer=n(this._pendingTimer),this._pendingTimer=setTimeout(()=>{this._isMounted&&this.setState({hasError:!1,error:null,ErrorComponent:null}),this._pendingTimer=null},50)};render(){if(this.state.hasError&&this.state.error){let{ErrorComponent:e}=this.state;return e?/* @__PURE__ */ a(e,{error:this.state.error,reset:this.reset}):/* @__PURE__ */ o(`div`,{className:`rari-error`,role:`alert`,style:{color:`red`,border:`1px solid red`,padding:`10px`,borderRadius:`4px`,backgroundColor:`#fff5f5`},children:[/* @__PURE__ */ a(`strong`,{children:`Error loading content: `}),this.state.error.message]})}return this.props.children}};export{c as ErrorBoundaryWrapper};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as e,v as t}from"../type-guards-BJXKlA6x.mjs";import{
|
|
1
|
+
import{d as e,v as t}from"../type-guards-BJXKlA6x.mjs";import{t as n}from"../serialize-router-state-uOGGpmBr.mjs";import{scheduleActionFlightRefresh as r}from"./action-flight-refresh.mjs";import{createFromFetch as i,createTemporaryReferenceSet as a,encodeReply as o}from"virtual:react-flight-client";const s=3e4;function c(e){if(!t(e))return e;let{"~rariSkipRefresh":n,...r}=e;return r}function l(){return typeof window<`u`?window.location.pathname+window.location.search:`/`}const u=/* @__PURE__ */ new Set([`http:`,`https:`]);function d(e){if(typeof window<`u`)try{let t=new URL(e,window.location.href);if(!u.has(t.protocol))return;t.href!==window.location.href&&(window.location.href=t.href)}catch{}}async function f(e,t){let s=a(),{headers:l,body:u}=p(await o(t,{temporaryReferences:s}));l.Accept=`text/x-component`,l[`rsc-action-id`]=e,l[`rari-router-state`]=n();let d=await m(e,l,u),_=h(d);if(_!=null)return _;await g(e,d);let v=await i(Promise.resolve(d),{callServer:f,temporaryReferences:s}),y=v.a,b=y instanceof Promise?await y:y;return r(d,v,b),c(b)}function p(e){let t={};return typeof e==`string`&&(t[`Content-Type`]=`text/plain;charset=UTF-8`),{headers:t,body:e}}async function m(t,n,r){try{return await fetch(l(),{method:`POST`,headers:n,body:r,signal:AbortSignal.timeout(s)})}catch(n){throw n instanceof DOMException&&n.name===`TimeoutError`||e(n)&&n.name===`AbortError`?Error(`Server action "${t}" timed out after ${s}ms`):n}}function h(e){let t=e.headers.get(`x-action-redirect`);if(t==null||t===``)return null;let[n=``]=t.split(`;`);return n!==``&&d(n),{redirect:n}}async function g(e,t){let n=t.headers.get(`content-type`),r=n!=null&&n!==``?n:``;if(r.startsWith(`text/x-component`))return;let i=t.status>=400&&r.startsWith(`text/plain`)?await t.text().catch(()=>t.statusText):`Server action "${e}" failed with status ${t.status}: ${t.statusText}`;throw Error(i)}export{f as callServer};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{i as e,n as t,
|
|
1
|
+
import{i as e,n as t,p as n,r,v as i}from"../type-guards-BJXKlA6x.mjs";import{t as a}from"../router-Cl4J7j1A.mjs";import{a as o,n as s,r as c}from"../rari-global-5vGzhToD.mjs";import{n as l,t as u}from"../preload-modules-Dv_GzGCm.mjs";import*as d from"react";import{createFromFetch as f,createFromReadableStream as p}from"virtual:react-flight-client";import{createRoot as m,hydrateRoot as h}from"react-dom/client";import{AppRouterProvider as g}from"virtual:app-router-provider";import{ClientRouter as _}from"virtual:client-router";import"virtual:rsc-integration.ts";function v(e,t){if(e.querySelector(`.rari-error[data-rari-hydration-failure]`))return;let n=document.createElement(`div`);n.className=`rari-error`,n.setAttribute(`data-rari-hydration-failure`,`true`),n.setAttribute(`role`,`alert`),n.style.cssText=`color:red;border:1px solid red;padding:10px;border-radius:4px;background-color:#fff5f5;margin:10px 0;`;let r=document.createElement(`strong`);r.textContent=`Failed to load page: `,n.append(r,document.createTextNode(t)),e.prepend(n)}function y(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_COMMENT);for(;t.nextNode();){let e=t.currentNode;if(e.nodeType===8&&`data`in e){let t=e.data;if(t===`$`||t===`$?`||t===`/$`)return!0}}return!!(e.querySelector(`[data-reactroot]`)||e.querySelectorAll(`template[data-rri]`).length>0)}function b(e){let t=e.tagName;if(t===`SCRIPT`||t===`STYLE`||t===`LINK`||t===`META`||t===`NOSCRIPT`)return!0;let n=typeof e.getAttribute==`function`?e.getAttribute.bind(e):null;return n==null?!1:n(`data-rari-nav-transition`)!=null||n(`aria-hidden`)===`true`}function x(e){let t=e.firstElementChild;for(;t!=null&&b(t);)t=t.nextElementSibling;return t}function S(e){if(y(e))return!0;let t=x(e);return t!==null&&!t.classList.contains(`rari-error`)}function C(e){return y(e)}function w(e){e.querySelectorAll(`.rari-error:not([data-rari-hydration-failure])`).forEach(e=>{e.remove()})}function T(e,t,n){return d.createElement(e,t,n)}async function E(e){let t=l(e);for(let e=0;e<10&&n(t);e+=1)t=l(await t);if(n(t))throw Error(`[rari] Failed to resolve Flight element to a React node`);return t}function D(e){return d.isValidElement(e)&&(e.type===`html`||e.type===`HTML`)}function O(e){if(!D(e))return v(document.body,`RSC payload did not resolve to an <html> document root. Try refreshing the page.`),console.error(`[rari] Hydration skipped: Flight content is not a document root`),!1;let t=d.createElement(g,{initialPayload:{element:e}});return t=T(_,{initialRoute:window.location.pathname},t),t=T(a,{initialPathname:window.location.pathname},t),j(t),!0}function k(){Reflect.set(globalThis,`__rari_client_ready`,!0),window.dispatchEvent(new CustomEvent(`rari:client-ready`))}function A(e){if(e===``)return;let t=()=>{document.title.trim()===``&&(document.title=e)};t(),queueMicrotask(t),requestAnimationFrame(()=>{t(),requestAnimationFrame(t)})}function j(e){let t=document.documentElement,n=document.title.trim();C(t)?(w(t),h(document,e,{onRecoverableError(e){import.meta.env.DEV&&console.warn(`[rari] Hydration mismatch:`,e)}})):m(document).render(e),A(n),k()}
|
|
2
2
|
/*! @preserve CLIENT_COMPONENT_IMPORTS_PLACEHOLDER */
|
|
3
|
-
|
|
3
|
+
c(),s();
|
|
4
4
|
/*! @preserve CLIENT_COMPONENT_REGISTRATIONS_PLACEHOLDER */
|
|
5
|
-
function
|
|
5
|
+
function M(){let e=Reflect.get(globalThis,`__rari_f`);if(Array.isArray(e))return e}function N(e){return i(e)&&typeof e.rscRow==`string`}function P(e){return Array.isArray(e)&&typeof e[1]==`string`}function F(){return!!M()?.some(e=>e!==0)}function I(){let e=M();if(e?.length==null||e.length===0)return null;let t=``,n=[];for(let r of e)r!==0&&(typeof r==`string`?t+=r:P(r)&&n.push(r[1]));if(n.length>0){let e=n.map(e=>Uint8Array.from(atob(e),e=>e.charCodeAt(0))),t=e.reduce((e,t)=>e+t.length,0),r=new Uint8Array(t),i=0;for(let t of e)r.set(t,i),i+=t.length;return r}return t?new TextEncoder().encode(t):null}async function L(t,n){let r=new TextDecoder().decode(t);await u(r);let i=o(),a=i.streaming,s=!!(a?.bufferedRows&&a.bufferedRows.length>0);if(n.streaming&&(a?.complete===void 0||s)){let n=new ReadableStream({start(n){let r=!1;n.enqueue(t);let a=t=>{if(r)return;let i=e(t,N);i&&n.enqueue(new TextEncoder().encode(`\n${i.rscRow}`))},o=()=>{r||(r=!0,n.close(),window.removeEventListener(`rari:html-stream-row`,a),window.removeEventListener(`rari:stream-complete`,o))};if(window.addEventListener(`rari:html-stream-row`,a),window.addEventListener(`rari:stream-complete`,o),i.streaming?.bufferedRows){let e=[...i.streaming.bufferedRows];for(let t of e)n.enqueue(new TextEncoder().encode(`\n${t}`));i.streaming.bufferedRows=[]}i.streaming?.complete&&o()}});return p(n)}let c=new ReadableStream({start(e){e.enqueue(t),e.close()}});return p(c)}async function R(e){let t=`Could not load interactive page data.`,n;try{n=await L(e,{streaming:!1})}catch(e){t=r(e,`Failed to parse embedded RSC payload.`);try{let e=window.location.pathname+window.location.search,r=await fetch(e,{headers:{Accept:`text/x-component`},cache:`no-store`});r.ok?n=await f(Promise.resolve(r)):t=`Failed to fetch RSC payload fallback: HTTP ${r.status}.`}catch(e){t=r(e,`Failed to fetch RSC payload fallback.`),console.error(`[rari] Failed to fetch RSC payload fallback:`,e)}}return n==null?(v(document.body,`${t} Try refreshing the page.`),console.error(`[rari] Hydration skipped: failed to load RSC payload`),{ok:!1,errorMessage:t}):(O(await E(n)),{ok:!0,errorMessage:t})}async function z(){try{let e=window.location.pathname+window.location.search,t=await fetch(e,{headers:{Accept:`text/x-component`},cache:`no-store`});if(!t.ok&&t.status!==404)throw Error(`Failed to fetch RSC data: ${t.status}`);if(!t.body)throw Error(`RSC response has no body`);return await f(Promise.resolve(t))}catch(e){if(e instanceof Promise)throw e;return console.error(`[rari] Failed to fetch initial RSC data:`,e),null}}function B(){return new ReadableStream({start(t){let n=n=>{let r=e(n,N);r&&t.enqueue(new TextEncoder().encode(`${r.rscRow}\n`))},r=()=>{t.close(),window.removeEventListener(`rari:html-stream-row`,n),window.removeEventListener(`rari:stream-complete`,r)};window.addEventListener(`rari:html-stream-row`,n),window.addEventListener(`rari:stream-complete`,r);let i=o();if(i.streaming?.bufferedRows){let e=[...i.streaming.bufferedRows];i.streaming.bufferedRows=[];for(let n of e)t.enqueue(new TextEncoder().encode(`${n}\n`))}i.streaming?.complete&&r()}})}async function V(){try{return await p(B())}catch(e){return console.error(`[rari] Failed to process streaming RSC payload:`,e),null}}async function H(e){try{return await L(e,{streaming:!0})}catch(e){return console.error(`[rari] Failed to parse embedded RSC payload:`,e),console.error(`[rari] Error stack:`,t(e)?.stack??`no stack`),null}}async function U(){let e=F(),t=I(),n=document.documentElement,r=S(document.body)||y(n),i=o().streaming,a=!!(i?.bufferedRows&&i.bufferedRows.length>0);try{if(r&&e&&t){await R(t);return}let n=!e&&!a&&!r,i;if(n?i=await z():e&&t?i=await H(t):a&&(i=await V()),i==null)throw Error(`No RSC data available for hydration`);O(await E(i))}catch(e){console.error(`[rari] Error rendering app:`,e)}}function W(){let e=import.meta.hot;if(!e)return{};let t=e.data;return i(t)?{hasRendered:t.hasRendered===!0}:{}}function G(){let e=import.meta.hot;if(!e)return;let t=e.data;i(t)&&(t.hasRendered=!0)}(!import.meta.hot||W().hasRendered!==!0)&&(U().catch(e=>{console.error(`[rari] Fatal error:`,e)}),G());export{U as renderApp};
|
|
@@ -7,4 +7,5 @@ export declare function buildFlightRouterState(pathname: string): FlightRouterSt
|
|
|
7
7
|
export declare function segmentPathFromRouterState(tree: FlightRouterState): SegmentPath;
|
|
8
8
|
export declare function segmentPathFromPathname(pathname: string): SegmentPath;
|
|
9
9
|
export declare function pathnameFromSegmentPath(segmentPath: SegmentPath): string;
|
|
10
|
+
export declare function sharedSegmentPath(fromPathname: string, toPathname: string): SegmentPath;
|
|
10
11
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=`children`;function t(e){let t=e.length;for(;t>1&&e[t-1]===`/`;)--t;return e.slice(0,t)}function n(n){let r=n===`/`||n===``?`/`:t(n)||`/`,i=r===`/`?[]:r.slice(1).split(`/`).filter(Boolean),a=[``,{}];for(let t=i.length-1;t>=0;--t)a=[i[t],{[e]:a}];return[``,{[e]:a}]}function r(e){let t=[],n=e;for(;n;){let e=n[0],r=n[1];e&&t.push(e),n=r.children}return t}function i(e){return r(n(e))}function a(e){return e.length===0?`/`:`/${e.join(`/`)}`}export{n as buildFlightRouterState,a as pathnameFromSegmentPath,i as segmentPathFromPathname,r as segmentPathFromRouterState};
|
|
1
|
+
const e=`children`;function t(e){let t=e.length;for(;t>1&&e[t-1]===`/`;)--t;return e.slice(0,t)}function n(n){let r=n===`/`||n===``?`/`:t(n)||`/`,i=r===`/`?[]:r.slice(1).split(`/`).filter(Boolean),a=[``,{}];for(let t=i.length-1;t>=0;--t)a=[i[t],{[e]:a}];return[``,{[e]:a}]}function r(e){let t=[],n=e;for(;n;){let e=n[0],r=n[1];e&&t.push(e),n=r.children}return t}function i(e){return r(n(e))}function a(e){return e.length===0?`/`:`/${e.join(`/`)}`}function o(e,t){let n=i(e),r=i(t),a=[],o=Math.min(n.length,r.length);for(let e=0;e<o&&n[e]===r[e];e+=1)a.push(n[e]);return a}export{n as buildFlightRouterState,a as pathnameFromSegmentPath,i as segmentPathFromPathname,r as segmentPathFromRouterState,o as sharedSegmentPath};
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
//#region src/runtime/flight/merge-refresh.d.ts
|
|
3
|
+
export declare const LAYOUT_REUSE_ELEMENT = "rari-layout-reuse";
|
|
4
|
+
export declare const LAYOUT_REUSE_PATH_PROP = "data-rari-layout-path";
|
|
5
|
+
export declare function isLayoutReuseMarker(element: React.ReactElement): boolean;
|
|
6
|
+
export declare function spliceLayoutReuseChildren(current: React.ReactNode, nextPage: React.ReactNode, layoutPath?: string): React.ReactNode;
|
|
3
7
|
export declare function mergeFlightRefresh(current: React.ReactNode, refresh: React.ReactNode): React.ReactNode;
|
|
4
8
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{l as e,o as t,s as n}from"../type-guards-BJXKlA6x.mjs";import*as r from"react";function
|
|
1
|
+
import{l as e,o as t,s as n}from"../type-guards-BJXKlA6x.mjs";import*as r from"react";const i=`rari-layout-reuse`,a=`data-rari-layout-path`;function o(e){return r.isValidElement(e)}function s(t){return e(t.type)}function c(e){return e.type===`head`||e.type===`HEAD`}function l(e){return e.type===`html`||e.type===`HTML`}function u(e){return e.type===`body`||e.type===`BODY`}function d(e){return e.type===i}function f(e){let t=m(e)[a];return typeof t==`string`&&t!==``?t:void 0}function p(e){let t={...e};return delete t.children,t}function m(e){return t(e)}function h(e,t){if(!s(e)||!s(t))return!1;let r=n(e.type)?e.type.$$id:void 0,i=n(t.type)?t.type.$$id:void 0;return r==null||r===``||i==null||i===``||r!==i?!1:(e.key??null)===(t.key??null)}function g(e){return b(m(e).children)}function _(e){return Array.isArray(e)&&e.some(e=>Array.isArray(e))}function v(e,t){let n=e.key,i=typeof n==`string`&&n!==``?`${t}:${n.replace(/^\.+/,``)}`:t;return r.cloneElement(e,{key:i})}function ee(e,t,n){return Array.isArray(e)?y(e,t==null?`.${n}`:`${t}:${n}`):e==null||e===!1||e===!0?[]:o(e)&&t!=null?[v(e,`${t}:${n}`)]:[e]}function y(e,t){if(!Array.isArray(e))return e==null||e===!1||e===!0?[]:o(e)&&t!=null?[v(e,t)]:[e];let n=[];for(let r=0;r<e.length;r+=1)n.push(...ee(e[r],t,r));return n}function b(e){return e==null||e===!1||e===!0?[]:o(e)||typeof e==`string`||typeof e==`number`?[e]:Array.isArray(e)?y(e,null):r.Children.toArray(e)}function x(e){return o(e)?d(e)?!0:b(m(e).children).some(e=>x(e)):!1}function te(e){let t=e.type;return t===`title`||t===`TITLE`||t===`meta`||t===`META`||t===`link`||t===`LINK`}function S(e){if(e.type!==`link`&&e.type!==`LINK`)return!1;let t=m(e).rel;if(typeof t!=`string`||t===``)return!1;let n=t.toLowerCase();return n===`stylesheet`||n===`preload`||n===`modulepreload`||n===`preconnect`||n===`dns-prefetch`||n===`icon`||n===`shortcut icon`||n===`apple-touch-icon`}function C(e){return e.type===r.Fragment}function w(e){let t=[];for(let n of e){if(o(n)&&C(n)){t.push(...w(g(n)));continue}t.push(n)}return t}function T(e){if(e.type!==`meta`&&e.type!==`META`)return!1;let t=m(e);return t.charSet!=null||t.charset!=null||typeof t.httpEquiv==`string`&&t.httpEquiv.toLowerCase()===`content-type`||typeof t.name==`string`&&t.name.toLowerCase()===`viewport`}function E(e,t){let n=m(e);return w(t).some(e=>{if(!o(e)||!T(e))return!1;let t=m(e);return n.charSet!=null||n.charset!=null?t.charSet!=null||t.charset!=null:typeof n.httpEquiv==`string`&&n.httpEquiv.toLowerCase()===`content-type`?typeof t.httpEquiv==`string`&&t.httpEquiv.toLowerCase()===`content-type`:typeof t.name==`string`&&t.name.toLowerCase()===`viewport`})}function D(e){return e.type===`title`||e.type===`TITLE`}function O(e){if(e.type!==`meta`&&e.type!==`META`)return!1;let t=m(e).name;return typeof t==`string`&&t.toLowerCase()===`description`}function ne(e){return w(e).some(e=>o(e)&&D(e))}function re(e){return w(e).some(e=>o(e)&&O(e))}function ie(e,t){let n=m(e),r=w(g(e)),i=g(t),a=w(i),s=ne(a),c=re(a);return P(e,n,[...r.filter(e=>{if(!o(e))return!0;if(D(e))return!s;if(e.type===`meta`||e.type===`META`)return T(e)?!E(e,i):O(e)?!c:!1;if(!S(e))return!te(e);let t=m(e);return!a.some(e=>{if(!o(e)||!S(e))return!1;let n=m(e);return t.rel!=null&&t.rel===n.rel&&t.href===n.href})}),...a])}function k(e){return e.length===0?null:e.length===1?e[0]:[...e]}function A(e){let t=[];for(let n of b(e))t.push(j(n));return t}function j(e){if(Array.isArray(e))return k(A(e));if(!o(e))return e;if(d(e))return k(A(m(e).children));let t=m(e),n=b(t.children);if(n.length===0)return e;let r=A(n);return!_(t.children)&&r.every((e,t)=>e===n[t])?e:P(e,t,k(r))}function M(e,t){if(e.length===0)return[j(t)];if(e.length===1)return[$(e[0],t)];let n=[],r=!1;for(let i of e)!r&&o(i)?(r=!0,n.push($(i,t))):n.push(i);return r?n:[j(t)]}function N(e,t){let n=[],r=0;for(let i of t){if(o(i)&&d(i)){n.push(...M(e.slice(r),i)),r=e.length;continue}let t=e[r];n.push(t===void 0?j(i):$(t,i)),r+=1}return r<e.length&&n.push(...e.slice(r)),k(n)}function ae(e,t){let n=b(e),r=b(t);return n.length===0||r.length===0?j(t):r.some(e=>o(e)&&d(e))?N(n,r):n.length===r.length?k(n.map((e,t)=>$(e,r[t]))):j(t)}function P(e,t,n){let i=b(n);return r.cloneElement(e,p(t),...i.length===0?[null]:i)}function F(e,t){let n=g(e);for(let r=0;r<n.length;r+=1){let i=n[r];if(o(i)&&f(i)===t)return{parent:e,slotIndex:r}}for(let e=0;e<n.length;e+=1){let r=n[e];if(!o(r))continue;let i=F(r,t);if(i!=null)return i}return null}function I(e){return e.type===`main`||e.type===`MAIN`||g(e).some(e=>o(e)&&I(e))}const L=/* @__PURE__ */ new Set([.../* @__PURE__ */ new Set(/* @__PURE__ */ `area.base.br.col.embed.hr.img.input.link.meta.param.source.track.wbr.AREA.BASE.BR.COL.EMBED.HR.IMG.INPUT.LINK.META.PARAM.SOURCE.TRACK.WBR`.split(`.`)),`script`,`style`,`iframe`,`textarea`,`noscript`,`template`,`canvas`,`video`,`audio`,`object`,`embed`,`svg`,`math`,`select`,`title`,`SCRIPT`,`STYLE`,`IFRAME`,`TEXTAREA`,`NOSCRIPT`,`TEMPLATE`,`CANVAS`,`VIDEO`,`AUDIO`,`OBJECT`,`EMBED`,`SVG`,`MATH`,`SELECT`,`TITLE`]);function oe(e){return typeof e.type!=`string`||L.has(e.type)?!1:g(e).length===0}function se(e,t){return h(e,t)?!0:e.type===t.type&&(e.key??null)===(t.key??null)}function ce(e){let t=e.type;return t===`nav`||t===`NAV`||t===`header`||t===`HEADER`||t===`footer`||t===`FOOTER`||t===`aside`||t===`ASIDE`}function R(e){return e.type===`main`||e.type===`MAIN`}function z(e){let t=m(e).role;if(typeof t!=`string`||t===``)return!1;let n=t.toLowerCase();return n===`status`||n===`alert`||n===`alertdialog`||n===`log`}function B(e){return typeof e.type==`string`&&!L.has(e.type)&&!ce(e)&&!z(e)}function V(e){return s(e)||C(e)}function H(e,t){return z(e)?!1:B(t)?B(e):V(t)?V(e):!1}function U(e){let t=e.findIndex(e=>o(e)&&R(e));if(t>=0)return t;for(let t=0;t<e.length;t+=1){let n=e[t];if(o(n)&&B(n)&&I(n))return t}for(let t=e.length-1;t>=0;--t){let n=e[t];if(o(n)&&B(n))return t}for(let t=e.length-1;t>=0;--t){let n=e[t];if(o(n)&&V(n))return t}return-1}function W(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(n!=null&&n!==!1&&n!==!0&&!o(n)&&(typeof n==`string`||typeof n==`number`))return t}return-1}function le(e){return R(e)||I(e)?!0:g(e).some(e=>o(e)&&B(e))}function ue(e,t){let n=e.length;for(let t=e.length-1;t>=0;--t){let r=e[t];if(o(r)&&(r.type===`footer`||r.type===`FOOTER`)){n=t;continue}break}return[...e.slice(0,n),t,...e.slice(n)]}function de(e,t){let n=e.findIndex(e=>o(e)&&se(e,t));if(n>=0){let r=[...e];return r[n]=$(e[n],t),r}let r=U(e);if(r<0)return null;let i=e[r];return o(i)&&(R(i)||I(i))?G(e,r,i,t):null}function G(e,t,n,r){let i=[...e];return i[t]=P(n,m(n),q(n,r)),i}function K(e,t,n,r){let i=o(n)&&(!V(n)||le(n)),a=[];for(let s=0;s<e.length;s+=1){let c=e[s];if(s===t){a.push(i?P(n,m(n),r):r);continue}o(n)&&o(c)&&H(c,n)||a.push(c)}return a}function q(e,t){let n=g(e);if(n.length===1&&o(n[0]))return $(n[0],t);if(n.length===0)return t;if(o(t)){let e=de(n,t);if(e!=null)return e}let r=U(n);if(r<0){let e=W(n);return e>=0?K(n,e,n[e],t):ue(n,t)}let i=n[r];return o(i)&&(R(i)||I(i))?G(n,r,i,t):K(n,r,i,t)}function J(e,t,n){let r=F(e,n);if(r==null)return null;let i=m(r.parent),a=g(r.parent),s=[...a],c=a[r.slotIndex];return s[r.slotIndex]=o(c)?P(c,m(c),q(c,t)):t,Z(e,r.parent,P(r.parent,i,s))}function Y(e,t,n,r,i){let a=[...n];return a[r]=i,P(e,t,a)}function fe(e,t,n){let r=m(e),i=g(e);if(e.type===`main`||e.type===`MAIN`)return P(e,r,q(e,t));if(i.length===1&&o(i[0]))return P(e,r,X(i[0],t,n));let a=i.findIndex(e=>o(e)&&(e.type===`main`||e.type===`MAIN`));if(a>=0)return Y(e,r,i,a,X(i[a],t,n));for(let a=0;a<i.length;a+=1){let s=i[a];if(o(s)&&I(s))return Y(e,r,i,a,X(s,t,n))}for(let n=0;n<i.length;n+=1){let a=i[n];if(o(a)&&oe(a))return Y(e,r,i,n,P(a,m(a),q(a,t)))}return P(e,r,q(e,t))}function X(e,t,n){if(!o(e))return t;if(o(t)&&d(t)){let r=f(t);return X(e,m(t).children,r??n)}if(n!=null&&n!==``){let r=J(e,t,n);if(r!=null)return r}return fe(e,t,n)}function Z(e,t,n){if(e===t)return n;let r=m(e),i=g(e),a=[],s=!1;for(let e of i){if(!o(e)){a.push(e);continue}if(e===t){s=!0,a.push(n);continue}let r=Z(e,t,n);r!==e&&(s=!0),a.push(r)}return s?P(e,r,a):e}function pe(e,t){let n=m(e),r=g(e),i=g(t),a=r.find(e=>o(e)&&c(e)),s=i.find(e=>o(e)&&c(e)),l=r.find(e=>o(e)&&u(e)),d=i.find(e=>o(e)&&u(e)),f=o(a)&&o(s)?ie(a,s):o(a)?a:s,p=o(l)&&o(d)?$(l,d):o(l)?l:d,h=[];return f!=null&&h.push(f),p!=null&&h.push(p),P(e,n,h)}function me(e,t,n){let r=m(e),i=g(e),a=i.findIndex(e=>o(e)&&u(e)),s=a>=0?i[a]:void 0,c=o(s)?X(s,t.children,n):X(e,t.children,n);if(o(s)&&a>=0){let t=[...i];return t[a]=c,P(e,r,t)}return P(e,r,c)}function Q(e,t){let n=m(e),r=m(t),i=b(r.children);if(i.length===1&&o(i[0])&&d(i[0])){let t=i[0];return X(e,m(t).children,f(t))}let a=ae(n.children,r.children);return a===r.children?t:x(t)?P(e,n,a):P(t,r,a)}function $(e,t){if(e==null)return j(t);if(t==null)return e;if(!o(e)||!o(t))return t;if(d(t)){let n=m(t),r=f(t);return l(e)?me(e,n,r):X(e,n.children,r)}return l(e)&&l(t)&&x(t)?pe(e,t):c(e)||c(t)?t:h(e,t)?x(t)?Q(e,t):t:e.type===t.type?Q(e,t):t}export{i as LAYOUT_REUSE_ELEMENT,a as LAYOUT_REUSE_PATH_PROP,d as isLayoutReuseMarker,$ as mergeFlightRefresh,X as spliceLayoutReuseChildren};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{v as e}from"../type-guards-BJXKlA6x.mjs";import{a as t,i as n,n as r,r as i,t as a}from"../rari-global-5vGzhToD.mjs";import{n as o,r as s}from"../get-client-component-
|
|
1
|
+
import{v as e}from"../type-guards-BJXKlA6x.mjs";import{a as t,i as n,n as r,r as i,t as a}from"../rari-global-5vGzhToD.mjs";import{n as o,r as s}from"../get-client-component-s7qprTUa.mjs";if(n().isDevelopment=process.env.NODE_ENV!==`production`,i(),a(),r(),typeof window<`u`&&(o(),Reflect.set(globalThis,`__rari_rsc_require__`,s)),typeof window<`u`){let e=t();e.streaming??={bufferedRows:[]}}if(import.meta.hot){function t(e){if(!e)return!1;try{return n().serverComponents?.has(e)===!0}catch{return!1}}let r=!1,i=[],a=/* @__PURE__ */ new Map;function o(e,t,n){a.set(e,async e=>{n(e)&&await t(e)}),import.meta.hot.on(e,t=>{(async()=>{if(!r){i.push({event:e,data:t});return}try{let n=a.get(e);n&&await n(t)}catch(t){console.error(`[rari] HMR: Error in handler for '${e}':`,t)}})()})}function s(t){return e(t)&&typeof t.filePath==`string`&&t.filePath!==``}function c(t){return e(t)&&Array.isArray(t.serverComponents)}function l(t){return e(t)&&typeof t.path==`string`&&t.path!==``}function u(t){return e(t)}function d(t){return e(t)&&typeof t.filePath==`string`&&t.filePath!==``}function f(t){return e(t)&&typeof t.filePath==`string`&&t.filePath!==``}o(`rari:register-server-component`,e=>{let t=n();t.serverComponents??=/* @__PURE__ */ new Set,t.serverComponents.add(e.filePath)},s),o(`rari:server-components-registry`,e=>{let t=n();t.serverComponents??=/* @__PURE__ */ new Set;for(let n of e.serverComponents)t.serverComponents.add(n)},c),o(`vite:beforeFullReload`,e=>{t(e.path)&&window.dispatchEvent(new CustomEvent(`rari:rsc-invalidate`,{detail:{filePath:e.path}}))},l),o(`rari:server-component-updated`,e=>{let n=e.id!=null&&e.id!==``?e.id:e.componentId,r=e.t!=null&&e.t!==0?e.t:e.timestamp;n!=null&&n!==``?window.dispatchEvent(new CustomEvent(`rari:rsc-invalidate`,{detail:{componentId:n,filePath:e.filePath!=null&&e.filePath!==``?e.filePath:e.file,type:`server-component`,timestamp:r}})):e.path!=null&&e.path!==``&&t(e.path)&&window.dispatchEvent(new CustomEvent(`rari:rsc-invalidate`,{detail:{filePath:e.path}}))},u);function p(e){if(e.title!=null&&e.title!==``&&(document.title=e.title),e.description==null||e.description===``)return;let t=document.querySelector(`meta[name="description"]`);t||(t=document.createElement(`meta`),t.setAttribute(`name`,`description`),document.head.appendChild(t)),t.setAttribute(`content`,e.description)}function m(t){let n=e(t)&&t.success===!0,r=e(t)&&t.reloaded===!0,i=e(t)&&t.content_unchanged===!0,a=e(t)&&typeof t.error==`string`?t.error:`Component reload unsuccessful`;return{ok:n||r,contentUnchanged:i,errorMessage:a}}async function h(e){if(e.routePath!=null&&e.routePath!==``||e.affectedRoutes!=null&&e.affectedRoutes.length!==0)try{let t=await fetch(`/_rari/hmr`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`register`,file_path:e.filePath})});if(!t.ok)throw Error(`Component reload failed: ${t.status}`);let n=m(await t.json());if(!n.ok)throw Error(n.errorMessage);if(n.contentUnchanged)return;await fetch(`/_rari/hmr`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`invalidate`,componentId:e.routePath!=null&&e.routePath!==``?e.routePath:e.filePath,filePath:e.filePath})}),e.metadataChanged&&e.metadata&&p(e.metadata),window.dispatchEvent(new CustomEvent(`rari:app-router-rerender`,{detail:{routePath:e.routePath,affectedRoutes:e.affectedRoutes??(e.routePath==null?[]:[e.routePath]),currentPath:window.location.pathname,preserveParams:!0}}))}catch(e){console.error(`[rari] HMR: App router update failed:`,e)}}o(`rari:app-router-updated`,h,d),o(`rari:server-action-updated`,e=>{window.dispatchEvent(new CustomEvent(`rari:rsc-invalidate`,{detail:{filePath:e.filePath,type:`server-action`}}))},f),i.length>0?(async()=>{try{let e=[...i];i.length=0;for(let{event:t,data:n}of e){let e=a.get(t);e&&await e(n)}}catch(e){console.error(`[rari] HMR: Error during event replay:`,e)}finally{r=!0}})():r=!0}export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{buildFlightRouterState as e}from"./runtime/flight-router-state.mjs";function t(){if(typeof window>`u`)return{pathname:`/`,search:``,tree:e(`/`)};let t=window.location.pathname;return{pathname:t,search:window.location.search,tree:e(t)}}function n(){return JSON.stringify(t())}export{n as t};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import{v as e}from"./type-guards-BJXKlA6x.mjs";import{t}from"./xml-DPsk9WTz.mjs";import{i as n,n as r,t as i}from"./execute-CbhDMAQ3.mjs";import{promises as a}from"node:fs";import o from"node:path";const s=/[^\w-]/g;function c(e){return(typeof e==`string`?new Date(e):e).toISOString()}function l(e){return[` <image:image>`,` <image:loc>${t(e)}</image:loc>`,` </image:image>`].join(`
|
|
2
|
+
`)}function u(e){let n=[` <image:image>`,` <image:loc>${t(e.loc)}</image:loc>`];return e.title!=null&&e.title!==``&&n.push(` <image:title>${t(e.title)}</image:title>`),e.caption!=null&&e.caption!==``&&n.push(` <image:caption>${t(e.caption)}</image:caption>`),e.geoLocation!=null&&e.geoLocation!==``&&n.push(` <image:geo_location>${t(e.geoLocation)}</image:geo_location>`),e.license!=null&&e.license!==``&&n.push(` <image:license>${t(e.license)}</image:license>`),n.push(` </image:image>`),n.join(`
|
|
3
|
+
`)}function d(e){let t=[];for(let n of e)typeof n==`string`?t.push(l(n)):t.push(u(n));return t.join(`
|
|
4
|
+
`)}function f(e){return[` <video:video>`,` <video:title>${t(e.title)}</video:title>`,` <video:thumbnail_loc>${t(e.thumbnail_loc)}</video:thumbnail_loc>`,` <video:description>${t(e.description)}</video:description>`,...p(e),...m(e),...h(e),...g(e),` </video:video>`].join(`
|
|
5
|
+
`)}function p(e){let n=[];return e.content_loc!=null&&e.content_loc!==``&&n.push(` <video:content_loc>${t(e.content_loc)}</video:content_loc>`),e.player_loc!=null&&e.player_loc!==``&&n.push(` <video:player_loc>${t(e.player_loc)}</video:player_loc>`),n}function m(e){let n=[];return e.duration!==void 0&&n.push(` <video:duration>${e.duration}</video:duration>`),e.expiration_date!=null&&e.expiration_date!==``&&n.push(` <video:expiration_date>${t(e.expiration_date)}</video:expiration_date>`),e.rating!==void 0&&n.push(` <video:rating>${e.rating}</video:rating>`),e.view_count!==void 0&&n.push(` <video:view_count>${e.view_count}</video:view_count>`),e.publication_date!=null&&e.publication_date!==``&&n.push(` <video:publication_date>${t(e.publication_date)}</video:publication_date>`),n}function h(e){let t=[];return e.family_friendly!==void 0&&t.push(` <video:family_friendly>${e.family_friendly?`yes`:`no`}</video:family_friendly>`),e.requires_subscription!==void 0&&t.push(` <video:requires_subscription>${e.requires_subscription?`yes`:`no`}</video:requires_subscription>`),e.live!==void 0&&t.push(` <video:live>${e.live?`yes`:`no`}</video:live>`),t}function g(e){let n=[];if(e.restriction&&n.push(` <video:restriction relationship="${t(e.restriction.relationship)}">${t(e.restriction.content)}</video:restriction>`),e.platform&&n.push(` <video:platform relationship="${t(e.platform.relationship)}">${t(e.platform.content)}</video:platform>`),e.uploader){let r=e.uploader.info!=null&&e.uploader.info!==``?` info="${t(e.uploader.info)}"`:``;n.push(` <video:uploader${r}>${t(e.uploader.name)}</video:uploader>`)}if(e.tag)for(let r of e.tag)n.push(` <video:tag>${t(r)}</video:tag>`);return n}function _(e){return e.map(e=>f(e)).join(`
|
|
6
|
+
`)}function v(e){let t=e.some(e=>e.images&&e.images.length>0),n=e.some(e=>e.videos&&e.videos.length>0),r=e.some(e=>e.alternates?.languages),i=[`xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"`];return t&&i.push(`xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"`),n&&i.push(`xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"`),r&&i.push(`xmlns:xhtml="http://www.w3.org/1999/xhtml"`),i}function y(e,n){e.push(` <url>`),e.push(` <loc>${t(n.url)}</loc>`),n.lastModified!=null&&e.push(` <lastmod>${c(n.lastModified)}</lastmod>`),n.changeFrequency&&e.push(` <changefreq>${n.changeFrequency}</changefreq>`),n.priority!==void 0&&e.push(` <priority>${n.priority}</priority>`)}function b(e,n){if(n.alternates?.languages)for(let[r,i]of Object.entries(n.alternates.languages))e.push(` <xhtml:link rel="alternate" hreflang="${t(r)}" href="${t(i)}" />`)}function x(e,t){t.images&&t.images.length>0&&e.push(d(t.images)),t.videos&&t.videos.length>0&&e.push(_(t.videos))}function S(e){let t=[`<?xml version="1.0" encoding="UTF-8"?>`,`<urlset ${v(e).join(` `)}>`];for(let n of e)y(t,n),b(t,n),x(t,n),t.push(` </url>`);return t.push(`</urlset>`),t.join(`
|
|
7
|
+
`)}
|
|
8
|
+
/* v8 ignore start - file system operations, better tested in integration/e2e */
|
|
9
|
+
async function C(e,t=[`.ts`,`.tsx`,`.js`,`.jsx`,`.mjs`,`.json`]){let r=await n({appDir:e,staticFileName:`sitemap.xml`,dynamicBaseName:`sitemap`,extensions:t});return r?[r]:[]}function w(e){return typeof e==`function`||Array.isArray(e)}function T(t){return e(t)?w(t.default):!1}async function E(e,t,n={},r){let a=await i({virtualId:`\0virtual:sitemap`,sourcePath:e.path,sourceCode:t,aliases:n,projectRoot:r,kind:`sitemap`,pluginName:`virtual-sitemap`,label:`sitemap`});if(!T(a))throw Error(`Sitemap module must export a default sitemap array or sitemap generator function`);return a}async function D(e,t){let n=await e.generateSitemaps(),r=o.join(t,`sitemap`);await a.mkdir(r,{recursive:!0});let i=/* @__PURE__ */ new Map;for(let{id:t}of n)try{let n=t.replace(s,`_`);(!n||n.length===0)&&(n=`_`);let c=i.get(n);if(c!==void 0)throw Error(`Duplicate sanitized sitemap ID "${n}": original IDs "${c}" and "${t}" collide`);i.set(n,t);let l=typeof e.default==`function`?await e.default({id:t}):e.default;if(!Array.isArray(l))throw Error(`Sitemap default export must resolve to a sitemap entry array`);let u=S(l),d=o.join(r,`${n}.xml`);await a.writeFile(d,u)}catch(e){throw Error(`Failed to generate sitemap for id "${t}"`,{cause:e})}}async function O(e,t){let n=typeof e.default==`function`?await e.default():e.default;if(!Array.isArray(n))throw Error(`Sitemap default export must resolve to a sitemap entry array`);let r=S(n),i=o.join(t,`sitemap.xml`);await a.writeFile(i,r)}
|
|
10
|
+
/* v8 ignore start - file system operations and dynamic imports, better tested in integration/e2e */
|
|
11
|
+
async function k(e){let{appDir:t,extensions:n,outDir:i,aliases:s={}}=e,c=await C(t,n);if(c.length===0)return!1;await a.mkdir(i,{recursive:!0});let l=c[0];if(l.type===`static`){let e=o.join(i,`sitemap.xml`);return await a.copyFile(l.path,e),!0}try{let e=await E(l,await a.readFile(l.path,`utf-8`),s,r(t));return typeof e.generateSitemaps==`function`?await D(e,i):await O(e,i),!0}catch(e){return console.error(`[rari] Failed to build/execute sitemap file:`,e),!1}}
|
|
12
|
+
/* v8 ignore stop */
|
|
13
|
+
export{k as generateSitemapFiles};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
//#region src/image/image.d.ts
|
|
2
|
+
interface ImageProps {
|
|
3
|
+
readonly src: string | StaticImageData;
|
|
4
|
+
readonly alt: string;
|
|
5
|
+
readonly width?: number;
|
|
6
|
+
readonly height?: number;
|
|
7
|
+
readonly quality?: number;
|
|
8
|
+
readonly preload?: boolean;
|
|
9
|
+
readonly loading?: 'lazy' | 'eager';
|
|
10
|
+
readonly placeholder?: 'blur' | 'empty';
|
|
11
|
+
readonly blurDataURL?: string;
|
|
12
|
+
readonly fill?: boolean;
|
|
13
|
+
readonly sizes?: string;
|
|
14
|
+
readonly style?: React.CSSProperties;
|
|
15
|
+
readonly className?: string;
|
|
16
|
+
readonly onLoad?: (event: React.SyntheticEvent<HTMLImageElement>) => void;
|
|
17
|
+
readonly onError?: (event: React.SyntheticEvent<HTMLImageElement>) => void;
|
|
18
|
+
readonly unoptimized?: boolean;
|
|
19
|
+
readonly loader?: (props: Readonly<{
|
|
20
|
+
src: string;
|
|
21
|
+
width: number;
|
|
22
|
+
quality: number;
|
|
23
|
+
}>) => string;
|
|
24
|
+
readonly overrideSrc?: string;
|
|
25
|
+
readonly decoding?: 'async' | 'sync' | 'auto';
|
|
26
|
+
}
|
|
27
|
+
interface StaticImageData {
|
|
28
|
+
readonly src: string;
|
|
29
|
+
readonly height: number;
|
|
30
|
+
readonly width: number;
|
|
31
|
+
readonly blurDataURL?: string;
|
|
32
|
+
}
|
|
33
|
+
declare function Image({ src, alt, width, height, quality, preload, loading, placeholder, blurDataURL, fill, sizes, style, className, onLoad, onError, unoptimized, loader, overrideSrc, decoding }: ImageProps): import("react").JSX.Element;
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/image/static-modules.d.ts
|
|
36
|
+
declare module '*.avif' {
|
|
37
|
+
const image: StaticImageData;
|
|
38
|
+
export default image;
|
|
39
|
+
}
|
|
40
|
+
declare module '*.gif' {
|
|
41
|
+
const image: StaticImageData;
|
|
42
|
+
export default image;
|
|
43
|
+
}
|
|
44
|
+
declare module '*.jpeg' {
|
|
45
|
+
const image: StaticImageData;
|
|
46
|
+
export default image;
|
|
47
|
+
}
|
|
48
|
+
declare module '*.jpg' {
|
|
49
|
+
const image: StaticImageData;
|
|
50
|
+
export default image;
|
|
51
|
+
}
|
|
52
|
+
declare module '*.png' {
|
|
53
|
+
const image: StaticImageData;
|
|
54
|
+
export default image;
|
|
55
|
+
}
|
|
56
|
+
declare module '*.webp' {
|
|
57
|
+
const image: StaticImageData;
|
|
58
|
+
export default image;
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
export { ImageProps as n, StaticImageData as r, Image as t };
|
|
@@ -104,6 +104,7 @@ declare global {
|
|
|
104
104
|
'__rari_client_ready'?: boolean;
|
|
105
105
|
'__rari_f'?: ReadonlyArray<0 | string | readonly [2, string]>;
|
|
106
106
|
'__rari_chunk_load__'?: (chunkId: string) => Promise<unknown>;
|
|
107
|
+
'__rari_get_script_filename__'?: (chunkId: string) => string;
|
|
107
108
|
}
|
|
108
109
|
interface Window {
|
|
109
110
|
'~rari'?: GlobalWithRari['~rari'];
|
|
@@ -7,15 +7,17 @@ declare module 'virtual:react-flight-client' {
|
|
|
7
7
|
readonly value?: T;
|
|
8
8
|
readonly reason?: unknown;
|
|
9
9
|
}
|
|
10
|
-
export function createServerReference<A extends unknown[] = unknown[], R = unknown>(id: string, callServer
|
|
10
|
+
export function createServerReference<A extends unknown[] = unknown[], R = unknown>(id: string, callServer?: (id: string, args: A) => Promise<R>, encodeFormAction?: (args: A) => Promise<FormData | string>, findSourceMapURL?: (filename: string, environmentName: string) => string | null, functionName?: string): unknown;
|
|
11
11
|
export function createFromReadableStream<T>(stream: ReadableStream<Uint8Array>, options?: Readonly<{
|
|
12
12
|
readonly callServer?: (id: string, args: readonly unknown[]) => Promise<unknown>;
|
|
13
13
|
readonly moduleMap?: unknown;
|
|
14
14
|
readonly moduleLoading?: unknown;
|
|
15
|
+
readonly findSourceMapURL?: (filename: string, environmentName: string) => string | null;
|
|
15
16
|
}>): Thenable<T>;
|
|
16
17
|
export function createFromFetch<T>(promiseForResponse: Promise<Response>, options?: Readonly<{
|
|
17
18
|
readonly callServer?: (id: string, args: readonly unknown[]) => Promise<unknown>;
|
|
18
19
|
readonly temporaryReferences?: Map<string, unknown>;
|
|
20
|
+
readonly findSourceMapURL?: (filename: string, environmentName: string) => string | null;
|
|
19
21
|
}>): Thenable<T>;
|
|
20
22
|
export function createTemporaryReferenceSet(): Map<string, unknown>;
|
|
21
23
|
export function encodeReply(value: unknown, options?: Readonly<{
|
package/dist/vite.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as RouteSegmentType, D as RouteContext, E as ApiRouteHandlers, O as RouteHandler, S as RouteSegment, T as ApiResponse, _ as LayoutProps, a as Sitemap, b as NotFoundEntry, c as SitemapVideo, d as AppRouteMatch, f as ErrorEntry, g as LayoutEntry, h as GenerateStaticParams, i as RobotsRule, l as AppRouteEntry, m as GenerateMetadata, o as SitemapEntry, p as ErrorProps, r as Robots, s as SitemapImage, u as AppRouteManifest, v as LoadingEntry, w as TemplateEntry, x as PageProps, y as Metadata } from "./types-
|
|
1
|
+
import { C as RouteSegmentType, D as RouteContext, E as ApiRouteHandlers, O as RouteHandler, S as RouteSegment, T as ApiResponse, _ as LayoutProps, a as Sitemap, b as NotFoundEntry, c as SitemapVideo, d as AppRouteMatch, f as ErrorEntry, g as LayoutEntry, h as GenerateStaticParams, i as RobotsRule, l as AppRouteEntry, m as GenerateMetadata, o as SitemapEntry, p as ErrorProps, r as Robots, s as SitemapImage, u as AppRouteManifest, v as LoadingEntry, w as TemplateEntry, x as PageProps, y as Metadata } from "./types-DfSnnFaF.mjs";
|
|
2
2
|
import { a as ProxyModule, c as RariURL, i as ProxyMatcher, l as RequestCookies, n as ProxyConfig, o as ProxyResult, r as ProxyFunction, s as RariFetchEvent, t as CookieOptions, u as ResponseCookies } from "./types-DAdRjhuk.mjs";
|
|
3
3
|
import { UserConfig } from "vite-plus";
|
|
4
4
|
import { ReactCompilerOptions as ReactCompilerOptions$1 } from "oxc-transform-react";
|
|
@@ -96,6 +96,7 @@ interface ServerConfig {
|
|
|
96
96
|
//#region src/vite/server/build.d.ts
|
|
97
97
|
interface ServerBuildOptions {
|
|
98
98
|
readonly outDir?: string;
|
|
99
|
+
readonly clientOutDir?: string;
|
|
99
100
|
readonly rscDir?: string;
|
|
100
101
|
readonly manifestPath?: string;
|
|
101
102
|
readonly serverConfigPath?: string;
|
|
@@ -290,6 +291,7 @@ export interface RariOptions {
|
|
|
290
291
|
readonly pathname: string;
|
|
291
292
|
readonly search?: string;
|
|
292
293
|
}>;
|
|
294
|
+
readonly includeBundledAssets?: boolean;
|
|
293
295
|
readonly deviceSizes?: readonly number[];
|
|
294
296
|
readonly imageSizes?: readonly number[];
|
|
295
297
|
readonly formats?: readonly ('avif' | 'webp')[];
|