react-router 0.0.0-experimental-28357fd2a → 0.0.0-experimental-3d7dcee
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 +51 -48
- package/dist/development/{chunk-5CCVAEBF.js → chunk-LSB26UC6.js} +210 -169
- package/dist/development/{chunk-QT7WPDUY.mjs → chunk-QMIAKNRH.mjs} +147 -33
- package/dist/development/{chunk-EU7MB5YT.js → chunk-S2WJDCRE.js} +77 -53
- package/dist/development/{chunk-Z4HFX7Q2.mjs → chunk-WJ2QP6HN.mjs} +102 -37
- package/dist/{production/context-DohQKLID.d.mts → development/context-DnZM5brG.d.mts} +843 -6
- package/dist/development/dom-export.d.mts +20 -2
- package/dist/development/dom-export.d.ts +20 -1
- package/dist/development/dom-export.js +10 -4
- package/dist/development/dom-export.mjs +10 -4
- package/dist/development/{index-react-server-client-DXb0OgpJ.d.mts → index-react-server-client-9rHNv-U3.d.mts} +2 -3
- package/dist/{production/index-react-server-client-CMphySRb.d.ts → development/index-react-server-client-zr5eNeut.d.ts} +6 -816
- package/dist/development/index-react-server-client.d.mts +3 -4
- 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.js +21 -7
- package/dist/development/index-react-server.mjs +21 -7
- package/dist/development/index.d.mts +7 -9
- package/dist/development/index.d.ts +5 -5
- package/dist/development/index.js +242 -128
- 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-CpB5xtMm.d.mts → route-data-C24VEkoE.d.mts} +1 -1
- package/dist/development/{routeModules-qBivMBjd.d.ts → routeModules-FY5IBiA_.d.ts} +843 -6
- package/dist/production/{chunk-EQ3NKH5J.mjs → chunk-2BFZ6QQU.mjs} +102 -37
- package/dist/production/{chunk-2DWPJCWX.js → chunk-7CWVKQLP.js} +77 -53
- package/dist/production/{chunk-DOZCQHLU.js → chunk-NIW37A6Q.js} +210 -169
- package/dist/production/{chunk-GPXYCHV5.mjs → chunk-OFC37UQM.mjs} +147 -33
- package/dist/{development/context-DohQKLID.d.mts → production/context-DnZM5brG.d.mts} +843 -6
- package/dist/production/dom-export.d.mts +20 -2
- package/dist/production/dom-export.d.ts +20 -1
- package/dist/production/dom-export.js +10 -4
- package/dist/production/dom-export.mjs +10 -4
- package/dist/production/{index-react-server-client-DXb0OgpJ.d.mts → index-react-server-client-9rHNv-U3.d.mts} +2 -3
- package/dist/{development/index-react-server-client-CMphySRb.d.ts → production/index-react-server-client-zr5eNeut.d.ts} +6 -816
- package/dist/production/index-react-server-client.d.mts +3 -4
- 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.js +21 -7
- package/dist/production/index-react-server.mjs +21 -7
- package/dist/production/index.d.mts +7 -9
- package/dist/production/index.d.ts +5 -5
- package/dist/production/index.js +242 -128
- 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-CpB5xtMm.d.mts → route-data-C24VEkoE.d.mts} +1 -1
- package/dist/production/{routeModules-qBivMBjd.d.ts → routeModules-FY5IBiA_.d.ts} +843 -6
- package/package.json +1 -1
- package/dist/development/components-CuPfnyiZ.d.mts +0 -814
- package/dist/production/components-CuPfnyiZ.d.mts +0 -814
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v0.0.0-experimental-
|
|
2
|
+
* react-router v0.0.0-experimental-3d7dcee
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -46,6 +46,7 @@ import {
|
|
|
46
46
|
redirect,
|
|
47
47
|
redirectDocument,
|
|
48
48
|
replace,
|
|
49
|
+
setIsHydrated,
|
|
49
50
|
shouldHydrateRouteLoader,
|
|
50
51
|
singleFetchUrl,
|
|
51
52
|
stripBasename,
|
|
@@ -57,7 +58,7 @@ import {
|
|
|
57
58
|
withComponentProps,
|
|
58
59
|
withErrorBoundaryProps,
|
|
59
60
|
withHydrateFallbackProps
|
|
60
|
-
} from "./chunk-
|
|
61
|
+
} from "./chunk-WJ2QP6HN.mjs";
|
|
61
62
|
|
|
62
63
|
// lib/dom/ssr/server.tsx
|
|
63
64
|
import * as React from "react";
|
|
@@ -1122,6 +1123,28 @@ var createRequestHandler = (build, mode) => {
|
|
|
1122
1123
|
let isSpaMode = getBuildTimeHeader(request, "X-React-Router-SPA-Mode") === "yes";
|
|
1123
1124
|
if (!_build.ssr) {
|
|
1124
1125
|
let decodedPath = decodeURI(normalizedPath);
|
|
1126
|
+
if (normalizedBasename !== "/") {
|
|
1127
|
+
let strippedPath = stripBasename(decodedPath, normalizedBasename);
|
|
1128
|
+
if (strippedPath == null) {
|
|
1129
|
+
errorHandler(
|
|
1130
|
+
new ErrorResponseImpl(
|
|
1131
|
+
404,
|
|
1132
|
+
"Not Found",
|
|
1133
|
+
`Refusing to prerender the \`${decodedPath}\` path because it does not start with the basename \`${normalizedBasename}\``
|
|
1134
|
+
),
|
|
1135
|
+
{
|
|
1136
|
+
context: loadContext,
|
|
1137
|
+
params,
|
|
1138
|
+
request
|
|
1139
|
+
}
|
|
1140
|
+
);
|
|
1141
|
+
return new Response("Not Found", {
|
|
1142
|
+
status: 404,
|
|
1143
|
+
statusText: "Not Found"
|
|
1144
|
+
});
|
|
1145
|
+
}
|
|
1146
|
+
decodedPath = strippedPath;
|
|
1147
|
+
}
|
|
1125
1148
|
if (_build.prerender.length === 0) {
|
|
1126
1149
|
isSpaMode = true;
|
|
1127
1150
|
} else if (!_build.prerender.includes(decodedPath) && !_build.prerender.includes(decodedPath + "/")) {
|
|
@@ -1834,6 +1857,26 @@ function RSCDefaultRootErrorBoundary({
|
|
|
1834
1857
|
);
|
|
1835
1858
|
}
|
|
1836
1859
|
|
|
1860
|
+
// lib/rsc/route-modules.ts
|
|
1861
|
+
function createRSCRouteModules(payload) {
|
|
1862
|
+
const routeModules = {};
|
|
1863
|
+
for (const match of payload.matches) {
|
|
1864
|
+
populateRSCRouteModules(routeModules, match);
|
|
1865
|
+
}
|
|
1866
|
+
return routeModules;
|
|
1867
|
+
}
|
|
1868
|
+
function populateRSCRouteModules(routeModules, matches) {
|
|
1869
|
+
matches = Array.isArray(matches) ? matches : [matches];
|
|
1870
|
+
for (const match of matches) {
|
|
1871
|
+
routeModules[match.id] = {
|
|
1872
|
+
links: match.links,
|
|
1873
|
+
meta: match.meta,
|
|
1874
|
+
default: noopComponent
|
|
1875
|
+
};
|
|
1876
|
+
}
|
|
1877
|
+
}
|
|
1878
|
+
var noopComponent = () => null;
|
|
1879
|
+
|
|
1837
1880
|
// lib/rsc/browser.tsx
|
|
1838
1881
|
function createCallServer({
|
|
1839
1882
|
createFromReadableStream,
|
|
@@ -1867,7 +1910,7 @@ function createCallServer({
|
|
|
1867
1910
|
window.location.href = payload.location;
|
|
1868
1911
|
return;
|
|
1869
1912
|
}
|
|
1870
|
-
globalVar.
|
|
1913
|
+
globalVar.__reactRouterDataRouter.navigate(payload.location, {
|
|
1871
1914
|
replace: payload.replace
|
|
1872
1915
|
});
|
|
1873
1916
|
return payload.actionResult;
|
|
@@ -1888,34 +1931,38 @@ function createCallServer({
|
|
|
1888
1931
|
window.location.href = rerender.location;
|
|
1889
1932
|
return;
|
|
1890
1933
|
}
|
|
1891
|
-
globalVar.
|
|
1934
|
+
globalVar.__reactRouterDataRouter.navigate(rerender.location, {
|
|
1892
1935
|
replace: rerender.replace
|
|
1893
1936
|
});
|
|
1894
1937
|
return;
|
|
1895
1938
|
}
|
|
1896
1939
|
let lastMatch;
|
|
1897
1940
|
for (const match of rerender.matches) {
|
|
1898
|
-
globalVar.
|
|
1941
|
+
globalVar.__reactRouterDataRouter.patchRoutes(
|
|
1899
1942
|
lastMatch?.id ?? null,
|
|
1900
1943
|
[createRouteFromServerManifest(match)],
|
|
1901
1944
|
true
|
|
1902
1945
|
);
|
|
1903
1946
|
lastMatch = match;
|
|
1904
1947
|
}
|
|
1905
|
-
window.
|
|
1948
|
+
window.__reactRouterDataRouter._internalSetStateDoNotUseOrYouWillBreakYourApp(
|
|
1949
|
+
{}
|
|
1950
|
+
);
|
|
1906
1951
|
React4.startTransition(() => {
|
|
1907
|
-
window.
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1952
|
+
window.__reactRouterDataRouter._internalSetStateDoNotUseOrYouWillBreakYourApp(
|
|
1953
|
+
{
|
|
1954
|
+
loaderData: Object.assign(
|
|
1955
|
+
{},
|
|
1956
|
+
globalVar.__reactRouterDataRouter.state.loaderData,
|
|
1957
|
+
rerender.loaderData
|
|
1958
|
+
),
|
|
1959
|
+
errors: rerender.errors ? Object.assign(
|
|
1960
|
+
{},
|
|
1961
|
+
globalVar.__reactRouterDataRouter.state.errors,
|
|
1962
|
+
rerender.errors
|
|
1963
|
+
) : null
|
|
1964
|
+
}
|
|
1965
|
+
);
|
|
1919
1966
|
});
|
|
1920
1967
|
}
|
|
1921
1968
|
}
|
|
@@ -1931,8 +1978,14 @@ function createRouterFromPayload({
|
|
|
1931
1978
|
payload
|
|
1932
1979
|
}) {
|
|
1933
1980
|
const globalVar = window;
|
|
1934
|
-
if (globalVar.
|
|
1981
|
+
if (globalVar.__reactRouterDataRouter && globalVar.__reactRouterRouteModules)
|
|
1982
|
+
return {
|
|
1983
|
+
router: globalVar.__reactRouterDataRouter,
|
|
1984
|
+
routeModules: globalVar.__reactRouterRouteModules
|
|
1985
|
+
};
|
|
1935
1986
|
if (payload.type !== "render") throw new Error("Invalid payload type");
|
|
1987
|
+
globalVar.__reactRouterRouteModules = globalVar.__reactRouterRouteModules ?? {};
|
|
1988
|
+
populateRSCRouteModules(globalVar.__reactRouterRouteModules, payload.matches);
|
|
1936
1989
|
let patches = /* @__PURE__ */ new Map();
|
|
1937
1990
|
payload.patches?.forEach((patch) => {
|
|
1938
1991
|
invariant(patch.parentId, "Invalid patch parentId");
|
|
@@ -1957,7 +2010,7 @@ function createRouterFromPayload({
|
|
|
1957
2010
|
}
|
|
1958
2011
|
return [route];
|
|
1959
2012
|
}, []);
|
|
1960
|
-
globalVar.
|
|
2013
|
+
globalVar.__reactRouterDataRouter = createRouter({
|
|
1961
2014
|
routes,
|
|
1962
2015
|
unstable_getContext,
|
|
1963
2016
|
basename: payload.basename,
|
|
@@ -1995,26 +2048,79 @@ function createRouterFromPayload({
|
|
|
1995
2048
|
},
|
|
1996
2049
|
// FIXME: Pass `build.ssr` into this function
|
|
1997
2050
|
dataStrategy: getRSCSingleFetchDataStrategy(
|
|
1998
|
-
() => globalVar.
|
|
2051
|
+
() => globalVar.__reactRouterDataRouter,
|
|
1999
2052
|
true,
|
|
2000
2053
|
payload.basename,
|
|
2001
2054
|
createFromReadableStream,
|
|
2002
2055
|
fetchImplementation
|
|
2003
2056
|
)
|
|
2004
2057
|
});
|
|
2005
|
-
if (globalVar.
|
|
2058
|
+
if (globalVar.__reactRouterDataRouter.state.initialized) {
|
|
2006
2059
|
globalVar.__routerInitialized = true;
|
|
2007
|
-
globalVar.
|
|
2060
|
+
globalVar.__reactRouterDataRouter.initialize();
|
|
2008
2061
|
} else {
|
|
2009
2062
|
globalVar.__routerInitialized = false;
|
|
2010
2063
|
}
|
|
2011
2064
|
let lastLoaderData = void 0;
|
|
2012
|
-
globalVar.
|
|
2065
|
+
globalVar.__reactRouterDataRouter.subscribe(({ loaderData, actionData }) => {
|
|
2013
2066
|
if (lastLoaderData !== loaderData) {
|
|
2014
2067
|
globalVar.__routerActionID = (globalVar.__routerActionID ?? (globalVar.__routerActionID = 0)) + 1;
|
|
2015
2068
|
}
|
|
2016
2069
|
});
|
|
2017
|
-
|
|
2070
|
+
globalVar.__reactRouterDataRouter._updateRoutesForHMR = (routeUpdateByRouteId) => {
|
|
2071
|
+
const oldRoutes = window.__reactRouterDataRouter.routes;
|
|
2072
|
+
const newRoutes = [];
|
|
2073
|
+
function walkRoutes(routes2, parentId) {
|
|
2074
|
+
return routes2.map((route) => {
|
|
2075
|
+
const routeUpdate = routeUpdateByRouteId.get(route.id);
|
|
2076
|
+
if (routeUpdate) {
|
|
2077
|
+
const {
|
|
2078
|
+
routeModule,
|
|
2079
|
+
hasAction,
|
|
2080
|
+
hasComponent,
|
|
2081
|
+
hasErrorBoundary,
|
|
2082
|
+
hasLoader
|
|
2083
|
+
} = routeUpdate;
|
|
2084
|
+
const newRoute = createRouteFromServerManifest({
|
|
2085
|
+
clientAction: routeModule.clientAction,
|
|
2086
|
+
clientLoader: routeModule.clientLoader,
|
|
2087
|
+
element: route.element,
|
|
2088
|
+
errorElement: route.errorElement,
|
|
2089
|
+
handle: route.handle,
|
|
2090
|
+
hasAction,
|
|
2091
|
+
hasComponent,
|
|
2092
|
+
hasErrorBoundary,
|
|
2093
|
+
hasLoader,
|
|
2094
|
+
hydrateFallbackElement: route.hydrateFallbackElement,
|
|
2095
|
+
id: route.id,
|
|
2096
|
+
index: route.index,
|
|
2097
|
+
links: routeModule.links,
|
|
2098
|
+
meta: routeModule.meta,
|
|
2099
|
+
parentId,
|
|
2100
|
+
path: route.path,
|
|
2101
|
+
shouldRevalidate: routeModule.shouldRevalidate
|
|
2102
|
+
});
|
|
2103
|
+
if (route.children) {
|
|
2104
|
+
newRoute.children = walkRoutes(route.children, route.id);
|
|
2105
|
+
}
|
|
2106
|
+
return newRoute;
|
|
2107
|
+
}
|
|
2108
|
+
const updatedRoute = { ...route };
|
|
2109
|
+
if (route.children) {
|
|
2110
|
+
updatedRoute.children = walkRoutes(route.children, route.id);
|
|
2111
|
+
}
|
|
2112
|
+
return updatedRoute;
|
|
2113
|
+
});
|
|
2114
|
+
}
|
|
2115
|
+
newRoutes.push(
|
|
2116
|
+
...walkRoutes(oldRoutes, void 0)
|
|
2117
|
+
);
|
|
2118
|
+
window.__reactRouterDataRouter._internalSetRoutes(newRoutes);
|
|
2119
|
+
};
|
|
2120
|
+
return {
|
|
2121
|
+
router: globalVar.__reactRouterDataRouter,
|
|
2122
|
+
routeModules: globalVar.__reactRouterRouteModules
|
|
2123
|
+
};
|
|
2018
2124
|
}
|
|
2019
2125
|
var renderedRoutesContext = unstable_createContext();
|
|
2020
2126
|
function getRSCSingleFetchDataStrategy(getRouter, ssr, basename, createFromReadableStream, fetchImplementation) {
|
|
@@ -2058,7 +2164,7 @@ function getRSCSingleFetchDataStrategy(getRouter, ssr, basename, createFromReada
|
|
|
2058
2164
|
const renderedRoutes = renderedRoutesById.get(match.route.id);
|
|
2059
2165
|
if (renderedRoutes) {
|
|
2060
2166
|
for (const rendered of renderedRoutes) {
|
|
2061
|
-
window.
|
|
2167
|
+
window.__reactRouterDataRouter.patchRoutes(
|
|
2062
2168
|
rendered.parentId ?? null,
|
|
2063
2169
|
[createRouteFromServerManifest(rendered)],
|
|
2064
2170
|
true
|
|
@@ -2132,7 +2238,7 @@ function RSCHydratedRouter({
|
|
|
2132
2238
|
unstable_getContext
|
|
2133
2239
|
}) {
|
|
2134
2240
|
if (payload.type !== "render") throw new Error("Invalid payload type");
|
|
2135
|
-
let router = React4.useMemo(
|
|
2241
|
+
let { router, routeModules } = React4.useMemo(
|
|
2136
2242
|
() => createRouterFromPayload({
|
|
2137
2243
|
payload,
|
|
2138
2244
|
fetchImplementation,
|
|
@@ -2146,11 +2252,14 @@ function RSCHydratedRouter({
|
|
|
2146
2252
|
unstable_getContext
|
|
2147
2253
|
]
|
|
2148
2254
|
);
|
|
2255
|
+
React4.useEffect(() => {
|
|
2256
|
+
setIsHydrated();
|
|
2257
|
+
}, []);
|
|
2149
2258
|
React4.useLayoutEffect(() => {
|
|
2150
2259
|
const globalVar = window;
|
|
2151
2260
|
if (!globalVar.__routerInitialized) {
|
|
2152
2261
|
globalVar.__routerInitialized = true;
|
|
2153
|
-
globalVar.
|
|
2262
|
+
globalVar.__reactRouterDataRouter.initialize();
|
|
2154
2263
|
}
|
|
2155
2264
|
}, []);
|
|
2156
2265
|
let [location2, setLocation] = React4.useState(router.state.location);
|
|
@@ -2216,7 +2325,7 @@ function RSCHydratedRouter({
|
|
|
2216
2325
|
unstable_middleware: false,
|
|
2217
2326
|
unstable_subResourceIntegrity: false
|
|
2218
2327
|
},
|
|
2219
|
-
isSpaMode:
|
|
2328
|
+
isSpaMode: false,
|
|
2220
2329
|
ssr: true,
|
|
2221
2330
|
criticalCss: "",
|
|
2222
2331
|
manifest: {
|
|
@@ -2229,7 +2338,7 @@ function RSCHydratedRouter({
|
|
|
2229
2338
|
}
|
|
2230
2339
|
},
|
|
2231
2340
|
routeDiscovery: { mode: "lazy", manifestPath: "/__manifest" },
|
|
2232
|
-
routeModules
|
|
2341
|
+
routeModules
|
|
2233
2342
|
};
|
|
2234
2343
|
return /* @__PURE__ */ React4.createElement(RSCRouterContext.Provider, { value: true }, /* @__PURE__ */ React4.createElement(RSCRouterGlobalErrorBoundary, { location: location2 }, /* @__PURE__ */ React4.createElement(FrameworkContext.Provider, { value: frameworkContext }, /* @__PURE__ */ React4.createElement(RouterProvider, { router, flushSync: ReactDOM.flushSync }))));
|
|
2235
2344
|
}
|
|
@@ -2242,6 +2351,8 @@ function createRouteFromServerManifest(match, payload) {
|
|
|
2242
2351
|
// the server loader flow regardless of whether the client loader calls
|
|
2243
2352
|
// `serverLoader` or not, otherwise we'll have nothing to render.
|
|
2244
2353
|
match.hasComponent && !match.element;
|
|
2354
|
+
invariant(window.__reactRouterRouteModules);
|
|
2355
|
+
populateRSCRouteModules(window.__reactRouterRouteModules, match);
|
|
2245
2356
|
let dataRoute = {
|
|
2246
2357
|
id: match.id,
|
|
2247
2358
|
element: match.element,
|
|
@@ -2337,7 +2448,10 @@ function getManifestUrl(paths) {
|
|
|
2337
2448
|
return new URL(`${paths[0]}.manifest`, window.location.origin);
|
|
2338
2449
|
}
|
|
2339
2450
|
const globalVar = window;
|
|
2340
|
-
let basename = (globalVar.
|
|
2451
|
+
let basename = (globalVar.__reactRouterDataRouter.basename ?? "").replace(
|
|
2452
|
+
/^\/|\/$/g,
|
|
2453
|
+
""
|
|
2454
|
+
);
|
|
2341
2455
|
let url = new URL(`${basename}/.manifest`, window.location.origin);
|
|
2342
2456
|
paths.sort().forEach((path) => url.searchParams.append("p", path));
|
|
2343
2457
|
return url;
|
|
@@ -2363,7 +2477,7 @@ async function fetchAndApplyManifestPatches(paths, createFromReadableStream, fet
|
|
|
2363
2477
|
}
|
|
2364
2478
|
paths.forEach((p) => addToFifoQueue(p, discoveredPaths));
|
|
2365
2479
|
payload.patches.forEach((p) => {
|
|
2366
|
-
window.
|
|
2480
|
+
window.__reactRouterDataRouter.patchRoutes(
|
|
2367
2481
|
p.parentId ?? null,
|
|
2368
2482
|
[createRouteFromServerManifest(p)]
|
|
2369
2483
|
);
|
|
@@ -2640,7 +2754,7 @@ function RSCStaticRouter({ getPayload }) {
|
|
|
2640
2754
|
}
|
|
2641
2755
|
},
|
|
2642
2756
|
routeDiscovery: { mode: "lazy", manifestPath: "/__manifest" },
|
|
2643
|
-
routeModules:
|
|
2757
|
+
routeModules: createRSCRouteModules(payload)
|
|
2644
2758
|
};
|
|
2645
2759
|
return /* @__PURE__ */ React5.createElement(RSCRouterContext.Provider, { value: true }, /* @__PURE__ */ React5.createElement(RSCRouterGlobalErrorBoundary, { location: payload.location }, /* @__PURE__ */ React5.createElement(FrameworkContext.Provider, { value: frameworkContext }, /* @__PURE__ */ React5.createElement(
|
|
2646
2760
|
StaticRouterProvider,
|