react-router 7.18.5 → 7.18.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 +14 -0
- package/dist/{production/chunk-K3NA4NUH.js → development/chunk-3QTLHDUO.js} +7 -7
- package/dist/{production/chunk-IAM5GYT3.mjs → development/chunk-E2PF4K4Z.mjs} +14 -5
- package/dist/development/{chunk-NDF5KBLP.js → chunk-QM7ETCUK.js} +109 -104
- package/dist/development/{chunk-2ZBLYC7V.js → chunk-S47XUPN5.js} +105 -65
- package/dist/development/{chunk-6KYCQHYJ.mjs → chunk-YDNE64FV.mjs} +107 -63
- package/dist/development/dom-export.js +37 -35
- package/dist/development/dom-export.mjs +6 -4
- 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 +72 -3
- package/dist/development/index-react-server.mjs +72 -3
- package/dist/development/index.d.mts +1 -1
- package/dist/development/index.d.ts +1 -1
- package/dist/development/index.js +111 -102
- 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-75HN637G.js → chunk-2WUBOUFU.js} +109 -104
- package/dist/{development/chunk-IFHLIXZW.js → production/chunk-3IBQ4CTZ.js} +7 -7
- package/dist/production/{chunk-HNBICOIU.js → chunk-AC65NKOP.js} +105 -65
- package/dist/production/{chunk-7RTFRKQW.mjs → chunk-HEAXLYUI.mjs} +107 -63
- package/dist/{development/chunk-JAHXRPFV.mjs → production/chunk-JRCXCPLA.mjs} +14 -5
- package/dist/production/dom-export.js +37 -35
- package/dist/production/dom-export.mjs +6 -4
- 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 +72 -3
- package/dist/production/index-react-server.mjs +72 -3
- package/dist/production/index.d.mts +1 -1
- package/dist/production/index.d.ts +1 -1
- package/dist/production/index.js +111 -102
- 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
|
/**
|
|
2
|
-
* react-router v7.18.
|
|
2
|
+
* react-router v7.18.6
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
isSession,
|
|
28
28
|
routeRSCServerRequest,
|
|
29
29
|
setDevServerHooks
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-E2PF4K4Z.mjs";
|
|
31
31
|
import {
|
|
32
32
|
Action,
|
|
33
33
|
Await,
|
|
@@ -141,7 +141,7 @@ import {
|
|
|
141
141
|
withComponentProps,
|
|
142
142
|
withErrorBoundaryProps,
|
|
143
143
|
withHydrateFallbackProps
|
|
144
|
-
} from "./chunk-
|
|
144
|
+
} from "./chunk-YDNE64FV.mjs";
|
|
145
145
|
export {
|
|
146
146
|
Await,
|
|
147
147
|
BrowserRouter,
|
|
@@ -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 v7.18.
|
|
2
|
+
* react-router v7.18.6
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -53,7 +53,8 @@
|
|
|
53
53
|
|
|
54
54
|
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
|
|
57
|
+
var _chunkAC65NKOPjs = require('./chunk-AC65NKOP.js');
|
|
57
58
|
|
|
58
59
|
// lib/dom/dom.ts
|
|
59
60
|
var defaultMethod = "get";
|
|
@@ -124,7 +125,7 @@ var supportedFormEncTypes = /* @__PURE__ */ new Set([
|
|
|
124
125
|
]);
|
|
125
126
|
function getFormEncType(encType) {
|
|
126
127
|
if (encType != null && !supportedFormEncTypes.has(encType)) {
|
|
127
|
-
|
|
128
|
+
_chunkAC65NKOPjs.warning.call(void 0,
|
|
128
129
|
false,
|
|
129
130
|
`"${encType}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${defaultEncType}"`
|
|
130
131
|
);
|
|
@@ -140,7 +141,7 @@ function getFormSubmissionInfo(target, basename) {
|
|
|
140
141
|
let body;
|
|
141
142
|
if (isFormElement(target)) {
|
|
142
143
|
let attr = target.getAttribute("action");
|
|
143
|
-
action = attr ?
|
|
144
|
+
action = attr ? _chunkAC65NKOPjs.stripBasename.call(void 0, attr, basename) : null;
|
|
144
145
|
method = target.getAttribute("method") || defaultMethod;
|
|
145
146
|
encType = getFormEncType(target.getAttribute("enctype")) || defaultEncType;
|
|
146
147
|
formData = new FormData(target);
|
|
@@ -152,7 +153,7 @@ function getFormSubmissionInfo(target, basename) {
|
|
|
152
153
|
);
|
|
153
154
|
}
|
|
154
155
|
let attr = target.getAttribute("formaction") || form.getAttribute("action");
|
|
155
|
-
action = attr ?
|
|
156
|
+
action = attr ? _chunkAC65NKOPjs.stripBasename.call(void 0, attr, basename) : null;
|
|
156
157
|
method = target.getAttribute("formmethod") || form.getAttribute("method") || defaultMethod;
|
|
157
158
|
encType = getFormEncType(target.getAttribute("formenctype")) || getFormEncType(form.getAttribute("enctype")) || defaultEncType;
|
|
158
159
|
formData = new FormData(form, target);
|
|
@@ -189,20 +190,20 @@ var isBrowser = typeof window !== "undefined" && typeof window.document !== "und
|
|
|
189
190
|
try {
|
|
190
191
|
if (isBrowser) {
|
|
191
192
|
window.__reactRouterVersion = // @ts-expect-error
|
|
192
|
-
"7.18.
|
|
193
|
+
"7.18.6";
|
|
193
194
|
}
|
|
194
195
|
} catch (e) {
|
|
195
196
|
}
|
|
196
197
|
function createBrowserRouter(routes, opts) {
|
|
197
|
-
return
|
|
198
|
+
return _chunkAC65NKOPjs.createRouter.call(void 0, {
|
|
198
199
|
basename: _optionalChain([opts, 'optionalAccess', _2 => _2.basename]),
|
|
199
200
|
getContext: _optionalChain([opts, 'optionalAccess', _3 => _3.getContext]),
|
|
200
201
|
future: _optionalChain([opts, 'optionalAccess', _4 => _4.future]),
|
|
201
|
-
history:
|
|
202
|
+
history: _chunkAC65NKOPjs.createBrowserHistory.call(void 0, { window: _optionalChain([opts, 'optionalAccess', _5 => _5.window]) }),
|
|
202
203
|
hydrationData: _optionalChain([opts, 'optionalAccess', _6 => _6.hydrationData]) || parseHydrationData(),
|
|
203
204
|
routes,
|
|
204
|
-
mapRouteProperties:
|
|
205
|
-
hydrationRouteProperties:
|
|
205
|
+
mapRouteProperties: _chunkAC65NKOPjs.mapRouteProperties,
|
|
206
|
+
hydrationRouteProperties: _chunkAC65NKOPjs.hydrationRouteProperties,
|
|
206
207
|
dataStrategy: _optionalChain([opts, 'optionalAccess', _7 => _7.dataStrategy]),
|
|
207
208
|
patchRoutesOnNavigation: _optionalChain([opts, 'optionalAccess', _8 => _8.patchRoutesOnNavigation]),
|
|
208
209
|
window: _optionalChain([opts, 'optionalAccess', _9 => _9.window]),
|
|
@@ -210,15 +211,15 @@ function createBrowserRouter(routes, opts) {
|
|
|
210
211
|
}).initialize();
|
|
211
212
|
}
|
|
212
213
|
function createHashRouter(routes, opts) {
|
|
213
|
-
return
|
|
214
|
+
return _chunkAC65NKOPjs.createRouter.call(void 0, {
|
|
214
215
|
basename: _optionalChain([opts, 'optionalAccess', _11 => _11.basename]),
|
|
215
216
|
getContext: _optionalChain([opts, 'optionalAccess', _12 => _12.getContext]),
|
|
216
217
|
future: _optionalChain([opts, 'optionalAccess', _13 => _13.future]),
|
|
217
|
-
history:
|
|
218
|
+
history: _chunkAC65NKOPjs.createHashHistory.call(void 0, { window: _optionalChain([opts, 'optionalAccess', _14 => _14.window]) }),
|
|
218
219
|
hydrationData: _optionalChain([opts, 'optionalAccess', _15 => _15.hydrationData]) || parseHydrationData(),
|
|
219
220
|
routes,
|
|
220
|
-
mapRouteProperties:
|
|
221
|
-
hydrationRouteProperties:
|
|
221
|
+
mapRouteProperties: _chunkAC65NKOPjs.mapRouteProperties,
|
|
222
|
+
hydrationRouteProperties: _chunkAC65NKOPjs.hydrationRouteProperties,
|
|
222
223
|
dataStrategy: _optionalChain([opts, 'optionalAccess', _16 => _16.dataStrategy]),
|
|
223
224
|
patchRoutesOnNavigation: _optionalChain([opts, 'optionalAccess', _17 => _17.patchRoutesOnNavigation]),
|
|
224
225
|
window: _optionalChain([opts, 'optionalAccess', _18 => _18.window]),
|
|
@@ -241,14 +242,14 @@ function deserializeErrors(errors) {
|
|
|
241
242
|
let serialized = {};
|
|
242
243
|
for (let [key, val] of entries) {
|
|
243
244
|
if (val && val.__type === "RouteErrorResponse") {
|
|
244
|
-
serialized[key] = new (0,
|
|
245
|
+
serialized[key] = new (0, _chunkAC65NKOPjs.ErrorResponseImpl)(
|
|
245
246
|
val.status,
|
|
246
247
|
val.statusText,
|
|
247
248
|
val.data,
|
|
248
249
|
val.internal === true
|
|
249
250
|
);
|
|
250
251
|
} else if (val && val.__type === "Error") {
|
|
251
|
-
if (typeof val.__subType === "string" &&
|
|
252
|
+
if (typeof val.__subType === "string" && _chunkAC65NKOPjs.SUPPORTED_ERROR_TYPES.includes(val.__subType)) {
|
|
252
253
|
let ErrorConstructor = window[val.__subType];
|
|
253
254
|
if (typeof ErrorConstructor === "function") {
|
|
254
255
|
try {
|
|
@@ -278,7 +279,7 @@ function BrowserRouter({
|
|
|
278
279
|
}) {
|
|
279
280
|
let historyRef = React.useRef();
|
|
280
281
|
if (historyRef.current == null) {
|
|
281
|
-
historyRef.current =
|
|
282
|
+
historyRef.current = _chunkAC65NKOPjs.createBrowserHistory.call(void 0, { window: window2, v5Compat: true });
|
|
282
283
|
}
|
|
283
284
|
let history = historyRef.current;
|
|
284
285
|
let [state, setStateImpl] = React.useState({
|
|
@@ -297,7 +298,7 @@ function BrowserRouter({
|
|
|
297
298
|
);
|
|
298
299
|
React.useLayoutEffect(() => history.listen(setState), [history, setState]);
|
|
299
300
|
return /* @__PURE__ */ React.createElement(
|
|
300
|
-
|
|
301
|
+
_chunkAC65NKOPjs.Router,
|
|
301
302
|
{
|
|
302
303
|
basename,
|
|
303
304
|
children,
|
|
@@ -316,7 +317,7 @@ function HashRouter({
|
|
|
316
317
|
}) {
|
|
317
318
|
let historyRef = React.useRef();
|
|
318
319
|
if (historyRef.current == null) {
|
|
319
|
-
historyRef.current =
|
|
320
|
+
historyRef.current = _chunkAC65NKOPjs.createHashHistory.call(void 0, { window: window2, v5Compat: true });
|
|
320
321
|
}
|
|
321
322
|
let history = historyRef.current;
|
|
322
323
|
let [state, setStateImpl] = React.useState({
|
|
@@ -335,7 +336,7 @@ function HashRouter({
|
|
|
335
336
|
);
|
|
336
337
|
React.useLayoutEffect(() => history.listen(setState), [history, setState]);
|
|
337
338
|
return /* @__PURE__ */ React.createElement(
|
|
338
|
-
|
|
339
|
+
_chunkAC65NKOPjs.Router,
|
|
339
340
|
{
|
|
340
341
|
basename,
|
|
341
342
|
children,
|
|
@@ -368,7 +369,7 @@ function HistoryRouter({
|
|
|
368
369
|
);
|
|
369
370
|
React.useLayoutEffect(() => history.listen(setState), [history, setState]);
|
|
370
371
|
return /* @__PURE__ */ React.createElement(
|
|
371
|
-
|
|
372
|
+
_chunkAC65NKOPjs.Router,
|
|
372
373
|
{
|
|
373
374
|
basename,
|
|
374
375
|
children,
|
|
@@ -397,26 +398,26 @@ var Link = React.forwardRef(
|
|
|
397
398
|
defaultShouldRevalidate,
|
|
398
399
|
...rest
|
|
399
400
|
}, forwardedRef) {
|
|
400
|
-
let { basename, navigator, useTransitions } = React.useContext(
|
|
401
|
-
let isAbsolute = typeof to === "string" &&
|
|
402
|
-
let parsed =
|
|
401
|
+
let { basename, navigator, useTransitions } = React.useContext(_chunkAC65NKOPjs.NavigationContext);
|
|
402
|
+
let isAbsolute = typeof to === "string" && _chunkAC65NKOPjs.ABSOLUTE_URL_REGEX.test(to);
|
|
403
|
+
let parsed = _chunkAC65NKOPjs.parseToInfo.call(void 0, to, basename);
|
|
403
404
|
to = parsed.to;
|
|
404
|
-
let href =
|
|
405
|
-
let location =
|
|
405
|
+
let href = _chunkAC65NKOPjs.useHref.call(void 0, to, { relative });
|
|
406
|
+
let location = _chunkAC65NKOPjs.useLocation.call(void 0, );
|
|
406
407
|
let maskedHref = null;
|
|
407
408
|
if (mask) {
|
|
408
|
-
let resolved =
|
|
409
|
+
let resolved = _chunkAC65NKOPjs.resolveTo.call(void 0,
|
|
409
410
|
mask,
|
|
410
411
|
[],
|
|
411
412
|
location.mask ? location.mask.pathname : "/",
|
|
412
413
|
true
|
|
413
414
|
);
|
|
414
415
|
if (basename !== "/") {
|
|
415
|
-
resolved.pathname = resolved.pathname === "/" ? basename :
|
|
416
|
+
resolved.pathname = resolved.pathname === "/" ? basename : _chunkAC65NKOPjs.joinPaths.call(void 0, [basename, resolved.pathname]);
|
|
416
417
|
}
|
|
417
418
|
maskedHref = navigator.createHref(resolved);
|
|
418
419
|
}
|
|
419
|
-
let [shouldPrefetch, prefetchRef, prefetchHandlers] =
|
|
420
|
+
let [shouldPrefetch, prefetchRef, prefetchHandlers] = _chunkAC65NKOPjs.usePrefetchBehavior.call(void 0,
|
|
420
421
|
prefetch,
|
|
421
422
|
rest
|
|
422
423
|
);
|
|
@@ -438,6 +439,8 @@ var Link = React.forwardRef(
|
|
|
438
439
|
}
|
|
439
440
|
}
|
|
440
441
|
let isSpaLink = !(parsed.isExternal || reloadDocument);
|
|
442
|
+
let renderedHref = (isSpaLink ? maskedHref : void 0) || parsed.absoluteURL || href;
|
|
443
|
+
_chunkAC65NKOPjs.validateDocumentNavigationTarget.call(void 0, renderedHref);
|
|
441
444
|
let link = (
|
|
442
445
|
// eslint-disable-next-line jsx-a11y/anchor-has-content
|
|
443
446
|
/* @__PURE__ */ React.createElement(
|
|
@@ -445,15 +448,15 @@ var Link = React.forwardRef(
|
|
|
445
448
|
{
|
|
446
449
|
...rest,
|
|
447
450
|
...prefetchHandlers,
|
|
448
|
-
href:
|
|
451
|
+
href: renderedHref,
|
|
449
452
|
onClick: isSpaLink ? handleClick : onClick,
|
|
450
|
-
ref:
|
|
453
|
+
ref: _chunkAC65NKOPjs.mergeRefs.call(void 0, forwardedRef, prefetchRef),
|
|
451
454
|
target,
|
|
452
455
|
"data-discover": !isAbsolute && discover === "render" ? "true" : void 0
|
|
453
456
|
}
|
|
454
457
|
)
|
|
455
458
|
);
|
|
456
|
-
return shouldPrefetch && !isAbsolute ? /* @__PURE__ */ React.createElement(React.Fragment, null, link, /* @__PURE__ */ React.createElement(
|
|
459
|
+
return shouldPrefetch && !isAbsolute ? /* @__PURE__ */ React.createElement(React.Fragment, null, link, /* @__PURE__ */ React.createElement(_chunkAC65NKOPjs.PrefetchPageLinks, { page: href })) : link;
|
|
457
460
|
}
|
|
458
461
|
);
|
|
459
462
|
Link.displayName = "Link";
|
|
@@ -469,10 +472,10 @@ var NavLink = React.forwardRef(
|
|
|
469
472
|
children,
|
|
470
473
|
...rest
|
|
471
474
|
}, ref) {
|
|
472
|
-
let path =
|
|
473
|
-
let location =
|
|
474
|
-
let routerState = React.useContext(
|
|
475
|
-
let { navigator, basename } = React.useContext(
|
|
475
|
+
let path = _chunkAC65NKOPjs.useResolvedPath.call(void 0, to, { relative: rest.relative });
|
|
476
|
+
let location = _chunkAC65NKOPjs.useLocation.call(void 0, );
|
|
477
|
+
let routerState = React.useContext(_chunkAC65NKOPjs.DataRouterStateContext);
|
|
478
|
+
let { navigator, basename } = React.useContext(_chunkAC65NKOPjs.NavigationContext);
|
|
476
479
|
let isTransitioning = routerState != null && // Conditional usage is OK here because the usage of a data router is static
|
|
477
480
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
478
481
|
useViewTransitionState(path) && viewTransition === true;
|
|
@@ -485,7 +488,7 @@ var NavLink = React.forwardRef(
|
|
|
485
488
|
toPathname = toPathname.toLowerCase();
|
|
486
489
|
}
|
|
487
490
|
if (nextLocationPathname && basename) {
|
|
488
|
-
nextLocationPathname =
|
|
491
|
+
nextLocationPathname = _chunkAC65NKOPjs.stripBasename.call(void 0, nextLocationPathname, basename) || nextLocationPathname;
|
|
489
492
|
}
|
|
490
493
|
const endSlashPosition = toPathname !== "/" && toPathname.endsWith("/") ? toPathname.length - 1 : toPathname.length;
|
|
491
494
|
let isActive = locationPathname === toPathname || !end && locationPathname.startsWith(toPathname) && locationPathname.charAt(endSlashPosition) === "/";
|
|
@@ -541,11 +544,11 @@ var Form = React.forwardRef(
|
|
|
541
544
|
defaultShouldRevalidate,
|
|
542
545
|
...props
|
|
543
546
|
}, forwardedRef) => {
|
|
544
|
-
let { useTransitions } = React.useContext(
|
|
547
|
+
let { useTransitions } = React.useContext(_chunkAC65NKOPjs.NavigationContext);
|
|
545
548
|
let submit = useSubmit();
|
|
546
549
|
let formAction = useFormAction(action, { relative });
|
|
547
550
|
let formMethod = method.toLowerCase() === "get" ? "get" : "post";
|
|
548
|
-
let isAbsolute = typeof action === "string" &&
|
|
551
|
+
let isAbsolute = typeof action === "string" && _chunkAC65NKOPjs.ABSOLUTE_URL_REGEX.test(action);
|
|
549
552
|
let submitHandler = (event) => {
|
|
550
553
|
onSubmit && onSubmit(event);
|
|
551
554
|
if (event.defaultPrevented) return;
|
|
@@ -588,10 +591,10 @@ function ScrollRestoration({
|
|
|
588
591
|
storageKey,
|
|
589
592
|
...props
|
|
590
593
|
}) {
|
|
591
|
-
let remixContext = React.useContext(
|
|
592
|
-
let { basename } = React.useContext(
|
|
593
|
-
let location =
|
|
594
|
-
let matches =
|
|
594
|
+
let remixContext = React.useContext(_chunkAC65NKOPjs.FrameworkContext);
|
|
595
|
+
let { basename } = React.useContext(_chunkAC65NKOPjs.NavigationContext);
|
|
596
|
+
let location = _chunkAC65NKOPjs.useLocation.call(void 0, );
|
|
597
|
+
let matches = _chunkAC65NKOPjs.useMatches.call(void 0, );
|
|
595
598
|
useScrollRestoration({ getKey, storageKey });
|
|
596
599
|
let ssrKey = React.useMemo(
|
|
597
600
|
() => {
|
|
@@ -636,9 +639,9 @@ function ScrollRestoration({
|
|
|
636
639
|
...props,
|
|
637
640
|
suppressHydrationWarning: true,
|
|
638
641
|
dangerouslySetInnerHTML: {
|
|
639
|
-
__html: `(${restoreScroll})(${
|
|
642
|
+
__html: `(${restoreScroll})(${_chunkAC65NKOPjs.escapeHtml.call(void 0,
|
|
640
643
|
JSON.stringify(storageKey || SCROLL_RESTORATION_STORAGE_KEY)
|
|
641
|
-
)}, ${
|
|
644
|
+
)}, ${_chunkAC65NKOPjs.escapeHtml.call(void 0, JSON.stringify(ssrKey))})`
|
|
642
645
|
}
|
|
643
646
|
}
|
|
644
647
|
);
|
|
@@ -648,13 +651,13 @@ function getDataRouterConsoleError(hookName) {
|
|
|
648
651
|
return `${hookName} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`;
|
|
649
652
|
}
|
|
650
653
|
function useDataRouterContext(hookName) {
|
|
651
|
-
let ctx = React.useContext(
|
|
652
|
-
|
|
654
|
+
let ctx = React.useContext(_chunkAC65NKOPjs.DataRouterContext);
|
|
655
|
+
_chunkAC65NKOPjs.invariant.call(void 0, ctx, getDataRouterConsoleError(hookName));
|
|
653
656
|
return ctx;
|
|
654
657
|
}
|
|
655
658
|
function useDataRouterState(hookName) {
|
|
656
|
-
let state = React.useContext(
|
|
657
|
-
|
|
659
|
+
let state = React.useContext(_chunkAC65NKOPjs.DataRouterStateContext);
|
|
660
|
+
_chunkAC65NKOPjs.invariant.call(void 0, state, getDataRouterConsoleError(hookName));
|
|
658
661
|
return state;
|
|
659
662
|
}
|
|
660
663
|
function useLinkClickHandler(to, {
|
|
@@ -668,14 +671,14 @@ function useLinkClickHandler(to, {
|
|
|
668
671
|
defaultShouldRevalidate,
|
|
669
672
|
useTransitions
|
|
670
673
|
} = {}) {
|
|
671
|
-
let navigate =
|
|
672
|
-
let location =
|
|
673
|
-
let path =
|
|
674
|
+
let navigate = _chunkAC65NKOPjs.useNavigate.call(void 0, );
|
|
675
|
+
let location = _chunkAC65NKOPjs.useLocation.call(void 0, );
|
|
676
|
+
let path = _chunkAC65NKOPjs.useResolvedPath.call(void 0, to, { relative });
|
|
674
677
|
return React.useCallback(
|
|
675
678
|
(event) => {
|
|
676
679
|
if (shouldProcessLinkClick(event, target)) {
|
|
677
680
|
event.preventDefault();
|
|
678
|
-
let replace = replaceProp !== void 0 ? replaceProp :
|
|
681
|
+
let replace = replaceProp !== void 0 ? replaceProp : _chunkAC65NKOPjs.createPath.call(void 0, location) === _chunkAC65NKOPjs.createPath.call(void 0, path);
|
|
679
682
|
let doNavigate = () => navigate(to, {
|
|
680
683
|
replace,
|
|
681
684
|
mask,
|
|
@@ -710,13 +713,13 @@ function useLinkClickHandler(to, {
|
|
|
710
713
|
);
|
|
711
714
|
}
|
|
712
715
|
function useSearchParams(defaultInit) {
|
|
713
|
-
|
|
716
|
+
_chunkAC65NKOPjs.warning.call(void 0,
|
|
714
717
|
typeof URLSearchParams !== "undefined",
|
|
715
718
|
`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.`
|
|
716
719
|
);
|
|
717
720
|
let defaultSearchParamsRef = React.useRef(createSearchParams(defaultInit));
|
|
718
721
|
let hasSetSearchParamsRef = React.useRef(false);
|
|
719
|
-
let location =
|
|
722
|
+
let location = _chunkAC65NKOPjs.useLocation.call(void 0, );
|
|
720
723
|
let searchParams = React.useMemo(
|
|
721
724
|
() => (
|
|
722
725
|
// Only merge in the defaults if we haven't yet called setSearchParams.
|
|
@@ -729,7 +732,7 @@ function useSearchParams(defaultInit) {
|
|
|
729
732
|
),
|
|
730
733
|
[location.search]
|
|
731
734
|
);
|
|
732
|
-
let navigate =
|
|
735
|
+
let navigate = _chunkAC65NKOPjs.useNavigate.call(void 0, );
|
|
733
736
|
let setSearchParams = React.useCallback(
|
|
734
737
|
(nextInit, navigateOptions) => {
|
|
735
738
|
const newSearchParams = createSearchParams(
|
|
@@ -746,8 +749,8 @@ var fetcherId = 0;
|
|
|
746
749
|
var getUniqueFetcherId = () => `__${String(++fetcherId)}__`;
|
|
747
750
|
function useSubmit() {
|
|
748
751
|
let { router } = useDataRouterContext("useSubmit" /* UseSubmit */);
|
|
749
|
-
let { basename } = React.useContext(
|
|
750
|
-
let currentRouteId =
|
|
752
|
+
let { basename } = React.useContext(_chunkAC65NKOPjs.NavigationContext);
|
|
753
|
+
let currentRouteId = _chunkAC65NKOPjs.useRouteId.call(void 0, );
|
|
751
754
|
let routerFetch = router.fetch;
|
|
752
755
|
let routerNavigate = router.navigate;
|
|
753
756
|
return React.useCallback(
|
|
@@ -787,12 +790,12 @@ function useSubmit() {
|
|
|
787
790
|
);
|
|
788
791
|
}
|
|
789
792
|
function useFormAction(action, { relative } = {}) {
|
|
790
|
-
let { basename } = React.useContext(
|
|
791
|
-
let routeContext = React.useContext(
|
|
792
|
-
|
|
793
|
+
let { basename } = React.useContext(_chunkAC65NKOPjs.NavigationContext);
|
|
794
|
+
let routeContext = React.useContext(_chunkAC65NKOPjs.RouteContext);
|
|
795
|
+
_chunkAC65NKOPjs.invariant.call(void 0, routeContext, "useFormAction must be used inside a RouteContext");
|
|
793
796
|
let [match] = routeContext.matches.slice(-1);
|
|
794
|
-
let path = { ...
|
|
795
|
-
let location =
|
|
797
|
+
let path = { ..._chunkAC65NKOPjs.useResolvedPath.call(void 0, action ? action : ".", { relative }) };
|
|
798
|
+
let location = _chunkAC65NKOPjs.useLocation.call(void 0, );
|
|
796
799
|
if (action == null) {
|
|
797
800
|
path.search = location.search;
|
|
798
801
|
let params = new URLSearchParams(path.search);
|
|
@@ -809,21 +812,23 @@ function useFormAction(action, { relative } = {}) {
|
|
|
809
812
|
path.search = path.search ? path.search.replace(/^\?/, "?index&") : "?index";
|
|
810
813
|
}
|
|
811
814
|
if (basename !== "/") {
|
|
812
|
-
path.pathname = path.pathname === "/" ? basename :
|
|
815
|
+
path.pathname = path.pathname === "/" ? basename : _chunkAC65NKOPjs.joinPaths.call(void 0, [basename, path.pathname]);
|
|
813
816
|
}
|
|
814
|
-
|
|
817
|
+
let formAction = _chunkAC65NKOPjs.createPath.call(void 0, path);
|
|
818
|
+
_chunkAC65NKOPjs.validateDocumentNavigationTarget.call(void 0, formAction);
|
|
819
|
+
return formAction;
|
|
815
820
|
}
|
|
816
821
|
function useFetcher({
|
|
817
822
|
key
|
|
818
823
|
} = {}) {
|
|
819
824
|
let { router } = useDataRouterContext("useFetcher" /* UseFetcher */);
|
|
820
825
|
let state = useDataRouterState("useFetcher" /* UseFetcher */);
|
|
821
|
-
let fetcherData = React.useContext(
|
|
822
|
-
let route = React.useContext(
|
|
826
|
+
let fetcherData = React.useContext(_chunkAC65NKOPjs.FetchersContext);
|
|
827
|
+
let route = React.useContext(_chunkAC65NKOPjs.RouteContext);
|
|
823
828
|
let routeId = _optionalChain([route, 'access', _24 => _24.matches, 'access', _25 => _25[route.matches.length - 1], 'optionalAccess', _26 => _26.route, 'access', _27 => _27.id]);
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
829
|
+
_chunkAC65NKOPjs.invariant.call(void 0, fetcherData, `useFetcher must be used inside a FetchersContext`);
|
|
830
|
+
_chunkAC65NKOPjs.invariant.call(void 0, route, `useFetcher must be used inside a RouteContext`);
|
|
831
|
+
_chunkAC65NKOPjs.invariant.call(void 0,
|
|
827
832
|
routeId != null,
|
|
828
833
|
`useFetcher can only be used on routes that contain a unique "id"`
|
|
829
834
|
);
|
|
@@ -839,7 +844,7 @@ function useFetcher({
|
|
|
839
844
|
}, [deleteFetcher, getFetcher, fetcherKey]);
|
|
840
845
|
let load = React.useCallback(
|
|
841
846
|
async (href, opts) => {
|
|
842
|
-
|
|
847
|
+
_chunkAC65NKOPjs.invariant.call(void 0, routeId, "No routeId available for fetcher.load()");
|
|
843
848
|
await routerFetch(fetcherKey, routeId, href, opts);
|
|
844
849
|
},
|
|
845
850
|
[fetcherKey, routeId, routerFetch]
|
|
@@ -868,7 +873,7 @@ function useFetcher({
|
|
|
868
873
|
FetcherForm2.displayName = "fetcher.Form";
|
|
869
874
|
return FetcherForm2;
|
|
870
875
|
}, [fetcherKey]);
|
|
871
|
-
let fetcher = state.fetchers.get(fetcherKey) ||
|
|
876
|
+
let fetcher = state.fetchers.get(fetcherKey) || _chunkAC65NKOPjs.IDLE_FETCHER;
|
|
872
877
|
let data = fetcherData.get(fetcherKey);
|
|
873
878
|
let fetcherWithComponents = React.useMemo(
|
|
874
879
|
() => ({
|
|
@@ -902,7 +907,7 @@ function getScrollRestorationKey(location, matches, basename, getKey) {
|
|
|
902
907
|
key = getKey(
|
|
903
908
|
{
|
|
904
909
|
...location,
|
|
905
|
-
pathname:
|
|
910
|
+
pathname: _chunkAC65NKOPjs.stripBasename.call(void 0, location.pathname, basename) || location.pathname
|
|
906
911
|
},
|
|
907
912
|
matches
|
|
908
913
|
);
|
|
@@ -923,10 +928,10 @@ function useScrollRestoration({
|
|
|
923
928
|
let { restoreScrollPosition, preventScrollReset } = useDataRouterState(
|
|
924
929
|
"useScrollRestoration" /* UseScrollRestoration */
|
|
925
930
|
);
|
|
926
|
-
let { basename } = React.useContext(
|
|
927
|
-
let location =
|
|
928
|
-
let matches =
|
|
929
|
-
let navigation =
|
|
931
|
+
let { basename } = React.useContext(_chunkAC65NKOPjs.NavigationContext);
|
|
932
|
+
let location = _chunkAC65NKOPjs.useLocation.call(void 0, );
|
|
933
|
+
let matches = _chunkAC65NKOPjs.useMatches.call(void 0, );
|
|
934
|
+
let navigation = _chunkAC65NKOPjs.useNavigation.call(void 0, );
|
|
930
935
|
React.useEffect(() => {
|
|
931
936
|
window.history.scrollRestoration = "manual";
|
|
932
937
|
return () => {
|
|
@@ -945,7 +950,7 @@ function useScrollRestoration({
|
|
|
945
950
|
JSON.stringify(savedScrollPositions)
|
|
946
951
|
);
|
|
947
952
|
} catch (error) {
|
|
948
|
-
|
|
953
|
+
_chunkAC65NKOPjs.warning.call(void 0,
|
|
949
954
|
false,
|
|
950
955
|
`Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (${error}).`
|
|
951
956
|
);
|
|
@@ -992,7 +997,7 @@ function useScrollRestoration({
|
|
|
992
997
|
}
|
|
993
998
|
}
|
|
994
999
|
} catch (e2) {
|
|
995
|
-
|
|
1000
|
+
_chunkAC65NKOPjs.warning.call(void 0,
|
|
996
1001
|
false,
|
|
997
1002
|
`"${location.hash.slice(
|
|
998
1003
|
1
|
|
@@ -1030,7 +1035,7 @@ function usePrompt({
|
|
|
1030
1035
|
when,
|
|
1031
1036
|
message
|
|
1032
1037
|
}) {
|
|
1033
|
-
let blocker =
|
|
1038
|
+
let blocker = _chunkAC65NKOPjs.useBlocker.call(void 0, when);
|
|
1034
1039
|
React.useEffect(() => {
|
|
1035
1040
|
if (blocker.state === "blocked") {
|
|
1036
1041
|
let proceed = window.confirm(message);
|
|
@@ -1048,21 +1053,21 @@ function usePrompt({
|
|
|
1048
1053
|
}, [blocker, when]);
|
|
1049
1054
|
}
|
|
1050
1055
|
function useViewTransitionState(to, { relative } = {}) {
|
|
1051
|
-
let vtContext = React.useContext(
|
|
1052
|
-
|
|
1056
|
+
let vtContext = React.useContext(_chunkAC65NKOPjs.ViewTransitionContext);
|
|
1057
|
+
_chunkAC65NKOPjs.invariant.call(void 0,
|
|
1053
1058
|
vtContext != null,
|
|
1054
1059
|
"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?"
|
|
1055
1060
|
);
|
|
1056
1061
|
let { basename } = useDataRouterContext(
|
|
1057
1062
|
"useViewTransitionState" /* useViewTransitionState */
|
|
1058
1063
|
);
|
|
1059
|
-
let path =
|
|
1064
|
+
let path = _chunkAC65NKOPjs.useResolvedPath.call(void 0, to, { relative });
|
|
1060
1065
|
if (!vtContext.isTransitioning) {
|
|
1061
1066
|
return false;
|
|
1062
1067
|
}
|
|
1063
|
-
let currentPath =
|
|
1064
|
-
let nextPath =
|
|
1065
|
-
return
|
|
1068
|
+
let currentPath = _chunkAC65NKOPjs.stripBasename.call(void 0, vtContext.currentLocation.pathname, basename) || vtContext.currentLocation.pathname;
|
|
1069
|
+
let nextPath = _chunkAC65NKOPjs.stripBasename.call(void 0, vtContext.nextLocation.pathname, basename) || vtContext.nextLocation.pathname;
|
|
1070
|
+
return _chunkAC65NKOPjs.matchPath.call(void 0, path.pathname, nextPath) != null || _chunkAC65NKOPjs.matchPath.call(void 0, path.pathname, currentPath) != null;
|
|
1066
1071
|
}
|
|
1067
1072
|
|
|
1068
1073
|
// lib/dom/server.tsx
|
|
@@ -1073,7 +1078,7 @@ function StaticRouter({
|
|
|
1073
1078
|
location: locationProp = "/"
|
|
1074
1079
|
}) {
|
|
1075
1080
|
if (typeof locationProp === "string") {
|
|
1076
|
-
locationProp =
|
|
1081
|
+
locationProp = _chunkAC65NKOPjs.parsePath.call(void 0, locationProp);
|
|
1077
1082
|
}
|
|
1078
1083
|
let action = "POP" /* Pop */;
|
|
1079
1084
|
let location = {
|
|
@@ -1086,7 +1091,7 @@ function StaticRouter({
|
|
|
1086
1091
|
};
|
|
1087
1092
|
let staticNavigator = getStatelessNavigator();
|
|
1088
1093
|
return /* @__PURE__ */ React2.createElement(
|
|
1089
|
-
|
|
1094
|
+
_chunkAC65NKOPjs.Router,
|
|
1090
1095
|
{
|
|
1091
1096
|
basename,
|
|
1092
1097
|
children,
|
|
@@ -1104,7 +1109,7 @@ function StaticRouterProvider({
|
|
|
1104
1109
|
hydrate = true,
|
|
1105
1110
|
nonce
|
|
1106
1111
|
}) {
|
|
1107
|
-
|
|
1112
|
+
_chunkAC65NKOPjs.invariant.call(void 0,
|
|
1108
1113
|
router && context,
|
|
1109
1114
|
"You must provide `router` and `context` to <StaticRouterProvider>"
|
|
1110
1115
|
);
|
|
@@ -1123,12 +1128,12 @@ function StaticRouterProvider({
|
|
|
1123
1128
|
actionData: context.actionData,
|
|
1124
1129
|
errors: serializeErrors(context.errors)
|
|
1125
1130
|
};
|
|
1126
|
-
let json =
|
|
1131
|
+
let json = _chunkAC65NKOPjs.escapeHtml.call(void 0, JSON.stringify(JSON.stringify(data)));
|
|
1127
1132
|
hydrateScript = `window.__staticRouterHydrationData = JSON.parse(${json});`;
|
|
1128
1133
|
}
|
|
1129
1134
|
let { state } = dataRouterContext.router;
|
|
1130
|
-
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(
|
|
1131
|
-
|
|
1135
|
+
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(_chunkAC65NKOPjs.DataRouterContext.Provider, { value: dataRouterContext }, /* @__PURE__ */ React2.createElement(_chunkAC65NKOPjs.DataRouterStateContext.Provider, { value: state }, /* @__PURE__ */ React2.createElement(_chunkAC65NKOPjs.FetchersContext.Provider, { value: fetchersContext }, /* @__PURE__ */ React2.createElement(_chunkAC65NKOPjs.ViewTransitionContext.Provider, { value: { isTransitioning: false } }, /* @__PURE__ */ React2.createElement(
|
|
1136
|
+
_chunkAC65NKOPjs.Router,
|
|
1132
1137
|
{
|
|
1133
1138
|
basename: dataRouterContext.basename,
|
|
1134
1139
|
location: state.location,
|
|
@@ -1138,7 +1143,7 @@ function StaticRouterProvider({
|
|
|
1138
1143
|
useTransitions: false
|
|
1139
1144
|
},
|
|
1140
1145
|
/* @__PURE__ */ React2.createElement(
|
|
1141
|
-
|
|
1146
|
+
_chunkAC65NKOPjs.DataRoutes,
|
|
1142
1147
|
{
|
|
1143
1148
|
manifest: router.manifest,
|
|
1144
1149
|
routes: router.routes,
|
|
@@ -1161,7 +1166,7 @@ function serializeErrors(errors) {
|
|
|
1161
1166
|
let entries = Object.entries(errors);
|
|
1162
1167
|
let serialized = {};
|
|
1163
1168
|
for (let [key, val] of entries) {
|
|
1164
|
-
if (
|
|
1169
|
+
if (_chunkAC65NKOPjs.isRouteErrorResponse.call(void 0, val)) {
|
|
1165
1170
|
serialized[key] = { ...val, __type: "RouteErrorResponse" };
|
|
1166
1171
|
} else if (val instanceof Error) {
|
|
1167
1172
|
serialized[key] = {
|
|
@@ -1211,16 +1216,16 @@ function getStatelessNavigator() {
|
|
|
1211
1216
|
};
|
|
1212
1217
|
}
|
|
1213
1218
|
function createStaticHandler2(routes, opts) {
|
|
1214
|
-
return
|
|
1219
|
+
return _chunkAC65NKOPjs.createStaticHandler.call(void 0, routes, {
|
|
1215
1220
|
...opts,
|
|
1216
|
-
mapRouteProperties:
|
|
1221
|
+
mapRouteProperties: _chunkAC65NKOPjs.mapRouteProperties
|
|
1217
1222
|
});
|
|
1218
1223
|
}
|
|
1219
1224
|
function createStaticRouter(routes, context, opts = {}) {
|
|
1220
1225
|
let manifest = {};
|
|
1221
|
-
let dataRoutes =
|
|
1226
|
+
let dataRoutes = _chunkAC65NKOPjs.convertRoutesToDataRoutes.call(void 0,
|
|
1222
1227
|
routes,
|
|
1223
|
-
|
|
1228
|
+
_chunkAC65NKOPjs.mapRouteProperties,
|
|
1224
1229
|
void 0,
|
|
1225
1230
|
manifest
|
|
1226
1231
|
);
|
|
@@ -1254,7 +1259,7 @@ function createStaticRouter(routes, context, opts = {}) {
|
|
|
1254
1259
|
errors: context.errors,
|
|
1255
1260
|
initialized: true,
|
|
1256
1261
|
renderFallback: false,
|
|
1257
|
-
navigation:
|
|
1262
|
+
navigation: _chunkAC65NKOPjs.IDLE_NAVIGATION,
|
|
1258
1263
|
restoreScrollPosition: null,
|
|
1259
1264
|
preventScrollReset: false,
|
|
1260
1265
|
revalidation: "idle",
|
|
@@ -1295,7 +1300,7 @@ function createStaticRouter(routes, context, opts = {}) {
|
|
|
1295
1300
|
createHref,
|
|
1296
1301
|
encodeLocation,
|
|
1297
1302
|
getFetcher() {
|
|
1298
|
-
return
|
|
1303
|
+
return _chunkAC65NKOPjs.IDLE_FETCHER;
|
|
1299
1304
|
},
|
|
1300
1305
|
deleteFetcher() {
|
|
1301
1306
|
throw msg("deleteFetcher");
|
|
@@ -1307,7 +1312,7 @@ function createStaticRouter(routes, context, opts = {}) {
|
|
|
1307
1312
|
throw msg("dispose");
|
|
1308
1313
|
},
|
|
1309
1314
|
getBlocker() {
|
|
1310
|
-
return
|
|
1315
|
+
return _chunkAC65NKOPjs.IDLE_BLOCKER;
|
|
1311
1316
|
},
|
|
1312
1317
|
deleteBlocker() {
|
|
1313
1318
|
throw msg("deleteBlocker");
|
|
@@ -1325,12 +1330,12 @@ function createStaticRouter(routes, context, opts = {}) {
|
|
|
1325
1330
|
};
|
|
1326
1331
|
}
|
|
1327
1332
|
function createHref(to) {
|
|
1328
|
-
return typeof to === "string" ? to :
|
|
1333
|
+
return typeof to === "string" ? to : _chunkAC65NKOPjs.createPath.call(void 0, to);
|
|
1329
1334
|
}
|
|
1330
1335
|
function encodeLocation(to) {
|
|
1331
|
-
let href = typeof to === "string" ? to :
|
|
1336
|
+
let href = typeof to === "string" ? to : _chunkAC65NKOPjs.createPath.call(void 0, to);
|
|
1332
1337
|
href = href.replace(/ $/, "%20");
|
|
1333
|
-
let encoded =
|
|
1338
|
+
let encoded = _chunkAC65NKOPjs.ABSOLUTE_URL_REGEX.test(href) ? new URL(href) : new URL(href, "http://localhost");
|
|
1334
1339
|
return {
|
|
1335
1340
|
pathname: encoded.pathname,
|
|
1336
1341
|
search: encoded.search,
|