Skip to content
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

WIP: Svelte 5 adapter #6981

Merged
merged 69 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
7b5e650
fix
zhihengGet Feb 27, 2024
603c97e
fix
zhihengGet Feb 27, 2024
ed9539c
fix
zhihengGet Feb 28, 2024
a7c62ca
allow enable to be function
zhihengGet Feb 28, 2024
206a324
wip
zhihengGet Mar 17, 2024
af611bc
fx
zhihengGet Mar 30, 2024
9cc0721
remove unstate
zhihengGet Apr 17, 2024
b983b34
Merge branch 'main' into zhihengGet/main
lachlancollins Jun 20, 2024
b46374c
Fix merge
lachlancollins Jun 20, 2024
f1797cf
Fix createQueries merge
lachlancollins Jun 20, 2024
cf389f1
Fix some CI errors
lachlancollins Jun 20, 2024
4f91fd4
Fix svelte-melt example
lachlancollins Jun 20, 2024
f1e0e69
Merge branch 'main' into zhihengGet/main
lachlancollins Jun 30, 2024
6548f1d
Fix merge
lachlancollins Jun 30, 2024
96b349d
Replace svelte-query
lachlancollins Jul 7, 2024
7e9e8bd
Merge branch 'main' into zhihengGet/main
lachlancollins Jul 7, 2024
0c3299c
svelte
zhihengGet Jul 13, 2024
4478ec0
svelte
zhihengGet Jul 13, 2024
18a65c2
fix tests
zhihengGet Jul 14, 2024
9147e65
fix tests
zhihengGet Jul 14, 2024
3a6112c
fix ts
zhihengGet Jul 14, 2024
4a3c1e0
remove
zhihengGet Jul 14, 2024
5e9b3bf
remove
zhihengGet Jul 14, 2024
8200ebf
fix
zhihengGet Jul 14, 2024
87038d1
fix
zhihengGet Jul 14, 2024
1f0c8c0
fix
zhihengGet Jul 14, 2024
ee417eb
fix
zhihengGet Jul 14, 2024
50d2538
fix tests
zhihengGet Jul 14, 2024
80d77b5
Merge branch 'main' into zhihengGet/main
lachlancollins Jul 14, 2024
10ba3bc
Fix lockfile
lachlancollins Jul 14, 2024
4800066
Merge branch 'main' of https://github.com/zhihengGet/query
zhihengGet Jul 14, 2024
016f9f0
Sync svelte versions
lachlancollins Jul 16, 2024
bb08ee8
Merge branch 'main' into zhihengGet/main
lachlancollins Jul 16, 2024
f0ebbf8
Fix eslint, update basic/ssr examples
lachlancollins Jul 16, 2024
c0bc55c
Merge branch 'main' into zhihengGet/main
lachlancollins Jul 16, 2024
c8713d6
Fix sherif, prettier
lachlancollins Jul 16, 2024
83eba3e
Add missing exports
lachlancollins Jul 16, 2024
1274401
dedupe useMutationState
lachlancollins Jul 16, 2024
12b0ed8
fix a test case
zhihengGet Jul 17, 2024
bc26e06
dude
zhihengGet Jul 17, 2024
47c7200
fix tests
zhihengGet Jul 17, 2024
e9c5990
Update $props, examples
lachlancollins Jul 17, 2024
3da88ba
Remove export let
lachlancollins Jul 17, 2024
cae27db
Simplify tracking test states
lachlancollins Jul 17, 2024
ee98bef
Merge 'main' into zhihengGet/main
lachlancollins Jul 17, 2024
c1b7778
Fix svelte-query-persist-client tests
lachlancollins Jul 17, 2024
f160633
Decrease difference from main
lachlancollins Jul 17, 2024
4c8c080
untrack
zhihengGet Jul 17, 2024
4cf0b24
Fix createQueries, remove console.log
lachlancollins Jul 17, 2024
34894de
Merge branch 'main' into zhihengGet/main
lachlancollins Jul 18, 2024
76c4292
hi
zhihengGet Jul 19, 2024
9a969be
omit
zhihengGet Jul 19, 2024
61ee18b
fix types
zhihengGet Jul 19, 2024
f01f9f4
Merge branch 'main' into zhihengGet/main
lachlancollins Jul 20, 2024
754daf8
Merge branch 'main' of https://github.com/zhihengGet/query into zhihe…
lachlancollins Jul 20, 2024
c63941e
Fix merge
lachlancollins Jul 20, 2024
b5f8d9e
Fix eslint
lachlancollins Jul 20, 2024
2f3aa1a
fix
zhihengGet Jul 21, 2024
5b6a69d
fix
zhihengGet Jul 21, 2024
195ee40
Merge branch 'main' into main
lachlancollins Jul 21, 2024
63fd463
Merge branch 'main' into zhihengGet/main
lachlancollins Jul 22, 2024
b7e81a9
fix
zhihengGet Jul 25, 2024
9771a13
Improvements
lachlancollins Jul 26, 2024
39cbe53
Fix reactive props
lachlancollins Jul 26, 2024
bb0c910
Add back missing option
lachlancollins Jul 26, 2024
56e9881
Merge branch 'svelte-5-adapter' into main
lachlancollins Jul 26, 2024
4cce385
Merge branch 'main' into zhihengGet/main
lachlancollins Jul 26, 2024
a48fadf
Remove missing export
lachlancollins Jul 26, 2024
07e64e7
Merge branch 'main' into zhihengGet/main
lachlancollins Jul 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .lintstagedrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"*": ["prettier --write"]
"*": [""]
}
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export default [
'ts/ban-types': 'off',
'ts/no-empty-function': 'off',
'no-case-declarations': 'off',
'prefer-const': 'off',
},
},
]
4 changes: 2 additions & 2 deletions examples/svelte/auto-refetching/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"devDependencies": {
"@sveltejs/adapter-auto": "^3.2.2",
"@sveltejs/kit": "^2.5.18",
"@sveltejs/vite-plugin-svelte": "^3.1.0",
"svelte": "^4.2.18",
"@sveltejs/vite-plugin-svelte": "^4.0.0-next.3",
"svelte": "5.0.0-next.183",
"svelte-check": "^3.8.4",
"typescript": "5.3.3",
"vite": "^5.3.3"
Expand Down
4 changes: 2 additions & 2 deletions examples/svelte/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"devDependencies": {
"@sveltejs/adapter-auto": "^3.2.2",
"@sveltejs/kit": "^2.5.18",
"@sveltejs/vite-plugin-svelte": "^3.1.0",
"svelte": "^4.2.18",
"@sveltejs/vite-plugin-svelte": "^4.0.0-next.3",
"svelte": "5.0.0-next.183",
"svelte-check": "^3.8.4",
"typescript": "5.3.3",
"vite": "^5.3.3"
Expand Down
16 changes: 8 additions & 8 deletions examples/svelte/basic/src/lib/Post.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { getPostById } from './data'
import type { Post } from './types'

export let postId: number
const { postId } = $props<{ postId: number }>()

const post = createQuery<Post>({
queryKey: ['post', postId],
Expand All @@ -15,17 +15,17 @@
<div>
<a class="button" href="/"> Back </a>
</div>
{#if !postId || $post.isPending}
{#if !postId || post.isPending}
<span>Loading...</span>
{/if}
{#if $post.error}
<span>Error: {$post.error.message}</span>
{#if post.error}
<span>Error: {post.error.message}</span>
{/if}
{#if $post.isSuccess}
<h1>{$post.data.title}</h1>
{#if post.isSuccess}
<h1>{post.data.title}</h1>
<div>
<p>{$post.data.body}</p>
<p>{post.data.body}</p>
</div>
<div>{$post.isFetching ? 'Background Updating...' : ' '}</div>
<div>{post.isFetching ? 'Background Updating...' : ' '}</div>
{/if}
</div>
10 changes: 5 additions & 5 deletions examples/svelte/basic/src/lib/Posts.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@

<div>
<div>
{#if $posts.status === 'pending'}
{#if posts.status === 'pending'}
<span>Loading...</span>
{:else if $posts.status === 'error'}
<span>Error: {$posts.error.message}</span>
{:else if posts.status === 'error'}
<span>Error: {posts.error.message}</span>
{:else}
<ul>
{#each $posts.data as post}
{#each posts.data as post}
<article>
<a
href={`/${post.id}`}
Expand All @@ -38,7 +38,7 @@
</article>
{/each}
</ul>
{#if $posts.isFetching}
{#if posts.isFetching}
<div style="color:darkgreen; font-weight:700">
Background Updating...
</div>
Expand Down
4 changes: 3 additions & 1 deletion examples/svelte/basic/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import { QueryClientProvider, QueryClient } from '@tanstack/svelte-query'
import { SvelteQueryDevtools } from '@tanstack/svelte-query-devtools'

const { children } = $props()

const queryClient = new QueryClient({
defaultOptions: {
queries: {
Expand All @@ -15,7 +17,7 @@

<QueryClientProvider client={queryClient}>
<main>
<slot />
{@render children()}
</main>
<SvelteQueryDevtools />
</QueryClientProvider>
3 changes: 1 addition & 2 deletions examples/svelte/basic/src/routes/[postId]/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<script lang="ts">
import Post from '$lib/Post.svelte'
import type { PageData } from './$types'

export let data: PageData
const { data } = $props()
</script>

<Post postId={data.postId} />
4 changes: 2 additions & 2 deletions examples/svelte/load-more-infinite-scroll/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"devDependencies": {
"@sveltejs/adapter-auto": "^3.2.2",
"@sveltejs/kit": "^2.5.18",
"@sveltejs/vite-plugin-svelte": "^3.1.0",
"svelte": "^4.2.18",
"@sveltejs/vite-plugin-svelte": "^4.0.0-next.3",
"svelte": "5.0.0-next.183",
"svelte-check": "^3.8.4",
"typescript": "5.3.3",
"vite": "^5.3.3"
Expand Down
4 changes: 2 additions & 2 deletions examples/svelte/optimistic-updates-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"devDependencies": {
"@sveltejs/adapter-auto": "^3.2.2",
"@sveltejs/kit": "^2.5.18",
"@sveltejs/vite-plugin-svelte": "^3.1.0",
"svelte": "^4.2.18",
"@sveltejs/vite-plugin-svelte": "^4.0.0-next.3",
"svelte": "5.0.0-next.183",
"svelte-check": "^3.8.4",
"typescript": "5.3.3",
"vite": "^5.3.3"
Expand Down
4 changes: 2 additions & 2 deletions examples/svelte/playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"devDependencies": {
"@sveltejs/adapter-auto": "^3.2.2",
"@sveltejs/kit": "^2.5.18",
"@sveltejs/vite-plugin-svelte": "^3.1.0",
"svelte": "^4.2.18",
"@sveltejs/vite-plugin-svelte": "^4.0.0-next.3",
"svelte": "5.0.0-next.183",
"svelte-check": "^3.8.4",
"typescript": "5.3.3",
"vite": "^5.3.3"
Expand Down
4 changes: 2 additions & 2 deletions examples/svelte/simple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
"@tanstack/svelte-query-devtools": "^5.51.1"
},
"devDependencies": {
"@sveltejs/vite-plugin-svelte": "^3.1.0",
"@sveltejs/vite-plugin-svelte": "^4.0.0-next.3",
"@tsconfig/svelte": "^5.0.4",
"svelte": "^4.2.18",
"svelte": "5.0.0-next.183",
"svelte-check": "^3.8.4",
"typescript": "5.3.3",
"vite": "^5.3.3"
Expand Down
18 changes: 9 additions & 9 deletions examples/svelte/simple/src/lib/Simple.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@
<h1>Simple</h1>
<div class="my-4">
<div>
{#if $query.isPending}
{#if query.isPending}
Loading...
{/if}
{#if $query.error}
{#if query.error}
An error has occurred:
{$query.error.message}
{query.error.message}
{/if}
{#if $query.isSuccess}
{#if query.isSuccess}
<div>
<h1>{$query.data.name}</h1>
<p>{$query.data.description}</p>
<strong>👀 {$query.data.subscribers_count}</strong>{' '}
<strong>✨ {$query.data.stargazers_count}</strong>{' '}
<strong>🍴 {$query.data.forks_count}</strong>
<h1>{query.data.name}</h1>
<p>{query.data.description}</p>
<strong>👀 {query.data.subscribers_count}</strong>{' '}
<strong>✨ {query.data.stargazers_count}</strong>{' '}
<strong>🍴 {query.data.forks_count}</strong>
</div>
{/if}
</div>
Expand Down
4 changes: 2 additions & 2 deletions examples/svelte/ssr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"devDependencies": {
"@sveltejs/adapter-auto": "^3.2.2",
"@sveltejs/kit": "^2.5.18",
"@sveltejs/vite-plugin-svelte": "^3.1.0",
"svelte": "^4.2.18",
"@sveltejs/vite-plugin-svelte": "^4.0.0-next.3",
"svelte": "5.0.0-next.183",
"svelte-check": "^3.8.4",
"typescript": "5.3.3",
"vite": "^5.3.3"
Expand Down
16 changes: 8 additions & 8 deletions examples/svelte/ssr/src/lib/Post.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { api } from './api'
import type { Post } from './types'

export let postId: number
const { postId } = $props<{ postId: number }>()

const post = createQuery<Post>({
queryKey: ['post', postId],
Expand All @@ -15,17 +15,17 @@
<div>
<a class="button" href="/"> Back </a>
</div>
{#if !postId || $post.isPending}
{#if !postId || post.isPending}
<span>Loading...</span>
{/if}
{#if $post.error}
<span>Error: {$post.error.message}</span>
{#if post.error}
<span>Error: {post.error.message}</span>
{/if}
{#if $post.isSuccess}
<h1>{$post.data.title}</h1>
{#if post.isSuccess}
<h1>{post.data.title}</h1>
<div>
<p>{$post.data.body}</p>
<p>{post.data.body}</p>
</div>
<div>{$post.isFetching ? 'Background Updating...' : ' '}</div>
<div>{post.isFetching ? 'Background Updating...' : ' '}</div>
{/if}
</div>
10 changes: 5 additions & 5 deletions examples/svelte/ssr/src/lib/Posts.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@

<div>
<div>
{#if $posts.status === 'pending'}
{#if posts.status === 'pending'}
<span>Loading...</span>
{:else if $posts.status === 'error'}
<span>Error: {$posts.error.message}</span>
{:else if posts.status === 'error'}
<span>Error: {posts.error.message}</span>
{:else}
<ul>
{#each $posts.data as post}
{#each posts.data as post}
<article>
<a
href={`/${post.id}`}
Expand All @@ -38,7 +38,7 @@
</article>
{/each}
</ul>
{#if $posts.isFetching}
{#if posts.isFetching}
<div style="color:darkgreen; font-weight:700">
Background Updating...
</div>
Expand Down
5 changes: 2 additions & 3 deletions examples/svelte/ssr/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
import '../app.css'
import { QueryClientProvider } from '@tanstack/svelte-query'
import { SvelteQueryDevtools } from '@tanstack/svelte-query-devtools'
import type { PageData } from './$types'

export let data: PageData
const { data, children } = $props()
</script>

<QueryClientProvider client={data.queryClient}>
<main>
<slot />
{@render children()}
</main>
<SvelteQueryDevtools />
</QueryClientProvider>
2 changes: 1 addition & 1 deletion examples/svelte/ssr/src/routes/+layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { browser } from '$app/environment'
import { QueryClient } from '@tanstack/svelte-query'
import type { LayoutLoad } from './$types'

export const load: LayoutLoad = async () => {
export const load: LayoutLoad = () => {
const queryClient = new QueryClient({
defaultOptions: {
queries: {
Expand Down
3 changes: 1 addition & 2 deletions examples/svelte/ssr/src/routes/[postId]/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<script lang="ts">
import Post from '$lib/Post.svelte'
import type { PageData } from './$types'

export let data: PageData
const { data } = $props()
</script>

<Post postId={data.postId} />
4 changes: 2 additions & 2 deletions examples/svelte/star-wars/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
"devDependencies": {
"@sveltejs/adapter-auto": "^3.2.2",
"@sveltejs/kit": "^2.5.18",
"@sveltejs/vite-plugin-svelte": "^3.1.0",
"@sveltejs/vite-plugin-svelte": "^4.0.0-next.3",
"autoprefixer": "^10.4.19",
"postcss": "^8.4.35",
"svelte": "^4.2.18",
"svelte": "5.0.0-next.183",
"svelte-check": "^3.8.4",
"tailwindcss": "^3.4.3",
"typescript": "5.3.3",
Expand Down
10 changes: 10 additions & 0 deletions examples/svelte/svelte-melt/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
38 changes: 38 additions & 0 deletions examples/svelte/svelte-melt/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# create-svelte

Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/main/packages/create-svelte).

## Creating a project

If you're seeing this, you've probably already done this step. Congrats!

```bash
# create a new project in the current directory
npm create svelte@latest

# create a new project in my-app
npm create svelte@latest my-app
```

## Developing

Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:

```bash
npm run dev

# or start the server and open the app in a new browser tab
npm run dev -- --open
```

## Building

To create a production version of your app:

```bash
npm run build
```

You can preview the production build with `npm run preview`.

> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.
29 changes: 29 additions & 0 deletions examples/svelte/svelte-melt/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "svelte-melt",
"private": true,
"type": "module",
"scripts": {
"dev": "vite dev --port 3000",
"build": "vite build",
"preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --check . && eslint .",
"format": "prettier --write ."
},
"dependencies": {
"@tanstack/query-sync-storage-persister": "^5.51.1",
"@tanstack/svelte-query": "^5.51.1",
"@tanstack/svelte-query-devtools": "^5.51.1",
"@tanstack/svelte-query-persist-client": "^5.51.1"
},
"devDependencies": {
"@sveltejs/adapter-auto": "^3.2.2",
"@sveltejs/kit": "^2.5.18",
"@sveltejs/vite-plugin-svelte": "^4.0.0-next.3",
"svelte": "5.0.0-next.183",
"svelte-check": "^3.8.4",
"typescript": "5.3.3",
"vite": "^5.3.3"
}
}
Loading
Loading