react-router 0.0.0-experimental-3f68c7c20 → 0.0.0-experimental-e87ed2fd4
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/{browser-BenyQgT4.d.mts → browser-C9OqCpRB.d.mts} +537 -136
- package/dist/development/{chunk-APN7PBP2.mjs → chunk-PVJCBITV.mjs} +65 -53
- package/dist/development/dom-export.d.mts +2 -2
- package/dist/development/dom-export.js +1 -1
- package/dist/development/dom-export.mjs +2 -2
- package/dist/development/index.d.mts +10 -390
- package/dist/development/index.d.ts +729 -708
- package/dist/development/index.js +68 -53
- package/dist/development/index.mjs +9 -3
- package/dist/development/lib/types/internal.d.mts +1 -1
- package/dist/development/lib/types/internal.d.ts +1 -1
- package/dist/development/lib/types/internal.js +1 -1
- package/dist/development/lib/types/internal.mjs +1 -1
- package/dist/{production/register-D3Ithcl4.d.ts → development/register-zy84znbA.d.ts} +1 -1
- package/dist/{production/route-data-CBHO1x2o.d.mts → development/route-data-C-cmsWVs.d.mts} +1 -1
- package/dist/development/rsc-export.d.mts +12 -1
- package/dist/development/rsc-export.d.ts +12 -1
- package/dist/development/rsc-export.js +209 -173
- package/dist/development/rsc-export.mjs +209 -174
- package/dist/production/{browser-BenyQgT4.d.mts → browser-C9OqCpRB.d.mts} +537 -136
- package/dist/production/{chunk-SAZGQ73S.mjs → chunk-FJS6IVQF.mjs} +65 -53
- package/dist/production/dom-export.d.mts +2 -2
- package/dist/production/dom-export.js +1 -1
- package/dist/production/dom-export.mjs +2 -2
- package/dist/production/index.d.mts +10 -390
- package/dist/production/index.d.ts +729 -708
- package/dist/production/index.js +68 -53
- package/dist/production/index.mjs +9 -3
- package/dist/production/lib/types/internal.d.mts +1 -1
- package/dist/production/lib/types/internal.d.ts +1 -1
- package/dist/production/lib/types/internal.js +1 -1
- package/dist/production/lib/types/internal.mjs +1 -1
- package/dist/{development/register-D3Ithcl4.d.ts → production/register-zy84znbA.d.ts} +1 -1
- package/dist/{development/route-data-CBHO1x2o.d.mts → production/route-data-C-cmsWVs.d.mts} +1 -1
- package/dist/production/rsc-export.d.mts +12 -1
- package/dist/production/rsc-export.d.ts +12 -1
- package/dist/production/rsc-export.js +209 -173
- package/dist/production/rsc-export.mjs +209 -174
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import { splitCookiesString } from 'set-cookie-parser';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* react-router v0.0.0-experimental-
|
|
6
|
+
* react-router v0.0.0-experimental-e87ed2fd4
|
|
7
7
|
*
|
|
8
8
|
* Copyright (c) Remix Software Inc.
|
|
9
9
|
*
|
|
@@ -84,6 +84,9 @@ function parsePath(path) {
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
// lib/router/utils.ts
|
|
87
|
+
function unstable_createContext(defaultValue) {
|
|
88
|
+
return { defaultValue };
|
|
89
|
+
}
|
|
87
90
|
var _map;
|
|
88
91
|
var unstable_RouterContextProvider = class {
|
|
89
92
|
constructor(init) {
|
|
@@ -2346,7 +2349,19 @@ function createMemorySessionStorage({ cookie } = {}) {
|
|
|
2346
2349
|
}
|
|
2347
2350
|
});
|
|
2348
2351
|
}
|
|
2349
|
-
|
|
2352
|
+
|
|
2353
|
+
// lib/server-runtime/invariant.ts
|
|
2354
|
+
function invariant2(value, message) {
|
|
2355
|
+
if (value === false || value === null || typeof value === "undefined") {
|
|
2356
|
+
console.error(
|
|
2357
|
+
"The following error is a bug in React Router; please open an issue! https://github.com/remix-run/react-router/issues/new/choose"
|
|
2358
|
+
);
|
|
2359
|
+
throw new Error(message);
|
|
2360
|
+
}
|
|
2361
|
+
}
|
|
2362
|
+
|
|
2363
|
+
// lib/server-runtime/headers.ts
|
|
2364
|
+
function getDocumentHeadersImpl(context, getRouteHeadersFn) {
|
|
2350
2365
|
let boundaryIdx = context.errors ? context.matches.findIndex((m) => context.errors[m.route.id]) : -1;
|
|
2351
2366
|
let matches = boundaryIdx >= 0 ? context.matches.slice(0, boundaryIdx + 1) : context.matches;
|
|
2352
2367
|
let errorHeaders;
|
|
@@ -2408,16 +2423,6 @@ function prependCookies(parentHeaders, childHeaders) {
|
|
|
2408
2423
|
}
|
|
2409
2424
|
}
|
|
2410
2425
|
|
|
2411
|
-
// lib/server-runtime/invariant.ts
|
|
2412
|
-
function invariant2(value, message) {
|
|
2413
|
-
if (value === false || value === null || typeof value === "undefined") {
|
|
2414
|
-
console.error(
|
|
2415
|
-
"The following error is a bug in React Router; please open an issue! https://github.com/remix-run/react-router/issues/new/choose"
|
|
2416
|
-
);
|
|
2417
|
-
throw new Error(message);
|
|
2418
|
-
}
|
|
2419
|
-
}
|
|
2420
|
-
|
|
2421
2426
|
// lib/rsc/server.rsc.ts
|
|
2422
2427
|
async function matchRSCServerRequest({
|
|
2423
2428
|
decodeCallServer,
|
|
@@ -2436,7 +2441,7 @@ async function matchRSCServerRequest({
|
|
|
2436
2441
|
);
|
|
2437
2442
|
return response2;
|
|
2438
2443
|
}
|
|
2439
|
-
let response = await
|
|
2444
|
+
let response = await generateRenderResponse(
|
|
2440
2445
|
request,
|
|
2441
2446
|
routes,
|
|
2442
2447
|
decodeCallServer,
|
|
@@ -2449,24 +2454,27 @@ async function matchRSCServerRequest({
|
|
|
2449
2454
|
}
|
|
2450
2455
|
async function generateManifestResponse(routes, request, generateResponse) {
|
|
2451
2456
|
let url = new URL(request.url);
|
|
2452
|
-
|
|
2457
|
+
let matches = matchRoutes(routes, url.pathname.replace(/\.manifest$/, ""));
|
|
2458
|
+
let payload = {
|
|
2459
|
+
type: "manifest",
|
|
2460
|
+
matches: await Promise.all(
|
|
2461
|
+
matches?.map(
|
|
2462
|
+
(m, i) => getManifestRoute(m.route, matches[i - 1]?.route.id)
|
|
2463
|
+
) ?? []
|
|
2464
|
+
),
|
|
2465
|
+
patches: await getAdditionalRoutePatches(
|
|
2466
|
+
url.pathname,
|
|
2467
|
+
routes,
|
|
2468
|
+
matches?.map((m) => m.route.id) ?? []
|
|
2469
|
+
)
|
|
2470
|
+
};
|
|
2453
2471
|
return generateResponse({
|
|
2454
2472
|
statusCode: 200,
|
|
2455
2473
|
headers: new Headers({
|
|
2456
2474
|
"Content-Type": "text/x-component",
|
|
2457
2475
|
Vary: "Content-Type"
|
|
2458
2476
|
}),
|
|
2459
|
-
payload
|
|
2460
|
-
type: "manifest",
|
|
2461
|
-
matches: await Promise.all(
|
|
2462
|
-
matches?.map((m, i) => getRoute(m.route, matches[i - 1]?.route.id)) ?? []
|
|
2463
|
-
),
|
|
2464
|
-
patches: await getAdditionalRoutePatches(
|
|
2465
|
-
url.pathname,
|
|
2466
|
-
routes,
|
|
2467
|
-
matches?.map((m) => m.route.id) ?? []
|
|
2468
|
-
)
|
|
2469
|
-
}
|
|
2477
|
+
payload
|
|
2470
2478
|
});
|
|
2471
2479
|
}
|
|
2472
2480
|
async function processServerAction(request, decodeCallServer, decodeFormAction, onError) {
|
|
@@ -2515,7 +2523,7 @@ async function processServerAction(request, decodeCallServer, decodeFormAction,
|
|
|
2515
2523
|
}
|
|
2516
2524
|
}
|
|
2517
2525
|
}
|
|
2518
|
-
async function
|
|
2526
|
+
async function generateRenderResponse(request, routes, decodeCallServer, decodeFormAction, onError, generateResponse) {
|
|
2519
2527
|
let statusCode = 200;
|
|
2520
2528
|
let url = new URL(request.url);
|
|
2521
2529
|
let isDataRequest = request.headers.has("X-React-Router-Data-Request");
|
|
@@ -2526,22 +2534,12 @@ async function getRenderPayload(request, routes, decodeCallServer, decodeFormAct
|
|
|
2526
2534
|
await Promise.all(matches.map((m) => explodeLazyRoute(m.route)));
|
|
2527
2535
|
}
|
|
2528
2536
|
const handler = createStaticHandler(routes);
|
|
2529
|
-
const respond = (staticContext, actionResult2) => generateStaticContextResponse(
|
|
2530
|
-
routes,
|
|
2531
|
-
generateResponse,
|
|
2532
|
-
statusCode,
|
|
2533
|
-
routeIdsToLoad,
|
|
2534
|
-
isDataRequest,
|
|
2535
|
-
isSubmission,
|
|
2536
|
-
actionResult2,
|
|
2537
|
-
staticContext
|
|
2538
|
-
);
|
|
2539
2537
|
const result = await handler.query(request, {
|
|
2540
2538
|
skipLoaderErrorBubbling: isDataRequest,
|
|
2541
2539
|
skipRevalidation: isSubmission,
|
|
2542
2540
|
...routeIdsToLoad ? { filterMatchesToLoad: (m) => routeIdsToLoad.includes(m.route.id) } : null,
|
|
2543
|
-
async unstable_stream(
|
|
2544
|
-
let
|
|
2541
|
+
async unstable_stream(_, query) {
|
|
2542
|
+
let actionResult;
|
|
2545
2543
|
if (request.method === "POST") {
|
|
2546
2544
|
let result2 = await processServerAction(
|
|
2547
2545
|
request,
|
|
@@ -2549,7 +2547,7 @@ async function getRenderPayload(request, routes, decodeCallServer, decodeFormAct
|
|
|
2549
2547
|
decodeFormAction,
|
|
2550
2548
|
onError
|
|
2551
2549
|
);
|
|
2552
|
-
|
|
2550
|
+
actionResult = result2?.actionResult;
|
|
2553
2551
|
request = result2?.revalidationRequest ?? request;
|
|
2554
2552
|
}
|
|
2555
2553
|
let staticContext = await query(request);
|
|
@@ -2560,7 +2558,16 @@ async function getRenderPayload(request, routes, decodeCallServer, decodeFormAct
|
|
|
2560
2558
|
generateResponse
|
|
2561
2559
|
);
|
|
2562
2560
|
}
|
|
2563
|
-
return
|
|
2561
|
+
return generateStaticContextResponse(
|
|
2562
|
+
routes,
|
|
2563
|
+
generateResponse,
|
|
2564
|
+
statusCode,
|
|
2565
|
+
routeIdsToLoad,
|
|
2566
|
+
isDataRequest,
|
|
2567
|
+
isSubmission,
|
|
2568
|
+
actionResult,
|
|
2569
|
+
staticContext
|
|
2570
|
+
);
|
|
2564
2571
|
}
|
|
2565
2572
|
});
|
|
2566
2573
|
if (isRedirectResponse(result)) {
|
|
@@ -2570,169 +2577,197 @@ async function getRenderPayload(request, routes, decodeCallServer, decodeFormAct
|
|
|
2570
2577
|
return result;
|
|
2571
2578
|
}
|
|
2572
2579
|
function generateRedirectResponse(statusCode, response, generateResponse) {
|
|
2580
|
+
let payload = {
|
|
2581
|
+
type: "redirect",
|
|
2582
|
+
location: response.headers.get("Location") || "",
|
|
2583
|
+
reload: response.headers.get("X-Remix-Reload-Document") === "true",
|
|
2584
|
+
replace: response.headers.get("X-Remix-Replace") === "true",
|
|
2585
|
+
status: response.status
|
|
2586
|
+
};
|
|
2573
2587
|
return generateResponse({
|
|
2574
2588
|
statusCode,
|
|
2575
2589
|
headers: new Headers({
|
|
2576
2590
|
"Content-Type": "text/x-component",
|
|
2577
2591
|
Vary: "Content-Type"
|
|
2578
2592
|
}),
|
|
2579
|
-
payload
|
|
2580
|
-
type: "redirect",
|
|
2581
|
-
location: response.headers.get("Location") || "",
|
|
2582
|
-
reload: response.headers.get("X-Remix-Reload-Document") === "true",
|
|
2583
|
-
replace: response.headers.get("X-Remix-Replace") === "true",
|
|
2584
|
-
status: response.status
|
|
2585
|
-
}
|
|
2593
|
+
payload
|
|
2586
2594
|
});
|
|
2587
2595
|
}
|
|
2588
2596
|
async function generateStaticContextResponse(routes, generateResponse, statusCode, routeIdsToLoad, isDataRequest, isSubmission, actionResult, staticContext) {
|
|
2589
2597
|
statusCode = staticContext.statusCode ?? statusCode;
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
key,
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2598
|
+
if (staticContext.errors) {
|
|
2599
|
+
staticContext.errors = Object.fromEntries(
|
|
2600
|
+
Object.entries(staticContext.errors).map(([key, error]) => [
|
|
2601
|
+
key,
|
|
2602
|
+
isRouteErrorResponse(error) ? Object.fromEntries(Object.entries(error)) : error
|
|
2603
|
+
])
|
|
2604
|
+
);
|
|
2605
|
+
}
|
|
2596
2606
|
staticContext.matches.forEach((m) => {
|
|
2597
2607
|
if (staticContext.loaderData[m.route.id] === void 0) {
|
|
2598
2608
|
staticContext.loaderData[m.route.id] = null;
|
|
2599
2609
|
}
|
|
2600
2610
|
});
|
|
2601
|
-
let headers =
|
|
2611
|
+
let headers = getDocumentHeadersImpl(
|
|
2602
2612
|
staticContext,
|
|
2603
2613
|
(match) => match.route.headers
|
|
2604
2614
|
);
|
|
2605
|
-
const
|
|
2615
|
+
const baseRenderPayload = {
|
|
2606
2616
|
type: "render",
|
|
2607
2617
|
actionData: staticContext.actionData,
|
|
2608
|
-
errors,
|
|
2618
|
+
errors: staticContext.errors,
|
|
2609
2619
|
loaderData: staticContext.loaderData,
|
|
2610
2620
|
location: staticContext.location
|
|
2611
2621
|
};
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
+
const renderPayloadPromise = () => getRenderPayload(
|
|
2623
|
+
baseRenderPayload,
|
|
2624
|
+
routes,
|
|
2625
|
+
routeIdsToLoad,
|
|
2626
|
+
isDataRequest,
|
|
2627
|
+
staticContext
|
|
2628
|
+
);
|
|
2629
|
+
let payload;
|
|
2630
|
+
if (actionResult) {
|
|
2631
|
+
payload = {
|
|
2632
|
+
type: "action",
|
|
2633
|
+
actionResult,
|
|
2634
|
+
rerender: renderPayloadPromise()
|
|
2635
|
+
};
|
|
2636
|
+
} else if (isSubmission && isDataRequest) {
|
|
2637
|
+
payload = {
|
|
2638
|
+
...baseRenderPayload,
|
|
2639
|
+
matches: [],
|
|
2640
|
+
patches: []
|
|
2641
|
+
};
|
|
2642
|
+
} else {
|
|
2643
|
+
payload = await renderPayloadPromise();
|
|
2622
2644
|
}
|
|
2623
|
-
|
|
2645
|
+
return generateResponse({
|
|
2646
|
+
statusCode,
|
|
2647
|
+
headers,
|
|
2648
|
+
payload
|
|
2649
|
+
});
|
|
2650
|
+
}
|
|
2651
|
+
async function getRenderPayload(baseRenderPayload, routes, routeIdsToLoad, isDataRequest, staticContext) {
|
|
2652
|
+
let deepestRenderedRouteIdx = staticContext.matches.length - 1;
|
|
2653
|
+
let parentIds = {};
|
|
2654
|
+
staticContext.matches.forEach((m, i) => {
|
|
2655
|
+
if (i > 0) {
|
|
2656
|
+
parentIds[m.route.id] = staticContext.matches[i - 1].route.id;
|
|
2657
|
+
}
|
|
2658
|
+
if (staticContext.errors && m.route.id in staticContext.errors && deepestRenderedRouteIdx > i) {
|
|
2659
|
+
deepestRenderedRouteIdx = i;
|
|
2660
|
+
}
|
|
2661
|
+
});
|
|
2624
2662
|
let matchesPromise = Promise.all(
|
|
2625
|
-
staticContext.matches.map(
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
});
|
|
2634
|
-
match.route.lazy = void 0;
|
|
2635
|
-
}
|
|
2636
|
-
const Layout = match.route.Layout || React.Fragment;
|
|
2637
|
-
const Component = match.route.default;
|
|
2638
|
-
const ErrorBoundary = match.route.ErrorBoundary;
|
|
2639
|
-
const HydrateFallback = match.route.HydrateFallback;
|
|
2640
|
-
const loaderData = staticContext.loaderData[match.route.id];
|
|
2641
|
-
const actionData = staticContext.actionData?.[match.route.id];
|
|
2642
|
-
const params = match.params;
|
|
2643
|
-
const element = Component ? staticContext.errors?.[match.route.id] ? false : React.createElement(
|
|
2644
|
-
Layout,
|
|
2645
|
-
null,
|
|
2646
|
-
React.createElement(Component, {
|
|
2647
|
-
loaderData,
|
|
2648
|
-
actionData,
|
|
2649
|
-
params,
|
|
2650
|
-
matches: staticContext.matches.map(
|
|
2651
|
-
(match2) => convertRouteMatchToUiMatch(match2, staticContext.loaderData)
|
|
2652
|
-
)
|
|
2653
|
-
})
|
|
2654
|
-
) : void 0;
|
|
2655
|
-
const errorElement = ErrorBoundary ? React.createElement(
|
|
2656
|
-
Layout,
|
|
2657
|
-
null,
|
|
2658
|
-
React.createElement(ErrorBoundary, {
|
|
2659
|
-
loaderData,
|
|
2660
|
-
actionData,
|
|
2661
|
-
params,
|
|
2662
|
-
error: [...staticContext.matches].reverse().find((match2) => staticContext.errors?.[match2.route.id])
|
|
2663
|
-
})
|
|
2664
|
-
) : void 0;
|
|
2665
|
-
const hydrateFallbackElement = HydrateFallback ? React.createElement(
|
|
2666
|
-
Layout,
|
|
2667
|
-
null,
|
|
2668
|
-
React.createElement(HydrateFallback, {
|
|
2669
|
-
loaderData,
|
|
2670
|
-
actionData,
|
|
2671
|
-
params
|
|
2672
|
-
})
|
|
2673
|
-
) : match.route.id === "root" ? (
|
|
2674
|
-
// FIXME: This should use the `RemixRootDefaultErrorBoundary` but that
|
|
2675
|
-
// currently uses a hook internally so it fails during RSC. Restructure
|
|
2676
|
-
// so it can be used safely in an RSC render pass.
|
|
2677
|
-
React.createElement("p", null, "Loading!")
|
|
2678
|
-
) : void 0;
|
|
2679
|
-
let result = {
|
|
2680
|
-
clientAction: match.route.clientAction,
|
|
2681
|
-
clientLoader: match.route.clientLoader,
|
|
2682
|
-
element,
|
|
2683
|
-
errorElement,
|
|
2684
|
-
handle: match.route.handle,
|
|
2685
|
-
hasAction: !!match.route.action,
|
|
2686
|
-
hasErrorBoundary: !!match.route.ErrorBoundary,
|
|
2687
|
-
hasLoader: !!match.route.loader,
|
|
2688
|
-
hydrateFallbackElement,
|
|
2689
|
-
id: match.route.id,
|
|
2690
|
-
index: match.route.index,
|
|
2691
|
-
links: match.route.links,
|
|
2692
|
-
meta: match.route.meta,
|
|
2693
|
-
params,
|
|
2694
|
-
parentId: lastMatch?.route.id,
|
|
2695
|
-
path: match.route.path,
|
|
2696
|
-
pathname: match.pathname,
|
|
2697
|
-
pathnameBase: match.pathnameBase,
|
|
2698
|
-
shouldRevalidate: match.route.shouldRevalidate
|
|
2699
|
-
};
|
|
2700
|
-
lastMatch = match;
|
|
2701
|
-
return result;
|
|
2663
|
+
staticContext.matches.map((match, i) => {
|
|
2664
|
+
let shouldRenderComponent = i <= deepestRenderedRouteIdx && (!routeIdsToLoad || routeIdsToLoad.includes(match.route.id)) && (!staticContext.errors || !(match.route.id in staticContext.errors));
|
|
2665
|
+
return getServerRouteMatch(
|
|
2666
|
+
staticContext,
|
|
2667
|
+
match,
|
|
2668
|
+
shouldRenderComponent,
|
|
2669
|
+
parentIds[match.route.id]
|
|
2670
|
+
);
|
|
2702
2671
|
})
|
|
2703
2672
|
);
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
};
|
|
2673
|
+
let patchesPromise = !isDataRequest ? getAdditionalRoutePatches(
|
|
2674
|
+
staticContext.location.pathname,
|
|
2675
|
+
routes,
|
|
2676
|
+
staticContext.matches.map((m) => m.route.id)
|
|
2677
|
+
) : void 0;
|
|
2678
|
+
let [matches, patches] = await Promise.all([matchesPromise, patchesPromise]);
|
|
2679
|
+
return {
|
|
2680
|
+
...baseRenderPayload,
|
|
2681
|
+
matches,
|
|
2682
|
+
patches
|
|
2715
2683
|
};
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
});
|
|
2726
|
-
} else {
|
|
2727
|
-
let payload2 = await getPayload();
|
|
2728
|
-
return generateResponse({
|
|
2729
|
-
statusCode,
|
|
2730
|
-
headers,
|
|
2731
|
-
payload: payload2
|
|
2684
|
+
}
|
|
2685
|
+
async function getServerRouteMatch(staticContext, match, shouldRenderComponent, parentId) {
|
|
2686
|
+
if ("lazy" in match.route && match.route.lazy) {
|
|
2687
|
+
Object.assign(match.route, {
|
|
2688
|
+
// @ts-expect-error - FIXME: Fix the types here
|
|
2689
|
+
...await match.route.lazy(),
|
|
2690
|
+
path: match.route.path,
|
|
2691
|
+
index: match.route.index,
|
|
2692
|
+
id: match.route.id
|
|
2732
2693
|
});
|
|
2694
|
+
match.route.lazy = void 0;
|
|
2695
|
+
}
|
|
2696
|
+
const Layout = match.route.Layout || React.Fragment;
|
|
2697
|
+
const Component = match.route.default;
|
|
2698
|
+
const ErrorBoundary = match.route.ErrorBoundary;
|
|
2699
|
+
const HydrateFallback = match.route.HydrateFallback;
|
|
2700
|
+
const loaderData = staticContext.loaderData[match.route.id];
|
|
2701
|
+
const actionData = staticContext.actionData?.[match.route.id];
|
|
2702
|
+
const params = match.params;
|
|
2703
|
+
const element = Component && shouldRenderComponent ? React.createElement(
|
|
2704
|
+
Layout,
|
|
2705
|
+
null,
|
|
2706
|
+
React.createElement(Component, {
|
|
2707
|
+
loaderData,
|
|
2708
|
+
actionData,
|
|
2709
|
+
params,
|
|
2710
|
+
matches: staticContext.matches.map(
|
|
2711
|
+
(match2) => convertRouteMatchToUiMatch(match2, staticContext.loaderData)
|
|
2712
|
+
)
|
|
2713
|
+
})
|
|
2714
|
+
) : void 0;
|
|
2715
|
+
let error = void 0;
|
|
2716
|
+
if (ErrorBoundary && staticContext.errors) {
|
|
2717
|
+
for (const match2 of [...staticContext.matches].reverse()) {
|
|
2718
|
+
if (match2.route.id in staticContext.errors) {
|
|
2719
|
+
error = staticContext.errors[match2.route.id];
|
|
2720
|
+
break;
|
|
2721
|
+
}
|
|
2722
|
+
}
|
|
2733
2723
|
}
|
|
2724
|
+
const errorElement = ErrorBoundary ? React.createElement(
|
|
2725
|
+
Layout,
|
|
2726
|
+
null,
|
|
2727
|
+
React.createElement(ErrorBoundary, {
|
|
2728
|
+
loaderData,
|
|
2729
|
+
actionData,
|
|
2730
|
+
params,
|
|
2731
|
+
error
|
|
2732
|
+
})
|
|
2733
|
+
) : void 0;
|
|
2734
|
+
const hydrateFallbackElement = HydrateFallback ? React.createElement(
|
|
2735
|
+
Layout,
|
|
2736
|
+
null,
|
|
2737
|
+
React.createElement(HydrateFallback, {
|
|
2738
|
+
loaderData,
|
|
2739
|
+
actionData,
|
|
2740
|
+
params
|
|
2741
|
+
})
|
|
2742
|
+
) : match.route.id === "root" ? (
|
|
2743
|
+
// FIXME: This should use the `RemixRootDefaultErrorBoundary` but that
|
|
2744
|
+
// currently uses a hook internally so it fails during RSC. Restructure
|
|
2745
|
+
// so it can be used safely in an RSC render pass.
|
|
2746
|
+
React.createElement("p", null, "Loading!")
|
|
2747
|
+
) : void 0;
|
|
2748
|
+
return {
|
|
2749
|
+
clientAction: match.route.clientAction,
|
|
2750
|
+
clientLoader: match.route.clientLoader,
|
|
2751
|
+
element,
|
|
2752
|
+
errorElement,
|
|
2753
|
+
handle: match.route.handle,
|
|
2754
|
+
hasAction: !!match.route.action,
|
|
2755
|
+
hasErrorBoundary: !!match.route.ErrorBoundary,
|
|
2756
|
+
hasLoader: !!match.route.loader,
|
|
2757
|
+
hydrateFallbackElement,
|
|
2758
|
+
id: match.route.id,
|
|
2759
|
+
index: match.route.index,
|
|
2760
|
+
links: match.route.links,
|
|
2761
|
+
meta: match.route.meta,
|
|
2762
|
+
params,
|
|
2763
|
+
parentId,
|
|
2764
|
+
path: match.route.path,
|
|
2765
|
+
pathname: match.pathname,
|
|
2766
|
+
pathnameBase: match.pathnameBase,
|
|
2767
|
+
shouldRevalidate: match.route.shouldRevalidate
|
|
2768
|
+
};
|
|
2734
2769
|
}
|
|
2735
|
-
async function
|
|
2770
|
+
async function getManifestRoute(route, parentId) {
|
|
2736
2771
|
await explodeLazyRoute(route);
|
|
2737
2772
|
const Layout = route.Layout || React.Fragment;
|
|
2738
2773
|
const errorElement = route.ErrorBoundary ? React.createElement(
|
|
@@ -2784,7 +2819,7 @@ async function getAdditionalRoutePatches(pathname, routes, matchedRouteIds) {
|
|
|
2784
2819
|
);
|
|
2785
2820
|
});
|
|
2786
2821
|
let patches = await Promise.all(
|
|
2787
|
-
[...patchRouteMatches.values()].filter((route) => !matchedRouteIds.some((id) => id === route.id)).map((route) =>
|
|
2822
|
+
[...patchRouteMatches.values()].filter((route) => !matchedRouteIds.some((id) => id === route.id)).map((route) => getManifestRoute(route, route.parentId))
|
|
2788
2823
|
);
|
|
2789
2824
|
return patches;
|
|
2790
2825
|
}
|
|
@@ -2796,4 +2831,4 @@ function canDecodeWithFormData(contentType) {
|
|
|
2796
2831
|
return contentType.match(/\bapplication\/x-www-form-urlencoded\b/) || contentType.match(/\bmultipart\/form-data\b/);
|
|
2797
2832
|
}
|
|
2798
2833
|
|
|
2799
|
-
export { createCookie, createCookieSessionStorage, createMemorySessionStorage, createSession, createSessionStorage, createStaticHandler, data, isCookie, isSession, matchRSCServerRequest, matchRoutes, redirect, redirectDocument, replace };
|
|
2834
|
+
export { createCookie, createCookieSessionStorage, createMemorySessionStorage, createSession, createSessionStorage, createStaticHandler, data, isCookie, isSession, matchRSCServerRequest, matchRoutes, redirect, redirectDocument, replace, unstable_createContext };
|