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