zudoku 0.3.0-dev.55 → 0.3.0-dev.56
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/dist/config/validators/validate.d.ts +12 -12
- package/dist/lib/components/DeveloperHint.d.ts +5 -0
- package/dist/lib/components/DeveloperHint.js +10 -0
- package/dist/lib/components/DeveloperHint.js.map +1 -0
- package/dist/lib/components/NotFoundPage.js +2 -2
- package/dist/lib/components/NotFoundPage.js.map +1 -1
- package/dist/lib/plugins/api-keys/ProtectedRoute.d.ts +1 -0
- package/dist/lib/plugins/api-keys/ProtectedRoute.js +14 -0
- package/dist/lib/plugins/api-keys/ProtectedRoute.js.map +1 -0
- package/dist/lib/plugins/api-keys/index.js +2 -12
- package/dist/lib/plugins/api-keys/index.js.map +1 -1
- package/dist/lib/plugins/openapi/OperationList.js +2 -2
- package/dist/lib/plugins/openapi/OperationList.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/PlaygroundDialog.js +3 -3
- package/dist/lib/plugins/openapi/playground/PlaygroundDialog.js.map +1 -1
- package/lib/AnchorLink-GNsUeGSX.js +705 -0
- package/lib/{AnchorLink-BaXHjhF-.js.map → AnchorLink-GNsUeGSX.js.map} +1 -1
- package/lib/Button-DpHMZvVs.js +4571 -0
- package/lib/Button-DpHMZvVs.js.map +1 -0
- package/lib/DevPortalProvider-Do9oJqme.js +1081 -0
- package/lib/{DevPortalProvider-GjdO0Xr-.js.map → DevPortalProvider-Do9oJqme.js.map} +1 -1
- package/lib/Markdown-DtLFdxD1.js +15031 -0
- package/lib/Markdown-DtLFdxD1.js.map +1 -0
- package/lib/MdxPage-CbwYRKf5.js +190 -0
- package/lib/{MdxPage-Dlujuj-J.js.map → MdxPage-CbwYRKf5.js.map} +1 -1
- package/lib/OperationList-DpR4KzIJ.js +5570 -0
- package/lib/OperationList-DpR4KzIJ.js.map +1 -0
- package/lib/Route-C1LyvITr.js +13 -0
- package/lib/{Route-CR6TEwVC.js.map → Route-C1LyvITr.js.map} +1 -1
- package/lib/Spinner-Bhbs5aPI.js +182 -0
- package/lib/Spinner-Bhbs5aPI.js.map +1 -0
- package/lib/_commonjsHelpers-BVfed4GL.js +29 -0
- package/lib/_commonjsHelpers-BVfed4GL.js.map +1 -0
- package/lib/assets/index-BPdJm2ty.js +4765 -0
- package/lib/assets/{index-CpIig0AX.js.map → index-BPdJm2ty.js.map} +1 -1
- package/lib/assets/worker-BjPv-hjP.js +14897 -0
- package/lib/assets/{worker-B5k2aBV9.js.map → worker-BjPv-hjP.js.map} +1 -1
- package/lib/context-_fYfJFgk.js +14 -0
- package/lib/{context-BoN_3uxi.js.map → context-_fYfJFgk.js.map} +1 -1
- package/lib/hook-Biq3zYel.js +92 -0
- package/lib/hook-Biq3zYel.js.map +1 -0
- package/lib/{index-Dih8IAqw.js → index-DZ910ttL.js} +83 -103
- package/lib/{index-Dih8IAqw.js.map → index-DZ910ttL.js.map} +1 -1
- package/lib/index-gsAuUwQh.js +418 -0
- package/lib/index-gsAuUwQh.js.map +1 -0
- package/lib/index-pI9JkN46.js +4765 -0
- package/lib/{index-Bn03IPZt.js.map → index-pI9JkN46.js.map} +1 -1
- package/lib/jsx-runtime-CJZJivg2.js +1526 -0
- package/lib/{jsx-runtime-DvZ6OKMM.js.map → jsx-runtime-CJZJivg2.js.map} +1 -1
- package/lib/prism-bash.min-DadFsM4Z.js +7 -0
- package/lib/{prism-bash.min-BtBk0onv.js.map → prism-bash.min-DadFsM4Z.js.map} +1 -1
- package/lib/prism-csharp.min-Yizuc34Y.js +35 -0
- package/lib/{prism-csharp.min-Cv7D49bv.js.map → prism-csharp.min-Yizuc34Y.js.map} +1 -1
- package/lib/prism-java.min-d5iT_mOd.js +7 -0
- package/lib/{prism-java.min-tNK-JX6x.js.map → prism-java.min-d5iT_mOd.js.map} +1 -1
- package/lib/prism-json.min-B1GJqK1k.js +2 -0
- package/lib/{prism-json.min-Cdtv-CME.js.map → prism-json.min-B1GJqK1k.js.map} +1 -1
- package/lib/prism-markup-templating-DZrrEs0A.js +62 -0
- package/lib/{prism-markup-templating-iotg2sCU.js.map → prism-markup-templating-DZrrEs0A.js.map} +1 -1
- package/lib/prism-objectivec.min-BXSWqpJJ.js +2 -0
- package/lib/{prism-objectivec.min-CY4WGixz.js.map → prism-objectivec.min-BXSWqpJJ.js.map} +1 -1
- package/lib/prism-php.min-o7FpoMP_.js +11 -0
- package/lib/{prism-php.min-T6sIVgED.js.map → prism-php.min-o7FpoMP_.js.map} +1 -1
- package/lib/prism-ruby.min-C7LwcKyz.js +10 -0
- package/lib/{prism-ruby.min-B-2KAa4y.js.map → prism-ruby.min-C7LwcKyz.js.map} +1 -1
- package/lib/router-CBw2vqJE.js +2973 -0
- package/lib/{router-ButO1QyY.js.map → router-CBw2vqJE.js.map} +1 -1
- package/lib/slugify-CiPVjteN.js +28 -0
- package/lib/{slugify-CmS97Vy8.js.map → slugify-CiPVjteN.js.map} +1 -1
- package/lib/state-DKdaQzvh.js +288 -0
- package/lib/{state-CmGfNKhR.js.map → state-DKdaQzvh.js.map} +1 -1
- package/lib/urql-DMlBWUKL.js +1592 -0
- package/lib/{urql-DtVKPBx_.js.map → urql-DMlBWUKL.js.map} +1 -1
- package/lib/util-_jwUlTBU.js +41 -0
- package/lib/{util-B5KX4h4M.js.map → util-_jwUlTBU.js.map} +1 -1
- package/lib/zudoku.auth-auth0.js +18 -24
- package/lib/zudoku.auth-auth0.js.map +1 -1
- package/lib/zudoku.auth-clerk.js +34 -43
- package/lib/zudoku.auth-clerk.js.map +1 -1
- package/lib/zudoku.auth-openid.js +734 -1121
- package/lib/zudoku.auth-openid.js.map +1 -1
- package/lib/zudoku.components.js +822 -1076
- package/lib/zudoku.components.js.map +1 -1
- package/lib/zudoku.openapi-worker.js +9691 -13786
- package/lib/zudoku.openapi-worker.js.map +1 -1
- package/lib/zudoku.plugin-api-keys.js +171 -208
- package/lib/zudoku.plugin-api-keys.js.map +1 -1
- package/lib/zudoku.plugin-markdown.js +33 -41
- package/lib/zudoku.plugin-markdown.js.map +1 -1
- package/lib/zudoku.plugin-openapi.js +6 -6
- package/lib/zudoku.plugin-redirect.js +8 -10
- package/lib/zudoku.plugin-redirect.js.map +1 -1
- package/package.json +1 -1
- package/src/lib/components/DeveloperHint.tsx +25 -0
- package/src/lib/components/NotFoundPage.tsx +8 -14
- package/src/lib/plugins/api-keys/ProtectedRoute.tsx +29 -0
- package/src/lib/plugins/api-keys/index.tsx +2 -21
- package/src/lib/plugins/openapi/OperationList.tsx +5 -8
- package/src/lib/plugins/openapi/playground/PlaygroundDialog.tsx +3 -5
- package/lib/AnchorLink-BaXHjhF-.js +0 -989
- package/lib/Combination-BfufJFkX.js +0 -1365
- package/lib/Combination-BfufJFkX.js.map +0 -1
- package/lib/DevPortalProvider-GjdO0Xr-.js +0 -1610
- package/lib/Markdown-B8nPVql1.js +0 -19708
- package/lib/Markdown-B8nPVql1.js.map +0 -1
- package/lib/MdxPage-Dlujuj-J.js +0 -223
- package/lib/OperationList-krPgt6sE.js +0 -8041
- package/lib/OperationList-krPgt6sE.js.map +0 -1
- package/lib/Playground-DOHxca0P.js +0 -539
- package/lib/Playground-DOHxca0P.js.map +0 -1
- package/lib/Route-CR6TEwVC.js +0 -13
- package/lib/Select-Boi_pe3L.js +0 -5298
- package/lib/Select-Boi_pe3L.js.map +0 -1
- package/lib/Spinner-oU0QJmi_.js +0 -16
- package/lib/Spinner-oU0QJmi_.js.map +0 -1
- package/lib/_commonjsHelpers-BxmBWJD2.js +0 -34
- package/lib/_commonjsHelpers-BxmBWJD2.js.map +0 -1
- package/lib/assets/index-CpIig0AX.js +0 -6341
- package/lib/assets/worker-B5k2aBV9.js +0 -18921
- package/lib/context-BoN_3uxi.js +0 -17
- package/lib/hook-CIuFuyBT.js +0 -90
- package/lib/hook-CIuFuyBT.js.map +0 -1
- package/lib/index-BL1P4Gqq.js +0 -280
- package/lib/index-BL1P4Gqq.js.map +0 -1
- package/lib/index-Bn03IPZt.js +0 -6341
- package/lib/index-FprhHF51.js +0 -253
- package/lib/index-FprhHF51.js.map +0 -1
- package/lib/jsx-runtime-DvZ6OKMM.js +0 -2110
- package/lib/mutation-DWY9x2Uc.js +0 -250
- package/lib/mutation-DWY9x2Uc.js.map +0 -1
- package/lib/prism-bash.min-BtBk0onv.js +0 -7
- package/lib/prism-csharp.min-Cv7D49bv.js +0 -30
- package/lib/prism-java.min-tNK-JX6x.js +0 -7
- package/lib/prism-json.min-Cdtv-CME.js +0 -2
- package/lib/prism-markup-templating-iotg2sCU.js +0 -94
- package/lib/prism-objectivec.min-CY4WGixz.js +0 -2
- package/lib/prism-php.min-T6sIVgED.js +0 -11
- package/lib/prism-ruby.min-B-2KAa4y.js +0 -8
- package/lib/router-ButO1QyY.js +0 -4062
- package/lib/slugify-CmS97Vy8.js +0 -50
- package/lib/state-CmGfNKhR.js +0 -436
- package/lib/urql-DtVKPBx_.js +0 -2567
- package/lib/util-B5KX4h4M.js +0 -55
|
@@ -1,1610 +0,0 @@
|
|
|
1
|
-
var __typeError = (msg) => {
|
|
2
|
-
throw TypeError(msg);
|
|
3
|
-
};
|
|
4
|
-
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
5
|
-
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
6
|
-
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
7
|
-
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
8
|
-
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
9
|
-
var _focused, _cleanup, _setup, _a, _online, _cleanup2, _setup2, _b, _gcTimeout, _c, _initialState, _revertState, _cache, _retryer, _defaultOptions, _abortSignalConsumed, _Query_instances, dispatch_fn, _d, _client, _currentQuery, _currentQueryInitialState, _currentResult, _currentResultState, _currentResultOptions, _selectError, _selectFn, _selectResult, _lastQueryWithDefinedData, _staleTimeoutId, _refetchIntervalId, _currentRefetchInterval, _trackedProps, _QueryObserver_instances, executeFetch_fn, updateStaleTimeout_fn, computeRefetchInterval_fn, updateRefetchInterval_fn, updateTimers_fn, clearStaleTimeout_fn, clearRefetchInterval_fn, updateQuery_fn, notify_fn, _e;
|
|
10
|
-
import * as React from "react";
|
|
11
|
-
import { createContext, useContext } from "react";
|
|
12
|
-
import { j as jsxRuntimeExports, u as useLocation } from "./jsx-runtime-DvZ6OKMM.js";
|
|
13
|
-
import { m as matchPath } from "./router-ButO1QyY.js";
|
|
14
|
-
var Subscribable = class {
|
|
15
|
-
constructor() {
|
|
16
|
-
this.listeners = /* @__PURE__ */ new Set();
|
|
17
|
-
this.subscribe = this.subscribe.bind(this);
|
|
18
|
-
}
|
|
19
|
-
subscribe(listener) {
|
|
20
|
-
this.listeners.add(listener);
|
|
21
|
-
this.onSubscribe();
|
|
22
|
-
return () => {
|
|
23
|
-
this.listeners.delete(listener);
|
|
24
|
-
this.onUnsubscribe();
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
hasListeners() {
|
|
28
|
-
return this.listeners.size > 0;
|
|
29
|
-
}
|
|
30
|
-
onSubscribe() {
|
|
31
|
-
}
|
|
32
|
-
onUnsubscribe() {
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
var isServer = typeof window === "undefined" || "Deno" in globalThis;
|
|
36
|
-
function noop$1() {
|
|
37
|
-
return void 0;
|
|
38
|
-
}
|
|
39
|
-
function functionalUpdate(updater, input) {
|
|
40
|
-
return typeof updater === "function" ? updater(input) : updater;
|
|
41
|
-
}
|
|
42
|
-
function isValidTimeout(value) {
|
|
43
|
-
return typeof value === "number" && value >= 0 && value !== Infinity;
|
|
44
|
-
}
|
|
45
|
-
function timeUntilStale(updatedAt, staleTime) {
|
|
46
|
-
return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0);
|
|
47
|
-
}
|
|
48
|
-
function resolveStaleTime(staleTime, query) {
|
|
49
|
-
return typeof staleTime === "function" ? staleTime(query) : staleTime;
|
|
50
|
-
}
|
|
51
|
-
function resolveEnabled(enabled, query) {
|
|
52
|
-
return typeof enabled === "function" ? enabled(query) : enabled;
|
|
53
|
-
}
|
|
54
|
-
function matchQuery(filters, query) {
|
|
55
|
-
const {
|
|
56
|
-
type = "all",
|
|
57
|
-
exact,
|
|
58
|
-
fetchStatus,
|
|
59
|
-
predicate,
|
|
60
|
-
queryKey,
|
|
61
|
-
stale
|
|
62
|
-
} = filters;
|
|
63
|
-
if (queryKey) {
|
|
64
|
-
if (exact) {
|
|
65
|
-
if (query.queryHash !== hashQueryKeyByOptions(queryKey, query.options)) {
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
} else if (!partialMatchKey(query.queryKey, queryKey)) {
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
if (type !== "all") {
|
|
73
|
-
const isActive = query.isActive();
|
|
74
|
-
if (type === "active" && !isActive) {
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
if (type === "inactive" && isActive) {
|
|
78
|
-
return false;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
if (typeof stale === "boolean" && query.isStale() !== stale) {
|
|
82
|
-
return false;
|
|
83
|
-
}
|
|
84
|
-
if (fetchStatus && fetchStatus !== query.state.fetchStatus) {
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
if (predicate && !predicate(query)) {
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
return true;
|
|
91
|
-
}
|
|
92
|
-
function matchMutation(filters, mutation) {
|
|
93
|
-
const { exact, status, predicate, mutationKey } = filters;
|
|
94
|
-
if (mutationKey) {
|
|
95
|
-
if (!mutation.options.mutationKey) {
|
|
96
|
-
return false;
|
|
97
|
-
}
|
|
98
|
-
if (exact) {
|
|
99
|
-
if (hashKey(mutation.options.mutationKey) !== hashKey(mutationKey)) {
|
|
100
|
-
return false;
|
|
101
|
-
}
|
|
102
|
-
} else if (!partialMatchKey(mutation.options.mutationKey, mutationKey)) {
|
|
103
|
-
return false;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
if (status && mutation.state.status !== status) {
|
|
107
|
-
return false;
|
|
108
|
-
}
|
|
109
|
-
if (predicate && !predicate(mutation)) {
|
|
110
|
-
return false;
|
|
111
|
-
}
|
|
112
|
-
return true;
|
|
113
|
-
}
|
|
114
|
-
function hashQueryKeyByOptions(queryKey, options) {
|
|
115
|
-
const hashFn = (options == null ? void 0 : options.queryKeyHashFn) || hashKey;
|
|
116
|
-
return hashFn(queryKey);
|
|
117
|
-
}
|
|
118
|
-
function hashKey(queryKey) {
|
|
119
|
-
return JSON.stringify(
|
|
120
|
-
queryKey,
|
|
121
|
-
(_, val) => isPlainObject(val) ? Object.keys(val).sort().reduce((result, key) => {
|
|
122
|
-
result[key] = val[key];
|
|
123
|
-
return result;
|
|
124
|
-
}, {}) : val
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
function partialMatchKey(a, b) {
|
|
128
|
-
if (a === b) {
|
|
129
|
-
return true;
|
|
130
|
-
}
|
|
131
|
-
if (typeof a !== typeof b) {
|
|
132
|
-
return false;
|
|
133
|
-
}
|
|
134
|
-
if (a && b && typeof a === "object" && typeof b === "object") {
|
|
135
|
-
return !Object.keys(b).some((key) => !partialMatchKey(a[key], b[key]));
|
|
136
|
-
}
|
|
137
|
-
return false;
|
|
138
|
-
}
|
|
139
|
-
function replaceEqualDeep(a, b) {
|
|
140
|
-
if (a === b) {
|
|
141
|
-
return a;
|
|
142
|
-
}
|
|
143
|
-
const array = isPlainArray(a) && isPlainArray(b);
|
|
144
|
-
if (array || isPlainObject(a) && isPlainObject(b)) {
|
|
145
|
-
const aItems = array ? a : Object.keys(a);
|
|
146
|
-
const aSize = aItems.length;
|
|
147
|
-
const bItems = array ? b : Object.keys(b);
|
|
148
|
-
const bSize = bItems.length;
|
|
149
|
-
const copy = array ? [] : {};
|
|
150
|
-
let equalItems = 0;
|
|
151
|
-
for (let i = 0; i < bSize; i++) {
|
|
152
|
-
const key = array ? i : bItems[i];
|
|
153
|
-
if ((!array && aItems.includes(key) || array) && a[key] === void 0 && b[key] === void 0) {
|
|
154
|
-
copy[key] = void 0;
|
|
155
|
-
equalItems++;
|
|
156
|
-
} else {
|
|
157
|
-
copy[key] = replaceEqualDeep(a[key], b[key]);
|
|
158
|
-
if (copy[key] === a[key] && a[key] !== void 0) {
|
|
159
|
-
equalItems++;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
return aSize === bSize && equalItems === aSize ? a : copy;
|
|
164
|
-
}
|
|
165
|
-
return b;
|
|
166
|
-
}
|
|
167
|
-
function shallowEqualObjects(a, b) {
|
|
168
|
-
if (!b || Object.keys(a).length !== Object.keys(b).length) {
|
|
169
|
-
return false;
|
|
170
|
-
}
|
|
171
|
-
for (const key in a) {
|
|
172
|
-
if (a[key] !== b[key]) {
|
|
173
|
-
return false;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
return true;
|
|
177
|
-
}
|
|
178
|
-
function isPlainArray(value) {
|
|
179
|
-
return Array.isArray(value) && value.length === Object.keys(value).length;
|
|
180
|
-
}
|
|
181
|
-
function isPlainObject(o) {
|
|
182
|
-
if (!hasObjectPrototype(o)) {
|
|
183
|
-
return false;
|
|
184
|
-
}
|
|
185
|
-
const ctor = o.constructor;
|
|
186
|
-
if (ctor === void 0) {
|
|
187
|
-
return true;
|
|
188
|
-
}
|
|
189
|
-
const prot = ctor.prototype;
|
|
190
|
-
if (!hasObjectPrototype(prot)) {
|
|
191
|
-
return false;
|
|
192
|
-
}
|
|
193
|
-
if (!prot.hasOwnProperty("isPrototypeOf")) {
|
|
194
|
-
return false;
|
|
195
|
-
}
|
|
196
|
-
if (Object.getPrototypeOf(o) !== Object.prototype) {
|
|
197
|
-
return false;
|
|
198
|
-
}
|
|
199
|
-
return true;
|
|
200
|
-
}
|
|
201
|
-
function hasObjectPrototype(o) {
|
|
202
|
-
return Object.prototype.toString.call(o) === "[object Object]";
|
|
203
|
-
}
|
|
204
|
-
function sleep(ms) {
|
|
205
|
-
return new Promise((resolve) => {
|
|
206
|
-
setTimeout(resolve, ms);
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
function replaceData(prevData, data, options) {
|
|
210
|
-
if (typeof options.structuralSharing === "function") {
|
|
211
|
-
return options.structuralSharing(prevData, data);
|
|
212
|
-
} else if (options.structuralSharing !== false) {
|
|
213
|
-
return replaceEqualDeep(prevData, data);
|
|
214
|
-
}
|
|
215
|
-
return data;
|
|
216
|
-
}
|
|
217
|
-
function addToEnd(items, item, max = 0) {
|
|
218
|
-
const newItems = [...items, item];
|
|
219
|
-
return max && newItems.length > max ? newItems.slice(1) : newItems;
|
|
220
|
-
}
|
|
221
|
-
function addToStart(items, item, max = 0) {
|
|
222
|
-
const newItems = [item, ...items];
|
|
223
|
-
return max && newItems.length > max ? newItems.slice(0, -1) : newItems;
|
|
224
|
-
}
|
|
225
|
-
var skipToken = Symbol();
|
|
226
|
-
var ensureQueryFn = (options, fetchOptions) => {
|
|
227
|
-
if (process.env.NODE_ENV !== "production") {
|
|
228
|
-
if (options.queryFn === skipToken) {
|
|
229
|
-
console.error(
|
|
230
|
-
`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${options.queryHash}'`
|
|
231
|
-
);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
if (!options.queryFn && (fetchOptions == null ? void 0 : fetchOptions.initialPromise)) {
|
|
235
|
-
return () => fetchOptions.initialPromise;
|
|
236
|
-
}
|
|
237
|
-
if (!options.queryFn || options.queryFn === skipToken) {
|
|
238
|
-
return () => Promise.reject(new Error(`Missing queryFn: '${options.queryHash}'`));
|
|
239
|
-
}
|
|
240
|
-
return options.queryFn;
|
|
241
|
-
};
|
|
242
|
-
var FocusManager = (_a = class extends Subscribable {
|
|
243
|
-
constructor() {
|
|
244
|
-
super();
|
|
245
|
-
__privateAdd(this, _focused);
|
|
246
|
-
__privateAdd(this, _cleanup);
|
|
247
|
-
__privateAdd(this, _setup);
|
|
248
|
-
__privateSet(this, _setup, (onFocus) => {
|
|
249
|
-
if (!isServer && window.addEventListener) {
|
|
250
|
-
const listener = () => onFocus();
|
|
251
|
-
window.addEventListener("visibilitychange", listener, false);
|
|
252
|
-
return () => {
|
|
253
|
-
window.removeEventListener("visibilitychange", listener);
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
|
-
return;
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
onSubscribe() {
|
|
260
|
-
if (!__privateGet(this, _cleanup)) {
|
|
261
|
-
this.setEventListener(__privateGet(this, _setup));
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
onUnsubscribe() {
|
|
265
|
-
var _a2;
|
|
266
|
-
if (!this.hasListeners()) {
|
|
267
|
-
(_a2 = __privateGet(this, _cleanup)) == null ? void 0 : _a2.call(this);
|
|
268
|
-
__privateSet(this, _cleanup, void 0);
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
setEventListener(setup) {
|
|
272
|
-
var _a2;
|
|
273
|
-
__privateSet(this, _setup, setup);
|
|
274
|
-
(_a2 = __privateGet(this, _cleanup)) == null ? void 0 : _a2.call(this);
|
|
275
|
-
__privateSet(this, _cleanup, setup((focused) => {
|
|
276
|
-
if (typeof focused === "boolean") {
|
|
277
|
-
this.setFocused(focused);
|
|
278
|
-
} else {
|
|
279
|
-
this.onFocus();
|
|
280
|
-
}
|
|
281
|
-
}));
|
|
282
|
-
}
|
|
283
|
-
setFocused(focused) {
|
|
284
|
-
const changed = __privateGet(this, _focused) !== focused;
|
|
285
|
-
if (changed) {
|
|
286
|
-
__privateSet(this, _focused, focused);
|
|
287
|
-
this.onFocus();
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
onFocus() {
|
|
291
|
-
const isFocused = this.isFocused();
|
|
292
|
-
this.listeners.forEach((listener) => {
|
|
293
|
-
listener(isFocused);
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
isFocused() {
|
|
297
|
-
var _a2;
|
|
298
|
-
if (typeof __privateGet(this, _focused) === "boolean") {
|
|
299
|
-
return __privateGet(this, _focused);
|
|
300
|
-
}
|
|
301
|
-
return ((_a2 = globalThis.document) == null ? void 0 : _a2.visibilityState) !== "hidden";
|
|
302
|
-
}
|
|
303
|
-
}, _focused = new WeakMap(), _cleanup = new WeakMap(), _setup = new WeakMap(), _a);
|
|
304
|
-
var focusManager = new FocusManager();
|
|
305
|
-
var OnlineManager = (_b = class extends Subscribable {
|
|
306
|
-
constructor() {
|
|
307
|
-
super();
|
|
308
|
-
__privateAdd(this, _online, true);
|
|
309
|
-
__privateAdd(this, _cleanup2);
|
|
310
|
-
__privateAdd(this, _setup2);
|
|
311
|
-
__privateSet(this, _setup2, (onOnline) => {
|
|
312
|
-
if (!isServer && window.addEventListener) {
|
|
313
|
-
const onlineListener = () => onOnline(true);
|
|
314
|
-
const offlineListener = () => onOnline(false);
|
|
315
|
-
window.addEventListener("online", onlineListener, false);
|
|
316
|
-
window.addEventListener("offline", offlineListener, false);
|
|
317
|
-
return () => {
|
|
318
|
-
window.removeEventListener("online", onlineListener);
|
|
319
|
-
window.removeEventListener("offline", offlineListener);
|
|
320
|
-
};
|
|
321
|
-
}
|
|
322
|
-
return;
|
|
323
|
-
});
|
|
324
|
-
}
|
|
325
|
-
onSubscribe() {
|
|
326
|
-
if (!__privateGet(this, _cleanup2)) {
|
|
327
|
-
this.setEventListener(__privateGet(this, _setup2));
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
onUnsubscribe() {
|
|
331
|
-
var _a2;
|
|
332
|
-
if (!this.hasListeners()) {
|
|
333
|
-
(_a2 = __privateGet(this, _cleanup2)) == null ? void 0 : _a2.call(this);
|
|
334
|
-
__privateSet(this, _cleanup2, void 0);
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
setEventListener(setup) {
|
|
338
|
-
var _a2;
|
|
339
|
-
__privateSet(this, _setup2, setup);
|
|
340
|
-
(_a2 = __privateGet(this, _cleanup2)) == null ? void 0 : _a2.call(this);
|
|
341
|
-
__privateSet(this, _cleanup2, setup(this.setOnline.bind(this)));
|
|
342
|
-
}
|
|
343
|
-
setOnline(online) {
|
|
344
|
-
const changed = __privateGet(this, _online) !== online;
|
|
345
|
-
if (changed) {
|
|
346
|
-
__privateSet(this, _online, online);
|
|
347
|
-
this.listeners.forEach((listener) => {
|
|
348
|
-
listener(online);
|
|
349
|
-
});
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
isOnline() {
|
|
353
|
-
return __privateGet(this, _online);
|
|
354
|
-
}
|
|
355
|
-
}, _online = new WeakMap(), _cleanup2 = new WeakMap(), _setup2 = new WeakMap(), _b);
|
|
356
|
-
var onlineManager = new OnlineManager();
|
|
357
|
-
function defaultRetryDelay(failureCount) {
|
|
358
|
-
return Math.min(1e3 * 2 ** failureCount, 3e4);
|
|
359
|
-
}
|
|
360
|
-
function canFetch(networkMode) {
|
|
361
|
-
return (networkMode ?? "online") === "online" ? onlineManager.isOnline() : true;
|
|
362
|
-
}
|
|
363
|
-
var CancelledError = class {
|
|
364
|
-
constructor(options) {
|
|
365
|
-
this.revert = options == null ? void 0 : options.revert;
|
|
366
|
-
this.silent = options == null ? void 0 : options.silent;
|
|
367
|
-
}
|
|
368
|
-
};
|
|
369
|
-
function isCancelledError(value) {
|
|
370
|
-
return value instanceof CancelledError;
|
|
371
|
-
}
|
|
372
|
-
function createRetryer(config) {
|
|
373
|
-
let isRetryCancelled = false;
|
|
374
|
-
let failureCount = 0;
|
|
375
|
-
let isResolved = false;
|
|
376
|
-
let continueFn;
|
|
377
|
-
let promiseResolve;
|
|
378
|
-
let promiseReject;
|
|
379
|
-
const promise = new Promise((outerResolve, outerReject) => {
|
|
380
|
-
promiseResolve = outerResolve;
|
|
381
|
-
promiseReject = outerReject;
|
|
382
|
-
});
|
|
383
|
-
const cancel = (cancelOptions) => {
|
|
384
|
-
var _a2;
|
|
385
|
-
if (!isResolved) {
|
|
386
|
-
reject(new CancelledError(cancelOptions));
|
|
387
|
-
(_a2 = config.abort) == null ? void 0 : _a2.call(config);
|
|
388
|
-
}
|
|
389
|
-
};
|
|
390
|
-
const cancelRetry = () => {
|
|
391
|
-
isRetryCancelled = true;
|
|
392
|
-
};
|
|
393
|
-
const continueRetry = () => {
|
|
394
|
-
isRetryCancelled = false;
|
|
395
|
-
};
|
|
396
|
-
const canContinue = () => focusManager.isFocused() && (config.networkMode === "always" || onlineManager.isOnline()) && config.canRun();
|
|
397
|
-
const canStart = () => canFetch(config.networkMode) && config.canRun();
|
|
398
|
-
const resolve = (value) => {
|
|
399
|
-
var _a2;
|
|
400
|
-
if (!isResolved) {
|
|
401
|
-
isResolved = true;
|
|
402
|
-
(_a2 = config.onSuccess) == null ? void 0 : _a2.call(config, value);
|
|
403
|
-
continueFn == null ? void 0 : continueFn();
|
|
404
|
-
promiseResolve(value);
|
|
405
|
-
}
|
|
406
|
-
};
|
|
407
|
-
const reject = (value) => {
|
|
408
|
-
var _a2;
|
|
409
|
-
if (!isResolved) {
|
|
410
|
-
isResolved = true;
|
|
411
|
-
(_a2 = config.onError) == null ? void 0 : _a2.call(config, value);
|
|
412
|
-
continueFn == null ? void 0 : continueFn();
|
|
413
|
-
promiseReject(value);
|
|
414
|
-
}
|
|
415
|
-
};
|
|
416
|
-
const pause = () => {
|
|
417
|
-
return new Promise((continueResolve) => {
|
|
418
|
-
var _a2;
|
|
419
|
-
continueFn = (value) => {
|
|
420
|
-
if (isResolved || canContinue()) {
|
|
421
|
-
continueResolve(value);
|
|
422
|
-
}
|
|
423
|
-
};
|
|
424
|
-
(_a2 = config.onPause) == null ? void 0 : _a2.call(config);
|
|
425
|
-
}).then(() => {
|
|
426
|
-
var _a2;
|
|
427
|
-
continueFn = void 0;
|
|
428
|
-
if (!isResolved) {
|
|
429
|
-
(_a2 = config.onContinue) == null ? void 0 : _a2.call(config);
|
|
430
|
-
}
|
|
431
|
-
});
|
|
432
|
-
};
|
|
433
|
-
const run = () => {
|
|
434
|
-
if (isResolved) {
|
|
435
|
-
return;
|
|
436
|
-
}
|
|
437
|
-
let promiseOrValue;
|
|
438
|
-
const initialPromise = failureCount === 0 ? config.initialPromise : void 0;
|
|
439
|
-
try {
|
|
440
|
-
promiseOrValue = initialPromise ?? config.fn();
|
|
441
|
-
} catch (error) {
|
|
442
|
-
promiseOrValue = Promise.reject(error);
|
|
443
|
-
}
|
|
444
|
-
Promise.resolve(promiseOrValue).then(resolve).catch((error) => {
|
|
445
|
-
var _a2;
|
|
446
|
-
if (isResolved) {
|
|
447
|
-
return;
|
|
448
|
-
}
|
|
449
|
-
const retry = config.retry ?? (isServer ? 0 : 3);
|
|
450
|
-
const retryDelay = config.retryDelay ?? defaultRetryDelay;
|
|
451
|
-
const delay = typeof retryDelay === "function" ? retryDelay(failureCount, error) : retryDelay;
|
|
452
|
-
const shouldRetry = retry === true || typeof retry === "number" && failureCount < retry || typeof retry === "function" && retry(failureCount, error);
|
|
453
|
-
if (isRetryCancelled || !shouldRetry) {
|
|
454
|
-
reject(error);
|
|
455
|
-
return;
|
|
456
|
-
}
|
|
457
|
-
failureCount++;
|
|
458
|
-
(_a2 = config.onFail) == null ? void 0 : _a2.call(config, failureCount, error);
|
|
459
|
-
sleep(delay).then(() => {
|
|
460
|
-
return canContinue() ? void 0 : pause();
|
|
461
|
-
}).then(() => {
|
|
462
|
-
if (isRetryCancelled) {
|
|
463
|
-
reject(error);
|
|
464
|
-
} else {
|
|
465
|
-
run();
|
|
466
|
-
}
|
|
467
|
-
});
|
|
468
|
-
});
|
|
469
|
-
};
|
|
470
|
-
return {
|
|
471
|
-
promise,
|
|
472
|
-
cancel,
|
|
473
|
-
continue: () => {
|
|
474
|
-
continueFn == null ? void 0 : continueFn();
|
|
475
|
-
return promise;
|
|
476
|
-
},
|
|
477
|
-
cancelRetry,
|
|
478
|
-
continueRetry,
|
|
479
|
-
canStart,
|
|
480
|
-
start: () => {
|
|
481
|
-
if (canStart()) {
|
|
482
|
-
run();
|
|
483
|
-
} else {
|
|
484
|
-
pause().then(run);
|
|
485
|
-
}
|
|
486
|
-
return promise;
|
|
487
|
-
}
|
|
488
|
-
};
|
|
489
|
-
}
|
|
490
|
-
function createNotifyManager() {
|
|
491
|
-
let queue = [];
|
|
492
|
-
let transactions = 0;
|
|
493
|
-
let notifyFn = (callback) => {
|
|
494
|
-
callback();
|
|
495
|
-
};
|
|
496
|
-
let batchNotifyFn = (callback) => {
|
|
497
|
-
callback();
|
|
498
|
-
};
|
|
499
|
-
let scheduleFn = (cb) => setTimeout(cb, 0);
|
|
500
|
-
const setScheduler = (fn) => {
|
|
501
|
-
scheduleFn = fn;
|
|
502
|
-
};
|
|
503
|
-
const batch = (callback) => {
|
|
504
|
-
let result;
|
|
505
|
-
transactions++;
|
|
506
|
-
try {
|
|
507
|
-
result = callback();
|
|
508
|
-
} finally {
|
|
509
|
-
transactions--;
|
|
510
|
-
if (!transactions) {
|
|
511
|
-
flush();
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
return result;
|
|
515
|
-
};
|
|
516
|
-
const schedule = (callback) => {
|
|
517
|
-
if (transactions) {
|
|
518
|
-
queue.push(callback);
|
|
519
|
-
} else {
|
|
520
|
-
scheduleFn(() => {
|
|
521
|
-
notifyFn(callback);
|
|
522
|
-
});
|
|
523
|
-
}
|
|
524
|
-
};
|
|
525
|
-
const batchCalls = (callback) => {
|
|
526
|
-
return (...args) => {
|
|
527
|
-
schedule(() => {
|
|
528
|
-
callback(...args);
|
|
529
|
-
});
|
|
530
|
-
};
|
|
531
|
-
};
|
|
532
|
-
const flush = () => {
|
|
533
|
-
const originalQueue = queue;
|
|
534
|
-
queue = [];
|
|
535
|
-
if (originalQueue.length) {
|
|
536
|
-
scheduleFn(() => {
|
|
537
|
-
batchNotifyFn(() => {
|
|
538
|
-
originalQueue.forEach((callback) => {
|
|
539
|
-
notifyFn(callback);
|
|
540
|
-
});
|
|
541
|
-
});
|
|
542
|
-
});
|
|
543
|
-
}
|
|
544
|
-
};
|
|
545
|
-
const setNotifyFunction = (fn) => {
|
|
546
|
-
notifyFn = fn;
|
|
547
|
-
};
|
|
548
|
-
const setBatchNotifyFunction = (fn) => {
|
|
549
|
-
batchNotifyFn = fn;
|
|
550
|
-
};
|
|
551
|
-
return {
|
|
552
|
-
batch,
|
|
553
|
-
batchCalls,
|
|
554
|
-
schedule,
|
|
555
|
-
setNotifyFunction,
|
|
556
|
-
setBatchNotifyFunction,
|
|
557
|
-
setScheduler
|
|
558
|
-
};
|
|
559
|
-
}
|
|
560
|
-
var notifyManager = createNotifyManager();
|
|
561
|
-
var Removable = (_c = class {
|
|
562
|
-
constructor() {
|
|
563
|
-
__privateAdd(this, _gcTimeout);
|
|
564
|
-
}
|
|
565
|
-
destroy() {
|
|
566
|
-
this.clearGcTimeout();
|
|
567
|
-
}
|
|
568
|
-
scheduleGc() {
|
|
569
|
-
this.clearGcTimeout();
|
|
570
|
-
if (isValidTimeout(this.gcTime)) {
|
|
571
|
-
__privateSet(this, _gcTimeout, setTimeout(() => {
|
|
572
|
-
this.optionalRemove();
|
|
573
|
-
}, this.gcTime));
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
updateGcTime(newGcTime) {
|
|
577
|
-
this.gcTime = Math.max(
|
|
578
|
-
this.gcTime || 0,
|
|
579
|
-
newGcTime ?? (isServer ? Infinity : 5 * 60 * 1e3)
|
|
580
|
-
);
|
|
581
|
-
}
|
|
582
|
-
clearGcTimeout() {
|
|
583
|
-
if (__privateGet(this, _gcTimeout)) {
|
|
584
|
-
clearTimeout(__privateGet(this, _gcTimeout));
|
|
585
|
-
__privateSet(this, _gcTimeout, void 0);
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
}, _gcTimeout = new WeakMap(), _c);
|
|
589
|
-
var Query = (_d = class extends Removable {
|
|
590
|
-
constructor(config) {
|
|
591
|
-
super();
|
|
592
|
-
__privateAdd(this, _Query_instances);
|
|
593
|
-
__privateAdd(this, _initialState);
|
|
594
|
-
__privateAdd(this, _revertState);
|
|
595
|
-
__privateAdd(this, _cache);
|
|
596
|
-
__privateAdd(this, _retryer);
|
|
597
|
-
__privateAdd(this, _defaultOptions);
|
|
598
|
-
__privateAdd(this, _abortSignalConsumed);
|
|
599
|
-
__privateSet(this, _abortSignalConsumed, false);
|
|
600
|
-
__privateSet(this, _defaultOptions, config.defaultOptions);
|
|
601
|
-
this.setOptions(config.options);
|
|
602
|
-
this.observers = [];
|
|
603
|
-
__privateSet(this, _cache, config.cache);
|
|
604
|
-
this.queryKey = config.queryKey;
|
|
605
|
-
this.queryHash = config.queryHash;
|
|
606
|
-
__privateSet(this, _initialState, config.state || getDefaultState(this.options));
|
|
607
|
-
this.state = __privateGet(this, _initialState);
|
|
608
|
-
this.scheduleGc();
|
|
609
|
-
}
|
|
610
|
-
get meta() {
|
|
611
|
-
return this.options.meta;
|
|
612
|
-
}
|
|
613
|
-
get promise() {
|
|
614
|
-
var _a2;
|
|
615
|
-
return (_a2 = __privateGet(this, _retryer)) == null ? void 0 : _a2.promise;
|
|
616
|
-
}
|
|
617
|
-
setOptions(options) {
|
|
618
|
-
this.options = { ...__privateGet(this, _defaultOptions), ...options };
|
|
619
|
-
this.updateGcTime(this.options.gcTime);
|
|
620
|
-
}
|
|
621
|
-
optionalRemove() {
|
|
622
|
-
if (!this.observers.length && this.state.fetchStatus === "idle") {
|
|
623
|
-
__privateGet(this, _cache).remove(this);
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
setData(newData, options) {
|
|
627
|
-
const data = replaceData(this.state.data, newData, this.options);
|
|
628
|
-
__privateMethod(this, _Query_instances, dispatch_fn).call(this, {
|
|
629
|
-
data,
|
|
630
|
-
type: "success",
|
|
631
|
-
dataUpdatedAt: options == null ? void 0 : options.updatedAt,
|
|
632
|
-
manual: options == null ? void 0 : options.manual
|
|
633
|
-
});
|
|
634
|
-
return data;
|
|
635
|
-
}
|
|
636
|
-
setState(state, setStateOptions) {
|
|
637
|
-
__privateMethod(this, _Query_instances, dispatch_fn).call(this, { type: "setState", state, setStateOptions });
|
|
638
|
-
}
|
|
639
|
-
cancel(options) {
|
|
640
|
-
var _a2, _b2;
|
|
641
|
-
const promise = (_a2 = __privateGet(this, _retryer)) == null ? void 0 : _a2.promise;
|
|
642
|
-
(_b2 = __privateGet(this, _retryer)) == null ? void 0 : _b2.cancel(options);
|
|
643
|
-
return promise ? promise.then(noop$1).catch(noop$1) : Promise.resolve();
|
|
644
|
-
}
|
|
645
|
-
destroy() {
|
|
646
|
-
super.destroy();
|
|
647
|
-
this.cancel({ silent: true });
|
|
648
|
-
}
|
|
649
|
-
reset() {
|
|
650
|
-
this.destroy();
|
|
651
|
-
this.setState(__privateGet(this, _initialState));
|
|
652
|
-
}
|
|
653
|
-
isActive() {
|
|
654
|
-
return this.observers.some(
|
|
655
|
-
(observer) => resolveEnabled(observer.options.enabled, this) !== false
|
|
656
|
-
);
|
|
657
|
-
}
|
|
658
|
-
isDisabled() {
|
|
659
|
-
return this.getObserversCount() > 0 && !this.isActive();
|
|
660
|
-
}
|
|
661
|
-
isStale() {
|
|
662
|
-
if (this.state.isInvalidated) {
|
|
663
|
-
return true;
|
|
664
|
-
}
|
|
665
|
-
if (this.getObserversCount() > 0) {
|
|
666
|
-
return this.observers.some(
|
|
667
|
-
(observer) => observer.getCurrentResult().isStale
|
|
668
|
-
);
|
|
669
|
-
}
|
|
670
|
-
return this.state.data === void 0;
|
|
671
|
-
}
|
|
672
|
-
isStaleByTime(staleTime = 0) {
|
|
673
|
-
return this.state.isInvalidated || this.state.data === void 0 || !timeUntilStale(this.state.dataUpdatedAt, staleTime);
|
|
674
|
-
}
|
|
675
|
-
onFocus() {
|
|
676
|
-
var _a2;
|
|
677
|
-
const observer = this.observers.find((x) => x.shouldFetchOnWindowFocus());
|
|
678
|
-
observer == null ? void 0 : observer.refetch({ cancelRefetch: false });
|
|
679
|
-
(_a2 = __privateGet(this, _retryer)) == null ? void 0 : _a2.continue();
|
|
680
|
-
}
|
|
681
|
-
onOnline() {
|
|
682
|
-
var _a2;
|
|
683
|
-
const observer = this.observers.find((x) => x.shouldFetchOnReconnect());
|
|
684
|
-
observer == null ? void 0 : observer.refetch({ cancelRefetch: false });
|
|
685
|
-
(_a2 = __privateGet(this, _retryer)) == null ? void 0 : _a2.continue();
|
|
686
|
-
}
|
|
687
|
-
addObserver(observer) {
|
|
688
|
-
if (!this.observers.includes(observer)) {
|
|
689
|
-
this.observers.push(observer);
|
|
690
|
-
this.clearGcTimeout();
|
|
691
|
-
__privateGet(this, _cache).notify({ type: "observerAdded", query: this, observer });
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
removeObserver(observer) {
|
|
695
|
-
if (this.observers.includes(observer)) {
|
|
696
|
-
this.observers = this.observers.filter((x) => x !== observer);
|
|
697
|
-
if (!this.observers.length) {
|
|
698
|
-
if (__privateGet(this, _retryer)) {
|
|
699
|
-
if (__privateGet(this, _abortSignalConsumed)) {
|
|
700
|
-
__privateGet(this, _retryer).cancel({ revert: true });
|
|
701
|
-
} else {
|
|
702
|
-
__privateGet(this, _retryer).cancelRetry();
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
this.scheduleGc();
|
|
706
|
-
}
|
|
707
|
-
__privateGet(this, _cache).notify({ type: "observerRemoved", query: this, observer });
|
|
708
|
-
}
|
|
709
|
-
}
|
|
710
|
-
getObserversCount() {
|
|
711
|
-
return this.observers.length;
|
|
712
|
-
}
|
|
713
|
-
invalidate() {
|
|
714
|
-
if (!this.state.isInvalidated) {
|
|
715
|
-
__privateMethod(this, _Query_instances, dispatch_fn).call(this, { type: "invalidate" });
|
|
716
|
-
}
|
|
717
|
-
}
|
|
718
|
-
fetch(options, fetchOptions) {
|
|
719
|
-
var _a2, _b2, _c2;
|
|
720
|
-
if (this.state.fetchStatus !== "idle") {
|
|
721
|
-
if (this.state.data !== void 0 && (fetchOptions == null ? void 0 : fetchOptions.cancelRefetch)) {
|
|
722
|
-
this.cancel({ silent: true });
|
|
723
|
-
} else if (__privateGet(this, _retryer)) {
|
|
724
|
-
__privateGet(this, _retryer).continueRetry();
|
|
725
|
-
return __privateGet(this, _retryer).promise;
|
|
726
|
-
}
|
|
727
|
-
}
|
|
728
|
-
if (options) {
|
|
729
|
-
this.setOptions(options);
|
|
730
|
-
}
|
|
731
|
-
if (!this.options.queryFn) {
|
|
732
|
-
const observer = this.observers.find((x) => x.options.queryFn);
|
|
733
|
-
if (observer) {
|
|
734
|
-
this.setOptions(observer.options);
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
if (process.env.NODE_ENV !== "production") {
|
|
738
|
-
if (!Array.isArray(this.options.queryKey)) {
|
|
739
|
-
console.error(
|
|
740
|
-
`As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']`
|
|
741
|
-
);
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
const abortController = new AbortController();
|
|
745
|
-
const addSignalProperty = (object) => {
|
|
746
|
-
Object.defineProperty(object, "signal", {
|
|
747
|
-
enumerable: true,
|
|
748
|
-
get: () => {
|
|
749
|
-
__privateSet(this, _abortSignalConsumed, true);
|
|
750
|
-
return abortController.signal;
|
|
751
|
-
}
|
|
752
|
-
});
|
|
753
|
-
};
|
|
754
|
-
const fetchFn = () => {
|
|
755
|
-
const queryFn = ensureQueryFn(this.options, fetchOptions);
|
|
756
|
-
const queryFnContext = {
|
|
757
|
-
queryKey: this.queryKey,
|
|
758
|
-
meta: this.meta
|
|
759
|
-
};
|
|
760
|
-
addSignalProperty(queryFnContext);
|
|
761
|
-
__privateSet(this, _abortSignalConsumed, false);
|
|
762
|
-
if (this.options.persister) {
|
|
763
|
-
return this.options.persister(
|
|
764
|
-
queryFn,
|
|
765
|
-
queryFnContext,
|
|
766
|
-
this
|
|
767
|
-
);
|
|
768
|
-
}
|
|
769
|
-
return queryFn(queryFnContext);
|
|
770
|
-
};
|
|
771
|
-
const context = {
|
|
772
|
-
fetchOptions,
|
|
773
|
-
options: this.options,
|
|
774
|
-
queryKey: this.queryKey,
|
|
775
|
-
state: this.state,
|
|
776
|
-
fetchFn
|
|
777
|
-
};
|
|
778
|
-
addSignalProperty(context);
|
|
779
|
-
(_a2 = this.options.behavior) == null ? void 0 : _a2.onFetch(
|
|
780
|
-
context,
|
|
781
|
-
this
|
|
782
|
-
);
|
|
783
|
-
__privateSet(this, _revertState, this.state);
|
|
784
|
-
if (this.state.fetchStatus === "idle" || this.state.fetchMeta !== ((_b2 = context.fetchOptions) == null ? void 0 : _b2.meta)) {
|
|
785
|
-
__privateMethod(this, _Query_instances, dispatch_fn).call(this, { type: "fetch", meta: (_c2 = context.fetchOptions) == null ? void 0 : _c2.meta });
|
|
786
|
-
}
|
|
787
|
-
const onError = (error) => {
|
|
788
|
-
var _a3, _b3, _c3, _d2;
|
|
789
|
-
if (!(isCancelledError(error) && error.silent)) {
|
|
790
|
-
__privateMethod(this, _Query_instances, dispatch_fn).call(this, {
|
|
791
|
-
type: "error",
|
|
792
|
-
error
|
|
793
|
-
});
|
|
794
|
-
}
|
|
795
|
-
if (!isCancelledError(error)) {
|
|
796
|
-
(_b3 = (_a3 = __privateGet(this, _cache).config).onError) == null ? void 0 : _b3.call(
|
|
797
|
-
_a3,
|
|
798
|
-
error,
|
|
799
|
-
this
|
|
800
|
-
);
|
|
801
|
-
(_d2 = (_c3 = __privateGet(this, _cache).config).onSettled) == null ? void 0 : _d2.call(
|
|
802
|
-
_c3,
|
|
803
|
-
this.state.data,
|
|
804
|
-
error,
|
|
805
|
-
this
|
|
806
|
-
);
|
|
807
|
-
}
|
|
808
|
-
if (!this.isFetchingOptimistic) {
|
|
809
|
-
this.scheduleGc();
|
|
810
|
-
}
|
|
811
|
-
this.isFetchingOptimistic = false;
|
|
812
|
-
};
|
|
813
|
-
__privateSet(this, _retryer, createRetryer({
|
|
814
|
-
initialPromise: fetchOptions == null ? void 0 : fetchOptions.initialPromise,
|
|
815
|
-
fn: context.fetchFn,
|
|
816
|
-
abort: abortController.abort.bind(abortController),
|
|
817
|
-
onSuccess: (data) => {
|
|
818
|
-
var _a3, _b3, _c3, _d2;
|
|
819
|
-
if (data === void 0) {
|
|
820
|
-
if (process.env.NODE_ENV !== "production") {
|
|
821
|
-
console.error(
|
|
822
|
-
`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`
|
|
823
|
-
);
|
|
824
|
-
}
|
|
825
|
-
onError(new Error(`${this.queryHash} data is undefined`));
|
|
826
|
-
return;
|
|
827
|
-
}
|
|
828
|
-
this.setData(data);
|
|
829
|
-
(_b3 = (_a3 = __privateGet(this, _cache).config).onSuccess) == null ? void 0 : _b3.call(_a3, data, this);
|
|
830
|
-
(_d2 = (_c3 = __privateGet(this, _cache).config).onSettled) == null ? void 0 : _d2.call(
|
|
831
|
-
_c3,
|
|
832
|
-
data,
|
|
833
|
-
this.state.error,
|
|
834
|
-
this
|
|
835
|
-
);
|
|
836
|
-
if (!this.isFetchingOptimistic) {
|
|
837
|
-
this.scheduleGc();
|
|
838
|
-
}
|
|
839
|
-
this.isFetchingOptimistic = false;
|
|
840
|
-
},
|
|
841
|
-
onError,
|
|
842
|
-
onFail: (failureCount, error) => {
|
|
843
|
-
__privateMethod(this, _Query_instances, dispatch_fn).call(this, { type: "failed", failureCount, error });
|
|
844
|
-
},
|
|
845
|
-
onPause: () => {
|
|
846
|
-
__privateMethod(this, _Query_instances, dispatch_fn).call(this, { type: "pause" });
|
|
847
|
-
},
|
|
848
|
-
onContinue: () => {
|
|
849
|
-
__privateMethod(this, _Query_instances, dispatch_fn).call(this, { type: "continue" });
|
|
850
|
-
},
|
|
851
|
-
retry: context.options.retry,
|
|
852
|
-
retryDelay: context.options.retryDelay,
|
|
853
|
-
networkMode: context.options.networkMode,
|
|
854
|
-
canRun: () => true
|
|
855
|
-
}));
|
|
856
|
-
return __privateGet(this, _retryer).start();
|
|
857
|
-
}
|
|
858
|
-
}, _initialState = new WeakMap(), _revertState = new WeakMap(), _cache = new WeakMap(), _retryer = new WeakMap(), _defaultOptions = new WeakMap(), _abortSignalConsumed = new WeakMap(), _Query_instances = new WeakSet(), dispatch_fn = function(action) {
|
|
859
|
-
const reducer = (state) => {
|
|
860
|
-
switch (action.type) {
|
|
861
|
-
case "failed":
|
|
862
|
-
return {
|
|
863
|
-
...state,
|
|
864
|
-
fetchFailureCount: action.failureCount,
|
|
865
|
-
fetchFailureReason: action.error
|
|
866
|
-
};
|
|
867
|
-
case "pause":
|
|
868
|
-
return {
|
|
869
|
-
...state,
|
|
870
|
-
fetchStatus: "paused"
|
|
871
|
-
};
|
|
872
|
-
case "continue":
|
|
873
|
-
return {
|
|
874
|
-
...state,
|
|
875
|
-
fetchStatus: "fetching"
|
|
876
|
-
};
|
|
877
|
-
case "fetch":
|
|
878
|
-
return {
|
|
879
|
-
...state,
|
|
880
|
-
...fetchState(state.data, this.options),
|
|
881
|
-
fetchMeta: action.meta ?? null
|
|
882
|
-
};
|
|
883
|
-
case "success":
|
|
884
|
-
return {
|
|
885
|
-
...state,
|
|
886
|
-
data: action.data,
|
|
887
|
-
dataUpdateCount: state.dataUpdateCount + 1,
|
|
888
|
-
dataUpdatedAt: action.dataUpdatedAt ?? Date.now(),
|
|
889
|
-
error: null,
|
|
890
|
-
isInvalidated: false,
|
|
891
|
-
status: "success",
|
|
892
|
-
...!action.manual && {
|
|
893
|
-
fetchStatus: "idle",
|
|
894
|
-
fetchFailureCount: 0,
|
|
895
|
-
fetchFailureReason: null
|
|
896
|
-
}
|
|
897
|
-
};
|
|
898
|
-
case "error":
|
|
899
|
-
const error = action.error;
|
|
900
|
-
if (isCancelledError(error) && error.revert && __privateGet(this, _revertState)) {
|
|
901
|
-
return { ...__privateGet(this, _revertState), fetchStatus: "idle" };
|
|
902
|
-
}
|
|
903
|
-
return {
|
|
904
|
-
...state,
|
|
905
|
-
error,
|
|
906
|
-
errorUpdateCount: state.errorUpdateCount + 1,
|
|
907
|
-
errorUpdatedAt: Date.now(),
|
|
908
|
-
fetchFailureCount: state.fetchFailureCount + 1,
|
|
909
|
-
fetchFailureReason: error,
|
|
910
|
-
fetchStatus: "idle",
|
|
911
|
-
status: "error"
|
|
912
|
-
};
|
|
913
|
-
case "invalidate":
|
|
914
|
-
return {
|
|
915
|
-
...state,
|
|
916
|
-
isInvalidated: true
|
|
917
|
-
};
|
|
918
|
-
case "setState":
|
|
919
|
-
return {
|
|
920
|
-
...state,
|
|
921
|
-
...action.state
|
|
922
|
-
};
|
|
923
|
-
}
|
|
924
|
-
};
|
|
925
|
-
this.state = reducer(this.state);
|
|
926
|
-
notifyManager.batch(() => {
|
|
927
|
-
this.observers.forEach((observer) => {
|
|
928
|
-
observer.onQueryUpdate();
|
|
929
|
-
});
|
|
930
|
-
__privateGet(this, _cache).notify({ query: this, type: "updated", action });
|
|
931
|
-
});
|
|
932
|
-
}, _d);
|
|
933
|
-
function fetchState(data, options) {
|
|
934
|
-
return {
|
|
935
|
-
fetchFailureCount: 0,
|
|
936
|
-
fetchFailureReason: null,
|
|
937
|
-
fetchStatus: canFetch(options.networkMode) ? "fetching" : "paused",
|
|
938
|
-
...data === void 0 && {
|
|
939
|
-
error: null,
|
|
940
|
-
status: "pending"
|
|
941
|
-
}
|
|
942
|
-
};
|
|
943
|
-
}
|
|
944
|
-
function getDefaultState(options) {
|
|
945
|
-
const data = typeof options.initialData === "function" ? options.initialData() : options.initialData;
|
|
946
|
-
const hasData = data !== void 0;
|
|
947
|
-
const initialDataUpdatedAt = hasData ? typeof options.initialDataUpdatedAt === "function" ? options.initialDataUpdatedAt() : options.initialDataUpdatedAt : 0;
|
|
948
|
-
return {
|
|
949
|
-
data,
|
|
950
|
-
dataUpdateCount: 0,
|
|
951
|
-
dataUpdatedAt: hasData ? initialDataUpdatedAt ?? Date.now() : 0,
|
|
952
|
-
error: null,
|
|
953
|
-
errorUpdateCount: 0,
|
|
954
|
-
errorUpdatedAt: 0,
|
|
955
|
-
fetchFailureCount: 0,
|
|
956
|
-
fetchFailureReason: null,
|
|
957
|
-
fetchMeta: null,
|
|
958
|
-
isInvalidated: false,
|
|
959
|
-
status: hasData ? "success" : "pending",
|
|
960
|
-
fetchStatus: "idle"
|
|
961
|
-
};
|
|
962
|
-
}
|
|
963
|
-
var QueryObserver = (_e = class extends Subscribable {
|
|
964
|
-
constructor(client, options) {
|
|
965
|
-
super();
|
|
966
|
-
__privateAdd(this, _QueryObserver_instances);
|
|
967
|
-
__privateAdd(this, _client);
|
|
968
|
-
__privateAdd(this, _currentQuery);
|
|
969
|
-
__privateAdd(this, _currentQueryInitialState);
|
|
970
|
-
__privateAdd(this, _currentResult);
|
|
971
|
-
__privateAdd(this, _currentResultState);
|
|
972
|
-
__privateAdd(this, _currentResultOptions);
|
|
973
|
-
__privateAdd(this, _selectError);
|
|
974
|
-
__privateAdd(this, _selectFn);
|
|
975
|
-
__privateAdd(this, _selectResult);
|
|
976
|
-
// This property keeps track of the last query with defined data.
|
|
977
|
-
// It will be used to pass the previous data and query to the placeholder function between renders.
|
|
978
|
-
__privateAdd(this, _lastQueryWithDefinedData);
|
|
979
|
-
__privateAdd(this, _staleTimeoutId);
|
|
980
|
-
__privateAdd(this, _refetchIntervalId);
|
|
981
|
-
__privateAdd(this, _currentRefetchInterval);
|
|
982
|
-
__privateAdd(this, _trackedProps, /* @__PURE__ */ new Set());
|
|
983
|
-
this.options = options;
|
|
984
|
-
__privateSet(this, _client, client);
|
|
985
|
-
__privateSet(this, _selectError, null);
|
|
986
|
-
this.bindMethods();
|
|
987
|
-
this.setOptions(options);
|
|
988
|
-
}
|
|
989
|
-
bindMethods() {
|
|
990
|
-
this.refetch = this.refetch.bind(this);
|
|
991
|
-
}
|
|
992
|
-
onSubscribe() {
|
|
993
|
-
if (this.listeners.size === 1) {
|
|
994
|
-
__privateGet(this, _currentQuery).addObserver(this);
|
|
995
|
-
if (shouldFetchOnMount(__privateGet(this, _currentQuery), this.options)) {
|
|
996
|
-
__privateMethod(this, _QueryObserver_instances, executeFetch_fn).call(this);
|
|
997
|
-
} else {
|
|
998
|
-
this.updateResult();
|
|
999
|
-
}
|
|
1000
|
-
__privateMethod(this, _QueryObserver_instances, updateTimers_fn).call(this);
|
|
1001
|
-
}
|
|
1002
|
-
}
|
|
1003
|
-
onUnsubscribe() {
|
|
1004
|
-
if (!this.hasListeners()) {
|
|
1005
|
-
this.destroy();
|
|
1006
|
-
}
|
|
1007
|
-
}
|
|
1008
|
-
shouldFetchOnReconnect() {
|
|
1009
|
-
return shouldFetchOn(
|
|
1010
|
-
__privateGet(this, _currentQuery),
|
|
1011
|
-
this.options,
|
|
1012
|
-
this.options.refetchOnReconnect
|
|
1013
|
-
);
|
|
1014
|
-
}
|
|
1015
|
-
shouldFetchOnWindowFocus() {
|
|
1016
|
-
return shouldFetchOn(
|
|
1017
|
-
__privateGet(this, _currentQuery),
|
|
1018
|
-
this.options,
|
|
1019
|
-
this.options.refetchOnWindowFocus
|
|
1020
|
-
);
|
|
1021
|
-
}
|
|
1022
|
-
destroy() {
|
|
1023
|
-
this.listeners = /* @__PURE__ */ new Set();
|
|
1024
|
-
__privateMethod(this, _QueryObserver_instances, clearStaleTimeout_fn).call(this);
|
|
1025
|
-
__privateMethod(this, _QueryObserver_instances, clearRefetchInterval_fn).call(this);
|
|
1026
|
-
__privateGet(this, _currentQuery).removeObserver(this);
|
|
1027
|
-
}
|
|
1028
|
-
setOptions(options, notifyOptions) {
|
|
1029
|
-
const prevOptions = this.options;
|
|
1030
|
-
const prevQuery = __privateGet(this, _currentQuery);
|
|
1031
|
-
this.options = __privateGet(this, _client).defaultQueryOptions(options);
|
|
1032
|
-
if (this.options.enabled !== void 0 && typeof this.options.enabled !== "boolean" && typeof this.options.enabled !== "function" && typeof resolveEnabled(this.options.enabled, __privateGet(this, _currentQuery)) !== "boolean") {
|
|
1033
|
-
throw new Error(
|
|
1034
|
-
"Expected enabled to be a boolean or a callback that returns a boolean"
|
|
1035
|
-
);
|
|
1036
|
-
}
|
|
1037
|
-
__privateMethod(this, _QueryObserver_instances, updateQuery_fn).call(this);
|
|
1038
|
-
__privateGet(this, _currentQuery).setOptions(this.options);
|
|
1039
|
-
if (prevOptions._defaulted && !shallowEqualObjects(this.options, prevOptions)) {
|
|
1040
|
-
__privateGet(this, _client).getQueryCache().notify({
|
|
1041
|
-
type: "observerOptionsUpdated",
|
|
1042
|
-
query: __privateGet(this, _currentQuery),
|
|
1043
|
-
observer: this
|
|
1044
|
-
});
|
|
1045
|
-
}
|
|
1046
|
-
const mounted = this.hasListeners();
|
|
1047
|
-
if (mounted && shouldFetchOptionally(
|
|
1048
|
-
__privateGet(this, _currentQuery),
|
|
1049
|
-
prevQuery,
|
|
1050
|
-
this.options,
|
|
1051
|
-
prevOptions
|
|
1052
|
-
)) {
|
|
1053
|
-
__privateMethod(this, _QueryObserver_instances, executeFetch_fn).call(this);
|
|
1054
|
-
}
|
|
1055
|
-
this.updateResult(notifyOptions);
|
|
1056
|
-
if (mounted && (__privateGet(this, _currentQuery) !== prevQuery || resolveEnabled(this.options.enabled, __privateGet(this, _currentQuery)) !== resolveEnabled(prevOptions.enabled, __privateGet(this, _currentQuery)) || resolveStaleTime(this.options.staleTime, __privateGet(this, _currentQuery)) !== resolveStaleTime(prevOptions.staleTime, __privateGet(this, _currentQuery)))) {
|
|
1057
|
-
__privateMethod(this, _QueryObserver_instances, updateStaleTimeout_fn).call(this);
|
|
1058
|
-
}
|
|
1059
|
-
const nextRefetchInterval = __privateMethod(this, _QueryObserver_instances, computeRefetchInterval_fn).call(this);
|
|
1060
|
-
if (mounted && (__privateGet(this, _currentQuery) !== prevQuery || resolveEnabled(this.options.enabled, __privateGet(this, _currentQuery)) !== resolveEnabled(prevOptions.enabled, __privateGet(this, _currentQuery)) || nextRefetchInterval !== __privateGet(this, _currentRefetchInterval))) {
|
|
1061
|
-
__privateMethod(this, _QueryObserver_instances, updateRefetchInterval_fn).call(this, nextRefetchInterval);
|
|
1062
|
-
}
|
|
1063
|
-
}
|
|
1064
|
-
getOptimisticResult(options) {
|
|
1065
|
-
const query = __privateGet(this, _client).getQueryCache().build(__privateGet(this, _client), options);
|
|
1066
|
-
const result = this.createResult(query, options);
|
|
1067
|
-
if (shouldAssignObserverCurrentProperties(this, result)) {
|
|
1068
|
-
__privateSet(this, _currentResult, result);
|
|
1069
|
-
__privateSet(this, _currentResultOptions, this.options);
|
|
1070
|
-
__privateSet(this, _currentResultState, __privateGet(this, _currentQuery).state);
|
|
1071
|
-
}
|
|
1072
|
-
return result;
|
|
1073
|
-
}
|
|
1074
|
-
getCurrentResult() {
|
|
1075
|
-
return __privateGet(this, _currentResult);
|
|
1076
|
-
}
|
|
1077
|
-
trackResult(result, onPropTracked) {
|
|
1078
|
-
const trackedResult = {};
|
|
1079
|
-
Object.keys(result).forEach((key) => {
|
|
1080
|
-
Object.defineProperty(trackedResult, key, {
|
|
1081
|
-
configurable: false,
|
|
1082
|
-
enumerable: true,
|
|
1083
|
-
get: () => {
|
|
1084
|
-
this.trackProp(key);
|
|
1085
|
-
onPropTracked == null ? void 0 : onPropTracked(key);
|
|
1086
|
-
return result[key];
|
|
1087
|
-
}
|
|
1088
|
-
});
|
|
1089
|
-
});
|
|
1090
|
-
return trackedResult;
|
|
1091
|
-
}
|
|
1092
|
-
trackProp(key) {
|
|
1093
|
-
__privateGet(this, _trackedProps).add(key);
|
|
1094
|
-
}
|
|
1095
|
-
getCurrentQuery() {
|
|
1096
|
-
return __privateGet(this, _currentQuery);
|
|
1097
|
-
}
|
|
1098
|
-
refetch({ ...options } = {}) {
|
|
1099
|
-
return this.fetch({
|
|
1100
|
-
...options
|
|
1101
|
-
});
|
|
1102
|
-
}
|
|
1103
|
-
fetchOptimistic(options) {
|
|
1104
|
-
const defaultedOptions = __privateGet(this, _client).defaultQueryOptions(options);
|
|
1105
|
-
const query = __privateGet(this, _client).getQueryCache().build(__privateGet(this, _client), defaultedOptions);
|
|
1106
|
-
query.isFetchingOptimistic = true;
|
|
1107
|
-
return query.fetch().then(() => this.createResult(query, defaultedOptions));
|
|
1108
|
-
}
|
|
1109
|
-
fetch(fetchOptions) {
|
|
1110
|
-
return __privateMethod(this, _QueryObserver_instances, executeFetch_fn).call(this, {
|
|
1111
|
-
...fetchOptions,
|
|
1112
|
-
cancelRefetch: fetchOptions.cancelRefetch ?? true
|
|
1113
|
-
}).then(() => {
|
|
1114
|
-
this.updateResult();
|
|
1115
|
-
return __privateGet(this, _currentResult);
|
|
1116
|
-
});
|
|
1117
|
-
}
|
|
1118
|
-
createResult(query, options) {
|
|
1119
|
-
var _a2;
|
|
1120
|
-
const prevQuery = __privateGet(this, _currentQuery);
|
|
1121
|
-
const prevOptions = this.options;
|
|
1122
|
-
const prevResult = __privateGet(this, _currentResult);
|
|
1123
|
-
const prevResultState = __privateGet(this, _currentResultState);
|
|
1124
|
-
const prevResultOptions = __privateGet(this, _currentResultOptions);
|
|
1125
|
-
const queryChange = query !== prevQuery;
|
|
1126
|
-
const queryInitialState = queryChange ? query.state : __privateGet(this, _currentQueryInitialState);
|
|
1127
|
-
const { state } = query;
|
|
1128
|
-
let newState = { ...state };
|
|
1129
|
-
let isPlaceholderData = false;
|
|
1130
|
-
let data;
|
|
1131
|
-
if (options._optimisticResults) {
|
|
1132
|
-
const mounted = this.hasListeners();
|
|
1133
|
-
const fetchOnMount = !mounted && shouldFetchOnMount(query, options);
|
|
1134
|
-
const fetchOptionally = mounted && shouldFetchOptionally(query, prevQuery, options, prevOptions);
|
|
1135
|
-
if (fetchOnMount || fetchOptionally) {
|
|
1136
|
-
newState = {
|
|
1137
|
-
...newState,
|
|
1138
|
-
...fetchState(state.data, query.options)
|
|
1139
|
-
};
|
|
1140
|
-
}
|
|
1141
|
-
if (options._optimisticResults === "isRestoring") {
|
|
1142
|
-
newState.fetchStatus = "idle";
|
|
1143
|
-
}
|
|
1144
|
-
}
|
|
1145
|
-
let { error, errorUpdatedAt, status } = newState;
|
|
1146
|
-
if (options.select && newState.data !== void 0) {
|
|
1147
|
-
if (prevResult && newState.data === (prevResultState == null ? void 0 : prevResultState.data) && options.select === __privateGet(this, _selectFn)) {
|
|
1148
|
-
data = __privateGet(this, _selectResult);
|
|
1149
|
-
} else {
|
|
1150
|
-
try {
|
|
1151
|
-
__privateSet(this, _selectFn, options.select);
|
|
1152
|
-
data = options.select(newState.data);
|
|
1153
|
-
data = replaceData(prevResult == null ? void 0 : prevResult.data, data, options);
|
|
1154
|
-
__privateSet(this, _selectResult, data);
|
|
1155
|
-
__privateSet(this, _selectError, null);
|
|
1156
|
-
} catch (selectError) {
|
|
1157
|
-
__privateSet(this, _selectError, selectError);
|
|
1158
|
-
}
|
|
1159
|
-
}
|
|
1160
|
-
} else {
|
|
1161
|
-
data = newState.data;
|
|
1162
|
-
}
|
|
1163
|
-
if (options.placeholderData !== void 0 && data === void 0 && status === "pending") {
|
|
1164
|
-
let placeholderData;
|
|
1165
|
-
if ((prevResult == null ? void 0 : prevResult.isPlaceholderData) && options.placeholderData === (prevResultOptions == null ? void 0 : prevResultOptions.placeholderData)) {
|
|
1166
|
-
placeholderData = prevResult.data;
|
|
1167
|
-
} else {
|
|
1168
|
-
placeholderData = typeof options.placeholderData === "function" ? options.placeholderData(
|
|
1169
|
-
(_a2 = __privateGet(this, _lastQueryWithDefinedData)) == null ? void 0 : _a2.state.data,
|
|
1170
|
-
__privateGet(this, _lastQueryWithDefinedData)
|
|
1171
|
-
) : options.placeholderData;
|
|
1172
|
-
if (options.select && placeholderData !== void 0) {
|
|
1173
|
-
try {
|
|
1174
|
-
placeholderData = options.select(placeholderData);
|
|
1175
|
-
__privateSet(this, _selectError, null);
|
|
1176
|
-
} catch (selectError) {
|
|
1177
|
-
__privateSet(this, _selectError, selectError);
|
|
1178
|
-
}
|
|
1179
|
-
}
|
|
1180
|
-
}
|
|
1181
|
-
if (placeholderData !== void 0) {
|
|
1182
|
-
status = "success";
|
|
1183
|
-
data = replaceData(
|
|
1184
|
-
prevResult == null ? void 0 : prevResult.data,
|
|
1185
|
-
placeholderData,
|
|
1186
|
-
options
|
|
1187
|
-
);
|
|
1188
|
-
isPlaceholderData = true;
|
|
1189
|
-
}
|
|
1190
|
-
}
|
|
1191
|
-
if (__privateGet(this, _selectError)) {
|
|
1192
|
-
error = __privateGet(this, _selectError);
|
|
1193
|
-
data = __privateGet(this, _selectResult);
|
|
1194
|
-
errorUpdatedAt = Date.now();
|
|
1195
|
-
status = "error";
|
|
1196
|
-
}
|
|
1197
|
-
const isFetching = newState.fetchStatus === "fetching";
|
|
1198
|
-
const isPending = status === "pending";
|
|
1199
|
-
const isError = status === "error";
|
|
1200
|
-
const isLoading = isPending && isFetching;
|
|
1201
|
-
const hasData = data !== void 0;
|
|
1202
|
-
const result = {
|
|
1203
|
-
status,
|
|
1204
|
-
fetchStatus: newState.fetchStatus,
|
|
1205
|
-
isPending,
|
|
1206
|
-
isSuccess: status === "success",
|
|
1207
|
-
isError,
|
|
1208
|
-
isInitialLoading: isLoading,
|
|
1209
|
-
isLoading,
|
|
1210
|
-
data,
|
|
1211
|
-
dataUpdatedAt: newState.dataUpdatedAt,
|
|
1212
|
-
error,
|
|
1213
|
-
errorUpdatedAt,
|
|
1214
|
-
failureCount: newState.fetchFailureCount,
|
|
1215
|
-
failureReason: newState.fetchFailureReason,
|
|
1216
|
-
errorUpdateCount: newState.errorUpdateCount,
|
|
1217
|
-
isFetched: newState.dataUpdateCount > 0 || newState.errorUpdateCount > 0,
|
|
1218
|
-
isFetchedAfterMount: newState.dataUpdateCount > queryInitialState.dataUpdateCount || newState.errorUpdateCount > queryInitialState.errorUpdateCount,
|
|
1219
|
-
isFetching,
|
|
1220
|
-
isRefetching: isFetching && !isPending,
|
|
1221
|
-
isLoadingError: isError && !hasData,
|
|
1222
|
-
isPaused: newState.fetchStatus === "paused",
|
|
1223
|
-
isPlaceholderData,
|
|
1224
|
-
isRefetchError: isError && hasData,
|
|
1225
|
-
isStale: isStale(query, options),
|
|
1226
|
-
refetch: this.refetch
|
|
1227
|
-
};
|
|
1228
|
-
return result;
|
|
1229
|
-
}
|
|
1230
|
-
updateResult(notifyOptions) {
|
|
1231
|
-
const prevResult = __privateGet(this, _currentResult);
|
|
1232
|
-
const nextResult = this.createResult(__privateGet(this, _currentQuery), this.options);
|
|
1233
|
-
__privateSet(this, _currentResultState, __privateGet(this, _currentQuery).state);
|
|
1234
|
-
__privateSet(this, _currentResultOptions, this.options);
|
|
1235
|
-
if (__privateGet(this, _currentResultState).data !== void 0) {
|
|
1236
|
-
__privateSet(this, _lastQueryWithDefinedData, __privateGet(this, _currentQuery));
|
|
1237
|
-
}
|
|
1238
|
-
if (shallowEqualObjects(nextResult, prevResult)) {
|
|
1239
|
-
return;
|
|
1240
|
-
}
|
|
1241
|
-
__privateSet(this, _currentResult, nextResult);
|
|
1242
|
-
const defaultNotifyOptions = {};
|
|
1243
|
-
const shouldNotifyListeners = () => {
|
|
1244
|
-
if (!prevResult) {
|
|
1245
|
-
return true;
|
|
1246
|
-
}
|
|
1247
|
-
const { notifyOnChangeProps } = this.options;
|
|
1248
|
-
const notifyOnChangePropsValue = typeof notifyOnChangeProps === "function" ? notifyOnChangeProps() : notifyOnChangeProps;
|
|
1249
|
-
if (notifyOnChangePropsValue === "all" || !notifyOnChangePropsValue && !__privateGet(this, _trackedProps).size) {
|
|
1250
|
-
return true;
|
|
1251
|
-
}
|
|
1252
|
-
const includedProps = new Set(
|
|
1253
|
-
notifyOnChangePropsValue ?? __privateGet(this, _trackedProps)
|
|
1254
|
-
);
|
|
1255
|
-
if (this.options.throwOnError) {
|
|
1256
|
-
includedProps.add("error");
|
|
1257
|
-
}
|
|
1258
|
-
return Object.keys(__privateGet(this, _currentResult)).some((key) => {
|
|
1259
|
-
const typedKey = key;
|
|
1260
|
-
const changed = __privateGet(this, _currentResult)[typedKey] !== prevResult[typedKey];
|
|
1261
|
-
return changed && includedProps.has(typedKey);
|
|
1262
|
-
});
|
|
1263
|
-
};
|
|
1264
|
-
if ((notifyOptions == null ? void 0 : notifyOptions.listeners) !== false && shouldNotifyListeners()) {
|
|
1265
|
-
defaultNotifyOptions.listeners = true;
|
|
1266
|
-
}
|
|
1267
|
-
__privateMethod(this, _QueryObserver_instances, notify_fn).call(this, { ...defaultNotifyOptions, ...notifyOptions });
|
|
1268
|
-
}
|
|
1269
|
-
onQueryUpdate() {
|
|
1270
|
-
this.updateResult();
|
|
1271
|
-
if (this.hasListeners()) {
|
|
1272
|
-
__privateMethod(this, _QueryObserver_instances, updateTimers_fn).call(this);
|
|
1273
|
-
}
|
|
1274
|
-
}
|
|
1275
|
-
}, _client = new WeakMap(), _currentQuery = new WeakMap(), _currentQueryInitialState = new WeakMap(), _currentResult = new WeakMap(), _currentResultState = new WeakMap(), _currentResultOptions = new WeakMap(), _selectError = new WeakMap(), _selectFn = new WeakMap(), _selectResult = new WeakMap(), _lastQueryWithDefinedData = new WeakMap(), _staleTimeoutId = new WeakMap(), _refetchIntervalId = new WeakMap(), _currentRefetchInterval = new WeakMap(), _trackedProps = new WeakMap(), _QueryObserver_instances = new WeakSet(), executeFetch_fn = function(fetchOptions) {
|
|
1276
|
-
__privateMethod(this, _QueryObserver_instances, updateQuery_fn).call(this);
|
|
1277
|
-
let promise = __privateGet(this, _currentQuery).fetch(
|
|
1278
|
-
this.options,
|
|
1279
|
-
fetchOptions
|
|
1280
|
-
);
|
|
1281
|
-
if (!(fetchOptions == null ? void 0 : fetchOptions.throwOnError)) {
|
|
1282
|
-
promise = promise.catch(noop$1);
|
|
1283
|
-
}
|
|
1284
|
-
return promise;
|
|
1285
|
-
}, updateStaleTimeout_fn = function() {
|
|
1286
|
-
__privateMethod(this, _QueryObserver_instances, clearStaleTimeout_fn).call(this);
|
|
1287
|
-
const staleTime = resolveStaleTime(
|
|
1288
|
-
this.options.staleTime,
|
|
1289
|
-
__privateGet(this, _currentQuery)
|
|
1290
|
-
);
|
|
1291
|
-
if (isServer || __privateGet(this, _currentResult).isStale || !isValidTimeout(staleTime)) {
|
|
1292
|
-
return;
|
|
1293
|
-
}
|
|
1294
|
-
const time = timeUntilStale(__privateGet(this, _currentResult).dataUpdatedAt, staleTime);
|
|
1295
|
-
const timeout = time + 1;
|
|
1296
|
-
__privateSet(this, _staleTimeoutId, setTimeout(() => {
|
|
1297
|
-
if (!__privateGet(this, _currentResult).isStale) {
|
|
1298
|
-
this.updateResult();
|
|
1299
|
-
}
|
|
1300
|
-
}, timeout));
|
|
1301
|
-
}, computeRefetchInterval_fn = function() {
|
|
1302
|
-
return (typeof this.options.refetchInterval === "function" ? this.options.refetchInterval(__privateGet(this, _currentQuery)) : this.options.refetchInterval) ?? false;
|
|
1303
|
-
}, updateRefetchInterval_fn = function(nextInterval) {
|
|
1304
|
-
__privateMethod(this, _QueryObserver_instances, clearRefetchInterval_fn).call(this);
|
|
1305
|
-
__privateSet(this, _currentRefetchInterval, nextInterval);
|
|
1306
|
-
if (isServer || resolveEnabled(this.options.enabled, __privateGet(this, _currentQuery)) === false || !isValidTimeout(__privateGet(this, _currentRefetchInterval)) || __privateGet(this, _currentRefetchInterval) === 0) {
|
|
1307
|
-
return;
|
|
1308
|
-
}
|
|
1309
|
-
__privateSet(this, _refetchIntervalId, setInterval(() => {
|
|
1310
|
-
if (this.options.refetchIntervalInBackground || focusManager.isFocused()) {
|
|
1311
|
-
__privateMethod(this, _QueryObserver_instances, executeFetch_fn).call(this);
|
|
1312
|
-
}
|
|
1313
|
-
}, __privateGet(this, _currentRefetchInterval)));
|
|
1314
|
-
}, updateTimers_fn = function() {
|
|
1315
|
-
__privateMethod(this, _QueryObserver_instances, updateStaleTimeout_fn).call(this);
|
|
1316
|
-
__privateMethod(this, _QueryObserver_instances, updateRefetchInterval_fn).call(this, __privateMethod(this, _QueryObserver_instances, computeRefetchInterval_fn).call(this));
|
|
1317
|
-
}, clearStaleTimeout_fn = function() {
|
|
1318
|
-
if (__privateGet(this, _staleTimeoutId)) {
|
|
1319
|
-
clearTimeout(__privateGet(this, _staleTimeoutId));
|
|
1320
|
-
__privateSet(this, _staleTimeoutId, void 0);
|
|
1321
|
-
}
|
|
1322
|
-
}, clearRefetchInterval_fn = function() {
|
|
1323
|
-
if (__privateGet(this, _refetchIntervalId)) {
|
|
1324
|
-
clearInterval(__privateGet(this, _refetchIntervalId));
|
|
1325
|
-
__privateSet(this, _refetchIntervalId, void 0);
|
|
1326
|
-
}
|
|
1327
|
-
}, updateQuery_fn = function() {
|
|
1328
|
-
const query = __privateGet(this, _client).getQueryCache().build(__privateGet(this, _client), this.options);
|
|
1329
|
-
if (query === __privateGet(this, _currentQuery)) {
|
|
1330
|
-
return;
|
|
1331
|
-
}
|
|
1332
|
-
const prevQuery = __privateGet(this, _currentQuery);
|
|
1333
|
-
__privateSet(this, _currentQuery, query);
|
|
1334
|
-
__privateSet(this, _currentQueryInitialState, query.state);
|
|
1335
|
-
if (this.hasListeners()) {
|
|
1336
|
-
prevQuery == null ? void 0 : prevQuery.removeObserver(this);
|
|
1337
|
-
query.addObserver(this);
|
|
1338
|
-
}
|
|
1339
|
-
}, notify_fn = function(notifyOptions) {
|
|
1340
|
-
notifyManager.batch(() => {
|
|
1341
|
-
if (notifyOptions.listeners) {
|
|
1342
|
-
this.listeners.forEach((listener) => {
|
|
1343
|
-
listener(__privateGet(this, _currentResult));
|
|
1344
|
-
});
|
|
1345
|
-
}
|
|
1346
|
-
__privateGet(this, _client).getQueryCache().notify({
|
|
1347
|
-
query: __privateGet(this, _currentQuery),
|
|
1348
|
-
type: "observerResultsUpdated"
|
|
1349
|
-
});
|
|
1350
|
-
});
|
|
1351
|
-
}, _e);
|
|
1352
|
-
function shouldLoadOnMount(query, options) {
|
|
1353
|
-
return resolveEnabled(options.enabled, query) !== false && query.state.data === void 0 && !(query.state.status === "error" && options.retryOnMount === false);
|
|
1354
|
-
}
|
|
1355
|
-
function shouldFetchOnMount(query, options) {
|
|
1356
|
-
return shouldLoadOnMount(query, options) || query.state.data !== void 0 && shouldFetchOn(query, options, options.refetchOnMount);
|
|
1357
|
-
}
|
|
1358
|
-
function shouldFetchOn(query, options, field) {
|
|
1359
|
-
if (resolveEnabled(options.enabled, query) !== false) {
|
|
1360
|
-
const value = typeof field === "function" ? field(query) : field;
|
|
1361
|
-
return value === "always" || value !== false && isStale(query, options);
|
|
1362
|
-
}
|
|
1363
|
-
return false;
|
|
1364
|
-
}
|
|
1365
|
-
function shouldFetchOptionally(query, prevQuery, options, prevOptions) {
|
|
1366
|
-
return (query !== prevQuery || resolveEnabled(prevOptions.enabled, query) === false) && (!options.suspense || query.state.status !== "error") && isStale(query, options);
|
|
1367
|
-
}
|
|
1368
|
-
function isStale(query, options) {
|
|
1369
|
-
return resolveEnabled(options.enabled, query) !== false && query.isStaleByTime(resolveStaleTime(options.staleTime, query));
|
|
1370
|
-
}
|
|
1371
|
-
function shouldAssignObserverCurrentProperties(observer, optimisticResult) {
|
|
1372
|
-
if (!shallowEqualObjects(observer.getCurrentResult(), optimisticResult)) {
|
|
1373
|
-
return true;
|
|
1374
|
-
}
|
|
1375
|
-
return false;
|
|
1376
|
-
}
|
|
1377
|
-
var QueryClientContext = React.createContext(
|
|
1378
|
-
void 0
|
|
1379
|
-
);
|
|
1380
|
-
var useQueryClient = (queryClient) => {
|
|
1381
|
-
const client = React.useContext(QueryClientContext);
|
|
1382
|
-
if (!client) {
|
|
1383
|
-
throw new Error("No QueryClient set, use QueryClientProvider to set one");
|
|
1384
|
-
}
|
|
1385
|
-
return client;
|
|
1386
|
-
};
|
|
1387
|
-
var QueryClientProvider = ({
|
|
1388
|
-
client,
|
|
1389
|
-
children
|
|
1390
|
-
}) => {
|
|
1391
|
-
React.useEffect(() => {
|
|
1392
|
-
client.mount();
|
|
1393
|
-
return () => {
|
|
1394
|
-
client.unmount();
|
|
1395
|
-
};
|
|
1396
|
-
}, [client]);
|
|
1397
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(QueryClientContext.Provider, { value: client, children });
|
|
1398
|
-
};
|
|
1399
|
-
var IsRestoringContext = React.createContext(false);
|
|
1400
|
-
var useIsRestoring = () => React.useContext(IsRestoringContext);
|
|
1401
|
-
IsRestoringContext.Provider;
|
|
1402
|
-
function createValue() {
|
|
1403
|
-
let isReset = false;
|
|
1404
|
-
return {
|
|
1405
|
-
clearReset: () => {
|
|
1406
|
-
isReset = false;
|
|
1407
|
-
},
|
|
1408
|
-
reset: () => {
|
|
1409
|
-
isReset = true;
|
|
1410
|
-
},
|
|
1411
|
-
isReset: () => {
|
|
1412
|
-
return isReset;
|
|
1413
|
-
}
|
|
1414
|
-
};
|
|
1415
|
-
}
|
|
1416
|
-
var QueryErrorResetBoundaryContext = React.createContext(createValue());
|
|
1417
|
-
var useQueryErrorResetBoundary = () => React.useContext(QueryErrorResetBoundaryContext);
|
|
1418
|
-
function shouldThrowError(throwError, params) {
|
|
1419
|
-
if (typeof throwError === "function") {
|
|
1420
|
-
return throwError(...params);
|
|
1421
|
-
}
|
|
1422
|
-
return !!throwError;
|
|
1423
|
-
}
|
|
1424
|
-
function noop() {
|
|
1425
|
-
}
|
|
1426
|
-
var ensurePreventErrorBoundaryRetry = (options, errorResetBoundary) => {
|
|
1427
|
-
if (options.suspense || options.throwOnError) {
|
|
1428
|
-
if (!errorResetBoundary.isReset()) {
|
|
1429
|
-
options.retryOnMount = false;
|
|
1430
|
-
}
|
|
1431
|
-
}
|
|
1432
|
-
};
|
|
1433
|
-
var useClearResetErrorBoundary = (errorResetBoundary) => {
|
|
1434
|
-
React.useEffect(() => {
|
|
1435
|
-
errorResetBoundary.clearReset();
|
|
1436
|
-
}, [errorResetBoundary]);
|
|
1437
|
-
};
|
|
1438
|
-
var getHasError = ({
|
|
1439
|
-
result,
|
|
1440
|
-
errorResetBoundary,
|
|
1441
|
-
throwOnError,
|
|
1442
|
-
query
|
|
1443
|
-
}) => {
|
|
1444
|
-
return result.isError && !errorResetBoundary.isReset() && !result.isFetching && query && shouldThrowError(throwOnError, [result.error, query]);
|
|
1445
|
-
};
|
|
1446
|
-
var defaultThrowOnError = (_error, query) => query.state.data === void 0;
|
|
1447
|
-
var ensureStaleTime = (defaultedOptions) => {
|
|
1448
|
-
if (defaultedOptions.suspense) {
|
|
1449
|
-
if (typeof defaultedOptions.staleTime !== "number") {
|
|
1450
|
-
defaultedOptions.staleTime = 1e3;
|
|
1451
|
-
}
|
|
1452
|
-
}
|
|
1453
|
-
};
|
|
1454
|
-
var shouldSuspend = (defaultedOptions, result) => (defaultedOptions == null ? void 0 : defaultedOptions.suspense) && result.isPending;
|
|
1455
|
-
var fetchOptimistic = (defaultedOptions, observer, errorResetBoundary) => observer.fetchOptimistic(defaultedOptions).catch(() => {
|
|
1456
|
-
errorResetBoundary.clearReset();
|
|
1457
|
-
});
|
|
1458
|
-
function useBaseQuery(options, Observer, queryClient) {
|
|
1459
|
-
var _a2, _b2, _c2, _d2;
|
|
1460
|
-
if (process.env.NODE_ENV !== "production") {
|
|
1461
|
-
if (typeof options !== "object" || Array.isArray(options)) {
|
|
1462
|
-
throw new Error(
|
|
1463
|
-
'Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object'
|
|
1464
|
-
);
|
|
1465
|
-
}
|
|
1466
|
-
}
|
|
1467
|
-
const client = useQueryClient();
|
|
1468
|
-
const isRestoring = useIsRestoring();
|
|
1469
|
-
const errorResetBoundary = useQueryErrorResetBoundary();
|
|
1470
|
-
const defaultedOptions = client.defaultQueryOptions(options);
|
|
1471
|
-
(_b2 = (_a2 = client.getDefaultOptions().queries) == null ? void 0 : _a2._experimental_beforeQuery) == null ? void 0 : _b2.call(
|
|
1472
|
-
_a2,
|
|
1473
|
-
defaultedOptions
|
|
1474
|
-
);
|
|
1475
|
-
defaultedOptions._optimisticResults = isRestoring ? "isRestoring" : "optimistic";
|
|
1476
|
-
ensureStaleTime(defaultedOptions);
|
|
1477
|
-
ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary);
|
|
1478
|
-
useClearResetErrorBoundary(errorResetBoundary);
|
|
1479
|
-
const [observer] = React.useState(
|
|
1480
|
-
() => new Observer(
|
|
1481
|
-
client,
|
|
1482
|
-
defaultedOptions
|
|
1483
|
-
)
|
|
1484
|
-
);
|
|
1485
|
-
const result = observer.getOptimisticResult(defaultedOptions);
|
|
1486
|
-
React.useSyncExternalStore(
|
|
1487
|
-
React.useCallback(
|
|
1488
|
-
(onStoreChange) => {
|
|
1489
|
-
const unsubscribe = isRestoring ? () => void 0 : observer.subscribe(notifyManager.batchCalls(onStoreChange));
|
|
1490
|
-
observer.updateResult();
|
|
1491
|
-
return unsubscribe;
|
|
1492
|
-
},
|
|
1493
|
-
[observer, isRestoring]
|
|
1494
|
-
),
|
|
1495
|
-
() => observer.getCurrentResult(),
|
|
1496
|
-
() => observer.getCurrentResult()
|
|
1497
|
-
);
|
|
1498
|
-
React.useEffect(() => {
|
|
1499
|
-
observer.setOptions(defaultedOptions, { listeners: false });
|
|
1500
|
-
}, [defaultedOptions, observer]);
|
|
1501
|
-
if (shouldSuspend(defaultedOptions, result)) {
|
|
1502
|
-
throw fetchOptimistic(defaultedOptions, observer, errorResetBoundary);
|
|
1503
|
-
}
|
|
1504
|
-
if (getHasError({
|
|
1505
|
-
result,
|
|
1506
|
-
errorResetBoundary,
|
|
1507
|
-
throwOnError: defaultedOptions.throwOnError,
|
|
1508
|
-
query: client.getQueryCache().get(defaultedOptions.queryHash)
|
|
1509
|
-
})) {
|
|
1510
|
-
throw result.error;
|
|
1511
|
-
}
|
|
1512
|
-
(_d2 = (_c2 = client.getDefaultOptions().queries) == null ? void 0 : _c2._experimental_afterQuery) == null ? void 0 : _d2.call(
|
|
1513
|
-
_c2,
|
|
1514
|
-
defaultedOptions,
|
|
1515
|
-
result
|
|
1516
|
-
);
|
|
1517
|
-
return !defaultedOptions.notifyOnChangeProps ? observer.trackResult(result) : result;
|
|
1518
|
-
}
|
|
1519
|
-
function useQuery(options, queryClient) {
|
|
1520
|
-
return useBaseQuery(options, QueryObserver);
|
|
1521
|
-
}
|
|
1522
|
-
function useSuspenseQuery(options, queryClient) {
|
|
1523
|
-
if (process.env.NODE_ENV !== "production") {
|
|
1524
|
-
if (options.queryFn === skipToken) {
|
|
1525
|
-
console.error("skipToken is not allowed for useSuspenseQuery");
|
|
1526
|
-
}
|
|
1527
|
-
}
|
|
1528
|
-
return useBaseQuery(
|
|
1529
|
-
{
|
|
1530
|
-
...options,
|
|
1531
|
-
enabled: true,
|
|
1532
|
-
suspense: true,
|
|
1533
|
-
throwOnError: defaultThrowOnError,
|
|
1534
|
-
placeholderData: void 0
|
|
1535
|
-
},
|
|
1536
|
-
QueryObserver
|
|
1537
|
-
);
|
|
1538
|
-
}
|
|
1539
|
-
const DevPortalReactContext = createContext(
|
|
1540
|
-
void 0
|
|
1541
|
-
);
|
|
1542
|
-
const DevPortalProvider = DevPortalReactContext.Provider;
|
|
1543
|
-
const useDevPortal = () => {
|
|
1544
|
-
const context = useContext(DevPortalReactContext);
|
|
1545
|
-
if (!context) {
|
|
1546
|
-
throw new Error("useDevPortal must be used within a DevPortalProvider.");
|
|
1547
|
-
}
|
|
1548
|
-
return context;
|
|
1549
|
-
};
|
|
1550
|
-
const useApiIdentities = () => {
|
|
1551
|
-
const { getApiIdentities } = useDevPortal();
|
|
1552
|
-
return useQuery({
|
|
1553
|
-
queryFn: getApiIdentities,
|
|
1554
|
-
queryKey: ["api-identities"]
|
|
1555
|
-
});
|
|
1556
|
-
};
|
|
1557
|
-
const useTopNavigationItem = () => {
|
|
1558
|
-
const { navigation } = useDevPortal();
|
|
1559
|
-
const location = useLocation();
|
|
1560
|
-
return navigation.find(
|
|
1561
|
-
(item) => matchPath({ path: item.path, end: false }, location.pathname)
|
|
1562
|
-
);
|
|
1563
|
-
};
|
|
1564
|
-
const useNavigation = () => {
|
|
1565
|
-
const { getNavigation } = useDevPortal();
|
|
1566
|
-
const navItem = useTopNavigationItem();
|
|
1567
|
-
const path = (navItem == null ? void 0 : navItem.path) ?? "";
|
|
1568
|
-
return useSuspenseQuery({
|
|
1569
|
-
queryFn: async () => {
|
|
1570
|
-
return {
|
|
1571
|
-
items: [...(navItem == null ? void 0 : navItem.categories) ?? [], ...await getNavigation(path)],
|
|
1572
|
-
currentTopNavItem: navItem
|
|
1573
|
-
};
|
|
1574
|
-
},
|
|
1575
|
-
queryKey: ["navigation", path]
|
|
1576
|
-
});
|
|
1577
|
-
};
|
|
1578
|
-
export {
|
|
1579
|
-
DevPortalProvider as D,
|
|
1580
|
-
Query as Q,
|
|
1581
|
-
Removable as R,
|
|
1582
|
-
Subscribable as S,
|
|
1583
|
-
matchMutation as a,
|
|
1584
|
-
noop$1 as b,
|
|
1585
|
-
addToStart as c,
|
|
1586
|
-
addToEnd as d,
|
|
1587
|
-
ensureQueryFn as e,
|
|
1588
|
-
focusManager as f,
|
|
1589
|
-
functionalUpdate as g,
|
|
1590
|
-
hashQueryKeyByOptions as h,
|
|
1591
|
-
hashKey as i,
|
|
1592
|
-
QueryClientProvider as j,
|
|
1593
|
-
useTopNavigationItem as k,
|
|
1594
|
-
useNavigation as l,
|
|
1595
|
-
matchQuery as m,
|
|
1596
|
-
notifyManager as n,
|
|
1597
|
-
onlineManager as o,
|
|
1598
|
-
partialMatchKey as p,
|
|
1599
|
-
useQueryClient as q,
|
|
1600
|
-
resolveStaleTime as r,
|
|
1601
|
-
skipToken as s,
|
|
1602
|
-
useSuspenseQuery as t,
|
|
1603
|
-
useDevPortal as u,
|
|
1604
|
-
useApiIdentities as v,
|
|
1605
|
-
shallowEqualObjects as w,
|
|
1606
|
-
noop as x,
|
|
1607
|
-
shouldThrowError as y,
|
|
1608
|
-
createRetryer as z
|
|
1609
|
-
};
|
|
1610
|
-
//# sourceMappingURL=DevPortalProvider-GjdO0Xr-.js.map
|