@tanstack/react-router-devtools 0.0.1-beta.83 → 1.114.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/LICENSE +1 -1
- package/README.md +3 -1
- package/dist/cjs/TanStackRouterDevtools.cjs +72 -0
- package/dist/cjs/TanStackRouterDevtools.cjs.map +1 -0
- package/dist/cjs/TanStackRouterDevtools.d.cts +41 -0
- package/dist/cjs/TanStackRouterDevtoolsPanel.cjs +44 -0
- package/dist/cjs/TanStackRouterDevtoolsPanel.cjs.map +1 -0
- package/dist/cjs/TanStackRouterDevtoolsPanel.d.cts +33 -0
- package/dist/cjs/index.cjs +17 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.cts +6 -0
- package/dist/esm/TanStackRouterDevtools.d.ts +41 -0
- package/dist/esm/TanStackRouterDevtools.js +72 -0
- package/dist/esm/TanStackRouterDevtools.js.map +1 -0
- package/dist/esm/TanStackRouterDevtoolsPanel.d.ts +33 -0
- package/dist/esm/TanStackRouterDevtoolsPanel.js +44 -0
- package/dist/esm/TanStackRouterDevtoolsPanel.js.map +1 -0
- package/dist/esm/index.d.ts +6 -0
- package/dist/esm/index.js +17 -0
- package/dist/esm/index.js.map +1 -0
- package/package.json +42 -26
- package/src/TanStackRouterDevtools.tsx +134 -0
- package/src/TanStackRouterDevtoolsPanel.tsx +87 -0
- package/src/index.ts +22 -0
- package/build/cjs/Explorer.js +0 -216
- package/build/cjs/Explorer.js.map +0 -1
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -31
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +0 -1
- package/build/cjs/devtools.js +0 -583
- package/build/cjs/devtools.js.map +0 -1
- package/build/cjs/index.js +0 -21
- package/build/cjs/index.js.map +0 -1
- package/build/cjs/styledComponents.js +0 -79
- package/build/cjs/styledComponents.js.map +0 -1
- package/build/cjs/theme.js +0 -51
- package/build/cjs/theme.js.map +0 -1
- package/build/cjs/useLocalStorage.js +0 -58
- package/build/cjs/useLocalStorage.js.map +0 -1
- package/build/cjs/useMediaQuery.js +0 -58
- package/build/cjs/useMediaQuery.js.map +0 -1
- package/build/cjs/utils.js +0 -107
- package/build/cjs/utils.js.map +0 -1
- package/build/esm/index.js +0 -984
- package/build/esm/index.js.map +0 -1
- package/build/stats-html.html +0 -4044
- package/build/stats-react.json +0 -504
- package/build/types/index.d.ts +0 -77
- package/build/umd/index.development.js +0 -1119
- package/build/umd/index.development.js.map +0 -1
- package/build/umd/index.production.js +0 -54
- package/build/umd/index.production.js.map +0 -1
- package/src/Explorer.tsx +0 -290
- package/src/devtools.tsx +0 -984
- package/src/index.tsx +0 -1
- package/src/styledComponents.ts +0 -106
- package/src/theme.tsx +0 -31
- package/src/useLocalStorage.ts +0 -52
- package/src/useMediaQuery.ts +0 -39
- package/src/utils.ts +0 -169
package/src/index.tsx
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './devtools'
|
package/src/styledComponents.ts
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { styled } from './utils'
|
|
2
|
-
|
|
3
|
-
export const Panel = styled(
|
|
4
|
-
'div',
|
|
5
|
-
(_props, theme) => ({
|
|
6
|
-
fontSize: 'clamp(12px, 1.5vw, 14px)',
|
|
7
|
-
fontFamily: `sans-serif`,
|
|
8
|
-
display: 'flex',
|
|
9
|
-
backgroundColor: theme.background,
|
|
10
|
-
color: theme.foreground,
|
|
11
|
-
}),
|
|
12
|
-
{
|
|
13
|
-
'(max-width: 700px)': {
|
|
14
|
-
flexDirection: 'column',
|
|
15
|
-
},
|
|
16
|
-
'(max-width: 600px)': {
|
|
17
|
-
fontSize: '.9em',
|
|
18
|
-
// flexDirection: 'column',
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
)
|
|
22
|
-
|
|
23
|
-
export const ActivePanel = styled(
|
|
24
|
-
'div',
|
|
25
|
-
() => ({
|
|
26
|
-
flex: '1 1 500px',
|
|
27
|
-
display: 'flex',
|
|
28
|
-
flexDirection: 'column',
|
|
29
|
-
overflow: 'auto',
|
|
30
|
-
height: '100%',
|
|
31
|
-
}),
|
|
32
|
-
{
|
|
33
|
-
'(max-width: 700px)': (_props, theme) => ({
|
|
34
|
-
borderTop: `2px solid ${theme.gray}`,
|
|
35
|
-
}),
|
|
36
|
-
},
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
export const Button = styled('button', (props, theme) => ({
|
|
40
|
-
appearance: 'none',
|
|
41
|
-
fontSize: '.9em',
|
|
42
|
-
fontWeight: 'bold',
|
|
43
|
-
background: theme.gray,
|
|
44
|
-
border: '0',
|
|
45
|
-
borderRadius: '.3em',
|
|
46
|
-
color: 'white',
|
|
47
|
-
padding: '.5em',
|
|
48
|
-
opacity: props.disabled ? '.5' : undefined,
|
|
49
|
-
cursor: 'pointer',
|
|
50
|
-
}))
|
|
51
|
-
|
|
52
|
-
// export const QueryKeys = styled('span', {
|
|
53
|
-
// display: 'inline-block',
|
|
54
|
-
// fontSize: '0.9em',
|
|
55
|
-
// })
|
|
56
|
-
|
|
57
|
-
// export const QueryKey = styled('span', {
|
|
58
|
-
// display: 'inline-flex',
|
|
59
|
-
// alignItems: 'center',
|
|
60
|
-
// padding: '.2em .4em',
|
|
61
|
-
// fontWeight: 'bold',
|
|
62
|
-
// textShadow: '0 0 10px black',
|
|
63
|
-
// borderRadius: '.2em',
|
|
64
|
-
// })
|
|
65
|
-
|
|
66
|
-
export const Code = styled('code', {
|
|
67
|
-
fontSize: '.9em',
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
export const Input = styled('input', (_props, theme) => ({
|
|
71
|
-
backgroundColor: theme.inputBackgroundColor,
|
|
72
|
-
border: 0,
|
|
73
|
-
borderRadius: '.2em',
|
|
74
|
-
color: theme.inputTextColor,
|
|
75
|
-
fontSize: '.9em',
|
|
76
|
-
lineHeight: `1.3`,
|
|
77
|
-
padding: '.3em .4em',
|
|
78
|
-
}))
|
|
79
|
-
|
|
80
|
-
export const Select = styled(
|
|
81
|
-
'select',
|
|
82
|
-
(_props, theme) => ({
|
|
83
|
-
display: `inline-block`,
|
|
84
|
-
fontSize: `.9em`,
|
|
85
|
-
fontFamily: `sans-serif`,
|
|
86
|
-
fontWeight: 'normal',
|
|
87
|
-
lineHeight: `1.3`,
|
|
88
|
-
padding: `.3em 1.5em .3em .5em`,
|
|
89
|
-
height: 'auto',
|
|
90
|
-
border: 0,
|
|
91
|
-
borderRadius: `.2em`,
|
|
92
|
-
appearance: `none`,
|
|
93
|
-
WebkitAppearance: 'none',
|
|
94
|
-
backgroundColor: theme.inputBackgroundColor,
|
|
95
|
-
backgroundImage: `url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100' fill='%23444444'><polygon points='0,25 100,25 50,75'/></svg>")`,
|
|
96
|
-
backgroundRepeat: `no-repeat`,
|
|
97
|
-
backgroundPosition: `right .55em center`,
|
|
98
|
-
backgroundSize: `.65em auto, 100%`,
|
|
99
|
-
color: theme.inputTextColor,
|
|
100
|
-
}),
|
|
101
|
-
{
|
|
102
|
-
'(max-width: 500px)': {
|
|
103
|
-
display: 'none',
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
)
|
package/src/theme.tsx
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
|
|
3
|
-
export const defaultTheme = {
|
|
4
|
-
background: '#0b1521',
|
|
5
|
-
backgroundAlt: '#132337',
|
|
6
|
-
foreground: 'white',
|
|
7
|
-
gray: '#3f4e60',
|
|
8
|
-
grayAlt: '#222e3e',
|
|
9
|
-
inputBackgroundColor: '#fff',
|
|
10
|
-
inputTextColor: '#000',
|
|
11
|
-
success: '#00ab52',
|
|
12
|
-
danger: '#ff0085',
|
|
13
|
-
active: '#006bff',
|
|
14
|
-
warning: '#ffb200',
|
|
15
|
-
} as const
|
|
16
|
-
|
|
17
|
-
export type Theme = typeof defaultTheme
|
|
18
|
-
interface ProviderProps {
|
|
19
|
-
theme: Theme
|
|
20
|
-
children?: React.ReactNode
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const ThemeContext = React.createContext(defaultTheme)
|
|
24
|
-
|
|
25
|
-
export function ThemeProvider({ theme, ...rest }: ProviderProps) {
|
|
26
|
-
return <ThemeContext.Provider value={theme} {...rest} />
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function useTheme() {
|
|
30
|
-
return React.useContext(ThemeContext)
|
|
31
|
-
}
|
package/src/useLocalStorage.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
|
|
3
|
-
const getItem = (key: string): unknown => {
|
|
4
|
-
try {
|
|
5
|
-
const itemValue = localStorage.getItem(key)
|
|
6
|
-
if (typeof itemValue === 'string') {
|
|
7
|
-
return JSON.parse(itemValue)
|
|
8
|
-
}
|
|
9
|
-
return undefined
|
|
10
|
-
} catch {
|
|
11
|
-
return undefined
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export default function useLocalStorage<T>(
|
|
16
|
-
key: string,
|
|
17
|
-
defaultValue: T | undefined,
|
|
18
|
-
): [T | undefined, (newVal: T | ((prevVal: T) => T)) => void] {
|
|
19
|
-
const [value, setValue] = React.useState<T>()
|
|
20
|
-
|
|
21
|
-
React.useEffect(() => {
|
|
22
|
-
const initialValue = getItem(key) as T | undefined
|
|
23
|
-
|
|
24
|
-
if (typeof initialValue === 'undefined' || initialValue === null) {
|
|
25
|
-
setValue(
|
|
26
|
-
typeof defaultValue === 'function' ? defaultValue() : defaultValue,
|
|
27
|
-
)
|
|
28
|
-
} else {
|
|
29
|
-
setValue(initialValue)
|
|
30
|
-
}
|
|
31
|
-
}, [defaultValue, key])
|
|
32
|
-
|
|
33
|
-
const setter = React.useCallback(
|
|
34
|
-
(updater: any) => {
|
|
35
|
-
setValue((old) => {
|
|
36
|
-
let newVal = updater
|
|
37
|
-
|
|
38
|
-
if (typeof updater == 'function') {
|
|
39
|
-
newVal = updater(old)
|
|
40
|
-
}
|
|
41
|
-
try {
|
|
42
|
-
localStorage.setItem(key, JSON.stringify(newVal))
|
|
43
|
-
} catch {}
|
|
44
|
-
|
|
45
|
-
return newVal
|
|
46
|
-
})
|
|
47
|
-
},
|
|
48
|
-
[key],
|
|
49
|
-
)
|
|
50
|
-
|
|
51
|
-
return [value, setter]
|
|
52
|
-
}
|
package/src/useMediaQuery.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
|
|
3
|
-
export default function useMediaQuery(query: string): boolean | undefined {
|
|
4
|
-
// Keep track of the preference in state, start with the current match
|
|
5
|
-
const [isMatch, setIsMatch] = React.useState(() => {
|
|
6
|
-
if (typeof window !== 'undefined') {
|
|
7
|
-
return window.matchMedia && window.matchMedia(query).matches
|
|
8
|
-
}
|
|
9
|
-
return
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
// Watch for changes
|
|
13
|
-
React.useEffect(() => {
|
|
14
|
-
if (typeof window !== 'undefined') {
|
|
15
|
-
if (!window.matchMedia) {
|
|
16
|
-
return
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// Create a matcher
|
|
20
|
-
const matcher = window.matchMedia(query)
|
|
21
|
-
|
|
22
|
-
// Create our handler
|
|
23
|
-
const onChange = ({ matches }: { matches: boolean }) =>
|
|
24
|
-
setIsMatch(matches)
|
|
25
|
-
|
|
26
|
-
// Listen for changes
|
|
27
|
-
matcher.addListener(onChange)
|
|
28
|
-
|
|
29
|
-
return () => {
|
|
30
|
-
// Stop listening for changes
|
|
31
|
-
matcher.removeListener(onChange)
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return
|
|
36
|
-
}, [isMatch, query, setIsMatch])
|
|
37
|
-
|
|
38
|
-
return isMatch
|
|
39
|
-
}
|
package/src/utils.ts
DELETED
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { AnyRouteMatch, RouteMatch } from '@tanstack/react-router'
|
|
3
|
-
|
|
4
|
-
import { Theme, useTheme } from './theme'
|
|
5
|
-
import useMediaQuery from './useMediaQuery'
|
|
6
|
-
|
|
7
|
-
export const isServer = typeof window === 'undefined'
|
|
8
|
-
|
|
9
|
-
type StyledComponent<T> = T extends 'button'
|
|
10
|
-
? React.DetailedHTMLProps<
|
|
11
|
-
React.ButtonHTMLAttributes<HTMLButtonElement>,
|
|
12
|
-
HTMLButtonElement
|
|
13
|
-
>
|
|
14
|
-
: T extends 'input'
|
|
15
|
-
? React.DetailedHTMLProps<
|
|
16
|
-
React.InputHTMLAttributes<HTMLInputElement>,
|
|
17
|
-
HTMLInputElement
|
|
18
|
-
>
|
|
19
|
-
: T extends 'select'
|
|
20
|
-
? React.DetailedHTMLProps<
|
|
21
|
-
React.SelectHTMLAttributes<HTMLSelectElement>,
|
|
22
|
-
HTMLSelectElement
|
|
23
|
-
>
|
|
24
|
-
: T extends keyof HTMLElementTagNameMap
|
|
25
|
-
? React.HTMLAttributes<HTMLElementTagNameMap[T]>
|
|
26
|
-
: never
|
|
27
|
-
|
|
28
|
-
export function getStatusColor(match: AnyRouteMatch, theme: Theme) {
|
|
29
|
-
return match.state.status === 'pending'
|
|
30
|
-
? theme.active
|
|
31
|
-
: match.state.status === 'error'
|
|
32
|
-
? theme.danger
|
|
33
|
-
: match.state.status === 'success'
|
|
34
|
-
? theme.success
|
|
35
|
-
: theme.gray
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
type Styles =
|
|
39
|
-
| React.CSSProperties
|
|
40
|
-
| ((props: Record<string, any>, theme: Theme) => React.CSSProperties)
|
|
41
|
-
|
|
42
|
-
export function styled<T extends keyof HTMLElementTagNameMap>(
|
|
43
|
-
type: T,
|
|
44
|
-
newStyles: Styles,
|
|
45
|
-
queries: Record<string, Styles> = {},
|
|
46
|
-
) {
|
|
47
|
-
return React.forwardRef<HTMLElementTagNameMap[T], StyledComponent<T>>(
|
|
48
|
-
({ style, ...rest }, ref) => {
|
|
49
|
-
const theme = useTheme()
|
|
50
|
-
|
|
51
|
-
const mediaStyles = Object.entries(queries).reduce(
|
|
52
|
-
(current, [key, value]) => {
|
|
53
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
54
|
-
return useMediaQuery(key)
|
|
55
|
-
? {
|
|
56
|
-
...current,
|
|
57
|
-
...(typeof value === 'function' ? value(rest, theme) : value),
|
|
58
|
-
}
|
|
59
|
-
: current
|
|
60
|
-
},
|
|
61
|
-
{},
|
|
62
|
-
)
|
|
63
|
-
|
|
64
|
-
return React.createElement(type, {
|
|
65
|
-
...rest,
|
|
66
|
-
style: {
|
|
67
|
-
...(typeof newStyles === 'function'
|
|
68
|
-
? newStyles(rest, theme)
|
|
69
|
-
: newStyles),
|
|
70
|
-
...style,
|
|
71
|
-
...mediaStyles,
|
|
72
|
-
},
|
|
73
|
-
ref,
|
|
74
|
-
})
|
|
75
|
-
},
|
|
76
|
-
)
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export function useIsMounted() {
|
|
80
|
-
const mountedRef = React.useRef(false)
|
|
81
|
-
const isMounted = React.useCallback(() => mountedRef.current, [])
|
|
82
|
-
|
|
83
|
-
React[isServer ? 'useEffect' : 'useLayoutEffect'](() => {
|
|
84
|
-
mountedRef.current = true
|
|
85
|
-
return () => {
|
|
86
|
-
mountedRef.current = false
|
|
87
|
-
}
|
|
88
|
-
}, [])
|
|
89
|
-
|
|
90
|
-
return isMounted
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Displays a string regardless the type of the data
|
|
95
|
-
* @param {unknown} value Value to be stringified
|
|
96
|
-
*/
|
|
97
|
-
export const displayValue = (value: unknown) => {
|
|
98
|
-
const name = Object.getOwnPropertyNames(Object(value))
|
|
99
|
-
const newValue = typeof value === 'bigint' ? `${value.toString()}n` : value
|
|
100
|
-
|
|
101
|
-
return JSON.stringify(newValue, name)
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* This hook is a safe useState version which schedules state updates in microtasks
|
|
106
|
-
* to prevent updating a component state while React is rendering different components
|
|
107
|
-
* or when the component is not mounted anymore.
|
|
108
|
-
*/
|
|
109
|
-
export function useSafeState<T>(initialState: T): [T, (value: T) => void] {
|
|
110
|
-
const isMounted = useIsMounted()
|
|
111
|
-
const [state, setState] = React.useState(initialState)
|
|
112
|
-
|
|
113
|
-
const safeSetState = React.useCallback(
|
|
114
|
-
(value: T) => {
|
|
115
|
-
scheduleMicrotask(() => {
|
|
116
|
-
if (isMounted()) {
|
|
117
|
-
setState(value)
|
|
118
|
-
}
|
|
119
|
-
})
|
|
120
|
-
},
|
|
121
|
-
[isMounted],
|
|
122
|
-
)
|
|
123
|
-
|
|
124
|
-
return [state, safeSetState]
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Schedules a microtask.
|
|
129
|
-
* This can be useful to schedule state updates after rendering.
|
|
130
|
-
*/
|
|
131
|
-
function scheduleMicrotask(callback: () => void) {
|
|
132
|
-
Promise.resolve()
|
|
133
|
-
.then(callback)
|
|
134
|
-
.catch((error) =>
|
|
135
|
-
setTimeout(() => {
|
|
136
|
-
throw error
|
|
137
|
-
}),
|
|
138
|
-
)
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
export function multiSortBy<T>(
|
|
142
|
-
arr: T[],
|
|
143
|
-
accessors: ((item: T) => any)[] = [(d) => d],
|
|
144
|
-
): T[] {
|
|
145
|
-
return arr
|
|
146
|
-
.map((d, i) => [d, i] as const)
|
|
147
|
-
.sort(([a, ai], [b, bi]) => {
|
|
148
|
-
for (const accessor of accessors) {
|
|
149
|
-
const ao = accessor(a)
|
|
150
|
-
const bo = accessor(b)
|
|
151
|
-
|
|
152
|
-
if (typeof ao === 'undefined') {
|
|
153
|
-
if (typeof bo === 'undefined') {
|
|
154
|
-
continue
|
|
155
|
-
}
|
|
156
|
-
return 1
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
if (ao === bo) {
|
|
160
|
-
continue
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
return ao > bo ? 1 : -1
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
return ai - bi
|
|
167
|
-
})
|
|
168
|
-
.map(([d]) => d)
|
|
169
|
-
}
|