@tanstack/query-core 4.0.11-beta.0 → 4.1.0
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/build/cjs/focusManager.js +101 -0
- package/build/cjs/focusManager.js.map +1 -0
- package/build/cjs/hydration.js +112 -0
- package/build/cjs/hydration.js.map +1 -0
- package/build/cjs/index.js +51 -0
- package/build/cjs/index.js.map +1 -0
- package/build/cjs/infiniteQueryBehavior.js +160 -0
- package/build/cjs/infiniteQueryBehavior.js.map +1 -0
- package/build/cjs/infiniteQueryObserver.js +92 -0
- package/build/cjs/infiniteQueryObserver.js.map +1 -0
- package/build/cjs/logger.js +18 -0
- package/build/cjs/logger.js.map +1 -0
- package/build/cjs/mutation.js +258 -0
- package/build/cjs/mutation.js.map +1 -0
- package/build/cjs/mutationCache.js +99 -0
- package/build/cjs/mutationCache.js.map +1 -0
- package/build/cjs/mutationObserver.js +140 -0
- package/build/cjs/mutationObserver.js.map +1 -0
- package/build/cjs/notifyManager.js +114 -0
- package/build/cjs/notifyManager.js.map +1 -0
- package/build/cjs/onlineManager.js +100 -0
- package/build/cjs/onlineManager.js.map +1 -0
- package/build/cjs/queriesObserver.js +170 -0
- package/build/cjs/queriesObserver.js.map +1 -0
- package/build/cjs/query.js +474 -0
- package/build/cjs/query.js.map +1 -0
- package/build/cjs/queryCache.js +140 -0
- package/build/cjs/queryCache.js.map +1 -0
- package/build/cjs/queryClient.js +353 -0
- package/build/cjs/queryClient.js.map +1 -0
- package/build/cjs/queryObserver.js +529 -0
- package/build/cjs/queryObserver.js.map +1 -0
- package/build/cjs/removable.js +47 -0
- package/build/cjs/removable.js.map +1 -0
- package/build/cjs/retryer.js +177 -0
- package/build/cjs/retryer.js.map +1 -0
- package/build/cjs/subscribable.js +43 -0
- package/build/cjs/subscribable.js.map +1 -0
- package/build/cjs/utils.js +356 -0
- package/build/cjs/utils.js.map +1 -0
- package/build/{lib/index.mjs → esm/index.js} +18 -1
- package/build/esm/index.js.map +1 -0
- package/build/stats-html.html +2689 -0
- package/build/stats.json +811 -0
- package/build/{lib → types/packages/query-core/src}/focusManager.d.ts +0 -0
- package/build/{lib → types/packages/query-core/src}/hydration.d.ts +0 -0
- package/build/{lib → types/packages/query-core/src}/index.d.ts +2 -2
- package/build/{lib → types/packages/query-core/src}/infiniteQueryBehavior.d.ts +0 -0
- package/build/{lib → types/packages/query-core/src}/infiniteQueryObserver.d.ts +0 -0
- package/build/{lib → types/packages/query-core/src}/logger.d.ts +0 -0
- package/build/{lib → types/packages/query-core/src}/logger.native.d.ts +0 -0
- package/build/{lib → types/packages/query-core/src}/mutation.d.ts +0 -0
- package/build/{lib → types/packages/query-core/src}/mutationCache.d.ts +6 -1
- package/build/{lib → types/packages/query-core/src}/mutationObserver.d.ts +0 -0
- package/build/{lib → types/packages/query-core/src}/notifyManager.d.ts +0 -0
- package/build/{lib → types/packages/query-core/src}/onlineManager.d.ts +0 -0
- package/build/{lib → types/packages/query-core/src}/queriesObserver.d.ts +0 -0
- package/build/{lib → types/packages/query-core/src}/query.d.ts +0 -0
- package/build/{lib → types/packages/query-core/src}/queryCache.d.ts +6 -1
- package/build/{lib → types/packages/query-core/src}/queryClient.d.ts +0 -0
- package/build/{lib → types/packages/query-core/src}/queryObserver.d.ts +0 -0
- package/build/{lib → types/packages/query-core/src}/removable.d.ts +0 -0
- package/build/{lib → types/packages/query-core/src}/retryer.d.ts +0 -0
- package/build/{lib → types/packages/query-core/src}/subscribable.d.ts +0 -0
- package/build/types/packages/query-core/src/tests/focusManager.test.d.ts +1 -0
- package/build/types/packages/query-core/src/tests/hydration.test.d.ts +1 -0
- package/build/types/packages/query-core/src/tests/infiniteQueryBehavior.test.d.ts +1 -0
- package/build/types/packages/query-core/src/tests/infiniteQueryObserver.test.d.ts +1 -0
- package/build/types/packages/query-core/src/tests/mutationCache.test.d.ts +1 -0
- package/build/types/packages/query-core/src/tests/mutationObserver.test.d.ts +1 -0
- package/build/types/packages/query-core/src/tests/mutations.test.d.ts +1 -0
- package/build/types/packages/query-core/src/tests/notifyManager.test.d.ts +1 -0
- package/build/types/packages/query-core/src/tests/onlineManager.test.d.ts +1 -0
- package/build/types/packages/query-core/src/tests/queriesObserver.test.d.ts +1 -0
- package/build/types/packages/query-core/src/tests/query.test.d.ts +1 -0
- package/build/types/packages/query-core/src/tests/queryCache.test.d.ts +1 -0
- package/build/types/packages/query-core/src/tests/queryClient.test.d.ts +1 -0
- package/build/types/packages/query-core/src/tests/queryObserver.test.d.ts +1 -0
- package/build/types/packages/query-core/src/tests/utils.test.d.ts +1 -0
- package/build/{lib → types/packages/query-core/src}/types.d.ts +0 -0
- package/build/{lib → types/packages/query-core/src}/utils.d.ts +0 -0
- package/build/types/tests/utils.d.ts +24 -0
- package/build/umd/index.development.js +17 -0
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +7 -16
- package/src/index.ts +2 -2
- package/src/mutationCache.ts +7 -0
- package/src/mutationObserver.ts +9 -0
- package/src/queryCache.ts +7 -0
- package/src/queryObserver.ts +8 -0
- package/src/tests/queryObserver.test.tsx +19 -0
- package/build/lib/index.js +0 -3096
- package/build/lib/index.js.map +0 -1
- package/build/lib/index.mjs.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/query-core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "TODO",
|
|
5
5
|
"author": "tannerlinsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -10,25 +10,16 @@
|
|
|
10
10
|
"type": "github",
|
|
11
11
|
"url": "https://github.com/sponsors/tannerlinsley"
|
|
12
12
|
},
|
|
13
|
-
"module": "build/
|
|
14
|
-
"main": "build/
|
|
13
|
+
"module": "build/esm/index.js",
|
|
14
|
+
"main": "build/cjs/index.js",
|
|
15
15
|
"browser": "build/umd/index.production.js",
|
|
16
|
-
"types": "build/
|
|
17
|
-
"exports": {
|
|
18
|
-
".": {
|
|
19
|
-
"types": "./build/lib/index.d.ts",
|
|
20
|
-
"import": "./build/lib/index.mjs",
|
|
21
|
-
"default": "./build/lib/index.js"
|
|
22
|
-
},
|
|
23
|
-
"./package.json": "./package.json"
|
|
24
|
-
},
|
|
16
|
+
"types": "build/types/packages/query-core/src/index.d.ts",
|
|
25
17
|
"files": [
|
|
26
|
-
"build
|
|
27
|
-
"build/umd/*",
|
|
18
|
+
"build/*",
|
|
28
19
|
"src"
|
|
29
20
|
],
|
|
30
21
|
"scripts": {
|
|
31
|
-
"
|
|
32
|
-
"
|
|
22
|
+
"test:eslint": "../../node_modules/.bin/eslint --ext .ts,.tsx ./src",
|
|
23
|
+
"compile": "../../node_modules/.bin/tsc -p tsconfig.json --noEmit --emitDeclarationOnly false"
|
|
33
24
|
}
|
|
34
25
|
}
|
package/src/index.ts
CHANGED
|
@@ -17,13 +17,13 @@ export {
|
|
|
17
17
|
parseMutationFilterArgs,
|
|
18
18
|
parseMutationArgs,
|
|
19
19
|
} from './utils'
|
|
20
|
-
export type { MutationFilters, QueryFilters
|
|
20
|
+
export type { MutationFilters, QueryFilters } from './utils'
|
|
21
21
|
export { isCancelledError } from './retryer'
|
|
22
22
|
export { dehydrate, hydrate } from './hydration'
|
|
23
23
|
|
|
24
24
|
// Types
|
|
25
25
|
export * from './types'
|
|
26
|
-
export type { Query
|
|
26
|
+
export type { Query } from './query'
|
|
27
27
|
export type { Mutation } from './mutation'
|
|
28
28
|
export type { Logger } from './logger'
|
|
29
29
|
export type {
|
package/src/mutationCache.ts
CHANGED
|
@@ -48,6 +48,12 @@ interface NotifyEventMutationObserverRemoved {
|
|
|
48
48
|
observer: MutationObserver<any, any, any>
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
interface NotifyEventMutationObserverOptionsUpdated {
|
|
52
|
+
type: 'observerOptionsUpdated'
|
|
53
|
+
mutation?: Mutation<any, any, any, any>
|
|
54
|
+
observer: MutationObserver<any, any, any, any>
|
|
55
|
+
}
|
|
56
|
+
|
|
51
57
|
interface NotifyEventMutationUpdated {
|
|
52
58
|
type: 'updated'
|
|
53
59
|
mutation: Mutation<any, any, any, any>
|
|
@@ -59,6 +65,7 @@ type MutationCacheNotifyEvent =
|
|
|
59
65
|
| NotifyEventMutationRemoved
|
|
60
66
|
| NotifyEventMutationObserverAdded
|
|
61
67
|
| NotifyEventMutationObserverRemoved
|
|
68
|
+
| NotifyEventMutationObserverOptionsUpdated
|
|
62
69
|
| NotifyEventMutationUpdated
|
|
63
70
|
|
|
64
71
|
type MutationCacheListener = (event: MutationCacheNotifyEvent) => void
|
package/src/mutationObserver.ts
CHANGED
|
@@ -8,6 +8,7 @@ import type {
|
|
|
8
8
|
MutationObserverResult,
|
|
9
9
|
MutationObserverOptions,
|
|
10
10
|
} from './types'
|
|
11
|
+
import { shallowEqualObjects } from './utils'
|
|
11
12
|
|
|
12
13
|
// TYPES
|
|
13
14
|
|
|
@@ -63,7 +64,15 @@ export class MutationObserver<
|
|
|
63
64
|
setOptions(
|
|
64
65
|
options?: MutationObserverOptions<TData, TError, TVariables, TContext>,
|
|
65
66
|
) {
|
|
67
|
+
const prevOptions = this.options
|
|
66
68
|
this.options = this.client.defaultMutationOptions(options)
|
|
69
|
+
if (!shallowEqualObjects(prevOptions, this.options)) {
|
|
70
|
+
this.client.getMutationCache().notify({
|
|
71
|
+
type: 'observerOptionsUpdated',
|
|
72
|
+
mutation: this.currentMutation,
|
|
73
|
+
observer: this,
|
|
74
|
+
})
|
|
75
|
+
}
|
|
67
76
|
}
|
|
68
77
|
|
|
69
78
|
protected onUnsubscribe(): void {
|
package/src/queryCache.ts
CHANGED
|
@@ -55,6 +55,12 @@ interface NotifyEventQueryObserverResultsUpdated {
|
|
|
55
55
|
query: Query<any, any, any, any>
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
interface NotifyEventQueryObserverOptionsUpdated {
|
|
59
|
+
type: 'observerOptionsUpdated'
|
|
60
|
+
query: Query<any, any, any, any>
|
|
61
|
+
observer: QueryObserver<any, any, any, any, any>
|
|
62
|
+
}
|
|
63
|
+
|
|
58
64
|
type QueryCacheNotifyEvent =
|
|
59
65
|
| NotifyEventQueryAdded
|
|
60
66
|
| NotifyEventQueryRemoved
|
|
@@ -62,6 +68,7 @@ type QueryCacheNotifyEvent =
|
|
|
62
68
|
| NotifyEventQueryObserverAdded
|
|
63
69
|
| NotifyEventQueryObserverRemoved
|
|
64
70
|
| NotifyEventQueryObserverResultsUpdated
|
|
71
|
+
| NotifyEventQueryObserverOptionsUpdated
|
|
65
72
|
|
|
66
73
|
type QueryCacheListener = (event: QueryCacheNotifyEvent) => void
|
|
67
74
|
|
package/src/queryObserver.ts
CHANGED
|
@@ -155,6 +155,14 @@ export class QueryObserver<
|
|
|
155
155
|
|
|
156
156
|
this.options = this.client.defaultQueryOptions(options)
|
|
157
157
|
|
|
158
|
+
if (!shallowEqualObjects(prevOptions, this.options)) {
|
|
159
|
+
this.client.getQueryCache().notify({
|
|
160
|
+
type: 'observerOptionsUpdated',
|
|
161
|
+
query: this.currentQuery,
|
|
162
|
+
observer: this,
|
|
163
|
+
})
|
|
164
|
+
}
|
|
165
|
+
|
|
158
166
|
if (
|
|
159
167
|
typeof this.options.enabled !== 'undefined' &&
|
|
160
168
|
typeof this.options.enabled !== 'boolean'
|
|
@@ -799,4 +799,23 @@ describe('queryObserver', () => {
|
|
|
799
799
|
|
|
800
800
|
unsubscribe()
|
|
801
801
|
})
|
|
802
|
+
|
|
803
|
+
test('setOptions should notify cache listeners', async () => {
|
|
804
|
+
const key = queryKey()
|
|
805
|
+
|
|
806
|
+
const observer = new QueryObserver(queryClient, {
|
|
807
|
+
queryKey: key,
|
|
808
|
+
})
|
|
809
|
+
|
|
810
|
+
const spy = jest.fn()
|
|
811
|
+
const unsubscribe = queryClient.getQueryCache().subscribe(spy)
|
|
812
|
+
observer.setOptions({ enabled: false })
|
|
813
|
+
|
|
814
|
+
expect(spy).toHaveBeenCalledTimes(1)
|
|
815
|
+
expect(spy).toHaveBeenCalledWith(
|
|
816
|
+
expect.objectContaining({ type: 'observerOptionsUpdated' }),
|
|
817
|
+
)
|
|
818
|
+
|
|
819
|
+
unsubscribe()
|
|
820
|
+
})
|
|
802
821
|
})
|