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-I4PRIPRX.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,
|