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