@ryuzaki13/react-foundation-lib 2.8.1 → 2.10.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/README.md +1 -0
- package/dist/chunks/query-client-BsiuEoJD.js +525 -0
- package/dist/chunks/query-client-BsiuEoJD.js.map +1 -0
- package/dist/decimal/addDecimals.d.ts +4 -0
- package/dist/decimal/addDecimals.d.ts.map +1 -0
- package/dist/decimal/alignDecimalParts.d.ts +8 -0
- package/dist/decimal/alignDecimalParts.d.ts.map +1 -0
- package/dist/decimal/compareDecimalRatios.d.ts +4 -0
- package/dist/decimal/compareDecimalRatios.d.ts.map +1 -0
- package/dist/decimal/compareDecimals.d.ts +4 -0
- package/dist/decimal/compareDecimals.d.ts.map +1 -0
- package/dist/decimal/index.d.ts +10 -0
- package/dist/decimal/index.d.ts.map +1 -0
- package/dist/decimal/index.js +108 -0
- package/dist/decimal/index.js.map +1 -0
- package/dist/decimal/isCanonicalDecimal.d.ts +4 -0
- package/dist/decimal/isCanonicalDecimal.d.ts.map +1 -0
- package/dist/decimal/multiplyDecimals.d.ts +4 -0
- package/dist/decimal/multiplyDecimals.d.ts.map +1 -0
- package/dist/decimal/normalizeDecimal.d.ts +4 -0
- package/dist/decimal/normalizeDecimal.d.ts.map +1 -0
- package/dist/decimal/readDecimalParts.d.ts +4 -0
- package/dist/decimal/readDecimalParts.d.ts.map +1 -0
- package/dist/decimal/resolveDecimalMaxLength.d.ts +4 -0
- package/dist/decimal/resolveDecimalMaxLength.d.ts.map +1 -0
- package/dist/decimal/subtractDecimals.d.ts +4 -0
- package/dist/decimal/subtractDecimals.d.ts.map +1 -0
- package/dist/decimal/sumDecimals.d.ts +4 -0
- package/dist/decimal/sumDecimals.d.ts.map +1 -0
- package/dist/decimal/types.d.ts +16 -0
- package/dist/decimal/types.d.ts.map +1 -0
- package/dist/decimal/writeDecimalParts.d.ts +4 -0
- package/dist/decimal/writeDecimalParts.d.ts.map +1 -0
- package/dist/error-report/index.js +1 -1
- package/dist/query-client/index.d.ts +3 -0
- package/dist/query-client/index.d.ts.map +1 -1
- package/dist/query-client/index.js +2 -439
- package/dist/query-client/sessionScoped.d.ts +1 -15
- package/dist/query-client/sessionScoped.d.ts.map +1 -1
- package/dist/query-client/sessionScopedResetLifecycle.d.ts +16 -0
- package/dist/query-client/sessionScopedResetLifecycle.d.ts.map +1 -0
- package/dist/query-client/sessionScopedResetLifecycleTypes.d.ts +16 -0
- package/dist/query-client/sessionScopedResetLifecycleTypes.d.ts.map +1 -0
- package/dist/query-client/sessionScopedTypes.d.ts +15 -0
- package/dist/query-client/sessionScopedTypes.d.ts.map +1 -0
- package/package.json +5 -1
- package/src/decimal/README.md +43 -0
- package/src/query-client/README.mdx +101 -19
- package/dist/query-client/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -111,6 +111,7 @@ npm run pack:dry-run
|
|
|
111
111
|
| `/crypto` | [`crypto/README.mdx`](./src/crypto/README.mdx) |
|
|
112
112
|
| `/currency` | [`currency/README.mdx`](./src/currency/README.mdx) |
|
|
113
113
|
| `/date-segments` | [`date-segments/README.mdx`](./src/date-segments/README.mdx) |
|
|
114
|
+
| `/decimal` | [Точная десятичная арифметика](./src/decimal/README.md) |
|
|
114
115
|
| `/dom` | [`dom/README.mdx`](./src/dom/README.mdx) |
|
|
115
116
|
| `/error` | [`error/README.mdx`](./src/error/README.mdx) |
|
|
116
117
|
| `/error-report` | [`error-report/README.mdx`](./src/error-report/README.mdx) |
|
|
@@ -0,0 +1,525 @@
|
|
|
1
|
+
import { i as e } from "./isRecord-DXDTW-jA.js";
|
|
2
|
+
import { uuidv4 as t } from "../crypto/index.js";
|
|
3
|
+
import { broadcastQueryClient as n } from "@tanstack/query-broadcast-client-experimental";
|
|
4
|
+
import { experimental_createQueryPersister as r } from "@tanstack/query-persist-client-core";
|
|
5
|
+
import { MutationCache as i, QueryCache as a, QueryClient as o } from "@tanstack/react-query";
|
|
6
|
+
//#region src/query-client/broadcast.ts
|
|
7
|
+
var s = null;
|
|
8
|
+
function c(e) {
|
|
9
|
+
s = e;
|
|
10
|
+
}
|
|
11
|
+
function l(e) {
|
|
12
|
+
s?.(e);
|
|
13
|
+
}
|
|
14
|
+
function u(e, r) {
|
|
15
|
+
if (typeof window > "u") return {
|
|
16
|
+
broadcast: () => {},
|
|
17
|
+
cleanup: () => {}
|
|
18
|
+
};
|
|
19
|
+
let i = !1, a = n({
|
|
20
|
+
queryClient: e,
|
|
21
|
+
broadcastChannel: r.queriesChannel
|
|
22
|
+
}), o = t(), s = new BroadcastChannel(r.eventsChannel), c = e.getQueryCache().subscribe((e) => {
|
|
23
|
+
i || e.type === "updated" && e.action.type === "invalidate" && l({
|
|
24
|
+
type: "invalidate",
|
|
25
|
+
keys: [e.query.queryKey],
|
|
26
|
+
refetchType: "none"
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
s.onmessage = (t) => {
|
|
30
|
+
let n = t.data;
|
|
31
|
+
if (!d(n) || n.tabId === o) return;
|
|
32
|
+
let r = n.event;
|
|
33
|
+
i = !0;
|
|
34
|
+
try {
|
|
35
|
+
if (r.type === "invalidate") {
|
|
36
|
+
let t = r.refetchType ?? "none";
|
|
37
|
+
for (let n of r.keys) e.invalidateQueries({
|
|
38
|
+
queryKey: n,
|
|
39
|
+
refetchType: t
|
|
40
|
+
});
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (r.type === "setQueryData") {
|
|
44
|
+
e.setQueryData(r.key, r.data);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
} finally {
|
|
48
|
+
i = !1;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
function l(e) {
|
|
52
|
+
let t = {
|
|
53
|
+
tabId: o,
|
|
54
|
+
event: e
|
|
55
|
+
};
|
|
56
|
+
s.postMessage(t);
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
broadcast: l,
|
|
60
|
+
cleanup: () => {
|
|
61
|
+
c(), a(), s.close();
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function d(t) {
|
|
66
|
+
return !e(t) || typeof t.tabId != "string" || !("event" in t) ? !1 : f(t.event);
|
|
67
|
+
}
|
|
68
|
+
function f(t) {
|
|
69
|
+
return e(t) ? t.type === "invalidate" ? Array.isArray(t.keys) ? t.refetchType === void 0 || t.refetchType === "none" || t.refetchType === "active" || t.refetchType === "inactive" || t.refetchType === "all" : !1 : t.type === "setQueryData" && "key" in t && "data" in t : !1;
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/query-client/invalidationBroadcast.ts
|
|
73
|
+
function ee(t) {
|
|
74
|
+
return e(t) && t.type === "query.invalidate" && typeof t.senderId == "string" && Array.isArray(t.queryKey);
|
|
75
|
+
}
|
|
76
|
+
function te(e, n) {
|
|
77
|
+
if (typeof window > "u" || typeof BroadcastChannel > "u") return {
|
|
78
|
+
broadcast: () => void 0,
|
|
79
|
+
cleanup: () => void 0
|
|
80
|
+
};
|
|
81
|
+
let r = t(), i = new BroadcastChannel(n.channelName), a = !1, o = !1, s = (e) => {
|
|
82
|
+
o || !n.matchesQuery(e) || i.postMessage({
|
|
83
|
+
type: "query.invalidate",
|
|
84
|
+
senderId: r,
|
|
85
|
+
queryKey: e
|
|
86
|
+
});
|
|
87
|
+
}, c = e.getQueryCache().subscribe((e) => {
|
|
88
|
+
a || e.type !== "updated" || e.action.type !== "invalidate" || s(e.query.queryKey);
|
|
89
|
+
});
|
|
90
|
+
return i.onmessage = (t) => {
|
|
91
|
+
let i = t.data;
|
|
92
|
+
if (!(o || !ee(i) || i.senderId === r || !n.matchesQuery(i.queryKey))) {
|
|
93
|
+
a = !0;
|
|
94
|
+
try {
|
|
95
|
+
e.invalidateQueries({
|
|
96
|
+
queryKey: i.queryKey,
|
|
97
|
+
exact: !0,
|
|
98
|
+
refetchType: n.refetchType ?? "active"
|
|
99
|
+
});
|
|
100
|
+
} finally {
|
|
101
|
+
a = !1;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}, {
|
|
105
|
+
broadcast: s,
|
|
106
|
+
cleanup() {
|
|
107
|
+
o || (o = !0, c(), i.close());
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
//#endregion
|
|
112
|
+
//#region src/query-client/queryPersistenceAdapter.ts
|
|
113
|
+
var p = {};
|
|
114
|
+
function ne(e) {
|
|
115
|
+
p = e;
|
|
116
|
+
}
|
|
117
|
+
function m() {
|
|
118
|
+
return p;
|
|
119
|
+
}
|
|
120
|
+
//#endregion
|
|
121
|
+
//#region src/query-client/persistence.ts
|
|
122
|
+
var h = "queries", re = "session", g = __REACT_QUERY_PERSISTENCE_BUSTER__, _ = 7776e6, v = null;
|
|
123
|
+
function y(e) {
|
|
124
|
+
if (e) return e;
|
|
125
|
+
if (globalThis.indexedDB !== void 0) return globalThis.indexedDB;
|
|
126
|
+
}
|
|
127
|
+
function b(e) {
|
|
128
|
+
return new Promise((t, n) => {
|
|
129
|
+
e.onsuccess = () => t(e.result), e.onerror = () => n(e.error);
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
function x() {
|
|
133
|
+
if (__DEV__) return `dev:${__APP_ID__}`;
|
|
134
|
+
let e = m().resolveSystemIdentifier?.();
|
|
135
|
+
if (e) return e;
|
|
136
|
+
let t = typeof window > "u" ? "server" : window.location.hostname;
|
|
137
|
+
return `${__APP_ID__}:${t}`;
|
|
138
|
+
}
|
|
139
|
+
function S() {
|
|
140
|
+
return `${x()}`;
|
|
141
|
+
}
|
|
142
|
+
function C(e) {
|
|
143
|
+
return encodeURIComponent(e);
|
|
144
|
+
}
|
|
145
|
+
function w() {
|
|
146
|
+
return `${S()}-${re}-`;
|
|
147
|
+
}
|
|
148
|
+
function T(e) {
|
|
149
|
+
return `${w()}${C(e)}-`;
|
|
150
|
+
}
|
|
151
|
+
function E(e, t) {
|
|
152
|
+
return `${T(e)}${C(t)}`;
|
|
153
|
+
}
|
|
154
|
+
function D(e) {
|
|
155
|
+
return !!e?.id.trim() && Number.isFinite(Date.parse(e?.expiresAt ?? "")) && Date.parse(e?.expiresAt ?? "") > Date.now();
|
|
156
|
+
}
|
|
157
|
+
function O() {
|
|
158
|
+
return D(v) ? v : null;
|
|
159
|
+
}
|
|
160
|
+
async function k(e) {
|
|
161
|
+
let t = F();
|
|
162
|
+
if (!t?.entries) return;
|
|
163
|
+
let n = await t.entries();
|
|
164
|
+
await Promise.all(n.filter(([t]) => e(t)).map(([e]) => t.removeItem(e)));
|
|
165
|
+
}
|
|
166
|
+
async function A(e) {
|
|
167
|
+
let t = e === void 0 ? w() : T(e);
|
|
168
|
+
await k((e) => e.startsWith(t));
|
|
169
|
+
}
|
|
170
|
+
async function j(e) {
|
|
171
|
+
let t = e && D(e) ? {
|
|
172
|
+
id: e.id.trim(),
|
|
173
|
+
expiresAt: e.expiresAt
|
|
174
|
+
} : null;
|
|
175
|
+
if (v = t, !t) {
|
|
176
|
+
await A();
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
let n = T(t.id);
|
|
180
|
+
await k((e) => e.startsWith(w()) && !e.startsWith(n));
|
|
181
|
+
}
|
|
182
|
+
function M(e) {
|
|
183
|
+
return e.meta?.persist === !0 && e.meta.sessionScoped !== !0;
|
|
184
|
+
}
|
|
185
|
+
function N(e) {
|
|
186
|
+
let t = e.meta?.sessionPersistence;
|
|
187
|
+
if (e.meta?.sessionScoped !== !0 || !t || typeof t != "object" || !("cacheName" in t) || !("maxEntries" in t) || typeof t.cacheName != "string" || !/^[a-z0-9][a-z0-9_-]{0,63}$/u.test(t.cacheName) || !Number.isSafeInteger(t.maxEntries) || t.maxEntries < 1 || t.maxEntries > 5e3) return null;
|
|
188
|
+
let n = "refetchOnRestore" in t ? t.refetchOnRestore : void 0;
|
|
189
|
+
if (n !== void 0 && typeof n != "boolean") return null;
|
|
190
|
+
let r = "monotonicRevisionField" in t ? t.monotonicRevisionField : void 0;
|
|
191
|
+
return r !== void 0 && (typeof r != "string" || !/^[A-Za-z][A-Za-z0-9_]{0,63}$/u.test(r)) ? null : {
|
|
192
|
+
cacheName: t.cacheName,
|
|
193
|
+
maxEntries: t.maxEntries,
|
|
194
|
+
refetchOnRestore: n,
|
|
195
|
+
monotonicRevisionField: r
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
function P(e, t) {
|
|
199
|
+
let n = e.state.data;
|
|
200
|
+
if (typeof n != "object" || !n || Array.isArray(n)) return null;
|
|
201
|
+
let r = Reflect.get(n, t);
|
|
202
|
+
return typeof r != "string" || !/^\d+$/u.test(r) ? null : r.replace(/^0+(?=\d)/u, "");
|
|
203
|
+
}
|
|
204
|
+
function ie(e, t) {
|
|
205
|
+
return e.length === t.length ? e === t ? 0 : e < t ? -1 : 1 : e.length - t.length;
|
|
206
|
+
}
|
|
207
|
+
function F(e = {}) {
|
|
208
|
+
let t = y(e.indexedDB);
|
|
209
|
+
if (!t) return;
|
|
210
|
+
let n = t, r = e.dbName ?? x(), i = e.storeName ?? h, a = null;
|
|
211
|
+
function o() {
|
|
212
|
+
return a || (a = new Promise((e, t) => {
|
|
213
|
+
let a = n.open(r, 1);
|
|
214
|
+
a.onupgradeneeded = () => {
|
|
215
|
+
let e = a.result;
|
|
216
|
+
e.objectStoreNames.contains(i) || e.createObjectStore(i);
|
|
217
|
+
}, a.onsuccess = () => e(a.result), a.onerror = () => t(a.error), a.onblocked = () => t(a.error ?? /* @__PURE__ */ Error("Открытие IndexedDB заблокировано"));
|
|
218
|
+
}), a);
|
|
219
|
+
}
|
|
220
|
+
async function s(e, t) {
|
|
221
|
+
return b(t((await o()).transaction(i, e).objectStore(i)));
|
|
222
|
+
}
|
|
223
|
+
async function c(e, t) {
|
|
224
|
+
let n = await o();
|
|
225
|
+
return new Promise((r, a) => {
|
|
226
|
+
let o = n.transaction(i, e), s = o.objectStore(i);
|
|
227
|
+
o.oncomplete = () => r(), o.onerror = () => a(o.error), o.onabort = () => a(o.error);
|
|
228
|
+
try {
|
|
229
|
+
t(s);
|
|
230
|
+
} catch (e) {
|
|
231
|
+
o.abort(), a(e);
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
async function l(e, t) {
|
|
236
|
+
let n = await o();
|
|
237
|
+
return new Promise((r, a) => {
|
|
238
|
+
let o = n.transaction(i, "readwrite"), s = o.objectStore(i), c = s.get(e), l, u = !1;
|
|
239
|
+
o.oncomplete = () => {
|
|
240
|
+
u ? r(l) : a(/* @__PURE__ */ Error("IndexedDB-транзакция завершилась без результата обновления"));
|
|
241
|
+
}, o.onerror = () => a(o.error), o.onabort = () => a(o.error), c.onerror = () => {
|
|
242
|
+
o.abort(), a(c.error);
|
|
243
|
+
}, c.onsuccess = () => {
|
|
244
|
+
try {
|
|
245
|
+
let n = t(c.result);
|
|
246
|
+
l = n.result, u = !0, n.action === "set" ? s.put(n.value, e) : n.action === "remove" && s.delete(e);
|
|
247
|
+
} catch (e) {
|
|
248
|
+
o.abort(), a(e);
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
return {
|
|
254
|
+
getItem: (e) => s("readonly", (t) => t.get(e)),
|
|
255
|
+
setItem: (e, t) => c("readwrite", (n) => n.put(t, e)),
|
|
256
|
+
removeItem: (e) => c("readwrite", (t) => t.delete(e)),
|
|
257
|
+
updateItem: l,
|
|
258
|
+
entries: async () => {
|
|
259
|
+
let e = await o();
|
|
260
|
+
return new Promise((t, n) => {
|
|
261
|
+
let r = e.transaction(i, "readonly"), a = r.objectStore(i).openCursor(), o = [];
|
|
262
|
+
r.oncomplete = () => t(o), r.onerror = () => n(r.error), r.onabort = () => n(r.error), a.onsuccess = () => {
|
|
263
|
+
let e = a.result;
|
|
264
|
+
e && (o.push([String(e.key), e.value]), e.continue());
|
|
265
|
+
}, a.onerror = () => n(a.error);
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
function I() {
|
|
271
|
+
let e = F();
|
|
272
|
+
if (!e) return;
|
|
273
|
+
let t = e, n = r({
|
|
274
|
+
storage: t,
|
|
275
|
+
serialize: (e) => e,
|
|
276
|
+
deserialize: (e) => e,
|
|
277
|
+
prefix: S(),
|
|
278
|
+
buster: m().persistenceBuster ?? g,
|
|
279
|
+
maxAge: _,
|
|
280
|
+
refetchOnRestore: !0,
|
|
281
|
+
filters: { predicate: M }
|
|
282
|
+
}), i = /* @__PURE__ */ new Map();
|
|
283
|
+
function a(e, n, a, o = !0, s) {
|
|
284
|
+
let c = E(e.id, n), l = `${c}:${a}:${o}:${s ?? ""}:${e.expiresAt}`, u = i.get(l);
|
|
285
|
+
if (u) return u;
|
|
286
|
+
let d = Promise.resolve(), f = r({
|
|
287
|
+
storage: {
|
|
288
|
+
getItem: (n) => O()?.id === e.id ? t.getItem(n) : void 0,
|
|
289
|
+
removeItem: (e) => t.removeItem(e),
|
|
290
|
+
entries: () => t.entries(),
|
|
291
|
+
setItem: async (n, r) => {
|
|
292
|
+
O()?.id === e.id && (s === void 0 ? await t.setItem(n, r) : await t.updateItem(n, (e) => {
|
|
293
|
+
if (!e || e.buster !== r.buster) return {
|
|
294
|
+
action: "set",
|
|
295
|
+
value: r,
|
|
296
|
+
result: void 0
|
|
297
|
+
};
|
|
298
|
+
let t = P(e, s), n = P(r, s);
|
|
299
|
+
return t !== null && n !== null && ie(t, n) > 0 ? {
|
|
300
|
+
action: "keep",
|
|
301
|
+
result: void 0
|
|
302
|
+
} : {
|
|
303
|
+
action: "set",
|
|
304
|
+
value: r,
|
|
305
|
+
result: void 0
|
|
306
|
+
};
|
|
307
|
+
}), d = d.then(async () => {
|
|
308
|
+
let e = (await t.entries()).filter(([e]) => e.startsWith(`${c}-`));
|
|
309
|
+
e.sort((e, t) => (t[1].state.dataUpdatedAt ?? 0) - (e[1].state.dataUpdatedAt ?? 0)), await Promise.all(e.slice(a).map(([e]) => t.removeItem(e)));
|
|
310
|
+
}), await d);
|
|
311
|
+
}
|
|
312
|
+
},
|
|
313
|
+
serialize: (e) => e,
|
|
314
|
+
deserialize: (e) => e,
|
|
315
|
+
prefix: c,
|
|
316
|
+
buster: m().persistenceBuster ?? g,
|
|
317
|
+
maxAge: _,
|
|
318
|
+
refetchOnRestore: o,
|
|
319
|
+
filters: { predicate: (e) => N(e)?.cacheName === n }
|
|
320
|
+
});
|
|
321
|
+
return i.set(l, f), f;
|
|
322
|
+
}
|
|
323
|
+
return {
|
|
324
|
+
...n,
|
|
325
|
+
async persisterFn(e, t, r) {
|
|
326
|
+
let i = N(r);
|
|
327
|
+
if (!i) return n.persisterFn(e, t, r);
|
|
328
|
+
let o = O();
|
|
329
|
+
return o ? a(o, i.cacheName, i.maxEntries, i.refetchOnRestore, i.monotonicRevisionField).persisterFn(e, t, r) : Promise.resolve(e(t));
|
|
330
|
+
}
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
//#endregion
|
|
334
|
+
//#region src/query-client/queryMeta.ts
|
|
335
|
+
var L = { persist: !0 }, R = { sessionScoped: !0 };
|
|
336
|
+
function z(e) {
|
|
337
|
+
let t = e.cacheName.trim();
|
|
338
|
+
if (!/^[a-z0-9][a-z0-9_-]{0,63}$/u.test(t)) throw Error("Имя session query cache должно содержать только строчные латинские буквы, цифры, _ и -");
|
|
339
|
+
if (!Number.isSafeInteger(e.maxEntries) || e.maxEntries < 1 || e.maxEntries > 5e3) throw Error("Лимит session query cache должен быть целым числом от 1 до 5000");
|
|
340
|
+
if (e.refetchOnRestore !== void 0 && typeof e.refetchOnRestore != "boolean") throw Error("Политика refetch после восстановления должна быть boolean");
|
|
341
|
+
let n = e.monotonicRevisionField?.trim();
|
|
342
|
+
if (n !== void 0 && !/^[A-Za-z][A-Za-z0-9_]{0,63}$/u.test(n)) throw Error("Имя поля монотонной ревизии должно быть JavaScript-идентификатором длиной до 64 символов");
|
|
343
|
+
return {
|
|
344
|
+
sessionScoped: !0,
|
|
345
|
+
sessionPersistence: {
|
|
346
|
+
cacheName: t,
|
|
347
|
+
maxEntries: e.maxEntries,
|
|
348
|
+
...e.refetchOnRestore === void 0 ? {} : { refetchOnRestore: e.refetchOnRestore },
|
|
349
|
+
...n === void 0 ? {} : { monotonicRevisionField: n }
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
//#endregion
|
|
354
|
+
//#region src/query-client/queryClient.ts
|
|
355
|
+
function B({ onQueryError: e, onMutationError: t }) {
|
|
356
|
+
let n = I();
|
|
357
|
+
return new o({
|
|
358
|
+
queryCache: new a({ onError: e }),
|
|
359
|
+
mutationCache: new i({ onError: t }),
|
|
360
|
+
defaultOptions: {
|
|
361
|
+
queries: {
|
|
362
|
+
staleTime: 6e5,
|
|
363
|
+
gcTime: 18e5,
|
|
364
|
+
throwOnError: !1,
|
|
365
|
+
retry: !1,
|
|
366
|
+
...n ? { persister: n.persisterFn } : {}
|
|
367
|
+
},
|
|
368
|
+
mutations: {
|
|
369
|
+
throwOnError: !1,
|
|
370
|
+
retry: !1
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
async function V(e, t, n) {
|
|
376
|
+
await e.cancelQueries({ queryKey: t });
|
|
377
|
+
let r = e.getQueryData(t);
|
|
378
|
+
return e.setQueryData(t, n), { previous: r };
|
|
379
|
+
}
|
|
380
|
+
function H(e, t, n) {
|
|
381
|
+
n?.previous !== void 0 && e.setQueryData(t, n.previous);
|
|
382
|
+
}
|
|
383
|
+
function U(e, t, n, r) {
|
|
384
|
+
e.setQueryData(t, (e) => r(e, n));
|
|
385
|
+
}
|
|
386
|
+
async function W(e, t, n) {
|
|
387
|
+
let r = n?.refetchType ?? "none", i = G(t) ? t : [t];
|
|
388
|
+
await Promise.all(i.map((t) => e.invalidateQueries({
|
|
389
|
+
queryKey: t,
|
|
390
|
+
refetchType: r
|
|
391
|
+
})));
|
|
392
|
+
}
|
|
393
|
+
function G(e) {
|
|
394
|
+
return Array.isArray(e) ? Array.isArray(e[0]) : !1;
|
|
395
|
+
}
|
|
396
|
+
//#endregion
|
|
397
|
+
//#region src/query-client/sessionScopedResetLifecycle.ts
|
|
398
|
+
var K = /* @__PURE__ */ new WeakMap();
|
|
399
|
+
function q(e) {
|
|
400
|
+
let t = K.get(e);
|
|
401
|
+
if (t) return t;
|
|
402
|
+
let n = {
|
|
403
|
+
registrations: /* @__PURE__ */ new Set(),
|
|
404
|
+
activeResets: 0
|
|
405
|
+
};
|
|
406
|
+
return K.set(e, n), n;
|
|
407
|
+
}
|
|
408
|
+
function J(e, t) {
|
|
409
|
+
t.activeResets === 0 && t.registrations.size === 0 && K.get(e) === t && K.delete(e);
|
|
410
|
+
}
|
|
411
|
+
function ae(e, t) {
|
|
412
|
+
let n = q(e);
|
|
413
|
+
if (n.activeResets > 0) throw Error("Lifecycle session-scoped Query нельзя установить во время сброса");
|
|
414
|
+
let r = {
|
|
415
|
+
beforeReset: t.beforeReset,
|
|
416
|
+
afterReset: t.afterReset
|
|
417
|
+
};
|
|
418
|
+
n.registrations.add(r);
|
|
419
|
+
let i = !1;
|
|
420
|
+
return { cleanup() {
|
|
421
|
+
i || (i = !0, n.registrations.delete(r), J(e, n));
|
|
422
|
+
} };
|
|
423
|
+
}
|
|
424
|
+
function oe(e) {
|
|
425
|
+
let t = q(e);
|
|
426
|
+
t.activeResets += 1;
|
|
427
|
+
let n = [...t.registrations], r = n.map(({ beforeReset: e }) => {
|
|
428
|
+
try {
|
|
429
|
+
return Promise.resolve(e());
|
|
430
|
+
} catch (e) {
|
|
431
|
+
return Promise.reject(e);
|
|
432
|
+
}
|
|
433
|
+
});
|
|
434
|
+
return {
|
|
435
|
+
retirement: n.length === 0 ? null : Y(r),
|
|
436
|
+
async complete(r) {
|
|
437
|
+
try {
|
|
438
|
+
return await Y(n.map(({ afterReset: e }) => {
|
|
439
|
+
try {
|
|
440
|
+
return Promise.resolve(e(r));
|
|
441
|
+
} catch (e) {
|
|
442
|
+
return Promise.reject(e);
|
|
443
|
+
}
|
|
444
|
+
}));
|
|
445
|
+
} finally {
|
|
446
|
+
--t.activeResets, J(e, t);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
async function Y(e) {
|
|
452
|
+
return (await Promise.allSettled(e)).flatMap((e) => e.status === "rejected" ? [e.reason] : []);
|
|
453
|
+
}
|
|
454
|
+
//#endregion
|
|
455
|
+
//#region src/query-client/sessionScoped.ts
|
|
456
|
+
var X = "session-scoped-query-cache-reset", Z;
|
|
457
|
+
function Q(e) {
|
|
458
|
+
return e.meta?.sessionScoped === !0;
|
|
459
|
+
}
|
|
460
|
+
async function $(e, t = {}) {
|
|
461
|
+
let n = oe(e), r = { predicate: Q }, i = [];
|
|
462
|
+
try {
|
|
463
|
+
n.retirement && i.push(...await n.retirement);
|
|
464
|
+
try {
|
|
465
|
+
await e.cancelQueries(r);
|
|
466
|
+
} catch (e) {
|
|
467
|
+
i.push(e);
|
|
468
|
+
}
|
|
469
|
+
let a = e.getQueryCache().findAll(r);
|
|
470
|
+
for (let t of a) try {
|
|
471
|
+
if (t.getObserversCount() === 0) e.getQueryCache().remove(t);
|
|
472
|
+
else try {
|
|
473
|
+
t.reset();
|
|
474
|
+
} finally {
|
|
475
|
+
t.setState({
|
|
476
|
+
data: void 0,
|
|
477
|
+
dataUpdatedAt: 0
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
} catch (e) {
|
|
481
|
+
i.push(e);
|
|
482
|
+
}
|
|
483
|
+
i.length === 0 && (await e.refetchQueries({
|
|
484
|
+
predicate: (e) => Q(e) && e.getObserversCount() > 0,
|
|
485
|
+
type: "active"
|
|
486
|
+
}, { cancelRefetch: !0 }), t.broadcast !== !1 && Z?.());
|
|
487
|
+
} catch (e) {
|
|
488
|
+
i.push(e);
|
|
489
|
+
} finally {
|
|
490
|
+
i.push(...await n.complete({ status: i.length === 0 ? "completed" : "failed" }));
|
|
491
|
+
}
|
|
492
|
+
if (i.length === 1) throw i[0];
|
|
493
|
+
if (i.length > 1) throw AggregateError(i, "Не удалось завершить сброс session-scoped Query");
|
|
494
|
+
}
|
|
495
|
+
function se(e, t) {
|
|
496
|
+
if (typeof window > "u" || typeof BroadcastChannel > "u") return { cleanup: () => void 0 };
|
|
497
|
+
let n = new BroadcastChannel(t.channelName), r = () => {
|
|
498
|
+
let e = { type: X };
|
|
499
|
+
n.postMessage(e);
|
|
500
|
+
};
|
|
501
|
+
Z = r, n.onmessage = (n) => {
|
|
502
|
+
ce(n.data) && $(e, { broadcast: !1 }).catch(async (e) => {
|
|
503
|
+
if (!t.onError) {
|
|
504
|
+
console.error("Не удалось обработать межвкладочный сброс session-scoped Query", e);
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
try {
|
|
508
|
+
await t.onError(e);
|
|
509
|
+
} catch (t) {
|
|
510
|
+
console.error("Не удалось сообщить об ошибке межвкладочного сброса session-scoped Query", AggregateError([e, t], "Ошибка сброса и её обработчика"));
|
|
511
|
+
}
|
|
512
|
+
});
|
|
513
|
+
};
|
|
514
|
+
let i = !1;
|
|
515
|
+
return { cleanup: () => {
|
|
516
|
+
i || (i = !0, n.onmessage = null, n.close(), Z === r && (Z = void 0));
|
|
517
|
+
} };
|
|
518
|
+
}
|
|
519
|
+
function ce(e) {
|
|
520
|
+
return typeof e == "object" && !!e && "type" in e && e.type === X;
|
|
521
|
+
}
|
|
522
|
+
//#endregion
|
|
523
|
+
export { te as C, c as E, m as S, u as T, I as _, B as a, M as b, W as c, L as d, R as f, F as g, A as h, ae as i, U as l, _ as m, Q as n, H as o, g as p, $ as r, V as s, se as t, z as u, O as v, l as w, ne as x, j as y };
|
|
524
|
+
|
|
525
|
+
//# sourceMappingURL=query-client-BsiuEoJD.js.map
|