@bitplanet/deva-sdk 0.8.3 → 0.8.5
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/assets/deva-sdk.css +1 -1
- package/dist/components.d.ts +53 -79
- package/dist/components.es.js +16534 -16001
- package/dist/config-CBh0zg_P.js +677 -0
- package/dist/index.d.ts +53 -79
- package/dist/index.es.js +251 -207
- package/package.json +20 -18
- package/dist/config-CL6PuR8K.js +0 -669
|
@@ -0,0 +1,677 @@
|
|
|
1
|
+
import oe, { createContext as Qe, useContext as Ze, useEffect as Et, useLayoutEffect as pt, useMemo as et, useRef as M, useCallback as Se, useDebugValue as St } from "react";
|
|
2
|
+
const vt = {
|
|
3
|
+
clientId: "",
|
|
4
|
+
redirectUri: "",
|
|
5
|
+
env: "development",
|
|
6
|
+
authInProgress: !1,
|
|
7
|
+
authError: null,
|
|
8
|
+
login: () => Promise.resolve(),
|
|
9
|
+
logout: () => Promise.resolve(),
|
|
10
|
+
idToken: null,
|
|
11
|
+
accessToken: null,
|
|
12
|
+
refreshToken: null,
|
|
13
|
+
user: null,
|
|
14
|
+
isAuthenticated: !1,
|
|
15
|
+
isReady: !1,
|
|
16
|
+
url: ""
|
|
17
|
+
}, _t = Qe(null), nn = () => Ze(_t) ?? vt;
|
|
18
|
+
var ue = { exports: {} }, ve = {};
|
|
19
|
+
/**
|
|
20
|
+
* @license React
|
|
21
|
+
* use-sync-external-store-shim.production.js
|
|
22
|
+
*
|
|
23
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
24
|
+
*
|
|
25
|
+
* This source code is licensed under the MIT license found in the
|
|
26
|
+
* LICENSE file in the root directory of this source tree.
|
|
27
|
+
*/
|
|
28
|
+
var He;
|
|
29
|
+
function mt() {
|
|
30
|
+
if (He) return ve;
|
|
31
|
+
He = 1;
|
|
32
|
+
var e = oe;
|
|
33
|
+
function t(c, h) {
|
|
34
|
+
return c === h && (c !== 0 || 1 / c === 1 / h) || c !== c && h !== h;
|
|
35
|
+
}
|
|
36
|
+
var n = typeof Object.is == "function" ? Object.is : t, r = e.useState, a = e.useEffect, l = e.useLayoutEffect, s = e.useDebugValue;
|
|
37
|
+
function f(c, h) {
|
|
38
|
+
var i = h(), d = r({ inst: { value: i, getSnapshot: h } }), E = d[0].inst, R = d[1];
|
|
39
|
+
return l(
|
|
40
|
+
function() {
|
|
41
|
+
E.value = i, E.getSnapshot = h, p(E) && R({ inst: E });
|
|
42
|
+
},
|
|
43
|
+
[c, i, h]
|
|
44
|
+
), a(
|
|
45
|
+
function() {
|
|
46
|
+
return p(E) && R({ inst: E }), c(function() {
|
|
47
|
+
p(E) && R({ inst: E });
|
|
48
|
+
});
|
|
49
|
+
},
|
|
50
|
+
[c]
|
|
51
|
+
), s(i), i;
|
|
52
|
+
}
|
|
53
|
+
function p(c) {
|
|
54
|
+
var h = c.getSnapshot;
|
|
55
|
+
c = c.value;
|
|
56
|
+
try {
|
|
57
|
+
var i = h();
|
|
58
|
+
return !n(c, i);
|
|
59
|
+
} catch {
|
|
60
|
+
return !0;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function D(c, h) {
|
|
64
|
+
return h();
|
|
65
|
+
}
|
|
66
|
+
var _ = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? D : f;
|
|
67
|
+
return ve.useSyncExternalStore = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : _, ve;
|
|
68
|
+
}
|
|
69
|
+
var _e = {};
|
|
70
|
+
/**
|
|
71
|
+
* @license React
|
|
72
|
+
* use-sync-external-store-shim.development.js
|
|
73
|
+
*
|
|
74
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
75
|
+
*
|
|
76
|
+
* This source code is licensed under the MIT license found in the
|
|
77
|
+
* LICENSE file in the root directory of this source tree.
|
|
78
|
+
*/
|
|
79
|
+
var ke;
|
|
80
|
+
function gt() {
|
|
81
|
+
return ke || (ke = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
82
|
+
function e(i, d) {
|
|
83
|
+
return i === d && (i !== 0 || 1 / i === 1 / d) || i !== i && d !== d;
|
|
84
|
+
}
|
|
85
|
+
function t(i, d) {
|
|
86
|
+
_ || a.startTransition === void 0 || (_ = !0, console.error(
|
|
87
|
+
"You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."
|
|
88
|
+
));
|
|
89
|
+
var E = d();
|
|
90
|
+
if (!c) {
|
|
91
|
+
var R = d();
|
|
92
|
+
l(E, R) || (console.error(
|
|
93
|
+
"The result of getSnapshot should be cached to avoid an infinite loop"
|
|
94
|
+
), c = !0);
|
|
95
|
+
}
|
|
96
|
+
R = s({
|
|
97
|
+
inst: { value: E, getSnapshot: d }
|
|
98
|
+
});
|
|
99
|
+
var C = R[0].inst, o = R[1];
|
|
100
|
+
return p(
|
|
101
|
+
function() {
|
|
102
|
+
C.value = E, C.getSnapshot = d, n(C) && o({ inst: C });
|
|
103
|
+
},
|
|
104
|
+
[i, E, d]
|
|
105
|
+
), f(
|
|
106
|
+
function() {
|
|
107
|
+
return n(C) && o({ inst: C }), i(function() {
|
|
108
|
+
n(C) && o({ inst: C });
|
|
109
|
+
});
|
|
110
|
+
},
|
|
111
|
+
[i]
|
|
112
|
+
), D(E), E;
|
|
113
|
+
}
|
|
114
|
+
function n(i) {
|
|
115
|
+
var d = i.getSnapshot;
|
|
116
|
+
i = i.value;
|
|
117
|
+
try {
|
|
118
|
+
var E = d();
|
|
119
|
+
return !l(i, E);
|
|
120
|
+
} catch {
|
|
121
|
+
return !0;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
function r(i, d) {
|
|
125
|
+
return d();
|
|
126
|
+
}
|
|
127
|
+
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
128
|
+
var a = oe, l = typeof Object.is == "function" ? Object.is : e, s = a.useState, f = a.useEffect, p = a.useLayoutEffect, D = a.useDebugValue, _ = !1, c = !1, h = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? r : t;
|
|
129
|
+
_e.useSyncExternalStore = a.useSyncExternalStore !== void 0 ? a.useSyncExternalStore : h, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
130
|
+
})()), _e;
|
|
131
|
+
}
|
|
132
|
+
var Ge;
|
|
133
|
+
function Ot() {
|
|
134
|
+
return Ge || (Ge = 1, process.env.NODE_ENV === "production" ? ue.exports = mt() : ue.exports = gt()), ue.exports;
|
|
135
|
+
}
|
|
136
|
+
var $e = Ot();
|
|
137
|
+
const tt = 0, nt = 1, rt = 2, Be = 3;
|
|
138
|
+
var Ke = Object.prototype.hasOwnProperty;
|
|
139
|
+
function Te(e, t) {
|
|
140
|
+
var n, r;
|
|
141
|
+
if (e === t) return !0;
|
|
142
|
+
if (e && t && (n = e.constructor) === t.constructor) {
|
|
143
|
+
if (n === Date) return e.getTime() === t.getTime();
|
|
144
|
+
if (n === RegExp) return e.toString() === t.toString();
|
|
145
|
+
if (n === Array) {
|
|
146
|
+
if ((r = e.length) === t.length)
|
|
147
|
+
for (; r-- && Te(e[r], t[r]); ) ;
|
|
148
|
+
return r === -1;
|
|
149
|
+
}
|
|
150
|
+
if (!n || typeof e == "object") {
|
|
151
|
+
r = 0;
|
|
152
|
+
for (n in e)
|
|
153
|
+
if (Ke.call(e, n) && ++r && !Ke.call(t, n) || !(n in t) || !Te(e[n], t[n])) return !1;
|
|
154
|
+
return Object.keys(t).length === r;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return e !== e && t !== t;
|
|
158
|
+
}
|
|
159
|
+
const j = /* @__PURE__ */ new WeakMap(), U = () => {
|
|
160
|
+
}, T = (
|
|
161
|
+
/*#__NOINLINE__*/
|
|
162
|
+
U()
|
|
163
|
+
), De = Object, u = (e) => e === T, F = (e) => typeof e == "function", q = (e, t) => ({
|
|
164
|
+
...e,
|
|
165
|
+
...t
|
|
166
|
+
}), ot = (e) => F(e.then), me = {}, le = {}, xe = "undefined", se = typeof window != xe, Ce = typeof document != xe, Rt = se && "Deno" in window, wt = () => se && typeof window.requestAnimationFrame != xe, st = (e, t) => {
|
|
167
|
+
const n = j.get(e);
|
|
168
|
+
return [
|
|
169
|
+
// Getter
|
|
170
|
+
() => !u(t) && e.get(t) || me,
|
|
171
|
+
// Setter
|
|
172
|
+
(r) => {
|
|
173
|
+
if (!u(t)) {
|
|
174
|
+
const a = e.get(t);
|
|
175
|
+
t in le || (le[t] = a), n[5](t, q(a, r), a || me);
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
// Subscriber
|
|
179
|
+
n[6],
|
|
180
|
+
// Get server cache snapshot
|
|
181
|
+
() => !u(t) && t in le ? le[t] : !u(t) && e.get(t) || me
|
|
182
|
+
];
|
|
183
|
+
};
|
|
184
|
+
let Le = !0;
|
|
185
|
+
const yt = () => Le, [Ae, Ie] = se && window.addEventListener ? [
|
|
186
|
+
window.addEventListener.bind(window),
|
|
187
|
+
window.removeEventListener.bind(window)
|
|
188
|
+
] : [
|
|
189
|
+
U,
|
|
190
|
+
U
|
|
191
|
+
], Tt = () => {
|
|
192
|
+
const e = Ce && document.visibilityState;
|
|
193
|
+
return u(e) || e !== "hidden";
|
|
194
|
+
}, Dt = (e) => (Ce && document.addEventListener("visibilitychange", e), Ae("focus", e), () => {
|
|
195
|
+
Ce && document.removeEventListener("visibilitychange", e), Ie("focus", e);
|
|
196
|
+
}), Ct = (e) => {
|
|
197
|
+
const t = () => {
|
|
198
|
+
Le = !0, e();
|
|
199
|
+
}, n = () => {
|
|
200
|
+
Le = !1;
|
|
201
|
+
};
|
|
202
|
+
return Ae("online", t), Ae("offline", n), () => {
|
|
203
|
+
Ie("online", t), Ie("offline", n);
|
|
204
|
+
};
|
|
205
|
+
}, Lt = {
|
|
206
|
+
isOnline: yt,
|
|
207
|
+
isVisible: Tt
|
|
208
|
+
}, At = {
|
|
209
|
+
initFocus: Dt,
|
|
210
|
+
initReconnect: Ct
|
|
211
|
+
}, ze = !oe.useId, Z = !se || Rt, It = (e) => wt() ? window.requestAnimationFrame(e) : setTimeout(e, 1), ge = Z ? Et : pt, Oe = typeof navigator < "u" && navigator.connection, Ye = !Z && Oe && ([
|
|
212
|
+
"slow-2g",
|
|
213
|
+
"2g"
|
|
214
|
+
].includes(Oe.effectiveType) || Oe.saveData), fe = /* @__PURE__ */ new WeakMap(), bt = (e) => De.prototype.toString.call(e), Re = (e, t) => e === `[object ${t}]`;
|
|
215
|
+
let Vt = 0;
|
|
216
|
+
const be = (e) => {
|
|
217
|
+
const t = typeof e, n = bt(e), r = Re(n, "Date"), a = Re(n, "RegExp"), l = Re(n, "Object");
|
|
218
|
+
let s, f;
|
|
219
|
+
if (De(e) === e && !r && !a) {
|
|
220
|
+
if (s = fe.get(e), s) return s;
|
|
221
|
+
if (s = ++Vt + "~", fe.set(e, s), Array.isArray(e)) {
|
|
222
|
+
for (s = "@", f = 0; f < e.length; f++)
|
|
223
|
+
s += be(e[f]) + ",";
|
|
224
|
+
fe.set(e, s);
|
|
225
|
+
}
|
|
226
|
+
if (l) {
|
|
227
|
+
s = "#";
|
|
228
|
+
const p = De.keys(e).sort();
|
|
229
|
+
for (; !u(f = p.pop()); )
|
|
230
|
+
u(e[f]) || (s += f + ":" + be(e[f]) + ",");
|
|
231
|
+
fe.set(e, s);
|
|
232
|
+
}
|
|
233
|
+
} else
|
|
234
|
+
s = r ? e.toJSON() : t == "symbol" ? e.toString() : t == "string" ? JSON.stringify(e) : "" + e;
|
|
235
|
+
return s;
|
|
236
|
+
}, Ne = (e) => {
|
|
237
|
+
if (F(e))
|
|
238
|
+
try {
|
|
239
|
+
e = e();
|
|
240
|
+
} catch {
|
|
241
|
+
e = "";
|
|
242
|
+
}
|
|
243
|
+
const t = e;
|
|
244
|
+
return e = typeof e == "string" ? e : (Array.isArray(e) ? e.length : e) ? be(e) : "", [
|
|
245
|
+
e,
|
|
246
|
+
t
|
|
247
|
+
];
|
|
248
|
+
};
|
|
249
|
+
let xt = 0;
|
|
250
|
+
const Ve = () => ++xt;
|
|
251
|
+
async function it(...e) {
|
|
252
|
+
const [t, n, r, a] = e, l = q({
|
|
253
|
+
populateCache: !0,
|
|
254
|
+
throwOnError: !0
|
|
255
|
+
}, typeof a == "boolean" ? {
|
|
256
|
+
revalidate: a
|
|
257
|
+
} : a || {});
|
|
258
|
+
let s = l.populateCache;
|
|
259
|
+
const f = l.rollbackOnError;
|
|
260
|
+
let p = l.optimisticData;
|
|
261
|
+
const D = (h) => typeof f == "function" ? f(h) : f !== !1, _ = l.throwOnError;
|
|
262
|
+
if (F(n)) {
|
|
263
|
+
const h = n, i = [], d = t.keys();
|
|
264
|
+
for (const E of d)
|
|
265
|
+
// Skip the special useSWRInfinite and useSWRSubscription keys.
|
|
266
|
+
!/^\$(inf|sub)\$/.test(E) && h(t.get(E)._k) && i.push(E);
|
|
267
|
+
return Promise.all(i.map(c));
|
|
268
|
+
}
|
|
269
|
+
return c(n);
|
|
270
|
+
async function c(h) {
|
|
271
|
+
const [i] = Ne(h);
|
|
272
|
+
if (!i) return;
|
|
273
|
+
const [d, E] = st(t, i), [R, C, o, ie] = j.get(t), $ = () => {
|
|
274
|
+
const I = R[i];
|
|
275
|
+
return (F(l.revalidate) ? l.revalidate(d().data, h) : l.revalidate !== !1) && (delete o[i], delete ie[i], I && I[0]) ? I[0](rt).then(() => d().data) : d().data;
|
|
276
|
+
};
|
|
277
|
+
if (e.length < 3)
|
|
278
|
+
return $();
|
|
279
|
+
let y = r, V, x = !1;
|
|
280
|
+
const B = Ve();
|
|
281
|
+
C[i] = [
|
|
282
|
+
B,
|
|
283
|
+
0
|
|
284
|
+
];
|
|
285
|
+
const v = !u(p), K = d(), N = K.data, z = K._c, H = u(z) ? N : z;
|
|
286
|
+
if (v && (p = F(p) ? p(H, N) : p, E({
|
|
287
|
+
data: p,
|
|
288
|
+
_c: H
|
|
289
|
+
})), F(y))
|
|
290
|
+
try {
|
|
291
|
+
y = y(H);
|
|
292
|
+
} catch (I) {
|
|
293
|
+
V = I, x = !0;
|
|
294
|
+
}
|
|
295
|
+
if (y && ot(y))
|
|
296
|
+
if (y = await y.catch((I) => {
|
|
297
|
+
V = I, x = !0;
|
|
298
|
+
}), B !== C[i][0]) {
|
|
299
|
+
if (x) throw V;
|
|
300
|
+
return y;
|
|
301
|
+
} else x && v && D(V) && (s = !0, E({
|
|
302
|
+
data: H,
|
|
303
|
+
_c: T
|
|
304
|
+
}));
|
|
305
|
+
if (s && !x)
|
|
306
|
+
if (F(s)) {
|
|
307
|
+
const I = s(y, H);
|
|
308
|
+
E({
|
|
309
|
+
data: I,
|
|
310
|
+
error: T,
|
|
311
|
+
_c: T
|
|
312
|
+
});
|
|
313
|
+
} else
|
|
314
|
+
E({
|
|
315
|
+
data: y,
|
|
316
|
+
error: T,
|
|
317
|
+
_c: T
|
|
318
|
+
});
|
|
319
|
+
if (C[i][1] = Ve(), Promise.resolve($()).then(() => {
|
|
320
|
+
E({
|
|
321
|
+
_c: T
|
|
322
|
+
});
|
|
323
|
+
}), x) {
|
|
324
|
+
if (_) throw V;
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
return y;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
const Je = (e, t) => {
|
|
331
|
+
for (const n in e)
|
|
332
|
+
e[n][0] && e[n][0](t);
|
|
333
|
+
}, Nt = (e, t) => {
|
|
334
|
+
if (!j.has(e)) {
|
|
335
|
+
const n = q(At, t), r = /* @__PURE__ */ Object.create(null), a = it.bind(T, e);
|
|
336
|
+
let l = U;
|
|
337
|
+
const s = /* @__PURE__ */ Object.create(null), f = (_, c) => {
|
|
338
|
+
const h = s[_] || [];
|
|
339
|
+
return s[_] = h, h.push(c), () => h.splice(h.indexOf(c), 1);
|
|
340
|
+
}, p = (_, c, h) => {
|
|
341
|
+
e.set(_, c);
|
|
342
|
+
const i = s[_];
|
|
343
|
+
if (i)
|
|
344
|
+
for (const d of i)
|
|
345
|
+
d(c, h);
|
|
346
|
+
}, D = () => {
|
|
347
|
+
if (!j.has(e) && (j.set(e, [
|
|
348
|
+
r,
|
|
349
|
+
/* @__PURE__ */ Object.create(null),
|
|
350
|
+
/* @__PURE__ */ Object.create(null),
|
|
351
|
+
/* @__PURE__ */ Object.create(null),
|
|
352
|
+
a,
|
|
353
|
+
p,
|
|
354
|
+
f
|
|
355
|
+
]), !Z)) {
|
|
356
|
+
const _ = n.initFocus(setTimeout.bind(T, Je.bind(T, r, tt))), c = n.initReconnect(setTimeout.bind(T, Je.bind(T, r, nt)));
|
|
357
|
+
l = () => {
|
|
358
|
+
_ && _(), c && c(), j.delete(e);
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
return D(), [
|
|
363
|
+
e,
|
|
364
|
+
a,
|
|
365
|
+
D,
|
|
366
|
+
l
|
|
367
|
+
];
|
|
368
|
+
}
|
|
369
|
+
return [
|
|
370
|
+
e,
|
|
371
|
+
j.get(e)[4]
|
|
372
|
+
];
|
|
373
|
+
}, Wt = (e, t, n, r, a) => {
|
|
374
|
+
const l = n.errorRetryCount, s = a.retryCount, f = ~~((Math.random() + 0.5) * (1 << (s < 8 ? s : 8))) * n.errorRetryInterval;
|
|
375
|
+
!u(l) && s > l || setTimeout(r, f, a);
|
|
376
|
+
}, Ft = Te, [at, Pt] = Nt(/* @__PURE__ */ new Map()), jt = q(
|
|
377
|
+
{
|
|
378
|
+
// events
|
|
379
|
+
onLoadingSlow: U,
|
|
380
|
+
onSuccess: U,
|
|
381
|
+
onError: U,
|
|
382
|
+
onErrorRetry: Wt,
|
|
383
|
+
onDiscarded: U,
|
|
384
|
+
// switches
|
|
385
|
+
revalidateOnFocus: !0,
|
|
386
|
+
revalidateOnReconnect: !0,
|
|
387
|
+
revalidateIfStale: !0,
|
|
388
|
+
shouldRetryOnError: !0,
|
|
389
|
+
// timeouts
|
|
390
|
+
errorRetryInterval: Ye ? 1e4 : 5e3,
|
|
391
|
+
focusThrottleInterval: 5 * 1e3,
|
|
392
|
+
dedupingInterval: 2 * 1e3,
|
|
393
|
+
loadingTimeout: Ye ? 5e3 : 3e3,
|
|
394
|
+
// providers
|
|
395
|
+
compare: Ft,
|
|
396
|
+
isPaused: () => !1,
|
|
397
|
+
cache: at,
|
|
398
|
+
mutate: Pt,
|
|
399
|
+
fallback: {}
|
|
400
|
+
},
|
|
401
|
+
// use web preset by default
|
|
402
|
+
Lt
|
|
403
|
+
), Ut = (e, t) => {
|
|
404
|
+
const n = q(e, t);
|
|
405
|
+
if (t) {
|
|
406
|
+
const { use: r, fallback: a } = e, { use: l, fallback: s } = t;
|
|
407
|
+
r && l && (n.use = r.concat(l)), a && s && (n.fallback = q(a, s));
|
|
408
|
+
}
|
|
409
|
+
return n;
|
|
410
|
+
}, Mt = Qe({}), qt = "$inf$", ct = se && window.__SWR_DEVTOOLS_USE__, Ht = ct ? window.__SWR_DEVTOOLS_USE__ : [], kt = () => {
|
|
411
|
+
ct && (window.__SWR_DEVTOOLS_REACT__ = oe);
|
|
412
|
+
}, Gt = (e) => F(e[1]) ? [
|
|
413
|
+
e[0],
|
|
414
|
+
e[1],
|
|
415
|
+
e[2] || {}
|
|
416
|
+
] : [
|
|
417
|
+
e[0],
|
|
418
|
+
null,
|
|
419
|
+
(e[1] === null ? e[2] : e[1]) || {}
|
|
420
|
+
], $t = () => {
|
|
421
|
+
const e = Ze(Mt);
|
|
422
|
+
return et(() => q(jt, e), [
|
|
423
|
+
e
|
|
424
|
+
]);
|
|
425
|
+
}, Bt = (e) => (t, n, r) => e(t, n && ((...l) => {
|
|
426
|
+
const [s] = Ne(t), [, , , f] = j.get(at);
|
|
427
|
+
if (s.startsWith(qt))
|
|
428
|
+
return n(...l);
|
|
429
|
+
const p = f[s];
|
|
430
|
+
return u(p) ? n(...l) : (delete f[s], p);
|
|
431
|
+
}), r), Kt = Ht.concat(Bt), zt = (e) => function(...n) {
|
|
432
|
+
const r = $t(), [a, l, s] = Gt(n), f = Ut(r, s);
|
|
433
|
+
let p = e;
|
|
434
|
+
const { use: D } = f, _ = (D || []).concat(Kt);
|
|
435
|
+
for (let c = _.length; c--; )
|
|
436
|
+
p = _[c](p);
|
|
437
|
+
return p(a, l || f.fetcher || null, f);
|
|
438
|
+
}, Yt = (e, t, n) => {
|
|
439
|
+
const r = t[e] || (t[e] = []);
|
|
440
|
+
return r.push(n), () => {
|
|
441
|
+
const a = r.indexOf(n);
|
|
442
|
+
a >= 0 && (r[a] = r[r.length - 1], r.pop());
|
|
443
|
+
};
|
|
444
|
+
};
|
|
445
|
+
kt();
|
|
446
|
+
const we = oe.use || // This extra generic is to avoid TypeScript mixing up the generic and JSX sytax
|
|
447
|
+
// and emitting an error.
|
|
448
|
+
// We assume that this is only for the `use(thenable)` case, not `use(context)`.
|
|
449
|
+
// https://github.com/facebook/react/blob/aed00dacfb79d17c53218404c52b1c7aa59c4a89/packages/react-server/src/ReactFizzThenable.js#L45
|
|
450
|
+
((e) => {
|
|
451
|
+
switch (e.status) {
|
|
452
|
+
case "pending":
|
|
453
|
+
throw e;
|
|
454
|
+
case "fulfilled":
|
|
455
|
+
return e.value;
|
|
456
|
+
case "rejected":
|
|
457
|
+
throw e.reason;
|
|
458
|
+
default:
|
|
459
|
+
throw e.status = "pending", e.then((t) => {
|
|
460
|
+
e.status = "fulfilled", e.value = t;
|
|
461
|
+
}, (t) => {
|
|
462
|
+
e.status = "rejected", e.reason = t;
|
|
463
|
+
}), e;
|
|
464
|
+
}
|
|
465
|
+
}), ye = {
|
|
466
|
+
dedupe: !0
|
|
467
|
+
}, Xe = Promise.resolve(T), Jt = () => U, Xt = (e, t, n) => {
|
|
468
|
+
const { cache: r, compare: a, suspense: l, fallbackData: s, revalidateOnMount: f, revalidateIfStale: p, refreshInterval: D, refreshWhenHidden: _, refreshWhenOffline: c, keepPreviousData: h, strictServerPrefetchWarning: i } = n, [d, E, R, C] = j.get(r), [o, ie] = Ne(e), $ = M(!1), y = M(!1), V = M(o), x = M(t), B = M(n), v = () => B.current, K = () => v().isVisible() && v().isOnline(), [N, z, H, I] = st(r, o), Y = M({}).current, J = u(s) ? u(n.fallback) ? T : n.fallback[o] : s, We = (S, m) => {
|
|
469
|
+
for (const g in Y) {
|
|
470
|
+
const O = g;
|
|
471
|
+
if (O === "data") {
|
|
472
|
+
if (!a(S[O], m[O]) && (!u(S[O]) || !a(ce, m[O])))
|
|
473
|
+
return !1;
|
|
474
|
+
} else if (m[O] !== S[O])
|
|
475
|
+
return !1;
|
|
476
|
+
}
|
|
477
|
+
return !0;
|
|
478
|
+
}, de = !$.current, Fe = et(() => {
|
|
479
|
+
const S = N(), m = I(), g = (w) => {
|
|
480
|
+
const b = q(w);
|
|
481
|
+
return delete b._k, (() => {
|
|
482
|
+
if (!o || !t || v().isPaused()) return !1;
|
|
483
|
+
if (de && !u(f)) return f;
|
|
484
|
+
const re = u(J) ? b.data : J;
|
|
485
|
+
return u(re) || p;
|
|
486
|
+
})() ? {
|
|
487
|
+
isValidating: !0,
|
|
488
|
+
isLoading: !0,
|
|
489
|
+
...b
|
|
490
|
+
} : b;
|
|
491
|
+
}, O = g(S), W = S === m ? O : g(m);
|
|
492
|
+
let L = O;
|
|
493
|
+
return [
|
|
494
|
+
() => {
|
|
495
|
+
const w = g(N());
|
|
496
|
+
return We(w, L) ? (L.data = w.data, L.isLoading = w.isLoading, L.isValidating = w.isValidating, L.error = w.error, L) : (L = w, w);
|
|
497
|
+
},
|
|
498
|
+
() => W
|
|
499
|
+
];
|
|
500
|
+
}, [
|
|
501
|
+
r,
|
|
502
|
+
o
|
|
503
|
+
]), X = $e.useSyncExternalStore(Se(
|
|
504
|
+
(S) => H(o, (m, g) => {
|
|
505
|
+
We(g, m) || S();
|
|
506
|
+
}),
|
|
507
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
508
|
+
[
|
|
509
|
+
r,
|
|
510
|
+
o
|
|
511
|
+
]
|
|
512
|
+
), Fe[0], Fe[1]), ut = d[o] && d[o].length > 0, Q = X.data, k = u(Q) ? J && ot(J) ? we(J) : J : Q, ae = X.error, he = M(k), ce = h ? u(Q) ? u(he.current) ? k : he.current : Q : k, G = o && u(k), ee = M(null);
|
|
513
|
+
!Z && // getServerSnapshot is only called during hydration
|
|
514
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
515
|
+
$e.useSyncExternalStore(Jt, () => (ee.current = !1, ee), () => (ee.current = !0, ee));
|
|
516
|
+
const lt = ee.current;
|
|
517
|
+
i && lt && !l && G && console.warn(`Missing pre-initiated data for serialized key "${o}" during server-side rendering. Data fetching should be initiated on the server and provided to SWR via fallback data. You can set "strictServerPrefetchWarning: false" to disable this warning.`);
|
|
518
|
+
const Pe = !o || !t || v().isPaused() || ut && !u(ae) ? !1 : de && !u(f) ? f : l ? u(k) ? !1 : p : u(k) || p, je = de && Pe, ft = u(X.isValidating) ? je : X.isValidating, dt = u(X.isLoading) ? je : X.isLoading, te = Se(
|
|
519
|
+
async (S) => {
|
|
520
|
+
const m = x.current;
|
|
521
|
+
if (!o || !m || y.current || v().isPaused())
|
|
522
|
+
return !1;
|
|
523
|
+
let g, O, W = !0;
|
|
524
|
+
const L = S || {}, w = !R[o] || !L.dedupe, b = () => ze ? !y.current && o === V.current && $.current : o === V.current, ne = {
|
|
525
|
+
isValidating: !1,
|
|
526
|
+
isLoading: !1
|
|
527
|
+
}, re = () => {
|
|
528
|
+
z(ne);
|
|
529
|
+
}, Me = () => {
|
|
530
|
+
const A = R[o];
|
|
531
|
+
A && A[1] === O && delete R[o];
|
|
532
|
+
}, qe = {
|
|
533
|
+
isValidating: !0
|
|
534
|
+
};
|
|
535
|
+
u(N().data) && (qe.isLoading = !0);
|
|
536
|
+
try {
|
|
537
|
+
if (w && (z(qe), n.loadingTimeout && u(N().data) && setTimeout(() => {
|
|
538
|
+
W && b() && v().onLoadingSlow(o, n);
|
|
539
|
+
}, n.loadingTimeout), R[o] = [
|
|
540
|
+
m(ie),
|
|
541
|
+
Ve()
|
|
542
|
+
]), [g, O] = R[o], g = await g, w && setTimeout(Me, n.dedupingInterval), !R[o] || R[o][1] !== O)
|
|
543
|
+
return w && b() && v().onDiscarded(o), !1;
|
|
544
|
+
ne.error = T;
|
|
545
|
+
const A = E[o];
|
|
546
|
+
if (!u(A) && // case 1
|
|
547
|
+
(O <= A[0] || // case 2
|
|
548
|
+
O <= A[1] || // case 3
|
|
549
|
+
A[1] === 0))
|
|
550
|
+
return re(), w && b() && v().onDiscarded(o), !1;
|
|
551
|
+
const P = N().data;
|
|
552
|
+
ne.data = a(P, g) ? P : g, w && b() && v().onSuccess(g, o, n);
|
|
553
|
+
} catch (A) {
|
|
554
|
+
Me();
|
|
555
|
+
const P = v(), { shouldRetryOnError: Ee } = P;
|
|
556
|
+
P.isPaused() || (ne.error = A, w && b() && (P.onError(A, o, P), (Ee === !0 || F(Ee) && Ee(A)) && (!v().revalidateOnFocus || !v().revalidateOnReconnect || K()) && P.onErrorRetry(A, o, P, (ht) => {
|
|
557
|
+
const pe = d[o];
|
|
558
|
+
pe && pe[0] && pe[0](Be, ht);
|
|
559
|
+
}, {
|
|
560
|
+
retryCount: (L.retryCount || 0) + 1,
|
|
561
|
+
dedupe: !0
|
|
562
|
+
})));
|
|
563
|
+
}
|
|
564
|
+
return W = !1, re(), !0;
|
|
565
|
+
},
|
|
566
|
+
// `setState` is immutable, and `eventsCallback`, `fnArg`, and
|
|
567
|
+
// `keyValidating` are depending on `key`, so we can exclude them from
|
|
568
|
+
// the deps array.
|
|
569
|
+
//
|
|
570
|
+
// FIXME:
|
|
571
|
+
// `fn` and `config` might be changed during the lifecycle,
|
|
572
|
+
// but they might be changed every render like this.
|
|
573
|
+
// `useSWR('key', () => fetch('/api/'), { suspense: true })`
|
|
574
|
+
// So we omit the values from the deps array
|
|
575
|
+
// even though it might cause unexpected behaviors.
|
|
576
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
577
|
+
[
|
|
578
|
+
o,
|
|
579
|
+
r
|
|
580
|
+
]
|
|
581
|
+
), Ue = Se(
|
|
582
|
+
// Use callback to make sure `keyRef.current` returns latest result every time
|
|
583
|
+
(...S) => it(r, V.current, ...S),
|
|
584
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
585
|
+
[]
|
|
586
|
+
);
|
|
587
|
+
if (ge(() => {
|
|
588
|
+
x.current = t, B.current = n, u(Q) || (he.current = Q);
|
|
589
|
+
}), ge(() => {
|
|
590
|
+
if (!o) return;
|
|
591
|
+
const S = te.bind(T, ye);
|
|
592
|
+
let m = 0;
|
|
593
|
+
v().revalidateOnFocus && (m = Date.now() + v().focusThrottleInterval);
|
|
594
|
+
const O = Yt(o, d, (W, L = {}) => {
|
|
595
|
+
if (W == tt) {
|
|
596
|
+
const w = Date.now();
|
|
597
|
+
v().revalidateOnFocus && w > m && K() && (m = w + v().focusThrottleInterval, S());
|
|
598
|
+
} else if (W == nt)
|
|
599
|
+
v().revalidateOnReconnect && K() && S();
|
|
600
|
+
else {
|
|
601
|
+
if (W == rt)
|
|
602
|
+
return te();
|
|
603
|
+
if (W == Be)
|
|
604
|
+
return te(L);
|
|
605
|
+
}
|
|
606
|
+
});
|
|
607
|
+
return y.current = !1, V.current = o, $.current = !0, z({
|
|
608
|
+
_k: ie
|
|
609
|
+
}), Pe && (R[o] || (u(k) || Z ? S() : It(S))), () => {
|
|
610
|
+
y.current = !0, O();
|
|
611
|
+
};
|
|
612
|
+
}, [
|
|
613
|
+
o
|
|
614
|
+
]), ge(() => {
|
|
615
|
+
let S;
|
|
616
|
+
function m() {
|
|
617
|
+
const O = F(D) ? D(N().data) : D;
|
|
618
|
+
O && S !== -1 && (S = setTimeout(g, O));
|
|
619
|
+
}
|
|
620
|
+
function g() {
|
|
621
|
+
!N().error && (_ || v().isVisible()) && (c || v().isOnline()) ? te(ye).then(m) : m();
|
|
622
|
+
}
|
|
623
|
+
return m(), () => {
|
|
624
|
+
S && (clearTimeout(S), S = -1);
|
|
625
|
+
};
|
|
626
|
+
}, [
|
|
627
|
+
D,
|
|
628
|
+
_,
|
|
629
|
+
c,
|
|
630
|
+
o
|
|
631
|
+
]), St(ce), l) {
|
|
632
|
+
if (!ze && Z && G)
|
|
633
|
+
throw new Error("Fallback data is required when using Suspense in SSR.");
|
|
634
|
+
G && (x.current = t, B.current = n, y.current = !1);
|
|
635
|
+
const S = C[o], m = !u(S) && G ? Ue(S) : Xe;
|
|
636
|
+
if (we(m), !u(ae) && G)
|
|
637
|
+
throw ae;
|
|
638
|
+
const g = G ? te(ye) : Xe;
|
|
639
|
+
!u(ce) && G && (g.status = "fulfilled", g.value = !0), we(g);
|
|
640
|
+
}
|
|
641
|
+
return {
|
|
642
|
+
mutate: Ue,
|
|
643
|
+
get data() {
|
|
644
|
+
return Y.data = !0, ce;
|
|
645
|
+
},
|
|
646
|
+
get error() {
|
|
647
|
+
return Y.error = !0, ae;
|
|
648
|
+
},
|
|
649
|
+
get isValidating() {
|
|
650
|
+
return Y.isValidating = !0, ft;
|
|
651
|
+
},
|
|
652
|
+
get isLoading() {
|
|
653
|
+
return Y.isLoading = !0, dt;
|
|
654
|
+
}
|
|
655
|
+
};
|
|
656
|
+
}, Qt = zt(Xt), Zt = (...e) => fetch(...e).then((t) => {
|
|
657
|
+
if (!t.ok)
|
|
658
|
+
throw new Error(t.statusText);
|
|
659
|
+
return t.json();
|
|
660
|
+
}), rn = (e, t) => Qt(e, async (n) => Zt(n, t)), on = (e) => {
|
|
661
|
+
switch (e) {
|
|
662
|
+
case "development":
|
|
663
|
+
return "http://localhost:3000";
|
|
664
|
+
case "staging":
|
|
665
|
+
return "https://staging.deva.me";
|
|
666
|
+
case "production":
|
|
667
|
+
return "https://www.deva.me";
|
|
668
|
+
}
|
|
669
|
+
};
|
|
670
|
+
export {
|
|
671
|
+
_t as D,
|
|
672
|
+
nn as a,
|
|
673
|
+
on as e,
|
|
674
|
+
Zt as f,
|
|
675
|
+
$e as s,
|
|
676
|
+
rn as u
|
|
677
|
+
};
|