react-router 0.0.0-experimental-e56aa53bc → 0.0.0-experimental-aecfb0db1
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 +19 -0
- package/dist/development/{chunk-RMWJZNG5.mjs → chunk-RXFCVJK2.mjs} +1132 -1142
- package/dist/development/dom-export.d.mts +2 -2
- package/dist/development/dom-export.d.ts +1 -2
- package/dist/development/dom-export.js +34 -6129
- package/dist/development/dom-export.mjs +6 -3
- package/dist/development/index.d.mts +13 -68
- package/dist/development/index.d.ts +1873 -198
- package/dist/development/index.js +1132 -1151
- package/dist/development/index.mjs +2 -19
- package/dist/development/lib/types/route-module.d.mts +1 -2
- package/dist/development/lib/types/route-module.d.ts +1 -2
- package/dist/development/lib/types/route-module.js +1 -1
- package/dist/development/lib/types/route-module.mjs +1 -1
- package/dist/development/{fog-of-war-DrUCUQQ-.d.ts → lib-BJBhVBWN.d.mts} +136 -178
- package/dist/{production/route-data-BIYebJr3.d.mts → development/route-data-BmDen1H_.d.mts} +12 -12
- package/dist/development/{route-data-BIYebJr3.d.mts → route-data-fNWkI-4T.d.ts} +12 -12
- package/dist/production/{chunk-BXBFRMFA.mjs → chunk-TLRBG5AD.mjs} +1132 -1142
- package/dist/production/dom-export.d.mts +2 -2
- package/dist/production/dom-export.d.ts +1 -2
- package/dist/production/dom-export.js +34 -6129
- package/dist/production/dom-export.mjs +6 -3
- package/dist/production/index.d.mts +13 -68
- package/dist/production/index.d.ts +1873 -198
- package/dist/production/index.js +1132 -1151
- package/dist/production/index.mjs +2 -19
- package/dist/production/lib/types/route-module.d.mts +1 -2
- package/dist/production/lib/types/route-module.d.ts +1 -2
- package/dist/production/lib/types/route-module.js +1 -1
- package/dist/production/lib/types/route-module.mjs +1 -1
- package/dist/production/{fog-of-war-DrUCUQQ-.d.ts → lib-BJBhVBWN.d.mts} +136 -178
- package/dist/{development/route-data-BIYebJr3.d.ts → production/route-data-BmDen1H_.d.mts} +12 -12
- package/dist/production/{route-data-BIYebJr3.d.ts → route-data-fNWkI-4T.d.ts} +12 -12
- package/package.json +6 -35
- package/dist/development/data-CQbyyGzl.d.mts +0 -11
- package/dist/development/data-CQbyyGzl.d.ts +0 -11
- package/dist/development/fog-of-war-C5L_Yd5M.d.mts +0 -1778
- package/dist/development/rsc-export.d.mts +0 -1788
- package/dist/development/rsc-export.d.ts +0 -1788
- package/dist/development/rsc-export.js +0 -2778
- package/dist/development/rsc-export.mjs +0 -2743
- package/dist/production/data-CQbyyGzl.d.mts +0 -11
- package/dist/production/data-CQbyyGzl.d.ts +0 -11
- package/dist/production/fog-of-war-C5L_Yd5M.d.mts +0 -1778
- package/dist/production/rsc-export.d.mts +0 -1788
- package/dist/production/rsc-export.d.ts +0 -1788
- package/dist/production/rsc-export.js +0 -2778
- package/dist/production/rsc-export.mjs +0 -2743
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v0.0.0-experimental-
|
|
2
|
+
* react-router v0.0.0-experimental-aecfb0db1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
11
|
"use strict";
|
|
12
|
-
"use client";
|
|
13
12
|
var __create = Object.create;
|
|
14
13
|
var __defProp = Object.defineProperty;
|
|
15
14
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -63,8 +62,6 @@ __export(react_router_exports, {
|
|
|
63
62
|
NavigationType: () => Action,
|
|
64
63
|
Outlet: () => Outlet,
|
|
65
64
|
PrefetchPageLinks: () => PrefetchPageLinks,
|
|
66
|
-
RSCHydratedRouter: () => RSCHydratedRouter,
|
|
67
|
-
RSCStaticRouter: () => RSCStaticRouter,
|
|
68
65
|
Route: () => Route,
|
|
69
66
|
Router: () => Router,
|
|
70
67
|
RouterProvider: () => RouterProvider,
|
|
@@ -86,9 +83,6 @@ __export(react_router_exports, {
|
|
|
86
83
|
UNSAFE_ServerMode: () => ServerMode,
|
|
87
84
|
UNSAFE_SingleFetchRedirectSymbol: () => SingleFetchRedirectSymbol,
|
|
88
85
|
UNSAFE_ViewTransitionContext: () => ViewTransitionContext,
|
|
89
|
-
UNSAFE_WithErrorBoundaryProps: () => WithErrorBoundaryProps,
|
|
90
|
-
UNSAFE_WithHydrateFallbackProps: () => WithHydrateFallbackProps,
|
|
91
|
-
UNSAFE_WithRouteComponentProps: () => WithRouteComponentProps,
|
|
92
86
|
UNSAFE_createBrowserHistory: () => createBrowserHistory,
|
|
93
87
|
UNSAFE_createClientRoutes: () => createClientRoutes,
|
|
94
88
|
UNSAFE_createClientRoutesWithHMRRevalidationOptOut: () => createClientRoutesWithHMRRevalidationOptOut,
|
|
@@ -105,7 +99,6 @@ __export(react_router_exports, {
|
|
|
105
99
|
UNSAFE_useFogOFWarDiscovery: () => useFogOFWarDiscovery,
|
|
106
100
|
UNSAFE_useScrollRestoration: () => useScrollRestoration,
|
|
107
101
|
createBrowserRouter: () => createBrowserRouter,
|
|
108
|
-
createCallServer: () => createCallServer,
|
|
109
102
|
createCookie: () => createCookie,
|
|
110
103
|
createCookieSessionStorage: () => createCookieSessionStorage,
|
|
111
104
|
createHashRouter: () => createHashRouter,
|
|
@@ -123,7 +116,6 @@ __export(react_router_exports, {
|
|
|
123
116
|
createStaticRouter: () => createStaticRouter,
|
|
124
117
|
data: () => data,
|
|
125
118
|
generatePath: () => generatePath,
|
|
126
|
-
getServerStream: () => getServerStream,
|
|
127
119
|
href: () => href,
|
|
128
120
|
isCookie: () => isCookie,
|
|
129
121
|
isRouteErrorResponse: () => isRouteErrorResponse,
|
|
@@ -136,7 +128,6 @@ __export(react_router_exports, {
|
|
|
136
128
|
renderMatches: () => renderMatches,
|
|
137
129
|
replace: () => replace,
|
|
138
130
|
resolvePath: () => resolvePath,
|
|
139
|
-
routeRSCServerRequest: () => routeRSCServerRequest,
|
|
140
131
|
unstable_HistoryRouter: () => HistoryRouter,
|
|
141
132
|
unstable_RouterContextProvider: () => unstable_RouterContextProvider,
|
|
142
133
|
unstable_createContext: () => unstable_createContext,
|
|
@@ -204,19 +195,19 @@ function createMemoryHistory(options = {}) {
|
|
|
204
195
|
return entries[index];
|
|
205
196
|
}
|
|
206
197
|
function createMemoryLocation(to, state = null, key) {
|
|
207
|
-
let
|
|
198
|
+
let location = createLocation(
|
|
208
199
|
entries ? getCurrentLocation().pathname : "/",
|
|
209
200
|
to,
|
|
210
201
|
state,
|
|
211
202
|
key
|
|
212
203
|
);
|
|
213
204
|
warning(
|
|
214
|
-
|
|
205
|
+
location.pathname.charAt(0) === "/",
|
|
215
206
|
`relative pathnames are not supported in memory history: ${JSON.stringify(
|
|
216
207
|
to
|
|
217
208
|
)}`
|
|
218
209
|
);
|
|
219
|
-
return
|
|
210
|
+
return location;
|
|
220
211
|
}
|
|
221
212
|
function createHref2(to) {
|
|
222
213
|
return typeof to === "string" ? to : createPath(to);
|
|
@@ -327,9 +318,9 @@ function createHashHistory(options = {}) {
|
|
|
327
318
|
}
|
|
328
319
|
return href2 + "#" + (typeof to === "string" ? to : createPath(to));
|
|
329
320
|
}
|
|
330
|
-
function validateHashLocation(
|
|
321
|
+
function validateHashLocation(location, to) {
|
|
331
322
|
warning(
|
|
332
|
-
|
|
323
|
+
location.pathname.charAt(0) === "/",
|
|
333
324
|
`relative pathnames are not supported in hash history.push(${JSON.stringify(
|
|
334
325
|
to
|
|
335
326
|
)})`
|
|
@@ -359,15 +350,15 @@ function warning(cond, message) {
|
|
|
359
350
|
function createKey() {
|
|
360
351
|
return Math.random().toString(36).substring(2, 10);
|
|
361
352
|
}
|
|
362
|
-
function getHistoryState(
|
|
353
|
+
function getHistoryState(location, index) {
|
|
363
354
|
return {
|
|
364
|
-
usr:
|
|
365
|
-
key:
|
|
355
|
+
usr: location.state,
|
|
356
|
+
key: location.key,
|
|
366
357
|
idx: index
|
|
367
358
|
};
|
|
368
359
|
}
|
|
369
360
|
function createLocation(current, to, state = null, key) {
|
|
370
|
-
let
|
|
361
|
+
let location = {
|
|
371
362
|
pathname: typeof current === "string" ? current : current.pathname,
|
|
372
363
|
search: "",
|
|
373
364
|
hash: "",
|
|
@@ -379,7 +370,7 @@ function createLocation(current, to, state = null, key) {
|
|
|
379
370
|
// keep as is for the time being and just let any incoming keys take precedence
|
|
380
371
|
key: to && to.key || key || createKey()
|
|
381
372
|
};
|
|
382
|
-
return
|
|
373
|
+
return location;
|
|
383
374
|
}
|
|
384
375
|
function createPath({
|
|
385
376
|
pathname = "/",
|
|
@@ -436,11 +427,11 @@ function getUrlBasedHistory(getLocation, createHref2, validateLocation, options
|
|
|
436
427
|
}
|
|
437
428
|
function push(to, state) {
|
|
438
429
|
action = "PUSH" /* Push */;
|
|
439
|
-
let
|
|
440
|
-
if (validateLocation) validateLocation(
|
|
430
|
+
let location = createLocation(history.location, to, state);
|
|
431
|
+
if (validateLocation) validateLocation(location, to);
|
|
441
432
|
index = getIndex() + 1;
|
|
442
|
-
let historyState = getHistoryState(
|
|
443
|
-
let url = history.createHref(
|
|
433
|
+
let historyState = getHistoryState(location, index);
|
|
434
|
+
let url = history.createHref(location);
|
|
444
435
|
try {
|
|
445
436
|
globalHistory.pushState(historyState, "", url);
|
|
446
437
|
} catch (error) {
|
|
@@ -455,25 +446,18 @@ function getUrlBasedHistory(getLocation, createHref2, validateLocation, options
|
|
|
455
446
|
}
|
|
456
447
|
function replace2(to, state) {
|
|
457
448
|
action = "REPLACE" /* Replace */;
|
|
458
|
-
let
|
|
459
|
-
if (validateLocation) validateLocation(
|
|
449
|
+
let location = createLocation(history.location, to, state);
|
|
450
|
+
if (validateLocation) validateLocation(location, to);
|
|
460
451
|
index = getIndex();
|
|
461
|
-
let historyState = getHistoryState(
|
|
462
|
-
let url = history.createHref(
|
|
452
|
+
let historyState = getHistoryState(location, index);
|
|
453
|
+
let url = history.createHref(location);
|
|
463
454
|
globalHistory.replaceState(historyState, "", url);
|
|
464
455
|
if (v5Compat && listener) {
|
|
465
456
|
listener({ action, location: history.location, delta: 0 });
|
|
466
457
|
}
|
|
467
458
|
}
|
|
468
459
|
function createURL(to) {
|
|
469
|
-
|
|
470
|
-
let href2 = typeof to === "string" ? to : createPath(to);
|
|
471
|
-
href2 = href2.replace(/ $/, "%20");
|
|
472
|
-
invariant(
|
|
473
|
-
base,
|
|
474
|
-
`No window.location.(origin|href) available to create URL for href: ${href2}`
|
|
475
|
-
);
|
|
476
|
-
return new URL(href2, base);
|
|
460
|
+
return createBrowserURLImpl(to);
|
|
477
461
|
}
|
|
478
462
|
let history = {
|
|
479
463
|
get action() {
|
|
@@ -513,6 +497,19 @@ function getUrlBasedHistory(getLocation, createHref2, validateLocation, options
|
|
|
513
497
|
};
|
|
514
498
|
return history;
|
|
515
499
|
}
|
|
500
|
+
function createBrowserURLImpl(to, isAbsolute = false) {
|
|
501
|
+
let base = "http://localhost";
|
|
502
|
+
if (typeof window !== "undefined") {
|
|
503
|
+
base = window.location.origin !== "null" ? window.location.origin : window.location.href;
|
|
504
|
+
}
|
|
505
|
+
invariant(base, "No window.location.(origin|href) available to create URL");
|
|
506
|
+
let href2 = typeof to === "string" ? to : createPath(to);
|
|
507
|
+
href2 = href2.replace(/ $/, "%20");
|
|
508
|
+
if (!isAbsolute && href2.startsWith("//")) {
|
|
509
|
+
href2 = base + href2;
|
|
510
|
+
}
|
|
511
|
+
return new URL(href2, base);
|
|
512
|
+
}
|
|
516
513
|
|
|
517
514
|
// lib/router/utils.ts
|
|
518
515
|
function unstable_createContext(defaultValue) {
|
|
@@ -572,7 +569,7 @@ function isUnsupportedLazyRouteFunctionKey(key) {
|
|
|
572
569
|
function isIndexRoute(route) {
|
|
573
570
|
return route.index === true;
|
|
574
571
|
}
|
|
575
|
-
function convertRoutesToDataRoutes(routes, mapRouteProperties2, parentPath = [], manifest = {}
|
|
572
|
+
function convertRoutesToDataRoutes(routes, mapRouteProperties2, parentPath = [], manifest = {}) {
|
|
576
573
|
return routes.map((route, index) => {
|
|
577
574
|
let treePath = [...parentPath, String(index)];
|
|
578
575
|
let id = typeof route.id === "string" ? route.id : treePath.join("-");
|
|
@@ -581,7 +578,7 @@ function convertRoutesToDataRoutes(routes, mapRouteProperties2, parentPath = [],
|
|
|
581
578
|
`Cannot specify children on an index route`
|
|
582
579
|
);
|
|
583
580
|
invariant(
|
|
584
|
-
|
|
581
|
+
!manifest[id],
|
|
585
582
|
`Found a route id collision on id "${id}". Route id's must be globally unique within Data Router usages`
|
|
586
583
|
);
|
|
587
584
|
if (isIndexRoute(route)) {
|
|
@@ -605,8 +602,7 @@ function convertRoutesToDataRoutes(routes, mapRouteProperties2, parentPath = [],
|
|
|
605
602
|
route.children,
|
|
606
603
|
mapRouteProperties2,
|
|
607
604
|
treePath,
|
|
608
|
-
manifest
|
|
609
|
-
allowInPlaceMutations
|
|
605
|
+
manifest
|
|
610
606
|
);
|
|
611
607
|
}
|
|
612
608
|
return pathOrLayoutRoute;
|
|
@@ -617,8 +613,8 @@ function matchRoutes(routes, locationArg, basename = "/") {
|
|
|
617
613
|
return matchRoutesImpl(routes, locationArg, basename, false);
|
|
618
614
|
}
|
|
619
615
|
function matchRoutesImpl(routes, locationArg, basename, allowPartial) {
|
|
620
|
-
let
|
|
621
|
-
let pathname = stripBasename(
|
|
616
|
+
let location = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
|
|
617
|
+
let pathname = stripBasename(location.pathname || "/", basename);
|
|
622
618
|
if (pathname == null) {
|
|
623
619
|
return null;
|
|
624
620
|
}
|
|
@@ -810,19 +806,19 @@ function generatePath(originalPath, params = {}) {
|
|
|
810
806
|
path = path.replace(/\*$/, "/*");
|
|
811
807
|
}
|
|
812
808
|
const prefix = path.startsWith("/") ? "/" : "";
|
|
813
|
-
const
|
|
809
|
+
const stringify2 = (p) => p == null ? "" : typeof p === "string" ? p : String(p);
|
|
814
810
|
const segments = path.split(/\/+/).map((segment, index, array) => {
|
|
815
811
|
const isLastSegment = index === array.length - 1;
|
|
816
812
|
if (isLastSegment && segment === "*") {
|
|
817
813
|
const star = "*";
|
|
818
|
-
return
|
|
814
|
+
return stringify2(params[star]);
|
|
819
815
|
}
|
|
820
816
|
const keyMatch = segment.match(/^:([\w-]+)(\??)$/);
|
|
821
817
|
if (keyMatch) {
|
|
822
818
|
const [, key, optional] = keyMatch;
|
|
823
819
|
let param = params[key];
|
|
824
820
|
invariant(optional === "?" || param != null, `Missing ":${key}" param`);
|
|
825
|
-
return
|
|
821
|
+
return stringify2(param);
|
|
826
822
|
}
|
|
827
823
|
return segment.replace(/\?$/g, "");
|
|
828
824
|
}).filter((segment) => !!segment);
|
|
@@ -1134,53 +1130,57 @@ function createRouter(init) {
|
|
|
1134
1130
|
let initialMatches = matchRoutes(dataRoutes, init.history.location, basename);
|
|
1135
1131
|
let initialMatchesIsFOW = false;
|
|
1136
1132
|
let initialErrors = null;
|
|
1133
|
+
let initialized;
|
|
1137
1134
|
if (initialMatches == null && !init.patchRoutesOnNavigation) {
|
|
1138
1135
|
let error = getInternalRouterError(404, {
|
|
1139
1136
|
pathname: init.history.location.pathname
|
|
1140
1137
|
});
|
|
1141
1138
|
let { matches, route } = getShortCircuitMatches(dataRoutes);
|
|
1139
|
+
initialized = true;
|
|
1142
1140
|
initialMatches = matches;
|
|
1143
1141
|
initialErrors = { [route.id]: error };
|
|
1144
|
-
}
|
|
1145
|
-
if (initialMatches && !init.hydrationData) {
|
|
1146
|
-
let fogOfWar = checkFogOfWar(
|
|
1147
|
-
initialMatches,
|
|
1148
|
-
dataRoutes,
|
|
1149
|
-
init.history.location.pathname
|
|
1150
|
-
);
|
|
1151
|
-
if (fogOfWar.active) {
|
|
1152
|
-
initialMatches = null;
|
|
1153
|
-
}
|
|
1154
|
-
}
|
|
1155
|
-
let initialized;
|
|
1156
|
-
if (!initialMatches) {
|
|
1157
|
-
initialized = false;
|
|
1158
|
-
initialMatches = [];
|
|
1159
|
-
let fogOfWar = checkFogOfWar(
|
|
1160
|
-
null,
|
|
1161
|
-
dataRoutes,
|
|
1162
|
-
init.history.location.pathname
|
|
1163
|
-
);
|
|
1164
|
-
if (fogOfWar.active && fogOfWar.matches) {
|
|
1165
|
-
initialMatchesIsFOW = true;
|
|
1166
|
-
initialMatches = fogOfWar.matches;
|
|
1167
|
-
}
|
|
1168
|
-
} else if (initialMatches.some((m) => m.route.lazy)) {
|
|
1169
|
-
initialized = false;
|
|
1170
|
-
} else if (!initialMatches.some((m) => m.route.loader)) {
|
|
1171
|
-
initialized = true;
|
|
1172
1142
|
} else {
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1143
|
+
if (initialMatches && !init.hydrationData) {
|
|
1144
|
+
let fogOfWar = checkFogOfWar(
|
|
1145
|
+
initialMatches,
|
|
1146
|
+
dataRoutes,
|
|
1147
|
+
init.history.location.pathname
|
|
1178
1148
|
);
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1149
|
+
if (fogOfWar.active) {
|
|
1150
|
+
initialMatches = null;
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
if (!initialMatches) {
|
|
1154
|
+
initialized = false;
|
|
1155
|
+
initialMatches = [];
|
|
1156
|
+
let fogOfWar = checkFogOfWar(
|
|
1157
|
+
null,
|
|
1158
|
+
dataRoutes,
|
|
1159
|
+
init.history.location.pathname
|
|
1183
1160
|
);
|
|
1161
|
+
if (fogOfWar.active && fogOfWar.matches) {
|
|
1162
|
+
initialMatchesIsFOW = true;
|
|
1163
|
+
initialMatches = fogOfWar.matches;
|
|
1164
|
+
}
|
|
1165
|
+
} else if (initialMatches.some((m) => m.route.lazy)) {
|
|
1166
|
+
initialized = false;
|
|
1167
|
+
} else if (!initialMatches.some((m) => m.route.loader)) {
|
|
1168
|
+
initialized = true;
|
|
1169
|
+
} else {
|
|
1170
|
+
let loaderData = init.hydrationData ? init.hydrationData.loaderData : null;
|
|
1171
|
+
let errors = init.hydrationData ? init.hydrationData.errors : null;
|
|
1172
|
+
if (errors) {
|
|
1173
|
+
let idx = initialMatches.findIndex(
|
|
1174
|
+
(m) => errors[m.route.id] !== void 0
|
|
1175
|
+
);
|
|
1176
|
+
initialized = initialMatches.slice(0, idx + 1).every(
|
|
1177
|
+
(m) => !shouldLoadRouteOnHydration(m.route, loaderData, errors)
|
|
1178
|
+
);
|
|
1179
|
+
} else {
|
|
1180
|
+
initialized = initialMatches.every(
|
|
1181
|
+
(m) => !shouldLoadRouteOnHydration(m.route, loaderData, errors)
|
|
1182
|
+
);
|
|
1183
|
+
}
|
|
1184
1184
|
}
|
|
1185
1185
|
}
|
|
1186
1186
|
let router;
|
|
@@ -1222,7 +1222,7 @@ function createRouter(init) {
|
|
|
1222
1222
|
let pendingRevalidationDfd = null;
|
|
1223
1223
|
function initialize() {
|
|
1224
1224
|
unlistenHistory = init.history.listen(
|
|
1225
|
-
({ action: historyAction, location
|
|
1225
|
+
({ action: historyAction, location, delta }) => {
|
|
1226
1226
|
if (unblockBlockerHistoryUpdate) {
|
|
1227
1227
|
unblockBlockerHistoryUpdate();
|
|
1228
1228
|
unblockBlockerHistoryUpdate = void 0;
|
|
@@ -1234,7 +1234,7 @@ function createRouter(init) {
|
|
|
1234
1234
|
);
|
|
1235
1235
|
let blockerKey = shouldBlockNavigation({
|
|
1236
1236
|
currentLocation: state.location,
|
|
1237
|
-
nextLocation:
|
|
1237
|
+
nextLocation: location,
|
|
1238
1238
|
historyAction
|
|
1239
1239
|
});
|
|
1240
1240
|
if (blockerKey && delta != null) {
|
|
@@ -1244,13 +1244,13 @@ function createRouter(init) {
|
|
|
1244
1244
|
init.history.go(delta * -1);
|
|
1245
1245
|
updateBlocker(blockerKey, {
|
|
1246
1246
|
state: "blocked",
|
|
1247
|
-
location
|
|
1247
|
+
location,
|
|
1248
1248
|
proceed() {
|
|
1249
1249
|
updateBlocker(blockerKey, {
|
|
1250
1250
|
state: "proceeding",
|
|
1251
1251
|
proceed: void 0,
|
|
1252
1252
|
reset: void 0,
|
|
1253
|
-
location
|
|
1253
|
+
location
|
|
1254
1254
|
});
|
|
1255
1255
|
nextHistoryUpdatePromise.then(() => init.history.go(delta));
|
|
1256
1256
|
},
|
|
@@ -1262,7 +1262,7 @@ function createRouter(init) {
|
|
|
1262
1262
|
});
|
|
1263
1263
|
return;
|
|
1264
1264
|
}
|
|
1265
|
-
return startNavigation(historyAction,
|
|
1265
|
+
return startNavigation(historyAction, location);
|
|
1266
1266
|
}
|
|
1267
1267
|
);
|
|
1268
1268
|
if (isBrowser2) {
|
|
@@ -1295,19 +1295,6 @@ function createRouter(init) {
|
|
|
1295
1295
|
return () => subscribers.delete(fn);
|
|
1296
1296
|
}
|
|
1297
1297
|
function updateState(newState, opts = {}) {
|
|
1298
|
-
if (newState.matches) {
|
|
1299
|
-
newState.matches = newState.matches.map((m) => {
|
|
1300
|
-
let route = manifest[m.route.id];
|
|
1301
|
-
let matchRoute = m.route;
|
|
1302
|
-
if (matchRoute.element !== route.element || matchRoute.errorElement !== route.errorElement || matchRoute.hydrateFallbackElement !== route.hydrateFallbackElement) {
|
|
1303
|
-
return {
|
|
1304
|
-
...m,
|
|
1305
|
-
route
|
|
1306
|
-
};
|
|
1307
|
-
}
|
|
1308
|
-
return m;
|
|
1309
|
-
});
|
|
1310
|
-
}
|
|
1311
1298
|
state = {
|
|
1312
1299
|
...state,
|
|
1313
1300
|
...newState
|
|
@@ -1338,8 +1325,8 @@ function createRouter(init) {
|
|
|
1338
1325
|
unmountedFetchers.forEach((key) => deleteFetcher(key));
|
|
1339
1326
|
mountedFetchers.forEach((key) => state.fetchers.delete(key));
|
|
1340
1327
|
}
|
|
1341
|
-
function completeNavigation(
|
|
1342
|
-
let isActionReload = state.actionData != null && state.navigation.formMethod != null && isMutationMethod(state.navigation.formMethod) && state.navigation.state === "loading" &&
|
|
1328
|
+
function completeNavigation(location, newState, { flushSync } = {}) {
|
|
1329
|
+
let isActionReload = state.actionData != null && state.navigation.formMethod != null && isMutationMethod(state.navigation.formMethod) && state.navigation.state === "loading" && location.state?._isRedirect !== true;
|
|
1343
1330
|
let actionData;
|
|
1344
1331
|
if (newState.actionData) {
|
|
1345
1332
|
if (Object.keys(newState.actionData).length > 0) {
|
|
@@ -1363,7 +1350,7 @@ function createRouter(init) {
|
|
|
1363
1350
|
blockers = new Map(blockers);
|
|
1364
1351
|
blockers.forEach((_, k) => blockers.set(k, IDLE_BLOCKER));
|
|
1365
1352
|
}
|
|
1366
|
-
let preventScrollReset = pendingPreventScrollReset === true || state.navigation.formMethod != null && isMutationMethod(state.navigation.formMethod) &&
|
|
1353
|
+
let preventScrollReset = pendingPreventScrollReset === true || state.navigation.formMethod != null && isMutationMethod(state.navigation.formMethod) && location.state?._isRedirect !== true;
|
|
1367
1354
|
if (inFlightDataRoutes) {
|
|
1368
1355
|
dataRoutes = inFlightDataRoutes;
|
|
1369
1356
|
inFlightDataRoutes = void 0;
|
|
@@ -1371,35 +1358,35 @@ function createRouter(init) {
|
|
|
1371
1358
|
if (isUninterruptedRevalidation) {
|
|
1372
1359
|
} else if (pendingAction === "POP" /* Pop */) {
|
|
1373
1360
|
} else if (pendingAction === "PUSH" /* Push */) {
|
|
1374
|
-
init.history.push(
|
|
1361
|
+
init.history.push(location, location.state);
|
|
1375
1362
|
} else if (pendingAction === "REPLACE" /* Replace */) {
|
|
1376
|
-
init.history.replace(
|
|
1363
|
+
init.history.replace(location, location.state);
|
|
1377
1364
|
}
|
|
1378
1365
|
let viewTransitionOpts;
|
|
1379
1366
|
if (pendingAction === "POP" /* Pop */) {
|
|
1380
1367
|
let priorPaths = appliedViewTransitions.get(state.location.pathname);
|
|
1381
|
-
if (priorPaths && priorPaths.has(
|
|
1368
|
+
if (priorPaths && priorPaths.has(location.pathname)) {
|
|
1382
1369
|
viewTransitionOpts = {
|
|
1383
1370
|
currentLocation: state.location,
|
|
1384
|
-
nextLocation:
|
|
1371
|
+
nextLocation: location
|
|
1385
1372
|
};
|
|
1386
|
-
} else if (appliedViewTransitions.has(
|
|
1373
|
+
} else if (appliedViewTransitions.has(location.pathname)) {
|
|
1387
1374
|
viewTransitionOpts = {
|
|
1388
|
-
currentLocation:
|
|
1375
|
+
currentLocation: location,
|
|
1389
1376
|
nextLocation: state.location
|
|
1390
1377
|
};
|
|
1391
1378
|
}
|
|
1392
1379
|
} else if (pendingViewTransitionEnabled) {
|
|
1393
1380
|
let toPaths = appliedViewTransitions.get(state.location.pathname);
|
|
1394
1381
|
if (toPaths) {
|
|
1395
|
-
toPaths.add(
|
|
1382
|
+
toPaths.add(location.pathname);
|
|
1396
1383
|
} else {
|
|
1397
|
-
toPaths = /* @__PURE__ */ new Set([
|
|
1384
|
+
toPaths = /* @__PURE__ */ new Set([location.pathname]);
|
|
1398
1385
|
appliedViewTransitions.set(state.location.pathname, toPaths);
|
|
1399
1386
|
}
|
|
1400
1387
|
viewTransitionOpts = {
|
|
1401
1388
|
currentLocation: state.location,
|
|
1402
|
-
nextLocation:
|
|
1389
|
+
nextLocation: location
|
|
1403
1390
|
};
|
|
1404
1391
|
}
|
|
1405
1392
|
updateState(
|
|
@@ -1409,12 +1396,12 @@ function createRouter(init) {
|
|
|
1409
1396
|
actionData,
|
|
1410
1397
|
loaderData,
|
|
1411
1398
|
historyAction: pendingAction,
|
|
1412
|
-
location
|
|
1399
|
+
location,
|
|
1413
1400
|
initialized: true,
|
|
1414
1401
|
navigation: IDLE_NAVIGATION,
|
|
1415
1402
|
revalidation: "idle",
|
|
1416
1403
|
restoreScrollPosition: getSavedScrollPosition(
|
|
1417
|
-
|
|
1404
|
+
location,
|
|
1418
1405
|
newState.matches || state.matches
|
|
1419
1406
|
),
|
|
1420
1407
|
preventScrollReset,
|
|
@@ -1531,7 +1518,7 @@ function createRouter(init) {
|
|
|
1531
1518
|
);
|
|
1532
1519
|
return promise;
|
|
1533
1520
|
}
|
|
1534
|
-
async function startNavigation(historyAction,
|
|
1521
|
+
async function startNavigation(historyAction, location, opts) {
|
|
1535
1522
|
pendingNavigationController && pendingNavigationController.abort();
|
|
1536
1523
|
pendingNavigationController = null;
|
|
1537
1524
|
pendingAction = historyAction;
|
|
@@ -1544,22 +1531,22 @@ function createRouter(init) {
|
|
|
1544
1531
|
let matches = opts?.initialHydration && state.matches && state.matches.length > 0 && !initialMatchesIsFOW ? (
|
|
1545
1532
|
// `matchRoutes()` has already been called if we're in here via `router.initialize()`
|
|
1546
1533
|
state.matches
|
|
1547
|
-
) : matchRoutes(routesToUse,
|
|
1534
|
+
) : matchRoutes(routesToUse, location, basename);
|
|
1548
1535
|
let flushSync = (opts && opts.flushSync) === true;
|
|
1549
|
-
if (matches && state.initialized && !isRevalidationRequired && isHashChangeOnly(state.location,
|
|
1550
|
-
completeNavigation(
|
|
1536
|
+
if (matches && state.initialized && !isRevalidationRequired && isHashChangeOnly(state.location, location) && !(opts && opts.submission && isMutationMethod(opts.submission.formMethod))) {
|
|
1537
|
+
completeNavigation(location, { matches }, { flushSync });
|
|
1551
1538
|
return;
|
|
1552
1539
|
}
|
|
1553
|
-
let fogOfWar = checkFogOfWar(matches, routesToUse,
|
|
1540
|
+
let fogOfWar = checkFogOfWar(matches, routesToUse, location.pathname);
|
|
1554
1541
|
if (fogOfWar.active && fogOfWar.matches) {
|
|
1555
1542
|
matches = fogOfWar.matches;
|
|
1556
1543
|
}
|
|
1557
1544
|
if (!matches) {
|
|
1558
1545
|
let { error, notFoundMatches, route } = handleNavigational404(
|
|
1559
|
-
|
|
1546
|
+
location.pathname
|
|
1560
1547
|
);
|
|
1561
1548
|
completeNavigation(
|
|
1562
|
-
|
|
1549
|
+
location,
|
|
1563
1550
|
{
|
|
1564
1551
|
matches: notFoundMatches,
|
|
1565
1552
|
loaderData: {},
|
|
@@ -1574,7 +1561,7 @@ function createRouter(init) {
|
|
|
1574
1561
|
pendingNavigationController = new AbortController();
|
|
1575
1562
|
let request = createClientSideRequest(
|
|
1576
1563
|
init.history,
|
|
1577
|
-
|
|
1564
|
+
location,
|
|
1578
1565
|
pendingNavigationController.signal,
|
|
1579
1566
|
opts && opts.submission
|
|
1580
1567
|
);
|
|
@@ -1590,7 +1577,7 @@ function createRouter(init) {
|
|
|
1590
1577
|
} else if (opts && opts.submission && isMutationMethod(opts.submission.formMethod)) {
|
|
1591
1578
|
let actionResult = await handleAction(
|
|
1592
1579
|
request,
|
|
1593
|
-
|
|
1580
|
+
location,
|
|
1594
1581
|
opts.submission,
|
|
1595
1582
|
matches,
|
|
1596
1583
|
scopedContext,
|
|
@@ -1605,7 +1592,7 @@ function createRouter(init) {
|
|
|
1605
1592
|
let [routeId, result] = actionResult.pendingActionResult;
|
|
1606
1593
|
if (isErrorResult(result) && isRouteErrorResponse(result.error) && result.error.status === 404) {
|
|
1607
1594
|
pendingNavigationController = null;
|
|
1608
|
-
completeNavigation(
|
|
1595
|
+
completeNavigation(location, {
|
|
1609
1596
|
matches: actionResult.matches,
|
|
1610
1597
|
loaderData: {},
|
|
1611
1598
|
errors: {
|
|
@@ -1617,7 +1604,7 @@ function createRouter(init) {
|
|
|
1617
1604
|
}
|
|
1618
1605
|
matches = actionResult.matches || matches;
|
|
1619
1606
|
pendingActionResult = actionResult.pendingActionResult;
|
|
1620
|
-
loadingNavigation = getLoadingNavigation(
|
|
1607
|
+
loadingNavigation = getLoadingNavigation(location, opts.submission);
|
|
1621
1608
|
flushSync = false;
|
|
1622
1609
|
fogOfWar.active = false;
|
|
1623
1610
|
request = createClientSideRequest(
|
|
@@ -1633,7 +1620,7 @@ function createRouter(init) {
|
|
|
1633
1620
|
errors
|
|
1634
1621
|
} = await handleLoaders(
|
|
1635
1622
|
request,
|
|
1636
|
-
|
|
1623
|
+
location,
|
|
1637
1624
|
matches,
|
|
1638
1625
|
scopedContext,
|
|
1639
1626
|
fogOfWar.active,
|
|
@@ -1649,21 +1636,21 @@ function createRouter(init) {
|
|
|
1649
1636
|
return;
|
|
1650
1637
|
}
|
|
1651
1638
|
pendingNavigationController = null;
|
|
1652
|
-
completeNavigation(
|
|
1639
|
+
completeNavigation(location, {
|
|
1653
1640
|
matches: updatedMatches || matches,
|
|
1654
1641
|
...getActionDataForCommit(pendingActionResult),
|
|
1655
1642
|
loaderData,
|
|
1656
1643
|
errors
|
|
1657
1644
|
});
|
|
1658
1645
|
}
|
|
1659
|
-
async function handleAction(request,
|
|
1646
|
+
async function handleAction(request, location, submission, matches, scopedContext, isFogOfWar, initialHydration, opts = {}) {
|
|
1660
1647
|
interruptActiveLoads();
|
|
1661
|
-
let navigation = getSubmittingNavigation(
|
|
1648
|
+
let navigation = getSubmittingNavigation(location, submission);
|
|
1662
1649
|
updateState({ navigation }, { flushSync: opts.flushSync === true });
|
|
1663
1650
|
if (isFogOfWar) {
|
|
1664
1651
|
let discoverResult = await discoverRoutes(
|
|
1665
1652
|
matches,
|
|
1666
|
-
|
|
1653
|
+
location.pathname,
|
|
1667
1654
|
request.signal
|
|
1668
1655
|
);
|
|
1669
1656
|
if (discoverResult.type === "aborted") {
|
|
@@ -1682,7 +1669,7 @@ function createRouter(init) {
|
|
|
1682
1669
|
};
|
|
1683
1670
|
} else if (!discoverResult.matches) {
|
|
1684
1671
|
let { notFoundMatches, error, route } = handleNavigational404(
|
|
1685
|
-
|
|
1672
|
+
location.pathname
|
|
1686
1673
|
);
|
|
1687
1674
|
return {
|
|
1688
1675
|
matches: notFoundMatches,
|
|
@@ -1699,13 +1686,13 @@ function createRouter(init) {
|
|
|
1699
1686
|
}
|
|
1700
1687
|
}
|
|
1701
1688
|
let result;
|
|
1702
|
-
let actionMatch = getTargetMatch(matches,
|
|
1689
|
+
let actionMatch = getTargetMatch(matches, location);
|
|
1703
1690
|
if (!actionMatch.route.action && !actionMatch.route.lazy) {
|
|
1704
1691
|
result = {
|
|
1705
1692
|
type: "error" /* error */,
|
|
1706
1693
|
error: getInternalRouterError(405, {
|
|
1707
1694
|
method: request.method,
|
|
1708
|
-
pathname:
|
|
1695
|
+
pathname: location.pathname,
|
|
1709
1696
|
routeId: actionMatch.route.id
|
|
1710
1697
|
})
|
|
1711
1698
|
};
|
|
@@ -1743,12 +1730,12 @@ function createRouter(init) {
|
|
|
1743
1730
|
if (opts && opts.replace != null) {
|
|
1744
1731
|
replace2 = opts.replace;
|
|
1745
1732
|
} else {
|
|
1746
|
-
let
|
|
1733
|
+
let location2 = normalizeRedirectLocation(
|
|
1747
1734
|
result.response.headers.get("Location"),
|
|
1748
1735
|
new URL(request.url),
|
|
1749
1736
|
basename
|
|
1750
1737
|
);
|
|
1751
|
-
replace2 =
|
|
1738
|
+
replace2 = location2 === state.location.pathname + state.location.search;
|
|
1752
1739
|
}
|
|
1753
1740
|
await startRedirectNavigation(request, result, true, {
|
|
1754
1741
|
submission,
|
|
@@ -1763,7 +1750,11 @@ function createRouter(init) {
|
|
|
1763
1750
|
}
|
|
1764
1751
|
return {
|
|
1765
1752
|
matches,
|
|
1766
|
-
pendingActionResult: [
|
|
1753
|
+
pendingActionResult: [
|
|
1754
|
+
boundaryMatch.route.id,
|
|
1755
|
+
result,
|
|
1756
|
+
actionMatch.route.id
|
|
1757
|
+
]
|
|
1767
1758
|
};
|
|
1768
1759
|
}
|
|
1769
1760
|
return {
|
|
@@ -1771,8 +1762,8 @@ function createRouter(init) {
|
|
|
1771
1762
|
pendingActionResult: [actionMatch.route.id, result]
|
|
1772
1763
|
};
|
|
1773
1764
|
}
|
|
1774
|
-
async function handleLoaders(request,
|
|
1775
|
-
let loadingNavigation = overrideNavigation || getLoadingNavigation(
|
|
1765
|
+
async function handleLoaders(request, location, matches, scopedContext, isFogOfWar, overrideNavigation, submission, fetcherSubmission, replace2, initialHydration, flushSync, pendingActionResult) {
|
|
1766
|
+
let loadingNavigation = overrideNavigation || getLoadingNavigation(location, submission);
|
|
1776
1767
|
let activeSubmission = submission || fetcherSubmission || getSubmissionFromNavigation(loadingNavigation);
|
|
1777
1768
|
let shouldUpdateNavigationState = !isUninterruptedRevalidation && !initialHydration;
|
|
1778
1769
|
if (isFogOfWar) {
|
|
@@ -1790,7 +1781,7 @@ function createRouter(init) {
|
|
|
1790
1781
|
}
|
|
1791
1782
|
let discoverResult = await discoverRoutes(
|
|
1792
1783
|
matches,
|
|
1793
|
-
|
|
1784
|
+
location.pathname,
|
|
1794
1785
|
request.signal
|
|
1795
1786
|
);
|
|
1796
1787
|
if (discoverResult.type === "aborted") {
|
|
@@ -1806,7 +1797,7 @@ function createRouter(init) {
|
|
|
1806
1797
|
};
|
|
1807
1798
|
} else if (!discoverResult.matches) {
|
|
1808
1799
|
let { error, notFoundMatches, route } = handleNavigational404(
|
|
1809
|
-
|
|
1800
|
+
location.pathname
|
|
1810
1801
|
);
|
|
1811
1802
|
return {
|
|
1812
1803
|
matches: notFoundMatches,
|
|
@@ -1829,7 +1820,7 @@ function createRouter(init) {
|
|
|
1829
1820
|
state,
|
|
1830
1821
|
matches,
|
|
1831
1822
|
activeSubmission,
|
|
1832
|
-
|
|
1823
|
+
location,
|
|
1833
1824
|
initialHydration ? [] : hydrationRouteProperties2,
|
|
1834
1825
|
initialHydration === true,
|
|
1835
1826
|
isRevalidationRequired,
|
|
@@ -1845,7 +1836,7 @@ function createRouter(init) {
|
|
|
1845
1836
|
if (!init.dataStrategy && !dsMatches.some((m) => m.shouldLoad) && revalidatingFetchers.length === 0) {
|
|
1846
1837
|
let updatedFetchers2 = markFetchRedirectsDone();
|
|
1847
1838
|
completeNavigation(
|
|
1848
|
-
|
|
1839
|
+
location,
|
|
1849
1840
|
{
|
|
1850
1841
|
matches,
|
|
1851
1842
|
loaderData: {},
|
|
@@ -2205,6 +2196,10 @@ function createRouter(init) {
|
|
|
2205
2196
|
fetchReloadIds.delete(key);
|
|
2206
2197
|
fetchControllers.delete(key);
|
|
2207
2198
|
revalidatingFetchers.forEach((r) => fetchControllers.delete(r.key));
|
|
2199
|
+
if (state.fetchers.has(key)) {
|
|
2200
|
+
let doneFetcher = getDoneFetcher(actionResult.data);
|
|
2201
|
+
state.fetchers.set(key, doneFetcher);
|
|
2202
|
+
}
|
|
2208
2203
|
let redirect2 = findRedirect(loaderResults);
|
|
2209
2204
|
if (redirect2) {
|
|
2210
2205
|
return startRedirectNavigation(
|
|
@@ -2232,10 +2227,6 @@ function createRouter(init) {
|
|
|
2232
2227
|
revalidatingFetchers,
|
|
2233
2228
|
fetcherResults
|
|
2234
2229
|
);
|
|
2235
|
-
if (state.fetchers.has(key)) {
|
|
2236
|
-
let doneFetcher = getDoneFetcher(actionResult.data);
|
|
2237
|
-
state.fetchers.set(key, doneFetcher);
|
|
2238
|
-
}
|
|
2239
2230
|
abortStaleFetchLoads(loadId);
|
|
2240
2231
|
if (state.navigation.state === "loading" && loadId > pendingNavigationLoadId) {
|
|
2241
2232
|
invariant(pendingAction, "Expected pending action");
|
|
@@ -2356,31 +2347,31 @@ function createRouter(init) {
|
|
|
2356
2347
|
if (redirect2.response.headers.has("X-Remix-Revalidate")) {
|
|
2357
2348
|
isRevalidationRequired = true;
|
|
2358
2349
|
}
|
|
2359
|
-
let
|
|
2360
|
-
invariant(
|
|
2361
|
-
|
|
2362
|
-
|
|
2350
|
+
let location = redirect2.response.headers.get("Location");
|
|
2351
|
+
invariant(location, "Expected a Location header on the redirect Response");
|
|
2352
|
+
location = normalizeRedirectLocation(
|
|
2353
|
+
location,
|
|
2363
2354
|
new URL(request.url),
|
|
2364
2355
|
basename
|
|
2365
2356
|
);
|
|
2366
|
-
let redirectLocation = createLocation(state.location,
|
|
2357
|
+
let redirectLocation = createLocation(state.location, location, {
|
|
2367
2358
|
_isRedirect: true
|
|
2368
2359
|
});
|
|
2369
2360
|
if (isBrowser2) {
|
|
2370
2361
|
let isDocumentReload = false;
|
|
2371
2362
|
if (redirect2.response.headers.has("X-Remix-Reload-Document")) {
|
|
2372
2363
|
isDocumentReload = true;
|
|
2373
|
-
} else if (ABSOLUTE_URL_REGEX.test(
|
|
2374
|
-
const url =
|
|
2364
|
+
} else if (ABSOLUTE_URL_REGEX.test(location)) {
|
|
2365
|
+
const url = createBrowserURLImpl(location, true);
|
|
2375
2366
|
isDocumentReload = // Hard reload if it's an absolute URL to a new origin
|
|
2376
2367
|
url.origin !== routerWindow.location.origin || // Hard reload if it's an absolute URL that does not match our basename
|
|
2377
2368
|
stripBasename(url.pathname, basename) == null;
|
|
2378
2369
|
}
|
|
2379
2370
|
if (isDocumentReload) {
|
|
2380
2371
|
if (replace2) {
|
|
2381
|
-
routerWindow.location.replace(
|
|
2372
|
+
routerWindow.location.replace(location);
|
|
2382
2373
|
} else {
|
|
2383
|
-
routerWindow.location.assign(
|
|
2374
|
+
routerWindow.location.assign(location);
|
|
2384
2375
|
}
|
|
2385
2376
|
return;
|
|
2386
2377
|
}
|
|
@@ -2396,7 +2387,7 @@ function createRouter(init) {
|
|
|
2396
2387
|
await startNavigation(redirectNavigationType, redirectLocation, {
|
|
2397
2388
|
submission: {
|
|
2398
2389
|
...activeSubmission,
|
|
2399
|
-
formAction:
|
|
2390
|
+
formAction: location
|
|
2400
2391
|
},
|
|
2401
2392
|
// Preserve these flags across redirects
|
|
2402
2393
|
preventScrollReset: preventScrollReset || pendingPreventScrollReset,
|
|
@@ -2438,6 +2429,9 @@ function createRouter(init) {
|
|
|
2438
2429
|
});
|
|
2439
2430
|
return dataResults;
|
|
2440
2431
|
}
|
|
2432
|
+
if (request.signal.aborted) {
|
|
2433
|
+
return dataResults;
|
|
2434
|
+
}
|
|
2441
2435
|
for (let [routeId, result] of Object.entries(results)) {
|
|
2442
2436
|
if (isRedirectDataStrategyResult(result)) {
|
|
2443
2437
|
let response = result.result;
|
|
@@ -2667,25 +2661,25 @@ function createRouter(init) {
|
|
|
2667
2661
|
getScrollRestorationKey2 = null;
|
|
2668
2662
|
};
|
|
2669
2663
|
}
|
|
2670
|
-
function getScrollKey(
|
|
2664
|
+
function getScrollKey(location, matches) {
|
|
2671
2665
|
if (getScrollRestorationKey2) {
|
|
2672
2666
|
let key = getScrollRestorationKey2(
|
|
2673
|
-
|
|
2667
|
+
location,
|
|
2674
2668
|
matches.map((m) => convertRouteMatchToUiMatch(m, state.loaderData))
|
|
2675
2669
|
);
|
|
2676
|
-
return key ||
|
|
2670
|
+
return key || location.key;
|
|
2677
2671
|
}
|
|
2678
|
-
return
|
|
2672
|
+
return location.key;
|
|
2679
2673
|
}
|
|
2680
|
-
function saveScrollPosition(
|
|
2674
|
+
function saveScrollPosition(location, matches) {
|
|
2681
2675
|
if (savedScrollPositions2 && getScrollPosition) {
|
|
2682
|
-
let key = getScrollKey(
|
|
2676
|
+
let key = getScrollKey(location, matches);
|
|
2683
2677
|
savedScrollPositions2[key] = getScrollPosition();
|
|
2684
2678
|
}
|
|
2685
2679
|
}
|
|
2686
|
-
function getSavedScrollPosition(
|
|
2680
|
+
function getSavedScrollPosition(location, matches) {
|
|
2687
2681
|
if (savedScrollPositions2) {
|
|
2688
|
-
let key = getScrollKey(
|
|
2682
|
+
let key = getScrollKey(location, matches);
|
|
2689
2683
|
let y = savedScrollPositions2[key];
|
|
2690
2684
|
if (typeof y === "number") {
|
|
2691
2685
|
return y;
|
|
@@ -2739,8 +2733,7 @@ function createRouter(init) {
|
|
|
2739
2733
|
children,
|
|
2740
2734
|
routesToUse,
|
|
2741
2735
|
localManifest,
|
|
2742
|
-
mapRouteProperties2
|
|
2743
|
-
false
|
|
2736
|
+
mapRouteProperties2
|
|
2744
2737
|
);
|
|
2745
2738
|
}
|
|
2746
2739
|
});
|
|
@@ -2781,7 +2774,7 @@ function createRouter(init) {
|
|
|
2781
2774
|
manifest
|
|
2782
2775
|
);
|
|
2783
2776
|
}
|
|
2784
|
-
function patchRoutes(routeId, children
|
|
2777
|
+
function patchRoutes(routeId, children) {
|
|
2785
2778
|
let isNonHMR = inFlightDataRoutes == null;
|
|
2786
2779
|
let routesToUse = inFlightDataRoutes || dataRoutes;
|
|
2787
2780
|
patchRoutesImpl(
|
|
@@ -2789,8 +2782,7 @@ function createRouter(init) {
|
|
|
2789
2782
|
children,
|
|
2790
2783
|
routesToUse,
|
|
2791
2784
|
manifest,
|
|
2792
|
-
mapRouteProperties2
|
|
2793
|
-
unstable_allowElementMutations
|
|
2785
|
+
mapRouteProperties2
|
|
2794
2786
|
);
|
|
2795
2787
|
if (isNonHMR) {
|
|
2796
2788
|
dataRoutes = [...dataRoutes];
|
|
@@ -2832,10 +2824,7 @@ function createRouter(init) {
|
|
|
2832
2824
|
_internalFetchControllers: fetchControllers,
|
|
2833
2825
|
// TODO: Remove setRoutes, it's temporary to avoid dealing with
|
|
2834
2826
|
// updating the tree while validating the update algorithm.
|
|
2835
|
-
_internalSetRoutes
|
|
2836
|
-
_internalSetStateDoNotUseOrYouWillBreakYourApp(newState) {
|
|
2837
|
-
updateState(newState);
|
|
2838
|
-
}
|
|
2827
|
+
_internalSetRoutes
|
|
2839
2828
|
};
|
|
2840
2829
|
return router;
|
|
2841
2830
|
}
|
|
@@ -2863,15 +2852,15 @@ function createStaticHandler(routes, opts) {
|
|
|
2863
2852
|
} = {}) {
|
|
2864
2853
|
let url = new URL(request.url);
|
|
2865
2854
|
let method = request.method;
|
|
2866
|
-
let
|
|
2867
|
-
let matches = matchRoutes(dataRoutes,
|
|
2855
|
+
let location = createLocation("", createPath(url), null, "default");
|
|
2856
|
+
let matches = matchRoutes(dataRoutes, location, basename);
|
|
2868
2857
|
requestContext = requestContext != null ? requestContext : new unstable_RouterContextProvider();
|
|
2869
2858
|
if (!isValidMethod(method) && method !== "HEAD") {
|
|
2870
2859
|
let error = getInternalRouterError(405, { method });
|
|
2871
2860
|
let { matches: methodNotAllowedMatches, route } = getShortCircuitMatches(dataRoutes);
|
|
2872
2861
|
let staticContext = {
|
|
2873
2862
|
basename,
|
|
2874
|
-
location
|
|
2863
|
+
location,
|
|
2875
2864
|
matches: methodNotAllowedMatches,
|
|
2876
2865
|
loaderData: {},
|
|
2877
2866
|
actionData: null,
|
|
@@ -2884,11 +2873,11 @@ function createStaticHandler(routes, opts) {
|
|
|
2884
2873
|
};
|
|
2885
2874
|
return respond ? respond(staticContext) : staticContext;
|
|
2886
2875
|
} else if (!matches) {
|
|
2887
|
-
let error = getInternalRouterError(404, { pathname:
|
|
2876
|
+
let error = getInternalRouterError(404, { pathname: location.pathname });
|
|
2888
2877
|
let { matches: notFoundMatches, route } = getShortCircuitMatches(dataRoutes);
|
|
2889
2878
|
let staticContext = {
|
|
2890
2879
|
basename,
|
|
2891
|
-
location
|
|
2880
|
+
location,
|
|
2892
2881
|
matches: notFoundMatches,
|
|
2893
2882
|
loaderData: {},
|
|
2894
2883
|
actionData: null,
|
|
@@ -2928,7 +2917,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2928
2917
|
async () => {
|
|
2929
2918
|
let result2 = await queryImpl(
|
|
2930
2919
|
request,
|
|
2931
|
-
|
|
2920
|
+
location,
|
|
2932
2921
|
matches,
|
|
2933
2922
|
requestContext,
|
|
2934
2923
|
dataStrategy || null,
|
|
@@ -2940,7 +2929,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2940
2929
|
if (isResponse(result2)) {
|
|
2941
2930
|
return result2;
|
|
2942
2931
|
}
|
|
2943
|
-
renderedStaticContext = { location
|
|
2932
|
+
renderedStaticContext = { location, basename, ...result2 };
|
|
2944
2933
|
let res = await respond(renderedStaticContext);
|
|
2945
2934
|
return res;
|
|
2946
2935
|
},
|
|
@@ -2965,7 +2954,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2965
2954
|
let boundary = loaderIdx >= 0 ? findNearestBoundary(matches, matches[loaderIdx].route.id) : findNearestBoundary(matches);
|
|
2966
2955
|
return respond({
|
|
2967
2956
|
matches,
|
|
2968
|
-
location
|
|
2957
|
+
location,
|
|
2969
2958
|
basename,
|
|
2970
2959
|
loaderData: {},
|
|
2971
2960
|
actionData: null,
|
|
@@ -2990,7 +2979,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2990
2979
|
}
|
|
2991
2980
|
let result = await queryImpl(
|
|
2992
2981
|
request,
|
|
2993
|
-
|
|
2982
|
+
location,
|
|
2994
2983
|
matches,
|
|
2995
2984
|
requestContext,
|
|
2996
2985
|
dataStrategy || null,
|
|
@@ -3002,7 +2991,7 @@ function createStaticHandler(routes, opts) {
|
|
|
3002
2991
|
if (isResponse(result)) {
|
|
3003
2992
|
return result;
|
|
3004
2993
|
}
|
|
3005
|
-
return { location
|
|
2994
|
+
return { location, basename, ...result };
|
|
3006
2995
|
}
|
|
3007
2996
|
async function queryRoute(request, {
|
|
3008
2997
|
routeId,
|
|
@@ -3012,22 +3001,22 @@ function createStaticHandler(routes, opts) {
|
|
|
3012
3001
|
} = {}) {
|
|
3013
3002
|
let url = new URL(request.url);
|
|
3014
3003
|
let method = request.method;
|
|
3015
|
-
let
|
|
3016
|
-
let matches = matchRoutes(dataRoutes,
|
|
3004
|
+
let location = createLocation("", createPath(url), null, "default");
|
|
3005
|
+
let matches = matchRoutes(dataRoutes, location, basename);
|
|
3017
3006
|
requestContext = requestContext != null ? requestContext : new unstable_RouterContextProvider();
|
|
3018
3007
|
if (!isValidMethod(method) && method !== "HEAD" && method !== "OPTIONS") {
|
|
3019
3008
|
throw getInternalRouterError(405, { method });
|
|
3020
3009
|
} else if (!matches) {
|
|
3021
|
-
throw getInternalRouterError(404, { pathname:
|
|
3010
|
+
throw getInternalRouterError(404, { pathname: location.pathname });
|
|
3022
3011
|
}
|
|
3023
|
-
let match = routeId ? matches.find((m) => m.route.id === routeId) : getTargetMatch(matches,
|
|
3012
|
+
let match = routeId ? matches.find((m) => m.route.id === routeId) : getTargetMatch(matches, location);
|
|
3024
3013
|
if (routeId && !match) {
|
|
3025
3014
|
throw getInternalRouterError(403, {
|
|
3026
|
-
pathname:
|
|
3015
|
+
pathname: location.pathname,
|
|
3027
3016
|
routeId
|
|
3028
3017
|
});
|
|
3029
3018
|
} else if (!match) {
|
|
3030
|
-
throw getInternalRouterError(404, { pathname:
|
|
3019
|
+
throw getInternalRouterError(404, { pathname: location.pathname });
|
|
3031
3020
|
}
|
|
3032
3021
|
if (respond && matches.some(
|
|
3033
3022
|
(m) => m.route.unstable_middleware || typeof m.route.lazy === "object" && m.route.lazy.unstable_middleware
|
|
@@ -3050,7 +3039,7 @@ function createStaticHandler(routes, opts) {
|
|
|
3050
3039
|
async () => {
|
|
3051
3040
|
let result2 = await queryImpl(
|
|
3052
3041
|
request,
|
|
3053
|
-
|
|
3042
|
+
location,
|
|
3054
3043
|
matches,
|
|
3055
3044
|
requestContext,
|
|
3056
3045
|
dataStrategy || null,
|
|
@@ -3083,7 +3072,7 @@ function createStaticHandler(routes, opts) {
|
|
|
3083
3072
|
}
|
|
3084
3073
|
let result = await queryImpl(
|
|
3085
3074
|
request,
|
|
3086
|
-
|
|
3075
|
+
location,
|
|
3087
3076
|
matches,
|
|
3088
3077
|
requestContext,
|
|
3089
3078
|
dataStrategy || null,
|
|
@@ -3107,7 +3096,7 @@ function createStaticHandler(routes, opts) {
|
|
|
3107
3096
|
}
|
|
3108
3097
|
return void 0;
|
|
3109
3098
|
}
|
|
3110
|
-
async function queryImpl(request,
|
|
3099
|
+
async function queryImpl(request, location, matches, requestContext, dataStrategy, skipLoaderErrorBubbling, routeMatch, filterMatchesToLoad, skipRevalidation) {
|
|
3111
3100
|
invariant(
|
|
3112
3101
|
request.signal,
|
|
3113
3102
|
"query()/queryRoute() requests must contain an AbortController signal"
|
|
@@ -3117,7 +3106,7 @@ function createStaticHandler(routes, opts) {
|
|
|
3117
3106
|
let result2 = await submit(
|
|
3118
3107
|
request,
|
|
3119
3108
|
matches,
|
|
3120
|
-
routeMatch || getTargetMatch(matches,
|
|
3109
|
+
routeMatch || getTargetMatch(matches, location),
|
|
3121
3110
|
requestContext,
|
|
3122
3111
|
dataStrategy,
|
|
3123
3112
|
skipLoaderErrorBubbling,
|
|
@@ -3433,7 +3422,7 @@ function throwStaticHandlerAbortedError(request, isRouteRequest) {
|
|
|
3433
3422
|
function isSubmissionNavigation(opts) {
|
|
3434
3423
|
return opts != null && ("formData" in opts && opts.formData != null || "body" in opts && opts.body !== void 0);
|
|
3435
3424
|
}
|
|
3436
|
-
function normalizeTo(
|
|
3425
|
+
function normalizeTo(location, matches, basename, to, fromRouteId, relative) {
|
|
3437
3426
|
let contextualMatches;
|
|
3438
3427
|
let activeRouteMatch;
|
|
3439
3428
|
if (fromRouteId) {
|
|
@@ -3452,12 +3441,12 @@ function normalizeTo(location2, matches, basename, to, fromRouteId, relative) {
|
|
|
3452
3441
|
let path = resolveTo(
|
|
3453
3442
|
to ? to : ".",
|
|
3454
3443
|
getResolveToMatches(contextualMatches),
|
|
3455
|
-
stripBasename(
|
|
3444
|
+
stripBasename(location.pathname, basename) || location.pathname,
|
|
3456
3445
|
relative === "path"
|
|
3457
3446
|
);
|
|
3458
3447
|
if (to == null) {
|
|
3459
|
-
path.search =
|
|
3460
|
-
path.hash =
|
|
3448
|
+
path.search = location.search;
|
|
3449
|
+
path.hash = location.hash;
|
|
3461
3450
|
}
|
|
3462
3451
|
if ((to == null || to === "" || to === ".") && activeRouteMatch) {
|
|
3463
3452
|
let nakedIndex = hasNakedIndexQuery(path.search);
|
|
@@ -3584,10 +3573,10 @@ function normalizeNavigateOptions(isFetcher, path, opts) {
|
|
|
3584
3573
|
parsedPath.search = `?${searchParams}`;
|
|
3585
3574
|
return { path: createPath(parsedPath), submission };
|
|
3586
3575
|
}
|
|
3587
|
-
function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest, history, state, matches, submission,
|
|
3576
|
+
function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest, history, state, matches, submission, location, lazyRoutePropertiesToSkip, initialHydration, isRevalidationRequired, cancelledFetcherLoads, fetchersQueuedForDeletion, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, pendingActionResult) {
|
|
3588
3577
|
let actionResult = pendingActionResult ? isErrorResult(pendingActionResult[1]) ? pendingActionResult[1].error : pendingActionResult[1].data : void 0;
|
|
3589
3578
|
let currentUrl = history.createURL(state.location);
|
|
3590
|
-
let nextUrl = history.createURL(
|
|
3579
|
+
let nextUrl = history.createURL(location);
|
|
3591
3580
|
let maxIdx;
|
|
3592
3581
|
if (initialHydration && state.errors) {
|
|
3593
3582
|
let boundaryId = Object.keys(state.errors)[0];
|
|
@@ -3749,7 +3738,7 @@ function shouldLoadRouteOnHydration(route, loaderData, errors) {
|
|
|
3749
3738
|
if (!route.loader) {
|
|
3750
3739
|
return false;
|
|
3751
3740
|
}
|
|
3752
|
-
let hasData = loaderData != null &&
|
|
3741
|
+
let hasData = loaderData != null && route.id in loaderData;
|
|
3753
3742
|
let hasError = errors != null && errors[route.id] !== void 0;
|
|
3754
3743
|
if (!hasData && hasError) {
|
|
3755
3744
|
return false;
|
|
@@ -3786,7 +3775,7 @@ function shouldRevalidateLoader(loaderMatch, arg) {
|
|
|
3786
3775
|
}
|
|
3787
3776
|
return arg.defaultShouldRevalidate;
|
|
3788
3777
|
}
|
|
3789
|
-
function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRouteProperties2
|
|
3778
|
+
function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRouteProperties2) {
|
|
3790
3779
|
let childrenToPatch;
|
|
3791
3780
|
if (routeId) {
|
|
3792
3781
|
let route = manifest[routeId];
|
|
@@ -3801,47 +3790,18 @@ function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRoutePrope
|
|
|
3801
3790
|
} else {
|
|
3802
3791
|
childrenToPatch = routesToUse;
|
|
3803
3792
|
}
|
|
3804
|
-
let uniqueChildren =
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
if (uniqueChildren.length > 0) {
|
|
3817
|
-
let newRoutes = convertRoutesToDataRoutes(
|
|
3818
|
-
uniqueChildren,
|
|
3819
|
-
mapRouteProperties2,
|
|
3820
|
-
[routeId || "_", "patch", String(childrenToPatch?.length || "0")],
|
|
3821
|
-
manifest
|
|
3822
|
-
);
|
|
3823
|
-
childrenToPatch.push(...newRoutes);
|
|
3824
|
-
}
|
|
3825
|
-
if (allowElementMutations && existingChildren.length > 0) {
|
|
3826
|
-
for (let i = 0; i < existingChildren.length; i++) {
|
|
3827
|
-
let { existingRoute, newRoute } = existingChildren[i];
|
|
3828
|
-
let existingRouteTyped = existingRoute;
|
|
3829
|
-
let [newRouteTyped] = convertRoutesToDataRoutes(
|
|
3830
|
-
[newRoute],
|
|
3831
|
-
mapRouteProperties2,
|
|
3832
|
-
[],
|
|
3833
|
-
// Doesn't matter for mutated routes since they already have an id
|
|
3834
|
-
{},
|
|
3835
|
-
// Don't touch the manifest here since we're updating in place
|
|
3836
|
-
true
|
|
3837
|
-
);
|
|
3838
|
-
Object.assign(existingRouteTyped, {
|
|
3839
|
-
element: newRouteTyped.element ? newRouteTyped.element : existingRouteTyped.element,
|
|
3840
|
-
errorElement: newRouteTyped.errorElement ? newRouteTyped.errorElement : existingRouteTyped.errorElement,
|
|
3841
|
-
hydrateFallbackElement: newRouteTyped.hydrateFallbackElement ? newRouteTyped.hydrateFallbackElement : existingRouteTyped.hydrateFallbackElement
|
|
3842
|
-
});
|
|
3843
|
-
}
|
|
3844
|
-
}
|
|
3793
|
+
let uniqueChildren = children.filter(
|
|
3794
|
+
(newRoute) => !childrenToPatch.some(
|
|
3795
|
+
(existingRoute) => isSameRoute(newRoute, existingRoute)
|
|
3796
|
+
)
|
|
3797
|
+
);
|
|
3798
|
+
let newRoutes = convertRoutesToDataRoutes(
|
|
3799
|
+
uniqueChildren,
|
|
3800
|
+
mapRouteProperties2,
|
|
3801
|
+
[routeId || "_", "patch", String(childrenToPatch?.length || "0")],
|
|
3802
|
+
manifest
|
|
3803
|
+
);
|
|
3804
|
+
childrenToPatch.push(...newRoutes);
|
|
3845
3805
|
}
|
|
3846
3806
|
function isSameRoute(newRoute, existingRoute) {
|
|
3847
3807
|
if ("id" in newRoute && "id" in existingRoute && newRoute.id === existingRoute.id) {
|
|
@@ -4190,7 +4150,7 @@ function getDataStrategyMatch(mapRouteProperties2, manifest, request, match, laz
|
|
|
4190
4150
|
return shouldRevalidateLoader(match, unstable_shouldRevalidateArgs);
|
|
4191
4151
|
},
|
|
4192
4152
|
resolve(handlerOverride) {
|
|
4193
|
-
if (isUsingNewApi || shouldLoad || handlerOverride &&
|
|
4153
|
+
if (isUsingNewApi || shouldLoad || handlerOverride && request.method === "GET" && (match.route.lazy || match.route.loader)) {
|
|
4194
4154
|
return callLoaderOrAction({
|
|
4195
4155
|
request,
|
|
4196
4156
|
match,
|
|
@@ -4450,39 +4410,39 @@ async function convertDataStrategyResultToDataResult(dataStrategyResult) {
|
|
|
4450
4410
|
return { type: "data" /* data */, data: result };
|
|
4451
4411
|
}
|
|
4452
4412
|
function normalizeRelativeRoutingRedirectResponse(response, request, routeId, matches, basename) {
|
|
4453
|
-
let
|
|
4413
|
+
let location = response.headers.get("Location");
|
|
4454
4414
|
invariant(
|
|
4455
|
-
|
|
4415
|
+
location,
|
|
4456
4416
|
"Redirects returned/thrown from loaders/actions must have a Location header"
|
|
4457
4417
|
);
|
|
4458
|
-
if (!ABSOLUTE_URL_REGEX.test(
|
|
4418
|
+
if (!ABSOLUTE_URL_REGEX.test(location)) {
|
|
4459
4419
|
let trimmedMatches = matches.slice(
|
|
4460
4420
|
0,
|
|
4461
4421
|
matches.findIndex((m) => m.route.id === routeId) + 1
|
|
4462
4422
|
);
|
|
4463
|
-
|
|
4423
|
+
location = normalizeTo(
|
|
4464
4424
|
new URL(request.url),
|
|
4465
4425
|
trimmedMatches,
|
|
4466
4426
|
basename,
|
|
4467
|
-
|
|
4427
|
+
location
|
|
4468
4428
|
);
|
|
4469
|
-
response.headers.set("Location",
|
|
4429
|
+
response.headers.set("Location", location);
|
|
4470
4430
|
}
|
|
4471
4431
|
return response;
|
|
4472
4432
|
}
|
|
4473
|
-
function normalizeRedirectLocation(
|
|
4474
|
-
if (ABSOLUTE_URL_REGEX.test(
|
|
4475
|
-
let normalizedLocation =
|
|
4433
|
+
function normalizeRedirectLocation(location, currentUrl, basename) {
|
|
4434
|
+
if (ABSOLUTE_URL_REGEX.test(location)) {
|
|
4435
|
+
let normalizedLocation = location;
|
|
4476
4436
|
let url = normalizedLocation.startsWith("//") ? new URL(currentUrl.protocol + normalizedLocation) : new URL(normalizedLocation);
|
|
4477
4437
|
let isSameBasename = stripBasename(url.pathname, basename) != null;
|
|
4478
4438
|
if (url.origin === currentUrl.origin && isSameBasename) {
|
|
4479
4439
|
return url.pathname + url.search + url.hash;
|
|
4480
4440
|
}
|
|
4481
4441
|
}
|
|
4482
|
-
return
|
|
4442
|
+
return location;
|
|
4483
4443
|
}
|
|
4484
|
-
function createClientSideRequest(history,
|
|
4485
|
-
let url = history.createURL(stripHashFromPath(
|
|
4444
|
+
function createClientSideRequest(history, location, signal, submission) {
|
|
4445
|
+
let url = history.createURL(stripHashFromPath(location)).toString();
|
|
4486
4446
|
let init = { signal };
|
|
4487
4447
|
if (submission && isMutationMethod(submission.formMethod)) {
|
|
4488
4448
|
let { formMethod, formEncType } = submission;
|
|
@@ -4568,7 +4528,9 @@ function processRouteLoaderData(matches, results, pendingActionResult, isStaticH
|
|
|
4568
4528
|
});
|
|
4569
4529
|
if (pendingError !== void 0 && pendingActionResult) {
|
|
4570
4530
|
errors = { [pendingActionResult[0]]: pendingError };
|
|
4571
|
-
|
|
4531
|
+
if (pendingActionResult[2]) {
|
|
4532
|
+
loaderData[pendingActionResult[2]] = void 0;
|
|
4533
|
+
}
|
|
4572
4534
|
}
|
|
4573
4535
|
return {
|
|
4574
4536
|
loaderData,
|
|
@@ -4752,8 +4714,8 @@ function isMutationMethod(method) {
|
|
|
4752
4714
|
function hasNakedIndexQuery(search) {
|
|
4753
4715
|
return new URLSearchParams(search).getAll("index").some((v) => v === "");
|
|
4754
4716
|
}
|
|
4755
|
-
function getTargetMatch(matches,
|
|
4756
|
-
let search = typeof
|
|
4717
|
+
function getTargetMatch(matches, location) {
|
|
4718
|
+
let search = typeof location === "string" ? parsePath(location).search : location.search;
|
|
4757
4719
|
if (matches[matches.length - 1].route.index && hasNakedIndexQuery(search || "")) {
|
|
4758
4720
|
return matches[matches.length - 1];
|
|
4759
4721
|
}
|
|
@@ -4794,11 +4756,11 @@ function getSubmissionFromNavigation(navigation) {
|
|
|
4794
4756
|
};
|
|
4795
4757
|
}
|
|
4796
4758
|
}
|
|
4797
|
-
function getLoadingNavigation(
|
|
4759
|
+
function getLoadingNavigation(location, submission) {
|
|
4798
4760
|
if (submission) {
|
|
4799
4761
|
let navigation = {
|
|
4800
4762
|
state: "loading",
|
|
4801
|
-
location
|
|
4763
|
+
location,
|
|
4802
4764
|
formMethod: submission.formMethod,
|
|
4803
4765
|
formAction: submission.formAction,
|
|
4804
4766
|
formEncType: submission.formEncType,
|
|
@@ -4810,7 +4772,7 @@ function getLoadingNavigation(location2, submission) {
|
|
|
4810
4772
|
} else {
|
|
4811
4773
|
let navigation = {
|
|
4812
4774
|
state: "loading",
|
|
4813
|
-
location
|
|
4775
|
+
location,
|
|
4814
4776
|
formMethod: void 0,
|
|
4815
4777
|
formAction: void 0,
|
|
4816
4778
|
formEncType: void 0,
|
|
@@ -4821,10 +4783,10 @@ function getLoadingNavigation(location2, submission) {
|
|
|
4821
4783
|
return navigation;
|
|
4822
4784
|
}
|
|
4823
4785
|
}
|
|
4824
|
-
function getSubmittingNavigation(
|
|
4786
|
+
function getSubmittingNavigation(location, submission) {
|
|
4825
4787
|
let navigation = {
|
|
4826
4788
|
state: "submitting",
|
|
4827
|
-
location
|
|
4789
|
+
location,
|
|
4828
4790
|
formMethod: submission.formMethod,
|
|
4829
4791
|
formAction: submission.formAction,
|
|
4830
4792
|
formEncType: submission.formEncType,
|
|
@@ -4985,10 +4947,10 @@ var RouteContext = React.createContext({
|
|
|
4985
4947
|
RouteContext.displayName = "Route";
|
|
4986
4948
|
var RouteErrorContext = React.createContext(null);
|
|
4987
4949
|
RouteErrorContext.displayName = "RouteError";
|
|
4950
|
+
var ENABLE_DEV_WARNINGS = true;
|
|
4988
4951
|
|
|
4989
4952
|
// lib/hooks.tsx
|
|
4990
4953
|
var React2 = __toESM(require("react"));
|
|
4991
|
-
var ENABLE_DEV_WARNINGS = true;
|
|
4992
4954
|
function useHref(to, { relative } = {}) {
|
|
4993
4955
|
invariant(
|
|
4994
4956
|
useInRouterContext(),
|
|
@@ -4996,13 +4958,13 @@ function useHref(to, { relative } = {}) {
|
|
|
4996
4958
|
// router loaded. We can help them understand how to avoid that.
|
|
4997
4959
|
`useHref() may be used only in the context of a <Router> component.`
|
|
4998
4960
|
);
|
|
4999
|
-
let { basename, navigator
|
|
4961
|
+
let { basename, navigator } = React2.useContext(NavigationContext);
|
|
5000
4962
|
let { hash, pathname, search } = useResolvedPath(to, { relative });
|
|
5001
4963
|
let joinedPathname = pathname;
|
|
5002
4964
|
if (basename !== "/") {
|
|
5003
4965
|
joinedPathname = pathname === "/" ? basename : joinPaths([basename, pathname]);
|
|
5004
4966
|
}
|
|
5005
|
-
return
|
|
4967
|
+
return navigator.createHref({ pathname: joinedPathname, search, hash });
|
|
5006
4968
|
}
|
|
5007
4969
|
function useInRouterContext() {
|
|
5008
4970
|
return React2.useContext(LocationContext) != null;
|
|
@@ -5051,7 +5013,7 @@ function useNavigateUnstable() {
|
|
|
5051
5013
|
`useNavigate() may be used only in the context of a <Router> component.`
|
|
5052
5014
|
);
|
|
5053
5015
|
let dataRouterContext = React2.useContext(DataRouterContext);
|
|
5054
|
-
let { basename, navigator
|
|
5016
|
+
let { basename, navigator } = React2.useContext(NavigationContext);
|
|
5055
5017
|
let { matches } = React2.useContext(RouteContext);
|
|
5056
5018
|
let { pathname: locationPathname } = useLocation();
|
|
5057
5019
|
let routePathnamesJson = JSON.stringify(getResolveToMatches(matches));
|
|
@@ -5064,7 +5026,7 @@ function useNavigateUnstable() {
|
|
|
5064
5026
|
warning(activeRef.current, navigateEffectWarning);
|
|
5065
5027
|
if (!activeRef.current) return;
|
|
5066
5028
|
if (typeof to === "number") {
|
|
5067
|
-
|
|
5029
|
+
navigator.go(to);
|
|
5068
5030
|
return;
|
|
5069
5031
|
}
|
|
5070
5032
|
let path = resolveTo(
|
|
@@ -5076,7 +5038,7 @@ function useNavigateUnstable() {
|
|
|
5076
5038
|
if (dataRouterContext == null && basename !== "/") {
|
|
5077
5039
|
path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
|
|
5078
5040
|
}
|
|
5079
|
-
(!!options.replace ?
|
|
5041
|
+
(!!options.replace ? navigator.replace : navigator.push)(
|
|
5080
5042
|
path,
|
|
5081
5043
|
options.state,
|
|
5082
5044
|
options
|
|
@@ -5084,7 +5046,7 @@ function useNavigateUnstable() {
|
|
|
5084
5046
|
},
|
|
5085
5047
|
[
|
|
5086
5048
|
basename,
|
|
5087
|
-
|
|
5049
|
+
navigator,
|
|
5088
5050
|
routePathnamesJson,
|
|
5089
5051
|
locationPathname,
|
|
5090
5052
|
dataRouterContext
|
|
@@ -5132,7 +5094,7 @@ function useRoutesImpl(routes, locationArg, dataRouterState, future) {
|
|
|
5132
5094
|
// router loaded. We can help them understand how to avoid that.
|
|
5133
5095
|
`useRoutes() may be used only in the context of a <Router> component.`
|
|
5134
5096
|
);
|
|
5135
|
-
let { navigator
|
|
5097
|
+
let { navigator, static: isStatic } = React2.useContext(NavigationContext);
|
|
5136
5098
|
let { matches: parentMatches } = React2.useContext(RouteContext);
|
|
5137
5099
|
let routeMatch = parentMatches[parentMatches.length - 1];
|
|
5138
5100
|
let parentParams = routeMatch ? routeMatch.params : {};
|
|
@@ -5150,18 +5112,18 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
|
|
|
5150
5112
|
);
|
|
5151
5113
|
}
|
|
5152
5114
|
let locationFromContext = useLocation();
|
|
5153
|
-
let
|
|
5115
|
+
let location;
|
|
5154
5116
|
if (locationArg) {
|
|
5155
5117
|
let parsedLocationArg = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
|
|
5156
5118
|
invariant(
|
|
5157
5119
|
parentPathnameBase === "/" || parsedLocationArg.pathname?.startsWith(parentPathnameBase),
|
|
5158
5120
|
`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.`
|
|
5159
5121
|
);
|
|
5160
|
-
|
|
5122
|
+
location = parsedLocationArg;
|
|
5161
5123
|
} else {
|
|
5162
|
-
|
|
5124
|
+
location = locationFromContext;
|
|
5163
5125
|
}
|
|
5164
|
-
let pathname =
|
|
5126
|
+
let pathname = location.pathname || "/";
|
|
5165
5127
|
let remainingPathname = pathname;
|
|
5166
5128
|
if (parentPathnameBase !== "/") {
|
|
5167
5129
|
let parentSegments = parentPathnameBase.replace(/^\//, "").split("/");
|
|
@@ -5172,11 +5134,11 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
|
|
|
5172
5134
|
if (ENABLE_DEV_WARNINGS) {
|
|
5173
5135
|
warning(
|
|
5174
5136
|
parentRoute || matches != null,
|
|
5175
|
-
`No routes matched location "${
|
|
5137
|
+
`No routes matched location "${location.pathname}${location.search}${location.hash}" `
|
|
5176
5138
|
);
|
|
5177
5139
|
warning(
|
|
5178
5140
|
matches == null || matches[matches.length - 1].route.element !== void 0 || matches[matches.length - 1].route.Component !== void 0 || matches[matches.length - 1].route.lazy !== void 0,
|
|
5179
|
-
`Matched leaf route at location "${
|
|
5141
|
+
`Matched leaf route at location "${location.pathname}${location.search}${location.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`
|
|
5180
5142
|
);
|
|
5181
5143
|
}
|
|
5182
5144
|
let renderedMatches = _renderMatches(
|
|
@@ -5186,12 +5148,12 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
|
|
|
5186
5148
|
pathname: joinPaths([
|
|
5187
5149
|
parentPathnameBase,
|
|
5188
5150
|
// Re-encode pathnames that were decoded inside matchRoutes
|
|
5189
|
-
|
|
5151
|
+
navigator.encodeLocation ? navigator.encodeLocation(match.pathname).pathname : match.pathname
|
|
5190
5152
|
]),
|
|
5191
5153
|
pathnameBase: match.pathnameBase === "/" ? parentPathnameBase : joinPaths([
|
|
5192
5154
|
parentPathnameBase,
|
|
5193
5155
|
// Re-encode pathnames that were decoded inside matchRoutes
|
|
5194
|
-
|
|
5156
|
+
navigator.encodeLocation ? navigator.encodeLocation(match.pathnameBase).pathname : match.pathnameBase
|
|
5195
5157
|
])
|
|
5196
5158
|
})
|
|
5197
5159
|
),
|
|
@@ -5210,7 +5172,7 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
|
|
|
5210
5172
|
hash: "",
|
|
5211
5173
|
state: null,
|
|
5212
5174
|
key: "default",
|
|
5213
|
-
...
|
|
5175
|
+
...location
|
|
5214
5176
|
},
|
|
5215
5177
|
navigationType: "POP" /* Pop */
|
|
5216
5178
|
}
|
|
@@ -5570,7 +5532,6 @@ function warnOnce(condition, message) {
|
|
|
5570
5532
|
}
|
|
5571
5533
|
|
|
5572
5534
|
// lib/components.tsx
|
|
5573
|
-
var ENABLE_DEV_WARNINGS2 = true;
|
|
5574
5535
|
function mapRouteProperties(route) {
|
|
5575
5536
|
let updates = {
|
|
5576
5537
|
// Note: this check also occurs in createRoutesFromChildren so update
|
|
@@ -5578,7 +5539,7 @@ function mapRouteProperties(route) {
|
|
|
5578
5539
|
hasErrorBoundary: route.hasErrorBoundary || route.ErrorBoundary != null || route.errorElement != null
|
|
5579
5540
|
};
|
|
5580
5541
|
if (route.Component) {
|
|
5581
|
-
if (
|
|
5542
|
+
if (ENABLE_DEV_WARNINGS) {
|
|
5582
5543
|
if (route.element) {
|
|
5583
5544
|
warning(
|
|
5584
5545
|
false,
|
|
@@ -5592,7 +5553,7 @@ function mapRouteProperties(route) {
|
|
|
5592
5553
|
});
|
|
5593
5554
|
}
|
|
5594
5555
|
if (route.HydrateFallback) {
|
|
5595
|
-
if (
|
|
5556
|
+
if (ENABLE_DEV_WARNINGS) {
|
|
5596
5557
|
if (route.hydrateFallbackElement) {
|
|
5597
5558
|
warning(
|
|
5598
5559
|
false,
|
|
@@ -5606,7 +5567,7 @@ function mapRouteProperties(route) {
|
|
|
5606
5567
|
});
|
|
5607
5568
|
}
|
|
5608
5569
|
if (route.ErrorBoundary) {
|
|
5609
|
-
if (
|
|
5570
|
+
if (ENABLE_DEV_WARNINGS) {
|
|
5610
5571
|
if (route.errorElement) {
|
|
5611
5572
|
warning(
|
|
5612
5573
|
false,
|
|
@@ -5691,11 +5652,25 @@ function RouterProvider({
|
|
|
5691
5652
|
viewTransitionOpts == null || isViewTransitionAvailable,
|
|
5692
5653
|
"You provided the `viewTransition` option to a router update, but you do not appear to be running in a DOM environment as `window.startViewTransition` is not available."
|
|
5693
5654
|
);
|
|
5655
|
+
const resetTransition = () => {
|
|
5656
|
+
setRenderDfd(void 0);
|
|
5657
|
+
setTransition(void 0);
|
|
5658
|
+
setPendingState(void 0);
|
|
5659
|
+
setVtContext({ isTransitioning: false });
|
|
5660
|
+
};
|
|
5694
5661
|
if (!viewTransitionOpts || !isViewTransitionAvailable) {
|
|
5662
|
+
renderDfd?.resolve();
|
|
5663
|
+
transition?.skipTransition();
|
|
5695
5664
|
if (reactDomFlushSyncImpl && flushSync) {
|
|
5696
|
-
reactDomFlushSyncImpl(() =>
|
|
5665
|
+
reactDomFlushSyncImpl(() => {
|
|
5666
|
+
setStateImpl(newState);
|
|
5667
|
+
resetTransition();
|
|
5668
|
+
});
|
|
5697
5669
|
} else {
|
|
5698
|
-
React3.startTransition(() =>
|
|
5670
|
+
React3.startTransition(() => {
|
|
5671
|
+
setStateImpl(newState);
|
|
5672
|
+
resetTransition();
|
|
5673
|
+
});
|
|
5699
5674
|
}
|
|
5700
5675
|
return;
|
|
5701
5676
|
}
|
|
@@ -5716,12 +5691,7 @@ function RouterProvider({
|
|
|
5716
5691
|
reactDomFlushSyncImpl(() => setStateImpl(newState));
|
|
5717
5692
|
});
|
|
5718
5693
|
t.finished.finally(() => {
|
|
5719
|
-
reactDomFlushSyncImpl(() =>
|
|
5720
|
-
setRenderDfd(void 0);
|
|
5721
|
-
setTransition(void 0);
|
|
5722
|
-
setPendingState(void 0);
|
|
5723
|
-
setVtContext({ isTransitioning: false });
|
|
5724
|
-
});
|
|
5694
|
+
reactDomFlushSyncImpl(() => resetTransition());
|
|
5725
5695
|
});
|
|
5726
5696
|
reactDomFlushSyncImpl(() => setTransition(t));
|
|
5727
5697
|
return;
|
|
@@ -5786,7 +5756,7 @@ function RouterProvider({
|
|
|
5786
5756
|
setInterruption(void 0);
|
|
5787
5757
|
}
|
|
5788
5758
|
}, [vtContext.isTransitioning, interruption]);
|
|
5789
|
-
let
|
|
5759
|
+
let navigator = React3.useMemo(() => {
|
|
5790
5760
|
return {
|
|
5791
5761
|
createHref: router.createHref,
|
|
5792
5762
|
encodeLocation: router.encodeLocation,
|
|
@@ -5806,11 +5776,11 @@ function RouterProvider({
|
|
|
5806
5776
|
let dataRouterContext = React3.useMemo(
|
|
5807
5777
|
() => ({
|
|
5808
5778
|
router,
|
|
5809
|
-
navigator
|
|
5779
|
+
navigator,
|
|
5810
5780
|
static: false,
|
|
5811
5781
|
basename
|
|
5812
5782
|
}),
|
|
5813
|
-
[router,
|
|
5783
|
+
[router, navigator, basename]
|
|
5814
5784
|
);
|
|
5815
5785
|
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(DataRouterContext.Provider, { value: dataRouterContext }, /* @__PURE__ */ React3.createElement(DataRouterStateContext.Provider, { value: state }, /* @__PURE__ */ React3.createElement(FetchersContext.Provider, { value: fetcherData.current }, /* @__PURE__ */ React3.createElement(ViewTransitionContext.Provider, { value: vtContext }, /* @__PURE__ */ React3.createElement(
|
|
5816
5786
|
Router,
|
|
@@ -5818,7 +5788,7 @@ function RouterProvider({
|
|
|
5818
5788
|
basename,
|
|
5819
5789
|
location: state.location,
|
|
5820
5790
|
navigationType: state.historyAction,
|
|
5821
|
-
navigator
|
|
5791
|
+
navigator
|
|
5822
5792
|
},
|
|
5823
5793
|
/* @__PURE__ */ React3.createElement(
|
|
5824
5794
|
MemoizedDataRoutes,
|
|
@@ -5921,7 +5891,7 @@ function Router({
|
|
|
5921
5891
|
children = null,
|
|
5922
5892
|
location: locationProp,
|
|
5923
5893
|
navigationType = "POP" /* Pop */,
|
|
5924
|
-
navigator
|
|
5894
|
+
navigator,
|
|
5925
5895
|
static: staticProp = false
|
|
5926
5896
|
}) {
|
|
5927
5897
|
invariant(
|
|
@@ -5932,11 +5902,11 @@ function Router({
|
|
|
5932
5902
|
let navigationContext = React3.useMemo(
|
|
5933
5903
|
() => ({
|
|
5934
5904
|
basename,
|
|
5935
|
-
navigator
|
|
5905
|
+
navigator,
|
|
5936
5906
|
static: staticProp,
|
|
5937
5907
|
future: {}
|
|
5938
5908
|
}),
|
|
5939
|
-
[basename,
|
|
5909
|
+
[basename, navigator, staticProp]
|
|
5940
5910
|
);
|
|
5941
5911
|
if (typeof locationProp === "string") {
|
|
5942
5912
|
locationProp = parsePath(locationProp);
|
|
@@ -5975,9 +5945,9 @@ function Router({
|
|
|
5975
5945
|
}
|
|
5976
5946
|
function Routes({
|
|
5977
5947
|
children,
|
|
5978
|
-
location
|
|
5948
|
+
location
|
|
5979
5949
|
}) {
|
|
5980
|
-
return useRoutes(createRoutesFromChildren(children),
|
|
5950
|
+
return useRoutes(createRoutesFromChildren(children), location);
|
|
5981
5951
|
}
|
|
5982
5952
|
function Await({
|
|
5983
5953
|
children,
|
|
@@ -6047,38 +6017,6 @@ function ResolveAwait({
|
|
|
6047
6017
|
let toRender = typeof children === "function" ? children(data2) : children;
|
|
6048
6018
|
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, toRender);
|
|
6049
6019
|
}
|
|
6050
|
-
function WithRouteComponentProps({
|
|
6051
|
-
children
|
|
6052
|
-
}) {
|
|
6053
|
-
let props = {
|
|
6054
|
-
loaderData: useLoaderData(),
|
|
6055
|
-
actionData: useActionData(),
|
|
6056
|
-
params: useParams(),
|
|
6057
|
-
matches: useMatches()
|
|
6058
|
-
};
|
|
6059
|
-
return React3.cloneElement(children, props);
|
|
6060
|
-
}
|
|
6061
|
-
function WithHydrateFallbackProps({
|
|
6062
|
-
children
|
|
6063
|
-
}) {
|
|
6064
|
-
let props = {
|
|
6065
|
-
loaderData: useLoaderData(),
|
|
6066
|
-
actionData: useActionData(),
|
|
6067
|
-
params: useParams()
|
|
6068
|
-
};
|
|
6069
|
-
return React3.cloneElement(children, props);
|
|
6070
|
-
}
|
|
6071
|
-
function WithErrorBoundaryProps({
|
|
6072
|
-
children
|
|
6073
|
-
}) {
|
|
6074
|
-
let props = {
|
|
6075
|
-
loaderData: useLoaderData(),
|
|
6076
|
-
actionData: useActionData(),
|
|
6077
|
-
params: useParams(),
|
|
6078
|
-
error: useRouteError()
|
|
6079
|
-
};
|
|
6080
|
-
return React3.cloneElement(children, props);
|
|
6081
|
-
}
|
|
6082
6020
|
function createRoutesFromChildren(children, parentPath = []) {
|
|
6083
6021
|
let routes = [];
|
|
6084
6022
|
React3.Children.forEach(children, (element, index) => {
|
|
@@ -6401,7 +6339,7 @@ async function getKeyedPrefetchLinks(matches, manifest, routeModules) {
|
|
|
6401
6339
|
)
|
|
6402
6340
|
);
|
|
6403
6341
|
}
|
|
6404
|
-
function getNewMatchesForLinks(page, nextMatches, currentMatches, manifest,
|
|
6342
|
+
function getNewMatchesForLinks(page, nextMatches, currentMatches, manifest, location, mode) {
|
|
6405
6343
|
let isNew = (match, index) => {
|
|
6406
6344
|
if (!currentMatches[index]) return true;
|
|
6407
6345
|
return match.route.id !== currentMatches[index].route.id;
|
|
@@ -6431,7 +6369,7 @@ function getNewMatchesForLinks(page, nextMatches, currentMatches, manifest, loca
|
|
|
6431
6369
|
if (match.route.shouldRevalidate) {
|
|
6432
6370
|
let routeChoice = match.route.shouldRevalidate({
|
|
6433
6371
|
currentUrl: new URL(
|
|
6434
|
-
|
|
6372
|
+
location.pathname + location.search + location.hash,
|
|
6435
6373
|
window.origin
|
|
6436
6374
|
),
|
|
6437
6375
|
currentParams: currentMatches[0]?.params || {},
|
|
@@ -6526,7 +6464,669 @@ function createHtml(html) {
|
|
|
6526
6464
|
|
|
6527
6465
|
// lib/dom/ssr/single-fetch.tsx
|
|
6528
6466
|
var React4 = __toESM(require("react"));
|
|
6529
|
-
|
|
6467
|
+
|
|
6468
|
+
// vendor/turbo-stream-v2/utils.ts
|
|
6469
|
+
var HOLE = -1;
|
|
6470
|
+
var NAN = -2;
|
|
6471
|
+
var NEGATIVE_INFINITY = -3;
|
|
6472
|
+
var NEGATIVE_ZERO = -4;
|
|
6473
|
+
var NULL = -5;
|
|
6474
|
+
var POSITIVE_INFINITY = -6;
|
|
6475
|
+
var UNDEFINED = -7;
|
|
6476
|
+
var TYPE_BIGINT = "B";
|
|
6477
|
+
var TYPE_DATE = "D";
|
|
6478
|
+
var TYPE_ERROR = "E";
|
|
6479
|
+
var TYPE_MAP = "M";
|
|
6480
|
+
var TYPE_NULL_OBJECT = "N";
|
|
6481
|
+
var TYPE_PROMISE = "P";
|
|
6482
|
+
var TYPE_REGEXP = "R";
|
|
6483
|
+
var TYPE_SET = "S";
|
|
6484
|
+
var TYPE_SYMBOL = "Y";
|
|
6485
|
+
var TYPE_URL = "U";
|
|
6486
|
+
var TYPE_PREVIOUS_RESOLVED = "Z";
|
|
6487
|
+
var Deferred2 = class {
|
|
6488
|
+
constructor() {
|
|
6489
|
+
this.promise = new Promise((resolve, reject) => {
|
|
6490
|
+
this.resolve = resolve;
|
|
6491
|
+
this.reject = reject;
|
|
6492
|
+
});
|
|
6493
|
+
}
|
|
6494
|
+
};
|
|
6495
|
+
function createLineSplittingTransform() {
|
|
6496
|
+
const decoder = new TextDecoder();
|
|
6497
|
+
let leftover = "";
|
|
6498
|
+
return new TransformStream({
|
|
6499
|
+
transform(chunk, controller) {
|
|
6500
|
+
const str = decoder.decode(chunk, { stream: true });
|
|
6501
|
+
const parts = (leftover + str).split("\n");
|
|
6502
|
+
leftover = parts.pop() || "";
|
|
6503
|
+
for (const part of parts) {
|
|
6504
|
+
controller.enqueue(part);
|
|
6505
|
+
}
|
|
6506
|
+
},
|
|
6507
|
+
flush(controller) {
|
|
6508
|
+
if (leftover) {
|
|
6509
|
+
controller.enqueue(leftover);
|
|
6510
|
+
}
|
|
6511
|
+
}
|
|
6512
|
+
});
|
|
6513
|
+
}
|
|
6514
|
+
|
|
6515
|
+
// vendor/turbo-stream-v2/flatten.ts
|
|
6516
|
+
function flatten(input) {
|
|
6517
|
+
const { indices } = this;
|
|
6518
|
+
const existing = indices.get(input);
|
|
6519
|
+
if (existing) return [existing];
|
|
6520
|
+
if (input === void 0) return UNDEFINED;
|
|
6521
|
+
if (input === null) return NULL;
|
|
6522
|
+
if (Number.isNaN(input)) return NAN;
|
|
6523
|
+
if (input === Number.POSITIVE_INFINITY) return POSITIVE_INFINITY;
|
|
6524
|
+
if (input === Number.NEGATIVE_INFINITY) return NEGATIVE_INFINITY;
|
|
6525
|
+
if (input === 0 && 1 / input < 0) return NEGATIVE_ZERO;
|
|
6526
|
+
const index = this.index++;
|
|
6527
|
+
indices.set(input, index);
|
|
6528
|
+
stringify.call(this, input, index);
|
|
6529
|
+
return index;
|
|
6530
|
+
}
|
|
6531
|
+
function stringify(input, index) {
|
|
6532
|
+
const { deferred, plugins, postPlugins } = this;
|
|
6533
|
+
const str = this.stringified;
|
|
6534
|
+
const stack = [[input, index]];
|
|
6535
|
+
while (stack.length > 0) {
|
|
6536
|
+
const [input2, index2] = stack.pop();
|
|
6537
|
+
const partsForObj = (obj) => Object.keys(obj).map((k) => `"_${flatten.call(this, k)}":${flatten.call(this, obj[k])}`).join(",");
|
|
6538
|
+
let error = null;
|
|
6539
|
+
switch (typeof input2) {
|
|
6540
|
+
case "boolean":
|
|
6541
|
+
case "number":
|
|
6542
|
+
case "string":
|
|
6543
|
+
str[index2] = JSON.stringify(input2);
|
|
6544
|
+
break;
|
|
6545
|
+
case "bigint":
|
|
6546
|
+
str[index2] = `["${TYPE_BIGINT}","${input2}"]`;
|
|
6547
|
+
break;
|
|
6548
|
+
case "symbol": {
|
|
6549
|
+
const keyFor = Symbol.keyFor(input2);
|
|
6550
|
+
if (!keyFor) {
|
|
6551
|
+
error = new Error(
|
|
6552
|
+
"Cannot encode symbol unless created with Symbol.for()"
|
|
6553
|
+
);
|
|
6554
|
+
} else {
|
|
6555
|
+
str[index2] = `["${TYPE_SYMBOL}",${JSON.stringify(keyFor)}]`;
|
|
6556
|
+
}
|
|
6557
|
+
break;
|
|
6558
|
+
}
|
|
6559
|
+
case "object": {
|
|
6560
|
+
if (!input2) {
|
|
6561
|
+
str[index2] = `${NULL}`;
|
|
6562
|
+
break;
|
|
6563
|
+
}
|
|
6564
|
+
const isArray = Array.isArray(input2);
|
|
6565
|
+
let pluginHandled = false;
|
|
6566
|
+
if (!isArray && plugins) {
|
|
6567
|
+
for (const plugin of plugins) {
|
|
6568
|
+
const pluginResult = plugin(input2);
|
|
6569
|
+
if (Array.isArray(pluginResult)) {
|
|
6570
|
+
pluginHandled = true;
|
|
6571
|
+
const [pluginIdentifier, ...rest] = pluginResult;
|
|
6572
|
+
str[index2] = `[${JSON.stringify(pluginIdentifier)}`;
|
|
6573
|
+
if (rest.length > 0) {
|
|
6574
|
+
str[index2] += `,${rest.map((v) => flatten.call(this, v)).join(",")}`;
|
|
6575
|
+
}
|
|
6576
|
+
str[index2] += "]";
|
|
6577
|
+
break;
|
|
6578
|
+
}
|
|
6579
|
+
}
|
|
6580
|
+
}
|
|
6581
|
+
if (!pluginHandled) {
|
|
6582
|
+
let result = isArray ? "[" : "{";
|
|
6583
|
+
if (isArray) {
|
|
6584
|
+
for (let i = 0; i < input2.length; i++)
|
|
6585
|
+
result += (i ? "," : "") + (i in input2 ? flatten.call(this, input2[i]) : HOLE);
|
|
6586
|
+
str[index2] = `${result}]`;
|
|
6587
|
+
} else if (input2 instanceof Date) {
|
|
6588
|
+
str[index2] = `["${TYPE_DATE}",${input2.getTime()}]`;
|
|
6589
|
+
} else if (input2 instanceof URL) {
|
|
6590
|
+
str[index2] = `["${TYPE_URL}",${JSON.stringify(input2.href)}]`;
|
|
6591
|
+
} else if (input2 instanceof RegExp) {
|
|
6592
|
+
str[index2] = `["${TYPE_REGEXP}",${JSON.stringify(
|
|
6593
|
+
input2.source
|
|
6594
|
+
)},${JSON.stringify(input2.flags)}]`;
|
|
6595
|
+
} else if (input2 instanceof Set) {
|
|
6596
|
+
if (input2.size > 0) {
|
|
6597
|
+
str[index2] = `["${TYPE_SET}",${[...input2].map((val) => flatten.call(this, val)).join(",")}]`;
|
|
6598
|
+
} else {
|
|
6599
|
+
str[index2] = `["${TYPE_SET}"]`;
|
|
6600
|
+
}
|
|
6601
|
+
} else if (input2 instanceof Map) {
|
|
6602
|
+
if (input2.size > 0) {
|
|
6603
|
+
str[index2] = `["${TYPE_MAP}",${[...input2].flatMap(([k, v]) => [
|
|
6604
|
+
flatten.call(this, k),
|
|
6605
|
+
flatten.call(this, v)
|
|
6606
|
+
]).join(",")}]`;
|
|
6607
|
+
} else {
|
|
6608
|
+
str[index2] = `["${TYPE_MAP}"]`;
|
|
6609
|
+
}
|
|
6610
|
+
} else if (input2 instanceof Promise) {
|
|
6611
|
+
str[index2] = `["${TYPE_PROMISE}",${index2}]`;
|
|
6612
|
+
deferred[index2] = input2;
|
|
6613
|
+
} else if (input2 instanceof Error) {
|
|
6614
|
+
str[index2] = `["${TYPE_ERROR}",${JSON.stringify(input2.message)}`;
|
|
6615
|
+
if (input2.name !== "Error") {
|
|
6616
|
+
str[index2] += `,${JSON.stringify(input2.name)}`;
|
|
6617
|
+
}
|
|
6618
|
+
str[index2] += "]";
|
|
6619
|
+
} else if (Object.getPrototypeOf(input2) === null) {
|
|
6620
|
+
str[index2] = `["${TYPE_NULL_OBJECT}",{${partsForObj(input2)}}]`;
|
|
6621
|
+
} else if (isPlainObject(input2)) {
|
|
6622
|
+
str[index2] = `{${partsForObj(input2)}}`;
|
|
6623
|
+
} else {
|
|
6624
|
+
error = new Error("Cannot encode object with prototype");
|
|
6625
|
+
}
|
|
6626
|
+
}
|
|
6627
|
+
break;
|
|
6628
|
+
}
|
|
6629
|
+
default: {
|
|
6630
|
+
const isArray = Array.isArray(input2);
|
|
6631
|
+
let pluginHandled = false;
|
|
6632
|
+
if (!isArray && plugins) {
|
|
6633
|
+
for (const plugin of plugins) {
|
|
6634
|
+
const pluginResult = plugin(input2);
|
|
6635
|
+
if (Array.isArray(pluginResult)) {
|
|
6636
|
+
pluginHandled = true;
|
|
6637
|
+
const [pluginIdentifier, ...rest] = pluginResult;
|
|
6638
|
+
str[index2] = `[${JSON.stringify(pluginIdentifier)}`;
|
|
6639
|
+
if (rest.length > 0) {
|
|
6640
|
+
str[index2] += `,${rest.map((v) => flatten.call(this, v)).join(",")}`;
|
|
6641
|
+
}
|
|
6642
|
+
str[index2] += "]";
|
|
6643
|
+
break;
|
|
6644
|
+
}
|
|
6645
|
+
}
|
|
6646
|
+
}
|
|
6647
|
+
if (!pluginHandled) {
|
|
6648
|
+
error = new Error("Cannot encode function or unexpected type");
|
|
6649
|
+
}
|
|
6650
|
+
}
|
|
6651
|
+
}
|
|
6652
|
+
if (error) {
|
|
6653
|
+
let pluginHandled = false;
|
|
6654
|
+
if (postPlugins) {
|
|
6655
|
+
for (const plugin of postPlugins) {
|
|
6656
|
+
const pluginResult = plugin(input2);
|
|
6657
|
+
if (Array.isArray(pluginResult)) {
|
|
6658
|
+
pluginHandled = true;
|
|
6659
|
+
const [pluginIdentifier, ...rest] = pluginResult;
|
|
6660
|
+
str[index2] = `[${JSON.stringify(pluginIdentifier)}`;
|
|
6661
|
+
if (rest.length > 0) {
|
|
6662
|
+
str[index2] += `,${rest.map((v) => flatten.call(this, v)).join(",")}`;
|
|
6663
|
+
}
|
|
6664
|
+
str[index2] += "]";
|
|
6665
|
+
break;
|
|
6666
|
+
}
|
|
6667
|
+
}
|
|
6668
|
+
}
|
|
6669
|
+
if (!pluginHandled) {
|
|
6670
|
+
throw error;
|
|
6671
|
+
}
|
|
6672
|
+
}
|
|
6673
|
+
}
|
|
6674
|
+
}
|
|
6675
|
+
var objectProtoNames = Object.getOwnPropertyNames(Object.prototype).sort().join("\0");
|
|
6676
|
+
function isPlainObject(thing) {
|
|
6677
|
+
const proto = Object.getPrototypeOf(thing);
|
|
6678
|
+
return proto === Object.prototype || proto === null || Object.getOwnPropertyNames(proto).sort().join("\0") === objectProtoNames;
|
|
6679
|
+
}
|
|
6680
|
+
|
|
6681
|
+
// vendor/turbo-stream-v2/unflatten.ts
|
|
6682
|
+
var globalObj = typeof window !== "undefined" ? window : typeof globalThis !== "undefined" ? globalThis : void 0;
|
|
6683
|
+
function unflatten(parsed) {
|
|
6684
|
+
const { hydrated, values } = this;
|
|
6685
|
+
if (typeof parsed === "number") return hydrate.call(this, parsed);
|
|
6686
|
+
if (!Array.isArray(parsed) || !parsed.length) throw new SyntaxError();
|
|
6687
|
+
const startIndex = values.length;
|
|
6688
|
+
for (const value of parsed) {
|
|
6689
|
+
values.push(value);
|
|
6690
|
+
}
|
|
6691
|
+
hydrated.length = values.length;
|
|
6692
|
+
return hydrate.call(this, startIndex);
|
|
6693
|
+
}
|
|
6694
|
+
function hydrate(index) {
|
|
6695
|
+
const { hydrated, values, deferred, plugins } = this;
|
|
6696
|
+
let result;
|
|
6697
|
+
const stack = [
|
|
6698
|
+
[
|
|
6699
|
+
index,
|
|
6700
|
+
(v) => {
|
|
6701
|
+
result = v;
|
|
6702
|
+
}
|
|
6703
|
+
]
|
|
6704
|
+
];
|
|
6705
|
+
let postRun = [];
|
|
6706
|
+
while (stack.length > 0) {
|
|
6707
|
+
const [index2, set] = stack.pop();
|
|
6708
|
+
switch (index2) {
|
|
6709
|
+
case UNDEFINED:
|
|
6710
|
+
set(void 0);
|
|
6711
|
+
continue;
|
|
6712
|
+
case NULL:
|
|
6713
|
+
set(null);
|
|
6714
|
+
continue;
|
|
6715
|
+
case NAN:
|
|
6716
|
+
set(NaN);
|
|
6717
|
+
continue;
|
|
6718
|
+
case POSITIVE_INFINITY:
|
|
6719
|
+
set(Infinity);
|
|
6720
|
+
continue;
|
|
6721
|
+
case NEGATIVE_INFINITY:
|
|
6722
|
+
set(-Infinity);
|
|
6723
|
+
continue;
|
|
6724
|
+
case NEGATIVE_ZERO:
|
|
6725
|
+
set(-0);
|
|
6726
|
+
continue;
|
|
6727
|
+
}
|
|
6728
|
+
if (hydrated[index2]) {
|
|
6729
|
+
set(hydrated[index2]);
|
|
6730
|
+
continue;
|
|
6731
|
+
}
|
|
6732
|
+
const value = values[index2];
|
|
6733
|
+
if (!value || typeof value !== "object") {
|
|
6734
|
+
hydrated[index2] = value;
|
|
6735
|
+
set(value);
|
|
6736
|
+
continue;
|
|
6737
|
+
}
|
|
6738
|
+
if (Array.isArray(value)) {
|
|
6739
|
+
if (typeof value[0] === "string") {
|
|
6740
|
+
const [type, b, c] = value;
|
|
6741
|
+
switch (type) {
|
|
6742
|
+
case TYPE_DATE:
|
|
6743
|
+
set(hydrated[index2] = new Date(b));
|
|
6744
|
+
continue;
|
|
6745
|
+
case TYPE_URL:
|
|
6746
|
+
set(hydrated[index2] = new URL(b));
|
|
6747
|
+
continue;
|
|
6748
|
+
case TYPE_BIGINT:
|
|
6749
|
+
set(hydrated[index2] = BigInt(b));
|
|
6750
|
+
continue;
|
|
6751
|
+
case TYPE_REGEXP:
|
|
6752
|
+
set(hydrated[index2] = new RegExp(b, c));
|
|
6753
|
+
continue;
|
|
6754
|
+
case TYPE_SYMBOL:
|
|
6755
|
+
set(hydrated[index2] = Symbol.for(b));
|
|
6756
|
+
continue;
|
|
6757
|
+
case TYPE_SET:
|
|
6758
|
+
const newSet = /* @__PURE__ */ new Set();
|
|
6759
|
+
hydrated[index2] = newSet;
|
|
6760
|
+
for (let i = value.length - 1; i > 0; i--)
|
|
6761
|
+
stack.push([
|
|
6762
|
+
value[i],
|
|
6763
|
+
(v) => {
|
|
6764
|
+
newSet.add(v);
|
|
6765
|
+
}
|
|
6766
|
+
]);
|
|
6767
|
+
set(newSet);
|
|
6768
|
+
continue;
|
|
6769
|
+
case TYPE_MAP:
|
|
6770
|
+
const map = /* @__PURE__ */ new Map();
|
|
6771
|
+
hydrated[index2] = map;
|
|
6772
|
+
for (let i = value.length - 2; i > 0; i -= 2) {
|
|
6773
|
+
const r = [];
|
|
6774
|
+
stack.push([
|
|
6775
|
+
value[i + 1],
|
|
6776
|
+
(v) => {
|
|
6777
|
+
r[1] = v;
|
|
6778
|
+
}
|
|
6779
|
+
]);
|
|
6780
|
+
stack.push([
|
|
6781
|
+
value[i],
|
|
6782
|
+
(k) => {
|
|
6783
|
+
r[0] = k;
|
|
6784
|
+
}
|
|
6785
|
+
]);
|
|
6786
|
+
postRun.push(() => {
|
|
6787
|
+
map.set(r[0], r[1]);
|
|
6788
|
+
});
|
|
6789
|
+
}
|
|
6790
|
+
set(map);
|
|
6791
|
+
continue;
|
|
6792
|
+
case TYPE_NULL_OBJECT:
|
|
6793
|
+
const obj = /* @__PURE__ */ Object.create(null);
|
|
6794
|
+
hydrated[index2] = obj;
|
|
6795
|
+
for (const key of Object.keys(b).reverse()) {
|
|
6796
|
+
const r = [];
|
|
6797
|
+
stack.push([
|
|
6798
|
+
b[key],
|
|
6799
|
+
(v) => {
|
|
6800
|
+
r[1] = v;
|
|
6801
|
+
}
|
|
6802
|
+
]);
|
|
6803
|
+
stack.push([
|
|
6804
|
+
Number(key.slice(1)),
|
|
6805
|
+
(k) => {
|
|
6806
|
+
r[0] = k;
|
|
6807
|
+
}
|
|
6808
|
+
]);
|
|
6809
|
+
postRun.push(() => {
|
|
6810
|
+
obj[r[0]] = r[1];
|
|
6811
|
+
});
|
|
6812
|
+
}
|
|
6813
|
+
set(obj);
|
|
6814
|
+
continue;
|
|
6815
|
+
case TYPE_PROMISE:
|
|
6816
|
+
if (hydrated[b]) {
|
|
6817
|
+
set(hydrated[index2] = hydrated[b]);
|
|
6818
|
+
} else {
|
|
6819
|
+
const d = new Deferred2();
|
|
6820
|
+
deferred[b] = d;
|
|
6821
|
+
set(hydrated[index2] = d.promise);
|
|
6822
|
+
}
|
|
6823
|
+
continue;
|
|
6824
|
+
case TYPE_ERROR:
|
|
6825
|
+
const [, message, errorType] = value;
|
|
6826
|
+
let error = errorType && globalObj && globalObj[errorType] ? new globalObj[errorType](message) : new Error(message);
|
|
6827
|
+
hydrated[index2] = error;
|
|
6828
|
+
set(error);
|
|
6829
|
+
continue;
|
|
6830
|
+
case TYPE_PREVIOUS_RESOLVED:
|
|
6831
|
+
set(hydrated[index2] = hydrated[b]);
|
|
6832
|
+
continue;
|
|
6833
|
+
default:
|
|
6834
|
+
if (Array.isArray(plugins)) {
|
|
6835
|
+
const r = [];
|
|
6836
|
+
const vals = value.slice(1);
|
|
6837
|
+
for (let i = 0; i < vals.length; i++) {
|
|
6838
|
+
const v = vals[i];
|
|
6839
|
+
stack.push([
|
|
6840
|
+
v,
|
|
6841
|
+
(v2) => {
|
|
6842
|
+
r[i] = v2;
|
|
6843
|
+
}
|
|
6844
|
+
]);
|
|
6845
|
+
}
|
|
6846
|
+
postRun.push(() => {
|
|
6847
|
+
for (const plugin of plugins) {
|
|
6848
|
+
const result2 = plugin(value[0], ...r);
|
|
6849
|
+
if (result2) {
|
|
6850
|
+
set(hydrated[index2] = result2.value);
|
|
6851
|
+
return;
|
|
6852
|
+
}
|
|
6853
|
+
}
|
|
6854
|
+
throw new SyntaxError();
|
|
6855
|
+
});
|
|
6856
|
+
continue;
|
|
6857
|
+
}
|
|
6858
|
+
throw new SyntaxError();
|
|
6859
|
+
}
|
|
6860
|
+
} else {
|
|
6861
|
+
const array = [];
|
|
6862
|
+
hydrated[index2] = array;
|
|
6863
|
+
for (let i = 0; i < value.length; i++) {
|
|
6864
|
+
const n = value[i];
|
|
6865
|
+
if (n !== HOLE) {
|
|
6866
|
+
stack.push([
|
|
6867
|
+
n,
|
|
6868
|
+
(v) => {
|
|
6869
|
+
array[i] = v;
|
|
6870
|
+
}
|
|
6871
|
+
]);
|
|
6872
|
+
}
|
|
6873
|
+
}
|
|
6874
|
+
set(array);
|
|
6875
|
+
continue;
|
|
6876
|
+
}
|
|
6877
|
+
} else {
|
|
6878
|
+
const object = {};
|
|
6879
|
+
hydrated[index2] = object;
|
|
6880
|
+
for (const key of Object.keys(value).reverse()) {
|
|
6881
|
+
const r = [];
|
|
6882
|
+
stack.push([
|
|
6883
|
+
value[key],
|
|
6884
|
+
(v) => {
|
|
6885
|
+
r[1] = v;
|
|
6886
|
+
}
|
|
6887
|
+
]);
|
|
6888
|
+
stack.push([
|
|
6889
|
+
Number(key.slice(1)),
|
|
6890
|
+
(k) => {
|
|
6891
|
+
r[0] = k;
|
|
6892
|
+
}
|
|
6893
|
+
]);
|
|
6894
|
+
postRun.push(() => {
|
|
6895
|
+
object[r[0]] = r[1];
|
|
6896
|
+
});
|
|
6897
|
+
}
|
|
6898
|
+
set(object);
|
|
6899
|
+
continue;
|
|
6900
|
+
}
|
|
6901
|
+
}
|
|
6902
|
+
while (postRun.length > 0) {
|
|
6903
|
+
postRun.pop()();
|
|
6904
|
+
}
|
|
6905
|
+
return result;
|
|
6906
|
+
}
|
|
6907
|
+
|
|
6908
|
+
// vendor/turbo-stream-v2/turbo-stream.ts
|
|
6909
|
+
async function decode(readable, options) {
|
|
6910
|
+
const { plugins } = options ?? {};
|
|
6911
|
+
const done = new Deferred2();
|
|
6912
|
+
const reader = readable.pipeThrough(createLineSplittingTransform()).getReader();
|
|
6913
|
+
const decoder = {
|
|
6914
|
+
values: [],
|
|
6915
|
+
hydrated: [],
|
|
6916
|
+
deferred: {},
|
|
6917
|
+
plugins
|
|
6918
|
+
};
|
|
6919
|
+
const decoded = await decodeInitial.call(decoder, reader);
|
|
6920
|
+
let donePromise = done.promise;
|
|
6921
|
+
if (decoded.done) {
|
|
6922
|
+
done.resolve();
|
|
6923
|
+
} else {
|
|
6924
|
+
donePromise = decodeDeferred.call(decoder, reader).then(done.resolve).catch((reason) => {
|
|
6925
|
+
for (const deferred of Object.values(decoder.deferred)) {
|
|
6926
|
+
deferred.reject(reason);
|
|
6927
|
+
}
|
|
6928
|
+
done.reject(reason);
|
|
6929
|
+
});
|
|
6930
|
+
}
|
|
6931
|
+
return {
|
|
6932
|
+
done: donePromise.then(() => reader.closed),
|
|
6933
|
+
value: decoded.value
|
|
6934
|
+
};
|
|
6935
|
+
}
|
|
6936
|
+
async function decodeInitial(reader) {
|
|
6937
|
+
const read = await reader.read();
|
|
6938
|
+
if (!read.value) {
|
|
6939
|
+
throw new SyntaxError();
|
|
6940
|
+
}
|
|
6941
|
+
let line;
|
|
6942
|
+
try {
|
|
6943
|
+
line = JSON.parse(read.value);
|
|
6944
|
+
} catch (reason) {
|
|
6945
|
+
throw new SyntaxError();
|
|
6946
|
+
}
|
|
6947
|
+
return {
|
|
6948
|
+
done: read.done,
|
|
6949
|
+
value: unflatten.call(this, line)
|
|
6950
|
+
};
|
|
6951
|
+
}
|
|
6952
|
+
async function decodeDeferred(reader) {
|
|
6953
|
+
let read = await reader.read();
|
|
6954
|
+
while (!read.done) {
|
|
6955
|
+
if (!read.value) continue;
|
|
6956
|
+
const line = read.value;
|
|
6957
|
+
switch (line[0]) {
|
|
6958
|
+
case TYPE_PROMISE: {
|
|
6959
|
+
const colonIndex = line.indexOf(":");
|
|
6960
|
+
const deferredId = Number(line.slice(1, colonIndex));
|
|
6961
|
+
const deferred = this.deferred[deferredId];
|
|
6962
|
+
if (!deferred) {
|
|
6963
|
+
throw new Error(`Deferred ID ${deferredId} not found in stream`);
|
|
6964
|
+
}
|
|
6965
|
+
const lineData = line.slice(colonIndex + 1);
|
|
6966
|
+
let jsonLine;
|
|
6967
|
+
try {
|
|
6968
|
+
jsonLine = JSON.parse(lineData);
|
|
6969
|
+
} catch (reason) {
|
|
6970
|
+
throw new SyntaxError();
|
|
6971
|
+
}
|
|
6972
|
+
const value = unflatten.call(this, jsonLine);
|
|
6973
|
+
deferred.resolve(value);
|
|
6974
|
+
break;
|
|
6975
|
+
}
|
|
6976
|
+
case TYPE_ERROR: {
|
|
6977
|
+
const colonIndex = line.indexOf(":");
|
|
6978
|
+
const deferredId = Number(line.slice(1, colonIndex));
|
|
6979
|
+
const deferred = this.deferred[deferredId];
|
|
6980
|
+
if (!deferred) {
|
|
6981
|
+
throw new Error(`Deferred ID ${deferredId} not found in stream`);
|
|
6982
|
+
}
|
|
6983
|
+
const lineData = line.slice(colonIndex + 1);
|
|
6984
|
+
let jsonLine;
|
|
6985
|
+
try {
|
|
6986
|
+
jsonLine = JSON.parse(lineData);
|
|
6987
|
+
} catch (reason) {
|
|
6988
|
+
throw new SyntaxError();
|
|
6989
|
+
}
|
|
6990
|
+
const value = unflatten.call(this, jsonLine);
|
|
6991
|
+
deferred.reject(value);
|
|
6992
|
+
break;
|
|
6993
|
+
}
|
|
6994
|
+
default:
|
|
6995
|
+
throw new SyntaxError();
|
|
6996
|
+
}
|
|
6997
|
+
read = await reader.read();
|
|
6998
|
+
}
|
|
6999
|
+
}
|
|
7000
|
+
function encode(input, options) {
|
|
7001
|
+
const { plugins, postPlugins, signal } = options ?? {};
|
|
7002
|
+
const encoder2 = {
|
|
7003
|
+
deferred: {},
|
|
7004
|
+
index: 0,
|
|
7005
|
+
indices: /* @__PURE__ */ new Map(),
|
|
7006
|
+
stringified: [],
|
|
7007
|
+
plugins,
|
|
7008
|
+
postPlugins,
|
|
7009
|
+
signal
|
|
7010
|
+
};
|
|
7011
|
+
const textEncoder = new TextEncoder();
|
|
7012
|
+
let lastSentIndex = 0;
|
|
7013
|
+
const readable = new ReadableStream({
|
|
7014
|
+
async start(controller) {
|
|
7015
|
+
const id = flatten.call(encoder2, input);
|
|
7016
|
+
if (Array.isArray(id)) {
|
|
7017
|
+
throw new Error("This should never happen");
|
|
7018
|
+
}
|
|
7019
|
+
if (id < 0) {
|
|
7020
|
+
controller.enqueue(textEncoder.encode(`${id}
|
|
7021
|
+
`));
|
|
7022
|
+
} else {
|
|
7023
|
+
controller.enqueue(
|
|
7024
|
+
textEncoder.encode(`[${encoder2.stringified.join(",")}]
|
|
7025
|
+
`)
|
|
7026
|
+
);
|
|
7027
|
+
lastSentIndex = encoder2.stringified.length - 1;
|
|
7028
|
+
}
|
|
7029
|
+
const seenPromises = /* @__PURE__ */ new WeakSet();
|
|
7030
|
+
if (Object.keys(encoder2.deferred).length) {
|
|
7031
|
+
let raceDone;
|
|
7032
|
+
const racePromise = new Promise((resolve, reject) => {
|
|
7033
|
+
raceDone = resolve;
|
|
7034
|
+
if (signal) {
|
|
7035
|
+
const rejectPromise = () => reject(signal.reason || new Error("Signal was aborted."));
|
|
7036
|
+
if (signal.aborted) {
|
|
7037
|
+
rejectPromise();
|
|
7038
|
+
} else {
|
|
7039
|
+
signal.addEventListener("abort", (event) => {
|
|
7040
|
+
rejectPromise();
|
|
7041
|
+
});
|
|
7042
|
+
}
|
|
7043
|
+
}
|
|
7044
|
+
});
|
|
7045
|
+
while (Object.keys(encoder2.deferred).length > 0) {
|
|
7046
|
+
for (const [deferredId, deferred] of Object.entries(
|
|
7047
|
+
encoder2.deferred
|
|
7048
|
+
)) {
|
|
7049
|
+
if (seenPromises.has(deferred)) continue;
|
|
7050
|
+
seenPromises.add(
|
|
7051
|
+
// biome-ignore lint/suspicious/noAssignInExpressions: <explanation>
|
|
7052
|
+
encoder2.deferred[Number(deferredId)] = Promise.race([
|
|
7053
|
+
racePromise,
|
|
7054
|
+
deferred
|
|
7055
|
+
]).then(
|
|
7056
|
+
(resolved) => {
|
|
7057
|
+
const id2 = flatten.call(encoder2, resolved);
|
|
7058
|
+
if (Array.isArray(id2)) {
|
|
7059
|
+
controller.enqueue(
|
|
7060
|
+
textEncoder.encode(
|
|
7061
|
+
`${TYPE_PROMISE}${deferredId}:[["${TYPE_PREVIOUS_RESOLVED}",${id2[0]}]]
|
|
7062
|
+
`
|
|
7063
|
+
)
|
|
7064
|
+
);
|
|
7065
|
+
encoder2.index++;
|
|
7066
|
+
lastSentIndex++;
|
|
7067
|
+
} else if (id2 < 0) {
|
|
7068
|
+
controller.enqueue(
|
|
7069
|
+
textEncoder.encode(
|
|
7070
|
+
`${TYPE_PROMISE}${deferredId}:${id2}
|
|
7071
|
+
`
|
|
7072
|
+
)
|
|
7073
|
+
);
|
|
7074
|
+
} else {
|
|
7075
|
+
const values = encoder2.stringified.slice(lastSentIndex + 1).join(",");
|
|
7076
|
+
controller.enqueue(
|
|
7077
|
+
textEncoder.encode(
|
|
7078
|
+
`${TYPE_PROMISE}${deferredId}:[${values}]
|
|
7079
|
+
`
|
|
7080
|
+
)
|
|
7081
|
+
);
|
|
7082
|
+
lastSentIndex = encoder2.stringified.length - 1;
|
|
7083
|
+
}
|
|
7084
|
+
},
|
|
7085
|
+
(reason) => {
|
|
7086
|
+
if (!reason || typeof reason !== "object" || !(reason instanceof Error)) {
|
|
7087
|
+
reason = new Error("An unknown error occurred");
|
|
7088
|
+
}
|
|
7089
|
+
const id2 = flatten.call(encoder2, reason);
|
|
7090
|
+
if (Array.isArray(id2)) {
|
|
7091
|
+
controller.enqueue(
|
|
7092
|
+
textEncoder.encode(
|
|
7093
|
+
`${TYPE_ERROR}${deferredId}:[["${TYPE_PREVIOUS_RESOLVED}",${id2[0]}]]
|
|
7094
|
+
`
|
|
7095
|
+
)
|
|
7096
|
+
);
|
|
7097
|
+
encoder2.index++;
|
|
7098
|
+
lastSentIndex++;
|
|
7099
|
+
} else if (id2 < 0) {
|
|
7100
|
+
controller.enqueue(
|
|
7101
|
+
textEncoder.encode(`${TYPE_ERROR}${deferredId}:${id2}
|
|
7102
|
+
`)
|
|
7103
|
+
);
|
|
7104
|
+
} else {
|
|
7105
|
+
const values = encoder2.stringified.slice(lastSentIndex + 1).join(",");
|
|
7106
|
+
controller.enqueue(
|
|
7107
|
+
textEncoder.encode(
|
|
7108
|
+
`${TYPE_ERROR}${deferredId}:[${values}]
|
|
7109
|
+
`
|
|
7110
|
+
)
|
|
7111
|
+
);
|
|
7112
|
+
lastSentIndex = encoder2.stringified.length - 1;
|
|
7113
|
+
}
|
|
7114
|
+
}
|
|
7115
|
+
).finally(() => {
|
|
7116
|
+
delete encoder2.deferred[Number(deferredId)];
|
|
7117
|
+
})
|
|
7118
|
+
);
|
|
7119
|
+
}
|
|
7120
|
+
await Promise.race(Object.values(encoder2.deferred));
|
|
7121
|
+
}
|
|
7122
|
+
raceDone();
|
|
7123
|
+
}
|
|
7124
|
+
await Promise.all(Object.values(encoder2.deferred));
|
|
7125
|
+
controller.close();
|
|
7126
|
+
}
|
|
7127
|
+
});
|
|
7128
|
+
return readable;
|
|
7129
|
+
}
|
|
6530
7130
|
|
|
6531
7131
|
// lib/dom/ssr/data.ts
|
|
6532
7132
|
async function createRequestInit(request) {
|
|
@@ -6551,6 +7151,7 @@ async function createRequestInit(request) {
|
|
|
6551
7151
|
|
|
6552
7152
|
// lib/dom/ssr/single-fetch.tsx
|
|
6553
7153
|
var SingleFetchRedirectSymbol = Symbol("SingleFetchRedirect");
|
|
7154
|
+
var SINGLE_FETCH_REDIRECT_STATUS = 202;
|
|
6554
7155
|
var NO_BODY_STATUS_CODES = /* @__PURE__ */ new Set([100, 101, 204, 205]);
|
|
6555
7156
|
function StreamTransfer({
|
|
6556
7157
|
context,
|
|
@@ -6678,7 +7279,7 @@ async function singleFetchActionStrategy(args, fetchAndDecode, basename) {
|
|
|
6678
7279
|
});
|
|
6679
7280
|
return result2;
|
|
6680
7281
|
});
|
|
6681
|
-
if (isResponse(result.result) || isRouteErrorResponse(result.result)) {
|
|
7282
|
+
if (isResponse(result.result) || isRouteErrorResponse(result.result) || isDataWithResponseInit(result.result)) {
|
|
6682
7283
|
return { [actionMatch.route.id]: result };
|
|
6683
7284
|
}
|
|
6684
7285
|
return {
|
|
@@ -6763,7 +7364,8 @@ async function singleFetchLoaderNavigationStrategy(args, router, getRouteInfo, f
|
|
|
6763
7364
|
)
|
|
6764
7365
|
);
|
|
6765
7366
|
await Promise.all(routeDfds.map((d) => d.promise));
|
|
6766
|
-
|
|
7367
|
+
let isInitialLoad = !router.state.initialized && router.state.navigation.state === "idle";
|
|
7368
|
+
if ((isInitialLoad || routesParams.size === 0) && !window.__reactRouterHdrActive) {
|
|
6767
7369
|
singleFetchDfd.resolve({ routes: {} });
|
|
6768
7370
|
} else {
|
|
6769
7371
|
let targetRoutes = ssr && foundOptOutRoute && routesParams.size > 0 ? [...routesParams.keys()] : void 0;
|
|
@@ -6803,7 +7405,7 @@ function stripIndexParam(url) {
|
|
|
6803
7405
|
}
|
|
6804
7406
|
return url;
|
|
6805
7407
|
}
|
|
6806
|
-
function singleFetchUrl(reqUrl, basename
|
|
7408
|
+
function singleFetchUrl(reqUrl, basename) {
|
|
6807
7409
|
let url = typeof reqUrl === "string" ? new URL(
|
|
6808
7410
|
reqUrl,
|
|
6809
7411
|
// This can be called during the SSR flow via PrefetchPageLinksImpl so
|
|
@@ -6811,17 +7413,17 @@ function singleFetchUrl(reqUrl, basename, extension) {
|
|
|
6811
7413
|
typeof window === "undefined" ? "server://singlefetch/" : window.location.origin
|
|
6812
7414
|
) : reqUrl;
|
|
6813
7415
|
if (url.pathname === "/") {
|
|
6814
|
-
url.pathname =
|
|
7416
|
+
url.pathname = "_root.data";
|
|
6815
7417
|
} else if (basename && stripBasename(url.pathname, basename) === "/") {
|
|
6816
|
-
url.pathname = `${basename.replace(/\/$/, "")}/_root
|
|
7418
|
+
url.pathname = `${basename.replace(/\/$/, "")}/_root.data`;
|
|
6817
7419
|
} else {
|
|
6818
|
-
url.pathname = `${url.pathname.replace(/\/$/, "")}
|
|
7420
|
+
url.pathname = `${url.pathname.replace(/\/$/, "")}.data`;
|
|
6819
7421
|
}
|
|
6820
7422
|
return url;
|
|
6821
7423
|
}
|
|
6822
7424
|
async function fetchAndDecodeViaTurboStream(args, basename, targetRoutes) {
|
|
6823
7425
|
let { request } = args;
|
|
6824
|
-
let url = singleFetchUrl(request.url, basename
|
|
7426
|
+
let url = singleFetchUrl(request.url, basename);
|
|
6825
7427
|
if (request.method === "GET") {
|
|
6826
7428
|
url = stripIndexParam(url);
|
|
6827
7429
|
if (targetRoutes) {
|
|
@@ -6832,6 +7434,20 @@ async function fetchAndDecodeViaTurboStream(args, basename, targetRoutes) {
|
|
|
6832
7434
|
if (res.status === 404 && !res.headers.has("X-Remix-Response")) {
|
|
6833
7435
|
throw new ErrorResponseImpl(404, "Not Found", true);
|
|
6834
7436
|
}
|
|
7437
|
+
if (res.status === 204 && res.headers.has("X-Remix-Redirect")) {
|
|
7438
|
+
return {
|
|
7439
|
+
status: SINGLE_FETCH_REDIRECT_STATUS,
|
|
7440
|
+
data: {
|
|
7441
|
+
redirect: {
|
|
7442
|
+
redirect: res.headers.get("X-Remix-Redirect"),
|
|
7443
|
+
status: Number(res.headers.get("X-Remix-Status") || "302"),
|
|
7444
|
+
revalidate: res.headers.get("X-Remix-Revalidate") === "true",
|
|
7445
|
+
reload: res.headers.get("X-Remix-Reload-Document") === "true",
|
|
7446
|
+
replace: res.headers.get("X-Remix-Replace") === "true"
|
|
7447
|
+
}
|
|
7448
|
+
}
|
|
7449
|
+
};
|
|
7450
|
+
}
|
|
6835
7451
|
if (NO_BODY_STATUS_CODES.has(res.status)) {
|
|
6836
7452
|
let routes = {};
|
|
6837
7453
|
if (targetRoutes && request.method !== "GET") {
|
|
@@ -6869,7 +7485,7 @@ async function fetchAndDecodeViaTurboStream(args, basename, targetRoutes) {
|
|
|
6869
7485
|
}
|
|
6870
7486
|
}
|
|
6871
7487
|
function decodeViaTurboStream(body, global2) {
|
|
6872
|
-
return
|
|
7488
|
+
return decode(body, {
|
|
6873
7489
|
plugins: [
|
|
6874
7490
|
(type, ...rest) => {
|
|
6875
7491
|
if (type === "SanitizedError") {
|
|
@@ -6904,13 +7520,13 @@ function decodeViaTurboStream(body, global2) {
|
|
|
6904
7520
|
function unwrapSingleFetchResult(result, routeId) {
|
|
6905
7521
|
if ("redirect" in result) {
|
|
6906
7522
|
let {
|
|
6907
|
-
redirect:
|
|
7523
|
+
redirect: location,
|
|
6908
7524
|
revalidate,
|
|
6909
7525
|
reload,
|
|
6910
7526
|
replace: replace2,
|
|
6911
7527
|
status
|
|
6912
7528
|
} = result.redirect;
|
|
6913
|
-
throw redirect(
|
|
7529
|
+
throw redirect(location, {
|
|
6914
7530
|
status,
|
|
6915
7531
|
headers: {
|
|
6916
7532
|
// Three R's of redirecting (lol Veep)
|
|
@@ -6921,13 +7537,12 @@ function unwrapSingleFetchResult(result, routeId) {
|
|
|
6921
7537
|
});
|
|
6922
7538
|
}
|
|
6923
7539
|
let routeResult = result.routes[routeId];
|
|
6924
|
-
invariant2(routeResult, `No response found for routeId "${routeId}"`);
|
|
6925
7540
|
if ("error" in routeResult) {
|
|
6926
7541
|
throw routeResult.error;
|
|
6927
7542
|
} else if ("data" in routeResult) {
|
|
6928
7543
|
return routeResult.data;
|
|
6929
7544
|
} else {
|
|
6930
|
-
throw new Error(`
|
|
7545
|
+
throw new Error(`No response found for routeId "${routeId}"`);
|
|
6931
7546
|
}
|
|
6932
7547
|
}
|
|
6933
7548
|
function createDeferred2() {
|
|
@@ -7005,14 +7620,14 @@ function RemixRootDefaultErrorBoundary({
|
|
|
7005
7620
|
dangerouslySetInnerHTML: {
|
|
7006
7621
|
__html: `
|
|
7007
7622
|
console.log(
|
|
7008
|
-
"\u{1F4BF} Hey developer \u{1F44B}. You can provide a way better UX than this when your app throws errors. Check out https://
|
|
7623
|
+
"\u{1F4BF} Hey developer \u{1F44B}. You can provide a way better UX than this when your app throws errors. Check out https://reactrouter.com/how-to/error-boundary for more information."
|
|
7009
7624
|
);
|
|
7010
7625
|
`
|
|
7011
7626
|
}
|
|
7012
7627
|
}
|
|
7013
7628
|
);
|
|
7014
7629
|
if (isRouteErrorResponse(error)) {
|
|
7015
|
-
return /* @__PURE__ */ React5.createElement(BoundaryShell, { title: "Unhandled Thrown Response!" }, /* @__PURE__ */ React5.createElement("h1", { style: { fontSize: "24px" } }, error.status, " ", error.statusText), heyDeveloper);
|
|
7630
|
+
return /* @__PURE__ */ React5.createElement(BoundaryShell, { title: "Unhandled Thrown Response!" }, /* @__PURE__ */ React5.createElement("h1", { style: { fontSize: "24px" } }, error.status, " ", error.statusText), ENABLE_DEV_WARNINGS ? heyDeveloper : null);
|
|
7016
7631
|
}
|
|
7017
7632
|
let errorInstance;
|
|
7018
7633
|
if (error instanceof Error) {
|
|
@@ -7065,7 +7680,7 @@ function BoundaryShell({
|
|
|
7065
7680
|
// lib/dom/ssr/fallback.tsx
|
|
7066
7681
|
var React6 = __toESM(require("react"));
|
|
7067
7682
|
function RemixRootDefaultHydrateFallback() {
|
|
7068
|
-
return /* @__PURE__ */ React6.createElement(BoundaryShell, { title: "Loading...", renderScripts: true }, /* @__PURE__ */ React6.createElement(
|
|
7683
|
+
return /* @__PURE__ */ React6.createElement(BoundaryShell, { title: "Loading...", renderScripts: true }, ENABLE_DEV_WARNINGS ? /* @__PURE__ */ React6.createElement(
|
|
7069
7684
|
"script",
|
|
7070
7685
|
{
|
|
7071
7686
|
dangerouslySetInnerHTML: {
|
|
@@ -7073,13 +7688,13 @@ function RemixRootDefaultHydrateFallback() {
|
|
|
7073
7688
|
console.log(
|
|
7074
7689
|
"\u{1F4BF} Hey developer \u{1F44B}. You can provide a way better UX than this " +
|
|
7075
7690
|
"when your app is loading JS modules and/or running \`clientLoader\` " +
|
|
7076
|
-
"functions. Check out https://
|
|
7691
|
+
"functions. Check out https://reactrouter.com/start/framework/route-module#hydratefallback " +
|
|
7077
7692
|
"for more information."
|
|
7078
7693
|
);
|
|
7079
7694
|
`
|
|
7080
7695
|
}
|
|
7081
7696
|
}
|
|
7082
|
-
));
|
|
7697
|
+
) : null);
|
|
7083
7698
|
}
|
|
7084
7699
|
|
|
7085
7700
|
// lib/dom/ssr/routes.tsx
|
|
@@ -7492,8 +8107,8 @@ var nextPaths = /* @__PURE__ */ new Set();
|
|
|
7492
8107
|
var discoveredPathsMaxSize = 1e3;
|
|
7493
8108
|
var discoveredPaths = /* @__PURE__ */ new Set();
|
|
7494
8109
|
var URL_LIMIT = 7680;
|
|
7495
|
-
function isFogOfWarEnabled(ssr) {
|
|
7496
|
-
return ssr === true;
|
|
8110
|
+
function isFogOfWarEnabled(routeDiscovery, ssr) {
|
|
8111
|
+
return routeDiscovery.mode === "lazy" && ssr === true;
|
|
7497
8112
|
}
|
|
7498
8113
|
function getPartialManifest({ sri, ...manifest }, router) {
|
|
7499
8114
|
let routeIds = new Set(router.state.matches.map((m) => m.route.id));
|
|
@@ -7520,8 +8135,8 @@ function getPartialManifest({ sri, ...manifest }, router) {
|
|
|
7520
8135
|
sri: sri ? true : void 0
|
|
7521
8136
|
};
|
|
7522
8137
|
}
|
|
7523
|
-
function getPatchRoutesOnNavigationFunction(manifest, routeModules, ssr, isSpaMode, basename) {
|
|
7524
|
-
if (!isFogOfWarEnabled(ssr)) {
|
|
8138
|
+
function getPatchRoutesOnNavigationFunction(manifest, routeModules, ssr, routeDiscovery, isSpaMode, basename) {
|
|
8139
|
+
if (!isFogOfWarEnabled(routeDiscovery, ssr)) {
|
|
7525
8140
|
return void 0;
|
|
7526
8141
|
}
|
|
7527
8142
|
return async ({ path, patch, signal, fetcherKey }) => {
|
|
@@ -7536,14 +8151,16 @@ function getPatchRoutesOnNavigationFunction(manifest, routeModules, ssr, isSpaMo
|
|
|
7536
8151
|
ssr,
|
|
7537
8152
|
isSpaMode,
|
|
7538
8153
|
basename,
|
|
8154
|
+
routeDiscovery.manifestPath,
|
|
7539
8155
|
patch,
|
|
7540
8156
|
signal
|
|
7541
8157
|
);
|
|
7542
8158
|
};
|
|
7543
8159
|
}
|
|
7544
|
-
function useFogOFWarDiscovery(router, manifest, routeModules, ssr, isSpaMode) {
|
|
8160
|
+
function useFogOFWarDiscovery(router, manifest, routeModules, ssr, routeDiscovery, isSpaMode) {
|
|
7545
8161
|
React8.useEffect(() => {
|
|
7546
|
-
if (!isFogOfWarEnabled(ssr) ||
|
|
8162
|
+
if (!isFogOfWarEnabled(routeDiscovery, ssr) || // @ts-expect-error - TS doesn't know about this yet
|
|
8163
|
+
window.navigator?.connection?.saveData === true) {
|
|
7547
8164
|
return;
|
|
7548
8165
|
}
|
|
7549
8166
|
function registerElement(el) {
|
|
@@ -7577,6 +8194,7 @@ function useFogOFWarDiscovery(router, manifest, routeModules, ssr, isSpaMode) {
|
|
|
7577
8194
|
ssr,
|
|
7578
8195
|
isSpaMode,
|
|
7579
8196
|
router.basename,
|
|
8197
|
+
routeDiscovery.manifestPath,
|
|
7580
8198
|
router.patchRoutes
|
|
7581
8199
|
);
|
|
7582
8200
|
} catch (e) {
|
|
@@ -7593,15 +8211,21 @@ function useFogOFWarDiscovery(router, manifest, routeModules, ssr, isSpaMode) {
|
|
|
7593
8211
|
attributeFilter: ["data-discover", "href", "action"]
|
|
7594
8212
|
});
|
|
7595
8213
|
return () => observer.disconnect();
|
|
7596
|
-
}, [ssr, isSpaMode, manifest, routeModules, router]);
|
|
8214
|
+
}, [ssr, isSpaMode, manifest, routeModules, router, routeDiscovery]);
|
|
8215
|
+
}
|
|
8216
|
+
function getManifestPath(_manifestPath, basename) {
|
|
8217
|
+
let manifestPath = _manifestPath || "/__manifest";
|
|
8218
|
+
if (basename == null) {
|
|
8219
|
+
return manifestPath;
|
|
8220
|
+
}
|
|
8221
|
+
return `${basename}${manifestPath}`.replace(/\/+/g, "/");
|
|
7597
8222
|
}
|
|
7598
8223
|
var MANIFEST_VERSION_STORAGE_KEY = "react-router-manifest-version";
|
|
7599
|
-
async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, routeModules, ssr, isSpaMode, basename, patchRoutes, signal) {
|
|
7600
|
-
let
|
|
7601
|
-
|
|
7602
|
-
|
|
8224
|
+
async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, routeModules, ssr, isSpaMode, basename, manifestPath, patchRoutes, signal) {
|
|
8225
|
+
let url = new URL(
|
|
8226
|
+
getManifestPath(manifestPath, basename),
|
|
8227
|
+
window.location.origin
|
|
7603
8228
|
);
|
|
7604
|
-
let url = new URL(manifestPath, window.location.origin);
|
|
7605
8229
|
paths.sort().forEach((path) => url.searchParams.append("p", path));
|
|
7606
8230
|
url.searchParams.set("version", manifest.version);
|
|
7607
8231
|
if (url.toString().length > URL_LIMIT) {
|
|
@@ -7628,7 +8252,9 @@ async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, ro
|
|
|
7628
8252
|
}
|
|
7629
8253
|
sessionStorage.setItem(MANIFEST_VERSION_STORAGE_KEY, manifest.version);
|
|
7630
8254
|
window.location.href = errorReloadPath;
|
|
7631
|
-
|
|
8255
|
+
console.warn("Detected manifest version mismatch, reloading...");
|
|
8256
|
+
await new Promise(() => {
|
|
8257
|
+
});
|
|
7632
8258
|
} else if (res.status >= 400) {
|
|
7633
8259
|
throw new Error(await res.text());
|
|
7634
8260
|
}
|
|
@@ -7827,7 +8453,7 @@ function PrefetchPageLinksImpl({
|
|
|
7827
8453
|
matches: nextMatches,
|
|
7828
8454
|
...linkProps
|
|
7829
8455
|
}) {
|
|
7830
|
-
let
|
|
8456
|
+
let location = useLocation();
|
|
7831
8457
|
let { manifest, routeModules } = useFrameworkContext();
|
|
7832
8458
|
let { basename } = useDataRouterContext2();
|
|
7833
8459
|
let { loaderData, matches } = useDataRouterStateContext();
|
|
@@ -7837,10 +8463,10 @@ function PrefetchPageLinksImpl({
|
|
|
7837
8463
|
nextMatches,
|
|
7838
8464
|
matches,
|
|
7839
8465
|
manifest,
|
|
7840
|
-
|
|
8466
|
+
location,
|
|
7841
8467
|
"data"
|
|
7842
8468
|
),
|
|
7843
|
-
[page, nextMatches, matches, manifest,
|
|
8469
|
+
[page, nextMatches, matches, manifest, location]
|
|
7844
8470
|
);
|
|
7845
8471
|
let newMatchesForAssets = React9.useMemo(
|
|
7846
8472
|
() => getNewMatchesForLinks(
|
|
@@ -7848,13 +8474,13 @@ function PrefetchPageLinksImpl({
|
|
|
7848
8474
|
nextMatches,
|
|
7849
8475
|
matches,
|
|
7850
8476
|
manifest,
|
|
7851
|
-
|
|
8477
|
+
location,
|
|
7852
8478
|
"assets"
|
|
7853
8479
|
),
|
|
7854
|
-
[page, nextMatches, matches, manifest,
|
|
8480
|
+
[page, nextMatches, matches, manifest, location]
|
|
7855
8481
|
);
|
|
7856
8482
|
let dataHrefs = React9.useMemo(() => {
|
|
7857
|
-
if (page ===
|
|
8483
|
+
if (page === location.pathname + location.search + location.hash) {
|
|
7858
8484
|
return [];
|
|
7859
8485
|
}
|
|
7860
8486
|
let routesParams = /* @__PURE__ */ new Set();
|
|
@@ -7875,7 +8501,7 @@ function PrefetchPageLinksImpl({
|
|
|
7875
8501
|
if (routesParams.size === 0) {
|
|
7876
8502
|
return [];
|
|
7877
8503
|
}
|
|
7878
|
-
let url = singleFetchUrl(page, basename
|
|
8504
|
+
let url = singleFetchUrl(page, basename);
|
|
7879
8505
|
if (foundOptOutRoute && routesParams.size > 0) {
|
|
7880
8506
|
url.searchParams.set(
|
|
7881
8507
|
"_routes",
|
|
@@ -7886,7 +8512,7 @@ function PrefetchPageLinksImpl({
|
|
|
7886
8512
|
}, [
|
|
7887
8513
|
basename,
|
|
7888
8514
|
loaderData,
|
|
7889
|
-
|
|
8515
|
+
location,
|
|
7890
8516
|
manifest,
|
|
7891
8517
|
newMatchesForData,
|
|
7892
8518
|
nextMatches,
|
|
@@ -7911,7 +8537,7 @@ function Meta() {
|
|
|
7911
8537
|
matches: routerMatches,
|
|
7912
8538
|
loaderData
|
|
7913
8539
|
} = useDataRouterStateContext();
|
|
7914
|
-
let
|
|
8540
|
+
let location = useLocation();
|
|
7915
8541
|
let _matches = getActiveMatches(routerMatches, errors, isSpaMode);
|
|
7916
8542
|
let error = null;
|
|
7917
8543
|
if (errors) {
|
|
@@ -7941,7 +8567,7 @@ function Meta() {
|
|
|
7941
8567
|
routeMeta = typeof routeModule.meta === "function" ? routeModule.meta({
|
|
7942
8568
|
data: data2,
|
|
7943
8569
|
params,
|
|
7944
|
-
location
|
|
8570
|
+
location,
|
|
7945
8571
|
matches,
|
|
7946
8572
|
error
|
|
7947
8573
|
}) : Array.isArray(routeModule.meta) ? [...routeModule.meta] : routeModule.meta;
|
|
@@ -8007,10 +8633,17 @@ function isValidMetaTag(tagName) {
|
|
|
8007
8633
|
}
|
|
8008
8634
|
var isHydrated = false;
|
|
8009
8635
|
function Scripts(props) {
|
|
8010
|
-
let {
|
|
8636
|
+
let {
|
|
8637
|
+
manifest,
|
|
8638
|
+
serverHandoffString,
|
|
8639
|
+
isSpaMode,
|
|
8640
|
+
renderMeta,
|
|
8641
|
+
routeDiscovery,
|
|
8642
|
+
ssr
|
|
8643
|
+
} = useFrameworkContext();
|
|
8011
8644
|
let { router, static: isStatic, staticContext } = useDataRouterContext2();
|
|
8012
8645
|
let { matches: routerMatches } = useDataRouterStateContext();
|
|
8013
|
-
let enableFogOfWar = isFogOfWarEnabled(ssr);
|
|
8646
|
+
let enableFogOfWar = isFogOfWarEnabled(routeDiscovery, ssr);
|
|
8014
8647
|
if (renderMeta) {
|
|
8015
8648
|
renderMeta.didRenderScripts = true;
|
|
8016
8649
|
}
|
|
@@ -8166,7 +8799,7 @@ function mergeRefs(...refs) {
|
|
|
8166
8799
|
var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
8167
8800
|
try {
|
|
8168
8801
|
if (isBrowser) {
|
|
8169
|
-
window.__reactRouterVersion = "0.0.0-experimental-
|
|
8802
|
+
window.__reactRouterVersion = "0.0.0-experimental-aecfb0db1";
|
|
8170
8803
|
}
|
|
8171
8804
|
} catch (e) {
|
|
8172
8805
|
}
|
|
@@ -8424,14 +9057,14 @@ var NavLink = React10.forwardRef(
|
|
|
8424
9057
|
...rest
|
|
8425
9058
|
}, ref) {
|
|
8426
9059
|
let path = useResolvedPath(to, { relative: rest.relative });
|
|
8427
|
-
let
|
|
9060
|
+
let location = useLocation();
|
|
8428
9061
|
let routerState = React10.useContext(DataRouterStateContext);
|
|
8429
|
-
let { navigator
|
|
9062
|
+
let { navigator, basename } = React10.useContext(NavigationContext);
|
|
8430
9063
|
let isTransitioning = routerState != null && // Conditional usage is OK here because the usage of a data router is static
|
|
8431
9064
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
8432
9065
|
useViewTransitionState(path) && viewTransition === true;
|
|
8433
|
-
let toPathname =
|
|
8434
|
-
let locationPathname =
|
|
9066
|
+
let toPathname = navigator.encodeLocation ? navigator.encodeLocation(path).pathname : path.pathname;
|
|
9067
|
+
let locationPathname = location.pathname;
|
|
8435
9068
|
let nextLocationPathname = routerState && routerState.navigation && routerState.navigation.location ? routerState.navigation.location.pathname : null;
|
|
8436
9069
|
if (!caseSensitive) {
|
|
8437
9070
|
locationPathname = locationPathname.toLowerCase();
|
|
@@ -8536,19 +9169,19 @@ function ScrollRestoration({
|
|
|
8536
9169
|
}) {
|
|
8537
9170
|
let remixContext = React10.useContext(FrameworkContext);
|
|
8538
9171
|
let { basename } = React10.useContext(NavigationContext);
|
|
8539
|
-
let
|
|
9172
|
+
let location = useLocation();
|
|
8540
9173
|
let matches = useMatches();
|
|
8541
9174
|
useScrollRestoration({ getKey, storageKey });
|
|
8542
9175
|
let ssrKey = React10.useMemo(
|
|
8543
9176
|
() => {
|
|
8544
9177
|
if (!remixContext || !getKey) return null;
|
|
8545
9178
|
let userKey = getScrollRestorationKey(
|
|
8546
|
-
|
|
9179
|
+
location,
|
|
8547
9180
|
matches,
|
|
8548
9181
|
basename,
|
|
8549
9182
|
getKey
|
|
8550
9183
|
);
|
|
8551
|
-
return userKey !==
|
|
9184
|
+
return userKey !== location.key ? userKey : null;
|
|
8552
9185
|
},
|
|
8553
9186
|
// Nah, we only need this the first time for the SSR render
|
|
8554
9187
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -8609,13 +9242,13 @@ function useLinkClickHandler(to, {
|
|
|
8609
9242
|
viewTransition
|
|
8610
9243
|
} = {}) {
|
|
8611
9244
|
let navigate = useNavigate();
|
|
8612
|
-
let
|
|
9245
|
+
let location = useLocation();
|
|
8613
9246
|
let path = useResolvedPath(to, { relative });
|
|
8614
9247
|
return React10.useCallback(
|
|
8615
9248
|
(event) => {
|
|
8616
9249
|
if (shouldProcessLinkClick(event, target)) {
|
|
8617
9250
|
event.preventDefault();
|
|
8618
|
-
let replace2 = replaceProp !== void 0 ? replaceProp : createPath(
|
|
9251
|
+
let replace2 = replaceProp !== void 0 ? replaceProp : createPath(location) === createPath(path);
|
|
8619
9252
|
navigate(to, {
|
|
8620
9253
|
replace: replace2,
|
|
8621
9254
|
state,
|
|
@@ -8626,7 +9259,7 @@ function useLinkClickHandler(to, {
|
|
|
8626
9259
|
}
|
|
8627
9260
|
},
|
|
8628
9261
|
[
|
|
8629
|
-
|
|
9262
|
+
location,
|
|
8630
9263
|
navigate,
|
|
8631
9264
|
path,
|
|
8632
9265
|
replaceProp,
|
|
@@ -8646,18 +9279,18 @@ function useSearchParams(defaultInit) {
|
|
|
8646
9279
|
);
|
|
8647
9280
|
let defaultSearchParamsRef = React10.useRef(createSearchParams(defaultInit));
|
|
8648
9281
|
let hasSetSearchParamsRef = React10.useRef(false);
|
|
8649
|
-
let
|
|
9282
|
+
let location = useLocation();
|
|
8650
9283
|
let searchParams = React10.useMemo(
|
|
8651
9284
|
() => (
|
|
8652
9285
|
// Only merge in the defaults if we haven't yet called setSearchParams.
|
|
8653
9286
|
// Once we call that we want those to take precedence, otherwise you can't
|
|
8654
9287
|
// remove a param with setSearchParams({}) if it has an initial value
|
|
8655
9288
|
getSearchParamsForLocation(
|
|
8656
|
-
|
|
9289
|
+
location.search,
|
|
8657
9290
|
hasSetSearchParamsRef.current ? null : defaultSearchParamsRef.current
|
|
8658
9291
|
)
|
|
8659
9292
|
),
|
|
8660
|
-
[
|
|
9293
|
+
[location.search]
|
|
8661
9294
|
);
|
|
8662
9295
|
let navigate = useNavigate();
|
|
8663
9296
|
let setSearchParams = React10.useCallback(
|
|
@@ -8718,9 +9351,9 @@ function useFormAction(action, { relative } = {}) {
|
|
|
8718
9351
|
invariant(routeContext, "useFormAction must be used inside a RouteContext");
|
|
8719
9352
|
let [match] = routeContext.matches.slice(-1);
|
|
8720
9353
|
let path = { ...useResolvedPath(action ? action : ".", { relative }) };
|
|
8721
|
-
let
|
|
9354
|
+
let location = useLocation();
|
|
8722
9355
|
if (action == null) {
|
|
8723
|
-
path.search =
|
|
9356
|
+
path.search = location.search;
|
|
8724
9357
|
let params = new URLSearchParams(path.search);
|
|
8725
9358
|
let indexValues = params.getAll("index");
|
|
8726
9359
|
let hasNakedIndexParam = indexValues.some((v) => v === "");
|
|
@@ -8812,23 +9445,23 @@ function useFetchers() {
|
|
|
8812
9445
|
}
|
|
8813
9446
|
var SCROLL_RESTORATION_STORAGE_KEY = "react-router-scroll-positions";
|
|
8814
9447
|
var savedScrollPositions = {};
|
|
8815
|
-
function getScrollRestorationKey(
|
|
9448
|
+
function getScrollRestorationKey(location, matches, basename, getKey) {
|
|
8816
9449
|
let key = null;
|
|
8817
9450
|
if (getKey) {
|
|
8818
9451
|
if (basename !== "/") {
|
|
8819
9452
|
key = getKey(
|
|
8820
9453
|
{
|
|
8821
|
-
...
|
|
8822
|
-
pathname: stripBasename(
|
|
9454
|
+
...location,
|
|
9455
|
+
pathname: stripBasename(location.pathname, basename) || location.pathname
|
|
8823
9456
|
},
|
|
8824
9457
|
matches
|
|
8825
9458
|
);
|
|
8826
9459
|
} else {
|
|
8827
|
-
key = getKey(
|
|
9460
|
+
key = getKey(location, matches);
|
|
8828
9461
|
}
|
|
8829
9462
|
}
|
|
8830
9463
|
if (key == null) {
|
|
8831
|
-
key =
|
|
9464
|
+
key = location.key;
|
|
8832
9465
|
}
|
|
8833
9466
|
return key;
|
|
8834
9467
|
}
|
|
@@ -8841,7 +9474,7 @@ function useScrollRestoration({
|
|
|
8841
9474
|
"useScrollRestoration" /* UseScrollRestoration */
|
|
8842
9475
|
);
|
|
8843
9476
|
let { basename } = React10.useContext(NavigationContext);
|
|
8844
|
-
let
|
|
9477
|
+
let location = useLocation();
|
|
8845
9478
|
let matches = useMatches();
|
|
8846
9479
|
let navigation = useNavigation();
|
|
8847
9480
|
React10.useEffect(() => {
|
|
@@ -8853,7 +9486,7 @@ function useScrollRestoration({
|
|
|
8853
9486
|
usePageHide(
|
|
8854
9487
|
React10.useCallback(() => {
|
|
8855
9488
|
if (navigation.state === "idle") {
|
|
8856
|
-
let key = getScrollRestorationKey(
|
|
9489
|
+
let key = getScrollRestorationKey(location, matches, basename, getKey);
|
|
8857
9490
|
savedScrollPositions[key] = window.scrollY;
|
|
8858
9491
|
}
|
|
8859
9492
|
try {
|
|
@@ -8868,7 +9501,7 @@ function useScrollRestoration({
|
|
|
8868
9501
|
);
|
|
8869
9502
|
}
|
|
8870
9503
|
window.history.scrollRestoration = "auto";
|
|
8871
|
-
}, [navigation.state, getKey, basename,
|
|
9504
|
+
}, [navigation.state, getKey, basename, location, matches, storageKey])
|
|
8872
9505
|
);
|
|
8873
9506
|
if (typeof document !== "undefined") {
|
|
8874
9507
|
React10.useLayoutEffect(() => {
|
|
@@ -8886,7 +9519,7 @@ function useScrollRestoration({
|
|
|
8886
9519
|
let disableScrollRestoration = router?.enableScrollRestoration(
|
|
8887
9520
|
savedScrollPositions,
|
|
8888
9521
|
() => window.scrollY,
|
|
8889
|
-
getKey ? (
|
|
9522
|
+
getKey ? (location2, matches2) => getScrollRestorationKey(location2, matches2, basename, getKey) : void 0
|
|
8890
9523
|
);
|
|
8891
9524
|
return () => disableScrollRestoration && disableScrollRestoration();
|
|
8892
9525
|
}, [router, basename, getKey]);
|
|
@@ -8898,9 +9531,9 @@ function useScrollRestoration({
|
|
|
8898
9531
|
window.scrollTo(0, restoreScrollPosition);
|
|
8899
9532
|
return;
|
|
8900
9533
|
}
|
|
8901
|
-
if (
|
|
9534
|
+
if (location.hash) {
|
|
8902
9535
|
let el = document.getElementById(
|
|
8903
|
-
decodeURIComponent(
|
|
9536
|
+
decodeURIComponent(location.hash.slice(1))
|
|
8904
9537
|
);
|
|
8905
9538
|
if (el) {
|
|
8906
9539
|
el.scrollIntoView();
|
|
@@ -8911,7 +9544,7 @@ function useScrollRestoration({
|
|
|
8911
9544
|
return;
|
|
8912
9545
|
}
|
|
8913
9546
|
window.scrollTo(0, 0);
|
|
8914
|
-
}, [
|
|
9547
|
+
}, [location, restoreScrollPosition, preventScrollReset]);
|
|
8915
9548
|
}
|
|
8916
9549
|
}
|
|
8917
9550
|
function useBeforeUnload(callback, options) {
|
|
@@ -8984,7 +9617,7 @@ function StaticRouter({
|
|
|
8984
9617
|
locationProp = parsePath(locationProp);
|
|
8985
9618
|
}
|
|
8986
9619
|
let action = "POP" /* Pop */;
|
|
8987
|
-
let
|
|
9620
|
+
let location = {
|
|
8988
9621
|
pathname: locationProp.pathname || "/",
|
|
8989
9622
|
search: locationProp.search || "",
|
|
8990
9623
|
hash: locationProp.hash || "",
|
|
@@ -8997,7 +9630,7 @@ function StaticRouter({
|
|
|
8997
9630
|
{
|
|
8998
9631
|
basename,
|
|
8999
9632
|
children,
|
|
9000
|
-
location
|
|
9633
|
+
location,
|
|
9001
9634
|
navigationType: action,
|
|
9002
9635
|
navigator: staticNavigator,
|
|
9003
9636
|
static: true
|
|
@@ -9007,7 +9640,7 @@ function StaticRouter({
|
|
|
9007
9640
|
function StaticRouterProvider({
|
|
9008
9641
|
context,
|
|
9009
9642
|
router,
|
|
9010
|
-
hydrate = true,
|
|
9643
|
+
hydrate: hydrate2 = true,
|
|
9011
9644
|
nonce
|
|
9012
9645
|
}) {
|
|
9013
9646
|
invariant(
|
|
@@ -9023,7 +9656,7 @@ function StaticRouterProvider({
|
|
|
9023
9656
|
};
|
|
9024
9657
|
let fetchersContext = /* @__PURE__ */ new Map();
|
|
9025
9658
|
let hydrateScript = "";
|
|
9026
|
-
if (
|
|
9659
|
+
if (hydrate2 !== false) {
|
|
9027
9660
|
let data2 = {
|
|
9028
9661
|
loaderData: context.loaderData,
|
|
9029
9662
|
actionData: context.actionData,
|
|
@@ -9216,9 +9849,6 @@ function createStaticRouter(routes, context, opts = {}) {
|
|
|
9216
9849
|
_internalFetchControllers: /* @__PURE__ */ new Map(),
|
|
9217
9850
|
_internalSetRoutes() {
|
|
9218
9851
|
throw msg("_internalSetRoutes");
|
|
9219
|
-
},
|
|
9220
|
-
_internalSetStateDoNotUseOrYouWillBreakYourApp() {
|
|
9221
|
-
throw msg("_internalSetStateDoNotUseOrYouWillBreakYourApp");
|
|
9222
9852
|
}
|
|
9223
9853
|
};
|
|
9224
9854
|
}
|
|
@@ -9293,6 +9923,7 @@ function ServerRouter({
|
|
|
9293
9923
|
future: context.future,
|
|
9294
9924
|
ssr: context.ssr,
|
|
9295
9925
|
isSpaMode: context.isSpaMode,
|
|
9926
|
+
routeDiscovery: context.routeDiscovery,
|
|
9296
9927
|
serializeError: context.serializeError,
|
|
9297
9928
|
renderMeta: context.renderMeta
|
|
9298
9929
|
}
|
|
@@ -9342,7 +9973,8 @@ function createRoutesStub(routes, unstable_getContext) {
|
|
|
9342
9973
|
},
|
|
9343
9974
|
routeModules: {},
|
|
9344
9975
|
ssr: false,
|
|
9345
|
-
isSpaMode: false
|
|
9976
|
+
isSpaMode: false,
|
|
9977
|
+
routeDiscovery: { mode: "lazy", manifestPath: "/__manifest" }
|
|
9346
9978
|
};
|
|
9347
9979
|
let patched = processRoutes(
|
|
9348
9980
|
// @ts-expect-error `StubRouteObject` is stricter about `loader`/`action`
|
|
@@ -9426,7 +10058,7 @@ function processRoutes(routes, manifest, routeModules, parentId) {
|
|
|
9426
10058
|
var import_cookie = require("cookie");
|
|
9427
10059
|
|
|
9428
10060
|
// lib/server-runtime/crypto.ts
|
|
9429
|
-
var encoder = new TextEncoder();
|
|
10061
|
+
var encoder = /* @__PURE__ */ new TextEncoder();
|
|
9430
10062
|
var sign = async (value, secret) => {
|
|
9431
10063
|
let data2 = encoder.encode(value);
|
|
9432
10064
|
let key = await createKey2(secret, ["sign"]);
|
|
@@ -9746,6 +10378,26 @@ function invariant3(value, message) {
|
|
|
9746
10378
|
}
|
|
9747
10379
|
}
|
|
9748
10380
|
|
|
10381
|
+
// lib/server-runtime/dev.ts
|
|
10382
|
+
var globalDevServerHooksKey = "__reactRouterDevServerHooks";
|
|
10383
|
+
function setDevServerHooks(devServerHooks) {
|
|
10384
|
+
globalThis[globalDevServerHooksKey] = devServerHooks;
|
|
10385
|
+
}
|
|
10386
|
+
function getDevServerHooks() {
|
|
10387
|
+
return globalThis[globalDevServerHooksKey];
|
|
10388
|
+
}
|
|
10389
|
+
function getBuildTimeHeader(request, headerName) {
|
|
10390
|
+
if (typeof process !== "undefined") {
|
|
10391
|
+
try {
|
|
10392
|
+
if (process.env?.IS_RR_BUILD_REQUEST === "yes") {
|
|
10393
|
+
return request.headers.get(headerName);
|
|
10394
|
+
}
|
|
10395
|
+
} catch (e) {
|
|
10396
|
+
}
|
|
10397
|
+
}
|
|
10398
|
+
return null;
|
|
10399
|
+
}
|
|
10400
|
+
|
|
9749
10401
|
// lib/server-runtime/routes.ts
|
|
9750
10402
|
function groupRoutesByParentId2(manifest) {
|
|
9751
10403
|
let routes = {};
|
|
@@ -9777,10 +10429,11 @@ function createStaticHandlerDataRoutes(manifest, future, parentId = "", routesBy
|
|
|
9777
10429
|
// Need to use RR's version in the param typed here to permit the optional
|
|
9778
10430
|
// context even though we know it'll always be provided in remix
|
|
9779
10431
|
loader: route.module.loader ? async (args) => {
|
|
9780
|
-
|
|
9781
|
-
|
|
9782
|
-
|
|
9783
|
-
|
|
10432
|
+
let preRenderedData = getBuildTimeHeader(
|
|
10433
|
+
args.request,
|
|
10434
|
+
"X-React-Router-Prerender-Data"
|
|
10435
|
+
);
|
|
10436
|
+
if (preRenderedData != null) {
|
|
9784
10437
|
let encoded = preRenderedData ? decodeURI(preRenderedData) : preRenderedData;
|
|
9785
10438
|
invariant3(encoded, "Missing prerendered data for route");
|
|
9786
10439
|
let uint8array = new TextEncoder().encode(encoded);
|
|
@@ -9855,21 +10508,9 @@ function createServerHandoffString(serverHandoff) {
|
|
|
9855
10508
|
return escapeHtml2(JSON.stringify(serverHandoff));
|
|
9856
10509
|
}
|
|
9857
10510
|
|
|
9858
|
-
// lib/server-runtime/dev.ts
|
|
9859
|
-
var globalDevServerHooksKey = "__reactRouterDevServerHooks";
|
|
9860
|
-
function setDevServerHooks(devServerHooks) {
|
|
9861
|
-
globalThis[globalDevServerHooksKey] = devServerHooks;
|
|
9862
|
-
}
|
|
9863
|
-
function getDevServerHooks() {
|
|
9864
|
-
return globalThis[globalDevServerHooksKey];
|
|
9865
|
-
}
|
|
9866
|
-
|
|
9867
|
-
// lib/server-runtime/single-fetch.ts
|
|
9868
|
-
var import_turbo_stream2 = require("turbo-stream");
|
|
9869
|
-
|
|
9870
10511
|
// lib/server-runtime/headers.ts
|
|
9871
10512
|
var import_set_cookie_parser = require("set-cookie-parser");
|
|
9872
|
-
function getDocumentHeaders(
|
|
10513
|
+
function getDocumentHeaders(build, context) {
|
|
9873
10514
|
let boundaryIdx = context.errors ? context.matches.findIndex((m) => context.errors[m.route.id]) : -1;
|
|
9874
10515
|
let matches = boundaryIdx >= 0 ? context.matches.slice(0, boundaryIdx + 1) : context.matches;
|
|
9875
10516
|
let errorHeaders;
|
|
@@ -9887,12 +10528,14 @@ function getDocumentHeaders(context, getRouteHeadersFn) {
|
|
|
9887
10528
|
}
|
|
9888
10529
|
return matches.reduce((parentHeaders, match, idx) => {
|
|
9889
10530
|
let { id } = match.route;
|
|
10531
|
+
let route = build.routes[id];
|
|
10532
|
+
invariant3(route, `Route with id "${id}" not found in build`);
|
|
10533
|
+
let routeModule = route.module;
|
|
9890
10534
|
let loaderHeaders = context.loaderHeaders[id] || new Headers();
|
|
9891
10535
|
let actionHeaders = context.actionHeaders[id] || new Headers();
|
|
9892
10536
|
let includeErrorHeaders = errorHeaders != null && idx === matches.length - 1;
|
|
9893
10537
|
let includeErrorCookies = includeErrorHeaders && errorHeaders !== loaderHeaders && errorHeaders !== actionHeaders;
|
|
9894
|
-
|
|
9895
|
-
if (headersFn == null) {
|
|
10538
|
+
if (routeModule.headers == null) {
|
|
9896
10539
|
let headers2 = new Headers(parentHeaders);
|
|
9897
10540
|
if (includeErrorCookies) {
|
|
9898
10541
|
prependCookies(errorHeaders, headers2);
|
|
@@ -9902,12 +10545,12 @@ function getDocumentHeaders(context, getRouteHeadersFn) {
|
|
|
9902
10545
|
return headers2;
|
|
9903
10546
|
}
|
|
9904
10547
|
let headers = new Headers(
|
|
9905
|
-
typeof
|
|
10548
|
+
routeModule.headers ? typeof routeModule.headers === "function" ? routeModule.headers({
|
|
9906
10549
|
loaderHeaders,
|
|
9907
10550
|
parentHeaders,
|
|
9908
10551
|
actionHeaders,
|
|
9909
10552
|
errorHeaders: includeErrorHeaders ? errorHeaders : void 0
|
|
9910
|
-
}) :
|
|
10553
|
+
}) : routeModule.headers : void 0
|
|
9911
10554
|
);
|
|
9912
10555
|
if (includeErrorCookies) {
|
|
9913
10556
|
prependCookies(errorHeaders, headers);
|
|
@@ -9932,7 +10575,6 @@ function prependCookies(parentHeaders, childHeaders) {
|
|
|
9932
10575
|
}
|
|
9933
10576
|
|
|
9934
10577
|
// lib/server-runtime/single-fetch.ts
|
|
9935
|
-
var SINGLE_FETCH_REDIRECT_STATUS = 202;
|
|
9936
10578
|
var SERVER_NO_BODY_STATUS_CODES = /* @__PURE__ */ new Set([
|
|
9937
10579
|
...NO_BODY_STATUS_CODES,
|
|
9938
10580
|
304
|
|
@@ -9940,10 +10582,7 @@ var SERVER_NO_BODY_STATUS_CODES = /* @__PURE__ */ new Set([
|
|
|
9940
10582
|
async function singleFetchAction(build, serverMode, staticHandler, request, handlerUrl, loadContext, handleError) {
|
|
9941
10583
|
try {
|
|
9942
10584
|
let respond2 = function(context) {
|
|
9943
|
-
let headers = getDocumentHeaders(
|
|
9944
|
-
context,
|
|
9945
|
-
(m) => build.routes[m.route.id]?.module.headers
|
|
9946
|
-
);
|
|
10585
|
+
let headers = getDocumentHeaders(build, context);
|
|
9947
10586
|
if (isRedirectStatusCode(context.statusCode) && headers.has("Location")) {
|
|
9948
10587
|
return generateSingleFetchResponse(request, build, serverMode, {
|
|
9949
10588
|
result: getSingleFetchRedirect(
|
|
@@ -10018,10 +10657,7 @@ async function singleFetchAction(build, serverMode, staticHandler, request, hand
|
|
|
10018
10657
|
async function singleFetchLoaders(build, serverMode, staticHandler, request, handlerUrl, loadContext, handleError) {
|
|
10019
10658
|
try {
|
|
10020
10659
|
let respond2 = function(context) {
|
|
10021
|
-
let headers = getDocumentHeaders(
|
|
10022
|
-
context,
|
|
10023
|
-
(m) => build.routes[m.route.id]?.module.headers
|
|
10024
|
-
);
|
|
10660
|
+
let headers = getDocumentHeaders(build, context);
|
|
10025
10661
|
if (isRedirectStatusCode(context.statusCode) && headers.has("Location")) {
|
|
10026
10662
|
return generateSingleFetchResponse(request, build, serverMode, {
|
|
10027
10663
|
result: {
|
|
@@ -10157,7 +10793,7 @@ function encodeViaTurboStream(data2, requestSignal, streamTimeout, serverMode) {
|
|
|
10157
10793
|
typeof streamTimeout === "number" ? streamTimeout : 4950
|
|
10158
10794
|
);
|
|
10159
10795
|
requestSignal.addEventListener("abort", () => clearTimeout(timeoutId));
|
|
10160
|
-
return
|
|
10796
|
+
return encode(data2, {
|
|
10161
10797
|
signal: controller.signal,
|
|
10162
10798
|
plugins: [
|
|
10163
10799
|
(value) => {
|
|
@@ -10277,9 +10913,10 @@ Error: ${e instanceof Error ? e.toString() : e}`
|
|
|
10277
10913
|
if (stripBasename(normalizedPath, normalizedBasename) !== "/" && normalizedPath.endsWith("/")) {
|
|
10278
10914
|
normalizedPath = normalizedPath.slice(0, -1);
|
|
10279
10915
|
}
|
|
10916
|
+
let isSpaMode = getBuildTimeHeader(request, "X-React-Router-SPA-Mode") === "yes";
|
|
10280
10917
|
if (!_build.ssr) {
|
|
10281
10918
|
if (_build.prerender.length === 0) {
|
|
10282
|
-
|
|
10919
|
+
isSpaMode = true;
|
|
10283
10920
|
} else if (!_build.prerender.includes(normalizedPath) && !_build.prerender.includes(normalizedPath + "/")) {
|
|
10284
10921
|
if (url.pathname.endsWith(".data")) {
|
|
10285
10922
|
errorHandler(
|
|
@@ -10299,11 +10936,14 @@ Error: ${e instanceof Error ? e.toString() : e}`
|
|
|
10299
10936
|
statusText: "Not Found"
|
|
10300
10937
|
});
|
|
10301
10938
|
} else {
|
|
10302
|
-
|
|
10939
|
+
isSpaMode = true;
|
|
10303
10940
|
}
|
|
10304
10941
|
}
|
|
10305
10942
|
}
|
|
10306
|
-
let manifestUrl =
|
|
10943
|
+
let manifestUrl = getManifestPath(
|
|
10944
|
+
_build.routeDiscovery.manifestPath,
|
|
10945
|
+
normalizedBasename
|
|
10946
|
+
);
|
|
10307
10947
|
if (url.pathname === manifestUrl) {
|
|
10308
10948
|
try {
|
|
10309
10949
|
let res = await handleManifestRequest(_build, routes, url);
|
|
@@ -10313,7 +10953,7 @@ Error: ${e instanceof Error ? e.toString() : e}`
|
|
|
10313
10953
|
return new Response("Unknown Server Error", { status: 500 });
|
|
10314
10954
|
}
|
|
10315
10955
|
}
|
|
10316
|
-
let matches = matchServerRoutes(routes,
|
|
10956
|
+
let matches = matchServerRoutes(routes, normalizedPath, _build.basename);
|
|
10317
10957
|
if (matches && matches.length > 0) {
|
|
10318
10958
|
Object.assign(params, matches[0].params);
|
|
10319
10959
|
}
|
|
@@ -10368,7 +11008,7 @@ Error: ${e instanceof Error ? e.toString() : e}`
|
|
|
10368
11008
|
);
|
|
10369
11009
|
}
|
|
10370
11010
|
}
|
|
10371
|
-
} else if (!
|
|
11011
|
+
} else if (!isSpaMode && matches && matches[matches.length - 1].route.module.default == null && matches[matches.length - 1].route.module.ErrorBoundary == null) {
|
|
10372
11012
|
response = await handleResourceRequest(
|
|
10373
11013
|
serverMode,
|
|
10374
11014
|
_build,
|
|
@@ -10393,6 +11033,7 @@ Error: ${e instanceof Error ? e.toString() : e}`
|
|
|
10393
11033
|
request,
|
|
10394
11034
|
loadContext,
|
|
10395
11035
|
handleError,
|
|
11036
|
+
isSpaMode,
|
|
10396
11037
|
criticalCss
|
|
10397
11038
|
);
|
|
10398
11039
|
}
|
|
@@ -10468,8 +11109,7 @@ async function handleSingleFetchRequest(serverMode, build, staticHandler, reques
|
|
|
10468
11109
|
);
|
|
10469
11110
|
return response;
|
|
10470
11111
|
}
|
|
10471
|
-
async function handleDocumentRequest(serverMode, build, staticHandler, request, loadContext, handleError, criticalCss) {
|
|
10472
|
-
let isSpaMode = request.headers.has("X-React-Router-SPA-Mode");
|
|
11112
|
+
async function handleDocumentRequest(serverMode, build, staticHandler, request, loadContext, handleError, isSpaMode, criticalCss) {
|
|
10473
11113
|
try {
|
|
10474
11114
|
let response = await staticHandler.query(request, {
|
|
10475
11115
|
requestContext: loadContext,
|
|
@@ -10484,10 +11124,7 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
|
|
|
10484
11124
|
if (isResponse(context)) {
|
|
10485
11125
|
return context;
|
|
10486
11126
|
}
|
|
10487
|
-
let headers = getDocumentHeaders(
|
|
10488
|
-
context,
|
|
10489
|
-
(m) => build.routes[m.route.id]?.module.headers
|
|
10490
|
-
);
|
|
11127
|
+
let headers = getDocumentHeaders(build, context);
|
|
10491
11128
|
if (SERVER_NO_BODY_STATUS_CODES.has(context.statusCode)) {
|
|
10492
11129
|
return new Response(null, { status: context.statusCode, headers });
|
|
10493
11130
|
}
|
|
@@ -10504,17 +11141,21 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
|
|
|
10504
11141
|
actionData: context.actionData,
|
|
10505
11142
|
errors: serializeErrors2(context.errors, serverMode)
|
|
10506
11143
|
};
|
|
11144
|
+
let baseServerHandoff = {
|
|
11145
|
+
basename: build.basename,
|
|
11146
|
+
future: build.future,
|
|
11147
|
+
routeDiscovery: build.routeDiscovery,
|
|
11148
|
+
ssr: build.ssr,
|
|
11149
|
+
isSpaMode: isSpaMode2
|
|
11150
|
+
};
|
|
10507
11151
|
let entryContext = {
|
|
10508
11152
|
manifest: build.assets,
|
|
10509
11153
|
routeModules: createEntryRouteModules(build.routes),
|
|
10510
11154
|
staticHandlerContext: context,
|
|
10511
11155
|
criticalCss,
|
|
10512
11156
|
serverHandoffString: createServerHandoffString({
|
|
10513
|
-
|
|
10514
|
-
criticalCss
|
|
10515
|
-
future: build.future,
|
|
10516
|
-
ssr: build.ssr,
|
|
10517
|
-
isSpaMode: isSpaMode2
|
|
11157
|
+
...baseServerHandoff,
|
|
11158
|
+
criticalCss
|
|
10518
11159
|
}),
|
|
10519
11160
|
serverHandoffStream: encodeViaTurboStream(
|
|
10520
11161
|
state,
|
|
@@ -10525,6 +11166,7 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
|
|
|
10525
11166
|
renderMeta: {},
|
|
10526
11167
|
future: build.future,
|
|
10527
11168
|
ssr: build.ssr,
|
|
11169
|
+
routeDiscovery: build.routeDiscovery,
|
|
10528
11170
|
isSpaMode: isSpaMode2,
|
|
10529
11171
|
serializeError: (err) => serializeError(err, serverMode)
|
|
10530
11172
|
};
|
|
@@ -10567,12 +11209,7 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
|
|
|
10567
11209
|
entryContext = {
|
|
10568
11210
|
...entryContext,
|
|
10569
11211
|
staticHandlerContext: context,
|
|
10570
|
-
serverHandoffString: createServerHandoffString(
|
|
10571
|
-
basename: build.basename,
|
|
10572
|
-
future: build.future,
|
|
10573
|
-
ssr: build.ssr,
|
|
10574
|
-
isSpaMode: isSpaMode2
|
|
10575
|
-
}),
|
|
11212
|
+
serverHandoffString: createServerHandoffString(baseServerHandoff),
|
|
10576
11213
|
serverHandoffStream: encodeViaTurboStream(
|
|
10577
11214
|
state2,
|
|
10578
11215
|
request.signal,
|
|
@@ -10745,7 +11382,7 @@ function createSessionStorage({
|
|
|
10745
11382
|
function warnOnceAboutSigningSessionCookie(cookie) {
|
|
10746
11383
|
warnOnce(
|
|
10747
11384
|
cookie.isSigned,
|
|
10748
|
-
`The "${cookie.name}" cookie is not signed, but session cookies should be signed to prevent tampering on the client before they are sent back to the server. See https://
|
|
11385
|
+
`The "${cookie.name}" cookie is not signed, but session cookies should be signed to prevent tampering on the client before they are sent back to the server. See https://reactrouter.com/explanation/sessions-and-cookies#signing-cookies for more information.`
|
|
10749
11386
|
);
|
|
10750
11387
|
}
|
|
10751
11388
|
|
|
@@ -10825,680 +11462,6 @@ function href(path, ...args) {
|
|
|
10825
11462
|
}).filter((segment) => segment !== void 0).join("/");
|
|
10826
11463
|
}
|
|
10827
11464
|
|
|
10828
|
-
// lib/rsc/browser.tsx
|
|
10829
|
-
var React14 = __toESM(require("react"));
|
|
10830
|
-
|
|
10831
|
-
// lib/dom/ssr/hydration.tsx
|
|
10832
|
-
function getHydrationData(state, routes, getRouteInfo, location2, basename, isSpaMode) {
|
|
10833
|
-
let hydrationData = {
|
|
10834
|
-
...state,
|
|
10835
|
-
loaderData: { ...state.loaderData }
|
|
10836
|
-
};
|
|
10837
|
-
let initialMatches = matchRoutes(routes, location2, basename);
|
|
10838
|
-
if (initialMatches) {
|
|
10839
|
-
for (let match of initialMatches) {
|
|
10840
|
-
let routeId = match.route.id;
|
|
10841
|
-
let routeInfo = getRouteInfo(routeId);
|
|
10842
|
-
if (shouldHydrateRouteLoader(
|
|
10843
|
-
routeId,
|
|
10844
|
-
routeInfo.clientLoader,
|
|
10845
|
-
routeInfo.hasLoader,
|
|
10846
|
-
isSpaMode
|
|
10847
|
-
) && (routeInfo.hasHydrateFallback || !routeInfo.hasLoader)) {
|
|
10848
|
-
delete hydrationData.loaderData[routeId];
|
|
10849
|
-
} else if (!routeInfo.hasLoader) {
|
|
10850
|
-
hydrationData.loaderData[routeId] = null;
|
|
10851
|
-
}
|
|
10852
|
-
}
|
|
10853
|
-
}
|
|
10854
|
-
return hydrationData;
|
|
10855
|
-
}
|
|
10856
|
-
|
|
10857
|
-
// lib/rsc/browser.tsx
|
|
10858
|
-
function createCallServer({
|
|
10859
|
-
decode: decode2,
|
|
10860
|
-
encodeAction
|
|
10861
|
-
}) {
|
|
10862
|
-
let landedActionId = 0;
|
|
10863
|
-
return async (id, args) => {
|
|
10864
|
-
let actionId = window.__routerActionID = (window.__routerActionID ?? (window.__routerActionID = 0)) + 1;
|
|
10865
|
-
const response = await fetch(location.href, {
|
|
10866
|
-
body: await encodeAction(args),
|
|
10867
|
-
method: "POST",
|
|
10868
|
-
headers: {
|
|
10869
|
-
Accept: "text/x-component",
|
|
10870
|
-
"rsc-action-id": id
|
|
10871
|
-
}
|
|
10872
|
-
});
|
|
10873
|
-
if (!response.body) {
|
|
10874
|
-
throw new Error("No response body");
|
|
10875
|
-
}
|
|
10876
|
-
const payload = await decode2(response.body);
|
|
10877
|
-
if (payload.type !== "action") {
|
|
10878
|
-
throw new Error("Unexpected payload type");
|
|
10879
|
-
}
|
|
10880
|
-
if (payload.rerender) {
|
|
10881
|
-
(async () => {
|
|
10882
|
-
const rerender = await payload.rerender;
|
|
10883
|
-
if (!rerender) return;
|
|
10884
|
-
if (landedActionId < actionId && window.__routerActionID <= actionId) {
|
|
10885
|
-
landedActionId = actionId;
|
|
10886
|
-
if (rerender.type === "redirect") {
|
|
10887
|
-
if (rerender.reload) {
|
|
10888
|
-
window.location.href = rerender.location;
|
|
10889
|
-
return;
|
|
10890
|
-
}
|
|
10891
|
-
window.__router.navigate(rerender.location, {
|
|
10892
|
-
replace: rerender.replace
|
|
10893
|
-
});
|
|
10894
|
-
return;
|
|
10895
|
-
}
|
|
10896
|
-
let lastMatch;
|
|
10897
|
-
for (const match of rerender.matches) {
|
|
10898
|
-
window.__router.patchRoutes(
|
|
10899
|
-
lastMatch?.id ?? null,
|
|
10900
|
-
[createRouteFromServerManifest(match)],
|
|
10901
|
-
true
|
|
10902
|
-
);
|
|
10903
|
-
lastMatch = match;
|
|
10904
|
-
}
|
|
10905
|
-
window.__router._internalSetStateDoNotUseOrYouWillBreakYourApp({});
|
|
10906
|
-
React14.startTransition(() => {
|
|
10907
|
-
window.__router._internalSetStateDoNotUseOrYouWillBreakYourApp({
|
|
10908
|
-
loaderData: Object.assign(
|
|
10909
|
-
{},
|
|
10910
|
-
window.__router.state.loaderData,
|
|
10911
|
-
rerender.loaderData
|
|
10912
|
-
),
|
|
10913
|
-
errors: rerender.errors ? Object.assign(
|
|
10914
|
-
{},
|
|
10915
|
-
window.__router.state.errors,
|
|
10916
|
-
rerender.errors
|
|
10917
|
-
) : null
|
|
10918
|
-
});
|
|
10919
|
-
});
|
|
10920
|
-
}
|
|
10921
|
-
})();
|
|
10922
|
-
}
|
|
10923
|
-
return payload.actionResult;
|
|
10924
|
-
};
|
|
10925
|
-
}
|
|
10926
|
-
function createRouterFromPayload({
|
|
10927
|
-
decode: decode2,
|
|
10928
|
-
payload
|
|
10929
|
-
}) {
|
|
10930
|
-
if (window.__router) return window.__router;
|
|
10931
|
-
if (payload.type !== "render") throw new Error("Invalid payload type");
|
|
10932
|
-
let patches = /* @__PURE__ */ new Map();
|
|
10933
|
-
payload.patches?.forEach((patch) => {
|
|
10934
|
-
invariant(patch.parentId, "Invalid patch parentId");
|
|
10935
|
-
if (!patches.has(patch.parentId)) {
|
|
10936
|
-
patches.set(patch.parentId, []);
|
|
10937
|
-
}
|
|
10938
|
-
patches.get(patch.parentId)?.push(patch);
|
|
10939
|
-
});
|
|
10940
|
-
let routes = payload.matches.reduceRight((previous, match) => {
|
|
10941
|
-
const route = createRouteFromServerManifest(
|
|
10942
|
-
match,
|
|
10943
|
-
payload
|
|
10944
|
-
);
|
|
10945
|
-
if (previous.length > 0) {
|
|
10946
|
-
route.children = previous;
|
|
10947
|
-
let childrenToPatch = patches.get(match.id);
|
|
10948
|
-
if (childrenToPatch) {
|
|
10949
|
-
route.children.push(
|
|
10950
|
-
...childrenToPatch.map((r) => createRouteFromServerManifest(r))
|
|
10951
|
-
);
|
|
10952
|
-
}
|
|
10953
|
-
}
|
|
10954
|
-
return [route];
|
|
10955
|
-
}, []);
|
|
10956
|
-
window.__router = createRouter({
|
|
10957
|
-
routes,
|
|
10958
|
-
basename: payload.basename,
|
|
10959
|
-
history: createBrowserHistory(),
|
|
10960
|
-
hydrationData: getHydrationData(
|
|
10961
|
-
{
|
|
10962
|
-
loaderData: payload.loaderData,
|
|
10963
|
-
actionData: payload.actionData,
|
|
10964
|
-
errors: payload.errors
|
|
10965
|
-
},
|
|
10966
|
-
routes,
|
|
10967
|
-
(routeId) => {
|
|
10968
|
-
let match = payload.matches.find((m) => m.id === routeId);
|
|
10969
|
-
invariant(match, "Route not found in payload");
|
|
10970
|
-
return {
|
|
10971
|
-
clientLoader: match.clientLoader,
|
|
10972
|
-
hasLoader: match.hasLoader,
|
|
10973
|
-
hasHydrateFallback: match.hydrateFallbackElement != null
|
|
10974
|
-
};
|
|
10975
|
-
},
|
|
10976
|
-
payload.location,
|
|
10977
|
-
void 0,
|
|
10978
|
-
false
|
|
10979
|
-
),
|
|
10980
|
-
async patchRoutesOnNavigation({ patch, path, signal }) {
|
|
10981
|
-
let response = await fetch(`${path}.manifest`, { signal });
|
|
10982
|
-
if (!response.body || response.status < 200 || response.status >= 300) {
|
|
10983
|
-
throw new Error("Unable to fetch new route matches from the server");
|
|
10984
|
-
}
|
|
10985
|
-
let payload2 = await decode2(response.body);
|
|
10986
|
-
if (payload2.type !== "manifest") {
|
|
10987
|
-
throw new Error("Failed to patch routes on navigation");
|
|
10988
|
-
}
|
|
10989
|
-
payload2.matches.forEach(
|
|
10990
|
-
(match, i) => patch(payload2.matches[i - 1]?.id ?? null, [
|
|
10991
|
-
createRouteFromServerManifest(match)
|
|
10992
|
-
])
|
|
10993
|
-
);
|
|
10994
|
-
payload2.patches.forEach((p) => {
|
|
10995
|
-
patch(p.parentId ?? null, [createRouteFromServerManifest(p)]);
|
|
10996
|
-
});
|
|
10997
|
-
},
|
|
10998
|
-
// FIXME: Pass `build.ssr` and `build.basename` into this function
|
|
10999
|
-
dataStrategy: getRSCSingleFetchDataStrategy(
|
|
11000
|
-
() => window.__router,
|
|
11001
|
-
true,
|
|
11002
|
-
void 0,
|
|
11003
|
-
decode2
|
|
11004
|
-
)
|
|
11005
|
-
});
|
|
11006
|
-
if (window.__router.state.initialized) {
|
|
11007
|
-
window.__routerInitialized = true;
|
|
11008
|
-
window.__router.initialize();
|
|
11009
|
-
} else {
|
|
11010
|
-
window.__routerInitialized = false;
|
|
11011
|
-
}
|
|
11012
|
-
let lastLoaderData = void 0;
|
|
11013
|
-
window.__router.subscribe(({ loaderData, actionData }) => {
|
|
11014
|
-
if (lastLoaderData !== loaderData) {
|
|
11015
|
-
window.__routerActionID = (window.__routerActionID ?? (window.__routerActionID = 0)) + 1;
|
|
11016
|
-
}
|
|
11017
|
-
});
|
|
11018
|
-
return window.__router;
|
|
11019
|
-
}
|
|
11020
|
-
var renderedRoutesContext = unstable_createContext();
|
|
11021
|
-
function getRSCSingleFetchDataStrategy(getRouter, ssr, basename, decode2) {
|
|
11022
|
-
let dataStrategy = getSingleFetchDataStrategyImpl(
|
|
11023
|
-
getRouter,
|
|
11024
|
-
(match) => {
|
|
11025
|
-
let M = match;
|
|
11026
|
-
return {
|
|
11027
|
-
hasLoader: M.route.hasLoader,
|
|
11028
|
-
hasClientLoader: M.route.hasClientLoader,
|
|
11029
|
-
hasAction: M.route.hasAction,
|
|
11030
|
-
hasClientAction: M.route.hasClientAction,
|
|
11031
|
-
hasShouldRevalidate: M.route.hasShouldRevalidate
|
|
11032
|
-
};
|
|
11033
|
-
},
|
|
11034
|
-
// pass map into fetchAndDecode so it can add payloads
|
|
11035
|
-
getFetchAndDecodeViaRSC(decode2),
|
|
11036
|
-
ssr,
|
|
11037
|
-
basename
|
|
11038
|
-
);
|
|
11039
|
-
return async (args) => args.unstable_runClientMiddleware(async () => {
|
|
11040
|
-
let context = args.context;
|
|
11041
|
-
context.set(renderedRoutesContext, []);
|
|
11042
|
-
let results = await dataStrategy(args);
|
|
11043
|
-
const renderedRouteById = new Map(
|
|
11044
|
-
context.get(renderedRoutesContext).map((r) => [r.id, r])
|
|
11045
|
-
);
|
|
11046
|
-
for (const match of args.matches) {
|
|
11047
|
-
const rendered = renderedRouteById.get(match.route.id);
|
|
11048
|
-
if (rendered) {
|
|
11049
|
-
window.__router.patchRoutes(
|
|
11050
|
-
rendered.parentId ?? null,
|
|
11051
|
-
[createRouteFromServerManifest(rendered)],
|
|
11052
|
-
true
|
|
11053
|
-
);
|
|
11054
|
-
}
|
|
11055
|
-
}
|
|
11056
|
-
return results;
|
|
11057
|
-
});
|
|
11058
|
-
}
|
|
11059
|
-
function getFetchAndDecodeViaRSC(decode2) {
|
|
11060
|
-
return async (args, basename, targetRoutes) => {
|
|
11061
|
-
let { request, context } = args;
|
|
11062
|
-
let url = singleFetchUrl(request.url, basename, "rsc");
|
|
11063
|
-
if (request.method === "GET") {
|
|
11064
|
-
url = stripIndexParam(url);
|
|
11065
|
-
if (targetRoutes) {
|
|
11066
|
-
url.searchParams.set("_routes", targetRoutes.join(","));
|
|
11067
|
-
}
|
|
11068
|
-
}
|
|
11069
|
-
let res = await fetch(url, await createRequestInit(request));
|
|
11070
|
-
if (res.status === 404 && !res.headers.has("X-Remix-Response")) {
|
|
11071
|
-
throw new ErrorResponseImpl(404, "Not Found", true);
|
|
11072
|
-
}
|
|
11073
|
-
invariant(res.body, "No response body to decode");
|
|
11074
|
-
try {
|
|
11075
|
-
const payload = await decode2(res.body);
|
|
11076
|
-
if (payload.type === "redirect") {
|
|
11077
|
-
return {
|
|
11078
|
-
status: res.status,
|
|
11079
|
-
data: {
|
|
11080
|
-
redirect: {
|
|
11081
|
-
redirect: payload.location,
|
|
11082
|
-
reload: false,
|
|
11083
|
-
replace: payload.replace,
|
|
11084
|
-
revalidate: false,
|
|
11085
|
-
status: payload.status
|
|
11086
|
-
}
|
|
11087
|
-
}
|
|
11088
|
-
};
|
|
11089
|
-
}
|
|
11090
|
-
if (payload.type !== "render") {
|
|
11091
|
-
throw new Error("Unexpected payload type");
|
|
11092
|
-
}
|
|
11093
|
-
context.get(renderedRoutesContext).push(...payload.matches);
|
|
11094
|
-
let results = { routes: {} };
|
|
11095
|
-
const dataKey = isMutationMethod(request.method) ? "actionData" : "loaderData";
|
|
11096
|
-
for (let [routeId, data2] of Object.entries(payload[dataKey] || {})) {
|
|
11097
|
-
results.routes[routeId] = { data: data2 };
|
|
11098
|
-
}
|
|
11099
|
-
if (payload.errors) {
|
|
11100
|
-
for (let [routeId, error] of Object.entries(payload.errors)) {
|
|
11101
|
-
results.routes[routeId] = { error };
|
|
11102
|
-
}
|
|
11103
|
-
}
|
|
11104
|
-
return { status: res.status, data: results };
|
|
11105
|
-
} catch (e) {
|
|
11106
|
-
throw new Error("Unable to decode RSC response");
|
|
11107
|
-
}
|
|
11108
|
-
};
|
|
11109
|
-
}
|
|
11110
|
-
function RSCHydratedRouter({
|
|
11111
|
-
decode: decode2,
|
|
11112
|
-
payload
|
|
11113
|
-
}) {
|
|
11114
|
-
if (payload.type !== "render") throw new Error("Invalid payload type");
|
|
11115
|
-
let router = React14.useMemo(
|
|
11116
|
-
() => createRouterFromPayload({ decode: decode2, payload }),
|
|
11117
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
11118
|
-
[]
|
|
11119
|
-
);
|
|
11120
|
-
React14.useLayoutEffect(() => {
|
|
11121
|
-
if (!window.__routerInitialized) {
|
|
11122
|
-
window.__routerInitialized = true;
|
|
11123
|
-
window.__router.initialize();
|
|
11124
|
-
}
|
|
11125
|
-
}, []);
|
|
11126
|
-
const frameworkContext = {
|
|
11127
|
-
future: {
|
|
11128
|
-
// These flags have no runtime impact so can always be false. If we add
|
|
11129
|
-
// flags that drive runtime behavior they'll need to be proxied through.
|
|
11130
|
-
unstable_middleware: false,
|
|
11131
|
-
unstable_subResourceIntegrity: false
|
|
11132
|
-
},
|
|
11133
|
-
isSpaMode: true,
|
|
11134
|
-
ssr: true,
|
|
11135
|
-
criticalCss: "",
|
|
11136
|
-
manifest: {
|
|
11137
|
-
routes: {},
|
|
11138
|
-
version: "1",
|
|
11139
|
-
url: "",
|
|
11140
|
-
entry: {
|
|
11141
|
-
module: "",
|
|
11142
|
-
imports: []
|
|
11143
|
-
}
|
|
11144
|
-
},
|
|
11145
|
-
routeModules: {}
|
|
11146
|
-
};
|
|
11147
|
-
return /* @__PURE__ */ React14.createElement(FrameworkContext.Provider, { value: frameworkContext }, /* @__PURE__ */ React14.createElement(RouterProvider, { router }));
|
|
11148
|
-
}
|
|
11149
|
-
function createRouteFromServerManifest(match, payload) {
|
|
11150
|
-
let hasInitialData = payload && match.id in payload.loaderData;
|
|
11151
|
-
let initialData = payload?.loaderData[match.id];
|
|
11152
|
-
let hasInitialError = payload?.errors && match.id in payload.errors;
|
|
11153
|
-
let initialError = payload?.errors?.[match.id];
|
|
11154
|
-
let isHydrationRequest = match.clientLoader?.hydrate === true || !match.hasLoader;
|
|
11155
|
-
let dataRoute = {
|
|
11156
|
-
id: match.id,
|
|
11157
|
-
element: match.element,
|
|
11158
|
-
errorElement: match.errorElement,
|
|
11159
|
-
handle: match.handle,
|
|
11160
|
-
hasErrorBoundary: match.hasErrorBoundary,
|
|
11161
|
-
hydrateFallbackElement: match.hydrateFallbackElement,
|
|
11162
|
-
index: match.index,
|
|
11163
|
-
loader: match.clientLoader ? async (args, singleFetch) => {
|
|
11164
|
-
try {
|
|
11165
|
-
let result = await match.clientLoader({
|
|
11166
|
-
...args,
|
|
11167
|
-
serverLoader: () => {
|
|
11168
|
-
preventInvalidServerHandlerCall2(
|
|
11169
|
-
"loader",
|
|
11170
|
-
match.id,
|
|
11171
|
-
match.hasLoader
|
|
11172
|
-
);
|
|
11173
|
-
if (isHydrationRequest) {
|
|
11174
|
-
if (hasInitialData) {
|
|
11175
|
-
return initialData;
|
|
11176
|
-
}
|
|
11177
|
-
if (hasInitialError) {
|
|
11178
|
-
throw initialError;
|
|
11179
|
-
}
|
|
11180
|
-
}
|
|
11181
|
-
return callSingleFetch(singleFetch);
|
|
11182
|
-
}
|
|
11183
|
-
});
|
|
11184
|
-
return result;
|
|
11185
|
-
} finally {
|
|
11186
|
-
isHydrationRequest = false;
|
|
11187
|
-
}
|
|
11188
|
-
} : (
|
|
11189
|
-
// We always make the call in this RSC world since even if we don't
|
|
11190
|
-
// have a `loader` we may need to get the `element` implementation
|
|
11191
|
-
(_, singleFetch) => callSingleFetch(singleFetch)
|
|
11192
|
-
),
|
|
11193
|
-
action: match.clientAction ? (args, singleFetch) => match.clientAction({
|
|
11194
|
-
...args,
|
|
11195
|
-
serverAction: async () => {
|
|
11196
|
-
preventInvalidServerHandlerCall2(
|
|
11197
|
-
"loader",
|
|
11198
|
-
match.id,
|
|
11199
|
-
match.hasLoader
|
|
11200
|
-
);
|
|
11201
|
-
return await callSingleFetch(singleFetch);
|
|
11202
|
-
}
|
|
11203
|
-
}) : match.hasAction ? (_, singleFetch) => callSingleFetch(singleFetch) : void 0,
|
|
11204
|
-
path: match.path,
|
|
11205
|
-
shouldRevalidate: match.shouldRevalidate,
|
|
11206
|
-
// We always have a "loader" in this RSC world since even if we don't
|
|
11207
|
-
// have a `loader` we may need to get the `element` implementation
|
|
11208
|
-
hasLoader: true,
|
|
11209
|
-
hasClientLoader: match.clientLoader != null,
|
|
11210
|
-
hasAction: match.hasAction,
|
|
11211
|
-
hasClientAction: match.clientAction != null,
|
|
11212
|
-
hasShouldRevalidate: match.shouldRevalidate != null
|
|
11213
|
-
};
|
|
11214
|
-
if (typeof dataRoute.loader === "function") {
|
|
11215
|
-
dataRoute.loader.hydrate = shouldHydrateRouteLoader(
|
|
11216
|
-
match.id,
|
|
11217
|
-
match.clientLoader,
|
|
11218
|
-
match.hasLoader,
|
|
11219
|
-
false
|
|
11220
|
-
);
|
|
11221
|
-
}
|
|
11222
|
-
return dataRoute;
|
|
11223
|
-
}
|
|
11224
|
-
function callSingleFetch(singleFetch) {
|
|
11225
|
-
invariant(typeof singleFetch === "function", "Invalid singleFetch parameter");
|
|
11226
|
-
return singleFetch();
|
|
11227
|
-
}
|
|
11228
|
-
function preventInvalidServerHandlerCall2(type, routeId, hasHandler) {
|
|
11229
|
-
if (!hasHandler) {
|
|
11230
|
-
let fn = type === "action" ? "serverAction()" : "serverLoader()";
|
|
11231
|
-
let msg = `You are trying to call ${fn} on a route that does not have a server ${type} (routeId: "${routeId}")`;
|
|
11232
|
-
console.error(msg);
|
|
11233
|
-
throw new ErrorResponseImpl(400, "Bad Request", new Error(msg), true);
|
|
11234
|
-
}
|
|
11235
|
-
}
|
|
11236
|
-
|
|
11237
|
-
// lib/rsc/server.ssr.tsx
|
|
11238
|
-
var React15 = __toESM(require("react"));
|
|
11239
|
-
|
|
11240
|
-
// lib/rsc/html-stream/server.ts
|
|
11241
|
-
var encoder2 = new TextEncoder();
|
|
11242
|
-
var trailer = "</body></html>";
|
|
11243
|
-
function injectRSCPayload(rscStream) {
|
|
11244
|
-
let decoder = new TextDecoder();
|
|
11245
|
-
let resolveFlightDataPromise;
|
|
11246
|
-
let flightDataPromise = new Promise(
|
|
11247
|
-
(resolve) => resolveFlightDataPromise = resolve
|
|
11248
|
-
);
|
|
11249
|
-
let startedRSC = false;
|
|
11250
|
-
let buffered = [];
|
|
11251
|
-
let timeout = null;
|
|
11252
|
-
function flushBufferedChunks(controller) {
|
|
11253
|
-
for (let chunk of buffered) {
|
|
11254
|
-
let buf = decoder.decode(chunk, { stream: true });
|
|
11255
|
-
if (buf.endsWith(trailer)) {
|
|
11256
|
-
buf = buf.slice(0, -trailer.length);
|
|
11257
|
-
}
|
|
11258
|
-
controller.enqueue(encoder2.encode(buf));
|
|
11259
|
-
}
|
|
11260
|
-
buffered.length = 0;
|
|
11261
|
-
timeout = null;
|
|
11262
|
-
}
|
|
11263
|
-
return new TransformStream({
|
|
11264
|
-
transform(chunk, controller) {
|
|
11265
|
-
buffered.push(chunk);
|
|
11266
|
-
if (timeout) {
|
|
11267
|
-
return;
|
|
11268
|
-
}
|
|
11269
|
-
timeout = setTimeout(async () => {
|
|
11270
|
-
flushBufferedChunks(controller);
|
|
11271
|
-
if (!startedRSC) {
|
|
11272
|
-
startedRSC = true;
|
|
11273
|
-
writeRSCStream(rscStream, controller).catch((err) => controller.error(err)).then(resolveFlightDataPromise);
|
|
11274
|
-
}
|
|
11275
|
-
}, 0);
|
|
11276
|
-
},
|
|
11277
|
-
async flush(controller) {
|
|
11278
|
-
await flightDataPromise;
|
|
11279
|
-
if (timeout) {
|
|
11280
|
-
clearTimeout(timeout);
|
|
11281
|
-
flushBufferedChunks(controller);
|
|
11282
|
-
}
|
|
11283
|
-
controller.enqueue(encoder2.encode("</body></html>"));
|
|
11284
|
-
}
|
|
11285
|
-
});
|
|
11286
|
-
}
|
|
11287
|
-
async function writeRSCStream(rscStream, controller) {
|
|
11288
|
-
let decoder = new TextDecoder("utf-8", { fatal: true });
|
|
11289
|
-
const reader = rscStream.getReader();
|
|
11290
|
-
try {
|
|
11291
|
-
let read;
|
|
11292
|
-
while ((read = await reader.read()) && !read.done) {
|
|
11293
|
-
const chunk = read.value;
|
|
11294
|
-
try {
|
|
11295
|
-
writeChunk(
|
|
11296
|
-
JSON.stringify(decoder.decode(chunk, { stream: true })),
|
|
11297
|
-
controller
|
|
11298
|
-
);
|
|
11299
|
-
} catch (err) {
|
|
11300
|
-
let base64 = JSON.stringify(btoa(String.fromCodePoint(...chunk)));
|
|
11301
|
-
writeChunk(
|
|
11302
|
-
`Uint8Array.from(atob(${base64}), m => m.codePointAt(0))`,
|
|
11303
|
-
controller
|
|
11304
|
-
);
|
|
11305
|
-
}
|
|
11306
|
-
}
|
|
11307
|
-
} finally {
|
|
11308
|
-
reader.releaseLock();
|
|
11309
|
-
}
|
|
11310
|
-
let remaining = decoder.decode();
|
|
11311
|
-
if (remaining.length) {
|
|
11312
|
-
writeChunk(JSON.stringify(remaining), controller);
|
|
11313
|
-
}
|
|
11314
|
-
}
|
|
11315
|
-
function writeChunk(chunk, controller) {
|
|
11316
|
-
controller.enqueue(
|
|
11317
|
-
encoder2.encode(
|
|
11318
|
-
`<script>${escapeScript(
|
|
11319
|
-
`(self.__FLIGHT_DATA||=[]).push(${chunk})`
|
|
11320
|
-
)}</script>`
|
|
11321
|
-
)
|
|
11322
|
-
);
|
|
11323
|
-
}
|
|
11324
|
-
function escapeScript(script) {
|
|
11325
|
-
return script.replace(/<!--/g, "<\\!--").replace(/<\/(script)/gi, "</\\$1");
|
|
11326
|
-
}
|
|
11327
|
-
|
|
11328
|
-
// lib/rsc/server.ssr.tsx
|
|
11329
|
-
async function routeRSCServerRequest(request, requestServer, decode2, renderHTML) {
|
|
11330
|
-
const url = new URL(request.url);
|
|
11331
|
-
let serverRequest = request;
|
|
11332
|
-
const isDataRequest = isReactServerRequest(url);
|
|
11333
|
-
const respondWithRSCPayload = isDataRequest || isManifestRequest(url) || request.headers.has("rsc-action-id");
|
|
11334
|
-
if (isDataRequest) {
|
|
11335
|
-
const serverURL = new URL(request.url);
|
|
11336
|
-
serverURL.pathname = serverURL.pathname.replace(/(_root)?\.rsc$/, "");
|
|
11337
|
-
let headers = new Headers(request.headers);
|
|
11338
|
-
headers.set("X-React-Router-Data-Request", "true");
|
|
11339
|
-
serverRequest = new Request(serverURL, {
|
|
11340
|
-
body: request.body,
|
|
11341
|
-
duplex: request.body ? "half" : void 0,
|
|
11342
|
-
headers,
|
|
11343
|
-
method: request.method,
|
|
11344
|
-
signal: request.signal
|
|
11345
|
-
});
|
|
11346
|
-
}
|
|
11347
|
-
const serverResponse = await requestServer(serverRequest);
|
|
11348
|
-
if (respondWithRSCPayload) {
|
|
11349
|
-
return serverResponse;
|
|
11350
|
-
}
|
|
11351
|
-
if (!serverResponse.body) {
|
|
11352
|
-
throw new Error("Missing body in server response");
|
|
11353
|
-
}
|
|
11354
|
-
const serverResponseB = serverResponse.clone();
|
|
11355
|
-
if (!serverResponseB.body) {
|
|
11356
|
-
throw new Error("Failed to clone server response");
|
|
11357
|
-
}
|
|
11358
|
-
const payload = await decode2(serverResponse.body);
|
|
11359
|
-
if (payload.type === "redirect") {
|
|
11360
|
-
return new Response(null, {
|
|
11361
|
-
status: payload.status,
|
|
11362
|
-
headers: {
|
|
11363
|
-
Location: payload.location
|
|
11364
|
-
}
|
|
11365
|
-
});
|
|
11366
|
-
}
|
|
11367
|
-
const html = await renderHTML(payload);
|
|
11368
|
-
try {
|
|
11369
|
-
const body = html.pipeThrough(injectRSCPayload(serverResponseB.body));
|
|
11370
|
-
const headers = new Headers(serverResponse.headers);
|
|
11371
|
-
headers.set("Content-Type", "text/html");
|
|
11372
|
-
return new Response(body, {
|
|
11373
|
-
status: serverResponse.status,
|
|
11374
|
-
headers
|
|
11375
|
-
});
|
|
11376
|
-
} catch (reason) {
|
|
11377
|
-
throw reason;
|
|
11378
|
-
}
|
|
11379
|
-
}
|
|
11380
|
-
function RSCStaticRouter({ payload }) {
|
|
11381
|
-
if (payload.type !== "render") return null;
|
|
11382
|
-
const context = {
|
|
11383
|
-
actionData: payload.actionData,
|
|
11384
|
-
actionHeaders: {},
|
|
11385
|
-
basename: payload.basename,
|
|
11386
|
-
errors: payload.errors,
|
|
11387
|
-
loaderData: payload.loaderData,
|
|
11388
|
-
loaderHeaders: {},
|
|
11389
|
-
location: payload.location,
|
|
11390
|
-
statusCode: 200,
|
|
11391
|
-
matches: payload.matches.map((match) => ({
|
|
11392
|
-
params: match.params,
|
|
11393
|
-
pathname: match.pathname,
|
|
11394
|
-
pathnameBase: match.pathnameBase,
|
|
11395
|
-
route: {
|
|
11396
|
-
id: match.id,
|
|
11397
|
-
action: match.hasAction || !!match.clientAction,
|
|
11398
|
-
handle: match.handle,
|
|
11399
|
-
hasErrorBoundary: match.hasErrorBoundary,
|
|
11400
|
-
loader: match.hasLoader || !!match.clientLoader,
|
|
11401
|
-
index: match.index,
|
|
11402
|
-
path: match.path,
|
|
11403
|
-
shouldRevalidate: match.shouldRevalidate
|
|
11404
|
-
}
|
|
11405
|
-
}))
|
|
11406
|
-
};
|
|
11407
|
-
const router = createStaticRouter(
|
|
11408
|
-
payload.matches.reduceRight((previous, match) => {
|
|
11409
|
-
const route = {
|
|
11410
|
-
id: match.id,
|
|
11411
|
-
action: match.hasAction || !!match.clientAction,
|
|
11412
|
-
element: match.element,
|
|
11413
|
-
errorElement: match.errorElement,
|
|
11414
|
-
handle: match.handle,
|
|
11415
|
-
hasErrorBoundary: !!match.errorElement,
|
|
11416
|
-
hydrateFallbackElement: match.hydrateFallbackElement,
|
|
11417
|
-
index: match.index,
|
|
11418
|
-
loader: match.hasLoader || !!match.clientLoader,
|
|
11419
|
-
path: match.path,
|
|
11420
|
-
shouldRevalidate: match.shouldRevalidate
|
|
11421
|
-
};
|
|
11422
|
-
if (previous.length > 0) {
|
|
11423
|
-
route.children = previous;
|
|
11424
|
-
}
|
|
11425
|
-
return [route];
|
|
11426
|
-
}, []),
|
|
11427
|
-
context
|
|
11428
|
-
);
|
|
11429
|
-
const frameworkContext = {
|
|
11430
|
-
future: {
|
|
11431
|
-
// These flags have no runtime impact so can always be false. If we add
|
|
11432
|
-
// flags that drive runtime behavior they'll need to be proxied through.
|
|
11433
|
-
unstable_middleware: false,
|
|
11434
|
-
unstable_subResourceIntegrity: false
|
|
11435
|
-
},
|
|
11436
|
-
isSpaMode: false,
|
|
11437
|
-
ssr: true,
|
|
11438
|
-
criticalCss: "",
|
|
11439
|
-
manifest: {
|
|
11440
|
-
routes: {},
|
|
11441
|
-
version: "1",
|
|
11442
|
-
url: "",
|
|
11443
|
-
entry: {
|
|
11444
|
-
module: "",
|
|
11445
|
-
imports: []
|
|
11446
|
-
}
|
|
11447
|
-
},
|
|
11448
|
-
routeModules: {}
|
|
11449
|
-
};
|
|
11450
|
-
return /* @__PURE__ */ React15.createElement(FrameworkContext.Provider, { value: frameworkContext }, /* @__PURE__ */ React15.createElement(
|
|
11451
|
-
StaticRouterProvider,
|
|
11452
|
-
{
|
|
11453
|
-
context,
|
|
11454
|
-
router,
|
|
11455
|
-
hydrate: false,
|
|
11456
|
-
nonce: payload.nonce
|
|
11457
|
-
}
|
|
11458
|
-
));
|
|
11459
|
-
}
|
|
11460
|
-
function isReactServerRequest(url) {
|
|
11461
|
-
return url.pathname.endsWith(".rsc");
|
|
11462
|
-
}
|
|
11463
|
-
function isManifestRequest(url) {
|
|
11464
|
-
return url.pathname.endsWith(".manifest");
|
|
11465
|
-
}
|
|
11466
|
-
|
|
11467
|
-
// lib/rsc/html-stream/browser.ts
|
|
11468
|
-
function getServerStream() {
|
|
11469
|
-
let encoder3 = new TextEncoder();
|
|
11470
|
-
let streamController = null;
|
|
11471
|
-
let rscStream = new ReadableStream({
|
|
11472
|
-
start(controller) {
|
|
11473
|
-
if (typeof window === "undefined") {
|
|
11474
|
-
return;
|
|
11475
|
-
}
|
|
11476
|
-
let handleChunk = (chunk) => {
|
|
11477
|
-
if (typeof chunk === "string") {
|
|
11478
|
-
controller.enqueue(encoder3.encode(chunk));
|
|
11479
|
-
} else {
|
|
11480
|
-
controller.enqueue(chunk);
|
|
11481
|
-
}
|
|
11482
|
-
};
|
|
11483
|
-
window.__FLIGHT_DATA || (window.__FLIGHT_DATA = []);
|
|
11484
|
-
window.__FLIGHT_DATA.forEach(handleChunk);
|
|
11485
|
-
window.__FLIGHT_DATA.push = (chunk) => {
|
|
11486
|
-
handleChunk(chunk);
|
|
11487
|
-
return 0;
|
|
11488
|
-
};
|
|
11489
|
-
streamController = controller;
|
|
11490
|
-
}
|
|
11491
|
-
});
|
|
11492
|
-
if (typeof document !== "undefined" && document.readyState === "loading") {
|
|
11493
|
-
document.addEventListener("DOMContentLoaded", () => {
|
|
11494
|
-
streamController?.close();
|
|
11495
|
-
});
|
|
11496
|
-
} else {
|
|
11497
|
-
streamController?.close();
|
|
11498
|
-
}
|
|
11499
|
-
return rscStream;
|
|
11500
|
-
}
|
|
11501
|
-
|
|
11502
11465
|
// lib/dom/ssr/errors.ts
|
|
11503
11466
|
function deserializeErrors2(errors) {
|
|
11504
11467
|
if (!errors) return null;
|
|
@@ -11535,6 +11498,32 @@ function deserializeErrors2(errors) {
|
|
|
11535
11498
|
}
|
|
11536
11499
|
return serialized;
|
|
11537
11500
|
}
|
|
11501
|
+
|
|
11502
|
+
// lib/dom/ssr/hydration.tsx
|
|
11503
|
+
function getHydrationData(state, routes, getRouteInfo, location, basename, isSpaMode) {
|
|
11504
|
+
let hydrationData = {
|
|
11505
|
+
...state,
|
|
11506
|
+
loaderData: { ...state.loaderData }
|
|
11507
|
+
};
|
|
11508
|
+
let initialMatches = matchRoutes(routes, location, basename);
|
|
11509
|
+
if (initialMatches) {
|
|
11510
|
+
for (let match of initialMatches) {
|
|
11511
|
+
let routeId = match.route.id;
|
|
11512
|
+
let routeInfo = getRouteInfo(routeId);
|
|
11513
|
+
if (shouldHydrateRouteLoader(
|
|
11514
|
+
routeId,
|
|
11515
|
+
routeInfo.clientLoader,
|
|
11516
|
+
routeInfo.hasLoader,
|
|
11517
|
+
isSpaMode
|
|
11518
|
+
) && (routeInfo.hasHydrateFallback || !routeInfo.hasLoader)) {
|
|
11519
|
+
delete hydrationData.loaderData[routeId];
|
|
11520
|
+
} else if (!routeInfo.hasLoader) {
|
|
11521
|
+
hydrationData.loaderData[routeId] = null;
|
|
11522
|
+
}
|
|
11523
|
+
}
|
|
11524
|
+
}
|
|
11525
|
+
return hydrationData;
|
|
11526
|
+
}
|
|
11538
11527
|
// Annotate the CommonJS export names for ESM import in node:
|
|
11539
11528
|
0 && (module.exports = {
|
|
11540
11529
|
Await,
|
|
@@ -11553,8 +11542,6 @@ function deserializeErrors2(errors) {
|
|
|
11553
11542
|
NavigationType,
|
|
11554
11543
|
Outlet,
|
|
11555
11544
|
PrefetchPageLinks,
|
|
11556
|
-
RSCHydratedRouter,
|
|
11557
|
-
RSCStaticRouter,
|
|
11558
11545
|
Route,
|
|
11559
11546
|
Router,
|
|
11560
11547
|
RouterProvider,
|
|
@@ -11576,9 +11563,6 @@ function deserializeErrors2(errors) {
|
|
|
11576
11563
|
UNSAFE_ServerMode,
|
|
11577
11564
|
UNSAFE_SingleFetchRedirectSymbol,
|
|
11578
11565
|
UNSAFE_ViewTransitionContext,
|
|
11579
|
-
UNSAFE_WithErrorBoundaryProps,
|
|
11580
|
-
UNSAFE_WithHydrateFallbackProps,
|
|
11581
|
-
UNSAFE_WithRouteComponentProps,
|
|
11582
11566
|
UNSAFE_createBrowserHistory,
|
|
11583
11567
|
UNSAFE_createClientRoutes,
|
|
11584
11568
|
UNSAFE_createClientRoutesWithHMRRevalidationOptOut,
|
|
@@ -11595,7 +11579,6 @@ function deserializeErrors2(errors) {
|
|
|
11595
11579
|
UNSAFE_useFogOFWarDiscovery,
|
|
11596
11580
|
UNSAFE_useScrollRestoration,
|
|
11597
11581
|
createBrowserRouter,
|
|
11598
|
-
createCallServer,
|
|
11599
11582
|
createCookie,
|
|
11600
11583
|
createCookieSessionStorage,
|
|
11601
11584
|
createHashRouter,
|
|
@@ -11613,7 +11596,6 @@ function deserializeErrors2(errors) {
|
|
|
11613
11596
|
createStaticRouter,
|
|
11614
11597
|
data,
|
|
11615
11598
|
generatePath,
|
|
11616
|
-
getServerStream,
|
|
11617
11599
|
href,
|
|
11618
11600
|
isCookie,
|
|
11619
11601
|
isRouteErrorResponse,
|
|
@@ -11626,7 +11608,6 @@ function deserializeErrors2(errors) {
|
|
|
11626
11608
|
renderMatches,
|
|
11627
11609
|
replace,
|
|
11628
11610
|
resolvePath,
|
|
11629
|
-
routeRSCServerRequest,
|
|
11630
11611
|
unstable_HistoryRouter,
|
|
11631
11612
|
unstable_RouterContextProvider,
|
|
11632
11613
|
unstable_createContext,
|