snapshot of https://github.com/TanStack/query.git (main, 2026-09-16; blobs > 131072B omitted)
Some checks failed
autofix.ci / autofix (push) Failing after 4s
Release / Release (push) Has been skipped
GitHub Actions Security Analysis / Run zizmor (push) Failing after 2s

This commit is contained in:
upstream-mirror
2026-09-16 01:13:08 +05:00
commit 3a013ccdfe
3570 changed files with 490194 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
<script lang="ts">
import {
persistQueryClientRestore,
persistQueryClientSubscribe,
} from '@tanstack/query-persist-client-core'
import {
QueryClientProvider,
setIsRestoringContext,
} from '@tanstack/svelte-query'
import { box } from './utils.svelte.js'
import type { PersistQueryClientOptions } from '@tanstack/query-persist-client-core'
import type {
OmitKeyof,
QueryClientProviderProps,
} from '@tanstack/svelte-query'
type PersistQueryClientProviderProps = QueryClientProviderProps & {
persistOptions: OmitKeyof<PersistQueryClientOptions, 'queryClient'>
onSuccess?: () => void
onError?: () => void
}
let {
client,
children,
persistOptions,
...props
}: PersistQueryClientProviderProps = $props()
let isRestoring = box(true)
setIsRestoringContext(isRestoring)
const options = $derived({
...persistOptions,
queryClient: client,
})
$effect(() => {
return isRestoring.current ? () => {} : persistQueryClientSubscribe(options)
})
$effect(() => {
isRestoring.current = true
persistQueryClientRestore(options)
.then(() => props.onSuccess?.())
.catch(() => props.onError?.())
.finally(() => {
isRestoring.current = false
})
})
</script>
<QueryClientProvider {client} {...props}>
{@render children()}
</QueryClientProvider>

View File

@@ -0,0 +1,3 @@
// Re-export core
export * from '@tanstack/query-persist-client-core'
export { default as PersistQueryClientProvider } from './PersistQueryClientProvider.svelte'

View File

@@ -0,0 +1,14 @@
type Box<T> = { current: T }
export function box<T>(initial: T): Box<T> {
let current = $state(initial)
return {
get current() {
return current
},
set current(newValue) {
current = newValue
},
}
}