@tanstack/react-router-devtools 0.0.1-alpha.4 → 0.0.1-alpha.5
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/build/cjs/packages/react-router-devtools/src/Explorer.js +8 -18
- package/build/cjs/packages/react-router-devtools/src/Explorer.js.map +1 -1
- package/build/cjs/packages/react-router-devtools/src/devtools.js +21 -13
- package/build/cjs/packages/react-router-devtools/src/devtools.js.map +1 -1
- package/build/esm/index.js +29 -31
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +2677 -2677
- package/build/umd/index.development.js +29 -31
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
- package/src/Explorer.tsx +13 -14
- package/src/devtools.tsx +53 -42
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/react-router-devtools",
|
|
3
3
|
"author": "Tanner Linsley",
|
|
4
|
-
"version": "0.0.1-alpha.
|
|
4
|
+
"version": "0.0.1-alpha.5",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "tanstack/router",
|
|
7
7
|
"homepage": "https://react-router.tanstack.com/",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"src"
|
|
36
36
|
],
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@tanstack/react-router": "0.0.1-alpha.
|
|
38
|
+
"@tanstack/react-router": "0.0.1-alpha.5",
|
|
39
39
|
"react": ">=16",
|
|
40
40
|
"react-dom": ">=16"
|
|
41
41
|
},
|
package/src/Explorer.tsx
CHANGED
|
@@ -67,7 +67,7 @@ type Entry = {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
type RendererProps = {
|
|
70
|
-
|
|
70
|
+
handleEntry: HandleEntryFn
|
|
71
71
|
label?: React.ReactNode
|
|
72
72
|
value: unknown
|
|
73
73
|
subEntries: Entry[]
|
|
@@ -102,7 +102,7 @@ export function chunkArray<T>(array: T[], size: number): T[][] {
|
|
|
102
102
|
type Renderer = (props: RendererProps) => JSX.Element
|
|
103
103
|
|
|
104
104
|
export const DefaultRenderer: Renderer = ({
|
|
105
|
-
|
|
105
|
+
handleEntry,
|
|
106
106
|
label,
|
|
107
107
|
value,
|
|
108
108
|
subEntries = [],
|
|
@@ -134,9 +134,7 @@ export const DefaultRenderer: Renderer = ({
|
|
|
134
134
|
{expanded ? (
|
|
135
135
|
subEntryPages.length === 1 ? (
|
|
136
136
|
<SubEntries>
|
|
137
|
-
{subEntries.map((entry) => (
|
|
138
|
-
<HandleEntry key={entry.label} entry={entry} />
|
|
139
|
-
))}
|
|
137
|
+
{subEntries.map((entry, index) => handleEntry(entry))}
|
|
140
138
|
</SubEntries>
|
|
141
139
|
) : (
|
|
142
140
|
<SubEntries>
|
|
@@ -157,9 +155,7 @@ export const DefaultRenderer: Renderer = ({
|
|
|
157
155
|
</LabelButton>
|
|
158
156
|
{expandedPages.includes(index) ? (
|
|
159
157
|
<SubEntries>
|
|
160
|
-
{entries.map((entry) => (
|
|
161
|
-
<HandleEntry key={entry.label} entry={entry} />
|
|
162
|
-
))}
|
|
158
|
+
{entries.map((entry) => handleEntry(entry))}
|
|
163
159
|
</SubEntries>
|
|
164
160
|
) : null}
|
|
165
161
|
</Entry>
|
|
@@ -198,7 +194,7 @@ export const DefaultRenderer: Renderer = ({
|
|
|
198
194
|
)
|
|
199
195
|
}
|
|
200
196
|
|
|
201
|
-
type
|
|
197
|
+
type HandleEntryFn = (entry: Entry) => JSX.Element
|
|
202
198
|
|
|
203
199
|
type ExplorerProps = Partial<RendererProps> & {
|
|
204
200
|
renderer?: Renderer
|
|
@@ -273,11 +269,14 @@ export default function Explorer({
|
|
|
273
269
|
const subEntryPages = chunkArray(subEntries, pageSize)
|
|
274
270
|
|
|
275
271
|
return renderer({
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
272
|
+
handleEntry: (entry) => (
|
|
273
|
+
<Explorer
|
|
274
|
+
key={entry.label}
|
|
275
|
+
value={value}
|
|
276
|
+
renderer={renderer}
|
|
277
|
+
{...rest}
|
|
278
|
+
{...entry}
|
|
279
|
+
/>
|
|
281
280
|
),
|
|
282
281
|
type,
|
|
283
282
|
subEntries,
|
package/src/devtools.tsx
CHANGED
|
@@ -365,12 +365,40 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
|
|
|
365
365
|
} = props
|
|
366
366
|
|
|
367
367
|
const router = useRouter() as Router
|
|
368
|
+
const routerExplorerValue = React.useMemo(() => {
|
|
369
|
+
const {
|
|
370
|
+
listeners,
|
|
371
|
+
buildLocation,
|
|
372
|
+
mount,
|
|
373
|
+
update,
|
|
374
|
+
buildNext,
|
|
375
|
+
navigate,
|
|
376
|
+
cancelMatches,
|
|
377
|
+
loadLocation,
|
|
378
|
+
cleanPreloadCache,
|
|
379
|
+
loadRoute,
|
|
380
|
+
matchRoutes,
|
|
381
|
+
loadMatches,
|
|
382
|
+
invalidateRoute,
|
|
383
|
+
resolvePath,
|
|
384
|
+
matchRoute,
|
|
385
|
+
buildLink,
|
|
386
|
+
__experimental__createSnapshot,
|
|
387
|
+
destroy,
|
|
388
|
+
...rest
|
|
389
|
+
} = router
|
|
390
|
+
|
|
391
|
+
return rest
|
|
392
|
+
}, [router.state])
|
|
393
|
+
|
|
394
|
+
const rerender = React.useReducer(() => ({}), {})[1]
|
|
368
395
|
|
|
369
396
|
React.useEffect(() => {
|
|
370
397
|
let interval = setInterval(() => {
|
|
371
398
|
router.cleanPreloadCache()
|
|
372
|
-
router.notify()
|
|
373
|
-
|
|
399
|
+
// router.notify()
|
|
400
|
+
rerender()
|
|
401
|
+
}, 250)
|
|
374
402
|
|
|
375
403
|
return () => {
|
|
376
404
|
clearInterval(interval)
|
|
@@ -386,6 +414,27 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
|
|
|
386
414
|
(d) => d.routeId === activeRouteId,
|
|
387
415
|
)
|
|
388
416
|
|
|
417
|
+
const activeMatchExplorerValue = React.useMemo(() => {
|
|
418
|
+
if (!activeMatch) {
|
|
419
|
+
return {}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
const {
|
|
423
|
+
cancel,
|
|
424
|
+
load,
|
|
425
|
+
router,
|
|
426
|
+
Link,
|
|
427
|
+
MatchRoute,
|
|
428
|
+
buildLink,
|
|
429
|
+
linkProps,
|
|
430
|
+
matchRoute,
|
|
431
|
+
navigate,
|
|
432
|
+
...rest
|
|
433
|
+
} = activeMatch
|
|
434
|
+
|
|
435
|
+
return rest
|
|
436
|
+
}, [activeMatch])
|
|
437
|
+
|
|
389
438
|
return (
|
|
390
439
|
<ThemeProvider theme={theme}>
|
|
391
440
|
<Panel ref={ref} className="TanStackRouterDevtoolsPanel" {...panelProps}>
|
|
@@ -505,30 +554,7 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
|
|
|
505
554
|
>
|
|
506
555
|
<Explorer
|
|
507
556
|
label="Router"
|
|
508
|
-
value={
|
|
509
|
-
const {
|
|
510
|
-
listeners,
|
|
511
|
-
buildLocation,
|
|
512
|
-
mount,
|
|
513
|
-
update,
|
|
514
|
-
buildNext,
|
|
515
|
-
navigate,
|
|
516
|
-
cancelMatches,
|
|
517
|
-
loadLocation,
|
|
518
|
-
cleanPreloadCache,
|
|
519
|
-
loadRoute,
|
|
520
|
-
matchRoutes,
|
|
521
|
-
loadMatches,
|
|
522
|
-
invalidateRoute,
|
|
523
|
-
resolvePath,
|
|
524
|
-
matchRoute,
|
|
525
|
-
buildLink,
|
|
526
|
-
__experimental__createSnapshot,
|
|
527
|
-
destroy,
|
|
528
|
-
...rest
|
|
529
|
-
} = router
|
|
530
|
-
return rest
|
|
531
|
-
})()}
|
|
557
|
+
value={routerExplorerValue}
|
|
532
558
|
defaultExpanded={{}}
|
|
533
559
|
/>
|
|
534
560
|
</div>
|
|
@@ -860,22 +886,7 @@ export const TanStackRouterDevtoolsPanel = React.forwardRef<
|
|
|
860
886
|
>
|
|
861
887
|
<Explorer
|
|
862
888
|
label="Match"
|
|
863
|
-
value={
|
|
864
|
-
const {
|
|
865
|
-
cancel,
|
|
866
|
-
load,
|
|
867
|
-
router,
|
|
868
|
-
Link,
|
|
869
|
-
MatchRoute,
|
|
870
|
-
buildLink,
|
|
871
|
-
linkProps,
|
|
872
|
-
matchRoute,
|
|
873
|
-
navigate,
|
|
874
|
-
...rest
|
|
875
|
-
} = activeMatch
|
|
876
|
-
|
|
877
|
-
return rest
|
|
878
|
-
})()}
|
|
889
|
+
value={activeMatchExplorerValue}
|
|
879
890
|
defaultExpanded={{}}
|
|
880
891
|
/>
|
|
881
892
|
</div>
|