@tanstack/solid-router 1.168.1 → 1.168.3
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/HeadContent.cjs +2 -2
- package/dist/cjs/HeadContent.cjs.map +1 -1
- package/dist/cjs/HeadContent.d.cts +5 -1
- package/dist/cjs/HeadContent.dev.cjs +2 -2
- package/dist/cjs/HeadContent.dev.cjs.map +1 -1
- package/dist/cjs/HeadContent.dev.d.cts +2 -1
- package/dist/cjs/Match.cjs +9 -7
- package/dist/cjs/Match.cjs.map +1 -1
- package/dist/cjs/Matches.cjs +2 -4
- package/dist/cjs/Matches.cjs.map +1 -1
- package/dist/cjs/fileRoute.cjs +4 -5
- package/dist/cjs/fileRoute.cjs.map +1 -1
- package/dist/cjs/headContentUtils.cjs +17 -10
- package/dist/cjs/headContentUtils.cjs.map +1 -1
- package/dist/cjs/headContentUtils.d.cts +3 -2
- package/dist/cjs/renderRouteNotFound.cjs +4 -4
- package/dist/cjs/renderRouteNotFound.cjs.map +1 -1
- package/dist/cjs/useMatch.cjs +4 -3
- package/dist/cjs/useMatch.cjs.map +1 -1
- package/dist/cjs/useRouter.cjs +3 -3
- package/dist/cjs/useRouter.cjs.map +1 -1
- package/dist/esm/HeadContent.d.ts +5 -1
- package/dist/esm/HeadContent.dev.d.ts +2 -1
- package/dist/esm/HeadContent.dev.js +2 -2
- package/dist/esm/HeadContent.dev.js.map +1 -1
- package/dist/esm/HeadContent.js +2 -2
- package/dist/esm/HeadContent.js.map +1 -1
- package/dist/esm/Match.js +10 -6
- package/dist/esm/Match.js.map +1 -1
- package/dist/esm/Matches.js +2 -3
- package/dist/esm/Matches.js.map +1 -1
- package/dist/esm/fileRoute.js +4 -3
- package/dist/esm/fileRoute.js.map +1 -1
- package/dist/esm/headContentUtils.d.ts +3 -2
- package/dist/esm/headContentUtils.js +18 -11
- package/dist/esm/headContentUtils.js.map +1 -1
- package/dist/esm/renderRouteNotFound.js +3 -2
- package/dist/esm/renderRouteNotFound.js.map +1 -1
- package/dist/esm/useMatch.js +5 -3
- package/dist/esm/useMatch.js.map +1 -1
- package/dist/esm/useRouter.js +3 -2
- package/dist/esm/useRouter.js.map +1 -1
- package/dist/source/HeadContent.d.ts +5 -1
- package/dist/source/HeadContent.dev.d.ts +2 -1
- package/dist/source/HeadContent.dev.jsx +2 -2
- package/dist/source/HeadContent.dev.jsx.map +1 -1
- package/dist/source/HeadContent.jsx +2 -2
- package/dist/source/HeadContent.jsx.map +1 -1
- package/dist/source/Match.jsx +16 -6
- package/dist/source/Match.jsx.map +1 -1
- package/dist/source/Matches.jsx +2 -3
- package/dist/source/Matches.jsx.map +1 -1
- package/dist/source/fileRoute.js +4 -3
- package/dist/source/fileRoute.js.map +1 -1
- package/dist/source/headContentUtils.d.ts +3 -2
- package/dist/source/headContentUtils.jsx +26 -12
- package/dist/source/headContentUtils.jsx.map +1 -1
- package/dist/source/renderRouteNotFound.jsx +4 -3
- package/dist/source/renderRouteNotFound.jsx.map +1 -1
- package/dist/source/useMatch.jsx +8 -4
- package/dist/source/useMatch.jsx.map +1 -1
- package/dist/source/useRouter.jsx +5 -2
- package/dist/source/useRouter.jsx.map +1 -1
- package/package.json +2 -4
- package/src/HeadContent.dev.tsx +3 -2
- package/src/HeadContent.tsx +7 -2
- package/src/Match.tsx +24 -14
- package/src/Matches.tsx +3 -5
- package/src/fileRoute.ts +7 -8
- package/src/headContentUtils.tsx +30 -7
- package/src/renderRouteNotFound.tsx +6 -6
- package/src/useMatch.tsx +14 -10
- package/src/useRouter.tsx +7 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"headContentUtils.jsx","sourceRoot":"","sources":["../../src/headContentUtils.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,UAAU,CAAA;AACjC,OAAO,
|
|
1
|
+
{"version":3,"file":"headContentUtils.jsx","sourceRoot":"","sources":["../../src/headContentUtils.tsx"],"names":[],"mappings":"AAAA,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AAG,EAAU,CAAA;IAC9B,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;QACzB,MAAM,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,CAAA;QACpB,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YAClB,OAAO,KAAK,CAAA;QACd,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QACb,OAAO,IAAI,CAAA;IACb,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import warning from 'tiny-warning';
|
|
2
1
|
import { DefaultGlobalNotFound } from './not-found';
|
|
3
2
|
/**
|
|
4
3
|
* Renders a not found component for a route when no matching route is found.
|
|
@@ -13,8 +12,10 @@ export function renderRouteNotFound(router, route, data) {
|
|
|
13
12
|
if (router.options.defaultNotFoundComponent) {
|
|
14
13
|
return <router.options.defaultNotFoundComponent {...data}/>;
|
|
15
14
|
}
|
|
16
|
-
if (process.env.NODE_ENV
|
|
17
|
-
|
|
15
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
16
|
+
if (!route.options.notFoundComponent) {
|
|
17
|
+
console.warn(`Warning: A notFoundError was encountered on the route with ID "${route.id}", but a notFoundComponent option was not configured, nor was a router level defaultNotFoundComponent configured. Consider configuring at least one of these to avoid TanStack Router's overly generic defaultNotFoundComponent (<p>Not Found</p>)`);
|
|
18
|
+
}
|
|
18
19
|
}
|
|
19
20
|
return <DefaultGlobalNotFound />;
|
|
20
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderRouteNotFound.jsx","sourceRoot":"","sources":["../../src/renderRouteNotFound.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"renderRouteNotFound.jsx","sourceRoot":"","sources":["../../src/renderRouteNotFound.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAGnD;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CACjC,MAAiB,EACjB,KAAe,EACf,IAAS;IAET,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,iBAAiB,EAAE,CAAC;QACrC,IAAI,MAAM,CAAC,OAAO,CAAC,wBAAwB,EAAE,CAAC;YAC5C,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,wBAAwB,CAAC,IAAI,IAAI,CAAC,EAAG,CAAA;QAC9D,CAAC;QAED,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE,CAAC;YAC1C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,iBAAiB,EAAE,CAAC;gBACrC,OAAO,CAAC,IAAI,CACV,kEAAkE,KAAK,CAAC,EAAE,oPAAoP,CAC/T,CAAA;YACH,CAAC;QACH,CAAC;QAED,OAAO,CAAC,qBAAqB,CAAC,AAAD,EAAG,CAAA;IAClC,CAAC;IAED,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,iBAAiB,CAAC,IAAI,IAAI,CAAC,EAAG,CAAA;AACtD,CAAC"}
|
package/dist/source/useMatch.jsx
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as Solid from 'solid-js';
|
|
2
|
-
import invariant from '
|
|
3
|
-
import { replaceEqualDeep } from '@tanstack/router-core';
|
|
2
|
+
import { invariant, replaceEqualDeep } from '@tanstack/router-core';
|
|
4
3
|
import { nearestMatchContext } from './matchContext';
|
|
5
4
|
import { useRouter } from './useRouter';
|
|
6
5
|
export function useMatch(opts) {
|
|
@@ -21,9 +20,14 @@ export function useMatch(opts) {
|
|
|
21
20
|
const hasPendingMatch = opts.from
|
|
22
21
|
? Boolean(router.stores.pendingRouteIds.state[opts.from])
|
|
23
22
|
: (nearestMatch?.hasPending() ?? false);
|
|
24
|
-
|
|
23
|
+
if (!hasPendingMatch &&
|
|
25
24
|
!router.stores.isTransitioning.state &&
|
|
26
|
-
(opts.shouldThrow ?? true))
|
|
25
|
+
(opts.shouldThrow ?? true)) {
|
|
26
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
27
|
+
throw new Error(`Invariant failed: Could not find ${opts.from ? `an active match from "${opts.from}"` : 'a nearest match!'}`);
|
|
28
|
+
}
|
|
29
|
+
invariant();
|
|
30
|
+
}
|
|
27
31
|
});
|
|
28
32
|
return Solid.createMemo((prev) => {
|
|
29
33
|
const selectedMatch = match();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMatch.jsx","sourceRoot":"","sources":["../../src/useMatch.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,UAAU,CAAA;AACjC,OAAO,SAAS,
|
|
1
|
+
{"version":3,"file":"useMatch.jsx","sourceRoot":"","sources":["../../src/useMatch.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAmDvC,MAAM,UAAU,QAAQ,CAOtB,IAMC;IAID,MAAM,MAAM,GAAG,SAAS,EAAW,CAAA;IACnC,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI;QAC5B,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,mBAAmB,CAAC,CAAA;IAEzC,MAAM,KAAK,GAAG,GAAG,EAAE;QACjB,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YACd,OAAO,MAAM,CAAC,MAAM,CAAC,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,CAAA;QAC9D,CAAC;QAED,OAAO,YAAY,EAAE,KAAK,EAAE,CAAA;IAC9B,CAAC,CAAA;IAED,KAAK,CAAC,YAAY,CAAC,GAAG,EAAE;QACtB,IAAI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warning';
|
|
3
2
|
import { routerContext } from './routerContext';
|
|
4
3
|
export function useRouter(opts) {
|
|
5
4
|
const value = Solid.useContext(routerContext);
|
|
6
|
-
|
|
5
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6
|
+
if ((opts?.warn ?? true) && !value) {
|
|
7
|
+
console.warn('Warning: useRouter must be used inside a <RouterProvider> component!');
|
|
8
|
+
}
|
|
9
|
+
}
|
|
7
10
|
return value;
|
|
8
11
|
}
|
|
9
12
|
//# sourceMappingURL=useRouter.jsx.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRouter.jsx","sourceRoot":"","sources":["../../src/useRouter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,UAAU,CAAA;AACjC,OAAO,
|
|
1
|
+
{"version":3,"file":"useRouter.jsx","sourceRoot":"","sources":["../../src/useRouter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAG/C,MAAM,UAAU,SAAS,CAA+C,IAEvE;IACC,MAAM,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC,aAAoB,CAAC,CAAA;IACpD,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE,CAAC;QAC1C,IAAI,CAAC,IAAI,EAAE,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YACnC,OAAO,CAAC,IAAI,CACV,sEAAsE,CACvE,CAAA;QACH,CAAC;IACH,CAAC;IACD,OAAO,KAAY,CAAA;AACrB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/solid-router",
|
|
3
|
-
"version": "1.168.
|
|
3
|
+
"version": "1.168.3",
|
|
4
4
|
"description": "Modern and scalable routing for Solid applications",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -91,10 +91,8 @@
|
|
|
91
91
|
"@solid-primitives/refs": "^1.0.8",
|
|
92
92
|
"@solidjs/meta": "^0.29.4",
|
|
93
93
|
"isbot": "^5.1.22",
|
|
94
|
-
"tiny-invariant": "^1.3.3",
|
|
95
|
-
"tiny-warning": "^1.0.3",
|
|
96
94
|
"@tanstack/history": "1.161.6",
|
|
97
|
-
"@tanstack/router-core": "1.168.
|
|
95
|
+
"@tanstack/router-core": "1.168.3"
|
|
98
96
|
},
|
|
99
97
|
"devDependencies": {
|
|
100
98
|
"@solidjs/testing-library": "^0.8.10",
|
package/src/HeadContent.dev.tsx
CHANGED
|
@@ -3,6 +3,7 @@ import { For, createEffect, createMemo } from 'solid-js'
|
|
|
3
3
|
import { Asset } from './Asset'
|
|
4
4
|
import { useHydrated } from './ClientOnly'
|
|
5
5
|
import { useTags } from './headContentUtils'
|
|
6
|
+
import type { HeadContentProps } from './HeadContent'
|
|
6
7
|
|
|
7
8
|
const DEV_STYLES_ATTR = 'data-tanstack-router-dev-styles'
|
|
8
9
|
|
|
@@ -15,8 +16,8 @@ const DEV_STYLES_ATTR = 'data-tanstack-router-dev-styles'
|
|
|
15
16
|
* Development version: filters out dev styles link after hydration and
|
|
16
17
|
* includes a fallback cleanup effect for hydration mismatch cases.
|
|
17
18
|
*/
|
|
18
|
-
export function HeadContent() {
|
|
19
|
-
const tags = useTags()
|
|
19
|
+
export function HeadContent(props: HeadContentProps) {
|
|
20
|
+
const tags = useTags(props.assetCrossOrigin)
|
|
20
21
|
const hydrated = useHydrated()
|
|
21
22
|
|
|
22
23
|
// Fallback cleanup for hydration mismatch cases
|
package/src/HeadContent.tsx
CHANGED
|
@@ -2,6 +2,11 @@ import { MetaProvider } from '@solidjs/meta'
|
|
|
2
2
|
import { For } from 'solid-js'
|
|
3
3
|
import { Asset } from './Asset'
|
|
4
4
|
import { useTags } from './headContentUtils'
|
|
5
|
+
import type { AssetCrossOriginConfig } from '@tanstack/router-core'
|
|
6
|
+
|
|
7
|
+
export interface HeadContentProps {
|
|
8
|
+
assetCrossOrigin?: AssetCrossOriginConfig
|
|
9
|
+
}
|
|
5
10
|
|
|
6
11
|
/**
|
|
7
12
|
* @description The `HeadContent` component is used to render meta tags, links, and scripts for the current route.
|
|
@@ -9,8 +14,8 @@ import { useTags } from './headContentUtils'
|
|
|
9
14
|
* to ensure it's part of the reactive tree and updates correctly during client-side navigation.
|
|
10
15
|
* The component uses portals internally to render content into the `<head>` element.
|
|
11
16
|
*/
|
|
12
|
-
export function HeadContent() {
|
|
13
|
-
const tags = useTags()
|
|
17
|
+
export function HeadContent(props: HeadContentProps) {
|
|
18
|
+
const tags = useTags(props.assetCrossOrigin)
|
|
14
19
|
|
|
15
20
|
return (
|
|
16
21
|
<MetaProvider>
|
package/src/Match.tsx
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import * as Solid from 'solid-js'
|
|
2
|
-
import invariant from 'tiny-invariant'
|
|
3
|
-
import warning from 'tiny-warning'
|
|
4
2
|
import {
|
|
5
3
|
createControlledPromise,
|
|
6
4
|
getLocationChangeInfo,
|
|
5
|
+
invariant,
|
|
7
6
|
isNotFound,
|
|
8
7
|
isRedirect,
|
|
9
8
|
rootRouteId,
|
|
@@ -119,10 +118,11 @@ export const Match = (props: { matchId: string }) => {
|
|
|
119
118
|
onCatch={(error: Error) => {
|
|
120
119
|
// Forward not found errors (we don't want to show the error component for these)
|
|
121
120
|
if (isNotFound(error)) throw error
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
121
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
122
|
+
console.warn(
|
|
123
|
+
`Warning: Error in route match: ${currentMatchState().routeId}`,
|
|
124
|
+
)
|
|
125
|
+
}
|
|
126
126
|
routeOnCatch()?.(error)
|
|
127
127
|
}}
|
|
128
128
|
>
|
|
@@ -342,10 +342,15 @@ export const MatchInner = (): any => {
|
|
|
342
342
|
</Solid.Match>
|
|
343
343
|
<Solid.Match when={currentMatch().status === 'notFound'}>
|
|
344
344
|
{(_) => {
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
345
|
+
if (!isNotFound(currentMatch().error)) {
|
|
346
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
347
|
+
throw new Error(
|
|
348
|
+
'Invariant failed: Expected a notFound error',
|
|
349
|
+
)
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
invariant()
|
|
353
|
+
}
|
|
349
354
|
|
|
350
355
|
// Use Show with keyed to ensure re-render when routeId changes
|
|
351
356
|
return (
|
|
@@ -359,10 +364,15 @@ export const MatchInner = (): any => {
|
|
|
359
364
|
</Solid.Match>
|
|
360
365
|
<Solid.Match when={currentMatch().status === 'redirected'}>
|
|
361
366
|
{(_) => {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
367
|
+
if (!isRedirect(currentMatch().error)) {
|
|
368
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
369
|
+
throw new Error(
|
|
370
|
+
'Invariant failed: Expected a redirect error',
|
|
371
|
+
)
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
invariant()
|
|
375
|
+
}
|
|
366
376
|
|
|
367
377
|
const [loaderResult] = Solid.createResource(async () => {
|
|
368
378
|
await new Promise((r) => setTimeout(r, 0))
|
package/src/Matches.tsx
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as Solid from 'solid-js'
|
|
2
|
-
import warning from 'tiny-warning'
|
|
3
2
|
import { replaceEqualDeep, rootRouteId } from '@tanstack/router-core'
|
|
4
3
|
import { isServer } from '@tanstack/router-core/isServer'
|
|
5
4
|
import { CatchBoundary, ErrorComponent } from './CatchBoundary'
|
|
@@ -103,11 +102,10 @@ function MatchesInner() {
|
|
|
103
102
|
onCatch={
|
|
104
103
|
process.env.NODE_ENV !== 'production'
|
|
105
104
|
? (error) => {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
`The following error wasn't caught by any route! At the very least, consider setting an 'errorComponent' in your RootRoute!`,
|
|
105
|
+
console.warn(
|
|
106
|
+
`Warning: The following error wasn't caught by any route! At the very least, consider setting an 'errorComponent' in your RootRoute!`,
|
|
109
107
|
)
|
|
110
|
-
|
|
108
|
+
console.warn(`Warning: ${error.message || error.toString()}`)
|
|
111
109
|
}
|
|
112
110
|
: undefined
|
|
113
111
|
}
|
package/src/fileRoute.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import warning from 'tiny-warning'
|
|
2
1
|
import { createRoute } from './route'
|
|
3
2
|
|
|
4
3
|
import { useMatch } from './useMatch'
|
|
@@ -140,10 +139,11 @@ export class FileRoute<
|
|
|
140
139
|
THandlers
|
|
141
140
|
> => {
|
|
142
141
|
if (process.env.NODE_ENV !== 'production') {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
142
|
+
if (!this.silent) {
|
|
143
|
+
console.warn(
|
|
144
|
+
'Warning: FileRoute is deprecated and will be removed in the next major version. Use the createFileRoute(path)(options) function instead.',
|
|
145
|
+
)
|
|
146
|
+
}
|
|
147
147
|
}
|
|
148
148
|
const route = createRoute(options as any)
|
|
149
149
|
;(route as any).isRoot = false
|
|
@@ -177,9 +177,8 @@ export function FileRouteLoader<
|
|
|
177
177
|
>,
|
|
178
178
|
) => TLoaderFn {
|
|
179
179
|
if (process.env.NODE_ENV !== 'production') {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
`FileRouteLoader is deprecated and will be removed in the next major version. Please place the loader function in the the main route file, inside the \`createFileRoute('/path/to/file')(options)\` options`,
|
|
180
|
+
console.warn(
|
|
181
|
+
`Warning: FileRouteLoader is deprecated and will be removed in the next major version. Please place the loader function in the the main route file, inside the \`createFileRoute('/path/to/file')(options)\` options`,
|
|
183
182
|
)
|
|
184
183
|
}
|
|
185
184
|
return (loaderFn) => loaderFn as any
|
package/src/headContentUtils.tsx
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import * as Solid from 'solid-js'
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
escapeHtml,
|
|
4
|
+
getAssetCrossOrigin,
|
|
5
|
+
replaceEqualDeep,
|
|
6
|
+
resolveManifestAssetLink,
|
|
7
|
+
} from '@tanstack/router-core'
|
|
3
8
|
import { useRouter } from './useRouter'
|
|
4
|
-
import type {
|
|
9
|
+
import type {
|
|
10
|
+
AssetCrossOriginConfig,
|
|
11
|
+
RouterManagedTag,
|
|
12
|
+
} from '@tanstack/router-core'
|
|
5
13
|
|
|
6
14
|
/**
|
|
7
15
|
* Build the list of head/link/meta/script tags to render for active matches.
|
|
8
16
|
* Used internally by `HeadContent`.
|
|
9
17
|
*/
|
|
10
|
-
export const useTags = () => {
|
|
18
|
+
export const useTags = (assetCrossOrigin?: AssetCrossOriginConfig) => {
|
|
11
19
|
const router = useRouter()
|
|
12
20
|
const nonce = router.options.ssr?.nonce
|
|
13
21
|
const activeMatches = Solid.createMemo(
|
|
@@ -116,7 +124,13 @@ export const useTags = () => {
|
|
|
116
124
|
(asset) =>
|
|
117
125
|
({
|
|
118
126
|
tag: 'link',
|
|
119
|
-
attrs: {
|
|
127
|
+
attrs: {
|
|
128
|
+
...asset.attrs,
|
|
129
|
+
crossOrigin:
|
|
130
|
+
getAssetCrossOrigin(assetCrossOrigin, 'stylesheet') ??
|
|
131
|
+
asset.attrs?.crossOrigin,
|
|
132
|
+
nonce,
|
|
133
|
+
},
|
|
120
134
|
}) satisfies RouterManagedTag,
|
|
121
135
|
)
|
|
122
136
|
|
|
@@ -133,11 +147,15 @@ export const useTags = () => {
|
|
|
133
147
|
router.ssr?.manifest?.routes[route.id]?.preloads
|
|
134
148
|
?.filter(Boolean)
|
|
135
149
|
.forEach((preload) => {
|
|
150
|
+
const preloadLink = resolveManifestAssetLink(preload)
|
|
136
151
|
preloadLinks.push({
|
|
137
152
|
tag: 'link',
|
|
138
153
|
attrs: {
|
|
139
154
|
rel: 'modulepreload',
|
|
140
|
-
href:
|
|
155
|
+
href: preloadLink.href,
|
|
156
|
+
crossOrigin:
|
|
157
|
+
getAssetCrossOrigin(assetCrossOrigin, 'modulepreload') ??
|
|
158
|
+
preloadLink.crossOrigin,
|
|
141
159
|
nonce,
|
|
142
160
|
},
|
|
143
161
|
})
|
|
@@ -179,8 +197,8 @@ export const useTags = () => {
|
|
|
179
197
|
})),
|
|
180
198
|
)
|
|
181
199
|
|
|
182
|
-
return () =>
|
|
183
|
-
uniqBy(
|
|
200
|
+
return Solid.createMemo((prev: Array<RouterManagedTag> | undefined) => {
|
|
201
|
+
const next = uniqBy(
|
|
184
202
|
[
|
|
185
203
|
...meta(),
|
|
186
204
|
...preloadLinks(),
|
|
@@ -192,6 +210,11 @@ export const useTags = () => {
|
|
|
192
210
|
return JSON.stringify(d)
|
|
193
211
|
},
|
|
194
212
|
)
|
|
213
|
+
if (prev === undefined) {
|
|
214
|
+
return next
|
|
215
|
+
}
|
|
216
|
+
return replaceEqualDeep(prev, next)
|
|
217
|
+
})
|
|
195
218
|
}
|
|
196
219
|
|
|
197
220
|
export function uniqBy<T>(arr: Array<T>, fn: (item: T) => string) {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import warning from 'tiny-warning'
|
|
2
1
|
import { DefaultGlobalNotFound } from './not-found'
|
|
3
2
|
import type { AnyRoute, AnyRouter } from '@tanstack/router-core'
|
|
4
3
|
|
|
@@ -20,11 +19,12 @@ export function renderRouteNotFound(
|
|
|
20
19
|
return <router.options.defaultNotFoundComponent {...data} />
|
|
21
20
|
}
|
|
22
21
|
|
|
23
|
-
if (process.env.NODE_ENV
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
23
|
+
if (!route.options.notFoundComponent) {
|
|
24
|
+
console.warn(
|
|
25
|
+
`Warning: A notFoundError was encountered on the route with ID "${route.id}", but a notFoundComponent option was not configured, nor was a router level defaultNotFoundComponent configured. Consider configuring at least one of these to avoid TanStack Router's overly generic defaultNotFoundComponent (<p>Not Found</p>)`,
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
return <DefaultGlobalNotFound />
|
package/src/useMatch.tsx
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as Solid from 'solid-js'
|
|
2
|
-
import invariant from '
|
|
3
|
-
import { replaceEqualDeep } from '@tanstack/router-core'
|
|
2
|
+
import { invariant, replaceEqualDeep } from '@tanstack/router-core'
|
|
4
3
|
import { nearestMatchContext } from './matchContext'
|
|
5
4
|
import { useRouter } from './useRouter'
|
|
6
5
|
import type {
|
|
@@ -92,14 +91,19 @@ export function useMatch<
|
|
|
92
91
|
? Boolean(router.stores.pendingRouteIds.state[opts.from!])
|
|
93
92
|
: (nearestMatch?.hasPending() ?? false)
|
|
94
93
|
|
|
95
|
-
|
|
96
|
-
!
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
)
|
|
101
|
-
|
|
102
|
-
|
|
94
|
+
if (
|
|
95
|
+
!hasPendingMatch &&
|
|
96
|
+
!router.stores.isTransitioning.state &&
|
|
97
|
+
(opts.shouldThrow ?? true)
|
|
98
|
+
) {
|
|
99
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
100
|
+
throw new Error(
|
|
101
|
+
`Invariant failed: Could not find ${opts.from ? `an active match from "${opts.from}"` : 'a nearest match!'}`,
|
|
102
|
+
)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
invariant()
|
|
106
|
+
}
|
|
103
107
|
})
|
|
104
108
|
|
|
105
109
|
return Solid.createMemo((prev: TSelected | undefined) => {
|
package/src/useRouter.tsx
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as Solid from 'solid-js'
|
|
2
|
-
import warning from 'tiny-warning'
|
|
3
2
|
import { routerContext } from './routerContext'
|
|
4
3
|
import type { AnyRouter, RegisteredRouter } from '@tanstack/router-core'
|
|
5
4
|
|
|
@@ -7,9 +6,12 @@ export function useRouter<TRouter extends AnyRouter = RegisteredRouter>(opts?: {
|
|
|
7
6
|
warn?: boolean
|
|
8
7
|
}): TRouter {
|
|
9
8
|
const value = Solid.useContext(routerContext as any)
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
10
|
+
if ((opts?.warn ?? true) && !value) {
|
|
11
|
+
console.warn(
|
|
12
|
+
'Warning: useRouter must be used inside a <RouterProvider> component!',
|
|
13
|
+
)
|
|
14
|
+
}
|
|
15
|
+
}
|
|
14
16
|
return value as any
|
|
15
17
|
}
|