react-router 7.9.1 → 7.9.2-pre.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -9
- package/dist/development/{chunk-B7RQU5TL.mjs → chunk-I4PRIPRX.mjs} +178 -26
- package/dist/{production/chunk-RCAZODXZ.mjs → development/chunk-ITFVGECV.mjs} +155 -65
- package/dist/development/{chunk-PW3F6ATG.js → chunk-MVCD4EFU.js} +102 -70
- package/dist/{production/chunk-3SXVZXGI.js → development/chunk-XCFBICS6.js} +277 -157
- package/dist/development/{context-CIdFp11b.d.mts → context-BqL5Eckq.d.mts} +20 -0
- package/dist/development/dom-export.d.mts +1 -1
- package/dist/development/dom-export.js +3 -3
- package/dist/development/dom-export.mjs +3 -3
- package/dist/development/{index-react-server-client-BeVfPpWg.d.mts → index-react-server-client-2EDmGlsZ.d.mts} +40 -24
- package/dist/{production/index-react-server-client-BYr9g50r.d.ts → development/index-react-server-client-DKvU8YRr.d.ts} +39 -23
- package/dist/development/index-react-server-client.d.mts +3 -3
- package/dist/development/index-react-server-client.d.ts +2 -2
- package/dist/development/index-react-server-client.js +4 -4
- package/dist/development/index-react-server-client.mjs +2 -2
- package/dist/development/index-react-server.d.mts +10 -0
- package/dist/development/index-react-server.d.ts +10 -0
- package/dist/development/index-react-server.js +3 -3
- package/dist/development/index-react-server.mjs +3 -3
- package/dist/development/index.d.mts +16 -12
- package/dist/development/index.d.ts +14 -10
- package/dist/development/index.js +250 -160
- package/dist/development/index.mjs +3 -3
- package/dist/development/lib/types/internal.d.mts +2 -2
- package/dist/development/lib/types/internal.d.ts +1 -1
- package/dist/development/lib/types/internal.js +1 -1
- package/dist/development/lib/types/internal.mjs +1 -1
- package/dist/development/{route-data-Bpm4liR_.d.mts → route-data-CDwqkzPE.d.mts} +1 -1
- package/dist/{production/routeModules-DnUHijGz.d.ts → development/routeModules-BmVo7q9e.d.ts} +20 -0
- package/dist/production/{chunk-HMYSPRGR.js → chunk-4FAGWJMT.js} +102 -70
- package/dist/{development/chunk-LWNHKVDL.js → production/chunk-MKNSEQLS.js} +277 -157
- package/dist/{development/chunk-SKNKB5VI.mjs → production/chunk-RXSRHQUT.mjs} +155 -65
- package/dist/production/{chunk-P25HWPOZ.mjs → chunk-SKKC22F5.mjs} +178 -26
- package/dist/production/{context-CIdFp11b.d.mts → context-BqL5Eckq.d.mts} +20 -0
- package/dist/production/dom-export.d.mts +1 -1
- package/dist/production/dom-export.js +3 -3
- package/dist/production/dom-export.mjs +3 -3
- package/dist/production/{index-react-server-client-BeVfPpWg.d.mts → index-react-server-client-2EDmGlsZ.d.mts} +40 -24
- package/dist/{development/index-react-server-client-BYr9g50r.d.ts → production/index-react-server-client-DKvU8YRr.d.ts} +39 -23
- package/dist/production/index-react-server-client.d.mts +3 -3
- package/dist/production/index-react-server-client.d.ts +2 -2
- package/dist/production/index-react-server-client.js +4 -4
- package/dist/production/index-react-server-client.mjs +2 -2
- package/dist/production/index-react-server.d.mts +10 -0
- package/dist/production/index-react-server.d.ts +10 -0
- package/dist/production/index-react-server.js +3 -3
- package/dist/production/index-react-server.mjs +3 -3
- package/dist/production/index.d.mts +16 -12
- package/dist/production/index.d.ts +14 -10
- package/dist/production/index.js +250 -160
- package/dist/production/index.mjs +3 -3
- package/dist/production/lib/types/internal.d.mts +2 -2
- package/dist/production/lib/types/internal.d.ts +1 -1
- package/dist/production/lib/types/internal.js +1 -1
- package/dist/production/lib/types/internal.mjs +1 -1
- package/dist/production/{route-data-Bpm4liR_.d.mts → route-data-CDwqkzPE.d.mts} +1 -1
- package/dist/{development/routeModules-DnUHijGz.d.ts → production/routeModules-BmVo7q9e.d.ts} +20 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v7.9.1
|
|
2
|
+
* react-router v7.9.2-pre.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
SingleFetchRedirectSymbol,
|
|
23
23
|
StaticRouterProvider,
|
|
24
24
|
StreamTransfer,
|
|
25
|
+
UNSTABLE_TransitionEnabledRouterProvider,
|
|
25
26
|
convertRoutesToDataRoutes,
|
|
26
27
|
createBrowserHistory,
|
|
27
28
|
createContext,
|
|
@@ -59,7 +60,7 @@ import {
|
|
|
59
60
|
withComponentProps,
|
|
60
61
|
withErrorBoundaryProps,
|
|
61
62
|
withHydrateFallbackProps
|
|
62
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-SKKC22F5.mjs";
|
|
63
64
|
|
|
64
65
|
// lib/dom/ssr/server.tsx
|
|
65
66
|
import * as React from "react";
|
|
@@ -192,6 +193,12 @@ function processRoutes(routes, context, manifest, routeModules, parentId) {
|
|
|
192
193
|
ErrorBoundary: route.ErrorBoundary ? withErrorBoundaryProps(route.ErrorBoundary) : void 0,
|
|
193
194
|
action: route.action ? (args) => route.action({ ...args, context }) : void 0,
|
|
194
195
|
loader: route.loader ? (args) => route.loader({ ...args, context }) : void 0,
|
|
196
|
+
middleware: route.middleware ? route.middleware.map(
|
|
197
|
+
(mw) => (...args) => mw(
|
|
198
|
+
{ ...args[0], context },
|
|
199
|
+
args[1]
|
|
200
|
+
)
|
|
201
|
+
) : void 0,
|
|
195
202
|
handle: route.handle,
|
|
196
203
|
shouldRevalidate: route.shouldRevalidate
|
|
197
204
|
};
|
|
@@ -1234,9 +1241,11 @@ async function handleManifestRequest(build, routes, url) {
|
|
|
1234
1241
|
});
|
|
1235
1242
|
}
|
|
1236
1243
|
let patches = {};
|
|
1237
|
-
if (url.searchParams.has("
|
|
1244
|
+
if (url.searchParams.has("paths")) {
|
|
1238
1245
|
let paths = /* @__PURE__ */ new Set();
|
|
1239
|
-
url.searchParams.
|
|
1246
|
+
let pathParam = url.searchParams.get("paths") || "";
|
|
1247
|
+
let requestedPaths = pathParam.split(",").filter(Boolean);
|
|
1248
|
+
requestedPaths.forEach((path) => {
|
|
1240
1249
|
if (!path.startsWith("/")) {
|
|
1241
1250
|
path = `/${path}`;
|
|
1242
1251
|
}
|
|
@@ -1848,7 +1857,7 @@ function createCallServer({
|
|
|
1848
1857
|
return async (id, args) => {
|
|
1849
1858
|
let actionId = globalVar.__routerActionID = (globalVar.__routerActionID ?? (globalVar.__routerActionID = 0)) + 1;
|
|
1850
1859
|
const temporaryReferences = createTemporaryReferenceSet();
|
|
1851
|
-
const
|
|
1860
|
+
const payloadPromise = fetchImplementation(
|
|
1852
1861
|
new Request(location.href, {
|
|
1853
1862
|
body: await encodeReply(args, { temporaryReferences }),
|
|
1854
1863
|
method: "POST",
|
|
@@ -1857,44 +1866,45 @@ function createCallServer({
|
|
|
1857
1866
|
"rsc-action-id": id
|
|
1858
1867
|
}
|
|
1859
1868
|
})
|
|
1860
|
-
)
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
}
|
|
1864
|
-
const payload = await createFromReadableStream(response.body, {
|
|
1865
|
-
temporaryReferences
|
|
1866
|
-
});
|
|
1867
|
-
if (payload.type === "redirect") {
|
|
1868
|
-
if (payload.reload) {
|
|
1869
|
-
window.location.href = payload.location;
|
|
1870
|
-
return;
|
|
1869
|
+
).then((response) => {
|
|
1870
|
+
if (!response.body) {
|
|
1871
|
+
throw new Error("No response body");
|
|
1871
1872
|
}
|
|
1872
|
-
|
|
1873
|
-
|
|
1873
|
+
return createFromReadableStream(response.body, {
|
|
1874
|
+
temporaryReferences
|
|
1874
1875
|
});
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1876
|
+
});
|
|
1877
|
+
globalVar.__reactRouterDataRouter.__setPendingRerender(
|
|
1878
|
+
Promise.resolve(payloadPromise).then(async (payload) => {
|
|
1879
|
+
if (payload.type === "redirect") {
|
|
1880
|
+
if (payload.reload) {
|
|
1881
|
+
window.location.href = payload.location;
|
|
1882
|
+
return () => {
|
|
1883
|
+
};
|
|
1884
|
+
}
|
|
1885
|
+
return () => {
|
|
1886
|
+
globalVar.__reactRouterDataRouter.navigate(payload.location, {
|
|
1887
|
+
replace: payload.replace
|
|
1888
|
+
});
|
|
1889
|
+
};
|
|
1890
|
+
}
|
|
1891
|
+
if (payload.type !== "action") {
|
|
1892
|
+
throw new Error("Unexpected payload type");
|
|
1893
|
+
}
|
|
1894
|
+
const rerender = await payload.rerender;
|
|
1895
|
+
if (rerender && landedActionId < actionId && globalVar.__routerActionID <= actionId) {
|
|
1896
|
+
if (rerender.type === "redirect") {
|
|
1897
|
+
if (rerender.reload) {
|
|
1898
|
+
window.location.href = rerender.location;
|
|
1899
|
+
return;
|
|
1900
|
+
}
|
|
1901
|
+
return () => {
|
|
1893
1902
|
globalVar.__reactRouterDataRouter.navigate(rerender.location, {
|
|
1894
1903
|
replace: rerender.replace
|
|
1895
1904
|
});
|
|
1896
|
-
|
|
1897
|
-
|
|
1905
|
+
};
|
|
1906
|
+
}
|
|
1907
|
+
return () => {
|
|
1898
1908
|
let lastMatch;
|
|
1899
1909
|
for (const match of rerender.matches) {
|
|
1900
1910
|
globalVar.__reactRouterDataRouter.patchRoutes(
|
|
@@ -1905,29 +1915,32 @@ function createCallServer({
|
|
|
1905
1915
|
lastMatch = match;
|
|
1906
1916
|
}
|
|
1907
1917
|
window.__reactRouterDataRouter._internalSetStateDoNotUseOrYouWillBreakYourApp(
|
|
1908
|
-
{
|
|
1918
|
+
{
|
|
1919
|
+
loaderData: Object.assign(
|
|
1920
|
+
{},
|
|
1921
|
+
globalVar.__reactRouterDataRouter.state.loaderData,
|
|
1922
|
+
rerender.loaderData
|
|
1923
|
+
),
|
|
1924
|
+
errors: rerender.errors ? Object.assign(
|
|
1925
|
+
{},
|
|
1926
|
+
globalVar.__reactRouterDataRouter.state.errors,
|
|
1927
|
+
rerender.errors
|
|
1928
|
+
) : null
|
|
1929
|
+
}
|
|
1909
1930
|
);
|
|
1910
|
-
|
|
1911
|
-
window.__reactRouterDataRouter._internalSetStateDoNotUseOrYouWillBreakYourApp(
|
|
1912
|
-
{
|
|
1913
|
-
loaderData: Object.assign(
|
|
1914
|
-
{},
|
|
1915
|
-
globalVar.__reactRouterDataRouter.state.loaderData,
|
|
1916
|
-
rerender.loaderData
|
|
1917
|
-
),
|
|
1918
|
-
errors: rerender.errors ? Object.assign(
|
|
1919
|
-
{},
|
|
1920
|
-
globalVar.__reactRouterDataRouter.state.errors,
|
|
1921
|
-
rerender.errors
|
|
1922
|
-
) : null
|
|
1923
|
-
}
|
|
1924
|
-
);
|
|
1925
|
-
});
|
|
1926
|
-
}
|
|
1931
|
+
};
|
|
1927
1932
|
}
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1933
|
+
return () => {
|
|
1934
|
+
};
|
|
1935
|
+
}).catch(() => {
|
|
1936
|
+
})
|
|
1937
|
+
);
|
|
1938
|
+
return payloadPromise.then((payload) => {
|
|
1939
|
+
if (payload.type !== "action" && payload.type !== "redirect") {
|
|
1940
|
+
throw new Error("Unexpected payload type");
|
|
1941
|
+
}
|
|
1942
|
+
return payload.actionResult;
|
|
1943
|
+
});
|
|
1931
1944
|
};
|
|
1932
1945
|
}
|
|
1933
1946
|
function createRouterFromPayload({
|
|
@@ -2294,7 +2307,7 @@ function RSCHydratedRouter({
|
|
|
2294
2307
|
routeDiscovery: { mode: "lazy", manifestPath: "/__manifest" },
|
|
2295
2308
|
routeModules
|
|
2296
2309
|
};
|
|
2297
|
-
return /* @__PURE__ */ React4.createElement(RSCRouterContext.Provider, { value: true }, /* @__PURE__ */ React4.createElement(RSCRouterGlobalErrorBoundary, { location: location2 }, /* @__PURE__ */ React4.createElement(FrameworkContext.Provider, { value: frameworkContext }, /* @__PURE__ */ React4.createElement(
|
|
2310
|
+
return /* @__PURE__ */ React4.createElement(RSCRouterContext.Provider, { value: true }, /* @__PURE__ */ React4.createElement(RSCRouterGlobalErrorBoundary, { location: location2 }, /* @__PURE__ */ React4.createElement(FrameworkContext.Provider, { value: frameworkContext }, /* @__PURE__ */ React4.createElement(UNSTABLE_TransitionEnabledRouterProvider, { router, flushSync: ReactDOM.flushSync }))));
|
|
2298
2311
|
}
|
|
2299
2312
|
function createRouteFromServerManifest(match, payload) {
|
|
2300
2313
|
let hasInitialData = payload && match.id in payload.loaderData;
|
|
@@ -2407,7 +2420,7 @@ function getManifestUrl(paths) {
|
|
|
2407
2420
|
""
|
|
2408
2421
|
);
|
|
2409
2422
|
let url = new URL(`${basename}/.manifest`, window.location.origin);
|
|
2410
|
-
|
|
2423
|
+
url.searchParams.set("paths", paths.sort().join(","));
|
|
2411
2424
|
return url;
|
|
2412
2425
|
}
|
|
2413
2426
|
async function fetchAndApplyManifestPatches(paths, createFromReadableStream, fetchImplementation, signal) {
|
|
@@ -2601,8 +2614,28 @@ async function routeRSCServerRequest({
|
|
|
2601
2614
|
}
|
|
2602
2615
|
});
|
|
2603
2616
|
};
|
|
2604
|
-
|
|
2605
|
-
|
|
2617
|
+
let deepestRenderedBoundaryId = null;
|
|
2618
|
+
const getPayload = () => {
|
|
2619
|
+
const payloadPromise = Promise.resolve(
|
|
2620
|
+
createFromReadableStream(createStream())
|
|
2621
|
+
);
|
|
2622
|
+
return Object.defineProperties(payloadPromise, {
|
|
2623
|
+
_deepestRenderedBoundaryId: {
|
|
2624
|
+
get() {
|
|
2625
|
+
return deepestRenderedBoundaryId;
|
|
2626
|
+
},
|
|
2627
|
+
set(boundaryId) {
|
|
2628
|
+
deepestRenderedBoundaryId = boundaryId;
|
|
2629
|
+
}
|
|
2630
|
+
},
|
|
2631
|
+
formState: {
|
|
2632
|
+
get() {
|
|
2633
|
+
return payloadPromise.then(
|
|
2634
|
+
(payload) => payload.type === "render" ? payload.formState : void 0
|
|
2635
|
+
);
|
|
2636
|
+
}
|
|
2637
|
+
}
|
|
2638
|
+
});
|
|
2606
2639
|
};
|
|
2607
2640
|
try {
|
|
2608
2641
|
if (!detectRedirectResponse.body) {
|
|
@@ -2626,7 +2659,7 @@ async function routeRSCServerRequest({
|
|
|
2626
2659
|
}
|
|
2627
2660
|
const html = await renderHTML(getPayload);
|
|
2628
2661
|
const headers = new Headers(serverResponse.headers);
|
|
2629
|
-
headers.set("Content-Type", "text/html");
|
|
2662
|
+
headers.set("Content-Type", "text/html; charset=utf-8");
|
|
2630
2663
|
if (!hydrate) {
|
|
2631
2664
|
return new Response(html, {
|
|
2632
2665
|
status: serverResponse.status,
|
|
@@ -2645,11 +2678,62 @@ async function routeRSCServerRequest({
|
|
|
2645
2678
|
if (reason instanceof Response) {
|
|
2646
2679
|
return reason;
|
|
2647
2680
|
}
|
|
2681
|
+
try {
|
|
2682
|
+
const status = isRouteErrorResponse(reason) ? reason.status : 500;
|
|
2683
|
+
const html = await renderHTML(() => {
|
|
2684
|
+
const decoded = Promise.resolve(
|
|
2685
|
+
createFromReadableStream(createStream())
|
|
2686
|
+
);
|
|
2687
|
+
const payloadPromise = decoded.then(
|
|
2688
|
+
(payload) => Object.assign(payload, {
|
|
2689
|
+
status,
|
|
2690
|
+
errors: deepestRenderedBoundaryId ? {
|
|
2691
|
+
[deepestRenderedBoundaryId]: reason
|
|
2692
|
+
} : {}
|
|
2693
|
+
})
|
|
2694
|
+
);
|
|
2695
|
+
return Object.defineProperties(payloadPromise, {
|
|
2696
|
+
_deepestRenderedBoundaryId: {
|
|
2697
|
+
get() {
|
|
2698
|
+
return deepestRenderedBoundaryId;
|
|
2699
|
+
},
|
|
2700
|
+
set(boundaryId) {
|
|
2701
|
+
deepestRenderedBoundaryId = boundaryId;
|
|
2702
|
+
}
|
|
2703
|
+
},
|
|
2704
|
+
formState: {
|
|
2705
|
+
get() {
|
|
2706
|
+
return payloadPromise.then(
|
|
2707
|
+
(payload) => payload.type === "render" ? payload.formState : void 0
|
|
2708
|
+
);
|
|
2709
|
+
}
|
|
2710
|
+
}
|
|
2711
|
+
});
|
|
2712
|
+
});
|
|
2713
|
+
const headers = new Headers(serverResponse.headers);
|
|
2714
|
+
headers.set("Content-Type", "text/html");
|
|
2715
|
+
if (!hydrate) {
|
|
2716
|
+
return new Response(html, {
|
|
2717
|
+
status,
|
|
2718
|
+
headers
|
|
2719
|
+
});
|
|
2720
|
+
}
|
|
2721
|
+
if (!serverResponseB?.body) {
|
|
2722
|
+
throw new Error("Failed to clone server response");
|
|
2723
|
+
}
|
|
2724
|
+
const body2 = html.pipeThrough(injectRSCPayload(serverResponseB.body));
|
|
2725
|
+
return new Response(body2, {
|
|
2726
|
+
status,
|
|
2727
|
+
headers
|
|
2728
|
+
});
|
|
2729
|
+
} catch {
|
|
2730
|
+
}
|
|
2648
2731
|
throw reason;
|
|
2649
2732
|
}
|
|
2650
2733
|
}
|
|
2651
2734
|
function RSCStaticRouter({ getPayload }) {
|
|
2652
|
-
const
|
|
2735
|
+
const decoded = getPayload();
|
|
2736
|
+
const payload = useSafe(decoded);
|
|
2653
2737
|
if (payload.type === "redirect") {
|
|
2654
2738
|
throw new Response(null, {
|
|
2655
2739
|
status: payload.status,
|
|
@@ -2671,6 +2755,12 @@ function RSCStaticRouter({ getPayload }) {
|
|
|
2671
2755
|
}
|
|
2672
2756
|
}
|
|
2673
2757
|
const context = {
|
|
2758
|
+
get _deepestRenderedBoundaryId() {
|
|
2759
|
+
return decoded._deepestRenderedBoundaryId ?? null;
|
|
2760
|
+
},
|
|
2761
|
+
set _deepestRenderedBoundaryId(boundaryId) {
|
|
2762
|
+
decoded._deepestRenderedBoundaryId = boundaryId;
|
|
2763
|
+
},
|
|
2674
2764
|
actionData: payload.actionData,
|
|
2675
2765
|
actionHeaders: {},
|
|
2676
2766
|
basename: payload.basename,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v7.9.1
|
|
2
|
+
* react-router v7.9.2-pre.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -1054,7 +1054,7 @@ function createRouter(init) {
|
|
|
1054
1054
|
}
|
|
1055
1055
|
} else if (initialMatches.some((m) => m.route.lazy)) {
|
|
1056
1056
|
initialized = false;
|
|
1057
|
-
} else if (!initialMatches.some((m) => m.route
|
|
1057
|
+
} else if (!initialMatches.some((m) => routeHasLoaderOrMiddleware(m.route))) {
|
|
1058
1058
|
initialized = true;
|
|
1059
1059
|
} else {
|
|
1060
1060
|
let loaderData = init.hydrationData ? init.hydrationData.loaderData : null;
|
|
@@ -1756,7 +1756,9 @@ function createRouter(init) {
|
|
|
1756
1756
|
pendingActionResult
|
|
1757
1757
|
);
|
|
1758
1758
|
pendingNavigationLoadId = ++incrementingLoadId;
|
|
1759
|
-
if (!init.dataStrategy && !dsMatches.some((m) => m.shouldLoad) && !dsMatches.some(
|
|
1759
|
+
if (!init.dataStrategy && !dsMatches.some((m) => m.shouldLoad) && !dsMatches.some(
|
|
1760
|
+
(m) => m.route.middleware && m.route.middleware.length > 0
|
|
1761
|
+
) && revalidatingFetchers.length === 0) {
|
|
1760
1762
|
let updatedFetchers2 = markFetchRedirectsDone();
|
|
1761
1763
|
completeNavigation(
|
|
1762
1764
|
location,
|
|
@@ -2437,6 +2439,10 @@ function createRouter(init) {
|
|
|
2437
2439
|
}
|
|
2438
2440
|
return state.fetchers.get(key) || IDLE_FETCHER;
|
|
2439
2441
|
}
|
|
2442
|
+
function resetFetcher(key, opts) {
|
|
2443
|
+
abortFetcher(key, opts?.reason);
|
|
2444
|
+
updateFetcherState(key, getDoneFetcher(null));
|
|
2445
|
+
}
|
|
2440
2446
|
function deleteFetcher(key) {
|
|
2441
2447
|
let fetcher = state.fetchers.get(key);
|
|
2442
2448
|
if (fetchControllers.has(key) && !(fetcher && fetcher.state === "loading" && fetchReloadIds.has(key))) {
|
|
@@ -2459,10 +2465,10 @@ function createRouter(init) {
|
|
|
2459
2465
|
}
|
|
2460
2466
|
updateState({ fetchers: new Map(state.fetchers) });
|
|
2461
2467
|
}
|
|
2462
|
-
function abortFetcher(key) {
|
|
2468
|
+
function abortFetcher(key, reason) {
|
|
2463
2469
|
let controller = fetchControllers.get(key);
|
|
2464
2470
|
if (controller) {
|
|
2465
|
-
controller.abort();
|
|
2471
|
+
controller.abort(reason);
|
|
2466
2472
|
fetchControllers.delete(key);
|
|
2467
2473
|
}
|
|
2468
2474
|
}
|
|
@@ -2726,6 +2732,7 @@ function createRouter(init) {
|
|
|
2726
2732
|
createHref: (to) => init.history.createHref(to),
|
|
2727
2733
|
encodeLocation: (to) => init.history.encodeLocation(to),
|
|
2728
2734
|
getFetcher,
|
|
2735
|
+
resetFetcher,
|
|
2729
2736
|
deleteFetcher: queueFetcherForDeletion,
|
|
2730
2737
|
dispose,
|
|
2731
2738
|
getBlocker,
|
|
@@ -3541,7 +3548,7 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest,
|
|
|
3541
3548
|
forceShouldLoad = false;
|
|
3542
3549
|
} else if (route.lazy) {
|
|
3543
3550
|
forceShouldLoad = true;
|
|
3544
|
-
} else if (route
|
|
3551
|
+
} else if (!routeHasLoaderOrMiddleware(route)) {
|
|
3545
3552
|
forceShouldLoad = false;
|
|
3546
3553
|
} else if (initialHydration) {
|
|
3547
3554
|
forceShouldLoad = shouldLoadRouteOnHydration(
|
|
@@ -3673,11 +3680,14 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest,
|
|
|
3673
3680
|
});
|
|
3674
3681
|
return { dsMatches, revalidatingFetchers };
|
|
3675
3682
|
}
|
|
3683
|
+
function routeHasLoaderOrMiddleware(route) {
|
|
3684
|
+
return route.loader != null || route.middleware != null && route.middleware.length > 0;
|
|
3685
|
+
}
|
|
3676
3686
|
function shouldLoadRouteOnHydration(route, loaderData, errors) {
|
|
3677
3687
|
if (route.lazy) {
|
|
3678
3688
|
return true;
|
|
3679
3689
|
}
|
|
3680
|
-
if (!route
|
|
3690
|
+
if (!routeHasLoaderOrMiddleware(route)) {
|
|
3681
3691
|
return false;
|
|
3682
3692
|
}
|
|
3683
3693
|
let hasData = loaderData != null && route.id in loaderData;
|
|
@@ -4006,9 +4016,15 @@ function runClientMiddlewarePipeline(args, handler) {
|
|
|
4006
4016
|
let { matches } = args;
|
|
4007
4017
|
let maxBoundaryIdx = Math.min(
|
|
4008
4018
|
// Throwing route
|
|
4009
|
-
|
|
4019
|
+
Math.max(
|
|
4020
|
+
matches.findIndex((m) => m.route.id === routeId),
|
|
4021
|
+
0
|
|
4022
|
+
),
|
|
4010
4023
|
// or the shallowest route that needs to load data
|
|
4011
|
-
|
|
4024
|
+
Math.max(
|
|
4025
|
+
matches.findIndex((m) => m.unstable_shouldCallHandler()),
|
|
4026
|
+
0
|
|
4027
|
+
)
|
|
4012
4028
|
);
|
|
4013
4029
|
let boundaryRouteId = findNearestBoundary(
|
|
4014
4030
|
matches,
|
|
@@ -5056,10 +5072,10 @@ function useOutletContext() {
|
|
|
5056
5072
|
}
|
|
5057
5073
|
function useOutlet(context) {
|
|
5058
5074
|
let outlet = React2.useContext(RouteContext).outlet;
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
|
|
5075
|
+
return React2.useMemo(
|
|
5076
|
+
() => outlet && /* @__PURE__ */ React2.createElement(OutletContext.Provider, { value: context }, outlet),
|
|
5077
|
+
[outlet, context]
|
|
5078
|
+
);
|
|
5063
5079
|
}
|
|
5064
5080
|
function useParams() {
|
|
5065
5081
|
let { matches } = React2.useContext(RouteContext);
|
|
@@ -5143,13 +5159,23 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
|
|
|
5143
5159
|
params: Object.assign({}, parentParams, match.params),
|
|
5144
5160
|
pathname: joinPaths([
|
|
5145
5161
|
parentPathnameBase,
|
|
5146
|
-
// Re-encode pathnames that were decoded inside matchRoutes
|
|
5147
|
-
|
|
5162
|
+
// Re-encode pathnames that were decoded inside matchRoutes.
|
|
5163
|
+
// Pre-encode `?` and `#` ahead of `encodeLocation` because it uses
|
|
5164
|
+
// `new URL()` internally and we need to prevent it from treating
|
|
5165
|
+
// them as separators
|
|
5166
|
+
navigator.encodeLocation ? navigator.encodeLocation(
|
|
5167
|
+
match.pathname.replace(/\?/g, "%3F").replace(/#/g, "%23")
|
|
5168
|
+
).pathname : match.pathname
|
|
5148
5169
|
]),
|
|
5149
5170
|
pathnameBase: match.pathnameBase === "/" ? parentPathnameBase : joinPaths([
|
|
5150
5171
|
parentPathnameBase,
|
|
5151
5172
|
// Re-encode pathnames that were decoded inside matchRoutes
|
|
5152
|
-
|
|
5173
|
+
// Pre-encode `?` and `#` ahead of `encodeLocation` because it uses
|
|
5174
|
+
// `new URL()` internally and we need to prevent it from treating
|
|
5175
|
+
// them as separators
|
|
5176
|
+
navigator.encodeLocation ? navigator.encodeLocation(
|
|
5177
|
+
match.pathnameBase.replace(/\?/g, "%3F").replace(/#/g, "%23")
|
|
5178
|
+
).pathname : match.pathnameBase
|
|
5153
5179
|
])
|
|
5154
5180
|
})
|
|
5155
5181
|
),
|
|
@@ -5627,6 +5653,119 @@ var Deferred = class {
|
|
|
5627
5653
|
});
|
|
5628
5654
|
}
|
|
5629
5655
|
};
|
|
5656
|
+
function shallowDiff(a, b) {
|
|
5657
|
+
if (a === b) {
|
|
5658
|
+
return false;
|
|
5659
|
+
}
|
|
5660
|
+
let aKeys = Object.keys(a);
|
|
5661
|
+
let bKeys = Object.keys(b);
|
|
5662
|
+
if (aKeys.length !== bKeys.length) {
|
|
5663
|
+
return true;
|
|
5664
|
+
}
|
|
5665
|
+
for (let key of aKeys) {
|
|
5666
|
+
if (a[key] !== b[key]) {
|
|
5667
|
+
return true;
|
|
5668
|
+
}
|
|
5669
|
+
}
|
|
5670
|
+
return false;
|
|
5671
|
+
}
|
|
5672
|
+
function UNSTABLE_TransitionEnabledRouterProvider({
|
|
5673
|
+
router,
|
|
5674
|
+
flushSync: reactDomFlushSyncImpl,
|
|
5675
|
+
unstable_onError
|
|
5676
|
+
}) {
|
|
5677
|
+
let fetcherData = React3.useRef(/* @__PURE__ */ new Map());
|
|
5678
|
+
let [revalidating, startRevalidation] = React3.useTransition();
|
|
5679
|
+
let [state, setState] = React3.useState(router.state);
|
|
5680
|
+
router.__setPendingRerender = (promise) => startRevalidation(
|
|
5681
|
+
// @ts-expect-error - need react 19 types for this to be async
|
|
5682
|
+
async () => {
|
|
5683
|
+
const rerender = await promise;
|
|
5684
|
+
startRevalidation(() => {
|
|
5685
|
+
rerender();
|
|
5686
|
+
});
|
|
5687
|
+
}
|
|
5688
|
+
);
|
|
5689
|
+
let navigator = React3.useMemo(() => {
|
|
5690
|
+
return {
|
|
5691
|
+
createHref: router.createHref,
|
|
5692
|
+
encodeLocation: router.encodeLocation,
|
|
5693
|
+
go: (n) => router.navigate(n),
|
|
5694
|
+
push: (to, state2, opts) => router.navigate(to, {
|
|
5695
|
+
state: state2,
|
|
5696
|
+
preventScrollReset: opts?.preventScrollReset
|
|
5697
|
+
}),
|
|
5698
|
+
replace: (to, state2, opts) => router.navigate(to, {
|
|
5699
|
+
replace: true,
|
|
5700
|
+
state: state2,
|
|
5701
|
+
preventScrollReset: opts?.preventScrollReset
|
|
5702
|
+
})
|
|
5703
|
+
};
|
|
5704
|
+
}, [router]);
|
|
5705
|
+
let basename = router.basename || "/";
|
|
5706
|
+
let dataRouterContext = React3.useMemo(
|
|
5707
|
+
() => ({
|
|
5708
|
+
router,
|
|
5709
|
+
navigator,
|
|
5710
|
+
static: false,
|
|
5711
|
+
basename,
|
|
5712
|
+
unstable_onError
|
|
5713
|
+
}),
|
|
5714
|
+
[router, navigator, basename, unstable_onError]
|
|
5715
|
+
);
|
|
5716
|
+
React3.useLayoutEffect(() => {
|
|
5717
|
+
return router.subscribe(
|
|
5718
|
+
(newState, { deletedFetchers, flushSync, viewTransitionOpts }) => {
|
|
5719
|
+
newState.fetchers.forEach((fetcher, key) => {
|
|
5720
|
+
if (fetcher.data !== void 0) {
|
|
5721
|
+
fetcherData.current.set(key, fetcher.data);
|
|
5722
|
+
}
|
|
5723
|
+
});
|
|
5724
|
+
deletedFetchers.forEach((key) => fetcherData.current.delete(key));
|
|
5725
|
+
const diff = shallowDiff(state, newState);
|
|
5726
|
+
if (!diff) return;
|
|
5727
|
+
if (flushSync) {
|
|
5728
|
+
if (reactDomFlushSyncImpl) {
|
|
5729
|
+
reactDomFlushSyncImpl(() => setState(newState));
|
|
5730
|
+
} else {
|
|
5731
|
+
setState(newState);
|
|
5732
|
+
}
|
|
5733
|
+
} else {
|
|
5734
|
+
React3.startTransition(() => {
|
|
5735
|
+
setState(newState);
|
|
5736
|
+
});
|
|
5737
|
+
}
|
|
5738
|
+
}
|
|
5739
|
+
);
|
|
5740
|
+
}, [router, reactDomFlushSyncImpl, state]);
|
|
5741
|
+
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(DataRouterContext.Provider, { value: dataRouterContext }, /* @__PURE__ */ React3.createElement(
|
|
5742
|
+
DataRouterStateContext.Provider,
|
|
5743
|
+
{
|
|
5744
|
+
value: {
|
|
5745
|
+
...state,
|
|
5746
|
+
revalidation: revalidating ? "loading" : state.revalidation
|
|
5747
|
+
}
|
|
5748
|
+
},
|
|
5749
|
+
/* @__PURE__ */ React3.createElement(FetchersContext.Provider, { value: fetcherData.current }, /* @__PURE__ */ React3.createElement(
|
|
5750
|
+
Router,
|
|
5751
|
+
{
|
|
5752
|
+
basename,
|
|
5753
|
+
location: state.location,
|
|
5754
|
+
navigationType: state.historyAction,
|
|
5755
|
+
navigator
|
|
5756
|
+
},
|
|
5757
|
+
/* @__PURE__ */ React3.createElement(
|
|
5758
|
+
MemoizedDataRoutes,
|
|
5759
|
+
{
|
|
5760
|
+
routes: router.routes,
|
|
5761
|
+
future: router.future,
|
|
5762
|
+
state,
|
|
5763
|
+
unstable_onError
|
|
5764
|
+
}
|
|
5765
|
+
)
|
|
5766
|
+
))
|
|
5767
|
+
)), null);
|
|
5768
|
+
}
|
|
5630
5769
|
function RouterProvider({
|
|
5631
5770
|
router,
|
|
5632
5771
|
flushSync: reactDomFlushSyncImpl,
|
|
@@ -6083,6 +6222,7 @@ function createRoutesFromChildren(children, parentPath = []) {
|
|
|
6083
6222
|
Component: element.props.Component,
|
|
6084
6223
|
index: element.props.index,
|
|
6085
6224
|
path: element.props.path,
|
|
6225
|
+
middleware: element.props.middleware,
|
|
6086
6226
|
loader: element.props.loader,
|
|
6087
6227
|
action: element.props.action,
|
|
6088
6228
|
hydrateFallbackElement: element.props.hydrateFallbackElement,
|
|
@@ -8262,7 +8402,7 @@ function getManifestPath(_manifestPath, basename) {
|
|
|
8262
8402
|
var MANIFEST_VERSION_STORAGE_KEY = "react-router-manifest-version";
|
|
8263
8403
|
async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, routeModules, ssr, isSpaMode, basename, manifestPath, patchRoutes, signal) {
|
|
8264
8404
|
const searchParams = new URLSearchParams();
|
|
8265
|
-
paths.sort().
|
|
8405
|
+
searchParams.set("paths", paths.sort().join(","));
|
|
8266
8406
|
searchParams.set("version", manifest.version);
|
|
8267
8407
|
let url = new URL(
|
|
8268
8408
|
getManifestPath(manifestPath, basename),
|
|
@@ -8285,13 +8425,16 @@ async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, ro
|
|
|
8285
8425
|
);
|
|
8286
8426
|
return;
|
|
8287
8427
|
}
|
|
8288
|
-
|
|
8289
|
-
|
|
8290
|
-
|
|
8291
|
-
|
|
8292
|
-
|
|
8428
|
+
try {
|
|
8429
|
+
if (sessionStorage.getItem(MANIFEST_VERSION_STORAGE_KEY) === manifest.version) {
|
|
8430
|
+
console.error(
|
|
8431
|
+
"Unable to discover routes due to manifest version mismatch."
|
|
8432
|
+
);
|
|
8433
|
+
return;
|
|
8434
|
+
}
|
|
8435
|
+
sessionStorage.setItem(MANIFEST_VERSION_STORAGE_KEY, manifest.version);
|
|
8436
|
+
} catch {
|
|
8293
8437
|
}
|
|
8294
|
-
sessionStorage.setItem(MANIFEST_VERSION_STORAGE_KEY, manifest.version);
|
|
8295
8438
|
window.location.href = errorReloadPath;
|
|
8296
8439
|
console.warn("Detected manifest version mismatch, reloading...");
|
|
8297
8440
|
await new Promise(() => {
|
|
@@ -8299,7 +8442,10 @@ async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, ro
|
|
|
8299
8442
|
} else if (res.status >= 400) {
|
|
8300
8443
|
throw new Error(await res.text());
|
|
8301
8444
|
}
|
|
8302
|
-
|
|
8445
|
+
try {
|
|
8446
|
+
sessionStorage.removeItem(MANIFEST_VERSION_STORAGE_KEY);
|
|
8447
|
+
} catch {
|
|
8448
|
+
}
|
|
8303
8449
|
serverPatches = await res.json();
|
|
8304
8450
|
} catch (e) {
|
|
8305
8451
|
if (signal?.aborted) return;
|
|
@@ -8964,7 +9110,7 @@ var isBrowser = typeof window !== "undefined" && typeof window.document !== "und
|
|
|
8964
9110
|
try {
|
|
8965
9111
|
if (isBrowser) {
|
|
8966
9112
|
window.__reactRouterVersion = // @ts-expect-error
|
|
8967
|
-
"7.9.1";
|
|
9113
|
+
"7.9.2-pre.1";
|
|
8968
9114
|
}
|
|
8969
9115
|
} catch (e) {
|
|
8970
9116
|
}
|
|
@@ -9578,6 +9724,7 @@ function useFetcher({
|
|
|
9578
9724
|
},
|
|
9579
9725
|
[fetcherKey, submitImpl]
|
|
9580
9726
|
);
|
|
9727
|
+
let unstable_reset = React10.useCallback((opts) => router.resetFetcher(fetcherKey, opts), [router, fetcherKey]);
|
|
9581
9728
|
let FetcherForm = React10.useMemo(() => {
|
|
9582
9729
|
let FetcherForm2 = React10.forwardRef(
|
|
9583
9730
|
(props, ref) => {
|
|
@@ -9594,10 +9741,11 @@ function useFetcher({
|
|
|
9594
9741
|
Form: FetcherForm,
|
|
9595
9742
|
submit,
|
|
9596
9743
|
load,
|
|
9744
|
+
unstable_reset,
|
|
9597
9745
|
...fetcher,
|
|
9598
9746
|
data: data2
|
|
9599
9747
|
}),
|
|
9600
|
-
[FetcherForm, submit, load, fetcher, data2]
|
|
9748
|
+
[FetcherForm, submit, load, unstable_reset, fetcher, data2]
|
|
9601
9749
|
);
|
|
9602
9750
|
return fetcherWithComponents;
|
|
9603
9751
|
}
|
|
@@ -10008,6 +10156,9 @@ function createStaticRouter(routes, context, opts = {}) {
|
|
|
10008
10156
|
deleteFetcher() {
|
|
10009
10157
|
throw msg("deleteFetcher");
|
|
10010
10158
|
},
|
|
10159
|
+
resetFetcher() {
|
|
10160
|
+
throw msg("resetFetcher");
|
|
10161
|
+
},
|
|
10011
10162
|
dispose() {
|
|
10012
10163
|
throw msg("dispose");
|
|
10013
10164
|
},
|
|
@@ -10121,6 +10272,7 @@ export {
|
|
|
10121
10272
|
mapRouteProperties,
|
|
10122
10273
|
hydrationRouteProperties,
|
|
10123
10274
|
createMemoryRouter,
|
|
10275
|
+
UNSTABLE_TransitionEnabledRouterProvider,
|
|
10124
10276
|
RouterProvider,
|
|
10125
10277
|
MemoryRouter,
|
|
10126
10278
|
Navigate,
|