@tanstack/react-router 1.133.8 → 1.133.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/dist/cjs/Asset.cjs +4 -6
- package/dist/cjs/Asset.cjs.map +1 -1
- package/dist/cjs/HeadContent.cjs +23 -7
- package/dist/cjs/HeadContent.cjs.map +1 -1
- package/dist/cjs/Scripts.cjs +5 -10
- package/dist/cjs/Scripts.cjs.map +1 -1
- package/dist/esm/Asset.js +4 -6
- package/dist/esm/Asset.js.map +1 -1
- package/dist/esm/HeadContent.js +23 -7
- package/dist/esm/HeadContent.js.map +1 -1
- package/dist/esm/Scripts.js +5 -10
- package/dist/esm/Scripts.js.map +1 -1
- package/dist/llms/rules/api.d.ts +1 -1
- package/dist/llms/rules/api.js +22 -4
- package/package.json +2 -2
- package/src/Asset.tsx +2 -9
- package/src/HeadContent.tsx +17 -2
- package/src/Scripts.tsx +4 -7
package/dist/llms/rules/api.js
CHANGED
|
@@ -263,7 +263,7 @@ The \`NavigateOptions\` object accepts the following properties:
|
|
|
263
263
|
- Optional
|
|
264
264
|
- Defaults to \`false\`.
|
|
265
265
|
- If \`true\`, navigation will be called using \`document.startViewTransition()\`.
|
|
266
|
-
- If [\`ViewTransitionOptions\`](../ViewTransitionOptionsType.md), route navigations will be called using \`document.startViewTransition({update, types})\` where \`types\` will
|
|
266
|
+
- If [\`ViewTransitionOptions\`](../ViewTransitionOptionsType.md), route navigations will be called using \`document.startViewTransition({update, types})\` where \`types\` will determine the strings array passed with \`ViewTransitionOptions["types"]\`. If the browser does not support viewTransition types, the navigation will fall back to normal \`document.startTransition()\`, same as if \`true\` was passed.
|
|
267
267
|
- If the browser does not support this api, this option will be ignored.
|
|
268
268
|
- See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Document/startViewTransition) for more information on how this function works.
|
|
269
269
|
- See [Google](https://developer.chrome.com/docs/web-platform/view-transitions/same-document#view-transition-types) for more information on viewTransition types
|
|
@@ -2003,7 +2003,15 @@ The \`ViewTransitionOptions\` type is used to define a
|
|
|
2003
2003
|
|
|
2004
2004
|
\`\`\`tsx
|
|
2005
2005
|
interface ViewTransitionOptions {
|
|
2006
|
-
types:
|
|
2006
|
+
types:
|
|
2007
|
+
| Array<string>
|
|
2008
|
+
| ((locationChangeInfo: {
|
|
2009
|
+
fromLocation?: ParsedLocation
|
|
2010
|
+
toLocation: ParsedLocation
|
|
2011
|
+
pathChanged: boolean
|
|
2012
|
+
hrefChanged: boolean
|
|
2013
|
+
hashChanged: boolean
|
|
2014
|
+
}) => Array<string> | false)
|
|
2007
2015
|
}
|
|
2008
2016
|
\`\`\`
|
|
2009
2017
|
|
|
@@ -2013,9 +2021,19 @@ The \`ViewTransitionOptions\` type accepts an object with a single property:
|
|
|
2013
2021
|
|
|
2014
2022
|
### \`types\` property
|
|
2015
2023
|
|
|
2016
|
-
- Type: \`Array<string
|
|
2024
|
+
- Type: \`Array<string> | ((locationChangeInfo: {
|
|
2025
|
+
fromLocation?: ParsedLocation
|
|
2026
|
+
toLocation: ParsedLocation
|
|
2027
|
+
pathChanged: boolean
|
|
2028
|
+
hrefChanged: boolean
|
|
2029
|
+
hashChanged: boolean
|
|
2030
|
+
}) => (Array<string> | false))\`
|
|
2017
2031
|
- Required
|
|
2018
|
-
-
|
|
2032
|
+
- Either one of:
|
|
2033
|
+
- An array of strings that will be passed to the \`document.startViewTransition({update, types}) call\`
|
|
2034
|
+
- A function that accepts \`locationChangeInfo\` object and returns either:
|
|
2035
|
+
- An array of strings that will be passed to the \`document.startViewTransition({update, types}) call\`
|
|
2036
|
+
- or \`false\` to skip the view transition
|
|
2019
2037
|
|
|
2020
2038
|
# Await component
|
|
2021
2039
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/react-router",
|
|
3
|
-
"version": "1.133.
|
|
3
|
+
"version": "1.133.12",
|
|
4
4
|
"description": "Modern and scalable routing for React applications",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"tiny-invariant": "^1.3.3",
|
|
81
81
|
"tiny-warning": "^1.0.3",
|
|
82
82
|
"@tanstack/history": "1.133.3",
|
|
83
|
-
"@tanstack/router-core": "1.133.
|
|
83
|
+
"@tanstack/router-core": "1.133.12"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
86
|
"@testing-library/jest-dom": "^6.6.3",
|
package/src/Asset.tsx
CHANGED
|
@@ -34,11 +34,7 @@ export function Asset({
|
|
|
34
34
|
/>
|
|
35
35
|
)
|
|
36
36
|
case 'script':
|
|
37
|
-
return
|
|
38
|
-
<Script attrs={attrs} nonce={nonce}>
|
|
39
|
-
{children}
|
|
40
|
-
</Script>
|
|
41
|
-
)
|
|
37
|
+
return <Script attrs={attrs}>{children}</Script>
|
|
42
38
|
default:
|
|
43
39
|
return null
|
|
44
40
|
}
|
|
@@ -47,11 +43,9 @@ export function Asset({
|
|
|
47
43
|
function Script({
|
|
48
44
|
attrs,
|
|
49
45
|
children,
|
|
50
|
-
nonce,
|
|
51
46
|
}: {
|
|
52
47
|
attrs?: ScriptAttrs
|
|
53
48
|
children?: string
|
|
54
|
-
nonce?: string
|
|
55
49
|
}) {
|
|
56
50
|
const router = useRouter()
|
|
57
51
|
|
|
@@ -154,7 +148,7 @@ function Script({
|
|
|
154
148
|
}
|
|
155
149
|
|
|
156
150
|
if (attrs?.src && typeof attrs.src === 'string') {
|
|
157
|
-
return <script {...attrs} suppressHydrationWarning
|
|
151
|
+
return <script {...attrs} suppressHydrationWarning />
|
|
158
152
|
}
|
|
159
153
|
|
|
160
154
|
if (typeof children === 'string') {
|
|
@@ -163,7 +157,6 @@ function Script({
|
|
|
163
157
|
{...attrs}
|
|
164
158
|
dangerouslySetInnerHTML={{ __html: children }}
|
|
165
159
|
suppressHydrationWarning
|
|
166
|
-
nonce={nonce}
|
|
167
160
|
/>
|
|
168
161
|
)
|
|
169
162
|
}
|
package/src/HeadContent.tsx
CHANGED
|
@@ -6,7 +6,7 @@ import type { RouterManagedTag } from '@tanstack/router-core'
|
|
|
6
6
|
|
|
7
7
|
export const useTags = () => {
|
|
8
8
|
const router = useRouter()
|
|
9
|
-
|
|
9
|
+
const nonce = router.options.ssr?.nonce
|
|
10
10
|
const routeMeta = useRouterState({
|
|
11
11
|
select: (state) => {
|
|
12
12
|
return state.matches.map((match) => match.meta!).filter(Boolean)
|
|
@@ -44,6 +44,7 @@ export const useTags = () => {
|
|
|
44
44
|
tag: 'meta',
|
|
45
45
|
attrs: {
|
|
46
46
|
...m,
|
|
47
|
+
nonce,
|
|
47
48
|
},
|
|
48
49
|
})
|
|
49
50
|
}
|
|
@@ -54,10 +55,19 @@ export const useTags = () => {
|
|
|
54
55
|
resultMeta.push(title)
|
|
55
56
|
}
|
|
56
57
|
|
|
58
|
+
if (nonce) {
|
|
59
|
+
resultMeta.push({
|
|
60
|
+
tag: 'meta',
|
|
61
|
+
attrs: {
|
|
62
|
+
property: 'csp-nonce',
|
|
63
|
+
content: nonce,
|
|
64
|
+
},
|
|
65
|
+
})
|
|
66
|
+
}
|
|
57
67
|
resultMeta.reverse()
|
|
58
68
|
|
|
59
69
|
return resultMeta
|
|
60
|
-
}, [routeMeta])
|
|
70
|
+
}, [routeMeta, nonce])
|
|
61
71
|
|
|
62
72
|
const links = useRouterState({
|
|
63
73
|
select: (state) => {
|
|
@@ -69,6 +79,7 @@ export const useTags = () => {
|
|
|
69
79
|
tag: 'link',
|
|
70
80
|
attrs: {
|
|
71
81
|
...link,
|
|
82
|
+
nonce,
|
|
72
83
|
},
|
|
73
84
|
})) satisfies Array<RouterManagedTag>
|
|
74
85
|
|
|
@@ -88,6 +99,7 @@ export const useTags = () => {
|
|
|
88
99
|
attrs: {
|
|
89
100
|
...asset.attrs,
|
|
90
101
|
suppressHydrationWarning: true,
|
|
102
|
+
nonce,
|
|
91
103
|
},
|
|
92
104
|
}) satisfies RouterManagedTag,
|
|
93
105
|
)
|
|
@@ -112,6 +124,7 @@ export const useTags = () => {
|
|
|
112
124
|
attrs: {
|
|
113
125
|
rel: 'modulepreload',
|
|
114
126
|
href: preload,
|
|
127
|
+
nonce,
|
|
115
128
|
},
|
|
116
129
|
})
|
|
117
130
|
}),
|
|
@@ -133,6 +146,7 @@ export const useTags = () => {
|
|
|
133
146
|
tag: 'style',
|
|
134
147
|
attrs,
|
|
135
148
|
children,
|
|
149
|
+
nonce,
|
|
136
150
|
})),
|
|
137
151
|
structuralSharing: true as any,
|
|
138
152
|
})
|
|
@@ -148,6 +162,7 @@ export const useTags = () => {
|
|
|
148
162
|
tag: 'script',
|
|
149
163
|
attrs: {
|
|
150
164
|
...script,
|
|
165
|
+
nonce,
|
|
151
166
|
},
|
|
152
167
|
children,
|
|
153
168
|
})),
|
package/src/Scripts.tsx
CHANGED
|
@@ -5,7 +5,7 @@ import type { RouterManagedTag } from '@tanstack/router-core'
|
|
|
5
5
|
|
|
6
6
|
export const Scripts = () => {
|
|
7
7
|
const router = useRouter()
|
|
8
|
-
|
|
8
|
+
const nonce = router.options.ssr?.nonce
|
|
9
9
|
const assetScripts = useRouterState({
|
|
10
10
|
select: (state) => {
|
|
11
11
|
const assetScripts: Array<RouterManagedTag> = []
|
|
@@ -23,7 +23,7 @@ export const Scripts = () => {
|
|
|
23
23
|
.forEach((asset) => {
|
|
24
24
|
assetScripts.push({
|
|
25
25
|
tag: 'script',
|
|
26
|
-
attrs: asset.attrs,
|
|
26
|
+
attrs: { ...asset.attrs, nonce },
|
|
27
27
|
children: asset.children,
|
|
28
28
|
} as any)
|
|
29
29
|
}),
|
|
@@ -46,6 +46,7 @@ export const Scripts = () => {
|
|
|
46
46
|
attrs: {
|
|
47
47
|
...script,
|
|
48
48
|
suppressHydrationWarning: true,
|
|
49
|
+
nonce,
|
|
49
50
|
},
|
|
50
51
|
children,
|
|
51
52
|
})),
|
|
@@ -58,11 +59,7 @@ export const Scripts = () => {
|
|
|
58
59
|
return (
|
|
59
60
|
<>
|
|
60
61
|
{allScripts.map((asset, i) => (
|
|
61
|
-
<Asset
|
|
62
|
-
{...asset}
|
|
63
|
-
key={`tsr-scripts-${asset.tag}-${i}`}
|
|
64
|
-
nonce={router.options.ssr?.nonce}
|
|
65
|
-
/>
|
|
62
|
+
<Asset {...asset} key={`tsr-scripts-${asset.tag}-${i}`} />
|
|
66
63
|
))}
|
|
67
64
|
</>
|
|
68
65
|
)
|