react-router 7.7.1 → 7.8.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/CHANGELOG.md +87 -5
- package/dist/development/browser-z32v5KVN.d.mts +46 -0
- package/dist/development/{chunk-R73PQUJU.js → chunk-4EVDZJGM.js} +130 -130
- package/dist/{production/chunk-K3SBCRK4.mjs → development/chunk-I22FVTOY.mjs} +177 -134
- package/dist/development/{chunk-K7YFBME3.js → chunk-NGF2R4G7.js} +285 -189
- package/dist/development/{chunk-C37GKA54.mjs → chunk-XFFANEXU.mjs} +266 -170
- package/dist/development/{components-CjQijYga.d.mts → components-CuPfnyiZ.d.mts} +33 -21
- package/dist/{production/route-data-CqEmXQub.d.mts → development/context-DohQKLID.d.mts} +312 -525
- package/dist/development/dom-export.d.mts +16 -12
- package/dist/development/dom-export.d.ts +13 -8
- package/dist/development/dom-export.js +3 -3
- package/dist/development/dom-export.mjs +3 -3
- package/dist/development/{index-react-server-client-Bi_fx8qz.d.ts → index-react-server-client-BzBbJLAD.d.ts} +357 -219
- package/dist/{production/index-react-server-client-KLg-U4nr.d.mts → development/index-react-server-client-CuajY2vy.d.mts} +327 -200
- package/dist/development/index-react-server-client.d.mts +4 -3
- package/dist/development/index-react-server-client.d.ts +2 -2
- package/dist/development/index-react-server-client.js +4 -4
- package/dist/development/index-react-server-client.mjs +2 -2
- package/dist/development/index-react-server.d.mts +291 -71
- package/dist/development/index-react-server.d.ts +291 -71
- package/dist/development/index-react-server.js +209 -182
- package/dist/development/index-react-server.mjs +209 -182
- package/dist/development/index.d.mts +294 -86
- package/dist/development/index.d.ts +136 -105
- package/dist/development/index.js +258 -215
- package/dist/development/index.mjs +3 -3
- package/dist/development/lib/types/internal.d.mts +13 -2
- package/dist/development/lib/types/internal.d.ts +12 -2
- package/dist/development/lib/types/internal.js +1 -1
- package/dist/development/lib/types/internal.mjs +1 -1
- package/dist/development/route-data-CpB5xtMm.d.mts +473 -0
- package/dist/{production/routeModules-BR2FO0ix.d.ts → development/routeModules-qBivMBjd.d.ts} +325 -68
- package/dist/production/browser-z32v5KVN.d.mts +46 -0
- package/dist/production/{chunk-4DGLNKXF.js → chunk-4PESVXQ2.js} +130 -130
- package/dist/{development/chunk-KIUJAIYX.mjs → production/chunk-JJOMWYJ4.mjs} +177 -134
- package/dist/production/{chunk-IZ57JD2V.mjs → chunk-P2ZJHOXZ.mjs} +266 -170
- package/dist/production/{chunk-7OQROU2D.js → chunk-RLJ23MYZ.js} +285 -189
- package/dist/production/{components-CjQijYga.d.mts → components-CuPfnyiZ.d.mts} +33 -21
- package/dist/{development/route-data-CqEmXQub.d.mts → production/context-DohQKLID.d.mts} +312 -525
- package/dist/production/dom-export.d.mts +16 -12
- package/dist/production/dom-export.d.ts +13 -8
- package/dist/production/dom-export.js +3 -3
- package/dist/production/dom-export.mjs +3 -3
- package/dist/production/{index-react-server-client-Bi_fx8qz.d.ts → index-react-server-client-BzBbJLAD.d.ts} +357 -219
- package/dist/{development/index-react-server-client-KLg-U4nr.d.mts → production/index-react-server-client-CuajY2vy.d.mts} +327 -200
- package/dist/production/index-react-server-client.d.mts +4 -3
- package/dist/production/index-react-server-client.d.ts +2 -2
- package/dist/production/index-react-server-client.js +4 -4
- package/dist/production/index-react-server-client.mjs +2 -2
- package/dist/production/index-react-server.d.mts +291 -71
- package/dist/production/index-react-server.d.ts +291 -71
- package/dist/production/index-react-server.js +209 -182
- package/dist/production/index-react-server.mjs +209 -182
- package/dist/production/index.d.mts +294 -86
- package/dist/production/index.d.ts +136 -105
- package/dist/production/index.js +258 -215
- package/dist/production/index.mjs +3 -3
- package/dist/production/lib/types/internal.d.mts +13 -2
- package/dist/production/lib/types/internal.d.ts +12 -2
- package/dist/production/lib/types/internal.js +1 -1
- package/dist/production/lib/types/internal.mjs +1 -1
- package/dist/production/route-data-CpB5xtMm.d.mts +473 -0
- package/dist/{development/routeModules-BR2FO0ix.d.ts → production/routeModules-qBivMBjd.d.ts} +325 -68
- package/package.json +1 -1
- package/dist/development/browser-7LYX59NK.d.mts +0 -226
- package/dist/production/browser-7LYX59NK.d.mts +0 -226
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }/**
|
|
2
|
-
* react-router v7.
|
|
2
|
+
* react-router v7.8.0-pre.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -367,6 +367,10 @@ function unstable_createContext(defaultValue) {
|
|
|
367
367
|
}
|
|
368
368
|
var _map;
|
|
369
369
|
var unstable_RouterContextProvider = class {
|
|
370
|
+
/**
|
|
371
|
+
* Create a new `unstable_RouterContextProvider` instance
|
|
372
|
+
* @param init An optional initial context map to populate the provider with
|
|
373
|
+
*/
|
|
370
374
|
constructor(init) {
|
|
371
375
|
__privateAdd(this, _map, /* @__PURE__ */ new Map());
|
|
372
376
|
if (init) {
|
|
@@ -375,6 +379,14 @@ var unstable_RouterContextProvider = class {
|
|
|
375
379
|
}
|
|
376
380
|
}
|
|
377
381
|
}
|
|
382
|
+
/**
|
|
383
|
+
* Access a value from the context. If no value has been set for the context,
|
|
384
|
+
* it will return the context's `defaultValue` if provided, or throw an error
|
|
385
|
+
* if no `defaultValue` was set.
|
|
386
|
+
* @param context The context to get the value for
|
|
387
|
+
* @returns The value for the context, or the context's `defaultValue` if no
|
|
388
|
+
* value was set
|
|
389
|
+
*/
|
|
378
390
|
get(context) {
|
|
379
391
|
if (__privateGet(this, _map).has(context)) {
|
|
380
392
|
return __privateGet(this, _map).get(context);
|
|
@@ -384,6 +396,14 @@ var unstable_RouterContextProvider = class {
|
|
|
384
396
|
}
|
|
385
397
|
throw new Error("No value found for context");
|
|
386
398
|
}
|
|
399
|
+
/**
|
|
400
|
+
* Set a value for the context. If the context already has a value set, this
|
|
401
|
+
* will overwrite it.
|
|
402
|
+
*
|
|
403
|
+
* @param context The context to set the value for
|
|
404
|
+
* @param value The value to set for the context
|
|
405
|
+
* @returns {void}
|
|
406
|
+
*/
|
|
387
407
|
set(context, value) {
|
|
388
408
|
__privateGet(this, _map).set(context, value);
|
|
389
409
|
}
|
|
@@ -489,6 +509,7 @@ function convertRouteMatchToUiMatch(match, loaderData) {
|
|
|
489
509
|
pathname,
|
|
490
510
|
params,
|
|
491
511
|
data: loaderData[route.id],
|
|
512
|
+
loaderData: loaderData[route.id],
|
|
492
513
|
handle: route.handle
|
|
493
514
|
};
|
|
494
515
|
}
|
|
@@ -1434,9 +1455,7 @@ function createRouter(init) {
|
|
|
1434
1455
|
pendingNavigationController.signal,
|
|
1435
1456
|
opts && opts.submission
|
|
1436
1457
|
);
|
|
1437
|
-
let scopedContext = new unstable_RouterContextProvider(
|
|
1438
|
-
init.unstable_getContext ? await init.unstable_getContext() : void 0
|
|
1439
|
-
);
|
|
1458
|
+
let scopedContext = init.unstable_getContext ? await init.unstable_getContext() : new unstable_RouterContextProvider();
|
|
1440
1459
|
let pendingActionResult;
|
|
1441
1460
|
if (opts && opts.pendingError) {
|
|
1442
1461
|
pendingActionResult = [
|
|
@@ -1703,7 +1722,7 @@ function createRouter(init) {
|
|
|
1703
1722
|
pendingActionResult
|
|
1704
1723
|
);
|
|
1705
1724
|
pendingNavigationLoadId = ++incrementingLoadId;
|
|
1706
|
-
if (!init.dataStrategy && !dsMatches.some((m) => m.shouldLoad) && revalidatingFetchers.length === 0) {
|
|
1725
|
+
if (!init.dataStrategy && !dsMatches.some((m) => m.shouldLoad) && !dsMatches.some((m) => m.route.unstable_middleware) && revalidatingFetchers.length === 0) {
|
|
1707
1726
|
let updatedFetchers2 = markFetchRedirectsDone();
|
|
1708
1727
|
completeNavigation(
|
|
1709
1728
|
location,
|
|
@@ -1857,9 +1876,7 @@ function createRouter(init) {
|
|
|
1857
1876
|
setFetcherError(key, routeId, error, { flushSync });
|
|
1858
1877
|
return;
|
|
1859
1878
|
}
|
|
1860
|
-
let scopedContext = new unstable_RouterContextProvider(
|
|
1861
|
-
init.unstable_getContext ? await init.unstable_getContext() : void 0
|
|
1862
|
-
);
|
|
1879
|
+
let scopedContext = init.unstable_getContext ? await init.unstable_getContext() : new unstable_RouterContextProvider();
|
|
1863
1880
|
let preventScrollReset = (opts && opts.preventScrollReset) === true;
|
|
1864
1881
|
if (submission && isMutationMethod(submission.formMethod)) {
|
|
1865
1882
|
await handleFetcherAction(
|
|
@@ -2710,20 +2727,13 @@ function createStaticHandler(routes, opts) {
|
|
|
2710
2727
|
skipLoaderErrorBubbling,
|
|
2711
2728
|
skipRevalidation,
|
|
2712
2729
|
dataStrategy,
|
|
2713
|
-
|
|
2714
|
-
unstable_respond: respond
|
|
2730
|
+
unstable_generateMiddlewareResponse: generateMiddlewareResponse
|
|
2715
2731
|
} = {}) {
|
|
2716
2732
|
let url = new URL(request.url);
|
|
2717
2733
|
let method = request.method;
|
|
2718
2734
|
let location = createLocation("", createPath(url), null, "default");
|
|
2719
2735
|
let matches = matchRoutes(dataRoutes, location, basename);
|
|
2720
2736
|
requestContext = requestContext != null ? requestContext : new unstable_RouterContextProvider();
|
|
2721
|
-
let respondOrStreamStaticContext = (ctx) => {
|
|
2722
|
-
return stream ? stream(
|
|
2723
|
-
requestContext,
|
|
2724
|
-
() => Promise.resolve(ctx)
|
|
2725
|
-
) : respond ? respond(ctx) : ctx;
|
|
2726
|
-
};
|
|
2727
2737
|
if (!isValidMethod(method) && method !== "HEAD") {
|
|
2728
2738
|
let error = getInternalRouterError(405, { method });
|
|
2729
2739
|
let { matches: methodNotAllowedMatches, route } = getShortCircuitMatches(dataRoutes);
|
|
@@ -2740,7 +2750,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2740
2750
|
loaderHeaders: {},
|
|
2741
2751
|
actionHeaders: {}
|
|
2742
2752
|
};
|
|
2743
|
-
return
|
|
2753
|
+
return generateMiddlewareResponse ? generateMiddlewareResponse(() => Promise.resolve(staticContext)) : staticContext;
|
|
2744
2754
|
} else if (!matches) {
|
|
2745
2755
|
let error = getInternalRouterError(404, { pathname: location.pathname });
|
|
2746
2756
|
let { matches: notFoundMatches, route } = getShortCircuitMatches(dataRoutes);
|
|
@@ -2757,11 +2767,9 @@ function createStaticHandler(routes, opts) {
|
|
|
2757
2767
|
loaderHeaders: {},
|
|
2758
2768
|
actionHeaders: {}
|
|
2759
2769
|
};
|
|
2760
|
-
return
|
|
2770
|
+
return generateMiddlewareResponse ? generateMiddlewareResponse(() => Promise.resolve(staticContext)) : staticContext;
|
|
2761
2771
|
}
|
|
2762
|
-
if (
|
|
2763
|
-
(m) => m.route.unstable_middleware || typeof m.route.lazy === "object" && m.route.lazy.unstable_middleware
|
|
2764
|
-
)) {
|
|
2772
|
+
if (generateMiddlewareResponse) {
|
|
2765
2773
|
invariant(
|
|
2766
2774
|
requestContext instanceof unstable_RouterContextProvider,
|
|
2767
2775
|
"When using middleware in `staticHandler.query()`, any provided `requestContext` must be an instance of `unstable_RouterContextProvider`"
|
|
@@ -2773,7 +2781,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2773
2781
|
mapRouteProperties
|
|
2774
2782
|
);
|
|
2775
2783
|
let renderedStaticContext;
|
|
2776
|
-
let response = await
|
|
2784
|
+
let response = await runServerMiddlewarePipeline(
|
|
2777
2785
|
{
|
|
2778
2786
|
request,
|
|
2779
2787
|
matches,
|
|
@@ -2782,45 +2790,27 @@ function createStaticHandler(routes, opts) {
|
|
|
2782
2790
|
// this to the proper type knowing it's not an `AppLoadContext`
|
|
2783
2791
|
context: requestContext
|
|
2784
2792
|
},
|
|
2785
|
-
true,
|
|
2786
2793
|
async () => {
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
return isResponse(result3) ? result3 : { location, basename, ...result3 };
|
|
2794
|
+
let res = await generateMiddlewareResponse(
|
|
2795
|
+
async (revalidationRequest) => {
|
|
2796
|
+
let result2 = await queryImpl(
|
|
2797
|
+
revalidationRequest,
|
|
2798
|
+
location,
|
|
2799
|
+
matches,
|
|
2800
|
+
requestContext,
|
|
2801
|
+
dataStrategy || null,
|
|
2802
|
+
skipLoaderErrorBubbling === true,
|
|
2803
|
+
null,
|
|
2804
|
+
filterMatchesToLoad || null,
|
|
2805
|
+
skipRevalidation === true
|
|
2806
|
+
);
|
|
2807
|
+
if (isResponse(result2)) {
|
|
2808
|
+
return result2;
|
|
2803
2809
|
}
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
invariant(respond, "Expected respond to be defined");
|
|
2808
|
-
let result2 = await queryImpl(
|
|
2809
|
-
request,
|
|
2810
|
-
location,
|
|
2811
|
-
matches,
|
|
2812
|
-
requestContext,
|
|
2813
|
-
dataStrategy || null,
|
|
2814
|
-
skipLoaderErrorBubbling === true,
|
|
2815
|
-
null,
|
|
2816
|
-
filterMatchesToLoad || null,
|
|
2817
|
-
skipRevalidation === true
|
|
2810
|
+
renderedStaticContext = { location, basename, ...result2 };
|
|
2811
|
+
return renderedStaticContext;
|
|
2812
|
+
}
|
|
2818
2813
|
);
|
|
2819
|
-
if (isResponse(result2)) {
|
|
2820
|
-
return result2;
|
|
2821
|
-
}
|
|
2822
|
-
renderedStaticContext = { location, basename, ...result2 };
|
|
2823
|
-
let res = await respond(renderedStaticContext);
|
|
2824
2814
|
return res;
|
|
2825
2815
|
},
|
|
2826
2816
|
async (error, routeId) => {
|
|
@@ -2837,7 +2827,9 @@ function createStaticHandler(routes, opts) {
|
|
|
2837
2827
|
error,
|
|
2838
2828
|
skipLoaderErrorBubbling ? routeId : findNearestBoundary(matches, routeId).route.id
|
|
2839
2829
|
);
|
|
2840
|
-
return
|
|
2830
|
+
return generateMiddlewareResponse(
|
|
2831
|
+
() => Promise.resolve(staticContext)
|
|
2832
|
+
);
|
|
2841
2833
|
} else {
|
|
2842
2834
|
let boundaryRouteId = skipLoaderErrorBubbling ? routeId : findNearestBoundary(
|
|
2843
2835
|
matches,
|
|
@@ -2858,7 +2850,9 @@ function createStaticHandler(routes, opts) {
|
|
|
2858
2850
|
actionHeaders: {},
|
|
2859
2851
|
loaderHeaders: {}
|
|
2860
2852
|
};
|
|
2861
|
-
return
|
|
2853
|
+
return generateMiddlewareResponse(
|
|
2854
|
+
() => Promise.resolve(staticContext)
|
|
2855
|
+
);
|
|
2862
2856
|
}
|
|
2863
2857
|
}
|
|
2864
2858
|
);
|
|
@@ -2891,7 +2885,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2891
2885
|
routeId,
|
|
2892
2886
|
requestContext,
|
|
2893
2887
|
dataStrategy,
|
|
2894
|
-
|
|
2888
|
+
unstable_generateMiddlewareResponse: generateMiddlewareResponse
|
|
2895
2889
|
} = {}) {
|
|
2896
2890
|
let url = new URL(request.url);
|
|
2897
2891
|
let method = request.method;
|
|
@@ -2912,15 +2906,13 @@ function createStaticHandler(routes, opts) {
|
|
|
2912
2906
|
} else if (!match) {
|
|
2913
2907
|
throw getInternalRouterError(404, { pathname: location.pathname });
|
|
2914
2908
|
}
|
|
2915
|
-
if (
|
|
2916
|
-
(m) => m.route.unstable_middleware || typeof m.route.lazy === "object" && m.route.lazy.unstable_middleware
|
|
2917
|
-
)) {
|
|
2909
|
+
if (generateMiddlewareResponse) {
|
|
2918
2910
|
invariant(
|
|
2919
2911
|
requestContext instanceof unstable_RouterContextProvider,
|
|
2920
2912
|
"When using middleware in `staticHandler.queryRoute()`, any provided `requestContext` must be an instance of `unstable_RouterContextProvider`"
|
|
2921
2913
|
);
|
|
2922
2914
|
await loadLazyMiddlewareForMatches(matches, manifest, mapRouteProperties);
|
|
2923
|
-
let response = await
|
|
2915
|
+
let response = await runServerMiddlewarePipeline(
|
|
2924
2916
|
{
|
|
2925
2917
|
request,
|
|
2926
2918
|
matches,
|
|
@@ -2929,37 +2921,34 @@ function createStaticHandler(routes, opts) {
|
|
|
2929
2921
|
// this to the proper type knowing it's not an `AppLoadContext`
|
|
2930
2922
|
context: requestContext
|
|
2931
2923
|
},
|
|
2932
|
-
true,
|
|
2933
2924
|
async () => {
|
|
2934
|
-
let
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2925
|
+
let res = await generateMiddlewareResponse(
|
|
2926
|
+
async (innerRequest) => {
|
|
2927
|
+
let result2 = await queryImpl(
|
|
2928
|
+
innerRequest,
|
|
2929
|
+
location,
|
|
2930
|
+
matches,
|
|
2931
|
+
requestContext,
|
|
2932
|
+
dataStrategy || null,
|
|
2933
|
+
false,
|
|
2934
|
+
match,
|
|
2935
|
+
null,
|
|
2936
|
+
false
|
|
2937
|
+
);
|
|
2938
|
+
let processed = handleQueryResult(result2);
|
|
2939
|
+
return isResponse(processed) ? processed : typeof processed === "string" ? new Response(processed) : Response.json(processed);
|
|
2940
|
+
}
|
|
2944
2941
|
);
|
|
2945
|
-
|
|
2946
|
-
return respond(result2);
|
|
2947
|
-
}
|
|
2948
|
-
let error2 = result2.errors ? Object.values(result2.errors)[0] : void 0;
|
|
2949
|
-
if (error2 !== void 0) {
|
|
2950
|
-
throw error2;
|
|
2951
|
-
}
|
|
2952
|
-
let value = result2.actionData ? Object.values(result2.actionData)[0] : Object.values(result2.loaderData)[0];
|
|
2953
|
-
return typeof value === "string" ? new Response(value) : Response.json(value);
|
|
2942
|
+
return res;
|
|
2954
2943
|
},
|
|
2955
|
-
(
|
|
2956
|
-
if (
|
|
2957
|
-
return
|
|
2944
|
+
(error) => {
|
|
2945
|
+
if (isRouteErrorResponse(error)) {
|
|
2946
|
+
return Promise.resolve(errorResponseToResponse(error));
|
|
2958
2947
|
}
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2948
|
+
if (isResponse(error)) {
|
|
2949
|
+
return Promise.resolve(error);
|
|
2950
|
+
}
|
|
2951
|
+
throw error;
|
|
2963
2952
|
}
|
|
2964
2953
|
);
|
|
2965
2954
|
return response;
|
|
@@ -2975,20 +2964,23 @@ function createStaticHandler(routes, opts) {
|
|
|
2975
2964
|
null,
|
|
2976
2965
|
false
|
|
2977
2966
|
);
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2967
|
+
return handleQueryResult(result);
|
|
2968
|
+
function handleQueryResult(result2) {
|
|
2969
|
+
if (isResponse(result2)) {
|
|
2970
|
+
return result2;
|
|
2971
|
+
}
|
|
2972
|
+
let error = result2.errors ? Object.values(result2.errors)[0] : void 0;
|
|
2973
|
+
if (error !== void 0) {
|
|
2974
|
+
throw error;
|
|
2975
|
+
}
|
|
2976
|
+
if (result2.actionData) {
|
|
2977
|
+
return Object.values(result2.actionData)[0];
|
|
2978
|
+
}
|
|
2979
|
+
if (result2.loaderData) {
|
|
2980
|
+
return Object.values(result2.loaderData)[0];
|
|
2981
|
+
}
|
|
2982
|
+
return void 0;
|
|
2990
2983
|
}
|
|
2991
|
-
return void 0;
|
|
2992
2984
|
}
|
|
2993
2985
|
async function queryImpl(request, location, matches, requestContext, dataStrategy, skipLoaderErrorBubbling, routeMatch, filterMatchesToLoad, skipRevalidation) {
|
|
2994
2986
|
invariant(
|
|
@@ -3928,45 +3920,118 @@ async function defaultDataStrategyWithMiddleware(args) {
|
|
|
3928
3920
|
if (!args.matches.some((m) => m.route.unstable_middleware)) {
|
|
3929
3921
|
return defaultDataStrategy(args);
|
|
3930
3922
|
}
|
|
3931
|
-
return
|
|
3923
|
+
return runClientMiddlewarePipeline(
|
|
3932
3924
|
args,
|
|
3933
|
-
false,
|
|
3934
3925
|
() => defaultDataStrategy(args),
|
|
3935
3926
|
(error, routeId) => ({ [routeId]: { type: "error", result: error } })
|
|
3936
3927
|
);
|
|
3937
3928
|
}
|
|
3938
|
-
async function
|
|
3929
|
+
async function runServerMiddlewarePipeline(args, handler, errorHandler) {
|
|
3939
3930
|
let { matches, request, params, context } = args;
|
|
3940
|
-
let
|
|
3941
|
-
|
|
3931
|
+
let tuples = matches.flatMap(
|
|
3932
|
+
(m) => m.route.unstable_middleware ? m.route.unstable_middleware.map((fn) => [m.route.id, fn]) : []
|
|
3933
|
+
);
|
|
3934
|
+
let result = await callServerRouteMiddleware(
|
|
3935
|
+
{ request, params, context },
|
|
3936
|
+
tuples,
|
|
3937
|
+
handler,
|
|
3938
|
+
errorHandler
|
|
3939
|
+
);
|
|
3940
|
+
if (isResponse(result)) {
|
|
3941
|
+
return result;
|
|
3942
|
+
}
|
|
3943
|
+
invariant(false, `Expected a Response to be returned from route middleware`);
|
|
3944
|
+
}
|
|
3945
|
+
async function callServerRouteMiddleware(args, middlewares, handler, errorHandler, idx = 0) {
|
|
3946
|
+
let { request } = args;
|
|
3947
|
+
if (request.signal.aborted) {
|
|
3948
|
+
if (request.signal.reason) {
|
|
3949
|
+
throw request.signal.reason;
|
|
3950
|
+
}
|
|
3951
|
+
throw new Error(
|
|
3952
|
+
`Request aborted without an \`AbortSignal.reason\`: ${request.method} ${request.url}`
|
|
3953
|
+
);
|
|
3954
|
+
}
|
|
3955
|
+
let tuple = middlewares[idx];
|
|
3956
|
+
if (!tuple) {
|
|
3957
|
+
let result = await handler();
|
|
3958
|
+
return result;
|
|
3959
|
+
}
|
|
3960
|
+
let [routeId, middleware] = tuple;
|
|
3961
|
+
let nextCalled = false;
|
|
3962
|
+
let nextResult = void 0;
|
|
3963
|
+
let next = async () => {
|
|
3964
|
+
if (nextCalled) {
|
|
3965
|
+
throw new Error("You may only call `next()` once per middleware");
|
|
3966
|
+
}
|
|
3967
|
+
nextCalled = true;
|
|
3968
|
+
try {
|
|
3969
|
+
let result = await callServerRouteMiddleware(
|
|
3970
|
+
args,
|
|
3971
|
+
middlewares,
|
|
3972
|
+
handler,
|
|
3973
|
+
errorHandler,
|
|
3974
|
+
idx + 1
|
|
3975
|
+
);
|
|
3976
|
+
if (isDataWithResponseInit(result)) {
|
|
3977
|
+
result = dataWithResponseInitToResponse(result);
|
|
3978
|
+
}
|
|
3979
|
+
nextResult = result;
|
|
3980
|
+
return nextResult;
|
|
3981
|
+
} catch (e) {
|
|
3982
|
+
nextResult = await errorHandler(
|
|
3983
|
+
// Convert thrown data() values to ErrorResponses
|
|
3984
|
+
isDataWithResponseInit(e) ? dataWithResponseInitToErrorResponse(e) : e,
|
|
3985
|
+
routeId
|
|
3986
|
+
);
|
|
3987
|
+
return nextResult;
|
|
3988
|
+
}
|
|
3942
3989
|
};
|
|
3943
3990
|
try {
|
|
3944
|
-
let
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
middlewareState,
|
|
3952
|
-
handler
|
|
3991
|
+
let result = await middleware(
|
|
3992
|
+
{
|
|
3993
|
+
request: args.request,
|
|
3994
|
+
params: args.params,
|
|
3995
|
+
context: args.context
|
|
3996
|
+
},
|
|
3997
|
+
next
|
|
3953
3998
|
);
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
if (!middlewareState.middlewareError) {
|
|
3957
|
-
throw e;
|
|
3999
|
+
if (isDataWithResponseInit(result)) {
|
|
4000
|
+
result = dataWithResponseInitToResponse(result);
|
|
3958
4001
|
}
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
);
|
|
3963
|
-
if (propagateResult || !middlewareState.handlerResult) {
|
|
4002
|
+
if (nextCalled) {
|
|
4003
|
+
return typeof result === "undefined" ? nextResult : result;
|
|
4004
|
+
} else if (isResponse(result)) {
|
|
3964
4005
|
return result;
|
|
4006
|
+
} else {
|
|
4007
|
+
nextResult = await next();
|
|
4008
|
+
return nextResult;
|
|
3965
4009
|
}
|
|
3966
|
-
|
|
4010
|
+
} catch (e) {
|
|
4011
|
+
let response = await errorHandler(
|
|
4012
|
+
// Convert thrown data() values to ErrorResponses
|
|
4013
|
+
isDataWithResponseInit(e) ? dataWithResponseInitToErrorResponse(e) : e,
|
|
4014
|
+
routeId
|
|
4015
|
+
);
|
|
4016
|
+
return response;
|
|
3967
4017
|
}
|
|
3968
4018
|
}
|
|
3969
|
-
async function
|
|
4019
|
+
async function runClientMiddlewarePipeline(args, handler, errorHandler) {
|
|
4020
|
+
let { matches, request, params, context } = args;
|
|
4021
|
+
let tuples = matches.flatMap(
|
|
4022
|
+
(m) => m.route.unstable_middleware ? m.route.unstable_middleware.map((fn) => [m.route.id, fn]) : []
|
|
4023
|
+
);
|
|
4024
|
+
let handlerResult = {};
|
|
4025
|
+
await callClientRouteMiddleware(
|
|
4026
|
+
{ request, params, context },
|
|
4027
|
+
tuples,
|
|
4028
|
+
handler,
|
|
4029
|
+
errorHandler,
|
|
4030
|
+
handlerResult
|
|
4031
|
+
);
|
|
4032
|
+
return handlerResult;
|
|
4033
|
+
}
|
|
4034
|
+
async function callClientRouteMiddleware(args, middlewares, handler, errorHandler, handlerResult = {}, idx = 0) {
|
|
3970
4035
|
let { request } = args;
|
|
3971
4036
|
if (request.signal.aborted) {
|
|
3972
4037
|
if (request.signal.reason) {
|
|
@@ -3978,28 +4043,30 @@ async function callRouteMiddleware(args, middlewares, propagateResult, middlewar
|
|
|
3978
4043
|
}
|
|
3979
4044
|
let tuple = middlewares[idx];
|
|
3980
4045
|
if (!tuple) {
|
|
3981
|
-
|
|
3982
|
-
|
|
4046
|
+
let result = await handler();
|
|
4047
|
+
Object.assign(handlerResult, result);
|
|
4048
|
+
return;
|
|
3983
4049
|
}
|
|
3984
4050
|
let [routeId, middleware] = tuple;
|
|
3985
4051
|
let nextCalled = false;
|
|
3986
|
-
let nextResult = void 0;
|
|
3987
4052
|
let next = async () => {
|
|
3988
4053
|
if (nextCalled) {
|
|
3989
4054
|
throw new Error("You may only call `next()` once per middleware");
|
|
3990
4055
|
}
|
|
3991
4056
|
nextCalled = true;
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4057
|
+
try {
|
|
4058
|
+
let result = await callClientRouteMiddleware(
|
|
4059
|
+
args,
|
|
4060
|
+
middlewares,
|
|
4061
|
+
handler,
|
|
4062
|
+
errorHandler,
|
|
4063
|
+
handlerResult,
|
|
4064
|
+
idx + 1
|
|
4065
|
+
);
|
|
4066
|
+
Object.assign(handlerResult, result);
|
|
4067
|
+
} catch (e) {
|
|
4068
|
+
let result = await errorHandler(e, routeId);
|
|
4069
|
+
Object.assign(handlerResult, result);
|
|
4003
4070
|
}
|
|
4004
4071
|
};
|
|
4005
4072
|
try {
|
|
@@ -4011,22 +4078,18 @@ async function callRouteMiddleware(args, middlewares, propagateResult, middlewar
|
|
|
4011
4078
|
},
|
|
4012
4079
|
next
|
|
4013
4080
|
);
|
|
4014
|
-
if (
|
|
4015
|
-
|
|
4016
|
-
return
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
}
|
|
4020
|
-
} else {
|
|
4021
|
-
return next();
|
|
4081
|
+
if (typeof result !== "undefined") {
|
|
4082
|
+
console.warn(
|
|
4083
|
+
"client middlewares are not intended to return values, the value will be ignored",
|
|
4084
|
+
result
|
|
4085
|
+
);
|
|
4022
4086
|
}
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
middlewareState.middlewareError = { routeId, error };
|
|
4026
|
-
} else if (middlewareState.middlewareError.error !== error) {
|
|
4027
|
-
middlewareState.middlewareError = { routeId, error };
|
|
4087
|
+
if (!nextCalled) {
|
|
4088
|
+
await next();
|
|
4028
4089
|
}
|
|
4029
|
-
|
|
4090
|
+
} catch (error) {
|
|
4091
|
+
let result = await errorHandler(error, routeId);
|
|
4092
|
+
Object.assign(handlerResult, result);
|
|
4030
4093
|
}
|
|
4031
4094
|
}
|
|
4032
4095
|
function getDataStrategyMatchLazyPromises(mapRouteProperties, manifest, request, match, lazyRoutePropertiesToSkip) {
|
|
@@ -4137,9 +4200,8 @@ async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherK
|
|
|
4137
4200
|
);
|
|
4138
4201
|
} : (cb) => {
|
|
4139
4202
|
let typedDataStrategyArgs = dataStrategyArgs;
|
|
4140
|
-
return
|
|
4203
|
+
return runClientMiddlewarePipeline(
|
|
4141
4204
|
typedDataStrategyArgs,
|
|
4142
|
-
false,
|
|
4143
4205
|
() => cb({
|
|
4144
4206
|
...typedDataStrategyArgs,
|
|
4145
4207
|
fetcherKey,
|
|
@@ -4477,11 +4539,12 @@ function processLoaderData(state, matches, results, pendingActionResult, revalid
|
|
|
4477
4539
|
);
|
|
4478
4540
|
revalidatingFetchers.filter((f) => !f.matches || f.matches.some((m) => m.shouldLoad)).forEach((rf) => {
|
|
4479
4541
|
let { key, match, controller } = rf;
|
|
4480
|
-
let result = fetcherResults[key];
|
|
4481
|
-
invariant(result, "Did not find corresponding fetcher result");
|
|
4482
4542
|
if (controller && controller.signal.aborted) {
|
|
4483
4543
|
return;
|
|
4484
|
-
}
|
|
4544
|
+
}
|
|
4545
|
+
let result = fetcherResults[key];
|
|
4546
|
+
invariant(result, "Did not find corresponding fetcher result");
|
|
4547
|
+
if (isErrorResult(result)) {
|
|
4485
4548
|
let boundaryMatch = findNearestBoundary(state.matches, _optionalChain([match, 'optionalAccess', _59 => _59.route, 'access', _60 => _60.id]));
|
|
4486
4549
|
if (!(errors && errors[boundaryMatch.route.id])) {
|
|
4487
4550
|
errors = {
|
|
@@ -4611,6 +4674,28 @@ function isHashChangeOnly(a, b) {
|
|
|
4611
4674
|
}
|
|
4612
4675
|
return false;
|
|
4613
4676
|
}
|
|
4677
|
+
function dataWithResponseInitToResponse(data2) {
|
|
4678
|
+
return new Response(
|
|
4679
|
+
typeof data2.data === "string" ? data2.data : JSON.stringify(data2.data),
|
|
4680
|
+
data2.init || void 0
|
|
4681
|
+
);
|
|
4682
|
+
}
|
|
4683
|
+
function dataWithResponseInitToErrorResponse(data2) {
|
|
4684
|
+
return new ErrorResponseImpl(
|
|
4685
|
+
_nullishCoalesce(_optionalChain([data2, 'access', _61 => _61.init, 'optionalAccess', _62 => _62.status]), () => ( 500)),
|
|
4686
|
+
_nullishCoalesce(_optionalChain([data2, 'access', _63 => _63.init, 'optionalAccess', _64 => _64.statusText]), () => ( "Internal Server Error")),
|
|
4687
|
+
data2.data
|
|
4688
|
+
);
|
|
4689
|
+
}
|
|
4690
|
+
function errorResponseToResponse(error) {
|
|
4691
|
+
return new Response(
|
|
4692
|
+
typeof error.data === "string" ? error.data : JSON.stringify(error.data),
|
|
4693
|
+
{
|
|
4694
|
+
status: error.status,
|
|
4695
|
+
statusText: error.statusText
|
|
4696
|
+
}
|
|
4697
|
+
);
|
|
4698
|
+
}
|
|
4614
4699
|
function isDataStrategyResult(result) {
|
|
4615
4700
|
return result != null && typeof result === "object" && "type" in result && "result" in result && (result.type === "data" /* data */ || result.type === "error" /* error */);
|
|
4616
4701
|
}
|
|
@@ -5637,7 +5722,7 @@ function getTurboStreamSingleFetchDataStrategy(getRouter, manifest, routeModules
|
|
|
5637
5722
|
return {
|
|
5638
5723
|
hasLoader: manifestRoute.hasLoader,
|
|
5639
5724
|
hasClientLoader: manifestRoute.hasClientLoader,
|
|
5640
|
-
hasShouldRevalidate: Boolean(_optionalChain([routeModule, 'optionalAccess',
|
|
5725
|
+
hasShouldRevalidate: Boolean(_optionalChain([routeModule, 'optionalAccess', _65 => _65.shouldRevalidate]))
|
|
5641
5726
|
};
|
|
5642
5727
|
},
|
|
5643
5728
|
fetchAndDecodeViaTurboStream,
|
|
@@ -5804,6 +5889,12 @@ async function bubbleMiddlewareErrors(singleFetchPromise, matches, routesParams,
|
|
|
5804
5889
|
let routeResult = fetchedData.routes[match.route.id];
|
|
5805
5890
|
if ("error" in routeResult) {
|
|
5806
5891
|
middlewareError = routeResult.error;
|
|
5892
|
+
if (_optionalChain([results, 'access', _66 => _66[match.route.id], 'optionalAccess', _67 => _67.result]) == null) {
|
|
5893
|
+
results[match.route.id] = {
|
|
5894
|
+
type: "error",
|
|
5895
|
+
result: middlewareError
|
|
5896
|
+
};
|
|
5897
|
+
}
|
|
5807
5898
|
break;
|
|
5808
5899
|
}
|
|
5809
5900
|
}
|
|
@@ -5911,7 +6002,7 @@ async function fetchAndDecodeViaTurboStream(args, basename, targetRoutes) {
|
|
|
5911
6002
|
}
|
|
5912
6003
|
} else {
|
|
5913
6004
|
let typed = decoded.value;
|
|
5914
|
-
let routeId = _optionalChain([targetRoutes, 'optionalAccess',
|
|
6005
|
+
let routeId = _optionalChain([targetRoutes, 'optionalAccess', _68 => _68[0]]);
|
|
5915
6006
|
invariant2(routeId, "No routeId found for single fetch call decoding");
|
|
5916
6007
|
if ("redirect" in typed) {
|
|
5917
6008
|
data2 = { redirect: typed };
|
|
@@ -6222,7 +6313,7 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
|
|
|
6222
6313
|
if (locationArg) {
|
|
6223
6314
|
let parsedLocationArg = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
|
|
6224
6315
|
invariant(
|
|
6225
|
-
parentPathnameBase === "/" || _optionalChain([parsedLocationArg, 'access',
|
|
6316
|
+
parentPathnameBase === "/" || _optionalChain([parsedLocationArg, 'access', _69 => _69.pathname, 'optionalAccess', _70 => _70.startsWith, 'call', _71 => _71(parentPathnameBase)]),
|
|
6226
6317
|
`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${parentPathnameBase}" but pathname "${parsedLocationArg.pathname}" was given in the \`location\` prop.`
|
|
6227
6318
|
);
|
|
6228
6319
|
location = parsedLocationArg;
|
|
@@ -6370,10 +6461,10 @@ function _renderMatches(matches, parentMatches = [], dataRouterState = null, fut
|
|
|
6370
6461
|
}
|
|
6371
6462
|
}
|
|
6372
6463
|
let renderedMatches = matches;
|
|
6373
|
-
let errors = _optionalChain([dataRouterState, 'optionalAccess',
|
|
6464
|
+
let errors = _optionalChain([dataRouterState, 'optionalAccess', _72 => _72.errors]);
|
|
6374
6465
|
if (errors != null) {
|
|
6375
6466
|
let errorIndex = renderedMatches.findIndex(
|
|
6376
|
-
(m) => m.route.id && _optionalChain([errors, 'optionalAccess',
|
|
6467
|
+
(m) => m.route.id && _optionalChain([errors, 'optionalAccess', _73 => _73[m.route.id]]) !== void 0
|
|
6377
6468
|
);
|
|
6378
6469
|
invariant(
|
|
6379
6470
|
errorIndex >= 0,
|
|
@@ -6550,15 +6641,15 @@ function useRouteError() {
|
|
|
6550
6641
|
if (error !== void 0) {
|
|
6551
6642
|
return error;
|
|
6552
6643
|
}
|
|
6553
|
-
return _optionalChain([state, 'access',
|
|
6644
|
+
return _optionalChain([state, 'access', _74 => _74.errors, 'optionalAccess', _75 => _75[routeId]]);
|
|
6554
6645
|
}
|
|
6555
6646
|
function useAsyncValue() {
|
|
6556
6647
|
let value = React3.useContext(AwaitContext);
|
|
6557
|
-
return _optionalChain([value, 'optionalAccess',
|
|
6648
|
+
return _optionalChain([value, 'optionalAccess', _76 => _76._data]);
|
|
6558
6649
|
}
|
|
6559
6650
|
function useAsyncError() {
|
|
6560
6651
|
let value = React3.useContext(AwaitContext);
|
|
6561
|
-
return _optionalChain([value, 'optionalAccess',
|
|
6652
|
+
return _optionalChain([value, 'optionalAccess', _77 => _77._error]);
|
|
6562
6653
|
}
|
|
6563
6654
|
var blockerId = 0;
|
|
6564
6655
|
function useBlocker(shouldBlock) {
|
|
@@ -6670,7 +6761,7 @@ function getKeyedLinksForMatches(matches, routeModules, manifest) {
|
|
|
6670
6761
|
let route = manifest.routes[match.route.id];
|
|
6671
6762
|
return [
|
|
6672
6763
|
route && route.css ? route.css.map((href) => ({ rel: "stylesheet", href })) : [],
|
|
6673
|
-
_optionalChain([module, 'optionalAccess',
|
|
6764
|
+
_optionalChain([module, 'optionalAccess', _78 => _78.links, 'optionalCall', _79 => _79()]) || []
|
|
6674
6765
|
];
|
|
6675
6766
|
}).flat(2);
|
|
6676
6767
|
let preloads = getModuleLinkHrefs(matches, manifest);
|
|
@@ -6771,7 +6862,7 @@ function getNewMatchesForLinks(page, nextMatches, currentMatches, manifest, loca
|
|
|
6771
6862
|
// param change, /users/123 -> /users/456
|
|
6772
6863
|
currentMatches[index].pathname !== match.pathname || // splat param changed, which is not present in match.path
|
|
6773
6864
|
// e.g. /files/images/avatar.jpg -> files/finances.xls
|
|
6774
|
-
_optionalChain([currentMatches, 'access',
|
|
6865
|
+
_optionalChain([currentMatches, 'access', _80 => _80[index], 'access', _81 => _81.route, 'access', _82 => _82.path, 'optionalAccess', _83 => _83.endsWith, 'call', _84 => _84("*")]) && currentMatches[index].params["*"] !== match.params["*"]
|
|
6775
6866
|
);
|
|
6776
6867
|
};
|
|
6777
6868
|
if (mode === "assets") {
|
|
@@ -6794,7 +6885,7 @@ function getNewMatchesForLinks(page, nextMatches, currentMatches, manifest, loca
|
|
|
6794
6885
|
location.pathname + location.search + location.hash,
|
|
6795
6886
|
window.origin
|
|
6796
6887
|
),
|
|
6797
|
-
currentParams: _optionalChain([currentMatches, 'access',
|
|
6888
|
+
currentParams: _optionalChain([currentMatches, 'access', _85 => _85[0], 'optionalAccess', _86 => _86.params]) || {},
|
|
6798
6889
|
nextUrl: new URL(page, window.origin),
|
|
6799
6890
|
nextParams: match.params,
|
|
6800
6891
|
defaultShouldRevalidate: true
|
|
@@ -7066,10 +7157,10 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
7066
7157
|
)
|
|
7067
7158
|
});
|
|
7068
7159
|
let hasInitialData = initialState && initialState.loaderData && route.id in initialState.loaderData;
|
|
7069
|
-
let initialData = hasInitialData ? _optionalChain([initialState, 'optionalAccess',
|
|
7160
|
+
let initialData = hasInitialData ? _optionalChain([initialState, 'optionalAccess', _87 => _87.loaderData, 'optionalAccess', _88 => _88[route.id]]) : void 0;
|
|
7070
7161
|
let hasInitialError = initialState && initialState.errors && route.id in initialState.errors;
|
|
7071
|
-
let initialError = hasInitialError ? _optionalChain([initialState, 'optionalAccess',
|
|
7072
|
-
let isHydrationRequest = needsRevalidation == null && (_optionalChain([routeModule, 'access',
|
|
7162
|
+
let initialError = hasInitialError ? _optionalChain([initialState, 'optionalAccess', _89 => _89.errors, 'optionalAccess', _90 => _90[route.id]]) : void 0;
|
|
7163
|
+
let isHydrationRequest = needsRevalidation == null && (_optionalChain([routeModule, 'access', _91 => _91.clientLoader, 'optionalAccess', _92 => _92.hydrate]) === true || !route.hasLoader);
|
|
7073
7164
|
dataRoute.loader = async ({ request, params, context }, singleFetch) => {
|
|
7074
7165
|
try {
|
|
7075
7166
|
let result = await prefetchStylesAndCallHandler(async () => {
|
|
@@ -7366,7 +7457,7 @@ function getPatchRoutesOnNavigationFunction(manifest, routeModules, ssr, routeDi
|
|
|
7366
7457
|
function useFogOFWarDiscovery(router, manifest, routeModules, ssr, routeDiscovery, isSpaMode) {
|
|
7367
7458
|
React6.useEffect(() => {
|
|
7368
7459
|
if (!isFogOfWarEnabled(routeDiscovery, ssr) || // @ts-expect-error - TS doesn't know about this yet
|
|
7369
|
-
_optionalChain([window, 'access',
|
|
7460
|
+
_optionalChain([window, 'access', _93 => _93.navigator, 'optionalAccess', _94 => _94.connection, 'optionalAccess', _95 => _95.saveData]) === true) {
|
|
7370
7461
|
return;
|
|
7371
7462
|
}
|
|
7372
7463
|
function registerElement(el) {
|
|
@@ -7428,12 +7519,14 @@ function getManifestPath(_manifestPath, basename) {
|
|
|
7428
7519
|
}
|
|
7429
7520
|
var MANIFEST_VERSION_STORAGE_KEY = "react-router-manifest-version";
|
|
7430
7521
|
async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, routeModules, ssr, isSpaMode, basename, manifestPath, patchRoutes, signal) {
|
|
7522
|
+
const searchParams = new URLSearchParams();
|
|
7523
|
+
paths.sort().forEach((path) => searchParams.append("p", path));
|
|
7524
|
+
searchParams.set("version", manifest.version);
|
|
7431
7525
|
let url = new URL(
|
|
7432
7526
|
getManifestPath(manifestPath, basename),
|
|
7433
7527
|
window.location.origin
|
|
7434
7528
|
);
|
|
7435
|
-
|
|
7436
|
-
url.searchParams.set("version", manifest.version);
|
|
7529
|
+
url.search = searchParams.toString();
|
|
7437
7530
|
if (url.toString().length > URL_LIMIT) {
|
|
7438
7531
|
nextPaths.clear();
|
|
7439
7532
|
return;
|
|
@@ -7467,7 +7560,7 @@ async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, ro
|
|
|
7467
7560
|
sessionStorage.removeItem(MANIFEST_VERSION_STORAGE_KEY);
|
|
7468
7561
|
serverPatches = await res.json();
|
|
7469
7562
|
} catch (e) {
|
|
7470
|
-
if (_optionalChain([signal, 'optionalAccess',
|
|
7563
|
+
if (_optionalChain([signal, 'optionalAccess', _96 => _96.aborted])) return;
|
|
7471
7564
|
throw e;
|
|
7472
7565
|
}
|
|
7473
7566
|
let knownRoutes = new Set(Object.keys(manifest.routes));
|
|
@@ -7611,7 +7704,7 @@ function getActiveMatches(matches, errors, isSpaMode) {
|
|
|
7611
7704
|
return matches;
|
|
7612
7705
|
}
|
|
7613
7706
|
var CRITICAL_CSS_DATA_ATTRIBUTE = "data-react-router-critical-css";
|
|
7614
|
-
function Links() {
|
|
7707
|
+
function Links({ nonce }) {
|
|
7615
7708
|
let { isSpaMode, manifest, routeModules, criticalCss } = useFrameworkContext();
|
|
7616
7709
|
let { errors, matches: routerMatches } = useDataRouterStateContext();
|
|
7617
7710
|
let matches = getActiveMatches(routerMatches, errors, isSpaMode);
|
|
@@ -7630,10 +7723,11 @@ function Links() {
|
|
|
7630
7723
|
{
|
|
7631
7724
|
...{ [CRITICAL_CSS_DATA_ATTRIBUTE]: "" },
|
|
7632
7725
|
rel: "stylesheet",
|
|
7633
|
-
href: criticalCss.href
|
|
7726
|
+
href: criticalCss.href,
|
|
7727
|
+
nonce
|
|
7634
7728
|
}
|
|
7635
7729
|
) : null, keyedLinks.map(
|
|
7636
|
-
({ key, link }) => isPageLinkDescriptor(link) ? /* @__PURE__ */ React7.createElement(PrefetchPageLinks, { key, ...link }) : /* @__PURE__ */ React7.createElement("link", { key, ...link })
|
|
7730
|
+
({ key, link }) => isPageLinkDescriptor(link) ? /* @__PURE__ */ React7.createElement(PrefetchPageLinks, { key, nonce, ...link }) : /* @__PURE__ */ React7.createElement("link", { key, nonce, ...link })
|
|
7637
7731
|
));
|
|
7638
7732
|
}
|
|
7639
7733
|
function PrefetchPageLinks({ page, ...linkProps }) {
|
|
@@ -7707,7 +7801,7 @@ function PrefetchPageLinksImpl({
|
|
|
7707
7801
|
if (!manifestRoute || !manifestRoute.hasLoader) {
|
|
7708
7802
|
return;
|
|
7709
7803
|
}
|
|
7710
|
-
if (!newMatchesForData.some((m2) => m2.route.id === m.route.id) && m.route.id in loaderData && _optionalChain([routeModules, 'access',
|
|
7804
|
+
if (!newMatchesForData.some((m2) => m2.route.id === m.route.id) && m.route.id in loaderData && _optionalChain([routeModules, 'access', _97 => _97[m.route.id], 'optionalAccess', _98 => _98.shouldRevalidate])) {
|
|
7711
7805
|
foundOptOutRoute = true;
|
|
7712
7806
|
} else if (manifestRoute.hasClientLoader) {
|
|
7713
7807
|
foundOptOutRoute = true;
|
|
@@ -7744,7 +7838,7 @@ function PrefetchPageLinksImpl({
|
|
|
7744
7838
|
return /* @__PURE__ */ React7.createElement(React7.Fragment, null, dataHrefs.map((href) => /* @__PURE__ */ React7.createElement("link", { key: href, rel: "prefetch", as: "fetch", href, ...linkProps })), moduleHrefs.map((href) => /* @__PURE__ */ React7.createElement("link", { key: href, rel: "modulepreload", href, ...linkProps })), keyedPrefetchLinks.map(({ key, link }) => (
|
|
7745
7839
|
// these don't spread `linkProps` because they are full link descriptors
|
|
7746
7840
|
// already with their own props
|
|
7747
|
-
/* @__PURE__ */ React7.createElement("link", { key, ...link })
|
|
7841
|
+
/* @__PURE__ */ React7.createElement("link", { key, nonce: linkProps.nonce, ...link })
|
|
7748
7842
|
)));
|
|
7749
7843
|
}
|
|
7750
7844
|
function Meta() {
|
|
@@ -7773,6 +7867,7 @@ function Meta() {
|
|
|
7773
7867
|
let match = {
|
|
7774
7868
|
id: routeId,
|
|
7775
7869
|
data: data2,
|
|
7870
|
+
loaderData: data2,
|
|
7776
7871
|
meta: [],
|
|
7777
7872
|
params: _match.params,
|
|
7778
7873
|
pathname: _match.pathname,
|
|
@@ -7780,9 +7875,10 @@ function Meta() {
|
|
|
7780
7875
|
error
|
|
7781
7876
|
};
|
|
7782
7877
|
matches[i] = match;
|
|
7783
|
-
if (_optionalChain([routeModule, 'optionalAccess',
|
|
7878
|
+
if (_optionalChain([routeModule, 'optionalAccess', _99 => _99.meta])) {
|
|
7784
7879
|
routeMeta = typeof routeModule.meta === "function" ? routeModule.meta({
|
|
7785
7880
|
data: data2,
|
|
7881
|
+
loaderData: data2,
|
|
7786
7882
|
params,
|
|
7787
7883
|
location,
|
|
7788
7884
|
matches,
|
|
@@ -7875,7 +7971,7 @@ function Scripts(scriptProps) {
|
|
|
7875
7971
|
}
|
|
7876
7972
|
let streamScript = "window.__reactRouterContext.stream = new ReadableStream({start(controller){window.__reactRouterContext.streamController = controller;}}).pipeThrough(new TextEncoderStream());";
|
|
7877
7973
|
let contextScript = staticContext ? `window.__reactRouterContext = ${serverHandoffString};${streamScript}` : " ";
|
|
7878
|
-
let routeModulesScript = !isStatic ? " " : `${_optionalChain([manifest, 'access',
|
|
7974
|
+
let routeModulesScript = !isStatic ? " " : `${_optionalChain([manifest, 'access', _100 => _100.hmr, 'optionalAccess', _101 => _101.runtime]) ? `import ${JSON.stringify(manifest.hmr.runtime)};` : ""}${!enableFogOfWar ? `import ${JSON.stringify(manifest.url)}` : ""};
|
|
7879
7975
|
${matches.map((match, routeIndex) => {
|
|
7880
7976
|
let routeVarName = `route${routeIndex}`;
|
|
7881
7977
|
let manifestEntry = manifest.routes[match.route.id];
|
|
@@ -8105,7 +8201,7 @@ function BoundaryShell({
|
|
|
8105
8201
|
children
|
|
8106
8202
|
}) {
|
|
8107
8203
|
let { routeModules } = useFrameworkContext();
|
|
8108
|
-
if (_optionalChain([routeModules, 'access',
|
|
8204
|
+
if (_optionalChain([routeModules, 'access', _102 => _102.root, 'optionalAccess', _103 => _103.Layout]) && !isOutsideRemixApp) {
|
|
8109
8205
|
return children;
|
|
8110
8206
|
}
|
|
8111
8207
|
return /* @__PURE__ */ React8.createElement("html", { lang: "en" }, /* @__PURE__ */ React8.createElement("head", null, /* @__PURE__ */ React8.createElement("meta", { charSet: "utf-8" }), /* @__PURE__ */ React8.createElement(
|