react-router 0.0.0-experimental-bfc808d6c → 0.0.0-experimental-3cde40396
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 +6 -0
- package/dist/development/{browser-C5z6FZmz.d.mts → browser-CEUcxl_U.d.mts} +3 -2
- package/dist/development/{browser-BpxEZgZC.d.ts → browser-G8W-FqRm.d.ts} +3 -2
- package/dist/development/{chunk-FMMLASRE.js → chunk-4DEXIV77.js} +97 -116
- package/dist/development/{chunk-TI7OZZDO.js → chunk-FOH5TLLB.js} +7 -7
- package/dist/{production/chunk-6FO4NWD5.mjs → development/chunk-GON545UX.mjs} +146 -36
- package/dist/development/{chunk-LAC6TU7N.js → chunk-KPWUG3WN.js} +168 -41
- package/dist/development/{chunk-ULP5ONEK.mjs → chunk-Q7OYBJ3O.mjs} +167 -61
- package/dist/development/dom-export.d.mts +1 -1
- package/dist/development/dom-export.d.ts +1 -1
- package/dist/development/dom-export.js +29 -30
- package/dist/development/dom-export.mjs +5 -6
- 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 +3 -2
- package/dist/development/index-react-server.d.ts +3 -2
- package/dist/development/index-react-server.js +49 -4
- package/dist/development/index-react-server.mjs +49 -4
- package/dist/development/index.d.mts +6 -3
- package/dist/development/index.d.ts +6 -3
- package/dist/development/index.js +219 -109
- 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/{browser-C5z6FZmz.d.mts → browser-CEUcxl_U.d.mts} +3 -2
- package/dist/production/{browser-BpxEZgZC.d.ts → browser-G8W-FqRm.d.ts} +3 -2
- package/dist/production/{chunk-UPSW6CVM.js → chunk-3OSNUNWR.js} +97 -116
- package/dist/{development/chunk-IQBGQZGG.mjs → production/chunk-5SH4UKJL.mjs} +146 -36
- package/dist/production/{chunk-4KIWW7RS.js → chunk-FR2NDPWQ.js} +7 -7
- package/dist/production/{chunk-IVXNSP6Y.js → chunk-OEZTISH7.js} +168 -41
- package/dist/production/{chunk-AT6RJ6WZ.mjs → chunk-UYLN26NU.mjs} +167 -61
- package/dist/production/dom-export.d.mts +1 -1
- package/dist/production/dom-export.d.ts +1 -1
- package/dist/production/dom-export.js +29 -30
- package/dist/production/dom-export.mjs +5 -6
- 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 +3 -2
- package/dist/production/index-react-server.d.ts +3 -2
- package/dist/production/index-react-server.js +49 -4
- package/dist/production/index-react-server.mjs +49 -4
- package/dist/production/index.d.mts +6 -3
- package/dist/production/index.d.ts +6 -3
- package/dist/production/index.js +219 -109
- 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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# `react-router`
|
|
2
2
|
|
|
3
|
+
## 7.10.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Update the `useOptimistic` stub we provide for React 18 users to use a stable setter function to avoid potential `useEffect` loops - specifically when using `<Link viewTransition>` ([#14628](https://github.com/remix-run/react-router/pull/14628))
|
|
8
|
+
|
|
3
9
|
## 7.10.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
|
@@ -93,7 +93,7 @@ type RSCMatch = {
|
|
|
93
93
|
};
|
|
94
94
|
type DecodeActionFunction = (formData: FormData) => Promise<() => Promise<unknown>>;
|
|
95
95
|
type DecodeFormStateFunction = (result: unknown, formData: FormData) => unknown;
|
|
96
|
-
type DecodeReplyFunction = (reply: FormData | string,
|
|
96
|
+
type DecodeReplyFunction = (reply: FormData | string, options: {
|
|
97
97
|
temporaryReferences: unknown;
|
|
98
98
|
}) => Promise<unknown[]>;
|
|
99
99
|
type LoadServerActionFunction = (id: string) => Promise<Function>;
|
|
@@ -178,7 +178,8 @@ declare function matchRSCServerRequest({ createTemporaryReferenceSet, basename,
|
|
|
178
178
|
onError?: (error: unknown) => void;
|
|
179
179
|
request: Request;
|
|
180
180
|
routes: RSCRouteConfigEntry[];
|
|
181
|
-
generateResponse: (match: RSCMatch, { temporaryReferences, }: {
|
|
181
|
+
generateResponse: (match: RSCMatch, { onError, temporaryReferences, }: {
|
|
182
|
+
onError(error: unknown): string | undefined;
|
|
182
183
|
temporaryReferences: unknown;
|
|
183
184
|
}) => Response;
|
|
184
185
|
}): Promise<Response>;
|
|
@@ -93,7 +93,7 @@ type RSCMatch = {
|
|
|
93
93
|
};
|
|
94
94
|
type DecodeActionFunction = (formData: FormData) => Promise<() => Promise<unknown>>;
|
|
95
95
|
type DecodeFormStateFunction = (result: unknown, formData: FormData) => unknown;
|
|
96
|
-
type DecodeReplyFunction = (reply: FormData | string,
|
|
96
|
+
type DecodeReplyFunction = (reply: FormData | string, options: {
|
|
97
97
|
temporaryReferences: unknown;
|
|
98
98
|
}) => Promise<unknown[]>;
|
|
99
99
|
type LoadServerActionFunction = (id: string) => Promise<Function>;
|
|
@@ -178,7 +178,8 @@ declare function matchRSCServerRequest({ createTemporaryReferenceSet, basename,
|
|
|
178
178
|
onError?: (error: unknown) => void;
|
|
179
179
|
request: Request;
|
|
180
180
|
routes: RSCRouteConfigEntry[];
|
|
181
|
-
generateResponse: (match: RSCMatch, { temporaryReferences, }: {
|
|
181
|
+
generateResponse: (match: RSCMatch, { onError, temporaryReferences, }: {
|
|
182
|
+
onError(error: unknown): string | undefined;
|
|
182
183
|
temporaryReferences: unknown;
|
|
183
184
|
}) => Response;
|
|
184
185
|
}): Promise<Response>;
|
|
@@ -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-3cde40396
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -48,7 +48,8 @@
|
|
|
48
48
|
|
|
49
49
|
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
|
|
52
|
+
var _chunkKPWUG3WNjs = require('./chunk-KPWUG3WN.js');
|
|
52
53
|
|
|
53
54
|
// lib/dom/dom.ts
|
|
54
55
|
var defaultMethod = "get";
|
|
@@ -119,7 +120,7 @@ var supportedFormEncTypes = /* @__PURE__ */ new Set([
|
|
|
119
120
|
]);
|
|
120
121
|
function getFormEncType(encType) {
|
|
121
122
|
if (encType != null && !supportedFormEncTypes.has(encType)) {
|
|
122
|
-
|
|
123
|
+
_chunkKPWUG3WNjs.warning.call(void 0,
|
|
123
124
|
false,
|
|
124
125
|
`"${encType}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${defaultEncType}"`
|
|
125
126
|
);
|
|
@@ -135,7 +136,7 @@ function getFormSubmissionInfo(target, basename) {
|
|
|
135
136
|
let body;
|
|
136
137
|
if (isFormElement(target)) {
|
|
137
138
|
let attr = target.getAttribute("action");
|
|
138
|
-
action = attr ?
|
|
139
|
+
action = attr ? _chunkKPWUG3WNjs.stripBasename.call(void 0, attr, basename) : null;
|
|
139
140
|
method = target.getAttribute("method") || defaultMethod;
|
|
140
141
|
encType = getFormEncType(target.getAttribute("enctype")) || defaultEncType;
|
|
141
142
|
formData = new FormData(target);
|
|
@@ -147,7 +148,7 @@ function getFormSubmissionInfo(target, basename) {
|
|
|
147
148
|
);
|
|
148
149
|
}
|
|
149
150
|
let attr = target.getAttribute("formaction") || form.getAttribute("action");
|
|
150
|
-
action = attr ?
|
|
151
|
+
action = attr ? _chunkKPWUG3WNjs.stripBasename.call(void 0, attr, basename) : null;
|
|
151
152
|
method = target.getAttribute("formmethod") || form.getAttribute("method") || defaultMethod;
|
|
152
153
|
encType = getFormEncType(target.getAttribute("formenctype")) || getFormEncType(form.getAttribute("enctype")) || defaultEncType;
|
|
153
154
|
formData = new FormData(form, target);
|
|
@@ -184,20 +185,20 @@ var isBrowser = typeof window !== "undefined" && typeof window.document !== "und
|
|
|
184
185
|
try {
|
|
185
186
|
if (isBrowser) {
|
|
186
187
|
window.__reactRouterVersion = // @ts-expect-error
|
|
187
|
-
"0.0.0-experimental-
|
|
188
|
+
"0.0.0-experimental-3cde40396";
|
|
188
189
|
}
|
|
189
190
|
} catch (e) {
|
|
190
191
|
}
|
|
191
192
|
function createBrowserRouter(routes, opts) {
|
|
192
|
-
return
|
|
193
|
+
return _chunkKPWUG3WNjs.createRouter.call(void 0, {
|
|
193
194
|
basename: _optionalChain([opts, 'optionalAccess', _2 => _2.basename]),
|
|
194
195
|
getContext: _optionalChain([opts, 'optionalAccess', _3 => _3.getContext]),
|
|
195
196
|
future: _optionalChain([opts, 'optionalAccess', _4 => _4.future]),
|
|
196
|
-
history:
|
|
197
|
+
history: _chunkKPWUG3WNjs.createBrowserHistory.call(void 0, { window: _optionalChain([opts, 'optionalAccess', _5 => _5.window]) }),
|
|
197
198
|
hydrationData: _optionalChain([opts, 'optionalAccess', _6 => _6.hydrationData]) || parseHydrationData(),
|
|
198
199
|
routes,
|
|
199
|
-
mapRouteProperties:
|
|
200
|
-
hydrationRouteProperties:
|
|
200
|
+
mapRouteProperties: _chunkKPWUG3WNjs.mapRouteProperties,
|
|
201
|
+
hydrationRouteProperties: _chunkKPWUG3WNjs.hydrationRouteProperties,
|
|
201
202
|
dataStrategy: _optionalChain([opts, 'optionalAccess', _7 => _7.dataStrategy]),
|
|
202
203
|
patchRoutesOnNavigation: _optionalChain([opts, 'optionalAccess', _8 => _8.patchRoutesOnNavigation]),
|
|
203
204
|
window: _optionalChain([opts, 'optionalAccess', _9 => _9.window]),
|
|
@@ -205,15 +206,15 @@ function createBrowserRouter(routes, opts) {
|
|
|
205
206
|
}).initialize();
|
|
206
207
|
}
|
|
207
208
|
function createHashRouter(routes, opts) {
|
|
208
|
-
return
|
|
209
|
+
return _chunkKPWUG3WNjs.createRouter.call(void 0, {
|
|
209
210
|
basename: _optionalChain([opts, 'optionalAccess', _11 => _11.basename]),
|
|
210
211
|
getContext: _optionalChain([opts, 'optionalAccess', _12 => _12.getContext]),
|
|
211
212
|
future: _optionalChain([opts, 'optionalAccess', _13 => _13.future]),
|
|
212
|
-
history:
|
|
213
|
+
history: _chunkKPWUG3WNjs.createHashHistory.call(void 0, { window: _optionalChain([opts, 'optionalAccess', _14 => _14.window]) }),
|
|
213
214
|
hydrationData: _optionalChain([opts, 'optionalAccess', _15 => _15.hydrationData]) || parseHydrationData(),
|
|
214
215
|
routes,
|
|
215
|
-
mapRouteProperties:
|
|
216
|
-
hydrationRouteProperties:
|
|
216
|
+
mapRouteProperties: _chunkKPWUG3WNjs.mapRouteProperties,
|
|
217
|
+
hydrationRouteProperties: _chunkKPWUG3WNjs.hydrationRouteProperties,
|
|
217
218
|
dataStrategy: _optionalChain([opts, 'optionalAccess', _16 => _16.dataStrategy]),
|
|
218
219
|
patchRoutesOnNavigation: _optionalChain([opts, 'optionalAccess', _17 => _17.patchRoutesOnNavigation]),
|
|
219
220
|
window: _optionalChain([opts, 'optionalAccess', _18 => _18.window]),
|
|
@@ -236,7 +237,7 @@ function deserializeErrors(errors) {
|
|
|
236
237
|
let serialized = {};
|
|
237
238
|
for (let [key, val] of entries) {
|
|
238
239
|
if (val && val.__type === "RouteErrorResponse") {
|
|
239
|
-
serialized[key] = new (0,
|
|
240
|
+
serialized[key] = new (0, _chunkKPWUG3WNjs.ErrorResponseImpl)(
|
|
240
241
|
val.status,
|
|
241
242
|
val.statusText,
|
|
242
243
|
val.data,
|
|
@@ -273,7 +274,7 @@ function BrowserRouter({
|
|
|
273
274
|
}) {
|
|
274
275
|
let historyRef = React.useRef();
|
|
275
276
|
if (historyRef.current == null) {
|
|
276
|
-
historyRef.current =
|
|
277
|
+
historyRef.current = _chunkKPWUG3WNjs.createBrowserHistory.call(void 0, { window: window2, v5Compat: true });
|
|
277
278
|
}
|
|
278
279
|
let history = historyRef.current;
|
|
279
280
|
let [state, setStateImpl] = React.useState({
|
|
@@ -292,7 +293,7 @@ function BrowserRouter({
|
|
|
292
293
|
);
|
|
293
294
|
React.useLayoutEffect(() => history.listen(setState), [history, setState]);
|
|
294
295
|
return /* @__PURE__ */ React.createElement(
|
|
295
|
-
|
|
296
|
+
_chunkKPWUG3WNjs.Router,
|
|
296
297
|
{
|
|
297
298
|
basename,
|
|
298
299
|
children,
|
|
@@ -311,7 +312,7 @@ function HashRouter({
|
|
|
311
312
|
}) {
|
|
312
313
|
let historyRef = React.useRef();
|
|
313
314
|
if (historyRef.current == null) {
|
|
314
|
-
historyRef.current =
|
|
315
|
+
historyRef.current = _chunkKPWUG3WNjs.createHashHistory.call(void 0, { window: window2, v5Compat: true });
|
|
315
316
|
}
|
|
316
317
|
let history = historyRef.current;
|
|
317
318
|
let [state, setStateImpl] = React.useState({
|
|
@@ -330,7 +331,7 @@ function HashRouter({
|
|
|
330
331
|
);
|
|
331
332
|
React.useLayoutEffect(() => history.listen(setState), [history, setState]);
|
|
332
333
|
return /* @__PURE__ */ React.createElement(
|
|
333
|
-
|
|
334
|
+
_chunkKPWUG3WNjs.Router,
|
|
334
335
|
{
|
|
335
336
|
basename,
|
|
336
337
|
children,
|
|
@@ -363,7 +364,7 @@ function HistoryRouter({
|
|
|
363
364
|
);
|
|
364
365
|
React.useLayoutEffect(() => history.listen(setState), [history, setState]);
|
|
365
366
|
return /* @__PURE__ */ React.createElement(
|
|
366
|
-
|
|
367
|
+
_chunkKPWUG3WNjs.Router,
|
|
367
368
|
{
|
|
368
369
|
basename,
|
|
369
370
|
children,
|
|
@@ -391,32 +392,12 @@ var Link = React.forwardRef(
|
|
|
391
392
|
viewTransition,
|
|
392
393
|
...rest
|
|
393
394
|
}, forwardedRef) {
|
|
394
|
-
let { basename, unstable_useTransitions } = React.useContext(
|
|
395
|
+
let { basename, unstable_useTransitions } = React.useContext(_chunkKPWUG3WNjs.NavigationContext);
|
|
395
396
|
let isAbsolute = typeof to === "string" && ABSOLUTE_URL_REGEX.test(to);
|
|
396
|
-
let
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
if (isBrowser) {
|
|
401
|
-
try {
|
|
402
|
-
let currentUrl = new URL(window.location.href);
|
|
403
|
-
let targetUrl = to.startsWith("//") ? new URL(currentUrl.protocol + to) : new URL(to);
|
|
404
|
-
let path = _chunkLAC6TU7Njs.stripBasename.call(void 0, targetUrl.pathname, basename);
|
|
405
|
-
if (targetUrl.origin === currentUrl.origin && path != null) {
|
|
406
|
-
to = path + targetUrl.search + targetUrl.hash;
|
|
407
|
-
} else {
|
|
408
|
-
isExternal = true;
|
|
409
|
-
}
|
|
410
|
-
} catch (e) {
|
|
411
|
-
_chunkLAC6TU7Njs.warning.call(void 0,
|
|
412
|
-
false,
|
|
413
|
-
`<Link to="${to}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`
|
|
414
|
-
);
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
let href = _chunkLAC6TU7Njs.useHref.call(void 0, to, { relative });
|
|
419
|
-
let [shouldPrefetch, prefetchRef, prefetchHandlers] = _chunkLAC6TU7Njs.usePrefetchBehavior.call(void 0,
|
|
397
|
+
let parsed = _chunkKPWUG3WNjs.parseToInfo.call(void 0, to, basename);
|
|
398
|
+
to = parsed.to;
|
|
399
|
+
let href = _chunkKPWUG3WNjs.useHref.call(void 0, to, { relative });
|
|
400
|
+
let [shouldPrefetch, prefetchRef, prefetchHandlers] = _chunkKPWUG3WNjs.usePrefetchBehavior.call(void 0,
|
|
420
401
|
prefetch,
|
|
421
402
|
rest
|
|
422
403
|
);
|
|
@@ -442,15 +423,15 @@ var Link = React.forwardRef(
|
|
|
442
423
|
{
|
|
443
424
|
...rest,
|
|
444
425
|
...prefetchHandlers,
|
|
445
|
-
href:
|
|
446
|
-
onClick: isExternal || reloadDocument ? onClick : handleClick,
|
|
447
|
-
ref:
|
|
426
|
+
href: parsed.absoluteURL || href,
|
|
427
|
+
onClick: parsed.isExternal || reloadDocument ? onClick : handleClick,
|
|
428
|
+
ref: _chunkKPWUG3WNjs.mergeRefs.call(void 0, forwardedRef, prefetchRef),
|
|
448
429
|
target,
|
|
449
430
|
"data-discover": !isAbsolute && discover === "render" ? "true" : void 0
|
|
450
431
|
}
|
|
451
432
|
)
|
|
452
433
|
);
|
|
453
|
-
return shouldPrefetch && !isAbsolute ? /* @__PURE__ */ React.createElement(React.Fragment, null, link, /* @__PURE__ */ React.createElement(
|
|
434
|
+
return shouldPrefetch && !isAbsolute ? /* @__PURE__ */ React.createElement(React.Fragment, null, link, /* @__PURE__ */ React.createElement(_chunkKPWUG3WNjs.PrefetchPageLinks, { page: href })) : link;
|
|
454
435
|
}
|
|
455
436
|
);
|
|
456
437
|
Link.displayName = "Link";
|
|
@@ -466,10 +447,10 @@ var NavLink = React.forwardRef(
|
|
|
466
447
|
children,
|
|
467
448
|
...rest
|
|
468
449
|
}, ref) {
|
|
469
|
-
let path =
|
|
470
|
-
let location =
|
|
471
|
-
let routerState = React.useContext(
|
|
472
|
-
let { navigator, basename } = React.useContext(
|
|
450
|
+
let path = _chunkKPWUG3WNjs.useResolvedPath.call(void 0, to, { relative: rest.relative });
|
|
451
|
+
let location = _chunkKPWUG3WNjs.useLocation.call(void 0, );
|
|
452
|
+
let routerState = React.useContext(_chunkKPWUG3WNjs.DataRouterStateContext);
|
|
453
|
+
let { navigator, basename } = React.useContext(_chunkKPWUG3WNjs.NavigationContext);
|
|
473
454
|
let isTransitioning = routerState != null && // Conditional usage is OK here because the usage of a data router is static
|
|
474
455
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
475
456
|
useViewTransitionState(path) && viewTransition === true;
|
|
@@ -482,7 +463,7 @@ var NavLink = React.forwardRef(
|
|
|
482
463
|
toPathname = toPathname.toLowerCase();
|
|
483
464
|
}
|
|
484
465
|
if (nextLocationPathname && basename) {
|
|
485
|
-
nextLocationPathname =
|
|
466
|
+
nextLocationPathname = _chunkKPWUG3WNjs.stripBasename.call(void 0, nextLocationPathname, basename) || nextLocationPathname;
|
|
486
467
|
}
|
|
487
468
|
const endSlashPosition = toPathname !== "/" && toPathname.endsWith("/") ? toPathname.length - 1 : toPathname.length;
|
|
488
469
|
let isActive = locationPathname === toPathname || !end && locationPathname.startsWith(toPathname) && locationPathname.charAt(endSlashPosition) === "/";
|
|
@@ -537,7 +518,7 @@ var Form = React.forwardRef(
|
|
|
537
518
|
viewTransition,
|
|
538
519
|
...props
|
|
539
520
|
}, forwardedRef) => {
|
|
540
|
-
let { unstable_useTransitions } = React.useContext(
|
|
521
|
+
let { unstable_useTransitions } = React.useContext(_chunkKPWUG3WNjs.NavigationContext);
|
|
541
522
|
let submit = useSubmit();
|
|
542
523
|
let formAction = useFormAction(action, { relative });
|
|
543
524
|
let formMethod = method.toLowerCase() === "get" ? "get" : "post";
|
|
@@ -583,10 +564,10 @@ function ScrollRestoration({
|
|
|
583
564
|
storageKey,
|
|
584
565
|
...props
|
|
585
566
|
}) {
|
|
586
|
-
let remixContext = React.useContext(
|
|
587
|
-
let { basename } = React.useContext(
|
|
588
|
-
let location =
|
|
589
|
-
let matches =
|
|
567
|
+
let remixContext = React.useContext(_chunkKPWUG3WNjs.FrameworkContext);
|
|
568
|
+
let { basename } = React.useContext(_chunkKPWUG3WNjs.NavigationContext);
|
|
569
|
+
let location = _chunkKPWUG3WNjs.useLocation.call(void 0, );
|
|
570
|
+
let matches = _chunkKPWUG3WNjs.useMatches.call(void 0, );
|
|
590
571
|
useScrollRestoration({ getKey, storageKey });
|
|
591
572
|
let ssrKey = React.useMemo(
|
|
592
573
|
() => {
|
|
@@ -640,13 +621,13 @@ function getDataRouterConsoleError(hookName) {
|
|
|
640
621
|
return `${hookName} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`;
|
|
641
622
|
}
|
|
642
623
|
function useDataRouterContext(hookName) {
|
|
643
|
-
let ctx = React.useContext(
|
|
644
|
-
|
|
624
|
+
let ctx = React.useContext(_chunkKPWUG3WNjs.DataRouterContext);
|
|
625
|
+
_chunkKPWUG3WNjs.invariant.call(void 0, ctx, getDataRouterConsoleError(hookName));
|
|
645
626
|
return ctx;
|
|
646
627
|
}
|
|
647
628
|
function useDataRouterState(hookName) {
|
|
648
|
-
let state = React.useContext(
|
|
649
|
-
|
|
629
|
+
let state = React.useContext(_chunkKPWUG3WNjs.DataRouterStateContext);
|
|
630
|
+
_chunkKPWUG3WNjs.invariant.call(void 0, state, getDataRouterConsoleError(hookName));
|
|
650
631
|
return state;
|
|
651
632
|
}
|
|
652
633
|
function useLinkClickHandler(to, {
|
|
@@ -658,14 +639,14 @@ function useLinkClickHandler(to, {
|
|
|
658
639
|
viewTransition,
|
|
659
640
|
unstable_useTransitions
|
|
660
641
|
} = {}) {
|
|
661
|
-
let navigate =
|
|
662
|
-
let location =
|
|
663
|
-
let path =
|
|
642
|
+
let navigate = _chunkKPWUG3WNjs.useNavigate.call(void 0, );
|
|
643
|
+
let location = _chunkKPWUG3WNjs.useLocation.call(void 0, );
|
|
644
|
+
let path = _chunkKPWUG3WNjs.useResolvedPath.call(void 0, to, { relative });
|
|
664
645
|
return React.useCallback(
|
|
665
646
|
(event) => {
|
|
666
647
|
if (shouldProcessLinkClick(event, target)) {
|
|
667
648
|
event.preventDefault();
|
|
668
|
-
let replace = replaceProp !== void 0 ? replaceProp :
|
|
649
|
+
let replace = replaceProp !== void 0 ? replaceProp : _chunkKPWUG3WNjs.createPath.call(void 0, location) === _chunkKPWUG3WNjs.createPath.call(void 0, path);
|
|
669
650
|
let doNavigate = () => navigate(to, {
|
|
670
651
|
replace,
|
|
671
652
|
state,
|
|
@@ -696,13 +677,13 @@ function useLinkClickHandler(to, {
|
|
|
696
677
|
);
|
|
697
678
|
}
|
|
698
679
|
function useSearchParams(defaultInit) {
|
|
699
|
-
|
|
680
|
+
_chunkKPWUG3WNjs.warning.call(void 0,
|
|
700
681
|
typeof URLSearchParams !== "undefined",
|
|
701
682
|
`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.`
|
|
702
683
|
);
|
|
703
684
|
let defaultSearchParamsRef = React.useRef(createSearchParams(defaultInit));
|
|
704
685
|
let hasSetSearchParamsRef = React.useRef(false);
|
|
705
|
-
let location =
|
|
686
|
+
let location = _chunkKPWUG3WNjs.useLocation.call(void 0, );
|
|
706
687
|
let searchParams = React.useMemo(
|
|
707
688
|
() => (
|
|
708
689
|
// Only merge in the defaults if we haven't yet called setSearchParams.
|
|
@@ -715,7 +696,7 @@ function useSearchParams(defaultInit) {
|
|
|
715
696
|
),
|
|
716
697
|
[location.search]
|
|
717
698
|
);
|
|
718
|
-
let navigate =
|
|
699
|
+
let navigate = _chunkKPWUG3WNjs.useNavigate.call(void 0, );
|
|
719
700
|
let setSearchParams = React.useCallback(
|
|
720
701
|
(nextInit, navigateOptions) => {
|
|
721
702
|
const newSearchParams = createSearchParams(
|
|
@@ -732,8 +713,8 @@ var fetcherId = 0;
|
|
|
732
713
|
var getUniqueFetcherId = () => `__${String(++fetcherId)}__`;
|
|
733
714
|
function useSubmit() {
|
|
734
715
|
let { router } = useDataRouterContext("useSubmit" /* UseSubmit */);
|
|
735
|
-
let { basename } = React.useContext(
|
|
736
|
-
let currentRouteId =
|
|
716
|
+
let { basename } = React.useContext(_chunkKPWUG3WNjs.NavigationContext);
|
|
717
|
+
let currentRouteId = _chunkKPWUG3WNjs.useRouteId.call(void 0, );
|
|
737
718
|
let routerFetch = router.fetch;
|
|
738
719
|
let routerNavigate = router.navigate;
|
|
739
720
|
return React.useCallback(
|
|
@@ -771,12 +752,12 @@ function useSubmit() {
|
|
|
771
752
|
);
|
|
772
753
|
}
|
|
773
754
|
function useFormAction(action, { relative } = {}) {
|
|
774
|
-
let { basename } = React.useContext(
|
|
775
|
-
let routeContext = React.useContext(
|
|
776
|
-
|
|
755
|
+
let { basename } = React.useContext(_chunkKPWUG3WNjs.NavigationContext);
|
|
756
|
+
let routeContext = React.useContext(_chunkKPWUG3WNjs.RouteContext);
|
|
757
|
+
_chunkKPWUG3WNjs.invariant.call(void 0, routeContext, "useFormAction must be used inside a RouteContext");
|
|
777
758
|
let [match] = routeContext.matches.slice(-1);
|
|
778
|
-
let path = { ...
|
|
779
|
-
let location =
|
|
759
|
+
let path = { ..._chunkKPWUG3WNjs.useResolvedPath.call(void 0, action ? action : ".", { relative }) };
|
|
760
|
+
let location = _chunkKPWUG3WNjs.useLocation.call(void 0, );
|
|
780
761
|
if (action == null) {
|
|
781
762
|
path.search = location.search;
|
|
782
763
|
let params = new URLSearchParams(path.search);
|
|
@@ -793,21 +774,21 @@ function useFormAction(action, { relative } = {}) {
|
|
|
793
774
|
path.search = path.search ? path.search.replace(/^\?/, "?index&") : "?index";
|
|
794
775
|
}
|
|
795
776
|
if (basename !== "/") {
|
|
796
|
-
path.pathname = path.pathname === "/" ? basename :
|
|
777
|
+
path.pathname = path.pathname === "/" ? basename : _chunkKPWUG3WNjs.joinPaths.call(void 0, [basename, path.pathname]);
|
|
797
778
|
}
|
|
798
|
-
return
|
|
779
|
+
return _chunkKPWUG3WNjs.createPath.call(void 0, path);
|
|
799
780
|
}
|
|
800
781
|
function useFetcher({
|
|
801
782
|
key
|
|
802
783
|
} = {}) {
|
|
803
784
|
let { router } = useDataRouterContext("useFetcher" /* UseFetcher */);
|
|
804
785
|
let state = useDataRouterState("useFetcher" /* UseFetcher */);
|
|
805
|
-
let fetcherData = React.useContext(
|
|
806
|
-
let route = React.useContext(
|
|
786
|
+
let fetcherData = React.useContext(_chunkKPWUG3WNjs.FetchersContext);
|
|
787
|
+
let route = React.useContext(_chunkKPWUG3WNjs.RouteContext);
|
|
807
788
|
let routeId = _optionalChain([route, 'access', _23 => _23.matches, 'access', _24 => _24[route.matches.length - 1], 'optionalAccess', _25 => _25.route, 'access', _26 => _26.id]);
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
789
|
+
_chunkKPWUG3WNjs.invariant.call(void 0, fetcherData, `useFetcher must be used inside a FetchersContext`);
|
|
790
|
+
_chunkKPWUG3WNjs.invariant.call(void 0, route, `useFetcher must be used inside a RouteContext`);
|
|
791
|
+
_chunkKPWUG3WNjs.invariant.call(void 0,
|
|
811
792
|
routeId != null,
|
|
812
793
|
`useFetcher can only be used on routes that contain a unique "id"`
|
|
813
794
|
);
|
|
@@ -823,7 +804,7 @@ function useFetcher({
|
|
|
823
804
|
}, [deleteFetcher, getFetcher, fetcherKey]);
|
|
824
805
|
let load = React.useCallback(
|
|
825
806
|
async (href, opts) => {
|
|
826
|
-
|
|
807
|
+
_chunkKPWUG3WNjs.invariant.call(void 0, routeId, "No routeId available for fetcher.load()");
|
|
827
808
|
await routerFetch(fetcherKey, routeId, href, opts);
|
|
828
809
|
},
|
|
829
810
|
[fetcherKey, routeId, routerFetch]
|
|
@@ -852,7 +833,7 @@ function useFetcher({
|
|
|
852
833
|
FetcherForm2.displayName = "fetcher.Form";
|
|
853
834
|
return FetcherForm2;
|
|
854
835
|
}, [fetcherKey]);
|
|
855
|
-
let fetcher = state.fetchers.get(fetcherKey) ||
|
|
836
|
+
let fetcher = state.fetchers.get(fetcherKey) || _chunkKPWUG3WNjs.IDLE_FETCHER;
|
|
856
837
|
let data = fetcherData.get(fetcherKey);
|
|
857
838
|
let fetcherWithComponents = React.useMemo(
|
|
858
839
|
() => ({
|
|
@@ -883,7 +864,7 @@ function getScrollRestorationKey(location, matches, basename, getKey) {
|
|
|
883
864
|
key = getKey(
|
|
884
865
|
{
|
|
885
866
|
...location,
|
|
886
|
-
pathname:
|
|
867
|
+
pathname: _chunkKPWUG3WNjs.stripBasename.call(void 0, location.pathname, basename) || location.pathname
|
|
887
868
|
},
|
|
888
869
|
matches
|
|
889
870
|
);
|
|
@@ -904,10 +885,10 @@ function useScrollRestoration({
|
|
|
904
885
|
let { restoreScrollPosition, preventScrollReset } = useDataRouterState(
|
|
905
886
|
"useScrollRestoration" /* UseScrollRestoration */
|
|
906
887
|
);
|
|
907
|
-
let { basename } = React.useContext(
|
|
908
|
-
let location =
|
|
909
|
-
let matches =
|
|
910
|
-
let navigation =
|
|
888
|
+
let { basename } = React.useContext(_chunkKPWUG3WNjs.NavigationContext);
|
|
889
|
+
let location = _chunkKPWUG3WNjs.useLocation.call(void 0, );
|
|
890
|
+
let matches = _chunkKPWUG3WNjs.useMatches.call(void 0, );
|
|
891
|
+
let navigation = _chunkKPWUG3WNjs.useNavigation.call(void 0, );
|
|
911
892
|
React.useEffect(() => {
|
|
912
893
|
window.history.scrollRestoration = "manual";
|
|
913
894
|
return () => {
|
|
@@ -926,7 +907,7 @@ function useScrollRestoration({
|
|
|
926
907
|
JSON.stringify(savedScrollPositions)
|
|
927
908
|
);
|
|
928
909
|
} catch (error) {
|
|
929
|
-
|
|
910
|
+
_chunkKPWUG3WNjs.warning.call(void 0,
|
|
930
911
|
false,
|
|
931
912
|
`Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (${error}).`
|
|
932
913
|
);
|
|
@@ -973,7 +954,7 @@ function useScrollRestoration({
|
|
|
973
954
|
}
|
|
974
955
|
}
|
|
975
956
|
} catch (e2) {
|
|
976
|
-
|
|
957
|
+
_chunkKPWUG3WNjs.warning.call(void 0,
|
|
977
958
|
false,
|
|
978
959
|
`"${location.hash.slice(
|
|
979
960
|
1
|
|
@@ -1011,7 +992,7 @@ function usePrompt({
|
|
|
1011
992
|
when,
|
|
1012
993
|
message
|
|
1013
994
|
}) {
|
|
1014
|
-
let blocker =
|
|
995
|
+
let blocker = _chunkKPWUG3WNjs.useBlocker.call(void 0, when);
|
|
1015
996
|
React.useEffect(() => {
|
|
1016
997
|
if (blocker.state === "blocked") {
|
|
1017
998
|
let proceed = window.confirm(message);
|
|
@@ -1029,21 +1010,21 @@ function usePrompt({
|
|
|
1029
1010
|
}, [blocker, when]);
|
|
1030
1011
|
}
|
|
1031
1012
|
function useViewTransitionState(to, { relative } = {}) {
|
|
1032
|
-
let vtContext = React.useContext(
|
|
1033
|
-
|
|
1013
|
+
let vtContext = React.useContext(_chunkKPWUG3WNjs.ViewTransitionContext);
|
|
1014
|
+
_chunkKPWUG3WNjs.invariant.call(void 0,
|
|
1034
1015
|
vtContext != null,
|
|
1035
1016
|
"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?"
|
|
1036
1017
|
);
|
|
1037
1018
|
let { basename } = useDataRouterContext(
|
|
1038
1019
|
"useViewTransitionState" /* useViewTransitionState */
|
|
1039
1020
|
);
|
|
1040
|
-
let path =
|
|
1021
|
+
let path = _chunkKPWUG3WNjs.useResolvedPath.call(void 0, to, { relative });
|
|
1041
1022
|
if (!vtContext.isTransitioning) {
|
|
1042
1023
|
return false;
|
|
1043
1024
|
}
|
|
1044
|
-
let currentPath =
|
|
1045
|
-
let nextPath =
|
|
1046
|
-
return
|
|
1025
|
+
let currentPath = _chunkKPWUG3WNjs.stripBasename.call(void 0, vtContext.currentLocation.pathname, basename) || vtContext.currentLocation.pathname;
|
|
1026
|
+
let nextPath = _chunkKPWUG3WNjs.stripBasename.call(void 0, vtContext.nextLocation.pathname, basename) || vtContext.nextLocation.pathname;
|
|
1027
|
+
return _chunkKPWUG3WNjs.matchPath.call(void 0, path.pathname, nextPath) != null || _chunkKPWUG3WNjs.matchPath.call(void 0, path.pathname, currentPath) != null;
|
|
1047
1028
|
}
|
|
1048
1029
|
|
|
1049
1030
|
// lib/dom/server.tsx
|
|
@@ -1054,7 +1035,7 @@ function StaticRouter({
|
|
|
1054
1035
|
location: locationProp = "/"
|
|
1055
1036
|
}) {
|
|
1056
1037
|
if (typeof locationProp === "string") {
|
|
1057
|
-
locationProp =
|
|
1038
|
+
locationProp = _chunkKPWUG3WNjs.parsePath.call(void 0, locationProp);
|
|
1058
1039
|
}
|
|
1059
1040
|
let action = "POP" /* Pop */;
|
|
1060
1041
|
let location = {
|
|
@@ -1066,7 +1047,7 @@ function StaticRouter({
|
|
|
1066
1047
|
};
|
|
1067
1048
|
let staticNavigator = getStatelessNavigator();
|
|
1068
1049
|
return /* @__PURE__ */ React2.createElement(
|
|
1069
|
-
|
|
1050
|
+
_chunkKPWUG3WNjs.Router,
|
|
1070
1051
|
{
|
|
1071
1052
|
basename,
|
|
1072
1053
|
children,
|
|
@@ -1084,7 +1065,7 @@ function StaticRouterProvider({
|
|
|
1084
1065
|
hydrate = true,
|
|
1085
1066
|
nonce
|
|
1086
1067
|
}) {
|
|
1087
|
-
|
|
1068
|
+
_chunkKPWUG3WNjs.invariant.call(void 0,
|
|
1088
1069
|
router && context,
|
|
1089
1070
|
"You must provide `router` and `context` to <StaticRouterProvider>"
|
|
1090
1071
|
);
|
|
@@ -1107,8 +1088,8 @@ function StaticRouterProvider({
|
|
|
1107
1088
|
hydrateScript = `window.__staticRouterHydrationData = JSON.parse(${json});`;
|
|
1108
1089
|
}
|
|
1109
1090
|
let { state } = dataRouterContext.router;
|
|
1110
|
-
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(
|
|
1111
|
-
|
|
1091
|
+
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(_chunkKPWUG3WNjs.DataRouterContext.Provider, { value: dataRouterContext }, /* @__PURE__ */ React2.createElement(_chunkKPWUG3WNjs.DataRouterStateContext.Provider, { value: state }, /* @__PURE__ */ React2.createElement(_chunkKPWUG3WNjs.FetchersContext.Provider, { value: fetchersContext }, /* @__PURE__ */ React2.createElement(_chunkKPWUG3WNjs.ViewTransitionContext.Provider, { value: { isTransitioning: false } }, /* @__PURE__ */ React2.createElement(
|
|
1092
|
+
_chunkKPWUG3WNjs.Router,
|
|
1112
1093
|
{
|
|
1113
1094
|
basename: dataRouterContext.basename,
|
|
1114
1095
|
location: state.location,
|
|
@@ -1139,14 +1120,14 @@ function DataRoutes({
|
|
|
1139
1120
|
future,
|
|
1140
1121
|
state
|
|
1141
1122
|
}) {
|
|
1142
|
-
return
|
|
1123
|
+
return _chunkKPWUG3WNjs.useRoutesImpl.call(void 0, routes, void 0, state, void 0, future);
|
|
1143
1124
|
}
|
|
1144
1125
|
function serializeErrors(errors) {
|
|
1145
1126
|
if (!errors) return null;
|
|
1146
1127
|
let entries = Object.entries(errors);
|
|
1147
1128
|
let serialized = {};
|
|
1148
1129
|
for (let [key, val] of entries) {
|
|
1149
|
-
if (
|
|
1130
|
+
if (_chunkKPWUG3WNjs.isRouteErrorResponse.call(void 0, val)) {
|
|
1150
1131
|
serialized[key] = { ...val, __type: "RouteErrorResponse" };
|
|
1151
1132
|
} else if (val instanceof Error) {
|
|
1152
1133
|
serialized[key] = {
|
|
@@ -1196,16 +1177,16 @@ function getStatelessNavigator() {
|
|
|
1196
1177
|
};
|
|
1197
1178
|
}
|
|
1198
1179
|
function createStaticHandler2(routes, opts) {
|
|
1199
|
-
return
|
|
1180
|
+
return _chunkKPWUG3WNjs.createStaticHandler.call(void 0, routes, {
|
|
1200
1181
|
...opts,
|
|
1201
|
-
mapRouteProperties:
|
|
1182
|
+
mapRouteProperties: _chunkKPWUG3WNjs.mapRouteProperties
|
|
1202
1183
|
});
|
|
1203
1184
|
}
|
|
1204
1185
|
function createStaticRouter(routes, context, opts = {}) {
|
|
1205
1186
|
let manifest = {};
|
|
1206
|
-
let dataRoutes =
|
|
1187
|
+
let dataRoutes = _chunkKPWUG3WNjs.convertRoutesToDataRoutes.call(void 0,
|
|
1207
1188
|
routes,
|
|
1208
|
-
|
|
1189
|
+
_chunkKPWUG3WNjs.mapRouteProperties,
|
|
1209
1190
|
void 0,
|
|
1210
1191
|
manifest
|
|
1211
1192
|
);
|
|
@@ -1236,7 +1217,7 @@ function createStaticRouter(routes, context, opts = {}) {
|
|
|
1236
1217
|
actionData: context.actionData,
|
|
1237
1218
|
errors: context.errors,
|
|
1238
1219
|
initialized: true,
|
|
1239
|
-
navigation:
|
|
1220
|
+
navigation: _chunkKPWUG3WNjs.IDLE_NAVIGATION,
|
|
1240
1221
|
restoreScrollPosition: null,
|
|
1241
1222
|
preventScrollReset: false,
|
|
1242
1223
|
revalidation: "idle",
|
|
@@ -1271,7 +1252,7 @@ function createStaticRouter(routes, context, opts = {}) {
|
|
|
1271
1252
|
createHref,
|
|
1272
1253
|
encodeLocation,
|
|
1273
1254
|
getFetcher() {
|
|
1274
|
-
return
|
|
1255
|
+
return _chunkKPWUG3WNjs.IDLE_FETCHER;
|
|
1275
1256
|
},
|
|
1276
1257
|
deleteFetcher() {
|
|
1277
1258
|
throw msg("deleteFetcher");
|
|
@@ -1283,7 +1264,7 @@ function createStaticRouter(routes, context, opts = {}) {
|
|
|
1283
1264
|
throw msg("dispose");
|
|
1284
1265
|
},
|
|
1285
1266
|
getBlocker() {
|
|
1286
|
-
return
|
|
1267
|
+
return _chunkKPWUG3WNjs.IDLE_BLOCKER;
|
|
1287
1268
|
},
|
|
1288
1269
|
deleteBlocker() {
|
|
1289
1270
|
throw msg("deleteBlocker");
|
|
@@ -1301,10 +1282,10 @@ function createStaticRouter(routes, context, opts = {}) {
|
|
|
1301
1282
|
};
|
|
1302
1283
|
}
|
|
1303
1284
|
function createHref(to) {
|
|
1304
|
-
return typeof to === "string" ? to :
|
|
1285
|
+
return typeof to === "string" ? to : _chunkKPWUG3WNjs.createPath.call(void 0, to);
|
|
1305
1286
|
}
|
|
1306
1287
|
function encodeLocation(to) {
|
|
1307
|
-
let href = typeof to === "string" ? to :
|
|
1288
|
+
let href = typeof to === "string" ? to : _chunkKPWUG3WNjs.createPath.call(void 0, to);
|
|
1308
1289
|
href = href.replace(/ $/, "%20");
|
|
1309
1290
|
let encoded = ABSOLUTE_URL_REGEX2.test(href) ? new URL(href) : new URL(href, "http://localhost");
|
|
1310
1291
|
return {
|