@ryuzaki13/react-foundation-lib 2.23.0 → 2.25.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/dist/analytical-table/index.js +1 -1
- package/dist/chunks/{formatters-D1ob2OkI.js → formatters-DVqfmx3V.js} +288 -278
- package/dist/chunks/formatters-DVqfmx3V.js.map +1 -0
- package/dist/chunks/{query-client-Gk7lxFz7.js → query-client-Dj_zNE22.js} +243 -154
- package/dist/chunks/query-client-Dj_zNE22.js.map +1 -0
- package/dist/error-report/index.js +2 -2
- package/dist/formatters/formatDurationMinutes.d.ts +7 -0
- package/dist/formatters/formatDurationMinutes.d.ts.map +1 -0
- package/dist/formatters/index.d.ts +1 -0
- package/dist/formatters/index.d.ts.map +1 -1
- package/dist/formatters/index.js +5 -5
- package/dist/indexed-records/createIndexedRecords.d.ts +8 -0
- package/dist/indexed-records/createIndexedRecords.d.ts.map +1 -0
- package/dist/indexed-records/getIndexedRecord.d.ts +9 -0
- package/dist/indexed-records/getIndexedRecord.d.ts.map +1 -0
- package/dist/indexed-records/index.d.ts +4 -0
- package/dist/indexed-records/index.d.ts.map +1 -0
- package/dist/indexed-records/index.js +22 -0
- package/dist/indexed-records/index.js.map +1 -0
- package/dist/indexed-records/indexedRecordsTypes.d.ts +12 -0
- package/dist/indexed-records/indexedRecordsTypes.d.ts.map +1 -0
- package/dist/query-client/createQueryRestoreSchedulerGuard.d.ts +9 -0
- package/dist/query-client/createQueryRestoreSchedulerGuard.d.ts.map +1 -0
- package/dist/query-client/createQueryRestoreStorage.d.ts +9 -0
- package/dist/query-client/createQueryRestoreStorage.d.ts.map +1 -0
- package/dist/query-client/index.js +2 -2
- package/dist/query-client/persistence.d.ts.map +1 -1
- package/dist/query-client/queryMeta.d.ts +13 -0
- package/dist/query-client/queryMeta.d.ts.map +1 -1
- package/dist/query-client/queryRestoreSchedulerTypes.d.ts +7 -0
- package/dist/query-client/queryRestoreSchedulerTypes.d.ts.map +1 -0
- package/dist/query-client/queryRestoreStorageTypes.d.ts +13 -0
- package/dist/query-client/queryRestoreStorageTypes.d.ts.map +1 -0
- package/package.json +5 -1
- package/src/formatters/README.mdx +18 -0
- package/src/indexed-records/README.md +32 -0
- package/src/query-client/README.mdx +55 -7
- package/dist/chunks/formatters-D1ob2OkI.js.map +0 -1
- package/dist/chunks/query-client-Gk7lxFz7.js.map +0 -1
|
@@ -2,16 +2,16 @@ import { i as e } from "./isRecord-DXDTW-jA.js";
|
|
|
2
2
|
import { uuidv4 as t } from "../crypto/index.js";
|
|
3
3
|
import { broadcastQueryClient as n } from "@tanstack/query-broadcast-client-experimental";
|
|
4
4
|
import { experimental_createQueryPersister as r } from "@tanstack/query-persist-client-core";
|
|
5
|
-
import {
|
|
5
|
+
import { CancelledError as i, MutationCache as a, QueryCache as o, QueryClient as s, isCancelledError as c } from "@tanstack/react-query";
|
|
6
6
|
//#region src/query-client/broadcast.ts
|
|
7
|
-
var
|
|
8
|
-
function
|
|
9
|
-
|
|
7
|
+
var l = null;
|
|
8
|
+
function u(e) {
|
|
9
|
+
l = e;
|
|
10
10
|
}
|
|
11
|
-
function
|
|
12
|
-
|
|
11
|
+
function d(e) {
|
|
12
|
+
l?.(e);
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function f(e, r) {
|
|
15
15
|
if (typeof window > "u") return {
|
|
16
16
|
broadcast: () => {},
|
|
17
17
|
cleanup: () => {}
|
|
@@ -28,7 +28,7 @@ function u(e, r) {
|
|
|
28
28
|
});
|
|
29
29
|
s.onmessage = (t) => {
|
|
30
30
|
let n = t.data;
|
|
31
|
-
if (!
|
|
31
|
+
if (!p(n) || n.tabId === o) return;
|
|
32
32
|
let r = n.event;
|
|
33
33
|
i = !0;
|
|
34
34
|
try {
|
|
@@ -62,18 +62,18 @@ function u(e, r) {
|
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
|
-
function
|
|
66
|
-
return !e(t) || typeof t.tabId != "string" || !("event" in t) ? !1 :
|
|
65
|
+
function p(t) {
|
|
66
|
+
return !e(t) || typeof t.tabId != "string" || !("event" in t) ? !1 : m(t.event);
|
|
67
67
|
}
|
|
68
|
-
function
|
|
68
|
+
function m(t) {
|
|
69
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
70
|
}
|
|
71
71
|
//#endregion
|
|
72
72
|
//#region src/query-client/invalidationBroadcast.ts
|
|
73
|
-
function
|
|
73
|
+
function h(t) {
|
|
74
74
|
return e(t) && t.type === "query.invalidate" && typeof t.senderId == "string" && Array.isArray(t.queryKey);
|
|
75
75
|
}
|
|
76
|
-
function
|
|
76
|
+
function g(e, n) {
|
|
77
77
|
if (typeof window > "u" || typeof BroadcastChannel > "u") return {
|
|
78
78
|
broadcast: () => void 0,
|
|
79
79
|
cleanup: () => void 0
|
|
@@ -89,7 +89,7 @@ function te(e, n) {
|
|
|
89
89
|
});
|
|
90
90
|
return i.onmessage = (t) => {
|
|
91
91
|
let i = t.data;
|
|
92
|
-
if (!(o || !
|
|
92
|
+
if (!(o || !h(i) || i.senderId === r || !n.matchesQuery(i.queryKey))) {
|
|
93
93
|
a = !0;
|
|
94
94
|
try {
|
|
95
95
|
e.cancelQueries({
|
|
@@ -112,80 +112,154 @@ function te(e, n) {
|
|
|
112
112
|
};
|
|
113
113
|
}
|
|
114
114
|
//#endregion
|
|
115
|
-
//#region src/query-client/
|
|
116
|
-
|
|
115
|
+
//#region src/query-client/createQueryRestoreSchedulerGuard.ts
|
|
116
|
+
function _({ query: e, assertCurrentRestore: t }) {
|
|
117
|
+
let n = () => {
|
|
118
|
+
try {
|
|
119
|
+
return t(), !0;
|
|
120
|
+
} catch (e) {
|
|
121
|
+
if (!c(e)) throw e;
|
|
122
|
+
return !1;
|
|
123
|
+
}
|
|
124
|
+
}, r = (...t) => {
|
|
125
|
+
n() && e.setState(...t);
|
|
126
|
+
}, i = (...t) => n() ? e.fetch(...t) : Promise.resolve();
|
|
127
|
+
return new Proxy(e, { get: (e, t) => {
|
|
128
|
+
if (t === "setState") return r;
|
|
129
|
+
if (t === "fetch") return i;
|
|
130
|
+
let n = Reflect.get(e, t, e);
|
|
131
|
+
return typeof n == "function" ? n.bind(e) : n;
|
|
132
|
+
} });
|
|
133
|
+
}
|
|
134
|
+
//#endregion
|
|
135
|
+
//#region src/query-client/createQueryRestoreStorage.ts
|
|
136
|
+
function ee({ storage: e, queryHash: t, prefix: n, buster: r, maxAge: i, parser: a, assertCurrentRestore: o }) {
|
|
137
|
+
return {
|
|
138
|
+
...e,
|
|
139
|
+
removeItem: (t) => {
|
|
140
|
+
try {
|
|
141
|
+
o();
|
|
142
|
+
} catch (e) {
|
|
143
|
+
if (c(e)) return;
|
|
144
|
+
throw e;
|
|
145
|
+
}
|
|
146
|
+
return e.removeItem(t);
|
|
147
|
+
},
|
|
148
|
+
getItem: async (s) => {
|
|
149
|
+
let c = await e.getItem(s);
|
|
150
|
+
if (!c) return c;
|
|
151
|
+
if (o(), s !== `${n}-${t}` || c.queryHash !== t) throw Error("Persisted запись не соответствует восстанавливаемой Query identity.");
|
|
152
|
+
let l = c.state?.dataUpdatedAt;
|
|
153
|
+
if (!l || Date.now() - l > i || c.buster !== r) return c;
|
|
154
|
+
if (typeof l != "number" || !Number.isFinite(l)) throw Error("Persisted запись содержит некорректное время обновления.");
|
|
155
|
+
let u = a(c.state.data);
|
|
156
|
+
if ((typeof u == "object" || typeof u == "function") && u !== null && typeof Reflect.get(u, "then") == "function") throw Promise.resolve(u).catch(() => void 0), TypeError("Parser восстановленных Query data должен синхронно вернуть значение.");
|
|
157
|
+
if (u === void 0) throw TypeError("Parser восстановленных Query data должен синхронно вернуть значение.");
|
|
158
|
+
return o(), {
|
|
159
|
+
...c,
|
|
160
|
+
state: {
|
|
161
|
+
...c.state,
|
|
162
|
+
data: u
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
//#endregion
|
|
169
|
+
//#region src/query-client/queryMeta.ts
|
|
170
|
+
var v = Symbol("query-restored-data-parser"), y = { persist: !0 }, te = { sessionScoped: !0 };
|
|
117
171
|
function ne(e) {
|
|
118
|
-
|
|
172
|
+
let t = e.cacheName.trim();
|
|
173
|
+
if (!/^[a-z0-9][a-z0-9_-]{0,63}$/u.test(t)) throw Error("Имя session query cache должно содержать только строчные латинские буквы, цифры, _ и -");
|
|
174
|
+
if (!Number.isSafeInteger(e.maxEntries) || e.maxEntries < 1 || e.maxEntries > 5e3) throw Error("Лимит session query cache должен быть целым числом от 1 до 5000");
|
|
175
|
+
if (e.refetchOnRestore !== void 0 && typeof e.refetchOnRestore != "boolean") throw Error("Политика refetch после восстановления должна быть boolean");
|
|
176
|
+
let n = e.monotonicRevisionField?.trim();
|
|
177
|
+
if (n !== void 0 && !/^[A-Za-z][A-Za-z0-9_]{0,63}$/u.test(n)) throw Error("Имя поля монотонной ревизии должно быть JavaScript-идентификатором длиной до 64 символов");
|
|
178
|
+
return {
|
|
179
|
+
sessionScoped: !0,
|
|
180
|
+
sessionPersistence: {
|
|
181
|
+
cacheName: t,
|
|
182
|
+
maxEntries: e.maxEntries,
|
|
183
|
+
...e.refetchOnRestore === void 0 ? {} : { refetchOnRestore: e.refetchOnRestore },
|
|
184
|
+
...n === void 0 ? {} : { monotonicRevisionField: n }
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
//#endregion
|
|
189
|
+
//#region src/query-client/queryPersistenceAdapter.ts
|
|
190
|
+
var b = {};
|
|
191
|
+
function x(e) {
|
|
192
|
+
b = e;
|
|
119
193
|
}
|
|
120
|
-
function
|
|
121
|
-
return
|
|
194
|
+
function S() {
|
|
195
|
+
return b;
|
|
122
196
|
}
|
|
123
197
|
//#endregion
|
|
124
198
|
//#region src/query-client/persistence.ts
|
|
125
|
-
var
|
|
126
|
-
function
|
|
199
|
+
var re = "queries", ie = "session", C = __REACT_QUERY_PERSISTENCE_BUSTER__, w = 7776e6, T = null;
|
|
200
|
+
function ae(e) {
|
|
127
201
|
if (e) return e;
|
|
128
202
|
if (globalThis.indexedDB !== void 0) return globalThis.indexedDB;
|
|
129
203
|
}
|
|
130
|
-
function
|
|
204
|
+
function E(e) {
|
|
131
205
|
return new Promise((t, n) => {
|
|
132
206
|
e.onsuccess = () => t(e.result), e.onerror = () => n(e.error);
|
|
133
207
|
});
|
|
134
208
|
}
|
|
135
|
-
function
|
|
209
|
+
function D() {
|
|
136
210
|
if (__DEV__) return `dev:${__APP_ID__}`;
|
|
137
|
-
let e =
|
|
211
|
+
let e = S().resolveSystemIdentifier?.();
|
|
138
212
|
if (e) return e;
|
|
139
213
|
let t = typeof window > "u" ? "server" : window.location.hostname;
|
|
140
214
|
return `${__APP_ID__}:${t}`;
|
|
141
215
|
}
|
|
142
|
-
function
|
|
143
|
-
return `${
|
|
216
|
+
function O() {
|
|
217
|
+
return `${D()}`;
|
|
144
218
|
}
|
|
145
|
-
function
|
|
219
|
+
function k(e) {
|
|
146
220
|
return encodeURIComponent(e);
|
|
147
221
|
}
|
|
148
|
-
function
|
|
149
|
-
return `${
|
|
222
|
+
function A() {
|
|
223
|
+
return `${O()}-${ie}-`;
|
|
150
224
|
}
|
|
151
|
-
function
|
|
152
|
-
return `${
|
|
225
|
+
function j(e) {
|
|
226
|
+
return `${A()}${k(e)}-`;
|
|
153
227
|
}
|
|
154
|
-
function
|
|
155
|
-
return `${
|
|
228
|
+
function oe(e, t) {
|
|
229
|
+
return `${j(e)}${k(t)}`;
|
|
156
230
|
}
|
|
157
|
-
function
|
|
231
|
+
function M(e) {
|
|
158
232
|
return !!e?.id.trim() && Number.isFinite(Date.parse(e?.expiresAt ?? "")) && Date.parse(e?.expiresAt ?? "") > Date.now();
|
|
159
233
|
}
|
|
160
|
-
function
|
|
161
|
-
return
|
|
234
|
+
function N() {
|
|
235
|
+
return M(T) ? T : null;
|
|
162
236
|
}
|
|
163
|
-
async function
|
|
164
|
-
let t =
|
|
237
|
+
async function P(e) {
|
|
238
|
+
let t = z();
|
|
165
239
|
if (!t?.entries) return;
|
|
166
240
|
let n = await t.entries();
|
|
167
241
|
await Promise.all(n.filter(([t]) => e(t)).map(([e]) => t.removeItem(e)));
|
|
168
242
|
}
|
|
169
|
-
async function
|
|
170
|
-
let t = e === void 0 ?
|
|
171
|
-
await
|
|
243
|
+
async function F(e) {
|
|
244
|
+
let t = e === void 0 ? A() : j(e);
|
|
245
|
+
await P((e) => e.startsWith(t));
|
|
172
246
|
}
|
|
173
|
-
async function
|
|
174
|
-
let t = e &&
|
|
247
|
+
async function se(e) {
|
|
248
|
+
let t = e && M(e) ? {
|
|
175
249
|
id: e.id.trim(),
|
|
176
250
|
expiresAt: e.expiresAt
|
|
177
251
|
} : null;
|
|
178
|
-
if (
|
|
179
|
-
await
|
|
252
|
+
if (T = t, !t) {
|
|
253
|
+
await F();
|
|
180
254
|
return;
|
|
181
255
|
}
|
|
182
|
-
let n =
|
|
183
|
-
await
|
|
256
|
+
let n = j(t.id);
|
|
257
|
+
await P((e) => e.startsWith(A()) && !e.startsWith(n));
|
|
184
258
|
}
|
|
185
|
-
function
|
|
259
|
+
function I(e) {
|
|
186
260
|
return e.meta?.persist === !0 && e.meta.sessionScoped !== !0;
|
|
187
261
|
}
|
|
188
|
-
function
|
|
262
|
+
function L(e) {
|
|
189
263
|
let t = e.meta?.sessionPersistence;
|
|
190
264
|
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;
|
|
191
265
|
let n = "refetchOnRestore" in t ? t.refetchOnRestore : void 0;
|
|
@@ -198,19 +272,19 @@ function N(e) {
|
|
|
198
272
|
monotonicRevisionField: r
|
|
199
273
|
};
|
|
200
274
|
}
|
|
201
|
-
function
|
|
275
|
+
function R(e, t) {
|
|
202
276
|
let n = e.state.data;
|
|
203
277
|
if (typeof n != "object" || !n || Array.isArray(n)) return null;
|
|
204
278
|
let r = Reflect.get(n, t);
|
|
205
279
|
return typeof r != "string" || !/^\d+$/u.test(r) ? null : r.replace(/^0+(?=\d)/u, "");
|
|
206
280
|
}
|
|
207
|
-
function
|
|
281
|
+
function ce(e, t) {
|
|
208
282
|
return e.length === t.length ? e === t ? 0 : e < t ? -1 : 1 : e.length - t.length;
|
|
209
283
|
}
|
|
210
|
-
function
|
|
211
|
-
let t =
|
|
284
|
+
function z(e = {}) {
|
|
285
|
+
let t = ae(e.indexedDB);
|
|
212
286
|
if (!t) return;
|
|
213
|
-
let n = t, r = e.dbName ??
|
|
287
|
+
let n = t, r = e.dbName ?? D(), i = e.storeName ?? re, a = null;
|
|
214
288
|
function o() {
|
|
215
289
|
return a || (a = new Promise((e, t) => {
|
|
216
290
|
let a = n.open(r, 1);
|
|
@@ -221,7 +295,7 @@ function F(e = {}) {
|
|
|
221
295
|
}), a);
|
|
222
296
|
}
|
|
223
297
|
async function s(e, t) {
|
|
224
|
-
return
|
|
298
|
+
return E(t((await o()).transaction(i, e).objectStore(i)));
|
|
225
299
|
}
|
|
226
300
|
async function c(e, t) {
|
|
227
301
|
let n = await o();
|
|
@@ -270,96 +344,111 @@ function F(e = {}) {
|
|
|
270
344
|
}
|
|
271
345
|
};
|
|
272
346
|
}
|
|
273
|
-
function
|
|
274
|
-
let e =
|
|
347
|
+
function B() {
|
|
348
|
+
let e = z();
|
|
275
349
|
if (!e) return;
|
|
276
350
|
let t = e, n = r({
|
|
277
351
|
storage: t,
|
|
278
352
|
serialize: (e) => e,
|
|
279
353
|
deserialize: (e) => e,
|
|
280
|
-
prefix:
|
|
281
|
-
buster:
|
|
282
|
-
maxAge:
|
|
354
|
+
prefix: O(),
|
|
355
|
+
buster: S().persistenceBuster ?? C,
|
|
356
|
+
maxAge: w,
|
|
283
357
|
refetchOnRestore: !0,
|
|
284
|
-
filters: { predicate:
|
|
285
|
-
}),
|
|
286
|
-
function
|
|
287
|
-
let c =
|
|
358
|
+
filters: { predicate: I }
|
|
359
|
+
}), a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new WeakMap();
|
|
360
|
+
function s(e, n, i, o = !0, s) {
|
|
361
|
+
let c = oe(e.id, n), l = `${c}:${i}:${o}:${s ?? ""}:${e.expiresAt}`, u = a.get(l);
|
|
288
362
|
if (u) return u;
|
|
289
|
-
let d = Promise.resolve(), f =
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
setItem:
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
363
|
+
let d = Promise.resolve(), f = {
|
|
364
|
+
getItem: (n) => N()?.id === e.id ? t.getItem(n) : void 0,
|
|
365
|
+
removeItem: (e) => t.removeItem(e),
|
|
366
|
+
entries: () => t.entries(),
|
|
367
|
+
setItem: async (n, r) => {
|
|
368
|
+
N()?.id === e.id && (s === void 0 ? await t.setItem(n, r) : await t.updateItem(n, (e) => {
|
|
369
|
+
if (!e || e.buster !== r.buster) return {
|
|
370
|
+
action: "set",
|
|
371
|
+
value: r,
|
|
372
|
+
result: void 0
|
|
373
|
+
};
|
|
374
|
+
let t = R(e, s), n = R(r, s);
|
|
375
|
+
return t !== null && n !== null && ce(t, n) > 0 ? {
|
|
376
|
+
action: "keep",
|
|
377
|
+
result: void 0
|
|
378
|
+
} : {
|
|
379
|
+
action: "set",
|
|
380
|
+
value: r,
|
|
381
|
+
result: void 0
|
|
382
|
+
};
|
|
383
|
+
}), d = d.then(async () => {
|
|
384
|
+
let e = (await t.entries()).filter(([e]) => e.startsWith(`${c}-`));
|
|
385
|
+
e.sort((e, t) => (t[1].state.dataUpdatedAt ?? 0) - (e[1].state.dataUpdatedAt ?? 0)), await Promise.all(e.slice(i).map(([e]) => t.removeItem(e)));
|
|
386
|
+
}), await d);
|
|
387
|
+
}
|
|
388
|
+
}, p = {
|
|
389
|
+
persister: r({
|
|
390
|
+
storage: f,
|
|
391
|
+
serialize: (e) => e,
|
|
392
|
+
deserialize: (e) => e,
|
|
393
|
+
prefix: c,
|
|
394
|
+
buster: S().persistenceBuster ?? C,
|
|
395
|
+
maxAge: w,
|
|
396
|
+
refetchOnRestore: o,
|
|
397
|
+
filters: { predicate: (e) => L(e)?.cacheName === n }
|
|
398
|
+
}),
|
|
399
|
+
storage: f,
|
|
400
|
+
prefix: c
|
|
401
|
+
};
|
|
402
|
+
return a.set(l, p), p;
|
|
325
403
|
}
|
|
326
404
|
return {
|
|
327
405
|
...n,
|
|
328
|
-
async persisterFn(e,
|
|
329
|
-
let
|
|
330
|
-
if (!
|
|
331
|
-
let
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
406
|
+
async persisterFn(e, a, c) {
|
|
407
|
+
let l = L(c), u = N();
|
|
408
|
+
if (l && !u) return Promise.resolve(e(a));
|
|
409
|
+
let d = l && u ? s(u, l.cacheName, l.maxEntries, l.refetchOnRestore, l.monotonicRevisionField) : {
|
|
410
|
+
persister: n,
|
|
411
|
+
storage: t,
|
|
412
|
+
prefix: O()
|
|
413
|
+
}, f = c.meta?.[v];
|
|
414
|
+
if (f === void 0) return o.delete(c), d.persister.persisterFn(e, a, c);
|
|
415
|
+
if (typeof f != "function") throw TypeError("Parser восстановленных Query data должен быть функцией.");
|
|
416
|
+
let p = {};
|
|
417
|
+
o.set(c, p);
|
|
418
|
+
let m = () => {
|
|
419
|
+
if (a.signal.aborted || o.get(c) !== p || l && N()?.id !== u?.id) throw new i({ revert: !0 });
|
|
420
|
+
}, h = S().persistenceBuster ?? C, g = ee({
|
|
421
|
+
storage: d.storage,
|
|
422
|
+
queryHash: c.queryHash,
|
|
423
|
+
prefix: d.prefix,
|
|
424
|
+
buster: h,
|
|
425
|
+
maxAge: w,
|
|
426
|
+
parser: f,
|
|
427
|
+
assertCurrentRestore: m
|
|
428
|
+
}), y = await r({
|
|
429
|
+
storage: g,
|
|
430
|
+
serialize: (e) => e,
|
|
431
|
+
deserialize: (e) => e,
|
|
432
|
+
prefix: d.prefix,
|
|
433
|
+
buster: h,
|
|
434
|
+
maxAge: w,
|
|
435
|
+
refetchOnRestore: l?.refetchOnRestore ?? !0,
|
|
436
|
+
filters: l ? { predicate: (e) => L(e)?.cacheName === l.cacheName } : { predicate: I }
|
|
437
|
+
}).persisterFn((t) => (m(), e(t)), a, _({
|
|
438
|
+
query: c,
|
|
439
|
+
assertCurrentRestore: m
|
|
440
|
+
}));
|
|
441
|
+
return m(), y;
|
|
353
442
|
}
|
|
354
443
|
};
|
|
355
444
|
}
|
|
356
445
|
//#endregion
|
|
357
446
|
//#region src/query-client/queryClient.ts
|
|
358
|
-
function
|
|
359
|
-
let n =
|
|
360
|
-
return new
|
|
361
|
-
queryCache: new
|
|
362
|
-
mutationCache: new
|
|
447
|
+
function V({ onQueryError: e, onMutationError: t }) {
|
|
448
|
+
let n = B();
|
|
449
|
+
return new s({
|
|
450
|
+
queryCache: new o({ onError: e }),
|
|
451
|
+
mutationCache: new a({ onError: t }),
|
|
363
452
|
defaultOptions: {
|
|
364
453
|
queries: {
|
|
365
454
|
staleTime: 6e5,
|
|
@@ -375,44 +464,44 @@ function B({ onQueryError: e, onMutationError: t }) {
|
|
|
375
464
|
}
|
|
376
465
|
});
|
|
377
466
|
}
|
|
378
|
-
async function
|
|
467
|
+
async function H(e, t, n) {
|
|
379
468
|
await e.cancelQueries({ queryKey: t });
|
|
380
469
|
let r = e.getQueryData(t);
|
|
381
470
|
return e.setQueryData(t, n), { previous: r };
|
|
382
471
|
}
|
|
383
|
-
function
|
|
472
|
+
function U(e, t, n) {
|
|
384
473
|
n?.previous !== void 0 && e.setQueryData(t, n.previous);
|
|
385
474
|
}
|
|
386
|
-
function
|
|
475
|
+
function W(e, t, n, r) {
|
|
387
476
|
e.setQueryData(t, (e) => r(e, n));
|
|
388
477
|
}
|
|
389
|
-
async function
|
|
390
|
-
let r = n?.refetchType ?? "none", i =
|
|
478
|
+
async function le(e, t, n) {
|
|
479
|
+
let r = n?.refetchType ?? "none", i = ue(t) ? t : [t];
|
|
391
480
|
await Promise.all(i.map((t) => e.invalidateQueries({
|
|
392
481
|
queryKey: t,
|
|
393
482
|
refetchType: r
|
|
394
483
|
})));
|
|
395
484
|
}
|
|
396
|
-
function
|
|
485
|
+
function ue(e) {
|
|
397
486
|
return Array.isArray(e) ? Array.isArray(e[0]) : !1;
|
|
398
487
|
}
|
|
399
488
|
//#endregion
|
|
400
489
|
//#region src/query-client/sessionScopedResetLifecycle.ts
|
|
401
|
-
var
|
|
402
|
-
function
|
|
403
|
-
let t =
|
|
490
|
+
var G = /* @__PURE__ */ new WeakMap();
|
|
491
|
+
function K(e) {
|
|
492
|
+
let t = G.get(e);
|
|
404
493
|
if (t) return t;
|
|
405
494
|
let n = {
|
|
406
495
|
registrations: /* @__PURE__ */ new Set(),
|
|
407
496
|
activeResets: 0
|
|
408
497
|
};
|
|
409
|
-
return
|
|
498
|
+
return G.set(e, n), n;
|
|
410
499
|
}
|
|
411
|
-
function
|
|
412
|
-
t.activeResets === 0 && t.registrations.size === 0 &&
|
|
500
|
+
function q(e, t) {
|
|
501
|
+
t.activeResets === 0 && t.registrations.size === 0 && G.get(e) === t && G.delete(e);
|
|
413
502
|
}
|
|
414
|
-
function
|
|
415
|
-
let n =
|
|
503
|
+
function J(e, t) {
|
|
504
|
+
let n = K(e);
|
|
416
505
|
if (n.activeResets > 0) throw Error("Lifecycle session-scoped Query нельзя установить во время сброса");
|
|
417
506
|
let r = {
|
|
418
507
|
beforeReset: t.beforeReset,
|
|
@@ -421,11 +510,11 @@ function ae(e, t) {
|
|
|
421
510
|
n.registrations.add(r);
|
|
422
511
|
let i = !1;
|
|
423
512
|
return { cleanup() {
|
|
424
|
-
i || (i = !0, n.registrations.delete(r),
|
|
513
|
+
i || (i = !0, n.registrations.delete(r), q(e, n));
|
|
425
514
|
} };
|
|
426
515
|
}
|
|
427
|
-
function
|
|
428
|
-
let t =
|
|
516
|
+
function de(e) {
|
|
517
|
+
let t = K(e);
|
|
429
518
|
t.activeResets += 1;
|
|
430
519
|
let n = [...t.registrations], r = n.map(({ beforeReset: e }) => {
|
|
431
520
|
try {
|
|
@@ -446,7 +535,7 @@ function oe(e) {
|
|
|
446
535
|
}
|
|
447
536
|
}));
|
|
448
537
|
} finally {
|
|
449
|
-
--t.activeResets,
|
|
538
|
+
--t.activeResets, q(e, t);
|
|
450
539
|
}
|
|
451
540
|
}
|
|
452
541
|
};
|
|
@@ -461,7 +550,7 @@ function Q(e) {
|
|
|
461
550
|
return e.meta?.sessionScoped === !0;
|
|
462
551
|
}
|
|
463
552
|
async function $(e, t = {}) {
|
|
464
|
-
let n =
|
|
553
|
+
let n = de(e), r = { predicate: Q }, i = [];
|
|
465
554
|
try {
|
|
466
555
|
n.retirement && i.push(...await n.retirement);
|
|
467
556
|
try {
|
|
@@ -495,14 +584,14 @@ async function $(e, t = {}) {
|
|
|
495
584
|
if (i.length === 1) throw i[0];
|
|
496
585
|
if (i.length > 1) throw AggregateError(i, "Не удалось завершить сброс session-scoped Query");
|
|
497
586
|
}
|
|
498
|
-
function
|
|
587
|
+
function fe(e, t) {
|
|
499
588
|
if (typeof window > "u" || typeof BroadcastChannel > "u") return { cleanup: () => void 0 };
|
|
500
589
|
let n = new BroadcastChannel(t.channelName), r = () => {
|
|
501
590
|
let e = { type: X };
|
|
502
591
|
n.postMessage(e);
|
|
503
592
|
};
|
|
504
593
|
Z = r, n.onmessage = (n) => {
|
|
505
|
-
|
|
594
|
+
pe(n.data) && $(e, { broadcast: !1 }).catch(async (e) => {
|
|
506
595
|
if (!t.onError) {
|
|
507
596
|
console.error("Не удалось обработать межвкладочный сброс session-scoped Query", e);
|
|
508
597
|
return;
|
|
@@ -519,10 +608,10 @@ function se(e, t) {
|
|
|
519
608
|
i || (i = !0, n.onmessage = null, n.close(), Z === r && (Z = void 0));
|
|
520
609
|
} };
|
|
521
610
|
}
|
|
522
|
-
function
|
|
611
|
+
function pe(e) {
|
|
523
612
|
return typeof e == "object" && !!e && "type" in e && e.type === X;
|
|
524
613
|
}
|
|
525
614
|
//#endregion
|
|
526
|
-
export { te as C,
|
|
615
|
+
export { te as C, u as D, f as E, y as S, d as T, I as _, V as a, v as b, le as c, w as d, F as f, se as g, N as h, J as i, W as l, B as m, Q as n, U as o, z as p, $ as r, H as s, fe as t, C as u, x as v, g as w, ne as x, S as y };
|
|
527
616
|
|
|
528
|
-
//# sourceMappingURL=query-client-
|
|
617
|
+
//# sourceMappingURL=query-client-Dj_zNE22.js.map
|