@graffiticode/l0000-view 0.1.2 → 0.1.4
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/index.d.ts +11 -1
- package/dist/index.js +507 -488
- package/dist/index.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
var
|
|
1
|
+
import { jsx as q, jsxs as Le } from "react/jsx-runtime";
|
|
2
|
+
import ce, { createContext as vt, useEffect as te, useLayoutEffect as Ot, useContext as wt, useMemo as me, useRef as W, useCallback as he, useDebugValue as _t, useState as ae, useReducer as Rt } from "react";
|
|
3
|
+
var Ce = { exports: {} }, ve = {};
|
|
4
4
|
/**
|
|
5
5
|
* @license React
|
|
6
6
|
* use-sync-external-store-shim.production.js
|
|
@@ -10,48 +10,48 @@ var Ct = { exports: {} }, yt = {};
|
|
|
10
10
|
* This source code is licensed under the MIT license found in the
|
|
11
11
|
* LICENSE file in the root directory of this source tree.
|
|
12
12
|
*/
|
|
13
|
-
var
|
|
14
|
-
function
|
|
15
|
-
if (
|
|
16
|
-
|
|
17
|
-
var
|
|
18
|
-
function
|
|
19
|
-
return u ===
|
|
13
|
+
var ze;
|
|
14
|
+
function Dt() {
|
|
15
|
+
if (ze) return ve;
|
|
16
|
+
ze = 1;
|
|
17
|
+
var e = ce;
|
|
18
|
+
function t(u, l) {
|
|
19
|
+
return u === l && (u !== 0 || 1 / u === 1 / l) || u !== u && l !== l;
|
|
20
20
|
}
|
|
21
|
-
var n = typeof Object.is == "function" ? Object.is :
|
|
22
|
-
function
|
|
23
|
-
var
|
|
24
|
-
return
|
|
21
|
+
var n = typeof Object.is == "function" ? Object.is : t, r = e.useState, s = e.useEffect, a = e.useLayoutEffect, o = e.useDebugValue;
|
|
22
|
+
function f(u, l) {
|
|
23
|
+
var c = l(), p = r({ inst: { value: c, getSnapshot: l } }), m = p[0].inst, g = p[1];
|
|
24
|
+
return a(
|
|
25
25
|
function() {
|
|
26
|
-
|
|
26
|
+
m.value = c, m.getSnapshot = l, h(m) && g({ inst: m });
|
|
27
27
|
},
|
|
28
|
-
[u,
|
|
29
|
-
),
|
|
28
|
+
[u, c, l]
|
|
29
|
+
), s(
|
|
30
30
|
function() {
|
|
31
|
-
return m
|
|
32
|
-
m
|
|
31
|
+
return h(m) && g({ inst: m }), u(function() {
|
|
32
|
+
h(m) && g({ inst: m });
|
|
33
33
|
});
|
|
34
34
|
},
|
|
35
35
|
[u]
|
|
36
|
-
),
|
|
36
|
+
), o(c), c;
|
|
37
37
|
}
|
|
38
|
-
function
|
|
39
|
-
var
|
|
38
|
+
function h(u) {
|
|
39
|
+
var l = u.getSnapshot;
|
|
40
40
|
u = u.value;
|
|
41
41
|
try {
|
|
42
|
-
var
|
|
43
|
-
return !n(u,
|
|
42
|
+
var c = l();
|
|
43
|
+
return !n(u, c);
|
|
44
44
|
} catch {
|
|
45
45
|
return !0;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
function
|
|
49
|
-
return
|
|
48
|
+
function A(u, l) {
|
|
49
|
+
return l();
|
|
50
50
|
}
|
|
51
|
-
var
|
|
52
|
-
return
|
|
51
|
+
var y = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? A : f;
|
|
52
|
+
return ve.useSyncExternalStore = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : y, ve;
|
|
53
53
|
}
|
|
54
|
-
var
|
|
54
|
+
var Oe = {};
|
|
55
55
|
/**
|
|
56
56
|
* @license React
|
|
57
57
|
* use-sync-external-store-shim.development.js
|
|
@@ -61,307 +61,307 @@ var Ot = {};
|
|
|
61
61
|
* This source code is licensed under the MIT license found in the
|
|
62
62
|
* LICENSE file in the root directory of this source tree.
|
|
63
63
|
*/
|
|
64
|
-
var
|
|
65
|
-
function
|
|
66
|
-
return
|
|
67
|
-
function
|
|
68
|
-
return
|
|
64
|
+
var Ye;
|
|
65
|
+
function Tt() {
|
|
66
|
+
return Ye || (Ye = 1, process.env.NODE_ENV !== "production" && function() {
|
|
67
|
+
function e(c, p) {
|
|
68
|
+
return c === p && (c !== 0 || 1 / c === 1 / p) || c !== c && p !== p;
|
|
69
69
|
}
|
|
70
|
-
function
|
|
71
|
-
|
|
70
|
+
function t(c, p) {
|
|
71
|
+
y || s.startTransition === void 0 || (y = !0, console.error(
|
|
72
72
|
"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."
|
|
73
73
|
));
|
|
74
|
-
var
|
|
74
|
+
var m = p();
|
|
75
75
|
if (!u) {
|
|
76
|
-
var
|
|
77
|
-
|
|
76
|
+
var g = p();
|
|
77
|
+
a(m, g) || (console.error(
|
|
78
78
|
"The result of getSnapshot should be cached to avoid an infinite loop"
|
|
79
79
|
), u = !0);
|
|
80
80
|
}
|
|
81
|
-
|
|
82
|
-
inst: { value:
|
|
81
|
+
g = o({
|
|
82
|
+
inst: { value: m, getSnapshot: p }
|
|
83
83
|
});
|
|
84
|
-
var
|
|
85
|
-
return
|
|
84
|
+
var T = g[0].inst, i = g[1];
|
|
85
|
+
return h(
|
|
86
86
|
function() {
|
|
87
|
-
|
|
87
|
+
T.value = m, T.getSnapshot = p, n(T) && i({ inst: T });
|
|
88
88
|
},
|
|
89
|
-
[
|
|
90
|
-
),
|
|
89
|
+
[c, m, p]
|
|
90
|
+
), f(
|
|
91
91
|
function() {
|
|
92
|
-
return n(
|
|
93
|
-
n(
|
|
92
|
+
return n(T) && i({ inst: T }), c(function() {
|
|
93
|
+
n(T) && i({ inst: T });
|
|
94
94
|
});
|
|
95
95
|
},
|
|
96
|
-
[
|
|
97
|
-
),
|
|
96
|
+
[c]
|
|
97
|
+
), A(m), m;
|
|
98
98
|
}
|
|
99
|
-
function n(
|
|
100
|
-
var
|
|
101
|
-
|
|
99
|
+
function n(c) {
|
|
100
|
+
var p = c.getSnapshot;
|
|
101
|
+
c = c.value;
|
|
102
102
|
try {
|
|
103
|
-
var
|
|
104
|
-
return !c
|
|
103
|
+
var m = p();
|
|
104
|
+
return !a(c, m);
|
|
105
105
|
} catch {
|
|
106
106
|
return !0;
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
|
-
function r(
|
|
110
|
-
return
|
|
109
|
+
function r(c, p) {
|
|
110
|
+
return p();
|
|
111
111
|
}
|
|
112
112
|
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
113
|
-
var
|
|
114
|
-
|
|
115
|
-
}()),
|
|
113
|
+
var s = ce, a = typeof Object.is == "function" ? Object.is : e, o = s.useState, f = s.useEffect, h = s.useLayoutEffect, A = s.useDebugValue, y = !1, u = !1, l = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? r : t;
|
|
114
|
+
Oe.useSyncExternalStore = s.useSyncExternalStore !== void 0 ? s.useSyncExternalStore : l, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
115
|
+
}()), Oe;
|
|
116
116
|
}
|
|
117
|
-
process.env.NODE_ENV === "production" ?
|
|
118
|
-
var
|
|
119
|
-
const
|
|
120
|
-
var
|
|
121
|
-
function
|
|
117
|
+
process.env.NODE_ENV === "production" ? Ce.exports = Dt() : Ce.exports = Tt();
|
|
118
|
+
var Je = Ce.exports;
|
|
119
|
+
const it = 0, at = 1, ct = 2, Xe = 3;
|
|
120
|
+
var Qe = Object.prototype.hasOwnProperty;
|
|
121
|
+
function be(e, t) {
|
|
122
122
|
var n, r;
|
|
123
|
-
if (
|
|
124
|
-
if (
|
|
125
|
-
if (n === Date) return
|
|
126
|
-
if (n === RegExp) return
|
|
123
|
+
if (e === t) return !0;
|
|
124
|
+
if (e && t && (n = e.constructor) === t.constructor) {
|
|
125
|
+
if (n === Date) return e.getTime() === t.getTime();
|
|
126
|
+
if (n === RegExp) return e.toString() === t.toString();
|
|
127
127
|
if (n === Array) {
|
|
128
|
-
if ((r =
|
|
129
|
-
for (; r-- &&
|
|
128
|
+
if ((r = e.length) === t.length)
|
|
129
|
+
for (; r-- && be(e[r], t[r]); ) ;
|
|
130
130
|
return r === -1;
|
|
131
131
|
}
|
|
132
|
-
if (!n || typeof
|
|
132
|
+
if (!n || typeof e == "object") {
|
|
133
133
|
r = 0;
|
|
134
|
-
for (n in
|
|
135
|
-
if (
|
|
136
|
-
return Object.keys(
|
|
134
|
+
for (n in e)
|
|
135
|
+
if (Qe.call(e, n) && ++r && !Qe.call(t, n) || !(n in t) || !be(e[n], t[n])) return !1;
|
|
136
|
+
return Object.keys(t).length === r;
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
|
-
return
|
|
139
|
+
return e !== e && t !== t;
|
|
140
140
|
}
|
|
141
|
-
const
|
|
142
|
-
},
|
|
141
|
+
const U = /* @__PURE__ */ new WeakMap(), $ = () => {
|
|
142
|
+
}, L = (
|
|
143
143
|
/*#__NOINLINE__*/
|
|
144
144
|
$()
|
|
145
|
-
),
|
|
146
|
-
...
|
|
147
|
-
...
|
|
148
|
-
}),
|
|
149
|
-
const n =
|
|
145
|
+
), xe = Object, d = (e) => e === L, M = (e) => typeof e == "function", k = (e, t) => ({
|
|
146
|
+
...e,
|
|
147
|
+
...t
|
|
148
|
+
}), ut = (e) => M(e.then), we = {}, de = {}, We = "undefined", ue = typeof window != We, Ie = typeof document != We, At = ue && "Deno" in window, Lt = () => ue && typeof window.requestAnimationFrame != We, lt = (e, t) => {
|
|
149
|
+
const n = U.get(e);
|
|
150
150
|
return [
|
|
151
151
|
// Getter
|
|
152
|
-
() => !d(
|
|
152
|
+
() => !d(t) && e.get(t) || we,
|
|
153
153
|
// Setter
|
|
154
154
|
(r) => {
|
|
155
|
-
if (!d(
|
|
156
|
-
const
|
|
157
|
-
|
|
155
|
+
if (!d(t)) {
|
|
156
|
+
const s = e.get(t);
|
|
157
|
+
t in de || (de[t] = s), n[5](t, k(s, r), s || we);
|
|
158
158
|
}
|
|
159
159
|
},
|
|
160
160
|
// Subscriber
|
|
161
161
|
n[6],
|
|
162
162
|
// Get server cache snapshot
|
|
163
|
-
() => !d(
|
|
163
|
+
() => !d(t) && t in de ? de[t] : !d(t) && e.get(t) || we
|
|
164
164
|
];
|
|
165
165
|
};
|
|
166
|
-
let
|
|
167
|
-
const
|
|
166
|
+
let Ne = !0;
|
|
167
|
+
const Ct = () => Ne, [Ve, je] = ue && window.addEventListener ? [
|
|
168
168
|
window.addEventListener.bind(window),
|
|
169
169
|
window.removeEventListener.bind(window)
|
|
170
170
|
] : [
|
|
171
171
|
$,
|
|
172
172
|
$
|
|
173
|
-
],
|
|
174
|
-
const
|
|
175
|
-
return d(
|
|
176
|
-
},
|
|
177
|
-
|
|
178
|
-
}),
|
|
179
|
-
const
|
|
180
|
-
|
|
173
|
+
], bt = () => {
|
|
174
|
+
const e = Ie && document.visibilityState;
|
|
175
|
+
return d(e) || e !== "hidden";
|
|
176
|
+
}, xt = (e) => (Ie && document.addEventListener("visibilitychange", e), Ve("focus", e), () => {
|
|
177
|
+
Ie && document.removeEventListener("visibilitychange", e), je("focus", e);
|
|
178
|
+
}), It = (e) => {
|
|
179
|
+
const t = () => {
|
|
180
|
+
Ne = !0, e();
|
|
181
181
|
}, n = () => {
|
|
182
|
-
|
|
182
|
+
Ne = !1;
|
|
183
183
|
};
|
|
184
|
-
return
|
|
185
|
-
|
|
184
|
+
return Ve("online", t), Ve("offline", n), () => {
|
|
185
|
+
je("online", t), je("offline", n);
|
|
186
186
|
};
|
|
187
|
-
},
|
|
188
|
-
isOnline:
|
|
189
|
-
isVisible:
|
|
190
|
-
},
|
|
191
|
-
initFocus:
|
|
192
|
-
initReconnect:
|
|
193
|
-
},
|
|
187
|
+
}, Nt = {
|
|
188
|
+
isOnline: Ct,
|
|
189
|
+
isVisible: bt
|
|
190
|
+
}, Vt = {
|
|
191
|
+
initFocus: xt,
|
|
192
|
+
initReconnect: It
|
|
193
|
+
}, Ze = !ce.useId, ne = !ue || At, jt = (e) => Lt() ? window.requestAnimationFrame(e) : setTimeout(e, 1), _e = ne ? te : Ot, Re = typeof navigator < "u" && navigator.connection, et = !ne && Re && ([
|
|
194
194
|
"slow-2g",
|
|
195
195
|
"2g"
|
|
196
|
-
].includes(
|
|
197
|
-
let
|
|
198
|
-
const
|
|
199
|
-
const
|
|
200
|
-
let
|
|
201
|
-
if (
|
|
202
|
-
if (
|
|
203
|
-
if (
|
|
204
|
-
for (
|
|
205
|
-
|
|
206
|
-
|
|
196
|
+
].includes(Re.effectiveType) || Re.saveData), pe = /* @__PURE__ */ new WeakMap(), Ft = (e) => xe.prototype.toString.call(e), De = (e, t) => e === `[object ${t}]`;
|
|
197
|
+
let Mt = 0;
|
|
198
|
+
const Fe = (e) => {
|
|
199
|
+
const t = typeof e, n = Ft(e), r = De(n, "Date"), s = De(n, "RegExp"), a = De(n, "Object");
|
|
200
|
+
let o, f;
|
|
201
|
+
if (xe(e) === e && !r && !s) {
|
|
202
|
+
if (o = pe.get(e), o) return o;
|
|
203
|
+
if (o = ++Mt + "~", pe.set(e, o), Array.isArray(e)) {
|
|
204
|
+
for (o = "@", f = 0; f < e.length; f++)
|
|
205
|
+
o += Fe(e[f]) + ",";
|
|
206
|
+
pe.set(e, o);
|
|
207
207
|
}
|
|
208
|
-
if (
|
|
209
|
-
|
|
210
|
-
const
|
|
211
|
-
for (; !d(
|
|
212
|
-
d(
|
|
213
|
-
|
|
208
|
+
if (a) {
|
|
209
|
+
o = "#";
|
|
210
|
+
const h = xe.keys(e).sort();
|
|
211
|
+
for (; !d(f = h.pop()); )
|
|
212
|
+
d(e[f]) || (o += f + ":" + Fe(e[f]) + ",");
|
|
213
|
+
pe.set(e, o);
|
|
214
214
|
}
|
|
215
215
|
} else
|
|
216
|
-
|
|
217
|
-
return
|
|
218
|
-
},
|
|
219
|
-
if (
|
|
216
|
+
o = r ? e.toJSON() : t == "symbol" ? e.toString() : t == "string" ? JSON.stringify(e) : "" + e;
|
|
217
|
+
return o;
|
|
218
|
+
}, qe = (e) => {
|
|
219
|
+
if (M(e))
|
|
220
220
|
try {
|
|
221
|
-
|
|
221
|
+
e = e();
|
|
222
222
|
} catch {
|
|
223
|
-
|
|
223
|
+
e = "";
|
|
224
224
|
}
|
|
225
|
-
const
|
|
226
|
-
return
|
|
227
|
-
|
|
228
|
-
|
|
225
|
+
const t = e;
|
|
226
|
+
return e = typeof e == "string" ? e : (Array.isArray(e) ? e.length : e) ? Fe(e) : "", [
|
|
227
|
+
e,
|
|
228
|
+
t
|
|
229
229
|
];
|
|
230
230
|
};
|
|
231
|
-
let
|
|
232
|
-
const
|
|
233
|
-
async function
|
|
234
|
-
const [
|
|
231
|
+
let Pt = 0;
|
|
232
|
+
const Me = () => ++Pt;
|
|
233
|
+
async function ft(...e) {
|
|
234
|
+
const [t, n, r, s] = e, a = k({
|
|
235
235
|
populateCache: !0,
|
|
236
236
|
throwOnError: !0
|
|
237
|
-
}, typeof
|
|
238
|
-
revalidate:
|
|
239
|
-
} :
|
|
240
|
-
let
|
|
241
|
-
const
|
|
242
|
-
let
|
|
243
|
-
const
|
|
244
|
-
if (
|
|
245
|
-
const
|
|
246
|
-
for (const
|
|
237
|
+
}, typeof s == "boolean" ? {
|
|
238
|
+
revalidate: s
|
|
239
|
+
} : s || {});
|
|
240
|
+
let o = a.populateCache;
|
|
241
|
+
const f = a.rollbackOnError;
|
|
242
|
+
let h = a.optimisticData;
|
|
243
|
+
const A = (l) => typeof f == "function" ? f(l) : f !== !1, y = a.throwOnError;
|
|
244
|
+
if (M(n)) {
|
|
245
|
+
const l = n, c = [], p = t.keys();
|
|
246
|
+
for (const m of p)
|
|
247
247
|
// Skip the special useSWRInfinite and useSWRSubscription keys.
|
|
248
|
-
!/^\$(inf|sub)\$/.test(
|
|
249
|
-
return Promise.all(
|
|
248
|
+
!/^\$(inf|sub)\$/.test(m) && l(t.get(m)._k) && c.push(m);
|
|
249
|
+
return Promise.all(c.map(u));
|
|
250
250
|
}
|
|
251
251
|
return u(n);
|
|
252
|
-
async function u(
|
|
253
|
-
const [
|
|
254
|
-
if (!
|
|
255
|
-
const [
|
|
256
|
-
const
|
|
257
|
-
return (
|
|
252
|
+
async function u(l) {
|
|
253
|
+
const [c] = qe(l);
|
|
254
|
+
if (!c) return;
|
|
255
|
+
const [p, m] = lt(t, c), [g, T, i, z] = U.get(t), H = () => {
|
|
256
|
+
const N = g[c];
|
|
257
|
+
return (M(a.revalidate) ? a.revalidate(p().data, l) : a.revalidate !== !1) && (delete i[c], delete z[c], N && N[0]) ? N[0](ct).then(() => p().data) : p().data;
|
|
258
258
|
};
|
|
259
|
-
if (
|
|
260
|
-
return
|
|
261
|
-
let _ = r,
|
|
262
|
-
const
|
|
263
|
-
|
|
264
|
-
|
|
259
|
+
if (e.length < 3)
|
|
260
|
+
return H();
|
|
261
|
+
let _ = r, R, C = !1;
|
|
262
|
+
const b = Me();
|
|
263
|
+
T[c] = [
|
|
264
|
+
b,
|
|
265
265
|
0
|
|
266
266
|
];
|
|
267
|
-
const
|
|
268
|
-
if (
|
|
269
|
-
data:
|
|
267
|
+
const S = !d(h), Y = p(), j = Y.data, J = Y._c, G = d(J) ? j : J;
|
|
268
|
+
if (S && (h = M(h) ? h(G, j) : h, m({
|
|
269
|
+
data: h,
|
|
270
270
|
_c: G
|
|
271
|
-
})),
|
|
271
|
+
})), M(_))
|
|
272
272
|
try {
|
|
273
273
|
_ = _(G);
|
|
274
|
-
} catch (
|
|
275
|
-
|
|
274
|
+
} catch (N) {
|
|
275
|
+
R = N, C = !0;
|
|
276
276
|
}
|
|
277
|
-
if (_ &&
|
|
278
|
-
if (_ = await _.catch((
|
|
279
|
-
|
|
280
|
-
}),
|
|
281
|
-
if (
|
|
277
|
+
if (_ && ut(_))
|
|
278
|
+
if (_ = await _.catch((N) => {
|
|
279
|
+
R = N, C = !0;
|
|
280
|
+
}), b !== T[c][0]) {
|
|
281
|
+
if (C) throw R;
|
|
282
282
|
return _;
|
|
283
|
-
} else
|
|
283
|
+
} else C && S && A(R) && (o = !0, m({
|
|
284
284
|
data: G,
|
|
285
|
-
_c:
|
|
285
|
+
_c: L
|
|
286
286
|
}));
|
|
287
|
-
if (
|
|
288
|
-
if (
|
|
289
|
-
const
|
|
290
|
-
|
|
291
|
-
data:
|
|
292
|
-
error:
|
|
293
|
-
_c:
|
|
287
|
+
if (o && !C)
|
|
288
|
+
if (M(o)) {
|
|
289
|
+
const N = o(_, G);
|
|
290
|
+
m({
|
|
291
|
+
data: N,
|
|
292
|
+
error: L,
|
|
293
|
+
_c: L
|
|
294
294
|
});
|
|
295
295
|
} else
|
|
296
|
-
|
|
296
|
+
m({
|
|
297
297
|
data: _,
|
|
298
|
-
error:
|
|
299
|
-
_c:
|
|
298
|
+
error: L,
|
|
299
|
+
_c: L
|
|
300
300
|
});
|
|
301
|
-
if (
|
|
302
|
-
|
|
303
|
-
_c:
|
|
301
|
+
if (T[c][1] = Me(), Promise.resolve(H()).then(() => {
|
|
302
|
+
m({
|
|
303
|
+
_c: L
|
|
304
304
|
});
|
|
305
|
-
}),
|
|
306
|
-
if (
|
|
305
|
+
}), C) {
|
|
306
|
+
if (y) throw R;
|
|
307
307
|
return;
|
|
308
308
|
}
|
|
309
309
|
return _;
|
|
310
310
|
}
|
|
311
311
|
}
|
|
312
|
-
const
|
|
313
|
-
for (const n in
|
|
314
|
-
|
|
315
|
-
},
|
|
316
|
-
if (!
|
|
317
|
-
const n = k(
|
|
318
|
-
let
|
|
319
|
-
const
|
|
320
|
-
const
|
|
321
|
-
return
|
|
322
|
-
},
|
|
323
|
-
|
|
324
|
-
const
|
|
325
|
-
if (
|
|
326
|
-
for (const
|
|
327
|
-
|
|
328
|
-
},
|
|
329
|
-
if (!
|
|
312
|
+
const tt = (e, t) => {
|
|
313
|
+
for (const n in e)
|
|
314
|
+
e[n][0] && e[n][0](t);
|
|
315
|
+
}, Wt = (e, t) => {
|
|
316
|
+
if (!U.has(e)) {
|
|
317
|
+
const n = k(Vt, t), r = /* @__PURE__ */ Object.create(null), s = ft.bind(L, e);
|
|
318
|
+
let a = $;
|
|
319
|
+
const o = /* @__PURE__ */ Object.create(null), f = (y, u) => {
|
|
320
|
+
const l = o[y] || [];
|
|
321
|
+
return o[y] = l, l.push(u), () => l.splice(l.indexOf(u), 1);
|
|
322
|
+
}, h = (y, u, l) => {
|
|
323
|
+
e.set(y, u);
|
|
324
|
+
const c = o[y];
|
|
325
|
+
if (c)
|
|
326
|
+
for (const p of c)
|
|
327
|
+
p(u, l);
|
|
328
|
+
}, A = () => {
|
|
329
|
+
if (!U.has(e) && (U.set(e, [
|
|
330
330
|
r,
|
|
331
331
|
/* @__PURE__ */ Object.create(null),
|
|
332
332
|
/* @__PURE__ */ Object.create(null),
|
|
333
333
|
/* @__PURE__ */ Object.create(null),
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
]), !
|
|
338
|
-
const
|
|
339
|
-
|
|
340
|
-
|
|
334
|
+
s,
|
|
335
|
+
h,
|
|
336
|
+
f
|
|
337
|
+
]), !ne)) {
|
|
338
|
+
const y = n.initFocus(setTimeout.bind(L, tt.bind(L, r, it))), u = n.initReconnect(setTimeout.bind(L, tt.bind(L, r, at)));
|
|
339
|
+
a = () => {
|
|
340
|
+
y && y(), u && u(), U.delete(e);
|
|
341
341
|
};
|
|
342
342
|
}
|
|
343
343
|
};
|
|
344
|
-
return
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
344
|
+
return A(), [
|
|
345
|
+
e,
|
|
346
|
+
s,
|
|
347
|
+
A,
|
|
348
|
+
a
|
|
349
349
|
];
|
|
350
350
|
}
|
|
351
351
|
return [
|
|
352
|
-
|
|
353
|
-
|
|
352
|
+
e,
|
|
353
|
+
U.get(e)[4]
|
|
354
354
|
];
|
|
355
|
-
},
|
|
356
|
-
const
|
|
357
|
-
!d(
|
|
358
|
-
},
|
|
355
|
+
}, qt = (e, t, n, r, s) => {
|
|
356
|
+
const a = n.errorRetryCount, o = s.retryCount, f = ~~((Math.random() + 0.5) * (1 << (o < 8 ? o : 8))) * n.errorRetryInterval;
|
|
357
|
+
!d(a) && o > a || setTimeout(r, f, s);
|
|
358
|
+
}, Ut = be, [dt, $t] = Wt(/* @__PURE__ */ new Map()), Ht = k(
|
|
359
359
|
{
|
|
360
360
|
// events
|
|
361
361
|
onLoadingSlow: $,
|
|
362
362
|
onSuccess: $,
|
|
363
363
|
onError: $,
|
|
364
|
-
onErrorRetry:
|
|
364
|
+
onErrorRetry: qt,
|
|
365
365
|
onDiscarded: $,
|
|
366
366
|
// switches
|
|
367
367
|
revalidateOnFocus: !0,
|
|
@@ -369,181 +369,181 @@ const te = (t, e) => {
|
|
|
369
369
|
revalidateIfStale: !0,
|
|
370
370
|
shouldRetryOnError: !0,
|
|
371
371
|
// timeouts
|
|
372
|
-
errorRetryInterval:
|
|
372
|
+
errorRetryInterval: et ? 1e4 : 5e3,
|
|
373
373
|
focusThrottleInterval: 5 * 1e3,
|
|
374
374
|
dedupingInterval: 2 * 1e3,
|
|
375
|
-
loadingTimeout:
|
|
375
|
+
loadingTimeout: et ? 5e3 : 3e3,
|
|
376
376
|
// providers
|
|
377
|
-
compare:
|
|
377
|
+
compare: Ut,
|
|
378
378
|
isPaused: () => !1,
|
|
379
|
-
cache:
|
|
380
|
-
mutate:
|
|
379
|
+
cache: dt,
|
|
380
|
+
mutate: $t,
|
|
381
381
|
fallback: {}
|
|
382
382
|
},
|
|
383
383
|
// use web preset by default
|
|
384
|
-
|
|
385
|
-
),
|
|
386
|
-
const n = k(
|
|
387
|
-
if (
|
|
388
|
-
const { use: r, fallback:
|
|
389
|
-
r &&
|
|
384
|
+
Nt
|
|
385
|
+
), kt = (e, t) => {
|
|
386
|
+
const n = k(e, t);
|
|
387
|
+
if (t) {
|
|
388
|
+
const { use: r, fallback: s } = e, { use: a, fallback: o } = t;
|
|
389
|
+
r && a && (n.use = r.concat(a)), s && o && (n.fallback = k(s, o));
|
|
390
390
|
}
|
|
391
391
|
return n;
|
|
392
|
-
},
|
|
393
|
-
|
|
394
|
-
},
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
392
|
+
}, Gt = vt({}), Kt = "$inf$", pt = ue && window.__SWR_DEVTOOLS_USE__, Bt = pt ? window.__SWR_DEVTOOLS_USE__ : [], zt = () => {
|
|
393
|
+
pt && (window.__SWR_DEVTOOLS_REACT__ = ce);
|
|
394
|
+
}, Yt = (e) => M(e[1]) ? [
|
|
395
|
+
e[0],
|
|
396
|
+
e[1],
|
|
397
|
+
e[2] || {}
|
|
398
398
|
] : [
|
|
399
|
-
|
|
399
|
+
e[0],
|
|
400
400
|
null,
|
|
401
|
-
(
|
|
402
|
-
],
|
|
403
|
-
const
|
|
404
|
-
return
|
|
405
|
-
|
|
401
|
+
(e[1] === null ? e[2] : e[1]) || {}
|
|
402
|
+
], Jt = () => {
|
|
403
|
+
const e = wt(Gt);
|
|
404
|
+
return me(() => k(Ht, e), [
|
|
405
|
+
e
|
|
406
406
|
]);
|
|
407
|
-
},
|
|
408
|
-
const [
|
|
409
|
-
if (
|
|
410
|
-
return n(...
|
|
411
|
-
const
|
|
412
|
-
return d(
|
|
413
|
-
}), r),
|
|
414
|
-
const r =
|
|
415
|
-
let
|
|
416
|
-
const { use:
|
|
417
|
-
for (let u =
|
|
418
|
-
|
|
419
|
-
return
|
|
420
|
-
},
|
|
421
|
-
const r = e
|
|
407
|
+
}, Xt = (e) => (t, n, r) => e(t, n && ((...a) => {
|
|
408
|
+
const [o] = qe(t), [, , , f] = U.get(dt);
|
|
409
|
+
if (o.startsWith(Kt))
|
|
410
|
+
return n(...a);
|
|
411
|
+
const h = f[o];
|
|
412
|
+
return d(h) ? n(...a) : (delete f[o], h);
|
|
413
|
+
}), r), Qt = Bt.concat(Xt), Zt = (e) => function(...n) {
|
|
414
|
+
const r = Jt(), [s, a, o] = Yt(n), f = kt(r, o);
|
|
415
|
+
let h = e;
|
|
416
|
+
const { use: A } = f, y = (A || []).concat(Qt);
|
|
417
|
+
for (let u = y.length; u--; )
|
|
418
|
+
h = y[u](h);
|
|
419
|
+
return h(s, a || f.fetcher || null, f);
|
|
420
|
+
}, en = (e, t, n) => {
|
|
421
|
+
const r = t[e] || (t[e] = []);
|
|
422
422
|
return r.push(n), () => {
|
|
423
|
-
const
|
|
424
|
-
|
|
423
|
+
const s = r.indexOf(n);
|
|
424
|
+
s >= 0 && (r[s] = r[r.length - 1], r.pop());
|
|
425
425
|
};
|
|
426
426
|
};
|
|
427
|
-
|
|
428
|
-
const
|
|
427
|
+
zt();
|
|
428
|
+
const Te = ce.use || // This extra generic is to avoid TypeScript mixing up the generic and JSX sytax
|
|
429
429
|
// and emitting an error.
|
|
430
430
|
// We assume that this is only for the `use(thenable)` case, not `use(context)`.
|
|
431
431
|
// https://github.com/facebook/react/blob/aed00dacfb79d17c53218404c52b1c7aa59c4a89/packages/react-server/src/ReactFizzThenable.js#L45
|
|
432
|
-
((
|
|
433
|
-
switch (
|
|
432
|
+
((e) => {
|
|
433
|
+
switch (e.status) {
|
|
434
434
|
case "pending":
|
|
435
|
-
throw
|
|
435
|
+
throw e;
|
|
436
436
|
case "fulfilled":
|
|
437
|
-
return
|
|
437
|
+
return e.value;
|
|
438
438
|
case "rejected":
|
|
439
|
-
throw
|
|
439
|
+
throw e.reason;
|
|
440
440
|
default:
|
|
441
|
-
throw
|
|
442
|
-
|
|
443
|
-
}, (
|
|
444
|
-
|
|
445
|
-
}),
|
|
441
|
+
throw e.status = "pending", e.then((t) => {
|
|
442
|
+
e.status = "fulfilled", e.value = t;
|
|
443
|
+
}, (t) => {
|
|
444
|
+
e.status = "rejected", e.reason = t;
|
|
445
|
+
}), e;
|
|
446
446
|
}
|
|
447
|
-
}),
|
|
447
|
+
}), Ae = {
|
|
448
448
|
dedupe: !0
|
|
449
|
-
},
|
|
450
|
-
const { cache: r, compare:
|
|
449
|
+
}, nt = Promise.resolve(L), tn = () => $, nn = (e, t, n) => {
|
|
450
|
+
const { cache: r, compare: s, suspense: a, fallbackData: o, revalidateOnMount: f, revalidateIfStale: h, refreshInterval: A, refreshWhenHidden: y, refreshWhenOffline: u, keepPreviousData: l, strictServerPrefetchWarning: c } = n, [p, m, g, T] = U.get(r), [i, z] = qe(e), H = W(!1), _ = W(!1), R = W(i), C = W(t), b = W(n), S = () => b.current, Y = () => S().isVisible() && S().isOnline(), [j, J, G, N] = lt(r, i), X = W({}).current, Q = d(o) ? d(n.fallback) ? L : n.fallback[i] : o, Ue = (E, v) => {
|
|
451
451
|
for (const O in X) {
|
|
452
452
|
const w = O;
|
|
453
453
|
if (w === "data") {
|
|
454
|
-
if (!
|
|
454
|
+
if (!s(E[w], v[w]) && (!d(E[w]) || !s(fe, v[w])))
|
|
455
455
|
return !1;
|
|
456
|
-
} else if (
|
|
456
|
+
} else if (v[w] !== E[w])
|
|
457
457
|
return !1;
|
|
458
458
|
}
|
|
459
459
|
return !0;
|
|
460
|
-
},
|
|
461
|
-
const
|
|
462
|
-
const
|
|
463
|
-
return delete
|
|
464
|
-
if (!
|
|
465
|
-
if (
|
|
466
|
-
const
|
|
467
|
-
return d(
|
|
460
|
+
}, ge = !H.current, $e = me(() => {
|
|
461
|
+
const E = j(), v = N(), O = (D) => {
|
|
462
|
+
const V = k(D);
|
|
463
|
+
return delete V._k, (() => {
|
|
464
|
+
if (!i || !t || S().isPaused()) return !1;
|
|
465
|
+
if (ge && !d(f)) return f;
|
|
466
|
+
const ie = d(Q) ? V.data : Q;
|
|
467
|
+
return d(ie) || h;
|
|
468
468
|
})() ? {
|
|
469
469
|
isValidating: !0,
|
|
470
470
|
isLoading: !0,
|
|
471
|
-
...
|
|
472
|
-
} :
|
|
473
|
-
}, w = O(
|
|
474
|
-
let
|
|
471
|
+
...V
|
|
472
|
+
} : V;
|
|
473
|
+
}, w = O(E), F = E === v ? w : O(v);
|
|
474
|
+
let x = w;
|
|
475
475
|
return [
|
|
476
476
|
() => {
|
|
477
|
-
const
|
|
478
|
-
return
|
|
477
|
+
const D = O(j());
|
|
478
|
+
return Ue(D, x) ? (x.data = D.data, x.isLoading = D.isLoading, x.isValidating = D.isValidating, x.error = D.error, x) : (x = D, D);
|
|
479
479
|
},
|
|
480
|
-
() =>
|
|
480
|
+
() => F
|
|
481
481
|
];
|
|
482
482
|
}, [
|
|
483
483
|
r,
|
|
484
|
-
|
|
485
|
-
]), Z =
|
|
486
|
-
(
|
|
487
|
-
|
|
484
|
+
i
|
|
485
|
+
]), Z = Je.useSyncExternalStore(he(
|
|
486
|
+
(E) => G(i, (v, O) => {
|
|
487
|
+
Ue(O, v) || E();
|
|
488
488
|
}),
|
|
489
489
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
490
490
|
[
|
|
491
491
|
r,
|
|
492
|
-
|
|
492
|
+
i
|
|
493
493
|
]
|
|
494
|
-
),
|
|
495
|
-
!
|
|
494
|
+
), $e[0], $e[1]), mt = p[i] && p[i].length > 0, ee = Z.data, K = d(ee) ? Q && ut(Q) ? Te(Q) : Q : ee, le = Z.error, Ee = W(K), fe = l ? d(ee) ? d(Ee.current) ? K : Ee.current : ee : K, B = i && d(K), re = W(null);
|
|
495
|
+
!ne && // getServerSnapshot is only called during hydration
|
|
496
496
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
497
|
-
|
|
498
|
-
const
|
|
499
|
-
|
|
500
|
-
const
|
|
501
|
-
async (
|
|
502
|
-
const
|
|
503
|
-
if (!
|
|
497
|
+
Je.useSyncExternalStore(tn, () => (re.current = !1, re), () => (re.current = !0, re));
|
|
498
|
+
const gt = re.current;
|
|
499
|
+
c && gt && !a && B && console.warn(`Missing pre-initiated data for serialized key "${i}" 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.`);
|
|
500
|
+
const He = !i || !t || S().isPaused() || mt && !d(le) ? !1 : ge && !d(f) ? f : a ? d(K) ? !1 : h : d(K) || h, ke = ge && He, Et = d(Z.isValidating) ? ke : Z.isValidating, St = d(Z.isLoading) ? ke : Z.isLoading, se = he(
|
|
501
|
+
async (E) => {
|
|
502
|
+
const v = C.current;
|
|
503
|
+
if (!i || !v || _.current || S().isPaused())
|
|
504
504
|
return !1;
|
|
505
|
-
let O, w,
|
|
506
|
-
const
|
|
505
|
+
let O, w, F = !0;
|
|
506
|
+
const x = E || {}, D = !g[i] || !x.dedupe, V = () => Ze ? !_.current && i === R.current && H.current : i === R.current, oe = {
|
|
507
507
|
isValidating: !1,
|
|
508
508
|
isLoading: !1
|
|
509
|
-
},
|
|
510
|
-
|
|
511
|
-
},
|
|
512
|
-
const
|
|
513
|
-
|
|
514
|
-
},
|
|
509
|
+
}, ie = () => {
|
|
510
|
+
J(oe);
|
|
511
|
+
}, Ke = () => {
|
|
512
|
+
const I = g[i];
|
|
513
|
+
I && I[1] === w && delete g[i];
|
|
514
|
+
}, Be = {
|
|
515
515
|
isValidating: !0
|
|
516
516
|
};
|
|
517
|
-
d(j().data) && (
|
|
517
|
+
d(j().data) && (Be.isLoading = !0);
|
|
518
518
|
try {
|
|
519
|
-
if (
|
|
520
|
-
|
|
521
|
-
}, n.loadingTimeout),
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
]), [O, w] =
|
|
525
|
-
return
|
|
526
|
-
|
|
527
|
-
const
|
|
528
|
-
if (!d(
|
|
529
|
-
(w <=
|
|
530
|
-
w <=
|
|
531
|
-
|
|
532
|
-
return
|
|
533
|
-
const
|
|
534
|
-
|
|
535
|
-
} catch (
|
|
536
|
-
|
|
537
|
-
const
|
|
538
|
-
|
|
539
|
-
const
|
|
540
|
-
|
|
519
|
+
if (D && (J(Be), n.loadingTimeout && d(j().data) && setTimeout(() => {
|
|
520
|
+
F && V() && S().onLoadingSlow(i, n);
|
|
521
|
+
}, n.loadingTimeout), g[i] = [
|
|
522
|
+
v(z),
|
|
523
|
+
Me()
|
|
524
|
+
]), [O, w] = g[i], O = await O, D && setTimeout(Ke, n.dedupingInterval), !g[i] || g[i][1] !== w)
|
|
525
|
+
return D && V() && S().onDiscarded(i), !1;
|
|
526
|
+
oe.error = L;
|
|
527
|
+
const I = m[i];
|
|
528
|
+
if (!d(I) && // case 1
|
|
529
|
+
(w <= I[0] || // case 2
|
|
530
|
+
w <= I[1] || // case 3
|
|
531
|
+
I[1] === 0))
|
|
532
|
+
return ie(), D && V() && S().onDiscarded(i), !1;
|
|
533
|
+
const P = j().data;
|
|
534
|
+
oe.data = s(P, O) ? P : O, D && V() && S().onSuccess(O, i, n);
|
|
535
|
+
} catch (I) {
|
|
536
|
+
Ke();
|
|
537
|
+
const P = S(), { shouldRetryOnError: Se } = P;
|
|
538
|
+
P.isPaused() || (oe.error = I, D && V() && (P.onError(I, i, P), (Se === !0 || M(Se) && Se(I)) && (!S().revalidateOnFocus || !S().revalidateOnReconnect || Y()) && P.onErrorRetry(I, i, P, (yt) => {
|
|
539
|
+
const ye = p[i];
|
|
540
|
+
ye && ye[0] && ye[0](Xe, yt);
|
|
541
541
|
}, {
|
|
542
|
-
retryCount: (
|
|
542
|
+
retryCount: (x.retryCount || 0) + 1,
|
|
543
543
|
dedupe: !0
|
|
544
544
|
})));
|
|
545
545
|
}
|
|
546
|
-
return
|
|
546
|
+
return F = !1, ie(), !0;
|
|
547
547
|
},
|
|
548
548
|
// `setState` is immutable, and `eventsCallback`, `fnArg`, and
|
|
549
549
|
// `keyValidating` are depending on `key`, so we can exclude them from
|
|
@@ -557,200 +557,219 @@ const Dt = ct.use || // This extra generic is to avoid TypeScript mixing up the
|
|
|
557
557
|
// even though it might cause unexpected behaviors.
|
|
558
558
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
559
559
|
[
|
|
560
|
-
|
|
560
|
+
i,
|
|
561
561
|
r
|
|
562
562
|
]
|
|
563
|
-
),
|
|
563
|
+
), Ge = he(
|
|
564
564
|
// Use callback to make sure `keyRef.current` returns latest result every time
|
|
565
|
-
(...
|
|
565
|
+
(...E) => ft(r, R.current, ...E),
|
|
566
566
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
567
567
|
[]
|
|
568
568
|
);
|
|
569
|
-
if (
|
|
570
|
-
|
|
571
|
-
}),
|
|
572
|
-
if (!
|
|
573
|
-
const
|
|
574
|
-
let
|
|
575
|
-
|
|
576
|
-
const w =
|
|
577
|
-
if (
|
|
578
|
-
const
|
|
579
|
-
|
|
580
|
-
} else if (
|
|
581
|
-
|
|
569
|
+
if (_e(() => {
|
|
570
|
+
C.current = t, b.current = n, d(ee) || (Ee.current = ee);
|
|
571
|
+
}), _e(() => {
|
|
572
|
+
if (!i) return;
|
|
573
|
+
const E = se.bind(L, Ae);
|
|
574
|
+
let v = 0;
|
|
575
|
+
S().revalidateOnFocus && (v = Date.now() + S().focusThrottleInterval);
|
|
576
|
+
const w = en(i, p, (F, x = {}) => {
|
|
577
|
+
if (F == it) {
|
|
578
|
+
const D = Date.now();
|
|
579
|
+
S().revalidateOnFocus && D > v && Y() && (v = D + S().focusThrottleInterval, E());
|
|
580
|
+
} else if (F == at)
|
|
581
|
+
S().revalidateOnReconnect && Y() && E();
|
|
582
582
|
else {
|
|
583
|
-
if (
|
|
584
|
-
return
|
|
585
|
-
if (
|
|
586
|
-
return
|
|
583
|
+
if (F == ct)
|
|
584
|
+
return se();
|
|
585
|
+
if (F == Xe)
|
|
586
|
+
return se(x);
|
|
587
587
|
}
|
|
588
588
|
});
|
|
589
|
-
return _.current = !1,
|
|
590
|
-
_k:
|
|
591
|
-
}),
|
|
589
|
+
return _.current = !1, R.current = i, H.current = !0, J({
|
|
590
|
+
_k: z
|
|
591
|
+
}), He && (g[i] || (d(K) || ne ? E() : jt(E))), () => {
|
|
592
592
|
_.current = !0, w();
|
|
593
593
|
};
|
|
594
594
|
}, [
|
|
595
|
-
|
|
596
|
-
]),
|
|
597
|
-
let
|
|
598
|
-
function
|
|
599
|
-
const w =
|
|
600
|
-
w &&
|
|
595
|
+
i
|
|
596
|
+
]), _e(() => {
|
|
597
|
+
let E;
|
|
598
|
+
function v() {
|
|
599
|
+
const w = M(A) ? A(j().data) : A;
|
|
600
|
+
w && E !== -1 && (E = setTimeout(O, w));
|
|
601
601
|
}
|
|
602
602
|
function O() {
|
|
603
|
-
!j().error && (
|
|
603
|
+
!j().error && (y || S().isVisible()) && (u || S().isOnline()) ? se(Ae).then(v) : v();
|
|
604
604
|
}
|
|
605
|
-
return
|
|
606
|
-
|
|
605
|
+
return v(), () => {
|
|
606
|
+
E && (clearTimeout(E), E = -1);
|
|
607
607
|
};
|
|
608
608
|
}, [
|
|
609
|
-
|
|
610
|
-
|
|
609
|
+
A,
|
|
610
|
+
y,
|
|
611
611
|
u,
|
|
612
|
-
|
|
613
|
-
]),
|
|
614
|
-
if (!
|
|
612
|
+
i
|
|
613
|
+
]), _t(fe), a) {
|
|
614
|
+
if (!Ze && ne && B)
|
|
615
615
|
throw new Error("Fallback data is required when using Suspense in SSR.");
|
|
616
|
-
|
|
617
|
-
const
|
|
618
|
-
if (
|
|
619
|
-
throw
|
|
620
|
-
const O =
|
|
621
|
-
!d(
|
|
616
|
+
B && (C.current = t, b.current = n, _.current = !1);
|
|
617
|
+
const E = T[i], v = !d(E) && B ? Ge(E) : nt;
|
|
618
|
+
if (Te(v), !d(le) && B)
|
|
619
|
+
throw le;
|
|
620
|
+
const O = B ? se(Ae) : nt;
|
|
621
|
+
!d(fe) && B && (O.status = "fulfilled", O.value = !0), Te(O);
|
|
622
622
|
}
|
|
623
623
|
return {
|
|
624
|
-
mutate:
|
|
624
|
+
mutate: Ge,
|
|
625
625
|
get data() {
|
|
626
|
-
return X.data = !0,
|
|
626
|
+
return X.data = !0, fe;
|
|
627
627
|
},
|
|
628
628
|
get error() {
|
|
629
|
-
return X.error = !0,
|
|
629
|
+
return X.error = !0, le;
|
|
630
630
|
},
|
|
631
631
|
get isValidating() {
|
|
632
|
-
return X.isValidating = !0,
|
|
632
|
+
return X.isValidating = !0, Et;
|
|
633
633
|
},
|
|
634
634
|
get isLoading() {
|
|
635
|
-
return X.isLoading = !0,
|
|
635
|
+
return X.isLoading = !0, St;
|
|
636
636
|
}
|
|
637
637
|
};
|
|
638
|
-
},
|
|
639
|
-
function
|
|
638
|
+
}, rn = Zt(nn);
|
|
639
|
+
function ht() {
|
|
640
640
|
return window.document.location.host.indexOf("localhost") === 0 ? "http://localhost:3100" : "https://api.graffiticode.org";
|
|
641
641
|
}
|
|
642
|
-
const
|
|
643
|
-
accessToken:
|
|
644
|
-
id:
|
|
642
|
+
const sn = async ({
|
|
643
|
+
accessToken: e,
|
|
644
|
+
id: t
|
|
645
645
|
}) => {
|
|
646
|
-
const n = await fetch(`${
|
|
647
|
-
headers: { Authorization:
|
|
648
|
-
}), { status: r, error:
|
|
646
|
+
const n = await fetch(`${ht()}/data?id=${t}`, {
|
|
647
|
+
headers: { Authorization: e || "" }
|
|
648
|
+
}), { status: r, error: s, data: a } = await n.json();
|
|
649
649
|
if (r !== "success")
|
|
650
|
-
throw new Error(`failed to get data ${
|
|
651
|
-
return
|
|
652
|
-
},
|
|
653
|
-
accessToken:
|
|
654
|
-
id:
|
|
650
|
+
throw new Error(`failed to get data ${t}: ${s == null ? void 0 : s.message}`);
|
|
651
|
+
return a;
|
|
652
|
+
}, on = async ({
|
|
653
|
+
accessToken: e,
|
|
654
|
+
id: t,
|
|
655
655
|
data: n
|
|
656
656
|
}) => {
|
|
657
|
-
var
|
|
658
|
-
const
|
|
657
|
+
var a;
|
|
658
|
+
const s = await (await fetch(`${ht()}/compile`, {
|
|
659
659
|
method: "POST",
|
|
660
660
|
headers: {
|
|
661
661
|
"Content-Type": "application/json",
|
|
662
|
-
authorization:
|
|
662
|
+
authorization: e || "",
|
|
663
663
|
"x-graffiticode-storage-type": "persistent"
|
|
664
664
|
},
|
|
665
|
-
body: JSON.stringify({ id:
|
|
665
|
+
body: JSON.stringify({ id: t, data: n })
|
|
666
666
|
})).json();
|
|
667
|
-
if (
|
|
668
|
-
throw new Error(`failed to post compile ${
|
|
669
|
-
return
|
|
670
|
-
},
|
|
671
|
-
accessToken:
|
|
672
|
-
id:
|
|
667
|
+
if (s.status !== "success")
|
|
668
|
+
throw new Error(`failed to post compile ${t}: ${(a = s.error) == null ? void 0 : a.message}`);
|
|
669
|
+
return s.data;
|
|
670
|
+
}, an = async ({
|
|
671
|
+
accessToken: e,
|
|
672
|
+
id: t,
|
|
673
673
|
data: n
|
|
674
674
|
}) => {
|
|
675
675
|
const r = Object.keys(n).length > 0 ? 1 : 2;
|
|
676
|
-
return
|
|
677
|
-
},
|
|
678
|
-
accessToken:
|
|
679
|
-
id:
|
|
680
|
-
}) => await
|
|
681
|
-
function
|
|
682
|
-
return
|
|
676
|
+
return t = t.split("+").slice(0, r).join("+"), await on({ accessToken: e, id: t, data: n });
|
|
677
|
+
}, cn = async ({
|
|
678
|
+
accessToken: e,
|
|
679
|
+
id: t
|
|
680
|
+
}) => await sn({ accessToken: e, id: t }), un = /* @__PURE__ */ new Set(["update", "response"]), ln = /* @__PURE__ */ new Set(["init", "loaded"]);
|
|
681
|
+
function rt(e) {
|
|
682
|
+
return e && typeof e == "object" && Array.isArray(e.errors) ? { data: e.data ?? null, errors: e.errors } : { data: e, errors: [] };
|
|
683
683
|
}
|
|
684
|
-
function
|
|
685
|
-
return
|
|
684
|
+
function st(e, t) {
|
|
685
|
+
return t.length > 0 ? !0 : !(e == null || typeof e == "object" && !Array.isArray(e) && Object.keys(e).length === 0);
|
|
686
686
|
}
|
|
687
|
-
function
|
|
688
|
-
switch (
|
|
687
|
+
function fn(e, { type: t, args: n }) {
|
|
688
|
+
switch (t) {
|
|
689
689
|
case "init":
|
|
690
690
|
return { ...n };
|
|
691
691
|
case "compiled":
|
|
692
|
+
case "loaded":
|
|
692
693
|
case "update":
|
|
693
694
|
case "response":
|
|
694
|
-
return { ...
|
|
695
|
+
return { ...e, ...n };
|
|
695
696
|
case "focus":
|
|
696
|
-
return { ...
|
|
697
|
+
return { ...e, focus: n };
|
|
697
698
|
default:
|
|
698
|
-
return console.error(`Unimplemented action type: ${
|
|
699
|
+
return console.error(`Unimplemented action type: ${t}`), e;
|
|
699
700
|
}
|
|
700
701
|
}
|
|
701
|
-
const
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
702
|
+
const Pe = (e, t) => {
|
|
703
|
+
if (e === t) return !0;
|
|
704
|
+
if (typeof e != typeof t || e === null || t === null || typeof e != "object" || Array.isArray(e) !== Array.isArray(t)) return !1;
|
|
705
|
+
if (Array.isArray(e))
|
|
706
|
+
return e.length !== t.length ? !1 : e.every((r, s) => Pe(r, t[s]));
|
|
707
|
+
const n = Object.keys(e);
|
|
708
|
+
return n.length !== Object.keys(t).length ? !1 : n.every((r) => Object.prototype.hasOwnProperty.call(t, r) && Pe(e[r], t[r]));
|
|
709
|
+
}, dn = (e, t) => (n, r) => {
|
|
710
|
+
const s = e ? e(n.data, r) : void 0, a = s !== void 0 ? s : fn(n.data, r);
|
|
711
|
+
return a === n.data || Pe(a, n.data) ? n : {
|
|
712
|
+
data: a,
|
|
713
|
+
renderData: t === "live" || ln.has(r.type) ? a : n.renderData,
|
|
714
|
+
compileSeq: n.compileSeq + (un.has(r.type) ? 1 : 0),
|
|
715
|
+
version: n.version + 1
|
|
706
716
|
};
|
|
707
|
-
}, Sn = ({
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
717
|
+
}, Sn = ({
|
|
718
|
+
Form: e,
|
|
719
|
+
reduce: t,
|
|
720
|
+
formModel: n = "live"
|
|
721
|
+
}) => {
|
|
722
|
+
var _;
|
|
723
|
+
const [r] = ae(() => new URLSearchParams(window.location.search)), [s] = ae(r.get("id") ?? void 0), [a] = ae(r.get("access_token") ?? void 0), [o] = ae(r.get("origin") ?? void 0), [f, h] = ae([]), A = me(() => dn(t, n), [t, n]), [y, u] = Rt(A, void 0, () => ({
|
|
724
|
+
data: {},
|
|
725
|
+
renderData: {},
|
|
726
|
+
compileSeq: 0,
|
|
727
|
+
version: 0
|
|
728
|
+
})), { data: l, renderData: c, compileSeq: p, version: m } = y;
|
|
729
|
+
te(() => {
|
|
730
|
+
const R = r.get("data");
|
|
731
|
+
R && u({ type: "init", args: JSON.parse(R) });
|
|
732
|
+
}, []), te(() => {
|
|
733
|
+
o && window.parent.postMessage({ type: "onload", data: l }, o);
|
|
734
|
+
}, []), te(() => {
|
|
735
|
+
o && window.parent.postMessage({ type: "data-updated", data: l }, o);
|
|
736
|
+
}, [m]);
|
|
737
|
+
const g = rn(s ? { accessToken: a, id: s } : null, cn, {
|
|
719
738
|
revalidateOnFocus: !1,
|
|
720
739
|
revalidateOnReconnect: !1,
|
|
721
740
|
revalidateIfStale: !1
|
|
722
741
|
});
|
|
723
|
-
|
|
724
|
-
if (
|
|
725
|
-
const
|
|
726
|
-
|
|
727
|
-
}, [
|
|
728
|
-
const
|
|
729
|
-
|
|
730
|
-
if (p === 0 || !
|
|
731
|
-
const
|
|
732
|
-
|
|
733
|
-
let
|
|
742
|
+
te(() => {
|
|
743
|
+
if (g.data === void 0) return;
|
|
744
|
+
const R = rt(g.data);
|
|
745
|
+
u({ type: "loaded", args: R.data }), h(R.errors);
|
|
746
|
+
}, [g.data]);
|
|
747
|
+
const T = W(0);
|
|
748
|
+
te(() => {
|
|
749
|
+
if (p === 0 || !s) return;
|
|
750
|
+
const R = ++T.current;
|
|
751
|
+
o && window.parent.postMessage({ focus: { type: "update", value: l } }, o);
|
|
752
|
+
let C = !1;
|
|
734
753
|
return (async () => {
|
|
735
754
|
try {
|
|
736
|
-
const
|
|
737
|
-
if (
|
|
738
|
-
const
|
|
739
|
-
|
|
740
|
-
} catch (
|
|
741
|
-
!
|
|
755
|
+
const b = await an({ accessToken: a, id: s, data: l });
|
|
756
|
+
if (C || R !== T.current) return;
|
|
757
|
+
const S = rt(b);
|
|
758
|
+
u({ type: "compiled", args: S.data }), h(S.errors);
|
|
759
|
+
} catch (b) {
|
|
760
|
+
!C && R === T.current && h([{ message: String((b == null ? void 0 : b.message) ?? b) }]);
|
|
742
761
|
}
|
|
743
762
|
})(), () => {
|
|
744
|
-
|
|
763
|
+
C = !0;
|
|
745
764
|
};
|
|
746
765
|
}, [p]);
|
|
747
|
-
const
|
|
748
|
-
return
|
|
749
|
-
/* @__PURE__ */
|
|
750
|
-
/* @__PURE__ */
|
|
751
|
-
/* @__PURE__ */
|
|
752
|
-
] }) :
|
|
753
|
-
},
|
|
766
|
+
const i = st(c, []) ? c : l, z = me(() => ({ data: i, errors: f, apply: u }), [i, f]), H = he(() => g.mutate(), [g]);
|
|
767
|
+
return st(l, f) ? /* @__PURE__ */ q(e, { state: z }) : g.error ? /* @__PURE__ */ Le("div", { role: "alert", style: ot, children: [
|
|
768
|
+
/* @__PURE__ */ q("p", { style: { margin: 0, fontWeight: 600 }, children: "Couldn’t load this form." }),
|
|
769
|
+
/* @__PURE__ */ q("p", { style: { margin: "4px 0 12px", color: "#555" }, children: String(((_ = g.error) == null ? void 0 : _.message) ?? g.error) }),
|
|
770
|
+
/* @__PURE__ */ q("button", { type: "button", style: pn, onClick: H, children: "Retry" })
|
|
771
|
+
] }) : g.isLoading ? /* @__PURE__ */ q("div", { role: "status", "aria-live": "polite", style: ot, children: "Loading…" }) : /* @__PURE__ */ q("div", {});
|
|
772
|
+
}, ot = {
|
|
754
773
|
display: "flex",
|
|
755
774
|
flexDirection: "column",
|
|
756
775
|
alignItems: "center",
|
|
@@ -759,24 +778,24 @@ const ln = (t) => (e, n) => {
|
|
|
759
778
|
padding: "24px",
|
|
760
779
|
textAlign: "center",
|
|
761
780
|
font: "14px/1.4 system-ui, sans-serif"
|
|
762
|
-
},
|
|
781
|
+
}, pn = {
|
|
763
782
|
padding: "6px 14px",
|
|
764
783
|
border: "1px solid #888",
|
|
765
784
|
borderRadius: "4px",
|
|
766
785
|
background: "#fff",
|
|
767
786
|
cursor: "pointer"
|
|
768
787
|
};
|
|
769
|
-
function
|
|
770
|
-
return /* @__PURE__ */
|
|
788
|
+
function hn({ errors: e }) {
|
|
789
|
+
return /* @__PURE__ */ q("div", { className: "flex flex-col gap-2 font-mono text-xs", children: e.map((t, n) => /* @__PURE__ */ Le(
|
|
771
790
|
"div",
|
|
772
791
|
{
|
|
773
792
|
className: "rounded-md border border-red-200 bg-red-50 p-3 text-red-800",
|
|
774
793
|
children: [
|
|
775
|
-
|
|
776
|
-
typeof
|
|
794
|
+
t.message,
|
|
795
|
+
typeof t.from == "number" && t.from >= 0 && /* @__PURE__ */ Le("span", { className: "ml-2 text-red-400", children: [
|
|
777
796
|
"[",
|
|
778
|
-
|
|
779
|
-
typeof
|
|
797
|
+
t.from,
|
|
798
|
+
typeof t.to == "number" && t.to >= 0 ? `–${t.to}` : "",
|
|
780
799
|
"]"
|
|
781
800
|
] })
|
|
782
801
|
]
|
|
@@ -784,15 +803,15 @@ function dn({ errors: t }) {
|
|
|
784
803
|
n
|
|
785
804
|
)) });
|
|
786
805
|
}
|
|
787
|
-
const
|
|
788
|
-
const
|
|
789
|
-
if (
|
|
790
|
-
return /* @__PURE__ */
|
|
791
|
-
const n =
|
|
792
|
-
return /* @__PURE__ */
|
|
806
|
+
const yn = ({ state: e }) => {
|
|
807
|
+
const t = e.errors ?? [];
|
|
808
|
+
if (t.length > 0)
|
|
809
|
+
return /* @__PURE__ */ q(hn, { errors: t });
|
|
810
|
+
const n = e.data;
|
|
811
|
+
return /* @__PURE__ */ q("pre", { className: "rounded-md bg-zinc-50 text-zinc-900 text-xs font-mono p-4 overflow-auto", children: JSON.stringify(n, null, 2) });
|
|
793
812
|
};
|
|
794
813
|
export {
|
|
795
|
-
|
|
814
|
+
yn as Form,
|
|
796
815
|
Sn as View
|
|
797
816
|
};
|
|
798
817
|
//# sourceMappingURL=index.js.map
|