@tanstack/query-devtools 5.0.0-alpha.52 → 5.0.0-alpha.54
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/{lib/index.cjs → cjs/Devtools-5f8e85ff.js} +1687 -2980
- package/build/cjs/Devtools-5f8e85ff.js.map +1 -0
- package/build/cjs/index-db699afb.js +1395 -0
- package/build/cjs/index-db699afb.js.map +1 -0
- package/build/cjs/index.js +8 -0
- package/build/cjs/index.js.map +1 -0
- package/build/{lib/index.js → esm/Devtools-8dd32079.js} +1407 -2706
- package/build/esm/Devtools-8dd32079.js.map +1 -0
- package/build/esm/index-34324cec.js +1365 -0
- package/build/esm/index-34324cec.js.map +1 -0
- package/build/esm/index.js +2 -0
- package/build/esm/index.js.map +1 -0
- package/build/source/Devtools.jsx +25 -1
- package/build/source/Explorer.jsx +2 -4
- package/build/source/index.jsx +21 -4
- package/build/source/utils.jsx +5 -2
- package/build/types/Context.d.ts +0 -1
- package/build/types/Devtools.d.ts +1 -2
- package/build/types/Explorer.d.ts +0 -1
- package/build/types/fonts.d.ts +0 -1
- package/build/types/icons/index.d.ts +0 -1
- package/build/types/index.d.ts +2 -1
- package/build/types/theme.d.ts +0 -1
- package/build/types/utils.d.ts +5 -4
- package/package.json +15 -8
- package/src/Devtools.tsx +40 -0
- package/src/Explorer.tsx +16 -18
- package/src/index.tsx +14 -3
- package/src/utils.tsx +12 -2
- package/build/lib/index.cjs.map +0 -1
- package/build/lib/index.js.map +0 -1
- package/build/source/__tests__/devtools.test.jsx +0 -6
- package/build/stats-html.html +0 -6177
- package/build/stats.json +0 -1699
- package/build/types/Context.d.ts.map +0 -1
- package/build/types/Devtools.d.ts.map +0 -1
- package/build/types/Explorer.d.ts.map +0 -1
- package/build/types/__tests__/devtools.test.d.ts +0 -1
- package/build/types/__tests__/devtools.test.d.ts.map +0 -1
- package/build/types/fonts.d.ts.map +0 -1
- package/build/types/icons/index.d.ts.map +0 -1
- package/build/types/index.d.ts.map +0 -1
- package/build/types/theme.d.ts.map +0 -1
- package/build/types/utils.d.ts.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/query-devtools",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.54",
|
|
4
4
|
"description": "Developer tools to interact with and visualize the TanStack Query cache",
|
|
5
5
|
"author": "tannerlinsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -12,15 +12,19 @@
|
|
|
12
12
|
},
|
|
13
13
|
"type": "module",
|
|
14
14
|
"types": "build/types/index.d.ts",
|
|
15
|
-
"main": "build/
|
|
16
|
-
"module": "build/
|
|
15
|
+
"main": "build/cjs/index.js",
|
|
16
|
+
"module": "build/esm/index.js",
|
|
17
17
|
"exports": {
|
|
18
18
|
".": {
|
|
19
19
|
"types": "./build/types/index.d.ts",
|
|
20
20
|
"solid": "./build/source/index.jsx",
|
|
21
|
-
"import": "./build/
|
|
22
|
-
"
|
|
23
|
-
|
|
21
|
+
"import": "./build/esm/index.js",
|
|
22
|
+
"browser": {
|
|
23
|
+
"import": "./build/esm/index.js",
|
|
24
|
+
"require": "./build/cjs/index.js"
|
|
25
|
+
},
|
|
26
|
+
"require": "./build/cjs/index.js",
|
|
27
|
+
"node": "./build/cjs/index.js"
|
|
24
28
|
},
|
|
25
29
|
"./package.json": "./package.json"
|
|
26
30
|
},
|
|
@@ -40,6 +44,7 @@
|
|
|
40
44
|
},
|
|
41
45
|
"devDependencies": {
|
|
42
46
|
"@tanstack/query-core": "^5.0.0-alpha.43",
|
|
47
|
+
"rollup-preset-solid": "^2.0.1",
|
|
43
48
|
"vite-plugin-solid": "^2.5.0"
|
|
44
49
|
},
|
|
45
50
|
"scripts": {
|
|
@@ -48,8 +53,10 @@
|
|
|
48
53
|
"test:types": "tsc --noEmit",
|
|
49
54
|
"test:lib": "vitest run --coverage",
|
|
50
55
|
"test:lib:dev": "pnpm run test:lib --watch",
|
|
51
|
-
"build": "
|
|
56
|
+
"test:build": "publint",
|
|
57
|
+
"build": "pnpm build:rollup && pnpm rename-build-dir",
|
|
58
|
+
"rename-build-dir": "rimraf ./build && mv ./dist ./build",
|
|
52
59
|
"build:rollup": "rollup --config rollup.config.js",
|
|
53
|
-
"build:types": "tsc"
|
|
60
|
+
"build:types": "tsc --emitDeclarationOnly"
|
|
54
61
|
}
|
|
55
62
|
}
|
package/src/Devtools.tsx
CHANGED
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
getQueryStatusColorByLabel,
|
|
21
21
|
sortFns,
|
|
22
22
|
convertRemToPixels,
|
|
23
|
+
getSidedProp,
|
|
23
24
|
} from './utils'
|
|
24
25
|
import {
|
|
25
26
|
ArrowDown,
|
|
@@ -82,6 +83,8 @@ export const DevtoolsComponent: Component<QueryDevtoolsProps> = (props) => {
|
|
|
82
83
|
)
|
|
83
84
|
}
|
|
84
85
|
|
|
86
|
+
export default DevtoolsComponent
|
|
87
|
+
|
|
85
88
|
export const Devtools = () => {
|
|
86
89
|
loadFonts()
|
|
87
90
|
|
|
@@ -315,6 +318,42 @@ export const DevtoolsPanel: Component<DevtoolsPanelProps> = (props) => {
|
|
|
315
318
|
setSettingsOpen(false)
|
|
316
319
|
}
|
|
317
320
|
|
|
321
|
+
createEffect(() => {
|
|
322
|
+
const rootContainer = panelRef.parentElement?.parentElement?.parentElement
|
|
323
|
+
if (!rootContainer) return
|
|
324
|
+
const styleProp = getSidedProp(
|
|
325
|
+
'padding',
|
|
326
|
+
props.localStore.position as DevtoolsPosition,
|
|
327
|
+
)
|
|
328
|
+
const isVertical =
|
|
329
|
+
props.localStore.position === 'left' ||
|
|
330
|
+
props.localStore.position === 'right'
|
|
331
|
+
const previousPaddings = (({
|
|
332
|
+
padding,
|
|
333
|
+
paddingTop,
|
|
334
|
+
paddingBottom,
|
|
335
|
+
paddingLeft,
|
|
336
|
+
paddingRight,
|
|
337
|
+
}) => ({
|
|
338
|
+
padding,
|
|
339
|
+
paddingTop,
|
|
340
|
+
paddingBottom,
|
|
341
|
+
paddingLeft,
|
|
342
|
+
paddingRight,
|
|
343
|
+
}))(rootContainer.style)
|
|
344
|
+
|
|
345
|
+
rootContainer.style[styleProp] = `${
|
|
346
|
+
isVertical ? props.localStore.width : props.localStore.height
|
|
347
|
+
}px`
|
|
348
|
+
|
|
349
|
+
onCleanup(() => {
|
|
350
|
+
Object.entries(previousPaddings).forEach(([property, previousValue]) => {
|
|
351
|
+
rootContainer.style[property as keyof typeof previousPaddings] =
|
|
352
|
+
previousValue
|
|
353
|
+
})
|
|
354
|
+
})
|
|
355
|
+
})
|
|
356
|
+
|
|
318
357
|
return (
|
|
319
358
|
<aside
|
|
320
359
|
// Some context for styles here
|
|
@@ -1200,6 +1239,7 @@ const getStyles = () => {
|
|
|
1200
1239
|
font-family: 'Inter', sans-serif;
|
|
1201
1240
|
color: ${colors.gray[300]};
|
|
1202
1241
|
box-sizing: border-box;
|
|
1242
|
+
text-transform: none;
|
|
1203
1243
|
}
|
|
1204
1244
|
`,
|
|
1205
1245
|
'devtoolsBtn-position-bottom-right': css`
|
package/src/Explorer.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { displayValue } from './utils'
|
|
2
|
-
import
|
|
2
|
+
import { stringify } from 'superjson'
|
|
3
3
|
import { css, cx } from '@emotion/css'
|
|
4
4
|
import { tokens } from './theme'
|
|
5
5
|
import { createMemo, createSignal, Index, Match, Show, Switch } from 'solid-js'
|
|
@@ -77,23 +77,21 @@ const CopyButton = (props: { value: unknown }) => {
|
|
|
77
77
|
onClick={
|
|
78
78
|
copyState() === 'NoCopy'
|
|
79
79
|
? () => {
|
|
80
|
-
navigator.clipboard
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
() => {
|
|
84
|
-
setCopyState('
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
(
|
|
90
|
-
|
|
91
|
-
setCopyState('
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
},
|
|
96
|
-
)
|
|
80
|
+
navigator.clipboard.writeText(stringify(props.value)).then(
|
|
81
|
+
() => {
|
|
82
|
+
setCopyState('SuccessCopy')
|
|
83
|
+
setTimeout(() => {
|
|
84
|
+
setCopyState('NoCopy')
|
|
85
|
+
}, 1500)
|
|
86
|
+
},
|
|
87
|
+
(err) => {
|
|
88
|
+
console.error('Failed to copy: ', err)
|
|
89
|
+
setCopyState('ErrorCopy')
|
|
90
|
+
setTimeout(() => {
|
|
91
|
+
setCopyState('NoCopy')
|
|
92
|
+
}, 1500)
|
|
93
|
+
},
|
|
94
|
+
)
|
|
97
95
|
}
|
|
98
96
|
: undefined
|
|
99
97
|
}
|
package/src/index.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import type {
|
|
|
2
2
|
QueryClient,
|
|
3
3
|
onlineManager as TonlineManager,
|
|
4
4
|
} from '@tanstack/query-core'
|
|
5
|
-
import { DevtoolsComponent } from './Devtools'
|
|
5
|
+
import type { DevtoolsComponent } from './Devtools'
|
|
6
6
|
import { render } from 'solid-js/web'
|
|
7
7
|
import type {
|
|
8
8
|
DevtoolsButtonPosition,
|
|
@@ -11,7 +11,7 @@ import type {
|
|
|
11
11
|
DevToolsErrorType,
|
|
12
12
|
} from './Context'
|
|
13
13
|
import type { Signal } from 'solid-js'
|
|
14
|
-
import { createSignal } from 'solid-js'
|
|
14
|
+
import { createSignal, lazy } from 'solid-js'
|
|
15
15
|
|
|
16
16
|
export type { DevtoolsButtonPosition, DevtoolsPosition, DevToolsErrorType }
|
|
17
17
|
export interface TanstackQueryDevtoolsConfig extends QueryDevtoolsProps {}
|
|
@@ -26,6 +26,7 @@ class TanstackQueryDevtools {
|
|
|
26
26
|
position: Signal<DevtoolsPosition | undefined>
|
|
27
27
|
initialIsOpen: Signal<boolean | undefined>
|
|
28
28
|
errorTypes: Signal<DevToolsErrorType[] | undefined>
|
|
29
|
+
Component: typeof DevtoolsComponent | undefined
|
|
29
30
|
dispose?: () => void
|
|
30
31
|
|
|
31
32
|
constructor(config: TanstackQueryDevtoolsConfig) {
|
|
@@ -79,8 +80,18 @@ class TanstackQueryDevtools {
|
|
|
79
80
|
const [isOpen] = this.initialIsOpen
|
|
80
81
|
const [errors] = this.errorTypes
|
|
81
82
|
const [queryClient] = this.client
|
|
83
|
+
|
|
84
|
+
let Devtools: typeof DevtoolsComponent
|
|
85
|
+
|
|
86
|
+
if (this.Component) {
|
|
87
|
+
Devtools = this.Component
|
|
88
|
+
} else {
|
|
89
|
+
Devtools = lazy(() => import('./Devtools'))
|
|
90
|
+
this.Component = Devtools
|
|
91
|
+
}
|
|
92
|
+
|
|
82
93
|
return (
|
|
83
|
-
<
|
|
94
|
+
<Devtools
|
|
84
95
|
queryFlavor={this.queryFlavor}
|
|
85
96
|
version={this.version}
|
|
86
97
|
onlineManager={this.onlineManager}
|
package/src/utils.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Query } from '@tanstack/query-core'
|
|
2
|
-
import
|
|
2
|
+
import { serialize } from 'superjson'
|
|
3
|
+
import type { DevtoolsPosition } from './Context'
|
|
3
4
|
|
|
4
5
|
export function getQueryStatusLabel(query: Query) {
|
|
5
6
|
return query.state.fetchStatus === 'fetching'
|
|
@@ -22,6 +23,15 @@ export const queryStatusLabels = [
|
|
|
22
23
|
] as const
|
|
23
24
|
export type IQueryStatusLabel = (typeof queryStatusLabels)[number]
|
|
24
25
|
|
|
26
|
+
export function getSidedProp<T extends string>(
|
|
27
|
+
prop: T,
|
|
28
|
+
side: DevtoolsPosition,
|
|
29
|
+
) {
|
|
30
|
+
return `${prop}${
|
|
31
|
+
side.charAt(0).toUpperCase() + side.slice(1)
|
|
32
|
+
}` as `${T}${Capitalize<DevtoolsPosition>}`
|
|
33
|
+
}
|
|
34
|
+
|
|
25
35
|
export function getQueryStatusColor({
|
|
26
36
|
queryState,
|
|
27
37
|
observerCount,
|
|
@@ -60,7 +70,7 @@ export function getQueryStatusColorByLabel(label: IQueryStatusLabel) {
|
|
|
60
70
|
* @param {boolean} beautify Formats json to multiline
|
|
61
71
|
*/
|
|
62
72
|
export const displayValue = (value: unknown, beautify: boolean = false) => {
|
|
63
|
-
const { json } =
|
|
73
|
+
const { json } = serialize(value)
|
|
64
74
|
|
|
65
75
|
return JSON.stringify(json, null, beautify ? 2 : undefined)
|
|
66
76
|
}
|