@tanstack/vue-query 5.107.0 → 5.107.2
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/README.md +2 -3
- package/build/legacy/devtools/devtools.cjs +1 -1
- package/build/legacy/devtools/devtools.cjs.map +1 -1
- package/build/legacy/devtools/devtools.d.cts +1 -1
- package/build/legacy/devtools/devtools.d.ts +1 -1
- package/build/legacy/devtools/devtools.js +1 -1
- package/build/legacy/devtools/devtools.js.map +1 -1
- package/build/legacy/index.cjs +1 -1
- package/build/legacy/index.d.cts +4 -4
- package/build/legacy/index.d.ts +4 -4
- package/build/legacy/index.js +1 -1
- package/build/legacy/{infiniteQueryOptions-lJ_zR-As.d.cts → infiniteQueryOptions-CLfd_vOE.d.cts} +61 -17
- package/build/legacy/infiniteQueryOptions-CLfd_vOE.d.cts.map +1 -0
- package/build/legacy/{infiniteQueryOptions-CN37iZvc.d.ts → infiniteQueryOptions-vEnw-JaW.d.ts} +61 -17
- package/build/legacy/infiniteQueryOptions-vEnw-JaW.d.ts.map +1 -0
- package/build/legacy/infiniteQueryOptions.d.cts +1 -1
- package/build/legacy/infiniteQueryOptions.d.ts +1 -1
- package/build/{modern/queryClient-Ba4HSFnn.d.ts → legacy/queryClient-6AWIHAhP.d.ts} +2 -2
- package/build/legacy/{queryClient-Ba4HSFnn.d.ts.map → queryClient-6AWIHAhP.d.ts.map} +1 -1
- package/build/{modern/queryClient-BGn8uIej.d.cts → legacy/queryClient-yJW8K_VP.d.cts} +2 -2
- package/build/legacy/{queryClient-BGn8uIej.d.cts.map → queryClient-yJW8K_VP.d.cts.map} +1 -1
- package/build/legacy/queryClient.cjs +1 -1
- package/build/legacy/queryClient.cjs.map +1 -1
- package/build/legacy/queryClient.d.cts +1 -1
- package/build/legacy/queryClient.d.ts +1 -1
- package/build/legacy/queryClient.js +1 -1
- package/build/legacy/queryClient.js.map +1 -1
- package/build/{modern/queryOptions-BuZEBLtg.d.cts → legacy/queryOptions-nndmAASX.d.cts} +22 -11
- package/build/legacy/queryOptions-nndmAASX.d.cts.map +1 -0
- package/build/{modern/queryOptions-dXiBZnGk.d.ts → legacy/queryOptions-v0l6M7Eo.d.ts} +22 -11
- package/build/legacy/queryOptions-v0l6M7Eo.d.ts.map +1 -0
- package/build/legacy/queryOptions.cjs.map +1 -1
- package/build/legacy/queryOptions.d.cts +2 -2
- package/build/legacy/queryOptions.d.ts +2 -2
- package/build/legacy/queryOptions.js.map +1 -1
- package/build/legacy/types-u_Tu5Ybs.d.cts.map +1 -1
- package/build/legacy/types-u_Tu5Ybs.d.ts.map +1 -1
- package/build/legacy/useBaseQuery.cjs +11 -5
- package/build/legacy/useBaseQuery.cjs.map +1 -1
- package/build/legacy/useBaseQuery.d.cts +1 -1
- package/build/legacy/useBaseQuery.d.ts +1 -1
- package/build/legacy/useBaseQuery.js +11 -5
- package/build/legacy/useBaseQuery.js.map +1 -1
- package/build/legacy/useInfiniteQuery.cjs.map +1 -1
- package/build/legacy/useInfiniteQuery.d.cts +1 -1
- package/build/legacy/useInfiniteQuery.d.ts +1 -1
- package/build/legacy/useInfiniteQuery.js.map +1 -1
- package/build/legacy/useIsFetching.cjs.map +1 -1
- package/build/legacy/useIsFetching.d.cts +1 -1
- package/build/legacy/useIsFetching.d.ts +1 -1
- package/build/legacy/useIsFetching.js.map +1 -1
- package/build/legacy/useMutation.cjs.map +1 -1
- package/build/legacy/useMutation.d.cts +1 -1
- package/build/legacy/useMutation.d.ts +1 -1
- package/build/legacy/useMutation.js.map +1 -1
- package/build/legacy/useMutationState.cjs.map +1 -1
- package/build/legacy/useMutationState.d.cts +1 -1
- package/build/legacy/useMutationState.d.ts +1 -1
- package/build/legacy/useMutationState.js.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.cjs.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.d.cts +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.d.ts +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.js.map +1 -1
- package/build/legacy/usePrefetchQuery.cjs.map +1 -1
- package/build/legacy/usePrefetchQuery.d.cts +1 -1
- package/build/legacy/usePrefetchQuery.d.ts +1 -1
- package/build/legacy/usePrefetchQuery.js.map +1 -1
- package/build/legacy/useQueries.cjs +1 -1
- package/build/legacy/useQueries.cjs.map +1 -1
- package/build/legacy/useQueries.d.cts +2 -2
- package/build/legacy/useQueries.d.cts.map +1 -1
- package/build/legacy/useQueries.d.ts +2 -2
- package/build/legacy/useQueries.d.ts.map +1 -1
- package/build/legacy/useQueries.js +1 -1
- package/build/legacy/useQueries.js.map +1 -1
- package/build/legacy/useQuery.cjs.map +1 -1
- package/build/legacy/useQuery.d.cts +56 -22
- package/build/legacy/useQuery.d.cts.map +1 -1
- package/build/legacy/useQuery.d.ts +56 -22
- package/build/legacy/useQuery.d.ts.map +1 -1
- package/build/legacy/useQuery.js.map +1 -1
- package/build/legacy/useQueryClient.cjs.map +1 -1
- package/build/legacy/useQueryClient.d.cts +1 -1
- package/build/legacy/useQueryClient.d.cts.map +1 -1
- package/build/legacy/useQueryClient.d.ts +1 -1
- package/build/legacy/useQueryClient.d.ts.map +1 -1
- package/build/legacy/useQueryClient.js.map +1 -1
- package/build/legacy/utils.cjs.map +1 -1
- package/build/legacy/utils.js.map +1 -1
- package/build/legacy/vueQueryPlugin.cjs +1 -1
- package/build/legacy/vueQueryPlugin.cjs.map +1 -1
- package/build/legacy/vueQueryPlugin.d.cts +1 -1
- package/build/legacy/vueQueryPlugin.d.cts.map +1 -1
- package/build/legacy/vueQueryPlugin.d.ts +1 -1
- package/build/legacy/vueQueryPlugin.d.ts.map +1 -1
- package/build/legacy/vueQueryPlugin.js +1 -1
- package/build/legacy/vueQueryPlugin.js.map +1 -1
- package/build/modern/devtools/devtools.cjs +1 -1
- package/build/modern/devtools/devtools.cjs.map +1 -1
- package/build/modern/devtools/devtools.d.cts +1 -1
- package/build/modern/devtools/devtools.d.ts +1 -1
- package/build/modern/devtools/devtools.js +1 -1
- package/build/modern/devtools/devtools.js.map +1 -1
- package/build/modern/index.cjs +1 -1
- package/build/modern/index.d.cts +4 -4
- package/build/modern/index.d.ts +4 -4
- package/build/modern/index.js +1 -1
- package/build/modern/{infiniteQueryOptions-lJ_zR-As.d.cts → infiniteQueryOptions-CLfd_vOE.d.cts} +61 -17
- package/build/modern/infiniteQueryOptions-CLfd_vOE.d.cts.map +1 -0
- package/build/modern/{infiniteQueryOptions-CN37iZvc.d.ts → infiniteQueryOptions-vEnw-JaW.d.ts} +61 -17
- package/build/modern/infiniteQueryOptions-vEnw-JaW.d.ts.map +1 -0
- package/build/modern/infiniteQueryOptions.d.cts +1 -1
- package/build/modern/infiniteQueryOptions.d.ts +1 -1
- package/build/{legacy/queryClient-Ba4HSFnn.d.ts → modern/queryClient-6AWIHAhP.d.ts} +2 -2
- package/build/modern/{queryClient-Ba4HSFnn.d.ts.map → queryClient-6AWIHAhP.d.ts.map} +1 -1
- package/build/{legacy/queryClient-BGn8uIej.d.cts → modern/queryClient-yJW8K_VP.d.cts} +2 -2
- package/build/modern/{queryClient-BGn8uIej.d.cts.map → queryClient-yJW8K_VP.d.cts.map} +1 -1
- package/build/modern/queryClient.cjs +1 -1
- package/build/modern/queryClient.cjs.map +1 -1
- package/build/modern/queryClient.d.cts +1 -1
- package/build/modern/queryClient.d.ts +1 -1
- package/build/modern/queryClient.js +1 -1
- package/build/modern/queryClient.js.map +1 -1
- package/build/{legacy/queryOptions-BuZEBLtg.d.cts → modern/queryOptions-nndmAASX.d.cts} +22 -11
- package/build/modern/queryOptions-nndmAASX.d.cts.map +1 -0
- package/build/{legacy/queryOptions-dXiBZnGk.d.ts → modern/queryOptions-v0l6M7Eo.d.ts} +22 -11
- package/build/modern/queryOptions-v0l6M7Eo.d.ts.map +1 -0
- package/build/modern/queryOptions.cjs.map +1 -1
- package/build/modern/queryOptions.d.cts +2 -2
- package/build/modern/queryOptions.d.ts +2 -2
- package/build/modern/queryOptions.js.map +1 -1
- package/build/modern/types-u_Tu5Ybs.d.cts.map +1 -1
- package/build/modern/types-u_Tu5Ybs.d.ts.map +1 -1
- package/build/modern/useBaseQuery.cjs +11 -5
- package/build/modern/useBaseQuery.cjs.map +1 -1
- package/build/modern/useBaseQuery.d.cts +1 -1
- package/build/modern/useBaseQuery.d.ts +1 -1
- package/build/modern/useBaseQuery.js +11 -5
- package/build/modern/useBaseQuery.js.map +1 -1
- package/build/modern/useInfiniteQuery.cjs.map +1 -1
- package/build/modern/useInfiniteQuery.d.cts +1 -1
- package/build/modern/useInfiniteQuery.d.ts +1 -1
- package/build/modern/useInfiniteQuery.js.map +1 -1
- package/build/modern/useIsFetching.cjs.map +1 -1
- package/build/modern/useIsFetching.d.cts +1 -1
- package/build/modern/useIsFetching.d.ts +1 -1
- package/build/modern/useIsFetching.js.map +1 -1
- package/build/modern/useMutation.cjs.map +1 -1
- package/build/modern/useMutation.d.cts +1 -1
- package/build/modern/useMutation.d.ts +1 -1
- package/build/modern/useMutation.js.map +1 -1
- package/build/modern/useMutationState.cjs.map +1 -1
- package/build/modern/useMutationState.d.cts +1 -1
- package/build/modern/useMutationState.d.ts +1 -1
- package/build/modern/useMutationState.js.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.cjs.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.d.cts +1 -1
- package/build/modern/usePrefetchInfiniteQuery.d.ts +1 -1
- package/build/modern/usePrefetchInfiniteQuery.js.map +1 -1
- package/build/modern/usePrefetchQuery.cjs.map +1 -1
- package/build/modern/usePrefetchQuery.d.cts +1 -1
- package/build/modern/usePrefetchQuery.d.ts +1 -1
- package/build/modern/usePrefetchQuery.js.map +1 -1
- package/build/modern/useQueries.cjs +1 -1
- package/build/modern/useQueries.cjs.map +1 -1
- package/build/modern/useQueries.d.cts +2 -2
- package/build/modern/useQueries.d.cts.map +1 -1
- package/build/modern/useQueries.d.ts +2 -2
- package/build/modern/useQueries.d.ts.map +1 -1
- package/build/modern/useQueries.js +1 -1
- package/build/modern/useQueries.js.map +1 -1
- package/build/modern/useQuery.cjs.map +1 -1
- package/build/modern/useQuery.d.cts +56 -22
- package/build/modern/useQuery.d.cts.map +1 -1
- package/build/modern/useQuery.d.ts +56 -22
- package/build/modern/useQuery.d.ts.map +1 -1
- package/build/modern/useQuery.js.map +1 -1
- package/build/modern/useQueryClient.cjs.map +1 -1
- package/build/modern/useQueryClient.d.cts +1 -1
- package/build/modern/useQueryClient.d.cts.map +1 -1
- package/build/modern/useQueryClient.d.ts +1 -1
- package/build/modern/useQueryClient.d.ts.map +1 -1
- package/build/modern/useQueryClient.js.map +1 -1
- package/build/modern/utils.cjs.map +1 -1
- package/build/modern/utils.js.map +1 -1
- package/build/modern/vueQueryPlugin.cjs +1 -1
- package/build/modern/vueQueryPlugin.cjs.map +1 -1
- package/build/modern/vueQueryPlugin.d.cts +1 -1
- package/build/modern/vueQueryPlugin.d.cts.map +1 -1
- package/build/modern/vueQueryPlugin.d.ts +1 -1
- package/build/modern/vueQueryPlugin.d.ts.map +1 -1
- package/build/modern/vueQueryPlugin.js +1 -1
- package/build/modern/vueQueryPlugin.js.map +1 -1
- package/package.json +12 -2
- package/src/devtools/devtools.ts +2 -2
- package/src/index.ts +2 -0
- package/src/queryClient.ts +12 -12
- package/src/queryOptions.ts +40 -23
- package/src/types.ts +2 -0
- package/src/useBaseQuery.ts +71 -11
- package/src/useInfiniteQuery.ts +32 -28
- package/src/useIsFetching.ts +2 -2
- package/src/useMutation.ts +4 -4
- package/src/useMutationState.ts +2 -2
- package/src/usePrefetchInfiniteQuery.ts +1 -1
- package/src/usePrefetchQuery.ts +1 -1
- package/src/useQueries.ts +9 -5
- package/src/useQuery.ts +55 -21
- package/src/useQueryClient.ts +0 -1
- package/src/utils.ts +2 -2
- package/src/vueQueryPlugin.ts +2 -3
- package/build/legacy/infiniteQueryOptions-CN37iZvc.d.ts.map +0 -1
- package/build/legacy/infiniteQueryOptions-lJ_zR-As.d.cts.map +0 -1
- package/build/legacy/queryOptions-BuZEBLtg.d.cts.map +0 -1
- package/build/legacy/queryOptions-dXiBZnGk.d.ts.map +0 -1
- package/build/modern/infiniteQueryOptions-CN37iZvc.d.ts.map +0 -1
- package/build/modern/infiniteQueryOptions-lJ_zR-As.d.cts.map +0 -1
- package/build/modern/queryOptions-BuZEBLtg.d.cts.map +0 -1
- package/build/modern/queryOptions-dXiBZnGk.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.cjs","names":["isRef","unref"],"sources":["../../src/utils.ts"],"sourcesContent":["import { isRef, unref } from 'vue-demi'\nimport type { MaybeRefDeep } from './types'\n\n/**\n * Base Vue injection key `VueQueryPlugin` provides the `QueryClient` under.\n * @internal\n */\nexport const VUE_QUERY_CLIENT = 'VUE_QUERY_CLIENT'\n\n/**\n * Builds the injection key `useQueryClient`/`VueQueryPlugin` use for a given `queryClientKey`.\n * @internal\n * @param key - The `queryClientKey`. Without it, the base key is used.\n * @returns The injection key.\n */\nexport function getClientKey(key?: string) {\n const suffix = key ? `:${key}` : ''\n return `${VUE_QUERY_CLIENT}${suffix}`\n}\n\n/**\n * Copies each property from `update` onto `state`, in place, for every key already on `state`.\n * @internal\n * @param state - The object to update.\n * @param update - The object to copy the values from.\n */\nexport function updateState(\n state: Record<string, any>,\n update: Record<string, any>,\n): void {\n Object.keys(state).forEach((key) => {\n state[key] = update[key]\n })\n}\n\n/**\n * Recursive implementation of {@link cloneDeep}, which also tracks the key and nesting level of\n * the current node for `customize`.\n * @param value - The value to clone.\n * @param customize - Called for every node with its key and nesting level. If it returns a value\n * other than `undefined`, that value is used instead of recursing.\n * @param currentKey - The key of the current node.\n * @param currentLevel - The nesting level of the current node.\n * @returns The cloned value.\n */\nfunction _cloneDeep<T>(\n value: MaybeRefDeep<T>,\n customize?: (\n val: MaybeRefDeep<T>,\n key: string,\n level: number,\n ) => T | undefined,\n currentKey: string = '',\n currentLevel: number = 0,\n): T {\n if (customize) {\n const result = customize(value, currentKey, currentLevel)\n if (result === undefined && isRef(value)) {\n return result as T\n }\n if (result !== undefined) {\n return result\n }\n }\n\n if (Array.isArray(value)) {\n return value.map((val, index) =>\n _cloneDeep(val, customize, String(index), currentLevel + 1),\n ) as unknown as T\n }\n\n if (typeof value === 'object' && isPlainObject(value)) {\n const entries = Object.entries(value as Record<string, any>).map(\n ([key, val]) => [key, _cloneDeep(val, customize, key, currentLevel + 1)],\n )\n return Object.fromEntries(entries)\n }\n\n return value as T\n}\n\n/**\n * Deep-clones `value`, recursing into arrays and plain objects. `customize`, if provided, can\n * intercept any node (by key and nesting level) and substitute its own return value instead of recursing\n * further.\n * @internal\n * @param value - The value to clone.\n * @param customize - Called for every node with its key and nesting level. If it returns a value\n * other than `undefined`, that value is used instead of recursing.\n * @returns The cloned value.\n */\nexport function cloneDeep<T>(\n value: MaybeRefDeep<T>,\n customize?: (\n val: MaybeRefDeep<T>,\n key: string,\n level: number,\n ) => T | undefined,\n): T {\n return _cloneDeep(value, customize)\n}\n\n/**\n * Deep-clones `value` like {@link cloneDeep}, additionally unwrapping any `ref`s it encounters (and,\n * if `unrefGetters` is `true`, calling any functions it encounters and unwrapping their result too). Always\n * resolves `queryKey` this way, regardless of `unrefGetters` — this is what lets a `queryKey` containing `ref`s\n * be passed straight through to `@tanstack/query-core`.\n * @internal\n * @param obj - The value to clone.\n * @param unrefGetters - Whether to also call functions and unwrap their result.\n * @returns The cloned value, with `ref`s unwrapped.\n */\nexport function cloneDeepUnref<T>(\n obj: MaybeRefDeep<T>,\n unrefGetters = false,\n): T {\n return cloneDeep(obj, (val, key, level) => {\n // Check if we're at the top level and the key is 'queryKey'\n //\n // If so, take the recursive descent where we resolve\n // getters to values as well as refs.\n if (level === 1 && key === 'queryKey') {\n return cloneDeepUnref(val, true)\n }\n\n // Resolve getters to values if specified.\n if (unrefGetters && isFunction(val)) {\n // Cast due to older TS versions not allowing calling\n // on certain intersection types.\n return cloneDeepUnref((val as
|
|
1
|
+
{"version":3,"file":"utils.cjs","names":["isRef","unref"],"sources":["../../src/utils.ts"],"sourcesContent":["import { isRef, unref } from 'vue-demi'\nimport type { MaybeRefDeep } from './types'\n\n/**\n * Base Vue injection key `VueQueryPlugin` provides the `QueryClient` under.\n * @internal\n */\nexport const VUE_QUERY_CLIENT = 'VUE_QUERY_CLIENT'\n\n/**\n * Builds the injection key `useQueryClient`/`VueQueryPlugin` use for a given `queryClientKey`.\n * @internal\n * @param key - The `queryClientKey`. Without it, the base key is used.\n * @returns The injection key.\n */\nexport function getClientKey(key?: string) {\n const suffix = key ? `:${key}` : ''\n return `${VUE_QUERY_CLIENT}${suffix}`\n}\n\n/**\n * Copies each property from `update` onto `state`, in place, for every key already on `state`.\n * @internal\n * @param state - The object to update.\n * @param update - The object to copy the values from.\n */\nexport function updateState(\n state: Record<string, any>,\n update: Record<string, any>,\n): void {\n Object.keys(state).forEach((key) => {\n state[key] = update[key]\n })\n}\n\n/**\n * Recursive implementation of {@link cloneDeep}, which also tracks the key and nesting level of\n * the current node for `customize`.\n * @param value - The value to clone.\n * @param customize - Called for every node with its key and nesting level. If it returns a value\n * other than `undefined`, that value is used instead of recursing.\n * @param currentKey - The key of the current node.\n * @param currentLevel - The nesting level of the current node.\n * @returns The cloned value.\n */\nfunction _cloneDeep<T>(\n value: MaybeRefDeep<T>,\n customize?: (\n val: MaybeRefDeep<T>,\n key: string,\n level: number,\n ) => T | undefined,\n currentKey: string = '',\n currentLevel: number = 0,\n): T {\n if (customize) {\n const result = customize(value, currentKey, currentLevel)\n if (result === undefined && isRef(value)) {\n return result as T\n }\n if (result !== undefined) {\n return result\n }\n }\n\n if (Array.isArray(value)) {\n return value.map((val, index) =>\n _cloneDeep(val, customize, String(index), currentLevel + 1),\n ) as unknown as T\n }\n\n if (typeof value === 'object' && isPlainObject(value)) {\n const entries = Object.entries(value as Record<string, any>).map(\n ([key, val]) => [key, _cloneDeep(val, customize, key, currentLevel + 1)],\n )\n return Object.fromEntries(entries)\n }\n\n return value as T\n}\n\n/**\n * Deep-clones `value`, recursing into arrays and plain objects. `customize`, if provided, can\n * intercept any node (by key and nesting level) and substitute its own return value instead of recursing\n * further.\n * @internal\n * @param value - The value to clone.\n * @param customize - Called for every node with its key and nesting level. If it returns a value\n * other than `undefined`, that value is used instead of recursing.\n * @returns The cloned value.\n */\nexport function cloneDeep<T>(\n value: MaybeRefDeep<T>,\n customize?: (\n val: MaybeRefDeep<T>,\n key: string,\n level: number,\n ) => T | undefined,\n): T {\n return _cloneDeep(value, customize)\n}\n\n/**\n * Deep-clones `value` like {@link cloneDeep}, additionally unwrapping any `ref`s it encounters (and,\n * if `unrefGetters` is `true`, calling any functions it encounters and unwrapping their result too). Always\n * resolves `queryKey` this way, regardless of `unrefGetters` — this is what lets a `queryKey` containing `ref`s\n * be passed straight through to `@tanstack/query-core`.\n * @internal\n * @param obj - The value to clone.\n * @param unrefGetters - Whether to also call functions and unwrap their result.\n * @returns The cloned value, with `ref`s unwrapped.\n */\nexport function cloneDeepUnref<T>(\n obj: MaybeRefDeep<T>,\n unrefGetters = false,\n): T {\n return cloneDeep(obj, (val, key, level) => {\n // Check if we're at the top level and the key is 'queryKey'\n //\n // If so, take the recursive descent where we resolve\n // getters to values as well as refs.\n if (level === 1 && key === 'queryKey') {\n return cloneDeepUnref(val, true)\n }\n\n // Resolve getters to values if specified.\n if (unrefGetters && isFunction(val)) {\n // Cast due to older TS versions not allowing calling\n // on certain intersection types.\n return cloneDeepUnref((val as () => any)(), unrefGetters)\n }\n\n // Unref refs and continue to recurse into the value.\n if (isRef(val)) {\n return cloneDeepUnref(unref(val), unrefGetters)\n }\n\n return undefined\n })\n}\n\n/**\n * Checks whether a value is a plain object, created with an object literal or\n * `Object.create(null)`.\n * @param value - The value to check.\n * @returns `true` if `value` is a plain object.\n */\nfunction isPlainObject(value: unknown): value is Record<PropertyKey, unknown> {\n if (Object.prototype.toString.call(value) !== '[object Object]') {\n return false\n }\n\n const prototype = Object.getPrototypeOf(value)\n return prototype === null || prototype === Object.prototype\n}\n\n/**\n * Checks whether a value is a function.\n * @param value - The value to check.\n * @returns `true` if `value` is a function.\n */\nfunction isFunction(value: unknown): value is (...args: Array<any>) => any {\n return typeof value === 'function'\n}\n\n/**\n * Resolves `source` to a plain value — calls it if it's a function, otherwise deep-unwraps it.\n * @internal\n * @param source - A getter, or a value that may contain `ref`s.\n * @returns The resolved plain value.\n */\nexport function toValueDeep<T>(source: (() => T) | MaybeRefDeep<T>): T {\n return isFunction(source) ? source() : cloneDeepUnref(source)\n}\n"],"mappings":";;;;;;;AAOA,MAAa,mBAAmB;;;;;;;AAQhC,SAAgB,aAAa,KAAc;CACzC,MAAM,SAAS,MAAM,IAAI,QAAQ;CACjC,OAAO,GAAG,mBAAmB;AAC/B;;;;;;;AAQA,SAAgB,YACd,OACA,QACM;CACN,OAAO,KAAK,KAAK,CAAC,CAAC,SAAS,QAAQ;EAClC,MAAM,OAAO,OAAO;CACtB,CAAC;AACH;;;;;;;;;;;AAYA,SAAS,WACP,OACA,WAKA,aAAqB,IACrB,eAAuB,GACpB;CACH,IAAI,WAAW;EACb,MAAM,SAAS,UAAU,OAAO,YAAY,YAAY;EACxD,IAAI,WAAW,KAAA,MAAA,GAAaA,SAAAA,MAAAA,CAAM,KAAK,GACrC,OAAO;EAET,IAAI,WAAW,KAAA,GACb,OAAO;CAEX;CAEA,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,KAAK,KAAK,UACrB,WAAW,KAAK,WAAW,OAAO,KAAK,GAAG,eAAe,CAAC,CAC5D;CAGF,IAAI,OAAO,UAAU,YAAY,cAAc,KAAK,GAAG;EACrD,MAAM,UAAU,OAAO,QAAQ,KAA4B,CAAC,CAAC,KAC1D,CAAC,KAAK,SAAS,CAAC,KAAK,WAAW,KAAK,WAAW,KAAK,eAAe,CAAC,CAAC,CACzE;EACA,OAAO,OAAO,YAAY,OAAO;CACnC;CAEA,OAAO;AACT;;;;;;;;;;;AAYA,SAAgB,UACd,OACA,WAKG;CACH,OAAO,WAAW,OAAO,SAAS;AACpC;;;;;;;;;;;AAYA,SAAgB,eACd,KACA,eAAe,OACZ;CACH,OAAO,UAAU,MAAM,KAAK,KAAK,UAAU;EAKzC,IAAI,UAAU,KAAK,QAAQ,YACzB,OAAO,eAAe,KAAK,IAAI;EAIjC,IAAI,gBAAgB,WAAW,GAAG,GAGhC,OAAO,eAAgB,IAAkB,GAAG,YAAY;EAI1D,KAAA,GAAIA,SAAAA,MAAAA,CAAM,GAAG,GACX,OAAO,gBAAA,GAAeC,SAAAA,MAAAA,CAAM,GAAG,GAAG,YAAY;CAIlD,CAAC;AACH;;;;;;;AAQA,SAAS,cAAc,OAAuD;CAC5E,IAAI,OAAO,UAAU,SAAS,KAAK,KAAK,MAAM,mBAC5C,OAAO;CAGT,MAAM,YAAY,OAAO,eAAe,KAAK;CAC7C,OAAO,cAAc,QAAQ,cAAc,OAAO;AACpD;;;;;;AAOA,SAAS,WAAW,OAAuD;CACzE,OAAO,OAAO,UAAU;AAC1B;;;;;;;AAQA,SAAgB,YAAe,QAAwC;CACrE,OAAO,WAAW,MAAM,IAAI,OAAO,IAAI,eAAe,MAAM;AAC9D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":[],"sources":["../../src/utils.ts"],"sourcesContent":["import { isRef, unref } from 'vue-demi'\nimport type { MaybeRefDeep } from './types'\n\n/**\n * Base Vue injection key `VueQueryPlugin` provides the `QueryClient` under.\n * @internal\n */\nexport const VUE_QUERY_CLIENT = 'VUE_QUERY_CLIENT'\n\n/**\n * Builds the injection key `useQueryClient`/`VueQueryPlugin` use for a given `queryClientKey`.\n * @internal\n * @param key - The `queryClientKey`. Without it, the base key is used.\n * @returns The injection key.\n */\nexport function getClientKey(key?: string) {\n const suffix = key ? `:${key}` : ''\n return `${VUE_QUERY_CLIENT}${suffix}`\n}\n\n/**\n * Copies each property from `update` onto `state`, in place, for every key already on `state`.\n * @internal\n * @param state - The object to update.\n * @param update - The object to copy the values from.\n */\nexport function updateState(\n state: Record<string, any>,\n update: Record<string, any>,\n): void {\n Object.keys(state).forEach((key) => {\n state[key] = update[key]\n })\n}\n\n/**\n * Recursive implementation of {@link cloneDeep}, which also tracks the key and nesting level of\n * the current node for `customize`.\n * @param value - The value to clone.\n * @param customize - Called for every node with its key and nesting level. If it returns a value\n * other than `undefined`, that value is used instead of recursing.\n * @param currentKey - The key of the current node.\n * @param currentLevel - The nesting level of the current node.\n * @returns The cloned value.\n */\nfunction _cloneDeep<T>(\n value: MaybeRefDeep<T>,\n customize?: (\n val: MaybeRefDeep<T>,\n key: string,\n level: number,\n ) => T | undefined,\n currentKey: string = '',\n currentLevel: number = 0,\n): T {\n if (customize) {\n const result = customize(value, currentKey, currentLevel)\n if (result === undefined && isRef(value)) {\n return result as T\n }\n if (result !== undefined) {\n return result\n }\n }\n\n if (Array.isArray(value)) {\n return value.map((val, index) =>\n _cloneDeep(val, customize, String(index), currentLevel + 1),\n ) as unknown as T\n }\n\n if (typeof value === 'object' && isPlainObject(value)) {\n const entries = Object.entries(value as Record<string, any>).map(\n ([key, val]) => [key, _cloneDeep(val, customize, key, currentLevel + 1)],\n )\n return Object.fromEntries(entries)\n }\n\n return value as T\n}\n\n/**\n * Deep-clones `value`, recursing into arrays and plain objects. `customize`, if provided, can\n * intercept any node (by key and nesting level) and substitute its own return value instead of recursing\n * further.\n * @internal\n * @param value - The value to clone.\n * @param customize - Called for every node with its key and nesting level. If it returns a value\n * other than `undefined`, that value is used instead of recursing.\n * @returns The cloned value.\n */\nexport function cloneDeep<T>(\n value: MaybeRefDeep<T>,\n customize?: (\n val: MaybeRefDeep<T>,\n key: string,\n level: number,\n ) => T | undefined,\n): T {\n return _cloneDeep(value, customize)\n}\n\n/**\n * Deep-clones `value` like {@link cloneDeep}, additionally unwrapping any `ref`s it encounters (and,\n * if `unrefGetters` is `true`, calling any functions it encounters and unwrapping their result too). Always\n * resolves `queryKey` this way, regardless of `unrefGetters` — this is what lets a `queryKey` containing `ref`s\n * be passed straight through to `@tanstack/query-core`.\n * @internal\n * @param obj - The value to clone.\n * @param unrefGetters - Whether to also call functions and unwrap their result.\n * @returns The cloned value, with `ref`s unwrapped.\n */\nexport function cloneDeepUnref<T>(\n obj: MaybeRefDeep<T>,\n unrefGetters = false,\n): T {\n return cloneDeep(obj, (val, key, level) => {\n // Check if we're at the top level and the key is 'queryKey'\n //\n // If so, take the recursive descent where we resolve\n // getters to values as well as refs.\n if (level === 1 && key === 'queryKey') {\n return cloneDeepUnref(val, true)\n }\n\n // Resolve getters to values if specified.\n if (unrefGetters && isFunction(val)) {\n // Cast due to older TS versions not allowing calling\n // on certain intersection types.\n return cloneDeepUnref((val as
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../../src/utils.ts"],"sourcesContent":["import { isRef, unref } from 'vue-demi'\nimport type { MaybeRefDeep } from './types'\n\n/**\n * Base Vue injection key `VueQueryPlugin` provides the `QueryClient` under.\n * @internal\n */\nexport const VUE_QUERY_CLIENT = 'VUE_QUERY_CLIENT'\n\n/**\n * Builds the injection key `useQueryClient`/`VueQueryPlugin` use for a given `queryClientKey`.\n * @internal\n * @param key - The `queryClientKey`. Without it, the base key is used.\n * @returns The injection key.\n */\nexport function getClientKey(key?: string) {\n const suffix = key ? `:${key}` : ''\n return `${VUE_QUERY_CLIENT}${suffix}`\n}\n\n/**\n * Copies each property from `update` onto `state`, in place, for every key already on `state`.\n * @internal\n * @param state - The object to update.\n * @param update - The object to copy the values from.\n */\nexport function updateState(\n state: Record<string, any>,\n update: Record<string, any>,\n): void {\n Object.keys(state).forEach((key) => {\n state[key] = update[key]\n })\n}\n\n/**\n * Recursive implementation of {@link cloneDeep}, which also tracks the key and nesting level of\n * the current node for `customize`.\n * @param value - The value to clone.\n * @param customize - Called for every node with its key and nesting level. If it returns a value\n * other than `undefined`, that value is used instead of recursing.\n * @param currentKey - The key of the current node.\n * @param currentLevel - The nesting level of the current node.\n * @returns The cloned value.\n */\nfunction _cloneDeep<T>(\n value: MaybeRefDeep<T>,\n customize?: (\n val: MaybeRefDeep<T>,\n key: string,\n level: number,\n ) => T | undefined,\n currentKey: string = '',\n currentLevel: number = 0,\n): T {\n if (customize) {\n const result = customize(value, currentKey, currentLevel)\n if (result === undefined && isRef(value)) {\n return result as T\n }\n if (result !== undefined) {\n return result\n }\n }\n\n if (Array.isArray(value)) {\n return value.map((val, index) =>\n _cloneDeep(val, customize, String(index), currentLevel + 1),\n ) as unknown as T\n }\n\n if (typeof value === 'object' && isPlainObject(value)) {\n const entries = Object.entries(value as Record<string, any>).map(\n ([key, val]) => [key, _cloneDeep(val, customize, key, currentLevel + 1)],\n )\n return Object.fromEntries(entries)\n }\n\n return value as T\n}\n\n/**\n * Deep-clones `value`, recursing into arrays and plain objects. `customize`, if provided, can\n * intercept any node (by key and nesting level) and substitute its own return value instead of recursing\n * further.\n * @internal\n * @param value - The value to clone.\n * @param customize - Called for every node with its key and nesting level. If it returns a value\n * other than `undefined`, that value is used instead of recursing.\n * @returns The cloned value.\n */\nexport function cloneDeep<T>(\n value: MaybeRefDeep<T>,\n customize?: (\n val: MaybeRefDeep<T>,\n key: string,\n level: number,\n ) => T | undefined,\n): T {\n return _cloneDeep(value, customize)\n}\n\n/**\n * Deep-clones `value` like {@link cloneDeep}, additionally unwrapping any `ref`s it encounters (and,\n * if `unrefGetters` is `true`, calling any functions it encounters and unwrapping their result too). Always\n * resolves `queryKey` this way, regardless of `unrefGetters` — this is what lets a `queryKey` containing `ref`s\n * be passed straight through to `@tanstack/query-core`.\n * @internal\n * @param obj - The value to clone.\n * @param unrefGetters - Whether to also call functions and unwrap their result.\n * @returns The cloned value, with `ref`s unwrapped.\n */\nexport function cloneDeepUnref<T>(\n obj: MaybeRefDeep<T>,\n unrefGetters = false,\n): T {\n return cloneDeep(obj, (val, key, level) => {\n // Check if we're at the top level and the key is 'queryKey'\n //\n // If so, take the recursive descent where we resolve\n // getters to values as well as refs.\n if (level === 1 && key === 'queryKey') {\n return cloneDeepUnref(val, true)\n }\n\n // Resolve getters to values if specified.\n if (unrefGetters && isFunction(val)) {\n // Cast due to older TS versions not allowing calling\n // on certain intersection types.\n return cloneDeepUnref((val as () => any)(), unrefGetters)\n }\n\n // Unref refs and continue to recurse into the value.\n if (isRef(val)) {\n return cloneDeepUnref(unref(val), unrefGetters)\n }\n\n return undefined\n })\n}\n\n/**\n * Checks whether a value is a plain object, created with an object literal or\n * `Object.create(null)`.\n * @param value - The value to check.\n * @returns `true` if `value` is a plain object.\n */\nfunction isPlainObject(value: unknown): value is Record<PropertyKey, unknown> {\n if (Object.prototype.toString.call(value) !== '[object Object]') {\n return false\n }\n\n const prototype = Object.getPrototypeOf(value)\n return prototype === null || prototype === Object.prototype\n}\n\n/**\n * Checks whether a value is a function.\n * @param value - The value to check.\n * @returns `true` if `value` is a function.\n */\nfunction isFunction(value: unknown): value is (...args: Array<any>) => any {\n return typeof value === 'function'\n}\n\n/**\n * Resolves `source` to a plain value — calls it if it's a function, otherwise deep-unwraps it.\n * @internal\n * @param source - A getter, or a value that may contain `ref`s.\n * @returns The resolved plain value.\n */\nexport function toValueDeep<T>(source: (() => T) | MaybeRefDeep<T>): T {\n return isFunction(source) ? source() : cloneDeepUnref(source)\n}\n"],"mappings":";;;;;;AAOA,MAAa,mBAAmB;;;;;;;AAQhC,SAAgB,aAAa,KAAc;CACzC,MAAM,SAAS,MAAM,IAAI,QAAQ;CACjC,OAAO,GAAG,mBAAmB;AAC/B;;;;;;;AAQA,SAAgB,YACd,OACA,QACM;CACN,OAAO,KAAK,KAAK,CAAC,CAAC,SAAS,QAAQ;EAClC,MAAM,OAAO,OAAO;CACtB,CAAC;AACH;;;;;;;;;;;AAYA,SAAS,WACP,OACA,WAKA,aAAqB,IACrB,eAAuB,GACpB;CACH,IAAI,WAAW;EACb,MAAM,SAAS,UAAU,OAAO,YAAY,YAAY;EACxD,IAAI,WAAW,KAAA,KAAa,MAAM,KAAK,GACrC,OAAO;EAET,IAAI,WAAW,KAAA,GACb,OAAO;CAEX;CAEA,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,KAAK,KAAK,UACrB,WAAW,KAAK,WAAW,OAAO,KAAK,GAAG,eAAe,CAAC,CAC5D;CAGF,IAAI,OAAO,UAAU,YAAY,cAAc,KAAK,GAAG;EACrD,MAAM,UAAU,OAAO,QAAQ,KAA4B,CAAC,CAAC,KAC1D,CAAC,KAAK,SAAS,CAAC,KAAK,WAAW,KAAK,WAAW,KAAK,eAAe,CAAC,CAAC,CACzE;EACA,OAAO,OAAO,YAAY,OAAO;CACnC;CAEA,OAAO;AACT;;;;;;;;;;;AAYA,SAAgB,UACd,OACA,WAKG;CACH,OAAO,WAAW,OAAO,SAAS;AACpC;;;;;;;;;;;AAYA,SAAgB,eACd,KACA,eAAe,OACZ;CACH,OAAO,UAAU,MAAM,KAAK,KAAK,UAAU;EAKzC,IAAI,UAAU,KAAK,QAAQ,YACzB,OAAO,eAAe,KAAK,IAAI;EAIjC,IAAI,gBAAgB,WAAW,GAAG,GAGhC,OAAO,eAAgB,IAAkB,GAAG,YAAY;EAI1D,IAAI,MAAM,GAAG,GACX,OAAO,eAAe,MAAM,GAAG,GAAG,YAAY;CAIlD,CAAC;AACH;;;;;;;AAQA,SAAS,cAAc,OAAuD;CAC5E,IAAI,OAAO,UAAU,SAAS,KAAK,KAAK,MAAM,mBAC5C,OAAO;CAGT,MAAM,YAAY,OAAO,eAAe,KAAK;CAC7C,OAAO,cAAc,QAAQ,cAAc,OAAO;AACpD;;;;;;AAOA,SAAS,WAAW,OAAuD;CACzE,OAAO,OAAO,UAAU;AAC1B;;;;;;;AAQA,SAAgB,YAAe,QAAwC;CACrE,OAAO,WAAW,MAAM,IAAI,OAAO,IAAI,eAAe,MAAM;AAC9D"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_utils = require("./utils.cjs");
|
|
3
|
-
const require_queryClient = require("./queryClient.cjs");
|
|
4
3
|
const require_devtools_devtools = require("./devtools/devtools.cjs");
|
|
4
|
+
const require_queryClient = require("./queryClient.cjs");
|
|
5
5
|
let _tanstack_query_core = require("@tanstack/query-core");
|
|
6
6
|
let vue_demi = require("vue-demi");
|
|
7
7
|
// src/vueQueryPlugin.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vueQueryPlugin.cjs","names":["getClientKey","QueryClient","environmentManager","isVue2"],"sources":["../../src/vueQueryPlugin.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"vueQueryPlugin.cjs","names":["getClientKey","QueryClient","environmentManager","isVue2"],"sources":["../../src/vueQueryPlugin.ts"],"sourcesContent":["import { environmentManager } from '@tanstack/query-core'\nimport { isVue2 } from 'vue-demi'\nimport { setupDevtools } from './devtools/devtools'\nimport { QueryClient } from './queryClient'\nimport { getClientKey } from './utils'\nimport type { QueryClientConfig } from './types'\n\ntype ClientPersister = (client: QueryClient) => [() => void, Promise<void>]\n\ninterface CommonOptions {\n /** Enables the legacy Vue Devtools v6 plugin panel. Prefer `@tanstack/vue-query-devtools` for Vue 3 apps. */\n enableDevtoolsV6Plugin?: boolean\n /**\n * Distinguishes multiple `QueryClient`s provided in the same app — pass the same key to `useQueryClient` to\n * pick this one. Only needed when installing more than one client.\n */\n queryClientKey?: string\n /**\n * Restores a persisted cache before the app mounts. While it runs, `queryClient.isRestoring` is `true`, which\n * suppresses fetches — see `usePersistQueryClient` in `@tanstack/query-persist-client-core` for building one.\n */\n clientPersister?: ClientPersister\n /** Called once `clientPersister`'s returned promise resolves and the cache has finished restoring. */\n clientPersisterOnSuccess?: (client: QueryClient) => void\n}\n\ninterface ConfigOptions extends CommonOptions {\n /** Options for the `QueryClient` the plugin constructs. Ignored if `queryClient` is also set. */\n queryClientConfig?: QueryClientConfig\n}\n\ninterface ClientOptions extends CommonOptions {\n /** Use your own `QueryClient` instance instead of having the plugin construct one from `queryClientConfig`. */\n queryClient?: QueryClient\n}\n\n/**\n * The options accepted by `VueQueryPlugin`: either a `queryClient` to install, or a `queryClientConfig` for the\n * client the plugin creates, plus the shared options.\n */\nexport type VueQueryPluginOptions = ConfigOptions | ClientOptions\n\n/**\n * Installs a `QueryClient` on the Vue app, making it available to every descendant component through\n * `useQueryClient` — the Vue equivalent of React's `QueryClientProvider`, but wired up as an app-level plugin\n * instead of a wrapping component.\n * @example\n * ```ts\n * import { createApp } from 'vue'\n * import { VueQueryPlugin } from '@tanstack/vue-query'\n *\n * const app = createApp(App)\n * app.use(VueQueryPlugin)\n * ```\n * @example\n * Pass a `queryClient` you constructed yourself — useful for SSR, where you need a fresh `QueryClient` per\n * request, or when the same instance also needs to be used outside of Vue components:\n * ```ts\n * import { QueryClient, VueQueryPlugin } from '@tanstack/vue-query'\n *\n * const queryClient = new QueryClient()\n * app.use(VueQueryPlugin, { queryClient })\n * ```\n * @example\n * Or pass `queryClientConfig` to let the plugin construct the `QueryClient` for you, with your own defaults:\n * ```ts\n * app.use(VueQueryPlugin, {\n * queryClientConfig: {\n * defaultOptions: { queries: { staleTime: 5 * 1000 } },\n * },\n * })\n * ```\n */\nexport const VueQueryPlugin = {\n install: (app: any, options: VueQueryPluginOptions = {}) => {\n const clientKey = getClientKey(options.queryClientKey)\n let client: QueryClient\n\n if ('queryClient' in options && options.queryClient) {\n client = options.queryClient\n } else {\n const clientConfig =\n 'queryClientConfig' in options ? options.queryClientConfig : undefined\n client = new QueryClient(clientConfig)\n }\n\n if (!environmentManager.isServer()) {\n client.mount()\n }\n\n let persisterUnmount = () => {\n // noop\n }\n\n if (options.clientPersister) {\n if (client.isRestoring) {\n client.isRestoring.value = true\n }\n const [unmount, promise] = options.clientPersister(client)\n persisterUnmount = unmount\n promise.then(\n () => {\n if (client.isRestoring) {\n client.isRestoring.value = false\n }\n options.clientPersisterOnSuccess?.(client)\n },\n () => {\n if (client.isRestoring) {\n client.isRestoring.value = false\n }\n },\n )\n }\n\n const cleanup = () => {\n client.unmount()\n persisterUnmount()\n }\n\n if (app.onUnmount) {\n app.onUnmount(cleanup)\n } else {\n const originalUnmount = app.unmount\n app.unmount = function vueQueryUnmount() {\n cleanup()\n originalUnmount()\n }\n }\n\n if (isVue2) {\n app.mixin({\n beforeCreate() {\n // HACK: taken from provide(): https://github.com/vuejs/composition-api/blob/master/src/apis/inject.ts#L30\n if (!this._provided) {\n const provideCache = {}\n Object.defineProperty(this, '_provided', {\n get: () => provideCache,\n set: (v) => Object.assign(provideCache, v),\n })\n }\n\n this._provided[clientKey] = client\n\n if (process.env.NODE_ENV === 'development') {\n if (this === this.$root && options.enableDevtoolsV6Plugin) {\n setupDevtools(this, client)\n }\n }\n },\n })\n } else {\n app.provide(clientKey, client)\n\n if (process.env.NODE_ENV === 'development') {\n if (options.enableDevtoolsV6Plugin) {\n setupDevtools(app, client)\n }\n }\n }\n },\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyEA,MAAa,iBAAiB,EAC5B,UAAU,KAAU,UAAiC,CAAC,MAAM;CAC1D,MAAM,YAAYA,cAAAA,aAAa,QAAQ,cAAc;CACrD,IAAI;CAEJ,IAAI,iBAAiB,WAAW,QAAQ,aACtC,SAAS,QAAQ;MACZ;EACL,MAAM,eACJ,uBAAuB,UAAU,QAAQ,oBAAoB,KAAA;EAC/D,SAAS,IAAIC,oBAAAA,YAAY,YAAY;CACvC;CAEA,IAAI,CAACC,qBAAAA,mBAAmB,SAAS,GAC/B,OAAO,MAAM;CAGf,IAAI,yBAAyB,CAE7B;CAEA,IAAI,QAAQ,iBAAiB;EAC3B,IAAI,OAAO,aACT,OAAO,YAAY,QAAQ;EAE7B,MAAM,CAAC,SAAS,WAAW,QAAQ,gBAAgB,MAAM;EACzD,mBAAmB;EACnB,QAAQ,WACA;;GACJ,IAAI,OAAO,aACT,OAAO,YAAY,QAAQ;GAE7B,CAAA,wBAAA,QAAQ,8BAAA,QAAA,0BAAA,KAAA,KAAA,sBAAA,KAAA,SAA2B,MAAM;EAC3C,SACM;GACJ,IAAI,OAAO,aACT,OAAO,YAAY,QAAQ;EAE/B,CACF;CACF;CAEA,MAAM,gBAAgB;EACpB,OAAO,QAAQ;EACf,iBAAiB;CACnB;CAEA,IAAI,IAAI,WACN,IAAI,UAAU,OAAO;MAChB;EACL,MAAM,kBAAkB,IAAI;EAC5B,IAAI,UAAU,SAAS,kBAAkB;GACvC,QAAQ;GACR,gBAAgB;EAClB;CACF;CAEA,IAAIC,SAAAA,QACF,IAAI,MAAM,EACR,eAAe;EAEb,IAAI,CAAC,KAAK,WAAW;GACnB,MAAM,eAAe,CAAC;GACtB,OAAO,eAAe,MAAM,aAAa;IACvC,WAAW;IACX,MAAM,MAAM,OAAO,OAAO,cAAc,CAAC;GAC3C,CAAC;EACH;EAEA,KAAK,UAAU,aAAa;EAE5B,IAAI,QAAQ,IAAI,aAAa,eACvB;OAAA,SAAS,KAAK,SAAS,QAAQ,wBACjC,0BAAA,cAAc,MAAM,MAAM;EAAA;CAGhC,EACF,CAAC;MACI;EACL,IAAI,QAAQ,WAAW,MAAM;EAE7B,IAAI,QAAQ,IAAI,aAAa,eACvB;OAAA,QAAQ,wBACV,0BAAA,cAAc,KAAK,MAAM;EAAA;CAG/B;AACF,EACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { u as QueryClientConfig } from "./types-u_Tu5Ybs.cjs";
|
|
2
|
-
import { t as QueryClient } from "./queryClient-
|
|
2
|
+
import { t as QueryClient } from "./queryClient-yJW8K_VP.cjs";
|
|
3
3
|
type ClientPersister = (client: QueryClient) => [() => void, Promise<void>];
|
|
4
4
|
interface CommonOptions {
|
|
5
5
|
/** Enables the legacy Vue Devtools v6 plugin panel. Prefer `@tanstack/vue-query-devtools` for Vue 3 apps. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vueQueryPlugin.d.cts","names":[],"sources":["../../src/vueQueryPlugin.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"vueQueryPlugin.d.cts","names":[],"sources":["../../src/vueQueryPlugin.ts"],"mappings":";;KAOK,mBAAmB,QAAQ,6BAA6B;UAEnD;;EAER;;;;;EAKA;;;;;EAKA,kBAAkB;;EAElB,4BAA4B,QAAQ;;UAG5B,sBAAsB;;EAE9B,oBAAoB;;UAGZ,sBAAsB;;EAE9B,cAAc;;;;;;YAOJ,wBAAwB,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAiCvC;EACI,UAAA,UAAG,UAAW"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { u as QueryClientConfig } from "./types-u_Tu5Ybs.js";
|
|
2
|
-
import { t as QueryClient } from "./queryClient-
|
|
2
|
+
import { t as QueryClient } from "./queryClient-6AWIHAhP.js";
|
|
3
3
|
type ClientPersister = (client: QueryClient) => [() => void, Promise<void>];
|
|
4
4
|
interface CommonOptions {
|
|
5
5
|
/** Enables the legacy Vue Devtools v6 plugin panel. Prefer `@tanstack/vue-query-devtools` for Vue 3 apps. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vueQueryPlugin.d.ts","names":[],"sources":["../../src/vueQueryPlugin.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"vueQueryPlugin.d.ts","names":[],"sources":["../../src/vueQueryPlugin.ts"],"mappings":";;KAOK,mBAAmB,QAAQ,6BAA6B;UAEnD;;EAER;;;;;EAKA;;;;;EAKA,kBAAkB;;EAElB,4BAA4B,QAAQ;;UAG5B,sBAAsB;;EAE9B,oBAAoB;;UAGZ,sBAAsB;;EAE9B,cAAc;;;;;;YAOJ,wBAAwB,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAiCvC;EACI,UAAA,UAAG,UAAW"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getClientKey } from "./utils.js";
|
|
2
|
-
import { QueryClient as QueryClient$1 } from "./queryClient.js";
|
|
3
2
|
import { setupDevtools } from "./devtools/devtools.js";
|
|
3
|
+
import { QueryClient as QueryClient$1 } from "./queryClient.js";
|
|
4
4
|
import { environmentManager } from "@tanstack/query-core";
|
|
5
5
|
import { isVue2 } from "vue-demi";
|
|
6
6
|
// src/vueQueryPlugin.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vueQueryPlugin.js","names":["QueryClient"],"sources":["../../src/vueQueryPlugin.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"vueQueryPlugin.js","names":["QueryClient"],"sources":["../../src/vueQueryPlugin.ts"],"sourcesContent":["import { environmentManager } from '@tanstack/query-core'\nimport { isVue2 } from 'vue-demi'\nimport { setupDevtools } from './devtools/devtools'\nimport { QueryClient } from './queryClient'\nimport { getClientKey } from './utils'\nimport type { QueryClientConfig } from './types'\n\ntype ClientPersister = (client: QueryClient) => [() => void, Promise<void>]\n\ninterface CommonOptions {\n /** Enables the legacy Vue Devtools v6 plugin panel. Prefer `@tanstack/vue-query-devtools` for Vue 3 apps. */\n enableDevtoolsV6Plugin?: boolean\n /**\n * Distinguishes multiple `QueryClient`s provided in the same app — pass the same key to `useQueryClient` to\n * pick this one. Only needed when installing more than one client.\n */\n queryClientKey?: string\n /**\n * Restores a persisted cache before the app mounts. While it runs, `queryClient.isRestoring` is `true`, which\n * suppresses fetches — see `usePersistQueryClient` in `@tanstack/query-persist-client-core` for building one.\n */\n clientPersister?: ClientPersister\n /** Called once `clientPersister`'s returned promise resolves and the cache has finished restoring. */\n clientPersisterOnSuccess?: (client: QueryClient) => void\n}\n\ninterface ConfigOptions extends CommonOptions {\n /** Options for the `QueryClient` the plugin constructs. Ignored if `queryClient` is also set. */\n queryClientConfig?: QueryClientConfig\n}\n\ninterface ClientOptions extends CommonOptions {\n /** Use your own `QueryClient` instance instead of having the plugin construct one from `queryClientConfig`. */\n queryClient?: QueryClient\n}\n\n/**\n * The options accepted by `VueQueryPlugin`: either a `queryClient` to install, or a `queryClientConfig` for the\n * client the plugin creates, plus the shared options.\n */\nexport type VueQueryPluginOptions = ConfigOptions | ClientOptions\n\n/**\n * Installs a `QueryClient` on the Vue app, making it available to every descendant component through\n * `useQueryClient` — the Vue equivalent of React's `QueryClientProvider`, but wired up as an app-level plugin\n * instead of a wrapping component.\n * @example\n * ```ts\n * import { createApp } from 'vue'\n * import { VueQueryPlugin } from '@tanstack/vue-query'\n *\n * const app = createApp(App)\n * app.use(VueQueryPlugin)\n * ```\n * @example\n * Pass a `queryClient` you constructed yourself — useful for SSR, where you need a fresh `QueryClient` per\n * request, or when the same instance also needs to be used outside of Vue components:\n * ```ts\n * import { QueryClient, VueQueryPlugin } from '@tanstack/vue-query'\n *\n * const queryClient = new QueryClient()\n * app.use(VueQueryPlugin, { queryClient })\n * ```\n * @example\n * Or pass `queryClientConfig` to let the plugin construct the `QueryClient` for you, with your own defaults:\n * ```ts\n * app.use(VueQueryPlugin, {\n * queryClientConfig: {\n * defaultOptions: { queries: { staleTime: 5 * 1000 } },\n * },\n * })\n * ```\n */\nexport const VueQueryPlugin = {\n install: (app: any, options: VueQueryPluginOptions = {}) => {\n const clientKey = getClientKey(options.queryClientKey)\n let client: QueryClient\n\n if ('queryClient' in options && options.queryClient) {\n client = options.queryClient\n } else {\n const clientConfig =\n 'queryClientConfig' in options ? options.queryClientConfig : undefined\n client = new QueryClient(clientConfig)\n }\n\n if (!environmentManager.isServer()) {\n client.mount()\n }\n\n let persisterUnmount = () => {\n // noop\n }\n\n if (options.clientPersister) {\n if (client.isRestoring) {\n client.isRestoring.value = true\n }\n const [unmount, promise] = options.clientPersister(client)\n persisterUnmount = unmount\n promise.then(\n () => {\n if (client.isRestoring) {\n client.isRestoring.value = false\n }\n options.clientPersisterOnSuccess?.(client)\n },\n () => {\n if (client.isRestoring) {\n client.isRestoring.value = false\n }\n },\n )\n }\n\n const cleanup = () => {\n client.unmount()\n persisterUnmount()\n }\n\n if (app.onUnmount) {\n app.onUnmount(cleanup)\n } else {\n const originalUnmount = app.unmount\n app.unmount = function vueQueryUnmount() {\n cleanup()\n originalUnmount()\n }\n }\n\n if (isVue2) {\n app.mixin({\n beforeCreate() {\n // HACK: taken from provide(): https://github.com/vuejs/composition-api/blob/master/src/apis/inject.ts#L30\n if (!this._provided) {\n const provideCache = {}\n Object.defineProperty(this, '_provided', {\n get: () => provideCache,\n set: (v) => Object.assign(provideCache, v),\n })\n }\n\n this._provided[clientKey] = client\n\n if (process.env.NODE_ENV === 'development') {\n if (this === this.$root && options.enableDevtoolsV6Plugin) {\n setupDevtools(this, client)\n }\n }\n },\n })\n } else {\n app.provide(clientKey, client)\n\n if (process.env.NODE_ENV === 'development') {\n if (options.enableDevtoolsV6Plugin) {\n setupDevtools(app, client)\n }\n }\n }\n },\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyEA,MAAa,iBAAiB,EAC5B,UAAU,KAAU,UAAiC,CAAC,MAAM;CAC1D,MAAM,YAAY,aAAa,QAAQ,cAAc;CACrD,IAAI;CAEJ,IAAI,iBAAiB,WAAW,QAAQ,aACtC,SAAS,QAAQ;MACZ;EACL,MAAM,eACJ,uBAAuB,UAAU,QAAQ,oBAAoB,KAAA;EAC/D,SAAS,IAAIA,cAAY,YAAY;CACvC;CAEA,IAAI,CAAC,mBAAmB,SAAS,GAC/B,OAAO,MAAM;CAGf,IAAI,yBAAyB,CAE7B;CAEA,IAAI,QAAQ,iBAAiB;EAC3B,IAAI,OAAO,aACT,OAAO,YAAY,QAAQ;EAE7B,MAAM,CAAC,SAAS,WAAW,QAAQ,gBAAgB,MAAM;EACzD,mBAAmB;EACnB,QAAQ,WACA;;GACJ,IAAI,OAAO,aACT,OAAO,YAAY,QAAQ;GAE7B,CAAA,wBAAA,QAAQ,8BAAA,QAAA,0BAAA,KAAA,KAAA,sBAAA,KAAA,SAA2B,MAAM;EAC3C,SACM;GACJ,IAAI,OAAO,aACT,OAAO,YAAY,QAAQ;EAE/B,CACF;CACF;CAEA,MAAM,gBAAgB;EACpB,OAAO,QAAQ;EACf,iBAAiB;CACnB;CAEA,IAAI,IAAI,WACN,IAAI,UAAU,OAAO;MAChB;EACL,MAAM,kBAAkB,IAAI;EAC5B,IAAI,UAAU,SAAS,kBAAkB;GACvC,QAAQ;GACR,gBAAgB;EAClB;CACF;CAEA,IAAI,QACF,IAAI,MAAM,EACR,eAAe;EAEb,IAAI,CAAC,KAAK,WAAW;GACnB,MAAM,eAAe,CAAC;GACtB,OAAO,eAAe,MAAM,aAAa;IACvC,WAAW;IACX,MAAM,MAAM,OAAO,OAAO,cAAc,CAAC;GAC3C,CAAC;EACH;EAEA,KAAK,UAAU,aAAa;EAE5B,IAAI,QAAQ,IAAI,aAAa,eACvB;OAAA,SAAS,KAAK,SAAS,QAAQ,wBACjC,cAAc,MAAM,MAAM;EAAA;CAGhC,EACF,CAAC;MACI;EACL,IAAI,QAAQ,WAAW,MAAM;EAE7B,IAAI,QAAQ,IAAI,aAAa,eACvB;OAAA,QAAQ,wBACV,cAAc,KAAK,MAAM;EAAA;CAG/B;AACF,EACF"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_devtools_utils = require("./utils.cjs");
|
|
3
3
|
let _tanstack_query_core = require("@tanstack/query-core");
|
|
4
|
-
let _vue_devtools_api = require("@vue/devtools-api");
|
|
5
4
|
let _tanstack_match_sorter_utils = require("@tanstack/match-sorter-utils");
|
|
5
|
+
let _vue_devtools_api = require("@vue/devtools-api");
|
|
6
6
|
// src/devtools/devtools.ts
|
|
7
7
|
const pluginId = "vue-query";
|
|
8
8
|
const pluginName = "Vue Query";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devtools.cjs","names":["sortFns","rankItem","getQueryStateLabel","getQueryStatusFg","getQueryStatusBg"],"sources":["../../../src/devtools/devtools.ts"],"sourcesContent":["import { setupDevtoolsPlugin } from '@vue/devtools-api'\nimport { rankItem } from '@tanstack/match-sorter-utils'\nimport { onlineManager } from '@tanstack/query-core'\nimport {\n getQueryStateLabel,\n getQueryStatusBg,\n getQueryStatusFg,\n sortFns,\n} from './utils'\nimport type { CustomInspectorNode } from '@vue/devtools-api'\nimport type { Query, QueryCacheNotifyEvent } from '@tanstack/query-core'\nimport type { QueryClient } from '../queryClient'\n\nconst pluginId = 'vue-query'\nconst pluginName = 'Vue Query'\n\n/**\n * Registers the Vue Query plugin with the Vue devtools, adding a query inspector and a timeline\n * layer for query cache events.\n * @param app - The Vue app instance.\n * @param queryClient - The client whose query cache is shown in the devtools.\n */\nexport function setupDevtools(app: any, queryClient: QueryClient) {\n setupDevtoolsPlugin(\n {\n id: pluginId,\n label: pluginName,\n packageName: 'vue-query',\n homepage: 'https://tanstack.com/query/latest',\n logo: 'https://raw.githubusercontent.com/TanStack/query/main/packages/vue-query/media/vue-query.svg',\n app,\n settings: {\n baseSort: {\n type: 'choice',\n component: 'button-group',\n label: 'Sort Cache Entries',\n options: [\n {\n label: 'ASC',\n value: 1,\n },\n {\n label: 'DESC',\n value: -1,\n },\n ],\n defaultValue: 1,\n },\n sortFn: {\n type: 'choice',\n label: 'Sort Function',\n options: Object.keys(sortFns).map((key) => ({\n label: key,\n value: key,\n })),\n defaultValue: Object.keys(sortFns)[0]!,\n },\n onlineMode: {\n type: 'choice',\n component: 'button-group',\n label: 'Online mode',\n options: [\n {\n label: 'Online',\n value: 1,\n },\n {\n label: 'Offline',\n value: 0,\n },\n ],\n defaultValue: 1,\n },\n },\n },\n (api) => {\n const initialSettings = api.getSettings()\n onlineManager.setOnline(Boolean(initialSettings.onlineMode.valueOf()))\n\n const queryCache = queryClient.getQueryCache()\n\n api.addInspector({\n id: pluginId,\n label: pluginName,\n icon: 'api',\n nodeActions: [\n {\n icon: 'file_download',\n tooltip: 'Refetch',\n action: (queryHash: string) => {\n queryCache.get(queryHash)?.fetch()\n },\n },\n {\n icon: 'alarm',\n tooltip: 'Invalidate',\n action: (queryHash: string) => {\n const query = queryCache.get(queryHash) as Query\n queryClient.invalidateQueries({\n queryKey: query.queryKey,\n exact: true,\n })\n },\n },\n {\n icon: 'settings_backup_restore',\n tooltip: 'Reset',\n action: (queryHash: string) => {\n queryCache.get(queryHash)?.reset()\n },\n },\n {\n icon: 'delete',\n tooltip: 'Remove',\n action: (queryHash: string) => {\n const query = queryCache.get(queryHash) as Query\n queryCache.remove(query)\n },\n },\n {\n icon: 'hourglass_empty',\n tooltip: 'Force loading',\n action: (queryHash: string) => {\n const query = queryCache.get(queryHash) as Query\n\n query.setState({\n data: undefined,\n status: 'pending',\n })\n },\n },\n {\n icon: 'error_outline',\n tooltip: 'Force error',\n action: (queryHash: string) => {\n const query = queryCache.get(queryHash) as Query\n\n query.setState({\n data: undefined,\n status: 'error',\n error: new Error('Unknown error from devtools'),\n })\n },\n },\n ],\n })\n\n api.addTimelineLayer({\n id: pluginId,\n label: pluginName,\n color: 0xffd94c,\n })\n\n queryCache.subscribe((event) => {\n api.sendInspectorTree(pluginId)\n api.sendInspectorState(pluginId)\n\n const queryEvents: Array<QueryCacheNotifyEvent['type']> = [\n 'added',\n 'removed',\n 'updated',\n ]\n\n if (queryEvents.includes(event.type)) {\n api.addTimelineEvent({\n layerId: pluginId,\n event: {\n title: event.type,\n subtitle: event.query.queryHash,\n time: api.now(),\n data: {\n queryHash: event.query.queryHash,\n ...event,\n },\n },\n })\n }\n })\n\n api.on.setPluginSettings((payload) => {\n if (payload.key === 'onlineMode') {\n onlineManager.setOnline(Boolean(payload.newValue))\n }\n })\n\n api.on.getInspectorTree((payload) => {\n if (payload.inspectorId === pluginId) {\n const queries = queryCache.getAll()\n const settings = api.getSettings()\n\n const filtered = payload.filter\n ? queries.filter(\n (item) => rankItem(item.queryHash, payload.filter).passed,\n )\n : [...queries]\n\n const sorted = filtered.sort(\n (a, b) => sortFns[settings.sortFn]!(a, b) * settings.baseSort,\n )\n\n const nodes: Array<CustomInspectorNode> = sorted.map((query) => {\n const stateLabel = getQueryStateLabel(query)\n\n return {\n id: query.queryHash,\n label: query.queryHash,\n tags: [\n {\n label: `${stateLabel} [${query.getObserversCount()}]`,\n textColor: getQueryStatusFg(query),\n backgroundColor: getQueryStatusBg(query),\n },\n ],\n }\n })\n payload.rootNodes = nodes\n }\n })\n\n api.on.getInspectorState((payload) => {\n if (payload.inspectorId === pluginId) {\n const query = queryCache.get(payload.nodeId)\n\n if (!query) {\n return\n }\n\n payload.state = {\n ' Query Details': [\n {\n key: 'Query key',\n value: query.queryHash,\n },\n {\n key: 'Query status',\n value: getQueryStateLabel(query),\n },\n {\n key: 'Observers',\n value: query.getObserversCount(),\n },\n {\n key: 'Last Updated',\n value: new Date(query.state.dataUpdatedAt).toLocaleTimeString(),\n },\n ],\n 'Data Explorer': [\n {\n key: 'Data',\n value: query.state.data,\n },\n ],\n 'Query Explorer': [\n {\n key: 'Query',\n value: query,\n },\n ],\n }\n }\n })\n },\n )\n}\n"],"mappings":";;;;;;AAaA,MAAM,WAAW;AACjB,MAAM,aAAa;;;;;;;AAQnB,SAAgB,cAAc,KAAU,aAA0B;CAChE,CAAA,GAAA,kBAAA,oBAAA,CACE;EACE,IAAI;EACJ,OAAO;EACP,aAAa;EACb,UAAU;EACV,MAAM;EACN;EACA,UAAU;GACR,UAAU;IACR,MAAM;IACN,WAAW;IACX,OAAO;IACP,SAAS,CACP;KACE,OAAO;KACP,OAAO;IACT,GACA;KACE,OAAO;KACP,OAAO;IACT,CACF;IACA,cAAc;GAChB;GACA,QAAQ;IACN,MAAM;IACN,OAAO;IACP,SAAS,OAAO,KAAKA,uBAAAA,OAAO,CAAC,CAAC,KAAK,SAAS;KAC1C,OAAO;KACP,OAAO;IACT,EAAE;IACF,cAAc,OAAO,KAAKA,uBAAAA,OAAO,CAAC,CAAC;GACrC;GACA,YAAY;IACV,MAAM;IACN,WAAW;IACX,OAAO;IACP,SAAS,CACP;KACE,OAAO;KACP,OAAO;IACT,GACA;KACE,OAAO;KACP,OAAO;IACT,CACF;IACA,cAAc;GAChB;EACF;CACF,IACC,QAAQ;EACP,MAAM,kBAAkB,IAAI,YAAY;EACxC,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OACL,OAAO,IAAI,KAAK,MAAM,MAAM,aAAa,CAAC,CAAC,mBAAmB;MAChE;KACF;KACA,iBAAiB,CACf;MACE,KAAK;MACL,OAAO,MAAM,MAAM;KACrB,CACF;KACA,kBAAkB,CAChB;MACE,KAAK;MACL,OAAO;KACT,CACF;IACF;GACF;EACF,CAAC;CACH,CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"devtools.cjs","names":["sortFns","rankItem","getQueryStateLabel","getQueryStatusFg","getQueryStatusBg"],"sources":["../../../src/devtools/devtools.ts"],"sourcesContent":["import { rankItem } from '@tanstack/match-sorter-utils'\nimport { onlineManager } from '@tanstack/query-core'\nimport { setupDevtoolsPlugin } from '@vue/devtools-api'\nimport {\n getQueryStateLabel,\n getQueryStatusBg,\n getQueryStatusFg,\n sortFns,\n} from './utils'\nimport type { Query, QueryCacheNotifyEvent } from '@tanstack/query-core'\nimport type { CustomInspectorNode } from '@vue/devtools-api'\nimport type { QueryClient } from '../queryClient'\n\nconst pluginId = 'vue-query'\nconst pluginName = 'Vue Query'\n\n/**\n * Registers the Vue Query plugin with the Vue devtools, adding a query inspector and a timeline\n * layer for query cache events.\n * @param app - The Vue app instance.\n * @param queryClient - The client whose query cache is shown in the devtools.\n */\nexport function setupDevtools(app: any, queryClient: QueryClient) {\n setupDevtoolsPlugin(\n {\n id: pluginId,\n label: pluginName,\n packageName: 'vue-query',\n homepage: 'https://tanstack.com/query/latest',\n logo: 'https://raw.githubusercontent.com/TanStack/query/main/packages/vue-query/media/vue-query.svg',\n app,\n settings: {\n baseSort: {\n type: 'choice',\n component: 'button-group',\n label: 'Sort Cache Entries',\n options: [\n {\n label: 'ASC',\n value: 1,\n },\n {\n label: 'DESC',\n value: -1,\n },\n ],\n defaultValue: 1,\n },\n sortFn: {\n type: 'choice',\n label: 'Sort Function',\n options: Object.keys(sortFns).map((key) => ({\n label: key,\n value: key,\n })),\n defaultValue: Object.keys(sortFns)[0]!,\n },\n onlineMode: {\n type: 'choice',\n component: 'button-group',\n label: 'Online mode',\n options: [\n {\n label: 'Online',\n value: 1,\n },\n {\n label: 'Offline',\n value: 0,\n },\n ],\n defaultValue: 1,\n },\n },\n },\n (api) => {\n const initialSettings = api.getSettings()\n onlineManager.setOnline(Boolean(initialSettings.onlineMode.valueOf()))\n\n const queryCache = queryClient.getQueryCache()\n\n api.addInspector({\n id: pluginId,\n label: pluginName,\n icon: 'api',\n nodeActions: [\n {\n icon: 'file_download',\n tooltip: 'Refetch',\n action: (queryHash: string) => {\n queryCache.get(queryHash)?.fetch()\n },\n },\n {\n icon: 'alarm',\n tooltip: 'Invalidate',\n action: (queryHash: string) => {\n const query = queryCache.get(queryHash) as Query\n queryClient.invalidateQueries({\n queryKey: query.queryKey,\n exact: true,\n })\n },\n },\n {\n icon: 'settings_backup_restore',\n tooltip: 'Reset',\n action: (queryHash: string) => {\n queryCache.get(queryHash)?.reset()\n },\n },\n {\n icon: 'delete',\n tooltip: 'Remove',\n action: (queryHash: string) => {\n const query = queryCache.get(queryHash) as Query\n queryCache.remove(query)\n },\n },\n {\n icon: 'hourglass_empty',\n tooltip: 'Force loading',\n action: (queryHash: string) => {\n const query = queryCache.get(queryHash) as Query\n\n query.setState({\n data: undefined,\n status: 'pending',\n })\n },\n },\n {\n icon: 'error_outline',\n tooltip: 'Force error',\n action: (queryHash: string) => {\n const query = queryCache.get(queryHash) as Query\n\n query.setState({\n data: undefined,\n status: 'error',\n error: new Error('Unknown error from devtools'),\n })\n },\n },\n ],\n })\n\n api.addTimelineLayer({\n id: pluginId,\n label: pluginName,\n color: 0xffd94c,\n })\n\n queryCache.subscribe((event) => {\n api.sendInspectorTree(pluginId)\n api.sendInspectorState(pluginId)\n\n const queryEvents: Array<QueryCacheNotifyEvent['type']> = [\n 'added',\n 'removed',\n 'updated',\n ]\n\n if (queryEvents.includes(event.type)) {\n api.addTimelineEvent({\n layerId: pluginId,\n event: {\n title: event.type,\n subtitle: event.query.queryHash,\n time: api.now(),\n data: {\n queryHash: event.query.queryHash,\n ...event,\n },\n },\n })\n }\n })\n\n api.on.setPluginSettings((payload) => {\n if (payload.key === 'onlineMode') {\n onlineManager.setOnline(Boolean(payload.newValue))\n }\n })\n\n api.on.getInspectorTree((payload) => {\n if (payload.inspectorId === pluginId) {\n const queries = queryCache.getAll()\n const settings = api.getSettings()\n\n const filtered = payload.filter\n ? queries.filter(\n (item) => rankItem(item.queryHash, payload.filter).passed,\n )\n : [...queries]\n\n const sorted = filtered.sort(\n (a, b) => sortFns[settings.sortFn]!(a, b) * settings.baseSort,\n )\n\n const nodes: Array<CustomInspectorNode> = sorted.map((query) => {\n const stateLabel = getQueryStateLabel(query)\n\n return {\n id: query.queryHash,\n label: query.queryHash,\n tags: [\n {\n label: `${stateLabel} [${query.getObserversCount()}]`,\n textColor: getQueryStatusFg(query),\n backgroundColor: getQueryStatusBg(query),\n },\n ],\n }\n })\n payload.rootNodes = nodes\n }\n })\n\n api.on.getInspectorState((payload) => {\n if (payload.inspectorId === pluginId) {\n const query = queryCache.get(payload.nodeId)\n\n if (!query) {\n return\n }\n\n payload.state = {\n ' Query Details': [\n {\n key: 'Query key',\n value: query.queryHash,\n },\n {\n key: 'Query status',\n value: getQueryStateLabel(query),\n },\n {\n key: 'Observers',\n value: query.getObserversCount(),\n },\n {\n key: 'Last Updated',\n value: new Date(query.state.dataUpdatedAt).toLocaleTimeString(),\n },\n ],\n 'Data Explorer': [\n {\n key: 'Data',\n value: query.state.data,\n },\n ],\n 'Query Explorer': [\n {\n key: 'Query',\n value: query,\n },\n ],\n }\n }\n })\n },\n )\n}\n"],"mappings":";;;;;;AAaA,MAAM,WAAW;AACjB,MAAM,aAAa;;;;;;;AAQnB,SAAgB,cAAc,KAAU,aAA0B;CAChE,CAAA,GAAA,kBAAA,oBAAA,CACE;EACE,IAAI;EACJ,OAAO;EACP,aAAa;EACb,UAAU;EACV,MAAM;EACN;EACA,UAAU;GACR,UAAU;IACR,MAAM;IACN,WAAW;IACX,OAAO;IACP,SAAS,CACP;KACE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M,kBAAkB,EAAE;OACnD,WAAWC,uBAAAA,iBAAiB,KAAK;OACjC,iBAAiBC,uBAAAA,iBAAiB,KAAK;MACzC,CACF;KACF;IACF,CACwB;GAC1B;EACF,CAAC;EAED,IAAI,GAAG,mBAAmB,YAAY;GACpC,IAAI,QAAQ,gBAAgB,UAAU;IACpC,MAAM,QAAQ,WAAW,IAAI,QAAQ,MAAM;IAE3C,IAAI,CAAC,OACH;IAGF,QAAQ,QAAQ;KACd,kBAAkB;MAChB;OACE,KAAK;OACL,OAAO,MAAM;MACf;MACA;OACE,KAAK;OACL,OAAOF,uBAAAA,mBAAmB,KAAK;MACjC;MACA;OACE,KAAK;OACL,OAAO,MAAM,kBAAkB;MACjC;MACA;OACE,KAAK;OACL,OAAO,IAAI,KAAK,MAAM,MAAM,aAAa,CAAC,CAAC,mBAAmB;MAChE;KACF;KACA,iBAAiB,CACf;MACE,KAAK;MACL,OAAO,MAAM,MAAM;KACrB,CACF;KACA,kBAAkB,CAChB;MACE,KAAK;MACL,OAAO;KACT,CACF;IACF;GACF;EACF,CAAC;CACH,CACF;AACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getQueryStateLabel, getQueryStatusBg, getQueryStatusFg, sortFns } from "./utils.js";
|
|
2
2
|
import { onlineManager } from "@tanstack/query-core";
|
|
3
|
-
import { setupDevtoolsPlugin } from "@vue/devtools-api";
|
|
4
3
|
import { rankItem } from "@tanstack/match-sorter-utils";
|
|
4
|
+
import { setupDevtoolsPlugin } from "@vue/devtools-api";
|
|
5
5
|
// src/devtools/devtools.ts
|
|
6
6
|
const pluginId = "vue-query";
|
|
7
7
|
const pluginName = "Vue Query";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devtools.js","names":[],"sources":["../../../src/devtools/devtools.ts"],"sourcesContent":["import { setupDevtoolsPlugin } from '@vue/devtools-api'\nimport { rankItem } from '@tanstack/match-sorter-utils'\nimport { onlineManager } from '@tanstack/query-core'\nimport {\n getQueryStateLabel,\n getQueryStatusBg,\n getQueryStatusFg,\n sortFns,\n} from './utils'\nimport type { CustomInspectorNode } from '@vue/devtools-api'\nimport type { Query, QueryCacheNotifyEvent } from '@tanstack/query-core'\nimport type { QueryClient } from '../queryClient'\n\nconst pluginId = 'vue-query'\nconst pluginName = 'Vue Query'\n\n/**\n * Registers the Vue Query plugin with the Vue devtools, adding a query inspector and a timeline\n * layer for query cache events.\n * @param app - The Vue app instance.\n * @param queryClient - The client whose query cache is shown in the devtools.\n */\nexport function setupDevtools(app: any, queryClient: QueryClient) {\n setupDevtoolsPlugin(\n {\n id: pluginId,\n label: pluginName,\n packageName: 'vue-query',\n homepage: 'https://tanstack.com/query/latest',\n logo: 'https://raw.githubusercontent.com/TanStack/query/main/packages/vue-query/media/vue-query.svg',\n app,\n settings: {\n baseSort: {\n type: 'choice',\n component: 'button-group',\n label: 'Sort Cache Entries',\n options: [\n {\n label: 'ASC',\n value: 1,\n },\n {\n label: 'DESC',\n value: -1,\n },\n ],\n defaultValue: 1,\n },\n sortFn: {\n type: 'choice',\n label: 'Sort Function',\n options: Object.keys(sortFns).map((key) => ({\n label: key,\n value: key,\n })),\n defaultValue: Object.keys(sortFns)[0]!,\n },\n onlineMode: {\n type: 'choice',\n component: 'button-group',\n label: 'Online mode',\n options: [\n {\n label: 'Online',\n value: 1,\n },\n {\n label: 'Offline',\n value: 0,\n },\n ],\n defaultValue: 1,\n },\n },\n },\n (api) => {\n const initialSettings = api.getSettings()\n onlineManager.setOnline(Boolean(initialSettings.onlineMode.valueOf()))\n\n const queryCache = queryClient.getQueryCache()\n\n api.addInspector({\n id: pluginId,\n label: pluginName,\n icon: 'api',\n nodeActions: [\n {\n icon: 'file_download',\n tooltip: 'Refetch',\n action: (queryHash: string) => {\n queryCache.get(queryHash)?.fetch()\n },\n },\n {\n icon: 'alarm',\n tooltip: 'Invalidate',\n action: (queryHash: string) => {\n const query = queryCache.get(queryHash) as Query\n queryClient.invalidateQueries({\n queryKey: query.queryKey,\n exact: true,\n })\n },\n },\n {\n icon: 'settings_backup_restore',\n tooltip: 'Reset',\n action: (queryHash: string) => {\n queryCache.get(queryHash)?.reset()\n },\n },\n {\n icon: 'delete',\n tooltip: 'Remove',\n action: (queryHash: string) => {\n const query = queryCache.get(queryHash) as Query\n queryCache.remove(query)\n },\n },\n {\n icon: 'hourglass_empty',\n tooltip: 'Force loading',\n action: (queryHash: string) => {\n const query = queryCache.get(queryHash) as Query\n\n query.setState({\n data: undefined,\n status: 'pending',\n })\n },\n },\n {\n icon: 'error_outline',\n tooltip: 'Force error',\n action: (queryHash: string) => {\n const query = queryCache.get(queryHash) as Query\n\n query.setState({\n data: undefined,\n status: 'error',\n error: new Error('Unknown error from devtools'),\n })\n },\n },\n ],\n })\n\n api.addTimelineLayer({\n id: pluginId,\n label: pluginName,\n color: 0xffd94c,\n })\n\n queryCache.subscribe((event) => {\n api.sendInspectorTree(pluginId)\n api.sendInspectorState(pluginId)\n\n const queryEvents: Array<QueryCacheNotifyEvent['type']> = [\n 'added',\n 'removed',\n 'updated',\n ]\n\n if (queryEvents.includes(event.type)) {\n api.addTimelineEvent({\n layerId: pluginId,\n event: {\n title: event.type,\n subtitle: event.query.queryHash,\n time: api.now(),\n data: {\n queryHash: event.query.queryHash,\n ...event,\n },\n },\n })\n }\n })\n\n api.on.setPluginSettings((payload) => {\n if (payload.key === 'onlineMode') {\n onlineManager.setOnline(Boolean(payload.newValue))\n }\n })\n\n api.on.getInspectorTree((payload) => {\n if (payload.inspectorId === pluginId) {\n const queries = queryCache.getAll()\n const settings = api.getSettings()\n\n const filtered = payload.filter\n ? queries.filter(\n (item) => rankItem(item.queryHash, payload.filter).passed,\n )\n : [...queries]\n\n const sorted = filtered.sort(\n (a, b) => sortFns[settings.sortFn]!(a, b) * settings.baseSort,\n )\n\n const nodes: Array<CustomInspectorNode> = sorted.map((query) => {\n const stateLabel = getQueryStateLabel(query)\n\n return {\n id: query.queryHash,\n label: query.queryHash,\n tags: [\n {\n label: `${stateLabel} [${query.getObserversCount()}]`,\n textColor: getQueryStatusFg(query),\n backgroundColor: getQueryStatusBg(query),\n },\n ],\n }\n })\n payload.rootNodes = nodes\n }\n })\n\n api.on.getInspectorState((payload) => {\n if (payload.inspectorId === pluginId) {\n const query = queryCache.get(payload.nodeId)\n\n if (!query) {\n return\n }\n\n payload.state = {\n ' Query Details': [\n {\n key: 'Query key',\n value: query.queryHash,\n },\n {\n key: 'Query status',\n value: getQueryStateLabel(query),\n },\n {\n key: 'Observers',\n value: query.getObserversCount(),\n },\n {\n key: 'Last Updated',\n value: new Date(query.state.dataUpdatedAt).toLocaleTimeString(),\n },\n ],\n 'Data Explorer': [\n {\n key: 'Data',\n value: query.state.data,\n },\n ],\n 'Query Explorer': [\n {\n key: 'Query',\n value: query,\n },\n ],\n }\n }\n })\n },\n )\n}\n"],"mappings":";;;;;AAaA,MAAM,WAAW;AACjB,MAAM,aAAa;;;;;;;AAQnB,SAAgB,cAAc,KAAU,aAA0B;CAChE,oBACE;EACE,IAAI;EACJ,OAAO;EACP,aAAa;EACb,UAAU;EACV,MAAM;EACN;EACA,UAAU;GACR,UAAU;IACR,MAAM;IACN,WAAW;IACX,OAAO;IACP,SAAS,CACP;KACE,OAAO;KACP,OAAO;IACT,GACA;KACE,OAAO;KACP,OAAO;IACT,CACF;IACA,cAAc;GAChB;GACA,QAAQ;IACN,MAAM;IACN,OAAO;IACP,SAAS,OAAO,KAAK,OAAO,CAAC,CAAC,KAAK,SAAS;KAC1C,OAAO;KACP,OAAO;IACT,EAAE;IACF,cAAc,OAAO,KAAK,OAAO,CAAC,CAAC;GACrC;GACA,YAAY;IACV,MAAM;IACN,WAAW;IACX,OAAO;IACP,SAAS,CACP;KACE,OAAO;KACP,OAAO;IACT,GACA;KACE,OAAO;KACP,OAAO;IACT,CACF;IACA,cAAc;GAChB;EACF;CACF,IACC,QAAQ;EACP,MAAM,kBAAkB,IAAI,YAAY;EACxC,cAAc,UAAU,QAAQ,gBAAgB,WAAW,Q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AAM;KACrB,CACF;KACA,kBAAkB,CAChB;MACE,KAAK;MACL,OAAO;KACT,CACF;IACF;GACF;EACF,CAAC;CACH,CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"devtools.js","names":[],"sources":["../../../src/devtools/devtools.ts"],"sourcesContent":["import { rankItem } from '@tanstack/match-sorter-utils'\nimport { onlineManager } from '@tanstack/query-core'\nimport { setupDevtoolsPlugin } from '@vue/devtools-api'\nimport {\n getQueryStateLabel,\n getQueryStatusBg,\n getQueryStatusFg,\n sortFns,\n} from './utils'\nimport type { Query, QueryCacheNotifyEvent } from '@tanstack/query-core'\nimport type { CustomInspectorNode } from '@vue/devtools-api'\nimport type { QueryClient } from '../queryClient'\n\nconst pluginId = 'vue-query'\nconst pluginName = 'Vue Query'\n\n/**\n * Registers the Vue Query plugin with the Vue devtools, adding a query inspector and a timeline\n * layer for query cache events.\n * @param app - The Vue app instance.\n * @param queryClient - The client whose query cache is shown in the devtools.\n */\nexport function setupDevtools(app: any, queryClient: QueryClient) {\n setupDevtoolsPlugin(\n {\n id: pluginId,\n label: pluginName,\n packageName: 'vue-query',\n homepage: 'https://tanstack.com/query/latest',\n logo: 'https://raw.githubusercontent.com/TanStack/query/main/packages/vue-query/media/vue-query.svg',\n app,\n settings: {\n baseSort: {\n type: 'choice',\n component: 'button-group',\n label: 'Sort Cache Entries',\n options: [\n {\n label: 'ASC',\n value: 1,\n },\n {\n label: 'DESC',\n value: -1,\n },\n ],\n defaultValue: 1,\n },\n sortFn: {\n type: 'choice',\n label: 'Sort Function',\n options: Object.keys(sortFns).map((key) => ({\n label: key,\n value: key,\n })),\n defaultValue: Object.keys(sortFns)[0]!,\n },\n onlineMode: {\n type: 'choice',\n component: 'button-group',\n label: 'Online mode',\n options: [\n {\n label: 'Online',\n value: 1,\n },\n {\n label: 'Offline',\n value: 0,\n },\n ],\n defaultValue: 1,\n },\n },\n },\n (api) => {\n const initialSettings = api.getSettings()\n onlineManager.setOnline(Boolean(initialSettings.onlineMode.valueOf()))\n\n const queryCache = queryClient.getQueryCache()\n\n api.addInspector({\n id: pluginId,\n label: pluginName,\n icon: 'api',\n nodeActions: [\n {\n icon: 'file_download',\n tooltip: 'Refetch',\n action: (queryHash: string) => {\n queryCache.get(queryHash)?.fetch()\n },\n },\n {\n icon: 'alarm',\n tooltip: 'Invalidate',\n action: (queryHash: string) => {\n const query = queryCache.get(queryHash) as Query\n queryClient.invalidateQueries({\n queryKey: query.queryKey,\n exact: true,\n })\n },\n },\n {\n icon: 'settings_backup_restore',\n tooltip: 'Reset',\n action: (queryHash: string) => {\n queryCache.get(queryHash)?.reset()\n },\n },\n {\n icon: 'delete',\n tooltip: 'Remove',\n action: (queryHash: string) => {\n const query = queryCache.get(queryHash) as Query\n queryCache.remove(query)\n },\n },\n {\n icon: 'hourglass_empty',\n tooltip: 'Force loading',\n action: (queryHash: string) => {\n const query = queryCache.get(queryHash) as Query\n\n query.setState({\n data: undefined,\n status: 'pending',\n })\n },\n },\n {\n icon: 'error_outline',\n tooltip: 'Force error',\n action: (queryHash: string) => {\n const query = queryCache.get(queryHash) as Query\n\n query.setState({\n data: undefined,\n status: 'error',\n error: new Error('Unknown error from devtools'),\n })\n },\n },\n ],\n })\n\n api.addTimelineLayer({\n id: pluginId,\n label: pluginName,\n color: 0xffd94c,\n })\n\n queryCache.subscribe((event) => {\n api.sendInspectorTree(pluginId)\n api.sendInspectorState(pluginId)\n\n const queryEvents: Array<QueryCacheNotifyEvent['type']> = [\n 'added',\n 'removed',\n 'updated',\n ]\n\n if (queryEvents.includes(event.type)) {\n api.addTimelineEvent({\n layerId: pluginId,\n event: {\n title: event.type,\n subtitle: event.query.queryHash,\n time: api.now(),\n data: {\n queryHash: event.query.queryHash,\n ...event,\n },\n },\n })\n }\n })\n\n api.on.setPluginSettings((payload) => {\n if (payload.key === 'onlineMode') {\n onlineManager.setOnline(Boolean(payload.newValue))\n }\n })\n\n api.on.getInspectorTree((payload) => {\n if (payload.inspectorId === pluginId) {\n const queries = queryCache.getAll()\n const settings = api.getSettings()\n\n const filtered = payload.filter\n ? queries.filter(\n (item) => rankItem(item.queryHash, payload.filter).passed,\n )\n : [...queries]\n\n const sorted = filtered.sort(\n (a, b) => sortFns[settings.sortFn]!(a, b) * settings.baseSort,\n )\n\n const nodes: Array<CustomInspectorNode> = sorted.map((query) => {\n const stateLabel = getQueryStateLabel(query)\n\n return {\n id: query.queryHash,\n label: query.queryHash,\n tags: [\n {\n label: `${stateLabel} [${query.getObserversCount()}]`,\n textColor: getQueryStatusFg(query),\n backgroundColor: getQueryStatusBg(query),\n },\n ],\n }\n })\n payload.rootNodes = nodes\n }\n })\n\n api.on.getInspectorState((payload) => {\n if (payload.inspectorId === pluginId) {\n const query = queryCache.get(payload.nodeId)\n\n if (!query) {\n return\n }\n\n payload.state = {\n ' Query Details': [\n {\n key: 'Query key',\n value: query.queryHash,\n },\n {\n key: 'Query status',\n value: getQueryStateLabel(query),\n },\n {\n key: 'Observers',\n value: query.getObserversCount(),\n },\n {\n key: 'Last Updated',\n value: new Date(query.state.dataUpdatedAt).toLocaleTimeString(),\n },\n ],\n 'Data Explorer': [\n {\n key: 'Data',\n value: query.state.data,\n },\n ],\n 'Query Explorer': [\n {\n key: 'Query',\n value: query,\n },\n ],\n }\n }\n })\n },\n )\n}\n"],"mappings":";;;;;AAaA,MAAM,WAAW;AACjB,MAAM,aAAa;;;;;;;AAQnB,SAAgB,cAAc,KAAU,aAA0B;CAChE,oBACE;EACE,IAAI;EACJ,OAAO;EACP,aAAa;EACb,UAAU;EACV,MAAM;EACN;EACA,UAAU;GACR,UAAU;IACR,MAAM;IACN,WAAW;IACX,OAAO;IACP,SAAS,CACP;KACE,OAAO;KACP,OAAO;IACT,GACA;KACE,OAAO;KACP,OAAO;IACT,CACF;IACA,cAAc;GAChB;GACA,QAAQ;IACN,MAAM;IACN,OAAO;IACP,SAAS,OAAO,KAAK,OAAO,CAAC,CAAC,KAAK,SAAS;KAC1C,OAAO;KACP,OAAO;IACT,EAAE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KACd,kBAAkB;MAChB;OACE,KAAK;OACL,OAAO,MAAM;MACf;MACA;OACE,KAAK;OACL,OAAO,mBAAmB,KAAK;MACjC;MACA;OACE,KAAK;OACL,OAAO,MAAM,kBAAkB;MACjC;MACA;OACE,KAAK;OACL,OAAO,IAAI,KAAK,MAAM,MAAM,aAAa,CAAC,CAAC,mBAAmB;MAChE;KACF;KACA,iBAAiB,CACf;MACE,KAAK;MACL,OAAO,MAAM,MAAM;KACrB,CACF;KACA,kBAAkB,CAChB;MACE,KAAK;MACL,OAAO;KACT,CACF;IACF;GACF;EACF,CAAC;CACH,CACF;AACF"}
|
package/build/modern/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_utils = require("./utils.cjs");
|
|
3
3
|
const require_useQueryClient = require("./useQueryClient.cjs");
|
|
4
|
-
const require_queryCache = require("./queryCache.cjs");
|
|
5
4
|
const require_mutationCache = require("./mutationCache.cjs");
|
|
5
|
+
const require_queryCache = require("./queryCache.cjs");
|
|
6
6
|
const require_queryClient = require("./queryClient.cjs");
|
|
7
7
|
const require_vueQueryPlugin = require("./vueQueryPlugin.cjs");
|
|
8
8
|
const require_queryOptions = require("./queryOptions.cjs");
|
package/build/modern/index.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { c as MutationOptions } from "./types-u_Tu5Ybs.cjs";
|
|
2
|
-
import { a as UndefinedInitialQueryOptionsWithDataTag, i as UndefinedInitialQueryOptions, n as DefinedInitialQueryOptionsWithDataTag, o as UseQueryOptions, r as QueryOptions, s as
|
|
3
|
-
import { t as QueryClient } from "./queryClient-
|
|
2
|
+
import { a as UndefinedInitialQueryOptionsWithDataTag, c as queryOptions, i as UndefinedInitialQueryOptions, n as DefinedInitialQueryOptionsWithDataTag, o as UseQueryOptions, r as QueryOptions, s as VueQueryEnabledOption, t as DefinedInitialQueryOptions } from "./queryOptions-nndmAASX.cjs";
|
|
3
|
+
import { t as QueryClient } from "./queryClient-yJW8K_VP.cjs";
|
|
4
4
|
import { useQueryClient } from "./useQueryClient.cjs";
|
|
5
5
|
import { VueQueryPlugin, VueQueryPluginOptions } from "./vueQueryPlugin.cjs";
|
|
6
6
|
import { QueryCache } from "./queryCache.cjs";
|
|
7
|
-
import { a as UseInfiniteQueryOptions, i as UseInfiniteQueryDefinedReturnType, n as UndefinedInitialDataInfiniteOptions, o as UseInfiniteQueryReturnType, r as infiniteQueryOptions, s as useInfiniteQuery, t as DefinedInitialDataInfiniteOptions } from "./infiniteQueryOptions-
|
|
7
|
+
import { a as UseInfiniteQueryOptions, i as UseInfiniteQueryDefinedReturnType, n as UndefinedInitialDataInfiniteOptions, o as UseInfiniteQueryReturnType, r as infiniteQueryOptions, s as useInfiniteQuery, t as DefinedInitialDataInfiniteOptions } from "./infiniteQueryOptions-CLfd_vOE.cjs";
|
|
8
8
|
import { MutationCache } from "./mutationCache.cjs";
|
|
9
9
|
import { mutationOptions } from "./mutationOptions.cjs";
|
|
10
10
|
import { UseQueryDefinedReturnType, UseQueryReturnType, useQuery } from "./useQuery.cjs";
|
|
@@ -16,4 +16,4 @@ import { UseIsFetchingFilters, useIsFetching } from "./useIsFetching.cjs";
|
|
|
16
16
|
import { MutationStateOptions, UseIsMutatingFilters, useIsMutating, useMutationState } from "./useMutationState.cjs";
|
|
17
17
|
import { VUE_QUERY_CLIENT } from "./utils.cjs";
|
|
18
18
|
export * from "@tanstack/query-core";
|
|
19
|
-
export { type DefinedInitialDataInfiniteOptions, type DefinedInitialQueryOptions, type DefinedInitialQueryOptionsWithDataTag, MutationCache, type MutationOptions, type MutationResult, type MutationStateOptions, QueryCache, QueryClient, type QueryOptions, type UndefinedInitialDataInfiniteOptions, type UndefinedInitialQueryOptions, type UndefinedInitialQueryOptionsWithDataTag, type UseInfiniteQueryDefinedReturnType, type UseInfiniteQueryOptions, type UseInfiniteQueryReturnType, type UseIsFetchingFilters, type UseIsMutatingFilters, type UseMutationOptions, type UseMutationReturnType, type UsePrefetchInfiniteQueryOptions, type UsePrefetchQueryOptions, type UseQueriesOptions, type UseQueriesResults, type UseQueryDefinedReturnType, type UseQueryOptions, type UseQueryReturnType, VUE_QUERY_CLIENT, VueQueryPlugin, type VueQueryPluginOptions, infiniteQueryOptions, mutationOptions, queryOptions, useInfiniteQuery, useIsFetching, useIsMutating, useMutation, useMutationState, usePrefetchInfiniteQuery, usePrefetchQuery, useQueries, useQuery, useQueryClient };
|
|
19
|
+
export { type DefinedInitialDataInfiniteOptions, type DefinedInitialQueryOptions, type DefinedInitialQueryOptionsWithDataTag, MutationCache, type MutationOptions, type MutationResult, type MutationStateOptions, QueryCache, QueryClient, type QueryOptions, type UndefinedInitialDataInfiniteOptions, type UndefinedInitialQueryOptions, type UndefinedInitialQueryOptionsWithDataTag, type UseInfiniteQueryDefinedReturnType, type UseInfiniteQueryOptions, type UseInfiniteQueryReturnType, type UseIsFetchingFilters, type UseIsMutatingFilters, type UseMutationOptions, type UseMutationReturnType, type UsePrefetchInfiniteQueryOptions, type UsePrefetchQueryOptions, type UseQueriesOptions, type UseQueriesResults, type UseQueryDefinedReturnType, type UseQueryOptions, type UseQueryReturnType, VUE_QUERY_CLIENT, type VueQueryEnabledOption, VueQueryPlugin, type VueQueryPluginOptions, infiniteQueryOptions, mutationOptions, queryOptions, useInfiniteQuery, useIsFetching, useIsMutating, useMutation, useMutationState, usePrefetchInfiniteQuery, usePrefetchQuery, useQueries, useQuery, useQueryClient };
|
package/build/modern/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { c as MutationOptions } from "./types-u_Tu5Ybs.js";
|
|
2
|
-
import { a as UndefinedInitialQueryOptionsWithDataTag, i as UndefinedInitialQueryOptions, n as DefinedInitialQueryOptionsWithDataTag, o as UseQueryOptions, r as QueryOptions, s as
|
|
3
|
-
import { t as QueryClient } from "./queryClient-
|
|
2
|
+
import { a as UndefinedInitialQueryOptionsWithDataTag, c as queryOptions, i as UndefinedInitialQueryOptions, n as DefinedInitialQueryOptionsWithDataTag, o as UseQueryOptions, r as QueryOptions, s as VueQueryEnabledOption, t as DefinedInitialQueryOptions } from "./queryOptions-v0l6M7Eo.js";
|
|
3
|
+
import { t as QueryClient } from "./queryClient-6AWIHAhP.js";
|
|
4
4
|
import { useQueryClient } from "./useQueryClient.js";
|
|
5
5
|
import { VueQueryPlugin, VueQueryPluginOptions } from "./vueQueryPlugin.js";
|
|
6
6
|
import { QueryCache } from "./queryCache.js";
|
|
7
|
-
import { a as UseInfiniteQueryOptions, i as UseInfiniteQueryDefinedReturnType, n as UndefinedInitialDataInfiniteOptions, o as UseInfiniteQueryReturnType, r as infiniteQueryOptions, s as useInfiniteQuery, t as DefinedInitialDataInfiniteOptions } from "./infiniteQueryOptions-
|
|
7
|
+
import { a as UseInfiniteQueryOptions, i as UseInfiniteQueryDefinedReturnType, n as UndefinedInitialDataInfiniteOptions, o as UseInfiniteQueryReturnType, r as infiniteQueryOptions, s as useInfiniteQuery, t as DefinedInitialDataInfiniteOptions } from "./infiniteQueryOptions-vEnw-JaW.js";
|
|
8
8
|
import { MutationCache } from "./mutationCache.js";
|
|
9
9
|
import { mutationOptions } from "./mutationOptions.js";
|
|
10
10
|
import { UseQueryDefinedReturnType, UseQueryReturnType, useQuery } from "./useQuery.js";
|
|
@@ -16,4 +16,4 @@ import { UseIsFetchingFilters, useIsFetching } from "./useIsFetching.js";
|
|
|
16
16
|
import { MutationStateOptions, UseIsMutatingFilters, useIsMutating, useMutationState } from "./useMutationState.js";
|
|
17
17
|
import { VUE_QUERY_CLIENT } from "./utils.js";
|
|
18
18
|
export * from "@tanstack/query-core";
|
|
19
|
-
export { type DefinedInitialDataInfiniteOptions, type DefinedInitialQueryOptions, type DefinedInitialQueryOptionsWithDataTag, MutationCache, type MutationOptions, type MutationResult, type MutationStateOptions, QueryCache, QueryClient, type QueryOptions, type UndefinedInitialDataInfiniteOptions, type UndefinedInitialQueryOptions, type UndefinedInitialQueryOptionsWithDataTag, type UseInfiniteQueryDefinedReturnType, type UseInfiniteQueryOptions, type UseInfiniteQueryReturnType, type UseIsFetchingFilters, type UseIsMutatingFilters, type UseMutationOptions, type UseMutationReturnType, type UsePrefetchInfiniteQueryOptions, type UsePrefetchQueryOptions, type UseQueriesOptions, type UseQueriesResults, type UseQueryDefinedReturnType, type UseQueryOptions, type UseQueryReturnType, VUE_QUERY_CLIENT, VueQueryPlugin, type VueQueryPluginOptions, infiniteQueryOptions, mutationOptions, queryOptions, useInfiniteQuery, useIsFetching, useIsMutating, useMutation, useMutationState, usePrefetchInfiniteQuery, usePrefetchQuery, useQueries, useQuery, useQueryClient };
|
|
19
|
+
export { type DefinedInitialDataInfiniteOptions, type DefinedInitialQueryOptions, type DefinedInitialQueryOptionsWithDataTag, MutationCache, type MutationOptions, type MutationResult, type MutationStateOptions, QueryCache, QueryClient, type QueryOptions, type UndefinedInitialDataInfiniteOptions, type UndefinedInitialQueryOptions, type UndefinedInitialQueryOptionsWithDataTag, type UseInfiniteQueryDefinedReturnType, type UseInfiniteQueryOptions, type UseInfiniteQueryReturnType, type UseIsFetchingFilters, type UseIsMutatingFilters, type UseMutationOptions, type UseMutationReturnType, type UsePrefetchInfiniteQueryOptions, type UsePrefetchQueryOptions, type UseQueriesOptions, type UseQueriesResults, type UseQueryDefinedReturnType, type UseQueryOptions, type UseQueryReturnType, VUE_QUERY_CLIENT, type VueQueryEnabledOption, VueQueryPlugin, type VueQueryPluginOptions, infiniteQueryOptions, mutationOptions, queryOptions, useInfiniteQuery, useIsFetching, useIsMutating, useMutation, useMutationState, usePrefetchInfiniteQuery, usePrefetchQuery, useQueries, useQuery, useQueryClient };
|
package/build/modern/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { VUE_QUERY_CLIENT } from "./utils.js";
|
|
2
2
|
import { useQueryClient } from "./useQueryClient.js";
|
|
3
|
-
import { QueryCache } from "./queryCache.js";
|
|
4
3
|
import { MutationCache } from "./mutationCache.js";
|
|
4
|
+
import { QueryCache } from "./queryCache.js";
|
|
5
5
|
import { QueryClient } from "./queryClient.js";
|
|
6
6
|
import { VueQueryPlugin } from "./vueQueryPlugin.js";
|
|
7
7
|
import { queryOptions } from "./queryOptions.js";
|
package/build/modern/{infiniteQueryOptions-lJ_zR-As.d.cts → infiniteQueryOptions-CLfd_vOE.d.cts}
RENAMED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { a as MaybeRef, d as ShallowOption, o as MaybeRefDeep, s as MaybeRefOrGetter, t as DeepUnwrapRef } from "./types-u_Tu5Ybs.cjs";
|
|
2
|
-
import { o as UseQueryOptions } from "./queryOptions-
|
|
3
|
-
import { t as QueryClient$1 } from "./queryClient-
|
|
2
|
+
import { o as UseQueryOptions, s as VueQueryEnabledOption } from "./queryOptions-nndmAASX.cjs";
|
|
3
|
+
import { t as QueryClient$1 } from "./queryClient-yJW8K_VP.cjs";
|
|
4
4
|
import { DefaultError, DefinedInfiniteQueryObserverResult, InfiniteData, InfiniteQueryObserverOptions, InfiniteQueryObserverResult, InitialDataFunction, NonUndefinedGuard, QueryKey, QueryKeyWithDataTag, QueryObserver, QueryObserverResult } from "@tanstack/query-core";
|
|
5
5
|
import { Ref } from "vue-demi";
|
|
6
|
+
/**
|
|
7
|
+
* Readonly view of a union that stays a union. A single `Readonly<Union>` collapses the members, which
|
|
8
|
+
* drops the `status` / `isSuccess` / `isPending` discriminants.
|
|
9
|
+
*/
|
|
10
|
+
type ReadonlyQueryState<T> = T extends any ? { readonly [K in keyof T]: T[K]; } : never;
|
|
6
11
|
/**
|
|
7
12
|
* The result of the query composables: every property of the observer result wrapped in a `Ref`, except
|
|
8
|
-
* the `refetch`, `fetchNextPage`, and `fetchPreviousPage` functions, plus `suspense`.
|
|
13
|
+
* the `refetch`, `fetchNextPage`, and `fetchPreviousPage` functions, plus `suspense` and `state`.
|
|
9
14
|
*/
|
|
10
15
|
type UseBaseQueryReturnType<TData, TError, TResult = QueryObserverResult<TData, TError>> = { [K in keyof TResult]: K extends 'fetchNextPage' | 'fetchPreviousPage' | 'refetch' ? TResult[K] : Ref<Readonly<TResult>[K]>; } & {
|
|
11
16
|
/**
|
|
@@ -17,6 +22,37 @@ type UseBaseQueryReturnType<TData, TError, TResult = QueryObserverResult<TData,
|
|
|
17
22
|
* `true`, in which case it rejects.
|
|
18
23
|
*/
|
|
19
24
|
suspense: () => Promise<TResult>;
|
|
25
|
+
/**
|
|
26
|
+
* The query result as one readonly reactive object. `data`, `error`, `status`, `isPending`, and the other
|
|
27
|
+
* fields are plain values — read `state.data`, not `state.data.value`.
|
|
28
|
+
*
|
|
29
|
+
* The object is a discriminated union, so a check on `status`, `isSuccess`, `isPending`, or `isError`
|
|
30
|
+
* narrows the other fields. When `status` is `'success'` (or `isSuccess` is `true`), `data` is `TData`.
|
|
31
|
+
* When `status` is `'pending'` (or `isPending` is `true`), `data` is `undefined` and `error` is `null`.
|
|
32
|
+
* @example
|
|
33
|
+
* ```vue
|
|
34
|
+
* <script setup lang="ts">
|
|
35
|
+
* import { useQuery } from '@tanstack/vue-query'
|
|
36
|
+
*
|
|
37
|
+
* const { state } = useQuery({
|
|
38
|
+
* queryKey: ['post'],
|
|
39
|
+
* queryFn: fetchPost,
|
|
40
|
+
* })
|
|
41
|
+
*
|
|
42
|
+
* if (state.status === 'success') {
|
|
43
|
+
* // `state.data` is `Post`, not `Post | undefined`
|
|
44
|
+
* console.log(state.data.title)
|
|
45
|
+
* }
|
|
46
|
+
* </script>
|
|
47
|
+
*
|
|
48
|
+
* <template>
|
|
49
|
+
* <span v-if="state.status === 'pending'">Loading...</span>
|
|
50
|
+
* <span v-else-if="state.status === 'error'">Error: {{ state.error.message }}</span>
|
|
51
|
+
* <h1 v-else>{{ state.data.title }}</h1>
|
|
52
|
+
* </template>
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
state: ReadonlyQueryState<TResult>;
|
|
20
56
|
};
|
|
21
57
|
type UseQueryOptionsGeneric<TQueryFnData, TError, TData, TQueryData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> = UseQueryOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey> | UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>;
|
|
22
58
|
/**
|
|
@@ -29,11 +65,16 @@ type UseQueryOptionsGeneric<TQueryFnData, TError, TData, TQueryData, TQueryKey e
|
|
|
29
65
|
*/
|
|
30
66
|
declare function useBaseQuery<TQueryFnData, TError, TData, TQueryData, TQueryKey extends QueryKey, TPageParam>(Observer: typeof QueryObserver, options: MaybeRefOrGetter<UseQueryOptionsGeneric<TQueryFnData, TError, TData, TQueryData, TQueryKey, TPageParam>>, queryClient?: QueryClient$1): UseBaseQueryReturnType<TData, TError>;
|
|
31
67
|
/**
|
|
32
|
-
* The options accepted by `useInfiniteQuery`.
|
|
33
|
-
* `@tanstack/query-core
|
|
34
|
-
* `enabled` a
|
|
68
|
+
* The options accepted by `useInfiniteQuery`. Extends {@link InfiniteQueryObserverOptions} from
|
|
69
|
+
* `@tanstack/query-core` with the `vue-query`-specific `shallow` option. Each option except `shallow` can also
|
|
70
|
+
* be a `ref` (and `enabled` a zero-argument getter or query-core's `(query) => boolean` callback).
|
|
71
|
+
* @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.
|
|
72
|
+
* @template TError - The type of errors your `queryFn` may throw.
|
|
73
|
+
* @template TData - The type `data` ends up as after `select` runs — defaults to `TQueryFnData`.
|
|
74
|
+
* @template TQueryKey - The type of your `queryKey`.
|
|
75
|
+
* @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.
|
|
35
76
|
*/
|
|
36
|
-
type UseInfiniteQueryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> = MaybeRef<{ [Property in keyof InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>]: Property extends 'enabled' ?
|
|
77
|
+
type UseInfiniteQueryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> = MaybeRef<{ [Property in keyof InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>]: Property extends 'enabled' ? VueQueryEnabledOption<TQueryFnData, TError, InfiniteData<TQueryFnData, TPageParam>, DeepUnwrapRef<TQueryKey>> : MaybeRefDeep<InfiniteQueryObserverOptions<TQueryFnData, TError, TData, DeepUnwrapRef<TQueryKey>, TPageParam>[Property]>; } & ShallowOption>;
|
|
37
78
|
/**
|
|
38
79
|
* The result of `useInfiniteQuery`: {@link InfiniteQueryObserverResult} from `@tanstack/query-core`, with
|
|
39
80
|
* its properties wrapped in `Ref`s as in {@link UseBaseQueryReturnType}.
|
|
@@ -51,9 +92,10 @@ type UseInfiniteQueryDefinedReturnType<TData, TError> = UseBaseQueryReturnType<T
|
|
|
51
92
|
* This overload is selected when `initialData` is known to be defined, so the resulting `data` is never
|
|
52
93
|
* `undefined` (unless a `select` changes `TData` to include `undefined`).
|
|
53
94
|
*
|
|
54
|
-
* `enabled`
|
|
55
|
-
*
|
|
56
|
-
*
|
|
95
|
+
* `enabled` accepts a `ref`, a plain boolean, or a zero-argument getter (`() => ...`): a `ref` or a getter is
|
|
96
|
+
* tracked, while a plain boolean isn't tracked on its own. query-core's `(query) => boolean` callback is
|
|
97
|
+
* accepted too and is passed through untracked. `queryKey` reacts through a `ref` for the array itself, or
|
|
98
|
+
* `ref`s and reactive getters as individual entries — the array itself can't be a bare getter.
|
|
57
99
|
* @param options - The {@link DefinedInitialDataInfiniteOptions} to use — everything you can pass to
|
|
58
100
|
* `useInfiniteQuery`, with `initialData` known to be defined.
|
|
59
101
|
* @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`
|
|
@@ -96,9 +138,10 @@ declare function useInfiniteQuery<TQueryFnData, TError = DefaultError, TData = I
|
|
|
96
138
|
* The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of
|
|
97
139
|
* `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`.
|
|
98
140
|
*
|
|
99
|
-
* `enabled`
|
|
100
|
-
*
|
|
101
|
-
*
|
|
141
|
+
* `enabled` accepts a `ref`, a plain boolean, or a zero-argument getter (`() => ...`): a `ref` or a getter is
|
|
142
|
+
* tracked, while a plain boolean isn't tracked on its own. query-core's `(query) => boolean` callback is
|
|
143
|
+
* accepted too and is passed through untracked. `queryKey` reacts through a `ref` for the array itself, or
|
|
144
|
+
* `ref`s and reactive getters as individual entries — the array itself can't be a bare getter.
|
|
102
145
|
* @param options - The {@link UndefinedInitialDataInfiniteOptions} to use — everything you can pass to
|
|
103
146
|
* `useInfiniteQuery`.
|
|
104
147
|
* @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`
|
|
@@ -210,9 +253,10 @@ declare function useInfiniteQuery<TQueryFnData, TError = DefaultError, TData = I
|
|
|
210
253
|
* `ref`/reactive object built up conditionally, rather than a plain object literal. Prefer one of the other
|
|
211
254
|
* overloads when possible, since they infer whether `data` can be `undefined` from `initialData` directly.
|
|
212
255
|
*
|
|
213
|
-
* `enabled`
|
|
214
|
-
*
|
|
215
|
-
*
|
|
256
|
+
* `enabled` accepts a `ref`, a plain boolean, or a zero-argument getter (`() => ...`): a `ref` or a getter is
|
|
257
|
+
* tracked, while a plain boolean isn't tracked on its own. query-core's `(query) => boolean` callback is
|
|
258
|
+
* accepted too and is passed through untracked. `queryKey` reacts through a `ref` for the array itself, or
|
|
259
|
+
* `ref`s and reactive getters as individual entries — the array itself can't be a bare getter.
|
|
216
260
|
* @param options - A `ref`, plain value, or reactive getter resolving to the {@link UseInfiniteQueryOptions} to
|
|
217
261
|
* use.
|
|
218
262
|
* @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`
|
|
@@ -371,4 +415,4 @@ declare function infiniteQueryOptions<TQueryFnData, TError = DefaultError, TData
|
|
|
371
415
|
*/
|
|
372
416
|
declare function infiniteQueryOptions<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(options: UndefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>): UndefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>;
|
|
373
417
|
export { UseInfiniteQueryOptions as a, UseBaseQueryReturnType as c, UseInfiniteQueryDefinedReturnType as i, useBaseQuery as l, UndefinedInitialDataInfiniteOptions as n, UseInfiniteQueryReturnType as o, infiniteQueryOptions as r, useInfiniteQuery as s, DefinedInitialDataInfiniteOptions as t };
|
|
374
|
-
//# sourceMappingURL=infiniteQueryOptions-
|
|
418
|
+
//# sourceMappingURL=infiniteQueryOptions-CLfd_vOE.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"infiniteQueryOptions-CLfd_vOE.d.cts","names":["QueryClient","QueryClient"],"sources":["../../src/useBaseQuery.ts","../../src/useInfiniteQuery.ts","../../src/infiniteQueryOptions.ts"],"mappings":";;;;;;;;;KA8BK,mBAAmB,KAAK,4BACb,WAAW,IAAI,EAAE;;;;;KAOrB,uBACV,OACA,QACA,UAAU,oBAAoB,OAAO,cAEpC,WAAW,UAAU,8DAIlB,QAAQ,KACR,IAAI,SAAS,SAAS;;;;;;;;;EAU1B,gBAAgB,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+BxB,OAAO,mBAAmB;;KAGvB,uBACH,cACA,QACA,OACA,YACA,kBAAkB,WAAW,UAC7B,wBAEE,gBAAgB,cAAc,QAAQ,OAAO,YAAY,aACzD,wBAAwB,cAAc,QAAQ,OAAO,WAAW;;;;;;;;;iBAUpD,aACd,cACA,QACA,OACA,YACA,kBAAkB,UAClB,YAEA,iBAAiB,eACjB,SAAS,iBACP,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