@animaapp/anima-sdk-react 0.21.0 → 0.23.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/dist/index.cjs +6 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +238 -225
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
var on = Object.defineProperty, an = Object.defineProperties;
|
|
2
2
|
var cn = Object.getOwnPropertyDescriptors;
|
|
3
|
-
var
|
|
3
|
+
var yt = Object.getOwnPropertySymbols;
|
|
4
4
|
var un = Object.prototype.hasOwnProperty, ln = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var
|
|
5
|
+
var _t = (e, n, t) => n in e ? on(e, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[n] = t, L = (e, n) => {
|
|
6
6
|
for (var t in n || (n = {}))
|
|
7
|
-
un.call(n, t) &&
|
|
8
|
-
if (
|
|
9
|
-
for (var t of
|
|
10
|
-
ln.call(n, t) &&
|
|
7
|
+
un.call(n, t) && _t(e, t, n[t]);
|
|
8
|
+
if (yt)
|
|
9
|
+
for (var t of yt(n))
|
|
10
|
+
ln.call(n, t) && _t(e, t, n[t]);
|
|
11
11
|
return e;
|
|
12
|
-
},
|
|
12
|
+
}, ke = (e, n) => an(e, cn(n));
|
|
13
13
|
var V = (e, n, t) => new Promise((s, i) => {
|
|
14
14
|
var c = (r) => {
|
|
15
15
|
try {
|
|
@@ -27,8 +27,8 @@ var V = (e, n, t) => new Promise((s, i) => {
|
|
|
27
27
|
l((t = t.apply(e, n)).next());
|
|
28
28
|
});
|
|
29
29
|
import { jsx as dn } from "react/jsx-runtime";
|
|
30
|
-
import we, { createContext as Wt, useState as Ge, useRef as z, useEffect as Ft, useContext as Vt, useCallback as
|
|
31
|
-
import { CodegenError as
|
|
30
|
+
import we, { createContext as Wt, useState as Ge, useRef as z, useEffect as Ft, useContext as Vt, useCallback as Ie, useLayoutEffect as fn, useMemo as Pt, useDebugValue as hn } from "react";
|
|
31
|
+
import { CodegenError as Re } from "@animaapp/anima-sdk";
|
|
32
32
|
class Ot extends Error {
|
|
33
33
|
constructor(n, t) {
|
|
34
34
|
super(n), this.name = "ParseError", this.type = t.type, this.field = t.field, this.value = t.value, this.line = t.line;
|
|
@@ -44,12 +44,12 @@ function pn(e) {
|
|
|
44
44
|
const { onEvent: n = je, onError: t = je, onRetry: s = je, onComment: i } = e;
|
|
45
45
|
let c = "", a = !0, l, r = "", o = "";
|
|
46
46
|
function f(d) {
|
|
47
|
-
const
|
|
47
|
+
const E = a ? d.replace(/^\xEF\xBB\xBF/, "") : d, [u, w] = gn(`${c}${E}`);
|
|
48
48
|
for (const O of u)
|
|
49
|
-
|
|
49
|
+
p(O);
|
|
50
50
|
c = w, a = !1;
|
|
51
51
|
}
|
|
52
|
-
function
|
|
52
|
+
function p(d) {
|
|
53
53
|
if (d === "") {
|
|
54
54
|
h();
|
|
55
55
|
return;
|
|
@@ -58,31 +58,31 @@ function pn(e) {
|
|
|
58
58
|
i && i(d.slice(d.startsWith(": ") ? 2 : 1));
|
|
59
59
|
return;
|
|
60
60
|
}
|
|
61
|
-
const
|
|
62
|
-
if (
|
|
63
|
-
const u = d.slice(0,
|
|
61
|
+
const E = d.indexOf(":");
|
|
62
|
+
if (E !== -1) {
|
|
63
|
+
const u = d.slice(0, E), w = d[E + 1] === " " ? 2 : 1, O = d.slice(E + w);
|
|
64
64
|
m(u, O, d);
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
67
67
|
m(d, "", d);
|
|
68
68
|
}
|
|
69
|
-
function m(d,
|
|
69
|
+
function m(d, E, u) {
|
|
70
70
|
switch (d) {
|
|
71
71
|
case "event":
|
|
72
|
-
o =
|
|
72
|
+
o = E;
|
|
73
73
|
break;
|
|
74
74
|
case "data":
|
|
75
|
-
r = `${r}${
|
|
75
|
+
r = `${r}${E}
|
|
76
76
|
`;
|
|
77
77
|
break;
|
|
78
78
|
case "id":
|
|
79
|
-
l =
|
|
79
|
+
l = E.includes("\0") ? void 0 : E;
|
|
80
80
|
break;
|
|
81
81
|
case "retry":
|
|
82
|
-
/^\d+$/.test(
|
|
83
|
-
new Ot(`Invalid \`retry\` value: "${
|
|
82
|
+
/^\d+$/.test(E) ? s(parseInt(E, 10)) : t(
|
|
83
|
+
new Ot(`Invalid \`retry\` value: "${E}"`, {
|
|
84
84
|
type: "invalid-retry",
|
|
85
|
-
value:
|
|
85
|
+
value: E,
|
|
86
86
|
line: u
|
|
87
87
|
})
|
|
88
88
|
);
|
|
@@ -91,7 +91,7 @@ function pn(e) {
|
|
|
91
91
|
t(
|
|
92
92
|
new Ot(
|
|
93
93
|
`Unknown field "${d.length > 20 ? `${d.slice(0, 20)}…` : d}"`,
|
|
94
|
-
{ type: "unknown-field", field: d, value:
|
|
94
|
+
{ type: "unknown-field", field: d, value: E, line: u }
|
|
95
95
|
)
|
|
96
96
|
);
|
|
97
97
|
break;
|
|
@@ -107,10 +107,10 @@ function pn(e) {
|
|
|
107
107
|
`) ? r.slice(0, -1) : r
|
|
108
108
|
}), l = void 0, r = "", o = "";
|
|
109
109
|
}
|
|
110
|
-
function
|
|
111
|
-
c && d.consume &&
|
|
110
|
+
function g(d = {}) {
|
|
111
|
+
c && d.consume && p(c), a = !0, l = void 0, r = "", o = "", c = "";
|
|
112
112
|
}
|
|
113
|
-
return { feed: f, reset:
|
|
113
|
+
return { feed: f, reset: g };
|
|
114
114
|
}
|
|
115
115
|
function gn(e) {
|
|
116
116
|
const n = [];
|
|
@@ -191,11 +191,11 @@ function Rt(e) {
|
|
|
191
191
|
}
|
|
192
192
|
var $t = (e) => {
|
|
193
193
|
throw TypeError(e);
|
|
194
|
-
}, ct = (e, n, t) => n.has(e) || $t("Cannot " + t), S = (e, n, t) => (ct(e, n, "read from private field"), t ? t.call(e) : n.get(e)), I = (e, n, t) => n.has(e) ? $t("Cannot add the same private member more than once") : n instanceof WeakSet ? n.add(e) : n.set(e, t), R = (e, n, t, s) => (ct(e, n, "write to private field"), n.set(e, t), t), H = (e, n, t) => (ct(e, n, "access private method"), t), W, te, ie,
|
|
194
|
+
}, ct = (e, n, t) => n.has(e) || $t("Cannot " + t), S = (e, n, t) => (ct(e, n, "read from private field"), t ? t.call(e) : n.get(e)), I = (e, n, t) => n.has(e) ? $t("Cannot add the same private member more than once") : n instanceof WeakSet ? n.add(e) : n.set(e, t), R = (e, n, t, s) => (ct(e, n, "write to private field"), n.set(e, t), t), H = (e, n, t) => (ct(e, n, "access private method"), t), W, te, ie, De, Ne, Ee, le, me, Y, ce, de, ue, pe, $, He, Ke, ze, Ct, Ye, Xe, ge, Qe, Ze;
|
|
195
195
|
class Se extends EventTarget {
|
|
196
196
|
constructor(n, t) {
|
|
197
197
|
var s, i;
|
|
198
|
-
super(), I(this, $), this.CONNECTING = 0, this.OPEN = 1, this.CLOSED = 2, I(this, W), I(this, te), I(this, ie), I(this,
|
|
198
|
+
super(), I(this, $), this.CONNECTING = 0, this.OPEN = 1, this.CLOSED = 2, I(this, W), I(this, te), I(this, ie), I(this, De), I(this, Ne), I(this, Ee), I(this, le), I(this, me, null), I(this, Y), I(this, ce), I(this, de, null), I(this, ue, null), I(this, pe, null), I(this, Ke, (c) => V(this, null, function* () {
|
|
199
199
|
var a;
|
|
200
200
|
S(this, ce).reset();
|
|
201
201
|
const { body: l, redirected: r, status: o, headers: f } = c;
|
|
@@ -214,17 +214,17 @@ class Se extends EventTarget {
|
|
|
214
214
|
if (S(this, W) === this.CLOSED)
|
|
215
215
|
return;
|
|
216
216
|
R(this, W, this.OPEN);
|
|
217
|
-
const
|
|
218
|
-
if ((a = S(this, pe)) == null || a.call(this,
|
|
217
|
+
const p = new Event("open");
|
|
218
|
+
if ((a = S(this, pe)) == null || a.call(this, p), this.dispatchEvent(p), typeof l != "object" || !l || !("getReader" in l)) {
|
|
219
219
|
H(this, $, ge).call(this, "Invalid response body, expected a web ReadableStream", o), this.close();
|
|
220
220
|
return;
|
|
221
221
|
}
|
|
222
222
|
const m = new TextDecoder(), h = l.getReader();
|
|
223
|
-
let
|
|
223
|
+
let g = !0;
|
|
224
224
|
do {
|
|
225
|
-
const { done: d, value:
|
|
226
|
-
|
|
227
|
-
} while (
|
|
225
|
+
const { done: d, value: E } = yield h.read();
|
|
226
|
+
E && S(this, ce).feed(m.decode(E, { stream: !d })), d && (g = !1, S(this, ce).reset(), H(this, $, Qe).call(this));
|
|
227
|
+
} while (g);
|
|
228
228
|
})), I(this, ze, (c) => {
|
|
229
229
|
R(this, Y, void 0), !(c.name === "AbortError" || c.type === "aborted") && H(this, $, Qe).call(this, Be(c));
|
|
230
230
|
}), I(this, Ye, (c) => {
|
|
@@ -253,7 +253,7 @@ class Se extends EventTarget {
|
|
|
253
253
|
R(this, ce, pn({
|
|
254
254
|
onEvent: S(this, Ye),
|
|
255
255
|
onRetry: S(this, Xe)
|
|
256
|
-
})), R(this, W, this.CONNECTING), R(this, Ee, 3e3), R(this,
|
|
256
|
+
})), R(this, W, this.CONNECTING), R(this, Ee, 3e3), R(this, Ne, (s = t == null ? void 0 : t.fetch) != null ? s : globalThis.fetch), R(this, De, (i = t == null ? void 0 : t.withCredentials) != null ? i : !1), H(this, $, He).call(this);
|
|
257
257
|
}
|
|
258
258
|
/**
|
|
259
259
|
* Returns the state of this EventSource object's connection. It can have the values described below.
|
|
@@ -284,7 +284,7 @@ class Se extends EventTarget {
|
|
|
284
284
|
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)
|
|
285
285
|
*/
|
|
286
286
|
get withCredentials() {
|
|
287
|
-
return S(this,
|
|
287
|
+
return S(this, De);
|
|
288
288
|
}
|
|
289
289
|
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
|
|
290
290
|
get onerror() {
|
|
@@ -326,20 +326,20 @@ class Se extends EventTarget {
|
|
|
326
326
|
S(this, le) && clearTimeout(S(this, le)), S(this, W) !== this.CLOSED && (S(this, Y) && S(this, Y).abort(), R(this, W, this.CLOSED), R(this, Y, void 0));
|
|
327
327
|
}
|
|
328
328
|
}
|
|
329
|
-
W = /* @__PURE__ */ new WeakMap(), te = /* @__PURE__ */ new WeakMap(), ie = /* @__PURE__ */ new WeakMap(),
|
|
329
|
+
W = /* @__PURE__ */ new WeakMap(), te = /* @__PURE__ */ new WeakMap(), ie = /* @__PURE__ */ new WeakMap(), De = /* @__PURE__ */ new WeakMap(), Ne = /* @__PURE__ */ new WeakMap(), Ee = /* @__PURE__ */ new WeakMap(), le = /* @__PURE__ */ new WeakMap(), me = /* @__PURE__ */ new WeakMap(), Y = /* @__PURE__ */ new WeakMap(), ce = /* @__PURE__ */ new WeakMap(), de = /* @__PURE__ */ new WeakMap(), ue = /* @__PURE__ */ new WeakMap(), pe = /* @__PURE__ */ new WeakMap(), $ = /* @__PURE__ */ new WeakSet(), /**
|
|
330
330
|
* Connect to the given URL and start receiving events
|
|
331
331
|
*
|
|
332
332
|
* @internal
|
|
333
333
|
*/
|
|
334
334
|
He = function() {
|
|
335
|
-
R(this, W, this.CONNECTING), R(this, Y, new AbortController()), S(this,
|
|
335
|
+
R(this, W, this.CONNECTING), R(this, Y, new AbortController()), S(this, Ne)(S(this, te), H(this, $, Ct).call(this)).then(S(this, Ke)).catch(S(this, ze));
|
|
336
336
|
}, Ke = /* @__PURE__ */ new WeakMap(), ze = /* @__PURE__ */ new WeakMap(), /**
|
|
337
337
|
* Get request options for the `fetch()` request
|
|
338
338
|
*
|
|
339
339
|
* @returns The request options
|
|
340
340
|
* @internal
|
|
341
341
|
*/
|
|
342
|
-
|
|
342
|
+
Ct = function() {
|
|
343
343
|
var e;
|
|
344
344
|
const n = {
|
|
345
345
|
// [spec] Let `corsAttributeState` be `Anonymous`…
|
|
@@ -416,14 +416,14 @@ const Sn = (e) => {
|
|
|
416
416
|
jobSessionId: null,
|
|
417
417
|
jobStatus: {},
|
|
418
418
|
jobType: null
|
|
419
|
-
},
|
|
419
|
+
}, Tt = 10, Jt = (e) => "path" in e ? {
|
|
420
420
|
filePath: e.path.replace(/^\//, ""),
|
|
421
421
|
referencePath: e.path === "/" ? "" : e.path
|
|
422
422
|
// Workaround to avoid duplicated slashes in the URL. Ideally, the fix should be done in Codegen.
|
|
423
423
|
} : {
|
|
424
424
|
filePath: e.filePath.replace(/^\//, ""),
|
|
425
425
|
referencePath: e.referencePath === "/" ? "" : e.referencePath
|
|
426
|
-
},
|
|
426
|
+
}, Ut = ({
|
|
427
427
|
es: e,
|
|
428
428
|
lastFetchResponse: n,
|
|
429
429
|
stateUpdated: t
|
|
@@ -452,16 +452,29 @@ const Sn = (e) => {
|
|
|
452
452
|
);
|
|
453
453
|
a.figmaFileName = o.figmaFileName, a.figmaSelectedFrameName = o.figmaSelectedFrameName;
|
|
454
454
|
}), e.addEventListener("aborted", () => {
|
|
455
|
-
const r = new
|
|
455
|
+
const r = new Re({ name: "Aborted", reason: "Unknown" });
|
|
456
456
|
s.status = "aborted", s.result = null, s.error = r, t(L({}, s)), i({
|
|
457
457
|
result: null,
|
|
458
458
|
error: r
|
|
459
459
|
});
|
|
460
460
|
}), e.addEventListener("generating_code", (r) => {
|
|
461
|
+
var f, p;
|
|
461
462
|
const o = JSON.parse(
|
|
462
463
|
r.data
|
|
463
464
|
);
|
|
464
|
-
o.payload.status === "success" && (a.files = o.payload.files),
|
|
465
|
+
if (o.payload.status === "success" && (a.files = o.payload.files), o.payload.status === "failure") {
|
|
466
|
+
const m = (p = (f = o.payload.files) == null ? void 0 : f.error) == null ? void 0 : p.content, h = new Re({
|
|
467
|
+
name: "Generation failed",
|
|
468
|
+
reason: "Code generation failed",
|
|
469
|
+
detail: m
|
|
470
|
+
});
|
|
471
|
+
s.status = "error", s.error = h, t(L({}, s)), i({
|
|
472
|
+
result: null,
|
|
473
|
+
error: h
|
|
474
|
+
});
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
s.tasks.codeGeneration.progress = o.payload.progress, s.tasks.codeGeneration.status = "running", t(L({}, s));
|
|
465
478
|
}), e.addEventListener("progress_messages_updated", (r) => {
|
|
466
479
|
const o = JSON.parse(
|
|
467
480
|
r.data
|
|
@@ -486,7 +499,7 @@ const Sn = (e) => {
|
|
|
486
499
|
});
|
|
487
500
|
let l = 0;
|
|
488
501
|
e.addEventListener("error", (r) => V(null, null, function* () {
|
|
489
|
-
var
|
|
502
|
+
var g, d, E, u, w, O, x;
|
|
490
503
|
if (!n)
|
|
491
504
|
return;
|
|
492
505
|
const o = yield n;
|
|
@@ -495,11 +508,11 @@ const Sn = (e) => {
|
|
|
495
508
|
try {
|
|
496
509
|
b = yield o.text();
|
|
497
510
|
const D = JSON.parse(b);
|
|
498
|
-
(
|
|
511
|
+
(g = D == null ? void 0 : D.payload) != null && g.message && (b = D.payload.message);
|
|
499
512
|
} catch (D) {
|
|
500
513
|
}
|
|
501
514
|
c(
|
|
502
|
-
new
|
|
515
|
+
new Re({
|
|
503
516
|
name: "Request failed",
|
|
504
517
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
505
518
|
reason: b,
|
|
@@ -509,17 +522,17 @@ const Sn = (e) => {
|
|
|
509
522
|
return;
|
|
510
523
|
}
|
|
511
524
|
console.warn(
|
|
512
|
-
`Experienced error during code generation (attempt ${l + 1} / ${
|
|
525
|
+
`Experienced error during code generation (attempt ${l + 1} / ${Tt})`,
|
|
513
526
|
r
|
|
514
527
|
);
|
|
515
|
-
let f,
|
|
528
|
+
let f, p = !1;
|
|
516
529
|
if (r instanceof MessageEvent)
|
|
517
530
|
try {
|
|
518
531
|
f = JSON.parse(r.data);
|
|
519
532
|
} catch (b) {
|
|
520
533
|
}
|
|
521
|
-
(((d = f == null ? void 0 : f.payload) == null ? void 0 : d.name) === "Task Crashed" || ((
|
|
522
|
-
const m = new
|
|
534
|
+
(((d = f == null ? void 0 : f.payload) == null ? void 0 : d.name) === "Task Crashed" || ((E = f == null ? void 0 : f.payload) == null ? void 0 : E.name) === "TimeoutError" || ((u = f == null ? void 0 : f.payload) == null ? void 0 : u.name) === "Error" || ((w = f == null ? void 0 : f.payload) == null ? void 0 : w.name) === "Unknown error") && (p = !0);
|
|
535
|
+
const m = new Re({
|
|
523
536
|
name: (O = f == null ? void 0 : f.payload.name) != null ? O : "Unknown error",
|
|
524
537
|
reason: (x = f == null ? void 0 : f.payload.message) != null ? x : "Unknown",
|
|
525
538
|
status: f == null ? void 0 : f.payload.status,
|
|
@@ -527,7 +540,7 @@ const Sn = (e) => {
|
|
|
527
540
|
});
|
|
528
541
|
l++;
|
|
529
542
|
let h = !1;
|
|
530
|
-
l >
|
|
543
|
+
l > Tt ? (console.error("Experienced too many errors, terminating request"), h = !0) : p && (console.error("Experienced unrecoverable error, terminating request"), h = !0), h && (s.status = "error", s.error = m, t(L({}, s)), i({
|
|
531
544
|
result: null,
|
|
532
545
|
error: m
|
|
533
546
|
}));
|
|
@@ -540,20 +553,20 @@ const Sn = (e) => {
|
|
|
540
553
|
var l;
|
|
541
554
|
const i = structuredClone(t);
|
|
542
555
|
if (((l = t.assetsStorage) == null ? void 0 : l.strategy) === "local") {
|
|
543
|
-
const { referencePath: r } =
|
|
556
|
+
const { referencePath: r } = Jt(
|
|
544
557
|
t.assetsStorage
|
|
545
558
|
);
|
|
546
559
|
t.assetsStorage = { strategy: "external", url: r };
|
|
547
560
|
}
|
|
548
561
|
let c;
|
|
549
562
|
const a = new Se(e, {
|
|
550
|
-
fetch: (r, o) => (c = fetch(r,
|
|
563
|
+
fetch: (r, o) => (c = fetch(r, ke(L({}, o), {
|
|
551
564
|
method: n,
|
|
552
565
|
body: JSON.stringify(t)
|
|
553
566
|
})), c)
|
|
554
567
|
});
|
|
555
568
|
try {
|
|
556
|
-
const { result: r, error: o } = yield
|
|
569
|
+
const { result: r, error: o } = yield Ut({
|
|
557
570
|
es: a,
|
|
558
571
|
lastFetchResponse: c,
|
|
559
572
|
stateUpdated: s
|
|
@@ -569,13 +582,13 @@ const Sn = (e) => {
|
|
|
569
582
|
const s = structuredClone(n);
|
|
570
583
|
let i;
|
|
571
584
|
const c = new Se(e, {
|
|
572
|
-
fetch: (a, l) => (i = fetch(a,
|
|
585
|
+
fetch: (a, l) => (i = fetch(a, ke(L({}, l), {
|
|
573
586
|
method: "POST",
|
|
574
587
|
body: JSON.stringify(n)
|
|
575
588
|
})), i)
|
|
576
589
|
});
|
|
577
590
|
try {
|
|
578
|
-
const { result: a, error: l } = yield
|
|
591
|
+
const { result: a, error: l } = yield Ut({
|
|
579
592
|
es: c,
|
|
580
593
|
lastFetchResponse: i,
|
|
581
594
|
stateUpdated: t
|
|
@@ -590,7 +603,7 @@ const Sn = (e) => {
|
|
|
590
603
|
}), Gt = (e, n) => V(null, null, function* () {
|
|
591
604
|
var t, s;
|
|
592
605
|
if (((t = n.assetsStorage) == null ? void 0 : t.strategy) === "local" && ((s = e.assets) != null && s.length)) {
|
|
593
|
-
const { filePath: i } =
|
|
606
|
+
const { filePath: i } = Jt(n.assetsStorage), c = e.assets.map(
|
|
594
607
|
(l) => V(null, null, function* () {
|
|
595
608
|
const o = yield (yield fetch(l.url)).arrayBuffer();
|
|
596
609
|
return {
|
|
@@ -614,34 +627,34 @@ class wn extends Error {
|
|
|
614
627
|
super(n), this.name = "CreateJobError", this.cause = t;
|
|
615
628
|
}
|
|
616
629
|
}
|
|
617
|
-
class
|
|
630
|
+
class yn extends Error {
|
|
618
631
|
constructor(n, t) {
|
|
619
632
|
super(n), this.name = "AttachJobError", this.cause = t;
|
|
620
633
|
}
|
|
621
634
|
}
|
|
622
|
-
class
|
|
635
|
+
class _n extends Error {
|
|
623
636
|
constructor() {
|
|
624
637
|
super(""), this.name = "UnknownCodegenError";
|
|
625
638
|
}
|
|
626
639
|
}
|
|
627
640
|
const Bt = Wt(null);
|
|
628
641
|
function us({ figmaRestApi: e, f2cUrl: n, l2cUrl: t, p2cUrl: s, jobsUrl: i, children: c }) {
|
|
629
|
-
const [a, l] = Ge({ status: "idle" }), r = z(null), [o, f] = Ge(ut),
|
|
642
|
+
const [a, l] = Ge({ status: "idle" }), r = z(null), [o, f] = Ge(ut), p = {
|
|
630
643
|
f2c: n,
|
|
631
644
|
l2c: t,
|
|
632
645
|
p2c: s
|
|
633
|
-
}, m = (
|
|
634
|
-
var
|
|
646
|
+
}, m = (g, d) => V(null, null, function* () {
|
|
647
|
+
var E;
|
|
635
648
|
if (a.status === "pending")
|
|
636
649
|
throw new Error("A job is already in progress");
|
|
637
|
-
r.current =
|
|
650
|
+
r.current = g;
|
|
638
651
|
try {
|
|
639
|
-
const u =
|
|
652
|
+
const u = p[g], { result: w } = yield qt(u, "POST", d, (O) => f(O));
|
|
640
653
|
if (w) {
|
|
641
654
|
const O = w.sessionId, x = w.files, b = w.assets;
|
|
642
655
|
l((D) => ({
|
|
643
656
|
status: "success",
|
|
644
|
-
type:
|
|
657
|
+
type: g,
|
|
645
658
|
params: "params" in D ? D.params : {},
|
|
646
659
|
sessionId: O,
|
|
647
660
|
payload: o.jobStatus,
|
|
@@ -656,20 +669,20 @@ function us({ figmaRestApi: e, f2cUrl: n, l2cUrl: t, p2cUrl: s, jobsUrl: i, chil
|
|
|
656
669
|
const w = u instanceof Error ? u.message : "Unknown error", O = new wn(w, u);
|
|
657
670
|
throw l({
|
|
658
671
|
status: "error",
|
|
659
|
-
type:
|
|
672
|
+
type: g,
|
|
660
673
|
params: d,
|
|
661
674
|
error: O,
|
|
662
|
-
sessionId: (
|
|
675
|
+
sessionId: (E = o.jobSessionId) != null ? E : null,
|
|
663
676
|
payload: o.jobStatus,
|
|
664
677
|
progressMessages: o.progressMessages
|
|
665
678
|
}), O;
|
|
666
679
|
}
|
|
667
|
-
}), h = (
|
|
680
|
+
}), h = (g, d) => V(null, null, function* () {
|
|
668
681
|
if (!i)
|
|
669
682
|
throw new Error("jobsUrl is required in order to attach to a job");
|
|
670
683
|
try {
|
|
671
|
-
const
|
|
672
|
-
|
|
684
|
+
const E = `${i}/${g}`, { result: u } = yield vn(
|
|
685
|
+
E,
|
|
673
686
|
d,
|
|
674
687
|
(w) => f(w)
|
|
675
688
|
);
|
|
@@ -679,37 +692,37 @@ function us({ figmaRestApi: e, f2cUrl: n, l2cUrl: t, p2cUrl: s, jobsUrl: i, chil
|
|
|
679
692
|
status: "success",
|
|
680
693
|
type: o.jobType,
|
|
681
694
|
params: "params" in x ? x.params : {},
|
|
682
|
-
sessionId:
|
|
695
|
+
sessionId: g,
|
|
683
696
|
payload: o.jobStatus,
|
|
684
697
|
assets: O,
|
|
685
698
|
files: w,
|
|
686
699
|
progressMessages: o.progressMessages
|
|
687
700
|
}));
|
|
688
701
|
}
|
|
689
|
-
} catch (
|
|
690
|
-
const u =
|
|
702
|
+
} catch (E) {
|
|
703
|
+
const u = E instanceof Error ? E.message : "Unknown error", w = new yn(u, E);
|
|
691
704
|
throw l({
|
|
692
705
|
status: "error",
|
|
693
706
|
type: r.current,
|
|
694
707
|
params: {},
|
|
695
708
|
error: w,
|
|
696
|
-
sessionId:
|
|
709
|
+
sessionId: g,
|
|
697
710
|
payload: o.jobStatus,
|
|
698
711
|
progressMessages: o.progressMessages
|
|
699
712
|
}), w;
|
|
700
713
|
}
|
|
701
714
|
});
|
|
702
715
|
return Ft(() => {
|
|
703
|
-
var d,
|
|
704
|
-
const
|
|
705
|
-
if (
|
|
716
|
+
var d, E;
|
|
717
|
+
const g = (d = r.current) != null ? d : o.jobType;
|
|
718
|
+
if (g) {
|
|
706
719
|
if (o.status === "error") {
|
|
707
|
-
const u = (
|
|
720
|
+
const u = (E = o.error) != null ? E : new _n();
|
|
708
721
|
l((w) => {
|
|
709
722
|
var O;
|
|
710
723
|
return {
|
|
711
724
|
status: "error",
|
|
712
|
-
type:
|
|
725
|
+
type: g,
|
|
713
726
|
params: "params" in w ? w.params : {},
|
|
714
727
|
error: u,
|
|
715
728
|
sessionId: (O = o.jobSessionId) != null ? O : null,
|
|
@@ -722,7 +735,7 @@ function us({ figmaRestApi: e, f2cUrl: n, l2cUrl: t, p2cUrl: s, jobsUrl: i, chil
|
|
|
722
735
|
if (o.status === "pending") {
|
|
723
736
|
l((u) => ({
|
|
724
737
|
status: "pending",
|
|
725
|
-
type:
|
|
738
|
+
type: g,
|
|
726
739
|
params: "params" in u ? u.params : {},
|
|
727
740
|
sessionId: o.jobSessionId,
|
|
728
741
|
payload: o.jobStatus,
|
|
@@ -756,7 +769,7 @@ const ls = ({
|
|
|
756
769
|
}) => {
|
|
757
770
|
const [t, s] = Ge(ut);
|
|
758
771
|
return {
|
|
759
|
-
getCode:
|
|
772
|
+
getCode: Ie(
|
|
760
773
|
(c) => qt(e, n, c, s),
|
|
761
774
|
[e, n]
|
|
762
775
|
),
|
|
@@ -769,7 +782,7 @@ const ls = ({
|
|
|
769
782
|
result: t.result
|
|
770
783
|
};
|
|
771
784
|
};
|
|
772
|
-
var
|
|
785
|
+
var Ce = { exports: {} }, We = {};
|
|
773
786
|
/**
|
|
774
787
|
* @license React
|
|
775
788
|
* use-sync-external-store-shim.production.js
|
|
@@ -784,37 +797,37 @@ function bn() {
|
|
|
784
797
|
if (Lt) return We;
|
|
785
798
|
Lt = 1;
|
|
786
799
|
var e = we;
|
|
787
|
-
function n(
|
|
788
|
-
return
|
|
800
|
+
function n(p, m) {
|
|
801
|
+
return p === m && (p !== 0 || 1 / p === 1 / m) || p !== p && m !== m;
|
|
789
802
|
}
|
|
790
803
|
var t = typeof Object.is == "function" ? Object.is : n, s = e.useState, i = e.useEffect, c = e.useLayoutEffect, a = e.useDebugValue;
|
|
791
|
-
function l(
|
|
792
|
-
var h = m(),
|
|
804
|
+
function l(p, m) {
|
|
805
|
+
var h = m(), g = s({ inst: { value: h, getSnapshot: m } }), d = g[0].inst, E = g[1];
|
|
793
806
|
return c(
|
|
794
807
|
function() {
|
|
795
|
-
d.value = h, d.getSnapshot = m, r(d) &&
|
|
808
|
+
d.value = h, d.getSnapshot = m, r(d) && E({ inst: d });
|
|
796
809
|
},
|
|
797
|
-
[
|
|
810
|
+
[p, h, m]
|
|
798
811
|
), i(
|
|
799
812
|
function() {
|
|
800
|
-
return r(d) &&
|
|
801
|
-
r(d) &&
|
|
813
|
+
return r(d) && E({ inst: d }), p(function() {
|
|
814
|
+
r(d) && E({ inst: d });
|
|
802
815
|
});
|
|
803
816
|
},
|
|
804
|
-
[
|
|
817
|
+
[p]
|
|
805
818
|
), a(h), h;
|
|
806
819
|
}
|
|
807
|
-
function r(
|
|
808
|
-
var m =
|
|
809
|
-
|
|
820
|
+
function r(p) {
|
|
821
|
+
var m = p.getSnapshot;
|
|
822
|
+
p = p.value;
|
|
810
823
|
try {
|
|
811
824
|
var h = m();
|
|
812
|
-
return !t(
|
|
813
|
-
} catch (
|
|
825
|
+
return !t(p, h);
|
|
826
|
+
} catch (g) {
|
|
814
827
|
return !0;
|
|
815
828
|
}
|
|
816
829
|
}
|
|
817
|
-
function o(
|
|
830
|
+
function o(p, m) {
|
|
818
831
|
return m();
|
|
819
832
|
}
|
|
820
833
|
var f = typeof window == "undefined" || typeof window.document == "undefined" || typeof window.document.createElement == "undefined" ? o : l;
|
|
@@ -833,29 +846,29 @@ var Fe = {};
|
|
|
833
846
|
var It;
|
|
834
847
|
function Rn() {
|
|
835
848
|
return It || (It = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
836
|
-
function e(h,
|
|
837
|
-
return h ===
|
|
849
|
+
function e(h, g) {
|
|
850
|
+
return h === g && (h !== 0 || 1 / h === 1 / g) || h !== h && g !== g;
|
|
838
851
|
}
|
|
839
|
-
function n(h,
|
|
852
|
+
function n(h, g) {
|
|
840
853
|
f || i.startTransition === void 0 || (f = !0, console.error(
|
|
841
854
|
"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."
|
|
842
855
|
));
|
|
843
|
-
var d =
|
|
844
|
-
if (!
|
|
845
|
-
var
|
|
846
|
-
c(d,
|
|
856
|
+
var d = g();
|
|
857
|
+
if (!p) {
|
|
858
|
+
var E = g();
|
|
859
|
+
c(d, E) || (console.error(
|
|
847
860
|
"The result of getSnapshot should be cached to avoid an infinite loop"
|
|
848
|
-
),
|
|
861
|
+
), p = !0);
|
|
849
862
|
}
|
|
850
|
-
|
|
851
|
-
inst: { value: d, getSnapshot:
|
|
863
|
+
E = a({
|
|
864
|
+
inst: { value: d, getSnapshot: g }
|
|
852
865
|
});
|
|
853
|
-
var u =
|
|
866
|
+
var u = E[0].inst, w = E[1];
|
|
854
867
|
return r(
|
|
855
868
|
function() {
|
|
856
|
-
u.value = d, u.getSnapshot =
|
|
869
|
+
u.value = d, u.getSnapshot = g, t(u) && w({ inst: u });
|
|
857
870
|
},
|
|
858
|
-
[h, d,
|
|
871
|
+
[h, d, g]
|
|
859
872
|
), l(
|
|
860
873
|
function() {
|
|
861
874
|
return t(u) && w({ inst: u }), h(function() {
|
|
@@ -866,28 +879,28 @@ function Rn() {
|
|
|
866
879
|
), o(d), d;
|
|
867
880
|
}
|
|
868
881
|
function t(h) {
|
|
869
|
-
var
|
|
882
|
+
var g = h.getSnapshot;
|
|
870
883
|
h = h.value;
|
|
871
884
|
try {
|
|
872
|
-
var d =
|
|
885
|
+
var d = g();
|
|
873
886
|
return !c(h, d);
|
|
874
|
-
} catch (
|
|
887
|
+
} catch (E) {
|
|
875
888
|
return !0;
|
|
876
889
|
}
|
|
877
890
|
}
|
|
878
|
-
function s(h,
|
|
879
|
-
return
|
|
891
|
+
function s(h, g) {
|
|
892
|
+
return g();
|
|
880
893
|
}
|
|
881
894
|
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ != "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
882
|
-
var i = we, c = typeof Object.is == "function" ? Object.is : e, a = i.useState, l = i.useEffect, r = i.useLayoutEffect, o = i.useDebugValue, f = !1,
|
|
895
|
+
var i = we, c = typeof Object.is == "function" ? Object.is : e, a = i.useState, l = i.useEffect, r = i.useLayoutEffect, o = i.useDebugValue, f = !1, p = !1, m = typeof window == "undefined" || typeof window.document == "undefined" || typeof window.document.createElement == "undefined" ? s : n;
|
|
883
896
|
Fe.useSyncExternalStore = i.useSyncExternalStore !== void 0 ? i.useSyncExternalStore : m, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ != "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
884
897
|
})()), Fe;
|
|
885
898
|
}
|
|
886
899
|
var Dt;
|
|
887
|
-
function
|
|
888
|
-
return Dt || (Dt = 1, process.env.NODE_ENV === "production" ?
|
|
900
|
+
function Cn() {
|
|
901
|
+
return Dt || (Dt = 1, process.env.NODE_ENV === "production" ? Ce.exports = bn() : Ce.exports = Rn()), Ce.exports;
|
|
889
902
|
}
|
|
890
|
-
var
|
|
903
|
+
var Tn = Cn();
|
|
891
904
|
const Ht = 0, Kt = 1, zt = 2, Nt = 3;
|
|
892
905
|
var At = Object.prototype.hasOwnProperty;
|
|
893
906
|
function et(e, n) {
|
|
@@ -914,7 +927,7 @@ const K = /* @__PURE__ */ new WeakMap(), X = () => {
|
|
|
914
927
|
}, M = (
|
|
915
928
|
/*#__NOINLINE__*/
|
|
916
929
|
X()
|
|
917
|
-
), tt = Object, v = (e) => e === M, q = (e) => typeof e == "function", Q = (e, n) => L(L({}, e), n), Yt = (e) => q(e.then), Ve = {}, Te = {}, lt = "undefined",
|
|
930
|
+
), tt = Object, v = (e) => e === M, q = (e) => typeof e == "function", Q = (e, n) => L(L({}, e), n), Yt = (e) => q(e.then), Ve = {}, Te = {}, lt = "undefined", ye = typeof window != lt, nt = typeof document != lt, Ln = ye && "Deno" in window, In = () => ye && typeof window.requestAnimationFrame != lt, Xt = (e, n) => {
|
|
918
931
|
const t = K.get(e);
|
|
919
932
|
return [
|
|
920
933
|
// Getter
|
|
@@ -933,7 +946,7 @@ const K = /* @__PURE__ */ new WeakMap(), X = () => {
|
|
|
933
946
|
];
|
|
934
947
|
};
|
|
935
948
|
let st = !0;
|
|
936
|
-
const Dn = () => st, [rt, ot] =
|
|
949
|
+
const Dn = () => st, [rt, ot] = ye && window.addEventListener ? [
|
|
937
950
|
window.addEventListener.bind(window),
|
|
938
951
|
window.removeEventListener.bind(window)
|
|
939
952
|
] : [
|
|
@@ -959,27 +972,27 @@ const Dn = () => st, [rt, ot] = _e && window.addEventListener ? [
|
|
|
959
972
|
}, kn = {
|
|
960
973
|
initFocus: An,
|
|
961
974
|
initReconnect: xn
|
|
962
|
-
}, xt = !we.useId, ve = !
|
|
975
|
+
}, xt = !we.useId, ve = !ye || Ln, jn = (e) => In() ? window.requestAnimationFrame(e) : setTimeout(e, 1), Pe = ve ? Ft : fn, $e = typeof navigator != "undefined" && navigator.connection, Mt = !ve && $e && ([
|
|
963
976
|
"slow-2g",
|
|
964
977
|
"2g"
|
|
965
|
-
].includes($e.effectiveType) || $e.saveData),
|
|
978
|
+
].includes($e.effectiveType) || $e.saveData), Le = /* @__PURE__ */ new WeakMap(), Wn = (e) => tt.prototype.toString.call(e), Je = (e, n) => e === `[object ${n}]`;
|
|
966
979
|
let Fn = 0;
|
|
967
980
|
const at = (e) => {
|
|
968
|
-
const n = typeof e, t = Wn(e), s =
|
|
981
|
+
const n = typeof e, t = Wn(e), s = Je(t, "Date"), i = Je(t, "RegExp"), c = Je(t, "Object");
|
|
969
982
|
let a, l;
|
|
970
983
|
if (tt(e) === e && !s && !i) {
|
|
971
|
-
if (a =
|
|
972
|
-
if (a = ++Fn + "~",
|
|
984
|
+
if (a = Le.get(e), a) return a;
|
|
985
|
+
if (a = ++Fn + "~", Le.set(e, a), Array.isArray(e)) {
|
|
973
986
|
for (a = "@", l = 0; l < e.length; l++)
|
|
974
987
|
a += at(e[l]) + ",";
|
|
975
|
-
|
|
988
|
+
Le.set(e, a);
|
|
976
989
|
}
|
|
977
990
|
if (c) {
|
|
978
991
|
a = "#";
|
|
979
992
|
const r = tt.keys(e).sort();
|
|
980
993
|
for (; !v(l = r.pop()); )
|
|
981
994
|
v(e[l]) || (a += l + ":" + at(e[l]) + ",");
|
|
982
|
-
|
|
995
|
+
Le.set(e, a);
|
|
983
996
|
}
|
|
984
997
|
} else
|
|
985
998
|
a = s ? e.toJSON() : n == "symbol" ? e.toString() : n == "string" ? JSON.stringify(e) : "" + e;
|
|
@@ -1012,30 +1025,30 @@ function Qt(...e) {
|
|
|
1012
1025
|
let r = c.optimisticData;
|
|
1013
1026
|
const o = (m) => typeof l == "function" ? l(m) : l !== !1, f = c.throwOnError;
|
|
1014
1027
|
if (q(t)) {
|
|
1015
|
-
const m = t, h = [],
|
|
1016
|
-
for (const d of
|
|
1028
|
+
const m = t, h = [], g = n.keys();
|
|
1029
|
+
for (const d of g)
|
|
1017
1030
|
// Skip the special useSWRInfinite and useSWRSubscription keys.
|
|
1018
1031
|
!/^\$(inf|sub)\$/.test(d) && m(n.get(d)._k) && h.push(d);
|
|
1019
|
-
return Promise.all(h.map(
|
|
1032
|
+
return Promise.all(h.map(p));
|
|
1020
1033
|
}
|
|
1021
|
-
return
|
|
1022
|
-
function
|
|
1034
|
+
return p(t);
|
|
1035
|
+
function p(m) {
|
|
1023
1036
|
return V(this, null, function* () {
|
|
1024
1037
|
const [h] = dt(m);
|
|
1025
1038
|
if (!h) return;
|
|
1026
|
-
const [
|
|
1027
|
-
const k =
|
|
1028
|
-
return (q(c.revalidate) ? c.revalidate(
|
|
1039
|
+
const [g, d] = Xt(n, h), [E, u, w, O] = K.get(n), x = () => {
|
|
1040
|
+
const k = E[h];
|
|
1041
|
+
return (q(c.revalidate) ? c.revalidate(g().data, m) : c.revalidate !== !1) && (delete w[h], delete O[h], k && k[0]) ? k[0](zt).then(() => g().data) : g().data;
|
|
1029
1042
|
};
|
|
1030
1043
|
if (e.length < 3)
|
|
1031
1044
|
return x();
|
|
1032
|
-
let b = s, D,
|
|
1033
|
-
const
|
|
1045
|
+
let b = s, D, J = !1;
|
|
1046
|
+
const T = it();
|
|
1034
1047
|
u[h] = [
|
|
1035
|
-
|
|
1048
|
+
T,
|
|
1036
1049
|
0
|
|
1037
1050
|
];
|
|
1038
|
-
const ne = !v(r),
|
|
1051
|
+
const ne = !v(r), U = g(), se = U.data, _e = U._c, Z = v(_e) ? se : _e;
|
|
1039
1052
|
if (ne && (r = q(r) ? r(Z, se) : r, d({
|
|
1040
1053
|
data: r,
|
|
1041
1054
|
_c: Z
|
|
@@ -1043,19 +1056,19 @@ function Qt(...e) {
|
|
|
1043
1056
|
try {
|
|
1044
1057
|
b = b(Z);
|
|
1045
1058
|
} catch (k) {
|
|
1046
|
-
D = k,
|
|
1059
|
+
D = k, J = !0;
|
|
1047
1060
|
}
|
|
1048
1061
|
if (b && Yt(b))
|
|
1049
1062
|
if (b = yield b.catch((k) => {
|
|
1050
|
-
D = k,
|
|
1051
|
-
}),
|
|
1052
|
-
if (
|
|
1063
|
+
D = k, J = !0;
|
|
1064
|
+
}), T !== u[h][0]) {
|
|
1065
|
+
if (J) throw D;
|
|
1053
1066
|
return b;
|
|
1054
|
-
} else
|
|
1067
|
+
} else J && ne && o(D) && (a = !0, d({
|
|
1055
1068
|
data: Z,
|
|
1056
1069
|
_c: M
|
|
1057
1070
|
}));
|
|
1058
|
-
if (a && !
|
|
1071
|
+
if (a && !J)
|
|
1059
1072
|
if (q(a)) {
|
|
1060
1073
|
const k = a(b, Z);
|
|
1061
1074
|
d({
|
|
@@ -1073,7 +1086,7 @@ function Qt(...e) {
|
|
|
1073
1086
|
d({
|
|
1074
1087
|
_c: M
|
|
1075
1088
|
});
|
|
1076
|
-
}),
|
|
1089
|
+
}), J) {
|
|
1077
1090
|
if (f) throw D;
|
|
1078
1091
|
return;
|
|
1079
1092
|
}
|
|
@@ -1089,15 +1102,15 @@ const kt = (e, n) => {
|
|
|
1089
1102
|
if (!K.has(e)) {
|
|
1090
1103
|
const t = Q(kn, n), s = /* @__PURE__ */ Object.create(null), i = Qt.bind(M, e);
|
|
1091
1104
|
let c = X;
|
|
1092
|
-
const a = /* @__PURE__ */ Object.create(null), l = (f,
|
|
1105
|
+
const a = /* @__PURE__ */ Object.create(null), l = (f, p) => {
|
|
1093
1106
|
const m = a[f] || [];
|
|
1094
|
-
return a[f] = m, m.push(
|
|
1095
|
-
}, r = (f,
|
|
1096
|
-
e.set(f,
|
|
1107
|
+
return a[f] = m, m.push(p), () => m.splice(m.indexOf(p), 1);
|
|
1108
|
+
}, r = (f, p, m) => {
|
|
1109
|
+
e.set(f, p);
|
|
1097
1110
|
const h = a[f];
|
|
1098
1111
|
if (h)
|
|
1099
|
-
for (const
|
|
1100
|
-
p
|
|
1112
|
+
for (const g of h)
|
|
1113
|
+
g(p, m);
|
|
1101
1114
|
}, o = () => {
|
|
1102
1115
|
if (!K.has(e) && (K.set(e, [
|
|
1103
1116
|
s,
|
|
@@ -1108,9 +1121,9 @@ const kt = (e, n) => {
|
|
|
1108
1121
|
r,
|
|
1109
1122
|
l
|
|
1110
1123
|
]), !ve)) {
|
|
1111
|
-
const f = t.initFocus(setTimeout.bind(M, kt.bind(M, s, Ht))),
|
|
1124
|
+
const f = t.initFocus(setTimeout.bind(M, kt.bind(M, s, Ht))), p = t.initReconnect(setTimeout.bind(M, kt.bind(M, s, Kt)));
|
|
1112
1125
|
c = () => {
|
|
1113
|
-
f && f(),
|
|
1126
|
+
f && f(), p && p(), K.delete(e);
|
|
1114
1127
|
};
|
|
1115
1128
|
}
|
|
1116
1129
|
};
|
|
@@ -1128,7 +1141,7 @@ const kt = (e, n) => {
|
|
|
1128
1141
|
}, $n = (e, n, t, s, i) => {
|
|
1129
1142
|
const c = t.errorRetryCount, a = i.retryCount, l = ~~((Math.random() + 0.5) * (1 << (a < 8 ? a : 8))) * t.errorRetryInterval;
|
|
1130
1143
|
!v(c) && a > c || setTimeout(s, l, i);
|
|
1131
|
-
},
|
|
1144
|
+
}, Jn = et, [Zt, Un] = Pn(/* @__PURE__ */ new Map()), qn = Q(
|
|
1132
1145
|
{
|
|
1133
1146
|
// events
|
|
1134
1147
|
onLoadingSlow: X,
|
|
@@ -1147,10 +1160,10 @@ const kt = (e, n) => {
|
|
|
1147
1160
|
dedupingInterval: 2 * 1e3,
|
|
1148
1161
|
loadingTimeout: Mt ? 5e3 : 3e3,
|
|
1149
1162
|
// providers
|
|
1150
|
-
compare:
|
|
1163
|
+
compare: Jn,
|
|
1151
1164
|
isPaused: () => !1,
|
|
1152
1165
|
cache: Zt,
|
|
1153
|
-
mutate:
|
|
1166
|
+
mutate: Un,
|
|
1154
1167
|
fallback: {}
|
|
1155
1168
|
},
|
|
1156
1169
|
// use web preset by default
|
|
@@ -1162,7 +1175,7 @@ const kt = (e, n) => {
|
|
|
1162
1175
|
s && c && (t.use = s.concat(c)), i && a && (t.fallback = Q(i, a));
|
|
1163
1176
|
}
|
|
1164
1177
|
return t;
|
|
1165
|
-
}, Bn = Wt({}), Hn = "$inf$", en =
|
|
1178
|
+
}, Bn = Wt({}), Hn = "$inf$", en = ye && window.__SWR_DEVTOOLS_USE__, Kn = en ? window.__SWR_DEVTOOLS_USE__ : [], zn = () => {
|
|
1166
1179
|
en && (window.__SWR_DEVTOOLS_REACT__ = we);
|
|
1167
1180
|
}, Yn = (e) => q(e[1]) ? [
|
|
1168
1181
|
e[0],
|
|
@@ -1187,8 +1200,8 @@ const kt = (e, n) => {
|
|
|
1187
1200
|
const s = Xn(), [i, c, a] = Yn(t), l = Gn(s, a);
|
|
1188
1201
|
let r = e;
|
|
1189
1202
|
const { use: o } = l, f = (o || []).concat(Zn);
|
|
1190
|
-
for (let
|
|
1191
|
-
r = f[
|
|
1203
|
+
for (let p = f.length; p--; )
|
|
1204
|
+
r = f[p](r);
|
|
1192
1205
|
return r(i, c || l.fetcher || null, l);
|
|
1193
1206
|
}, ts = (e, n, t) => {
|
|
1194
1207
|
const s = n[e] || (n[e] = []);
|
|
@@ -1198,7 +1211,7 @@ const kt = (e, n) => {
|
|
|
1198
1211
|
};
|
|
1199
1212
|
};
|
|
1200
1213
|
zn();
|
|
1201
|
-
const
|
|
1214
|
+
const Ue = we.use || // This extra generic is to avoid TypeScript mixing up the generic and JSX sytax
|
|
1202
1215
|
// and emitting an error.
|
|
1203
1216
|
// We assume that this is only for the `use(thenable)` case, not `use(context)`.
|
|
1204
1217
|
// https://github.com/facebook/react/blob/aed00dacfb79d17c53218404c52b1c7aa59c4a89/packages/react-server/src/ReactFizzThenable.js#L45
|
|
@@ -1220,28 +1233,28 @@ const Je = we.use || // This extra generic is to avoid TypeScript mixing up the
|
|
|
1220
1233
|
}), qe = {
|
|
1221
1234
|
dedupe: !0
|
|
1222
1235
|
}, jt = Promise.resolve(M), ns = (e, n, t) => {
|
|
1223
|
-
const { cache: s, compare: i, suspense: c, fallbackData: a, revalidateOnMount: l, revalidateIfStale: r, refreshInterval: o, refreshWhenHidden: f, refreshWhenOffline:
|
|
1236
|
+
const { cache: s, compare: i, suspense: c, fallbackData: a, revalidateOnMount: l, revalidateIfStale: r, refreshInterval: o, refreshWhenHidden: f, refreshWhenOffline: p, keepPreviousData: m } = t, [h, g, d, E] = K.get(s), [u, w] = dt(e), O = z(!1), x = z(!1), b = z(u), D = z(n), J = z(t), T = () => J.current, ne = () => T().isVisible() && T().isOnline(), [U, se, _e, Z] = Xt(s, u), k = z({}).current, fe = v(a) ? v(t.fallback) ? M : t.fallback[u] : a, ft = (y, C) => {
|
|
1224
1237
|
for (const N in k) {
|
|
1225
|
-
const
|
|
1226
|
-
if (
|
|
1227
|
-
if (!i(_
|
|
1238
|
+
const _ = N;
|
|
1239
|
+
if (_ === "data") {
|
|
1240
|
+
if (!i(y[_], C[_]) && (!v(y[_]) || !i(be, C[_])))
|
|
1228
1241
|
return !1;
|
|
1229
|
-
} else if (
|
|
1242
|
+
} else if (C[_] !== y[_])
|
|
1230
1243
|
return !1;
|
|
1231
1244
|
}
|
|
1232
1245
|
return !0;
|
|
1233
1246
|
}, ht = Pt(() => {
|
|
1234
|
-
const
|
|
1247
|
+
const y = !u || !n ? !1 : v(l) ? T().isPaused() || c ? !1 : r !== !1 : l, C = (j) => {
|
|
1235
1248
|
const G = Q(j);
|
|
1236
|
-
return delete G._k,
|
|
1249
|
+
return delete G._k, y ? L({
|
|
1237
1250
|
isValidating: !0,
|
|
1238
1251
|
isLoading: !0
|
|
1239
1252
|
}, G) : G;
|
|
1240
|
-
}, N =
|
|
1253
|
+
}, N = U(), _ = Z(), P = C(N), ae = N === _ ? P : C(_);
|
|
1241
1254
|
let A = P;
|
|
1242
1255
|
return [
|
|
1243
1256
|
() => {
|
|
1244
|
-
const j =
|
|
1257
|
+
const j = C(U());
|
|
1245
1258
|
return ft(j, A) ? (A.data = j.data, A.isLoading = j.isLoading, A.isValidating = j.isValidating, A.error = j.error, A) : (A = j, j);
|
|
1246
1259
|
},
|
|
1247
1260
|
() => ae
|
|
@@ -1249,56 +1262,56 @@ const Je = we.use || // This extra generic is to avoid TypeScript mixing up the
|
|
|
1249
1262
|
}, [
|
|
1250
1263
|
s,
|
|
1251
1264
|
u
|
|
1252
|
-
]), re =
|
|
1253
|
-
(
|
|
1254
|
-
ft(N,
|
|
1265
|
+
]), re = Tn.useSyncExternalStore(Ie(
|
|
1266
|
+
(y) => _e(u, (C, N) => {
|
|
1267
|
+
ft(N, C) || y();
|
|
1255
1268
|
}),
|
|
1256
1269
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1257
1270
|
[
|
|
1258
1271
|
s,
|
|
1259
1272
|
u
|
|
1260
1273
|
]
|
|
1261
|
-
), ht[0], ht[1]), pt = !O.current, tn = h[u] && h[u].length > 0, oe = re.data, ee = v(oe) ? fe && Yt(fe) ?
|
|
1262
|
-
(
|
|
1263
|
-
const
|
|
1264
|
-
if (!u || !
|
|
1274
|
+
), ht[0], ht[1]), pt = !O.current, tn = h[u] && h[u].length > 0, oe = re.data, ee = v(oe) ? fe && Yt(fe) ? Ue(fe) : fe : oe, Oe = re.error, Ae = z(ee), be = m ? v(oe) ? v(Ae.current) ? ee : Ae.current : oe : ee, gt = tn && !v(Oe) ? !1 : pt && !v(l) ? l : T().isPaused() ? !1 : c ? v(ee) ? !1 : r : v(ee) || r, Et = !!(u && n && pt && gt), nn = v(re.isValidating) ? Et : re.isValidating, sn = v(re.isLoading) ? Et : re.isLoading, he = Ie(
|
|
1275
|
+
(y) => V(null, null, function* () {
|
|
1276
|
+
const C = D.current;
|
|
1277
|
+
if (!u || !C || x.current || T().isPaused())
|
|
1265
1278
|
return !1;
|
|
1266
|
-
let N,
|
|
1267
|
-
const ae =
|
|
1279
|
+
let N, _, P = !0;
|
|
1280
|
+
const ae = y || {}, A = !d[u] || !ae.dedupe, j = () => xt ? !x.current && u === b.current && O.current : u === b.current, G = {
|
|
1268
1281
|
isValidating: !1,
|
|
1269
1282
|
isLoading: !1
|
|
1270
1283
|
}, St = () => {
|
|
1271
1284
|
se(G);
|
|
1272
1285
|
}, vt = () => {
|
|
1273
1286
|
const F = d[u];
|
|
1274
|
-
F && F[1] ===
|
|
1287
|
+
F && F[1] === _ && delete d[u];
|
|
1275
1288
|
}, wt = {
|
|
1276
1289
|
isValidating: !0
|
|
1277
1290
|
};
|
|
1278
|
-
v(
|
|
1291
|
+
v(U().data) && (wt.isLoading = !0);
|
|
1279
1292
|
try {
|
|
1280
|
-
if (A && (se(wt), t.loadingTimeout && v(
|
|
1281
|
-
P && j() &&
|
|
1293
|
+
if (A && (se(wt), t.loadingTimeout && v(U().data) && setTimeout(() => {
|
|
1294
|
+
P && j() && T().onLoadingSlow(u, t);
|
|
1282
1295
|
}, t.loadingTimeout), d[u] = [
|
|
1283
|
-
|
|
1296
|
+
C(w),
|
|
1284
1297
|
it()
|
|
1285
|
-
]), [N,
|
|
1286
|
-
return A && j() &&
|
|
1298
|
+
]), [N, _] = d[u], N = yield N, A && setTimeout(vt, t.dedupingInterval), !d[u] || d[u][1] !== _)
|
|
1299
|
+
return A && j() && T().onDiscarded(u), !1;
|
|
1287
1300
|
G.error = M;
|
|
1288
|
-
const F =
|
|
1301
|
+
const F = g[u];
|
|
1289
1302
|
if (!v(F) && // case 1
|
|
1290
|
-
(
|
|
1291
|
-
|
|
1303
|
+
(_ <= F[0] || // case 2
|
|
1304
|
+
_ <= F[1] || // case 3
|
|
1292
1305
|
F[1] === 0))
|
|
1293
|
-
return St(), A && j() &&
|
|
1294
|
-
const B =
|
|
1295
|
-
G.data = i(B, N) ? B : N, A && j() &&
|
|
1306
|
+
return St(), A && j() && T().onDiscarded(u), !1;
|
|
1307
|
+
const B = U().data;
|
|
1308
|
+
G.data = i(B, N) ? B : N, A && j() && T().onSuccess(N, u, t);
|
|
1296
1309
|
} catch (F) {
|
|
1297
1310
|
vt();
|
|
1298
|
-
const B =
|
|
1299
|
-
B.isPaused() || (G.error = F, A && j() && (B.onError(F, u, B), (
|
|
1300
|
-
const
|
|
1301
|
-
|
|
1311
|
+
const B = T(), { shouldRetryOnError: xe } = B;
|
|
1312
|
+
B.isPaused() || (G.error = F, A && j() && (B.onError(F, u, B), (xe === !0 || q(xe) && xe(F)) && (!T().revalidateOnFocus || !T().revalidateOnReconnect || ne()) && B.onErrorRetry(F, u, B, (rn) => {
|
|
1313
|
+
const Me = h[u];
|
|
1314
|
+
Me && Me[0] && Me[0](Nt, rn);
|
|
1302
1315
|
}, {
|
|
1303
1316
|
retryCount: (ae.retryCount || 0) + 1,
|
|
1304
1317
|
dedupe: !0
|
|
@@ -1321,25 +1334,25 @@ const Je = we.use || // This extra generic is to avoid TypeScript mixing up the
|
|
|
1321
1334
|
u,
|
|
1322
1335
|
s
|
|
1323
1336
|
]
|
|
1324
|
-
), mt =
|
|
1337
|
+
), mt = Ie(
|
|
1325
1338
|
// Use callback to make sure `keyRef.current` returns latest result every time
|
|
1326
|
-
(...
|
|
1339
|
+
(...y) => Qt(s, b.current, ...y),
|
|
1327
1340
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1328
1341
|
[]
|
|
1329
1342
|
);
|
|
1330
1343
|
if (Pe(() => {
|
|
1331
|
-
D.current = n,
|
|
1344
|
+
D.current = n, J.current = t, v(oe) || (Ae.current = oe);
|
|
1332
1345
|
}), Pe(() => {
|
|
1333
1346
|
if (!u) return;
|
|
1334
|
-
const
|
|
1335
|
-
let
|
|
1336
|
-
|
|
1337
|
-
const
|
|
1347
|
+
const y = he.bind(M, qe);
|
|
1348
|
+
let C = 0;
|
|
1349
|
+
T().revalidateOnFocus && (C = Date.now() + T().focusThrottleInterval);
|
|
1350
|
+
const _ = ts(u, h, (P, ae = {}) => {
|
|
1338
1351
|
if (P == Ht) {
|
|
1339
1352
|
const A = Date.now();
|
|
1340
|
-
|
|
1353
|
+
T().revalidateOnFocus && A > C && ne() && (C = A + T().focusThrottleInterval, y());
|
|
1341
1354
|
} else if (P == Kt)
|
|
1342
|
-
|
|
1355
|
+
T().revalidateOnReconnect && ne() && y();
|
|
1343
1356
|
else {
|
|
1344
1357
|
if (P == zt)
|
|
1345
1358
|
return he();
|
|
@@ -1349,38 +1362,38 @@ const Je = we.use || // This extra generic is to avoid TypeScript mixing up the
|
|
|
1349
1362
|
});
|
|
1350
1363
|
return x.current = !1, b.current = u, O.current = !0, se({
|
|
1351
1364
|
_k: w
|
|
1352
|
-
}), gt && (d[u] || (v(ee) || ve ?
|
|
1353
|
-
x.current = !0,
|
|
1365
|
+
}), gt && (d[u] || (v(ee) || ve ? y() : jn(y))), () => {
|
|
1366
|
+
x.current = !0, _();
|
|
1354
1367
|
};
|
|
1355
1368
|
}, [
|
|
1356
1369
|
u
|
|
1357
1370
|
]), Pe(() => {
|
|
1358
|
-
let
|
|
1359
|
-
function
|
|
1360
|
-
const
|
|
1361
|
-
|
|
1371
|
+
let y;
|
|
1372
|
+
function C() {
|
|
1373
|
+
const _ = q(o) ? o(U().data) : o;
|
|
1374
|
+
_ && y !== -1 && (y = setTimeout(N, _));
|
|
1362
1375
|
}
|
|
1363
1376
|
function N() {
|
|
1364
|
-
!
|
|
1377
|
+
!U().error && (f || T().isVisible()) && (p || T().isOnline()) ? he(qe).then(C) : C();
|
|
1365
1378
|
}
|
|
1366
|
-
return
|
|
1367
|
-
|
|
1379
|
+
return C(), () => {
|
|
1380
|
+
y && (clearTimeout(y), y = -1);
|
|
1368
1381
|
};
|
|
1369
1382
|
}, [
|
|
1370
1383
|
o,
|
|
1371
1384
|
f,
|
|
1372
|
-
|
|
1385
|
+
p,
|
|
1373
1386
|
u
|
|
1374
1387
|
]), hn(be), c) {
|
|
1375
|
-
const
|
|
1376
|
-
if (!xt && ve &&
|
|
1388
|
+
const y = u && v(ee);
|
|
1389
|
+
if (!xt && ve && y)
|
|
1377
1390
|
throw new Error("Fallback data is required when using Suspense in SSR.");
|
|
1378
|
-
|
|
1379
|
-
const
|
|
1380
|
-
if (
|
|
1391
|
+
y && (D.current = n, J.current = t, x.current = !1);
|
|
1392
|
+
const C = E[u], N = !v(C) && y ? mt(C) : jt;
|
|
1393
|
+
if (Ue(N), !v(Oe) && y)
|
|
1381
1394
|
throw Oe;
|
|
1382
|
-
const
|
|
1383
|
-
!v(be) &&
|
|
1395
|
+
const _ = y ? he(qe) : jt;
|
|
1396
|
+
!v(be) && y && (_.status = "fulfilled", _.value = !0), Ue(_);
|
|
1384
1397
|
}
|
|
1385
1398
|
return {
|
|
1386
1399
|
mutate: mt,
|
|
@@ -1424,9 +1437,9 @@ const Je = we.use || // This extra generic is to avoid TypeScript mixing up the
|
|
|
1424
1437
|
export {
|
|
1425
1438
|
Bt as AnimaSdkContext,
|
|
1426
1439
|
us as AnimaSdkProvider,
|
|
1427
|
-
|
|
1440
|
+
yn as AttachJobError,
|
|
1428
1441
|
wn as CreateJobError,
|
|
1429
|
-
|
|
1442
|
+
_n as UnknownCodegenError,
|
|
1430
1443
|
ls as useAnimaCodegen,
|
|
1431
1444
|
On as useAnimaSDK,
|
|
1432
1445
|
ds as useFigmaFile
|