@tanstack/react-router 1.95.5 → 1.97.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/react-router",
3
- "version": "1.95.5",
3
+ "version": "1.97.0",
4
4
  "description": "Modern and scalable routing for React applications",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -53,7 +53,7 @@
53
53
  "jsesc": "^3.0.2",
54
54
  "tiny-invariant": "^1.3.3",
55
55
  "tiny-warning": "^1.0.3",
56
- "@tanstack/history": "1.95.2"
56
+ "@tanstack/history": "1.97.0"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@testing-library/jest-dom": "^6.6.3",
@@ -1,31 +1,14 @@
1
- import jsesc from 'jsesc'
1
+ import { useRouter } from './useRouter'
2
2
 
3
3
  export function ScriptOnce({
4
- className,
5
4
  children,
6
5
  log,
7
- ...rest
8
- }: { children: string; log?: boolean } & React.HTMLProps<HTMLScriptElement>) {
9
- if (typeof document !== 'undefined') {
10
- return null
11
- }
6
+ }: {
7
+ children: string
8
+ log?: boolean
9
+ }) {
10
+ const router = useRouter()
12
11
 
13
- return (
14
- <script
15
- {...rest}
16
- className={`tsr-once ${className || ''}`}
17
- dangerouslySetInnerHTML={{
18
- __html: [
19
- children,
20
- (log ?? true) && process.env.NODE_ENV === 'development'
21
- ? `console.info(\`Injected From Server:
22
- ${jsesc(children.toString(), { quotes: 'backtick' })}\`)`
23
- : '',
24
- 'if (typeof __TSR__ !== "undefined") __TSR__.cleanScripts()',
25
- ]
26
- .filter(Boolean)
27
- .join('\n'),
28
- }}
29
- />
30
- )
12
+ router.injectScript(children, { logScript: log })
13
+ return null
31
14
  }
package/src/router.ts CHANGED
@@ -6,6 +6,7 @@ import {
6
6
  import { Store, batch } from '@tanstack/react-store'
7
7
  import invariant from 'tiny-invariant'
8
8
  import warning from 'tiny-warning'
9
+ import jsesc from 'jsesc'
9
10
  import { rootRouteId } from './root'
10
11
  import { defaultParseSearch, defaultStringifySearch } from './searchParams'
11
12
  import {
@@ -3100,7 +3101,7 @@ export class Router<
3100
3101
  `<script class='tsr-once'>${script}${
3101
3102
  process.env.NODE_ENV === 'development' && (opts?.logScript ?? true)
3102
3103
  ? `; console.info(\`Injected From Server:
3103
- ${script}\`)`
3104
+ ${jsesc(script, { quotes: 'backtick' })}\`)`
3104
3105
  : ''
3105
3106
  }; if (typeof __TSR__ !== 'undefined') __TSR__.cleanScripts()</script>`,
3106
3107
  )