@pdf-viewer/react 1.14.0-beta.2 → 1.14.0-beta.3

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.
Files changed (66) hide show
  1. package/dist/{ToolbarLayout.module-c133fcc0.js → ToolbarLayout.module-f62490d8.js} +31 -31
  2. package/dist/components/RPConfig.js +10 -1489
  3. package/dist/components/RPController.js +3 -6
  4. package/dist/components/RPPages.js +5 -8
  5. package/dist/components/RPProvider.js +3 -6
  6. package/dist/components/layout/LayoutContainer.js +4 -7
  7. package/dist/components/layout/RPDefaultLayout.js +2 -5
  8. package/dist/components/layout/RPLayout.js +5 -8
  9. package/dist/components/layout/sidebar/RPSidebar.js +2 -5
  10. package/dist/components/layout/sidebar/Thumbnail.js +5 -8
  11. package/dist/components/layout/sidebar/Thumbnails.js +2 -5
  12. package/dist/components/layout/toolbar/DocumentDialog.js +5 -8
  13. package/dist/components/layout/toolbar/FileDownloadTool.js +2 -5
  14. package/dist/components/layout/toolbar/MostPageTool.js +5 -8
  15. package/dist/components/layout/toolbar/OtherTool.js +2 -5
  16. package/dist/components/layout/toolbar/Paginate.js +2 -5
  17. package/dist/components/layout/toolbar/PrintTool.js +2 -5
  18. package/dist/components/layout/toolbar/RPMoreOptions.js +9 -12
  19. package/dist/components/layout/toolbar/RPToolbar.js +2 -5
  20. package/dist/components/layout/toolbar/RPToolbarEnd.js +2 -5
  21. package/dist/components/layout/toolbar/SearchResultNavigator.js +2 -5
  22. package/dist/components/layout/toolbar/SearchTool.js +5 -8
  23. package/dist/components/layout/toolbar/ThumbnailTool.js +3 -6
  24. package/dist/components/layout/toolbar/ToolbarCustom.js +6 -9
  25. package/dist/components/layout/toolbar/ToolbarDefault.js +6 -9
  26. package/dist/components/layout/toolbar/ToolbarLayout.js +3 -6
  27. package/dist/components/layout/toolbar/ZoomTool.js +2 -5
  28. package/dist/components/layout/toolbar/tools/DocumentPropertiesTool.js +3 -6
  29. package/dist/components/layout/toolbar/tools/FileDownloadTool.js +3 -6
  30. package/dist/components/layout/toolbar/tools/InputPageTool.js +3 -6
  31. package/dist/components/layout/toolbar/tools/NextPageTool.js +6 -9
  32. package/dist/components/layout/toolbar/tools/PreviousPageTool.js +3 -6
  33. package/dist/components/layout/toolbar/tools/PrintTool.js +3 -6
  34. package/dist/components/layout/toolbar/tools/ThumbnailTool.js +3 -6
  35. package/dist/components/layout/toolbar/tools/ZoomLevelDisplay.js +5 -8
  36. package/dist/components/layout/toolbar/tools/ZoomLevelTool.js +3 -6
  37. package/dist/components/layout/toolbar/tools/defaults/RPHorizontalBar.js +6 -9
  38. package/dist/components/layout/toolbar/tools/defaults/RPVerticalBar.js +3 -6
  39. package/dist/components/layout/toolbar/tools/more-options/FileDownloadTool.js +3 -6
  40. package/dist/components/layout/toolbar/tools/more-options/FileUploadTool.js +6 -9
  41. package/dist/components/layout/toolbar/tools/more-options/MostPageTool.js +6 -9
  42. package/dist/components/layout/toolbar/tools/more-options/PrintTool.js +3 -6
  43. package/dist/components/page/AnnotationLayer.js +5 -8
  44. package/dist/components/page/CanvasLayer.js +5 -8
  45. package/dist/components/page/DualPage.js +2 -5
  46. package/dist/components/page/RPPage.js +5 -8
  47. package/dist/components/page/SinglePage.js +2 -5
  48. package/dist/components/page/TextHighlightLayer.js +5 -8
  49. package/dist/components/page/TextLayer.js +5 -8
  50. package/dist/components/ui/LoadingIndicator.js +2 -5
  51. package/dist/contexts/PaginationContext.js +4 -7
  52. package/dist/contexts/PrintContext.js +4 -7
  53. package/dist/contexts/RenderQueueProvider.js +4 -7
  54. package/dist/contexts/SearchContext.js +4 -7
  55. package/dist/contexts/ThumbnailsContext.js +4 -7
  56. package/dist/main.js +3 -3
  57. package/dist/utils/hooks/useFileDownload.js +5 -8
  58. package/dist/utils/hooks/useLicense.js +1 -1
  59. package/dist/utils/hooks/usePaginate.js +5 -8
  60. package/dist/utils/hooks/usePresentPage.js +5 -8
  61. package/dist/utils/hooks/usePrint.js +5 -8
  62. package/dist/utils/hooks/useScrollToPage.js +5 -8
  63. package/dist/utils/hooks/useSearch.js +5 -8
  64. package/dist/utils/hooks/useThumbnail.js +5 -8
  65. package/dist/utils/hooks/useVirtualReactWindow.js +5 -8
  66. package/package.json +1 -3
@@ -1,1496 +1,17 @@
1
- var St = (e, t, s) => {
2
- if (!t.has(e))
3
- throw TypeError("Cannot " + s);
4
- };
5
- var i = (e, t, s) => (St(e, t, "read from private field"), s ? s.call(e) : t.get(e)), c = (e, t, s) => {
6
- if (t.has(e))
7
- throw TypeError("Cannot add the same private member more than once");
8
- t instanceof WeakSet ? t.add(e) : t.set(e, s);
9
- }, o = (e, t, s, r) => (St(e, t, "write to private field"), r ? r.call(e, s) : t.set(e, s), s);
10
- var bt = (e, t, s, r) => ({
11
- set _(n) {
12
- o(e, t, n, s);
13
- },
14
- get _() {
15
- return i(e, t, r);
16
- }
17
- }), F = (e, t, s) => (St(e, t, "access private method"), s);
18
- import { jsx as dt } from "react/jsx-runtime";
19
- import { RPTheme as ee } from "./RPTheme.js";
20
- import { ConfigContextProvider as se } from "../contexts/ConfigContext.js";
21
- import { useLoadWorker as re } from "../utils/hooks/useLoadWorker.js";
22
- import * as Jt from "react";
23
- import { LicenseProvider as ie } from "../contexts/LicenseContext.js";
1
+ import { jsx as r } from "react/jsx-runtime";
2
+ import { RPTheme as s } from "./RPTheme.js";
3
+ import { ConfigContextProvider as d } from "../contexts/ConfigContext.js";
4
+ import { useLoadWorker as f } from "../utils/hooks/useLoadWorker.js";
5
+ import { LicenseProvider as l } from "../contexts/LicenseContext.js";
24
6
  import "../contexts/ThemeContext.js";
7
+ import "react";
25
8
  import "pdfjs-dist";
26
9
  import "../utils/hooks/useLicense.js";
27
10
  import "../utils/appConsole.js";
28
- var Ct = class {
29
- constructor() {
30
- this.listeners = /* @__PURE__ */ new Set(), this.subscribe = this.subscribe.bind(this);
31
- }
32
- subscribe(e) {
33
- return this.listeners.add(e), this.onSubscribe(), () => {
34
- this.listeners.delete(e), this.onUnsubscribe();
35
- };
36
- }
37
- hasListeners() {
38
- return this.listeners.size > 0;
39
- }
40
- onSubscribe() {
41
- }
42
- onUnsubscribe() {
43
- }
44
- }, ne = {
45
- // We need the wrapper function syntax below instead of direct references to
46
- // global setTimeout etc.
47
- //
48
- // BAD: `setTimeout: setTimeout`
49
- // GOOD: `setTimeout: (cb, delay) => setTimeout(cb, delay)`
50
- //
51
- // If we use direct references here, then anything that wants to spy on or
52
- // replace the global setTimeout (like tests) won't work since we'll already
53
- // have a hard reference to the original implementation at the time when this
54
- // file was imported.
55
- setTimeout: (e, t) => setTimeout(e, t),
56
- clearTimeout: (e) => clearTimeout(e),
57
- setInterval: (e, t) => setInterval(e, t),
58
- clearInterval: (e) => clearInterval(e)
59
- }, x, W, Nt, ae = (Nt = class {
60
- constructor() {
61
- // We cannot have TimeoutManager<T> as we must instantiate it with a concrete
62
- // type at app boot; and if we leave that type, then any new timer provider
63
- // would need to support ReturnType<typeof setTimeout>, which is infeasible.
64
- //
65
- // We settle for type safety for the TimeoutProvider type, and accept that
66
- // this class is unsafe internally to allow for extension.
67
- c(this, x, ne);
68
- c(this, W, !1);
69
- }
70
- setTimeoutProvider(e) {
71
- process.env.NODE_ENV !== "production" && i(this, W) && e !== i(this, x) && console.error(
72
- "[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",
73
- { previous: i(this, x), provider: e }
74
- ), o(this, x, e), process.env.NODE_ENV !== "production" && o(this, W, !1);
75
- }
76
- setTimeout(e, t) {
77
- return process.env.NODE_ENV !== "production" && o(this, W, !0), i(this, x).setTimeout(e, t);
78
- }
79
- clearTimeout(e) {
80
- i(this, x).clearTimeout(e);
81
- }
82
- setInterval(e, t) {
83
- return process.env.NODE_ENV !== "production" && o(this, W, !0), i(this, x).setInterval(e, t);
84
- }
85
- clearInterval(e) {
86
- i(this, x).clearInterval(e);
87
- }
88
- }, x = new WeakMap(), W = new WeakMap(), Nt), Et = new ae();
89
- function oe(e) {
90
- setTimeout(e, 0);
91
- }
92
- var Ft = typeof window > "u" || "Deno" in globalThis;
93
- function R() {
94
- }
95
- function ue(e, t) {
96
- return typeof e == "function" ? e(t) : e;
97
- }
98
- function he(e) {
99
- return typeof e == "number" && e >= 0 && e !== 1 / 0;
100
- }
101
- function ce(e, t) {
102
- return Math.max(e + (t || 0) - Date.now(), 0);
103
- }
104
- function qt(e, t) {
105
- return typeof e == "function" ? e(t) : e;
106
- }
107
- function le(e, t) {
108
- return typeof e == "function" ? e(t) : e;
109
- }
110
- function Tt(e, t) {
111
- const {
112
- type: s = "all",
113
- exact: r,
114
- fetchStatus: n,
115
- predicate: a,
116
- queryKey: l,
117
- stale: u
118
- } = e;
119
- if (l) {
120
- if (r) {
121
- if (t.queryHash !== Mt(l, t.options))
122
- return !1;
123
- } else if (!yt(t.queryKey, l))
124
- return !1;
125
- }
126
- if (s !== "all") {
127
- const f = t.isActive();
128
- if (s === "active" && !f || s === "inactive" && f)
129
- return !1;
130
- }
131
- return !(typeof u == "boolean" && t.isStale() !== u || n && n !== t.state.fetchStatus || a && !a(t));
132
- }
133
- function Rt(e, t) {
134
- const { exact: s, status: r, predicate: n, mutationKey: a } = e;
135
- if (a) {
136
- if (!t.options.mutationKey)
137
- return !1;
138
- if (s) {
139
- if (ft(t.options.mutationKey) !== ft(a))
140
- return !1;
141
- } else if (!yt(t.options.mutationKey, a))
142
- return !1;
143
- }
144
- return !(r && t.state.status !== r || n && !n(t));
145
- }
146
- function Mt(e, t) {
147
- return ((t == null ? void 0 : t.queryKeyHashFn) || ft)(e);
148
- }
149
- function ft(e) {
150
- return JSON.stringify(
151
- e,
152
- (t, s) => At(s) ? Object.keys(s).sort().reduce((r, n) => (r[n] = s[n], r), {}) : s
153
- );
154
- }
155
- function yt(e, t) {
156
- return e === t ? !0 : typeof e != typeof t ? !1 : e && t && typeof e == "object" && typeof t == "object" ? Object.keys(t).every((s) => yt(e[s], t[s])) : !1;
157
- }
158
- var de = Object.prototype.hasOwnProperty;
159
- function Dt(e, t) {
160
- if (e === t)
161
- return e;
162
- const s = It(e) && It(t);
163
- if (!s && !(At(e) && At(t)))
164
- return t;
165
- const n = (s ? e : Object.keys(e)).length, a = s ? t : Object.keys(t), l = a.length, u = s ? new Array(l) : {};
166
- let f = 0;
167
- for (let O = 0; O < l; O++) {
168
- const v = s ? O : a[O], C = e[v], g = t[v];
169
- if (C === g) {
170
- u[v] = C, (s ? O < n : de.call(e, v)) && f++;
171
- continue;
172
- }
173
- if (C === null || g === null || typeof C != "object" || typeof g != "object") {
174
- u[v] = g;
175
- continue;
176
- }
177
- const D = Dt(C, g);
178
- u[v] = D, D === C && f++;
179
- }
180
- return n === l && f === n ? e : u;
181
- }
182
- function It(e) {
183
- return Array.isArray(e) && e.length === Object.keys(e).length;
184
- }
185
- function At(e) {
186
- if (!jt(e))
187
- return !1;
188
- const t = e.constructor;
189
- if (t === void 0)
190
- return !0;
191
- const s = t.prototype;
192
- return !(!jt(s) || !s.hasOwnProperty("isPrototypeOf") || Object.getPrototypeOf(e) !== Object.prototype);
193
- }
194
- function jt(e) {
195
- return Object.prototype.toString.call(e) === "[object Object]";
196
- }
197
- function fe(e) {
198
- return new Promise((t) => {
199
- Et.setTimeout(t, e);
200
- });
201
- }
202
- function ye(e, t, s) {
203
- if (typeof s.structuralSharing == "function")
204
- return s.structuralSharing(e, t);
205
- if (s.structuralSharing !== !1) {
206
- if (process.env.NODE_ENV !== "production")
207
- try {
208
- return Dt(e, t);
209
- } catch (r) {
210
- throw console.error(
211
- `Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${s.queryHash}]: ${r}`
212
- ), r;
213
- }
214
- return Dt(e, t);
215
- }
216
- return t;
217
- }
218
- function pe(e, t, s = 0) {
219
- const r = [...e, t];
220
- return s && r.length > s ? r.slice(1) : r;
221
- }
222
- function me(e, t, s = 0) {
223
- const r = [t, ...e];
224
- return s && r.length > s ? r.slice(0, -1) : r;
225
- }
226
- var Pt = Symbol();
227
- function Wt(e, t) {
228
- return process.env.NODE_ENV !== "production" && e.queryFn === Pt && console.error(
229
- `Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${e.queryHash}'`
230
- ), !e.queryFn && (t != null && t.initialPromise) ? () => t.initialPromise : !e.queryFn || e.queryFn === Pt ? () => Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)) : e.queryFn;
231
- }
232
- var Z, G, rt, Ht, ve = (Ht = class extends Ct {
233
- constructor() {
234
- super();
235
- c(this, Z, void 0);
236
- c(this, G, void 0);
237
- c(this, rt, void 0);
238
- o(this, rt, (t) => {
239
- if (!Ft && window.addEventListener) {
240
- const s = () => t();
241
- return window.addEventListener("visibilitychange", s, !1), () => {
242
- window.removeEventListener("visibilitychange", s);
243
- };
244
- }
245
- });
246
- }
247
- onSubscribe() {
248
- i(this, G) || this.setEventListener(i(this, rt));
249
- }
250
- onUnsubscribe() {
251
- var t;
252
- this.hasListeners() || ((t = i(this, G)) == null || t.call(this), o(this, G, void 0));
253
- }
254
- setEventListener(t) {
255
- var s;
256
- o(this, rt, t), (s = i(this, G)) == null || s.call(this), o(this, G, t((r) => {
257
- typeof r == "boolean" ? this.setFocused(r) : this.onFocus();
258
- }));
259
- }
260
- setFocused(t) {
261
- i(this, Z) !== t && (o(this, Z, t), this.onFocus());
262
- }
263
- onFocus() {
264
- const t = this.isFocused();
265
- this.listeners.forEach((s) => {
266
- s(t);
267
- });
268
- }
269
- isFocused() {
270
- var t;
271
- return typeof i(this, Z) == "boolean" ? i(this, Z) : ((t = globalThis.document) == null ? void 0 : t.visibilityState) !== "hidden";
272
- }
273
- }, Z = new WeakMap(), G = new WeakMap(), rt = new WeakMap(), Ht), Zt = new ve();
274
- function ge() {
275
- let e, t;
276
- const s = new Promise((n, a) => {
277
- e = n, t = a;
278
- });
279
- s.status = "pending", s.catch(() => {
280
- });
281
- function r(n) {
282
- Object.assign(s, n), delete s.resolve, delete s.reject;
283
- }
284
- return s.resolve = (n) => {
285
- r({
286
- status: "fulfilled",
287
- value: n
288
- }), e(n);
289
- }, s.reject = (n) => {
290
- r({
291
- status: "rejected",
292
- reason: n
293
- }), t(n);
294
- }, s;
295
- }
296
- var be = oe;
297
- function we() {
298
- let e = [], t = 0, s = (u) => {
299
- u();
300
- }, r = (u) => {
301
- u();
302
- }, n = be;
303
- const a = (u) => {
304
- t ? e.push(u) : n(() => {
305
- s(u);
306
- });
307
- }, l = () => {
308
- const u = e;
309
- e = [], u.length && n(() => {
310
- r(() => {
311
- u.forEach((f) => {
312
- s(f);
313
- });
314
- });
315
- });
316
- };
317
- return {
318
- batch: (u) => {
319
- let f;
320
- t++;
321
- try {
322
- f = u();
323
- } finally {
324
- t--, t || l();
325
- }
326
- return f;
327
- },
328
- /**
329
- * All calls to the wrapped function will be batched.
330
- */
331
- batchCalls: (u) => (...f) => {
332
- a(() => {
333
- u(...f);
334
- });
335
- },
336
- schedule: a,
337
- /**
338
- * Use this method to set a custom notify function.
339
- * This can be used to for example wrap notifications with `React.act` while running tests.
340
- */
341
- setNotifyFunction: (u) => {
342
- s = u;
343
- },
344
- /**
345
- * Use this method to set a custom function to batch notifications together into a single tick.
346
- * By default React Query will use the batch function provided by ReactDOM or React Native.
347
- */
348
- setBatchNotifyFunction: (u) => {
349
- r = u;
350
- },
351
- setScheduler: (u) => {
352
- n = u;
353
- }
354
- };
355
- }
356
- var q = we(), it, _, nt, Lt, Pe = (Lt = class extends Ct {
357
- constructor() {
358
- super();
359
- c(this, it, !0);
360
- c(this, _, void 0);
361
- c(this, nt, void 0);
362
- o(this, nt, (t) => {
363
- if (!Ft && window.addEventListener) {
364
- const s = () => t(!0), r = () => t(!1);
365
- return window.addEventListener("online", s, !1), window.addEventListener("offline", r, !1), () => {
366
- window.removeEventListener("online", s), window.removeEventListener("offline", r);
367
- };
368
- }
369
- });
370
- }
371
- onSubscribe() {
372
- i(this, _) || this.setEventListener(i(this, nt));
373
- }
374
- onUnsubscribe() {
375
- var t;
376
- this.hasListeners() || ((t = i(this, _)) == null || t.call(this), o(this, _, void 0));
377
- }
378
- setEventListener(t) {
379
- var s;
380
- o(this, nt, t), (s = i(this, _)) == null || s.call(this), o(this, _, t(this.setOnline.bind(this)));
381
- }
382
- setOnline(t) {
383
- i(this, it) !== t && (o(this, it, t), this.listeners.forEach((r) => {
384
- r(t);
385
- }));
386
- }
387
- isOnline() {
388
- return i(this, it);
389
- }
390
- }, it = new WeakMap(), _ = new WeakMap(), nt = new WeakMap(), Lt), Ot = new Pe();
391
- function Oe(e) {
392
- return Math.min(1e3 * 2 ** e, 3e4);
393
- }
394
- function Xt(e) {
395
- return (e ?? "online") === "online" ? Ot.isOnline() : !0;
396
- }
397
- var Qt = class extends Error {
398
- constructor(e) {
399
- super("CancelledError"), this.revert = e == null ? void 0 : e.revert, this.silent = e == null ? void 0 : e.silent;
400
- }
401
- };
402
- function Yt(e) {
403
- let t = !1, s = 0, r;
404
- const n = ge(), a = () => n.status !== "pending", l = (d) => {
405
- var b;
406
- if (!a()) {
407
- const m = new Qt(d);
408
- g(m), (b = e.onCancel) == null || b.call(e, m);
409
- }
410
- }, u = () => {
411
- t = !0;
412
- }, f = () => {
413
- t = !1;
414
- }, O = () => Zt.isFocused() && (e.networkMode === "always" || Ot.isOnline()) && e.canRun(), v = () => Xt(e.networkMode) && e.canRun(), C = (d) => {
415
- a() || (r == null || r(), n.resolve(d));
416
- }, g = (d) => {
417
- a() || (r == null || r(), n.reject(d));
418
- }, D = () => new Promise((d) => {
419
- var b;
420
- r = (m) => {
421
- (a() || O()) && d(m);
422
- }, (b = e.onPause) == null || b.call(e);
423
- }).then(() => {
424
- var d;
425
- r = void 0, a() || (d = e.onContinue) == null || d.call(e);
426
- }), Q = () => {
427
- if (a())
428
- return;
429
- let d;
430
- const b = s === 0 ? e.initialPromise : void 0;
431
- try {
432
- d = b ?? e.fn();
433
- } catch (m) {
434
- d = Promise.reject(m);
435
- }
436
- Promise.resolve(d).then(C).catch((m) => {
437
- var T;
438
- if (a())
439
- return;
440
- const A = e.retry ?? (Ft ? 0 : 3), p = e.retryDelay ?? Oe, h = typeof p == "function" ? p(s, m) : p, S = A === !0 || typeof A == "number" && s < A || typeof A == "function" && A(s, m);
441
- if (t || !S) {
442
- g(m);
443
- return;
444
- }
445
- s++, (T = e.onFail) == null || T.call(e, s, m), fe(h).then(() => O() ? void 0 : D()).then(() => {
446
- t ? g(m) : Q();
447
- });
448
- });
449
- };
450
- return {
451
- promise: n,
452
- status: () => n.status,
453
- cancel: l,
454
- continue: () => (r == null || r(), n),
455
- cancelRetry: u,
456
- continueRetry: f,
457
- canStart: v,
458
- start: () => (v() ? Q() : D().then(Q), n)
459
- };
460
- }
461
- var X, Gt, te = (Gt = class {
462
- constructor() {
463
- c(this, X, void 0);
464
- }
465
- destroy() {
466
- this.clearGcTimeout();
467
- }
468
- scheduleGc() {
469
- this.clearGcTimeout(), he(this.gcTime) && o(this, X, Et.setTimeout(() => {
470
- this.optionalRemove();
471
- }, this.gcTime));
472
- }
473
- updateGcTime(e) {
474
- this.gcTime = Math.max(
475
- this.gcTime || 0,
476
- e ?? (Ft ? 1 / 0 : 5 * 60 * 1e3)
477
- );
478
- }
479
- clearGcTimeout() {
480
- i(this, X) && (Et.clearTimeout(i(this, X)), o(this, X, void 0));
481
- }
482
- }, X = new WeakMap(), Gt), Y, at, M, tt, P, pt, et, I, N, _t, Ce = (_t = class extends te {
483
- constructor(t) {
484
- super();
485
- c(this, I);
486
- c(this, Y, void 0);
487
- c(this, at, void 0);
488
- c(this, M, void 0);
489
- c(this, tt, void 0);
490
- c(this, P, void 0);
491
- c(this, pt, void 0);
492
- c(this, et, void 0);
493
- o(this, et, !1), o(this, pt, t.defaultOptions), this.setOptions(t.options), this.observers = [], o(this, tt, t.client), o(this, M, i(this, tt).getQueryCache()), this.queryKey = t.queryKey, this.queryHash = t.queryHash, o(this, Y, kt(this.options)), this.state = t.state ?? i(this, Y), this.scheduleGc();
494
- }
495
- get meta() {
496
- return this.options.meta;
497
- }
498
- get promise() {
499
- var t;
500
- return (t = i(this, P)) == null ? void 0 : t.promise;
501
- }
502
- setOptions(t) {
503
- if (this.options = { ...i(this, pt), ...t }, this.updateGcTime(this.options.gcTime), this.state && this.state.data === void 0) {
504
- const s = kt(this.options);
505
- s.data !== void 0 && (this.setState(
506
- xt(s.data, s.dataUpdatedAt)
507
- ), o(this, Y, s));
508
- }
509
- }
510
- optionalRemove() {
511
- !this.observers.length && this.state.fetchStatus === "idle" && i(this, M).remove(this);
512
- }
513
- setData(t, s) {
514
- const r = ye(this.state.data, t, this.options);
515
- return F(this, I, N).call(this, {
516
- data: r,
517
- type: "success",
518
- dataUpdatedAt: s == null ? void 0 : s.updatedAt,
519
- manual: s == null ? void 0 : s.manual
520
- }), r;
521
- }
522
- setState(t, s) {
523
- F(this, I, N).call(this, { type: "setState", state: t, setStateOptions: s });
524
- }
525
- cancel(t) {
526
- var r, n;
527
- const s = (r = i(this, P)) == null ? void 0 : r.promise;
528
- return (n = i(this, P)) == null || n.cancel(t), s ? s.then(R).catch(R) : Promise.resolve();
529
- }
530
- destroy() {
531
- super.destroy(), this.cancel({ silent: !0 });
532
- }
533
- reset() {
534
- this.destroy(), this.setState(i(this, Y));
535
- }
536
- isActive() {
537
- return this.observers.some(
538
- (t) => le(t.options.enabled, this) !== !1
539
- );
540
- }
541
- isDisabled() {
542
- return this.getObserversCount() > 0 ? !this.isActive() : this.options.queryFn === Pt || this.state.dataUpdateCount + this.state.errorUpdateCount === 0;
543
- }
544
- isStatic() {
545
- return this.getObserversCount() > 0 ? this.observers.some(
546
- (t) => qt(t.options.staleTime, this) === "static"
547
- ) : !1;
548
- }
549
- isStale() {
550
- return this.getObserversCount() > 0 ? this.observers.some(
551
- (t) => t.getCurrentResult().isStale
552
- ) : this.state.data === void 0 || this.state.isInvalidated;
553
- }
554
- isStaleByTime(t = 0) {
555
- return this.state.data === void 0 ? !0 : t === "static" ? !1 : this.state.isInvalidated ? !0 : !ce(this.state.dataUpdatedAt, t);
556
- }
557
- onFocus() {
558
- var s;
559
- const t = this.observers.find((r) => r.shouldFetchOnWindowFocus());
560
- t == null || t.refetch({ cancelRefetch: !1 }), (s = i(this, P)) == null || s.continue();
561
- }
562
- onOnline() {
563
- var s;
564
- const t = this.observers.find((r) => r.shouldFetchOnReconnect());
565
- t == null || t.refetch({ cancelRefetch: !1 }), (s = i(this, P)) == null || s.continue();
566
- }
567
- addObserver(t) {
568
- this.observers.includes(t) || (this.observers.push(t), this.clearGcTimeout(), i(this, M).notify({ type: "observerAdded", query: this, observer: t }));
569
- }
570
- removeObserver(t) {
571
- this.observers.includes(t) && (this.observers = this.observers.filter((s) => s !== t), this.observers.length || (i(this, P) && (i(this, et) ? i(this, P).cancel({ revert: !0 }) : i(this, P).cancelRetry()), this.scheduleGc()), i(this, M).notify({ type: "observerRemoved", query: this, observer: t }));
572
- }
573
- getObserversCount() {
574
- return this.observers.length;
575
- }
576
- invalidate() {
577
- this.state.isInvalidated || F(this, I, N).call(this, { type: "invalidate" });
578
- }
579
- async fetch(t, s) {
580
- var f, O, v, C, g, D, Q, d, b, m, A, p;
581
- if (this.state.fetchStatus !== "idle" && // If the promise in the retyer is already rejected, we have to definitely
582
- // re-start the fetch; there is a chance that the query is still in a
583
- // pending state when that happens
584
- ((f = i(this, P)) == null ? void 0 : f.status()) !== "rejected") {
585
- if (this.state.data !== void 0 && (s != null && s.cancelRefetch))
586
- this.cancel({ silent: !0 });
587
- else if (i(this, P))
588
- return i(this, P).continueRetry(), i(this, P).promise;
589
- }
590
- if (t && this.setOptions(t), !this.options.queryFn) {
591
- const h = this.observers.find((S) => S.options.queryFn);
592
- h && this.setOptions(h.options);
593
- }
594
- process.env.NODE_ENV !== "production" && (Array.isArray(this.options.queryKey) || console.error(
595
- "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']"
596
- ));
597
- const r = new AbortController(), n = (h) => {
598
- Object.defineProperty(h, "signal", {
599
- enumerable: !0,
600
- get: () => (o(this, et, !0), r.signal)
601
- });
602
- }, a = () => {
603
- const h = Wt(this.options, s), T = (() => {
604
- const B = {
605
- client: i(this, tt),
606
- queryKey: this.queryKey,
607
- meta: this.meta
608
- };
609
- return n(B), B;
610
- })();
611
- return o(this, et, !1), this.options.persister ? this.options.persister(
612
- h,
613
- T,
614
- this
615
- ) : h(T);
616
- }, u = (() => {
617
- const h = {
618
- fetchOptions: s,
619
- options: this.options,
620
- queryKey: this.queryKey,
621
- client: i(this, tt),
622
- state: this.state,
623
- fetchFn: a
624
- };
625
- return n(h), h;
626
- })();
627
- (O = this.options.behavior) == null || O.onFetch(u, this), o(this, at, this.state), (this.state.fetchStatus === "idle" || this.state.fetchMeta !== ((v = u.fetchOptions) == null ? void 0 : v.meta)) && F(this, I, N).call(this, { type: "fetch", meta: (C = u.fetchOptions) == null ? void 0 : C.meta }), o(this, P, Yt({
628
- initialPromise: s == null ? void 0 : s.initialPromise,
629
- fn: u.fetchFn,
630
- onCancel: (h) => {
631
- h instanceof Qt && h.revert && this.setState({
632
- ...i(this, at),
633
- fetchStatus: "idle"
634
- }), r.abort();
635
- },
636
- onFail: (h, S) => {
637
- F(this, I, N).call(this, { type: "failed", failureCount: h, error: S });
638
- },
639
- onPause: () => {
640
- F(this, I, N).call(this, { type: "pause" });
641
- },
642
- onContinue: () => {
643
- F(this, I, N).call(this, { type: "continue" });
644
- },
645
- retry: u.options.retry,
646
- retryDelay: u.options.retryDelay,
647
- networkMode: u.options.networkMode,
648
- canRun: () => !0
649
- }));
650
- try {
651
- const h = await i(this, P).start();
652
- if (h === void 0)
653
- throw process.env.NODE_ENV !== "production" && console.error(
654
- `Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`
655
- ), new Error(`${this.queryHash} data is undefined`);
656
- return this.setData(h), (D = (g = i(this, M).config).onSuccess) == null || D.call(g, h, this), (d = (Q = i(this, M).config).onSettled) == null || d.call(
657
- Q,
658
- h,
659
- this.state.error,
660
- this
661
- ), h;
662
- } catch (h) {
663
- if (h instanceof Qt) {
664
- if (h.silent)
665
- return i(this, P).promise;
666
- if (h.revert) {
667
- if (this.state.data === void 0)
668
- throw h;
669
- return this.state.data;
670
- }
671
- }
672
- throw F(this, I, N).call(this, {
673
- type: "error",
674
- error: h
675
- }), (m = (b = i(this, M).config).onError) == null || m.call(
676
- b,
677
- h,
678
- this
679
- ), (p = (A = i(this, M).config).onSettled) == null || p.call(
680
- A,
681
- this.state.data,
682
- h,
683
- this
684
- ), h;
685
- } finally {
686
- this.scheduleGc();
687
- }
688
- }
689
- }, Y = new WeakMap(), at = new WeakMap(), M = new WeakMap(), tt = new WeakMap(), P = new WeakMap(), pt = new WeakMap(), et = new WeakMap(), I = new WeakSet(), N = function(t) {
690
- const s = (r) => {
691
- switch (t.type) {
692
- case "failed":
693
- return {
694
- ...r,
695
- fetchFailureCount: t.failureCount,
696
- fetchFailureReason: t.error
697
- };
698
- case "pause":
699
- return {
700
- ...r,
701
- fetchStatus: "paused"
702
- };
703
- case "continue":
704
- return {
705
- ...r,
706
- fetchStatus: "fetching"
707
- };
708
- case "fetch":
709
- return {
710
- ...r,
711
- ...Fe(r.data, this.options),
712
- fetchMeta: t.meta ?? null
713
- };
714
- case "success":
715
- const n = {
716
- ...r,
717
- ...xt(t.data, t.dataUpdatedAt),
718
- dataUpdateCount: r.dataUpdateCount + 1,
719
- ...!t.manual && {
720
- fetchStatus: "idle",
721
- fetchFailureCount: 0,
722
- fetchFailureReason: null
723
- }
724
- };
725
- return o(this, at, t.manual ? n : void 0), n;
726
- case "error":
727
- const a = t.error;
728
- return {
729
- ...r,
730
- error: a,
731
- errorUpdateCount: r.errorUpdateCount + 1,
732
- errorUpdatedAt: Date.now(),
733
- fetchFailureCount: r.fetchFailureCount + 1,
734
- fetchFailureReason: a,
735
- fetchStatus: "idle",
736
- status: "error"
737
- };
738
- case "invalidate":
739
- return {
740
- ...r,
741
- isInvalidated: !0
742
- };
743
- case "setState":
744
- return {
745
- ...r,
746
- ...t.state
747
- };
748
- }
749
- };
750
- this.state = s(this.state), q.batch(() => {
751
- this.observers.forEach((r) => {
752
- r.onQueryUpdate();
753
- }), i(this, M).notify({ query: this, type: "updated", action: t });
754
- });
755
- }, _t);
756
- function Fe(e, t) {
757
- return {
758
- fetchFailureCount: 0,
759
- fetchFailureReason: null,
760
- fetchStatus: Xt(t.networkMode) ? "fetching" : "paused",
761
- ...e === void 0 && {
762
- error: null,
763
- status: "pending"
764
- }
765
- };
766
- }
767
- function xt(e, t) {
768
- return {
769
- data: e,
770
- dataUpdatedAt: t ?? Date.now(),
771
- error: null,
772
- isInvalidated: !1,
773
- status: "success"
774
- };
775
- }
776
- function kt(e) {
777
- const t = typeof e.initialData == "function" ? e.initialData() : e.initialData, s = t !== void 0, r = s ? typeof e.initialDataUpdatedAt == "function" ? e.initialDataUpdatedAt() : e.initialDataUpdatedAt : 0;
778
- return {
779
- data: t,
780
- dataUpdateCount: 0,
781
- dataUpdatedAt: s ? r ?? Date.now() : 0,
782
- error: null,
783
- errorUpdateCount: 0,
784
- errorUpdatedAt: 0,
785
- fetchFailureCount: 0,
786
- fetchFailureReason: null,
787
- fetchMeta: null,
788
- isInvalidated: !1,
789
- status: s ? "success" : "pending",
790
- fetchStatus: "idle"
791
- };
792
- }
793
- function Kt(e) {
794
- return {
795
- onFetch: (t, s) => {
796
- var v, C, g, D, Q;
797
- const r = t.options, n = (g = (C = (v = t.fetchOptions) == null ? void 0 : v.meta) == null ? void 0 : C.fetchMore) == null ? void 0 : g.direction, a = ((D = t.state.data) == null ? void 0 : D.pages) || [], l = ((Q = t.state.data) == null ? void 0 : Q.pageParams) || [];
798
- let u = { pages: [], pageParams: [] }, f = 0;
799
- const O = async () => {
800
- let d = !1;
801
- const b = (p) => {
802
- Object.defineProperty(p, "signal", {
803
- enumerable: !0,
804
- get: () => (t.signal.aborted ? d = !0 : t.signal.addEventListener("abort", () => {
805
- d = !0;
806
- }), t.signal)
807
- });
808
- }, m = Wt(t.options, t.fetchOptions), A = async (p, h, S) => {
809
- if (d)
810
- return Promise.reject();
811
- if (h == null && p.pages.length)
812
- return Promise.resolve(p);
813
- const B = (() => {
814
- const J = {
815
- client: t.client,
816
- queryKey: t.queryKey,
817
- pageParam: h,
818
- direction: S ? "backward" : "forward",
819
- meta: t.options.meta
820
- };
821
- return b(J), J;
822
- })(), gt = await m(B), { maxPages: lt } = t.options, w = S ? me : pe;
823
- return {
824
- pages: w(p.pages, gt, lt),
825
- pageParams: w(p.pageParams, h, lt)
826
- };
827
- };
828
- if (n && a.length) {
829
- const p = n === "backward", h = p ? Se : Ut, S = {
830
- pages: a,
831
- pageParams: l
832
- }, T = h(r, S);
833
- u = await A(S, T, p);
834
- } else {
835
- const p = e ?? a.length;
836
- do {
837
- const h = f === 0 ? l[0] ?? r.initialPageParam : Ut(r, u);
838
- if (f > 0 && h == null)
839
- break;
840
- u = await A(u, h), f++;
841
- } while (f < p);
842
- }
843
- return u;
844
- };
845
- t.options.persister ? t.fetchFn = () => {
846
- var d, b;
847
- return (b = (d = t.options).persister) == null ? void 0 : b.call(
848
- d,
849
- O,
850
- {
851
- client: t.client,
852
- queryKey: t.queryKey,
853
- meta: t.options.meta,
854
- signal: t.signal
855
- },
856
- s
857
- );
858
- } : t.fetchFn = O;
859
- }
860
- };
861
- }
862
- function Ut(e, { pages: t, pageParams: s }) {
863
- const r = t.length - 1;
864
- return t.length > 0 ? e.getNextPageParam(
865
- t[r],
866
- t,
867
- s[r],
868
- s
869
- ) : void 0;
870
- }
871
- function Se(e, { pages: t, pageParams: s }) {
872
- var r;
873
- return t.length > 0 ? (r = e.getPreviousPageParam) == null ? void 0 : r.call(e, t[0], t, s[0], s) : void 0;
874
- }
875
- var mt, k, E, st, K, L, Vt, Ee = (Vt = class extends te {
876
- constructor(t) {
877
- super();
878
- c(this, K);
879
- c(this, mt, void 0);
880
- c(this, k, void 0);
881
- c(this, E, void 0);
882
- c(this, st, void 0);
883
- o(this, mt, t.client), this.mutationId = t.mutationId, o(this, E, t.mutationCache), o(this, k, []), this.state = t.state || qe(), this.setOptions(t.options), this.scheduleGc();
884
- }
885
- setOptions(t) {
886
- this.options = t, this.updateGcTime(this.options.gcTime);
887
- }
888
- get meta() {
889
- return this.options.meta;
890
- }
891
- addObserver(t) {
892
- i(this, k).includes(t) || (i(this, k).push(t), this.clearGcTimeout(), i(this, E).notify({
893
- type: "observerAdded",
894
- mutation: this,
895
- observer: t
896
- }));
897
- }
898
- removeObserver(t) {
899
- o(this, k, i(this, k).filter((s) => s !== t)), this.scheduleGc(), i(this, E).notify({
900
- type: "observerRemoved",
901
- mutation: this,
902
- observer: t
903
- });
904
- }
905
- optionalRemove() {
906
- i(this, k).length || (this.state.status === "pending" ? this.scheduleGc() : i(this, E).remove(this));
907
- }
908
- continue() {
909
- var t;
910
- return ((t = i(this, st)) == null ? void 0 : t.continue()) ?? // continuing a mutation assumes that variables are set, mutation must have been dehydrated before
911
- this.execute(this.state.variables);
912
- }
913
- async execute(t) {
914
- var l, u, f, O, v, C, g, D, Q, d, b, m, A, p, h, S, T, B, gt, lt;
915
- const s = () => {
916
- F(this, K, L).call(this, { type: "continue" });
917
- }, r = {
918
- client: i(this, mt),
919
- meta: this.options.meta,
920
- mutationKey: this.options.mutationKey
921
- };
922
- o(this, st, Yt({
923
- fn: () => this.options.mutationFn ? this.options.mutationFn(t, r) : Promise.reject(new Error("No mutationFn found")),
924
- onFail: (w, J) => {
925
- F(this, K, L).call(this, { type: "failed", failureCount: w, error: J });
926
- },
927
- onPause: () => {
928
- F(this, K, L).call(this, { type: "pause" });
929
- },
930
- onContinue: s,
931
- retry: this.options.retry ?? 0,
932
- retryDelay: this.options.retryDelay,
933
- networkMode: this.options.networkMode,
934
- canRun: () => i(this, E).canRun(this)
935
- }));
936
- const n = this.state.status === "pending", a = !i(this, st).canStart();
937
- try {
938
- if (n)
939
- s();
940
- else {
941
- F(this, K, L).call(this, { type: "pending", variables: t, isPaused: a }), await ((u = (l = i(this, E).config).onMutate) == null ? void 0 : u.call(
942
- l,
943
- t,
944
- this,
945
- r
946
- ));
947
- const J = await ((O = (f = this.options).onMutate) == null ? void 0 : O.call(
948
- f,
949
- t,
950
- r
951
- ));
952
- J !== this.state.context && F(this, K, L).call(this, {
953
- type: "pending",
954
- context: J,
955
- variables: t,
956
- isPaused: a
957
- });
958
- }
959
- const w = await i(this, st).start();
960
- return await ((C = (v = i(this, E).config).onSuccess) == null ? void 0 : C.call(
961
- v,
962
- w,
963
- t,
964
- this.state.context,
965
- this,
966
- r
967
- )), await ((D = (g = this.options).onSuccess) == null ? void 0 : D.call(
968
- g,
969
- w,
970
- t,
971
- this.state.context,
972
- r
973
- )), await ((d = (Q = i(this, E).config).onSettled) == null ? void 0 : d.call(
974
- Q,
975
- w,
976
- null,
977
- this.state.variables,
978
- this.state.context,
979
- this,
980
- r
981
- )), await ((m = (b = this.options).onSettled) == null ? void 0 : m.call(
982
- b,
983
- w,
984
- null,
985
- t,
986
- this.state.context,
987
- r
988
- )), F(this, K, L).call(this, { type: "success", data: w }), w;
989
- } catch (w) {
990
- try {
991
- throw await ((p = (A = i(this, E).config).onError) == null ? void 0 : p.call(
992
- A,
993
- w,
994
- t,
995
- this.state.context,
996
- this,
997
- r
998
- )), await ((S = (h = this.options).onError) == null ? void 0 : S.call(
999
- h,
1000
- w,
1001
- t,
1002
- this.state.context,
1003
- r
1004
- )), await ((B = (T = i(this, E).config).onSettled) == null ? void 0 : B.call(
1005
- T,
1006
- void 0,
1007
- w,
1008
- this.state.variables,
1009
- this.state.context,
1010
- this,
1011
- r
1012
- )), await ((lt = (gt = this.options).onSettled) == null ? void 0 : lt.call(
1013
- gt,
1014
- void 0,
1015
- w,
1016
- t,
1017
- this.state.context,
1018
- r
1019
- )), w;
1020
- } finally {
1021
- F(this, K, L).call(this, { type: "error", error: w });
1022
- }
1023
- } finally {
1024
- i(this, E).runNext(this);
1025
- }
1026
- }
1027
- }, mt = new WeakMap(), k = new WeakMap(), E = new WeakMap(), st = new WeakMap(), K = new WeakSet(), L = function(t) {
1028
- const s = (r) => {
1029
- switch (t.type) {
1030
- case "failed":
1031
- return {
1032
- ...r,
1033
- failureCount: t.failureCount,
1034
- failureReason: t.error
1035
- };
1036
- case "pause":
1037
- return {
1038
- ...r,
1039
- isPaused: !0
1040
- };
1041
- case "continue":
1042
- return {
1043
- ...r,
1044
- isPaused: !1
1045
- };
1046
- case "pending":
1047
- return {
1048
- ...r,
1049
- context: t.context,
1050
- data: void 0,
1051
- failureCount: 0,
1052
- failureReason: null,
1053
- error: null,
1054
- isPaused: t.isPaused,
1055
- status: "pending",
1056
- variables: t.variables,
1057
- submittedAt: Date.now()
1058
- };
1059
- case "success":
1060
- return {
1061
- ...r,
1062
- data: t.data,
1063
- failureCount: 0,
1064
- failureReason: null,
1065
- error: null,
1066
- status: "success",
1067
- isPaused: !1
1068
- };
1069
- case "error":
1070
- return {
1071
- ...r,
1072
- data: void 0,
1073
- error: t.error,
1074
- failureCount: r.failureCount + 1,
1075
- failureReason: t.error,
1076
- isPaused: !1,
1077
- status: "error"
1078
- };
1079
- }
1080
- };
1081
- this.state = s(this.state), q.batch(() => {
1082
- i(this, k).forEach((r) => {
1083
- r.onMutationUpdate(t);
1084
- }), i(this, E).notify({
1085
- mutation: this,
1086
- type: "updated",
1087
- action: t
1088
- });
1089
- });
1090
- }, Vt);
1091
- function qe() {
1092
- return {
1093
- context: void 0,
1094
- data: void 0,
1095
- error: null,
1096
- failureCount: 0,
1097
- failureReason: null,
1098
- isPaused: !1,
1099
- status: "idle",
1100
- variables: void 0,
1101
- submittedAt: 0
1102
- };
1103
- }
1104
- var H, j, vt, $t, De = ($t = class extends Ct {
1105
- constructor(t = {}) {
1106
- super();
1107
- c(this, H, void 0);
1108
- c(this, j, void 0);
1109
- c(this, vt, void 0);
1110
- this.config = t, o(this, H, /* @__PURE__ */ new Set()), o(this, j, /* @__PURE__ */ new Map()), o(this, vt, 0);
1111
- }
1112
- build(t, s, r) {
1113
- const n = new Ee({
1114
- client: t,
1115
- mutationCache: this,
1116
- mutationId: ++bt(this, vt)._,
1117
- options: t.defaultMutationOptions(s),
1118
- state: r
1119
- });
1120
- return this.add(n), n;
1121
- }
1122
- add(t) {
1123
- i(this, H).add(t);
1124
- const s = wt(t);
1125
- if (typeof s == "string") {
1126
- const r = i(this, j).get(s);
1127
- r ? r.push(t) : i(this, j).set(s, [t]);
1128
- }
1129
- this.notify({ type: "added", mutation: t });
1130
- }
1131
- remove(t) {
1132
- if (i(this, H).delete(t)) {
1133
- const s = wt(t);
1134
- if (typeof s == "string") {
1135
- const r = i(this, j).get(s);
1136
- if (r)
1137
- if (r.length > 1) {
1138
- const n = r.indexOf(t);
1139
- n !== -1 && r.splice(n, 1);
1140
- } else
1141
- r[0] === t && i(this, j).delete(s);
1142
- }
1143
- }
1144
- this.notify({ type: "removed", mutation: t });
1145
- }
1146
- canRun(t) {
1147
- const s = wt(t);
1148
- if (typeof s == "string") {
1149
- const r = i(this, j).get(s), n = r == null ? void 0 : r.find(
1150
- (a) => a.state.status === "pending"
1151
- );
1152
- return !n || n === t;
1153
- } else
1154
- return !0;
1155
- }
1156
- runNext(t) {
1157
- var r;
1158
- const s = wt(t);
1159
- if (typeof s == "string") {
1160
- const n = (r = i(this, j).get(s)) == null ? void 0 : r.find((a) => a !== t && a.state.isPaused);
1161
- return (n == null ? void 0 : n.continue()) ?? Promise.resolve();
1162
- } else
1163
- return Promise.resolve();
1164
- }
1165
- clear() {
1166
- q.batch(() => {
1167
- i(this, H).forEach((t) => {
1168
- this.notify({ type: "removed", mutation: t });
1169
- }), i(this, H).clear(), i(this, j).clear();
1170
- });
1171
- }
1172
- getAll() {
1173
- return Array.from(i(this, H));
1174
- }
1175
- find(t) {
1176
- const s = { exact: !0, ...t };
1177
- return this.getAll().find(
1178
- (r) => Rt(s, r)
1179
- );
1180
- }
1181
- findAll(t = {}) {
1182
- return this.getAll().filter((s) => Rt(t, s));
1183
- }
1184
- notify(t) {
1185
- q.batch(() => {
1186
- this.listeners.forEach((s) => {
1187
- s(t);
1188
- });
1189
- });
1190
- }
1191
- resumePausedMutations() {
1192
- const t = this.getAll().filter((s) => s.state.isPaused);
1193
- return q.batch(
1194
- () => Promise.all(
1195
- t.map((s) => s.continue().catch(R))
1196
- )
1197
- );
1198
- }
1199
- }, H = new WeakMap(), j = new WeakMap(), vt = new WeakMap(), $t);
1200
- function wt(e) {
1201
- var t;
1202
- return (t = e.options.scope) == null ? void 0 : t.id;
1203
- }
1204
- var U, zt, Ae = (zt = class extends Ct {
1205
- constructor(t = {}) {
1206
- super();
1207
- c(this, U, void 0);
1208
- this.config = t, o(this, U, /* @__PURE__ */ new Map());
1209
- }
1210
- build(t, s, r) {
1211
- const n = s.queryKey, a = s.queryHash ?? Mt(n, s);
1212
- let l = this.get(a);
1213
- return l || (l = new Ce({
1214
- client: t,
1215
- queryKey: n,
1216
- queryHash: a,
1217
- options: t.defaultQueryOptions(s),
1218
- state: r,
1219
- defaultOptions: t.getQueryDefaults(n)
1220
- }), this.add(l)), l;
1221
- }
1222
- add(t) {
1223
- i(this, U).has(t.queryHash) || (i(this, U).set(t.queryHash, t), this.notify({
1224
- type: "added",
1225
- query: t
1226
- }));
1227
- }
1228
- remove(t) {
1229
- const s = i(this, U).get(t.queryHash);
1230
- s && (t.destroy(), s === t && i(this, U).delete(t.queryHash), this.notify({ type: "removed", query: t }));
1231
- }
1232
- clear() {
1233
- q.batch(() => {
1234
- this.getAll().forEach((t) => {
1235
- this.remove(t);
1236
- });
1237
- });
1238
- }
1239
- get(t) {
1240
- return i(this, U).get(t);
1241
- }
1242
- getAll() {
1243
- return [...i(this, U).values()];
1244
- }
1245
- find(t) {
1246
- const s = { exact: !0, ...t };
1247
- return this.getAll().find(
1248
- (r) => Tt(s, r)
1249
- );
1250
- }
1251
- findAll(t = {}) {
1252
- const s = this.getAll();
1253
- return Object.keys(t).length > 0 ? s.filter((r) => Tt(t, r)) : s;
1254
- }
1255
- notify(t) {
1256
- q.batch(() => {
1257
- this.listeners.forEach((s) => {
1258
- s(t);
1259
- });
1260
- });
1261
- }
1262
- onFocus() {
1263
- q.batch(() => {
1264
- this.getAll().forEach((t) => {
1265
- t.onFocus();
1266
- });
1267
- });
1268
- }
1269
- onOnline() {
1270
- q.batch(() => {
1271
- this.getAll().forEach((t) => {
1272
- t.onOnline();
1273
- });
1274
- });
1275
- }
1276
- }, U = new WeakMap(), zt), y, V, $, ot, ut, z, ht, ct, Bt, Qe = (Bt = class {
1277
- constructor(e = {}) {
1278
- c(this, y, void 0);
1279
- c(this, V, void 0);
1280
- c(this, $, void 0);
1281
- c(this, ot, void 0);
1282
- c(this, ut, void 0);
1283
- c(this, z, void 0);
1284
- c(this, ht, void 0);
1285
- c(this, ct, void 0);
1286
- o(this, y, e.queryCache || new Ae()), o(this, V, e.mutationCache || new De()), o(this, $, e.defaultOptions || {}), o(this, ot, /* @__PURE__ */ new Map()), o(this, ut, /* @__PURE__ */ new Map()), o(this, z, 0);
1287
- }
1288
- mount() {
1289
- bt(this, z)._++, i(this, z) === 1 && (o(this, ht, Zt.subscribe(async (e) => {
1290
- e && (await this.resumePausedMutations(), i(this, y).onFocus());
1291
- })), o(this, ct, Ot.subscribe(async (e) => {
1292
- e && (await this.resumePausedMutations(), i(this, y).onOnline());
1293
- })));
1294
- }
1295
- unmount() {
1296
- var e, t;
1297
- bt(this, z)._--, i(this, z) === 0 && ((e = i(this, ht)) == null || e.call(this), o(this, ht, void 0), (t = i(this, ct)) == null || t.call(this), o(this, ct, void 0));
1298
- }
1299
- isFetching(e) {
1300
- return i(this, y).findAll({ ...e, fetchStatus: "fetching" }).length;
1301
- }
1302
- isMutating(e) {
1303
- return i(this, V).findAll({ ...e, status: "pending" }).length;
1304
- }
1305
- /**
1306
- * Imperative (non-reactive) way to retrieve data for a QueryKey.
1307
- * Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates.
1308
- *
1309
- * Hint: Do not use this function inside a component, because it won't receive updates.
1310
- * Use `useQuery` to create a `QueryObserver` that subscribes to changes.
1311
- */
1312
- getQueryData(e) {
1313
- var s;
1314
- const t = this.defaultQueryOptions({ queryKey: e });
1315
- return (s = i(this, y).get(t.queryHash)) == null ? void 0 : s.state.data;
1316
- }
1317
- ensureQueryData(e) {
1318
- const t = this.defaultQueryOptions(e), s = i(this, y).build(this, t), r = s.state.data;
1319
- return r === void 0 ? this.fetchQuery(e) : (e.revalidateIfStale && s.isStaleByTime(qt(t.staleTime, s)) && this.prefetchQuery(t), Promise.resolve(r));
1320
- }
1321
- getQueriesData(e) {
1322
- return i(this, y).findAll(e).map(({ queryKey: t, state: s }) => {
1323
- const r = s.data;
1324
- return [t, r];
1325
- });
1326
- }
1327
- setQueryData(e, t, s) {
1328
- const r = this.defaultQueryOptions({ queryKey: e }), n = i(this, y).get(
1329
- r.queryHash
1330
- ), a = n == null ? void 0 : n.state.data, l = ue(t, a);
1331
- if (l !== void 0)
1332
- return i(this, y).build(this, r).setData(l, { ...s, manual: !0 });
1333
- }
1334
- setQueriesData(e, t, s) {
1335
- return q.batch(
1336
- () => i(this, y).findAll(e).map(({ queryKey: r }) => [
1337
- r,
1338
- this.setQueryData(r, t, s)
1339
- ])
1340
- );
1341
- }
1342
- getQueryState(e) {
1343
- var s;
1344
- const t = this.defaultQueryOptions({ queryKey: e });
1345
- return (s = i(this, y).get(
1346
- t.queryHash
1347
- )) == null ? void 0 : s.state;
1348
- }
1349
- removeQueries(e) {
1350
- const t = i(this, y);
1351
- q.batch(() => {
1352
- t.findAll(e).forEach((s) => {
1353
- t.remove(s);
1354
- });
1355
- });
1356
- }
1357
- resetQueries(e, t) {
1358
- const s = i(this, y);
1359
- return q.batch(() => (s.findAll(e).forEach((r) => {
1360
- r.reset();
1361
- }), this.refetchQueries(
1362
- {
1363
- type: "active",
1364
- ...e
1365
- },
1366
- t
1367
- )));
1368
- }
1369
- cancelQueries(e, t = {}) {
1370
- const s = { revert: !0, ...t }, r = q.batch(
1371
- () => i(this, y).findAll(e).map((n) => n.cancel(s))
1372
- );
1373
- return Promise.all(r).then(R).catch(R);
1374
- }
1375
- invalidateQueries(e, t = {}) {
1376
- return q.batch(() => (i(this, y).findAll(e).forEach((s) => {
1377
- s.invalidate();
1378
- }), (e == null ? void 0 : e.refetchType) === "none" ? Promise.resolve() : this.refetchQueries(
1379
- {
1380
- ...e,
1381
- type: (e == null ? void 0 : e.refetchType) ?? (e == null ? void 0 : e.type) ?? "active"
1382
- },
1383
- t
1384
- )));
1385
- }
1386
- refetchQueries(e, t = {}) {
1387
- const s = {
1388
- ...t,
1389
- cancelRefetch: t.cancelRefetch ?? !0
1390
- }, r = q.batch(
1391
- () => i(this, y).findAll(e).filter((n) => !n.isDisabled() && !n.isStatic()).map((n) => {
1392
- let a = n.fetch(void 0, s);
1393
- return s.throwOnError || (a = a.catch(R)), n.state.fetchStatus === "paused" ? Promise.resolve() : a;
1394
- })
1395
- );
1396
- return Promise.all(r).then(R);
1397
- }
1398
- fetchQuery(e) {
1399
- const t = this.defaultQueryOptions(e);
1400
- t.retry === void 0 && (t.retry = !1);
1401
- const s = i(this, y).build(this, t);
1402
- return s.isStaleByTime(
1403
- qt(t.staleTime, s)
1404
- ) ? s.fetch(t) : Promise.resolve(s.state.data);
1405
- }
1406
- prefetchQuery(e) {
1407
- return this.fetchQuery(e).then(R).catch(R);
1408
- }
1409
- fetchInfiniteQuery(e) {
1410
- return e.behavior = Kt(e.pages), this.fetchQuery(e);
1411
- }
1412
- prefetchInfiniteQuery(e) {
1413
- return this.fetchInfiniteQuery(e).then(R).catch(R);
1414
- }
1415
- ensureInfiniteQueryData(e) {
1416
- return e.behavior = Kt(e.pages), this.ensureQueryData(e);
1417
- }
1418
- resumePausedMutations() {
1419
- return Ot.isOnline() ? i(this, V).resumePausedMutations() : Promise.resolve();
1420
- }
1421
- getQueryCache() {
1422
- return i(this, y);
1423
- }
1424
- getMutationCache() {
1425
- return i(this, V);
1426
- }
1427
- getDefaultOptions() {
1428
- return i(this, $);
1429
- }
1430
- setDefaultOptions(e) {
1431
- o(this, $, e);
1432
- }
1433
- setQueryDefaults(e, t) {
1434
- i(this, ot).set(ft(e), {
1435
- queryKey: e,
1436
- defaultOptions: t
1437
- });
1438
- }
1439
- getQueryDefaults(e) {
1440
- const t = [...i(this, ot).values()], s = {};
1441
- return t.forEach((r) => {
1442
- yt(e, r.queryKey) && Object.assign(s, r.defaultOptions);
1443
- }), s;
1444
- }
1445
- setMutationDefaults(e, t) {
1446
- i(this, ut).set(ft(e), {
1447
- mutationKey: e,
1448
- defaultOptions: t
1449
- });
1450
- }
1451
- getMutationDefaults(e) {
1452
- const t = [...i(this, ut).values()], s = {};
1453
- return t.forEach((r) => {
1454
- yt(e, r.mutationKey) && Object.assign(s, r.defaultOptions);
1455
- }), s;
1456
- }
1457
- defaultQueryOptions(e) {
1458
- if (e._defaulted)
1459
- return e;
1460
- const t = {
1461
- ...i(this, $).queries,
1462
- ...this.getQueryDefaults(e.queryKey),
1463
- ...e,
1464
- _defaulted: !0
1465
- };
1466
- return t.queryHash || (t.queryHash = Mt(
1467
- t.queryKey,
1468
- t
1469
- )), t.refetchOnReconnect === void 0 && (t.refetchOnReconnect = t.networkMode !== "always"), t.throwOnError === void 0 && (t.throwOnError = !!t.suspense), !t.networkMode && t.persister && (t.networkMode = "offlineFirst"), t.queryFn === Pt && (t.enabled = !1), t;
1470
- }
1471
- defaultMutationOptions(e) {
1472
- return e != null && e._defaulted ? e : {
1473
- ...i(this, $).mutations,
1474
- ...(e == null ? void 0 : e.mutationKey) && this.getMutationDefaults(e.mutationKey),
1475
- ...e,
1476
- _defaulted: !0
1477
- };
1478
- }
1479
- clear() {
1480
- i(this, y).clear(), i(this, V).clear();
1481
- }
1482
- }, y = new WeakMap(), V = new WeakMap(), $ = new WeakMap(), ot = new WeakMap(), ut = new WeakMap(), z = new WeakMap(), ht = new WeakMap(), ct = new WeakMap(), Bt), Me = Jt.createContext(
1483
- void 0
1484
- ), Te = ({
1485
- client: e,
1486
- children: t
1487
- }) => (Jt.useEffect(() => (e.mount(), () => {
1488
- e.unmount();
1489
- }), [e]), /* @__PURE__ */ dt(Me.Provider, { value: e, children: t }));
1490
- const Re = new Qe(), _e = (e) => {
1491
- const { children: t, customVariables: s, customDarkVariables: r, workerUrl: n, licenseKey: a, ...l } = e, { workerUrlAdded: u } = re(n);
1492
- return /* @__PURE__ */ dt(Te, { client: Re, children: /* @__PURE__ */ dt(ie, { licenseKey: a, children: /* @__PURE__ */ dt(se, { workerUrlAdded: u, ...l, children: /* @__PURE__ */ dt(ee, { customDarkVariables: r, customVariables: s, children: t }) }) }) });
11
+ const w = (o) => {
12
+ const { children: e, customVariables: i, customDarkVariables: t, workerUrl: m, licenseKey: n, ...c } = o, { workerUrlAdded: p } = f(m);
13
+ return /* @__PURE__ */ r(l, { licenseKey: n, children: /* @__PURE__ */ r(d, { workerUrlAdded: p, ...c, children: /* @__PURE__ */ r(s, { customDarkVariables: t, customVariables: i, children: e }) }) });
1493
14
  };
1494
15
  export {
1495
- _e as RPConfig
16
+ w as RPConfig
1496
17
  };