@tanstack/query-core 5.0.0-alpha.3 → 5.0.0-alpha.32
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/lib/_virtual/_rollupPluginBabelHelpers.esm.js +13 -0
- package/build/lib/_virtual/_rollupPluginBabelHelpers.esm.js.map +1 -0
- package/build/lib/_virtual/_rollupPluginBabelHelpers.js +16 -0
- package/build/lib/_virtual/_rollupPluginBabelHelpers.js.map +1 -0
- package/build/lib/focusManager.d.ts +1 -0
- package/build/lib/focusManager.d.ts.map +1 -0
- package/build/lib/focusManager.esm.js +31 -15
- package/build/lib/focusManager.esm.js.map +1 -1
- package/build/lib/focusManager.js +31 -15
- package/build/lib/focusManager.js.map +1 -1
- package/build/lib/hydration.d.ts +3 -6
- package/build/lib/hydration.d.ts.map +1 -0
- package/build/lib/hydration.esm.js +9 -20
- package/build/lib/hydration.esm.js.map +1 -1
- package/build/lib/hydration.js +9 -20
- package/build/lib/hydration.js.map +1 -1
- package/build/lib/hydration.mjs +4 -18
- package/build/lib/hydration.mjs.map +1 -1
- package/build/lib/index.d.ts +4 -3
- package/build/lib/index.d.ts.map +1 -0
- package/build/lib/infiniteQueryBehavior.d.ts +3 -2
- package/build/lib/infiniteQueryBehavior.d.ts.map +1 -0
- package/build/lib/infiniteQueryBehavior.esm.js +52 -48
- package/build/lib/infiniteQueryBehavior.esm.js.map +1 -1
- package/build/lib/infiniteQueryBehavior.js +52 -48
- package/build/lib/infiniteQueryBehavior.js.map +1 -1
- package/build/lib/infiniteQueryBehavior.mjs +48 -45
- package/build/lib/infiniteQueryBehavior.mjs.map +1 -1
- package/build/lib/infiniteQueryObserver.d.ts +7 -6
- package/build/lib/infiniteQueryObserver.d.ts.map +1 -0
- package/build/lib/infiniteQueryObserver.esm.js +7 -8
- package/build/lib/infiniteQueryObserver.esm.js.map +1 -1
- package/build/lib/infiniteQueryObserver.js +7 -8
- package/build/lib/infiniteQueryObserver.js.map +1 -1
- package/build/lib/infiniteQueryObserver.mjs +4 -6
- package/build/lib/infiniteQueryObserver.mjs.map +1 -1
- package/build/lib/mutation.d.ts +1 -0
- package/build/lib/mutation.d.ts.map +1 -0
- package/build/lib/mutation.esm.js +127 -102
- package/build/lib/mutation.esm.js.map +1 -1
- package/build/lib/mutation.js +127 -102
- package/build/lib/mutation.js.map +1 -1
- package/build/lib/mutationCache.d.ts +1 -0
- package/build/lib/mutationCache.d.ts.map +1 -0
- package/build/lib/mutationCache.esm.js +34 -20
- package/build/lib/mutationCache.esm.js.map +1 -1
- package/build/lib/mutationCache.js +34 -20
- package/build/lib/mutationCache.js.map +1 -1
- package/build/lib/mutationCache.mjs +5 -4
- package/build/lib/mutationCache.mjs.map +1 -1
- package/build/lib/mutationObserver.d.ts +1 -0
- package/build/lib/mutationObserver.d.ts.map +1 -0
- package/build/lib/mutationObserver.esm.js +82 -52
- package/build/lib/mutationObserver.esm.js.map +1 -1
- package/build/lib/mutationObserver.js +82 -52
- package/build/lib/mutationObserver.js.map +1 -1
- package/build/lib/mutationObserver.mjs +1 -1
- package/build/lib/mutationObserver.mjs.map +1 -1
- package/build/lib/notifyManager.d.ts +1 -0
- package/build/lib/notifyManager.d.ts.map +1 -0
- package/build/lib/onlineManager.d.ts +1 -0
- package/build/lib/onlineManager.d.ts.map +1 -0
- package/build/lib/onlineManager.esm.js +29 -14
- package/build/lib/onlineManager.esm.js.map +1 -1
- package/build/lib/onlineManager.js +29 -14
- package/build/lib/onlineManager.js.map +1 -1
- package/build/lib/queriesObserver.d.ts +1 -0
- package/build/lib/queriesObserver.d.ts.map +1 -0
- package/build/lib/queriesObserver.esm.js +98 -68
- package/build/lib/queriesObserver.esm.js.map +1 -1
- package/build/lib/queriesObserver.js +98 -68
- package/build/lib/queriesObserver.js.map +1 -1
- package/build/lib/queriesObserver.mjs +7 -6
- package/build/lib/queriesObserver.mjs.map +1 -1
- package/build/lib/query.d.ts +5 -3
- package/build/lib/query.d.ts.map +1 -0
- package/build/lib/query.esm.js +211 -162
- package/build/lib/query.esm.js.map +1 -1
- package/build/lib/query.js +211 -162
- package/build/lib/query.js.map +1 -1
- package/build/lib/query.mjs +2 -2
- package/build/lib/query.mjs.map +1 -1
- package/build/lib/queryCache.d.ts +1 -1
- package/build/lib/queryCache.d.ts.map +1 -0
- package/build/lib/queryCache.esm.js +20 -13
- package/build/lib/queryCache.esm.js.map +1 -1
- package/build/lib/queryCache.js +20 -13
- package/build/lib/queryCache.js.map +1 -1
- package/build/lib/queryCache.mjs +6 -5
- package/build/lib/queryCache.mjs.map +1 -1
- package/build/lib/queryClient.d.ts +1 -0
- package/build/lib/queryClient.d.ts.map +1 -0
- package/build/lib/queryClient.esm.js +113 -71
- package/build/lib/queryClient.esm.js.map +1 -1
- package/build/lib/queryClient.js +113 -71
- package/build/lib/queryClient.js.map +1 -1
- package/build/lib/queryClient.mjs +17 -13
- package/build/lib/queryClient.mjs.map +1 -1
- package/build/lib/queryObserver.d.ts +3 -4
- package/build/lib/queryObserver.d.ts.map +1 -0
- package/build/lib/queryObserver.esm.js +303 -214
- package/build/lib/queryObserver.esm.js.map +1 -1
- package/build/lib/queryObserver.js +301 -212
- package/build/lib/queryObserver.js.map +1 -1
- package/build/lib/queryObserver.mjs +16 -28
- package/build/lib/queryObserver.mjs.map +1 -1
- package/build/lib/removable.d.ts +1 -0
- package/build/lib/removable.d.ts.map +1 -0
- package/build/lib/removable.esm.js +13 -6
- package/build/lib/removable.esm.js.map +1 -1
- package/build/lib/removable.js +13 -6
- package/build/lib/removable.js.map +1 -1
- package/build/lib/retryer.d.ts +1 -0
- package/build/lib/retryer.d.ts.map +1 -0
- package/build/lib/retryer.esm.js +15 -14
- package/build/lib/retryer.esm.js.map +1 -1
- package/build/lib/retryer.js +15 -14
- package/build/lib/retryer.js.map +1 -1
- package/build/lib/subscribable.d.ts +2 -1
- package/build/lib/subscribable.d.ts.map +1 -0
- package/build/lib/subscribable.esm.js +4 -4
- package/build/lib/subscribable.esm.js.map +1 -1
- package/build/lib/subscribable.js +4 -4
- package/build/lib/subscribable.js.map +1 -1
- package/build/lib/subscribable.mjs +4 -4
- package/build/lib/subscribable.mjs.map +1 -1
- package/build/lib/tests/focusManager.test.d.ts +1 -0
- package/build/lib/tests/focusManager.test.d.ts.map +1 -0
- package/build/lib/tests/hydration.test.d.ts +1 -0
- package/build/lib/tests/hydration.test.d.ts.map +1 -0
- package/build/lib/tests/infiniteQueryBehavior.test.d.ts +1 -0
- package/build/lib/tests/infiniteQueryBehavior.test.d.ts.map +1 -0
- package/build/lib/tests/infiniteQueryObserver.test.d.ts +1 -0
- package/build/lib/tests/infiniteQueryObserver.test.d.ts.map +1 -0
- package/build/lib/tests/mutationCache.test.d.ts +1 -0
- package/build/lib/tests/mutationCache.test.d.ts.map +1 -0
- package/build/lib/tests/mutationObserver.test.d.ts +1 -0
- package/build/lib/tests/mutationObserver.test.d.ts.map +1 -0
- package/build/lib/tests/mutations.test.d.ts +1 -0
- package/build/lib/tests/mutations.test.d.ts.map +1 -0
- package/build/lib/tests/notifyManager.test.d.ts +1 -0
- package/build/lib/tests/notifyManager.test.d.ts.map +1 -0
- package/build/lib/tests/onlineManager.test.d.ts +1 -0
- package/build/lib/tests/onlineManager.test.d.ts.map +1 -0
- package/build/lib/tests/queriesObserver.test.d.ts +1 -0
- package/build/lib/tests/queriesObserver.test.d.ts.map +1 -0
- package/build/lib/tests/query.test.d.ts +1 -0
- package/build/lib/tests/query.test.d.ts.map +1 -0
- package/build/lib/tests/queryCache.test.d.ts +1 -0
- package/build/lib/tests/queryCache.test.d.ts.map +1 -0
- package/build/lib/tests/queryClient.test.d.ts +1 -0
- package/build/lib/tests/queryClient.test.d.ts.map +1 -0
- package/build/lib/tests/queryObserver.test.d.ts +1 -0
- package/build/lib/tests/queryObserver.test.d.ts.map +1 -0
- package/build/lib/tests/utils.d.ts +5 -5
- package/build/lib/tests/utils.d.ts.map +1 -0
- package/build/lib/tests/utils.test.d.ts +1 -0
- package/build/lib/tests/utils.test.d.ts.map +1 -0
- package/build/lib/types.d.ts +12 -21
- package/build/lib/types.d.ts.map +1 -0
- package/build/lib/utils.d.ts +1 -0
- package/build/lib/utils.d.ts.map +1 -0
- package/build/lib/utils.esm.js +1 -1
- package/build/lib/utils.esm.js.map +1 -1
- package/build/lib/utils.js +1 -1
- package/build/lib/utils.js.map +1 -1
- package/build/umd/index.development.js +113 -131
- 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 +2 -2
- package/src/hydration.ts +18 -37
- package/src/index.ts +2 -4
- package/src/infiniteQueryBehavior.ts +52 -60
- package/src/infiniteQueryObserver.ts +15 -10
- package/src/mutationCache.ts +4 -4
- package/src/mutationObserver.ts +1 -1
- package/src/queriesObserver.ts +11 -11
- package/src/query.ts +8 -6
- package/src/queryCache.ts +5 -8
- package/src/queryClient.ts +18 -19
- package/src/queryObserver.ts +32 -41
- package/src/subscribable.ts +5 -5
- package/src/tests/focusManager.test.tsx +12 -14
- package/src/tests/hydration.test.tsx +22 -17
- package/src/tests/infiniteQueryBehavior.test.tsx +16 -9
- package/src/tests/infiniteQueryObserver.test.tsx +62 -1
- package/src/tests/mutationCache.test.tsx +11 -10
- package/src/tests/mutationObserver.test.tsx +3 -2
- package/src/tests/mutations.test.tsx +11 -10
- package/src/tests/notifyManager.test.tsx +7 -6
- package/src/tests/onlineManager.test.tsx +12 -17
- package/src/tests/queriesObserver.test.tsx +18 -17
- package/src/tests/query.test.tsx +19 -18
- package/src/tests/queryCache.test.tsx +12 -28
- package/src/tests/queryClient.test.tsx +82 -49
- package/src/tests/queryObserver.test.tsx +131 -9
- package/src/tests/utils.test.tsx +2 -1
- package/src/tests/utils.ts +5 -4
- package/src/types.ts +22 -20
|
@@ -1,31 +1,131 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var _rollupPluginBabelHelpers = require('./_virtual/_rollupPluginBabelHelpers.js');
|
|
3
4
|
var utils = require('./utils.js');
|
|
4
5
|
var notifyManager = require('./notifyManager.js');
|
|
5
6
|
var focusManager = require('./focusManager.js');
|
|
6
7
|
var subscribable = require('./subscribable.js');
|
|
7
8
|
var retryer = require('./retryer.js');
|
|
8
9
|
|
|
10
|
+
var _client = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("client");
|
|
11
|
+
var _currentQuery = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("currentQuery");
|
|
12
|
+
var _currentQueryInitialState = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("currentQueryInitialState");
|
|
13
|
+
var _currentResult = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("currentResult");
|
|
14
|
+
var _currentResultState = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("currentResultState");
|
|
15
|
+
var _currentResultOptions = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("currentResultOptions");
|
|
16
|
+
var _selectError = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("selectError");
|
|
17
|
+
var _selectFn = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("selectFn");
|
|
18
|
+
var _selectResult = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("selectResult");
|
|
19
|
+
var _lastQueryWithDefinedData = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("lastQueryWithDefinedData");
|
|
20
|
+
var _staleTimeoutId = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("staleTimeoutId");
|
|
21
|
+
var _refetchIntervalId = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("refetchIntervalId");
|
|
22
|
+
var _currentRefetchInterval = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("currentRefetchInterval");
|
|
23
|
+
var _trackedProps = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("trackedProps");
|
|
24
|
+
var _executeFetch = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("executeFetch");
|
|
25
|
+
var _updateStaleTimeout = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("updateStaleTimeout");
|
|
26
|
+
var _computeRefetchInterval = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("computeRefetchInterval");
|
|
27
|
+
var _updateRefetchInterval = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("updateRefetchInterval");
|
|
28
|
+
var _updateTimers = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("updateTimers");
|
|
29
|
+
var _clearStaleTimeout = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("clearStaleTimeout");
|
|
30
|
+
var _clearRefetchInterval = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("clearRefetchInterval");
|
|
31
|
+
var _updateResult = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("updateResult");
|
|
32
|
+
var _updateQuery = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("updateQuery");
|
|
33
|
+
var _notify = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("notify");
|
|
9
34
|
class QueryObserver extends subscribable.Subscribable {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
#currentResult = undefined;
|
|
14
|
-
#currentResultState;
|
|
15
|
-
#currentResultOptions;
|
|
16
|
-
#previousQueryResult;
|
|
17
|
-
#selectError;
|
|
18
|
-
#selectFn;
|
|
19
|
-
#selectResult;
|
|
20
|
-
#staleTimeoutId;
|
|
21
|
-
#refetchIntervalId;
|
|
22
|
-
#currentRefetchInterval;
|
|
23
|
-
#trackedProps = new Set();
|
|
35
|
+
// This property keeps track of the last query with defined data.
|
|
36
|
+
// It will be used to pass the previous data and query to the placeholder function between renders.
|
|
37
|
+
|
|
24
38
|
constructor(client, options) {
|
|
25
39
|
super();
|
|
26
|
-
this
|
|
40
|
+
Object.defineProperty(this, _notify, {
|
|
41
|
+
value: _notify2
|
|
42
|
+
});
|
|
43
|
+
Object.defineProperty(this, _updateQuery, {
|
|
44
|
+
value: _updateQuery2
|
|
45
|
+
});
|
|
46
|
+
Object.defineProperty(this, _updateResult, {
|
|
47
|
+
value: _updateResult2
|
|
48
|
+
});
|
|
49
|
+
Object.defineProperty(this, _clearRefetchInterval, {
|
|
50
|
+
value: _clearRefetchInterval2
|
|
51
|
+
});
|
|
52
|
+
Object.defineProperty(this, _clearStaleTimeout, {
|
|
53
|
+
value: _clearStaleTimeout2
|
|
54
|
+
});
|
|
55
|
+
Object.defineProperty(this, _updateTimers, {
|
|
56
|
+
value: _updateTimers2
|
|
57
|
+
});
|
|
58
|
+
Object.defineProperty(this, _updateRefetchInterval, {
|
|
59
|
+
value: _updateRefetchInterval2
|
|
60
|
+
});
|
|
61
|
+
Object.defineProperty(this, _computeRefetchInterval, {
|
|
62
|
+
value: _computeRefetchInterval2
|
|
63
|
+
});
|
|
64
|
+
Object.defineProperty(this, _updateStaleTimeout, {
|
|
65
|
+
value: _updateStaleTimeout2
|
|
66
|
+
});
|
|
67
|
+
Object.defineProperty(this, _executeFetch, {
|
|
68
|
+
value: _executeFetch2
|
|
69
|
+
});
|
|
70
|
+
Object.defineProperty(this, _client, {
|
|
71
|
+
writable: true,
|
|
72
|
+
value: void 0
|
|
73
|
+
});
|
|
74
|
+
Object.defineProperty(this, _currentQuery, {
|
|
75
|
+
writable: true,
|
|
76
|
+
value: undefined
|
|
77
|
+
});
|
|
78
|
+
Object.defineProperty(this, _currentQueryInitialState, {
|
|
79
|
+
writable: true,
|
|
80
|
+
value: undefined
|
|
81
|
+
});
|
|
82
|
+
Object.defineProperty(this, _currentResult, {
|
|
83
|
+
writable: true,
|
|
84
|
+
value: undefined
|
|
85
|
+
});
|
|
86
|
+
Object.defineProperty(this, _currentResultState, {
|
|
87
|
+
writable: true,
|
|
88
|
+
value: void 0
|
|
89
|
+
});
|
|
90
|
+
Object.defineProperty(this, _currentResultOptions, {
|
|
91
|
+
writable: true,
|
|
92
|
+
value: void 0
|
|
93
|
+
});
|
|
94
|
+
Object.defineProperty(this, _selectError, {
|
|
95
|
+
writable: true,
|
|
96
|
+
value: void 0
|
|
97
|
+
});
|
|
98
|
+
Object.defineProperty(this, _selectFn, {
|
|
99
|
+
writable: true,
|
|
100
|
+
value: void 0
|
|
101
|
+
});
|
|
102
|
+
Object.defineProperty(this, _selectResult, {
|
|
103
|
+
writable: true,
|
|
104
|
+
value: void 0
|
|
105
|
+
});
|
|
106
|
+
Object.defineProperty(this, _lastQueryWithDefinedData, {
|
|
107
|
+
writable: true,
|
|
108
|
+
value: void 0
|
|
109
|
+
});
|
|
110
|
+
Object.defineProperty(this, _staleTimeoutId, {
|
|
111
|
+
writable: true,
|
|
112
|
+
value: void 0
|
|
113
|
+
});
|
|
114
|
+
Object.defineProperty(this, _refetchIntervalId, {
|
|
115
|
+
writable: true,
|
|
116
|
+
value: void 0
|
|
117
|
+
});
|
|
118
|
+
Object.defineProperty(this, _currentRefetchInterval, {
|
|
119
|
+
writable: true,
|
|
120
|
+
value: void 0
|
|
121
|
+
});
|
|
122
|
+
Object.defineProperty(this, _trackedProps, {
|
|
123
|
+
writable: true,
|
|
124
|
+
value: new Set()
|
|
125
|
+
});
|
|
126
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _client)[_client] = client;
|
|
27
127
|
this.options = options;
|
|
28
|
-
this
|
|
128
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _selectError)[_selectError] = null;
|
|
29
129
|
this.bindMethods();
|
|
30
130
|
this.setOptions(options);
|
|
31
131
|
}
|
|
@@ -33,39 +133,39 @@ class QueryObserver extends subscribable.Subscribable {
|
|
|
33
133
|
this.refetch = this.refetch.bind(this);
|
|
34
134
|
}
|
|
35
135
|
onSubscribe() {
|
|
36
|
-
if (this.listeners.
|
|
37
|
-
this
|
|
38
|
-
if (shouldFetchOnMount(this
|
|
39
|
-
this
|
|
136
|
+
if (this.listeners.size === 1) {
|
|
137
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentQuery)[_currentQuery].addObserver(this);
|
|
138
|
+
if (shouldFetchOnMount(_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentQuery)[_currentQuery], this.options)) {
|
|
139
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _executeFetch)[_executeFetch]();
|
|
40
140
|
}
|
|
41
|
-
this
|
|
141
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _updateTimers)[_updateTimers]();
|
|
42
142
|
}
|
|
43
143
|
}
|
|
44
144
|
onUnsubscribe() {
|
|
45
|
-
if (!this.
|
|
145
|
+
if (!this.hasListeners()) {
|
|
46
146
|
this.destroy();
|
|
47
147
|
}
|
|
48
148
|
}
|
|
49
149
|
shouldFetchOnReconnect() {
|
|
50
|
-
return shouldFetchOn(this
|
|
150
|
+
return shouldFetchOn(_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentQuery)[_currentQuery], this.options, this.options.refetchOnReconnect);
|
|
51
151
|
}
|
|
52
152
|
shouldFetchOnWindowFocus() {
|
|
53
|
-
return shouldFetchOn(this
|
|
153
|
+
return shouldFetchOn(_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentQuery)[_currentQuery], this.options, this.options.refetchOnWindowFocus);
|
|
54
154
|
}
|
|
55
155
|
destroy() {
|
|
56
|
-
this.listeners =
|
|
57
|
-
this
|
|
58
|
-
this
|
|
59
|
-
this
|
|
156
|
+
this.listeners = new Set();
|
|
157
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _clearStaleTimeout)[_clearStaleTimeout]();
|
|
158
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _clearRefetchInterval)[_clearRefetchInterval]();
|
|
159
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentQuery)[_currentQuery].removeObserver(this);
|
|
60
160
|
}
|
|
61
161
|
setOptions(options, notifyOptions) {
|
|
62
162
|
const prevOptions = this.options;
|
|
63
|
-
const prevQuery = this
|
|
64
|
-
this.options = this
|
|
163
|
+
const prevQuery = _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentQuery)[_currentQuery];
|
|
164
|
+
this.options = _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _client)[_client].defaultQueryOptions(options);
|
|
65
165
|
if (!utils.shallowEqualObjects(prevOptions, this.options)) {
|
|
66
|
-
this
|
|
166
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _client)[_client].getQueryCache().notify({
|
|
67
167
|
type: 'observerOptionsUpdated',
|
|
68
|
-
query: this
|
|
168
|
+
query: _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentQuery)[_currentQuery],
|
|
69
169
|
observer: this
|
|
70
170
|
});
|
|
71
171
|
}
|
|
@@ -77,34 +177,34 @@ class QueryObserver extends subscribable.Subscribable {
|
|
|
77
177
|
if (!this.options.queryKey) {
|
|
78
178
|
this.options.queryKey = prevOptions.queryKey;
|
|
79
179
|
}
|
|
80
|
-
this
|
|
180
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _updateQuery)[_updateQuery]();
|
|
81
181
|
const mounted = this.hasListeners();
|
|
82
182
|
|
|
83
183
|
// Fetch if there are subscribers
|
|
84
|
-
if (mounted && shouldFetchOptionally(this
|
|
85
|
-
this
|
|
184
|
+
if (mounted && shouldFetchOptionally(_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentQuery)[_currentQuery], prevQuery, this.options, prevOptions)) {
|
|
185
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _executeFetch)[_executeFetch]();
|
|
86
186
|
}
|
|
87
187
|
|
|
88
188
|
// Update result
|
|
89
|
-
this
|
|
189
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _updateResult)[_updateResult](notifyOptions);
|
|
90
190
|
|
|
91
191
|
// Update stale interval if needed
|
|
92
|
-
if (mounted && (this
|
|
93
|
-
this
|
|
192
|
+
if (mounted && (_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentQuery)[_currentQuery] !== prevQuery || this.options.enabled !== prevOptions.enabled || this.options.staleTime !== prevOptions.staleTime)) {
|
|
193
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _updateStaleTimeout)[_updateStaleTimeout]();
|
|
94
194
|
}
|
|
95
|
-
const nextRefetchInterval = this
|
|
195
|
+
const nextRefetchInterval = _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _computeRefetchInterval)[_computeRefetchInterval]();
|
|
96
196
|
|
|
97
197
|
// Update refetch interval if needed
|
|
98
|
-
if (mounted && (this
|
|
99
|
-
this
|
|
198
|
+
if (mounted && (_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentQuery)[_currentQuery] !== prevQuery || this.options.enabled !== prevOptions.enabled || nextRefetchInterval !== _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentRefetchInterval)[_currentRefetchInterval])) {
|
|
199
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _updateRefetchInterval)[_updateRefetchInterval](nextRefetchInterval);
|
|
100
200
|
}
|
|
101
201
|
}
|
|
102
202
|
getOptimisticResult(options) {
|
|
103
|
-
const query = this
|
|
203
|
+
const query = _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _client)[_client].getQueryCache().build(_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _client)[_client], options);
|
|
104
204
|
return this.createResult(query, options);
|
|
105
205
|
}
|
|
106
206
|
getCurrentResult() {
|
|
107
|
-
return this
|
|
207
|
+
return _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentResult)[_currentResult];
|
|
108
208
|
}
|
|
109
209
|
trackResult(result) {
|
|
110
210
|
const trackedResult = {};
|
|
@@ -113,7 +213,7 @@ class QueryObserver extends subscribable.Subscribable {
|
|
|
113
213
|
configurable: false,
|
|
114
214
|
enumerable: true,
|
|
115
215
|
get: () => {
|
|
116
|
-
this
|
|
216
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _trackedProps)[_trackedProps].add(key);
|
|
117
217
|
return result[key];
|
|
118
218
|
}
|
|
119
219
|
});
|
|
@@ -121,7 +221,7 @@ class QueryObserver extends subscribable.Subscribable {
|
|
|
121
221
|
return trackedResult;
|
|
122
222
|
}
|
|
123
223
|
getCurrentQuery() {
|
|
124
|
-
return this
|
|
224
|
+
return _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentQuery)[_currentQuery];
|
|
125
225
|
}
|
|
126
226
|
refetch({
|
|
127
227
|
...options
|
|
@@ -131,87 +231,29 @@ class QueryObserver extends subscribable.Subscribable {
|
|
|
131
231
|
});
|
|
132
232
|
}
|
|
133
233
|
fetchOptimistic(options) {
|
|
134
|
-
const defaultedOptions = this
|
|
135
|
-
const query = this
|
|
234
|
+
const defaultedOptions = _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _client)[_client].defaultQueryOptions(options);
|
|
235
|
+
const query = _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _client)[_client].getQueryCache().build(_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _client)[_client], defaultedOptions);
|
|
136
236
|
query.isFetchingOptimistic = true;
|
|
137
237
|
return query.fetch().then(() => this.createResult(query, defaultedOptions));
|
|
138
238
|
}
|
|
139
239
|
fetch(fetchOptions) {
|
|
140
|
-
|
|
240
|
+
var _fetchOptions$cancelR;
|
|
241
|
+
return _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _executeFetch)[_executeFetch]({
|
|
141
242
|
...fetchOptions,
|
|
142
|
-
cancelRefetch: fetchOptions.cancelRefetch
|
|
243
|
+
cancelRefetch: (_fetchOptions$cancelR = fetchOptions.cancelRefetch) != null ? _fetchOptions$cancelR : true
|
|
143
244
|
}).then(() => {
|
|
144
|
-
this
|
|
145
|
-
return this
|
|
245
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _updateResult)[_updateResult]();
|
|
246
|
+
return _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentResult)[_currentResult];
|
|
146
247
|
});
|
|
147
248
|
}
|
|
148
|
-
#executeFetch(fetchOptions) {
|
|
149
|
-
// Make sure we reference the latest query as the current one might have been removed
|
|
150
|
-
this.#updateQuery();
|
|
151
|
-
|
|
152
|
-
// Fetch
|
|
153
|
-
let promise = this.#currentQuery.fetch(this.options, fetchOptions);
|
|
154
|
-
if (!fetchOptions?.throwOnError) {
|
|
155
|
-
promise = promise.catch(utils.noop);
|
|
156
|
-
}
|
|
157
|
-
return promise;
|
|
158
|
-
}
|
|
159
|
-
#updateStaleTimeout() {
|
|
160
|
-
this.#clearStaleTimeout();
|
|
161
|
-
if (utils.isServer || this.#currentResult.isStale || !utils.isValidTimeout(this.options.staleTime)) {
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
const time = utils.timeUntilStale(this.#currentResult.dataUpdatedAt, this.options.staleTime);
|
|
165
|
-
|
|
166
|
-
// The timeout is sometimes triggered 1 ms before the stale time expiration.
|
|
167
|
-
// To mitigate this issue we always add 1 ms to the timeout.
|
|
168
|
-
const timeout = time + 1;
|
|
169
|
-
this.#staleTimeoutId = setTimeout(() => {
|
|
170
|
-
if (!this.#currentResult.isStale) {
|
|
171
|
-
this.#updateResult();
|
|
172
|
-
}
|
|
173
|
-
}, timeout);
|
|
174
|
-
}
|
|
175
|
-
#computeRefetchInterval() {
|
|
176
|
-
return typeof this.options.refetchInterval === 'function' ? this.options.refetchInterval(this.#currentResult.data, this.#currentQuery) : this.options.refetchInterval ?? false;
|
|
177
|
-
}
|
|
178
|
-
#updateRefetchInterval(nextInterval) {
|
|
179
|
-
this.#clearRefetchInterval();
|
|
180
|
-
this.#currentRefetchInterval = nextInterval;
|
|
181
|
-
if (utils.isServer || this.options.enabled === false || !utils.isValidTimeout(this.#currentRefetchInterval) || this.#currentRefetchInterval === 0) {
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
this.#refetchIntervalId = setInterval(() => {
|
|
185
|
-
if (this.options.refetchIntervalInBackground || focusManager.focusManager.isFocused()) {
|
|
186
|
-
this.#executeFetch();
|
|
187
|
-
}
|
|
188
|
-
}, this.#currentRefetchInterval);
|
|
189
|
-
}
|
|
190
|
-
#updateTimers() {
|
|
191
|
-
this.#updateStaleTimeout();
|
|
192
|
-
this.#updateRefetchInterval(this.#computeRefetchInterval());
|
|
193
|
-
}
|
|
194
|
-
#clearStaleTimeout() {
|
|
195
|
-
if (this.#staleTimeoutId) {
|
|
196
|
-
clearTimeout(this.#staleTimeoutId);
|
|
197
|
-
this.#staleTimeoutId = undefined;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
#clearRefetchInterval() {
|
|
201
|
-
if (this.#refetchIntervalId) {
|
|
202
|
-
clearInterval(this.#refetchIntervalId);
|
|
203
|
-
this.#refetchIntervalId = undefined;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
249
|
createResult(query, options) {
|
|
207
|
-
const prevQuery = this
|
|
250
|
+
const prevQuery = _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentQuery)[_currentQuery];
|
|
208
251
|
const prevOptions = this.options;
|
|
209
|
-
const prevResult = this
|
|
210
|
-
const prevResultState = this
|
|
211
|
-
const prevResultOptions = this
|
|
252
|
+
const prevResult = _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentResult)[_currentResult];
|
|
253
|
+
const prevResultState = _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentResultState)[_currentResultState];
|
|
254
|
+
const prevResultOptions = _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentResultOptions)[_currentResultOptions];
|
|
212
255
|
const queryChange = query !== prevQuery;
|
|
213
|
-
const queryInitialState = queryChange ? query.state : this
|
|
214
|
-
const prevQueryResult = queryChange ? this.#currentResult : this.#previousQueryResult;
|
|
256
|
+
const queryInitialState = queryChange ? query.state : _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentQueryInitialState)[_currentQueryInitialState];
|
|
215
257
|
const {
|
|
216
258
|
state
|
|
217
259
|
} = query;
|
|
@@ -243,17 +285,17 @@ class QueryObserver extends subscribable.Subscribable {
|
|
|
243
285
|
// Select data if needed
|
|
244
286
|
if (options.select && typeof state.data !== 'undefined') {
|
|
245
287
|
// Memoize select result
|
|
246
|
-
if (prevResult && state.data === prevResultState
|
|
247
|
-
data = this
|
|
288
|
+
if (prevResult && state.data === (prevResultState == null ? void 0 : prevResultState.data) && options.select === _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _selectFn)[_selectFn]) {
|
|
289
|
+
data = _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _selectResult)[_selectResult];
|
|
248
290
|
} else {
|
|
249
291
|
try {
|
|
250
|
-
this
|
|
292
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _selectFn)[_selectFn] = options.select;
|
|
251
293
|
data = options.select(state.data);
|
|
252
|
-
data = utils.replaceData(prevResult
|
|
253
|
-
this
|
|
254
|
-
this
|
|
294
|
+
data = utils.replaceData(prevResult == null ? void 0 : prevResult.data, data, options);
|
|
295
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _selectResult)[_selectResult] = data;
|
|
296
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _selectError)[_selectError] = null;
|
|
255
297
|
} catch (selectError) {
|
|
256
|
-
this
|
|
298
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _selectError)[_selectError] = selectError;
|
|
257
299
|
}
|
|
258
300
|
}
|
|
259
301
|
}
|
|
@@ -267,28 +309,29 @@ class QueryObserver extends subscribable.Subscribable {
|
|
|
267
309
|
let placeholderData;
|
|
268
310
|
|
|
269
311
|
// Memoize placeholder data
|
|
270
|
-
if (prevResult
|
|
312
|
+
if (prevResult != null && prevResult.isPlaceholderData && options.placeholderData === (prevResultOptions == null ? void 0 : prevResultOptions.placeholderData)) {
|
|
271
313
|
placeholderData = prevResult.data;
|
|
272
314
|
} else {
|
|
273
|
-
|
|
315
|
+
var _classPrivateFieldLoo;
|
|
316
|
+
placeholderData = typeof options.placeholderData === 'function' ? options.placeholderData((_classPrivateFieldLoo = _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _lastQueryWithDefinedData)[_lastQueryWithDefinedData]) == null ? void 0 : _classPrivateFieldLoo.state.data, _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _lastQueryWithDefinedData)[_lastQueryWithDefinedData]) : options.placeholderData;
|
|
274
317
|
if (options.select && typeof placeholderData !== 'undefined') {
|
|
275
318
|
try {
|
|
276
319
|
placeholderData = options.select(placeholderData);
|
|
277
|
-
this
|
|
320
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _selectError)[_selectError] = null;
|
|
278
321
|
} catch (selectError) {
|
|
279
|
-
this
|
|
322
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _selectError)[_selectError] = selectError;
|
|
280
323
|
}
|
|
281
324
|
}
|
|
282
325
|
}
|
|
283
326
|
if (typeof placeholderData !== 'undefined') {
|
|
284
327
|
status = 'success';
|
|
285
|
-
data = utils.replaceData(prevResult
|
|
328
|
+
data = utils.replaceData(prevResult == null ? void 0 : prevResult.data, placeholderData, options);
|
|
286
329
|
isPlaceholderData = true;
|
|
287
330
|
}
|
|
288
331
|
}
|
|
289
|
-
if (this
|
|
290
|
-
error = this
|
|
291
|
-
data = this
|
|
332
|
+
if (_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _selectError)[_selectError]) {
|
|
333
|
+
error = _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _selectError)[_selectError];
|
|
334
|
+
data = _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _selectResult)[_selectResult];
|
|
292
335
|
errorUpdatedAt = Date.now();
|
|
293
336
|
status = 'error';
|
|
294
337
|
}
|
|
@@ -324,100 +367,146 @@ class QueryObserver extends subscribable.Subscribable {
|
|
|
324
367
|
};
|
|
325
368
|
return result;
|
|
326
369
|
}
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
this.#currentResultOptions = this.options;
|
|
332
|
-
|
|
333
|
-
// Only notify and update result if something has changed
|
|
334
|
-
if (utils.shallowEqualObjects(nextResult, prevResult)) {
|
|
335
|
-
return;
|
|
370
|
+
onQueryUpdate() {
|
|
371
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _updateResult)[_updateResult]();
|
|
372
|
+
if (this.hasListeners()) {
|
|
373
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _updateTimers)[_updateTimers]();
|
|
336
374
|
}
|
|
337
|
-
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
function _executeFetch2(fetchOptions) {
|
|
378
|
+
// Make sure we reference the latest query as the current one might have been removed
|
|
379
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _updateQuery)[_updateQuery]();
|
|
338
380
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
return true;
|
|
344
|
-
}
|
|
345
|
-
const {
|
|
346
|
-
notifyOnChangeProps
|
|
347
|
-
} = this.options;
|
|
348
|
-
if (notifyOnChangeProps === 'all' || !notifyOnChangeProps && !this.#trackedProps.size) {
|
|
349
|
-
return true;
|
|
350
|
-
}
|
|
351
|
-
const includedProps = new Set(notifyOnChangeProps ?? this.#trackedProps);
|
|
352
|
-
if (this.options.throwErrors) {
|
|
353
|
-
includedProps.add('error');
|
|
354
|
-
}
|
|
355
|
-
return Object.keys(this.#currentResult).some(key => {
|
|
356
|
-
const typedKey = key;
|
|
357
|
-
const changed = this.#currentResult[typedKey] !== prevResult[typedKey];
|
|
358
|
-
return changed && includedProps.has(typedKey);
|
|
359
|
-
});
|
|
360
|
-
};
|
|
361
|
-
if (notifyOptions?.listeners !== false && shouldNotifyListeners()) {
|
|
362
|
-
defaultNotifyOptions.listeners = true;
|
|
363
|
-
}
|
|
364
|
-
this.#notify({
|
|
365
|
-
...defaultNotifyOptions,
|
|
366
|
-
...notifyOptions
|
|
367
|
-
});
|
|
381
|
+
// Fetch
|
|
382
|
+
let promise = _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentQuery)[_currentQuery].fetch(this.options, fetchOptions);
|
|
383
|
+
if (!(fetchOptions != null && fetchOptions.throwOnError)) {
|
|
384
|
+
promise = promise.catch(utils.noop);
|
|
368
385
|
}
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
this.#currentQuery = query;
|
|
376
|
-
this.#currentQueryInitialState = query.state;
|
|
377
|
-
this.#previousQueryResult = this.#currentResult;
|
|
378
|
-
if (this.hasListeners()) {
|
|
379
|
-
prevQuery?.removeObserver(this);
|
|
380
|
-
query.addObserver(this);
|
|
381
|
-
}
|
|
386
|
+
return promise;
|
|
387
|
+
}
|
|
388
|
+
function _updateStaleTimeout2() {
|
|
389
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _clearStaleTimeout)[_clearStaleTimeout]();
|
|
390
|
+
if (utils.isServer || _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentResult)[_currentResult].isStale || !utils.isValidTimeout(this.options.staleTime)) {
|
|
391
|
+
return;
|
|
382
392
|
}
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
393
|
+
const time = utils.timeUntilStale(_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentResult)[_currentResult].dataUpdatedAt, this.options.staleTime);
|
|
394
|
+
|
|
395
|
+
// The timeout is sometimes triggered 1 ms before the stale time expiration.
|
|
396
|
+
// To mitigate this issue we always add 1 ms to the timeout.
|
|
397
|
+
const timeout = time + 1;
|
|
398
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _staleTimeoutId)[_staleTimeoutId] = setTimeout(() => {
|
|
399
|
+
if (!_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentResult)[_currentResult].isStale) {
|
|
400
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _updateResult)[_updateResult]();
|
|
389
401
|
}
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
402
|
+
}, timeout);
|
|
403
|
+
}
|
|
404
|
+
function _computeRefetchInterval2() {
|
|
405
|
+
var _ref;
|
|
406
|
+
return (_ref = typeof this.options.refetchInterval === 'function' ? this.options.refetchInterval(_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentResult)[_currentResult].data, _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentQuery)[_currentQuery]) : this.options.refetchInterval) != null ? _ref : false;
|
|
407
|
+
}
|
|
408
|
+
function _updateRefetchInterval2(nextInterval) {
|
|
409
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _clearRefetchInterval)[_clearRefetchInterval]();
|
|
410
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentRefetchInterval)[_currentRefetchInterval] = nextInterval;
|
|
411
|
+
if (utils.isServer || this.options.enabled === false || !utils.isValidTimeout(_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentRefetchInterval)[_currentRefetchInterval]) || _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentRefetchInterval)[_currentRefetchInterval] === 0) {
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _refetchIntervalId)[_refetchIntervalId] = setInterval(() => {
|
|
415
|
+
if (this.options.refetchIntervalInBackground || focusManager.focusManager.isFocused()) {
|
|
416
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _executeFetch)[_executeFetch]();
|
|
393
417
|
}
|
|
418
|
+
}, _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentRefetchInterval)[_currentRefetchInterval]);
|
|
419
|
+
}
|
|
420
|
+
function _updateTimers2() {
|
|
421
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _updateStaleTimeout)[_updateStaleTimeout]();
|
|
422
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _updateRefetchInterval)[_updateRefetchInterval](_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _computeRefetchInterval)[_computeRefetchInterval]());
|
|
423
|
+
}
|
|
424
|
+
function _clearStaleTimeout2() {
|
|
425
|
+
if (_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _staleTimeoutId)[_staleTimeoutId]) {
|
|
426
|
+
clearTimeout(_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _staleTimeoutId)[_staleTimeoutId]);
|
|
427
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _staleTimeoutId)[_staleTimeoutId] = undefined;
|
|
394
428
|
}
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
429
|
+
}
|
|
430
|
+
function _clearRefetchInterval2() {
|
|
431
|
+
if (_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _refetchIntervalId)[_refetchIntervalId]) {
|
|
432
|
+
clearInterval(_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _refetchIntervalId)[_refetchIntervalId]);
|
|
433
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _refetchIntervalId)[_refetchIntervalId] = undefined;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
function _updateResult2(notifyOptions) {
|
|
437
|
+
const prevResult = _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentResult)[_currentResult];
|
|
438
|
+
const nextResult = this.createResult(_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentQuery)[_currentQuery], this.options);
|
|
439
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentResultState)[_currentResultState] = _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentQuery)[_currentQuery].state;
|
|
440
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentResultOptions)[_currentResultOptions] = this.options;
|
|
405
441
|
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
442
|
+
// Only notify and update result if something has changed
|
|
443
|
+
if (utils.shallowEqualObjects(nextResult, prevResult)) {
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
if (_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentResultState)[_currentResultState].data !== undefined) {
|
|
447
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _lastQueryWithDefinedData)[_lastQueryWithDefinedData] = _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentQuery)[_currentQuery];
|
|
448
|
+
}
|
|
449
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentResult)[_currentResult] = nextResult;
|
|
412
450
|
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
451
|
+
// Determine which callbacks to trigger
|
|
452
|
+
const defaultNotifyOptions = {};
|
|
453
|
+
const shouldNotifyListeners = () => {
|
|
454
|
+
if (!prevResult) {
|
|
455
|
+
return true;
|
|
456
|
+
}
|
|
457
|
+
const {
|
|
458
|
+
notifyOnChangeProps
|
|
459
|
+
} = this.options;
|
|
460
|
+
if (notifyOnChangeProps === 'all' || !notifyOnChangeProps && !_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _trackedProps)[_trackedProps].size) {
|
|
461
|
+
return true;
|
|
462
|
+
}
|
|
463
|
+
const includedProps = new Set(notifyOnChangeProps != null ? notifyOnChangeProps : _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _trackedProps)[_trackedProps]);
|
|
464
|
+
if (this.options.throwOnError) {
|
|
465
|
+
includedProps.add('error');
|
|
466
|
+
}
|
|
467
|
+
return Object.keys(_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentResult)[_currentResult]).some(key => {
|
|
468
|
+
const typedKey = key;
|
|
469
|
+
const changed = _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentResult)[_currentResult][typedKey] !== prevResult[typedKey];
|
|
470
|
+
return changed && includedProps.has(typedKey);
|
|
418
471
|
});
|
|
472
|
+
};
|
|
473
|
+
if ((notifyOptions == null ? void 0 : notifyOptions.listeners) !== false && shouldNotifyListeners()) {
|
|
474
|
+
defaultNotifyOptions.listeners = true;
|
|
475
|
+
}
|
|
476
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _notify)[_notify]({
|
|
477
|
+
...defaultNotifyOptions,
|
|
478
|
+
...notifyOptions
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
function _updateQuery2() {
|
|
482
|
+
const query = _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _client)[_client].getQueryCache().build(_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _client)[_client], this.options);
|
|
483
|
+
if (query === _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentQuery)[_currentQuery]) {
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
const prevQuery = _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentQuery)[_currentQuery];
|
|
487
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentQuery)[_currentQuery] = query;
|
|
488
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentQueryInitialState)[_currentQueryInitialState] = query.state;
|
|
489
|
+
if (this.hasListeners()) {
|
|
490
|
+
prevQuery == null ? void 0 : prevQuery.removeObserver(this);
|
|
491
|
+
query.addObserver(this);
|
|
419
492
|
}
|
|
420
493
|
}
|
|
494
|
+
function _notify2(notifyOptions) {
|
|
495
|
+
notifyManager.notifyManager.batch(() => {
|
|
496
|
+
// First, trigger the listeners
|
|
497
|
+
if (notifyOptions.listeners) {
|
|
498
|
+
this.listeners.forEach(listener => {
|
|
499
|
+
listener(_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentResult)[_currentResult]);
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
// Then the cache listeners
|
|
504
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _client)[_client].getQueryCache().notify({
|
|
505
|
+
query: _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentQuery)[_currentQuery],
|
|
506
|
+
type: 'observerResultsUpdated'
|
|
507
|
+
});
|
|
508
|
+
});
|
|
509
|
+
}
|
|
421
510
|
function shouldLoadOnMount(query, options) {
|
|
422
511
|
return options.enabled !== false && !query.state.dataUpdatedAt && !(query.state.status === 'error' && options.retryOnMount === false);
|
|
423
512
|
}
|