@tanstack/preact-query-devtools 0.0.1 → 5.94.4
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 +21 -0
- package/package.json +93 -8
- package/src/PreactQueryDevtools.tsx +127 -0
- package/src/PreactQueryDevtoolsPanel.tsx +110 -0
- package/src/index.ts +18 -0
- package/src/production.ts +5 -0
- package/README.md +0 -45
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021-present Tanner Linsley
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
CHANGED
|
@@ -1,10 +1,95 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/preact-query-devtools",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
"version": "5.94.4",
|
|
4
|
+
"description": "Developer tools to interact with and visualize the TanStack/preact-query cache",
|
|
5
|
+
"author": "tannerlinsley",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/TanStack/query.git",
|
|
10
|
+
"directory": "packages/preact-query-devtools"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://tanstack.com/query",
|
|
13
|
+
"funding": {
|
|
14
|
+
"type": "github",
|
|
15
|
+
"url": "https://github.com/sponsors/tannerlinsley"
|
|
16
|
+
},
|
|
17
|
+
"type": "module",
|
|
18
|
+
"types": "build/legacy/index.d.ts",
|
|
19
|
+
"main": "build/legacy/index.cjs",
|
|
20
|
+
"module": "build/legacy/index.js",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"@tanstack/custom-condition": "./src/index.ts",
|
|
24
|
+
"import": {
|
|
25
|
+
"types": "./build/modern/index.d.ts",
|
|
26
|
+
"default": "./build/modern/index.js"
|
|
27
|
+
},
|
|
28
|
+
"require": {
|
|
29
|
+
"types": "./build/modern/index.d.cts",
|
|
30
|
+
"default": "./build/modern/index.cjs"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"./production": {
|
|
34
|
+
"import": {
|
|
35
|
+
"types": "./build/modern/production.d.ts",
|
|
36
|
+
"default": "./build/modern/production.js"
|
|
37
|
+
},
|
|
38
|
+
"require": {
|
|
39
|
+
"types": "./build/modern/production.d.cts",
|
|
40
|
+
"default": "./build/modern/production.cjs"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"./build/modern/production.js": {
|
|
44
|
+
"import": {
|
|
45
|
+
"types": "./build/modern/production.d.ts",
|
|
46
|
+
"default": "./build/modern/production.js"
|
|
47
|
+
},
|
|
48
|
+
"require": {
|
|
49
|
+
"types": "./build/modern/production.d.cts",
|
|
50
|
+
"default": "./build/modern/production.cjs"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"./package.json": "./package.json"
|
|
54
|
+
},
|
|
55
|
+
"sideEffects": false,
|
|
56
|
+
"files": [
|
|
57
|
+
"build",
|
|
58
|
+
"src",
|
|
59
|
+
"!src/__tests__"
|
|
60
|
+
],
|
|
61
|
+
"dependencies": {
|
|
62
|
+
"@tanstack/query-devtools": "5.94.4"
|
|
63
|
+
},
|
|
64
|
+
"devDependencies": {
|
|
65
|
+
"@preact/preset-vite": "^2.10.2",
|
|
66
|
+
"@testing-library/preact": "^3.2.4",
|
|
67
|
+
"eslint-config-preact": "^2.0.0",
|
|
68
|
+
"npm-run-all2": "^5.0.0",
|
|
69
|
+
"preact": "^10.28.0",
|
|
70
|
+
"typescript": "5.9.3",
|
|
71
|
+
"typescript-eslint": "^8.54.0",
|
|
72
|
+
"@tanstack/preact-query": "5.94.4"
|
|
73
|
+
},
|
|
74
|
+
"peerDependencies": {
|
|
75
|
+
"preact": "^10.0.0",
|
|
76
|
+
"@tanstack/preact-query": "^5.94.4"
|
|
77
|
+
},
|
|
78
|
+
"scripts": {
|
|
79
|
+
"clean": "premove ./build ./coverage ./dist-ts",
|
|
80
|
+
"compile": "tsc --build",
|
|
81
|
+
"test:eslint": "eslint --concurrency=auto ./src",
|
|
82
|
+
"test:types": "npm-run-all --serial test:types:*",
|
|
83
|
+
"test:types:ts54": "node ../../node_modules/typescript54/lib/tsc.js --build tsconfig.legacy.json",
|
|
84
|
+
"test:types:ts55": "node ../../node_modules/typescript55/lib/tsc.js --build tsconfig.legacy.json",
|
|
85
|
+
"test:types:ts56": "node ../../node_modules/typescript56/lib/tsc.js --build tsconfig.legacy.json",
|
|
86
|
+
"test:types:ts57": "node ../../node_modules/typescript57/lib/tsc.js --build tsconfig.legacy.json",
|
|
87
|
+
"test:types:ts58": "node ../../node_modules/typescript58/lib/tsc.js --build tsconfig.legacy.json",
|
|
88
|
+
"test:types:ts59": "node ../../node_modules/typescript59/lib/tsc.js --build tsconfig.legacy.json",
|
|
89
|
+
"test:types:tscurrent": "tsc --build",
|
|
90
|
+
"test:types:ts60": "node ../../node_modules/typescript60/lib/tsc.js --build tsconfig.legacy.json",
|
|
91
|
+
"test:build": "publint --strict && attw --pack",
|
|
92
|
+
"build": "tsup --tsconfig tsconfig.prod.json",
|
|
93
|
+
"build:dev": "tsup --watch"
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { useRef, useState, useEffect } from 'preact/hooks'
|
|
2
|
+
import { onlineManager, useQueryClient } from '@tanstack/preact-query'
|
|
3
|
+
import { TanstackQueryDevtools } from '@tanstack/query-devtools'
|
|
4
|
+
import type {
|
|
5
|
+
DevtoolsButtonPosition,
|
|
6
|
+
DevtoolsErrorType,
|
|
7
|
+
DevtoolsPosition,
|
|
8
|
+
Theme,
|
|
9
|
+
} from '@tanstack/query-devtools'
|
|
10
|
+
import type { QueryClient } from '@tanstack/preact-query'
|
|
11
|
+
import type { VNode } from 'preact'
|
|
12
|
+
|
|
13
|
+
export interface DevtoolsOptions {
|
|
14
|
+
/**
|
|
15
|
+
* Set this true if you want the dev tools to default to being open
|
|
16
|
+
*/
|
|
17
|
+
initialIsOpen?: boolean
|
|
18
|
+
/**
|
|
19
|
+
* The position of the TanStack logo to open and close the devtools panel.
|
|
20
|
+
* Defaults to 'bottom-right'.
|
|
21
|
+
*/
|
|
22
|
+
buttonPosition?: DevtoolsButtonPosition
|
|
23
|
+
/**
|
|
24
|
+
* The position of the Preact Query devtools panel.
|
|
25
|
+
* Defaults to 'bottom'.
|
|
26
|
+
*/
|
|
27
|
+
position?: DevtoolsPosition
|
|
28
|
+
/**
|
|
29
|
+
* Use this to provide a custom QueryClient. Otherwise, the one from the
|
|
30
|
+
* nearest QueryClientProvider will be used.
|
|
31
|
+
*/
|
|
32
|
+
client?: QueryClient
|
|
33
|
+
/**
|
|
34
|
+
* Use this to provide custom error type handlers for the devtools panel.
|
|
35
|
+
*/
|
|
36
|
+
errorTypes?: Array<DevtoolsErrorType>
|
|
37
|
+
/**
|
|
38
|
+
* Use this to pass a nonce to the style tag that is added to the document
|
|
39
|
+
* head. This is useful if you are using a Content Security Policy (CSP)
|
|
40
|
+
* nonce to allow inline styles.
|
|
41
|
+
*/
|
|
42
|
+
styleNonce?: string
|
|
43
|
+
/**
|
|
44
|
+
* Use this to render the devtools inside a Shadow DOM.
|
|
45
|
+
*/
|
|
46
|
+
shadowDOMTarget?: ShadowRoot
|
|
47
|
+
/**
|
|
48
|
+
* Use this to hide disabled queries from the devtools panel.
|
|
49
|
+
*/
|
|
50
|
+
hideDisabledQueries?: boolean
|
|
51
|
+
/**
|
|
52
|
+
* Use this to set the theme of the devtools panel.
|
|
53
|
+
* Defaults to 'system'.
|
|
54
|
+
*/
|
|
55
|
+
theme?: Theme
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function PreactQueryDevtools(props: DevtoolsOptions): VNode | null {
|
|
59
|
+
const queryClient = useQueryClient(props.client)
|
|
60
|
+
const ref = useRef<HTMLDivElement>(null)
|
|
61
|
+
const {
|
|
62
|
+
buttonPosition,
|
|
63
|
+
position,
|
|
64
|
+
initialIsOpen,
|
|
65
|
+
errorTypes,
|
|
66
|
+
styleNonce,
|
|
67
|
+
shadowDOMTarget,
|
|
68
|
+
hideDisabledQueries,
|
|
69
|
+
theme,
|
|
70
|
+
} = props
|
|
71
|
+
const [devtools] = useState(
|
|
72
|
+
() =>
|
|
73
|
+
new TanstackQueryDevtools({
|
|
74
|
+
client: queryClient,
|
|
75
|
+
queryFlavor: 'Preact Query',
|
|
76
|
+
version: '5',
|
|
77
|
+
onlineManager,
|
|
78
|
+
buttonPosition,
|
|
79
|
+
position,
|
|
80
|
+
initialIsOpen,
|
|
81
|
+
errorTypes,
|
|
82
|
+
styleNonce,
|
|
83
|
+
shadowDOMTarget,
|
|
84
|
+
hideDisabledQueries,
|
|
85
|
+
theme,
|
|
86
|
+
}),
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
devtools.setClient(queryClient)
|
|
91
|
+
}, [queryClient, devtools])
|
|
92
|
+
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
if (buttonPosition) {
|
|
95
|
+
devtools.setButtonPosition(buttonPosition)
|
|
96
|
+
}
|
|
97
|
+
}, [buttonPosition, devtools])
|
|
98
|
+
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
if (position) {
|
|
101
|
+
devtools.setPosition(position)
|
|
102
|
+
}
|
|
103
|
+
}, [position, devtools])
|
|
104
|
+
|
|
105
|
+
useEffect(() => {
|
|
106
|
+
devtools.setInitialIsOpen(initialIsOpen || false)
|
|
107
|
+
}, [initialIsOpen, devtools])
|
|
108
|
+
|
|
109
|
+
useEffect(() => {
|
|
110
|
+
devtools.setErrorTypes(errorTypes || [])
|
|
111
|
+
}, [errorTypes, devtools])
|
|
112
|
+
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
devtools.setTheme(theme)
|
|
115
|
+
}, [theme, devtools])
|
|
116
|
+
|
|
117
|
+
useEffect(() => {
|
|
118
|
+
if (ref.current) {
|
|
119
|
+
devtools.mount(ref.current)
|
|
120
|
+
}
|
|
121
|
+
return () => {
|
|
122
|
+
devtools.unmount()
|
|
123
|
+
}
|
|
124
|
+
}, [devtools])
|
|
125
|
+
|
|
126
|
+
return <div dir="ltr" className="tsqd-parent-container" ref={ref} />
|
|
127
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { useRef, useState, useEffect } from 'preact/hooks'
|
|
2
|
+
import { onlineManager, useQueryClient } from '@tanstack/preact-query'
|
|
3
|
+
import { TanstackQueryDevtoolsPanel } from '@tanstack/query-devtools'
|
|
4
|
+
import type { DevtoolsErrorType, Theme } from '@tanstack/query-devtools'
|
|
5
|
+
import type { QueryClient } from '@tanstack/preact-query'
|
|
6
|
+
import type { JSX, VNode } from 'preact'
|
|
7
|
+
|
|
8
|
+
export interface DevtoolsPanelOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Use this to provide a custom QueryClient. Otherwise, the one from the
|
|
11
|
+
* nearest QueryClientProvider will be used.
|
|
12
|
+
*/
|
|
13
|
+
client?: QueryClient
|
|
14
|
+
/**
|
|
15
|
+
* Custom error types to be shown in the devtools.
|
|
16
|
+
*/
|
|
17
|
+
errorTypes?: Array<DevtoolsErrorType>
|
|
18
|
+
/**
|
|
19
|
+
* Use this to pass a nonce to the style tag that is added to the document
|
|
20
|
+
* head. This is useful if you are using a Content Security Policy (CSP)
|
|
21
|
+
* nonce to allow inline styles.
|
|
22
|
+
*/
|
|
23
|
+
styleNonce?: string
|
|
24
|
+
/**
|
|
25
|
+
* Use this to render the devtools inside a Shadow DOM.
|
|
26
|
+
*/
|
|
27
|
+
shadowDOMTarget?: ShadowRoot
|
|
28
|
+
/**
|
|
29
|
+
* Custom styles for the devtools panel container.
|
|
30
|
+
*/
|
|
31
|
+
style?: JSX.CSSProperties
|
|
32
|
+
/**
|
|
33
|
+
* Callback function when the devtools panel is closed.
|
|
34
|
+
*/
|
|
35
|
+
onClose?: () => unknown
|
|
36
|
+
/**
|
|
37
|
+
* Use this to hide disabled queries from the devtools panel.
|
|
38
|
+
*/
|
|
39
|
+
hideDisabledQueries?: boolean
|
|
40
|
+
/**
|
|
41
|
+
* Use this to set the theme of the devtools panel.
|
|
42
|
+
* Defaults to 'system'.
|
|
43
|
+
*/
|
|
44
|
+
theme?: Theme
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function PreactQueryDevtoolsPanel(
|
|
48
|
+
props: DevtoolsPanelOptions,
|
|
49
|
+
): VNode | null {
|
|
50
|
+
const queryClient = useQueryClient(props.client)
|
|
51
|
+
const ref = useRef<HTMLDivElement>(null)
|
|
52
|
+
const {
|
|
53
|
+
errorTypes,
|
|
54
|
+
styleNonce,
|
|
55
|
+
shadowDOMTarget,
|
|
56
|
+
hideDisabledQueries,
|
|
57
|
+
theme,
|
|
58
|
+
} = props
|
|
59
|
+
const [devtools] = useState(
|
|
60
|
+
() =>
|
|
61
|
+
new TanstackQueryDevtoolsPanel({
|
|
62
|
+
client: queryClient,
|
|
63
|
+
queryFlavor: 'Preact Query',
|
|
64
|
+
version: '5',
|
|
65
|
+
onlineManager,
|
|
66
|
+
buttonPosition: 'bottom-left',
|
|
67
|
+
position: 'bottom',
|
|
68
|
+
initialIsOpen: true,
|
|
69
|
+
errorTypes,
|
|
70
|
+
styleNonce,
|
|
71
|
+
shadowDOMTarget,
|
|
72
|
+
onClose: props.onClose,
|
|
73
|
+
hideDisabledQueries,
|
|
74
|
+
theme,
|
|
75
|
+
}),
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
devtools.setClient(queryClient)
|
|
80
|
+
}, [queryClient, devtools])
|
|
81
|
+
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
devtools.setOnClose(props.onClose ?? (() => {}))
|
|
84
|
+
}, [props.onClose, devtools])
|
|
85
|
+
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
devtools.setErrorTypes(errorTypes || [])
|
|
88
|
+
}, [errorTypes, devtools])
|
|
89
|
+
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
devtools.setTheme(theme)
|
|
92
|
+
}, [theme, devtools])
|
|
93
|
+
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
if (ref.current) {
|
|
96
|
+
devtools.mount(ref.current)
|
|
97
|
+
}
|
|
98
|
+
return () => {
|
|
99
|
+
devtools.unmount()
|
|
100
|
+
}
|
|
101
|
+
}, [devtools])
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<div
|
|
105
|
+
style={{ height: '500px', ...props.style }}
|
|
106
|
+
className="tsqd-parent-container"
|
|
107
|
+
ref={ref}
|
|
108
|
+
/>
|
|
109
|
+
)
|
|
110
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as Devtools from './PreactQueryDevtools'
|
|
2
|
+
import * as DevtoolsPanel from './PreactQueryDevtoolsPanel'
|
|
3
|
+
|
|
4
|
+
export const PreactQueryDevtools: (typeof Devtools)['PreactQueryDevtools'] =
|
|
5
|
+
process.env.NODE_ENV !== 'development'
|
|
6
|
+
? function () {
|
|
7
|
+
return null
|
|
8
|
+
}
|
|
9
|
+
: Devtools.PreactQueryDevtools
|
|
10
|
+
|
|
11
|
+
export const PreactQueryDevtoolsPanel: (typeof DevtoolsPanel)['PreactQueryDevtoolsPanel'] =
|
|
12
|
+
process.env.NODE_ENV !== 'development'
|
|
13
|
+
? function () {
|
|
14
|
+
return null
|
|
15
|
+
}
|
|
16
|
+
: DevtoolsPanel.PreactQueryDevtoolsPanel
|
|
17
|
+
|
|
18
|
+
export type DevtoolsPanelOptions = DevtoolsPanel.DevtoolsPanelOptions
|
package/README.md
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
# @tanstack/preact-query-devtools
|
|
2
|
-
|
|
3
|
-
## ⚠️ IMPORTANT NOTICE ⚠️
|
|
4
|
-
|
|
5
|
-
**This package is created solely for the purpose of setting up OIDC (OpenID Connect) trusted publishing with npm.**
|
|
6
|
-
|
|
7
|
-
This is **NOT** a functional package and contains **NO** code or functionality beyond the OIDC setup configuration.
|
|
8
|
-
|
|
9
|
-
## Purpose
|
|
10
|
-
|
|
11
|
-
This package exists to:
|
|
12
|
-
1. Configure OIDC trusted publishing for the package name `@tanstack/preact-query-devtools`
|
|
13
|
-
2. Enable secure, token-less publishing from CI/CD workflows
|
|
14
|
-
3. Establish provenance for packages published under this name
|
|
15
|
-
|
|
16
|
-
## What is OIDC Trusted Publishing?
|
|
17
|
-
|
|
18
|
-
OIDC trusted publishing allows package maintainers to publish packages directly from their CI/CD workflows without needing to manage npm access tokens. Instead, it uses OpenID Connect to establish trust between the CI/CD provider (like GitHub Actions) and npm.
|
|
19
|
-
|
|
20
|
-
## Setup Instructions
|
|
21
|
-
|
|
22
|
-
To properly configure OIDC trusted publishing for this package:
|
|
23
|
-
|
|
24
|
-
1. Go to [npmjs.com](https://www.npmjs.com/) and navigate to your package settings
|
|
25
|
-
2. Configure the trusted publisher (e.g., GitHub Actions)
|
|
26
|
-
3. Specify the repository and workflow that should be allowed to publish
|
|
27
|
-
4. Use the configured workflow to publish your actual package
|
|
28
|
-
|
|
29
|
-
## DO NOT USE THIS PACKAGE
|
|
30
|
-
|
|
31
|
-
This package is a placeholder for OIDC configuration only. It:
|
|
32
|
-
- Contains no executable code
|
|
33
|
-
- Provides no functionality
|
|
34
|
-
- Should not be installed as a dependency
|
|
35
|
-
- Exists only for administrative purposes
|
|
36
|
-
|
|
37
|
-
## More Information
|
|
38
|
-
|
|
39
|
-
For more details about npm's trusted publishing feature, see:
|
|
40
|
-
- [npm Trusted Publishing Documentation](https://docs.npmjs.com/generating-provenance-statements)
|
|
41
|
-
- [GitHub Actions OIDC Documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
|
|
42
|
-
|
|
43
|
-
---
|
|
44
|
-
|
|
45
|
-
**Maintained for OIDC setup purposes only**
|