react-router 0.0.0-experimental-8e9d8ef63 → 0.0.0-experimental-66d5af831
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/{chunk-EJSPM7NW.mjs → chunk-5PWWYJB4.mjs} +199 -57
- package/dist/development/chunk-7XTHOCJS.mjs +678 -0
- package/dist/development/dom-export.d.mts +2 -2
- package/dist/development/dom-export.d.ts +2 -2
- package/dist/development/dom-export.js +806 -44
- package/dist/development/dom-export.mjs +23 -7
- package/dist/development/{fog-of-war-BOz-S1N8.d.mts → fog-of-war-D9FGCk6a.d.mts} +6 -3
- package/dist/{production/fog-of-war-BBVWdkR1.d.ts → development/fog-of-war-kKHMEhB_.d.ts} +6 -3
- package/dist/development/index.d.mts +10 -9
- package/dist/development/index.d.ts +10 -9
- package/dist/development/index.js +900 -64
- package/dist/development/index.mjs +3 -2
- package/dist/development/lib/types/route-module.d.mts +3 -1
- package/dist/development/lib/types/route-module.d.ts +3 -1
- package/dist/development/lib/types/route-module.js +1 -1
- package/dist/development/lib/types/route-module.mjs +1 -1
- package/dist/development/{route-data-CfLfC_Bh.d.ts → route-data-B_Qv26O_.d.mts} +12 -2
- package/dist/{production/route-data-CfLfC_Bh.d.mts → development/route-data-B_Qv26O_.d.ts} +12 -2
- package/dist/development/turbo-stream-TG2U76TX.mjs +18 -0
- package/dist/production/chunk-7XTHOCJS.mjs +678 -0
- package/dist/production/{chunk-7VURRAOS.mjs → chunk-KOUGJ2WY.mjs} +199 -57
- package/dist/production/dom-export.d.mts +2 -2
- package/dist/production/dom-export.d.ts +2 -2
- package/dist/production/dom-export.js +806 -44
- package/dist/production/dom-export.mjs +23 -7
- package/dist/production/{fog-of-war-BOz-S1N8.d.mts → fog-of-war-D9FGCk6a.d.mts} +6 -3
- package/dist/{development/fog-of-war-BBVWdkR1.d.ts → production/fog-of-war-kKHMEhB_.d.ts} +6 -3
- package/dist/production/index.d.mts +10 -9
- package/dist/production/index.d.ts +10 -9
- package/dist/production/index.js +900 -64
- package/dist/production/index.mjs +3 -2
- package/dist/production/lib/types/route-module.d.mts +3 -1
- package/dist/production/lib/types/route-module.d.ts +3 -1
- package/dist/production/lib/types/route-module.js +1 -1
- package/dist/production/lib/types/route-module.mjs +1 -1
- package/dist/production/{route-data-CfLfC_Bh.d.ts → route-data-B_Qv26O_.d.mts} +12 -2
- package/dist/{development/route-data-CfLfC_Bh.d.mts → production/route-data-B_Qv26O_.d.ts} +12 -2
- package/dist/production/turbo-stream-TG2U76TX.mjs +18 -0
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v0.0.0-experimental-
|
|
2
|
+
* react-router v0.0.0-experimental-66d5af831
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
+
import {
|
|
12
|
+
encode
|
|
13
|
+
} from "./chunk-7XTHOCJS.mjs";
|
|
11
14
|
|
|
12
15
|
// lib/router/history.ts
|
|
13
16
|
var Action = /* @__PURE__ */ ((Action2) => {
|
|
@@ -5573,7 +5576,6 @@ function createHtml(html) {
|
|
|
5573
5576
|
|
|
5574
5577
|
// lib/dom/ssr/single-fetch.tsx
|
|
5575
5578
|
import * as React4 from "react";
|
|
5576
|
-
import { decode } from "turbo-stream";
|
|
5577
5579
|
|
|
5578
5580
|
// lib/dom/ssr/data.ts
|
|
5579
5581
|
async function createRequestInit(request) {
|
|
@@ -5647,7 +5649,7 @@ function StreamTransfer({
|
|
|
5647
5649
|
{
|
|
5648
5650
|
nonce,
|
|
5649
5651
|
dangerouslySetInnerHTML: {
|
|
5650
|
-
__html: `window.__reactRouterContext.streamController.close();`
|
|
5652
|
+
__html: `window.__reactRouterContext.streamDone=true;window.__reactRouterContext.streamController.close();`
|
|
5651
5653
|
}
|
|
5652
5654
|
}
|
|
5653
5655
|
));
|
|
@@ -5664,24 +5666,39 @@ function StreamTransfer({
|
|
|
5664
5666
|
)));
|
|
5665
5667
|
}
|
|
5666
5668
|
}
|
|
5667
|
-
function getSingleFetchDataStrategy(manifest, routeModules, getRouter) {
|
|
5669
|
+
function getSingleFetchDataStrategy(manifest, routeModules, getRouter, ssr, turboV3) {
|
|
5668
5670
|
return async ({ request, matches, fetcherKey }) => {
|
|
5669
5671
|
if (request.method !== "GET") {
|
|
5670
|
-
return singleFetchActionStrategy(request, matches);
|
|
5672
|
+
return singleFetchActionStrategy(request, matches, turboV3);
|
|
5673
|
+
}
|
|
5674
|
+
if (!ssr) {
|
|
5675
|
+
let foundLoaderBelowRoot = matches.some(
|
|
5676
|
+
(m) => m.route.id !== "root" && manifest.routes[m.route.id]?.hasLoader
|
|
5677
|
+
);
|
|
5678
|
+
if (!foundLoaderBelowRoot) {
|
|
5679
|
+
let matchesToLoad = matches.filter((m) => m.shouldLoad);
|
|
5680
|
+
let results = await Promise.all(matchesToLoad.map((m) => m.resolve()));
|
|
5681
|
+
return results.reduce(
|
|
5682
|
+
(acc, result, i) => Object.assign(acc, { [matchesToLoad[i].route.id]: result }),
|
|
5683
|
+
{}
|
|
5684
|
+
);
|
|
5685
|
+
}
|
|
5671
5686
|
}
|
|
5672
5687
|
if (fetcherKey) {
|
|
5673
|
-
return singleFetchLoaderFetcherStrategy(request, matches);
|
|
5688
|
+
return singleFetchLoaderFetcherStrategy(request, matches, turboV3);
|
|
5674
5689
|
}
|
|
5675
5690
|
return singleFetchLoaderNavigationStrategy(
|
|
5676
5691
|
manifest,
|
|
5677
5692
|
routeModules,
|
|
5693
|
+
ssr,
|
|
5678
5694
|
getRouter(),
|
|
5679
5695
|
request,
|
|
5680
|
-
matches
|
|
5696
|
+
matches,
|
|
5697
|
+
turboV3
|
|
5681
5698
|
);
|
|
5682
5699
|
};
|
|
5683
5700
|
}
|
|
5684
|
-
async function singleFetchActionStrategy(request, matches) {
|
|
5701
|
+
async function singleFetchActionStrategy(request, matches, turboV3) {
|
|
5685
5702
|
let actionMatch = matches.find((m) => m.shouldLoad);
|
|
5686
5703
|
invariant2(actionMatch, "No action match found");
|
|
5687
5704
|
let actionStatus = void 0;
|
|
@@ -5689,7 +5706,7 @@ async function singleFetchActionStrategy(request, matches) {
|
|
|
5689
5706
|
let result2 = await handler(async () => {
|
|
5690
5707
|
let url = singleFetchUrl(request.url);
|
|
5691
5708
|
let init = await createRequestInit(request);
|
|
5692
|
-
let { data: data2, status } = await fetchAndDecode(url, init);
|
|
5709
|
+
let { data: data2, status } = await fetchAndDecode(url, init, turboV3);
|
|
5693
5710
|
actionStatus = status;
|
|
5694
5711
|
return unwrapSingleFetchResult(
|
|
5695
5712
|
data2,
|
|
@@ -5708,7 +5725,7 @@ async function singleFetchActionStrategy(request, matches) {
|
|
|
5708
5725
|
}
|
|
5709
5726
|
};
|
|
5710
5727
|
}
|
|
5711
|
-
async function singleFetchLoaderNavigationStrategy(manifest, routeModules, router, request, matches) {
|
|
5728
|
+
async function singleFetchLoaderNavigationStrategy(manifest, routeModules, ssr, router, request, matches, turboV3) {
|
|
5712
5729
|
let routesParams = /* @__PURE__ */ new Set();
|
|
5713
5730
|
let foundOptOutRoute = false;
|
|
5714
5731
|
let routeDfds = matches.map(() => createDeferred2());
|
|
@@ -5740,7 +5757,8 @@ async function singleFetchLoaderNavigationStrategy(manifest, routeModules, route
|
|
|
5740
5757
|
handler,
|
|
5741
5758
|
url,
|
|
5742
5759
|
init,
|
|
5743
|
-
m.route.id
|
|
5760
|
+
m.route.id,
|
|
5761
|
+
turboV3
|
|
5744
5762
|
);
|
|
5745
5763
|
results[m.route.id] = { type: "data", result };
|
|
5746
5764
|
} catch (e) {
|
|
@@ -5774,13 +5792,13 @@ async function singleFetchLoaderNavigationStrategy(manifest, routeModules, route
|
|
|
5774
5792
|
singleFetchDfd.resolve({});
|
|
5775
5793
|
} else {
|
|
5776
5794
|
try {
|
|
5777
|
-
if (foundOptOutRoute && routesParams.size > 0) {
|
|
5795
|
+
if (ssr && foundOptOutRoute && routesParams.size > 0) {
|
|
5778
5796
|
url.searchParams.set(
|
|
5779
5797
|
"_routes",
|
|
5780
5798
|
matches.filter((m) => routesParams.has(m.route.id)).map((m) => m.route.id).join(",")
|
|
5781
5799
|
);
|
|
5782
5800
|
}
|
|
5783
|
-
let data2 = await fetchAndDecode(url, init);
|
|
5801
|
+
let data2 = await fetchAndDecode(url, init, turboV3);
|
|
5784
5802
|
singleFetchDfd.resolve(data2.data);
|
|
5785
5803
|
} catch (e) {
|
|
5786
5804
|
singleFetchDfd.reject(e);
|
|
@@ -5789,21 +5807,27 @@ async function singleFetchLoaderNavigationStrategy(manifest, routeModules, route
|
|
|
5789
5807
|
await resolvePromise;
|
|
5790
5808
|
return results;
|
|
5791
5809
|
}
|
|
5792
|
-
async function singleFetchLoaderFetcherStrategy(request, matches) {
|
|
5810
|
+
async function singleFetchLoaderFetcherStrategy(request, matches, turboV3) {
|
|
5793
5811
|
let fetcherMatch = matches.find((m) => m.shouldLoad);
|
|
5794
5812
|
invariant2(fetcherMatch, "No fetcher match found");
|
|
5795
5813
|
let result = await fetcherMatch.resolve(async (handler) => {
|
|
5796
5814
|
let url = stripIndexParam(singleFetchUrl(request.url));
|
|
5797
5815
|
let init = await createRequestInit(request);
|
|
5798
|
-
return fetchSingleLoader(
|
|
5816
|
+
return fetchSingleLoader(
|
|
5817
|
+
handler,
|
|
5818
|
+
url,
|
|
5819
|
+
init,
|
|
5820
|
+
fetcherMatch.route.id,
|
|
5821
|
+
turboV3
|
|
5822
|
+
);
|
|
5799
5823
|
});
|
|
5800
5824
|
return { [fetcherMatch.route.id]: result };
|
|
5801
5825
|
}
|
|
5802
|
-
function fetchSingleLoader(handler, url, init, routeId) {
|
|
5826
|
+
function fetchSingleLoader(handler, url, init, routeId, turboV3) {
|
|
5803
5827
|
return handler(async () => {
|
|
5804
5828
|
let singleLoaderUrl = new URL(url);
|
|
5805
5829
|
singleLoaderUrl.searchParams.set("_routes", routeId);
|
|
5806
|
-
let { data: data2 } = await fetchAndDecode(singleLoaderUrl, init);
|
|
5830
|
+
let { data: data2 } = await fetchAndDecode(singleLoaderUrl, init, turboV3);
|
|
5807
5831
|
return unwrapSingleFetchResults(data2, routeId);
|
|
5808
5832
|
});
|
|
5809
5833
|
}
|
|
@@ -5835,7 +5859,7 @@ function singleFetchUrl(reqUrl) {
|
|
|
5835
5859
|
}
|
|
5836
5860
|
return url;
|
|
5837
5861
|
}
|
|
5838
|
-
async function fetchAndDecode(url, init) {
|
|
5862
|
+
async function fetchAndDecode(url, init, turboV3) {
|
|
5839
5863
|
let res = await fetch(url, init);
|
|
5840
5864
|
if (res.status === 404 && !res.headers.has("X-Remix-Response")) {
|
|
5841
5865
|
throw new ErrorResponseImpl(404, "Not Found", true);
|
|
@@ -5850,13 +5874,35 @@ async function fetchAndDecode(url, init) {
|
|
|
5850
5874
|
}
|
|
5851
5875
|
invariant2(res.body, "No response body to decode");
|
|
5852
5876
|
try {
|
|
5853
|
-
let decoded = await decodeViaTurboStream(res.body, window);
|
|
5854
|
-
return { status: res.status, data: decoded
|
|
5877
|
+
let decoded = await decodeViaTurboStream(res.body, window, turboV3);
|
|
5878
|
+
return { status: res.status, data: decoded };
|
|
5855
5879
|
} catch (e) {
|
|
5856
5880
|
throw new Error("Unable to decode turbo-stream response");
|
|
5857
5881
|
}
|
|
5858
5882
|
}
|
|
5859
|
-
function decodeViaTurboStream(body, global2) {
|
|
5883
|
+
async function decodeViaTurboStream(body, global2, turboV3) {
|
|
5884
|
+
if (turboV3) {
|
|
5885
|
+
const { decode: decode2 } = await import("turbo-stream");
|
|
5886
|
+
return decode2(body.pipeThrough(new TextDecoderStream()), {
|
|
5887
|
+
plugins: [
|
|
5888
|
+
(type, ...rest) => {
|
|
5889
|
+
if (type === "ErrorResponse") {
|
|
5890
|
+
let [data2, status, statusText] = rest;
|
|
5891
|
+
return {
|
|
5892
|
+
value: new ErrorResponseImpl(status, statusText, data2)
|
|
5893
|
+
};
|
|
5894
|
+
}
|
|
5895
|
+
if (type === "SingleFetchRedirect") {
|
|
5896
|
+
return { value: { [SingleFetchRedirectSymbol]: rest[0] } };
|
|
5897
|
+
}
|
|
5898
|
+
}
|
|
5899
|
+
]
|
|
5900
|
+
});
|
|
5901
|
+
}
|
|
5902
|
+
const { decode } = await import(
|
|
5903
|
+
// @ts-expect-error - bad tsconfig
|
|
5904
|
+
"./turbo-stream-TG2U76TX.mjs"
|
|
5905
|
+
);
|
|
5860
5906
|
return decode(body, {
|
|
5861
5907
|
plugins: [
|
|
5862
5908
|
(type, ...rest) => {
|
|
@@ -5887,7 +5933,7 @@ function decodeViaTurboStream(body, global2) {
|
|
|
5887
5933
|
}
|
|
5888
5934
|
}
|
|
5889
5935
|
]
|
|
5890
|
-
});
|
|
5936
|
+
}).then((res) => res.value);
|
|
5891
5937
|
}
|
|
5892
5938
|
function unwrapSingleFetchResults(results, routeId) {
|
|
5893
5939
|
let redirect2 = results[SingleFetchRedirectSymbol];
|
|
@@ -6142,11 +6188,12 @@ function createServerRoutes(manifest, routeModules, future, isSpaMode, parentId
|
|
|
6142
6188
|
return dataRoute;
|
|
6143
6189
|
});
|
|
6144
6190
|
}
|
|
6145
|
-
function createClientRoutesWithHMRRevalidationOptOut(needsRevalidation, manifest, routeModulesCache, initialState,
|
|
6191
|
+
function createClientRoutesWithHMRRevalidationOptOut(needsRevalidation, manifest, routeModulesCache, initialState, ssr, isSpaMode) {
|
|
6146
6192
|
return createClientRoutes(
|
|
6147
6193
|
manifest,
|
|
6148
6194
|
routeModulesCache,
|
|
6149
6195
|
initialState,
|
|
6196
|
+
ssr,
|
|
6150
6197
|
isSpaMode,
|
|
6151
6198
|
"",
|
|
6152
6199
|
groupRoutesByParentId(manifest),
|
|
@@ -6155,14 +6202,14 @@ function createClientRoutesWithHMRRevalidationOptOut(needsRevalidation, manifest
|
|
|
6155
6202
|
}
|
|
6156
6203
|
function preventInvalidServerHandlerCall(type, route, isSpaMode) {
|
|
6157
6204
|
if (isSpaMode) {
|
|
6158
|
-
let
|
|
6159
|
-
let
|
|
6160
|
-
console.error(
|
|
6161
|
-
throw new ErrorResponseImpl(400, "Bad Request", new Error(
|
|
6205
|
+
let fn = type === "action" ? "serverAction()" : "serverLoader()";
|
|
6206
|
+
let msg = `You cannot call ${fn} in SPA Mode (routeId: "${route.id}")`;
|
|
6207
|
+
console.error(msg);
|
|
6208
|
+
throw new ErrorResponseImpl(400, "Bad Request", new Error(msg), true);
|
|
6162
6209
|
}
|
|
6163
|
-
let fn = type === "action" ? "serverAction()" : "serverLoader()";
|
|
6164
|
-
let msg = `You are trying to call ${fn} on a route that does not have a server ${type} (routeId: "${route.id}")`;
|
|
6165
6210
|
if (type === "loader" && !route.hasLoader || type === "action" && !route.hasAction) {
|
|
6211
|
+
let fn = type === "action" ? "serverAction()" : "serverLoader()";
|
|
6212
|
+
let msg = `You are trying to call ${fn} on a route that does not have a server ${type} (routeId: "${route.id}")`;
|
|
6166
6213
|
console.error(msg);
|
|
6167
6214
|
throw new ErrorResponseImpl(400, "Bad Request", new Error(msg), true);
|
|
6168
6215
|
}
|
|
@@ -6173,7 +6220,7 @@ function noActionDefinedError(type, routeId) {
|
|
|
6173
6220
|
console.error(msg);
|
|
6174
6221
|
throw new ErrorResponseImpl(405, "Method Not Allowed", new Error(msg), true);
|
|
6175
6222
|
}
|
|
6176
|
-
function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode, parentId = "", routesByParentId = groupRoutesByParentId(manifest), needsRevalidation) {
|
|
6223
|
+
function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSpaMode, parentId = "", routesByParentId = groupRoutesByParentId(manifest), needsRevalidation) {
|
|
6177
6224
|
return (routesByParentId[parentId] || []).map((route) => {
|
|
6178
6225
|
let routeModule = routeModulesCache[route.id];
|
|
6179
6226
|
function fetchServerHandler(singleFetch) {
|
|
@@ -6229,7 +6276,8 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
|
|
|
6229
6276
|
handle: routeModule.handle,
|
|
6230
6277
|
shouldRevalidate: getShouldRevalidateFunction(
|
|
6231
6278
|
routeModule,
|
|
6232
|
-
route
|
|
6279
|
+
route,
|
|
6280
|
+
ssr,
|
|
6233
6281
|
needsRevalidation
|
|
6234
6282
|
)
|
|
6235
6283
|
});
|
|
@@ -6246,7 +6294,6 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
|
|
|
6246
6294
|
"No `routeModule` available for critical-route loader"
|
|
6247
6295
|
);
|
|
6248
6296
|
if (!routeModule.clientLoader) {
|
|
6249
|
-
if (isSpaMode) return null;
|
|
6250
6297
|
return fetchServerLoader(singleFetch);
|
|
6251
6298
|
}
|
|
6252
6299
|
return routeModule.clientLoader({
|
|
@@ -6301,7 +6348,6 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
|
|
|
6301
6348
|
} else {
|
|
6302
6349
|
if (!route.hasClientLoader) {
|
|
6303
6350
|
dataRoute.loader = ({ request }, singleFetch) => prefetchStylesAndCallHandler(() => {
|
|
6304
|
-
if (isSpaMode) return Promise.resolve(null);
|
|
6305
6351
|
return fetchServerLoader(singleFetch);
|
|
6306
6352
|
});
|
|
6307
6353
|
} else if (route.clientLoaderModule) {
|
|
@@ -6383,7 +6429,8 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
|
|
|
6383
6429
|
hasErrorBoundary: lazyRoute.hasErrorBoundary,
|
|
6384
6430
|
shouldRevalidate: getShouldRevalidateFunction(
|
|
6385
6431
|
lazyRoute,
|
|
6386
|
-
route
|
|
6432
|
+
route,
|
|
6433
|
+
ssr,
|
|
6387
6434
|
needsRevalidation
|
|
6388
6435
|
),
|
|
6389
6436
|
handle: lazyRoute.handle,
|
|
@@ -6398,6 +6445,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
|
|
|
6398
6445
|
manifest,
|
|
6399
6446
|
routeModulesCache,
|
|
6400
6447
|
initialState,
|
|
6448
|
+
ssr,
|
|
6401
6449
|
isSpaMode,
|
|
6402
6450
|
route.id,
|
|
6403
6451
|
routesByParentId,
|
|
@@ -6407,15 +6455,18 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
|
|
|
6407
6455
|
return dataRoute;
|
|
6408
6456
|
});
|
|
6409
6457
|
}
|
|
6410
|
-
function getShouldRevalidateFunction(route,
|
|
6458
|
+
function getShouldRevalidateFunction(route, manifestRoute, ssr, needsRevalidation) {
|
|
6411
6459
|
if (needsRevalidation) {
|
|
6412
6460
|
return wrapShouldRevalidateForHdr(
|
|
6413
|
-
|
|
6461
|
+
manifestRoute.id,
|
|
6414
6462
|
route.shouldRevalidate,
|
|
6415
6463
|
needsRevalidation
|
|
6416
6464
|
);
|
|
6417
6465
|
}
|
|
6418
|
-
if (
|
|
6466
|
+
if (!ssr && manifestRoute.id === "root" && manifestRoute.hasLoader && !manifestRoute.hasClientLoader) {
|
|
6467
|
+
return () => false;
|
|
6468
|
+
}
|
|
6469
|
+
if (ssr && route.shouldRevalidate) {
|
|
6419
6470
|
let fn = route.shouldRevalidate;
|
|
6420
6471
|
return (opts) => fn({ ...opts, defaultShouldRevalidate: true });
|
|
6421
6472
|
}
|
|
@@ -6505,6 +6556,7 @@ function getPatchRoutesOnNavigationFunction(manifest, routeModules, ssr, isSpaMo
|
|
|
6505
6556
|
[path],
|
|
6506
6557
|
manifest,
|
|
6507
6558
|
routeModules,
|
|
6559
|
+
ssr,
|
|
6508
6560
|
isSpaMode,
|
|
6509
6561
|
basename,
|
|
6510
6562
|
patch,
|
|
@@ -6544,6 +6596,7 @@ function useFogOFWarDiscovery(router, manifest, routeModules, ssr, isSpaMode) {
|
|
|
6544
6596
|
lazyPaths,
|
|
6545
6597
|
manifest,
|
|
6546
6598
|
routeModules,
|
|
6599
|
+
ssr,
|
|
6547
6600
|
isSpaMode,
|
|
6548
6601
|
router.basename,
|
|
6549
6602
|
router.patchRoutes
|
|
@@ -6564,7 +6617,7 @@ function useFogOFWarDiscovery(router, manifest, routeModules, ssr, isSpaMode) {
|
|
|
6564
6617
|
return () => observer.disconnect();
|
|
6565
6618
|
}, [ssr, isSpaMode, manifest, routeModules, router]);
|
|
6566
6619
|
}
|
|
6567
|
-
async function fetchAndApplyManifestPatches(paths, manifest, routeModules, isSpaMode, basename, patchRoutes, signal) {
|
|
6620
|
+
async function fetchAndApplyManifestPatches(paths, manifest, routeModules, ssr, isSpaMode, basename, patchRoutes, signal) {
|
|
6568
6621
|
let manifestPath = `${basename != null ? basename : "/"}/__manifest`.replace(
|
|
6569
6622
|
/\/+/g,
|
|
6570
6623
|
"/"
|
|
@@ -6607,7 +6660,7 @@ async function fetchAndApplyManifestPatches(paths, manifest, routeModules, isSpa
|
|
|
6607
6660
|
parentIds.forEach(
|
|
6608
6661
|
(parentId) => patchRoutes(
|
|
6609
6662
|
parentId || null,
|
|
6610
|
-
createClientRoutes(patches, routeModules, null, isSpaMode, parentId)
|
|
6663
|
+
createClientRoutes(patches, routeModules, null, ssr, isSpaMode, parentId)
|
|
6611
6664
|
)
|
|
6612
6665
|
);
|
|
6613
6666
|
}
|
|
@@ -6962,6 +7015,7 @@ function Scripts(props) {
|
|
|
6962
7015
|
let enableFogOfWar = isFogOfWarEnabled(ssr);
|
|
6963
7016
|
if (renderMeta) {
|
|
6964
7017
|
renderMeta.didRenderScripts = true;
|
|
7018
|
+
renderMeta.nonce = props.nonce;
|
|
6965
7019
|
}
|
|
6966
7020
|
let matches = getActiveMatches(routerMatches, null, isSpaMode);
|
|
6967
7021
|
React9.useEffect(() => {
|
|
@@ -7087,7 +7141,7 @@ function mergeRefs(...refs) {
|
|
|
7087
7141
|
var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
7088
7142
|
try {
|
|
7089
7143
|
if (isBrowser) {
|
|
7090
|
-
window.__reactRouterVersion = "0.0.0-experimental-
|
|
7144
|
+
window.__reactRouterVersion = "0.0.0-experimental-66d5af831";
|
|
7091
7145
|
}
|
|
7092
7146
|
} catch (e) {
|
|
7093
7147
|
}
|
|
@@ -8693,8 +8747,12 @@ function createStaticHandlerDataRoutes(manifest, future, parentId = "", routesBy
|
|
|
8693
8747
|
controller.close();
|
|
8694
8748
|
}
|
|
8695
8749
|
});
|
|
8696
|
-
let decoded = await decodeViaTurboStream(
|
|
8697
|
-
|
|
8750
|
+
let decoded = await decodeViaTurboStream(
|
|
8751
|
+
stream,
|
|
8752
|
+
global,
|
|
8753
|
+
future.turboV3 ?? false
|
|
8754
|
+
);
|
|
8755
|
+
let data2 = decoded;
|
|
8698
8756
|
invariant3(
|
|
8699
8757
|
data2 && route.id in data2,
|
|
8700
8758
|
"Unable to decode prerendered data"
|
|
@@ -8753,7 +8811,7 @@ function getDevServerHooks() {
|
|
|
8753
8811
|
}
|
|
8754
8812
|
|
|
8755
8813
|
// lib/server-runtime/single-fetch.ts
|
|
8756
|
-
import { encode } from "turbo-stream";
|
|
8814
|
+
import { encode as encode2 } from "turbo-stream";
|
|
8757
8815
|
|
|
8758
8816
|
// lib/server-runtime/headers.ts
|
|
8759
8817
|
import { splitCookiesString } from "set-cookie-parser";
|
|
@@ -9007,13 +9065,33 @@ function getSingleFetchRedirect(status, headers, basename) {
|
|
|
9007
9065
|
replace: headers.has("X-Remix-Replace")
|
|
9008
9066
|
};
|
|
9009
9067
|
}
|
|
9010
|
-
function encodeViaTurboStream(data2, requestSignal, streamTimeout, serverMode) {
|
|
9068
|
+
function encodeViaTurboStream(data2, requestSignal, streamTimeout, serverMode, turboV3) {
|
|
9011
9069
|
let controller = new AbortController();
|
|
9012
9070
|
let timeoutId = setTimeout(
|
|
9013
9071
|
() => controller.abort(new Error("Server Timeout")),
|
|
9014
9072
|
typeof streamTimeout === "number" ? streamTimeout : 4950
|
|
9015
9073
|
);
|
|
9016
9074
|
requestSignal.addEventListener("abort", () => clearTimeout(timeoutId));
|
|
9075
|
+
if (turboV3) {
|
|
9076
|
+
return encode2(data2, {
|
|
9077
|
+
signal: controller.signal,
|
|
9078
|
+
redactErrors: serverMode === "development" /* Development */ ? false : "Unexpected Server Error",
|
|
9079
|
+
plugins: [
|
|
9080
|
+
(value) => {
|
|
9081
|
+
if (value instanceof ErrorResponseImpl) {
|
|
9082
|
+
let { data: data3, status, statusText } = value;
|
|
9083
|
+
return ["ErrorResponse", data3, status, statusText];
|
|
9084
|
+
}
|
|
9085
|
+
if (SingleFetchRedirectSymbol in value) {
|
|
9086
|
+
return [
|
|
9087
|
+
"SingleFetchRedirect",
|
|
9088
|
+
value[SingleFetchRedirectSymbol]
|
|
9089
|
+
];
|
|
9090
|
+
}
|
|
9091
|
+
}
|
|
9092
|
+
]
|
|
9093
|
+
}).pipeThrough(new TextEncoderStream());
|
|
9094
|
+
}
|
|
9017
9095
|
return encode(data2, {
|
|
9018
9096
|
signal: controller.signal,
|
|
9019
9097
|
plugins: [
|
|
@@ -9092,6 +9170,10 @@ var createRequestHandler = (build, mode) => {
|
|
|
9092
9170
|
errorHandler = derived.errorHandler;
|
|
9093
9171
|
}
|
|
9094
9172
|
let url = new URL(request.url);
|
|
9173
|
+
let normalizedPath = url.pathname.replace(/\.data$/, "").replace(/^\/_root$/, "/");
|
|
9174
|
+
if (normalizedPath !== "/" && normalizedPath.endsWith("/")) {
|
|
9175
|
+
normalizedPath = normalizedPath.slice(0, -1);
|
|
9176
|
+
}
|
|
9095
9177
|
let params = {};
|
|
9096
9178
|
let handleError = (error) => {
|
|
9097
9179
|
if (mode === "development" /* Development */) {
|
|
@@ -9103,6 +9185,32 @@ var createRequestHandler = (build, mode) => {
|
|
|
9103
9185
|
request
|
|
9104
9186
|
});
|
|
9105
9187
|
};
|
|
9188
|
+
if (!_build.ssr) {
|
|
9189
|
+
if (_build.prerender.length === 0) {
|
|
9190
|
+
request.headers.set("X-React-Router-SPA-Mode", "yes");
|
|
9191
|
+
} else if (!_build.prerender.includes(normalizedPath) && !_build.prerender.includes(normalizedPath + "/")) {
|
|
9192
|
+
if (url.pathname.endsWith(".data")) {
|
|
9193
|
+
errorHandler(
|
|
9194
|
+
new ErrorResponseImpl(
|
|
9195
|
+
404,
|
|
9196
|
+
"Not Found",
|
|
9197
|
+
`Refusing to SSR the path \`${normalizedPath}\` because \`ssr:false\` is set and the path is not included in the \`prerender\` config, so in production the path will be a 404.`
|
|
9198
|
+
),
|
|
9199
|
+
{
|
|
9200
|
+
context: loadContext,
|
|
9201
|
+
params,
|
|
9202
|
+
request
|
|
9203
|
+
}
|
|
9204
|
+
);
|
|
9205
|
+
return new Response("Not Found", {
|
|
9206
|
+
status: 404,
|
|
9207
|
+
statusText: "Not Found"
|
|
9208
|
+
});
|
|
9209
|
+
} else {
|
|
9210
|
+
request.headers.set("X-React-Router-SPA-Mode", "yes");
|
|
9211
|
+
}
|
|
9212
|
+
}
|
|
9213
|
+
}
|
|
9106
9214
|
let manifestUrl = `${_build.basename ?? "/"}/__manifest`.replace(
|
|
9107
9215
|
/\/+/g,
|
|
9108
9216
|
"/"
|
|
@@ -9123,7 +9231,7 @@ var createRequestHandler = (build, mode) => {
|
|
|
9123
9231
|
let response;
|
|
9124
9232
|
if (url.pathname.endsWith(".data")) {
|
|
9125
9233
|
let handlerUrl = new URL(request.url);
|
|
9126
|
-
handlerUrl.pathname =
|
|
9234
|
+
handlerUrl.pathname = normalizedPath;
|
|
9127
9235
|
let singleFetchMatches = matchServerRoutes(
|
|
9128
9236
|
routes,
|
|
9129
9237
|
handlerUrl.pathname,
|
|
@@ -9162,7 +9270,8 @@ var createRequestHandler = (build, mode) => {
|
|
|
9162
9270
|
result,
|
|
9163
9271
|
request.signal,
|
|
9164
9272
|
_build.entry.module.streamTimeout,
|
|
9165
|
-
serverMode
|
|
9273
|
+
serverMode,
|
|
9274
|
+
_build.future.turboV3 ?? false
|
|
9166
9275
|
),
|
|
9167
9276
|
{
|
|
9168
9277
|
status: SINGLE_FETCH_REDIRECT_STATUS,
|
|
@@ -9192,6 +9301,9 @@ var createRequestHandler = (build, mode) => {
|
|
|
9192
9301
|
criticalCss
|
|
9193
9302
|
);
|
|
9194
9303
|
}
|
|
9304
|
+
if (!response) {
|
|
9305
|
+
return new Response("Unknown Server Error", { status: 500 });
|
|
9306
|
+
}
|
|
9195
9307
|
if (request.method === "HEAD") {
|
|
9196
9308
|
return new Response(null, {
|
|
9197
9309
|
headers: response.headers,
|
|
@@ -9254,7 +9366,8 @@ async function handleSingleFetchRequest(serverMode, build, staticHandler, reques
|
|
|
9254
9366
|
result,
|
|
9255
9367
|
request.signal,
|
|
9256
9368
|
build.entry.module.streamTimeout,
|
|
9257
|
-
serverMode
|
|
9369
|
+
serverMode,
|
|
9370
|
+
build.future.turboV3 ?? false
|
|
9258
9371
|
),
|
|
9259
9372
|
{
|
|
9260
9373
|
status: status || 200,
|
|
@@ -9263,6 +9376,7 @@ async function handleSingleFetchRequest(serverMode, build, staticHandler, reques
|
|
|
9263
9376
|
);
|
|
9264
9377
|
}
|
|
9265
9378
|
async function handleDocumentRequest(serverMode, build, staticHandler, request, loadContext, handleError, criticalCss) {
|
|
9379
|
+
let isSpaMode = request.headers.has("X-React-Router-SPA-Mode");
|
|
9266
9380
|
let context;
|
|
9267
9381
|
try {
|
|
9268
9382
|
context = await staticHandler.query(request, {
|
|
@@ -9287,6 +9401,7 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
|
|
|
9287
9401
|
});
|
|
9288
9402
|
context.errors = sanitizeErrors(context.errors, serverMode);
|
|
9289
9403
|
}
|
|
9404
|
+
let renderMeta = {};
|
|
9290
9405
|
let state = {
|
|
9291
9406
|
loaderData: context.loaderData,
|
|
9292
9407
|
actionData: context.actionData,
|
|
@@ -9302,23 +9417,25 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
|
|
|
9302
9417
|
criticalCss,
|
|
9303
9418
|
future: build.future,
|
|
9304
9419
|
ssr: build.ssr,
|
|
9305
|
-
isSpaMode
|
|
9420
|
+
isSpaMode
|
|
9306
9421
|
}),
|
|
9307
9422
|
serverHandoffStream: encodeViaTurboStream(
|
|
9308
9423
|
state,
|
|
9309
9424
|
request.signal,
|
|
9310
9425
|
build.entry.module.streamTimeout,
|
|
9311
|
-
serverMode
|
|
9426
|
+
serverMode,
|
|
9427
|
+
build.future.turboV3 ?? false
|
|
9312
9428
|
),
|
|
9313
|
-
renderMeta
|
|
9429
|
+
renderMeta,
|
|
9314
9430
|
future: build.future,
|
|
9315
9431
|
ssr: build.ssr,
|
|
9316
|
-
isSpaMode
|
|
9432
|
+
isSpaMode,
|
|
9317
9433
|
serializeError: (err) => serializeError(err, serverMode)
|
|
9318
9434
|
};
|
|
9319
9435
|
let handleDocumentRequestFunction = build.entry.module.default;
|
|
9436
|
+
let response;
|
|
9320
9437
|
try {
|
|
9321
|
-
|
|
9438
|
+
response = await handleDocumentRequestFunction(
|
|
9322
9439
|
request,
|
|
9323
9440
|
context.statusCode,
|
|
9324
9441
|
headers,
|
|
@@ -9359,18 +9476,19 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
|
|
|
9359
9476
|
basename: build.basename,
|
|
9360
9477
|
future: build.future,
|
|
9361
9478
|
ssr: build.ssr,
|
|
9362
|
-
isSpaMode
|
|
9479
|
+
isSpaMode
|
|
9363
9480
|
}),
|
|
9364
9481
|
serverHandoffStream: encodeViaTurboStream(
|
|
9365
9482
|
state2,
|
|
9366
9483
|
request.signal,
|
|
9367
9484
|
build.entry.module.streamTimeout,
|
|
9368
|
-
serverMode
|
|
9485
|
+
serverMode,
|
|
9486
|
+
build.future.turboV3 ?? false
|
|
9369
9487
|
),
|
|
9370
|
-
renderMeta
|
|
9488
|
+
renderMeta
|
|
9371
9489
|
};
|
|
9372
9490
|
try {
|
|
9373
|
-
|
|
9491
|
+
response = await handleDocumentRequestFunction(
|
|
9374
9492
|
request,
|
|
9375
9493
|
context.statusCode,
|
|
9376
9494
|
headers,
|
|
@@ -9379,9 +9497,33 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
|
|
|
9379
9497
|
);
|
|
9380
9498
|
} catch (error2) {
|
|
9381
9499
|
handleError(error2);
|
|
9382
|
-
|
|
9500
|
+
response = returnLastResortErrorResponse(error2, serverMode);
|
|
9383
9501
|
}
|
|
9384
9502
|
}
|
|
9503
|
+
if (!response) {
|
|
9504
|
+
return void 0;
|
|
9505
|
+
}
|
|
9506
|
+
return new Response(
|
|
9507
|
+
response.body?.pipeThrough(
|
|
9508
|
+
new TransformStream({
|
|
9509
|
+
flush(controller) {
|
|
9510
|
+
if (renderMeta.didRenderScripts) {
|
|
9511
|
+
const script = renderMeta.nonce ? `<script nonce="${renderMeta.nonce}">` : "<script>";
|
|
9512
|
+
controller.enqueue(
|
|
9513
|
+
new TextEncoder().encode(
|
|
9514
|
+
`${script}if (!window.__reactRouterContext.streamDone)window.__reactRouterContext.streamController.error(new Error("Server aborted."));</script>`
|
|
9515
|
+
)
|
|
9516
|
+
);
|
|
9517
|
+
}
|
|
9518
|
+
}
|
|
9519
|
+
})
|
|
9520
|
+
),
|
|
9521
|
+
{
|
|
9522
|
+
headers: response.headers,
|
|
9523
|
+
status: response.status,
|
|
9524
|
+
statusText: response.statusText
|
|
9525
|
+
}
|
|
9526
|
+
);
|
|
9385
9527
|
}
|
|
9386
9528
|
async function handleResourceRequest(serverMode, staticHandler, routeId, request, loadContext, handleError) {
|
|
9387
9529
|
try {
|