react-router 7.18.0 → 8.0.0-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/dist/development/dom-export.d.ts +6 -172
- package/dist/development/dom-export.js +12 -1009
- package/dist/development/index-react-server-client.d.ts +7 -4
- package/dist/development/index-react-server-client.js +8 -52
- package/dist/development/index-react-server.d.ts +1650 -1641
- package/dist/development/index-react-server.js +2882 -3664
- package/dist/development/index.d.ts +42 -1476
- package/dist/development/index.js +36 -2553
- package/dist/development/lib/actions.js +50 -0
- package/dist/development/lib/components.d.ts +1030 -0
- package/dist/development/lib/components.js +841 -0
- package/dist/development/lib/context.d.ts +83 -0
- package/dist/development/lib/context.js +41 -0
- package/dist/development/lib/dom/dom.d.ts +119 -0
- package/dist/development/lib/dom/dom.js +143 -0
- package/dist/development/lib/dom/lib.d.ts +2053 -0
- package/dist/development/lib/dom/lib.js +1271 -0
- package/dist/development/lib/dom/server.d.ts +138 -0
- package/dist/development/lib/dom/server.js +301 -0
- package/dist/development/lib/dom/ssr/components.d.ts +198 -0
- package/dist/development/lib/dom/ssr/components.js +589 -0
- package/dist/development/lib/dom/ssr/data.js +29 -0
- package/dist/development/lib/dom/ssr/entry.d.ts +60 -0
- package/dist/development/lib/dom/ssr/errorBoundaries.d.ts +27 -0
- package/dist/development/lib/dom/ssr/errorBoundaries.js +87 -0
- package/dist/development/lib/dom/ssr/fallback.js +33 -0
- package/dist/development/lib/dom/ssr/fog-of-war.d.ts +12 -0
- package/dist/development/lib/dom/ssr/fog-of-war.js +180 -0
- package/dist/development/lib/dom/ssr/hydration.d.ts +32 -0
- package/dist/development/lib/dom/ssr/hydration.js +29 -0
- package/dist/development/lib/dom/ssr/invariant.js +16 -0
- package/dist/development/lib/dom/ssr/links.js +170 -0
- package/dist/development/lib/dom/ssr/markup.js +24 -0
- package/dist/development/lib/dom/ssr/routeModules.d.ts +206 -0
- package/dist/development/lib/dom/ssr/routeModules.js +31 -0
- package/dist/development/lib/dom/ssr/routes-test-stub.d.ts +62 -0
- package/dist/development/lib/dom/ssr/routes-test-stub.js +108 -0
- package/dist/development/lib/dom/ssr/routes.d.ts +33 -0
- package/dist/development/lib/dom/ssr/routes.js +303 -0
- package/dist/development/lib/dom/ssr/server.d.ts +48 -0
- package/dist/development/lib/dom/ssr/server.js +69 -0
- package/dist/development/lib/dom/ssr/single-fetch.d.ts +14 -0
- package/dist/development/lib/dom/ssr/single-fetch.js +345 -0
- package/dist/development/lib/dom-export/dom-router-provider.d.ts +9 -0
- package/dist/development/lib/dom-export/dom-router-provider.js +22 -0
- package/dist/development/lib/dom-export/hydrated-router.d.ts +125 -0
- package/dist/development/lib/dom-export/hydrated-router.js +150 -0
- package/dist/development/lib/errors.js +29 -0
- package/dist/development/lib/hooks.d.ts +947 -0
- package/dist/development/lib/hooks.js +1388 -0
- package/dist/development/lib/href.d.ts +20 -0
- package/dist/development/lib/href.js +50 -0
- package/dist/development/lib/router/history.d.ts +258 -0
- package/dist/development/lib/router/history.js +372 -0
- package/dist/development/lib/router/instrumentation.d.ts +86 -0
- package/dist/development/lib/router/instrumentation.js +213 -0
- package/dist/development/lib/router/links.d.ts +114 -0
- package/dist/development/lib/router/router.d.ts +663 -0
- package/dist/development/lib/router/router.js +2988 -0
- package/dist/development/lib/router/url.js +18 -0
- package/dist/development/lib/router/utils.d.ts +948 -0
- package/dist/development/lib/router/utils.js +810 -0
- package/dist/development/lib/rsc/browser.d.ts +137 -0
- package/dist/development/lib/rsc/browser.js +603 -0
- package/dist/development/lib/rsc/errorBoundaries.d.ts +11 -0
- package/dist/development/lib/rsc/errorBoundaries.js +90 -0
- package/dist/development/lib/rsc/html-stream/browser.d.ts +48 -0
- package/dist/development/lib/rsc/html-stream/browser.js +74 -0
- package/dist/development/lib/rsc/html-stream/server.js +78 -0
- package/dist/development/lib/rsc/route-modules.js +27 -0
- package/dist/development/lib/rsc/server.rsc.d.ts +219 -0
- package/dist/development/lib/rsc/server.ssr.d.ts +129 -0
- package/dist/development/lib/rsc/server.ssr.js +404 -0
- package/dist/development/lib/server-runtime/build.d.ts +66 -0
- package/dist/development/lib/server-runtime/cookies.d.ts +66 -0
- package/dist/development/lib/server-runtime/cookies.js +139 -0
- package/dist/development/lib/server-runtime/crypto.js +43 -0
- package/dist/development/lib/server-runtime/data.d.ts +13 -0
- package/dist/development/lib/server-runtime/data.js +25 -0
- package/dist/development/lib/server-runtime/dev.d.ts +9 -0
- package/dist/development/lib/server-runtime/dev.js +26 -0
- package/dist/development/lib/server-runtime/entry.js +20 -0
- package/dist/development/lib/server-runtime/errors.js +75 -0
- package/dist/development/lib/server-runtime/headers.js +73 -0
- package/dist/development/lib/server-runtime/invariant.js +19 -0
- package/dist/development/lib/server-runtime/mode.d.ts +12 -0
- package/dist/development/lib/server-runtime/mode.js +25 -0
- package/dist/development/lib/server-runtime/routeMatching.js +28 -0
- package/dist/development/lib/server-runtime/routes.d.ts +13 -0
- package/dist/development/lib/server-runtime/routes.js +74 -0
- package/dist/development/lib/server-runtime/server.d.ts +10 -0
- package/dist/development/lib/server-runtime/server.js +345 -0
- package/dist/development/lib/server-runtime/serverHandoff.js +17 -0
- package/dist/development/lib/server-runtime/sessions/cookieStorage.d.ts +25 -0
- package/dist/development/lib/server-runtime/sessions/cookieStorage.js +45 -0
- package/dist/development/lib/server-runtime/sessions/memoryStorage.d.ts +23 -0
- package/dist/development/lib/server-runtime/sessions/memoryStorage.js +52 -0
- package/dist/development/lib/server-runtime/sessions.d.ts +145 -0
- package/dist/development/lib/server-runtime/sessions.js +98 -0
- package/dist/development/lib/server-runtime/single-fetch.d.ts +7 -0
- package/dist/development/lib/server-runtime/single-fetch.js +215 -0
- package/dist/development/lib/server-runtime/urls.js +28 -0
- package/dist/development/lib/server-runtime/warnings.js +20 -0
- package/dist/development/lib/types/future.d.ts +9 -0
- package/dist/development/lib/types/internal.d.ts +26 -177
- package/dist/development/lib/types/internal.js +3 -2
- package/dist/development/{register-roq_0qYo.d.ts → lib/types/register.d.ts} +9 -15
- package/dist/development/lib/types/route-data.d.ts +113 -0
- package/dist/development/lib/types/route-module-annotations.d.ts +149 -0
- package/dist/development/lib/types/route-module.d.ts +19 -0
- package/dist/development/lib/types/serializes-to.d.ts +13 -0
- package/dist/development/lib/types/utils.d.ts +11 -0
- package/dist/development/vendor/turbo-stream-v2/flatten.js +159 -0
- package/dist/development/vendor/turbo-stream-v2/turbo-stream.js +179 -0
- package/dist/development/vendor/turbo-stream-v2/unflatten.js +199 -0
- package/dist/development/vendor/turbo-stream-v2/utils.js +39 -0
- package/dist/production/dom-export.d.ts +6 -172
- package/dist/production/dom-export.js +12 -1009
- package/dist/production/index-react-server-client.d.ts +7 -4
- package/dist/production/index-react-server-client.js +8 -52
- package/dist/production/index-react-server.d.ts +1650 -1641
- package/dist/production/index-react-server.js +2873 -3664
- package/dist/production/index.d.ts +42 -1476
- package/dist/production/index.js +36 -2553
- package/dist/production/lib/actions.js +50 -0
- package/dist/production/lib/components.d.ts +1030 -0
- package/dist/production/lib/components.js +841 -0
- package/dist/production/lib/context.d.ts +83 -0
- package/dist/production/lib/context.js +41 -0
- package/dist/production/lib/dom/dom.d.ts +119 -0
- package/dist/production/lib/dom/dom.js +143 -0
- package/dist/production/lib/dom/lib.d.ts +2053 -0
- package/dist/production/lib/dom/lib.js +1271 -0
- package/dist/production/lib/dom/server.d.ts +138 -0
- package/dist/production/lib/dom/server.js +301 -0
- package/dist/production/lib/dom/ssr/components.d.ts +198 -0
- package/dist/production/lib/dom/ssr/components.js +589 -0
- package/dist/production/lib/dom/ssr/data.js +29 -0
- package/dist/production/lib/dom/ssr/entry.d.ts +60 -0
- package/dist/production/lib/dom/ssr/errorBoundaries.d.ts +27 -0
- package/dist/production/lib/dom/ssr/errorBoundaries.js +87 -0
- package/dist/production/lib/dom/ssr/fallback.js +23 -0
- package/dist/production/lib/dom/ssr/fog-of-war.d.ts +12 -0
- package/dist/production/lib/dom/ssr/fog-of-war.js +180 -0
- package/dist/production/lib/dom/ssr/hydration.d.ts +32 -0
- package/dist/production/lib/dom/ssr/hydration.js +29 -0
- package/dist/production/lib/dom/ssr/invariant.js +16 -0
- package/dist/production/lib/dom/ssr/links.js +170 -0
- package/dist/production/lib/dom/ssr/markup.js +24 -0
- package/dist/production/lib/dom/ssr/routeModules.d.ts +206 -0
- package/dist/production/lib/dom/ssr/routeModules.js +31 -0
- package/dist/production/lib/dom/ssr/routes-test-stub.d.ts +62 -0
- package/dist/production/lib/dom/ssr/routes-test-stub.js +108 -0
- package/dist/production/lib/dom/ssr/routes.d.ts +33 -0
- package/dist/production/lib/dom/ssr/routes.js +303 -0
- package/dist/production/lib/dom/ssr/server.d.ts +48 -0
- package/dist/production/lib/dom/ssr/server.js +69 -0
- package/dist/production/lib/dom/ssr/single-fetch.d.ts +14 -0
- package/dist/production/lib/dom/ssr/single-fetch.js +345 -0
- package/dist/production/lib/dom-export/dom-router-provider.d.ts +9 -0
- package/dist/production/lib/dom-export/dom-router-provider.js +22 -0
- package/dist/production/lib/dom-export/hydrated-router.d.ts +125 -0
- package/dist/production/lib/dom-export/hydrated-router.js +150 -0
- package/dist/production/lib/errors.js +29 -0
- package/dist/production/lib/hooks.d.ts +947 -0
- package/dist/production/lib/hooks.js +1373 -0
- package/dist/production/lib/href.d.ts +20 -0
- package/dist/production/lib/href.js +50 -0
- package/dist/production/lib/router/history.d.ts +258 -0
- package/dist/production/lib/router/history.js +372 -0
- package/dist/production/lib/router/instrumentation.d.ts +86 -0
- package/dist/production/lib/router/instrumentation.js +213 -0
- package/dist/production/lib/router/links.d.ts +114 -0
- package/dist/production/lib/router/router.d.ts +663 -0
- package/dist/production/lib/router/router.js +2988 -0
- package/dist/production/lib/router/url.js +18 -0
- package/dist/production/lib/router/utils.d.ts +948 -0
- package/dist/production/lib/router/utils.js +801 -0
- package/dist/production/lib/rsc/browser.d.ts +137 -0
- package/dist/production/lib/rsc/browser.js +603 -0
- package/dist/production/lib/rsc/errorBoundaries.d.ts +11 -0
- package/dist/production/lib/rsc/errorBoundaries.js +90 -0
- package/dist/production/lib/rsc/html-stream/browser.d.ts +48 -0
- package/dist/production/lib/rsc/html-stream/browser.js +74 -0
- package/dist/production/lib/rsc/html-stream/server.js +78 -0
- package/dist/production/lib/rsc/route-modules.js +27 -0
- package/dist/production/lib/rsc/server.rsc.d.ts +219 -0
- package/dist/production/lib/rsc/server.ssr.d.ts +129 -0
- package/dist/production/lib/rsc/server.ssr.js +404 -0
- package/dist/production/lib/server-runtime/build.d.ts +66 -0
- package/dist/production/lib/server-runtime/cookies.d.ts +66 -0
- package/dist/production/lib/server-runtime/cookies.js +139 -0
- package/dist/production/lib/server-runtime/crypto.js +43 -0
- package/dist/production/lib/server-runtime/data.d.ts +13 -0
- package/dist/production/lib/server-runtime/data.js +25 -0
- package/dist/production/lib/server-runtime/dev.d.ts +9 -0
- package/dist/production/lib/server-runtime/dev.js +26 -0
- package/dist/production/lib/server-runtime/entry.js +20 -0
- package/dist/production/lib/server-runtime/errors.js +75 -0
- package/dist/production/lib/server-runtime/headers.js +73 -0
- package/dist/production/lib/server-runtime/invariant.js +19 -0
- package/dist/production/lib/server-runtime/mode.d.ts +12 -0
- package/dist/production/lib/server-runtime/mode.js +25 -0
- package/dist/production/lib/server-runtime/routeMatching.js +28 -0
- package/dist/production/lib/server-runtime/routes.d.ts +13 -0
- package/dist/production/lib/server-runtime/routes.js +74 -0
- package/dist/production/lib/server-runtime/server.d.ts +10 -0
- package/dist/production/lib/server-runtime/server.js +345 -0
- package/dist/production/lib/server-runtime/serverHandoff.js +17 -0
- package/dist/production/lib/server-runtime/sessions/cookieStorage.d.ts +25 -0
- package/dist/production/lib/server-runtime/sessions/cookieStorage.js +45 -0
- package/dist/production/lib/server-runtime/sessions/memoryStorage.d.ts +23 -0
- package/dist/production/lib/server-runtime/sessions/memoryStorage.js +52 -0
- package/dist/production/lib/server-runtime/sessions.d.ts +145 -0
- package/dist/production/lib/server-runtime/sessions.js +98 -0
- package/dist/production/lib/server-runtime/single-fetch.d.ts +7 -0
- package/dist/production/lib/server-runtime/single-fetch.js +215 -0
- package/dist/production/lib/server-runtime/urls.js +28 -0
- package/dist/production/lib/server-runtime/warnings.js +20 -0
- package/dist/production/lib/types/future.d.ts +9 -0
- package/dist/production/lib/types/internal.d.ts +26 -177
- package/dist/production/lib/types/internal.js +3 -2
- package/dist/production/{register-roq_0qYo.d.ts → lib/types/register.d.ts} +9 -15
- package/dist/production/lib/types/route-data.d.ts +113 -0
- package/dist/production/lib/types/route-module-annotations.d.ts +149 -0
- package/dist/production/lib/types/route-module.d.ts +19 -0
- package/dist/production/lib/types/serializes-to.d.ts +13 -0
- package/dist/production/lib/types/utils.d.ts +11 -0
- package/dist/production/vendor/turbo-stream-v2/flatten.js +159 -0
- package/dist/production/vendor/turbo-stream-v2/turbo-stream.js +179 -0
- package/dist/production/vendor/turbo-stream-v2/unflatten.js +199 -0
- package/dist/production/vendor/turbo-stream-v2/utils.js +39 -0
- package/docs/explanation/code-splitting.md +16 -0
- package/docs/how-to/middleware.md +6 -41
- package/docs/how-to/react-server-components.md +1 -1
- package/docs/upgrading/future.md +0 -249
- package/package.json +43 -87
- package/dist/development/browser-B2PdsXXH.d.ts +0 -318
- package/dist/development/browser-DBmQ1yAR.d.mts +0 -318
- package/dist/development/chunk-4ZMWKKQ3.mjs +0 -11606
- package/dist/development/chunk-E4MTK73K.mjs +0 -2517
- package/dist/development/chunk-U7ORXROY.js +0 -10307
- package/dist/development/chunk-WW7PN6QI.js +0 -188
- package/dist/development/chunk-YL5M26XI.js +0 -1366
- package/dist/development/context-CeD5LmaF.d.mts +0 -1779
- package/dist/development/data-CjO11-hU.d.ts +0 -1740
- package/dist/development/data-DEjBmEfD.d.mts +0 -1740
- package/dist/development/dom-export.d.mts +0 -172
- package/dist/development/dom-export.mjs +0 -1010
- package/dist/development/index-react-server-client-3ykjivgQ.d.ts +0 -3677
- package/dist/development/index-react-server-client-CACgcj2J.d.mts +0 -2614
- package/dist/development/index-react-server-client.d.mts +0 -4
- package/dist/development/index-react-server-client.mjs +0 -59
- package/dist/development/index-react-server.d.mts +0 -2711
- package/dist/development/index-react-server.mjs +0 -3803
- package/dist/development/index.d.mts +0 -1479
- package/dist/development/index.mjs +0 -275
- package/dist/development/instrumentation-Dkmpzd13.d.ts +0 -715
- package/dist/development/lib/types/internal.d.mts +0 -184
- package/dist/development/lib/types/internal.mjs +0 -10
- package/dist/development/register-CmkRspdl.d.mts +0 -30
- package/dist/production/browser-B2PdsXXH.d.ts +0 -318
- package/dist/production/browser-DBmQ1yAR.d.mts +0 -318
- package/dist/production/chunk-3Z6WS2WZ.js +0 -188
- package/dist/production/chunk-BIP66BKV.js +0 -1366
- package/dist/production/chunk-EGOTSXNH.mjs +0 -2517
- package/dist/production/chunk-IUPBOWYO.js +0 -10307
- package/dist/production/chunk-M7NGGUU6.mjs +0 -11606
- package/dist/production/context-CeD5LmaF.d.mts +0 -1779
- package/dist/production/data-CjO11-hU.d.ts +0 -1740
- package/dist/production/data-DEjBmEfD.d.mts +0 -1740
- package/dist/production/dom-export.d.mts +0 -172
- package/dist/production/dom-export.mjs +0 -1010
- package/dist/production/index-react-server-client-3ykjivgQ.d.ts +0 -3677
- package/dist/production/index-react-server-client-CACgcj2J.d.mts +0 -2614
- package/dist/production/index-react-server-client.d.mts +0 -4
- package/dist/production/index-react-server-client.mjs +0 -59
- package/dist/production/index-react-server.d.mts +0 -2711
- package/dist/production/index-react-server.mjs +0 -3803
- package/dist/production/index.d.mts +0 -1479
- package/dist/production/index.mjs +0 -275
- package/dist/production/instrumentation-Dkmpzd13.d.ts +0 -715
- package/dist/production/lib/types/internal.d.mts +0 -184
- package/dist/production/lib/types/internal.mjs +0 -10
- package/dist/production/register-CmkRspdl.d.mts +0 -30
|
@@ -1,1010 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* react-router v7.18.0
|
|
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
|
-
"use client";
|
|
12
|
-
import {
|
|
13
|
-
RSCRouterGlobalErrorBoundary,
|
|
14
|
-
getHydrationData,
|
|
15
|
-
populateRSCRouteModules
|
|
16
|
-
} from "./chunk-EGOTSXNH.mjs";
|
|
17
|
-
import {
|
|
18
|
-
CRITICAL_CSS_DATA_ATTRIBUTE,
|
|
19
|
-
ErrorResponseImpl,
|
|
20
|
-
FrameworkContext,
|
|
21
|
-
PROTOCOL_RELATIVE_URL_REGEX,
|
|
22
|
-
RSCRouterContext,
|
|
23
|
-
RemixErrorBoundary,
|
|
24
|
-
RouterProvider,
|
|
25
|
-
URL_LIMIT,
|
|
26
|
-
createBrowserHistory,
|
|
27
|
-
createClientRoutes,
|
|
28
|
-
createClientRoutesWithHMRRevalidationOptOut,
|
|
29
|
-
createContext,
|
|
30
|
-
createRequestInit,
|
|
31
|
-
createRouter,
|
|
32
|
-
decodeViaTurboStream,
|
|
33
|
-
getPatchRoutesOnNavigationFunction,
|
|
34
|
-
getPathsWithAncestors,
|
|
35
|
-
getSingleFetchDataStrategyImpl,
|
|
36
|
-
getTurboStreamSingleFetchDataStrategy,
|
|
37
|
-
hasInvalidProtocol,
|
|
38
|
-
hydrationRouteProperties,
|
|
39
|
-
invariant,
|
|
40
|
-
isMutationMethod,
|
|
41
|
-
mapRouteProperties,
|
|
42
|
-
noActionDefinedError,
|
|
43
|
-
resolvePath,
|
|
44
|
-
setIsHydrated,
|
|
45
|
-
shouldHydrateRouteLoader,
|
|
46
|
-
singleFetchUrl,
|
|
47
|
-
stripIndexParam,
|
|
48
|
-
useFogOFWarDiscovery
|
|
49
|
-
} from "./chunk-M7NGGUU6.mjs";
|
|
50
|
-
|
|
51
|
-
// lib/dom-export/dom-router-provider.tsx
|
|
52
|
-
import * as React from "react";
|
|
53
|
-
import * as ReactDOM from "react-dom";
|
|
54
|
-
function RouterProvider2(props) {
|
|
55
|
-
return /* @__PURE__ */ React.createElement(RouterProvider, { flushSync: ReactDOM.flushSync, ...props });
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// lib/dom-export/hydrated-router.tsx
|
|
59
|
-
import * as React2 from "react";
|
|
60
|
-
var ssrInfo = null;
|
|
61
|
-
var router = null;
|
|
62
|
-
function initSsrInfo() {
|
|
63
|
-
if (!ssrInfo && window.__reactRouterContext && window.__reactRouterManifest && window.__reactRouterRouteModules) {
|
|
64
|
-
if (window.__reactRouterManifest.sri === true) {
|
|
65
|
-
const importMap = document.querySelector("script[rr-importmap]");
|
|
66
|
-
if (importMap?.textContent) {
|
|
67
|
-
try {
|
|
68
|
-
window.__reactRouterManifest.sri = JSON.parse(
|
|
69
|
-
importMap.textContent
|
|
70
|
-
).integrity;
|
|
71
|
-
} catch (err) {
|
|
72
|
-
console.error("Failed to parse import map", err);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
ssrInfo = {
|
|
77
|
-
context: window.__reactRouterContext,
|
|
78
|
-
manifest: window.__reactRouterManifest,
|
|
79
|
-
routeModules: window.__reactRouterRouteModules,
|
|
80
|
-
stateDecodingPromise: void 0,
|
|
81
|
-
router: void 0,
|
|
82
|
-
routerInitialized: false
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
function createHydratedRouter({
|
|
87
|
-
getContext,
|
|
88
|
-
instrumentations
|
|
89
|
-
}) {
|
|
90
|
-
initSsrInfo();
|
|
91
|
-
if (!ssrInfo) {
|
|
92
|
-
throw new Error(
|
|
93
|
-
"You must be using the SSR features of React Router in order to skip passing a `router` prop to `<RouterProvider>`"
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
let localSsrInfo = ssrInfo;
|
|
97
|
-
if (!ssrInfo.stateDecodingPromise) {
|
|
98
|
-
let stream = ssrInfo.context.stream;
|
|
99
|
-
invariant(stream, "No stream found for single fetch decoding");
|
|
100
|
-
ssrInfo.context.stream = void 0;
|
|
101
|
-
ssrInfo.stateDecodingPromise = decodeViaTurboStream(stream, window).then((value) => {
|
|
102
|
-
ssrInfo.context.state = value.value;
|
|
103
|
-
localSsrInfo.stateDecodingPromise.value = true;
|
|
104
|
-
}).catch((e) => {
|
|
105
|
-
localSsrInfo.stateDecodingPromise.error = e;
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
if (ssrInfo.stateDecodingPromise.error) {
|
|
109
|
-
throw ssrInfo.stateDecodingPromise.error;
|
|
110
|
-
}
|
|
111
|
-
if (!ssrInfo.stateDecodingPromise.value) {
|
|
112
|
-
throw ssrInfo.stateDecodingPromise;
|
|
113
|
-
}
|
|
114
|
-
let routes = createClientRoutes(
|
|
115
|
-
ssrInfo.manifest.routes,
|
|
116
|
-
ssrInfo.routeModules,
|
|
117
|
-
ssrInfo.context.state,
|
|
118
|
-
ssrInfo.context.ssr,
|
|
119
|
-
ssrInfo.context.isSpaMode
|
|
120
|
-
);
|
|
121
|
-
let hydrationData = void 0;
|
|
122
|
-
if (ssrInfo.context.isSpaMode) {
|
|
123
|
-
let { loaderData } = ssrInfo.context.state;
|
|
124
|
-
if (ssrInfo.manifest.routes.root?.hasLoader && loaderData && "root" in loaderData) {
|
|
125
|
-
hydrationData = {
|
|
126
|
-
loaderData: {
|
|
127
|
-
root: loaderData.root
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
} else {
|
|
132
|
-
hydrationData = getHydrationData({
|
|
133
|
-
state: ssrInfo.context.state,
|
|
134
|
-
routes,
|
|
135
|
-
getRouteInfo: (routeId) => ({
|
|
136
|
-
clientLoader: ssrInfo.routeModules[routeId]?.clientLoader,
|
|
137
|
-
hasLoader: ssrInfo.manifest.routes[routeId]?.hasLoader === true,
|
|
138
|
-
hasHydrateFallback: ssrInfo.routeModules[routeId]?.HydrateFallback != null
|
|
139
|
-
}),
|
|
140
|
-
location: window.location,
|
|
141
|
-
basename: window.__reactRouterContext?.basename,
|
|
142
|
-
isSpaMode: ssrInfo.context.isSpaMode
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
if (window.history.state && window.history.state.masked) {
|
|
146
|
-
window.history.replaceState(
|
|
147
|
-
{ ...window.history.state, masked: void 0 },
|
|
148
|
-
""
|
|
149
|
-
);
|
|
150
|
-
}
|
|
151
|
-
let router2 = createRouter({
|
|
152
|
-
routes,
|
|
153
|
-
history: createBrowserHistory(),
|
|
154
|
-
basename: ssrInfo.context.basename,
|
|
155
|
-
getContext,
|
|
156
|
-
hydrationData,
|
|
157
|
-
hydrationRouteProperties,
|
|
158
|
-
instrumentations,
|
|
159
|
-
mapRouteProperties,
|
|
160
|
-
future: {
|
|
161
|
-
v8_passThroughRequests: ssrInfo.context.future.v8_passThroughRequests
|
|
162
|
-
},
|
|
163
|
-
dataStrategy: getTurboStreamSingleFetchDataStrategy(
|
|
164
|
-
() => router2,
|
|
165
|
-
ssrInfo.manifest,
|
|
166
|
-
ssrInfo.routeModules,
|
|
167
|
-
ssrInfo.context.ssr,
|
|
168
|
-
ssrInfo.context.basename,
|
|
169
|
-
ssrInfo.context.future.v8_trailingSlashAwareDataRequests
|
|
170
|
-
),
|
|
171
|
-
patchRoutesOnNavigation: getPatchRoutesOnNavigationFunction(
|
|
172
|
-
() => router2,
|
|
173
|
-
ssrInfo.manifest,
|
|
174
|
-
ssrInfo.routeModules,
|
|
175
|
-
ssrInfo.context.ssr,
|
|
176
|
-
ssrInfo.context.routeDiscovery,
|
|
177
|
-
ssrInfo.context.isSpaMode,
|
|
178
|
-
ssrInfo.context.basename
|
|
179
|
-
)
|
|
180
|
-
});
|
|
181
|
-
ssrInfo.router = router2;
|
|
182
|
-
if (router2.state.initialized) {
|
|
183
|
-
ssrInfo.routerInitialized = true;
|
|
184
|
-
router2.initialize();
|
|
185
|
-
}
|
|
186
|
-
router2.createRoutesForHMR = /* spacer so ts-ignore does not affect the right hand of the assignment */
|
|
187
|
-
createClientRoutesWithHMRRevalidationOptOut;
|
|
188
|
-
window.__reactRouterDataRouter = router2;
|
|
189
|
-
return router2;
|
|
190
|
-
}
|
|
191
|
-
function HydratedRouter(props) {
|
|
192
|
-
if (!router) {
|
|
193
|
-
router = createHydratedRouter({
|
|
194
|
-
getContext: props.getContext,
|
|
195
|
-
instrumentations: props.instrumentations
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
let [criticalCss, setCriticalCss] = React2.useState(
|
|
199
|
-
process.env.NODE_ENV === "development" ? ssrInfo?.context.criticalCss : void 0
|
|
200
|
-
);
|
|
201
|
-
React2.useEffect(() => {
|
|
202
|
-
if (process.env.NODE_ENV === "development") {
|
|
203
|
-
setCriticalCss(void 0);
|
|
204
|
-
}
|
|
205
|
-
}, []);
|
|
206
|
-
React2.useEffect(() => {
|
|
207
|
-
if (process.env.NODE_ENV === "development" && criticalCss === void 0) {
|
|
208
|
-
document.querySelectorAll(`[${CRITICAL_CSS_DATA_ATTRIBUTE}]`).forEach((element) => element.remove());
|
|
209
|
-
}
|
|
210
|
-
}, [criticalCss]);
|
|
211
|
-
let [location2, setLocation] = React2.useState(router.state.location);
|
|
212
|
-
React2.useLayoutEffect(() => {
|
|
213
|
-
if (ssrInfo && ssrInfo.router && !ssrInfo.routerInitialized) {
|
|
214
|
-
ssrInfo.routerInitialized = true;
|
|
215
|
-
ssrInfo.router.initialize();
|
|
216
|
-
}
|
|
217
|
-
}, []);
|
|
218
|
-
React2.useLayoutEffect(() => {
|
|
219
|
-
if (ssrInfo && ssrInfo.router) {
|
|
220
|
-
return ssrInfo.router.subscribe((newState) => {
|
|
221
|
-
if (newState.location !== location2) {
|
|
222
|
-
setLocation(newState.location);
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
}, [location2]);
|
|
227
|
-
invariant(ssrInfo, "ssrInfo unavailable for HydratedRouter");
|
|
228
|
-
useFogOFWarDiscovery(
|
|
229
|
-
router,
|
|
230
|
-
ssrInfo.manifest,
|
|
231
|
-
ssrInfo.routeModules,
|
|
232
|
-
ssrInfo.context.ssr,
|
|
233
|
-
ssrInfo.context.routeDiscovery,
|
|
234
|
-
ssrInfo.context.isSpaMode
|
|
235
|
-
);
|
|
236
|
-
return (
|
|
237
|
-
// This fragment is important to ensure we match the <ServerRouter> JSX
|
|
238
|
-
// structure so that useId values hydrate correctly
|
|
239
|
-
/* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(
|
|
240
|
-
FrameworkContext.Provider,
|
|
241
|
-
{
|
|
242
|
-
value: {
|
|
243
|
-
manifest: ssrInfo.manifest,
|
|
244
|
-
routeModules: ssrInfo.routeModules,
|
|
245
|
-
future: ssrInfo.context.future,
|
|
246
|
-
criticalCss,
|
|
247
|
-
ssr: ssrInfo.context.ssr,
|
|
248
|
-
isSpaMode: ssrInfo.context.isSpaMode,
|
|
249
|
-
routeDiscovery: ssrInfo.context.routeDiscovery
|
|
250
|
-
}
|
|
251
|
-
},
|
|
252
|
-
/* @__PURE__ */ React2.createElement(RemixErrorBoundary, { location: location2 }, /* @__PURE__ */ React2.createElement(
|
|
253
|
-
RouterProvider2,
|
|
254
|
-
{
|
|
255
|
-
router,
|
|
256
|
-
useTransitions: props.useTransitions,
|
|
257
|
-
onError: props.onError
|
|
258
|
-
}
|
|
259
|
-
))
|
|
260
|
-
), /* @__PURE__ */ React2.createElement(React2.Fragment, null))
|
|
261
|
-
);
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
// lib/rsc/browser.tsx
|
|
265
|
-
import * as React3 from "react";
|
|
266
|
-
import * as ReactDOM2 from "react-dom";
|
|
267
|
-
var defaultManifestPath = "/__manifest";
|
|
268
|
-
function createCallServer({
|
|
269
|
-
createFromReadableStream,
|
|
270
|
-
createTemporaryReferenceSet,
|
|
271
|
-
encodeReply,
|
|
272
|
-
fetch: fetchImplementation = fetch
|
|
273
|
-
}) {
|
|
274
|
-
const globalVar = window;
|
|
275
|
-
let landedActionId = 0;
|
|
276
|
-
return async (id, args) => {
|
|
277
|
-
let actionId = globalVar.__routerActionID = (globalVar.__routerActionID ?? (globalVar.__routerActionID = 0)) + 1;
|
|
278
|
-
const temporaryReferences = createTemporaryReferenceSet();
|
|
279
|
-
const payloadPromise = fetchImplementation(
|
|
280
|
-
new Request(location.href, {
|
|
281
|
-
body: await encodeReply(args, { temporaryReferences }),
|
|
282
|
-
method: "POST",
|
|
283
|
-
headers: {
|
|
284
|
-
Accept: "text/x-component",
|
|
285
|
-
"rsc-action-id": id
|
|
286
|
-
}
|
|
287
|
-
})
|
|
288
|
-
).then((response) => {
|
|
289
|
-
if (!response.body) {
|
|
290
|
-
throw new Error("No response body");
|
|
291
|
-
}
|
|
292
|
-
return createFromReadableStream(response.body, {
|
|
293
|
-
temporaryReferences
|
|
294
|
-
});
|
|
295
|
-
});
|
|
296
|
-
React3.startTransition(
|
|
297
|
-
() => (
|
|
298
|
-
// @ts-expect-error - Needs React 19 types
|
|
299
|
-
Promise.resolve(payloadPromise).then(async (payload) => {
|
|
300
|
-
if (payload.type === "redirect") {
|
|
301
|
-
let location2 = normalizeRedirectLocation(payload.location);
|
|
302
|
-
if (payload.reload || isExternalLocation(location2)) {
|
|
303
|
-
if (hasInvalidProtocol(location2)) {
|
|
304
|
-
throw new Error("Invalid redirect location");
|
|
305
|
-
}
|
|
306
|
-
window.location.href = location2;
|
|
307
|
-
return;
|
|
308
|
-
}
|
|
309
|
-
React3.startTransition(() => {
|
|
310
|
-
globalVar.__reactRouterDataRouter.navigate(location2, {
|
|
311
|
-
replace: payload.replace
|
|
312
|
-
});
|
|
313
|
-
});
|
|
314
|
-
return;
|
|
315
|
-
}
|
|
316
|
-
if (payload.type !== "action") {
|
|
317
|
-
throw new Error("Unexpected payload type");
|
|
318
|
-
}
|
|
319
|
-
const rerender = await payload.rerender;
|
|
320
|
-
if (rerender && landedActionId < actionId && globalVar.__routerActionID <= actionId) {
|
|
321
|
-
if (rerender.type === "redirect") {
|
|
322
|
-
let location2 = normalizeRedirectLocation(rerender.location);
|
|
323
|
-
if (rerender.reload || isExternalLocation(location2)) {
|
|
324
|
-
if (hasInvalidProtocol(location2)) {
|
|
325
|
-
throw new Error("Invalid redirect location");
|
|
326
|
-
}
|
|
327
|
-
window.location.href = location2;
|
|
328
|
-
return;
|
|
329
|
-
}
|
|
330
|
-
React3.startTransition(() => {
|
|
331
|
-
globalVar.__reactRouterDataRouter.navigate(location2, {
|
|
332
|
-
replace: rerender.replace
|
|
333
|
-
});
|
|
334
|
-
});
|
|
335
|
-
return;
|
|
336
|
-
}
|
|
337
|
-
React3.startTransition(() => {
|
|
338
|
-
let lastMatch;
|
|
339
|
-
for (const match of rerender.matches) {
|
|
340
|
-
globalVar.__reactRouterDataRouter.patchRoutes(
|
|
341
|
-
lastMatch?.id ?? null,
|
|
342
|
-
[createRouteFromServerManifest(match)],
|
|
343
|
-
true
|
|
344
|
-
);
|
|
345
|
-
lastMatch = match;
|
|
346
|
-
}
|
|
347
|
-
window.__reactRouterDataRouter._internalSetStateDoNotUseOrYouWillBreakYourApp(
|
|
348
|
-
{
|
|
349
|
-
loaderData: Object.assign(
|
|
350
|
-
{},
|
|
351
|
-
globalVar.__reactRouterDataRouter.state.loaderData,
|
|
352
|
-
rerender.loaderData
|
|
353
|
-
),
|
|
354
|
-
errors: rerender.errors ? Object.assign(
|
|
355
|
-
{},
|
|
356
|
-
globalVar.__reactRouterDataRouter.state.errors,
|
|
357
|
-
rerender.errors
|
|
358
|
-
) : null
|
|
359
|
-
}
|
|
360
|
-
);
|
|
361
|
-
});
|
|
362
|
-
}
|
|
363
|
-
}).catch(() => {
|
|
364
|
-
})
|
|
365
|
-
)
|
|
366
|
-
);
|
|
367
|
-
return payloadPromise.then((payload) => {
|
|
368
|
-
if (payload.type !== "action" && payload.type !== "redirect") {
|
|
369
|
-
throw new Error("Unexpected payload type");
|
|
370
|
-
}
|
|
371
|
-
return payload.actionResult;
|
|
372
|
-
});
|
|
373
|
-
};
|
|
374
|
-
}
|
|
375
|
-
function createRouterFromPayload({
|
|
376
|
-
fetchImplementation,
|
|
377
|
-
createFromReadableStream,
|
|
378
|
-
getContext,
|
|
379
|
-
payload
|
|
380
|
-
}) {
|
|
381
|
-
const globalVar = window;
|
|
382
|
-
if (globalVar.__reactRouterDataRouter && globalVar.__reactRouterRouteModules)
|
|
383
|
-
return {
|
|
384
|
-
router: globalVar.__reactRouterDataRouter,
|
|
385
|
-
routeModules: globalVar.__reactRouterRouteModules
|
|
386
|
-
};
|
|
387
|
-
if (payload.type !== "render") throw new Error("Invalid payload type");
|
|
388
|
-
globalVar.__reactRouterRouteModules = globalVar.__reactRouterRouteModules ?? {};
|
|
389
|
-
populateRSCRouteModules(globalVar.__reactRouterRouteModules, payload.matches);
|
|
390
|
-
let routes = payload.matches.reduceRight((previous, match) => {
|
|
391
|
-
const route = createRouteFromServerManifest(
|
|
392
|
-
match,
|
|
393
|
-
payload
|
|
394
|
-
);
|
|
395
|
-
if (previous.length > 0) {
|
|
396
|
-
route.children = previous;
|
|
397
|
-
} else if (!route.index) {
|
|
398
|
-
route.children = [];
|
|
399
|
-
}
|
|
400
|
-
return [route];
|
|
401
|
-
}, []);
|
|
402
|
-
let applyPatchesPromise;
|
|
403
|
-
globalVar.__reactRouterDataRouter = createRouter({
|
|
404
|
-
routes,
|
|
405
|
-
getContext,
|
|
406
|
-
basename: payload.basename,
|
|
407
|
-
history: createBrowserHistory(),
|
|
408
|
-
hydrationData: getHydrationData({
|
|
409
|
-
state: {
|
|
410
|
-
loaderData: payload.loaderData,
|
|
411
|
-
actionData: payload.actionData,
|
|
412
|
-
errors: payload.errors
|
|
413
|
-
},
|
|
414
|
-
routes,
|
|
415
|
-
getRouteInfo: (routeId) => {
|
|
416
|
-
let match = payload.matches.find((m) => m.id === routeId);
|
|
417
|
-
invariant(match, "Route not found in payload");
|
|
418
|
-
return {
|
|
419
|
-
clientLoader: match.clientLoader,
|
|
420
|
-
hasLoader: match.hasLoader,
|
|
421
|
-
hasHydrateFallback: match.hydrateFallbackElement != null
|
|
422
|
-
};
|
|
423
|
-
},
|
|
424
|
-
location: payload.location,
|
|
425
|
-
basename: payload.basename,
|
|
426
|
-
isSpaMode: false
|
|
427
|
-
}),
|
|
428
|
-
async patchRoutesOnNavigation({ path, signal }) {
|
|
429
|
-
if (payload.routeDiscovery.mode === "initial") {
|
|
430
|
-
if (!applyPatchesPromise) {
|
|
431
|
-
applyPatchesPromise = (async () => {
|
|
432
|
-
if (!payload.patches) return;
|
|
433
|
-
let patches = await payload.patches;
|
|
434
|
-
React3.startTransition(() => {
|
|
435
|
-
patches.forEach((p) => {
|
|
436
|
-
window.__reactRouterDataRouter.patchRoutes(p.parentId ?? null, [
|
|
437
|
-
createRouteFromServerManifest(p)
|
|
438
|
-
]);
|
|
439
|
-
});
|
|
440
|
-
});
|
|
441
|
-
})();
|
|
442
|
-
}
|
|
443
|
-
await applyPatchesPromise;
|
|
444
|
-
return;
|
|
445
|
-
}
|
|
446
|
-
if (discoveredPaths.has(path)) {
|
|
447
|
-
return;
|
|
448
|
-
}
|
|
449
|
-
await fetchAndApplyManifestPatches(
|
|
450
|
-
[path],
|
|
451
|
-
createFromReadableStream,
|
|
452
|
-
fetchImplementation,
|
|
453
|
-
signal
|
|
454
|
-
);
|
|
455
|
-
},
|
|
456
|
-
// FIXME: Pass `build.ssr` into this function
|
|
457
|
-
dataStrategy: getRSCSingleFetchDataStrategy(
|
|
458
|
-
() => globalVar.__reactRouterDataRouter,
|
|
459
|
-
true,
|
|
460
|
-
payload.basename,
|
|
461
|
-
createFromReadableStream,
|
|
462
|
-
fetchImplementation
|
|
463
|
-
)
|
|
464
|
-
});
|
|
465
|
-
if (globalVar.__reactRouterDataRouter.state.initialized) {
|
|
466
|
-
globalVar.__routerInitialized = true;
|
|
467
|
-
globalVar.__reactRouterDataRouter.initialize();
|
|
468
|
-
} else {
|
|
469
|
-
globalVar.__routerInitialized = false;
|
|
470
|
-
}
|
|
471
|
-
let lastLoaderData = void 0;
|
|
472
|
-
globalVar.__reactRouterDataRouter.subscribe(({ loaderData, actionData }) => {
|
|
473
|
-
if (lastLoaderData !== loaderData) {
|
|
474
|
-
globalVar.__routerActionID = (globalVar.__routerActionID ?? (globalVar.__routerActionID = 0)) + 1;
|
|
475
|
-
}
|
|
476
|
-
});
|
|
477
|
-
globalVar.__reactRouterDataRouter._updateRoutesForHMR = (routeUpdateByRouteId) => {
|
|
478
|
-
const oldRoutes = window.__reactRouterDataRouter.routes;
|
|
479
|
-
const newRoutes = [];
|
|
480
|
-
function walkRoutes(routes2, parentId) {
|
|
481
|
-
return routes2.map((route) => {
|
|
482
|
-
const routeUpdate = routeUpdateByRouteId.get(route.id);
|
|
483
|
-
if (routeUpdate) {
|
|
484
|
-
const {
|
|
485
|
-
routeModule,
|
|
486
|
-
hasAction,
|
|
487
|
-
hasComponent,
|
|
488
|
-
hasErrorBoundary,
|
|
489
|
-
hasLoader
|
|
490
|
-
} = routeUpdate;
|
|
491
|
-
const newRoute = createRouteFromServerManifest({
|
|
492
|
-
clientAction: routeModule.clientAction,
|
|
493
|
-
clientLoader: routeModule.clientLoader,
|
|
494
|
-
element: route.element,
|
|
495
|
-
errorElement: route.errorElement,
|
|
496
|
-
handle: route.handle,
|
|
497
|
-
hasAction,
|
|
498
|
-
hasComponent,
|
|
499
|
-
hasErrorBoundary,
|
|
500
|
-
hasLoader,
|
|
501
|
-
hydrateFallbackElement: route.hydrateFallbackElement,
|
|
502
|
-
id: route.id,
|
|
503
|
-
index: route.index,
|
|
504
|
-
links: routeModule.links,
|
|
505
|
-
meta: routeModule.meta,
|
|
506
|
-
parentId,
|
|
507
|
-
path: route.path,
|
|
508
|
-
shouldRevalidate: routeModule.shouldRevalidate
|
|
509
|
-
});
|
|
510
|
-
if (route.children) {
|
|
511
|
-
newRoute.children = walkRoutes(route.children, route.id);
|
|
512
|
-
}
|
|
513
|
-
return newRoute;
|
|
514
|
-
}
|
|
515
|
-
const updatedRoute = { ...route };
|
|
516
|
-
if (route.children) {
|
|
517
|
-
updatedRoute.children = walkRoutes(route.children, route.id);
|
|
518
|
-
}
|
|
519
|
-
return updatedRoute;
|
|
520
|
-
});
|
|
521
|
-
}
|
|
522
|
-
newRoutes.push(
|
|
523
|
-
...walkRoutes(oldRoutes, void 0)
|
|
524
|
-
);
|
|
525
|
-
window.__reactRouterDataRouter._internalSetRoutes(newRoutes);
|
|
526
|
-
};
|
|
527
|
-
return {
|
|
528
|
-
router: globalVar.__reactRouterDataRouter,
|
|
529
|
-
routeModules: globalVar.__reactRouterRouteModules
|
|
530
|
-
};
|
|
531
|
-
}
|
|
532
|
-
var renderedRoutesContext = createContext();
|
|
533
|
-
function getRSCSingleFetchDataStrategy(getRouter, ssr, basename, createFromReadableStream, fetchImplementation) {
|
|
534
|
-
let dataStrategy = getSingleFetchDataStrategyImpl(
|
|
535
|
-
getRouter,
|
|
536
|
-
(match) => {
|
|
537
|
-
let M = match;
|
|
538
|
-
return {
|
|
539
|
-
hasLoader: M.route.hasLoader,
|
|
540
|
-
hasClientLoader: M.route.hasClientLoader,
|
|
541
|
-
hasComponent: M.route.hasComponent,
|
|
542
|
-
hasAction: M.route.hasAction,
|
|
543
|
-
hasClientAction: M.route.hasClientAction
|
|
544
|
-
};
|
|
545
|
-
},
|
|
546
|
-
// pass map into fetchAndDecode so it can add payloads
|
|
547
|
-
getFetchAndDecodeViaRSC(createFromReadableStream, fetchImplementation),
|
|
548
|
-
ssr,
|
|
549
|
-
basename,
|
|
550
|
-
// .rsc requests are always trailing slash aware
|
|
551
|
-
true,
|
|
552
|
-
// If the route has a component but we don't have an element, we need to hit
|
|
553
|
-
// the server loader flow regardless of whether the client loader calls
|
|
554
|
-
// `serverLoader` or not, otherwise we'll have nothing to render.
|
|
555
|
-
(match) => {
|
|
556
|
-
let M = match;
|
|
557
|
-
return M.route.hasComponent && !M.route.element;
|
|
558
|
-
}
|
|
559
|
-
);
|
|
560
|
-
return async (args) => args.runClientMiddleware(async () => {
|
|
561
|
-
let context = args.context;
|
|
562
|
-
context.set(renderedRoutesContext, []);
|
|
563
|
-
let results = await dataStrategy(args);
|
|
564
|
-
const renderedRoutesById = /* @__PURE__ */ new Map();
|
|
565
|
-
for (const route of context.get(renderedRoutesContext)) {
|
|
566
|
-
if (!renderedRoutesById.has(route.id)) {
|
|
567
|
-
renderedRoutesById.set(route.id, []);
|
|
568
|
-
}
|
|
569
|
-
renderedRoutesById.get(route.id).push(route);
|
|
570
|
-
}
|
|
571
|
-
React3.startTransition(() => {
|
|
572
|
-
for (const match of args.matches) {
|
|
573
|
-
const renderedRoutes = renderedRoutesById.get(match.route.id);
|
|
574
|
-
if (renderedRoutes) {
|
|
575
|
-
for (const rendered of renderedRoutes) {
|
|
576
|
-
window.__reactRouterDataRouter.patchRoutes(
|
|
577
|
-
rendered.parentId ?? null,
|
|
578
|
-
[createRouteFromServerManifest(rendered)],
|
|
579
|
-
true
|
|
580
|
-
);
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
});
|
|
585
|
-
return results;
|
|
586
|
-
});
|
|
587
|
-
}
|
|
588
|
-
function getFetchAndDecodeViaRSC(createFromReadableStream, fetchImplementation) {
|
|
589
|
-
return async (args, basename, trailingSlashAware, targetRoutes) => {
|
|
590
|
-
let { request, context } = args;
|
|
591
|
-
let url = singleFetchUrl(request.url, basename, trailingSlashAware, "rsc");
|
|
592
|
-
if (request.method === "GET") {
|
|
593
|
-
url = stripIndexParam(url);
|
|
594
|
-
if (targetRoutes) {
|
|
595
|
-
url.searchParams.set("_routes", targetRoutes.join(","));
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
let res = await fetchImplementation(
|
|
599
|
-
new Request(url, await createRequestInit(request))
|
|
600
|
-
);
|
|
601
|
-
if (res.status >= 400 && !res.headers.has("X-Remix-Response")) {
|
|
602
|
-
throw new ErrorResponseImpl(res.status, res.statusText, await res.text());
|
|
603
|
-
}
|
|
604
|
-
invariant(res.body, "No response body to decode");
|
|
605
|
-
try {
|
|
606
|
-
const payload = await createFromReadableStream(res.body, {
|
|
607
|
-
temporaryReferences: void 0
|
|
608
|
-
});
|
|
609
|
-
if (payload.type === "redirect") {
|
|
610
|
-
return {
|
|
611
|
-
status: res.status,
|
|
612
|
-
data: {
|
|
613
|
-
redirect: {
|
|
614
|
-
redirect: payload.location,
|
|
615
|
-
reload: payload.reload,
|
|
616
|
-
replace: payload.replace,
|
|
617
|
-
revalidate: false,
|
|
618
|
-
status: payload.status
|
|
619
|
-
}
|
|
620
|
-
}
|
|
621
|
-
};
|
|
622
|
-
}
|
|
623
|
-
if (payload.type !== "render") {
|
|
624
|
-
throw new Error("Unexpected payload type");
|
|
625
|
-
}
|
|
626
|
-
context.get(renderedRoutesContext).push(...payload.matches);
|
|
627
|
-
let results = { routes: {} };
|
|
628
|
-
const dataKey = isMutationMethod(request.method) ? "actionData" : "loaderData";
|
|
629
|
-
for (let [routeId, data] of Object.entries(payload[dataKey] || {})) {
|
|
630
|
-
results.routes[routeId] = { data };
|
|
631
|
-
}
|
|
632
|
-
if (payload.errors) {
|
|
633
|
-
for (let [routeId, error] of Object.entries(payload.errors)) {
|
|
634
|
-
results.routes[routeId] = { error };
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
return { status: res.status, data: results };
|
|
638
|
-
} catch (cause) {
|
|
639
|
-
throw new Error("Unable to decode RSC response", { cause });
|
|
640
|
-
}
|
|
641
|
-
};
|
|
642
|
-
}
|
|
643
|
-
function RSCHydratedRouter({
|
|
644
|
-
createFromReadableStream,
|
|
645
|
-
fetch: fetchImplementation = fetch,
|
|
646
|
-
payload,
|
|
647
|
-
getContext
|
|
648
|
-
}) {
|
|
649
|
-
if (payload.type !== "render") throw new Error("Invalid payload type");
|
|
650
|
-
let { routeDiscovery } = payload;
|
|
651
|
-
let { router: router2, routeModules } = React3.useMemo(
|
|
652
|
-
() => createRouterFromPayload({
|
|
653
|
-
payload,
|
|
654
|
-
fetchImplementation,
|
|
655
|
-
getContext,
|
|
656
|
-
createFromReadableStream
|
|
657
|
-
}),
|
|
658
|
-
[createFromReadableStream, payload, fetchImplementation, getContext]
|
|
659
|
-
);
|
|
660
|
-
React3.useEffect(() => {
|
|
661
|
-
setIsHydrated();
|
|
662
|
-
}, []);
|
|
663
|
-
React3.useLayoutEffect(() => {
|
|
664
|
-
const globalVar = window;
|
|
665
|
-
if (!globalVar.__routerInitialized) {
|
|
666
|
-
globalVar.__routerInitialized = true;
|
|
667
|
-
globalVar.__reactRouterDataRouter.initialize();
|
|
668
|
-
}
|
|
669
|
-
}, []);
|
|
670
|
-
let [{ routes, state }, setState] = React3.useState(() => ({
|
|
671
|
-
routes: cloneRoutes(router2.routes),
|
|
672
|
-
state: router2.state
|
|
673
|
-
}));
|
|
674
|
-
React3.useLayoutEffect(
|
|
675
|
-
() => router2.subscribe((newState) => {
|
|
676
|
-
if (diffRoutes(router2.routes, routes))
|
|
677
|
-
React3.startTransition(() => {
|
|
678
|
-
setState({
|
|
679
|
-
routes: cloneRoutes(router2.routes),
|
|
680
|
-
state: newState
|
|
681
|
-
});
|
|
682
|
-
});
|
|
683
|
-
}),
|
|
684
|
-
[router2.subscribe, routes, router2]
|
|
685
|
-
);
|
|
686
|
-
const transitionEnabledRouter = React3.useMemo(
|
|
687
|
-
() => ({
|
|
688
|
-
...router2,
|
|
689
|
-
state,
|
|
690
|
-
routes
|
|
691
|
-
}),
|
|
692
|
-
[router2, routes, state]
|
|
693
|
-
);
|
|
694
|
-
React3.useEffect(() => {
|
|
695
|
-
if (routeDiscovery.mode === "initial" || // @ts-expect-error - TS doesn't know about this yet
|
|
696
|
-
window.navigator?.connection?.saveData === true) {
|
|
697
|
-
return;
|
|
698
|
-
}
|
|
699
|
-
function registerElement(el) {
|
|
700
|
-
let path = el.tagName === "FORM" ? el.getAttribute("action") : el.getAttribute("href");
|
|
701
|
-
if (!path) {
|
|
702
|
-
return;
|
|
703
|
-
}
|
|
704
|
-
let pathname = el.tagName === "A" ? el.pathname : new URL(path, window.location.origin).pathname;
|
|
705
|
-
if (!discoveredPaths.has(pathname)) {
|
|
706
|
-
nextPaths.add(pathname);
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
async function fetchPatches() {
|
|
710
|
-
document.querySelectorAll("a[data-discover], form[data-discover]").forEach(registerElement);
|
|
711
|
-
let paths = Array.from(nextPaths.keys()).filter((path) => {
|
|
712
|
-
if (discoveredPaths.has(path)) {
|
|
713
|
-
nextPaths.delete(path);
|
|
714
|
-
return false;
|
|
715
|
-
}
|
|
716
|
-
return true;
|
|
717
|
-
});
|
|
718
|
-
if (paths.length === 0) {
|
|
719
|
-
return;
|
|
720
|
-
}
|
|
721
|
-
try {
|
|
722
|
-
await fetchAndApplyManifestPatches(
|
|
723
|
-
paths,
|
|
724
|
-
createFromReadableStream,
|
|
725
|
-
fetchImplementation
|
|
726
|
-
);
|
|
727
|
-
} catch (e) {
|
|
728
|
-
console.error("Failed to fetch manifest patches", e);
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
let debouncedFetchPatches = debounce(fetchPatches, 100);
|
|
732
|
-
fetchPatches();
|
|
733
|
-
let observer = new MutationObserver(() => debouncedFetchPatches());
|
|
734
|
-
observer.observe(document.documentElement, {
|
|
735
|
-
subtree: true,
|
|
736
|
-
childList: true,
|
|
737
|
-
attributes: true,
|
|
738
|
-
attributeFilter: ["data-discover", "href", "action"]
|
|
739
|
-
});
|
|
740
|
-
}, [routeDiscovery, createFromReadableStream, fetchImplementation]);
|
|
741
|
-
const frameworkContext = {
|
|
742
|
-
future: {
|
|
743
|
-
// These flags have no runtime impact so can always be false. If we add
|
|
744
|
-
// flags that drive runtime behavior they'll need to be proxied through.
|
|
745
|
-
v8_middleware: false,
|
|
746
|
-
v8_trailingSlashAwareDataRequests: true,
|
|
747
|
-
// always on for RSC
|
|
748
|
-
v8_passThroughRequests: true
|
|
749
|
-
// always on for RSC
|
|
750
|
-
},
|
|
751
|
-
isSpaMode: false,
|
|
752
|
-
ssr: true,
|
|
753
|
-
criticalCss: "",
|
|
754
|
-
manifest: {
|
|
755
|
-
routes: {},
|
|
756
|
-
version: "1",
|
|
757
|
-
url: "",
|
|
758
|
-
entry: {
|
|
759
|
-
module: "",
|
|
760
|
-
imports: []
|
|
761
|
-
}
|
|
762
|
-
},
|
|
763
|
-
routeDiscovery: payload.routeDiscovery.mode === "initial" ? { mode: "initial", manifestPath: defaultManifestPath } : {
|
|
764
|
-
mode: "lazy",
|
|
765
|
-
manifestPath: payload.routeDiscovery.manifestPath || defaultManifestPath
|
|
766
|
-
},
|
|
767
|
-
routeModules
|
|
768
|
-
};
|
|
769
|
-
return /* @__PURE__ */ React3.createElement(RSCRouterContext.Provider, { value: true }, /* @__PURE__ */ React3.createElement(RSCRouterGlobalErrorBoundary, { location: state.location }, /* @__PURE__ */ React3.createElement(FrameworkContext.Provider, { value: frameworkContext }, /* @__PURE__ */ React3.createElement(
|
|
770
|
-
RouterProvider,
|
|
771
|
-
{
|
|
772
|
-
router: transitionEnabledRouter,
|
|
773
|
-
flushSync: ReactDOM2.flushSync
|
|
774
|
-
}
|
|
775
|
-
))));
|
|
776
|
-
}
|
|
777
|
-
function createRouteFromServerManifest(match, payload) {
|
|
778
|
-
let hasInitialData = payload && match.id in payload.loaderData;
|
|
779
|
-
let initialData = payload?.loaderData[match.id];
|
|
780
|
-
let hasInitialError = payload?.errors && match.id in payload.errors;
|
|
781
|
-
let initialError = payload?.errors?.[match.id];
|
|
782
|
-
let isHydrationRequest = match.clientLoader?.hydrate === true || !match.hasLoader || // If the route has a component but we don't have an element, we need to hit
|
|
783
|
-
// the server loader flow regardless of whether the client loader calls
|
|
784
|
-
// `serverLoader` or not, otherwise we'll have nothing to render.
|
|
785
|
-
match.hasComponent && !match.element;
|
|
786
|
-
invariant(window.__reactRouterRouteModules);
|
|
787
|
-
populateRSCRouteModules(window.__reactRouterRouteModules, match);
|
|
788
|
-
let dataRoute = {
|
|
789
|
-
id: match.id,
|
|
790
|
-
element: match.element,
|
|
791
|
-
errorElement: match.errorElement,
|
|
792
|
-
handle: match.handle,
|
|
793
|
-
hasErrorBoundary: match.hasErrorBoundary,
|
|
794
|
-
hydrateFallbackElement: match.hydrateFallbackElement,
|
|
795
|
-
index: match.index,
|
|
796
|
-
loader: match.clientLoader ? async (args, singleFetch) => {
|
|
797
|
-
let _isHydrationRequest = isHydrationRequest;
|
|
798
|
-
isHydrationRequest = false;
|
|
799
|
-
let result = await match.clientLoader({
|
|
800
|
-
...args,
|
|
801
|
-
serverLoader: () => {
|
|
802
|
-
preventInvalidServerHandlerCall(
|
|
803
|
-
"loader",
|
|
804
|
-
match.id,
|
|
805
|
-
match.hasLoader
|
|
806
|
-
);
|
|
807
|
-
if (_isHydrationRequest) {
|
|
808
|
-
if (hasInitialData) {
|
|
809
|
-
return initialData;
|
|
810
|
-
}
|
|
811
|
-
if (hasInitialError) {
|
|
812
|
-
throw initialError;
|
|
813
|
-
}
|
|
814
|
-
}
|
|
815
|
-
return callSingleFetch(singleFetch);
|
|
816
|
-
}
|
|
817
|
-
});
|
|
818
|
-
return result;
|
|
819
|
-
} : (
|
|
820
|
-
// We always make the call in this RSC world since even if we don't
|
|
821
|
-
// have a `loader` we may need to get the `element` implementation
|
|
822
|
-
(_, singleFetch) => callSingleFetch(singleFetch)
|
|
823
|
-
),
|
|
824
|
-
action: match.clientAction ? (args, singleFetch) => match.clientAction({
|
|
825
|
-
...args,
|
|
826
|
-
serverAction: async () => {
|
|
827
|
-
preventInvalidServerHandlerCall(
|
|
828
|
-
"action",
|
|
829
|
-
match.id,
|
|
830
|
-
match.hasLoader
|
|
831
|
-
);
|
|
832
|
-
return await callSingleFetch(singleFetch);
|
|
833
|
-
}
|
|
834
|
-
}) : match.hasAction ? (_, singleFetch) => callSingleFetch(singleFetch) : () => {
|
|
835
|
-
throw noActionDefinedError("action", match.id);
|
|
836
|
-
},
|
|
837
|
-
path: match.path,
|
|
838
|
-
shouldRevalidate: match.shouldRevalidate,
|
|
839
|
-
// We always have a "loader" in this RSC world since even if we don't
|
|
840
|
-
// have a `loader` we may need to get the `element` implementation
|
|
841
|
-
hasLoader: true,
|
|
842
|
-
hasClientLoader: match.clientLoader != null,
|
|
843
|
-
hasAction: match.hasAction,
|
|
844
|
-
hasClientAction: match.clientAction != null
|
|
845
|
-
};
|
|
846
|
-
if (typeof dataRoute.loader === "function") {
|
|
847
|
-
dataRoute.loader.hydrate = shouldHydrateRouteLoader(
|
|
848
|
-
match.id,
|
|
849
|
-
match.clientLoader,
|
|
850
|
-
match.hasLoader,
|
|
851
|
-
false
|
|
852
|
-
);
|
|
853
|
-
}
|
|
854
|
-
return dataRoute;
|
|
855
|
-
}
|
|
856
|
-
function callSingleFetch(singleFetch) {
|
|
857
|
-
invariant(typeof singleFetch === "function", "Invalid singleFetch parameter");
|
|
858
|
-
return singleFetch();
|
|
859
|
-
}
|
|
860
|
-
function preventInvalidServerHandlerCall(type, routeId, hasHandler) {
|
|
861
|
-
if (!hasHandler) {
|
|
862
|
-
let fn = type === "action" ? "serverAction()" : "serverLoader()";
|
|
863
|
-
let msg = `You are trying to call ${fn} on a route that does not have a server ${type} (routeId: "${routeId}")`;
|
|
864
|
-
console.error(msg);
|
|
865
|
-
throw new ErrorResponseImpl(400, "Bad Request", new Error(msg), true);
|
|
866
|
-
}
|
|
867
|
-
}
|
|
868
|
-
var nextPaths = /* @__PURE__ */ new Set();
|
|
869
|
-
var discoveredPathsMaxSize = 1e3;
|
|
870
|
-
var discoveredPaths = /* @__PURE__ */ new Set();
|
|
871
|
-
function getManifestUrl(paths) {
|
|
872
|
-
if (paths.length === 0) {
|
|
873
|
-
return null;
|
|
874
|
-
}
|
|
875
|
-
if (paths.length === 1) {
|
|
876
|
-
return new URL(`${paths[0]}.manifest`, window.location.origin);
|
|
877
|
-
}
|
|
878
|
-
const globalVar = window;
|
|
879
|
-
let basename = (globalVar.__reactRouterDataRouter.basename ?? "").replace(
|
|
880
|
-
/^\/|\/$/g,
|
|
881
|
-
""
|
|
882
|
-
);
|
|
883
|
-
let url = new URL(`${basename}/.manifest`, window.location.origin);
|
|
884
|
-
url.searchParams.set("paths", paths.sort().join(","));
|
|
885
|
-
return url;
|
|
886
|
-
}
|
|
887
|
-
async function fetchAndApplyManifestPatches(paths, createFromReadableStream, fetchImplementation, signal) {
|
|
888
|
-
paths = getPathsWithAncestors(paths);
|
|
889
|
-
let url = getManifestUrl(paths);
|
|
890
|
-
if (url == null) {
|
|
891
|
-
return;
|
|
892
|
-
}
|
|
893
|
-
if (url.toString().length > URL_LIMIT) {
|
|
894
|
-
nextPaths.clear();
|
|
895
|
-
return;
|
|
896
|
-
}
|
|
897
|
-
let response = await fetchImplementation(new Request(url, { signal }));
|
|
898
|
-
if (!response.body || response.status < 200 || response.status >= 300) {
|
|
899
|
-
throw new Error("Unable to fetch new route matches from the server");
|
|
900
|
-
}
|
|
901
|
-
let payload = await createFromReadableStream(response.body, {
|
|
902
|
-
temporaryReferences: void 0
|
|
903
|
-
});
|
|
904
|
-
if (payload.type !== "manifest") {
|
|
905
|
-
throw new Error("Failed to patch routes");
|
|
906
|
-
}
|
|
907
|
-
paths.forEach((p) => addToFifoQueue(p, discoveredPaths));
|
|
908
|
-
let patches = await payload.patches;
|
|
909
|
-
React3.startTransition(() => {
|
|
910
|
-
patches.forEach((p) => {
|
|
911
|
-
window.__reactRouterDataRouter.patchRoutes(
|
|
912
|
-
p.parentId ?? null,
|
|
913
|
-
[createRouteFromServerManifest(p)]
|
|
914
|
-
);
|
|
915
|
-
});
|
|
916
|
-
});
|
|
917
|
-
}
|
|
918
|
-
function addToFifoQueue(path, queue) {
|
|
919
|
-
if (queue.size >= discoveredPathsMaxSize) {
|
|
920
|
-
let first = queue.values().next().value;
|
|
921
|
-
if (typeof first === "string") queue.delete(first);
|
|
922
|
-
}
|
|
923
|
-
queue.add(path);
|
|
924
|
-
}
|
|
925
|
-
function debounce(callback, wait) {
|
|
926
|
-
let timeoutId;
|
|
927
|
-
return (...args) => {
|
|
928
|
-
window.clearTimeout(timeoutId);
|
|
929
|
-
timeoutId = window.setTimeout(() => callback(...args), wait);
|
|
930
|
-
};
|
|
931
|
-
}
|
|
932
|
-
function isExternalLocation(location2) {
|
|
933
|
-
const newLocation = new URL(location2, window.location.href);
|
|
934
|
-
return newLocation.origin !== window.location.origin;
|
|
935
|
-
}
|
|
936
|
-
function normalizeRedirectLocation(location2) {
|
|
937
|
-
if (PROTOCOL_RELATIVE_URL_REGEX.test(location2)) {
|
|
938
|
-
let path = resolvePath(location2);
|
|
939
|
-
return path.pathname + path.search + path.hash;
|
|
940
|
-
}
|
|
941
|
-
return location2;
|
|
942
|
-
}
|
|
943
|
-
function cloneRoutes(routes) {
|
|
944
|
-
if (!routes) return void 0;
|
|
945
|
-
return routes.map((route) => ({
|
|
946
|
-
...route,
|
|
947
|
-
children: cloneRoutes(route.children)
|
|
948
|
-
}));
|
|
949
|
-
}
|
|
950
|
-
function diffRoutes(a, b) {
|
|
951
|
-
if (a.length !== b.length) return true;
|
|
952
|
-
return a.some((route, index) => {
|
|
953
|
-
if (route.element !== b[index].element) return true;
|
|
954
|
-
if (route.errorElement !== b[index].errorElement)
|
|
955
|
-
return true;
|
|
956
|
-
if (route.hydrateFallbackElement !== b[index].hydrateFallbackElement)
|
|
957
|
-
return true;
|
|
958
|
-
if (route.hasErrorBoundary !== b[index].hasErrorBoundary)
|
|
959
|
-
return true;
|
|
960
|
-
if (route.hasLoader !== b[index].hasLoader) return true;
|
|
961
|
-
if (route.hasClientLoader !== b[index].hasClientLoader)
|
|
962
|
-
return true;
|
|
963
|
-
if (route.hasAction !== b[index].hasAction) return true;
|
|
964
|
-
if (route.hasClientAction !== b[index].hasClientAction)
|
|
965
|
-
return true;
|
|
966
|
-
return diffRoutes(route.children || [], b[index].children || []);
|
|
967
|
-
});
|
|
968
|
-
}
|
|
969
|
-
|
|
970
|
-
// lib/rsc/html-stream/browser.ts
|
|
971
|
-
function getRSCStream() {
|
|
972
|
-
let encoder = new TextEncoder();
|
|
973
|
-
let streamController = null;
|
|
974
|
-
let rscStream = new ReadableStream({
|
|
975
|
-
start(controller) {
|
|
976
|
-
if (typeof window === "undefined") {
|
|
977
|
-
return;
|
|
978
|
-
}
|
|
979
|
-
let handleChunk = (chunk) => {
|
|
980
|
-
if (typeof chunk === "string") {
|
|
981
|
-
controller.enqueue(encoder.encode(chunk));
|
|
982
|
-
} else {
|
|
983
|
-
controller.enqueue(chunk);
|
|
984
|
-
}
|
|
985
|
-
};
|
|
986
|
-
window.__FLIGHT_DATA || (window.__FLIGHT_DATA = []);
|
|
987
|
-
window.__FLIGHT_DATA.forEach(handleChunk);
|
|
988
|
-
window.__FLIGHT_DATA.push = (chunk) => {
|
|
989
|
-
handleChunk(chunk);
|
|
990
|
-
return 0;
|
|
991
|
-
};
|
|
992
|
-
streamController = controller;
|
|
993
|
-
}
|
|
994
|
-
});
|
|
995
|
-
if (typeof document !== "undefined" && document.readyState === "loading") {
|
|
996
|
-
document.addEventListener("DOMContentLoaded", () => {
|
|
997
|
-
streamController?.close();
|
|
998
|
-
});
|
|
999
|
-
} else {
|
|
1000
|
-
streamController?.close();
|
|
1001
|
-
}
|
|
1002
|
-
return rscStream;
|
|
1003
|
-
}
|
|
1004
|
-
export {
|
|
1005
|
-
HydratedRouter,
|
|
1006
|
-
RouterProvider2 as RouterProvider,
|
|
1007
|
-
RSCHydratedRouter as unstable_RSCHydratedRouter,
|
|
1008
|
-
createCallServer as unstable_createCallServer,
|
|
1009
|
-
getRSCStream as unstable_getRSCStream
|
|
1010
|
-
};
|