rari 0.17.9 → 0.17.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.d.mts +0 -4
- package/dist/define-BIL9PMLh.mjs +1 -0
- package/dist/{define-BafO1-XT.d.mts → define-DCZgXfOp.d.mts} +0 -2
- package/dist/font/google-catalog.d.mts +15 -0
- package/dist/font/google.d.mts +1 -3
- package/dist/font/local.d.mts +2 -4
- package/dist/font.d.mts +1 -1
- package/dist/get-client-component-DVAbynLr.mjs +1 -0
- package/dist/headers.d.mts +1 -3
- package/dist/image/runtime-config.d.mts +1 -3
- package/dist/image/static.d.mts +1 -1
- package/dist/image.d.mts +1 -5
- package/dist/index.d.mts +2 -4
- package/dist/mdx/define.d.mts +1 -1
- package/dist/mdx/define.mjs +1 -1
- package/dist/mdx/registry.d.mts +1 -3
- package/dist/mdx.d.mts +1 -5
- package/dist/mdx.mjs +1 -1
- package/dist/og.d.mts +0 -2
- package/dist/platform.d.mts +1 -3
- package/dist/{preload-modules-BDQFWAlZ.mjs → preload-modules-0iyuP4Vs.mjs} +2 -2
- package/dist/proxy/RariRequest.d.mts +2 -4
- package/dist/proxy/RariResponse.d.mts +1 -1
- package/dist/proxy/executor.d.mts +1 -3
- package/dist/{react-helpers-GTRYJwF2.d.mts → react-helpers-CZtKqfS6.d.mts} +0 -2
- package/dist/{router-kf_rLP_F.mjs → router-861SNPMt.mjs} +1 -1
- package/dist/router.d.mts +0 -8
- package/dist/router.mjs +1 -1
- package/dist/runtime/AppRouterProvider.d.mts +1 -5
- package/dist/runtime/AppRouterProvider.mjs +1 -1
- package/dist/runtime/ClientRouter.d.mts +1 -3
- package/dist/runtime/ClientRouter.mjs +3 -3
- package/dist/runtime/ErrorBoundaryWrapper.d.mts +0 -2
- package/dist/runtime/ErrorBoundaryWrapper.mjs +1 -1
- package/dist/runtime/action-flight-refresh.d.mts +0 -2
- package/dist/runtime/action-revalidation-kind.d.mts +1 -3
- package/dist/runtime/call-server.d.mts +1 -3
- package/dist/runtime/entry-client.d.mts +2 -4
- package/dist/runtime/entry-client.mjs +3 -3
- package/dist/runtime/merge-flight-refresh.d.mts +2 -4
- package/dist/runtime/rsc-client-runtime.d.mts +1 -5
- package/dist/runtime/rsc-client-runtime.mjs +1 -1
- package/dist/runtime/rsc-references.d.mts +0 -2
- package/dist/{sitemap-DIL-PFSt.mjs → sitemap-ByPlT2YN.mjs} +1 -1
- package/dist/{static-modules-BnpA9S9v.d.mts → static-modules-DmO7M_cF.d.mts} +0 -4
- package/dist/{types-DAdRjhuk.d.mts → types-CSDt4P_t.d.mts} +0 -4
- package/dist/{types-C8N3Hc8I.d.mts → types-Cw2SI7r7.d.mts} +0 -2
- package/dist/{types-yeW6ju9Y.d.mts → types-DNk27dqJ.d.mts} +0 -10
- package/dist/{types-CkZPEEdi.d.mts → types-DeWes1rB.d.mts} +0 -2
- package/dist/vite.d.mts +2 -26
- package/dist/vite.mjs +77 -75
- package/package.json +13 -13
- package/dist/define-Dsj1lR4C.mjs +0 -1
- package/dist/get-client-component-D2K213pV.mjs +0 -1
package/dist/cli.d.mts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/cli/build-target.d.ts
|
|
2
1
|
type ViteAppCommand = 'build' | 'dev' | 'preview' | 'pack';
|
|
3
2
|
export declare function readDefaultPackageTarget(configSource: string, command?: ViteAppCommand): string | null;
|
|
4
3
|
export declare function readBuildOutDir(configSource: string): string | null;
|
|
@@ -8,8 +7,6 @@ export declare function resolveViteBuildPackageRoot(cwd: string, viteBin?: 'vp'
|
|
|
8
7
|
export declare function resolveConfiguredBuildOutDir(packageRoot: string): string;
|
|
9
8
|
export declare function findImageConfigPath(packageRoot: string): string | null;
|
|
10
9
|
export declare function outDirFromImageConfigPath(imageConfigPath: string, packageRoot: string): string;
|
|
11
|
-
//#endregion
|
|
12
|
-
//#region src/cli/index.d.ts
|
|
13
10
|
type PackageManager = 'pnpm' | 'yarn' | 'bun' | 'npm';
|
|
14
11
|
declare function detectPackageManager(): PackageManager;
|
|
15
12
|
declare function isRailwayEnvironment(): boolean;
|
|
@@ -19,5 +16,4 @@ declare function getDeploymentConfig(): {
|
|
|
19
16
|
mode: string;
|
|
20
17
|
host: string;
|
|
21
18
|
};
|
|
22
|
-
//#endregion
|
|
23
19
|
export { detectPackageManager, getDeploymentConfig, isRailwayEnvironment, isRenderEnvironment };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{g as e}from"./type-guards-BLY2PlGR.mjs";import{t}from"./names-CLmM0CPi.mjs";import{registerClientReference as n}from"./runtime/rsc-references.mjs";import{r}from"./rari-global-5vGzhToD.mjs";import{s as i}from"./regex-constants-DzXwNGh2.mjs";function a(e,t,a=`default`){let o=`${t}#${a}`;if(typeof globalThis<`u`){let n=r(),s=t.replace(i,``).split(`/`).pop(),c=s!=null&&s!==``?s:a,l={id:a==="default"?c:a,path:t,type:`client`,component:e,registered:!0};n[o]=l,n[c]=l,n[t]=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 n(s,t,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 n=c(e);return e=>{let r={},i={},a=new Set(t(e));for(let e of n)a.has(e.name)&&(e.client===!1?r[e.name]=e.component:i[e.name]={component:e.component,id:e.id,exportName:e.exportName});return{...r,...o(i)}}}export{l as t};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ComponentType } from "react";
|
|
2
|
-
//#region src/mdx/components/define.d.ts
|
|
3
2
|
interface MdxComponentEntry {
|
|
4
3
|
readonly name: string;
|
|
5
4
|
readonly component: ComponentType<any>;
|
|
@@ -9,5 +8,4 @@ interface MdxComponentEntry {
|
|
|
9
8
|
}
|
|
10
9
|
type MdxComponentsInput = Readonly<Record<string, ComponentType<any> | MdxComponentEntry>>;
|
|
11
10
|
declare function defineMdxComponents(input: readonly MdxComponentEntry[] | MdxComponentsInput): (content: string) => Record<string, any>;
|
|
12
|
-
//#endregion
|
|
13
11
|
export { defineMdxComponents as n, MdxComponentEntry as t };
|
|
@@ -18,6 +18,7 @@ export declare const Afacad: GoogleFontFn
|
|
|
18
18
|
export declare const Afacad_Flux: GoogleFontFn
|
|
19
19
|
export declare const Agbalumo: GoogleFontFn
|
|
20
20
|
export declare const Agdasima: GoogleFontFn
|
|
21
|
+
export declare const Agrave_Pro: GoogleFontFn
|
|
21
22
|
export declare const Agu_Display: GoogleFontFn
|
|
22
23
|
export declare const Aguafina_Script: GoogleFontFn
|
|
23
24
|
export declare const Akatab: GoogleFontFn
|
|
@@ -350,6 +351,7 @@ export declare const Chokokutai: GoogleFontFn
|
|
|
350
351
|
export declare const Chonburi: GoogleFontFn
|
|
351
352
|
export declare const Cinzel: GoogleFontFn
|
|
352
353
|
export declare const Cinzel_Decorative: GoogleFontFn
|
|
354
|
+
export declare const Clarity_City: GoogleFontFn
|
|
353
355
|
export declare const Clicker_Script: GoogleFontFn
|
|
354
356
|
export declare const Climate_Crisis: GoogleFontFn
|
|
355
357
|
export declare const Coda: GoogleFontFn
|
|
@@ -520,6 +522,7 @@ export declare const Fira_Mono: GoogleFontFn
|
|
|
520
522
|
export declare const Fira_Sans: GoogleFontFn
|
|
521
523
|
export declare const Fira_Sans_Condensed: GoogleFontFn
|
|
522
524
|
export declare const Fira_Sans_Extra_Condensed: GoogleFontFn
|
|
525
|
+
export declare const Firjar: GoogleFontFn
|
|
523
526
|
export declare const Fjalla_One: GoogleFontFn
|
|
524
527
|
export declare const Fjord_One: GoogleFontFn
|
|
525
528
|
export declare const Flamenco: GoogleFontFn
|
|
@@ -712,6 +715,7 @@ export declare const Iosevka_Charon: GoogleFontFn
|
|
|
712
715
|
export declare const Iosevka_Charon_Mono: GoogleFontFn
|
|
713
716
|
export declare const Irish_Grover: GoogleFontFn
|
|
714
717
|
export declare const Island_Moments: GoogleFontFn
|
|
718
|
+
export declare const Isometra: GoogleFontFn
|
|
715
719
|
export declare const Istok_Web: GoogleFontFn
|
|
716
720
|
export declare const Italiana: GoogleFontFn
|
|
717
721
|
export declare const Italianno: GoogleFontFn
|
|
@@ -806,6 +810,7 @@ export declare const Kotta_One: GoogleFontFn
|
|
|
806
810
|
export declare const Koulen: GoogleFontFn
|
|
807
811
|
export declare const Kranky: GoogleFontFn
|
|
808
812
|
export declare const Kreon: GoogleFontFn
|
|
813
|
+
export declare const Kripa: GoogleFontFn
|
|
809
814
|
export declare const Kristi: GoogleFontFn
|
|
810
815
|
export declare const Krona_One: GoogleFontFn
|
|
811
816
|
export declare const Krub: GoogleFontFn
|
|
@@ -857,6 +862,7 @@ export declare const Libre_Barcode_39_Text: GoogleFontFn
|
|
|
857
862
|
export declare const Libre_Barcode_EAN13_Text: GoogleFontFn
|
|
858
863
|
export declare const Libre_Baskerville: GoogleFontFn
|
|
859
864
|
export declare const Libre_Bodoni: GoogleFontFn
|
|
865
|
+
export declare const Libre_Caslon_Condensed: GoogleFontFn
|
|
860
866
|
export declare const Libre_Caslon_Display: GoogleFontFn
|
|
861
867
|
export declare const Libre_Caslon_Text: GoogleFontFn
|
|
862
868
|
export declare const Libre_Franklin: GoogleFontFn
|
|
@@ -1543,6 +1549,13 @@ export declare const Red_Hat_Text: GoogleFontFn
|
|
|
1543
1549
|
export declare const Red_Rose: GoogleFontFn
|
|
1544
1550
|
export declare const Redacted: GoogleFontFn
|
|
1545
1551
|
export declare const Redacted_Script: GoogleFontFn
|
|
1552
|
+
export declare const Redaction: GoogleFontFn
|
|
1553
|
+
export declare const Redaction_10: GoogleFontFn
|
|
1554
|
+
export declare const Redaction_100: GoogleFontFn
|
|
1555
|
+
export declare const Redaction_20: GoogleFontFn
|
|
1556
|
+
export declare const Redaction_35: GoogleFontFn
|
|
1557
|
+
export declare const Redaction_50: GoogleFontFn
|
|
1558
|
+
export declare const Redaction_70: GoogleFontFn
|
|
1546
1559
|
export declare const Reddit_Mono: GoogleFontFn
|
|
1547
1560
|
export declare const Reddit_Sans: GoogleFontFn
|
|
1548
1561
|
export declare const Reddit_Sans_Condensed: GoogleFontFn
|
|
@@ -1808,6 +1821,7 @@ export declare const Tilt_Warp: GoogleFontFn
|
|
|
1808
1821
|
export declare const Timmana: GoogleFontFn
|
|
1809
1822
|
export declare const Tinos: GoogleFontFn
|
|
1810
1823
|
export declare const Tiny5: GoogleFontFn
|
|
1824
|
+
export declare const Tiny5_Duo: GoogleFontFn
|
|
1811
1825
|
export declare const Tiro_Bangla: GoogleFontFn
|
|
1812
1826
|
export declare const Tiro_Devanagari_Hindi: GoogleFontFn
|
|
1813
1827
|
export declare const Tiro_Devanagari_Marathi: GoogleFontFn
|
|
@@ -1900,6 +1914,7 @@ export declare const Wix_Madefor_Text: GoogleFontFn
|
|
|
1900
1914
|
export declare const Work_Sans: GoogleFontFn
|
|
1901
1915
|
export declare const Workbench: GoogleFontFn
|
|
1902
1916
|
export declare const Xanh_Mono: GoogleFontFn
|
|
1917
|
+
export declare const Xmind: GoogleFontFn
|
|
1903
1918
|
export declare const Yaldevi: GoogleFontFn
|
|
1904
1919
|
export declare const Yanone_Kaffeesatz: GoogleFontFn
|
|
1905
1920
|
export declare const Yantramanav: GoogleFontFn
|
package/dist/font/google.d.mts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { n as FontDisplay, r as GoogleFontOptions, t as Font } from "../types-
|
|
2
|
-
//#region src/font/google.d.ts
|
|
1
|
+
import { n as FontDisplay, r as GoogleFontOptions, t as Font } from "../types-DeWes1rB.mjs";
|
|
3
2
|
export type GoogleFontFn = (options?: GoogleFontOptions) => Font;
|
|
4
3
|
export declare function googleFont(): Font;
|
|
5
|
-
//#endregion
|
|
6
4
|
export type { Font, FontDisplay, GoogleFontOptions };
|
package/dist/font/local.d.mts
CHANGED
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
import { i as LocalFontOptions, t as Font } from "../types-
|
|
2
|
-
|
|
3
|
-
export default function localFont(_options: LocalFontOptions): Font;
|
|
4
|
-
//#endregion
|
|
1
|
+
import { i as LocalFontOptions, t as Font } from "../types-DeWes1rB.mjs";
|
|
2
|
+
export default function localFont(_options: LocalFontOptions): Font;
|
package/dist/font.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as LocalFontSrc, i as LocalFontOptions, n as FontDisplay, r as GoogleFontOptions, t as Font } from "./types-CkZPEEdi.mjs";
|
|
2
1
|
import localFont from "./font/local.mjs";
|
|
2
|
+
import { a as LocalFontSrc, i as LocalFontOptions, n as FontDisplay, r as GoogleFontOptions, t as Font } from "./types-DeWes1rB.mjs";
|
|
3
3
|
export { type Font, type FontDisplay, type GoogleFontOptions, type LocalFontOptions, type LocalFontSrc, localFont };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e}from"./path-CTEC1xmy.mjs";import{S as t,g as n,m as r,u as i}from"./type-guards-BLY2PlGR.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(t){let n=e(t),r=/* @__PURE__ */ new Set([n]),i=n.indexOf(`/src/`);i!==-1&&r.add(n.slice(i+1));let a=n.indexOf(`/components/`);return a!==-1&&r.add(n.slice(a+1)),[...r]}function d(e,t){if(t!==void 0)return t;let n=e.exportName;if(n!=null&&n!==``)return n}function f(t,n){let r=e(t),i=e(n);return!!(r===i||i.includes(`/`)&&r.endsWith(`/${i}`)||r.includes(`/`)&&i.endsWith(`/${r}`))}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(e,t){let i=e.component;if(i==null)return null;if(r(i))return i;if(!n(i))return null;if(t==null||t===``||t==="default")return i.default??i;if(t in i)return i[t];let a=i.default;return n(a)&&t in a?a[t]:null}function _(t){let n=e(t);return n===t?[n]:[n,t]}function v(t){let n=o(),r=a(),i=s(),c=e(t),l=y(t,n);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(t,f,n)??x(t,d,f,n,r,i)??p(d,f,n)}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(t,n,r,i,a,o){let s=e(t)===t?[n]:[n,t.includes(`#`)?t.slice(0,t.indexOf(`#`)):t];for(let e of s){let t=S(e,r,i,a);if(t!=null)return t;let n=C(e,r,i,o);if(n!=null)return n}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(t(e.loadError))}function T(e,t,i){let a=d(e,i),o=g({...e,component:t},a);if(o==null)return n(t)&&(`default`in t||`__esModule`in t)?t:r(t)?{default:t,[a!=null&&a!==``?a:`default`]:t,__esModule:!0}:t;let s=a!=null&&a!==``?a:`default`;return{...n(t)?t:{},default:o,[s]:o,__esModule:!0}}function E(e,n,r,a){let o=d(e,a),s=o!=null&&o!==``?o:`default`,l=a=>{if(e.loadError!=null)throw t(e.loadError);if(e.component!=null){let t=g(e,o);if(t==null)throw Error(`[rari] Lazy component "${n}" loaded but export "${s}" is missing`);if(!i(t))throw Error(`[rari] Lazy component "${n}" export "${s}" is not a component`);return c(t,a)}throw r};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 t=t=>{let n=o(),r=e(t);return t in n?n[t]:r in n?n[r]:Object.values(n).find(e=>e.path===t||e.path===r)};Reflect.set(globalThis,`__rari_get_script_filename__`,n=>{let r=t(n)?.path??e(n),i=e(r);if(i.startsWith(`http://`)||i.startsWith(`https://`))return i;let a=i.indexOf(`/src/`);return a===-1?i.startsWith(`src/`)?`/${i}`:i.startsWith(`/`)?i:`/${i}`:i.slice(a)}),Reflect.set(globalThis,`__rari_chunk_load__`,async e=>{let n=t(e);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/headers.d.mts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { i as ReadonlyHeaders, n as CookieStore, r as ReadonlyCookie, t as CookieOptions } from "./types-
|
|
2
|
-
//#region src/headers.d.ts
|
|
1
|
+
import { i as ReadonlyHeaders, n as CookieStore, r as ReadonlyCookie, t as CookieOptions } from "./types-Cw2SI7r7.mjs";
|
|
3
2
|
export declare function cookies(): Promise<CookieStore>;
|
|
4
3
|
export declare function headers(): Promise<ReadonlyHeaders>;
|
|
5
|
-
//#endregion
|
|
6
4
|
export type { CookieOptions, CookieStore, ReadonlyCookie, ReadonlyHeaders };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/image/runtime-config.d.ts
|
|
2
1
|
export declare function configureImageSizes(options: {
|
|
3
2
|
readonly deviceSizes?: readonly number[];
|
|
4
3
|
readonly imageSizes?: readonly number[];
|
|
@@ -6,5 +5,4 @@ export declare function configureImageSizes(options: {
|
|
|
6
5
|
export declare function getImageDeviceSizes(): readonly number[];
|
|
7
6
|
export declare function getImageSizes(): readonly number[];
|
|
8
7
|
export declare function getAllImageSizes(): readonly number[];
|
|
9
|
-
export declare function getMaxOptimizedWidth(): number;
|
|
10
|
-
//#endregion
|
|
8
|
+
export declare function getMaxOptimizedWidth(): number;
|
package/dist/image/static.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import "../static-modules-
|
|
1
|
+
import "../static-modules-DmO7M_cF.mjs";
|
package/dist/image.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
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-DmO7M_cF.mjs";
|
|
2
2
|
import { configureImageSizes } from "./image/runtime-config.mjs";
|
|
3
|
-
//#region src/image/constants.d.ts
|
|
4
3
|
type ImageFormat = 'avif' | 'webp' | 'jpeg';
|
|
5
4
|
export declare const MAX_OPTIMIZED_OUTPUT_WIDTH = 3840;
|
|
6
5
|
export declare const DEFAULT_DEVICE_SIZES: number[];
|
|
@@ -10,11 +9,8 @@ export declare const DEFAULT_QUALITY_LEVELS: number[];
|
|
|
10
9
|
export declare const DEFAULT_MINIMUM_CACHE_TTL = 60;
|
|
11
10
|
export declare const BLUR_PLACEHOLDER_WIDTH = 16;
|
|
12
11
|
export declare const BLUR_PLACEHOLDER_QUALITY = 25;
|
|
13
|
-
//#endregion
|
|
14
|
-
//#region src/image/index.d.ts
|
|
15
12
|
declare const Image: typeof Image$1 & {
|
|
16
13
|
$$typeof?: symbol;
|
|
17
14
|
$$id?: string;
|
|
18
15
|
};
|
|
19
|
-
//#endregion
|
|
20
16
|
export { Image, type ImageFormat, type ImageProps, type StaticImageData, configureImageSizes };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
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-
|
|
2
|
-
import { c as RariURL, d as RariResponse, n as ProxyConfig, r as ProxyFunction, s as RariFetchEvent } from "./types-DAdRjhuk.mjs";
|
|
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-DNk27dqJ.mjs";
|
|
3
2
|
import { RariRequest } from "./proxy/RariRequest.mjs";
|
|
4
|
-
|
|
3
|
+
import { c as RariURL, d as RariResponse, n as ProxyConfig, r as ProxyFunction, s as RariFetchEvent } from "./types-CSDt4P_t.mjs";
|
|
5
4
|
export declare const NOT_FOUND_ERROR_DIGEST = "RARI_NOT_FOUND";
|
|
6
5
|
export declare function isNotFoundError(error: unknown): boolean;
|
|
7
6
|
export declare function notFound(): never;
|
|
8
|
-
//#endregion
|
|
9
7
|
export { ApiResponse, type ApiRouteHandlers, type ErrorProps, type Feed, type FeedEntry, type LayoutProps, type Metadata, type PageProps, type ProxyConfig, type ProxyFunction, type RariFetchEvent, RariRequest, RariResponse, type RariURL, type Robots, type RobotsRule, type RouteContext, type RouteHandler, type Sitemap, type SitemapEntry, type SitemapImage, type SitemapVideo };
|
package/dist/mdx/define.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as defineMdxComponents, t as MdxComponentEntry } from "../define-
|
|
1
|
+
import { n as defineMdxComponents, t as MdxComponentEntry } from "../define-DCZgXfOp.mjs";
|
|
2
2
|
export { type MdxComponentEntry, defineMdxComponents };
|
package/dist/mdx/define.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{t as defineMdxComponents}from"../define-
|
|
1
|
+
export{t as defineMdxComponents}from"../define-BIL9PMLh.mjs";
|
package/dist/mdx/registry.d.mts
CHANGED
package/dist/mdx.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { n as defineMdxComponents, t as MdxComponentEntry } from "./define-
|
|
1
|
+
import { n as defineMdxComponents, t as MdxComponentEntry } from "./define-DCZgXfOp.mjs";
|
|
2
2
|
import { ComponentType } from "react";
|
|
3
3
|
import { EvaluateOptions as EvaluateOptions$1 } from "@mdx-js/mdx";
|
|
4
|
-
//#region src/mdx/evaluate.d.ts
|
|
5
4
|
interface EvaluateOptions extends EvaluateOptions$1 {
|
|
6
5
|
components?: Record<string, any>;
|
|
7
6
|
}
|
|
@@ -11,8 +10,5 @@ interface EvaluateResult {
|
|
|
11
10
|
}>;
|
|
12
11
|
}
|
|
13
12
|
export declare function evaluate(source: string, options: EvaluateOptions): Promise<EvaluateResult>;
|
|
14
|
-
//#endregion
|
|
15
|
-
//#region src/mdx/scan/names.d.ts
|
|
16
13
|
export declare function scanMdxComponentNames(content: string): string[];
|
|
17
|
-
//#endregion
|
|
18
14
|
export { type EvaluateOptions, type EvaluateResult, type MdxComponentEntry, defineMdxComponents };
|
package/dist/mdx.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./
|
|
1
|
+
import{t as e}from"./define-BIL9PMLh.mjs";import{t}from"./names-CLmM0CPi.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{e as defineMdxComponents,a as evaluate,t as scanMdxComponentNames};
|
package/dist/og.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ReactElement } from "react";
|
|
2
|
-
//#region src/og/image-response.d.ts
|
|
3
2
|
interface ImageResponseOptions {
|
|
4
3
|
readonly width?: number;
|
|
5
4
|
readonly height?: number;
|
|
@@ -34,5 +33,4 @@ export declare class ImageResponse {
|
|
|
34
33
|
private serializeProps;
|
|
35
34
|
private serializePropValue;
|
|
36
35
|
}
|
|
37
|
-
//#endregion
|
|
38
36
|
export type { ImageResponseOptions, ImageResponseSize };
|
package/dist/platform.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{f as e}from"./type-guards-BLY2PlGR.mjs";import{o as t}from"./path-CTEC1xmy.mjs";import{t as n}from"./get-client-component-
|
|
2
|
-
`)){let e=u(r);e!=null&&(
|
|
1
|
+
import{f as e}from"./type-guards-BLY2PlGR.mjs";import{o as t}from"./path-CTEC1xmy.mjs";import{t as n}from"./get-client-component-DVAbynLr.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,5 +1,4 @@
|
|
|
1
|
-
import { c as RariURL, l as RequestCookies } from "../types-
|
|
2
|
-
//#region src/proxy/http/request.d.ts
|
|
1
|
+
import { c as RariURL, l as RequestCookies } from "../types-CSDt4P_t.mjs";
|
|
3
2
|
export declare class RariRequest {
|
|
4
3
|
url: string;
|
|
5
4
|
method: string;
|
|
@@ -34,5 +33,4 @@ export declare class RariRequest {
|
|
|
34
33
|
readonly longitude?: string;
|
|
35
34
|
};
|
|
36
35
|
}>): RariRequest;
|
|
37
|
-
}
|
|
38
|
-
//#endregion
|
|
36
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { d as RariResponse } from "../types-
|
|
1
|
+
import { d as RariResponse } from "../types-CSDt4P_t.mjs";
|
|
2
2
|
export { RariResponse };
|
|
@@ -1,3 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function initializeProxyExecutor(proxyModulePath: string, rariRequestPath: string): Promise<boolean>;
|
|
3
|
-
//#endregion
|
|
1
|
+
export declare function initializeProxyExecutor(proxyModulePath: string, rariRequestPath: string): Promise<boolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./navigate-CSQP4q53.mjs";import{g as t,i as n}from"./type-guards-BLY2PlGR.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(
|
|
1
|
+
import{n as e}from"./navigate-CSQP4q53.mjs";import{g as t,i as n}from"./type-guards-BLY2PlGR.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(15),{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;r[9]!==k||r[10]!==g.pathname?(A={pathname:g.pathname,searchParams:k,push:async(e,t)=>{_.current?await _.current(e,t):(console.warn(`[rari] Router not ready, falling back to window.location`),window.location.href=e)},replace: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))},back:E,forward:T,refresh:w,prefetch:C},r[9]=k,r[10]=g.pathname,r[11]=A):A=r[11];let j=A,M;return r[12]!==c||r[13]!==j?(M=/* @__PURE__ */ p(m,{value:j,children:c}),r[12]=c,r[13]=j,r[14]=M):M=r[14],M}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,22 +1,15 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
|
-
//#region src/router/navigation/types.d.ts
|
|
3
2
|
interface NavigationOptions {
|
|
4
3
|
readonly replace?: boolean;
|
|
5
4
|
readonly scroll?: boolean;
|
|
6
5
|
readonly historyKey?: string;
|
|
7
6
|
}
|
|
8
|
-
//#endregion
|
|
9
|
-
//#region src/router/navigation/navigate.d.ts
|
|
10
7
|
export declare function navigate(href: string, options?: NavigationOptions): Promise<void>;
|
|
11
|
-
//#endregion
|
|
12
|
-
//#region src/router/navigation/router-provider.d.ts
|
|
13
8
|
interface RouterProviderProps {
|
|
14
9
|
readonly children: ReactNode;
|
|
15
10
|
readonly initialPathname: string;
|
|
16
11
|
}
|
|
17
12
|
export declare function RouterProvider({ children, initialPathname }: RouterProviderProps): import("react").JSX.Element;
|
|
18
|
-
//#endregion
|
|
19
|
-
//#region src/router/navigation/use-router.d.ts
|
|
20
13
|
interface RouterContextValue {
|
|
21
14
|
pathname: string;
|
|
22
15
|
searchParams: URLSearchParams;
|
|
@@ -31,5 +24,4 @@ export declare function useRouter(): RouterContextValue;
|
|
|
31
24
|
export declare function usePathname(): string;
|
|
32
25
|
export declare function useSearchParams(): URLSearchParams;
|
|
33
26
|
export declare function useViewTransitionKey(): number;
|
|
34
|
-
//#endregion
|
|
35
27
|
export type { NavigationOptions, RouterContextValue, RouterProviderProps };
|
package/dist/router.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./navigate-CSQP4q53.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-CSQP4q53.mjs";import{a as t,i as n,n as r,r as i,t as a}from"./router-861SNPMt.mjs";export{a as RouterProvider,e as navigate,r as usePathname,i as useRouter,n as useSearchParams,t as useViewTransitionKey};
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import { t as FlightContent } from "../react-helpers-
|
|
1
|
+
import { t as FlightContent } from "../react-helpers-CZtKqfS6.mjs";
|
|
2
2
|
import { ReactElement, ReactNode } from "react";
|
|
3
|
-
//#region src/runtime/flight/apply-flight-patch.d.ts
|
|
4
3
|
interface PendingLeafEviction {
|
|
5
4
|
readonly pathname: string;
|
|
6
5
|
readonly search: string;
|
|
7
6
|
}
|
|
8
|
-
//#endregion
|
|
9
|
-
//#region src/runtime/flight/app-router-provider.d.ts
|
|
10
7
|
interface RscPayload {
|
|
11
8
|
readonly element: FlightContent;
|
|
12
9
|
readonly flightProtocol?: string;
|
|
@@ -43,5 +40,4 @@ interface NavigationDetail {
|
|
|
43
40
|
};
|
|
44
41
|
}
|
|
45
42
|
export declare function AppRouterProvider({ children, initialPayload, onNavigate }: AppRouterProviderProps): import("react").JSX.Element;
|
|
46
|
-
//#endregion
|
|
47
43
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{S as e,d as t,g as n,i as r,p as i,r as a,s as o}from"../type-guards-BLY2PlGR.mjs";import{i as s}from"../navigation-transition-store-dfNJmkIX.mjs";import{isLayoutReuseMarker as c,layoutPathOf as l,mergeFlightRefresh as u,unwrapFulfilledFlightNode as d}from"./merge-flight-refresh.mjs";import{a as f,i as p,n as m,r as h,t as g}from"../react-helpers-duOBWuYF.mjs";import{i as _,n as v,r as y,t as b}from"../route-cache-BfEqTT9i.mjs";import"./action-revalidation-kind.mjs";import{n as x,t as ee}from"../preload-modules-BDQFWAlZ.mjs";import{n as te,r as ne}from"../form-state-C9jn086j.mjs";import{c as S}from"react/compiler-runtime";import{Suspense as C,addTransitionType as re,cloneElement as ie,createContext as w,createElement as T,isValidElement as E,startTransition as ae,use as D,useCallback as oe,useEffect as O,useLayoutEffect as se,useRef as k,useState as A,useSyncExternalStore as j}from"react";import{jsx as M,jsxs as N}from"react/jsx-runtime";import{createFromFetch as ce,createFromReadableStream as le}from"virtual:react-flight-client";const ue={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)`},P={padding:`8px 16px`,background:`white`,color:`#dc2626`,border:`none`,borderRadius:`4px`,cursor:`pointer`,fontWeight:`bold`,fontSize:`14px`},F={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`},de={fetch:`Failed to fetch updated content from server.`,parse:`Failed to parse server response.`,stale:`Server returned stale content.`,network:`Network error occurred.`};function I(e){return de[e]}function fe(e){let t=S(27),{failure:n,maxRetries:r,onRefresh:i,onDismiss:a}=e,o,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=/* @__PURE__ */ M(`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=I(n.type),t[2]=n.type,t[3]=c);let l;t[4]===c?l=t[5]:(l=/* @__PURE__ */ M(`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__ */ M(`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__ */ N(`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__ */ M(`button`,{onClick:i,type:`button`,style:P,children:`Refresh Page`}),t[14]=i,t[15]=h);let g;t[16]===a?g=t[17]:(g=/* @__PURE__ */ M(`button`,{onClick:a,type:`button`,style:F,children:`Dismiss`}),t[16]=a,t[17]=g);let _;t[18]!==h||t[19]!==g?(_=/* @__PURE__ */ N(`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__ */ M(`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__ */ N(`div`,{style:ue,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 L(e,t,n){y.getShell()??y.ingest(e,t,n)}function R(e){if(e.fromPathname!==`/`&&(e.fromPathname!==e.toPathname||e.fromSearch!==e.search))return{pathname:e.fromPathname,search:e.fromSearch}}function z(e){if(L(e.previousDocument,e.fromPathname,e.fromSearch),h(e.refresh)){if(!y.ingest(e.refresh,e.toPathname,e.search))return{kind:`hard-nav`}}else if(E(e.refresh)){if(!y.ingestSegment(e.refresh,e.toPathname,e.search))return{kind:`hard-nav`}}else return{kind:`hard-nav`};if(y.getShell()==null||!y.hasRoute(e.toPathname,e.search))return{kind:`hard-nav`};let t=y.readLeaf(e.toPathname,e.search),n=m(e.refresh)||t!=null&&m(t),r=t!=null&&p(t)||p(e.refresh),i=R(e);return h(e.refresh)?{kind:`merged`,element:e.refresh,maySuspend:n,hasLoadingFallback:r,pendingEvictLeaf:i}:{kind:`merged`,element:e.previousDocument,maySuspend:n,hasLoadingFallback:r,pendingEvictLeaf:i}}function B(e,t,n,r){if(h(t))return y.ingest(t,n,r);if(E(t)&&y.getShell()!=null)return y.ingestSegment(t,n,r);let i=u(e,t);return E(t)&&c(t)&&i===e||!h(i)?!1:y.ingest(i,n,r)}function V(e,t){let n=m(e),r=p(e);return h(e)?{kind:`merged`,element:e,maySuspend:n,hasLoadingFallback:r}:h(t)?{kind:`merged`,element:t,maySuspend:n,hasLoadingFallback:r}:{kind:`hard-nav`}}function pe(e){return h(e.previousDocument)&&y.getShell()==null&&!y.ingest(e.previousDocument,e.pathname,e.search)||!B(e.previousDocument,e.refresh,e.pathname,e.search)||y.getShell()==null||!y.hasRoute(e.pathname,e.search)?{kind:`hard-nav`}:V(e.refresh,e.previousDocument)}function me(e){return e.historyKey!=null&&e.historyKey!==``?[`nav`,`nav-traverse`]:e.replace===!0?[`nav`,`nav-replace`]:[`nav`,`nav-forward`]}function he(e,t){if(e==null||e.url===``)return t;try{let t=`http://localhost/`;if(typeof window<`u`)try{t=window.location.href}catch{}let n=new URL(e.url,t);return{pathname:n.pathname,search:n.search}}catch{return t}}function H(e){e!=null&&typeof window<`u`&&(e.replace===!0?window.history.replaceState(e.state,``,e.url):window.history.pushState(e.state,``,e.url))}function ge(e){let{parsedPayload:t,shouldScrollToTop:n,navigationId:r,transitionTypes:i,maySuspend:a=!1,hasLoadingFallback:o=!1,pendingHistory:s,routeLocation:c,startTransition:l=ae,currentNavigationIdRef:u,pendingScrollPayloadRef:d,setRenderKey:f,setRscPayload:p,setRouteLocation:m,setPendingLoadingLeaf:h,clearHmrError:g,pendingNavigateCommittedIdRef:_,pendingEvictLeaf:v}=e;if(u.current!==r)return;let b=a&&o;a&&H(s),b&&c!=null&&(m?.(c),h?.(c));let x=()=>{u.current===r&&(h?.(null),a||H(s),c!=null&&m?.(c),v!=null&&y.evictLeaf(v.pathname,v.search),f(e=>{let r=e+1;return d.current=n?{payload:t,commitKey:r}:null,r}),p(t),g(),_.current=r)};l(()=>{if(i!=null)for(let e of i)re(e);x()})}const _e=w(null);function U(){return D(_e)}function W(e,t,n){return n?.pathname===e&&n.search===t}function G(){return j(y.subscribe,y.getVersion,y.getVersion)}function K(e){return l(e)!=null&&!_(e)&&!c(e)}function q(e,t,n){if(e==null||e===!1||e===!0)return e;if(Array.isArray(e))return g(e).map(e=>q(e,t,n));if(!E(e))return e;if(_(e)||K(e)){let r=l(e);return r==null?null:T(Y,{key:r,layoutPath:r,pathname:t,search:n})}let r=e.props,i=r.children;if(i==null)return e;let a=q(i,t,n);if(Object.is(a,i))return e;let o=g(a),s={...r};return delete s.children,ie(e,s,...o.length===0?[null]:o)}function J({layoutPath:e,pathname:t,search:n},r,i=null){let a=y.readSegmentSnapshot(e,{pathname:t,search:n});if(a==null||E(a)&&_(a))return null;if(y.isDeepestLayout(e,t)){let{fallback:e,content:r}=f(a);return W(t,n,i)&&e!=null?e:T(C,{fallback:e},r)}return q(a,t,n)}function Y(e){let t=S(4),n=G(),r=U(),i;return t[0]!==n||t[1]!==r||t[2]!==e?(i=J(e,n,r),t[0]=n,t[1]=r,t[2]=e,t[3]=i):i=t[3],i}function ve({fallback:e=null,pathname:t,search:n},r){let i=y.getShell();if(i!=null){let e=q(i,t,n);return E(e)?e:null}return e!=null&&b(e)?null:e}function ye(e){let t=S(3),n=G(),r;return t[0]!==n||t[1]!==e?(r=ve(e,n),t[0]=n,t[1]=e,t[2]=r):r=t[2],r}function be(e,t,n){return e==null||e.commitKey!==n?{shouldScroll:!1,nextPending:null}:t===e.payload?{shouldScroll:!0,nextPending:null}:{shouldScroll:!1,nextPending:e}}function xe(e){if(e==null)return null;if(i(e)){let t=d(e);return t===e||!h(t)?null:t}return h(e)?e:null}const Se=/"timestamp":(\d+)/;function Ce(e){if(!t(e)||o(e))return!1;let n=e.message;return n===`Failed to fetch`||n.includes(`NetworkError`)||n.includes(`network error`)||n.includes(`Load failed`)}async function we(e){await new Promise(t=>{setTimeout(t,e)})}async function X(e,t,n){if(e.maySuspend!==!0||e.hasLoadingFallback!==!0)return e;if(e.bodyComplete==null){await Promise.resolve();let r=y.readLeaf(t,n);return r!=null&&!m(r)?{...e,maySuspend:!1}:e}if(await Promise.race([e.bodyComplete.then(e=>e?`body`:`failed`),we(100).then(()=>`timeout`)])===`body`)return{...e,maySuspend:!1};let r=y.readLeaf(t,n);return r!=null&&!m(r)?{...e,maySuspend:!1}:e}function Te(e){return e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`||E(e)||Array.isArray(e)}function Ee(e){return n(e)&&typeof e.from==`string`&&typeof e.to==`string`&&typeof e.navigationId==`number`&&n(e.options)}function De(e){return n(e)&&`element`in e}function Oe(e){return n(e)&&typeof e.navigationId==`number`&&typeof e.targetPath==`string`}function ke(e){if(!i(e))return e;if(n(e)&&e.status===`fulfilled`)return Te(e.value)?e.value:void 0}function Ae(e){return h(e)||E(e)&&c(e)}function je(e){let t=e.pendingHistory?.url;if(t!=null&&t!==``)try{return new URL(t,window.location.origin).search}catch{}return v().search}function Me(e,t){console.error(`[rari] AppRouter: Navigation failed:`,t),window.dispatchEvent(new CustomEvent(`rari:navigate-error`,{detail:{from:e.from,to:e.to,error:t,navigationId:e.navigationId}}))}function Ne(e){let t=e.pendingHistory?.url,n=t!=null&&t!==``?new URL(t,window.location.origin).hash.length>0:window.location.hash.length>0;return(e.options.historyKey==null||e.options.historyKey===``)&&!n&&e.options.scroll!==!1}async function Pe(e,t,n,r,i,a,o,s){let l=await Fe(e.element);if(r!==n)return{kind:`superseded`};if(!Ae(l))return{kind:`error`,error:/* @__PURE__ */ Error(`[rari] AppRouter: navigated Flight content did not resolve to an <html> document root`)};let u=xe(t);if(E(l)&&c(l)&&u==null)return{kind:`error`,error:/* @__PURE__ */ Error(`[rari] AppRouter: layout-reuse Flight marker requires a previous <html> document`)};if(u==null)return h(l)?(y.set(a,o,l),{kind:`payload`,payload:await X({...e,element:l,maySuspend:m(l),hasLoadingFallback:p(l)},a,o)}):{kind:`error`,error:/* @__PURE__ */ Error(`[rari] AppRouter: navigated Flight content did not resolve to an <html> document root`)};let d=z({previousDocument:u,refresh:l,fromPathname:i,toPathname:a,fromSearch:s,search:o});return d.kind===`hard-nav`?{kind:`hard-nav`}:{kind:`payload`,payload:await X({...e,element:d.element,maySuspend:d.maySuspend,hasLoadingFallback:d.hasLoadingFallback===!0,pendingEvictLeaf:d.pendingEvictLeaf},a,o)}}async function Fe(e){let t=x(e);for(let e=0;e<10&&i(t);e+=1)t=x(await t);if(i(t))throw Error(`[rari] AppRouter: Flight content did not resolve to a React node`);return t}function Ie({children:c,initialPayload:l,onNavigate:u}){let[d,f]=A(l),p=k(l),[m,g]=A(0),[_,S]=A(()=>v()),[C,re]=A(null),ie=k(_),w=k({x:0,y:0}),T=k(null),D=k(/* @__PURE__ */ new Map),j=k(/* @__PURE__ */ new Set),ue=k(u),P=k(0),F=k(0),de=k(/* @__PURE__ */ new Map),I=k(null),L=k(null),R=k(/* @__PURE__ */ new Map),z=k([]),B=k(null),V=k(0),[H,U]=A(null);O(()=>{ie.current=_},[_]),O(()=>{ue.current=u},[u]),se(()=>{let{shouldScroll:e,nextPending:t}=be(T.current,d,m);T.current=t,e&&window.scrollTo(0,0);let n=L.current;n!=null&&(L.current=null,window.dispatchEvent(new CustomEvent(`rari:navigate-committed`,{detail:{navigationId:n}})))},[d,m]),O(()=>{s()},[m]);let W=oe(e=>{if(e==null||i(e)||!E(e)||e.type!==`html`&&e.type!==`HTML`||b(e))return;let{pathname:t,search:n}=_;y.getShell()!=null&&y.hasRoute(t,n)||y.set(t,n,e)},[_]),G=k(W);O(()=>{G.current=W},[W]),O(()=>{p.current=d,d?.element!=null&&W(d.element)},[d,W]),O(()=>{if(d?.element!=null){let e=d.element;if(n(e)&&`status`in e&&e.status===`rejected`){let t=e.reason;t!=null&&t!==``&&console.error(`[rari] AppRouter: Flight payload rejected:`,t)}}},[d]);let K=()=>{D.current=te()},q=()=>{ne(D.current)};se(()=>{let e=I.current;e!=null&&d===e&&(I.current=null,window.scrollTo(w.current.x,w.current.y),q())},[d,m]);let J=(e,t,n,r)=>{V.current+=1;let i={timestamp:Date.now(),error:e,type:t,details:n,filePath:r,consecutiveFailures:V.current};z.current.push(i),z.current.length>10&&z.current.shift(),V.current>=2&&U(i),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`rari:hmr-failure`,{detail:i}))},Y=()=>{setTimeout(()=>{window.location.reload()},1e3)},ve=()=>{V.current>0&&(V.current=0)},xe=e=>{if(B.current==null||B.current===``)return!1;if(e===B.current)return!0;let t=Se.exec(e);if(t){let e=Number.parseInt(t[1],10);if(Date.now()-e>5e3)return!0}return!1},X=e=>{ee(e,j.current);let t=new ReadableStream({start(t){t.enqueue(new TextEncoder().encode(e)),t.close()}});return{element:le(t),flightProtocol:e}},Ae=async e=>{let t=await e;if(!t.body)throw Error(`Response has no body stream`);let n=t.clone();return{element:ce(Promise.resolve(t)),flightProtocol:``,bodyComplete:n.text().then(async e=>(await ee(e,j.current),e!==``&&(B.current=e),!0)).catch(()=>!1)}},Ie=async(t,n)=>{try{let e=await t.text();if(xe(e))return R.current.delete(n),`stale`;let r=await Fe(X(e).element);if(!h(r))throw Error(`[rari] AppRouter: refetched Flight content did not resolve to an <html> document root`);return{element:r,flightProtocol:e}}catch(t){if(o(t))throw t;let n=e(t),r=Error(`Failed to parse RSC Flight protocol: ${n.message}`,{cause:n});return J(r,`parse`,r.message,window.location.pathname),r}},Le=async(n,r,i)=>{let a=n!=null&&n!==``?n:window.location.pathname,s=P.current,c=i?.commit!==!1,l=i?.expectedRoute!=null&&i.expectedSeq!=null?`:hmr:${i.expectedRoute}:${i.expectedSeq}`:``,u=`${s}:${a}${window.location.search}:${c?`commit`:`defer`}${l}`,d=R.current.get(u);if(d)return d;let p=i?.expectedRoute,m=i?.expectedSeq,h=(async()=>{try{let e=a+window.location.search,t=await fetch(e,{headers:{Accept:`text/x-component`,"rari-navigation-id":String(P.current)},cache:`no-store`,signal:r});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 n=await Ie(t,u);if(n===`stale`)return;if(n instanceof Error)throw n;let i=p==null||m==null||de.current.get(p)===m;return P.current===s&&i&&(c&&f(n),n.flightProtocol!=null&&n.flightProtocol!==``&&(B.current=n.flightProtocol),ve()),R.current.delete(u),n}catch(n){throw R.current.delete(u),t(n)&&!o(n)&&!n.message.includes(`Failed to fetch RSC data`)&&!n.message.includes(`Failed to parse`)&&J(n,`network`,`Network error: ${n.message}`,window.location.pathname),e(n)}})();return R.current.set(u,h),h},Re=k(X),ze=k(Ae),Be=k(Le);O(()=>{Re.current=X,ze.current=Ae,Be.current=Le}),O(()=>{if(typeof window>`u`)return;let t=async e=>{if(e.rscResponsePromise){let t=await e.rscResponsePromise;if(P.current!==e.navigationId)return;let n=await ze.current(Promise.resolve(t));return P.current===e.navigationId?n:void 0}if(e.rscResponse){let t=await ze.current(Promise.resolve(e.rscResponse));return P.current===e.navigationId?t:void 0}if(e.rscFlightProtocol!=null&&e.rscFlightProtocol!==``)return Re.current(e.rscFlightProtocol);if(!e.isStreaming)return Be.current(e.to,e.abortSignal,{commit:!1})},n=async(t,n)=>{try{let e=await Pe(n,p.current?.element,t.navigationId,P.current,t.from,t.to,je(t),ie.current.search);if(e.kind===`superseded`)return null;if(e.kind===`hard-nav`){if(P.current!==t.navigationId)return null;let e=t.pendingHistory?.url!=null&&t.pendingHistory.url!==``?t.pendingHistory.url:t.to;return window.dispatchEvent(new CustomEvent(`rari:navigate-committed`,{detail:{navigationId:t.navigationId}})),window.location.assign(e),null}return e.kind===`error`?(Me(t,e.error),null):P.current===t.navigationId?e.payload:null}catch(n){return Me(t,e(n)),null}},s=(e,t)=>{let n=he(e.pendingHistory,{pathname:e.to,search:je(e)});ge({parsedPayload:t,shouldScrollToTop:Ne(e),navigationId:e.navigationId,transitionTypes:me({historyKey:e.options.historyKey,replace:e.options.replace}),maySuspend:t.maySuspend===!0,hasLoadingFallback:t.hasLoadingFallback===!0,pendingHistory:e.pendingHistory,routeLocation:n,pendingEvictLeaf:t.pendingEvictLeaf,startTransition:ae,currentNavigationIdRef:P,pendingScrollPayloadRef:T,setRenderKey:g,setRscPayload:f,setRouteLocation:S,setPendingLoadingLeaf:re,clearHmrError:()=>{U(null)},pendingNavigateCommittedIdRef:L}),t.flightProtocol!=null&&t.flightProtocol!==``&&(B.current=t.flightProtocol),ve(),ue.current&&ue.current(e)},c=async n=>{try{return{kind:`payload`,payload:await t(n)}}catch(t){return o(t)?{kind:`aborted`}:{kind:`error`,error:e(t)}}},l=async e=>{let t=r(e,Ee);if(!t||t.navigationId!==P.current)return;w.current={x:window.scrollX,y:window.scrollY},K();let i=await c(t);if(i.kind===`aborted`)return;if(i.kind===`error`){Me(t,i.error),V.current>=3&&Y();return}let a=i.payload;if(a==null&&t.isStreaming&&P.current===t.navigationId||a==null||P.current!==t.navigationId)return;let o=await n(t,a);o!=null&&s(t,o)},u=async t=>{let n;for(let e=0;e<3;e+=1)try{return await Be.current(void 0,void 0,{commit:!0,expectedRoute:t.expectedRoute,expectedSeq:t.expectedSeq})}catch(t){if(n=t,!Ce(t)||e===2)throw t;await we(150*(e+1))}throw e(n)},d=async()=>{let e=P.current,{pathname:t,search:n}=v(),r=`${t}${n}`,a=de.current,o=(a.get(r)??0)+1;a.set(r,o);let s=await u({expectedRoute:r,expectedSeq:o});if(P.current!==e)return!1;let{pathname:c,search:l}=v();if(`${c}${l}`!==r||a.get(r)!==o)return!1;let d=s?.element;return d!=null&&!i(d)&&E(d)&&(d.type===`html`||d.type===`HTML`)&&!b(d)&&y.set(t,n,d),!0},m=async()=>{w.current={x:window.scrollX,y:window.scrollY},K();try{if(!await d())return;let e=P.current,{pathname:t,search:n}=v(),r=`${t}${n}`,i={x:w.current.x,y:w.current.y};g(e=>e+1),U(null),requestAnimationFrame(()=>{if(P.current!==e)return;let{pathname:t,search:n}=v();`${t}${n}`===r&&(window.scrollTo(i.x,i.y),q())})}catch(e){console.error(`HMR refetch error:`,a(e,String(e))),V.current>=3&&Y()}},h=t=>{let n=r(t,De);if(n?.element==null||!Te(n.element)&&!i(n.element))return;let{pathname:a,search:o}=v(),s=++F.current,c=P.current,l=`${a}${o}`;w.current={x:window.scrollX,y:window.scrollY},K();try{n.revalidationKind===1?y.clear():n.revalidatedPath!=null&&n.revalidatedPath!==``?y.invalidate(n.revalidatedPath,o):y.invalidate(a,o);let t=p.current?.element,r=y.getElement(a,o)??(t!=null&&i(t)?null:t??null),u=n.element;(async()=>{try{let e=await Fe(u);if(s!==F.current||P.current!==c)return;let{pathname:t,search:n}=v();if(`${t}${n}`!==l)return;let i=pe({previousDocument:r??null,refresh:e,pathname:a,search:o});if(i.kind===`hard-nav`){window.location.reload();return}let d=i.element;if(s!==F.current||P.current!==c)return;let p=v();if(`${p.pathname}${p.search}`!==l)return;let m={element:d};I.current=m,ae(()=>{f(m),U(null)}),G.current(d),ve()}catch(t){if(s!==F.current||P.current!==c)return;let n=e(t);J(n,`parse`,`Action flight refresh failed: ${n.message}`,window.location.pathname),V.current>=3&&Y()}})()}catch(t){let n=e(t);J(n,`parse`,`Action flight refresh failed: ${n.message}`,window.location.pathname),V.current>=3&&Y()}},_=async()=>{try{if(!await d())return;g(e=>e+1),U(null)}catch(e){console.error(`RSC invalidate error:`,a(e,String(e))),V.current>=3&&Y()}},x=e=>{let t=r(e,Oe);t&&(j.current.clear(),P.current=t.navigationId,F.current+=1,T.current=null,I.current=null,re(null))},ee=async()=>{try{if(!await d())return;U(null)}catch(e){console.error(`Manifest update error:`,a(e,String(e))),V.current>=3&&Y()}},te=e=>{l(e)},ne=()=>{m()},C=()=>{_()},D=()=>{ee()};return window.addEventListener(`rari:navigation-start`,x),window.addEventListener(`rari:navigate`,te),window.addEventListener(`rari:app-router-rerender`,ne),window.addEventListener(`rari:action-flight-refresh`,h),window.addEventListener(`rari:rsc-invalidate`,C),window.addEventListener(`rari:app-router-manifest-updated`,D),()=>{window.removeEventListener(`rari:navigation-start`,x),window.removeEventListener(`rari:navigate`,te),window.removeEventListener(`rari:app-router-rerender`,ne),window.removeEventListener(`rari:action-flight-refresh`,h),window.removeEventListener(`rari:rsc-invalidate`,C),window.removeEventListener(`rari:app-router-manifest-updated`,D)}},[]),O(()=>{if(typeof window<`u`&&window.location.hash&&d){let e=window.location.hash.slice(1);requestAnimationFrame(()=>{requestAnimationFrame(()=>{let t=document.getElementById(e);t&&t.scrollIntoView({behavior:`instant`,block:`start`})})})}},[d]);let Ve=d?.element??c,He=x(Ve),[Z,Ue]=A(null),We=ke(He),Ge=i(He)&&We===void 0,Ke=We===void 0?i(He)?null:He:x(We),Q=Ke!=null&&!i(Ke)&&h(Ke)?Ke:null;Q!=null&&!Object.is(Q,Z)&&!b(Q)&&Ue(Q);let $=Ge?Z:Q,qe=$!=null&&h($)&&!b($)?$:Z!=null&&h(Z)&&!b(Z)?Z:null;if(qe==null&&!y.hasRoute(_.pathname,_.search))throw Error(`[rari] AppRouter: expected a resolved <html> document root`);return/* @__PURE__ */ N(_e,{value:C,children:[H!=null&&/* @__PURE__ */ M(fe,{failure:H,maxRetries:3,onRefresh:()=>{window.location.reload()},onDismiss:()=>{U(null)}}),/* @__PURE__ */ M(ye,{fallback:qe,pathname:_.pathname,search:_.search})]})}export{Ie as AppRouterProvider};
|
|
1
|
+
import{i as e}from"../navigation-transition-store-dfNJmkIX.mjs";import{n as t,r as n}from"../form-state-C9jn086j.mjs";import{S as r,d as i,g as a,i as o,p as s,r as c,s as l}from"../type-guards-BLY2PlGR.mjs";import"./action-revalidation-kind.mjs";import{n as u,t as d}from"../preload-modules-0iyuP4Vs.mjs";import{isLayoutReuseMarker as f,layoutPathOf as p,mergeFlightRefresh as m,unwrapFulfilledFlightNode as h}from"./merge-flight-refresh.mjs";import{a as g,i as _,n as v,r as y,t as b}from"../react-helpers-duOBWuYF.mjs";import{i as x,n as S,r as C,t as w}from"../route-cache-BfEqTT9i.mjs";import{c as ee}from"react/compiler-runtime";import{Suspense as T,addTransitionType as te,cloneElement as ne,createContext as E,createElement as D,isValidElement as O,startTransition as re,use as k,useCallback as ie,useEffect as A,useLayoutEffect as ae,useRef as j,useState as M,useSyncExternalStore as N}from"react";import{jsx as P,jsxs as F}from"react/jsx-runtime";import{createFromFetch as oe,createFromReadableStream as se}from"virtual:react-flight-client";const ce={position:`fixed`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,padding:`24px`,background:`rgba(220, 38, 38, 0.95)`,color:`white`,borderRadius:`8px`,fontSize:`14px`,zIndex:1e4,maxWidth:`500px`,boxShadow:`0 4px 6px rgba(0, 0, 0, 0.3)`},I={padding:`8px 16px`,background:`white`,color:`#dc2626`,border:`none`,borderRadius:`4px`,cursor:`pointer`,fontWeight:`bold`,fontSize:`14px`},L={padding:`8px 16px`,background:`rgba(255, 255, 255, 0.2)`,color:`white`,border:`1px solid rgba(255, 255, 255, 0.3)`,borderRadius:`4px`,cursor:`pointer`,fontSize:`14px`},le={fetch:`Failed to fetch updated content from server.`,parse:`Failed to parse server response.`,stale:`Server returned stale content.`,network:`Network error occurred.`};function R(e){return le[e]}function ue(e){let t=ee(27),{failure:n,maxRetries:r,onRefresh:i,onDismiss:a}=e,o,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=/* @__PURE__ */ P(`div`,{style:{marginBottom:`16px`,fontWeight:`bold`,fontSize:`16px`},children:`⚠️ HMR Update Failed`}),s={marginBottom:`12px`,opacity:.9},t[0]=o,t[1]=s):(o=t[0],s=t[1]);let c;t[2]===n.type?c=t[3]:(c=R(n.type),t[2]=n.type,t[3]=c);let l;t[4]===c?l=t[5]:(l=/* @__PURE__ */ P(`div`,{style:s,children:c}),t[4]=c,t[5]=l);let u;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(u={marginBottom:`16px`,fontSize:`12px`,opacity:.8,fontFamily:`monospace`},t[6]=u):u=t[6];let d;t[7]===n.details?d=t[8]:(d=/* @__PURE__ */ P(`div`,{style:u,children:n.details}),t[7]=n.details,t[8]=d);let f;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(f={marginBottom:`12px`,fontSize:`12px`,opacity:.7},t[9]=f):f=t[9];let p;t[10]!==n.consecutiveFailures||t[11]!==r?(p=/* @__PURE__ */ F(`div`,{style:f,children:[`Consecutive failures: `,n.consecutiveFailures,` / `,r]}),t[10]=n.consecutiveFailures,t[11]=r,t[12]=p):p=t[12];let m;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(m={display:`flex`,gap:`8px`},t[13]=m):m=t[13];let h;t[14]===i?h=t[15]:(h=/* @__PURE__ */ P(`button`,{onClick:i,type:`button`,style:I,children:`Refresh Page`}),t[14]=i,t[15]=h);let g;t[16]===a?g=t[17]:(g=/* @__PURE__ */ P(`button`,{onClick:a,type:`button`,style:L,children:`Dismiss`}),t[16]=a,t[17]=g);let _;t[18]!==h||t[19]!==g?(_=/* @__PURE__ */ F(`div`,{style:m,children:[h,g]}),t[18]=h,t[19]=g,t[20]=_):_=t[20];let v;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(v=/* @__PURE__ */ P(`div`,{style:{marginTop:`12px`,fontSize:`11px`,opacity:.6},children:`Check the console for detailed error logs.`}),t[21]=v):v=t[21];let y;return t[22]!==_||t[23]!==l||t[24]!==d||t[25]!==p?(y=/* @__PURE__ */ F(`div`,{style:ce,children:[o,l,d,p,_,v]}),t[22]=_,t[23]=l,t[24]=d,t[25]=p,t[26]=y):y=t[26],y}function z(e,t,n){C.getShell()??C.ingest(e,t,n)}function B(e){if(e.fromPathname!==`/`&&(e.fromPathname!==e.toPathname||e.fromSearch!==e.search))return{pathname:e.fromPathname,search:e.fromSearch}}function V(e){if(z(e.previousDocument,e.fromPathname,e.fromSearch),y(e.refresh)){if(!C.ingest(e.refresh,e.toPathname,e.search))return{kind:`hard-nav`}}else if(O(e.refresh)){if(!C.ingestSegment(e.refresh,e.toPathname,e.search))return{kind:`hard-nav`}}else return{kind:`hard-nav`};if(C.getShell()==null||!C.hasRoute(e.toPathname,e.search))return{kind:`hard-nav`};let t=C.readLeaf(e.toPathname,e.search),n=v(e.refresh)||t!=null&&v(t),r=t!=null&&_(t)||_(e.refresh),i=B(e);return y(e.refresh)?{kind:`merged`,element:e.refresh,maySuspend:n,hasLoadingFallback:r,pendingEvictLeaf:i}:{kind:`merged`,element:e.previousDocument,maySuspend:n,hasLoadingFallback:r,pendingEvictLeaf:i}}function H(e,t,n,r){if(y(t))return C.ingest(t,n,r);if(O(t)&&C.getShell()!=null)return C.ingestSegment(t,n,r);let i=m(e,t);return O(t)&&f(t)&&i===e||!y(i)?!1:C.ingest(i,n,r)}function U(e,t){let n=v(e),r=_(e);return y(e)?{kind:`merged`,element:e,maySuspend:n,hasLoadingFallback:r}:y(t)?{kind:`merged`,element:t,maySuspend:n,hasLoadingFallback:r}:{kind:`hard-nav`}}function de(e){return y(e.previousDocument)&&C.getShell()==null&&!C.ingest(e.previousDocument,e.pathname,e.search)||!H(e.previousDocument,e.refresh,e.pathname,e.search)||C.getShell()==null||!C.hasRoute(e.pathname,e.search)?{kind:`hard-nav`}:U(e.refresh,e.previousDocument)}function fe(e){return e.historyKey!=null&&e.historyKey!==``?[`nav`,`nav-traverse`]:e.replace===!0?[`nav`,`nav-replace`]:[`nav`,`nav-forward`]}function pe(e,t){if(e==null||e.url===``)return t;try{let t=`http://localhost/`;if(typeof window<`u`)try{t=window.location.href}catch{}let n=new URL(e.url,t);return{pathname:n.pathname,search:n.search}}catch{return t}}function W(e){e!=null&&typeof window<`u`&&(e.replace===!0?window.history.replaceState(e.state,``,e.url):window.history.pushState(e.state,``,e.url))}function me(e){let{parsedPayload:t,shouldScrollToTop:n,navigationId:r,transitionTypes:i,maySuspend:a=!1,hasLoadingFallback:o=!1,pendingHistory:s,routeLocation:c,startTransition:l=re,currentNavigationIdRef:u,pendingScrollPayloadRef:d,setRenderKey:f,setRscPayload:p,setRouteLocation:m,setPendingLoadingLeaf:h,clearHmrError:g,pendingNavigateCommittedIdRef:_,pendingEvictLeaf:v}=e;if(u.current!==r)return;let y=a&&o;a&&W(s),y&&c!=null&&(m?.(c),h?.(c));let b=()=>{u.current===r&&(h?.(null),a||W(s),c!=null&&m?.(c),v!=null&&C.evictLeaf(v.pathname,v.search),f(e=>{let r=e+1;return d.current=n?{payload:t,commitKey:r}:null,r}),p(t),g(),_.current=r)};l(()=>{if(i!=null)for(let e of i)te(e);b()})}const he=E(null);function G(){return k(he)}function K(e,t,n){return n?.pathname===e&&n.search===t}function ge(){return N(C.subscribe,C.getVersion,C.getVersion)}function _e(e){return p(e)!=null&&!x(e)&&!f(e)}function q(e,t,n){if(e==null||e===!1||e===!0)return e;if(Array.isArray(e))return b(e).map(e=>q(e,t,n));if(!O(e))return e;if(x(e)||_e(e)){let r=p(e);return r==null?null:D(Y,{key:r,layoutPath:r,pathname:t,search:n})}let r=e.props,i=r.children;if(i==null)return e;let a=q(i,t,n);if(Object.is(a,i))return e;let o=b(a),s={...r};return delete s.children,ne(e,s,...o.length===0?[null]:o)}function J({layoutPath:e,pathname:t,search:n},r,i=null){let a=C.readSegmentSnapshot(e,{pathname:t,search:n});if(a==null||O(a)&&x(a))return null;if(C.isDeepestLayout(e,t)){let{fallback:e,content:r}=g(a);return K(t,n,i)&&e!=null?e:D(T,{fallback:e},r)}return q(a,t,n)}function Y(e){let t=ee(4),n=ge(),r=G(),i;return t[0]!==n||t[1]!==r||t[2]!==e?(i=J(e,n,r),t[0]=n,t[1]=r,t[2]=e,t[3]=i):i=t[3],i}function ve({fallback:e=null,pathname:t,search:n},r){let i=C.getShell();if(i!=null){let e=q(i,t,n);return O(e)?e:null}return e!=null&&w(e)?null:e}function ye(e){let t=ee(3),n=ge(),r;return t[0]!==n||t[1]!==e?(r=ve(e,n),t[0]=n,t[1]=e,t[2]=r):r=t[2],r}function be(e,t,n){return e==null||e.commitKey!==n?{shouldScroll:!1,nextPending:null}:t===e.payload?{shouldScroll:!0,nextPending:null}:{shouldScroll:!1,nextPending:e}}function xe(e){if(e==null)return null;if(s(e)){let t=h(e);return t===e||!y(t)?null:t}return y(e)?e:null}const Se=/"timestamp":(\d+)/;function Ce(e){if(!i(e)||l(e))return!1;let t=e.message;return t===`Failed to fetch`||t.includes(`NetworkError`)||t.includes(`network error`)||t.includes(`Load failed`)}async function we(e){await new Promise(t=>{setTimeout(t,e)})}async function X(e,t,n){if(e.maySuspend!==!0||e.hasLoadingFallback!==!0)return e;if(e.bodyComplete==null){await Promise.resolve();let r=C.readLeaf(t,n);return r!=null&&!v(r)?{...e,maySuspend:!1}:e}if(await Promise.race([e.bodyComplete.then(e=>e?`body`:`failed`),we(100).then(()=>`timeout`)])===`body`)return{...e,maySuspend:!1};let r=C.readLeaf(t,n);return r!=null&&!v(r)?{...e,maySuspend:!1}:e}function Te(e){return e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`||O(e)||Array.isArray(e)}function Ee(e){return a(e)&&typeof e.from==`string`&&typeof e.to==`string`&&typeof e.navigationId==`number`&&a(e.options)}function De(e){return a(e)&&`element`in e}function Oe(e){return a(e)&&typeof e.navigationId==`number`&&typeof e.targetPath==`string`}function ke(e){if(!s(e))return e;if(a(e)&&e.status===`fulfilled`)return Te(e.value)?e.value:void 0}function Ae(e){return y(e)||O(e)&&f(e)}function je(e){let t=e.pendingHistory?.url;if(t!=null&&t!==``)try{return new URL(t,window.location.origin).search}catch{}return S().search}function Me(e,t){console.error(`[rari] AppRouter: Navigation failed:`,t),window.dispatchEvent(new CustomEvent(`rari:navigate-error`,{detail:{from:e.from,to:e.to,error:t,navigationId:e.navigationId}}))}function Ne(e){let t=e.pendingHistory?.url,n=t!=null&&t!==``?new URL(t,window.location.origin).hash.length>0:window.location.hash.length>0;return(e.options.historyKey==null||e.options.historyKey===``)&&!n&&e.options.scroll!==!1}async function Pe(e,t,n,r,i,a,o,s){let c=await Fe(e.element);if(r!==n)return{kind:`superseded`};if(!Ae(c))return{kind:`error`,error:/* @__PURE__ */ Error(`[rari] AppRouter: navigated Flight content did not resolve to an <html> document root`)};let l=xe(t);if(O(c)&&f(c)&&l==null)return{kind:`error`,error:/* @__PURE__ */ Error(`[rari] AppRouter: layout-reuse Flight marker requires a previous <html> document`)};if(l==null)return y(c)?(C.set(a,o,c),{kind:`payload`,payload:await X({...e,element:c,maySuspend:v(c),hasLoadingFallback:_(c)},a,o)}):{kind:`error`,error:/* @__PURE__ */ Error(`[rari] AppRouter: navigated Flight content did not resolve to an <html> document root`)};let u=V({previousDocument:l,refresh:c,fromPathname:i,toPathname:a,fromSearch:s,search:o});return u.kind===`hard-nav`?{kind:`hard-nav`}:{kind:`payload`,payload:await X({...e,element:u.element,maySuspend:u.maySuspend,hasLoadingFallback:u.hasLoadingFallback===!0,pendingEvictLeaf:u.pendingEvictLeaf},a,o)}}async function Fe(e){let t=u(e);for(let e=0;e<10&&s(t);e+=1)t=u(await t);if(s(t))throw Error(`[rari] AppRouter: Flight content did not resolve to a React node`);return t}function Ie({children:f,initialPayload:p,onNavigate:m}){let[h,g]=M(p),_=j(p),[v,b]=M(0),[x,ee]=M(()=>S()),[T,te]=M(null),ne=j(x),E=j({x:0,y:0}),D=j(null),k=j(/* @__PURE__ */ new Map),N=j(/* @__PURE__ */ new Set),ce=j(m),I=j(0),L=j(0),le=j(/* @__PURE__ */ new Map),R=j(null),z=j(null),B=j(/* @__PURE__ */ new Map),V=j([]),H=j(null),U=j(0),[W,G]=M(null);A(()=>{ne.current=x},[x]),A(()=>{ce.current=m},[m]),ae(()=>{let{shouldScroll:e,nextPending:t}=be(D.current,h,v);D.current=t,e&&window.scrollTo(0,0);let n=z.current;n!=null&&(z.current=null,window.dispatchEvent(new CustomEvent(`rari:navigate-committed`,{detail:{navigationId:n}})))},[h,v]),A(()=>{e()},[v]);let K=ie(e=>{if(e==null||s(e)||!O(e)||e.type!==`html`&&e.type!==`HTML`||w(e))return;let{pathname:t,search:n}=x;C.getShell()!=null&&C.hasRoute(t,n)||C.set(t,n,e)},[x]),ge=j(K);A(()=>{ge.current=K},[K]),A(()=>{_.current=h,h?.element!=null&&K(h.element)},[h,K]),A(()=>{if(h?.element!=null){let e=h.element;if(a(e)&&`status`in e&&e.status===`rejected`){let t=e.reason;t!=null&&t!==``&&console.error(`[rari] AppRouter: Flight payload rejected:`,t)}}},[h]);let _e=()=>{k.current=t()},q=()=>{n(k.current)};ae(()=>{let e=R.current;e!=null&&h===e&&(R.current=null,window.scrollTo(E.current.x,E.current.y),q())},[h,v]);let J=(e,t,n,r)=>{U.current+=1;let i={timestamp:Date.now(),error:e,type:t,details:n,filePath:r,consecutiveFailures:U.current};V.current.push(i),V.current.length>10&&V.current.shift(),U.current>=2&&G(i),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`rari:hmr-failure`,{detail:i}))},Y=()=>{setTimeout(()=>{window.location.reload()},1e3)},ve=()=>{U.current>0&&(U.current=0)},xe=e=>{if(H.current==null||H.current===``)return!1;if(e===H.current)return!0;let t=Se.exec(e);if(t){let e=Number.parseInt(t[1],10);if(Date.now()-e>5e3)return!0}return!1},X=e=>{d(e,N.current);let t=new ReadableStream({start(t){t.enqueue(new TextEncoder().encode(e)),t.close()}});return{element:se(t),flightProtocol:e}},Ae=async e=>{let t=await e;if(!t.body)throw Error(`Response has no body stream`);let n=t.clone();return{element:oe(Promise.resolve(t)),flightProtocol:``,bodyComplete:n.text().then(async e=>(await d(e,N.current),e!==``&&(H.current=e),!0)).catch(()=>!1)}},Ie=async(e,t)=>{try{let n=await e.text();if(xe(n))return B.current.delete(t),`stale`;let r=await Fe(X(n).element);if(!y(r))throw Error(`[rari] AppRouter: refetched Flight content did not resolve to an <html> document root`);return{element:r,flightProtocol:n}}catch(e){if(l(e))throw e;let t=r(e),n=Error(`Failed to parse RSC Flight protocol: ${t.message}`,{cause:t});return J(n,`parse`,n.message,window.location.pathname),n}},Le=async(e,t,n)=>{let a=e!=null&&e!==``?e:window.location.pathname,o=I.current,s=n?.commit!==!1,c=n?.expectedRoute!=null&&n.expectedSeq!=null?`:hmr:${n.expectedRoute}:${n.expectedSeq}`:``,u=`${o}:${a}${window.location.search}:${s?`commit`:`defer`}${c}`,d=B.current.get(u);if(d)return d;let f=n?.expectedRoute,p=n?.expectedSeq,m=(async()=>{try{let e=a+window.location.search,n=await fetch(e,{headers:{Accept:`text/x-component`,"rari-navigation-id":String(I.current)},cache:`no-store`,signal:t});if(!n.ok){let t=/* @__PURE__ */ Error(`Failed to fetch RSC data: ${n.status} ${n.statusText}`);throw J(t,`fetch`,`HTTP ${n.status} when fetching ${e}`,window.location.pathname),t}let r=await Ie(n,u);if(r===`stale`)return;if(r instanceof Error)throw r;let i=f==null||p==null||le.current.get(f)===p;return I.current===o&&i&&(s&&g(r),r.flightProtocol!=null&&r.flightProtocol!==``&&(H.current=r.flightProtocol),ve()),B.current.delete(u),r}catch(e){throw B.current.delete(u),i(e)&&!l(e)&&!e.message.includes(`Failed to fetch RSC data`)&&!e.message.includes(`Failed to parse`)&&J(e,`network`,`Network error: ${e.message}`,window.location.pathname),r(e)}})();return B.current.set(u,m),m},Re=j(X),ze=j(Ae),Be=j(Le);A(()=>{Re.current=X,ze.current=Ae,Be.current=Le}),A(()=>{if(typeof window>`u`)return;let e=async e=>{if(e.rscResponsePromise){let t=await e.rscResponsePromise;if(I.current!==e.navigationId)return;let n=await ze.current(Promise.resolve(t));return I.current===e.navigationId?n:void 0}if(e.rscResponse){let t=await ze.current(Promise.resolve(e.rscResponse));return I.current===e.navigationId?t:void 0}if(e.rscFlightProtocol!=null&&e.rscFlightProtocol!==``)return Re.current(e.rscFlightProtocol);if(!e.isStreaming)return Be.current(e.to,e.abortSignal,{commit:!1})},t=async(e,t)=>{try{let n=await Pe(t,_.current?.element,e.navigationId,I.current,e.from,e.to,je(e),ne.current.search);if(n.kind===`superseded`)return null;if(n.kind===`hard-nav`){if(I.current!==e.navigationId)return null;let t=e.pendingHistory?.url!=null&&e.pendingHistory.url!==``?e.pendingHistory.url:e.to;return window.dispatchEvent(new CustomEvent(`rari:navigate-committed`,{detail:{navigationId:e.navigationId}})),window.location.assign(t),null}return n.kind===`error`?(Me(e,n.error),null):I.current===e.navigationId?n.payload:null}catch(t){return Me(e,r(t)),null}},n=(e,t)=>{let n=pe(e.pendingHistory,{pathname:e.to,search:je(e)});me({parsedPayload:t,shouldScrollToTop:Ne(e),navigationId:e.navigationId,transitionTypes:fe({historyKey:e.options.historyKey,replace:e.options.replace}),maySuspend:t.maySuspend===!0,hasLoadingFallback:t.hasLoadingFallback===!0,pendingHistory:e.pendingHistory,routeLocation:n,pendingEvictLeaf:t.pendingEvictLeaf,startTransition:re,currentNavigationIdRef:I,pendingScrollPayloadRef:D,setRenderKey:b,setRscPayload:g,setRouteLocation:ee,setPendingLoadingLeaf:te,clearHmrError:()=>{G(null)},pendingNavigateCommittedIdRef:z}),t.flightProtocol!=null&&t.flightProtocol!==``&&(H.current=t.flightProtocol),ve(),ce.current&&ce.current(e)},i=async t=>{try{return{kind:`payload`,payload:await e(t)}}catch(e){return l(e)?{kind:`aborted`}:{kind:`error`,error:r(e)}}},a=async e=>{let r=o(e,Ee);if(!r||r.navigationId!==I.current)return;E.current={x:window.scrollX,y:window.scrollY},_e();let a=await i(r);if(a.kind===`aborted`)return;if(a.kind===`error`){Me(r,a.error),U.current>=3&&Y();return}let s=a.payload;if(s==null&&r.isStreaming&&I.current===r.navigationId||s==null||I.current!==r.navigationId)return;let c=await t(r,s);c!=null&&n(r,c)},u=async e=>{let t;for(let n=0;n<3;n+=1)try{return await Be.current(void 0,void 0,{commit:!0,expectedRoute:e.expectedRoute,expectedSeq:e.expectedSeq})}catch(e){if(t=e,!Ce(e)||n===2)throw e;await we(150*(n+1))}throw r(t)},d=async()=>{let e=I.current,{pathname:t,search:n}=S(),r=`${t}${n}`,i=le.current,a=(i.get(r)??0)+1;i.set(r,a);let o=await u({expectedRoute:r,expectedSeq:a});if(I.current!==e)return!1;let{pathname:c,search:l}=S();if(`${c}${l}`!==r||i.get(r)!==a)return!1;let d=o?.element;return d==null||s(d)||!O(d)||d.type!==`html`&&d.type!==`HTML`||w(d)||C.set(t,n,d),!0},f=async()=>{E.current={x:window.scrollX,y:window.scrollY},_e();try{if(!await d())return;let e=I.current,{pathname:t,search:n}=S(),r=`${t}${n}`,i={x:E.current.x,y:E.current.y};b(e=>e+1),G(null),requestAnimationFrame(()=>{if(I.current!==e)return;let{pathname:t,search:n}=S();`${t}${n}`===r&&(window.scrollTo(i.x,i.y),q())})}catch(e){console.error(`HMR refetch error:`,c(e,String(e))),U.current>=3&&Y()}},p=e=>{let t=o(e,De);if(t?.element==null||!Te(t.element)&&!s(t.element))return;let{pathname:n,search:i}=S(),a=++L.current,c=I.current,l=`${n}${i}`;E.current={x:window.scrollX,y:window.scrollY},_e();try{t.revalidationKind===1?C.clear():t.revalidatedPath!=null&&t.revalidatedPath!==``?C.invalidate(t.revalidatedPath,i):C.invalidate(n,i);let e=_.current?.element,o=C.getElement(n,i)??(e!=null&&s(e)?null:e??null),u=t.element;(async()=>{try{let e=await Fe(u);if(a!==L.current||I.current!==c)return;let{pathname:t,search:r}=S();if(`${t}${r}`!==l)return;let s=de({previousDocument:o??null,refresh:e,pathname:n,search:i});if(s.kind===`hard-nav`){window.location.reload();return}let d=s.element;if(a!==L.current||I.current!==c)return;let f=S();if(`${f.pathname}${f.search}`!==l)return;let p={element:d};R.current=p,re(()=>{g(p),G(null)}),ge.current(d),ve()}catch(e){if(a!==L.current||I.current!==c)return;let t=r(e);J(t,`parse`,`Action flight refresh failed: ${t.message}`,window.location.pathname),U.current>=3&&Y()}})()}catch(e){let t=r(e);J(t,`parse`,`Action flight refresh failed: ${t.message}`,window.location.pathname),U.current>=3&&Y()}},m=async()=>{try{if(!await d())return;b(e=>e+1),G(null)}catch(e){console.error(`RSC invalidate error:`,c(e,String(e))),U.current>=3&&Y()}},h=e=>{let t=o(e,Oe);t&&(N.current.clear(),I.current=t.navigationId,L.current+=1,D.current=null,R.current=null,te(null))},v=async()=>{try{if(!await d())return;G(null)}catch(e){console.error(`Manifest update error:`,c(e,String(e))),U.current>=3&&Y()}},y=e=>{a(e)},x=()=>{f()},T=()=>{m()},k=()=>{v()};return window.addEventListener(`rari:navigation-start`,h),window.addEventListener(`rari:navigate`,y),window.addEventListener(`rari:app-router-rerender`,x),window.addEventListener(`rari:action-flight-refresh`,p),window.addEventListener(`rari:rsc-invalidate`,T),window.addEventListener(`rari:app-router-manifest-updated`,k),()=>{window.removeEventListener(`rari:navigation-start`,h),window.removeEventListener(`rari:navigate`,y),window.removeEventListener(`rari:app-router-rerender`,x),window.removeEventListener(`rari:action-flight-refresh`,p),window.removeEventListener(`rari:rsc-invalidate`,T),window.removeEventListener(`rari:app-router-manifest-updated`,k)}},[]),A(()=>{if(typeof window<`u`&&window.location.hash&&h){let e=window.location.hash.slice(1);requestAnimationFrame(()=>{requestAnimationFrame(()=>{let t=document.getElementById(e);t&&t.scrollIntoView({behavior:`instant`,block:`start`})})})}},[h]);let Ve=h?.element??f,He=u(Ve),[Z,Ue]=M(null),We=ke(He),Ge=s(He)&&We===void 0,Ke=We===void 0?s(He)?null:He:u(We),Q=Ke!=null&&!s(Ke)&&y(Ke)?Ke:null;Q!=null&&!Object.is(Q,Z)&&!w(Q)&&Ue(Q);let $=Ge?Z:Q,qe=$!=null&&y($)&&!w($)?$:Z!=null&&y(Z)&&!w(Z)?Z:null;if(qe==null&&!C.hasRoute(x.pathname,x.search))throw Error(`[rari] AppRouter: expected a resolved <html> document root`);return/* @__PURE__ */ F(he,{value:T,children:[W!=null&&/* @__PURE__ */ P(ue,{failure:W,maxRetries:3,onRefresh:()=>{window.location.reload()},onDismiss:()=>{G(null)}}),/* @__PURE__ */ P(ye,{fallback:qe,pathname:x.pathname,search:x.search})]})}export{Ie as AppRouterProvider};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
|
-
//#region src/router/navigation/client-router.d.ts
|
|
3
2
|
export interface ClientRouterProps {
|
|
4
3
|
readonly children: ReactNode;
|
|
5
4
|
readonly initialRoute: string;
|
|
6
5
|
}
|
|
7
|
-
export declare function ClientRouter({ children, initialRoute }: ClientRouterProps): ReactNode;
|
|
8
|
-
//#endregion
|
|
6
|
+
export declare function ClientRouter({ children, initialRoute }: ClientRouterProps): ReactNode;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{a as e}from"../route-cache-BfEqTT9i.mjs";import{r as t}from"../path-CTEC1xmy.mjs";import{d as n,g as r,h as i,i as a,n as o,s}from"../type-guards-BLY2PlGR.mjs";import{i as c,t as l}from"../navigate-CSQP4q53.mjs";import{t as u}from"../form-state-C9jn086j.mjs";import{c as d}from"react/compiler-runtime";import{useEffect as f,useLayoutEffect as p,useRef as m,useState as h}from"react";function ee(e,t,n={}){let r=null,i=0,a=0,o=null,s=null,{leading:c=!1,trailing:l=!0,maxWait:u}=n;function d(t){let n=o,r=s;o=null,s=null,a=t,e.apply(r,n)}function f(e){let n=e-i,r=e-a;return i===0||n>=t||n<0||u!==void 0&&r>=u}function p(){let e=Date.now();if(f(e)){h(e);return}let n=e-i,o=e-a,s=t-n,c=u===void 0?1/0:u-o;r=setTimeout(p,Math.min(s,c))}function m(e){a=e,r=setTimeout(p,t),c&&d(e)}function h(e){r=null,l&&o?d(e):(o=null,s=null)}function ee(){r!==null&&clearTimeout(r),a=0,o=null,i=0,s=null,r=null}function g(){r!==null&&h(Date.now())}function _(){return r!==null}function v(...e){let n=Date.now(),a=f(n);if(o=e,s=this,i=n,a){if(r===null){m(i);return}
|
|
2
2
|
/* v8 ignore start - edge case: isInvoking true with existing timeout and maxWait defined */
|
|
3
|
-
if(
|
|
3
|
+
if(u!==void 0){r=setTimeout(p,t),d(i);return}}r??=setTimeout(p,t)}return v.cancel=ee,v.flush=g,v.pending=_,v}const g=/fetch|networkerror|load failed/i;function _(e,t){return{type:`abort`,message:`Navigation was cancelled`,originalError:e,url:t,timestamp:Date.now(),retryable:!1}}function v(e,t){return{type:`timeout`,message:`Navigation request timed out`,originalError:e,url:t,timestamp:Date.now(),retryable:!0}}function y(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 b(e,t){return{type:`network-error`,message:`Network error - check your connection`,originalError:e,url:t,timestamp:Date.now(),retryable:!0}}function x(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
5
|
originalError:o(e),url:t,timestamp:Date.now(),retryable:!1}}function S(e,t){return{type:`fetch-error`,message:o(e)?.message??`Unknown error occurred`,originalError:o(e),url:t,timestamp:Date.now(),retryable:!1}}function C(e,t){if(s(e))return _(o(e)??/* @__PURE__ */ Error(`Aborted`),t);if(n(e)&&(e.name===`TimeoutError`||e.message.includes(`timeout`)))return v(e,t);if(n(e)&&`status`in e){let n=e.status;return typeof n==`number`?y(e,n,t):S(e,t)}return e instanceof TypeError&&g.test(e.message)?b(e,t):e instanceof SyntaxError||n(e)&&e.message.includes(`parse`)?x(e,t):S(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 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&&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 r(e)&&typeof e.navigationId==`number`}function T(e){return r(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(!r(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`,i),window.removeEventListener(`rari:navigate-error`,o),t.removeEventListener(`abort`,s)}function i(t){a(t,w)?.navigationId===e&&(r(),n(`committed`))}function o(t){let i=a(t,T);i?.navigationId===e&&(r(),n({error:i.error}))}function s(){r(),n({error:new DOMException(`Aborted`,`AbortError`)})}window.addEventListener(`rari:navigate-committed`,i),window.addEventListener(`rari:navigate-error`,o),t.addEventListener(`abort`,s,{once:!0})})}function se(n){let r=u(35),{children:a,initialRoute:o}=n,l;r[0]===o?l=r[1]:(l=()=>({currentRoute:typeof window<`u`?`${window.location.pathname}${window.location.search}`:c(o),navigationId:0,error:null}),r[0]=o,r[1]=l);let[g,_]=m(l),v=p(null),y=p(!0),b;r[2]===o?b=r[3]:(b=typeof window<`u`?`${window.location.pathname}${window.location.search}`:c(o),r[2]=o,r[3]=b);let x=p(b),S;r[4]===o?S=r[5]:(S=typeof window<`u`?`${window.location.pathname}${window.location.search}${window.location.hash}`:c(o),r[4]=o,r[5]=S);let C=p(S),w=p(0),T;r[6]===Symbol.for(`react.memo_cache_sentinel`)?(T=new te({onError:ue}),r[6]=T):T=r[6];let se=p(T),E;r[7]===Symbol.for(`react.memo_cache_sentinel`)?(E=/* @__PURE__ */ new Map,r[7]=E):E=r[7];let D=p(E),O;r[8]===Symbol.for(`react.memo_cache_sentinel`)?(O=new ie({maxHistorySize:50}),r[8]=O):O=r[8];let k=p(O),de=le,A;r[9]===Symbol.for(`react.memo_cache_sentinel`)?(A=()=>{v.current&&=(v.current.abort(),null)},r[9]=A):A=r[9];let fe=A,j;r[10]===Symbol.for(`react.memo_cache_sentinel`)?(j=()=>{for(let[,e]of D.current.entries())e.bodyHandedOff?window.dispatchEvent(new CustomEvent(`rari:navigate-error`,{detail:{navigationId:e.navigationId,error:new DOMException(`Aborted`,`AbortError`)}})):e.abortController.abort();D.current.clear()},r[10]=j):j=r[10];let pe=j,M;r[11]===g?M=r[12]:(M=(e,t)=>{D.current.delete(e),y.current&&g.navigationId===t&&_(ce)},r[11]=g,r[12]=M);let N=M,P;r[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},r[13]=P):P=r[13];let me=P,F;if(r[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))},r[14]=F}else F=r[14];let he=F,I;r[15]===N?I=r[16]:(I=(e,t,n,r,i)=>{let a=i===void 0?{}:i;if(s(e)){N(t,n);return}let o=se.current.handleError(e,t);y.current&&(_(e=>({...e,error:o})),window.history.replaceState(window.history.state,``,r)),D.current.delete(t),a.emitEvent!==!1&&window.dispatchEvent(new CustomEvent(`rari:navigate-error`,{detail:{from:r,to:t,error:o,navigationId:n}}))},r[15]=N,r[16]=I);let L=I,R;r[17]!==N||r[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=c(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 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===``)&&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},c=await fetch(r,{headers:{Accept:`text/x-component`,"rari-navigation-id":String(l),"rari-router-state":ee()},cache:`no-store`,signal:s.signal});if(!c.ok&&c.status!==404){L(/* @__PURE__ */ Error(`Failed to fetch: ${c.status}`),a,l,e);return}if(s.signal.aborted){N(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=oe(l,s.signal),g=D.current.get(a);if(g!=null&&(g.bodyHandedOff=!0),v.current===s&&(v.current=null),window.dispatchEvent(new CustomEvent(`rari:navigate`,{detail:{from:new URL(e,window.location.origin).pathname,to:d,navigationId:l,options:n,abortSignal:s.signal,rscResponse:c,pendingHistory:{url:m,state:p,replace:n.replace===!0}}})),w.current!==l){window.dispatchEvent(new CustomEvent(`rari:navigate-error`,{detail:{navigationId:l,error:new DOMException(`Aborted`,`AbortError`)}}));return}let _=await h;if(w.current!==l)return;if(_!==`committed`){L(_.error,a,l,e,{emitEvent:!1});return}he(f,i,n,l,m),ae(c),D.current.delete(a)}catch(t){L(t,a,l,e)}})();return D.current.set(a,{targetPath:a,navigationId:l,promise:u,abortController:s,bodyHandedOff:!1}),u},r[17]=N,r[18]=L,r[19]=R):R=r[19];let z=R,B=p(z),V;r[20]===z?V=r[21]:(V=()=>(B.current=z,()=>{B.current=null}),r[20]=z,r[21]=V),f(V);let ge=p(null),H,U;r[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=[],r[22]=H,r[23]=U):(H=r[22],U=r[23]),f(H,U);let W;r[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})},r[24]=W):W=r[24];let _e=W,G;r[25]===Symbol.for(`react.memo_cache_sentinel`)?(G=e=>{let t=`${window.location.pathname}${window.location.search}${window.location.hash}`,n=i(e.state)?e.state:null;B.current&&B.current(t,{replace:!0,scroll:!1,historyKey:n?.key})},r[25]=G):G=r[25];let ve=G,K;r[26]===Symbol.for(`react.memo_cache_sentinel`)?(K=()=>{let e=i(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)}},r[26]=K):K=r[26];let q;r[27]===o?q=r[28]:(q=[o],r[27]=o,r[28]=q),d(K,q);let J;r[29]===Symbol.for(`react.memo_cache_sentinel`)?(J=e=>{if(e.persisted){let e=window.location.pathname;k.current.captureState(e)}},r[29]=J):J=r[29];let ye=J,Y;r[30]===Symbol.for(`react.memo_cache_sentinel`)?(Y=e=>{if(e.persisted){let e=window.location.pathname,t=i(window.history.state)?window.history.state:null;requestAnimationFrame(()=>{k.current.restoreState(e),t?.scrollPosition&&window.scrollTo(t.scrollPosition.x,t.scrollPosition.y)})}},r[30]=Y):Y=r[30];let be=Y,X,Z;r[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=[],r[31]=X,r[32]=Z):(X=r[31],Z=r[32]),d(X,Z);let Q,$;return r[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()}),$=[],r[33]=Q,r[34]=$):(Q=r[33],$=r[34]),d(Q,$),a}function ce(e){return{...e}}function le(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`hk-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,11)}`}function ue(e){console.error(`[rari] Router: Navigation error:`,e)}export{se as ClientRouter};
|
|
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 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&&u(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 r(e)&&typeof e.navigationId==`number`}function T(e){return r(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(!r(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`,i),window.removeEventListener(`rari:navigate-error`,o),t.removeEventListener(`abort`,s)}function i(t){a(t,w)?.navigationId===e&&(r(),n(`committed`))}function o(t){let i=a(t,T);i?.navigationId===e&&(r(),n({error:i.error}))}function s(){r(),n({error:new DOMException(`Aborted`,`AbortError`)})}window.addEventListener(`rari:navigate-committed`,i),window.addEventListener(`rari:navigate-error`,o),t.addEventListener(`abort`,s,{once:!0})})}function se(n){let r=d(35),{children:a,initialRoute:o}=n,u;r[0]===o?u=r[1]:(u=()=>({currentRoute:typeof window<`u`?`${window.location.pathname}${window.location.search}`:t(o),navigationId:0,error:null}),r[0]=o,r[1]=u);let[g,_]=h(u),v=m(null),y=m(!0),b;r[2]===o?b=r[3]:(b=typeof window<`u`?`${window.location.pathname}${window.location.search}`:t(o),r[2]=o,r[3]=b);let x=m(b),S;r[4]===o?S=r[5]:(S=typeof window<`u`?`${window.location.pathname}${window.location.search}${window.location.hash}`:t(o),r[4]=o,r[5]=S);let C=m(S),w=m(0),T;r[6]===Symbol.for(`react.memo_cache_sentinel`)?(T=new te({onError:ue}),r[6]=T):T=r[6];let se=m(T),E;r[7]===Symbol.for(`react.memo_cache_sentinel`)?(E=/* @__PURE__ */ new Map,r[7]=E):E=r[7];let D=m(E),O;r[8]===Symbol.for(`react.memo_cache_sentinel`)?(O=new ie({maxHistorySize:50}),r[8]=O):O=r[8];let k=m(O),de=le,A;r[9]===Symbol.for(`react.memo_cache_sentinel`)?(A=()=>{v.current&&=(v.current.abort(),null)},r[9]=A):A=r[9];let fe=A,j;r[10]===Symbol.for(`react.memo_cache_sentinel`)?(j=()=>{for(let[,e]of D.current.entries())e.bodyHandedOff?window.dispatchEvent(new CustomEvent(`rari:navigate-error`,{detail:{navigationId:e.navigationId,error:new DOMException(`Aborted`,`AbortError`)}})):e.abortController.abort();D.current.clear()},r[10]=j):j=r[10];let pe=j,M;r[11]===g?M=r[12]:(M=(e,t)=>{D.current.delete(e),y.current&&g.navigationId===t&&_(ce)},r[11]=g,r[12]=M);let N=M,P;r[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},r[13]=P):P=r[13];let me=P,F;if(r[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))},r[14]=F}else F=r[14];let he=F,I;r[15]===N?I=r[16]:(I=(e,t,n,r,i)=>{let a=i===void 0?{}:i;if(s(e)){N(t,n);return}let o=se.current.handleError(e,t);y.current&&(_(e=>({...e,error:o})),window.history.replaceState(window.history.state,``,r)),D.current.delete(t),a.emitEvent!==!1&&window.dispatchEvent(new CustomEvent(`rari:navigate-error`,{detail:{from:r,to:t,error:o,navigationId:n}}))},r[15]=N,r[16]=I);let L=I,R;r[17]!==N||r[18]!==L?(R=async(n,r)=>{let i=r===void 0?{}:r;if(!n||typeof n!=`string`)return;let[a,o]=n.includes(`#`)?n.split(`#`):[n,``],s=t(a);if(s===x.current){me(o,{replace:i.replace===!0});return}let c=D.current.get(s);if(c)return c.promise;pe(),fe();let l=new AbortController;v.current=l,w.current+=1;let u=w.current;window.dispatchEvent(new CustomEvent(`rari:navigation-start`,{detail:{navigationId:u,targetPath:s}}));let d=(async()=>{let t=C.current;try{(i.historyKey==null||i.historyKey===``)&&k.current.captureState(x.current);let n=i.historyKey!=null&&i.historyKey!==``?i.historyKey:de(),r=window.location.origin+s,a={route:s,navigationId:u,scrollPosition:{x:window.scrollX,y:window.scrollY},timestamp:Date.now(),key:n},c=await fetch(r,{headers:{Accept:`text/x-component`,"rari-navigation-id":String(u),"rari-router-state":e()},cache:`no-store`,signal:l.signal});if(!c.ok&&c.status!==404){L(/* @__PURE__ */ Error(`Failed to fetch: ${c.status}`),s,u,t);return}if(l.signal.aborted){N(s,u);return}let d=new URL(c.url),f=d.pathname,p=`${d.pathname}${d.search}`,m={...a,route:p},h=`${p}${o?`#${o}`:``}`;if(w.current!==u)return;let ee=oe(u,l.signal),g=D.current.get(s);if(g!=null&&(g.bodyHandedOff=!0),v.current===l&&(v.current=null),window.dispatchEvent(new CustomEvent(`rari:navigate`,{detail:{from:new URL(t,window.location.origin).pathname,to:f,navigationId:u,options:i,abortSignal:l.signal,rscResponse:c,pendingHistory:{url:h,state:m,replace:i.replace===!0}}})),w.current!==u){window.dispatchEvent(new CustomEvent(`rari:navigate-error`,{detail:{navigationId:u,error:new DOMException(`Aborted`,`AbortError`)}}));return}let _=await ee;if(w.current!==u)return;if(_!==`committed`){L(_.error,s,u,t,{emitEvent:!1});return}he(p,o,i,u,h),ae(c),D.current.delete(s)}catch(e){L(e,s,u,t)}})();return D.current.set(s,{targetPath:s,navigationId:u,promise:d,abortController:l,bodyHandedOff:!1}),d},r[17]=N,r[18]=L,r[19]=R):R=r[19];let z=R,B=m(z),V;r[20]===z?V=r[21]:(V=()=>(B.current=z,()=>{B.current=null}),r[20]=z,r[21]=V),p(V);let ge=m(null),H,U;r[22]===Symbol.for(`react.memo_cache_sentinel`)?(H=()=>{ge.current??=ee((e,t)=>{B.current?.(e,t)},50,{leading:!0,trailing:!0,maxWait:200})},U=[],r[22]=H,r[23]=U):(H=r[22],U=r[23]),p(H,U);let W;r[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})},r[24]=W):W=r[24];let _e=W,G;r[25]===Symbol.for(`react.memo_cache_sentinel`)?(G=e=>{let t=`${window.location.pathname}${window.location.search}${window.location.hash}`,n=i(e.state)?e.state:null;B.current&&B.current(t,{replace:!0,scroll:!1,historyKey:n?.key})},r[25]=G):G=r[25];let ve=G,K;r[26]===Symbol.for(`react.memo_cache_sentinel`)?(K=()=>{let e=i(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)}},r[26]=K):K=r[26];let q;r[27]===o?q=r[28]:(q=[o],r[27]=o,r[28]=q),f(K,q);let J;r[29]===Symbol.for(`react.memo_cache_sentinel`)?(J=e=>{if(e.persisted){let e=window.location.pathname;k.current.captureState(e)}},r[29]=J):J=r[29];let ye=J,Y;r[30]===Symbol.for(`react.memo_cache_sentinel`)?(Y=e=>{if(e.persisted){let e=window.location.pathname,t=i(window.history.state)?window.history.state:null;requestAnimationFrame(()=>{k.current.restoreState(e),t?.scrollPosition&&window.scrollTo(t.scrollPosition.x,t.scrollPosition.y)})}},r[30]=Y):Y=r[30];let be=Y,X,Z;r[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=[],r[31]=X,r[32]=Z):(X=r[31],Z=r[32]),f(X,Z);let Q,$;return r[33]===Symbol.for(`react.memo_cache_sentinel`)?(Q=()=>(y.current=!0,c(async(e,t)=>B.current?.(e,t)??Promise.resolve()),()=>{y.current=!1,l(),fe(),pe(),ge.current?.cancel()}),$=[],r[33]=Q,r[34]=$):(Q=r[33],$=r[34]),f(Q,$),a}function ce(e){return{...e}}function le(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`hk-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,11)}`}function ue(e){console.error(`[rari] Router: Navigation error:`,e)}export{se as ClientRouter};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Component, ComponentType, ErrorInfo, ReactNode } from "react";
|
|
2
|
-
//#region src/runtime/boundaries/error-boundary-wrapper.d.ts
|
|
3
2
|
interface ErrorBoundaryWrapperProps {
|
|
4
3
|
readonly errorComponentId: string;
|
|
5
4
|
readonly children: ReactNode;
|
|
@@ -23,5 +22,4 @@ export declare class ErrorBoundaryWrapper extends Component<ErrorBoundaryWrapper
|
|
|
23
22
|
reset: () => void;
|
|
24
23
|
render(): ReactNode;
|
|
25
24
|
}
|
|
26
|
-
//#endregion
|
|
27
25
|
export {};
|