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