-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
feat(svelte-query-devtools): Svelte Adapter for new Devtools #5362
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
Merged
lachlancollins
merged 13 commits into
TanStack:alpha
from
lachlancollins:svelte-query-devtools
May 3, 2023
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
5b0c756
Implement working devtools component
lachlancollins 6a4273a
Fix pnpm-lock.yaml
lachlancollins 02fd859
Update workspace config
lachlancollins 135d134
Always a prettier error
lachlancollins 7d69718
Fix eslint error
lachlancollins f8cbc63
Fix test:types
lachlancollins 3ef2ca5
Add svelte-query to deps
lachlancollins 8e6e105
Merge branch 'alpha' into svelte-query-devtools
lachlancollins b52bd05
Use esm-env to block loading in prod
lachlancollins 31c9481
Remove example changes
lachlancollins 58702c5
Simpler export
lachlancollins c319680
Allow dynamically editing props
lachlancollins 24bd249
Run prettier
lachlancollins 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,28 @@ | ||
// @ts-check | ||
|
||
/** @type {import('eslint').Linter.Config} */ | ||
const config = { | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
tsconfigRootDir: __dirname, | ||
project: './tsconfig.eslint.json', | ||
sourceType: 'module', | ||
extraFileExtensions: ['.svelte'], | ||
}, | ||
rules: { | ||
'react-hooks/rules-of-hooks': 'off', | ||
}, | ||
extends: ['plugin:svelte/recommended', '../../.eslintrc'], | ||
ignorePatterns: ['*.config.*', '**/build/*', '**/.svelte-kit/*'], | ||
overrides: [ | ||
{ | ||
files: ['*.svelte'], | ||
parser: 'svelte-eslint-parser', | ||
parserOptions: { | ||
parser: '@typescript-eslint/parser', | ||
}, | ||
}, | ||
], | ||
} | ||
|
||
module.exports = config |
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,57 @@ | ||
{ | ||
"name": "@tanstack/svelte-query-devtools", | ||
"version": "5.0.0-alpha.27", | ||
"description": "Developer tools to interact with and visualize the TanStack/svelte-query cache", | ||
"author": "Lachlan Collins", | ||
"license": "MIT", | ||
"repository": "tanstack/query", | ||
"homepage": "https://tanstack.com/query", | ||
"funding": { | ||
"type": "github", | ||
"url": "https://github.com/sponsors/tannerlinsley" | ||
}, | ||
"type": "module", | ||
"types": "build/lib/index.d.ts", | ||
"module": "build/lib/index.js", | ||
"svelte": "build/lib/index.js", | ||
"exports": { | ||
".": { | ||
"types": "./build/lib/index.d.ts", | ||
"import": "./build/lib/index.js", | ||
"svelte": "./build/lib/index.js", | ||
"default": "./build/lib/index.js" | ||
}, | ||
"./package.json": "./package.json" | ||
}, | ||
"files": [ | ||
"build/lib", | ||
"src" | ||
], | ||
"scripts": { | ||
"clean": "rimraf ./build", | ||
"test:types": "svelte-check --tsconfig ./tsconfig.json", | ||
"test:eslint": "eslint --ext .svelte,.ts ./src", | ||
"build": "svelte-package --input ./src --output ./build/lib" | ||
}, | ||
"devDependencies": { | ||
"@sveltejs/package": "^2.0.2", | ||
"@sveltejs/vite-plugin-svelte": "^2.0.2", | ||
"@testing-library/svelte": "^3.2.2", | ||
"eslint-plugin-svelte": "^2.14.1", | ||
"jsdom": "^20.0.3", | ||
"svelte": "^3.54.0", | ||
"svelte-check": "^2.9.2", | ||
"tslib": "^2.4.1", | ||
"typescript": "^4.7.4", | ||
"vite": "^4.0.0" | ||
}, | ||
"dependencies": { | ||
"@tanstack/query-devtools": "workspace:*", | ||
"@tanstack/svelte-query": "workspace:*", | ||
"esm-env": "^1.0.0" | ||
}, | ||
"peerDependencies": { | ||
"@tanstack/svelte-query": "workspace:*", | ||
"svelte": "^3.54.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,55 @@ | ||
<script lang="ts"> | ||
import { onMount } from 'svelte' | ||
import { DEV, BROWSER } from 'esm-env' | ||
import type { QueryClient } from '@tanstack/svelte-query' | ||
import { useQueryClient, onlineManager } from '@tanstack/svelte-query' | ||
import type { | ||
TanstackQueryDevtools, | ||
DevtoolsButtonPosition, | ||
DevtoolsPosition, | ||
DevToolsErrorType, | ||
} from '@tanstack/query-devtools' | ||
|
||
export let initialIsOpen = false | ||
export let buttonPosition: DevtoolsButtonPosition = 'bottom-left' | ||
export let position: DevtoolsPosition = 'bottom' | ||
export let client: QueryClient = useQueryClient() | ||
export let errorTypes: DevToolsErrorType[] = [] | ||
|
||
let ref: HTMLDivElement | ||
let devtools: TanstackQueryDevtools | ||
|
||
if (DEV && BROWSER) { | ||
onMount(async () => { | ||
const QueryDevtools = (await import('@tanstack/query-devtools')) | ||
.TanstackQueryDevtools | ||
devtools = new QueryDevtools({ | ||
client, | ||
queryFlavor: 'Svelte Query', | ||
version: '5', | ||
onlineManager, | ||
buttonPosition, | ||
position, | ||
initialIsOpen, | ||
errorTypes, | ||
}) | ||
|
||
devtools.mount(ref) | ||
|
||
return () => { | ||
devtools.unmount() | ||
} | ||
}) | ||
} | ||
|
||
$: { | ||
if (devtools) { | ||
devtools.setButtonPosition(buttonPosition) | ||
devtools.setPosition(position) | ||
devtools.setInitialIsOpen(initialIsOpen) | ||
devtools.setErrorTypes(errorTypes) | ||
} | ||
} | ||
</script> | ||
|
||
<div bind:this={ref} /> |
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 @@ | ||
export { default as SvelteQueryDevtools } from './Devtools.svelte' |
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,7 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"noEmit": true | ||
}, | ||
"include": ["**/*.ts", "**/*.tsx", "**/*.svelte", "./.eslintrc.cjs"] | ||
} |
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,43 @@ | ||
{ | ||
"compilerOptions": { | ||
"allowJs": true, | ||
"allowSyntheticDefaultImports": true, | ||
"checkJs": true, | ||
"composite": true, | ||
"esModuleInterop": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"importsNotUsedAsValues": "error", | ||
"isolatedModules": true, | ||
"preserveValueImports": true, | ||
"lib": ["esnext", "DOM", "DOM.Iterable"], | ||
"moduleResolution": "node", | ||
"module": "esnext", | ||
"noEmit": true, | ||
"noImplicitAny": true, | ||
"noImplicitReturns": true, | ||
"noImplicitThis": true, | ||
"noUncheckedIndexedAccess": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"resolveJsonModule": true, | ||
"rootDir": "./src", | ||
"skipLibCheck": true, | ||
"sourceMap": true, | ||
"strict": true, | ||
"strictNullChecks": true, | ||
"target": "esnext", | ||
"tsBuildInfoFile": "./build/.tsbuildinfo", | ||
"types": ["vitest/globals", "@testing-library/jest-dom"] | ||
}, | ||
"include": ["src", "src/**/*.svelte"], | ||
"paths": { | ||
"@tanstack/query-core": ["../query-core/src"], | ||
"@tanstack/query-devtools": ["../query-devtools/src"], | ||
"@tanstack/svelte-query": ["../svelte-query/src"], | ||
}, | ||
"references": [ | ||
{ "path": "../query-core" }, | ||
{ "path": "../query-devtools" }, | ||
{ "path": "../svelte-query" } | ||
] | ||
} |
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,16 @@ | ||
import { svelte } from '@sveltejs/vite-plugin-svelte'; | ||
import path from 'path'; | ||
import type { UserConfig } from 'vite'; | ||
|
||
const config: UserConfig = { | ||
plugins: [svelte()], | ||
resolve: { | ||
alias: { | ||
"@tanstack/query-core": path.resolve(__dirname, '..', 'query-core', 'src'), | ||
"@tanstack/query-devtools": path.resolve(__dirname, '..', 'query-devtools', 'src'), | ||
"@tanstack/svelte-query": path.resolve(__dirname, '..', 'svelte-query', 'src'), | ||
} | ||
} | ||
}; | ||
|
||
export default config; |
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.
Uh oh!
There was an error while loading. Please reload this page.