@tanstack/react-router 1.114.6 → 1.114.12

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/src/Match.tsx CHANGED
@@ -4,14 +4,15 @@ import warning from 'tiny-warning'
4
4
  import {
5
5
  createControlledPromise,
6
6
  getLocationChangeInfo,
7
+ isNotFound,
8
+ isRedirect,
7
9
  pick,
8
10
  rootRouteId,
9
11
  } from '@tanstack/router-core'
10
12
  import { CatchBoundary, ErrorComponent } from './CatchBoundary'
11
13
  import { useRouterState } from './useRouterState'
12
14
  import { useRouter } from './useRouter'
13
- import { CatchNotFound, isNotFound } from './not-found'
14
- import { isRedirect } from './redirects'
15
+ import { CatchNotFound } from './not-found'
15
16
  import { matchContext } from './matchContext'
16
17
  import { SafeFragment } from './SafeFragment'
17
18
  import { renderRouteNotFound } from './renderRouteNotFound'
package/src/index.tsx CHANGED
@@ -261,7 +261,7 @@ export { useMatch } from './useMatch'
261
261
  export { useLoaderDeps } from './useLoaderDeps'
262
262
  export { useLoaderData } from './useLoaderData'
263
263
 
264
- export { redirect, isRedirect } from './redirects'
264
+ export { redirect, isRedirect } from '@tanstack/router-core'
265
265
 
266
266
  export {
267
267
  RouteApi,
@@ -326,18 +326,13 @@ export {
326
326
  useStableCallback,
327
327
  } from './utils'
328
328
 
329
- export {
330
- notFound,
331
- isNotFound,
332
- CatchNotFound,
333
- DefaultGlobalNotFound,
334
- } from './not-found'
335
- export type { NotFoundError } from './not-found'
329
+ export { CatchNotFound, DefaultGlobalNotFound } from './not-found'
330
+ export { notFound, isNotFound } from '@tanstack/router-core'
331
+ export type { NotFoundError } from '@tanstack/router-core'
336
332
 
337
333
  export * from './typePrimitives'
338
334
 
339
335
  export { ScriptOnce } from './ScriptOnce'
340
-
341
336
  export { Asset } from './Asset'
342
337
  export { HeadContent } from './HeadContent'
343
338
  export { Scripts } from './Scripts'
package/src/not-found.tsx CHANGED
@@ -1,35 +1,9 @@
1
1
  import * as React from 'react'
2
+ import { isNotFound } from '@tanstack/router-core'
2
3
  import { CatchBoundary } from './CatchBoundary'
3
4
  import { useRouterState } from './useRouterState'
4
5
  import type { ErrorInfo } from 'react'
5
- import type { RegisteredRouter, RouteIds } from '@tanstack/router-core'
6
-
7
- export type NotFoundError = {
8
- /**
9
- @deprecated
10
- Use `routeId: rootRouteId` instead
11
- */
12
- global?: boolean
13
- /**
14
- @private
15
- Do not use this. It's used internally to indicate a path matching error
16
- */
17
- _global?: boolean
18
- data?: any
19
- throw?: boolean
20
- routeId?: RouteIds<RegisteredRouter['routeTree']>
21
- headers?: HeadersInit
22
- }
23
-
24
- export function notFound(options: NotFoundError = {}) {
25
- ;(options as any).isNotFound = true
26
- if (options.throw) throw options
27
- return options
28
- }
29
-
30
- export function isNotFound(obj: any): obj is NotFoundError {
31
- return !!obj?.isNotFound
32
- }
6
+ import type { NotFoundError } from '@tanstack/router-core'
33
7
 
34
8
  export function CatchNotFound(props: {
35
9
  fallback?: (error: NotFoundError) => React.ReactElement
package/src/route.ts CHANGED
@@ -1,10 +1,14 @@
1
1
  import invariant from 'tiny-invariant'
2
- import { joinPaths, rootRouteId, trimPathLeft } from '@tanstack/router-core'
2
+ import {
3
+ joinPaths,
4
+ notFound,
5
+ rootRouteId,
6
+ trimPathLeft,
7
+ } from '@tanstack/router-core'
3
8
  import { useLoaderData } from './useLoaderData'
4
9
  import { useLoaderDeps } from './useLoaderDeps'
5
10
  import { useParams } from './useParams'
6
11
  import { useSearch } from './useSearch'
7
- import { notFound } from './not-found'
8
12
  import { useNavigate } from './useNavigate'
9
13
  import { useMatch } from './useMatch'
10
14
  import { useRouter } from './useRouter'
@@ -17,6 +21,7 @@ import type {
17
21
  LazyRoute as CoreLazyRoute,
18
22
  Route as CoreRoute,
19
23
  ErrorComponentProps,
24
+ NotFoundError,
20
25
  NotFoundRouteProps,
21
26
  RegisteredRouter,
22
27
  ResolveFullPath,
@@ -48,7 +53,6 @@ import type { UseLoaderDepsRoute } from './useLoaderDeps'
48
53
  import type { UseParamsRoute } from './useParams'
49
54
  import type { UseSearchRoute } from './useSearch'
50
55
  import type * as React from 'react'
51
- import type { NotFoundError } from './not-found'
52
56
  import type { UseRouteContextRoute } from './useRouteContext'
53
57
 
54
58
  declare module '@tanstack/router-core' {
package/src/router.ts CHANGED
@@ -14,6 +14,9 @@ import {
14
14
  functionalUpdate,
15
15
  getLocationChangeInfo,
16
16
  interpolatePath,
17
+ isNotFound,
18
+ isRedirect,
19
+ isResolvedRedirect,
17
20
  joinPaths,
18
21
  last,
19
22
  matchPathname,
@@ -26,8 +29,6 @@ import {
26
29
  trimPathLeft,
27
30
  trimPathRight,
28
31
  } from '@tanstack/router-core'
29
- import { isRedirect, isResolvedRedirect } from './redirects'
30
- import { isNotFound } from './not-found'
31
32
 
32
33
  import { setupScrollRestoration } from './scroll-restoration'
33
34
  import type * as React from 'react'
@@ -64,6 +65,7 @@ import type {
64
65
  MatchRoutesOpts,
65
66
  MatchedRoutesResult,
66
67
  NavigateFn,
68
+ NotFoundError,
67
69
  ParseLocationFn,
68
70
  ParsedLocation,
69
71
  PickAsRequired,
@@ -92,8 +94,6 @@ import type {
92
94
  RouteComponent,
93
95
  } from './route'
94
96
 
95
- import type { NotFoundError } from './not-found'
96
-
97
97
  declare module '@tanstack/router-core' {
98
98
  export interface RouterOptionsExtensions {
99
99
  /**
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- function redirect(opts) {
4
- opts.isRedirect = true;
5
- opts.statusCode = opts.statusCode || opts.code || 307;
6
- opts.headers = opts.headers || {};
7
- if (!opts.reloadDocument) {
8
- opts.reloadDocument = false;
9
- try {
10
- new URL(`${opts.href}`);
11
- opts.reloadDocument = true;
12
- } catch {
13
- }
14
- }
15
- if (opts.throw) {
16
- throw opts;
17
- }
18
- return opts;
19
- }
20
- function isRedirect(obj) {
21
- return !!(obj == null ? void 0 : obj.isRedirect);
22
- }
23
- function isResolvedRedirect(obj) {
24
- return !!(obj == null ? void 0 : obj.isRedirect) && obj.href;
25
- }
26
- exports.isRedirect = isRedirect;
27
- exports.isResolvedRedirect = isResolvedRedirect;
28
- exports.redirect = redirect;
29
- //# sourceMappingURL=redirects.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"redirects.cjs","sources":["../../src/redirects.ts"],"sourcesContent":["import type {\n AnyRedirect,\n Redirect,\n RegisteredRouter,\n ResolvedRedirect,\n} from '@tanstack/router-core'\n\nexport function redirect<\n TRouter extends RegisteredRouter,\n const TTo extends string | undefined,\n const TFrom extends string = string,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = '',\n>(\n opts: Redirect<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n): Redirect<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> {\n ;(opts as any).isRedirect = true\n opts.statusCode = opts.statusCode || opts.code || 307\n opts.headers = opts.headers || {}\n if (!opts.reloadDocument) {\n opts.reloadDocument = false\n try {\n new URL(`${opts.href}`)\n opts.reloadDocument = true\n } catch {}\n }\n\n if (opts.throw) {\n throw opts\n }\n\n return opts\n}\n\nexport function isRedirect(obj: any): obj is AnyRedirect {\n return !!obj?.isRedirect\n}\n\nexport function isResolvedRedirect(obj: any): obj is ResolvedRedirect {\n return !!obj?.isRedirect && obj.href\n}\n"],"names":[],"mappings":";;AAOO,SAAS,SAOd,MACmD;AACjD,OAAa,aAAa;AAC5B,OAAK,aAAa,KAAK,cAAc,KAAK,QAAQ;AAC7C,OAAA,UAAU,KAAK,WAAW,CAAC;AAC5B,MAAA,CAAC,KAAK,gBAAgB;AACxB,SAAK,iBAAiB;AAClB,QAAA;AACF,UAAI,IAAI,GAAG,KAAK,IAAI,EAAE;AACtB,WAAK,iBAAiB;AAAA,IAAA,QAChB;AAAA,IAAA;AAAA,EAAC;AAGX,MAAI,KAAK,OAAO;AACR,UAAA;AAAA,EAAA;AAGD,SAAA;AACT;AAEO,SAAS,WAAW,KAA8B;AAChD,SAAA,CAAC,EAAC,2BAAK;AAChB;AAEO,SAAS,mBAAmB,KAAmC;AACpE,SAAO,CAAC,EAAC,2BAAK,eAAc,IAAI;AAClC;;;;"}
@@ -1,4 +0,0 @@
1
- import { AnyRedirect, Redirect, RegisteredRouter, ResolvedRedirect } from '@tanstack/router-core';
2
- export declare function redirect<TRouter extends RegisteredRouter, const TTo extends string | undefined, const TFrom extends string = string, const TMaskFrom extends string = TFrom, const TMaskTo extends string = ''>(opts: Redirect<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>): Redirect<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>;
3
- export declare function isRedirect(obj: any): obj is AnyRedirect;
4
- export declare function isResolvedRedirect(obj: any): obj is ResolvedRedirect;
@@ -1,4 +0,0 @@
1
- import { AnyRedirect, Redirect, RegisteredRouter, ResolvedRedirect } from '@tanstack/router-core';
2
- export declare function redirect<TRouter extends RegisteredRouter, const TTo extends string | undefined, const TFrom extends string = string, const TMaskFrom extends string = TFrom, const TMaskTo extends string = ''>(opts: Redirect<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>): Redirect<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>;
3
- export declare function isRedirect(obj: any): obj is AnyRedirect;
4
- export declare function isResolvedRedirect(obj: any): obj is ResolvedRedirect;
@@ -1,29 +0,0 @@
1
- function redirect(opts) {
2
- opts.isRedirect = true;
3
- opts.statusCode = opts.statusCode || opts.code || 307;
4
- opts.headers = opts.headers || {};
5
- if (!opts.reloadDocument) {
6
- opts.reloadDocument = false;
7
- try {
8
- new URL(`${opts.href}`);
9
- opts.reloadDocument = true;
10
- } catch {
11
- }
12
- }
13
- if (opts.throw) {
14
- throw opts;
15
- }
16
- return opts;
17
- }
18
- function isRedirect(obj) {
19
- return !!(obj == null ? void 0 : obj.isRedirect);
20
- }
21
- function isResolvedRedirect(obj) {
22
- return !!(obj == null ? void 0 : obj.isRedirect) && obj.href;
23
- }
24
- export {
25
- isRedirect,
26
- isResolvedRedirect,
27
- redirect
28
- };
29
- //# sourceMappingURL=redirects.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"redirects.js","sources":["../../src/redirects.ts"],"sourcesContent":["import type {\n AnyRedirect,\n Redirect,\n RegisteredRouter,\n ResolvedRedirect,\n} from '@tanstack/router-core'\n\nexport function redirect<\n TRouter extends RegisteredRouter,\n const TTo extends string | undefined,\n const TFrom extends string = string,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = '',\n>(\n opts: Redirect<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n): Redirect<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> {\n ;(opts as any).isRedirect = true\n opts.statusCode = opts.statusCode || opts.code || 307\n opts.headers = opts.headers || {}\n if (!opts.reloadDocument) {\n opts.reloadDocument = false\n try {\n new URL(`${opts.href}`)\n opts.reloadDocument = true\n } catch {}\n }\n\n if (opts.throw) {\n throw opts\n }\n\n return opts\n}\n\nexport function isRedirect(obj: any): obj is AnyRedirect {\n return !!obj?.isRedirect\n}\n\nexport function isResolvedRedirect(obj: any): obj is ResolvedRedirect {\n return !!obj?.isRedirect && obj.href\n}\n"],"names":[],"mappings":"AAOO,SAAS,SAOd,MACmD;AACjD,OAAa,aAAa;AAC5B,OAAK,aAAa,KAAK,cAAc,KAAK,QAAQ;AAC7C,OAAA,UAAU,KAAK,WAAW,CAAC;AAC5B,MAAA,CAAC,KAAK,gBAAgB;AACxB,SAAK,iBAAiB;AAClB,QAAA;AACF,UAAI,IAAI,GAAG,KAAK,IAAI,EAAE;AACtB,WAAK,iBAAiB;AAAA,IAAA,QAChB;AAAA,IAAA;AAAA,EAAC;AAGX,MAAI,KAAK,OAAO;AACR,UAAA;AAAA,EAAA;AAGD,SAAA;AACT;AAEO,SAAS,WAAW,KAA8B;AAChD,SAAA,CAAC,EAAC,2BAAK;AAChB;AAEO,SAAS,mBAAmB,KAAmC;AACpE,SAAO,CAAC,EAAC,2BAAK,eAAc,IAAI;AAClC;"}
package/src/redirects.ts DELETED
@@ -1,41 +0,0 @@
1
- import type {
2
- AnyRedirect,
3
- Redirect,
4
- RegisteredRouter,
5
- ResolvedRedirect,
6
- } from '@tanstack/router-core'
7
-
8
- export function redirect<
9
- TRouter extends RegisteredRouter,
10
- const TTo extends string | undefined,
11
- const TFrom extends string = string,
12
- const TMaskFrom extends string = TFrom,
13
- const TMaskTo extends string = '',
14
- >(
15
- opts: Redirect<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,
16
- ): Redirect<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> {
17
- ;(opts as any).isRedirect = true
18
- opts.statusCode = opts.statusCode || opts.code || 307
19
- opts.headers = opts.headers || {}
20
- if (!opts.reloadDocument) {
21
- opts.reloadDocument = false
22
- try {
23
- new URL(`${opts.href}`)
24
- opts.reloadDocument = true
25
- } catch {}
26
- }
27
-
28
- if (opts.throw) {
29
- throw opts
30
- }
31
-
32
- return opts
33
- }
34
-
35
- export function isRedirect(obj: any): obj is AnyRedirect {
36
- return !!obj?.isRedirect
37
- }
38
-
39
- export function isResolvedRedirect(obj: any): obj is ResolvedRedirect {
40
- return !!obj?.isRedirect && obj.href
41
- }