react-router 7.9.4 → 7.9.6
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 +70 -0
- package/dist/development/browser-BbBXFHbO.d.ts +310 -0
- package/dist/development/browser-C07r42Tt.d.mts +310 -0
- package/dist/development/{chunk-OIYGIGL5.mjs → chunk-4WY6JWTD.mjs} +458 -43
- package/dist/development/{chunk-DI2QHYMJ.js → chunk-AMVS5XVJ.js} +1314 -138
- package/dist/development/{chunk-WY5IRSCW.mjs → chunk-G3INQAYP.mjs} +197 -857
- package/dist/development/chunk-O4JVZSOY.js +1310 -0
- package/dist/development/chunk-PZWDWJAY.js +188 -0
- package/dist/development/dom-export.d.mts +103 -6
- package/dist/development/dom-export.d.ts +103 -4
- package/dist/development/dom-export.js +708 -20
- package/dist/development/dom-export.mjs +692 -11
- package/dist/{production/index-react-server-client-BbRcBjrA.d.ts → development/index-react-server-client-Da3kmxNd.d.ts} +195 -135
- package/dist/{production/index-react-server-client-BIz4AUNd.d.mts → development/index-react-server-client-rcoGPJhU.d.mts} +137 -78
- package/dist/development/index-react-server-client.d.mts +2 -3
- package/dist/development/index-react-server-client.d.ts +2 -2
- package/dist/development/index-react-server-client.js +4 -4
- package/dist/development/index-react-server-client.mjs +2 -2
- package/dist/development/index-react-server.d.mts +107 -3
- package/dist/development/index-react-server.d.ts +107 -3
- package/dist/development/index-react-server.js +259 -13
- package/dist/development/index-react-server.mjs +259 -13
- package/dist/development/index.d.mts +14 -320
- package/dist/development/index.d.ts +14 -362
- package/dist/development/index.js +146 -962
- package/dist/development/index.mjs +3 -9
- package/dist/development/{routeModules-D5iJ6JYT.d.ts → instrumentation-Unc20tLk.d.ts} +178 -25
- package/dist/development/lib/types/internal.d.mts +2 -3
- package/dist/development/lib/types/internal.d.ts +2 -2
- package/dist/development/lib/types/internal.js +1 -1
- package/dist/development/lib/types/internal.mjs +1 -1
- package/dist/{production/register-C34pU-in.d.ts → development/register-BpU9rFBJ.d.ts} +1 -1
- package/dist/development/{register-CI4bTprK.d.mts → register-QkB3HGjm.d.mts} +1 -1
- package/dist/{production/context-DSyS5mLj.d.mts → development/router-CAvh_Drx.d.mts} +1877 -1254
- package/dist/production/browser-BbBXFHbO.d.ts +310 -0
- package/dist/production/browser-C07r42Tt.d.mts +310 -0
- package/dist/production/{chunk-4E5LHRQP.js → chunk-EAIF67OW.js} +1314 -138
- package/dist/production/{chunk-FR6HSPLK.mjs → chunk-FDUMZGKM.mjs} +197 -857
- package/dist/production/{chunk-3TADTUL4.mjs → chunk-FUSXQSWG.mjs} +458 -43
- package/dist/production/chunk-G5A35OQU.js +188 -0
- package/dist/production/chunk-QN64DHI4.js +1310 -0
- package/dist/production/dom-export.d.mts +103 -6
- package/dist/production/dom-export.d.ts +103 -4
- package/dist/production/dom-export.js +708 -20
- package/dist/production/dom-export.mjs +692 -11
- package/dist/{development/index-react-server-client-BIz4AUNd.d.mts → production/index-react-server-client-Da3kmxNd.d.ts} +137 -78
- package/dist/{development/index-react-server-client-BbRcBjrA.d.ts → production/index-react-server-client-rcoGPJhU.d.mts} +195 -135
- package/dist/production/index-react-server-client.d.mts +2 -3
- package/dist/production/index-react-server-client.d.ts +2 -2
- package/dist/production/index-react-server-client.js +4 -4
- package/dist/production/index-react-server-client.mjs +2 -2
- package/dist/production/index-react-server.d.mts +107 -3
- package/dist/production/index-react-server.d.ts +107 -3
- package/dist/production/index-react-server.js +259 -13
- package/dist/production/index-react-server.mjs +259 -13
- package/dist/production/index.d.mts +14 -320
- package/dist/production/index.d.ts +14 -362
- package/dist/production/index.js +146 -962
- package/dist/production/index.mjs +3 -9
- package/dist/production/{routeModules-D5iJ6JYT.d.ts → instrumentation-Unc20tLk.d.ts} +178 -25
- package/dist/production/lib/types/internal.d.mts +2 -3
- package/dist/production/lib/types/internal.d.ts +2 -2
- package/dist/production/lib/types/internal.js +1 -1
- package/dist/production/lib/types/internal.mjs +1 -1
- package/dist/{development/register-C34pU-in.d.ts → production/register-BpU9rFBJ.d.ts} +1 -1
- package/dist/production/{register-CI4bTprK.d.mts → register-QkB3HGjm.d.mts} +1 -1
- package/dist/{development/context-DSyS5mLj.d.mts → production/router-CAvh_Drx.d.mts} +1877 -1254
- package/package.json +1 -1
- package/dist/development/browser-z32v5KVN.d.mts +0 -46
- package/dist/development/chunk-72XNTZCV.js +0 -2089
- package/dist/development/route-data-DZQOUSqV.d.mts +0 -473
- package/dist/production/browser-z32v5KVN.d.mts +0 -46
- package/dist/production/chunk-WNLQ53P5.js +0 -2089
- package/dist/production/route-data-DZQOUSqV.d.mts +0 -473
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }/**
|
|
2
|
-
* react-router v7.9.
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }/**
|
|
2
|
+
* react-router v7.9.6
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -11,11 +11,32 @@
|
|
|
11
11
|
"use client";
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
var _chunkPZWDWJAYjs = require('./chunk-PZWDWJAY.js');
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
var _chunkAMVS5XVJjs = require('./chunk-AMVS5XVJ.js');
|
|
15
36
|
|
|
16
37
|
// lib/dom-export/dom-router-provider.tsx
|
|
17
|
-
var _react = require('react'); var React = _interopRequireWildcard(_react); var React2 = _interopRequireWildcard(_react);
|
|
18
|
-
var _reactdom = require('react-dom'); var ReactDOM = _interopRequireWildcard(_reactdom);
|
|
38
|
+
var _react = require('react'); var React = _interopRequireWildcard(_react); var React2 = _interopRequireWildcard(_react); var React3 = _interopRequireWildcard(_react);
|
|
39
|
+
var _reactdom = require('react-dom'); var ReactDOM = _interopRequireWildcard(_reactdom); var ReactDOM2 = _interopRequireWildcard(_reactdom);
|
|
19
40
|
var _reactrouter = require('react-router');
|
|
20
41
|
function RouterProvider(props) {
|
|
21
42
|
return /* @__PURE__ */ React.createElement(_reactrouter.RouterProvider, { flushSync: ReactDOM.flushSync, ...props });
|
|
@@ -46,7 +67,7 @@ function initSsrInfo() {
|
|
|
46
67
|
if (!ssrInfo && window.__reactRouterContext && window.__reactRouterManifest && window.__reactRouterRouteModules) {
|
|
47
68
|
if (window.__reactRouterManifest.sri === true) {
|
|
48
69
|
const importMap = document.querySelector("script[rr-importmap]");
|
|
49
|
-
if (_optionalChain([importMap, 'optionalAccess',
|
|
70
|
+
if (_optionalChain([importMap, 'optionalAccess', _2 => _2.textContent])) {
|
|
50
71
|
try {
|
|
51
72
|
window.__reactRouterManifest.sri = JSON.parse(
|
|
52
73
|
importMap.textContent
|
|
@@ -67,7 +88,8 @@ function initSsrInfo() {
|
|
|
67
88
|
}
|
|
68
89
|
}
|
|
69
90
|
function createHydratedRouter({
|
|
70
|
-
getContext
|
|
91
|
+
getContext,
|
|
92
|
+
unstable_instrumentations
|
|
71
93
|
}) {
|
|
72
94
|
initSsrInfo();
|
|
73
95
|
if (!ssrInfo) {
|
|
@@ -103,7 +125,7 @@ function createHydratedRouter({
|
|
|
103
125
|
let hydrationData = void 0;
|
|
104
126
|
if (ssrInfo.context.isSpaMode) {
|
|
105
127
|
let { loaderData } = ssrInfo.context.state;
|
|
106
|
-
if (_optionalChain([ssrInfo, 'access',
|
|
128
|
+
if (_optionalChain([ssrInfo, 'access', _3 => _3.manifest, 'access', _4 => _4.routes, 'access', _5 => _5.root, 'optionalAccess', _6 => _6.hasLoader]) && loaderData && "root" in loaderData) {
|
|
107
129
|
hydrationData = {
|
|
108
130
|
loaderData: {
|
|
109
131
|
root: loaderData.root
|
|
@@ -115,12 +137,12 @@ function createHydratedRouter({
|
|
|
115
137
|
state: ssrInfo.context.state,
|
|
116
138
|
routes,
|
|
117
139
|
getRouteInfo: (routeId) => ({
|
|
118
|
-
clientLoader: _optionalChain([ssrInfo, 'access',
|
|
119
|
-
hasLoader: _optionalChain([ssrInfo, 'access',
|
|
120
|
-
hasHydrateFallback: _optionalChain([ssrInfo, 'access',
|
|
140
|
+
clientLoader: _optionalChain([ssrInfo, 'access', _7 => _7.routeModules, 'access', _8 => _8[routeId], 'optionalAccess', _9 => _9.clientLoader]),
|
|
141
|
+
hasLoader: _optionalChain([ssrInfo, 'access', _10 => _10.manifest, 'access', _11 => _11.routes, 'access', _12 => _12[routeId], 'optionalAccess', _13 => _13.hasLoader]) === true,
|
|
142
|
+
hasHydrateFallback: _optionalChain([ssrInfo, 'access', _14 => _14.routeModules, 'access', _15 => _15[routeId], 'optionalAccess', _16 => _16.HydrateFallback]) != null
|
|
121
143
|
}),
|
|
122
144
|
location: window.location,
|
|
123
|
-
basename: _optionalChain([window, 'access',
|
|
145
|
+
basename: _optionalChain([window, 'access', _17 => _17.__reactRouterContext, 'optionalAccess', _18 => _18.basename]),
|
|
124
146
|
isSpaMode: ssrInfo.context.isSpaMode
|
|
125
147
|
});
|
|
126
148
|
if (hydrationData && hydrationData.errors) {
|
|
@@ -134,6 +156,7 @@ function createHydratedRouter({
|
|
|
134
156
|
getContext,
|
|
135
157
|
hydrationData,
|
|
136
158
|
hydrationRouteProperties: _reactrouter.UNSAFE_hydrationRouteProperties,
|
|
159
|
+
unstable_instrumentations,
|
|
137
160
|
mapRouteProperties: _reactrouter.UNSAFE_mapRouteProperties,
|
|
138
161
|
future: {
|
|
139
162
|
middleware: ssrInfo.context.future.v8_middleware
|
|
@@ -167,11 +190,12 @@ function createHydratedRouter({
|
|
|
167
190
|
function HydratedRouter(props) {
|
|
168
191
|
if (!router) {
|
|
169
192
|
router = createHydratedRouter({
|
|
170
|
-
getContext: props.getContext
|
|
193
|
+
getContext: props.getContext,
|
|
194
|
+
unstable_instrumentations: props.unstable_instrumentations
|
|
171
195
|
});
|
|
172
196
|
}
|
|
173
197
|
let [criticalCss, setCriticalCss] = React2.useState(
|
|
174
|
-
process.env.NODE_ENV === "development" ? _optionalChain([ssrInfo, 'optionalAccess',
|
|
198
|
+
process.env.NODE_ENV === "development" ? _optionalChain([ssrInfo, 'optionalAccess', _19 => _19.context, 'access', _20 => _20.criticalCss]) : void 0
|
|
175
199
|
);
|
|
176
200
|
React2.useEffect(() => {
|
|
177
201
|
if (process.env.NODE_ENV === "development") {
|
|
@@ -180,10 +204,10 @@ function HydratedRouter(props) {
|
|
|
180
204
|
}, []);
|
|
181
205
|
React2.useEffect(() => {
|
|
182
206
|
if (process.env.NODE_ENV === "development" && criticalCss === void 0) {
|
|
183
|
-
document.querySelectorAll(`[${
|
|
207
|
+
document.querySelectorAll(`[${_chunkAMVS5XVJjs.CRITICAL_CSS_DATA_ATTRIBUTE}]`).forEach((element) => element.remove());
|
|
184
208
|
}
|
|
185
209
|
}, [criticalCss]);
|
|
186
|
-
let [
|
|
210
|
+
let [location2, setLocation] = React2.useState(router.state.location);
|
|
187
211
|
React2.useLayoutEffect(() => {
|
|
188
212
|
if (ssrInfo && ssrInfo.router && !ssrInfo.routerInitialized) {
|
|
189
213
|
ssrInfo.routerInitialized = true;
|
|
@@ -193,12 +217,12 @@ function HydratedRouter(props) {
|
|
|
193
217
|
React2.useLayoutEffect(() => {
|
|
194
218
|
if (ssrInfo && ssrInfo.router) {
|
|
195
219
|
return ssrInfo.router.subscribe((newState) => {
|
|
196
|
-
if (newState.location !==
|
|
220
|
+
if (newState.location !== location2) {
|
|
197
221
|
setLocation(newState.location);
|
|
198
222
|
}
|
|
199
223
|
});
|
|
200
224
|
}
|
|
201
|
-
}, [
|
|
225
|
+
}, [location2]);
|
|
202
226
|
_reactrouter.UNSAFE_invariant.call(void 0, ssrInfo, "ssrInfo unavailable for HydratedRouter");
|
|
203
227
|
_reactrouter.UNSAFE_useFogOFWarDiscovery.call(void 0,
|
|
204
228
|
router,
|
|
@@ -224,7 +248,7 @@ function HydratedRouter(props) {
|
|
|
224
248
|
routeDiscovery: ssrInfo.context.routeDiscovery
|
|
225
249
|
}
|
|
226
250
|
},
|
|
227
|
-
/* @__PURE__ */ React2.createElement(_reactrouter.UNSAFE_RemixErrorBoundary, { location }, /* @__PURE__ */ React2.createElement(
|
|
251
|
+
/* @__PURE__ */ React2.createElement(_reactrouter.UNSAFE_RemixErrorBoundary, { location: location2 }, /* @__PURE__ */ React2.createElement(
|
|
228
252
|
RouterProvider,
|
|
229
253
|
{
|
|
230
254
|
router,
|
|
@@ -235,6 +259,670 @@ function HydratedRouter(props) {
|
|
|
235
259
|
);
|
|
236
260
|
}
|
|
237
261
|
|
|
262
|
+
// lib/rsc/browser.tsx
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
function createCallServer({
|
|
266
|
+
createFromReadableStream,
|
|
267
|
+
createTemporaryReferenceSet,
|
|
268
|
+
encodeReply,
|
|
269
|
+
fetch: fetchImplementation = fetch
|
|
270
|
+
}) {
|
|
271
|
+
const globalVar = window;
|
|
272
|
+
let landedActionId = 0;
|
|
273
|
+
return async (id, args) => {
|
|
274
|
+
let actionId = globalVar.__routerActionID = (_nullishCoalesce(globalVar.__routerActionID, () => ( (globalVar.__routerActionID = 0)))) + 1;
|
|
275
|
+
const temporaryReferences = createTemporaryReferenceSet();
|
|
276
|
+
const payloadPromise = fetchImplementation(
|
|
277
|
+
new Request(location.href, {
|
|
278
|
+
body: await encodeReply(args, { temporaryReferences }),
|
|
279
|
+
method: "POST",
|
|
280
|
+
headers: {
|
|
281
|
+
Accept: "text/x-component",
|
|
282
|
+
"rsc-action-id": id
|
|
283
|
+
}
|
|
284
|
+
})
|
|
285
|
+
).then((response) => {
|
|
286
|
+
if (!response.body) {
|
|
287
|
+
throw new Error("No response body");
|
|
288
|
+
}
|
|
289
|
+
return createFromReadableStream(response.body, {
|
|
290
|
+
temporaryReferences
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
globalVar.__reactRouterDataRouter.__setPendingRerender(
|
|
294
|
+
Promise.resolve(payloadPromise).then(async (payload) => {
|
|
295
|
+
if (payload.type === "redirect") {
|
|
296
|
+
if (payload.reload || isExternalLocation(payload.location)) {
|
|
297
|
+
window.location.href = payload.location;
|
|
298
|
+
return () => {
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
return () => {
|
|
302
|
+
globalVar.__reactRouterDataRouter.navigate(payload.location, {
|
|
303
|
+
replace: payload.replace
|
|
304
|
+
});
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
if (payload.type !== "action") {
|
|
308
|
+
throw new Error("Unexpected payload type");
|
|
309
|
+
}
|
|
310
|
+
const rerender = await payload.rerender;
|
|
311
|
+
if (rerender && landedActionId < actionId && globalVar.__routerActionID <= actionId) {
|
|
312
|
+
if (rerender.type === "redirect") {
|
|
313
|
+
if (rerender.reload || isExternalLocation(rerender.location)) {
|
|
314
|
+
window.location.href = rerender.location;
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
return () => {
|
|
318
|
+
globalVar.__reactRouterDataRouter.navigate(rerender.location, {
|
|
319
|
+
replace: rerender.replace
|
|
320
|
+
});
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
return () => {
|
|
324
|
+
let lastMatch;
|
|
325
|
+
for (const match of rerender.matches) {
|
|
326
|
+
globalVar.__reactRouterDataRouter.patchRoutes(
|
|
327
|
+
_nullishCoalesce(_optionalChain([lastMatch, 'optionalAccess', _21 => _21.id]), () => ( null)),
|
|
328
|
+
[createRouteFromServerManifest(match)],
|
|
329
|
+
true
|
|
330
|
+
);
|
|
331
|
+
lastMatch = match;
|
|
332
|
+
}
|
|
333
|
+
window.__reactRouterDataRouter._internalSetStateDoNotUseOrYouWillBreakYourApp(
|
|
334
|
+
{
|
|
335
|
+
loaderData: Object.assign(
|
|
336
|
+
{},
|
|
337
|
+
globalVar.__reactRouterDataRouter.state.loaderData,
|
|
338
|
+
rerender.loaderData
|
|
339
|
+
),
|
|
340
|
+
errors: rerender.errors ? Object.assign(
|
|
341
|
+
{},
|
|
342
|
+
globalVar.__reactRouterDataRouter.state.errors,
|
|
343
|
+
rerender.errors
|
|
344
|
+
) : null
|
|
345
|
+
}
|
|
346
|
+
);
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
return () => {
|
|
350
|
+
};
|
|
351
|
+
}).catch(() => {
|
|
352
|
+
})
|
|
353
|
+
);
|
|
354
|
+
return payloadPromise.then((payload) => {
|
|
355
|
+
if (payload.type !== "action" && payload.type !== "redirect") {
|
|
356
|
+
throw new Error("Unexpected payload type");
|
|
357
|
+
}
|
|
358
|
+
return payload.actionResult;
|
|
359
|
+
});
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
function createRouterFromPayload({
|
|
363
|
+
fetchImplementation,
|
|
364
|
+
createFromReadableStream,
|
|
365
|
+
getContext,
|
|
366
|
+
payload
|
|
367
|
+
}) {
|
|
368
|
+
const globalVar = window;
|
|
369
|
+
if (globalVar.__reactRouterDataRouter && globalVar.__reactRouterRouteModules)
|
|
370
|
+
return {
|
|
371
|
+
router: globalVar.__reactRouterDataRouter,
|
|
372
|
+
routeModules: globalVar.__reactRouterRouteModules
|
|
373
|
+
};
|
|
374
|
+
if (payload.type !== "render") throw new Error("Invalid payload type");
|
|
375
|
+
globalVar.__reactRouterRouteModules = _nullishCoalesce(globalVar.__reactRouterRouteModules, () => ( {}));
|
|
376
|
+
_chunkPZWDWJAYjs.populateRSCRouteModules.call(void 0, globalVar.__reactRouterRouteModules, payload.matches);
|
|
377
|
+
let patches = /* @__PURE__ */ new Map();
|
|
378
|
+
_optionalChain([payload, 'access', _22 => _22.patches, 'optionalAccess', _23 => _23.forEach, 'call', _24 => _24((patch) => {
|
|
379
|
+
_chunkAMVS5XVJjs.invariant.call(void 0, patch.parentId, "Invalid patch parentId");
|
|
380
|
+
if (!patches.has(patch.parentId)) {
|
|
381
|
+
patches.set(patch.parentId, []);
|
|
382
|
+
}
|
|
383
|
+
_optionalChain([patches, 'access', _25 => _25.get, 'call', _26 => _26(patch.parentId), 'optionalAccess', _27 => _27.push, 'call', _28 => _28(patch)]);
|
|
384
|
+
})]);
|
|
385
|
+
let routes = payload.matches.reduceRight((previous, match) => {
|
|
386
|
+
const route = createRouteFromServerManifest(
|
|
387
|
+
match,
|
|
388
|
+
payload
|
|
389
|
+
);
|
|
390
|
+
if (previous.length > 0) {
|
|
391
|
+
route.children = previous;
|
|
392
|
+
let childrenToPatch = patches.get(match.id);
|
|
393
|
+
if (childrenToPatch) {
|
|
394
|
+
route.children.push(
|
|
395
|
+
...childrenToPatch.map((r) => createRouteFromServerManifest(r))
|
|
396
|
+
);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
return [route];
|
|
400
|
+
}, []);
|
|
401
|
+
globalVar.__reactRouterDataRouter = _chunkAMVS5XVJjs.createRouter.call(void 0, {
|
|
402
|
+
routes,
|
|
403
|
+
getContext,
|
|
404
|
+
basename: payload.basename,
|
|
405
|
+
history: _chunkAMVS5XVJjs.createBrowserHistory.call(void 0, ),
|
|
406
|
+
hydrationData: _chunkPZWDWJAYjs.getHydrationData.call(void 0, {
|
|
407
|
+
state: {
|
|
408
|
+
loaderData: payload.loaderData,
|
|
409
|
+
actionData: payload.actionData,
|
|
410
|
+
errors: payload.errors
|
|
411
|
+
},
|
|
412
|
+
routes,
|
|
413
|
+
getRouteInfo: (routeId) => {
|
|
414
|
+
let match = payload.matches.find((m) => m.id === routeId);
|
|
415
|
+
_chunkAMVS5XVJjs.invariant.call(void 0, match, "Route not found in payload");
|
|
416
|
+
return {
|
|
417
|
+
clientLoader: match.clientLoader,
|
|
418
|
+
hasLoader: match.hasLoader,
|
|
419
|
+
hasHydrateFallback: match.hydrateFallbackElement != null
|
|
420
|
+
};
|
|
421
|
+
},
|
|
422
|
+
location: payload.location,
|
|
423
|
+
basename: payload.basename,
|
|
424
|
+
isSpaMode: false
|
|
425
|
+
}),
|
|
426
|
+
async patchRoutesOnNavigation({ path, signal }) {
|
|
427
|
+
if (discoveredPaths.has(path)) {
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
await fetchAndApplyManifestPatches(
|
|
431
|
+
[path],
|
|
432
|
+
createFromReadableStream,
|
|
433
|
+
fetchImplementation,
|
|
434
|
+
signal
|
|
435
|
+
);
|
|
436
|
+
},
|
|
437
|
+
// FIXME: Pass `build.ssr` into this function
|
|
438
|
+
dataStrategy: getRSCSingleFetchDataStrategy(
|
|
439
|
+
() => globalVar.__reactRouterDataRouter,
|
|
440
|
+
true,
|
|
441
|
+
payload.basename,
|
|
442
|
+
createFromReadableStream,
|
|
443
|
+
fetchImplementation
|
|
444
|
+
)
|
|
445
|
+
});
|
|
446
|
+
if (globalVar.__reactRouterDataRouter.state.initialized) {
|
|
447
|
+
globalVar.__routerInitialized = true;
|
|
448
|
+
globalVar.__reactRouterDataRouter.initialize();
|
|
449
|
+
} else {
|
|
450
|
+
globalVar.__routerInitialized = false;
|
|
451
|
+
}
|
|
452
|
+
let lastLoaderData = void 0;
|
|
453
|
+
globalVar.__reactRouterDataRouter.subscribe(({ loaderData, actionData }) => {
|
|
454
|
+
if (lastLoaderData !== loaderData) {
|
|
455
|
+
globalVar.__routerActionID = (_nullishCoalesce(globalVar.__routerActionID, () => ( (globalVar.__routerActionID = 0)))) + 1;
|
|
456
|
+
}
|
|
457
|
+
});
|
|
458
|
+
globalVar.__reactRouterDataRouter._updateRoutesForHMR = (routeUpdateByRouteId) => {
|
|
459
|
+
const oldRoutes = window.__reactRouterDataRouter.routes;
|
|
460
|
+
const newRoutes = [];
|
|
461
|
+
function walkRoutes(routes2, parentId) {
|
|
462
|
+
return routes2.map((route) => {
|
|
463
|
+
const routeUpdate = routeUpdateByRouteId.get(route.id);
|
|
464
|
+
if (routeUpdate) {
|
|
465
|
+
const {
|
|
466
|
+
routeModule,
|
|
467
|
+
hasAction,
|
|
468
|
+
hasComponent,
|
|
469
|
+
hasErrorBoundary,
|
|
470
|
+
hasLoader
|
|
471
|
+
} = routeUpdate;
|
|
472
|
+
const newRoute = createRouteFromServerManifest({
|
|
473
|
+
clientAction: routeModule.clientAction,
|
|
474
|
+
clientLoader: routeModule.clientLoader,
|
|
475
|
+
element: route.element,
|
|
476
|
+
errorElement: route.errorElement,
|
|
477
|
+
handle: route.handle,
|
|
478
|
+
hasAction,
|
|
479
|
+
hasComponent,
|
|
480
|
+
hasErrorBoundary,
|
|
481
|
+
hasLoader,
|
|
482
|
+
hydrateFallbackElement: route.hydrateFallbackElement,
|
|
483
|
+
id: route.id,
|
|
484
|
+
index: route.index,
|
|
485
|
+
links: routeModule.links,
|
|
486
|
+
meta: routeModule.meta,
|
|
487
|
+
parentId,
|
|
488
|
+
path: route.path,
|
|
489
|
+
shouldRevalidate: routeModule.shouldRevalidate
|
|
490
|
+
});
|
|
491
|
+
if (route.children) {
|
|
492
|
+
newRoute.children = walkRoutes(route.children, route.id);
|
|
493
|
+
}
|
|
494
|
+
return newRoute;
|
|
495
|
+
}
|
|
496
|
+
const updatedRoute = { ...route };
|
|
497
|
+
if (route.children) {
|
|
498
|
+
updatedRoute.children = walkRoutes(route.children, route.id);
|
|
499
|
+
}
|
|
500
|
+
return updatedRoute;
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
newRoutes.push(
|
|
504
|
+
...walkRoutes(oldRoutes, void 0)
|
|
505
|
+
);
|
|
506
|
+
window.__reactRouterDataRouter._internalSetRoutes(newRoutes);
|
|
507
|
+
};
|
|
508
|
+
return {
|
|
509
|
+
router: globalVar.__reactRouterDataRouter,
|
|
510
|
+
routeModules: globalVar.__reactRouterRouteModules
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
var renderedRoutesContext = _chunkAMVS5XVJjs.createContext.call(void 0, );
|
|
514
|
+
function getRSCSingleFetchDataStrategy(getRouter, ssr, basename, createFromReadableStream, fetchImplementation) {
|
|
515
|
+
let dataStrategy = _chunkAMVS5XVJjs.getSingleFetchDataStrategyImpl.call(void 0,
|
|
516
|
+
getRouter,
|
|
517
|
+
(match) => {
|
|
518
|
+
let M = match;
|
|
519
|
+
return {
|
|
520
|
+
hasLoader: M.route.hasLoader,
|
|
521
|
+
hasClientLoader: M.route.hasClientLoader,
|
|
522
|
+
hasComponent: M.route.hasComponent,
|
|
523
|
+
hasAction: M.route.hasAction,
|
|
524
|
+
hasClientAction: M.route.hasClientAction,
|
|
525
|
+
hasShouldRevalidate: M.route.hasShouldRevalidate
|
|
526
|
+
};
|
|
527
|
+
},
|
|
528
|
+
// pass map into fetchAndDecode so it can add payloads
|
|
529
|
+
getFetchAndDecodeViaRSC(createFromReadableStream, fetchImplementation),
|
|
530
|
+
ssr,
|
|
531
|
+
basename,
|
|
532
|
+
// If the route has a component but we don't have an element, we need to hit
|
|
533
|
+
// the server loader flow regardless of whether the client loader calls
|
|
534
|
+
// `serverLoader` or not, otherwise we'll have nothing to render.
|
|
535
|
+
(match) => {
|
|
536
|
+
let M = match;
|
|
537
|
+
return M.route.hasComponent && !M.route.element;
|
|
538
|
+
}
|
|
539
|
+
);
|
|
540
|
+
return async (args) => args.runClientMiddleware(async () => {
|
|
541
|
+
let context = args.context;
|
|
542
|
+
context.set(renderedRoutesContext, []);
|
|
543
|
+
let results = await dataStrategy(args);
|
|
544
|
+
const renderedRoutesById = /* @__PURE__ */ new Map();
|
|
545
|
+
for (const route of context.get(renderedRoutesContext)) {
|
|
546
|
+
if (!renderedRoutesById.has(route.id)) {
|
|
547
|
+
renderedRoutesById.set(route.id, []);
|
|
548
|
+
}
|
|
549
|
+
renderedRoutesById.get(route.id).push(route);
|
|
550
|
+
}
|
|
551
|
+
for (const match of args.matches) {
|
|
552
|
+
const renderedRoutes = renderedRoutesById.get(match.route.id);
|
|
553
|
+
if (renderedRoutes) {
|
|
554
|
+
for (const rendered of renderedRoutes) {
|
|
555
|
+
window.__reactRouterDataRouter.patchRoutes(
|
|
556
|
+
_nullishCoalesce(rendered.parentId, () => ( null)),
|
|
557
|
+
[createRouteFromServerManifest(rendered)],
|
|
558
|
+
true
|
|
559
|
+
);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
return results;
|
|
564
|
+
});
|
|
565
|
+
}
|
|
566
|
+
function getFetchAndDecodeViaRSC(createFromReadableStream, fetchImplementation) {
|
|
567
|
+
return async (args, basename, targetRoutes) => {
|
|
568
|
+
let { request, context } = args;
|
|
569
|
+
let url = _chunkAMVS5XVJjs.singleFetchUrl.call(void 0, request.url, basename, "rsc");
|
|
570
|
+
if (request.method === "GET") {
|
|
571
|
+
url = _chunkAMVS5XVJjs.stripIndexParam.call(void 0, url);
|
|
572
|
+
if (targetRoutes) {
|
|
573
|
+
url.searchParams.set("_routes", targetRoutes.join(","));
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
let res = await fetchImplementation(
|
|
577
|
+
new Request(url, await _chunkAMVS5XVJjs.createRequestInit.call(void 0, request))
|
|
578
|
+
);
|
|
579
|
+
if (res.status >= 400 && !res.headers.has("X-Remix-Response")) {
|
|
580
|
+
throw new (0, _chunkAMVS5XVJjs.ErrorResponseImpl)(res.status, res.statusText, await res.text());
|
|
581
|
+
}
|
|
582
|
+
_chunkAMVS5XVJjs.invariant.call(void 0, res.body, "No response body to decode");
|
|
583
|
+
try {
|
|
584
|
+
const payload = await createFromReadableStream(res.body, {
|
|
585
|
+
temporaryReferences: void 0
|
|
586
|
+
});
|
|
587
|
+
if (payload.type === "redirect") {
|
|
588
|
+
return {
|
|
589
|
+
status: res.status,
|
|
590
|
+
data: {
|
|
591
|
+
redirect: {
|
|
592
|
+
redirect: payload.location,
|
|
593
|
+
reload: payload.reload,
|
|
594
|
+
replace: payload.replace,
|
|
595
|
+
revalidate: false,
|
|
596
|
+
status: payload.status
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
};
|
|
600
|
+
}
|
|
601
|
+
if (payload.type !== "render") {
|
|
602
|
+
throw new Error("Unexpected payload type");
|
|
603
|
+
}
|
|
604
|
+
context.get(renderedRoutesContext).push(...payload.matches);
|
|
605
|
+
let results = { routes: {} };
|
|
606
|
+
const dataKey = _chunkAMVS5XVJjs.isMutationMethod.call(void 0, request.method) ? "actionData" : "loaderData";
|
|
607
|
+
for (let [routeId, data] of Object.entries(payload[dataKey] || {})) {
|
|
608
|
+
results.routes[routeId] = { data };
|
|
609
|
+
}
|
|
610
|
+
if (payload.errors) {
|
|
611
|
+
for (let [routeId, error] of Object.entries(payload.errors)) {
|
|
612
|
+
results.routes[routeId] = { error };
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
return { status: res.status, data: results };
|
|
616
|
+
} catch (e) {
|
|
617
|
+
throw new Error("Unable to decode RSC response");
|
|
618
|
+
}
|
|
619
|
+
};
|
|
620
|
+
}
|
|
621
|
+
function RSCHydratedRouter({
|
|
622
|
+
createFromReadableStream,
|
|
623
|
+
fetch: fetchImplementation = fetch,
|
|
624
|
+
payload,
|
|
625
|
+
routeDiscovery = "eager",
|
|
626
|
+
getContext
|
|
627
|
+
}) {
|
|
628
|
+
if (payload.type !== "render") throw new Error("Invalid payload type");
|
|
629
|
+
let { router: router2, routeModules } = React3.useMemo(
|
|
630
|
+
() => createRouterFromPayload({
|
|
631
|
+
payload,
|
|
632
|
+
fetchImplementation,
|
|
633
|
+
getContext,
|
|
634
|
+
createFromReadableStream
|
|
635
|
+
}),
|
|
636
|
+
[createFromReadableStream, payload, fetchImplementation, getContext]
|
|
637
|
+
);
|
|
638
|
+
React3.useEffect(() => {
|
|
639
|
+
_chunkAMVS5XVJjs.setIsHydrated.call(void 0, );
|
|
640
|
+
}, []);
|
|
641
|
+
React3.useLayoutEffect(() => {
|
|
642
|
+
const globalVar = window;
|
|
643
|
+
if (!globalVar.__routerInitialized) {
|
|
644
|
+
globalVar.__routerInitialized = true;
|
|
645
|
+
globalVar.__reactRouterDataRouter.initialize();
|
|
646
|
+
}
|
|
647
|
+
}, []);
|
|
648
|
+
let [location2, setLocation] = React3.useState(router2.state.location);
|
|
649
|
+
React3.useLayoutEffect(
|
|
650
|
+
() => router2.subscribe((newState) => {
|
|
651
|
+
if (newState.location !== location2) {
|
|
652
|
+
setLocation(newState.location);
|
|
653
|
+
}
|
|
654
|
+
}),
|
|
655
|
+
[router2, location2]
|
|
656
|
+
);
|
|
657
|
+
React3.useEffect(() => {
|
|
658
|
+
if (routeDiscovery === "lazy" || // @ts-expect-error - TS doesn't know about this yet
|
|
659
|
+
_optionalChain([window, 'access', _29 => _29.navigator, 'optionalAccess', _30 => _30.connection, 'optionalAccess', _31 => _31.saveData]) === true) {
|
|
660
|
+
return;
|
|
661
|
+
}
|
|
662
|
+
function registerElement(el) {
|
|
663
|
+
let path = el.tagName === "FORM" ? el.getAttribute("action") : el.getAttribute("href");
|
|
664
|
+
if (!path) {
|
|
665
|
+
return;
|
|
666
|
+
}
|
|
667
|
+
let pathname = el.tagName === "A" ? el.pathname : new URL(path, window.location.origin).pathname;
|
|
668
|
+
if (!discoveredPaths.has(pathname)) {
|
|
669
|
+
nextPaths.add(pathname);
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
async function fetchPatches() {
|
|
673
|
+
document.querySelectorAll("a[data-discover], form[data-discover]").forEach(registerElement);
|
|
674
|
+
let paths = Array.from(nextPaths.keys()).filter((path) => {
|
|
675
|
+
if (discoveredPaths.has(path)) {
|
|
676
|
+
nextPaths.delete(path);
|
|
677
|
+
return false;
|
|
678
|
+
}
|
|
679
|
+
return true;
|
|
680
|
+
});
|
|
681
|
+
if (paths.length === 0) {
|
|
682
|
+
return;
|
|
683
|
+
}
|
|
684
|
+
try {
|
|
685
|
+
await fetchAndApplyManifestPatches(
|
|
686
|
+
paths,
|
|
687
|
+
createFromReadableStream,
|
|
688
|
+
fetchImplementation
|
|
689
|
+
);
|
|
690
|
+
} catch (e) {
|
|
691
|
+
console.error("Failed to fetch manifest patches", e);
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
let debouncedFetchPatches = debounce(fetchPatches, 100);
|
|
695
|
+
fetchPatches();
|
|
696
|
+
let observer = new MutationObserver(() => debouncedFetchPatches());
|
|
697
|
+
observer.observe(document.documentElement, {
|
|
698
|
+
subtree: true,
|
|
699
|
+
childList: true,
|
|
700
|
+
attributes: true,
|
|
701
|
+
attributeFilter: ["data-discover", "href", "action"]
|
|
702
|
+
});
|
|
703
|
+
}, [routeDiscovery, createFromReadableStream, fetchImplementation]);
|
|
704
|
+
const frameworkContext = {
|
|
705
|
+
future: {
|
|
706
|
+
// These flags have no runtime impact so can always be false. If we add
|
|
707
|
+
// flags that drive runtime behavior they'll need to be proxied through.
|
|
708
|
+
v8_middleware: false,
|
|
709
|
+
unstable_subResourceIntegrity: false
|
|
710
|
+
},
|
|
711
|
+
isSpaMode: false,
|
|
712
|
+
ssr: true,
|
|
713
|
+
criticalCss: "",
|
|
714
|
+
manifest: {
|
|
715
|
+
routes: {},
|
|
716
|
+
version: "1",
|
|
717
|
+
url: "",
|
|
718
|
+
entry: {
|
|
719
|
+
module: "",
|
|
720
|
+
imports: []
|
|
721
|
+
}
|
|
722
|
+
},
|
|
723
|
+
routeDiscovery: { mode: "lazy", manifestPath: "/__manifest" },
|
|
724
|
+
routeModules
|
|
725
|
+
};
|
|
726
|
+
return /* @__PURE__ */ React3.createElement(_chunkAMVS5XVJjs.RSCRouterContext.Provider, { value: true }, /* @__PURE__ */ React3.createElement(_chunkPZWDWJAYjs.RSCRouterGlobalErrorBoundary, { location: location2 }, /* @__PURE__ */ React3.createElement(_chunkAMVS5XVJjs.FrameworkContext.Provider, { value: frameworkContext }, /* @__PURE__ */ React3.createElement(_chunkAMVS5XVJjs.UNSTABLE_TransitionEnabledRouterProvider, { router: router2, flushSync: ReactDOM2.flushSync }))));
|
|
727
|
+
}
|
|
728
|
+
function createRouteFromServerManifest(match, payload) {
|
|
729
|
+
let hasInitialData = payload && match.id in payload.loaderData;
|
|
730
|
+
let initialData = _optionalChain([payload, 'optionalAccess', _32 => _32.loaderData, 'access', _33 => _33[match.id]]);
|
|
731
|
+
let hasInitialError = _optionalChain([payload, 'optionalAccess', _34 => _34.errors]) && match.id in payload.errors;
|
|
732
|
+
let initialError = _optionalChain([payload, 'optionalAccess', _35 => _35.errors, 'optionalAccess', _36 => _36[match.id]]);
|
|
733
|
+
let isHydrationRequest = _optionalChain([match, 'access', _37 => _37.clientLoader, 'optionalAccess', _38 => _38.hydrate]) === true || !match.hasLoader || // If the route has a component but we don't have an element, we need to hit
|
|
734
|
+
// the server loader flow regardless of whether the client loader calls
|
|
735
|
+
// `serverLoader` or not, otherwise we'll have nothing to render.
|
|
736
|
+
match.hasComponent && !match.element;
|
|
737
|
+
_chunkAMVS5XVJjs.invariant.call(void 0, window.__reactRouterRouteModules);
|
|
738
|
+
_chunkPZWDWJAYjs.populateRSCRouteModules.call(void 0, window.__reactRouterRouteModules, match);
|
|
739
|
+
let dataRoute = {
|
|
740
|
+
id: match.id,
|
|
741
|
+
element: match.element,
|
|
742
|
+
errorElement: match.errorElement,
|
|
743
|
+
handle: match.handle,
|
|
744
|
+
hasErrorBoundary: match.hasErrorBoundary,
|
|
745
|
+
hydrateFallbackElement: match.hydrateFallbackElement,
|
|
746
|
+
index: match.index,
|
|
747
|
+
loader: match.clientLoader ? async (args, singleFetch) => {
|
|
748
|
+
try {
|
|
749
|
+
let result = await match.clientLoader({
|
|
750
|
+
...args,
|
|
751
|
+
serverLoader: () => {
|
|
752
|
+
preventInvalidServerHandlerCall(
|
|
753
|
+
"loader",
|
|
754
|
+
match.id,
|
|
755
|
+
match.hasLoader
|
|
756
|
+
);
|
|
757
|
+
if (isHydrationRequest) {
|
|
758
|
+
if (hasInitialData) {
|
|
759
|
+
return initialData;
|
|
760
|
+
}
|
|
761
|
+
if (hasInitialError) {
|
|
762
|
+
throw initialError;
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
return callSingleFetch(singleFetch);
|
|
766
|
+
}
|
|
767
|
+
});
|
|
768
|
+
return result;
|
|
769
|
+
} finally {
|
|
770
|
+
isHydrationRequest = false;
|
|
771
|
+
}
|
|
772
|
+
} : (
|
|
773
|
+
// We always make the call in this RSC world since even if we don't
|
|
774
|
+
// have a `loader` we may need to get the `element` implementation
|
|
775
|
+
(_, singleFetch) => callSingleFetch(singleFetch)
|
|
776
|
+
),
|
|
777
|
+
action: match.clientAction ? (args, singleFetch) => match.clientAction({
|
|
778
|
+
...args,
|
|
779
|
+
serverAction: async () => {
|
|
780
|
+
preventInvalidServerHandlerCall(
|
|
781
|
+
"action",
|
|
782
|
+
match.id,
|
|
783
|
+
match.hasLoader
|
|
784
|
+
);
|
|
785
|
+
return await callSingleFetch(singleFetch);
|
|
786
|
+
}
|
|
787
|
+
}) : match.hasAction ? (_, singleFetch) => callSingleFetch(singleFetch) : () => {
|
|
788
|
+
throw _chunkAMVS5XVJjs.noActionDefinedError.call(void 0, "action", match.id);
|
|
789
|
+
},
|
|
790
|
+
path: match.path,
|
|
791
|
+
shouldRevalidate: match.shouldRevalidate,
|
|
792
|
+
// We always have a "loader" in this RSC world since even if we don't
|
|
793
|
+
// have a `loader` we may need to get the `element` implementation
|
|
794
|
+
hasLoader: true,
|
|
795
|
+
hasClientLoader: match.clientLoader != null,
|
|
796
|
+
hasAction: match.hasAction,
|
|
797
|
+
hasClientAction: match.clientAction != null,
|
|
798
|
+
hasShouldRevalidate: match.shouldRevalidate != null
|
|
799
|
+
};
|
|
800
|
+
if (typeof dataRoute.loader === "function") {
|
|
801
|
+
dataRoute.loader.hydrate = _chunkAMVS5XVJjs.shouldHydrateRouteLoader.call(void 0,
|
|
802
|
+
match.id,
|
|
803
|
+
match.clientLoader,
|
|
804
|
+
match.hasLoader,
|
|
805
|
+
false
|
|
806
|
+
);
|
|
807
|
+
}
|
|
808
|
+
return dataRoute;
|
|
809
|
+
}
|
|
810
|
+
function callSingleFetch(singleFetch) {
|
|
811
|
+
_chunkAMVS5XVJjs.invariant.call(void 0, typeof singleFetch === "function", "Invalid singleFetch parameter");
|
|
812
|
+
return singleFetch();
|
|
813
|
+
}
|
|
814
|
+
function preventInvalidServerHandlerCall(type, routeId, hasHandler) {
|
|
815
|
+
if (!hasHandler) {
|
|
816
|
+
let fn = type === "action" ? "serverAction()" : "serverLoader()";
|
|
817
|
+
let msg = `You are trying to call ${fn} on a route that does not have a server ${type} (routeId: "${routeId}")`;
|
|
818
|
+
console.error(msg);
|
|
819
|
+
throw new (0, _chunkAMVS5XVJjs.ErrorResponseImpl)(400, "Bad Request", new Error(msg), true);
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
var nextPaths = /* @__PURE__ */ new Set();
|
|
823
|
+
var discoveredPathsMaxSize = 1e3;
|
|
824
|
+
var discoveredPaths = /* @__PURE__ */ new Set();
|
|
825
|
+
var URL_LIMIT = 7680;
|
|
826
|
+
function getManifestUrl(paths) {
|
|
827
|
+
if (paths.length === 0) {
|
|
828
|
+
return null;
|
|
829
|
+
}
|
|
830
|
+
if (paths.length === 1) {
|
|
831
|
+
return new URL(`${paths[0]}.manifest`, window.location.origin);
|
|
832
|
+
}
|
|
833
|
+
const globalVar = window;
|
|
834
|
+
let basename = (_nullishCoalesce(globalVar.__reactRouterDataRouter.basename, () => ( ""))).replace(
|
|
835
|
+
/^\/|\/$/g,
|
|
836
|
+
""
|
|
837
|
+
);
|
|
838
|
+
let url = new URL(`${basename}/.manifest`, window.location.origin);
|
|
839
|
+
url.searchParams.set("paths", paths.sort().join(","));
|
|
840
|
+
return url;
|
|
841
|
+
}
|
|
842
|
+
async function fetchAndApplyManifestPatches(paths, createFromReadableStream, fetchImplementation, signal) {
|
|
843
|
+
let url = getManifestUrl(paths);
|
|
844
|
+
if (url == null) {
|
|
845
|
+
return;
|
|
846
|
+
}
|
|
847
|
+
if (url.toString().length > URL_LIMIT) {
|
|
848
|
+
nextPaths.clear();
|
|
849
|
+
return;
|
|
850
|
+
}
|
|
851
|
+
let response = await fetchImplementation(new Request(url, { signal }));
|
|
852
|
+
if (!response.body || response.status < 200 || response.status >= 300) {
|
|
853
|
+
throw new Error("Unable to fetch new route matches from the server");
|
|
854
|
+
}
|
|
855
|
+
let payload = await createFromReadableStream(response.body, {
|
|
856
|
+
temporaryReferences: void 0
|
|
857
|
+
});
|
|
858
|
+
if (payload.type !== "manifest") {
|
|
859
|
+
throw new Error("Failed to patch routes");
|
|
860
|
+
}
|
|
861
|
+
paths.forEach((p) => addToFifoQueue(p, discoveredPaths));
|
|
862
|
+
payload.patches.forEach((p) => {
|
|
863
|
+
window.__reactRouterDataRouter.patchRoutes(
|
|
864
|
+
_nullishCoalesce(p.parentId, () => ( null)),
|
|
865
|
+
[createRouteFromServerManifest(p)]
|
|
866
|
+
);
|
|
867
|
+
});
|
|
868
|
+
}
|
|
869
|
+
function addToFifoQueue(path, queue) {
|
|
870
|
+
if (queue.size >= discoveredPathsMaxSize) {
|
|
871
|
+
let first = queue.values().next().value;
|
|
872
|
+
queue.delete(first);
|
|
873
|
+
}
|
|
874
|
+
queue.add(path);
|
|
875
|
+
}
|
|
876
|
+
function debounce(callback, wait) {
|
|
877
|
+
let timeoutId;
|
|
878
|
+
return (...args) => {
|
|
879
|
+
window.clearTimeout(timeoutId);
|
|
880
|
+
timeoutId = window.setTimeout(() => callback(...args), wait);
|
|
881
|
+
};
|
|
882
|
+
}
|
|
883
|
+
function isExternalLocation(location2) {
|
|
884
|
+
const newLocation = new URL(location2, window.location.href);
|
|
885
|
+
return newLocation.origin !== window.location.origin;
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
// lib/rsc/html-stream/browser.ts
|
|
889
|
+
function getRSCStream() {
|
|
890
|
+
let encoder = new TextEncoder();
|
|
891
|
+
let streamController = null;
|
|
892
|
+
let rscStream = new ReadableStream({
|
|
893
|
+
start(controller) {
|
|
894
|
+
if (typeof window === "undefined") {
|
|
895
|
+
return;
|
|
896
|
+
}
|
|
897
|
+
let handleChunk = (chunk) => {
|
|
898
|
+
if (typeof chunk === "string") {
|
|
899
|
+
controller.enqueue(encoder.encode(chunk));
|
|
900
|
+
} else {
|
|
901
|
+
controller.enqueue(chunk);
|
|
902
|
+
}
|
|
903
|
+
};
|
|
904
|
+
window.__FLIGHT_DATA || (window.__FLIGHT_DATA = []);
|
|
905
|
+
window.__FLIGHT_DATA.forEach(handleChunk);
|
|
906
|
+
window.__FLIGHT_DATA.push = (chunk) => {
|
|
907
|
+
handleChunk(chunk);
|
|
908
|
+
return 0;
|
|
909
|
+
};
|
|
910
|
+
streamController = controller;
|
|
911
|
+
}
|
|
912
|
+
});
|
|
913
|
+
if (typeof document !== "undefined" && document.readyState === "loading") {
|
|
914
|
+
document.addEventListener("DOMContentLoaded", () => {
|
|
915
|
+
_optionalChain([streamController, 'optionalAccess', _39 => _39.close, 'call', _40 => _40()]);
|
|
916
|
+
});
|
|
917
|
+
} else {
|
|
918
|
+
_optionalChain([streamController, 'optionalAccess', _41 => _41.close, 'call', _42 => _42()]);
|
|
919
|
+
}
|
|
920
|
+
return rscStream;
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
|
|
924
|
+
|
|
925
|
+
|
|
238
926
|
|
|
239
927
|
|
|
240
|
-
exports.HydratedRouter = HydratedRouter; exports.RouterProvider = RouterProvider;
|
|
928
|
+
exports.HydratedRouter = HydratedRouter; exports.RouterProvider = RouterProvider; exports.unstable_RSCHydratedRouter = RSCHydratedRouter; exports.unstable_createCallServer = createCallServer; exports.unstable_getRSCStream = getRSCStream;
|