@inventreedb/ui 0.7.0 → 0.8.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/CHANGELOG.md +4 -0
- package/dist/.vite/manifest.json +162 -1
- package/dist/components/ProgressBar.d.ts +1 -0
- package/dist/components/ProgressBar.js +12 -4
- package/dist/components/ProgressBar.js.map +1 -1
- package/dist/components/RowActions.js +1 -2
- package/dist/components/RowActions.js.map +1 -1
- package/dist/enums/ApiEndpoints.d.ts +11 -4
- package/dist/enums/ApiEndpoints.js +10 -3
- package/dist/enums/ApiEndpoints.js.map +1 -1
- package/dist/enums/ModelInformation.d.ts +1 -0
- package/dist/enums/ModelInformation.js +34 -8
- package/dist/enums/ModelInformation.js.map +1 -1
- package/dist/enums/ModelType.d.ts +2 -1
- package/dist/enums/ModelType.js +2 -1
- package/dist/enums/ModelType.js.map +1 -1
- package/dist/functions/Conversion.d.ts +1 -0
- package/dist/functions/Conversion.js.map +1 -1
- package/dist/functions/Events.js +3 -4
- package/dist/functions/Events.js.map +1 -1
- package/dist/functions/Navigation.d.ts +5 -0
- package/dist/functions/Navigation.js +2 -5
- package/dist/functions/Navigation.js.map +1 -1
- package/dist/functions/Plugins.js +2 -4
- package/dist/functions/Plugins.js.map +1 -1
- package/dist/hooks/MonitorDataOutput.d.ts +10 -0
- package/dist/hooks/MonitorDataOutput.js +112 -0
- package/dist/hooks/MonitorDataOutput.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/node_modules/@mantine/hooks/esm/use-document-visibility/use-document-visibility.js +16 -0
- package/dist/node_modules/@mantine/hooks/esm/use-document-visibility/use-document-visibility.js.map +1 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCircleCheck.js +14 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCircleCheck.js.map +1 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconExclamationCircle.js +14 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconExclamationCircle.js.map +1 -0
- package/dist/node_modules/@tanstack/query-core/build/modern/focusManager.js +67 -0
- package/dist/node_modules/@tanstack/query-core/build/modern/focusManager.js.map +1 -0
- package/dist/node_modules/@tanstack/query-core/build/modern/notifyManager.js +84 -0
- package/dist/node_modules/@tanstack/query-core/build/modern/notifyManager.js.map +1 -0
- package/dist/node_modules/@tanstack/query-core/build/modern/onlineManager.js +57 -0
- package/dist/node_modules/@tanstack/query-core/build/modern/onlineManager.js.map +1 -0
- package/dist/node_modules/@tanstack/query-core/build/modern/query.js +16 -0
- package/dist/node_modules/@tanstack/query-core/build/modern/query.js.map +1 -0
- package/dist/node_modules/@tanstack/query-core/build/modern/queryObserver.js +456 -0
- package/dist/node_modules/@tanstack/query-core/build/modern/queryObserver.js.map +1 -0
- package/dist/node_modules/@tanstack/query-core/build/modern/retryer.js +8 -0
- package/dist/node_modules/@tanstack/query-core/build/modern/retryer.js.map +1 -0
- package/dist/node_modules/@tanstack/query-core/build/modern/subscribable.js +25 -0
- package/dist/node_modules/@tanstack/query-core/build/modern/subscribable.js.map +1 -0
- package/dist/node_modules/@tanstack/query-core/build/modern/thenable.js +35 -0
- package/dist/node_modules/@tanstack/query-core/build/modern/thenable.js.map +1 -0
- package/dist/node_modules/@tanstack/query-core/build/modern/utils.js +123 -0
- package/dist/node_modules/@tanstack/query-core/build/modern/utils.js.map +1 -0
- package/dist/node_modules/@tanstack/react-query/build/modern/IsRestoringProvider.js +8 -0
- package/dist/node_modules/@tanstack/react-query/build/modern/IsRestoringProvider.js.map +1 -0
- package/dist/node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js +17 -0
- package/dist/node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js.map +1 -0
- package/dist/node_modules/@tanstack/react-query/build/modern/QueryErrorResetBoundary.js +22 -0
- package/dist/node_modules/@tanstack/react-query/build/modern/QueryErrorResetBoundary.js.map +1 -0
- package/dist/node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js +29 -0
- package/dist/node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js.map +1 -0
- package/dist/node_modules/@tanstack/react-query/build/modern/suspense.js +26 -0
- package/dist/node_modules/@tanstack/react-query/build/modern/suspense.js.map +1 -0
- package/dist/node_modules/@tanstack/react-query/build/modern/useBaseQuery.js +92 -0
- package/dist/node_modules/@tanstack/react-query/build/modern/useBaseQuery.js.map +1 -0
- package/dist/node_modules/@tanstack/react-query/build/modern/useQuery.js +9 -0
- package/dist/node_modules/@tanstack/react-query/build/modern/useQuery.js.map +1 -0
- package/dist/node_modules/react/cjs/react-jsx-runtime.development.js +13 -17
- package/dist/node_modules/react/cjs/react-jsx-runtime.development.js.map +1 -1
- package/dist/types/Auth.d.ts +2 -1
- package/dist/types/Filters.d.ts +1 -1
- package/dist/types/Forms.d.ts +12 -0
- package/dist/types/Plugins.js +3 -3
- package/dist/types/Settings.d.ts +2 -0
- package/dist/types/Tables.d.ts +6 -0
- package/lib/components/ProgressBar.tsx +8 -4
- package/lib/enums/ApiEndpoints.tsx +13 -4
- package/lib/enums/ModelInformation.tsx +25 -8
- package/lib/enums/ModelType.tsx +2 -1
- package/lib/functions/Conversion.tsx +38 -0
- package/lib/functions/Navigation.tsx +22 -0
- package/lib/hooks/MonitorDataOutput.tsx +122 -0
- package/lib/index.ts +3 -0
- package/lib/types/Auth.tsx +2 -1
- package/lib/types/Filters.tsx +1 -1
- package/lib/types/Forms.tsx +12 -0
- package/lib/types/Settings.tsx +2 -0
- package/lib/types/Tables.tsx +6 -0
- package/package.json +8 -6
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
import { focusManager } from "./focusManager.js";
|
|
2
|
+
import { notifyManager } from "./notifyManager.js";
|
|
3
|
+
import { fetchState } from "./query.js";
|
|
4
|
+
import { Subscribable } from "./subscribable.js";
|
|
5
|
+
import { pendingThenable } from "./thenable.js";
|
|
6
|
+
import { resolveEnabled, shallowEqualObjects, resolveStaleTime, noop, isServer, isValidTimeout, timeUntilStale, replaceData } from "./utils.js";
|
|
7
|
+
var QueryObserver = class extends Subscribable {
|
|
8
|
+
constructor(client, options) {
|
|
9
|
+
super();
|
|
10
|
+
this.options = options;
|
|
11
|
+
this.#client = client;
|
|
12
|
+
this.#selectError = null;
|
|
13
|
+
this.#currentThenable = pendingThenable();
|
|
14
|
+
this.bindMethods();
|
|
15
|
+
this.setOptions(options);
|
|
16
|
+
}
|
|
17
|
+
#client;
|
|
18
|
+
#currentQuery = void 0;
|
|
19
|
+
#currentQueryInitialState = void 0;
|
|
20
|
+
#currentResult = void 0;
|
|
21
|
+
#currentResultState;
|
|
22
|
+
#currentResultOptions;
|
|
23
|
+
#currentThenable;
|
|
24
|
+
#selectError;
|
|
25
|
+
#selectFn;
|
|
26
|
+
#selectResult;
|
|
27
|
+
// This property keeps track of the last query with defined data.
|
|
28
|
+
// It will be used to pass the previous data and query to the placeholder function between renders.
|
|
29
|
+
#lastQueryWithDefinedData;
|
|
30
|
+
#staleTimeoutId;
|
|
31
|
+
#refetchIntervalId;
|
|
32
|
+
#currentRefetchInterval;
|
|
33
|
+
#trackedProps = /* @__PURE__ */ new Set();
|
|
34
|
+
bindMethods() {
|
|
35
|
+
this.refetch = this.refetch.bind(this);
|
|
36
|
+
}
|
|
37
|
+
onSubscribe() {
|
|
38
|
+
if (this.listeners.size === 1) {
|
|
39
|
+
this.#currentQuery.addObserver(this);
|
|
40
|
+
if (shouldFetchOnMount(this.#currentQuery, this.options)) {
|
|
41
|
+
this.#executeFetch();
|
|
42
|
+
} else {
|
|
43
|
+
this.updateResult();
|
|
44
|
+
}
|
|
45
|
+
this.#updateTimers();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
onUnsubscribe() {
|
|
49
|
+
if (!this.hasListeners()) {
|
|
50
|
+
this.destroy();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
shouldFetchOnReconnect() {
|
|
54
|
+
return shouldFetchOn(
|
|
55
|
+
this.#currentQuery,
|
|
56
|
+
this.options,
|
|
57
|
+
this.options.refetchOnReconnect
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
shouldFetchOnWindowFocus() {
|
|
61
|
+
return shouldFetchOn(
|
|
62
|
+
this.#currentQuery,
|
|
63
|
+
this.options,
|
|
64
|
+
this.options.refetchOnWindowFocus
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
destroy() {
|
|
68
|
+
this.listeners = /* @__PURE__ */ new Set();
|
|
69
|
+
this.#clearStaleTimeout();
|
|
70
|
+
this.#clearRefetchInterval();
|
|
71
|
+
this.#currentQuery.removeObserver(this);
|
|
72
|
+
}
|
|
73
|
+
setOptions(options) {
|
|
74
|
+
const prevOptions = this.options;
|
|
75
|
+
const prevQuery = this.#currentQuery;
|
|
76
|
+
this.options = this.#client.defaultQueryOptions(options);
|
|
77
|
+
if (this.options.enabled !== void 0 && typeof this.options.enabled !== "boolean" && typeof this.options.enabled !== "function" && typeof resolveEnabled(this.options.enabled, this.#currentQuery) !== "boolean") {
|
|
78
|
+
throw new Error(
|
|
79
|
+
"Expected enabled to be a boolean or a callback that returns a boolean"
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
this.#updateQuery();
|
|
83
|
+
this.#currentQuery.setOptions(this.options);
|
|
84
|
+
if (prevOptions._defaulted && !shallowEqualObjects(this.options, prevOptions)) {
|
|
85
|
+
this.#client.getQueryCache().notify({
|
|
86
|
+
type: "observerOptionsUpdated",
|
|
87
|
+
query: this.#currentQuery,
|
|
88
|
+
observer: this
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
const mounted = this.hasListeners();
|
|
92
|
+
if (mounted && shouldFetchOptionally(
|
|
93
|
+
this.#currentQuery,
|
|
94
|
+
prevQuery,
|
|
95
|
+
this.options,
|
|
96
|
+
prevOptions
|
|
97
|
+
)) {
|
|
98
|
+
this.#executeFetch();
|
|
99
|
+
}
|
|
100
|
+
this.updateResult();
|
|
101
|
+
if (mounted && (this.#currentQuery !== prevQuery || resolveEnabled(this.options.enabled, this.#currentQuery) !== resolveEnabled(prevOptions.enabled, this.#currentQuery) || resolveStaleTime(this.options.staleTime, this.#currentQuery) !== resolveStaleTime(prevOptions.staleTime, this.#currentQuery))) {
|
|
102
|
+
this.#updateStaleTimeout();
|
|
103
|
+
}
|
|
104
|
+
const nextRefetchInterval = this.#computeRefetchInterval();
|
|
105
|
+
if (mounted && (this.#currentQuery !== prevQuery || resolveEnabled(this.options.enabled, this.#currentQuery) !== resolveEnabled(prevOptions.enabled, this.#currentQuery) || nextRefetchInterval !== this.#currentRefetchInterval)) {
|
|
106
|
+
this.#updateRefetchInterval(nextRefetchInterval);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
getOptimisticResult(options) {
|
|
110
|
+
const query = this.#client.getQueryCache().build(this.#client, options);
|
|
111
|
+
const result = this.createResult(query, options);
|
|
112
|
+
if (shouldAssignObserverCurrentProperties(this, result)) {
|
|
113
|
+
this.#currentResult = result;
|
|
114
|
+
this.#currentResultOptions = this.options;
|
|
115
|
+
this.#currentResultState = this.#currentQuery.state;
|
|
116
|
+
}
|
|
117
|
+
return result;
|
|
118
|
+
}
|
|
119
|
+
getCurrentResult() {
|
|
120
|
+
return this.#currentResult;
|
|
121
|
+
}
|
|
122
|
+
trackResult(result, onPropTracked) {
|
|
123
|
+
return new Proxy(result, {
|
|
124
|
+
get: (target, key) => {
|
|
125
|
+
this.trackProp(key);
|
|
126
|
+
onPropTracked?.(key);
|
|
127
|
+
if (key === "promise" && !this.options.experimental_prefetchInRender && this.#currentThenable.status === "pending") {
|
|
128
|
+
this.#currentThenable.reject(
|
|
129
|
+
new Error(
|
|
130
|
+
"experimental_prefetchInRender feature flag is not enabled"
|
|
131
|
+
)
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
return Reflect.get(target, key);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
trackProp(key) {
|
|
139
|
+
this.#trackedProps.add(key);
|
|
140
|
+
}
|
|
141
|
+
getCurrentQuery() {
|
|
142
|
+
return this.#currentQuery;
|
|
143
|
+
}
|
|
144
|
+
refetch({ ...options } = {}) {
|
|
145
|
+
return this.fetch({
|
|
146
|
+
...options
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
fetchOptimistic(options) {
|
|
150
|
+
const defaultedOptions = this.#client.defaultQueryOptions(options);
|
|
151
|
+
const query = this.#client.getQueryCache().build(this.#client, defaultedOptions);
|
|
152
|
+
return query.fetch().then(() => this.createResult(query, defaultedOptions));
|
|
153
|
+
}
|
|
154
|
+
fetch(fetchOptions) {
|
|
155
|
+
return this.#executeFetch({
|
|
156
|
+
...fetchOptions,
|
|
157
|
+
cancelRefetch: fetchOptions.cancelRefetch ?? true
|
|
158
|
+
}).then(() => {
|
|
159
|
+
this.updateResult();
|
|
160
|
+
return this.#currentResult;
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
#executeFetch(fetchOptions) {
|
|
164
|
+
this.#updateQuery();
|
|
165
|
+
let promise = this.#currentQuery.fetch(
|
|
166
|
+
this.options,
|
|
167
|
+
fetchOptions
|
|
168
|
+
);
|
|
169
|
+
if (!fetchOptions?.throwOnError) {
|
|
170
|
+
promise = promise.catch(noop);
|
|
171
|
+
}
|
|
172
|
+
return promise;
|
|
173
|
+
}
|
|
174
|
+
#updateStaleTimeout() {
|
|
175
|
+
this.#clearStaleTimeout();
|
|
176
|
+
const staleTime = resolveStaleTime(
|
|
177
|
+
this.options.staleTime,
|
|
178
|
+
this.#currentQuery
|
|
179
|
+
);
|
|
180
|
+
if (isServer || this.#currentResult.isStale || !isValidTimeout(staleTime)) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
const time = timeUntilStale(this.#currentResult.dataUpdatedAt, staleTime);
|
|
184
|
+
const timeout = time + 1;
|
|
185
|
+
this.#staleTimeoutId = setTimeout(() => {
|
|
186
|
+
if (!this.#currentResult.isStale) {
|
|
187
|
+
this.updateResult();
|
|
188
|
+
}
|
|
189
|
+
}, timeout);
|
|
190
|
+
}
|
|
191
|
+
#computeRefetchInterval() {
|
|
192
|
+
return (typeof this.options.refetchInterval === "function" ? this.options.refetchInterval(this.#currentQuery) : this.options.refetchInterval) ?? false;
|
|
193
|
+
}
|
|
194
|
+
#updateRefetchInterval(nextInterval) {
|
|
195
|
+
this.#clearRefetchInterval();
|
|
196
|
+
this.#currentRefetchInterval = nextInterval;
|
|
197
|
+
if (isServer || resolveEnabled(this.options.enabled, this.#currentQuery) === false || !isValidTimeout(this.#currentRefetchInterval) || this.#currentRefetchInterval === 0) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
this.#refetchIntervalId = setInterval(() => {
|
|
201
|
+
if (this.options.refetchIntervalInBackground || focusManager.isFocused()) {
|
|
202
|
+
this.#executeFetch();
|
|
203
|
+
}
|
|
204
|
+
}, this.#currentRefetchInterval);
|
|
205
|
+
}
|
|
206
|
+
#updateTimers() {
|
|
207
|
+
this.#updateStaleTimeout();
|
|
208
|
+
this.#updateRefetchInterval(this.#computeRefetchInterval());
|
|
209
|
+
}
|
|
210
|
+
#clearStaleTimeout() {
|
|
211
|
+
if (this.#staleTimeoutId) {
|
|
212
|
+
clearTimeout(this.#staleTimeoutId);
|
|
213
|
+
this.#staleTimeoutId = void 0;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
#clearRefetchInterval() {
|
|
217
|
+
if (this.#refetchIntervalId) {
|
|
218
|
+
clearInterval(this.#refetchIntervalId);
|
|
219
|
+
this.#refetchIntervalId = void 0;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
createResult(query, options) {
|
|
223
|
+
const prevQuery = this.#currentQuery;
|
|
224
|
+
const prevOptions = this.options;
|
|
225
|
+
const prevResult = this.#currentResult;
|
|
226
|
+
const prevResultState = this.#currentResultState;
|
|
227
|
+
const prevResultOptions = this.#currentResultOptions;
|
|
228
|
+
const queryChange = query !== prevQuery;
|
|
229
|
+
const queryInitialState = queryChange ? query.state : this.#currentQueryInitialState;
|
|
230
|
+
const { state } = query;
|
|
231
|
+
let newState = { ...state };
|
|
232
|
+
let isPlaceholderData = false;
|
|
233
|
+
let data;
|
|
234
|
+
if (options._optimisticResults) {
|
|
235
|
+
const mounted = this.hasListeners();
|
|
236
|
+
const fetchOnMount = !mounted && shouldFetchOnMount(query, options);
|
|
237
|
+
const fetchOptionally = mounted && shouldFetchOptionally(query, prevQuery, options, prevOptions);
|
|
238
|
+
if (fetchOnMount || fetchOptionally) {
|
|
239
|
+
newState = {
|
|
240
|
+
...newState,
|
|
241
|
+
...fetchState(state.data, query.options)
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
if (options._optimisticResults === "isRestoring") {
|
|
245
|
+
newState.fetchStatus = "idle";
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
let { error, errorUpdatedAt, status } = newState;
|
|
249
|
+
data = newState.data;
|
|
250
|
+
let skipSelect = false;
|
|
251
|
+
if (options.placeholderData !== void 0 && data === void 0 && status === "pending") {
|
|
252
|
+
let placeholderData;
|
|
253
|
+
if (prevResult?.isPlaceholderData && options.placeholderData === prevResultOptions?.placeholderData) {
|
|
254
|
+
placeholderData = prevResult.data;
|
|
255
|
+
skipSelect = true;
|
|
256
|
+
} else {
|
|
257
|
+
placeholderData = typeof options.placeholderData === "function" ? options.placeholderData(
|
|
258
|
+
this.#lastQueryWithDefinedData?.state.data,
|
|
259
|
+
this.#lastQueryWithDefinedData
|
|
260
|
+
) : options.placeholderData;
|
|
261
|
+
}
|
|
262
|
+
if (placeholderData !== void 0) {
|
|
263
|
+
status = "success";
|
|
264
|
+
data = replaceData(
|
|
265
|
+
prevResult?.data,
|
|
266
|
+
placeholderData,
|
|
267
|
+
options
|
|
268
|
+
);
|
|
269
|
+
isPlaceholderData = true;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
if (options.select && data !== void 0 && !skipSelect) {
|
|
273
|
+
if (prevResult && data === prevResultState?.data && options.select === this.#selectFn) {
|
|
274
|
+
data = this.#selectResult;
|
|
275
|
+
} else {
|
|
276
|
+
try {
|
|
277
|
+
this.#selectFn = options.select;
|
|
278
|
+
data = options.select(data);
|
|
279
|
+
data = replaceData(prevResult?.data, data, options);
|
|
280
|
+
this.#selectResult = data;
|
|
281
|
+
this.#selectError = null;
|
|
282
|
+
} catch (selectError) {
|
|
283
|
+
this.#selectError = selectError;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
if (this.#selectError) {
|
|
288
|
+
error = this.#selectError;
|
|
289
|
+
data = this.#selectResult;
|
|
290
|
+
errorUpdatedAt = Date.now();
|
|
291
|
+
status = "error";
|
|
292
|
+
}
|
|
293
|
+
const isFetching = newState.fetchStatus === "fetching";
|
|
294
|
+
const isPending = status === "pending";
|
|
295
|
+
const isError = status === "error";
|
|
296
|
+
const isLoading = isPending && isFetching;
|
|
297
|
+
const hasData = data !== void 0;
|
|
298
|
+
const result = {
|
|
299
|
+
status,
|
|
300
|
+
fetchStatus: newState.fetchStatus,
|
|
301
|
+
isPending,
|
|
302
|
+
isSuccess: status === "success",
|
|
303
|
+
isError,
|
|
304
|
+
isInitialLoading: isLoading,
|
|
305
|
+
isLoading,
|
|
306
|
+
data,
|
|
307
|
+
dataUpdatedAt: newState.dataUpdatedAt,
|
|
308
|
+
error,
|
|
309
|
+
errorUpdatedAt,
|
|
310
|
+
failureCount: newState.fetchFailureCount,
|
|
311
|
+
failureReason: newState.fetchFailureReason,
|
|
312
|
+
errorUpdateCount: newState.errorUpdateCount,
|
|
313
|
+
isFetched: newState.dataUpdateCount > 0 || newState.errorUpdateCount > 0,
|
|
314
|
+
isFetchedAfterMount: newState.dataUpdateCount > queryInitialState.dataUpdateCount || newState.errorUpdateCount > queryInitialState.errorUpdateCount,
|
|
315
|
+
isFetching,
|
|
316
|
+
isRefetching: isFetching && !isPending,
|
|
317
|
+
isLoadingError: isError && !hasData,
|
|
318
|
+
isPaused: newState.fetchStatus === "paused",
|
|
319
|
+
isPlaceholderData,
|
|
320
|
+
isRefetchError: isError && hasData,
|
|
321
|
+
isStale: isStale(query, options),
|
|
322
|
+
refetch: this.refetch,
|
|
323
|
+
promise: this.#currentThenable,
|
|
324
|
+
isEnabled: resolveEnabled(options.enabled, query) !== false
|
|
325
|
+
};
|
|
326
|
+
const nextResult = result;
|
|
327
|
+
if (this.options.experimental_prefetchInRender) {
|
|
328
|
+
const finalizeThenableIfPossible = (thenable) => {
|
|
329
|
+
if (nextResult.status === "error") {
|
|
330
|
+
thenable.reject(nextResult.error);
|
|
331
|
+
} else if (nextResult.data !== void 0) {
|
|
332
|
+
thenable.resolve(nextResult.data);
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
const recreateThenable = () => {
|
|
336
|
+
const pending = this.#currentThenable = nextResult.promise = pendingThenable();
|
|
337
|
+
finalizeThenableIfPossible(pending);
|
|
338
|
+
};
|
|
339
|
+
const prevThenable = this.#currentThenable;
|
|
340
|
+
switch (prevThenable.status) {
|
|
341
|
+
case "pending":
|
|
342
|
+
if (query.queryHash === prevQuery.queryHash) {
|
|
343
|
+
finalizeThenableIfPossible(prevThenable);
|
|
344
|
+
}
|
|
345
|
+
break;
|
|
346
|
+
case "fulfilled":
|
|
347
|
+
if (nextResult.status === "error" || nextResult.data !== prevThenable.value) {
|
|
348
|
+
recreateThenable();
|
|
349
|
+
}
|
|
350
|
+
break;
|
|
351
|
+
case "rejected":
|
|
352
|
+
if (nextResult.status !== "error" || nextResult.error !== prevThenable.reason) {
|
|
353
|
+
recreateThenable();
|
|
354
|
+
}
|
|
355
|
+
break;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
return nextResult;
|
|
359
|
+
}
|
|
360
|
+
updateResult() {
|
|
361
|
+
const prevResult = this.#currentResult;
|
|
362
|
+
const nextResult = this.createResult(this.#currentQuery, this.options);
|
|
363
|
+
this.#currentResultState = this.#currentQuery.state;
|
|
364
|
+
this.#currentResultOptions = this.options;
|
|
365
|
+
if (this.#currentResultState.data !== void 0) {
|
|
366
|
+
this.#lastQueryWithDefinedData = this.#currentQuery;
|
|
367
|
+
}
|
|
368
|
+
if (shallowEqualObjects(nextResult, prevResult)) {
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
this.#currentResult = nextResult;
|
|
372
|
+
const shouldNotifyListeners = () => {
|
|
373
|
+
if (!prevResult) {
|
|
374
|
+
return true;
|
|
375
|
+
}
|
|
376
|
+
const { notifyOnChangeProps } = this.options;
|
|
377
|
+
const notifyOnChangePropsValue = typeof notifyOnChangeProps === "function" ? notifyOnChangeProps() : notifyOnChangeProps;
|
|
378
|
+
if (notifyOnChangePropsValue === "all" || !notifyOnChangePropsValue && !this.#trackedProps.size) {
|
|
379
|
+
return true;
|
|
380
|
+
}
|
|
381
|
+
const includedProps = new Set(
|
|
382
|
+
notifyOnChangePropsValue ?? this.#trackedProps
|
|
383
|
+
);
|
|
384
|
+
if (this.options.throwOnError) {
|
|
385
|
+
includedProps.add("error");
|
|
386
|
+
}
|
|
387
|
+
return Object.keys(this.#currentResult).some((key) => {
|
|
388
|
+
const typedKey = key;
|
|
389
|
+
const changed = this.#currentResult[typedKey] !== prevResult[typedKey];
|
|
390
|
+
return changed && includedProps.has(typedKey);
|
|
391
|
+
});
|
|
392
|
+
};
|
|
393
|
+
this.#notify({ listeners: shouldNotifyListeners() });
|
|
394
|
+
}
|
|
395
|
+
#updateQuery() {
|
|
396
|
+
const query = this.#client.getQueryCache().build(this.#client, this.options);
|
|
397
|
+
if (query === this.#currentQuery) {
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
const prevQuery = this.#currentQuery;
|
|
401
|
+
this.#currentQuery = query;
|
|
402
|
+
this.#currentQueryInitialState = query.state;
|
|
403
|
+
if (this.hasListeners()) {
|
|
404
|
+
prevQuery?.removeObserver(this);
|
|
405
|
+
query.addObserver(this);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
onQueryUpdate() {
|
|
409
|
+
this.updateResult();
|
|
410
|
+
if (this.hasListeners()) {
|
|
411
|
+
this.#updateTimers();
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
#notify(notifyOptions) {
|
|
415
|
+
notifyManager.batch(() => {
|
|
416
|
+
if (notifyOptions.listeners) {
|
|
417
|
+
this.listeners.forEach((listener) => {
|
|
418
|
+
listener(this.#currentResult);
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
this.#client.getQueryCache().notify({
|
|
422
|
+
query: this.#currentQuery,
|
|
423
|
+
type: "observerResultsUpdated"
|
|
424
|
+
});
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
function shouldLoadOnMount(query, options) {
|
|
429
|
+
return resolveEnabled(options.enabled, query) !== false && query.state.data === void 0 && !(query.state.status === "error" && options.retryOnMount === false);
|
|
430
|
+
}
|
|
431
|
+
function shouldFetchOnMount(query, options) {
|
|
432
|
+
return shouldLoadOnMount(query, options) || query.state.data !== void 0 && shouldFetchOn(query, options, options.refetchOnMount);
|
|
433
|
+
}
|
|
434
|
+
function shouldFetchOn(query, options, field) {
|
|
435
|
+
if (resolveEnabled(options.enabled, query) !== false && resolveStaleTime(options.staleTime, query) !== "static") {
|
|
436
|
+
const value = typeof field === "function" ? field(query) : field;
|
|
437
|
+
return value === "always" || value !== false && isStale(query, options);
|
|
438
|
+
}
|
|
439
|
+
return false;
|
|
440
|
+
}
|
|
441
|
+
function shouldFetchOptionally(query, prevQuery, options, prevOptions) {
|
|
442
|
+
return (query !== prevQuery || resolveEnabled(prevOptions.enabled, query) === false) && (!options.suspense || query.state.status !== "error") && isStale(query, options);
|
|
443
|
+
}
|
|
444
|
+
function isStale(query, options) {
|
|
445
|
+
return resolveEnabled(options.enabled, query) !== false && query.isStaleByTime(resolveStaleTime(options.staleTime, query));
|
|
446
|
+
}
|
|
447
|
+
function shouldAssignObserverCurrentProperties(observer, optimisticResult) {
|
|
448
|
+
if (!shallowEqualObjects(observer.getCurrentResult(), optimisticResult)) {
|
|
449
|
+
return true;
|
|
450
|
+
}
|
|
451
|
+
return false;
|
|
452
|
+
}
|
|
453
|
+
export {
|
|
454
|
+
QueryObserver
|
|
455
|
+
};
|
|
456
|
+
//# sourceMappingURL=queryObserver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queryObserver.js","sources":["../../../../../../node_modules/@tanstack/query-core/build/modern/queryObserver.js"],"sourcesContent":["// src/queryObserver.ts\nimport { focusManager } from \"./focusManager.js\";\nimport { notifyManager } from \"./notifyManager.js\";\nimport { fetchState } from \"./query.js\";\nimport { Subscribable } from \"./subscribable.js\";\nimport { pendingThenable } from \"./thenable.js\";\nimport {\n isServer,\n isValidTimeout,\n noop,\n replaceData,\n resolveEnabled,\n resolveStaleTime,\n shallowEqualObjects,\n timeUntilStale\n} from \"./utils.js\";\nvar QueryObserver = class extends Subscribable {\n constructor(client, options) {\n super();\n this.options = options;\n this.#client = client;\n this.#selectError = null;\n this.#currentThenable = pendingThenable();\n this.bindMethods();\n this.setOptions(options);\n }\n #client;\n #currentQuery = void 0;\n #currentQueryInitialState = void 0;\n #currentResult = void 0;\n #currentResultState;\n #currentResultOptions;\n #currentThenable;\n #selectError;\n #selectFn;\n #selectResult;\n // This property keeps track of the last query with defined data.\n // It will be used to pass the previous data and query to the placeholder function between renders.\n #lastQueryWithDefinedData;\n #staleTimeoutId;\n #refetchIntervalId;\n #currentRefetchInterval;\n #trackedProps = /* @__PURE__ */ new Set();\n bindMethods() {\n this.refetch = this.refetch.bind(this);\n }\n onSubscribe() {\n if (this.listeners.size === 1) {\n this.#currentQuery.addObserver(this);\n if (shouldFetchOnMount(this.#currentQuery, this.options)) {\n this.#executeFetch();\n } else {\n this.updateResult();\n }\n this.#updateTimers();\n }\n }\n onUnsubscribe() {\n if (!this.hasListeners()) {\n this.destroy();\n }\n }\n shouldFetchOnReconnect() {\n return shouldFetchOn(\n this.#currentQuery,\n this.options,\n this.options.refetchOnReconnect\n );\n }\n shouldFetchOnWindowFocus() {\n return shouldFetchOn(\n this.#currentQuery,\n this.options,\n this.options.refetchOnWindowFocus\n );\n }\n destroy() {\n this.listeners = /* @__PURE__ */ new Set();\n this.#clearStaleTimeout();\n this.#clearRefetchInterval();\n this.#currentQuery.removeObserver(this);\n }\n setOptions(options) {\n const prevOptions = this.options;\n const prevQuery = this.#currentQuery;\n this.options = this.#client.defaultQueryOptions(options);\n if (this.options.enabled !== void 0 && typeof this.options.enabled !== \"boolean\" && typeof this.options.enabled !== \"function\" && typeof resolveEnabled(this.options.enabled, this.#currentQuery) !== \"boolean\") {\n throw new Error(\n \"Expected enabled to be a boolean or a callback that returns a boolean\"\n );\n }\n this.#updateQuery();\n this.#currentQuery.setOptions(this.options);\n if (prevOptions._defaulted && !shallowEqualObjects(this.options, prevOptions)) {\n this.#client.getQueryCache().notify({\n type: \"observerOptionsUpdated\",\n query: this.#currentQuery,\n observer: this\n });\n }\n const mounted = this.hasListeners();\n if (mounted && shouldFetchOptionally(\n this.#currentQuery,\n prevQuery,\n this.options,\n prevOptions\n )) {\n this.#executeFetch();\n }\n this.updateResult();\n if (mounted && (this.#currentQuery !== prevQuery || resolveEnabled(this.options.enabled, this.#currentQuery) !== resolveEnabled(prevOptions.enabled, this.#currentQuery) || resolveStaleTime(this.options.staleTime, this.#currentQuery) !== resolveStaleTime(prevOptions.staleTime, this.#currentQuery))) {\n this.#updateStaleTimeout();\n }\n const nextRefetchInterval = this.#computeRefetchInterval();\n if (mounted && (this.#currentQuery !== prevQuery || resolveEnabled(this.options.enabled, this.#currentQuery) !== resolveEnabled(prevOptions.enabled, this.#currentQuery) || nextRefetchInterval !== this.#currentRefetchInterval)) {\n this.#updateRefetchInterval(nextRefetchInterval);\n }\n }\n getOptimisticResult(options) {\n const query = this.#client.getQueryCache().build(this.#client, options);\n const result = this.createResult(query, options);\n if (shouldAssignObserverCurrentProperties(this, result)) {\n this.#currentResult = result;\n this.#currentResultOptions = this.options;\n this.#currentResultState = this.#currentQuery.state;\n }\n return result;\n }\n getCurrentResult() {\n return this.#currentResult;\n }\n trackResult(result, onPropTracked) {\n return new Proxy(result, {\n get: (target, key) => {\n this.trackProp(key);\n onPropTracked?.(key);\n if (key === \"promise\" && !this.options.experimental_prefetchInRender && this.#currentThenable.status === \"pending\") {\n this.#currentThenable.reject(\n new Error(\n \"experimental_prefetchInRender feature flag is not enabled\"\n )\n );\n }\n return Reflect.get(target, key);\n }\n });\n }\n trackProp(key) {\n this.#trackedProps.add(key);\n }\n getCurrentQuery() {\n return this.#currentQuery;\n }\n refetch({ ...options } = {}) {\n return this.fetch({\n ...options\n });\n }\n fetchOptimistic(options) {\n const defaultedOptions = this.#client.defaultQueryOptions(options);\n const query = this.#client.getQueryCache().build(this.#client, defaultedOptions);\n return query.fetch().then(() => this.createResult(query, defaultedOptions));\n }\n fetch(fetchOptions) {\n return this.#executeFetch({\n ...fetchOptions,\n cancelRefetch: fetchOptions.cancelRefetch ?? true\n }).then(() => {\n this.updateResult();\n return this.#currentResult;\n });\n }\n #executeFetch(fetchOptions) {\n this.#updateQuery();\n let promise = this.#currentQuery.fetch(\n this.options,\n fetchOptions\n );\n if (!fetchOptions?.throwOnError) {\n promise = promise.catch(noop);\n }\n return promise;\n }\n #updateStaleTimeout() {\n this.#clearStaleTimeout();\n const staleTime = resolveStaleTime(\n this.options.staleTime,\n this.#currentQuery\n );\n if (isServer || this.#currentResult.isStale || !isValidTimeout(staleTime)) {\n return;\n }\n const time = timeUntilStale(this.#currentResult.dataUpdatedAt, staleTime);\n const timeout = time + 1;\n this.#staleTimeoutId = setTimeout(() => {\n if (!this.#currentResult.isStale) {\n this.updateResult();\n }\n }, timeout);\n }\n #computeRefetchInterval() {\n return (typeof this.options.refetchInterval === \"function\" ? this.options.refetchInterval(this.#currentQuery) : this.options.refetchInterval) ?? false;\n }\n #updateRefetchInterval(nextInterval) {\n this.#clearRefetchInterval();\n this.#currentRefetchInterval = nextInterval;\n if (isServer || resolveEnabled(this.options.enabled, this.#currentQuery) === false || !isValidTimeout(this.#currentRefetchInterval) || this.#currentRefetchInterval === 0) {\n return;\n }\n this.#refetchIntervalId = setInterval(() => {\n if (this.options.refetchIntervalInBackground || focusManager.isFocused()) {\n this.#executeFetch();\n }\n }, this.#currentRefetchInterval);\n }\n #updateTimers() {\n this.#updateStaleTimeout();\n this.#updateRefetchInterval(this.#computeRefetchInterval());\n }\n #clearStaleTimeout() {\n if (this.#staleTimeoutId) {\n clearTimeout(this.#staleTimeoutId);\n this.#staleTimeoutId = void 0;\n }\n }\n #clearRefetchInterval() {\n if (this.#refetchIntervalId) {\n clearInterval(this.#refetchIntervalId);\n this.#refetchIntervalId = void 0;\n }\n }\n createResult(query, options) {\n const prevQuery = this.#currentQuery;\n const prevOptions = this.options;\n const prevResult = this.#currentResult;\n const prevResultState = this.#currentResultState;\n const prevResultOptions = this.#currentResultOptions;\n const queryChange = query !== prevQuery;\n const queryInitialState = queryChange ? query.state : this.#currentQueryInitialState;\n const { state } = query;\n let newState = { ...state };\n let isPlaceholderData = false;\n let data;\n if (options._optimisticResults) {\n const mounted = this.hasListeners();\n const fetchOnMount = !mounted && shouldFetchOnMount(query, options);\n const fetchOptionally = mounted && shouldFetchOptionally(query, prevQuery, options, prevOptions);\n if (fetchOnMount || fetchOptionally) {\n newState = {\n ...newState,\n ...fetchState(state.data, query.options)\n };\n }\n if (options._optimisticResults === \"isRestoring\") {\n newState.fetchStatus = \"idle\";\n }\n }\n let { error, errorUpdatedAt, status } = newState;\n data = newState.data;\n let skipSelect = false;\n if (options.placeholderData !== void 0 && data === void 0 && status === \"pending\") {\n let placeholderData;\n if (prevResult?.isPlaceholderData && options.placeholderData === prevResultOptions?.placeholderData) {\n placeholderData = prevResult.data;\n skipSelect = true;\n } else {\n placeholderData = typeof options.placeholderData === \"function\" ? options.placeholderData(\n this.#lastQueryWithDefinedData?.state.data,\n this.#lastQueryWithDefinedData\n ) : options.placeholderData;\n }\n if (placeholderData !== void 0) {\n status = \"success\";\n data = replaceData(\n prevResult?.data,\n placeholderData,\n options\n );\n isPlaceholderData = true;\n }\n }\n if (options.select && data !== void 0 && !skipSelect) {\n if (prevResult && data === prevResultState?.data && options.select === this.#selectFn) {\n data = this.#selectResult;\n } else {\n try {\n this.#selectFn = options.select;\n data = options.select(data);\n data = replaceData(prevResult?.data, data, options);\n this.#selectResult = data;\n this.#selectError = null;\n } catch (selectError) {\n this.#selectError = selectError;\n }\n }\n }\n if (this.#selectError) {\n error = this.#selectError;\n data = this.#selectResult;\n errorUpdatedAt = Date.now();\n status = \"error\";\n }\n const isFetching = newState.fetchStatus === \"fetching\";\n const isPending = status === \"pending\";\n const isError = status === \"error\";\n const isLoading = isPending && isFetching;\n const hasData = data !== void 0;\n const result = {\n status,\n fetchStatus: newState.fetchStatus,\n isPending,\n isSuccess: status === \"success\",\n isError,\n isInitialLoading: isLoading,\n isLoading,\n data,\n dataUpdatedAt: newState.dataUpdatedAt,\n error,\n errorUpdatedAt,\n failureCount: newState.fetchFailureCount,\n failureReason: newState.fetchFailureReason,\n errorUpdateCount: newState.errorUpdateCount,\n isFetched: newState.dataUpdateCount > 0 || newState.errorUpdateCount > 0,\n isFetchedAfterMount: newState.dataUpdateCount > queryInitialState.dataUpdateCount || newState.errorUpdateCount > queryInitialState.errorUpdateCount,\n isFetching,\n isRefetching: isFetching && !isPending,\n isLoadingError: isError && !hasData,\n isPaused: newState.fetchStatus === \"paused\",\n isPlaceholderData,\n isRefetchError: isError && hasData,\n isStale: isStale(query, options),\n refetch: this.refetch,\n promise: this.#currentThenable,\n isEnabled: resolveEnabled(options.enabled, query) !== false\n };\n const nextResult = result;\n if (this.options.experimental_prefetchInRender) {\n const finalizeThenableIfPossible = (thenable) => {\n if (nextResult.status === \"error\") {\n thenable.reject(nextResult.error);\n } else if (nextResult.data !== void 0) {\n thenable.resolve(nextResult.data);\n }\n };\n const recreateThenable = () => {\n const pending = this.#currentThenable = nextResult.promise = pendingThenable();\n finalizeThenableIfPossible(pending);\n };\n const prevThenable = this.#currentThenable;\n switch (prevThenable.status) {\n case \"pending\":\n if (query.queryHash === prevQuery.queryHash) {\n finalizeThenableIfPossible(prevThenable);\n }\n break;\n case \"fulfilled\":\n if (nextResult.status === \"error\" || nextResult.data !== prevThenable.value) {\n recreateThenable();\n }\n break;\n case \"rejected\":\n if (nextResult.status !== \"error\" || nextResult.error !== prevThenable.reason) {\n recreateThenable();\n }\n break;\n }\n }\n return nextResult;\n }\n updateResult() {\n const prevResult = this.#currentResult;\n const nextResult = this.createResult(this.#currentQuery, this.options);\n this.#currentResultState = this.#currentQuery.state;\n this.#currentResultOptions = this.options;\n if (this.#currentResultState.data !== void 0) {\n this.#lastQueryWithDefinedData = this.#currentQuery;\n }\n if (shallowEqualObjects(nextResult, prevResult)) {\n return;\n }\n this.#currentResult = nextResult;\n const shouldNotifyListeners = () => {\n if (!prevResult) {\n return true;\n }\n const { notifyOnChangeProps } = this.options;\n const notifyOnChangePropsValue = typeof notifyOnChangeProps === \"function\" ? notifyOnChangeProps() : notifyOnChangeProps;\n if (notifyOnChangePropsValue === \"all\" || !notifyOnChangePropsValue && !this.#trackedProps.size) {\n return true;\n }\n const includedProps = new Set(\n notifyOnChangePropsValue ?? this.#trackedProps\n );\n if (this.options.throwOnError) {\n includedProps.add(\"error\");\n }\n return Object.keys(this.#currentResult).some((key) => {\n const typedKey = key;\n const changed = this.#currentResult[typedKey] !== prevResult[typedKey];\n return changed && includedProps.has(typedKey);\n });\n };\n this.#notify({ listeners: shouldNotifyListeners() });\n }\n #updateQuery() {\n const query = this.#client.getQueryCache().build(this.#client, this.options);\n if (query === this.#currentQuery) {\n return;\n }\n const prevQuery = this.#currentQuery;\n this.#currentQuery = query;\n this.#currentQueryInitialState = query.state;\n if (this.hasListeners()) {\n prevQuery?.removeObserver(this);\n query.addObserver(this);\n }\n }\n onQueryUpdate() {\n this.updateResult();\n if (this.hasListeners()) {\n this.#updateTimers();\n }\n }\n #notify(notifyOptions) {\n notifyManager.batch(() => {\n if (notifyOptions.listeners) {\n this.listeners.forEach((listener) => {\n listener(this.#currentResult);\n });\n }\n this.#client.getQueryCache().notify({\n query: this.#currentQuery,\n type: \"observerResultsUpdated\"\n });\n });\n }\n};\nfunction shouldLoadOnMount(query, options) {\n return resolveEnabled(options.enabled, query) !== false && query.state.data === void 0 && !(query.state.status === \"error\" && options.retryOnMount === false);\n}\nfunction shouldFetchOnMount(query, options) {\n return shouldLoadOnMount(query, options) || query.state.data !== void 0 && shouldFetchOn(query, options, options.refetchOnMount);\n}\nfunction shouldFetchOn(query, options, field) {\n if (resolveEnabled(options.enabled, query) !== false && resolveStaleTime(options.staleTime, query) !== \"static\") {\n const value = typeof field === \"function\" ? field(query) : field;\n return value === \"always\" || value !== false && isStale(query, options);\n }\n return false;\n}\nfunction shouldFetchOptionally(query, prevQuery, options, prevOptions) {\n return (query !== prevQuery || resolveEnabled(prevOptions.enabled, query) === false) && (!options.suspense || query.state.status !== \"error\") && isStale(query, options);\n}\nfunction isStale(query, options) {\n return resolveEnabled(options.enabled, query) !== false && query.isStaleByTime(resolveStaleTime(options.staleTime, query));\n}\nfunction shouldAssignObserverCurrentProperties(observer, optimisticResult) {\n if (!shallowEqualObjects(observer.getCurrentResult(), optimisticResult)) {\n return true;\n }\n return false;\n}\nexport {\n QueryObserver\n};\n//# sourceMappingURL=queryObserver.js.map"],"names":[],"mappings":";;;;;;AAgBG,IAAC,gBAAgB,cAAc,aAAa;AAAA,EAC7C,YAAY,QAAQ,SAAS;AAC3B,UAAK;AACL,SAAK,UAAU;AACf,SAAK,UAAU;AACf,SAAK,eAAe;AACpB,SAAK,mBAAmB,gBAAe;AACvC,SAAK,YAAW;AAChB,SAAK,WAAW,OAAO;AAAA,EACzB;AAAA,EACA;AAAA,EACA,gBAAgB;AAAA,EAChB,4BAA4B;AAAA,EAC5B,iBAAiB;AAAA,EACjB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,E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MAAM,SAAS,MAAM,MAAM,SAAS,UAAU,EAAE,MAAM,MAAM,WAAW,WAAW,QAAQ,iBAAiB;AACzJ;AACA,SAAS,mBAAmB,OAAO,SAAS;AAC1C,SAAO,kBAAkB,OAAO,OAAO,KAAK,MAAM,MAAM,SAAS,UAAU,cAAc,OAAO,SAAS,QAAQ,cAAc;AACjI;AACA,SAAS,cAAc,OAAO,SAAS,OAAO;AAC5C,MAAI,eAAe,QAAQ,SAAS,KAAK,MAAM,SAAS,iBAAiB,QAAQ,WAAW,KAAK,MAAM,UAAU;AAC/G,UAAM,QAAQ,OAAO,UAAU,aAAa,MAAM,KAAK,IAAI;AAC3D,WAAO,UAAU,YAAY,UAAU,SAAS,QAAQ,OAAO,OAAO;AAAA,EACxE;AACA,SAAO;AACT;AACA,SAAS,sBAAsB,OAAO,WAAW,SAAS,aAAa;AACrE,UAAQ,UAAU,aAAa,eAAe,YAAY,SAAS,KAAK,MAAM,WAAW,CAAC,QAAQ,YAAY,MAAM,MAAM,WAAW,YAAY,QAAQ,OAAO,OAAO;AACzK;AACA,SAAS,QAAQ,OAAO,SAAS;AAC/B,SAAO,eAAe,QAAQ,SAAS,KAAK,MAAM,SAAS,MAAM,cAAc,iBAAiB,QAAQ,WAAW,KAAK,CAAC;AAC3H;AACA,SAAS,sCAAsC,UAAU,kBAAkB;AACzE,MAAI,CAAC,oBAAoB,SAAS,iBAAgB,GAAI,gBAAgB,GAAG;AACvE,WAAO;AAAA,EACT;AACA,SAAO;AACT;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retryer.js","sources":["../../../../../../node_modules/@tanstack/query-core/build/modern/retryer.js"],"sourcesContent":["// src/retryer.ts\nimport { focusManager } from \"./focusManager.js\";\nimport { onlineManager } from \"./onlineManager.js\";\nimport { pendingThenable } from \"./thenable.js\";\nimport { isServer, sleep } from \"./utils.js\";\nfunction defaultRetryDelay(failureCount) {\n return Math.min(1e3 * 2 ** failureCount, 3e4);\n}\nfunction canFetch(networkMode) {\n return (networkMode ?? \"online\") === \"online\" ? onlineManager.isOnline() : true;\n}\nvar CancelledError = class extends Error {\n constructor(options) {\n super(\"CancelledError\");\n this.revert = options?.revert;\n this.silent = options?.silent;\n }\n};\nfunction isCancelledError(value) {\n return value instanceof CancelledError;\n}\nfunction createRetryer(config) {\n let isRetryCancelled = false;\n let failureCount = 0;\n let continueFn;\n const thenable = pendingThenable();\n const isResolved = () => thenable.status !== \"pending\";\n const cancel = (cancelOptions) => {\n if (!isResolved()) {\n const error = new CancelledError(cancelOptions);\n reject(error);\n config.onCancel?.(error);\n }\n };\n const cancelRetry = () => {\n isRetryCancelled = true;\n };\n const continueRetry = () => {\n isRetryCancelled = false;\n };\n const canContinue = () => focusManager.isFocused() && (config.networkMode === \"always\" || onlineManager.isOnline()) && config.canRun();\n const canStart = () => canFetch(config.networkMode) && config.canRun();\n const resolve = (value) => {\n if (!isResolved()) {\n continueFn?.();\n thenable.resolve(value);\n }\n };\n const reject = (value) => {\n if (!isResolved()) {\n continueFn?.();\n thenable.reject(value);\n }\n };\n const pause = () => {\n return new Promise((continueResolve) => {\n continueFn = (value) => {\n if (isResolved() || canContinue()) {\n continueResolve(value);\n }\n };\n config.onPause?.();\n }).then(() => {\n continueFn = void 0;\n if (!isResolved()) {\n config.onContinue?.();\n }\n });\n };\n const run = () => {\n if (isResolved()) {\n return;\n }\n let promiseOrValue;\n const initialPromise = failureCount === 0 ? config.initialPromise : void 0;\n try {\n promiseOrValue = initialPromise ?? config.fn();\n } catch (error) {\n promiseOrValue = Promise.reject(error);\n }\n Promise.resolve(promiseOrValue).then(resolve).catch((error) => {\n if (isResolved()) {\n return;\n }\n const retry = config.retry ?? (isServer ? 0 : 3);\n const retryDelay = config.retryDelay ?? defaultRetryDelay;\n const delay = typeof retryDelay === \"function\" ? retryDelay(failureCount, error) : retryDelay;\n const shouldRetry = retry === true || typeof retry === \"number\" && failureCount < retry || typeof retry === \"function\" && retry(failureCount, error);\n if (isRetryCancelled || !shouldRetry) {\n reject(error);\n return;\n }\n failureCount++;\n config.onFail?.(failureCount, error);\n sleep(delay).then(() => {\n return canContinue() ? void 0 : pause();\n }).then(() => {\n if (isRetryCancelled) {\n reject(error);\n } else {\n run();\n }\n });\n });\n };\n return {\n promise: thenable,\n status: () => thenable.status,\n cancel,\n continue: () => {\n continueFn?.();\n return thenable;\n },\n cancelRetry,\n continueRetry,\n canStart,\n start: () => {\n if (canStart()) {\n run();\n } else {\n pause().then(run);\n }\n return thenable;\n }\n };\n}\nexport {\n CancelledError,\n canFetch,\n createRetryer,\n isCancelledError\n};\n//# sourceMappingURL=retryer.js.map"],"names":[],"mappings":";AAQA,SAAS,SAAS,aAAa;AAC7B,UAAQ,eAAe,cAAc,WAAW,cAAc,SAAQ,IAAK;AAC7E;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
var Subscribable = class {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.listeners = /* @__PURE__ */ new Set();
|
|
4
|
+
this.subscribe = this.subscribe.bind(this);
|
|
5
|
+
}
|
|
6
|
+
subscribe(listener) {
|
|
7
|
+
this.listeners.add(listener);
|
|
8
|
+
this.onSubscribe();
|
|
9
|
+
return () => {
|
|
10
|
+
this.listeners.delete(listener);
|
|
11
|
+
this.onUnsubscribe();
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
hasListeners() {
|
|
15
|
+
return this.listeners.size > 0;
|
|
16
|
+
}
|
|
17
|
+
onSubscribe() {
|
|
18
|
+
}
|
|
19
|
+
onUnsubscribe() {
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
Subscribable
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=subscribable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscribable.js","sources":["../../../../../../node_modules/@tanstack/query-core/build/modern/subscribable.js"],"sourcesContent":["// src/subscribable.ts\nvar Subscribable = class {\n constructor() {\n this.listeners = /* @__PURE__ */ new Set();\n this.subscribe = this.subscribe.bind(this);\n }\n subscribe(listener) {\n this.listeners.add(listener);\n this.onSubscribe();\n return () => {\n this.listeners.delete(listener);\n this.onUnsubscribe();\n };\n }\n hasListeners() {\n return this.listeners.size > 0;\n }\n onSubscribe() {\n }\n onUnsubscribe() {\n }\n};\nexport {\n Subscribable\n};\n//# sourceMappingURL=subscribable.js.map"],"names":[],"mappings":"AACG,IAAC,eAAe,MAAM;AAAA,EACvB,cAAc;AACZ,SAAK,YAA4B,oBAAI,IAAG;AACxC,SAAK,YAAY,KAAK,UAAU,KAAK,IAAI;AAAA,EAC3C;AAAA,EACA,UAAU,UAAU;AAClB,SAAK,UAAU,IAAI,QAAQ;AAC3B,SAAK,YAAW;AAChB,WAAO,MAAM;AACX,WAAK,UAAU,OAAO,QAAQ;AAC9B,WAAK,cAAa;AAAA,IACpB;AAAA,EACF;AAAA,EACA,eAAe;AACb,WAAO,KAAK,UAAU,OAAO;AAAA,EAC/B;AAAA,EACA,cAAc;AAAA,EACd;AAAA,EACA,gBAAgB;AAAA,EAChB;AACF;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
function pendingThenable() {
|
|
2
|
+
let resolve;
|
|
3
|
+
let reject;
|
|
4
|
+
const thenable = new Promise((_resolve, _reject) => {
|
|
5
|
+
resolve = _resolve;
|
|
6
|
+
reject = _reject;
|
|
7
|
+
});
|
|
8
|
+
thenable.status = "pending";
|
|
9
|
+
thenable.catch(() => {
|
|
10
|
+
});
|
|
11
|
+
function finalize(data) {
|
|
12
|
+
Object.assign(thenable, data);
|
|
13
|
+
delete thenable.resolve;
|
|
14
|
+
delete thenable.reject;
|
|
15
|
+
}
|
|
16
|
+
thenable.resolve = (value) => {
|
|
17
|
+
finalize({
|
|
18
|
+
status: "fulfilled",
|
|
19
|
+
value
|
|
20
|
+
});
|
|
21
|
+
resolve(value);
|
|
22
|
+
};
|
|
23
|
+
thenable.reject = (reason) => {
|
|
24
|
+
finalize({
|
|
25
|
+
status: "rejected",
|
|
26
|
+
reason
|
|
27
|
+
});
|
|
28
|
+
reject(reason);
|
|
29
|
+
};
|
|
30
|
+
return thenable;
|
|
31
|
+
}
|
|
32
|
+
export {
|
|
33
|
+
pendingThenable
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=thenable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thenable.js","sources":["../../../../../../node_modules/@tanstack/query-core/build/modern/thenable.js"],"sourcesContent":["// src/thenable.ts\nimport { noop } from \"./utils.js\";\nfunction pendingThenable() {\n let resolve;\n let reject;\n const thenable = new Promise((_resolve, _reject) => {\n resolve = _resolve;\n reject = _reject;\n });\n thenable.status = \"pending\";\n thenable.catch(() => {\n });\n function finalize(data) {\n Object.assign(thenable, data);\n delete thenable.resolve;\n delete thenable.reject;\n }\n thenable.resolve = (value) => {\n finalize({\n status: \"fulfilled\",\n value\n });\n resolve(value);\n };\n thenable.reject = (reason) => {\n finalize({\n status: \"rejected\",\n reason\n });\n reject(reason);\n };\n return thenable;\n}\nfunction tryResolveSync(promise) {\n let data;\n promise.then((result) => {\n data = result;\n return result;\n }, noop)?.catch(noop);\n if (data !== void 0) {\n return { data };\n }\n return void 0;\n}\nexport {\n pendingThenable,\n tryResolveSync\n};\n//# sourceMappingURL=thenable.js.map"],"names":[],"mappings":"AAEA,SAAS,kBAAkB;AACzB,MAAI;AACJ,MAAI;AACJ,QAAM,WAAW,IAAI,QAAQ,CAAC,UAAU,YAAY;AAClD,cAAU;AACV,aAAS;AAAA,EACX,CAAC;AACD,WAAS,SAAS;AAClB,WAAS,MAAM,MAAM;AAAA,EACrB,CAAC;AACD,WAAS,SAAS,MAAM;AACtB,WAAO,OAAO,UAAU,IAAI;AAC5B,WAAO,SAAS;AAChB,WAAO,SAAS;AAAA,EAClB;AACA,WAAS,UAAU,CAAC,UAAU;AAC5B,aAAS;AAAA,MACP,QAAQ;AAAA,MACR;AAAA,IACN,CAAK;AACD,YAAQ,KAAK;AAAA,EACf;AACA,WAAS,SAAS,CAAC,WAAW;AAC5B,aAAS;AAAA,MACP,QAAQ;AAAA,MACR;AAAA,IACN,CAAK;AACD,WAAO,MAAM;AAAA,EACf;AACA,SAAO;AACT;","x_google_ignoreList":[0]}
|