-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Add preact query devtools #10119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
JoviDeCroock
wants to merge
1
commit into
TanStack:main
Choose a base branch
from
JoviDeCroock:add-preact-devtools-package
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+690
−0
Open
Add preact query devtools #10119
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| --- | ||
| id: devtools | ||
| title: Devtools | ||
| --- | ||
|
|
||
| Wave your hands in the air and shout hooray because Preact Query comes with dedicated devtools! 🥳 | ||
|
|
||
| When you begin your Preact Query journey, you'll want these devtools by your side. They help visualize all of the inner workings of Preact Query and will likely save you hours of debugging if you find yourself in a pinch! | ||
|
|
||
| > For Chrome, Firefox, and Edge users: Third-party browser extensions are available for debugging TanStack Query directly in browser DevTools. These provide the same functionality as the framework-specific devtools packages: | ||
| > | ||
| > - <img alt="Chrome logo" src="https://www.google.com/chrome/static/images/chrome-logo.svg" width="16" height="16" class="inline mr-1 not-prose" /> [Devtools for Chrome](https://chromewebstore.google.com/detail/tanstack-query-devtools/annajfchloimdhceglpgglpeepfghfai) | ||
| > - <img alt="Firefox logo" src="https://upload.wikimedia.org/wikipedia/commons/a/a0/Firefox_logo%2C_2019.svg" width="16" height="16" class="inline mr-1 not-prose" /> [Devtools for Firefox](https://addons.mozilla.org/en-US/firefox/addon/tanstack-query-devtools/) | ||
| > - <img alt="Edge logo" src="https://upload.wikimedia.org/wikipedia/commons/9/98/Microsoft_Edge_logo_%282019%29.svg" width="16" height="16" class="inline mr-1 not-prose" /> [Devtools for Edge](https://microsoftedge.microsoft.com/addons/detail/tanstack-query-devtools/edmdpkgkacmjopodhfolmphdenmddobj) | ||
|
|
||
| ## Install and Import the Devtools | ||
|
|
||
| The devtools are a separate package that you need to install: | ||
|
|
||
| ```bash | ||
| npm i @tanstack/preact-query-devtools | ||
| ``` | ||
|
|
||
| or | ||
|
|
||
| ```bash | ||
| pnpm add @tanstack/preact-query-devtools | ||
| ``` | ||
|
|
||
| or | ||
|
|
||
| ```bash | ||
| yarn add @tanstack/preact-query-devtools | ||
| ``` | ||
|
|
||
| or | ||
|
|
||
| ```bash | ||
| bun add @tanstack/preact-query-devtools | ||
| ``` | ||
|
|
||
| You can import the devtools like this: | ||
|
|
||
| ```tsx | ||
| import { PreactQueryDevtools } from '@tanstack/preact-query-devtools' | ||
| ``` | ||
|
|
||
| By default, Preact Query Devtools are only included in bundles when `process.env.NODE_ENV === 'development'`, so you don't need to worry about excluding them during a production build. | ||
|
|
||
| ## Floating Mode | ||
|
|
||
| Floating Mode will mount the devtools as a fixed, floating element in your app and provide a toggle in the corner of the screen to show and hide the devtools. This toggle state will be stored and remembered in localStorage across reloads. | ||
|
|
||
| Place the following code as high in your Preact app as you can. The closer it is to the root of the page, the better it will work! | ||
|
|
||
| ```tsx | ||
| import { PreactQueryDevtools } from '@tanstack/preact-query-devtools' | ||
|
|
||
| function App() { | ||
| return ( | ||
| <QueryClientProvider client={queryClient}> | ||
| {/* The rest of your application */} | ||
| <PreactQueryDevtools initialIsOpen={false} /> | ||
| </QueryClientProvider> | ||
| ) | ||
| } | ||
| ``` | ||
|
|
||
| ### Options | ||
|
|
||
| - `initialIsOpen: boolean` | ||
| - Set this `true` if you want the dev tools to default to being open | ||
| - `buttonPosition?: "top-left" | "top-right" | "bottom-left" | "bottom-right"` | ||
| - Defaults to `bottom-right` | ||
| - The position of the Preact Query logo to open and close the devtools panel | ||
| - `position?: "top" | "bottom" | "left" | "right"` | ||
| - Defaults to `bottom` | ||
| - The position of the Preact Query devtools panel | ||
| - `client?: QueryClient`, | ||
| - Use this to use a custom QueryClient. Otherwise, the one from the nearest context will be used. | ||
| - `errorTypes?: { name: string; initializer: (query: Query) => TError}` | ||
| - Use this to predefine some errors that can be triggered on your queries. Initializer will be called (with the specific query) when that error is toggled on from the UI. It must return an Error. | ||
| - `styleNonce?: string` | ||
| - Use this to pass a nonce to the style tag that is added to the document head. This is useful if you are using a Content Security Policy (CSP) nonce to allow inline styles. | ||
| - `shadowDOMTarget?: ShadowRoot` | ||
| - Default behavior will apply the devtool's styles to the head tag within the DOM. | ||
| - Use this to pass a shadow DOM target to the devtools so that the styles will be applied within the shadow DOM instead of within the head tag in the light DOM. | ||
|
Comment on lines
+69
to
+87
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Documentation is missing The 🤖 Prompt for AI Agents |
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "ignoreRules": ["no-resolution"] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| // @ts-check | ||
| // @ts-ignore: no types for eslint-config-preact | ||
| import preact from 'eslint-config-preact' | ||
| // eslint-config-preact uses typescript-eslint under the hood | ||
| import tseslint from 'typescript-eslint' | ||
|
|
||
| import rootConfig from './root.eslint.config.js' | ||
|
|
||
| export default [ | ||
| ...rootConfig, | ||
| ...preact, | ||
| { | ||
| files: ['**/*.{ts,tsx}'], | ||
| languageOptions: { | ||
| parser: tseslint.parser, | ||
| parserOptions: { | ||
| project: true, | ||
| }, | ||
| }, | ||
| plugins: { | ||
| 'typescript-eslint': tseslint.plugin, | ||
| }, | ||
| rules: { | ||
| // Disable base rule to prevent overload false positives | ||
| 'no-redeclare': 'off', | ||
| 'no-duplicate-imports': 'off', | ||
| 'no-unused-vars': 'off', | ||
| 'import/order': 'off', | ||
| 'sort-imports': 'off', | ||
| 'no-import-assign': 'off', | ||
| // TS-aware version handles overloads correctly | ||
| '@typescript-eslint/no-redeclare': 'error', | ||
| '@typescript-eslint/array-type': 'off', | ||
| '@typescript-eslint/no-unnecessary-type-assertion': 'off', | ||
| '@typescript-eslint/no-unnecessary-condition': 'off', | ||
| }, | ||
| }, | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| { | ||
| "name": "@tanstack/preact-query-devtools", | ||
| "version": "5.91.0", | ||
| "description": "Developer tools to interact with and visualize the TanStack/preact-query cache", | ||
| "author": "tannerlinsley", | ||
| "license": "MIT", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/TanStack/query.git", | ||
| "directory": "packages/preact-query-devtools" | ||
| }, | ||
| "homepage": "https://tanstack.com/query", | ||
| "funding": { | ||
| "type": "github", | ||
| "url": "https://github.com/sponsors/tannerlinsley" | ||
| }, | ||
| "scripts": { | ||
| "clean": "premove ./build ./coverage ./dist-ts", | ||
| "compile": "tsc --build", | ||
| "test:eslint": "eslint --concurrency=auto ./src", | ||
| "test:types": "npm-run-all --serial test:types:*", | ||
| "test:types:ts50": "node ../../node_modules/typescript50/lib/tsc.js --build tsconfig.legacy.json", | ||
| "test:types:ts51": "node ../../node_modules/typescript51/lib/tsc.js --build tsconfig.legacy.json", | ||
| "test:types:ts52": "node ../../node_modules/typescript52/lib/tsc.js --build tsconfig.legacy.json", | ||
| "test:types:ts53": "node ../../node_modules/typescript53/lib/tsc.js --build tsconfig.legacy.json", | ||
| "test:types:ts54": "node ../../node_modules/typescript54/lib/tsc.js --build tsconfig.legacy.json", | ||
| "test:types:ts55": "node ../../node_modules/typescript55/lib/tsc.js --build tsconfig.legacy.json", | ||
| "test:types:ts56": "node ../../node_modules/typescript56/lib/tsc.js --build tsconfig.legacy.json", | ||
| "test:types:ts57": "node ../../node_modules/typescript57/lib/tsc.js --build tsconfig.legacy.json", | ||
| "test:types:tscurrent": "tsc --build", | ||
| "test:build": "publint --strict && attw --pack", | ||
| "build": "tsup --tsconfig tsconfig.prod.json", | ||
| "build:dev": "tsup --watch" | ||
| }, | ||
| "type": "module", | ||
| "types": "build/legacy/index.d.ts", | ||
| "main": "build/legacy/index.cjs", | ||
| "module": "build/legacy/index.js", | ||
| "exports": { | ||
| ".": { | ||
| "@tanstack/custom-condition": "./src/index.ts", | ||
| "import": { | ||
| "types": "./build/modern/index.d.ts", | ||
| "default": "./build/modern/index.js" | ||
| }, | ||
| "require": { | ||
| "types": "./build/modern/index.d.cts", | ||
| "default": "./build/modern/index.cjs" | ||
| } | ||
| }, | ||
| "./production": { | ||
| "import": { | ||
| "types": "./build/modern/production.d.ts", | ||
| "default": "./build/modern/production.js" | ||
| }, | ||
| "require": { | ||
| "types": "./build/modern/production.d.cts", | ||
| "default": "./build/modern/production.cjs" | ||
| } | ||
| }, | ||
| "./build/modern/production.js": { | ||
| "import": { | ||
| "types": "./build/modern/production.d.ts", | ||
| "default": "./build/modern/production.js" | ||
| }, | ||
| "require": { | ||
| "types": "./build/modern/production.d.cts", | ||
| "default": "./build/modern/production.cjs" | ||
| } | ||
| }, | ||
| "./package.json": "./package.json" | ||
| }, | ||
| "sideEffects": false, | ||
| "files": ["build", "src", "!src/__tests__"], | ||
| "dependencies": { | ||
| "@tanstack/query-devtools": "workspace:*" | ||
| }, | ||
| "devDependencies": { | ||
| "@preact/preset-vite": "^2.10.2", | ||
| "@tanstack/preact-query": "workspace:*", | ||
| "@testing-library/preact": "^3.2.4", | ||
| "npm-run-all2": "^5.0.0", | ||
| "preact": "^10.28.0", | ||
| "typescript-eslint": "^8.54.0" | ||
| }, | ||
| "peerDependencies": { | ||
| "@tanstack/preact-query": "workspace:^", | ||
| "preact": "^10.0.0" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| // @ts-check | ||
|
|
||
| // @ts-ignore Needed due to moduleResolution Node vs Bundler | ||
| import { tanstackConfig } from '@tanstack/eslint-config' | ||
| import pluginCspell from '@cspell/eslint-plugin' | ||
| import vitest from '@vitest/eslint-plugin' | ||
|
|
||
| export default [ | ||
| ...tanstackConfig, | ||
| { | ||
| name: 'tanstack/temp', | ||
| plugins: { | ||
| cspell: pluginCspell, | ||
| }, | ||
| rules: { | ||
| 'cspell/spellchecker': [ | ||
| 'warn', | ||
| { | ||
| cspell: { | ||
| words: [ | ||
| 'Promisable', // Our public interface | ||
| 'TSES', // @typescript-eslint package's interface | ||
| 'codemod', // We support our codemod | ||
| 'combinate', // Library name | ||
| 'datatag', // Query options tagging | ||
| 'extralight', // Our public interface | ||
| 'jscodeshift', | ||
| 'refetches', // Query refetch operations | ||
| 'retryer', // Our public interface | ||
| 'solidjs', // Our target framework | ||
| 'tabular-nums', // https://developer.mozilla.org/en-US/docs/Web/CSS/font-variant-numeric | ||
| 'tanstack', // Our package scope | ||
| 'todos', // Too general word to be caught as error | ||
| 'tsqd', // Our public interface (TanStack Query Devtools shorthand) | ||
| 'tsup', // We use tsup as builder | ||
| 'typecheck', // Field of vite.config.ts | ||
| 'vue-demi', // dependency of @tanstack/vue-query | ||
| 'ɵkind', // Angular specific | ||
| 'ɵproviders', // Angular specific | ||
| ], | ||
| }, | ||
| }, | ||
| ], | ||
| '@typescript-eslint/no-empty-function': 'off', | ||
| '@typescript-eslint/no-unsafe-function-type': 'off', | ||
| 'no-case-declarations': 'off', | ||
| 'prefer-const': 'off', | ||
| }, | ||
| }, | ||
| { | ||
| files: ['**/*.spec.ts*', '**/*.test.ts*', '**/*.test-d.ts*'], | ||
| plugins: { vitest }, | ||
| rules: { | ||
| ...vitest.configs.recommended.rules, | ||
| 'vitest/no-standalone-expect': [ | ||
| 'error', | ||
| { | ||
| additionalTestBlockFunctions: ['testIf'], | ||
| }, | ||
| ], | ||
| }, | ||
| settings: { vitest: { typecheck: true } }, | ||
| }, | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| // @ts-check | ||
|
|
||
| import { esbuildPluginFilePathExtensions } from 'esbuild-plugin-file-path-extensions' | ||
|
|
||
| /** | ||
| * @param {Object} opts - Options for building configurations. | ||
| * @param {string[]} opts.entry - The entry array. | ||
| * @returns {import('tsup').Options} | ||
| */ | ||
| export function modernConfig(opts) { | ||
| return { | ||
| entry: opts.entry, | ||
| format: ['cjs', 'esm'], | ||
| target: ['chrome91', 'firefox90', 'edge91', 'safari15', 'ios15', 'opera77'], | ||
| outDir: 'build/modern', | ||
| dts: true, | ||
| sourcemap: true, | ||
| clean: true, | ||
| esbuildPlugins: [esbuildPluginFilePathExtensions({ esmExtension: 'js' })], | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * @param {Object} opts - Options for building configurations. | ||
| * @param {string[]} opts.entry - The entry array. | ||
| * @returns {import('tsup').Options} | ||
| */ | ||
| export function legacyConfig(opts) { | ||
| return { | ||
| entry: opts.entry, | ||
| format: ['cjs', 'esm'], | ||
| target: ['es2020', 'node16'], | ||
| outDir: 'build/legacy', | ||
| dts: true, | ||
| sourcemap: true, | ||
| clean: true, | ||
| esbuildPlugins: [esbuildPluginFilePathExtensions({ esmExtension: 'js' })], | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like most of the docs are the same as react-query-devtools, can we use them like so:
and then have sections separated using