@tanstack/solid-router 1.168.8 → 1.168.10
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/dist/cjs/Match.cjs +9 -3
- package/dist/cjs/Match.cjs.map +1 -1
- package/dist/cjs/link.cjs +3 -1
- package/dist/cjs/link.cjs.map +1 -1
- package/dist/cjs/not-found.cjs +9 -2
- package/dist/cjs/not-found.cjs.map +1 -1
- package/dist/cjs/not-found.d.cts +4 -1
- package/dist/esm/Match.js +10 -4
- package/dist/esm/Match.js.map +1 -1
- package/dist/esm/link.js +3 -1
- package/dist/esm/link.js.map +1 -1
- package/dist/esm/not-found.d.ts +4 -1
- package/dist/esm/not-found.js +9 -3
- package/dist/esm/not-found.js.map +1 -1
- package/dist/source/Match.jsx +16 -8
- package/dist/source/Match.jsx.map +1 -1
- package/dist/source/link.jsx +2 -0
- package/dist/source/link.jsx.map +1 -1
- package/dist/source/not-found.d.ts +4 -1
- package/dist/source/not-found.jsx +17 -4
- package/dist/source/not-found.jsx.map +1 -1
- package/package.json +2 -2
- package/src/Match.tsx +18 -7
- package/src/link.tsx +2 -0
- package/src/not-found.tsx +25 -5
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import * as Solid from 'solid-js';
|
|
2
2
|
import type { NotFoundError } from '@tanstack/router-core';
|
|
3
|
+
export declare function getNotFound(error: unknown): (NotFoundError & {
|
|
4
|
+
isNotFound: true;
|
|
5
|
+
}) | undefined;
|
|
3
6
|
export declare function CatchNotFound(props: {
|
|
4
7
|
fallback?: (error: NotFoundError) => Solid.JSX.Element;
|
|
5
|
-
onCatch?: (error:
|
|
8
|
+
onCatch?: (error: NotFoundError) => void;
|
|
6
9
|
children: Solid.JSX.Element;
|
|
7
10
|
}): Solid.JSX.Element;
|
|
8
11
|
export declare function DefaultGlobalNotFound(): Solid.JSX.Element;
|
|
@@ -2,21 +2,34 @@ import { isNotFound } from '@tanstack/router-core';
|
|
|
2
2
|
import * as Solid from 'solid-js';
|
|
3
3
|
import { CatchBoundary } from './CatchBoundary';
|
|
4
4
|
import { useRouter } from './useRouter';
|
|
5
|
+
// Solid wraps non-Error throws in an Error and stores the original thrown value
|
|
6
|
+
// on `cause`, so component-thrown `notFound()` needs one extra unwrapping step.
|
|
7
|
+
export function getNotFound(error) {
|
|
8
|
+
if (isNotFound(error)) {
|
|
9
|
+
return error;
|
|
10
|
+
}
|
|
11
|
+
if (isNotFound(error?.cause)) {
|
|
12
|
+
return error.cause;
|
|
13
|
+
}
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
5
16
|
export function CatchNotFound(props) {
|
|
6
17
|
const router = useRouter();
|
|
7
18
|
// TODO: Some way for the user to programmatically reset the not-found boundary?
|
|
8
19
|
const pathname = Solid.createMemo(() => router.stores.location.state.pathname);
|
|
9
20
|
const status = Solid.createMemo(() => router.stores.status.state);
|
|
10
21
|
return (<CatchBoundary getResetKey={() => `not-found-${pathname()}-${status()}`} onCatch={(error) => {
|
|
11
|
-
|
|
12
|
-
|
|
22
|
+
const notFoundError = getNotFound(error);
|
|
23
|
+
if (notFoundError) {
|
|
24
|
+
props.onCatch?.(notFoundError);
|
|
13
25
|
}
|
|
14
26
|
else {
|
|
15
27
|
throw error;
|
|
16
28
|
}
|
|
17
29
|
}} errorComponent={({ error }) => {
|
|
18
|
-
|
|
19
|
-
|
|
30
|
+
const notFoundError = getNotFound(error);
|
|
31
|
+
if (notFoundError) {
|
|
32
|
+
return props.fallback?.(notFoundError);
|
|
20
33
|
}
|
|
21
34
|
else {
|
|
22
35
|
throw error;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"not-found.jsx","sourceRoot":"","sources":["../../src/not-found.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,KAAK,KAAK,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,E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version": "1.168.10",
|
|
4
4
|
"description": "Modern and scalable routing for Solid applications",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"@solidjs/meta": "^0.29.4",
|
|
93
93
|
"isbot": "^5.1.22",
|
|
94
94
|
"@tanstack/history": "1.161.6",
|
|
95
|
-
"@tanstack/router-core": "1.168.
|
|
95
|
+
"@tanstack/router-core": "1.168.9"
|
|
96
96
|
},
|
|
97
97
|
"devDependencies": {
|
|
98
98
|
"@solidjs/testing-library": "^0.8.10",
|
package/src/Match.tsx
CHANGED
|
@@ -11,7 +11,7 @@ import { isServer } from '@tanstack/router-core/isServer'
|
|
|
11
11
|
import { Dynamic } from 'solid-js/web'
|
|
12
12
|
import { CatchBoundary, ErrorComponent } from './CatchBoundary'
|
|
13
13
|
import { useRouter } from './useRouter'
|
|
14
|
-
import { CatchNotFound } from './not-found'
|
|
14
|
+
import { CatchNotFound, getNotFound } from './not-found'
|
|
15
15
|
import { nearestMatchContext } from './matchContext'
|
|
16
16
|
import { SafeFragment } from './SafeFragment'
|
|
17
17
|
import { renderRouteNotFound } from './renderRouteNotFound'
|
|
@@ -117,7 +117,12 @@ export const Match = (props: { matchId: string }) => {
|
|
|
117
117
|
errorComponent={routeErrorComponent() || ErrorComponent}
|
|
118
118
|
onCatch={(error: Error) => {
|
|
119
119
|
// Forward not found errors (we don't want to show the error component for these)
|
|
120
|
-
|
|
120
|
+
const notFoundError = getNotFound(error)
|
|
121
|
+
if (notFoundError) {
|
|
122
|
+
notFoundError.routeId ??= currentMatchState()
|
|
123
|
+
.routeId as any
|
|
124
|
+
throw notFoundError
|
|
125
|
+
}
|
|
121
126
|
if (process.env.NODE_ENV !== 'production') {
|
|
122
127
|
console.warn(
|
|
123
128
|
`Warning: Error in route match: ${currentMatchState().routeId}`,
|
|
@@ -129,20 +134,26 @@ export const Match = (props: { matchId: string }) => {
|
|
|
129
134
|
<Dynamic
|
|
130
135
|
component={ResolvedNotFoundBoundary()}
|
|
131
136
|
fallback={(error: any) => {
|
|
137
|
+
const notFoundError = getNotFound(error) ?? error
|
|
138
|
+
|
|
139
|
+
notFoundError.routeId ??= currentMatchState()
|
|
140
|
+
.routeId as any
|
|
141
|
+
|
|
132
142
|
// If the current not found handler doesn't exist or it has a
|
|
133
143
|
// route ID which doesn't match the current route, rethrow the error
|
|
134
144
|
if (
|
|
135
145
|
!routeNotFoundComponent() ||
|
|
136
|
-
(
|
|
137
|
-
|
|
138
|
-
|
|
146
|
+
(notFoundError.routeId &&
|
|
147
|
+
notFoundError.routeId !==
|
|
148
|
+
currentMatchState().routeId) ||
|
|
149
|
+
(!notFoundError.routeId && !route().isRoot)
|
|
139
150
|
)
|
|
140
|
-
throw
|
|
151
|
+
throw notFoundError
|
|
141
152
|
|
|
142
153
|
return (
|
|
143
154
|
<Dynamic
|
|
144
155
|
component={routeNotFoundComponent()}
|
|
145
|
-
{...
|
|
156
|
+
{...notFoundError}
|
|
146
157
|
/>
|
|
147
158
|
)
|
|
148
159
|
}}
|
package/src/link.tsx
CHANGED
|
@@ -63,6 +63,7 @@ export function useLinkProps<
|
|
|
63
63
|
'to',
|
|
64
64
|
'preload',
|
|
65
65
|
'preloadDelay',
|
|
66
|
+
'preloadIntentProximity',
|
|
66
67
|
'hashScrollIntoView',
|
|
67
68
|
'replace',
|
|
68
69
|
'startTransition',
|
|
@@ -120,6 +121,7 @@ export function useLinkProps<
|
|
|
120
121
|
'mask',
|
|
121
122
|
'reloadDocument',
|
|
122
123
|
'unsafeRelative',
|
|
124
|
+
'from',
|
|
123
125
|
])
|
|
124
126
|
|
|
125
127
|
const currentLocation = Solid.createMemo(
|
package/src/not-found.tsx
CHANGED
|
@@ -4,9 +4,25 @@ import { CatchBoundary } from './CatchBoundary'
|
|
|
4
4
|
import { useRouter } from './useRouter'
|
|
5
5
|
import type { NotFoundError } from '@tanstack/router-core'
|
|
6
6
|
|
|
7
|
+
// Solid wraps non-Error throws in an Error and stores the original thrown value
|
|
8
|
+
// on `cause`, so component-thrown `notFound()` needs one extra unwrapping step.
|
|
9
|
+
export function getNotFound(
|
|
10
|
+
error: unknown,
|
|
11
|
+
): (NotFoundError & { isNotFound: true }) | undefined {
|
|
12
|
+
if (isNotFound(error)) {
|
|
13
|
+
return error as NotFoundError & { isNotFound: true }
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (isNotFound((error as any)?.cause)) {
|
|
17
|
+
return (error as any).cause as NotFoundError & { isNotFound: true }
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return undefined
|
|
21
|
+
}
|
|
22
|
+
|
|
7
23
|
export function CatchNotFound(props: {
|
|
8
24
|
fallback?: (error: NotFoundError) => Solid.JSX.Element
|
|
9
|
-
onCatch?: (error:
|
|
25
|
+
onCatch?: (error: NotFoundError) => void
|
|
10
26
|
children: Solid.JSX.Element
|
|
11
27
|
}) {
|
|
12
28
|
const router = useRouter()
|
|
@@ -18,15 +34,19 @@ export function CatchNotFound(props: {
|
|
|
18
34
|
<CatchBoundary
|
|
19
35
|
getResetKey={() => `not-found-${pathname()}-${status()}`}
|
|
20
36
|
onCatch={(error) => {
|
|
21
|
-
|
|
22
|
-
|
|
37
|
+
const notFoundError = getNotFound(error)
|
|
38
|
+
|
|
39
|
+
if (notFoundError) {
|
|
40
|
+
props.onCatch?.(notFoundError)
|
|
23
41
|
} else {
|
|
24
42
|
throw error
|
|
25
43
|
}
|
|
26
44
|
}}
|
|
27
45
|
errorComponent={({ error }) => {
|
|
28
|
-
|
|
29
|
-
|
|
46
|
+
const notFoundError = getNotFound(error)
|
|
47
|
+
|
|
48
|
+
if (notFoundError) {
|
|
49
|
+
return props.fallback?.(notFoundError)
|
|
30
50
|
} else {
|
|
31
51
|
throw error
|
|
32
52
|
}
|