react-router 0.0.0-experimental-73e447577 → 0.0.0-experimental-4e44d47
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 +35 -0
- package/dist/development/{chunk-WQE2SM7S.js → chunk-7B7CUJYE.js} +7 -4
- package/dist/{production/chunk-TA3WUUL6.js → development/chunk-MTLWRICG.js} +272 -158
- package/dist/development/{chunk-NKIXC2FA.mjs → chunk-PSQFTIPQ.mjs} +71 -66
- package/dist/development/{chunk-PF7FO4KS.mjs → chunk-XVVWTPHF.mjs} +122 -5
- package/dist/development/dom-export.js +3 -3
- package/dist/development/dom-export.mjs +3 -3
- 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.js +5 -2
- package/dist/development/index-react-server.mjs +5 -2
- package/dist/development/index.js +165 -160
- package/dist/development/index.mjs +3 -3
- package/dist/development/lib/types/internal.js +1 -1
- package/dist/development/lib/types/internal.mjs +1 -1
- package/dist/production/{chunk-YUNRQEIK.mjs → chunk-GSSVRQ6M.mjs} +122 -5
- package/dist/production/{chunk-TUGDEB6V.mjs → chunk-IZVJSKMU.mjs} +71 -66
- package/dist/production/{chunk-VRFRIIGI.js → chunk-OXRQQZPR.js} +7 -4
- package/dist/{development/chunk-SOMUQ5BV.js → production/chunk-UNIYMJFU.js} +272 -158
- package/dist/production/dom-export.js +3 -3
- package/dist/production/dom-export.mjs +3 -3
- 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.js +5 -2
- package/dist/production/index-react-server.mjs +5 -2
- package/dist/production/index.js +165 -160
- package/dist/production/index.mjs +3 -3
- package/dist/production/lib/types/internal.js +1 -1
- package/dist/production/lib/types/internal.mjs +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _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 v0.0.0-experimental-
|
|
2
|
+
* react-router v0.0.0-experimental-4e44d47
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
|
|
62
62
|
|
|
63
63
|
|
|
64
|
-
var
|
|
64
|
+
var _chunk7B7CUJYEjs = require('./chunk-7B7CUJYE.js');
|
|
65
65
|
|
|
66
66
|
// lib/components.tsx
|
|
67
67
|
var _react = require('react'); var React = _interopRequireWildcard(_react); var React2 = _interopRequireWildcard(_react); var React3 = _interopRequireWildcard(_react);
|
|
@@ -72,9 +72,9 @@ function mapRouteProperties(route) {
|
|
|
72
72
|
hasErrorBoundary: route.hasErrorBoundary || route.ErrorBoundary != null || route.errorElement != null
|
|
73
73
|
};
|
|
74
74
|
if (route.Component) {
|
|
75
|
-
if (
|
|
75
|
+
if (_chunk7B7CUJYEjs.ENABLE_DEV_WARNINGS) {
|
|
76
76
|
if (route.element) {
|
|
77
|
-
|
|
77
|
+
_chunk7B7CUJYEjs.warning.call(void 0,
|
|
78
78
|
false,
|
|
79
79
|
"You should not include both `Component` and `element` on your route - `Component` will be used."
|
|
80
80
|
);
|
|
@@ -86,9 +86,9 @@ function mapRouteProperties(route) {
|
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
88
|
if (route.HydrateFallback) {
|
|
89
|
-
if (
|
|
89
|
+
if (_chunk7B7CUJYEjs.ENABLE_DEV_WARNINGS) {
|
|
90
90
|
if (route.hydrateFallbackElement) {
|
|
91
|
-
|
|
91
|
+
_chunk7B7CUJYEjs.warning.call(void 0,
|
|
92
92
|
false,
|
|
93
93
|
"You should not include both `HydrateFallback` and `hydrateFallbackElement` on your route - `HydrateFallback` will be used."
|
|
94
94
|
);
|
|
@@ -100,9 +100,9 @@ function mapRouteProperties(route) {
|
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
102
|
if (route.ErrorBoundary) {
|
|
103
|
-
if (
|
|
103
|
+
if (_chunk7B7CUJYEjs.ENABLE_DEV_WARNINGS) {
|
|
104
104
|
if (route.errorElement) {
|
|
105
|
-
|
|
105
|
+
_chunk7B7CUJYEjs.warning.call(void 0,
|
|
106
106
|
false,
|
|
107
107
|
"You should not include both `ErrorBoundary` and `errorElement` on your route - `ErrorBoundary` will be used."
|
|
108
108
|
);
|
|
@@ -120,11 +120,11 @@ var hydrationRouteProperties = [
|
|
|
120
120
|
"hydrateFallbackElement"
|
|
121
121
|
];
|
|
122
122
|
function createMemoryRouter(routes, opts) {
|
|
123
|
-
return
|
|
123
|
+
return _chunk7B7CUJYEjs.createRouter.call(void 0, {
|
|
124
124
|
basename: _optionalChain([opts, 'optionalAccess', _2 => _2.basename]),
|
|
125
125
|
getContext: _optionalChain([opts, 'optionalAccess', _3 => _3.getContext]),
|
|
126
126
|
future: _optionalChain([opts, 'optionalAccess', _4 => _4.future]),
|
|
127
|
-
history:
|
|
127
|
+
history: _chunk7B7CUJYEjs.createMemoryHistory.call(void 0, {
|
|
128
128
|
initialEntries: _optionalChain([opts, 'optionalAccess', _5 => _5.initialEntries]),
|
|
129
129
|
initialIndex: _optionalChain([opts, 'optionalAccess', _6 => _6.initialIndex])
|
|
130
130
|
}),
|
|
@@ -156,6 +156,119 @@ var Deferred = class {
|
|
|
156
156
|
});
|
|
157
157
|
}
|
|
158
158
|
};
|
|
159
|
+
function shallowDiff(a, b) {
|
|
160
|
+
if (a === b) {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
let aKeys = Object.keys(a);
|
|
164
|
+
let bKeys = Object.keys(b);
|
|
165
|
+
if (aKeys.length !== bKeys.length) {
|
|
166
|
+
return true;
|
|
167
|
+
}
|
|
168
|
+
for (let key of aKeys) {
|
|
169
|
+
if (a[key] !== b[key]) {
|
|
170
|
+
return true;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
function UNSTABLE_TransitionEnabledRouterProvider({
|
|
176
|
+
router,
|
|
177
|
+
flushSync: reactDomFlushSyncImpl,
|
|
178
|
+
unstable_onError
|
|
179
|
+
}) {
|
|
180
|
+
let fetcherData = React.useRef(/* @__PURE__ */ new Map());
|
|
181
|
+
let [revalidating, startRevalidation] = React.useTransition();
|
|
182
|
+
let [state, setState] = React.useState(router.state);
|
|
183
|
+
router.__setPendingRerender = (promise) => startRevalidation(
|
|
184
|
+
// @ts-expect-error - need react 19 types for this to be async
|
|
185
|
+
async () => {
|
|
186
|
+
const rerender = await promise;
|
|
187
|
+
startRevalidation(() => {
|
|
188
|
+
rerender();
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
);
|
|
192
|
+
let navigator = React.useMemo(() => {
|
|
193
|
+
return {
|
|
194
|
+
createHref: router.createHref,
|
|
195
|
+
encodeLocation: router.encodeLocation,
|
|
196
|
+
go: (n) => router.navigate(n),
|
|
197
|
+
push: (to, state2, opts) => router.navigate(to, {
|
|
198
|
+
state: state2,
|
|
199
|
+
preventScrollReset: _optionalChain([opts, 'optionalAccess', _11 => _11.preventScrollReset])
|
|
200
|
+
}),
|
|
201
|
+
replace: (to, state2, opts) => router.navigate(to, {
|
|
202
|
+
replace: true,
|
|
203
|
+
state: state2,
|
|
204
|
+
preventScrollReset: _optionalChain([opts, 'optionalAccess', _12 => _12.preventScrollReset])
|
|
205
|
+
})
|
|
206
|
+
};
|
|
207
|
+
}, [router]);
|
|
208
|
+
let basename = router.basename || "/";
|
|
209
|
+
let dataRouterContext = React.useMemo(
|
|
210
|
+
() => ({
|
|
211
|
+
router,
|
|
212
|
+
navigator,
|
|
213
|
+
static: false,
|
|
214
|
+
basename,
|
|
215
|
+
unstable_onError
|
|
216
|
+
}),
|
|
217
|
+
[router, navigator, basename, unstable_onError]
|
|
218
|
+
);
|
|
219
|
+
React.useLayoutEffect(() => {
|
|
220
|
+
return router.subscribe(
|
|
221
|
+
(newState, { deletedFetchers, flushSync, viewTransitionOpts }) => {
|
|
222
|
+
newState.fetchers.forEach((fetcher, key) => {
|
|
223
|
+
if (fetcher.data !== void 0) {
|
|
224
|
+
fetcherData.current.set(key, fetcher.data);
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
deletedFetchers.forEach((key) => fetcherData.current.delete(key));
|
|
228
|
+
const diff = shallowDiff(state, newState);
|
|
229
|
+
if (!diff) return;
|
|
230
|
+
if (flushSync) {
|
|
231
|
+
if (reactDomFlushSyncImpl) {
|
|
232
|
+
reactDomFlushSyncImpl(() => setState(newState));
|
|
233
|
+
} else {
|
|
234
|
+
setState(newState);
|
|
235
|
+
}
|
|
236
|
+
} else {
|
|
237
|
+
React.startTransition(() => {
|
|
238
|
+
setState(newState);
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
);
|
|
243
|
+
}, [router, reactDomFlushSyncImpl, state]);
|
|
244
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(_chunk7B7CUJYEjs.DataRouterContext.Provider, { value: dataRouterContext }, /* @__PURE__ */ React.createElement(
|
|
245
|
+
_chunk7B7CUJYEjs.DataRouterStateContext.Provider,
|
|
246
|
+
{
|
|
247
|
+
value: {
|
|
248
|
+
...state,
|
|
249
|
+
revalidation: revalidating ? "loading" : state.revalidation
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
/* @__PURE__ */ React.createElement(_chunk7B7CUJYEjs.FetchersContext.Provider, { value: fetcherData.current }, /* @__PURE__ */ React.createElement(
|
|
253
|
+
Router,
|
|
254
|
+
{
|
|
255
|
+
basename,
|
|
256
|
+
location: state.location,
|
|
257
|
+
navigationType: state.historyAction,
|
|
258
|
+
navigator
|
|
259
|
+
},
|
|
260
|
+
/* @__PURE__ */ React.createElement(
|
|
261
|
+
MemoizedDataRoutes,
|
|
262
|
+
{
|
|
263
|
+
routes: router.routes,
|
|
264
|
+
future: router.future,
|
|
265
|
+
state,
|
|
266
|
+
unstable_onError
|
|
267
|
+
}
|
|
268
|
+
)
|
|
269
|
+
))
|
|
270
|
+
)), null);
|
|
271
|
+
}
|
|
159
272
|
function RouterProvider({
|
|
160
273
|
router,
|
|
161
274
|
flushSync: reactDomFlushSyncImpl,
|
|
@@ -175,7 +288,7 @@ function RouterProvider({
|
|
|
175
288
|
setStateImpl((prevState) => {
|
|
176
289
|
if (newState.errors && unstable_onError) {
|
|
177
290
|
Object.entries(newState.errors).forEach(([routeId, error]) => {
|
|
178
|
-
if (_optionalChain([prevState, 'access',
|
|
291
|
+
if (_optionalChain([prevState, 'access', _13 => _13.errors, 'optionalAccess', _14 => _14[routeId]]) !== error) {
|
|
179
292
|
unstable_onError(error);
|
|
180
293
|
}
|
|
181
294
|
});
|
|
@@ -193,12 +306,12 @@ function RouterProvider({
|
|
|
193
306
|
}
|
|
194
307
|
});
|
|
195
308
|
deletedFetchers.forEach((key) => fetcherData.current.delete(key));
|
|
196
|
-
|
|
309
|
+
_chunk7B7CUJYEjs.warnOnce.call(void 0,
|
|
197
310
|
flushSync === false || reactDomFlushSyncImpl != null,
|
|
198
311
|
'You provided the `flushSync` option to a router update, but you are not using the `<RouterProvider>` from `react-router/dom` so `ReactDOM.flushSync()` is unavailable. Please update your app to `import { RouterProvider } from "react-router/dom"` and ensure you have `react-dom` installed as a dependency to use the `flushSync` option.'
|
|
199
312
|
);
|
|
200
313
|
let isViewTransitionAvailable = router.window != null && router.window.document != null && typeof router.window.document.startViewTransition === "function";
|
|
201
|
-
|
|
314
|
+
_chunk7B7CUJYEjs.warnOnce.call(void 0,
|
|
202
315
|
viewTransitionOpts == null || isViewTransitionAvailable,
|
|
203
316
|
"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."
|
|
204
317
|
);
|
|
@@ -310,12 +423,12 @@ function RouterProvider({
|
|
|
310
423
|
go: (n) => router.navigate(n),
|
|
311
424
|
push: (to, state2, opts) => router.navigate(to, {
|
|
312
425
|
state: state2,
|
|
313
|
-
preventScrollReset: _optionalChain([opts, 'optionalAccess',
|
|
426
|
+
preventScrollReset: _optionalChain([opts, 'optionalAccess', _15 => _15.preventScrollReset])
|
|
314
427
|
}),
|
|
315
428
|
replace: (to, state2, opts) => router.navigate(to, {
|
|
316
429
|
replace: true,
|
|
317
430
|
state: state2,
|
|
318
|
-
preventScrollReset: _optionalChain([opts, 'optionalAccess',
|
|
431
|
+
preventScrollReset: _optionalChain([opts, 'optionalAccess', _16 => _16.preventScrollReset])
|
|
319
432
|
})
|
|
320
433
|
};
|
|
321
434
|
}, [router]);
|
|
@@ -330,7 +443,7 @@ function RouterProvider({
|
|
|
330
443
|
}),
|
|
331
444
|
[router, navigator, basename, unstable_onError]
|
|
332
445
|
);
|
|
333
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
|
|
446
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(_chunk7B7CUJYEjs.DataRouterContext.Provider, { value: dataRouterContext }, /* @__PURE__ */ React.createElement(_chunk7B7CUJYEjs.DataRouterStateContext.Provider, { value: state }, /* @__PURE__ */ React.createElement(_chunk7B7CUJYEjs.FetchersContext.Provider, { value: fetcherData.current }, /* @__PURE__ */ React.createElement(_chunk7B7CUJYEjs.ViewTransitionContext.Provider, { value: vtContext }, /* @__PURE__ */ React.createElement(
|
|
334
447
|
Router,
|
|
335
448
|
{
|
|
336
449
|
basename,
|
|
@@ -356,7 +469,7 @@ function DataRoutes({
|
|
|
356
469
|
state,
|
|
357
470
|
unstable_onError
|
|
358
471
|
}) {
|
|
359
|
-
return
|
|
472
|
+
return _chunk7B7CUJYEjs.useRoutesImpl.call(void 0, routes, void 0, state, unstable_onError, future);
|
|
360
473
|
}
|
|
361
474
|
function MemoryRouter({
|
|
362
475
|
basename,
|
|
@@ -366,7 +479,7 @@ function MemoryRouter({
|
|
|
366
479
|
}) {
|
|
367
480
|
let historyRef = React.useRef();
|
|
368
481
|
if (historyRef.current == null) {
|
|
369
|
-
historyRef.current =
|
|
482
|
+
historyRef.current = _chunk7B7CUJYEjs.createMemoryHistory.call(void 0, {
|
|
370
483
|
initialEntries,
|
|
371
484
|
initialIndex,
|
|
372
485
|
v5Compat: true
|
|
@@ -401,23 +514,23 @@ function Navigate({
|
|
|
401
514
|
state,
|
|
402
515
|
relative
|
|
403
516
|
}) {
|
|
404
|
-
|
|
405
|
-
|
|
517
|
+
_chunk7B7CUJYEjs.invariant.call(void 0,
|
|
518
|
+
_chunk7B7CUJYEjs.useInRouterContext.call(void 0, ),
|
|
406
519
|
// TODO: This error is probably because they somehow have 2 versions of
|
|
407
520
|
// the router loaded. We can help them understand how to avoid that.
|
|
408
521
|
`<Navigate> may be used only in the context of a <Router> component.`
|
|
409
522
|
);
|
|
410
|
-
let { static: isStatic } = React.useContext(
|
|
411
|
-
|
|
523
|
+
let { static: isStatic } = React.useContext(_chunk7B7CUJYEjs.NavigationContext);
|
|
524
|
+
_chunk7B7CUJYEjs.warning.call(void 0,
|
|
412
525
|
!isStatic,
|
|
413
526
|
`<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.`
|
|
414
527
|
);
|
|
415
|
-
let { matches } = React.useContext(
|
|
416
|
-
let { pathname: locationPathname } =
|
|
417
|
-
let navigate =
|
|
418
|
-
let path =
|
|
528
|
+
let { matches } = React.useContext(_chunk7B7CUJYEjs.RouteContext);
|
|
529
|
+
let { pathname: locationPathname } = _chunk7B7CUJYEjs.useLocation.call(void 0, );
|
|
530
|
+
let navigate = _chunk7B7CUJYEjs.useNavigate.call(void 0, );
|
|
531
|
+
let path = _chunk7B7CUJYEjs.resolveTo.call(void 0,
|
|
419
532
|
to,
|
|
420
|
-
|
|
533
|
+
_chunk7B7CUJYEjs.getResolveToMatches.call(void 0, matches),
|
|
421
534
|
locationPathname,
|
|
422
535
|
relative === "path"
|
|
423
536
|
);
|
|
@@ -428,10 +541,10 @@ function Navigate({
|
|
|
428
541
|
return null;
|
|
429
542
|
}
|
|
430
543
|
function Outlet(props) {
|
|
431
|
-
return
|
|
544
|
+
return _chunk7B7CUJYEjs.useOutlet.call(void 0, props.context);
|
|
432
545
|
}
|
|
433
546
|
function Route(props) {
|
|
434
|
-
|
|
547
|
+
_chunk7B7CUJYEjs.invariant.call(void 0,
|
|
435
548
|
false,
|
|
436
549
|
`A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.`
|
|
437
550
|
);
|
|
@@ -444,8 +557,8 @@ function Router({
|
|
|
444
557
|
navigator,
|
|
445
558
|
static: staticProp = false
|
|
446
559
|
}) {
|
|
447
|
-
|
|
448
|
-
!
|
|
560
|
+
_chunk7B7CUJYEjs.invariant.call(void 0,
|
|
561
|
+
!_chunk7B7CUJYEjs.useInRouterContext.call(void 0, ),
|
|
449
562
|
`You cannot render a <Router> inside another <Router>. You should never have more than one in your app.`
|
|
450
563
|
);
|
|
451
564
|
let basename = basenameProp.replace(/^\/*/, "/");
|
|
@@ -459,7 +572,7 @@ function Router({
|
|
|
459
572
|
[basename, navigator, staticProp]
|
|
460
573
|
);
|
|
461
574
|
if (typeof locationProp === "string") {
|
|
462
|
-
locationProp =
|
|
575
|
+
locationProp = _chunk7B7CUJYEjs.parsePath.call(void 0, locationProp);
|
|
463
576
|
}
|
|
464
577
|
let {
|
|
465
578
|
pathname = "/",
|
|
@@ -469,7 +582,7 @@ function Router({
|
|
|
469
582
|
key = "default"
|
|
470
583
|
} = locationProp;
|
|
471
584
|
let locationContext = React.useMemo(() => {
|
|
472
|
-
let trailingPathname =
|
|
585
|
+
let trailingPathname = _chunk7B7CUJYEjs.stripBasename.call(void 0, pathname, basename);
|
|
473
586
|
if (trailingPathname == null) {
|
|
474
587
|
return null;
|
|
475
588
|
}
|
|
@@ -484,33 +597,33 @@ function Router({
|
|
|
484
597
|
navigationType
|
|
485
598
|
};
|
|
486
599
|
}, [basename, pathname, search, hash, state, key, navigationType]);
|
|
487
|
-
|
|
600
|
+
_chunk7B7CUJYEjs.warning.call(void 0,
|
|
488
601
|
locationContext != null,
|
|
489
602
|
`<Router basename="${basename}"> is not able to match the URL "${pathname}${search}${hash}" because it does not start with the basename, so the <Router> won't render anything.`
|
|
490
603
|
);
|
|
491
604
|
if (locationContext == null) {
|
|
492
605
|
return null;
|
|
493
606
|
}
|
|
494
|
-
return /* @__PURE__ */ React.createElement(
|
|
607
|
+
return /* @__PURE__ */ React.createElement(_chunk7B7CUJYEjs.NavigationContext.Provider, { value: navigationContext }, /* @__PURE__ */ React.createElement(_chunk7B7CUJYEjs.LocationContext.Provider, { children, value: locationContext }));
|
|
495
608
|
}
|
|
496
609
|
function Routes({
|
|
497
610
|
children,
|
|
498
611
|
location
|
|
499
612
|
}) {
|
|
500
|
-
return
|
|
613
|
+
return _chunk7B7CUJYEjs.useRoutes.call(void 0, createRoutesFromChildren(children), location);
|
|
501
614
|
}
|
|
502
615
|
function Await({
|
|
503
616
|
children,
|
|
504
617
|
errorElement,
|
|
505
618
|
resolve
|
|
506
619
|
}) {
|
|
507
|
-
let dataRouterContext = React.useContext(
|
|
620
|
+
let dataRouterContext = React.useContext(_chunk7B7CUJYEjs.DataRouterContext);
|
|
508
621
|
return /* @__PURE__ */ React.createElement(
|
|
509
622
|
AwaitErrorBoundary,
|
|
510
623
|
{
|
|
511
624
|
resolve,
|
|
512
625
|
errorElement,
|
|
513
|
-
unstable_onError: _optionalChain([dataRouterContext, 'optionalAccess',
|
|
626
|
+
unstable_onError: _optionalChain([dataRouterContext, 'optionalAccess', _17 => _17.unstable_onError])
|
|
514
627
|
},
|
|
515
628
|
/* @__PURE__ */ React.createElement(ResolveAwait, null, children)
|
|
516
629
|
);
|
|
@@ -559,7 +672,7 @@ var AwaitErrorBoundary = class extends React.Component {
|
|
|
559
672
|
promise = resolve.then(
|
|
560
673
|
(data) => Object.defineProperty(resolve, "_data", { get: () => data }),
|
|
561
674
|
(error) => {
|
|
562
|
-
_optionalChain([this, 'access',
|
|
675
|
+
_optionalChain([this, 'access', _18 => _18.props, 'access', _19 => _19.unstable_onError, 'optionalCall', _20 => _20(error)]);
|
|
563
676
|
Object.defineProperty(resolve, "_error", { get: () => error });
|
|
564
677
|
}
|
|
565
678
|
);
|
|
@@ -568,10 +681,10 @@ var AwaitErrorBoundary = class extends React.Component {
|
|
|
568
681
|
throw promise._error;
|
|
569
682
|
}
|
|
570
683
|
if (status === 2 /* error */) {
|
|
571
|
-
return /* @__PURE__ */ React.createElement(
|
|
684
|
+
return /* @__PURE__ */ React.createElement(_chunk7B7CUJYEjs.AwaitContext.Provider, { value: promise, children: errorElement });
|
|
572
685
|
}
|
|
573
686
|
if (status === 1 /* success */) {
|
|
574
|
-
return /* @__PURE__ */ React.createElement(
|
|
687
|
+
return /* @__PURE__ */ React.createElement(_chunk7B7CUJYEjs.AwaitContext.Provider, { value: promise, children });
|
|
575
688
|
}
|
|
576
689
|
throw promise;
|
|
577
690
|
}
|
|
@@ -579,7 +692,7 @@ var AwaitErrorBoundary = class extends React.Component {
|
|
|
579
692
|
function ResolveAwait({
|
|
580
693
|
children
|
|
581
694
|
}) {
|
|
582
|
-
let data =
|
|
695
|
+
let data = _chunk7B7CUJYEjs.useAsyncValue.call(void 0, );
|
|
583
696
|
let toRender = typeof children === "function" ? children(data) : children;
|
|
584
697
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, toRender);
|
|
585
698
|
}
|
|
@@ -597,11 +710,11 @@ function createRoutesFromChildren(children, parentPath = []) {
|
|
|
597
710
|
);
|
|
598
711
|
return;
|
|
599
712
|
}
|
|
600
|
-
|
|
713
|
+
_chunk7B7CUJYEjs.invariant.call(void 0,
|
|
601
714
|
element.type === Route,
|
|
602
715
|
`[${typeof element.type === "string" ? element.type : element.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`
|
|
603
716
|
);
|
|
604
|
-
|
|
717
|
+
_chunk7B7CUJYEjs.invariant.call(void 0,
|
|
605
718
|
!element.props.index || !element.props.children,
|
|
606
719
|
"An index route cannot have child routes."
|
|
607
720
|
);
|
|
@@ -636,14 +749,14 @@ function createRoutesFromChildren(children, parentPath = []) {
|
|
|
636
749
|
}
|
|
637
750
|
var createRoutesFromElements = createRoutesFromChildren;
|
|
638
751
|
function renderMatches(matches) {
|
|
639
|
-
return
|
|
752
|
+
return _chunk7B7CUJYEjs._renderMatches.call(void 0, matches);
|
|
640
753
|
}
|
|
641
754
|
function useRouteComponentProps() {
|
|
642
755
|
return {
|
|
643
|
-
params:
|
|
644
|
-
loaderData:
|
|
645
|
-
actionData:
|
|
646
|
-
matches:
|
|
756
|
+
params: _chunk7B7CUJYEjs.useParams.call(void 0, ),
|
|
757
|
+
loaderData: _chunk7B7CUJYEjs.useLoaderData.call(void 0, ),
|
|
758
|
+
actionData: _chunk7B7CUJYEjs.useActionData.call(void 0, ),
|
|
759
|
+
matches: _chunk7B7CUJYEjs.useMatches.call(void 0, )
|
|
647
760
|
};
|
|
648
761
|
}
|
|
649
762
|
function WithComponentProps({
|
|
@@ -660,9 +773,9 @@ function withComponentProps(Component2) {
|
|
|
660
773
|
}
|
|
661
774
|
function useHydrateFallbackProps() {
|
|
662
775
|
return {
|
|
663
|
-
params:
|
|
664
|
-
loaderData:
|
|
665
|
-
actionData:
|
|
776
|
+
params: _chunk7B7CUJYEjs.useParams.call(void 0, ),
|
|
777
|
+
loaderData: _chunk7B7CUJYEjs.useLoaderData.call(void 0, ),
|
|
778
|
+
actionData: _chunk7B7CUJYEjs.useActionData.call(void 0, )
|
|
666
779
|
};
|
|
667
780
|
}
|
|
668
781
|
function WithHydrateFallbackProps({
|
|
@@ -679,10 +792,10 @@ function withHydrateFallbackProps(HydrateFallback) {
|
|
|
679
792
|
}
|
|
680
793
|
function useErrorBoundaryProps() {
|
|
681
794
|
return {
|
|
682
|
-
params:
|
|
683
|
-
loaderData:
|
|
684
|
-
actionData:
|
|
685
|
-
error:
|
|
795
|
+
params: _chunk7B7CUJYEjs.useParams.call(void 0, ),
|
|
796
|
+
loaderData: _chunk7B7CUJYEjs.useLoaderData.call(void 0, ),
|
|
797
|
+
actionData: _chunk7B7CUJYEjs.useActionData.call(void 0, ),
|
|
798
|
+
error: _chunk7B7CUJYEjs.useRouteError.call(void 0, )
|
|
686
799
|
};
|
|
687
800
|
}
|
|
688
801
|
function WithErrorBoundaryProps({
|
|
@@ -767,7 +880,7 @@ var supportedFormEncTypes = /* @__PURE__ */ new Set([
|
|
|
767
880
|
]);
|
|
768
881
|
function getFormEncType(encType) {
|
|
769
882
|
if (encType != null && !supportedFormEncTypes.has(encType)) {
|
|
770
|
-
|
|
883
|
+
_chunk7B7CUJYEjs.warning.call(void 0,
|
|
771
884
|
false,
|
|
772
885
|
`"${encType}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${defaultEncType}"`
|
|
773
886
|
);
|
|
@@ -783,7 +896,7 @@ function getFormSubmissionInfo(target, basename) {
|
|
|
783
896
|
let body;
|
|
784
897
|
if (isFormElement(target)) {
|
|
785
898
|
let attr = target.getAttribute("action");
|
|
786
|
-
action = attr ?
|
|
899
|
+
action = attr ? _chunk7B7CUJYEjs.stripBasename.call(void 0, attr, basename) : null;
|
|
787
900
|
method = target.getAttribute("method") || defaultMethod;
|
|
788
901
|
encType = getFormEncType(target.getAttribute("enctype")) || defaultEncType;
|
|
789
902
|
formData = new FormData(target);
|
|
@@ -795,7 +908,7 @@ function getFormSubmissionInfo(target, basename) {
|
|
|
795
908
|
);
|
|
796
909
|
}
|
|
797
910
|
let attr = target.getAttribute("formaction") || form.getAttribute("action");
|
|
798
|
-
action = attr ?
|
|
911
|
+
action = attr ? _chunk7B7CUJYEjs.stripBasename.call(void 0, attr, basename) : null;
|
|
799
912
|
method = target.getAttribute("formmethod") || form.getAttribute("method") || defaultMethod;
|
|
800
913
|
encType = getFormEncType(target.getAttribute("formenctype")) || getFormEncType(form.getAttribute("enctype")) || defaultEncType;
|
|
801
914
|
formData = new FormData(form, target);
|
|
@@ -832,44 +945,44 @@ var isBrowser = typeof window !== "undefined" && typeof window.document !== "und
|
|
|
832
945
|
try {
|
|
833
946
|
if (isBrowser) {
|
|
834
947
|
window.__reactRouterVersion = // @ts-expect-error
|
|
835
|
-
"0.0.0-experimental-
|
|
948
|
+
"0.0.0-experimental-4e44d47";
|
|
836
949
|
}
|
|
837
950
|
} catch (e) {
|
|
838
951
|
}
|
|
839
952
|
function createBrowserRouter(routes, opts) {
|
|
840
|
-
return
|
|
841
|
-
basename: _optionalChain([opts, 'optionalAccess',
|
|
842
|
-
getContext: _optionalChain([opts, 'optionalAccess',
|
|
843
|
-
future: _optionalChain([opts, 'optionalAccess',
|
|
844
|
-
history:
|
|
845
|
-
hydrationData: _optionalChain([opts, 'optionalAccess',
|
|
953
|
+
return _chunk7B7CUJYEjs.createRouter.call(void 0, {
|
|
954
|
+
basename: _optionalChain([opts, 'optionalAccess', _21 => _21.basename]),
|
|
955
|
+
getContext: _optionalChain([opts, 'optionalAccess', _22 => _22.getContext]),
|
|
956
|
+
future: _optionalChain([opts, 'optionalAccess', _23 => _23.future]),
|
|
957
|
+
history: _chunk7B7CUJYEjs.createBrowserHistory.call(void 0, { window: _optionalChain([opts, 'optionalAccess', _24 => _24.window]) }),
|
|
958
|
+
hydrationData: _optionalChain([opts, 'optionalAccess', _25 => _25.hydrationData]) || parseHydrationData(),
|
|
846
959
|
routes,
|
|
847
960
|
mapRouteProperties,
|
|
848
961
|
hydrationRouteProperties,
|
|
849
|
-
dataStrategy: _optionalChain([opts, 'optionalAccess',
|
|
850
|
-
patchRoutesOnNavigation: _optionalChain([opts, 'optionalAccess',
|
|
851
|
-
window: _optionalChain([opts, 'optionalAccess',
|
|
852
|
-
unstable_instrumentations: _optionalChain([opts, 'optionalAccess',
|
|
962
|
+
dataStrategy: _optionalChain([opts, 'optionalAccess', _26 => _26.dataStrategy]),
|
|
963
|
+
patchRoutesOnNavigation: _optionalChain([opts, 'optionalAccess', _27 => _27.patchRoutesOnNavigation]),
|
|
964
|
+
window: _optionalChain([opts, 'optionalAccess', _28 => _28.window]),
|
|
965
|
+
unstable_instrumentations: _optionalChain([opts, 'optionalAccess', _29 => _29.unstable_instrumentations])
|
|
853
966
|
}).initialize();
|
|
854
967
|
}
|
|
855
968
|
function createHashRouter(routes, opts) {
|
|
856
|
-
return
|
|
857
|
-
basename: _optionalChain([opts, 'optionalAccess',
|
|
858
|
-
getContext: _optionalChain([opts, 'optionalAccess',
|
|
859
|
-
future: _optionalChain([opts, 'optionalAccess',
|
|
860
|
-
history:
|
|
861
|
-
hydrationData: _optionalChain([opts, 'optionalAccess',
|
|
969
|
+
return _chunk7B7CUJYEjs.createRouter.call(void 0, {
|
|
970
|
+
basename: _optionalChain([opts, 'optionalAccess', _30 => _30.basename]),
|
|
971
|
+
getContext: _optionalChain([opts, 'optionalAccess', _31 => _31.getContext]),
|
|
972
|
+
future: _optionalChain([opts, 'optionalAccess', _32 => _32.future]),
|
|
973
|
+
history: _chunk7B7CUJYEjs.createHashHistory.call(void 0, { window: _optionalChain([opts, 'optionalAccess', _33 => _33.window]) }),
|
|
974
|
+
hydrationData: _optionalChain([opts, 'optionalAccess', _34 => _34.hydrationData]) || parseHydrationData(),
|
|
862
975
|
routes,
|
|
863
976
|
mapRouteProperties,
|
|
864
977
|
hydrationRouteProperties,
|
|
865
|
-
dataStrategy: _optionalChain([opts, 'optionalAccess',
|
|
866
|
-
patchRoutesOnNavigation: _optionalChain([opts, 'optionalAccess',
|
|
867
|
-
window: _optionalChain([opts, 'optionalAccess',
|
|
868
|
-
unstable_instrumentations: _optionalChain([opts, 'optionalAccess',
|
|
978
|
+
dataStrategy: _optionalChain([opts, 'optionalAccess', _35 => _35.dataStrategy]),
|
|
979
|
+
patchRoutesOnNavigation: _optionalChain([opts, 'optionalAccess', _36 => _36.patchRoutesOnNavigation]),
|
|
980
|
+
window: _optionalChain([opts, 'optionalAccess', _37 => _37.window]),
|
|
981
|
+
unstable_instrumentations: _optionalChain([opts, 'optionalAccess', _38 => _38.unstable_instrumentations])
|
|
869
982
|
}).initialize();
|
|
870
983
|
}
|
|
871
984
|
function parseHydrationData() {
|
|
872
|
-
let state = _optionalChain([window, 'optionalAccess',
|
|
985
|
+
let state = _optionalChain([window, 'optionalAccess', _39 => _39.__staticRouterHydrationData]);
|
|
873
986
|
if (state && state.errors) {
|
|
874
987
|
state = {
|
|
875
988
|
...state,
|
|
@@ -884,7 +997,7 @@ function deserializeErrors(errors) {
|
|
|
884
997
|
let serialized = {};
|
|
885
998
|
for (let [key, val] of entries) {
|
|
886
999
|
if (val && val.__type === "RouteErrorResponse") {
|
|
887
|
-
serialized[key] = new (0,
|
|
1000
|
+
serialized[key] = new (0, _chunk7B7CUJYEjs.ErrorResponseImpl)(
|
|
888
1001
|
val.status,
|
|
889
1002
|
val.statusText,
|
|
890
1003
|
val.data,
|
|
@@ -920,7 +1033,7 @@ function BrowserRouter({
|
|
|
920
1033
|
}) {
|
|
921
1034
|
let historyRef = React2.useRef();
|
|
922
1035
|
if (historyRef.current == null) {
|
|
923
|
-
historyRef.current =
|
|
1036
|
+
historyRef.current = _chunk7B7CUJYEjs.createBrowserHistory.call(void 0, { window: window2, v5Compat: true });
|
|
924
1037
|
}
|
|
925
1038
|
let history = historyRef.current;
|
|
926
1039
|
let [state, setStateImpl] = React2.useState({
|
|
@@ -948,7 +1061,7 @@ function BrowserRouter({
|
|
|
948
1061
|
function HashRouter({ basename, children, window: window2 }) {
|
|
949
1062
|
let historyRef = React2.useRef();
|
|
950
1063
|
if (historyRef.current == null) {
|
|
951
|
-
historyRef.current =
|
|
1064
|
+
historyRef.current = _chunk7B7CUJYEjs.createHashHistory.call(void 0, { window: window2, v5Compat: true });
|
|
952
1065
|
}
|
|
953
1066
|
let history = historyRef.current;
|
|
954
1067
|
let [state, setStateImpl] = React2.useState({
|
|
@@ -1017,7 +1130,7 @@ var Link = React2.forwardRef(
|
|
|
1017
1130
|
viewTransition,
|
|
1018
1131
|
...rest
|
|
1019
1132
|
}, forwardedRef) {
|
|
1020
|
-
let { basename } = React2.useContext(
|
|
1133
|
+
let { basename } = React2.useContext(_chunk7B7CUJYEjs.NavigationContext);
|
|
1021
1134
|
let isAbsolute = typeof to === "string" && ABSOLUTE_URL_REGEX.test(to);
|
|
1022
1135
|
let absoluteHref;
|
|
1023
1136
|
let isExternal = false;
|
|
@@ -1027,22 +1140,22 @@ var Link = React2.forwardRef(
|
|
|
1027
1140
|
try {
|
|
1028
1141
|
let currentUrl = new URL(window.location.href);
|
|
1029
1142
|
let targetUrl = to.startsWith("//") ? new URL(currentUrl.protocol + to) : new URL(to);
|
|
1030
|
-
let path =
|
|
1143
|
+
let path = _chunk7B7CUJYEjs.stripBasename.call(void 0, targetUrl.pathname, basename);
|
|
1031
1144
|
if (targetUrl.origin === currentUrl.origin && path != null) {
|
|
1032
1145
|
to = path + targetUrl.search + targetUrl.hash;
|
|
1033
1146
|
} else {
|
|
1034
1147
|
isExternal = true;
|
|
1035
1148
|
}
|
|
1036
1149
|
} catch (e) {
|
|
1037
|
-
|
|
1150
|
+
_chunk7B7CUJYEjs.warning.call(void 0,
|
|
1038
1151
|
false,
|
|
1039
1152
|
`<Link to="${to}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`
|
|
1040
1153
|
);
|
|
1041
1154
|
}
|
|
1042
1155
|
}
|
|
1043
1156
|
}
|
|
1044
|
-
let href =
|
|
1045
|
-
let [shouldPrefetch, prefetchRef, prefetchHandlers] =
|
|
1157
|
+
let href = _chunk7B7CUJYEjs.useHref.call(void 0, to, { relative });
|
|
1158
|
+
let [shouldPrefetch, prefetchRef, prefetchHandlers] = _chunk7B7CUJYEjs.usePrefetchBehavior.call(void 0,
|
|
1046
1159
|
prefetch,
|
|
1047
1160
|
rest
|
|
1048
1161
|
);
|
|
@@ -1069,13 +1182,13 @@ var Link = React2.forwardRef(
|
|
|
1069
1182
|
...prefetchHandlers,
|
|
1070
1183
|
href: absoluteHref || href,
|
|
1071
1184
|
onClick: isExternal || reloadDocument ? onClick : handleClick,
|
|
1072
|
-
ref:
|
|
1185
|
+
ref: _chunk7B7CUJYEjs.mergeRefs.call(void 0, forwardedRef, prefetchRef),
|
|
1073
1186
|
target,
|
|
1074
1187
|
"data-discover": !isAbsolute && discover === "render" ? "true" : void 0
|
|
1075
1188
|
}
|
|
1076
1189
|
)
|
|
1077
1190
|
);
|
|
1078
|
-
return shouldPrefetch && !isAbsolute ? /* @__PURE__ */ React2.createElement(React2.Fragment, null, link, /* @__PURE__ */ React2.createElement(
|
|
1191
|
+
return shouldPrefetch && !isAbsolute ? /* @__PURE__ */ React2.createElement(React2.Fragment, null, link, /* @__PURE__ */ React2.createElement(_chunk7B7CUJYEjs.PrefetchPageLinks, { page: href })) : link;
|
|
1079
1192
|
}
|
|
1080
1193
|
);
|
|
1081
1194
|
Link.displayName = "Link";
|
|
@@ -1091,10 +1204,10 @@ var NavLink = React2.forwardRef(
|
|
|
1091
1204
|
children,
|
|
1092
1205
|
...rest
|
|
1093
1206
|
}, ref) {
|
|
1094
|
-
let path =
|
|
1095
|
-
let location =
|
|
1096
|
-
let routerState = React2.useContext(
|
|
1097
|
-
let { navigator, basename } = React2.useContext(
|
|
1207
|
+
let path = _chunk7B7CUJYEjs.useResolvedPath.call(void 0, to, { relative: rest.relative });
|
|
1208
|
+
let location = _chunk7B7CUJYEjs.useLocation.call(void 0, );
|
|
1209
|
+
let routerState = React2.useContext(_chunk7B7CUJYEjs.DataRouterStateContext);
|
|
1210
|
+
let { navigator, basename } = React2.useContext(_chunk7B7CUJYEjs.NavigationContext);
|
|
1098
1211
|
let isTransitioning = routerState != null && // Conditional usage is OK here because the usage of a data router is static
|
|
1099
1212
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
1100
1213
|
useViewTransitionState(path) && viewTransition === true;
|
|
@@ -1107,7 +1220,7 @@ var NavLink = React2.forwardRef(
|
|
|
1107
1220
|
toPathname = toPathname.toLowerCase();
|
|
1108
1221
|
}
|
|
1109
1222
|
if (nextLocationPathname && basename) {
|
|
1110
|
-
nextLocationPathname =
|
|
1223
|
+
nextLocationPathname = _chunk7B7CUJYEjs.stripBasename.call(void 0, nextLocationPathname, basename) || nextLocationPathname;
|
|
1111
1224
|
}
|
|
1112
1225
|
const endSlashPosition = toPathname !== "/" && toPathname.endsWith("/") ? toPathname.length - 1 : toPathname.length;
|
|
1113
1226
|
let isActive = locationPathname === toPathname || !end && locationPathname.startsWith(toPathname) && locationPathname.charAt(endSlashPosition) === "/";
|
|
@@ -1171,7 +1284,7 @@ var Form = React2.forwardRef(
|
|
|
1171
1284
|
if (event.defaultPrevented) return;
|
|
1172
1285
|
event.preventDefault();
|
|
1173
1286
|
let submitter = event.nativeEvent.submitter;
|
|
1174
|
-
let submitMethod = _optionalChain([submitter, 'optionalAccess',
|
|
1287
|
+
let submitMethod = _optionalChain([submitter, 'optionalAccess', _40 => _40.getAttribute, 'call', _41 => _41("formmethod")]) || method;
|
|
1175
1288
|
submit(submitter || event.currentTarget, {
|
|
1176
1289
|
fetcherKey,
|
|
1177
1290
|
method: submitMethod,
|
|
@@ -1202,10 +1315,10 @@ function ScrollRestoration({
|
|
|
1202
1315
|
storageKey,
|
|
1203
1316
|
...props
|
|
1204
1317
|
}) {
|
|
1205
|
-
let remixContext = React2.useContext(
|
|
1206
|
-
let { basename } = React2.useContext(
|
|
1207
|
-
let location =
|
|
1208
|
-
let matches =
|
|
1318
|
+
let remixContext = React2.useContext(_chunk7B7CUJYEjs.FrameworkContext);
|
|
1319
|
+
let { basename } = React2.useContext(_chunk7B7CUJYEjs.NavigationContext);
|
|
1320
|
+
let location = _chunk7B7CUJYEjs.useLocation.call(void 0, );
|
|
1321
|
+
let matches = _chunk7B7CUJYEjs.useMatches.call(void 0, );
|
|
1209
1322
|
useScrollRestoration({ getKey, storageKey });
|
|
1210
1323
|
let ssrKey = React2.useMemo(
|
|
1211
1324
|
() => {
|
|
@@ -1259,13 +1372,13 @@ function getDataRouterConsoleError(hookName) {
|
|
|
1259
1372
|
return `${hookName} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`;
|
|
1260
1373
|
}
|
|
1261
1374
|
function useDataRouterContext(hookName) {
|
|
1262
|
-
let ctx = React2.useContext(
|
|
1263
|
-
|
|
1375
|
+
let ctx = React2.useContext(_chunk7B7CUJYEjs.DataRouterContext);
|
|
1376
|
+
_chunk7B7CUJYEjs.invariant.call(void 0, ctx, getDataRouterConsoleError(hookName));
|
|
1264
1377
|
return ctx;
|
|
1265
1378
|
}
|
|
1266
1379
|
function useDataRouterState(hookName) {
|
|
1267
|
-
let state = React2.useContext(
|
|
1268
|
-
|
|
1380
|
+
let state = React2.useContext(_chunk7B7CUJYEjs.DataRouterStateContext);
|
|
1381
|
+
_chunk7B7CUJYEjs.invariant.call(void 0, state, getDataRouterConsoleError(hookName));
|
|
1269
1382
|
return state;
|
|
1270
1383
|
}
|
|
1271
1384
|
function useLinkClickHandler(to, {
|
|
@@ -1276,14 +1389,14 @@ function useLinkClickHandler(to, {
|
|
|
1276
1389
|
relative,
|
|
1277
1390
|
viewTransition
|
|
1278
1391
|
} = {}) {
|
|
1279
|
-
let navigate =
|
|
1280
|
-
let location =
|
|
1281
|
-
let path =
|
|
1392
|
+
let navigate = _chunk7B7CUJYEjs.useNavigate.call(void 0, );
|
|
1393
|
+
let location = _chunk7B7CUJYEjs.useLocation.call(void 0, );
|
|
1394
|
+
let path = _chunk7B7CUJYEjs.useResolvedPath.call(void 0, to, { relative });
|
|
1282
1395
|
return React2.useCallback(
|
|
1283
1396
|
(event) => {
|
|
1284
1397
|
if (shouldProcessLinkClick(event, target)) {
|
|
1285
1398
|
event.preventDefault();
|
|
1286
|
-
let replace = replaceProp !== void 0 ? replaceProp :
|
|
1399
|
+
let replace = replaceProp !== void 0 ? replaceProp : _chunk7B7CUJYEjs.createPath.call(void 0, location) === _chunk7B7CUJYEjs.createPath.call(void 0, path);
|
|
1287
1400
|
navigate(to, {
|
|
1288
1401
|
replace,
|
|
1289
1402
|
state,
|
|
@@ -1308,13 +1421,13 @@ function useLinkClickHandler(to, {
|
|
|
1308
1421
|
);
|
|
1309
1422
|
}
|
|
1310
1423
|
function useSearchParams(defaultInit) {
|
|
1311
|
-
|
|
1424
|
+
_chunk7B7CUJYEjs.warning.call(void 0,
|
|
1312
1425
|
typeof URLSearchParams !== "undefined",
|
|
1313
1426
|
`You cannot use the \`useSearchParams\` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.`
|
|
1314
1427
|
);
|
|
1315
1428
|
let defaultSearchParamsRef = React2.useRef(createSearchParams(defaultInit));
|
|
1316
1429
|
let hasSetSearchParamsRef = React2.useRef(false);
|
|
1317
|
-
let location =
|
|
1430
|
+
let location = _chunk7B7CUJYEjs.useLocation.call(void 0, );
|
|
1318
1431
|
let searchParams = React2.useMemo(
|
|
1319
1432
|
() => (
|
|
1320
1433
|
// Only merge in the defaults if we haven't yet called setSearchParams.
|
|
@@ -1327,7 +1440,7 @@ function useSearchParams(defaultInit) {
|
|
|
1327
1440
|
),
|
|
1328
1441
|
[location.search]
|
|
1329
1442
|
);
|
|
1330
|
-
let navigate =
|
|
1443
|
+
let navigate = _chunk7B7CUJYEjs.useNavigate.call(void 0, );
|
|
1331
1444
|
let setSearchParams = React2.useCallback(
|
|
1332
1445
|
(nextInit, navigateOptions) => {
|
|
1333
1446
|
const newSearchParams = createSearchParams(
|
|
@@ -1344,8 +1457,8 @@ var fetcherId = 0;
|
|
|
1344
1457
|
var getUniqueFetcherId = () => `__${String(++fetcherId)}__`;
|
|
1345
1458
|
function useSubmit() {
|
|
1346
1459
|
let { router } = useDataRouterContext("useSubmit" /* UseSubmit */);
|
|
1347
|
-
let { basename } = React2.useContext(
|
|
1348
|
-
let currentRouteId =
|
|
1460
|
+
let { basename } = React2.useContext(_chunk7B7CUJYEjs.NavigationContext);
|
|
1461
|
+
let currentRouteId = _chunk7B7CUJYEjs.useRouteId.call(void 0, );
|
|
1349
1462
|
return React2.useCallback(
|
|
1350
1463
|
async (target, options = {}) => {
|
|
1351
1464
|
let { action, method, encType, formData, body } = getFormSubmissionInfo(
|
|
@@ -1381,12 +1494,12 @@ function useSubmit() {
|
|
|
1381
1494
|
);
|
|
1382
1495
|
}
|
|
1383
1496
|
function useFormAction(action, { relative } = {}) {
|
|
1384
|
-
let { basename } = React2.useContext(
|
|
1385
|
-
let routeContext = React2.useContext(
|
|
1386
|
-
|
|
1497
|
+
let { basename } = React2.useContext(_chunk7B7CUJYEjs.NavigationContext);
|
|
1498
|
+
let routeContext = React2.useContext(_chunk7B7CUJYEjs.RouteContext);
|
|
1499
|
+
_chunk7B7CUJYEjs.invariant.call(void 0, routeContext, "useFormAction must be used inside a RouteContext");
|
|
1387
1500
|
let [match] = routeContext.matches.slice(-1);
|
|
1388
|
-
let path = { ...
|
|
1389
|
-
let location =
|
|
1501
|
+
let path = { ..._chunk7B7CUJYEjs.useResolvedPath.call(void 0, action ? action : ".", { relative }) };
|
|
1502
|
+
let location = _chunk7B7CUJYEjs.useLocation.call(void 0, );
|
|
1390
1503
|
if (action == null) {
|
|
1391
1504
|
path.search = location.search;
|
|
1392
1505
|
let params = new URLSearchParams(path.search);
|
|
@@ -1403,21 +1516,21 @@ function useFormAction(action, { relative } = {}) {
|
|
|
1403
1516
|
path.search = path.search ? path.search.replace(/^\?/, "?index&") : "?index";
|
|
1404
1517
|
}
|
|
1405
1518
|
if (basename !== "/") {
|
|
1406
|
-
path.pathname = path.pathname === "/" ? basename :
|
|
1519
|
+
path.pathname = path.pathname === "/" ? basename : _chunk7B7CUJYEjs.joinPaths.call(void 0, [basename, path.pathname]);
|
|
1407
1520
|
}
|
|
1408
|
-
return
|
|
1521
|
+
return _chunk7B7CUJYEjs.createPath.call(void 0, path);
|
|
1409
1522
|
}
|
|
1410
1523
|
function useFetcher({
|
|
1411
1524
|
key
|
|
1412
1525
|
} = {}) {
|
|
1413
1526
|
let { router } = useDataRouterContext("useFetcher" /* UseFetcher */);
|
|
1414
1527
|
let state = useDataRouterState("useFetcher" /* UseFetcher */);
|
|
1415
|
-
let fetcherData = React2.useContext(
|
|
1416
|
-
let route = React2.useContext(
|
|
1417
|
-
let routeId = _optionalChain([route, 'access',
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1528
|
+
let fetcherData = React2.useContext(_chunk7B7CUJYEjs.FetchersContext);
|
|
1529
|
+
let route = React2.useContext(_chunk7B7CUJYEjs.RouteContext);
|
|
1530
|
+
let routeId = _optionalChain([route, 'access', _42 => _42.matches, 'access', _43 => _43[route.matches.length - 1], 'optionalAccess', _44 => _44.route, 'access', _45 => _45.id]);
|
|
1531
|
+
_chunk7B7CUJYEjs.invariant.call(void 0, fetcherData, `useFetcher must be used inside a FetchersContext`);
|
|
1532
|
+
_chunk7B7CUJYEjs.invariant.call(void 0, route, `useFetcher must be used inside a RouteContext`);
|
|
1533
|
+
_chunk7B7CUJYEjs.invariant.call(void 0,
|
|
1421
1534
|
routeId != null,
|
|
1422
1535
|
`useFetcher can only be used on routes that contain a unique "id"`
|
|
1423
1536
|
);
|
|
@@ -1432,7 +1545,7 @@ function useFetcher({
|
|
|
1432
1545
|
}, [router, fetcherKey]);
|
|
1433
1546
|
let load = React2.useCallback(
|
|
1434
1547
|
async (href, opts) => {
|
|
1435
|
-
|
|
1548
|
+
_chunk7B7CUJYEjs.invariant.call(void 0, routeId, "No routeId available for fetcher.load()");
|
|
1436
1549
|
await router.fetch(fetcherKey, routeId, href, opts);
|
|
1437
1550
|
},
|
|
1438
1551
|
[fetcherKey, routeId, router]
|
|
@@ -1458,7 +1571,7 @@ function useFetcher({
|
|
|
1458
1571
|
FetcherForm2.displayName = "fetcher.Form";
|
|
1459
1572
|
return FetcherForm2;
|
|
1460
1573
|
}, [fetcherKey]);
|
|
1461
|
-
let fetcher = state.fetchers.get(fetcherKey) ||
|
|
1574
|
+
let fetcher = state.fetchers.get(fetcherKey) || _chunk7B7CUJYEjs.IDLE_FETCHER;
|
|
1462
1575
|
let data = fetcherData.get(fetcherKey);
|
|
1463
1576
|
let fetcherWithComponents = React2.useMemo(
|
|
1464
1577
|
() => ({
|
|
@@ -1489,7 +1602,7 @@ function getScrollRestorationKey(location, matches, basename, getKey) {
|
|
|
1489
1602
|
key = getKey(
|
|
1490
1603
|
{
|
|
1491
1604
|
...location,
|
|
1492
|
-
pathname:
|
|
1605
|
+
pathname: _chunk7B7CUJYEjs.stripBasename.call(void 0, location.pathname, basename) || location.pathname
|
|
1493
1606
|
},
|
|
1494
1607
|
matches
|
|
1495
1608
|
);
|
|
@@ -1510,10 +1623,10 @@ function useScrollRestoration({
|
|
|
1510
1623
|
let { restoreScrollPosition, preventScrollReset } = useDataRouterState(
|
|
1511
1624
|
"useScrollRestoration" /* UseScrollRestoration */
|
|
1512
1625
|
);
|
|
1513
|
-
let { basename } = React2.useContext(
|
|
1514
|
-
let location =
|
|
1515
|
-
let matches =
|
|
1516
|
-
let navigation =
|
|
1626
|
+
let { basename } = React2.useContext(_chunk7B7CUJYEjs.NavigationContext);
|
|
1627
|
+
let location = _chunk7B7CUJYEjs.useLocation.call(void 0, );
|
|
1628
|
+
let matches = _chunk7B7CUJYEjs.useMatches.call(void 0, );
|
|
1629
|
+
let navigation = _chunk7B7CUJYEjs.useNavigation.call(void 0, );
|
|
1517
1630
|
React2.useEffect(() => {
|
|
1518
1631
|
window.history.scrollRestoration = "manual";
|
|
1519
1632
|
return () => {
|
|
@@ -1532,7 +1645,7 @@ function useScrollRestoration({
|
|
|
1532
1645
|
JSON.stringify(savedScrollPositions)
|
|
1533
1646
|
);
|
|
1534
1647
|
} catch (error) {
|
|
1535
|
-
|
|
1648
|
+
_chunk7B7CUJYEjs.warning.call(void 0,
|
|
1536
1649
|
false,
|
|
1537
1650
|
`Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (${error}).`
|
|
1538
1651
|
);
|
|
@@ -1553,7 +1666,7 @@ function useScrollRestoration({
|
|
|
1553
1666
|
}
|
|
1554
1667
|
}, [storageKey]);
|
|
1555
1668
|
React2.useLayoutEffect(() => {
|
|
1556
|
-
let disableScrollRestoration = _optionalChain([router, 'optionalAccess',
|
|
1669
|
+
let disableScrollRestoration = _optionalChain([router, 'optionalAccess', _46 => _46.enableScrollRestoration, 'call', _47 => _47(
|
|
1557
1670
|
savedScrollPositions,
|
|
1558
1671
|
() => window.scrollY,
|
|
1559
1672
|
getKey ? (location2, matches2) => getScrollRestorationKey(location2, matches2, basename, getKey) : void 0
|
|
@@ -1579,7 +1692,7 @@ function useScrollRestoration({
|
|
|
1579
1692
|
}
|
|
1580
1693
|
}
|
|
1581
1694
|
} catch (e2) {
|
|
1582
|
-
|
|
1695
|
+
_chunk7B7CUJYEjs.warning.call(void 0,
|
|
1583
1696
|
false,
|
|
1584
1697
|
`"${location.hash.slice(
|
|
1585
1698
|
1
|
|
@@ -1617,7 +1730,7 @@ function usePrompt({
|
|
|
1617
1730
|
when,
|
|
1618
1731
|
message
|
|
1619
1732
|
}) {
|
|
1620
|
-
let blocker =
|
|
1733
|
+
let blocker = _chunk7B7CUJYEjs.useBlocker.call(void 0, when);
|
|
1621
1734
|
React2.useEffect(() => {
|
|
1622
1735
|
if (blocker.state === "blocked") {
|
|
1623
1736
|
let proceed = window.confirm(message);
|
|
@@ -1635,21 +1748,21 @@ function usePrompt({
|
|
|
1635
1748
|
}, [blocker, when]);
|
|
1636
1749
|
}
|
|
1637
1750
|
function useViewTransitionState(to, { relative } = {}) {
|
|
1638
|
-
let vtContext = React2.useContext(
|
|
1639
|
-
|
|
1751
|
+
let vtContext = React2.useContext(_chunk7B7CUJYEjs.ViewTransitionContext);
|
|
1752
|
+
_chunk7B7CUJYEjs.invariant.call(void 0,
|
|
1640
1753
|
vtContext != null,
|
|
1641
1754
|
"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?"
|
|
1642
1755
|
);
|
|
1643
1756
|
let { basename } = useDataRouterContext(
|
|
1644
1757
|
"useViewTransitionState" /* useViewTransitionState */
|
|
1645
1758
|
);
|
|
1646
|
-
let path =
|
|
1759
|
+
let path = _chunk7B7CUJYEjs.useResolvedPath.call(void 0, to, { relative });
|
|
1647
1760
|
if (!vtContext.isTransitioning) {
|
|
1648
1761
|
return false;
|
|
1649
1762
|
}
|
|
1650
|
-
let currentPath =
|
|
1651
|
-
let nextPath =
|
|
1652
|
-
return
|
|
1763
|
+
let currentPath = _chunk7B7CUJYEjs.stripBasename.call(void 0, vtContext.currentLocation.pathname, basename) || vtContext.currentLocation.pathname;
|
|
1764
|
+
let nextPath = _chunk7B7CUJYEjs.stripBasename.call(void 0, vtContext.nextLocation.pathname, basename) || vtContext.nextLocation.pathname;
|
|
1765
|
+
return _chunk7B7CUJYEjs.matchPath.call(void 0, path.pathname, nextPath) != null || _chunk7B7CUJYEjs.matchPath.call(void 0, path.pathname, currentPath) != null;
|
|
1653
1766
|
}
|
|
1654
1767
|
|
|
1655
1768
|
// lib/dom/server.tsx
|
|
@@ -1660,7 +1773,7 @@ function StaticRouter({
|
|
|
1660
1773
|
location: locationProp = "/"
|
|
1661
1774
|
}) {
|
|
1662
1775
|
if (typeof locationProp === "string") {
|
|
1663
|
-
locationProp =
|
|
1776
|
+
locationProp = _chunk7B7CUJYEjs.parsePath.call(void 0, locationProp);
|
|
1664
1777
|
}
|
|
1665
1778
|
let action = "POP" /* Pop */;
|
|
1666
1779
|
let location = {
|
|
@@ -1689,7 +1802,7 @@ function StaticRouterProvider({
|
|
|
1689
1802
|
hydrate = true,
|
|
1690
1803
|
nonce
|
|
1691
1804
|
}) {
|
|
1692
|
-
|
|
1805
|
+
_chunk7B7CUJYEjs.invariant.call(void 0,
|
|
1693
1806
|
router && context,
|
|
1694
1807
|
"You must provide `router` and `context` to <StaticRouterProvider>"
|
|
1695
1808
|
);
|
|
@@ -1712,7 +1825,7 @@ function StaticRouterProvider({
|
|
|
1712
1825
|
hydrateScript = `window.__staticRouterHydrationData = JSON.parse(${json});`;
|
|
1713
1826
|
}
|
|
1714
1827
|
let { state } = dataRouterContext.router;
|
|
1715
|
-
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(
|
|
1828
|
+
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(_chunk7B7CUJYEjs.DataRouterContext.Provider, { value: dataRouterContext }, /* @__PURE__ */ React3.createElement(_chunk7B7CUJYEjs.DataRouterStateContext.Provider, { value: state }, /* @__PURE__ */ React3.createElement(_chunk7B7CUJYEjs.FetchersContext.Provider, { value: fetchersContext }, /* @__PURE__ */ React3.createElement(_chunk7B7CUJYEjs.ViewTransitionContext.Provider, { value: { isTransitioning: false } }, /* @__PURE__ */ React3.createElement(
|
|
1716
1829
|
Router,
|
|
1717
1830
|
{
|
|
1718
1831
|
basename: dataRouterContext.basename,
|
|
@@ -1743,14 +1856,14 @@ function DataRoutes2({
|
|
|
1743
1856
|
future,
|
|
1744
1857
|
state
|
|
1745
1858
|
}) {
|
|
1746
|
-
return
|
|
1859
|
+
return _chunk7B7CUJYEjs.useRoutesImpl.call(void 0, routes, void 0, state, void 0, future);
|
|
1747
1860
|
}
|
|
1748
1861
|
function serializeErrors(errors) {
|
|
1749
1862
|
if (!errors) return null;
|
|
1750
1863
|
let entries = Object.entries(errors);
|
|
1751
1864
|
let serialized = {};
|
|
1752
1865
|
for (let [key, val] of entries) {
|
|
1753
|
-
if (
|
|
1866
|
+
if (_chunk7B7CUJYEjs.isRouteErrorResponse.call(void 0, val)) {
|
|
1754
1867
|
serialized[key] = { ...val, __type: "RouteErrorResponse" };
|
|
1755
1868
|
} else if (val instanceof Error) {
|
|
1756
1869
|
serialized[key] = {
|
|
@@ -1800,14 +1913,14 @@ function getStatelessNavigator() {
|
|
|
1800
1913
|
};
|
|
1801
1914
|
}
|
|
1802
1915
|
function createStaticHandler2(routes, opts) {
|
|
1803
|
-
return
|
|
1916
|
+
return _chunk7B7CUJYEjs.createStaticHandler.call(void 0, routes, {
|
|
1804
1917
|
...opts,
|
|
1805
1918
|
mapRouteProperties
|
|
1806
1919
|
});
|
|
1807
1920
|
}
|
|
1808
1921
|
function createStaticRouter(routes, context, opts = {}) {
|
|
1809
1922
|
let manifest = {};
|
|
1810
|
-
let dataRoutes =
|
|
1923
|
+
let dataRoutes = _chunk7B7CUJYEjs.convertRoutesToDataRoutes.call(void 0,
|
|
1811
1924
|
routes,
|
|
1812
1925
|
mapRouteProperties,
|
|
1813
1926
|
void 0,
|
|
@@ -1828,7 +1941,7 @@ function createStaticRouter(routes, context, opts = {}) {
|
|
|
1828
1941
|
get future() {
|
|
1829
1942
|
return {
|
|
1830
1943
|
v8_middleware: false,
|
|
1831
|
-
..._optionalChain([opts, 'optionalAccess',
|
|
1944
|
+
..._optionalChain([opts, 'optionalAccess', _48 => _48.future])
|
|
1832
1945
|
};
|
|
1833
1946
|
},
|
|
1834
1947
|
get state() {
|
|
@@ -1840,7 +1953,7 @@ function createStaticRouter(routes, context, opts = {}) {
|
|
|
1840
1953
|
actionData: context.actionData,
|
|
1841
1954
|
errors: context.errors,
|
|
1842
1955
|
initialized: true,
|
|
1843
|
-
navigation:
|
|
1956
|
+
navigation: _chunk7B7CUJYEjs.IDLE_NAVIGATION,
|
|
1844
1957
|
restoreScrollPosition: null,
|
|
1845
1958
|
preventScrollReset: false,
|
|
1846
1959
|
revalidation: "idle",
|
|
@@ -1875,7 +1988,7 @@ function createStaticRouter(routes, context, opts = {}) {
|
|
|
1875
1988
|
createHref,
|
|
1876
1989
|
encodeLocation,
|
|
1877
1990
|
getFetcher() {
|
|
1878
|
-
return
|
|
1991
|
+
return _chunk7B7CUJYEjs.IDLE_FETCHER;
|
|
1879
1992
|
},
|
|
1880
1993
|
deleteFetcher() {
|
|
1881
1994
|
throw msg("deleteFetcher");
|
|
@@ -1887,7 +2000,7 @@ function createStaticRouter(routes, context, opts = {}) {
|
|
|
1887
2000
|
throw msg("dispose");
|
|
1888
2001
|
},
|
|
1889
2002
|
getBlocker() {
|
|
1890
|
-
return
|
|
2003
|
+
return _chunk7B7CUJYEjs.IDLE_BLOCKER;
|
|
1891
2004
|
},
|
|
1892
2005
|
deleteBlocker() {
|
|
1893
2006
|
throw msg("deleteBlocker");
|
|
@@ -1905,10 +2018,10 @@ function createStaticRouter(routes, context, opts = {}) {
|
|
|
1905
2018
|
};
|
|
1906
2019
|
}
|
|
1907
2020
|
function createHref(to) {
|
|
1908
|
-
return typeof to === "string" ? to :
|
|
2021
|
+
return typeof to === "string" ? to : _chunk7B7CUJYEjs.createPath.call(void 0, to);
|
|
1909
2022
|
}
|
|
1910
2023
|
function encodeLocation(to) {
|
|
1911
|
-
let href = typeof to === "string" ? to :
|
|
2024
|
+
let href = typeof to === "string" ? to : _chunk7B7CUJYEjs.createPath.call(void 0, to);
|
|
1912
2025
|
href = href.replace(/ $/, "%20");
|
|
1913
2026
|
let encoded = ABSOLUTE_URL_REGEX2.test(href) ? new URL(href) : new URL(href, "http://localhost");
|
|
1914
2027
|
return {
|
|
@@ -1975,4 +2088,5 @@ function htmlEscape(str) {
|
|
|
1975
2088
|
|
|
1976
2089
|
|
|
1977
2090
|
|
|
1978
|
-
|
|
2091
|
+
|
|
2092
|
+
exports.mapRouteProperties = mapRouteProperties; exports.hydrationRouteProperties = hydrationRouteProperties; exports.createMemoryRouter = createMemoryRouter; exports.UNSTABLE_TransitionEnabledRouterProvider = UNSTABLE_TransitionEnabledRouterProvider; exports.RouterProvider = RouterProvider; exports.MemoryRouter = MemoryRouter; exports.Navigate = Navigate; exports.Outlet = Outlet; exports.Route = Route; exports.Router = Router; exports.Routes = Routes; exports.Await = Await; exports.createRoutesFromChildren = createRoutesFromChildren; exports.createRoutesFromElements = createRoutesFromElements; exports.renderMatches = renderMatches; exports.WithComponentProps = WithComponentProps; exports.withComponentProps = withComponentProps; exports.WithHydrateFallbackProps = WithHydrateFallbackProps; exports.withHydrateFallbackProps = withHydrateFallbackProps; exports.WithErrorBoundaryProps = WithErrorBoundaryProps; exports.withErrorBoundaryProps = withErrorBoundaryProps; exports.createSearchParams = createSearchParams; exports.createBrowserRouter = createBrowserRouter; exports.createHashRouter = createHashRouter; exports.BrowserRouter = BrowserRouter; exports.HashRouter = HashRouter; exports.HistoryRouter = HistoryRouter; exports.Link = Link; exports.NavLink = NavLink; exports.Form = Form; exports.ScrollRestoration = ScrollRestoration; exports.useLinkClickHandler = useLinkClickHandler; exports.useSearchParams = useSearchParams; exports.useSubmit = useSubmit; exports.useFormAction = useFormAction; exports.useFetcher = useFetcher; exports.useFetchers = useFetchers; exports.useScrollRestoration = useScrollRestoration; exports.useBeforeUnload = useBeforeUnload; exports.usePrompt = usePrompt; exports.useViewTransitionState = useViewTransitionState; exports.StaticRouter = StaticRouter; exports.StaticRouterProvider = StaticRouterProvider; exports.createStaticHandler = createStaticHandler2; exports.createStaticRouter = createStaticRouter;
|