@figma-vars/hooks 1.0.9 → 1.1.0
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/README.md +73 -64
- package/dist/constants/index.d.ts +0 -8
- package/dist/contexts/FigmaTokenContext.d.ts +11 -0
- package/dist/figma-vars-hooks.js +1153 -201
- package/dist/figma-vars-hooks.umd.cjs +38 -1
- package/dist/hooks/useFigmaToken.d.ts +3 -2
- package/dist/hooks/useVariableCollections.d.ts +13 -3
- package/dist/hooks/useVariableModes.d.ts +8 -5
- package/dist/hooks/useVariables.d.ts +10 -12
- package/dist/index.d.ts +12 -15
- package/dist/mutations/bulkUpdateVariables.d.ts +7 -0
- package/dist/mutations/createVariable.d.ts +7 -8
- package/dist/mutations/deleteVariable.d.ts +7 -8
- package/dist/mutations/updateVariable.d.ts +7 -9
- package/dist/types/figma.d.ts +33 -5
- package/dist/types/hooks.d.ts +9 -0
- package/dist/types/mutations.d.ts +67 -0
- package/dist/utils/authHelpers.d.ts +0 -4
- package/dist/utils/fetchHelpers.d.ts +1 -1
- package/dist/utils/filterVariables.d.ts +2 -2
- package/package.json +8 -4
- package/dist/experimental/usePublishVars.d.ts +0 -2
- package/dist/experimental/useSync.d.ts +0 -2
- package/dist/experimental/useVariableAliases.d.ts +0 -9
- package/dist/experimental/useVariableBindings.d.ts +0 -7
- package/dist/mutations/updateVariableValues.d.ts +0 -8
- package/dist/utils/cache.d.ts +0 -7
package/dist/figma-vars-hooks.js
CHANGED
|
@@ -1,222 +1,1174 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
import fe, { createContext as it, useContext as ct, useEffect as ht, useLayoutEffect as St, useRef as se, useMemo as bt, useCallback as ae, useDebugValue as Ot, useState as M } from "react";
|
|
2
|
+
var Se = { exports: {} }, pe = {};
|
|
3
|
+
/**
|
|
4
|
+
* @license React
|
|
5
|
+
* react-jsx-runtime.production.js
|
|
6
|
+
*
|
|
7
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the MIT license found in the
|
|
10
|
+
* LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/
|
|
12
|
+
var ze;
|
|
13
|
+
function Rt() {
|
|
14
|
+
if (ze) return pe;
|
|
15
|
+
ze = 1;
|
|
16
|
+
var e = Symbol.for("react.transitional.element"), r = Symbol.for("react.fragment");
|
|
17
|
+
function t(n, o, a) {
|
|
18
|
+
var i = null;
|
|
19
|
+
if (a !== void 0 && (i = "" + a), o.key !== void 0 && (i = "" + o.key), "key" in o) {
|
|
20
|
+
a = {};
|
|
21
|
+
for (var f in o)
|
|
22
|
+
f !== "key" && (a[f] = o[f]);
|
|
23
|
+
} else a = o;
|
|
24
|
+
return o = a.ref, {
|
|
25
|
+
$$typeof: e,
|
|
26
|
+
type: n,
|
|
27
|
+
key: i,
|
|
28
|
+
ref: o !== void 0 ? o : null,
|
|
29
|
+
props: a
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
return pe.Fragment = r, pe.jsx = t, pe.jsxs = t, pe;
|
|
33
|
+
}
|
|
34
|
+
var ve = {};
|
|
35
|
+
/**
|
|
36
|
+
* @license React
|
|
37
|
+
* react-jsx-runtime.development.js
|
|
38
|
+
*
|
|
39
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
40
|
+
*
|
|
41
|
+
* This source code is licensed under the MIT license found in the
|
|
42
|
+
* LICENSE file in the root directory of this source tree.
|
|
43
|
+
*/
|
|
44
|
+
var Xe;
|
|
45
|
+
function Tt() {
|
|
46
|
+
return Xe || (Xe = 1, process.env.NODE_ENV !== "production" && function() {
|
|
47
|
+
function e(s) {
|
|
48
|
+
if (s == null) return null;
|
|
49
|
+
if (typeof s == "function")
|
|
50
|
+
return s.$$typeof === V ? null : s.displayName || s.name || null;
|
|
51
|
+
if (typeof s == "string") return s;
|
|
52
|
+
switch (s) {
|
|
53
|
+
case m:
|
|
54
|
+
return "Fragment";
|
|
55
|
+
case c:
|
|
56
|
+
return "Profiler";
|
|
57
|
+
case k:
|
|
58
|
+
return "StrictMode";
|
|
59
|
+
case y:
|
|
60
|
+
return "Suspense";
|
|
61
|
+
case I:
|
|
62
|
+
return "SuspenseList";
|
|
63
|
+
case Q:
|
|
64
|
+
return "Activity";
|
|
65
|
+
}
|
|
66
|
+
if (typeof s == "object")
|
|
67
|
+
switch (typeof s.tag == "number" && console.error(
|
|
68
|
+
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
69
|
+
), s.$$typeof) {
|
|
70
|
+
case h:
|
|
71
|
+
return "Portal";
|
|
72
|
+
case ne:
|
|
73
|
+
return (s.displayName || "Context") + ".Provider";
|
|
74
|
+
case W:
|
|
75
|
+
return (s._context.displayName || "Context") + ".Consumer";
|
|
76
|
+
case $:
|
|
77
|
+
var l = s.render;
|
|
78
|
+
return s = s.displayName, s || (s = l.displayName || l.name || "", s = s !== "" ? "ForwardRef(" + s + ")" : "ForwardRef"), s;
|
|
79
|
+
case Z:
|
|
80
|
+
return l = s.displayName || null, l !== null ? l : e(s.type) || "Memo";
|
|
81
|
+
case O:
|
|
82
|
+
l = s._payload, s = s._init;
|
|
83
|
+
try {
|
|
84
|
+
return e(s(l));
|
|
85
|
+
} catch {
|
|
86
|
+
}
|
|
22
87
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
m.current && clearInterval(m.current);
|
|
44
|
-
};
|
|
45
|
-
}, [u, e == null ? void 0 : e.pollInterval]), { variables: r, loading: n, error: o, refresh: v };
|
|
46
|
-
}, V = (t) => {
|
|
47
|
-
const [e, r] = i({
|
|
48
|
-
data: null,
|
|
49
|
-
loading: !0,
|
|
50
|
-
error: null
|
|
51
|
-
}), a = c();
|
|
52
|
-
return d(() => {
|
|
53
|
-
(async () => {
|
|
54
|
-
if (!a) {
|
|
55
|
-
r((o) => ({
|
|
56
|
-
...o,
|
|
57
|
-
loading: !1,
|
|
58
|
-
error: new Error("API token is not provided")
|
|
59
|
-
}));
|
|
60
|
-
return;
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
function r(s) {
|
|
91
|
+
return "" + s;
|
|
92
|
+
}
|
|
93
|
+
function t(s) {
|
|
94
|
+
try {
|
|
95
|
+
r(s);
|
|
96
|
+
var l = !1;
|
|
97
|
+
} catch {
|
|
98
|
+
l = !0;
|
|
99
|
+
}
|
|
100
|
+
if (l) {
|
|
101
|
+
l = console;
|
|
102
|
+
var S = l.error, T = typeof Symbol == "function" && Symbol.toStringTag && s[Symbol.toStringTag] || s.constructor.name || "Object";
|
|
103
|
+
return S.call(
|
|
104
|
+
l,
|
|
105
|
+
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
106
|
+
T
|
|
107
|
+
), r(s);
|
|
61
108
|
}
|
|
62
|
-
|
|
109
|
+
}
|
|
110
|
+
function n(s) {
|
|
111
|
+
if (s === m) return "<>";
|
|
112
|
+
if (typeof s == "object" && s !== null && s.$$typeof === O)
|
|
113
|
+
return "<...>";
|
|
63
114
|
try {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
115
|
+
var l = e(s);
|
|
116
|
+
return l ? "<" + l + ">" : "<...>";
|
|
117
|
+
} catch {
|
|
118
|
+
return "<...>";
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function o() {
|
|
122
|
+
var s = q.A;
|
|
123
|
+
return s === null ? null : s.getOwner();
|
|
124
|
+
}
|
|
125
|
+
function a() {
|
|
126
|
+
return Error("react-stack-top-frame");
|
|
127
|
+
}
|
|
128
|
+
function i(s) {
|
|
129
|
+
if (G.call(s, "key")) {
|
|
130
|
+
var l = Object.getOwnPropertyDescriptor(s, "key").get;
|
|
131
|
+
if (l && l.isReactWarning) return !1;
|
|
132
|
+
}
|
|
133
|
+
return s.key !== void 0;
|
|
134
|
+
}
|
|
135
|
+
function f(s, l) {
|
|
136
|
+
function S() {
|
|
137
|
+
oe || (oe = !0, console.error(
|
|
138
|
+
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
139
|
+
l
|
|
140
|
+
));
|
|
141
|
+
}
|
|
142
|
+
S.isReactWarning = !0, Object.defineProperty(s, "key", {
|
|
143
|
+
get: S,
|
|
144
|
+
configurable: !0
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
function E() {
|
|
148
|
+
var s = e(this.type);
|
|
149
|
+
return de[s] || (de[s] = !0, console.error(
|
|
150
|
+
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
151
|
+
)), s = this.props.ref, s !== void 0 ? s : null;
|
|
152
|
+
}
|
|
153
|
+
function g(s, l, S, T, F, L, ce, ue) {
|
|
154
|
+
return S = L.ref, s = {
|
|
155
|
+
$$typeof: u,
|
|
156
|
+
type: s,
|
|
157
|
+
key: l,
|
|
158
|
+
props: L,
|
|
159
|
+
_owner: F
|
|
160
|
+
}, (S !== void 0 ? S : null) !== null ? Object.defineProperty(s, "ref", {
|
|
161
|
+
enumerable: !1,
|
|
162
|
+
get: E
|
|
163
|
+
}) : Object.defineProperty(s, "ref", { enumerable: !1, value: null }), s._store = {}, Object.defineProperty(s._store, "validated", {
|
|
164
|
+
configurable: !1,
|
|
165
|
+
enumerable: !1,
|
|
166
|
+
writable: !0,
|
|
167
|
+
value: 0
|
|
168
|
+
}), Object.defineProperty(s, "_debugInfo", {
|
|
169
|
+
configurable: !1,
|
|
170
|
+
enumerable: !1,
|
|
171
|
+
writable: !0,
|
|
172
|
+
value: null
|
|
173
|
+
}), Object.defineProperty(s, "_debugStack", {
|
|
174
|
+
configurable: !1,
|
|
175
|
+
enumerable: !1,
|
|
176
|
+
writable: !0,
|
|
177
|
+
value: ce
|
|
178
|
+
}), Object.defineProperty(s, "_debugTask", {
|
|
179
|
+
configurable: !1,
|
|
180
|
+
enumerable: !1,
|
|
181
|
+
writable: !0,
|
|
182
|
+
value: ue
|
|
183
|
+
}), Object.freeze && (Object.freeze(s.props), Object.freeze(s)), s;
|
|
184
|
+
}
|
|
185
|
+
function v(s, l, S, T, F, L, ce, ue) {
|
|
186
|
+
var A = l.children;
|
|
187
|
+
if (A !== void 0)
|
|
188
|
+
if (T)
|
|
189
|
+
if (P(A)) {
|
|
190
|
+
for (T = 0; T < A.length; T++)
|
|
191
|
+
d(A[T]);
|
|
192
|
+
Object.freeze && Object.freeze(A);
|
|
193
|
+
} else
|
|
194
|
+
console.error(
|
|
195
|
+
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
196
|
+
);
|
|
197
|
+
else d(A);
|
|
198
|
+
if (G.call(l, "key")) {
|
|
199
|
+
A = e(s);
|
|
200
|
+
var ee = Object.keys(l).filter(function(he) {
|
|
201
|
+
return he !== "key";
|
|
68
202
|
});
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
203
|
+
T = 0 < ee.length ? "{key: someKey, " + ee.join(": ..., ") + ": ...}" : "{key: someKey}", Ee[A + T] || (ee = 0 < ee.length ? "{" + ee.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
204
|
+
`A props object containing a "key" prop is being spread into JSX:
|
|
205
|
+
let props = %s;
|
|
206
|
+
<%s {...props} />
|
|
207
|
+
React keys must be passed directly to JSX without using spread:
|
|
208
|
+
let props = %s;
|
|
209
|
+
<%s key={someKey} {...props} />`,
|
|
210
|
+
T,
|
|
211
|
+
A,
|
|
212
|
+
ee,
|
|
213
|
+
A
|
|
214
|
+
), Ee[A + T] = !0);
|
|
215
|
+
}
|
|
216
|
+
if (A = null, S !== void 0 && (t(S), A = "" + S), i(l) && (t(l.key), A = "" + l.key), "key" in l) {
|
|
217
|
+
S = {};
|
|
218
|
+
for (var J in l)
|
|
219
|
+
J !== "key" && (S[J] = l[J]);
|
|
220
|
+
} else S = l;
|
|
221
|
+
return A && f(
|
|
222
|
+
S,
|
|
223
|
+
typeof s == "function" ? s.displayName || s.name || "Unknown" : s
|
|
224
|
+
), g(
|
|
225
|
+
s,
|
|
226
|
+
A,
|
|
227
|
+
L,
|
|
228
|
+
F,
|
|
229
|
+
o(),
|
|
230
|
+
S,
|
|
231
|
+
ce,
|
|
232
|
+
ue
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
function d(s) {
|
|
236
|
+
typeof s == "object" && s !== null && s.$$typeof === u && s._store && (s._store.validated = 1);
|
|
237
|
+
}
|
|
238
|
+
var p = fe, u = Symbol.for("react.transitional.element"), h = Symbol.for("react.portal"), m = Symbol.for("react.fragment"), k = Symbol.for("react.strict_mode"), c = Symbol.for("react.profiler"), W = Symbol.for("react.consumer"), ne = Symbol.for("react.context"), $ = Symbol.for("react.forward_ref"), y = Symbol.for("react.suspense"), I = Symbol.for("react.suspense_list"), Z = Symbol.for("react.memo"), O = Symbol.for("react.lazy"), Q = Symbol.for("react.activity"), V = Symbol.for("react.client.reference"), q = p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, G = Object.prototype.hasOwnProperty, P = Array.isArray, Y = console.createTask ? console.createTask : function() {
|
|
239
|
+
return null;
|
|
240
|
+
};
|
|
241
|
+
p = {
|
|
242
|
+
"react-stack-bottom-frame": function(s) {
|
|
243
|
+
return s();
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
var oe, de = {}, me = p["react-stack-bottom-frame"].bind(
|
|
247
|
+
p,
|
|
248
|
+
a
|
|
249
|
+
)(), H = Y(n(a)), Ee = {};
|
|
250
|
+
ve.Fragment = m, ve.jsx = function(s, l, S, T, F) {
|
|
251
|
+
var L = 1e4 > q.recentlyCreatedOwnerStacks++;
|
|
252
|
+
return v(
|
|
253
|
+
s,
|
|
254
|
+
l,
|
|
255
|
+
S,
|
|
256
|
+
!1,
|
|
257
|
+
T,
|
|
258
|
+
F,
|
|
259
|
+
L ? Error("react-stack-top-frame") : me,
|
|
260
|
+
L ? Y(n(s)) : H
|
|
261
|
+
);
|
|
262
|
+
}, ve.jsxs = function(s, l, S, T, F) {
|
|
263
|
+
var L = 1e4 > q.recentlyCreatedOwnerStacks++;
|
|
264
|
+
return v(
|
|
265
|
+
s,
|
|
266
|
+
l,
|
|
267
|
+
S,
|
|
268
|
+
!0,
|
|
269
|
+
T,
|
|
270
|
+
F,
|
|
271
|
+
L ? Error("react-stack-top-frame") : me,
|
|
272
|
+
L ? Y(n(s)) : H
|
|
273
|
+
);
|
|
274
|
+
};
|
|
275
|
+
}()), ve;
|
|
276
|
+
}
|
|
277
|
+
var Ze;
|
|
278
|
+
function wt() {
|
|
279
|
+
return Ze || (Ze = 1, process.env.NODE_ENV === "production" ? Se.exports = Rt() : Se.exports = Tt()), Se.exports;
|
|
280
|
+
}
|
|
281
|
+
var yt = wt();
|
|
282
|
+
const ut = it(
|
|
283
|
+
void 0
|
|
284
|
+
), Er = ({
|
|
285
|
+
children: e,
|
|
286
|
+
token: r
|
|
287
|
+
}) => /* @__PURE__ */ yt.jsx(ut.Provider, { value: { token: r }, children: e }), At = () => {
|
|
288
|
+
const e = ct(ut);
|
|
289
|
+
if (e === void 0)
|
|
290
|
+
throw new Error(
|
|
291
|
+
"useFigmaTokenContext must be used within a FigmaVarsProvider"
|
|
292
|
+
);
|
|
293
|
+
return e;
|
|
294
|
+
}, ie = () => {
|
|
295
|
+
const { token: e } = At();
|
|
296
|
+
return e;
|
|
297
|
+
};
|
|
298
|
+
var be = { exports: {} }, ye = {};
|
|
299
|
+
/**
|
|
300
|
+
* @license React
|
|
301
|
+
* use-sync-external-store-shim.production.js
|
|
302
|
+
*
|
|
303
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
304
|
+
*
|
|
305
|
+
* This source code is licensed under the MIT license found in the
|
|
306
|
+
* LICENSE file in the root directory of this source tree.
|
|
307
|
+
*/
|
|
308
|
+
var Qe;
|
|
309
|
+
function Dt() {
|
|
310
|
+
if (Qe) return ye;
|
|
311
|
+
Qe = 1;
|
|
312
|
+
var e = fe;
|
|
313
|
+
function r(d, p) {
|
|
314
|
+
return d === p && (d !== 0 || 1 / d === 1 / p) || d !== d && p !== p;
|
|
315
|
+
}
|
|
316
|
+
var t = typeof Object.is == "function" ? Object.is : r, n = e.useState, o = e.useEffect, a = e.useLayoutEffect, i = e.useDebugValue;
|
|
317
|
+
function f(d, p) {
|
|
318
|
+
var u = p(), h = n({ inst: { value: u, getSnapshot: p } }), m = h[0].inst, k = h[1];
|
|
319
|
+
return a(
|
|
320
|
+
function() {
|
|
321
|
+
m.value = u, m.getSnapshot = p, E(m) && k({ inst: m });
|
|
322
|
+
},
|
|
323
|
+
[d, u, p]
|
|
324
|
+
), o(
|
|
325
|
+
function() {
|
|
326
|
+
return E(m) && k({ inst: m }), d(function() {
|
|
327
|
+
E(m) && k({ inst: m });
|
|
78
328
|
});
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
329
|
+
},
|
|
330
|
+
[d]
|
|
331
|
+
), i(u), u;
|
|
332
|
+
}
|
|
333
|
+
function E(d) {
|
|
334
|
+
var p = d.getSnapshot;
|
|
335
|
+
d = d.value;
|
|
336
|
+
try {
|
|
337
|
+
var u = p();
|
|
338
|
+
return !t(d, u);
|
|
339
|
+
} catch {
|
|
340
|
+
return !0;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
function g(d, p) {
|
|
344
|
+
return p();
|
|
345
|
+
}
|
|
346
|
+
var v = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? g : f;
|
|
347
|
+
return ye.useSyncExternalStore = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : v, ye;
|
|
348
|
+
}
|
|
349
|
+
var Ae = {};
|
|
350
|
+
/**
|
|
351
|
+
* @license React
|
|
352
|
+
* use-sync-external-store-shim.development.js
|
|
353
|
+
*
|
|
354
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
355
|
+
*
|
|
356
|
+
* This source code is licensed under the MIT license found in the
|
|
357
|
+
* LICENSE file in the root directory of this source tree.
|
|
358
|
+
*/
|
|
359
|
+
var et;
|
|
360
|
+
function Ct() {
|
|
361
|
+
return et || (et = 1, process.env.NODE_ENV !== "production" && function() {
|
|
362
|
+
function e(u, h) {
|
|
363
|
+
return u === h && (u !== 0 || 1 / u === 1 / h) || u !== u && h !== h;
|
|
364
|
+
}
|
|
365
|
+
function r(u, h) {
|
|
366
|
+
v || o.startTransition === void 0 || (v = !0, console.error(
|
|
367
|
+
"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."
|
|
368
|
+
));
|
|
369
|
+
var m = h();
|
|
370
|
+
if (!d) {
|
|
371
|
+
var k = h();
|
|
372
|
+
a(m, k) || (console.error(
|
|
373
|
+
"The result of getSnapshot should be cached to avoid an infinite loop"
|
|
374
|
+
), d = !0);
|
|
375
|
+
}
|
|
376
|
+
k = i({
|
|
377
|
+
inst: { value: m, getSnapshot: h }
|
|
378
|
+
});
|
|
379
|
+
var c = k[0].inst, W = k[1];
|
|
380
|
+
return E(
|
|
381
|
+
function() {
|
|
382
|
+
c.value = m, c.getSnapshot = h, t(c) && W({ inst: c });
|
|
383
|
+
},
|
|
384
|
+
[u, m, h]
|
|
385
|
+
), f(
|
|
386
|
+
function() {
|
|
387
|
+
return t(c) && W({ inst: c }), u(function() {
|
|
388
|
+
t(c) && W({ inst: c });
|
|
389
|
+
});
|
|
390
|
+
},
|
|
391
|
+
[u]
|
|
392
|
+
), g(m), m;
|
|
393
|
+
}
|
|
394
|
+
function t(u) {
|
|
395
|
+
var h = u.getSnapshot;
|
|
396
|
+
u = u.value;
|
|
397
|
+
try {
|
|
398
|
+
var m = h();
|
|
399
|
+
return !a(u, m);
|
|
400
|
+
} catch {
|
|
401
|
+
return !0;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
function n(u, h) {
|
|
405
|
+
return h();
|
|
406
|
+
}
|
|
407
|
+
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
408
|
+
var o = fe, a = typeof Object.is == "function" ? Object.is : e, i = o.useState, f = o.useEffect, E = o.useLayoutEffect, g = o.useDebugValue, v = !1, d = !1, p = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? n : r;
|
|
409
|
+
Ae.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());
|
|
410
|
+
}()), Ae;
|
|
411
|
+
}
|
|
412
|
+
var tt;
|
|
413
|
+
function kt() {
|
|
414
|
+
return tt || (tt = 1, process.env.NODE_ENV === "production" ? be.exports = Dt() : be.exports = Ct()), be.exports;
|
|
415
|
+
}
|
|
416
|
+
var It = kt();
|
|
417
|
+
const lt = 0, ft = 1, dt = 2, rt = 3;
|
|
418
|
+
var nt = Object.prototype.hasOwnProperty;
|
|
419
|
+
function je(e, r) {
|
|
420
|
+
var t, n;
|
|
421
|
+
if (e === r) return !0;
|
|
422
|
+
if (e && r && (t = e.constructor) === r.constructor) {
|
|
423
|
+
if (t === Date) return e.getTime() === r.getTime();
|
|
424
|
+
if (t === RegExp) return e.toString() === r.toString();
|
|
425
|
+
if (t === Array) {
|
|
426
|
+
if ((n = e.length) === r.length)
|
|
427
|
+
for (; n-- && je(e[n], r[n]); ) ;
|
|
428
|
+
return n === -1;
|
|
429
|
+
}
|
|
430
|
+
if (!t || typeof e == "object") {
|
|
431
|
+
n = 0;
|
|
432
|
+
for (t in e)
|
|
433
|
+
if (nt.call(e, t) && ++n && !nt.call(r, t) || !(t in r) || !je(e[t], r[t])) return !1;
|
|
434
|
+
return Object.keys(r).length === n;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
return e !== e && r !== r;
|
|
438
|
+
}
|
|
439
|
+
const X = /* @__PURE__ */ new WeakMap(), te = () => {
|
|
440
|
+
}, j = (
|
|
441
|
+
/*#__NOINLINE__*/
|
|
442
|
+
te()
|
|
443
|
+
), Pe = Object, _ = (e) => e === j, B = (e) => typeof e == "function", re = (e, r) => ({
|
|
444
|
+
...e,
|
|
445
|
+
...r
|
|
446
|
+
}), mt = (e) => B(e.then), De = {}, Oe = {}, $e = "undefined", _e = typeof window != $e, Ve = typeof document != $e, Lt = _e && "Deno" in window, xt = () => _e && typeof window.requestAnimationFrame != $e, Et = (e, r) => {
|
|
447
|
+
const t = X.get(e);
|
|
448
|
+
return [
|
|
449
|
+
// Getter
|
|
450
|
+
() => !_(r) && e.get(r) || De,
|
|
451
|
+
// Setter
|
|
452
|
+
(n) => {
|
|
453
|
+
if (!_(r)) {
|
|
454
|
+
const o = e.get(r);
|
|
455
|
+
r in Oe || (Oe[r] = o), t[5](r, re(o, n), o || De);
|
|
456
|
+
}
|
|
457
|
+
},
|
|
458
|
+
// Subscriber
|
|
459
|
+
t[6],
|
|
460
|
+
// Get server cache snapshot
|
|
461
|
+
() => !_(r) && r in Oe ? Oe[r] : !_(r) && e.get(r) || De
|
|
462
|
+
];
|
|
463
|
+
};
|
|
464
|
+
let Fe = !0;
|
|
465
|
+
const jt = () => Fe, [Ne, Me] = _e && window.addEventListener ? [
|
|
466
|
+
window.addEventListener.bind(window),
|
|
467
|
+
window.removeEventListener.bind(window)
|
|
468
|
+
] : [
|
|
469
|
+
te,
|
|
470
|
+
te
|
|
471
|
+
], Pt = () => {
|
|
472
|
+
const e = Ve && document.visibilityState;
|
|
473
|
+
return _(e) || e !== "hidden";
|
|
474
|
+
}, Vt = (e) => (Ve && document.addEventListener("visibilitychange", e), Ne("focus", e), () => {
|
|
475
|
+
Ve && document.removeEventListener("visibilitychange", e), Me("focus", e);
|
|
476
|
+
}), Ft = (e) => {
|
|
477
|
+
const r = () => {
|
|
478
|
+
Fe = !0, e();
|
|
479
|
+
}, t = () => {
|
|
480
|
+
Fe = !1;
|
|
481
|
+
};
|
|
482
|
+
return Ne("online", r), Ne("offline", t), () => {
|
|
483
|
+
Me("online", r), Me("offline", t);
|
|
484
|
+
};
|
|
485
|
+
}, Nt = {
|
|
486
|
+
isOnline: jt,
|
|
487
|
+
isVisible: Pt
|
|
488
|
+
}, Mt = {
|
|
489
|
+
initFocus: Vt,
|
|
490
|
+
initReconnect: Ft
|
|
491
|
+
}, ot = !fe.useId, ge = !_e || Lt, Ut = (e) => xt() ? window.requestAnimationFrame(e) : setTimeout(e, 1), Ce = ge ? ht : St, ke = typeof navigator < "u" && navigator.connection, st = !ge && ke && ([
|
|
492
|
+
"slow-2g",
|
|
493
|
+
"2g"
|
|
494
|
+
].includes(ke.effectiveType) || ke.saveData), Re = /* @__PURE__ */ new WeakMap(), Ie = (e, r) => Pe.prototype.toString.call(e) === `[object ${r}]`;
|
|
495
|
+
let Wt = 0;
|
|
496
|
+
const Ue = (e) => {
|
|
497
|
+
const r = typeof e, t = Ie(e, "Date"), n = Ie(e, "RegExp"), o = Ie(e, "Object");
|
|
498
|
+
let a, i;
|
|
499
|
+
if (Pe(e) === e && !t && !n) {
|
|
500
|
+
if (a = Re.get(e), a) return a;
|
|
501
|
+
if (a = ++Wt + "~", Re.set(e, a), Array.isArray(e)) {
|
|
502
|
+
for (a = "@", i = 0; i < e.length; i++)
|
|
503
|
+
a += Ue(e[i]) + ",";
|
|
504
|
+
Re.set(e, a);
|
|
505
|
+
}
|
|
506
|
+
if (o) {
|
|
507
|
+
a = "#";
|
|
508
|
+
const f = Pe.keys(e).sort();
|
|
509
|
+
for (; !_(i = f.pop()); )
|
|
510
|
+
_(e[i]) || (a += i + ":" + Ue(e[i]) + ",");
|
|
511
|
+
Re.set(e, a);
|
|
512
|
+
}
|
|
513
|
+
} else
|
|
514
|
+
a = t ? e.toJSON() : r == "symbol" ? e.toString() : r == "string" ? JSON.stringify(e) : "" + e;
|
|
515
|
+
return a;
|
|
516
|
+
}, qe = (e) => {
|
|
517
|
+
if (B(e))
|
|
518
|
+
try {
|
|
519
|
+
e = e();
|
|
520
|
+
} catch {
|
|
521
|
+
e = "";
|
|
522
|
+
}
|
|
523
|
+
const r = e;
|
|
524
|
+
return e = typeof e == "string" ? e : (Array.isArray(e) ? e.length : e) ? Ue(e) : "", [
|
|
525
|
+
e,
|
|
526
|
+
r
|
|
527
|
+
];
|
|
528
|
+
};
|
|
529
|
+
let $t = 0;
|
|
530
|
+
const We = () => ++$t;
|
|
531
|
+
async function pt(...e) {
|
|
532
|
+
const [r, t, n, o] = e, a = re({
|
|
533
|
+
populateCache: !0,
|
|
534
|
+
throwOnError: !0
|
|
535
|
+
}, typeof o == "boolean" ? {
|
|
536
|
+
revalidate: o
|
|
537
|
+
} : o || {});
|
|
538
|
+
let i = a.populateCache;
|
|
539
|
+
const f = a.rollbackOnError;
|
|
540
|
+
let E = a.optimisticData;
|
|
541
|
+
const g = (p) => typeof f == "function" ? f(p) : f !== !1, v = a.throwOnError;
|
|
542
|
+
if (B(t)) {
|
|
543
|
+
const p = t, u = [], h = r.keys();
|
|
544
|
+
for (const m of h)
|
|
545
|
+
// Skip the special useSWRInfinite and useSWRSubscription keys.
|
|
546
|
+
!/^\$(inf|sub)\$/.test(m) && p(r.get(m)._k) && u.push(m);
|
|
547
|
+
return Promise.all(u.map(d));
|
|
548
|
+
}
|
|
549
|
+
return d(t);
|
|
550
|
+
async function d(p) {
|
|
551
|
+
const [u] = qe(p);
|
|
552
|
+
if (!u) return;
|
|
553
|
+
const [h, m] = Et(r, u), [k, c, W, ne] = X.get(r), $ = () => {
|
|
554
|
+
const P = k[u];
|
|
555
|
+
return (B(a.revalidate) ? a.revalidate(h().data, p) : a.revalidate !== !1) && (delete W[u], delete ne[u], P && P[0]) ? P[0](dt).then(() => h().data) : h().data;
|
|
556
|
+
};
|
|
557
|
+
if (e.length < 3)
|
|
558
|
+
return $();
|
|
559
|
+
let y = n, I;
|
|
560
|
+
const Z = We();
|
|
561
|
+
c[u] = [
|
|
562
|
+
Z,
|
|
563
|
+
0
|
|
564
|
+
];
|
|
565
|
+
const O = !_(E), Q = h(), V = Q.data, q = Q._c, G = _(q) ? V : q;
|
|
566
|
+
if (O && (E = B(E) ? E(G, V) : E, m({
|
|
567
|
+
data: E,
|
|
568
|
+
_c: G
|
|
569
|
+
})), B(y))
|
|
93
570
|
try {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
571
|
+
y = y(G);
|
|
572
|
+
} catch (P) {
|
|
573
|
+
I = P;
|
|
574
|
+
}
|
|
575
|
+
if (y && mt(y))
|
|
576
|
+
if (y = await y.catch((P) => {
|
|
577
|
+
I = P;
|
|
578
|
+
}), Z !== c[u][0]) {
|
|
579
|
+
if (I) throw I;
|
|
580
|
+
return y;
|
|
581
|
+
} else I && O && g(I) && (i = !0, m({
|
|
582
|
+
data: G,
|
|
583
|
+
_c: j
|
|
584
|
+
}));
|
|
585
|
+
if (i && !I)
|
|
586
|
+
if (B(i)) {
|
|
587
|
+
const P = i(y, G);
|
|
588
|
+
m({
|
|
589
|
+
data: P,
|
|
590
|
+
error: j,
|
|
591
|
+
_c: j
|
|
592
|
+
});
|
|
593
|
+
} else
|
|
594
|
+
m({
|
|
595
|
+
data: y,
|
|
596
|
+
error: j,
|
|
597
|
+
_c: j
|
|
104
598
|
});
|
|
599
|
+
if (c[u][1] = We(), Promise.resolve($()).then(() => {
|
|
600
|
+
m({
|
|
601
|
+
_c: j
|
|
602
|
+
});
|
|
603
|
+
}), I) {
|
|
604
|
+
if (v) throw I;
|
|
605
|
+
return;
|
|
606
|
+
}
|
|
607
|
+
return y;
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
const at = (e, r) => {
|
|
611
|
+
for (const t in e)
|
|
612
|
+
e[t][0] && e[t][0](r);
|
|
613
|
+
}, qt = (e, r) => {
|
|
614
|
+
if (!X.has(e)) {
|
|
615
|
+
const t = re(Mt, r), n = /* @__PURE__ */ Object.create(null), o = pt.bind(j, e);
|
|
616
|
+
let a = te;
|
|
617
|
+
const i = /* @__PURE__ */ Object.create(null), f = (v, d) => {
|
|
618
|
+
const p = i[v] || [];
|
|
619
|
+
return i[v] = p, p.push(d), () => p.splice(p.indexOf(d), 1);
|
|
620
|
+
}, E = (v, d, p) => {
|
|
621
|
+
e.set(v, d);
|
|
622
|
+
const u = i[v];
|
|
623
|
+
if (u)
|
|
624
|
+
for (const h of u)
|
|
625
|
+
h(d, p);
|
|
626
|
+
}, g = () => {
|
|
627
|
+
if (!X.has(e) && (X.set(e, [
|
|
628
|
+
n,
|
|
629
|
+
/* @__PURE__ */ Object.create(null),
|
|
630
|
+
/* @__PURE__ */ Object.create(null),
|
|
631
|
+
/* @__PURE__ */ Object.create(null),
|
|
632
|
+
o,
|
|
633
|
+
E,
|
|
634
|
+
f
|
|
635
|
+
]), !ge)) {
|
|
636
|
+
const v = t.initFocus(setTimeout.bind(j, at.bind(j, n, lt))), d = t.initReconnect(setTimeout.bind(j, at.bind(j, n, ft)));
|
|
637
|
+
a = () => {
|
|
638
|
+
v && v(), d && d(), X.delete(e);
|
|
639
|
+
};
|
|
105
640
|
}
|
|
106
|
-
}
|
|
107
|
-
|
|
641
|
+
};
|
|
642
|
+
return g(), [
|
|
643
|
+
e,
|
|
644
|
+
o,
|
|
645
|
+
g,
|
|
646
|
+
a
|
|
647
|
+
];
|
|
648
|
+
}
|
|
649
|
+
return [
|
|
650
|
+
e,
|
|
651
|
+
X.get(e)[4]
|
|
652
|
+
];
|
|
653
|
+
}, Gt = (e, r, t, n, o) => {
|
|
654
|
+
const a = t.errorRetryCount, i = o.retryCount, f = ~~((Math.random() + 0.5) * (1 << (i < 8 ? i : 8))) * t.errorRetryInterval;
|
|
655
|
+
!_(a) && i > a || setTimeout(n, f, o);
|
|
656
|
+
}, Yt = je, [vt, Bt] = qt(/* @__PURE__ */ new Map()), Ht = re(
|
|
657
|
+
{
|
|
658
|
+
// events
|
|
659
|
+
onLoadingSlow: te,
|
|
660
|
+
onSuccess: te,
|
|
661
|
+
onError: te,
|
|
662
|
+
onErrorRetry: Gt,
|
|
663
|
+
onDiscarded: te,
|
|
664
|
+
// switches
|
|
665
|
+
revalidateOnFocus: !0,
|
|
666
|
+
revalidateOnReconnect: !0,
|
|
667
|
+
revalidateIfStale: !0,
|
|
668
|
+
shouldRetryOnError: !0,
|
|
669
|
+
// timeouts
|
|
670
|
+
errorRetryInterval: st ? 1e4 : 5e3,
|
|
671
|
+
focusThrottleInterval: 5 * 1e3,
|
|
672
|
+
dedupingInterval: 2 * 1e3,
|
|
673
|
+
loadingTimeout: st ? 5e3 : 3e3,
|
|
674
|
+
// providers
|
|
675
|
+
compare: Yt,
|
|
676
|
+
isPaused: () => !1,
|
|
677
|
+
cache: vt,
|
|
678
|
+
mutate: Bt,
|
|
679
|
+
fallback: {}
|
|
680
|
+
},
|
|
681
|
+
// use web preset by default
|
|
682
|
+
Nt
|
|
683
|
+
), Jt = (e, r) => {
|
|
684
|
+
const t = re(e, r);
|
|
685
|
+
if (r) {
|
|
686
|
+
const { use: n, fallback: o } = e, { use: a, fallback: i } = r;
|
|
687
|
+
n && a && (t.use = n.concat(a)), o && i && (t.fallback = re(o, i));
|
|
688
|
+
}
|
|
689
|
+
return t;
|
|
690
|
+
}, Kt = it({}), zt = "$inf$", gt = _e && window.__SWR_DEVTOOLS_USE__, Xt = gt ? window.__SWR_DEVTOOLS_USE__ : [], Zt = () => {
|
|
691
|
+
gt && (window.__SWR_DEVTOOLS_REACT__ = fe);
|
|
692
|
+
}, Qt = (e) => B(e[1]) ? [
|
|
693
|
+
e[0],
|
|
694
|
+
e[1],
|
|
695
|
+
e[2] || {}
|
|
696
|
+
] : [
|
|
697
|
+
e[0],
|
|
698
|
+
null,
|
|
699
|
+
(e[1] === null ? e[2] : e[1]) || {}
|
|
700
|
+
], er = () => re(Ht, ct(Kt)), tr = (e) => (r, t, n) => e(r, t && ((...a) => {
|
|
701
|
+
const [i] = qe(r), [, , , f] = X.get(vt);
|
|
702
|
+
if (i.startsWith(zt))
|
|
703
|
+
return t(...a);
|
|
704
|
+
const E = f[i];
|
|
705
|
+
return _(E) ? t(...a) : (delete f[i], E);
|
|
706
|
+
}), n), rr = Xt.concat(tr), nr = (e) => function(...t) {
|
|
707
|
+
const n = er(), [o, a, i] = Qt(t), f = Jt(n, i);
|
|
708
|
+
let E = e;
|
|
709
|
+
const { use: g } = f, v = (g || []).concat(rr);
|
|
710
|
+
for (let d = v.length; d--; )
|
|
711
|
+
E = v[d](E);
|
|
712
|
+
return E(o, a || f.fetcher || null, f);
|
|
713
|
+
}, or = (e, r, t) => {
|
|
714
|
+
const n = r[e] || (r[e] = []);
|
|
715
|
+
return n.push(t), () => {
|
|
716
|
+
const o = n.indexOf(t);
|
|
717
|
+
o >= 0 && (n[o] = n[n.length - 1], n.pop());
|
|
718
|
+
};
|
|
108
719
|
};
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
720
|
+
Zt();
|
|
721
|
+
const Le = fe.use || // This extra generic is to avoid TypeScript mixing up the generic and JSX sytax
|
|
722
|
+
// and emitting an error.
|
|
723
|
+
// We assume that this is only for the `use(thenable)` case, not `use(context)`.
|
|
724
|
+
// https://github.com/facebook/react/blob/aed00dacfb79d17c53218404c52b1c7aa59c4a89/packages/react-server/src/ReactFizzThenable.js#L45
|
|
725
|
+
((e) => {
|
|
726
|
+
switch (e.status) {
|
|
727
|
+
case "pending":
|
|
728
|
+
throw e;
|
|
729
|
+
case "fulfilled":
|
|
730
|
+
return e.value;
|
|
731
|
+
case "rejected":
|
|
732
|
+
throw e.reason;
|
|
733
|
+
default:
|
|
734
|
+
throw e.status = "pending", e.then((r) => {
|
|
735
|
+
e.status = "fulfilled", e.value = r;
|
|
736
|
+
}, (r) => {
|
|
737
|
+
e.status = "rejected", e.reason = r;
|
|
738
|
+
}), e;
|
|
739
|
+
}
|
|
740
|
+
}), xe = {
|
|
741
|
+
dedupe: !0
|
|
742
|
+
}, sr = (e, r, t) => {
|
|
743
|
+
const { cache: n, compare: o, suspense: a, fallbackData: i, revalidateOnMount: f, revalidateIfStale: E, refreshInterval: g, refreshWhenHidden: v, refreshWhenOffline: d, keepPreviousData: p } = t, [u, h, m, k] = X.get(n), [c, W] = qe(e), ne = se(!1), $ = se(!1), y = se(c), I = se(r), Z = se(t), O = () => Z.current, Q = () => O().isVisible() && O().isOnline(), [V, q, G, P] = Et(n, c), Y = se({}).current, oe = _(i) ? _(t.fallback) ? j : t.fallback[c] : i, de = (R, b) => {
|
|
744
|
+
for (const C in Y) {
|
|
745
|
+
const w = C;
|
|
746
|
+
if (w === "data") {
|
|
747
|
+
if (!o(R[w], b[w]) && (!_(R[w]) || !o(L, b[w])))
|
|
748
|
+
return !1;
|
|
749
|
+
} else if (b[w] !== R[w])
|
|
750
|
+
return !1;
|
|
751
|
+
}
|
|
752
|
+
return !0;
|
|
753
|
+
}, me = bt(() => {
|
|
754
|
+
const R = !c || !r ? !1 : _(f) ? O().isPaused() || a ? !1 : E !== !1 : f, b = (x) => {
|
|
755
|
+
const K = re(x);
|
|
756
|
+
return delete K._k, R ? {
|
|
757
|
+
isValidating: !0,
|
|
758
|
+
isLoading: !0,
|
|
759
|
+
...K
|
|
760
|
+
} : K;
|
|
761
|
+
}, C = V(), w = P(), U = b(C), le = C === w ? U : b(w);
|
|
762
|
+
let D = U;
|
|
763
|
+
return [
|
|
764
|
+
() => {
|
|
765
|
+
const x = b(V());
|
|
766
|
+
return de(x, D) ? (D.data = x.data, D.isLoading = x.isLoading, D.isValidating = x.isValidating, D.error = x.error, D) : (D = x, x);
|
|
767
|
+
},
|
|
768
|
+
() => le
|
|
769
|
+
];
|
|
770
|
+
}, [
|
|
771
|
+
n,
|
|
772
|
+
c
|
|
773
|
+
]), H = It.useSyncExternalStore(ae(
|
|
774
|
+
(R) => G(c, (b, C) => {
|
|
775
|
+
de(C, b) || R();
|
|
776
|
+
}),
|
|
777
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
778
|
+
[
|
|
779
|
+
n,
|
|
780
|
+
c
|
|
781
|
+
]
|
|
782
|
+
), me[0], me[1]), Ee = !ne.current, s = u[c] && u[c].length > 0, l = H.data, S = _(l) ? oe && mt(oe) ? Le(oe) : oe : l, T = H.error, F = se(S), L = p ? _(l) ? _(F.current) ? S : F.current : l : S, ce = s && !_(T) ? !1 : Ee && !_(f) ? f : O().isPaused() ? !1 : a ? _(S) ? !1 : E : _(S) || E, ue = !!(c && r && Ee && ce), A = _(H.isValidating) ? ue : H.isValidating, ee = _(H.isLoading) ? ue : H.isLoading, J = ae(
|
|
783
|
+
async (R) => {
|
|
784
|
+
const b = I.current;
|
|
785
|
+
if (!c || !b || $.current || O().isPaused())
|
|
786
|
+
return !1;
|
|
787
|
+
let C, w, U = !0;
|
|
788
|
+
const le = R || {}, D = !m[c] || !le.dedupe, x = () => ot ? !$.current && c === y.current && ne.current : c === y.current, K = {
|
|
789
|
+
isValidating: !1,
|
|
790
|
+
isLoading: !1
|
|
791
|
+
}, He = () => {
|
|
792
|
+
q(K);
|
|
793
|
+
}, Je = () => {
|
|
794
|
+
const N = m[c];
|
|
795
|
+
N && N[1] === w && delete m[c];
|
|
796
|
+
}, Ke = {
|
|
797
|
+
isValidating: !0
|
|
798
|
+
};
|
|
799
|
+
_(V().data) && (Ke.isLoading = !0);
|
|
800
|
+
try {
|
|
801
|
+
if (D && (q(Ke), t.loadingTimeout && _(V().data) && setTimeout(() => {
|
|
802
|
+
U && x() && O().onLoadingSlow(c, t);
|
|
803
|
+
}, t.loadingTimeout), m[c] = [
|
|
804
|
+
b(W),
|
|
805
|
+
We()
|
|
806
|
+
]), [C, w] = m[c], C = await C, D && setTimeout(Je, t.dedupingInterval), !m[c] || m[c][1] !== w)
|
|
807
|
+
return D && x() && O().onDiscarded(c), !1;
|
|
808
|
+
K.error = j;
|
|
809
|
+
const N = h[c];
|
|
810
|
+
if (!_(N) && // case 1
|
|
811
|
+
(w <= N[0] || // case 2
|
|
812
|
+
w <= N[1] || // case 3
|
|
813
|
+
N[1] === 0))
|
|
814
|
+
return He(), D && x() && O().onDiscarded(c), !1;
|
|
815
|
+
const z = V().data;
|
|
816
|
+
K.data = o(z, C) ? z : C, D && x() && O().onSuccess(C, c, t);
|
|
817
|
+
} catch (N) {
|
|
818
|
+
Je();
|
|
819
|
+
const z = O(), { shouldRetryOnError: Te } = z;
|
|
820
|
+
z.isPaused() || (K.error = N, D && x() && (z.onError(N, c, z), (Te === !0 || B(Te) && Te(N)) && (!O().revalidateOnFocus || !O().revalidateOnReconnect || Q()) && z.onErrorRetry(N, c, z, (_t) => {
|
|
821
|
+
const we = u[c];
|
|
822
|
+
we && we[0] && we[0](rt, _t);
|
|
823
|
+
}, {
|
|
824
|
+
retryCount: (le.retryCount || 0) + 1,
|
|
825
|
+
dedupe: !0
|
|
826
|
+
})));
|
|
827
|
+
}
|
|
828
|
+
return U = !1, He(), !0;
|
|
117
829
|
},
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
830
|
+
// `setState` is immutable, and `eventsCallback`, `fnArg`, and
|
|
831
|
+
// `keyValidating` are depending on `key`, so we can exclude them from
|
|
832
|
+
// the deps array.
|
|
833
|
+
//
|
|
834
|
+
// FIXME:
|
|
835
|
+
// `fn` and `config` might be changed during the lifecycle,
|
|
836
|
+
// but they might be changed every render like this.
|
|
837
|
+
// `useSWR('key', () => fetch('/api/'), { suspense: true })`
|
|
838
|
+
// So we omit the values from the deps array
|
|
839
|
+
// even though it might cause unexpected behaviors.
|
|
840
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
841
|
+
[
|
|
842
|
+
c,
|
|
843
|
+
n
|
|
844
|
+
]
|
|
845
|
+
), he = ae(
|
|
846
|
+
// Use callback to make sure `keyRef.current` returns latest result every time
|
|
847
|
+
(...R) => pt(n, y.current, ...R),
|
|
848
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
849
|
+
[]
|
|
850
|
+
);
|
|
851
|
+
if (Ce(() => {
|
|
852
|
+
I.current = r, Z.current = t, _(l) || (F.current = l);
|
|
853
|
+
}), Ce(() => {
|
|
854
|
+
if (!c) return;
|
|
855
|
+
const R = J.bind(j, xe);
|
|
856
|
+
let b = 0;
|
|
857
|
+
O().revalidateOnFocus && (b = Date.now() + O().focusThrottleInterval);
|
|
858
|
+
const w = or(c, u, (U, le = {}) => {
|
|
859
|
+
if (U == lt) {
|
|
860
|
+
const D = Date.now();
|
|
861
|
+
O().revalidateOnFocus && D > b && Q() && (b = D + O().focusThrottleInterval, R());
|
|
862
|
+
} else if (U == ft)
|
|
863
|
+
O().revalidateOnReconnect && Q() && R();
|
|
864
|
+
else {
|
|
865
|
+
if (U == dt)
|
|
866
|
+
return J();
|
|
867
|
+
if (U == rt)
|
|
868
|
+
return J(le);
|
|
869
|
+
}
|
|
870
|
+
});
|
|
871
|
+
return $.current = !1, y.current = c, ne.current = !0, q({
|
|
872
|
+
_k: W
|
|
873
|
+
}), ce && (_(S) || ge ? R() : Ut(R)), () => {
|
|
874
|
+
$.current = !0, w();
|
|
875
|
+
};
|
|
876
|
+
}, [
|
|
877
|
+
c
|
|
878
|
+
]), Ce(() => {
|
|
879
|
+
let R;
|
|
880
|
+
function b() {
|
|
881
|
+
const w = B(g) ? g(V().data) : g;
|
|
882
|
+
w && R !== -1 && (R = setTimeout(C, w));
|
|
883
|
+
}
|
|
884
|
+
function C() {
|
|
885
|
+
!V().error && (v || O().isVisible()) && (d || O().isOnline()) ? J(xe).then(b) : b();
|
|
886
|
+
}
|
|
887
|
+
return b(), () => {
|
|
888
|
+
R && (clearTimeout(R), R = -1);
|
|
889
|
+
};
|
|
890
|
+
}, [
|
|
891
|
+
g,
|
|
892
|
+
v,
|
|
893
|
+
d,
|
|
894
|
+
c
|
|
895
|
+
]), Ot(L), a && _(S) && c) {
|
|
896
|
+
if (!ot && ge)
|
|
897
|
+
throw new Error("Fallback data is required when using Suspense in SSR.");
|
|
898
|
+
I.current = r, Z.current = t, $.current = !1;
|
|
899
|
+
const R = k[c];
|
|
900
|
+
if (!_(R)) {
|
|
901
|
+
const b = he(R);
|
|
902
|
+
Le(b);
|
|
903
|
+
}
|
|
904
|
+
if (_(T)) {
|
|
905
|
+
const b = J(xe);
|
|
906
|
+
_(L) || (b.status = "fulfilled", b.value = !0), Le(b);
|
|
907
|
+
} else
|
|
908
|
+
throw T;
|
|
909
|
+
}
|
|
910
|
+
return {
|
|
911
|
+
mutate: he,
|
|
912
|
+
get data() {
|
|
913
|
+
return Y.data = !0, L;
|
|
914
|
+
},
|
|
915
|
+
get error() {
|
|
916
|
+
return Y.error = !0, T;
|
|
917
|
+
},
|
|
918
|
+
get isValidating() {
|
|
919
|
+
return Y.isValidating = !0, A;
|
|
920
|
+
},
|
|
921
|
+
get isLoading() {
|
|
922
|
+
return Y.isLoading = !0, ee;
|
|
923
|
+
}
|
|
924
|
+
};
|
|
925
|
+
}, Ge = nr(sr), pr = () => null, Ye = async (e, r = { method: "GET" }) => {
|
|
926
|
+
throw new Error("Figma API token is not available.");
|
|
927
|
+
}, ar = "https://api.figma.com", ir = `${ar}/v1/files`, Be = (e) => `${ir}/${e}/variables`, vr = (e) => {
|
|
928
|
+
const r = ie(), { data: t, error: n, isLoading: o, isValidating: a } = Ge(
|
|
929
|
+
r ? Be(e) : null,
|
|
930
|
+
Ye
|
|
931
|
+
), i = t != null && t.meta ? Object.values(t.meta.variables) : [], f = t != null && t.meta ? t.meta.variables : {};
|
|
932
|
+
return {
|
|
933
|
+
variables: i,
|
|
934
|
+
variablesById: f,
|
|
935
|
+
isLoading: o,
|
|
936
|
+
isValidating: a,
|
|
937
|
+
error: n ?? (t && "message" in t ? new Error(t.message) : null)
|
|
938
|
+
};
|
|
939
|
+
}, gr = (e) => {
|
|
940
|
+
const r = ie(), { data: t, error: n, isLoading: o, isValidating: a } = Ge(
|
|
941
|
+
r ? Be(e) : null,
|
|
942
|
+
Ye
|
|
943
|
+
), i = t != null && t.meta ? Object.values(t.meta.variableCollections) : [], f = t != null && t.meta ? t.meta.variableCollections : {};
|
|
944
|
+
return {
|
|
945
|
+
collections: i,
|
|
946
|
+
collectionsById: f,
|
|
947
|
+
isLoading: o,
|
|
948
|
+
isValidating: a,
|
|
949
|
+
error: n ?? (t && "message" in t ? new Error(t.message) : null)
|
|
950
|
+
};
|
|
951
|
+
}, _r = (e) => {
|
|
952
|
+
const r = ie(), { data: t, error: n, isLoading: o, isValidating: a } = Ge(
|
|
953
|
+
r ? Be(e) : null,
|
|
954
|
+
Ye
|
|
955
|
+
), i = [], f = {}, E = {};
|
|
956
|
+
if (t != null && t.meta)
|
|
957
|
+
for (const g of Object.values(
|
|
958
|
+
t.meta.variableCollections
|
|
959
|
+
)) {
|
|
960
|
+
i.push(...g.modes), f[g.id] = g.modes;
|
|
961
|
+
for (const v of g.modes)
|
|
962
|
+
E[v.modeId] = v;
|
|
963
|
+
}
|
|
964
|
+
return {
|
|
965
|
+
modes: i,
|
|
966
|
+
modesByCollectionId: f,
|
|
967
|
+
modesById: E,
|
|
968
|
+
isLoading: o,
|
|
969
|
+
isValidating: a,
|
|
970
|
+
error: n ?? (t && "message" in t ? new Error(t.message) : null)
|
|
971
|
+
};
|
|
972
|
+
};
|
|
973
|
+
async function cr(e, r, t) {
|
|
974
|
+
const n = `https://api.figma.com/v1/files/${r}/variables`;
|
|
975
|
+
try {
|
|
976
|
+
const o = await fetch(n, {
|
|
977
|
+
method: "POST",
|
|
978
|
+
headers: {
|
|
979
|
+
"Content-Type": "application/json",
|
|
980
|
+
"X-FIGMA-TOKEN": e
|
|
981
|
+
},
|
|
982
|
+
body: JSON.stringify(t)
|
|
983
|
+
}), a = await o.json();
|
|
984
|
+
return o.ok ? {
|
|
985
|
+
error: !1,
|
|
986
|
+
status: o.status,
|
|
987
|
+
meta: a.meta
|
|
988
|
+
} : {
|
|
989
|
+
error: !0,
|
|
990
|
+
status: o.status,
|
|
991
|
+
message: a.message || "Failed to perform bulk update."
|
|
992
|
+
};
|
|
993
|
+
} catch (o) {
|
|
994
|
+
return {
|
|
995
|
+
error: !0,
|
|
996
|
+
status: 500,
|
|
997
|
+
message: o instanceof Error ? o.message : "An unknown error occurred."
|
|
998
|
+
};
|
|
999
|
+
}
|
|
123
1000
|
}
|
|
124
|
-
|
|
125
|
-
const a =
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
1001
|
+
const hr = () => {
|
|
1002
|
+
const e = ie(), [r, t] = M(!1), [n, o] = M(null), [a, i] = M(null);
|
|
1003
|
+
return { bulkUpdate: ae(
|
|
1004
|
+
async (E, g) => {
|
|
1005
|
+
if (!e) {
|
|
1006
|
+
o("Figma API token is not provided.");
|
|
1007
|
+
return;
|
|
1008
|
+
}
|
|
1009
|
+
t(!0), o(null);
|
|
1010
|
+
const v = await cr(e, E, g);
|
|
1011
|
+
i(v), v.error && o(v.message || "An error occurred during the bulk update."), t(!1);
|
|
132
1012
|
},
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
1013
|
+
[e]
|
|
1014
|
+
), loading: r, error: n, data: a };
|
|
1015
|
+
};
|
|
1016
|
+
async function ur(e, r) {
|
|
1017
|
+
const t = "https://api.figma.com/v1/variables";
|
|
1018
|
+
try {
|
|
1019
|
+
const n = await fetch(t, {
|
|
1020
|
+
method: "POST",
|
|
1021
|
+
headers: {
|
|
1022
|
+
"Content-Type": "application/json",
|
|
1023
|
+
"X-FIGMA-TOKEN": e
|
|
1024
|
+
},
|
|
1025
|
+
body: JSON.stringify(r)
|
|
1026
|
+
});
|
|
1027
|
+
if (!n.ok) {
|
|
1028
|
+
const a = await n.json();
|
|
1029
|
+
return {
|
|
1030
|
+
error: !0,
|
|
1031
|
+
status: n.status,
|
|
1032
|
+
message: a.message || "Failed to create Figma variable"
|
|
1033
|
+
};
|
|
1034
|
+
}
|
|
1035
|
+
const o = await n.json();
|
|
1036
|
+
return {
|
|
1037
|
+
error: !1,
|
|
1038
|
+
status: n.status,
|
|
1039
|
+
variable: o
|
|
1040
|
+
};
|
|
1041
|
+
} catch (n) {
|
|
1042
|
+
return {
|
|
1043
|
+
error: !0,
|
|
1044
|
+
status: 500,
|
|
1045
|
+
message: n instanceof Error ? n.message : "An unknown error occurred"
|
|
1046
|
+
};
|
|
1047
|
+
}
|
|
138
1048
|
}
|
|
139
|
-
|
|
140
|
-
const r =
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
1049
|
+
const Sr = () => {
|
|
1050
|
+
const e = ie(), [r, t] = M(!1), [n, o] = M(null), [a, i] = M(null);
|
|
1051
|
+
return { createVariable: ae(
|
|
1052
|
+
async (E) => {
|
|
1053
|
+
if (!e) {
|
|
1054
|
+
o("Figma API token is not provided.");
|
|
1055
|
+
return;
|
|
1056
|
+
}
|
|
1057
|
+
t(!0), o(null);
|
|
1058
|
+
const g = await ur(e, E);
|
|
1059
|
+
i(g), g.error && o(g.message || "An error occurred."), t(!1);
|
|
1060
|
+
},
|
|
1061
|
+
[e]
|
|
1062
|
+
), loading: r, error: n, data: a };
|
|
1063
|
+
};
|
|
1064
|
+
async function lr(e, r) {
|
|
1065
|
+
const t = `https://api.figma.com/v1/variables/${r}`;
|
|
1066
|
+
try {
|
|
1067
|
+
const n = await fetch(t, {
|
|
1068
|
+
method: "DELETE",
|
|
1069
|
+
headers: {
|
|
1070
|
+
"Content-Type": "application/json",
|
|
1071
|
+
"X-FIGMA-TOKEN": e
|
|
1072
|
+
}
|
|
1073
|
+
});
|
|
1074
|
+
if (!n.ok) {
|
|
1075
|
+
const o = await n.json();
|
|
1076
|
+
return {
|
|
1077
|
+
error: !0,
|
|
1078
|
+
status: n.status,
|
|
1079
|
+
message: o.message || "Failed to delete Figma variable"
|
|
1080
|
+
};
|
|
146
1081
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
1082
|
+
return {
|
|
1083
|
+
error: !1,
|
|
1084
|
+
status: n.status
|
|
1085
|
+
};
|
|
1086
|
+
} catch (n) {
|
|
1087
|
+
return {
|
|
1088
|
+
error: !0,
|
|
1089
|
+
status: 500,
|
|
1090
|
+
message: n instanceof Error ? n.message : "An unknown error occurred"
|
|
1091
|
+
};
|
|
1092
|
+
}
|
|
151
1093
|
}
|
|
152
|
-
|
|
153
|
-
const r =
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
1094
|
+
const br = () => {
|
|
1095
|
+
const e = ie(), [r, t] = M(!1), [n, o] = M(null), [a, i] = M(null);
|
|
1096
|
+
return { deleteVariable: ae(
|
|
1097
|
+
async (E) => {
|
|
1098
|
+
if (!e) {
|
|
1099
|
+
o("Figma API token is not provided.");
|
|
1100
|
+
return;
|
|
1101
|
+
}
|
|
1102
|
+
t(!0), o(null);
|
|
1103
|
+
const g = await lr(e, E);
|
|
1104
|
+
i(g), g.error && o(g.message || "An error occurred."), t(!1);
|
|
160
1105
|
},
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
1106
|
+
[e]
|
|
1107
|
+
), loading: r, error: n, data: a };
|
|
1108
|
+
};
|
|
1109
|
+
async function fr(e, r, t) {
|
|
1110
|
+
const n = `https://api.figma.com/v1/variables/${r}`;
|
|
1111
|
+
try {
|
|
1112
|
+
const o = await fetch(n, {
|
|
1113
|
+
method: "PUT",
|
|
1114
|
+
headers: {
|
|
1115
|
+
"Content-Type": "application/json",
|
|
1116
|
+
"X-FIGMA-TOKEN": e
|
|
1117
|
+
},
|
|
1118
|
+
body: JSON.stringify(t)
|
|
1119
|
+
});
|
|
1120
|
+
if (!o.ok) {
|
|
1121
|
+
const a = await o.json();
|
|
1122
|
+
return {
|
|
1123
|
+
error: !0,
|
|
1124
|
+
status: o.status,
|
|
1125
|
+
message: a.message || "Failed to update Figma variable"
|
|
1126
|
+
};
|
|
1127
|
+
}
|
|
1128
|
+
return {
|
|
1129
|
+
error: !1,
|
|
1130
|
+
status: o.status
|
|
1131
|
+
};
|
|
1132
|
+
} catch (o) {
|
|
1133
|
+
return {
|
|
1134
|
+
error: !0,
|
|
1135
|
+
status: 500,
|
|
1136
|
+
message: o instanceof Error ? o.message : "An unknown error occurred"
|
|
1137
|
+
};
|
|
1138
|
+
}
|
|
166
1139
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
1140
|
+
const Or = () => {
|
|
1141
|
+
const e = ie(), [r, t] = M(!1), [n, o] = M(null), [a, i] = M(null);
|
|
1142
|
+
return { updateVariable: ae(
|
|
1143
|
+
async (E, g) => {
|
|
1144
|
+
if (!e) {
|
|
1145
|
+
o("Figma API token is not provided.");
|
|
1146
|
+
return;
|
|
1147
|
+
}
|
|
1148
|
+
t(!0), o(null);
|
|
1149
|
+
const v = await fr(e, E, g);
|
|
1150
|
+
i(v), v.error && o(v.message || "An error occurred."), t(!1);
|
|
1151
|
+
},
|
|
1152
|
+
[e]
|
|
1153
|
+
), loading: r, error: n, data: a };
|
|
1154
|
+
};
|
|
1155
|
+
function Rr(e, r) {
|
|
1156
|
+
return e.filter((t) => {
|
|
1157
|
+
let n = !0;
|
|
1158
|
+
return r.resolvedType && (n = n && t.resolvedType === r.resolvedType), r.name && (n = n && t.name.includes(r.name)), n;
|
|
171
1159
|
});
|
|
172
1160
|
}
|
|
173
|
-
class N {
|
|
174
|
-
constructor() {
|
|
175
|
-
w(this, "cache", {});
|
|
176
|
-
}
|
|
177
|
-
get(e) {
|
|
178
|
-
return this.cache[e];
|
|
179
|
-
}
|
|
180
|
-
set(e, r) {
|
|
181
|
-
this.cache[e] = r;
|
|
182
|
-
}
|
|
183
|
-
clear(e) {
|
|
184
|
-
e ? delete this.cache[e] : this.cache = {};
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
const C = () => null, G = () => !0, S = async (t, e = { method: "GET" }) => {
|
|
188
|
-
throw new Error("Figma API token is not available.");
|
|
189
|
-
}, X = () => {
|
|
190
|
-
const [t, e] = i({});
|
|
191
|
-
return { aliases: t, setAlias: (n, s) => e((o) => ({ ...o, [n]: s })), removeAlias: (n) => {
|
|
192
|
-
const s = { ...t };
|
|
193
|
-
delete s[n], e(s);
|
|
194
|
-
} };
|
|
195
|
-
}, K = () => {
|
|
196
|
-
const [t, e] = i(
|
|
197
|
-
/* @__PURE__ */ new Map()
|
|
198
|
-
);
|
|
199
|
-
return { bindings: t, bindVariable: (n, s) => e(new Map(t.set(n, s))), unbindVariable: (n) => {
|
|
200
|
-
const s = new Map(t);
|
|
201
|
-
s.delete(n), e(s);
|
|
202
|
-
} };
|
|
203
|
-
}, x = () => ({}), B = () => ({});
|
|
204
1161
|
export {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
K as useVariableBindings,
|
|
218
|
-
V as useVariableCollections,
|
|
219
|
-
I as useVariableModes,
|
|
220
|
-
A as useVariables,
|
|
221
|
-
G as validateToken
|
|
1162
|
+
Er as FigmaVarsProvider,
|
|
1163
|
+
Ye as fetchWithAuth,
|
|
1164
|
+
Rr as filterVariables,
|
|
1165
|
+
pr as getFigmaToken,
|
|
1166
|
+
hr as useBulkUpdateVariables,
|
|
1167
|
+
Sr as useCreateVariable,
|
|
1168
|
+
br as useDeleteVariable,
|
|
1169
|
+
ie as useFigmaToken,
|
|
1170
|
+
Or as useUpdateVariable,
|
|
1171
|
+
gr as useVariableCollections,
|
|
1172
|
+
_r as useVariableModes,
|
|
1173
|
+
vr as useVariables
|
|
222
1174
|
};
|