react-router 8.4.0 → 8.5.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 +94 -1
- package/dist/development/dom-export.d.ts +2 -1
- package/dist/development/dom-export.js +1 -1
- package/dist/development/index-react-server-client.js +2 -2
- package/dist/development/index-react-server.d.ts +237 -165
- package/dist/development/index-react-server.js +69 -33
- package/dist/development/index.d.ts +9 -8
- package/dist/development/index.js +5 -4
- package/dist/development/lib/actions.js +1 -1
- package/dist/development/lib/await.js +58 -0
- package/dist/development/lib/components.d.ts +41 -5
- package/dist/development/lib/components.js +82 -5
- package/dist/development/lib/context.d.ts +8 -3
- package/dist/development/lib/context.js +1 -1
- package/dist/development/lib/dom/dom.d.ts +3 -0
- package/dist/development/lib/dom/dom.js +1 -1
- package/dist/development/lib/dom/lib.d.ts +34 -9
- package/dist/development/lib/dom/lib.js +17 -6
- package/dist/development/lib/dom/server.js +2 -2
- package/dist/development/lib/dom/ssr/components.js +12 -9
- package/dist/development/lib/dom/ssr/data.js +1 -1
- package/dist/development/lib/dom/ssr/entry.d.ts +9 -2
- package/dist/development/lib/dom/ssr/errorBoundaries.js +1 -1
- package/dist/development/lib/dom/ssr/fallback.js +1 -1
- package/dist/development/lib/dom/ssr/fog-of-war.d.ts +3 -2
- package/dist/development/lib/dom/ssr/fog-of-war.js +25 -13
- package/dist/development/lib/dom/ssr/hydration.js +1 -1
- package/dist/development/lib/dom/ssr/invariant.js +1 -1
- package/dist/development/lib/dom/ssr/links.js +1 -1
- package/dist/development/lib/dom/ssr/markup.js +1 -1
- package/dist/development/lib/dom/ssr/route-discovery.d.ts +120 -0
- package/dist/development/lib/dom/ssr/route-discovery.js +415 -0
- package/dist/development/lib/dom/ssr/routeModules.js +1 -1
- package/dist/development/lib/dom/ssr/routes-test-stub.js +2 -2
- package/dist/development/lib/dom/ssr/routes.d.ts +2 -2
- package/dist/development/lib/dom/ssr/routes.js +8 -8
- package/dist/development/lib/dom/ssr/server.js +3 -1
- package/dist/development/lib/dom/ssr/single-fetch.d.ts +28 -2
- package/dist/development/lib/dom/ssr/single-fetch.js +73 -55
- package/dist/development/lib/dom-export/dom-router-provider.js +1 -1
- package/dist/development/lib/dom-export/hydrated-router.d.ts +28 -0
- package/dist/development/lib/dom-export/hydrated-router.js +32 -12
- package/dist/development/lib/errors.js +1 -1
- package/dist/development/lib/hooks.d.ts +3 -6
- package/dist/development/lib/hooks.js +8 -9
- package/dist/development/lib/href.js +1 -1
- package/dist/development/lib/router/history.js +1 -1
- package/dist/development/lib/router/instrumentation.js +1 -1
- package/dist/development/lib/router/matcher-route-pattern.js +1 -1
- package/dist/development/lib/router/matcher-route-pattern.preload.js +1 -1
- package/dist/development/lib/router/matcher.js +6 -1
- package/dist/development/lib/router/navigation.js +1 -1
- package/dist/development/lib/router/router.d.ts +8 -0
- package/dist/development/lib/router/router.js +213 -91
- package/dist/development/lib/router/url.js +1 -1
- package/dist/development/lib/router/utils.d.ts +31 -4
- package/dist/development/lib/router/utils.js +4 -3
- package/dist/development/lib/rsc/browser.js +4 -4
- package/dist/development/lib/rsc/errorBoundaries.js +1 -1
- package/dist/development/lib/rsc/html-stream/browser.js +1 -1
- package/dist/development/lib/rsc/html-stream/server.js +24 -12
- package/dist/development/lib/rsc/route-modules.js +1 -1
- package/dist/development/lib/rsc/server.rsc.d.ts +3 -2
- package/dist/development/lib/rsc/server.ssr.js +1 -1
- package/dist/development/lib/server-runtime/build.d.ts +14 -0
- package/dist/development/lib/server-runtime/cookies.js +1 -1
- package/dist/development/lib/server-runtime/crypto.js +1 -1
- package/dist/development/lib/server-runtime/data.js +1 -1
- package/dist/development/lib/server-runtime/dev.js +1 -1
- package/dist/development/lib/server-runtime/entry.js +1 -1
- package/dist/development/lib/server-runtime/errors.js +1 -1
- package/dist/development/lib/server-runtime/headers.js +1 -1
- package/dist/development/lib/server-runtime/invariant.js +1 -1
- package/dist/development/lib/server-runtime/mode.js +1 -1
- package/dist/development/lib/server-runtime/routeMatching.js +1 -1
- package/dist/development/lib/server-runtime/routes.d.ts +1 -1
- package/dist/development/lib/server-runtime/routes.js +1 -1
- package/dist/development/lib/server-runtime/server.js +24 -8
- package/dist/development/lib/server-runtime/serverHandoff.d.ts +17 -0
- package/dist/development/lib/server-runtime/serverHandoff.js +1 -1
- package/dist/development/lib/server-runtime/sessions/cookieStorage.js +1 -1
- package/dist/development/lib/server-runtime/sessions/memoryStorage.js +1 -1
- package/dist/development/lib/server-runtime/sessions.js +2 -2
- package/dist/development/lib/server-runtime/single-fetch.js +1 -1
- package/dist/development/lib/server-runtime/urls.js +1 -1
- package/dist/development/lib/server-runtime/warnings.js +1 -1
- package/dist/development/lib/types/internal.js +1 -1
- package/dist/development/lib/types/route-data.d.ts +2 -2
- package/dist/development/lib/types/route-module-annotations.d.ts +1 -1
- package/dist/development/route-pattern.js +1 -1
- package/dist/development/vendor/turbo-stream-v2/flatten.js +1 -1
- package/dist/development/vendor/turbo-stream-v2/turbo-stream.js +1 -1
- package/dist/development/vendor/turbo-stream-v2/unflatten.js +23 -3
- package/dist/development/vendor/turbo-stream-v2/utils.js +1 -1
- package/dist/production/dom-export.d.ts +2 -1
- package/dist/production/dom-export.js +1 -1
- package/dist/production/index-react-server-client.js +2 -2
- package/dist/production/index-react-server.d.ts +237 -165
- package/dist/production/index-react-server.js +69 -33
- package/dist/production/index.d.ts +9 -8
- package/dist/production/index.js +5 -4
- package/dist/production/lib/actions.js +1 -1
- package/dist/production/lib/await.js +58 -0
- package/dist/production/lib/components.d.ts +41 -5
- package/dist/production/lib/components.js +82 -5
- package/dist/production/lib/context.d.ts +8 -3
- package/dist/production/lib/context.js +1 -1
- package/dist/production/lib/dom/dom.d.ts +3 -0
- package/dist/production/lib/dom/dom.js +1 -1
- package/dist/production/lib/dom/lib.d.ts +34 -9
- package/dist/production/lib/dom/lib.js +17 -6
- package/dist/production/lib/dom/server.js +2 -2
- package/dist/production/lib/dom/ssr/components.js +12 -9
- package/dist/production/lib/dom/ssr/data.js +1 -1
- package/dist/production/lib/dom/ssr/entry.d.ts +9 -2
- package/dist/production/lib/dom/ssr/errorBoundaries.js +1 -1
- package/dist/production/lib/dom/ssr/fallback.js +1 -1
- package/dist/production/lib/dom/ssr/fog-of-war.d.ts +3 -2
- package/dist/production/lib/dom/ssr/fog-of-war.js +25 -13
- package/dist/production/lib/dom/ssr/hydration.js +1 -1
- package/dist/production/lib/dom/ssr/invariant.js +1 -1
- package/dist/production/lib/dom/ssr/links.js +1 -1
- package/dist/production/lib/dom/ssr/markup.js +1 -1
- package/dist/production/lib/dom/ssr/route-discovery.d.ts +120 -0
- package/dist/production/lib/dom/ssr/route-discovery.js +415 -0
- package/dist/production/lib/dom/ssr/routeModules.js +1 -1
- package/dist/production/lib/dom/ssr/routes-test-stub.js +2 -2
- package/dist/production/lib/dom/ssr/routes.d.ts +2 -2
- package/dist/production/lib/dom/ssr/routes.js +8 -8
- package/dist/production/lib/dom/ssr/server.js +3 -1
- package/dist/production/lib/dom/ssr/single-fetch.d.ts +28 -2
- package/dist/production/lib/dom/ssr/single-fetch.js +73 -55
- package/dist/production/lib/dom-export/dom-router-provider.js +1 -1
- package/dist/production/lib/dom-export/hydrated-router.d.ts +28 -0
- package/dist/production/lib/dom-export/hydrated-router.js +32 -12
- package/dist/production/lib/errors.js +1 -1
- package/dist/production/lib/hooks.d.ts +3 -6
- package/dist/production/lib/hooks.js +7 -8
- package/dist/production/lib/href.js +1 -1
- package/dist/production/lib/router/history.js +1 -1
- package/dist/production/lib/router/instrumentation.js +1 -1
- package/dist/production/lib/router/matcher-route-pattern.js +1 -1
- package/dist/production/lib/router/matcher-route-pattern.preload.js +1 -1
- package/dist/production/lib/router/matcher.js +6 -1
- package/dist/production/lib/router/navigation.js +1 -1
- package/dist/production/lib/router/router.d.ts +8 -0
- package/dist/production/lib/router/router.js +213 -91
- package/dist/production/lib/router/url.js +1 -1
- package/dist/production/lib/router/utils.d.ts +31 -4
- package/dist/production/lib/router/utils.js +4 -3
- package/dist/production/lib/rsc/browser.js +4 -4
- package/dist/production/lib/rsc/errorBoundaries.js +1 -1
- package/dist/production/lib/rsc/html-stream/browser.js +1 -1
- package/dist/production/lib/rsc/html-stream/server.js +24 -12
- package/dist/production/lib/rsc/route-modules.js +1 -1
- package/dist/production/lib/rsc/server.rsc.d.ts +3 -2
- package/dist/production/lib/rsc/server.ssr.js +1 -1
- package/dist/production/lib/server-runtime/build.d.ts +14 -0
- package/dist/production/lib/server-runtime/cookies.js +1 -1
- package/dist/production/lib/server-runtime/crypto.js +1 -1
- package/dist/production/lib/server-runtime/data.js +1 -1
- package/dist/production/lib/server-runtime/dev.js +1 -1
- package/dist/production/lib/server-runtime/entry.js +1 -1
- package/dist/production/lib/server-runtime/errors.js +1 -1
- package/dist/production/lib/server-runtime/headers.js +1 -1
- package/dist/production/lib/server-runtime/invariant.js +1 -1
- package/dist/production/lib/server-runtime/mode.js +1 -1
- package/dist/production/lib/server-runtime/routeMatching.js +1 -1
- package/dist/production/lib/server-runtime/routes.d.ts +1 -1
- package/dist/production/lib/server-runtime/routes.js +1 -1
- package/dist/production/lib/server-runtime/server.js +24 -8
- package/dist/production/lib/server-runtime/serverHandoff.d.ts +17 -0
- package/dist/production/lib/server-runtime/serverHandoff.js +1 -1
- package/dist/production/lib/server-runtime/sessions/cookieStorage.js +1 -1
- package/dist/production/lib/server-runtime/sessions/memoryStorage.js +1 -1
- package/dist/production/lib/server-runtime/sessions.js +2 -2
- package/dist/production/lib/server-runtime/single-fetch.js +1 -1
- package/dist/production/lib/server-runtime/urls.js +1 -1
- package/dist/production/lib/server-runtime/warnings.js +1 -1
- package/dist/production/lib/types/internal.js +1 -1
- package/dist/production/lib/types/route-data.d.ts +2 -2
- package/dist/production/lib/types/route-module-annotations.d.ts +1 -1
- package/dist/production/route-pattern.js +1 -1
- package/dist/production/vendor/turbo-stream-v2/flatten.js +1 -1
- package/dist/production/vendor/turbo-stream-v2/turbo-stream.js +1 -1
- package/dist/production/vendor/turbo-stream-v2/unflatten.js +23 -3
- package/dist/production/vendor/turbo-stream-v2/utils.js +1 -1
- package/docs/explanation/backend-for-frontend.md +0 -3
- package/docs/explanation/code-splitting.md +0 -3
- package/docs/explanation/concurrency.md +0 -3
- package/docs/explanation/hot-module-replacement.md +0 -3
- package/docs/explanation/lazy-route-discovery.md +4 -3
- package/docs/explanation/progressive-enhancement.md +0 -3
- package/docs/explanation/race-conditions.md +0 -3
- package/docs/explanation/react-transitions.md +0 -3
- package/docs/explanation/sessions-and-cookies.md +109 -5
- package/docs/explanation/state-management.md +0 -3
- package/docs/explanation/styling.md +0 -3
- package/docs/explanation/type-safety.md +0 -3
- package/docs/how-to/accessibility.md +0 -6
- package/docs/how-to/client-data.md +0 -3
- package/docs/how-to/custom-fetch.md +218 -0
- package/docs/how-to/data-strategy.md +23 -4
- package/docs/how-to/error-boundary.md +0 -3
- package/docs/how-to/error-reporting.md +0 -3
- package/docs/how-to/fetchers.md +0 -3
- package/docs/how-to/file-route-conventions.md +0 -3
- package/docs/how-to/file-uploads.md +0 -3
- package/docs/how-to/form-validation.md +0 -3
- package/docs/how-to/headers.md +0 -3
- package/docs/how-to/instrumentation.md +0 -3
- package/docs/how-to/middleware.md +7 -3
- package/docs/how-to/navigation-blocking.md +0 -3
- package/docs/how-to/optimize-revalidation.md +2 -5
- package/docs/how-to/pre-rendering.md +23 -4
- package/docs/how-to/presets.md +0 -3
- package/docs/how-to/react-server-components.md +0 -3
- package/docs/how-to/resource-routes.md +0 -3
- package/docs/how-to/route-discovery.md +147 -0
- package/docs/how-to/route-module-type-safety.md +0 -3
- package/docs/how-to/security.md +0 -3
- package/docs/how-to/server-bundles.md +0 -3
- package/docs/how-to/spa.md +2 -3
- package/docs/how-to/status.md +0 -3
- package/docs/how-to/suspense.md +22 -6
- package/docs/how-to/using-handle.md +0 -3
- package/docs/how-to/view-transitions.md +79 -15
- package/docs/start/framework/data-loading.md +9 -0
- package/docs/start/framework/navigating.md +5 -9
- package/docs/start/framework/rendering.md +37 -0
- package/docs/upgrading/future.md +0 -12
- package/docs/upgrading/v7.md +3 -33
- package/package.json +9 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.
|
|
2
|
+
* react-router v8.5.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -540,7 +540,7 @@ function compilePath(path, caseSensitive = false, end = true) {
|
|
|
540
540
|
return "(?:/([^\\/]*))?";
|
|
541
541
|
}
|
|
542
542
|
return "/([^\\/]+)";
|
|
543
|
-
}).replace(/\/([\
|
|
543
|
+
}).replace(/\/((?:[^/?()[\]*^\\]|\\.)+)\?(?=\/|$|\()/g, "(?:/$1)?");
|
|
544
544
|
if (path.endsWith("*")) {
|
|
545
545
|
params.push({ paramName: "*" });
|
|
546
546
|
regexpSource += path === "*" || path === "/*" ? "(.*)$" : "(?:\\/(.+)|\\/*)$";
|
|
@@ -1038,12 +1038,17 @@ var V6RegExMatcher = class {
|
|
|
1038
1038
|
#routes = [];
|
|
1039
1039
|
#branches = [];
|
|
1040
1040
|
#basename;
|
|
1041
|
+
#matchCost = 0;
|
|
1041
1042
|
constructor(basename) {
|
|
1042
1043
|
this.#basename = basename;
|
|
1043
1044
|
}
|
|
1044
1045
|
update(routes) {
|
|
1045
1046
|
this.#routes = routes;
|
|
1046
1047
|
this.#branches = flattenAndRankRoutes(routes);
|
|
1048
|
+
this.#matchCost = this.#branches.reduce((total, branch) => total + branch.routesMeta.length, 0);
|
|
1049
|
+
}
|
|
1050
|
+
get matchCost() {
|
|
1051
|
+
return this.#matchCost;
|
|
1047
1052
|
}
|
|
1048
1053
|
match(locationArg, allowPartial = false) {
|
|
1049
1054
|
return matchRoutesImpl(this.#routes, locationArg, this.#basename, allowPartial, this.#branches);
|
|
@@ -1450,7 +1455,7 @@ function createStaticHandler(routes, opts) {
|
|
|
1450
1455
|
};
|
|
1451
1456
|
}
|
|
1452
1457
|
async function callDataStrategy(request, location, matches, isRouteRequest, requestContext, dataStrategy) {
|
|
1453
|
-
let results = await callDataStrategyImpl(dataStrategy || defaultDataStrategy, request, location, matches, null, requestContext, true);
|
|
1458
|
+
let results = await callDataStrategyImpl(dataStrategy || defaultDataStrategy, request, location, matches, null, "static", requestContext, true);
|
|
1454
1459
|
let dataResults = {};
|
|
1455
1460
|
await Promise.all(matches.map(async (match) => {
|
|
1456
1461
|
if (!(match.route.id in results)) return;
|
|
@@ -1469,6 +1474,9 @@ function createStaticHandler(routes, opts) {
|
|
|
1469
1474
|
}
|
|
1470
1475
|
return {
|
|
1471
1476
|
dataRoutes,
|
|
1477
|
+
get _matchCost() {
|
|
1478
|
+
return dataRouteMatcher instanceof V6RegExMatcher ? dataRouteMatcher.matchCost : void 0;
|
|
1479
|
+
},
|
|
1472
1480
|
match,
|
|
1473
1481
|
query,
|
|
1474
1482
|
queryRoute
|
|
@@ -1580,6 +1588,9 @@ const loadLazyRouteProperty = ({ key, route, manifest, mapRouteProperties }) =>
|
|
|
1580
1588
|
}
|
|
1581
1589
|
})();
|
|
1582
1590
|
cache[key] = propertyPromise;
|
|
1591
|
+
propertyPromise.catch(() => {
|
|
1592
|
+
if (cache[key] === propertyPromise) delete cache[key];
|
|
1593
|
+
});
|
|
1583
1594
|
return propertyPromise;
|
|
1584
1595
|
};
|
|
1585
1596
|
const lazyRouteFunctionCache = /* @__PURE__ */ new WeakMap();
|
|
@@ -1621,7 +1632,9 @@ function loadLazyRoute(route, type, manifest, mapRouteProperties, lazyRoutePrope
|
|
|
1621
1632
|
});
|
|
1622
1633
|
})();
|
|
1623
1634
|
lazyRouteFunctionCache.set(routeToUpdate, lazyRoutePromise);
|
|
1624
|
-
lazyRoutePromise.catch(() => {
|
|
1635
|
+
lazyRoutePromise.catch(() => {
|
|
1636
|
+
if (lazyRouteFunctionCache.get(routeToUpdate) === lazyRoutePromise) lazyRouteFunctionCache.delete(routeToUpdate);
|
|
1637
|
+
});
|
|
1625
1638
|
return {
|
|
1626
1639
|
lazyRoutePromise,
|
|
1627
1640
|
lazyHandlerPromise: lazyRoutePromise
|
|
@@ -1813,7 +1826,7 @@ function getTargetedDataStrategyMatches(mapRouteProperties, manifest, request, p
|
|
|
1813
1826
|
return getDataStrategyMatch(mapRouteProperties, manifest, request, path, getRoutePattern(matches), match, lazyRoutePropertiesToSkip, scopedContext, true, shouldRevalidateArgs);
|
|
1814
1827
|
});
|
|
1815
1828
|
}
|
|
1816
|
-
async function callDataStrategyImpl(dataStrategyImpl, request, path, matches, fetcherKey, scopedContext, isStaticHandler) {
|
|
1829
|
+
async function callDataStrategyImpl(dataStrategyImpl, request, path, matches, fetcherKey, initiator, scopedContext, isStaticHandler, navigationType = null) {
|
|
1817
1830
|
if (matches.some((m) => m._lazyPromises?.middleware)) await Promise.all(matches.map((m) => m._lazyPromises?.middleware));
|
|
1818
1831
|
let dataStrategyArgs = {
|
|
1819
1832
|
request,
|
|
@@ -1821,7 +1834,9 @@ async function callDataStrategyImpl(dataStrategyImpl, request, path, matches, fe
|
|
|
1821
1834
|
pattern: getRoutePattern(matches),
|
|
1822
1835
|
params: matches[0].params,
|
|
1823
1836
|
context: scopedContext,
|
|
1824
|
-
matches
|
|
1837
|
+
matches,
|
|
1838
|
+
unstable_initiator: initiator,
|
|
1839
|
+
unstable_navigationType: initiator === "navigation" ? navigationType : null
|
|
1825
1840
|
};
|
|
1826
1841
|
let runClientMiddleware = isStaticHandler ? () => {
|
|
1827
1842
|
throw new Error("You cannot call `runClientMiddleware()` from a static handler `dataStrategy`. Middleware is run outside of `dataStrategy` during SSR in order to bubble up the Response. You can enable middleware via the `respond` API in `query`/`queryRoute`");
|
|
@@ -1907,10 +1922,13 @@ async function callLoaderOrAction({ request, path, pattern, match, lazyHandlerPr
|
|
|
1907
1922
|
pathname,
|
|
1908
1923
|
routeId: match.route.id
|
|
1909
1924
|
});
|
|
1910
|
-
} else
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1925
|
+
} else {
|
|
1926
|
+
await lazyRoutePromise;
|
|
1927
|
+
return {
|
|
1928
|
+
type: "data",
|
|
1929
|
+
result: void 0
|
|
1930
|
+
};
|
|
1931
|
+
}
|
|
1914
1932
|
}
|
|
1915
1933
|
else if (!handler) {
|
|
1916
1934
|
let url = new URL(request.url);
|
|
@@ -2240,6 +2258,12 @@ function getPathsWithAncestors(paths) {
|
|
|
2240
2258
|
});
|
|
2241
2259
|
return Array.from(result);
|
|
2242
2260
|
}
|
|
2261
|
+
const MANIFEST_MATCH_COST_LIMIT = 5e4;
|
|
2262
|
+
const MANIFEST_MATCH_COST_SEGMENT_THRESHOLD = 10;
|
|
2263
|
+
function shouldUseInitialRouteDiscovery(pathname, matchCost = 0) {
|
|
2264
|
+
let segmentCount = pathname.split("/").length - 1;
|
|
2265
|
+
return Math.max(segmentCount - 1, 0) * pathname.length + 1 > 7680 || segmentCount > MANIFEST_MATCH_COST_SEGMENT_THRESHOLD && segmentCount * matchCost > MANIFEST_MATCH_COST_LIMIT;
|
|
2266
|
+
}
|
|
2243
2267
|
//#endregion
|
|
2244
2268
|
//#region lib/actions.ts
|
|
2245
2269
|
function throwIfPotentialCSRFAttack(request, allowedActionOrigins) {
|
|
@@ -2335,12 +2359,15 @@ const replace = (...args) => {
|
|
|
2335
2359
|
const cachedResolvePromise = React.cache(async (resolve) => {
|
|
2336
2360
|
return Promise.allSettled([resolve]).then((r) => r[0]);
|
|
2337
2361
|
});
|
|
2338
|
-
const Await = (async (
|
|
2339
|
-
|
|
2362
|
+
const Await = (async (props) => {
|
|
2363
|
+
invariant$1("resolve" in props !== "unstable_promise" in props, "<Await> requires exactly one of `resolve` or `unstable_promise`");
|
|
2364
|
+
let { children, errorElement } = props;
|
|
2365
|
+
let usePromise = "unstable_promise" in props;
|
|
2366
|
+
let resolved = await cachedResolvePromise(usePromise ? props.unstable_promise : props.resolve);
|
|
2340
2367
|
if (resolved.status === "rejected" && !errorElement) throw resolved.reason;
|
|
2341
2368
|
if (resolved.status === "rejected") return React.createElement(UNSAFE_AwaitContextProvider, {
|
|
2342
2369
|
children: React.createElement(React.Fragment, null, errorElement),
|
|
2343
|
-
value: {
|
|
2370
|
+
value: usePromise ? resolved : {
|
|
2344
2371
|
_tracked: true,
|
|
2345
2372
|
_error: resolved.reason
|
|
2346
2373
|
}
|
|
@@ -2348,7 +2375,7 @@ const Await = (async ({ children, resolve, errorElement }) => {
|
|
|
2348
2375
|
const toRender = typeof children === "function" ? children(resolved.value) : children;
|
|
2349
2376
|
return React.createElement(UNSAFE_AwaitContextProvider, {
|
|
2350
2377
|
children: toRender,
|
|
2351
|
-
value: {
|
|
2378
|
+
value: usePromise ? resolved : {
|
|
2352
2379
|
_tracked: true,
|
|
2353
2380
|
_data: resolved.value
|
|
2354
2381
|
}
|
|
@@ -2435,7 +2462,12 @@ const Await = (async ({ children, resolve, errorElement }) => {
|
|
|
2435
2462
|
* that contains the [RSC](https://react.dev/reference/rsc/server-components)
|
|
2436
2463
|
* data for hydration.
|
|
2437
2464
|
*/
|
|
2438
|
-
async function matchRSCServerRequest({ allowedActionOrigins, createTemporaryReferenceSet, basename, decodeReply, requestContext, routeDiscovery, loadServerAction, decodeAction, decodeFormState, clientVersion, onError, request, routes, generateResponse }) {
|
|
2465
|
+
async function matchRSCServerRequest({ allowedActionOrigins, createTemporaryReferenceSet, basename, decodeReply, requestContext, routeDiscovery, loadServerAction, decodeAction, decodeFormState, clientVersion, onError, request, routes, generateResponse: encodeResponse }) {
|
|
2466
|
+
let generateResponse = (match, options) => {
|
|
2467
|
+
let response = encodeResponse(match, options);
|
|
2468
|
+
response.headers.set("Content-Type", "text/x-component");
|
|
2469
|
+
return response;
|
|
2470
|
+
};
|
|
2439
2471
|
let url = new URL(request.url);
|
|
2440
2472
|
basename = basename || "/";
|
|
2441
2473
|
let normalizedPath = url.pathname;
|
|
@@ -2582,18 +2614,18 @@ async function processServerAction(request, basename, decodeReply, loadServerAct
|
|
|
2582
2614
|
}
|
|
2583
2615
|
async function generateResourceResponse(request, staticHandler, routeId, requestContext, onError) {
|
|
2584
2616
|
try {
|
|
2585
|
-
return await staticHandler.queryRoute(request, {
|
|
2617
|
+
return tagResourceResponse(await staticHandler.queryRoute(request, {
|
|
2586
2618
|
routeId,
|
|
2587
2619
|
requestContext,
|
|
2588
2620
|
async generateMiddlewareResponse(queryRoute) {
|
|
2589
2621
|
try {
|
|
2590
|
-
return
|
|
2622
|
+
return tagResourceResponse(await queryRoute(request));
|
|
2591
2623
|
} catch (error) {
|
|
2592
2624
|
return generateErrorResponse(error);
|
|
2593
2625
|
}
|
|
2594
2626
|
},
|
|
2595
2627
|
normalizePath: (r) => getNormalizedPath(r)
|
|
2596
|
-
});
|
|
2628
|
+
}));
|
|
2597
2629
|
} catch (error) {
|
|
2598
2630
|
return generateErrorResponse(error);
|
|
2599
2631
|
}
|
|
@@ -2611,18 +2643,18 @@ async function generateResourceResponse(request, staticHandler, routeId, request
|
|
|
2611
2643
|
onError?.(error);
|
|
2612
2644
|
response = new Response("Internal Server Error", { status: 500 });
|
|
2613
2645
|
}
|
|
2614
|
-
return
|
|
2615
|
-
}
|
|
2616
|
-
function generateResourceResponse(response) {
|
|
2617
|
-
const headers = new Headers(response.headers);
|
|
2618
|
-
headers.set("React-Router-Resource", "true");
|
|
2619
|
-
return new Response(response.body, {
|
|
2620
|
-
status: response.status,
|
|
2621
|
-
statusText: response.statusText,
|
|
2622
|
-
headers
|
|
2623
|
-
});
|
|
2646
|
+
return tagResourceResponse(response);
|
|
2624
2647
|
}
|
|
2625
2648
|
}
|
|
2649
|
+
function tagResourceResponse(response) {
|
|
2650
|
+
const headers = new Headers(response.headers);
|
|
2651
|
+
headers.set("React-Router-Resource", "true");
|
|
2652
|
+
return new Response(response.body, {
|
|
2653
|
+
status: response.status,
|
|
2654
|
+
statusText: response.statusText,
|
|
2655
|
+
headers
|
|
2656
|
+
});
|
|
2657
|
+
}
|
|
2626
2658
|
async function generateRenderResponse(request, staticHandler, basename, isDataRequest, decodeReply, requestContext, loadServerAction, decodeAction, decodeFormState, onError, generateResponse, temporaryReferences, allowedActionOrigins, routeDiscovery, clientVersion) {
|
|
2627
2659
|
let statusCode = 200;
|
|
2628
2660
|
let url = new URL(request.url);
|
|
@@ -2660,7 +2692,7 @@ async function generateRenderResponse(request, staticHandler, basename, isDataRe
|
|
|
2660
2692
|
let result = await processServerAction(request, basename, decodeReply, loadServerAction, decodeAction, decodeFormState, onError, temporaryReferences).finally(() => {
|
|
2661
2693
|
ctx.runningAction = false;
|
|
2662
2694
|
});
|
|
2663
|
-
if (isResponse(result)) return generateRedirectResponse(result, actionResult, basename, isDataRequest, generateResponse, temporaryReferences, ctx.redirect?.headers);
|
|
2695
|
+
if (isResponse(result)) return generateRedirectResponse(result, actionResult, basename, isDataRequest, generateResponse, temporaryReferences, result === ctx.redirect ? void 0 : ctx.redirect?.headers);
|
|
2664
2696
|
skipRevalidation = result?.skipRevalidation ?? false;
|
|
2665
2697
|
actionResult = result?.actionResult;
|
|
2666
2698
|
formState = result?.formState;
|
|
@@ -2680,6 +2712,7 @@ async function generateRenderResponse(request, staticHandler, basename, isDataRe
|
|
|
2680
2712
|
}));
|
|
2681
2713
|
if (isRedirectResponse(result)) return generateRedirectResponse(result, actionResult, basename, isDataRequest, generateResponse, temporaryReferences, ctx.redirect?.headers);
|
|
2682
2714
|
invariant(isResponse(result), "Expected a response from query");
|
|
2715
|
+
if (result.headers.get("Content-Type")?.split(";")[0].trim().toLowerCase() !== "text/x-component") return tagResourceResponse(result);
|
|
2683
2716
|
return result;
|
|
2684
2717
|
}
|
|
2685
2718
|
function generateRedirectResponse(response, actionResult, basename, isDataRequest, generateResponse, temporaryReferences, sideEffectRedirectHeaders) {
|
|
@@ -2693,7 +2726,7 @@ function generateRedirectResponse(response, actionResult, basename, isDataReques
|
|
|
2693
2726
|
status: response.status,
|
|
2694
2727
|
actionResult
|
|
2695
2728
|
};
|
|
2696
|
-
let headers = new Headers(sideEffectRedirectHeaders);
|
|
2729
|
+
let headers = new Headers(sideEffectRedirectHeaders === response.headers ? void 0 : sideEffectRedirectHeaders);
|
|
2697
2730
|
for (const [key, value] of response.headers.entries()) headers.append(key, value);
|
|
2698
2731
|
headers.delete("Location");
|
|
2699
2732
|
headers.delete("X-Remix-Reload-Document");
|
|
@@ -2771,11 +2804,14 @@ async function getRenderPayload(baseRenderPayload, staticHandler, basename, rout
|
|
|
2771
2804
|
parentId
|
|
2772
2805
|
});
|
|
2773
2806
|
}));
|
|
2807
|
+
let pathname = staticContext.location.pathname;
|
|
2808
|
+
let useInitialRouteDiscovery = routeDiscovery?.mode === "initial" && !isDataRequest || shouldUseInitialRouteDiscovery(pathname, staticHandler._matchCost);
|
|
2774
2809
|
let patches;
|
|
2775
|
-
if (
|
|
2776
|
-
else patches = getAdditionalRoutePatches(getPathsWithAncestors([
|
|
2810
|
+
if (useInitialRouteDiscovery) patches = getAllRoutePatches(routes, basename).then((patches) => patches.filter((patch) => !staticContext.matches.some((m) => m.route.id === patch.id)));
|
|
2811
|
+
else patches = getAdditionalRoutePatches(getPathsWithAncestors([pathname]).slice(0, -1), staticHandler, staticContext.matches.map((m) => m.route.id));
|
|
2777
2812
|
return {
|
|
2778
2813
|
...baseRenderPayload,
|
|
2814
|
+
routeDiscovery: useInitialRouteDiscovery ? { mode: "initial" } : baseRenderPayload.routeDiscovery,
|
|
2779
2815
|
matches: await matchesPromise,
|
|
2780
2816
|
patches
|
|
2781
2817
|
};
|
|
@@ -3234,7 +3270,7 @@ function createSessionStorage({ cookie: cookieArg, createData, readData, updateD
|
|
|
3234
3270
|
return cookie.serialize(id, options);
|
|
3235
3271
|
},
|
|
3236
3272
|
async destroySession(session, options) {
|
|
3237
|
-
await deleteData(session.id);
|
|
3273
|
+
if (session.id) await deleteData(session.id);
|
|
3238
3274
|
return cookie.serialize("", {
|
|
3239
3275
|
...options,
|
|
3240
3276
|
maxAge: void 0,
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
|
|
2
2
|
import { Action, InitialEntry, Location, Path, To, createBrowserHistory, createHashHistory, createMemoryHistory, createPath, invariant, parsePath } from "./lib/router/history.js";
|
|
3
|
-
import { ActionFunction, ActionFunctionArgs, BaseRouteObject, DataRouteMatch, DataRouteObject, DataStrategyFunction, DataStrategyFunctionArgs, DataStrategyMatch, DataStrategyResult, DataWithResponseInit, ErrorResponse, ErrorResponseImpl, FormEncType, FormMethod, HTMLFormMethod, IndexRouteObject, LazyRouteFunction, LoaderFunction, LoaderFunctionArgs, MiddlewareFunction, NonIndexRouteObject, ParamParseKey, Params, PatchRoutesOnNavigationFunction, PatchRoutesOnNavigationFunctionArgs, PathMatch, PathParam, PathPattern, RedirectFunction, RouteMatch, RouteObject, RouterContext, RouterContextProvider, ShouldRevalidateFunction, ShouldRevalidateFunctionArgs, UIMatch, createContext, data, defaultMapRouteProperties, generatePath, isRouteErrorResponse, matchPath, matchRoutes, redirect, redirectDocument, replace, resolvePath } from "./lib/router/utils.js";
|
|
3
|
+
import { ActionFunction, ActionFunctionArgs, BaseRouteObject, DataRouteMatch, DataRouteObject, DataStrategyFunction, DataStrategyFunctionArgs, DataStrategyInitiator, DataStrategyMatch, DataStrategyResult, DataWithResponseInit, ErrorResponse, ErrorResponseImpl, FormEncType, FormMethod, HTMLFormMethod, IndexRouteObject, LazyRouteFunction, LoaderFunction, LoaderFunctionArgs, MiddlewareFunction, NonIndexRouteObject, ParamParseKey, Params, PatchRoutesOnNavigationFunction, PatchRoutesOnNavigationFunctionArgs, PathMatch, PathParam, PathPattern, RedirectFunction, RouteMatch, RouteObject, RouterContext, RouterContextProvider, ShouldRevalidateFunction, ShouldRevalidateFunctionArgs, UIMatch, createContext, data, defaultMapRouteProperties, generatePath, isRouteErrorResponse, matchPath, matchRoutes, redirect, redirectDocument, replace, resolvePath } from "./lib/router/utils.js";
|
|
4
4
|
import { Blocker, BlockerFunction, Fetcher, GetScrollPositionFunction, GetScrollRestorationKeyFunction, HydrationState, IDLE_BLOCKER, IDLE_FETCHER, IDLE_NAVIGATION, Navigation, NavigationStates, RelativeRoutingType, RevalidationState, Router, RouterFetchOptions, RouterInit, RouterNavigateOptions, RouterState, RouterSubscriber, StaticHandler, StaticHandlerContext, createRouter, createStaticHandler } from "./lib/router/router.js";
|
|
5
|
-
import { HtmlLinkDescriptor, LinkDescriptor, PageLinkDescriptor } from "./lib/router/links.js";
|
|
6
5
|
import { Await, AwaitProps, ClientOnErrorFunction, IndexRouteProps, LayoutRouteProps, MemoryRouter, MemoryRouterOpts, MemoryRouterProps, Navigate, NavigateProps, Outlet, OutletProps, PathRouteProps, Route, RouteProps, Router as Router$1, RouterProps, RouterProvider, RouterProviderProps, Routes, RoutesProps, WithComponentProps, WithErrorBoundaryProps, WithHydrateFallbackProps, createMemoryRouter, createRoutesFromChildren, createRoutesFromElements, hydrationRouteProperties, renderMatches, withComponentProps, withErrorBoundaryProps, withHydrateFallbackProps } from "./lib/components.js";
|
|
7
6
|
import { AwaitContextProvider, DataRouterContext, DataRouterDataContext, DataRouterNavigationContext, DataRouterStateContext, FetchersContext, LocationContext, NavigateOptions, NavigationContext, Navigator, RouteContext, ViewTransitionContext } from "./lib/context.js";
|
|
7
|
+
import { createClientRoutes, createClientRoutesWithHMRRevalidationOptOut, shouldHydrateRouteLoader } from "./lib/dom/ssr/routes.js";
|
|
8
|
+
import { HtmlLinkDescriptor, LinkDescriptor, PageLinkDescriptor } from "./lib/router/links.js";
|
|
9
|
+
import { ClientActionFunction, ClientActionFunctionArgs, ClientLoaderFunction, ClientLoaderFunctionArgs, HeadersArgs, HeadersFunction, LinksFunction, MetaArgs, MetaDescriptor, MetaFunction, RouteModules } from "./lib/dom/ssr/routeModules.js";
|
|
10
|
+
import { SingleFetchRedirectSymbol, decodeViaTurboStream, getTurboStreamSingleFetchDataStrategy } from "./lib/dom/ssr/single-fetch.js";
|
|
11
|
+
import { ServerMode } from "./lib/server-runtime/mode.js";
|
|
12
|
+
import { unstable_SerializesTo } from "./lib/types/serializes-to.js";
|
|
8
13
|
import { Register } from "./lib/types/register.js";
|
|
9
14
|
import { NavigateFunction, unstable_RouterState, unstable_RouterStateActiveVariant, unstable_RouterStatePendingVariant, useActionData, useAsyncError, useAsyncValue, useBlocker, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRoute, useRouteError, useRouteLoaderData, useRouterState, useRoutes } from "./lib/hooks.js";
|
|
10
15
|
import { FetcherSubmitOptions, ParamKeyValuePair, SubmitOptions, SubmitTarget, URLSearchParamsInit, createSearchParams } from "./lib/dom/dom.js";
|
|
@@ -19,7 +24,6 @@ import { createCookieSessionStorage } from "./lib/server-runtime/sessions/cookie
|
|
|
19
24
|
import { createMemorySessionStorage } from "./lib/server-runtime/sessions/memoryStorage.js";
|
|
20
25
|
import { setDevServerHooks } from "./lib/server-runtime/dev.js";
|
|
21
26
|
import { Future } from "./lib/types/future.js";
|
|
22
|
-
import { unstable_SerializesTo } from "./lib/types/serializes-to.js";
|
|
23
27
|
import { href } from "./lib/href.js";
|
|
24
28
|
import { DecodeActionFunction, DecodeFormStateFunction, DecodeReplyFunction, LoadServerActionFunction, RSCManifestPayload, RSCMatch, RSCPayload, RSCRenderPayload, RSCRouteConfig, RSCRouteConfigEntry, RSCRouteManifest, RSCRouteMatch, getRequest, matchRSCServerRequest } from "./lib/rsc/server.rsc.js";
|
|
25
29
|
import { BrowserCreateFromReadableStreamFunction, EncodeReplyFunction, RSCHydratedRouterProps } from "./lib/rsc/browser.js";
|
|
@@ -28,10 +32,7 @@ import { RSCDefaultRootErrorBoundary } from "./lib/rsc/errorBoundaries.js";
|
|
|
28
32
|
import { RemixErrorBoundary } from "./lib/dom/ssr/errorBoundaries.js";
|
|
29
33
|
import { getPatchRoutesOnNavigationFunction, useFogOFWarDiscovery } from "./lib/dom/ssr/fog-of-war.js";
|
|
30
34
|
import { getHydrationData } from "./lib/dom/ssr/hydration.js";
|
|
31
|
-
import {
|
|
32
|
-
import { ServerMode } from "./lib/server-runtime/mode.js";
|
|
33
|
-
import { ClientActionFunction, ClientActionFunctionArgs, ClientLoaderFunction, ClientLoaderFunctionArgs, HeadersArgs, HeadersFunction, LinksFunction, MetaArgs, MetaDescriptor, MetaFunction, RouteModules } from "./lib/dom/ssr/routeModules.js";
|
|
34
|
-
import { createClientRoutes, createClientRoutesWithHMRRevalidationOptOut, shouldHydrateRouteLoader } from "./lib/dom/ssr/routes.js";
|
|
35
|
+
import { DiscoveryResult, ManifestMismatchEvent, RouteDiscoveryOptions, RouteDiscoveryRuntime, getCustomPatchRoutesOnNavigationFunction, useCustomRouteDiscovery, useRouteDiscovery } from "./lib/dom/ssr/route-discovery.js";
|
|
35
36
|
import { AssetsManifest, EntryContext } from "./lib/dom/ssr/entry.js";
|
|
36
37
|
import { HandleDataRequestFunction, HandleDocumentRequestFunction, HandleErrorFunction, ServerBuild, ServerEntryModule } from "./lib/server-runtime/build.js";
|
|
37
38
|
import { CreateRequestHandlerFunction, RequestHandler, createRequestHandler } from "./lib/server-runtime/server.js";
|
|
@@ -41,4 +42,4 @@ import { ClientInstrumentation, InstrumentRequestHandlerFunction, InstrumentRout
|
|
|
41
42
|
declare const unstable_getRequest: typeof getRequest;
|
|
42
43
|
declare const unstable_matchRSCServerRequest: typeof matchRSCServerRequest;
|
|
43
44
|
//#endregion
|
|
44
|
-
export { type ActionFunction, type ActionFunctionArgs, Await, type AwaitProps, type BaseRouteObject, type Blocker, type BlockerFunction, BrowserRouter, type BrowserRouterProps, type ClientActionFunction, type ClientActionFunctionArgs, type ClientInstrumentation, type ClientLoaderFunction, type ClientLoaderFunctionArgs, type ClientOnErrorFunction, type Cookie, type CookieOptions, type CookieParseOptions, type CookieSerializeOptions, type CookieSignatureOptions, type CreateRequestHandlerFunction, type DOMRouterOpts, type DataRouteMatch, type DataRouteObject, type Router as DataRouter, type DataStrategyFunction, type DataStrategyFunctionArgs, type DataStrategyMatch, type DataStrategyResult, type DiscoverBehavior, type EntryContext, type ErrorResponse, type Fetcher, type FetcherFormProps, type FetcherSubmitFunction, type FetcherSubmitOptions, type FetcherWithComponents, type FlashSessionData, Form, type FormEncType, type FormMethod, type FormProps, type Future, type GetScrollPositionFunction, type GetScrollRestorationKeyFunction, type HTMLFormMethod, type HandleDataRequestFunction, type HandleDocumentRequestFunction, type HandleErrorFunction, HashRouter, type HashRouterProps, type HeadersArgs, type HeadersFunction, type HistoryRouterProps, type HtmlLinkDescriptor, type HydrationState, IDLE_BLOCKER, IDLE_FETCHER, IDLE_NAVIGATION, type IndexRouteObject, type IndexRouteProps, type InitialEntry, type InstrumentRequestHandlerFunction, type InstrumentRouteFunction, type InstrumentRouterFunction, type InstrumentationClientRouterResult, type InstrumentationHandlerResult, type InstrumentationServerHandlerResult, type IsCookieFunction, type IsSessionFunction, type LayoutRouteProps, type LazyRouteFunction, Link, type LinkDescriptor, type LinkProps, Links, type LinksFunction, type LinksProps, type LoaderFunction, type LoaderFunctionArgs, type Location, MemoryRouter, type MemoryRouterOpts, type MemoryRouterProps, Meta, type MetaArgs, type MetaDescriptor, type MetaFunction, type MiddlewareFunction, NavLink, type NavLinkProps, type NavLinkRenderProps, Navigate, type NavigateFunction, type NavigateOptions, type NavigateProps, type Navigation, type NavigationStates, Action as NavigationType, type Navigator, type NonIndexRouteObject, Outlet, type OutletProps, type PageLinkDescriptor, type ParamKeyValuePair, type ParamParseKey, type Params, type PatchRoutesOnNavigationFunction, type PatchRoutesOnNavigationFunctionArgs, type Path, type PathMatch, type PathParam, type PathPattern, type PathRouteProps, type PrefetchBehavior, PrefetchPageLinks, type RedirectFunction, type Register, type RelativeRoutingType, type RequestHandler, type RevalidationState, Route, type RouteMatch, type RouteObject, type RouteProps, Router$1 as Router, type RouterContext, RouterContextProvider, type RouterFetchOptions, type RouterInit, type RouterNavigateOptions, type RouterProps, RouterProvider, type RouterProviderProps, type RouterState, type RouterSubscriber, Routes, type RoutesProps, type RoutesTestStubProps, Scripts, type ScriptsProps, ScrollRestoration, type ScrollRestorationProps, type ServerBuild, type ServerEntryModule, type ServerInstrumentation, ServerRouter, type ServerRouterProps, type Session, type SessionData, type SessionIdStorageStrategy, type SessionStorage, type SetURLSearchParams, type ShouldRevalidateFunction, type ShouldRevalidateFunctionArgs, type StaticHandler, type StaticHandlerContext, StaticRouter, type StaticRouterProps, StaticRouterProvider, type StaticRouterProviderProps, type SubmitFunction, type SubmitOptions, type SubmitTarget, type To, type UIMatch, type AssetsManifest as UNSAFE_AssetsManifest, AwaitContextProvider as UNSAFE_AwaitContextProvider, DataRouterContext as UNSAFE_DataRouterContext, DataRouterDataContext as UNSAFE_DataRouterDataContext, DataRouterNavigationContext as UNSAFE_DataRouterNavigationContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, type DataWithResponseInit as UNSAFE_DataWithResponseInit, ErrorResponseImpl as UNSAFE_ErrorResponseImpl, FetchersContext as UNSAFE_FetchersContext, FrameworkContext as UNSAFE_FrameworkContext, LocationContext as UNSAFE_LocationContext, NavigationContext as UNSAFE_NavigationContext, RSCDefaultRootErrorBoundary as UNSAFE_RSCDefaultRootErrorBoundary, RemixErrorBoundary as UNSAFE_RemixErrorBoundary, RouteContext as UNSAFE_RouteContext, type RouteModules as UNSAFE_RouteModules, ServerMode as UNSAFE_ServerMode, SingleFetchRedirectSymbol as UNSAFE_SingleFetchRedirectSymbol, ViewTransitionContext as UNSAFE_ViewTransitionContext, WithComponentProps as UNSAFE_WithComponentProps, WithErrorBoundaryProps as UNSAFE_WithErrorBoundaryProps, WithHydrateFallbackProps as UNSAFE_WithHydrateFallbackProps, createBrowserHistory as UNSAFE_createBrowserHistory, createClientRoutes as UNSAFE_createClientRoutes, createClientRoutesWithHMRRevalidationOptOut as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, createHashHistory as UNSAFE_createHashHistory, createMemoryHistory as UNSAFE_createMemoryHistory, createRouter as UNSAFE_createRouter, decodeViaTurboStream as UNSAFE_decodeViaTurboStream, defaultMapRouteProperties as UNSAFE_defaultMapRouteProperties, getHydrationData as UNSAFE_getHydrationData, getPatchRoutesOnNavigationFunction as UNSAFE_getPatchRoutesOnNavigationFunction, getTurboStreamSingleFetchDataStrategy as UNSAFE_getTurboStreamSingleFetchDataStrategy, hydrationRouteProperties as UNSAFE_hydrationRouteProperties, invariant as UNSAFE_invariant, shouldHydrateRouteLoader as UNSAFE_shouldHydrateRouteLoader, useFogOFWarDiscovery as UNSAFE_useFogOFWarDiscovery, useScrollRestoration as UNSAFE_useScrollRestoration, withComponentProps as UNSAFE_withComponentProps, withErrorBoundaryProps as UNSAFE_withErrorBoundaryProps, withHydrateFallbackProps as UNSAFE_withHydrateFallbackProps, type URLSearchParamsInit, createBrowserRouter, createContext, createCookie, createCookieSessionStorage, createHashRouter, createMemoryRouter, createMemorySessionStorage, createPath, createRequestHandler, createRoutesFromChildren, createRoutesFromElements, createRoutesStub, createSearchParams, createSession, createSessionStorage, createStaticHandler, createStaticRouter, data, generatePath, href, isCookie, isRouteErrorResponse, isSession, matchPath, matchRoutes, parsePath, redirect, redirectDocument, renderMatches, replace, resolvePath, type BrowserCreateFromReadableStreamFunction as unstable_BrowserCreateFromReadableStreamFunction, type DecodeActionFunction as unstable_DecodeActionFunction, type DecodeFormStateFunction as unstable_DecodeFormStateFunction, type DecodeReplyFunction as unstable_DecodeReplyFunction, type EncodeReplyFunction as unstable_EncodeReplyFunction, HistoryRouter as unstable_HistoryRouter, type LoadServerActionFunction as unstable_LoadServerActionFunction, type RSCHydratedRouterProps as unstable_RSCHydratedRouterProps, type RSCManifestPayload as unstable_RSCManifestPayload, type RSCMatch as unstable_RSCMatch, type RSCPayload as unstable_RSCPayload, type RSCRenderPayload as unstable_RSCRenderPayload, type RSCRouteConfig as unstable_RSCRouteConfig, type RSCRouteConfigEntry as unstable_RSCRouteConfigEntry, type RSCRouteManifest as unstable_RSCRouteManifest, type RSCRouteMatch as unstable_RSCRouteMatch, RSCStaticRouter as unstable_RSCStaticRouter, type RSCStaticRouterProps as unstable_RSCStaticRouterProps, type unstable_RouterState, type unstable_RouterStateActiveVariant, type unstable_RouterStatePendingVariant, type SSRCreateFromReadableStreamFunction as unstable_SSRCreateFromReadableStreamFunction, type unstable_SerializesTo, unstable_getRequest, unstable_matchRSCServerRequest, routeRSCServerRequest as unstable_routeRSCServerRequest, setDevServerHooks as unstable_setDevServerHooks, usePrompt as unstable_usePrompt, useRoute as unstable_useRoute, useRouterState as unstable_useRouterState, useActionData, useAsyncError, useAsyncValue, useBeforeUnload, useBlocker, useFetcher, useFetchers, useFormAction, useHref, useInRouterContext, useLinkClickHandler, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes, useSearchParams, useSubmit, useViewTransitionState };
|
|
45
|
+
export { type ActionFunction, type ActionFunctionArgs, Await, type AwaitProps, type BaseRouteObject, type Blocker, type BlockerFunction, BrowserRouter, type BrowserRouterProps, type ClientActionFunction, type ClientActionFunctionArgs, type ClientInstrumentation, type ClientLoaderFunction, type ClientLoaderFunctionArgs, type ClientOnErrorFunction, type Cookie, type CookieOptions, type CookieParseOptions, type CookieSerializeOptions, type CookieSignatureOptions, type CreateRequestHandlerFunction, type DOMRouterOpts, type DataRouteMatch, type DataRouteObject, type Router as DataRouter, type DataStrategyFunction, type DataStrategyFunctionArgs, type DataStrategyMatch, type DataStrategyResult, type DiscoverBehavior, type EntryContext, type ErrorResponse, type Fetcher, type FetcherFormProps, type FetcherSubmitFunction, type FetcherSubmitOptions, type FetcherWithComponents, type FlashSessionData, Form, type FormEncType, type FormMethod, type FormProps, type Future, type GetScrollPositionFunction, type GetScrollRestorationKeyFunction, type HTMLFormMethod, type HandleDataRequestFunction, type HandleDocumentRequestFunction, type HandleErrorFunction, HashRouter, type HashRouterProps, type HeadersArgs, type HeadersFunction, type HistoryRouterProps, type HtmlLinkDescriptor, type HydrationState, IDLE_BLOCKER, IDLE_FETCHER, IDLE_NAVIGATION, type IndexRouteObject, type IndexRouteProps, type InitialEntry, type InstrumentRequestHandlerFunction, type InstrumentRouteFunction, type InstrumentRouterFunction, type InstrumentationClientRouterResult, type InstrumentationHandlerResult, type InstrumentationServerHandlerResult, type IsCookieFunction, type IsSessionFunction, type LayoutRouteProps, type LazyRouteFunction, Link, type LinkDescriptor, type LinkProps, Links, type LinksFunction, type LinksProps, type LoaderFunction, type LoaderFunctionArgs, type Location, MemoryRouter, type MemoryRouterOpts, type MemoryRouterProps, Meta, type MetaArgs, type MetaDescriptor, type MetaFunction, type MiddlewareFunction, NavLink, type NavLinkProps, type NavLinkRenderProps, Navigate, type NavigateFunction, type NavigateOptions, type NavigateProps, type Navigation, type NavigationStates, Action as NavigationType, type Navigator, type NonIndexRouteObject, Outlet, type OutletProps, type PageLinkDescriptor, type ParamKeyValuePair, type ParamParseKey, type Params, type PatchRoutesOnNavigationFunction, type PatchRoutesOnNavigationFunctionArgs, type Path, type PathMatch, type PathParam, type PathPattern, type PathRouteProps, type PrefetchBehavior, PrefetchPageLinks, type RedirectFunction, type Register, type RelativeRoutingType, type RequestHandler, type RevalidationState, Route, type RouteMatch, type RouteObject, type RouteProps, Router$1 as Router, type RouterContext, RouterContextProvider, type RouterFetchOptions, type RouterInit, type RouterNavigateOptions, type RouterProps, RouterProvider, type RouterProviderProps, type RouterState, type RouterSubscriber, Routes, type RoutesProps, type RoutesTestStubProps, Scripts, type ScriptsProps, ScrollRestoration, type ScrollRestorationProps, type ServerBuild, type ServerEntryModule, type ServerInstrumentation, ServerRouter, type ServerRouterProps, type Session, type SessionData, type SessionIdStorageStrategy, type SessionStorage, type SetURLSearchParams, type ShouldRevalidateFunction, type ShouldRevalidateFunctionArgs, type StaticHandler, type StaticHandlerContext, StaticRouter, type StaticRouterProps, StaticRouterProvider, type StaticRouterProviderProps, type SubmitFunction, type SubmitOptions, type SubmitTarget, type To, type UIMatch, type AssetsManifest as UNSAFE_AssetsManifest, AwaitContextProvider as UNSAFE_AwaitContextProvider, DataRouterContext as UNSAFE_DataRouterContext, DataRouterDataContext as UNSAFE_DataRouterDataContext, DataRouterNavigationContext as UNSAFE_DataRouterNavigationContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, type DataWithResponseInit as UNSAFE_DataWithResponseInit, ErrorResponseImpl as UNSAFE_ErrorResponseImpl, FetchersContext as UNSAFE_FetchersContext, FrameworkContext as UNSAFE_FrameworkContext, LocationContext as UNSAFE_LocationContext, NavigationContext as UNSAFE_NavigationContext, RSCDefaultRootErrorBoundary as UNSAFE_RSCDefaultRootErrorBoundary, RemixErrorBoundary as UNSAFE_RemixErrorBoundary, RouteContext as UNSAFE_RouteContext, RouteDiscoveryRuntime as UNSAFE_RouteDiscoveryRuntime, type RouteModules as UNSAFE_RouteModules, ServerMode as UNSAFE_ServerMode, SingleFetchRedirectSymbol as UNSAFE_SingleFetchRedirectSymbol, ViewTransitionContext as UNSAFE_ViewTransitionContext, WithComponentProps as UNSAFE_WithComponentProps, WithErrorBoundaryProps as UNSAFE_WithErrorBoundaryProps, WithHydrateFallbackProps as UNSAFE_WithHydrateFallbackProps, createBrowserHistory as UNSAFE_createBrowserHistory, createClientRoutes as UNSAFE_createClientRoutes, createClientRoutesWithHMRRevalidationOptOut as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, createHashHistory as UNSAFE_createHashHistory, createMemoryHistory as UNSAFE_createMemoryHistory, createRouter as UNSAFE_createRouter, decodeViaTurboStream as UNSAFE_decodeViaTurboStream, defaultMapRouteProperties as UNSAFE_defaultMapRouteProperties, getCustomPatchRoutesOnNavigationFunction as UNSAFE_getCustomPatchRoutesOnNavigationFunction, getHydrationData as UNSAFE_getHydrationData, getPatchRoutesOnNavigationFunction as UNSAFE_getPatchRoutesOnNavigationFunction, getTurboStreamSingleFetchDataStrategy as UNSAFE_getTurboStreamSingleFetchDataStrategy, hydrationRouteProperties as UNSAFE_hydrationRouteProperties, invariant as UNSAFE_invariant, shouldHydrateRouteLoader as UNSAFE_shouldHydrateRouteLoader, useCustomRouteDiscovery as UNSAFE_useCustomRouteDiscovery, useFogOFWarDiscovery as UNSAFE_useFogOFWarDiscovery, useScrollRestoration as UNSAFE_useScrollRestoration, withComponentProps as UNSAFE_withComponentProps, withErrorBoundaryProps as UNSAFE_withErrorBoundaryProps, withHydrateFallbackProps as UNSAFE_withHydrateFallbackProps, type URLSearchParamsInit, createBrowserRouter, createContext, createCookie, createCookieSessionStorage, createHashRouter, createMemoryRouter, createMemorySessionStorage, createPath, createRequestHandler, createRoutesFromChildren, createRoutesFromElements, createRoutesStub, createSearchParams, createSession, createSessionStorage, createStaticHandler, createStaticRouter, data, generatePath, href, isCookie, isRouteErrorResponse, isSession, matchPath, matchRoutes, parsePath, redirect, redirectDocument, renderMatches, replace, resolvePath, type BrowserCreateFromReadableStreamFunction as unstable_BrowserCreateFromReadableStreamFunction, type DataStrategyInitiator as unstable_DataStrategyInitiator, type DecodeActionFunction as unstable_DecodeActionFunction, type DecodeFormStateFunction as unstable_DecodeFormStateFunction, type DecodeReplyFunction as unstable_DecodeReplyFunction, type DiscoveryResult as unstable_DiscoveryResult, type EncodeReplyFunction as unstable_EncodeReplyFunction, HistoryRouter as unstable_HistoryRouter, type LoadServerActionFunction as unstable_LoadServerActionFunction, type ManifestMismatchEvent as unstable_ManifestMismatchEvent, type RSCHydratedRouterProps as unstable_RSCHydratedRouterProps, type RSCManifestPayload as unstable_RSCManifestPayload, type RSCMatch as unstable_RSCMatch, type RSCPayload as unstable_RSCPayload, type RSCRenderPayload as unstable_RSCRenderPayload, type RSCRouteConfig as unstable_RSCRouteConfig, type RSCRouteConfigEntry as unstable_RSCRouteConfigEntry, type RSCRouteManifest as unstable_RSCRouteManifest, type RSCRouteMatch as unstable_RSCRouteMatch, RSCStaticRouter as unstable_RSCStaticRouter, type RSCStaticRouterProps as unstable_RSCStaticRouterProps, type RouteDiscoveryOptions as unstable_RouteDiscoveryOptions, type unstable_RouterState, type unstable_RouterStateActiveVariant, type unstable_RouterStatePendingVariant, type SSRCreateFromReadableStreamFunction as unstable_SSRCreateFromReadableStreamFunction, type unstable_SerializesTo, unstable_getRequest, unstable_matchRSCServerRequest, routeRSCServerRequest as unstable_routeRSCServerRequest, setDevServerHooks as unstable_setDevServerHooks, usePrompt as unstable_usePrompt, useRoute as unstable_useRoute, useRouteDiscovery as unstable_useRouteDiscovery, useRouterState as unstable_useRouterState, useActionData, useAsyncError, useAsyncValue, useBeforeUnload, useBlocker, useFetcher, useFetchers, useFormAction, useHref, useInRouterContext, useLinkClickHandler, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes, useSearchParams, useSubmit, useViewTransitionState };
|
package/dist/production/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.
|
|
2
|
+
* react-router v8.5.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -14,13 +14,13 @@ import { ErrorResponseImpl, RouterContextProvider, createContext, data, defaultM
|
|
|
14
14
|
import { IDLE_BLOCKER, IDLE_FETCHER, IDLE_NAVIGATION, createRouter, createStaticHandler } from "./lib/router/router.js";
|
|
15
15
|
import { AwaitContextProvider, DataRouterContext, DataRouterDataContext, DataRouterNavigationContext, DataRouterStateContext, FetchersContext, LocationContext, NavigationContext, RouteContext, ViewTransitionContext } from "./lib/context.js";
|
|
16
16
|
import { useActionData, useAsyncError, useAsyncValue, useBlocker, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRoute, useRouteError, useRouteLoaderData, useRouterState, useRoutes } from "./lib/hooks.js";
|
|
17
|
-
import { Await, MemoryRouter, Navigate, Outlet, Route, Router, RouterProvider, Routes, WithComponentProps, WithErrorBoundaryProps, WithHydrateFallbackProps, createMemoryRouter, createRoutesFromChildren, createRoutesFromElements, hydrationRouteProperties, renderMatches, withComponentProps, withErrorBoundaryProps, withHydrateFallbackProps } from "./lib/components.js";
|
|
18
|
-
import { createSearchParams } from "./lib/dom/dom.js";
|
|
19
17
|
import { SingleFetchRedirectSymbol, decodeViaTurboStream, getTurboStreamSingleFetchDataStrategy } from "./lib/dom/ssr/single-fetch.js";
|
|
20
18
|
import { RemixErrorBoundary } from "./lib/dom/ssr/errorBoundaries.js";
|
|
21
19
|
import { createClientRoutes, createClientRoutesWithHMRRevalidationOptOut, shouldHydrateRouteLoader } from "./lib/dom/ssr/routes.js";
|
|
22
20
|
import { getPatchRoutesOnNavigationFunction, useFogOFWarDiscovery } from "./lib/dom/ssr/fog-of-war.js";
|
|
23
21
|
import { FrameworkContext, Links, Meta, PrefetchPageLinks, Scripts } from "./lib/dom/ssr/components.js";
|
|
22
|
+
import { Await, MemoryRouter, Navigate, Outlet, Route, Router, RouterProvider, Routes, WithComponentProps, WithErrorBoundaryProps, WithHydrateFallbackProps, createMemoryRouter, createRoutesFromChildren, createRoutesFromElements, hydrationRouteProperties, renderMatches, withComponentProps, withErrorBoundaryProps, withHydrateFallbackProps } from "./lib/components.js";
|
|
23
|
+
import { createSearchParams } from "./lib/dom/dom.js";
|
|
24
24
|
import { BrowserRouter, Form, HashRouter, HistoryRouter, Link, NavLink, ScrollRestoration, createBrowserRouter, createHashRouter, useBeforeUnload, useFetcher, useFetchers, useFormAction, useLinkClickHandler, usePrompt, useScrollRestoration, useSearchParams, useSubmit, useViewTransitionState } from "./lib/dom/lib.js";
|
|
25
25
|
import { StaticRouter, StaticRouterProvider, createStaticRouter } from "./lib/dom/server.js";
|
|
26
26
|
import { ServerRouter } from "./lib/dom/ssr/server.js";
|
|
@@ -36,10 +36,11 @@ import { href } from "./lib/href.js";
|
|
|
36
36
|
import { RSCDefaultRootErrorBoundary } from "./lib/rsc/errorBoundaries.js";
|
|
37
37
|
import { RSCStaticRouter, routeRSCServerRequest } from "./lib/rsc/server.ssr.js";
|
|
38
38
|
import { getHydrationData } from "./lib/dom/ssr/hydration.js";
|
|
39
|
+
import { RouteDiscoveryRuntime, getCustomPatchRoutesOnNavigationFunction, useCustomRouteDiscovery, useRouteDiscovery } from "./lib/dom/ssr/route-discovery.js";
|
|
39
40
|
//#region index.ts
|
|
40
41
|
/**
|
|
41
42
|
* @module index
|
|
42
43
|
* @mergeModuleWith react-router
|
|
43
44
|
*/
|
|
44
45
|
//#endregion
|
|
45
|
-
export { Await, BrowserRouter, Form, HashRouter, IDLE_BLOCKER, IDLE_FETCHER, IDLE_NAVIGATION, Link, Links, MemoryRouter, Meta, NavLink, Navigate, Action as NavigationType, Outlet, PrefetchPageLinks, Route, Router, RouterContextProvider, RouterProvider, Routes, Scripts, ScrollRestoration, ServerRouter, StaticRouter, StaticRouterProvider, AwaitContextProvider as UNSAFE_AwaitContextProvider, DataRouterContext as UNSAFE_DataRouterContext, DataRouterDataContext as UNSAFE_DataRouterDataContext, DataRouterNavigationContext as UNSAFE_DataRouterNavigationContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, ErrorResponseImpl as UNSAFE_ErrorResponseImpl, FetchersContext as UNSAFE_FetchersContext, FrameworkContext as UNSAFE_FrameworkContext, LocationContext as UNSAFE_LocationContext, NavigationContext as UNSAFE_NavigationContext, RSCDefaultRootErrorBoundary as UNSAFE_RSCDefaultRootErrorBoundary, RemixErrorBoundary as UNSAFE_RemixErrorBoundary, RouteContext as UNSAFE_RouteContext, ServerMode as UNSAFE_ServerMode, SingleFetchRedirectSymbol as UNSAFE_SingleFetchRedirectSymbol, ViewTransitionContext as UNSAFE_ViewTransitionContext, WithComponentProps as UNSAFE_WithComponentProps, WithErrorBoundaryProps as UNSAFE_WithErrorBoundaryProps, WithHydrateFallbackProps as UNSAFE_WithHydrateFallbackProps, createBrowserHistory as UNSAFE_createBrowserHistory, createClientRoutes as UNSAFE_createClientRoutes, createClientRoutesWithHMRRevalidationOptOut as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, createHashHistory as UNSAFE_createHashHistory, createMemoryHistory as UNSAFE_createMemoryHistory, createRouter as UNSAFE_createRouter, decodeViaTurboStream as UNSAFE_decodeViaTurboStream, defaultMapRouteProperties as UNSAFE_defaultMapRouteProperties, getHydrationData as UNSAFE_getHydrationData, getPatchRoutesOnNavigationFunction as UNSAFE_getPatchRoutesOnNavigationFunction, getTurboStreamSingleFetchDataStrategy as UNSAFE_getTurboStreamSingleFetchDataStrategy, hydrationRouteProperties as UNSAFE_hydrationRouteProperties, invariant as UNSAFE_invariant, shouldHydrateRouteLoader as UNSAFE_shouldHydrateRouteLoader, useFogOFWarDiscovery as UNSAFE_useFogOFWarDiscovery, useScrollRestoration as UNSAFE_useScrollRestoration, withComponentProps as UNSAFE_withComponentProps, withErrorBoundaryProps as UNSAFE_withErrorBoundaryProps, withHydrateFallbackProps as UNSAFE_withHydrateFallbackProps, createBrowserRouter, createContext, createCookie, createCookieSessionStorage, createHashRouter, createMemoryRouter, createMemorySessionStorage, createPath, createRequestHandler, createRoutesFromChildren, createRoutesFromElements, createRoutesStub, createSearchParams, createSession, createSessionStorage, createStaticHandler, createStaticRouter, data, generatePath, href, isCookie, isRouteErrorResponse, isSession, matchPath, matchRoutes, parsePath, redirect, redirectDocument, renderMatches, replace, resolvePath, HistoryRouter as unstable_HistoryRouter, RSCStaticRouter as unstable_RSCStaticRouter, routeRSCServerRequest as unstable_routeRSCServerRequest, setDevServerHooks as unstable_setDevServerHooks, usePrompt as unstable_usePrompt, useRoute as unstable_useRoute, useRouterState as unstable_useRouterState, useActionData, useAsyncError, useAsyncValue, useBeforeUnload, useBlocker, useFetcher, useFetchers, useFormAction, useHref, useInRouterContext, useLinkClickHandler, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes, useSearchParams, useSubmit, useViewTransitionState };
|
|
46
|
+
export { Await, BrowserRouter, Form, HashRouter, IDLE_BLOCKER, IDLE_FETCHER, IDLE_NAVIGATION, Link, Links, MemoryRouter, Meta, NavLink, Navigate, Action as NavigationType, Outlet, PrefetchPageLinks, Route, Router, RouterContextProvider, RouterProvider, Routes, Scripts, ScrollRestoration, ServerRouter, StaticRouter, StaticRouterProvider, AwaitContextProvider as UNSAFE_AwaitContextProvider, DataRouterContext as UNSAFE_DataRouterContext, DataRouterDataContext as UNSAFE_DataRouterDataContext, DataRouterNavigationContext as UNSAFE_DataRouterNavigationContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, ErrorResponseImpl as UNSAFE_ErrorResponseImpl, FetchersContext as UNSAFE_FetchersContext, FrameworkContext as UNSAFE_FrameworkContext, LocationContext as UNSAFE_LocationContext, NavigationContext as UNSAFE_NavigationContext, RSCDefaultRootErrorBoundary as UNSAFE_RSCDefaultRootErrorBoundary, RemixErrorBoundary as UNSAFE_RemixErrorBoundary, RouteContext as UNSAFE_RouteContext, RouteDiscoveryRuntime as UNSAFE_RouteDiscoveryRuntime, ServerMode as UNSAFE_ServerMode, SingleFetchRedirectSymbol as UNSAFE_SingleFetchRedirectSymbol, ViewTransitionContext as UNSAFE_ViewTransitionContext, WithComponentProps as UNSAFE_WithComponentProps, WithErrorBoundaryProps as UNSAFE_WithErrorBoundaryProps, WithHydrateFallbackProps as UNSAFE_WithHydrateFallbackProps, createBrowserHistory as UNSAFE_createBrowserHistory, createClientRoutes as UNSAFE_createClientRoutes, createClientRoutesWithHMRRevalidationOptOut as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, createHashHistory as UNSAFE_createHashHistory, createMemoryHistory as UNSAFE_createMemoryHistory, createRouter as UNSAFE_createRouter, decodeViaTurboStream as UNSAFE_decodeViaTurboStream, defaultMapRouteProperties as UNSAFE_defaultMapRouteProperties, getCustomPatchRoutesOnNavigationFunction as UNSAFE_getCustomPatchRoutesOnNavigationFunction, getHydrationData as UNSAFE_getHydrationData, getPatchRoutesOnNavigationFunction as UNSAFE_getPatchRoutesOnNavigationFunction, getTurboStreamSingleFetchDataStrategy as UNSAFE_getTurboStreamSingleFetchDataStrategy, hydrationRouteProperties as UNSAFE_hydrationRouteProperties, invariant as UNSAFE_invariant, shouldHydrateRouteLoader as UNSAFE_shouldHydrateRouteLoader, useCustomRouteDiscovery as UNSAFE_useCustomRouteDiscovery, useFogOFWarDiscovery as UNSAFE_useFogOFWarDiscovery, useScrollRestoration as UNSAFE_useScrollRestoration, withComponentProps as UNSAFE_withComponentProps, withErrorBoundaryProps as UNSAFE_withErrorBoundaryProps, withHydrateFallbackProps as UNSAFE_withHydrateFallbackProps, createBrowserRouter, createContext, createCookie, createCookieSessionStorage, createHashRouter, createMemoryRouter, createMemorySessionStorage, createPath, createRequestHandler, createRoutesFromChildren, createRoutesFromElements, createRoutesStub, createSearchParams, createSession, createSessionStorage, createStaticHandler, createStaticRouter, data, generatePath, href, isCookie, isRouteErrorResponse, isSession, matchPath, matchRoutes, parsePath, redirect, redirectDocument, renderMatches, replace, resolvePath, HistoryRouter as unstable_HistoryRouter, RSCStaticRouter as unstable_RSCStaticRouter, routeRSCServerRequest as unstable_routeRSCServerRequest, setDevServerHooks as unstable_setDevServerHooks, usePrompt as unstable_usePrompt, useRoute as unstable_useRoute, useRouteDiscovery as unstable_useRouteDiscovery, useRouterState as unstable_useRouterState, useActionData, useAsyncError, useAsyncValue, useBeforeUnload, useBlocker, useFetcher, useFetchers, useFormAction, useHref, useInRouterContext, useLinkClickHandler, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes, useSearchParams, useSubmit, useViewTransitionState };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* react-router v8.5.1
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Remix Software Inc.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
//#region lib/await.ts
|
|
12
|
+
function getPromiseResult(promise) {
|
|
13
|
+
if (promise.status === "fulfilled") return {
|
|
14
|
+
status: "fulfilled",
|
|
15
|
+
value: promise.value
|
|
16
|
+
};
|
|
17
|
+
if (promise.status === "rejected") return {
|
|
18
|
+
status: "rejected",
|
|
19
|
+
reason: promise.reason
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
let awaitPromises = /* @__PURE__ */ new WeakMap();
|
|
23
|
+
function getAwaitPromise(source, onError) {
|
|
24
|
+
let cached = awaitPromises.get(source);
|
|
25
|
+
if (!cached) {
|
|
26
|
+
cached = {
|
|
27
|
+
promise: Promise.resolve(source).then((value) => settle({
|
|
28
|
+
status: "fulfilled",
|
|
29
|
+
value
|
|
30
|
+
}), (reason) => {
|
|
31
|
+
let result = settle({
|
|
32
|
+
status: "rejected",
|
|
33
|
+
reason
|
|
34
|
+
});
|
|
35
|
+
try {
|
|
36
|
+
cached.onError(reason);
|
|
37
|
+
} catch (error) {
|
|
38
|
+
console.error("<Await> caught the following error in onError", error);
|
|
39
|
+
}
|
|
40
|
+
return result;
|
|
41
|
+
}),
|
|
42
|
+
onError
|
|
43
|
+
};
|
|
44
|
+
awaitPromises.set(source, cached);
|
|
45
|
+
} else cached.onError = onError;
|
|
46
|
+
function settle(result) {
|
|
47
|
+
Object.assign(cached.promise, {
|
|
48
|
+
status: "fulfilled",
|
|
49
|
+
value: result
|
|
50
|
+
});
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
let result = getPromiseResult(source);
|
|
54
|
+
if (result) settle(result);
|
|
55
|
+
return cached.promise;
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
export { getAwaitPromise, getPromiseResult };
|
|
@@ -768,6 +768,8 @@ interface AwaitResolveRenderFunction<Resolve = any> {
|
|
|
768
768
|
* @category Types
|
|
769
769
|
*/
|
|
770
770
|
interface AwaitProps<Resolve> {
|
|
771
|
+
/** Use either `resolve` or `unstable_promise`, never both. */
|
|
772
|
+
unstable_promise?: never;
|
|
771
773
|
/**
|
|
772
774
|
* When using a function, the resolved value is provided as the parameter.
|
|
773
775
|
*
|
|
@@ -869,11 +871,46 @@ interface AwaitProps<Resolve> {
|
|
|
869
871
|
*/
|
|
870
872
|
resolve: Resolve;
|
|
871
873
|
}
|
|
874
|
+
interface AwaitPromiseProps<Resolve> extends Omit<AwaitProps<Resolve>, "resolve" | "unstable_promise"> {
|
|
875
|
+
resolve?: never;
|
|
876
|
+
/**
|
|
877
|
+
* A promise (or value) to read using React's `use()` API in client components.
|
|
878
|
+
* Unlike `resolve` in client components, this accepts promise-like values
|
|
879
|
+
* without modifying the source promise.
|
|
880
|
+
*
|
|
881
|
+
* `errorElement` handles promise rejections. Errors thrown while rendering
|
|
882
|
+
* children bubble to the nearest React error boundary.
|
|
883
|
+
*
|
|
884
|
+
* ```tsx
|
|
885
|
+
* <Await unstable_promise={reviewsPromise} errorElement={<ReviewsError />}>
|
|
886
|
+
* {(reviews) => <Reviews items={reviews} />}
|
|
887
|
+
* </Await>
|
|
888
|
+
* ```
|
|
889
|
+
*
|
|
890
|
+
* Pass exactly one of `unstable_promise` or `resolve`.
|
|
891
|
+
*/
|
|
892
|
+
unstable_promise: Resolve;
|
|
893
|
+
}
|
|
872
894
|
/**
|
|
873
895
|
* Used to render promise values with automatic error handling.
|
|
874
896
|
*
|
|
875
897
|
* **Note:** `<Await>` expects to be rendered inside a [`<React.Suspense>`](https://react.dev/reference/react/Suspense)
|
|
876
898
|
*
|
|
899
|
+
* Pass `unstable_promise` instead of `resolve` to opt into React's
|
|
900
|
+
* [`use()`](https://react.dev/reference/react/use) implementation. With
|
|
901
|
+
* `unstable_promise`, `errorElement` handles promise rejections, while errors
|
|
902
|
+
* thrown by children bubble to the nearest React error boundary.
|
|
903
|
+
*
|
|
904
|
+
* In React Server Components, `resolve` already has this error-handling behavior:
|
|
905
|
+
* `errorElement` handles only input rejections, while child render errors
|
|
906
|
+
* propagate to the surrounding error boundary. Both props accept promise-like
|
|
907
|
+
* values without modifying the source promise. Both props treat a falsy
|
|
908
|
+
* `errorElement` as absent and propagate the rejection. Pass an empty fragment
|
|
909
|
+
* to handle a rejection without rendering any content.
|
|
910
|
+
*
|
|
911
|
+
* <docs-warning>The `unstable_promise` prop is experimental and may change in
|
|
912
|
+
* minor or patch releases.</docs-warning>
|
|
913
|
+
*
|
|
877
914
|
* @example
|
|
878
915
|
* import { Await, useLoaderData } from "react-router";
|
|
879
916
|
*
|
|
@@ -914,13 +951,12 @@ interface AwaitProps<Resolve> {
|
|
|
914
951
|
* @param {AwaitProps.children} props.children n/a
|
|
915
952
|
* @param {AwaitProps.errorElement} props.errorElement n/a
|
|
916
953
|
* @param {AwaitProps.resolve} props.resolve n/a
|
|
954
|
+
* @param props.unstable_promise A promise (or value) to read using React's `use()`
|
|
955
|
+
* API in client components. Accepts promise-like values without modifying the
|
|
956
|
+
* source promise. Pass exactly one of `unstable_promise` or `resolve`.
|
|
917
957
|
* @returns React element for the rendered awaited value
|
|
918
958
|
*/
|
|
919
|
-
declare function Await<Resolve>(
|
|
920
|
-
children,
|
|
921
|
-
errorElement,
|
|
922
|
-
resolve
|
|
923
|
-
}: AwaitProps<Resolve>): React$1.JSX.Element;
|
|
959
|
+
declare function Await<Resolve>(props: AwaitProps<Resolve> | AwaitPromiseProps<Resolve>): React$1.JSX.Element;
|
|
924
960
|
/**
|
|
925
961
|
* Creates a route config from a React "children" object, which is usually
|
|
926
962
|
* either a `<Route>` element or an array of them. Used internally by
|