@figma-vars/hooks 3.0.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +50 -0
  2. package/dist/api/fetcher.d.ts +32 -1
  3. package/dist/api/fetcher.d.ts.map +1 -1
  4. package/dist/api/index.d.ts +2 -0
  5. package/dist/api/index.d.ts.map +1 -1
  6. package/dist/api/mutator.d.ts +27 -1
  7. package/dist/api/mutator.d.ts.map +1 -1
  8. package/dist/contexts/FigmaVarsProvider.d.ts +2 -0
  9. package/dist/contexts/FigmaVarsProvider.d.ts.map +1 -1
  10. package/dist/core.cjs +1 -1
  11. package/dist/core.mjs +1 -1
  12. package/dist/hooks/index.d.ts +45 -0
  13. package/dist/hooks/index.d.ts.map +1 -1
  14. package/dist/hooks/useCollectionById.d.ts +31 -0
  15. package/dist/hooks/useCollectionById.d.ts.map +1 -0
  16. package/dist/hooks/useInvalidateVariables.d.ts +3 -0
  17. package/dist/hooks/useInvalidateVariables.d.ts.map +1 -1
  18. package/dist/hooks/useModesByCollection.d.ts +34 -0
  19. package/dist/hooks/useModesByCollection.d.ts.map +1 -0
  20. package/dist/hooks/usePublishedVariables.d.ts.map +1 -1
  21. package/dist/hooks/useVariableById.d.ts +31 -0
  22. package/dist/hooks/useVariableById.d.ts.map +1 -0
  23. package/dist/hooks/useVariables.d.ts.map +1 -1
  24. package/dist/index-5ZyKWuYv.cjs +1 -0
  25. package/dist/index-ClHLYVvu.js +142 -0
  26. package/dist/index.cjs +1 -1
  27. package/dist/index.mjs +250 -167
  28. package/dist/types/contexts.d.ts +1 -0
  29. package/dist/types/contexts.d.ts.map +1 -1
  30. package/dist/types/figma.d.ts +9 -1
  31. package/dist/types/figma.d.ts.map +1 -1
  32. package/dist/types/mutations.d.ts +14 -0
  33. package/dist/types/mutations.d.ts.map +1 -1
  34. package/dist/utils/errorHelpers.d.ts +46 -0
  35. package/dist/utils/errorHelpers.d.ts.map +1 -1
  36. package/dist/utils/index.d.ts +2 -1
  37. package/dist/utils/index.d.ts.map +1 -1
  38. package/dist/utils/swrKeys.d.ts +24 -0
  39. package/dist/utils/swrKeys.d.ts.map +1 -0
  40. package/dist/utils/typeGuards.d.ts +50 -0
  41. package/dist/utils/typeGuards.d.ts.map +1 -0
  42. package/package.json +1 -1
  43. package/dist/index-BIUpDTdr.cjs +0 -1
  44. package/dist/index-Cd4HQQHO.js +0 -94
package/dist/index.mjs CHANGED
@@ -1,131 +1,212 @@
1
- import { jsx as K } from "react/jsx-runtime";
2
- import { createContext as L, useMemo as m, useContext as T, useReducer as V, useRef as w, useEffect as k, useCallback as _ } from "react";
3
- import A, { useSWRConfig as S } from "swr";
4
- import { f as I, E as v, a as p, m as E, F as b, b as h, c as P } from "./index-Cd4HQQHO.js";
5
- import { d as te } from "./index-Cd4HQQHO.js";
6
- const g = L(void 0);
7
- let R = 0;
8
- const G = ({
1
+ import { jsx as O } from "react/jsx-runtime";
2
+ import { createContext as P, useId as _, useMemo as p, useContext as x, useReducer as L, useRef as m, useEffect as g, useCallback as T } from "react";
3
+ import V, { useSWRConfig as j } from "swr";
4
+ import { f as A, E as b, a as E, m as y, F as h, b as D } from "./index-ClHLYVvu.js";
5
+ import { c as ie } from "./index-ClHLYVvu.js";
6
+ const C = P(void 0);
7
+ function S(e) {
8
+ if (typeof e != "object" || e === null)
9
+ return !1;
10
+ const r = e;
11
+ if (typeof r.meta != "object" || r.meta === null)
12
+ return !1;
13
+ const t = r.meta;
14
+ return !(typeof t.variableCollections != "object" || t.variableCollections === null || typeof t.variables != "object" || t.variables === null);
15
+ }
16
+ function I(e) {
17
+ if (S(e))
18
+ return e;
19
+ }
20
+ const W = ({
9
21
  children: e,
10
- token: t,
11
- fileKey: r,
22
+ token: r,
23
+ fileKey: t,
12
24
  fallbackFile: o,
13
25
  swrConfig: n
14
26
  }) => {
15
- const s = m(() => (R += 1, `figma-vars-provider-${R}`), []), c = m(() => {
16
- const a = {
17
- token: t,
18
- fileKey: r,
19
- providerId: s,
27
+ const a = _(), c = p(() => `figma-vars-provider-${a}`, [a]), u = p(() => {
28
+ if (o) {
29
+ if (typeof o == "object") {
30
+ const s = I(o);
31
+ if (s)
32
+ return s;
33
+ process.env.NODE_ENV !== "production" && console.warn(
34
+ "[figma-vars-hooks] fallbackFile object does not match expected Figma Variables API response structure. Expected { meta: { variableCollections: {...}, variables: {...} } }"
35
+ );
36
+ return;
37
+ }
38
+ if (typeof o == "string")
39
+ try {
40
+ const s = JSON.parse(o), l = I(s);
41
+ if (l)
42
+ return l;
43
+ process.env.NODE_ENV !== "production" && console.warn(
44
+ "[figma-vars-hooks] Parsed fallbackFile JSON does not match expected Figma Variables API response structure. Expected { meta: { variableCollections: {...}, variables: {...} } }"
45
+ );
46
+ return;
47
+ } catch (s) {
48
+ process.env.NODE_ENV !== "production" && console.error(
49
+ `[figma-vars-hooks] Failed to parse fallbackFile JSON: ${s instanceof Error ? s.message : "Unknown error"}`
50
+ );
51
+ return;
52
+ }
53
+ }
54
+ }, [o]), i = p(() => {
55
+ const s = {
56
+ token: r,
57
+ fileKey: t,
58
+ providerId: c,
20
59
  ...n !== void 0 && { swrConfig: n }
21
60
  };
22
- return o === void 0 ? a : { ...a, fallbackFile: o };
23
- }, [t, r, o, s, n]);
24
- return /* @__PURE__ */ K(g.Provider, { value: c, children: e });
25
- }, u = () => {
26
- const e = T(g);
61
+ return o === void 0 ? s : {
62
+ ...s,
63
+ fallbackFile: o,
64
+ // Keep for backward compatibility
65
+ parsedFallbackFile: u
66
+ // Pre-parsed version for hooks to use
67
+ };
68
+ }, [r, t, o, u, c, n]);
69
+ return /* @__PURE__ */ O(C.Provider, { value: i, children: e });
70
+ }, d = () => {
71
+ const e = x(C);
27
72
  if (e === void 0)
28
73
  throw new Error(
29
74
  "useFigmaTokenContext must be used within a FigmaVarsProvider"
30
75
  );
31
76
  return e;
32
- }, C = () => {
33
- const { token: e, fileKey: t, fallbackFile: r, providerId: o, swrConfig: n } = u(), s = t ? `https://api.figma.com/v1/files/${t}/variables/local` : null, l = !!(e && s) ? [s, e] : !!r ? [`fallback-${o ?? "default"}`, "fallback"] : null;
34
- return A(
35
- l,
36
- async (...i) => {
37
- const [f, d] = Array.isArray(i[0]) ? i[0] : [i[0], i[1]];
38
- if (r)
39
- return typeof r == "string" ? JSON.parse(r) : r;
40
- if (!f || !d)
77
+ };
78
+ function N(e) {
79
+ const { fileKey: r, token: t, providerId: o, hasFallback: n } = e;
80
+ return !!(t && r) && t && r ? [`https://api.figma.com/v1/files/${r}/variables/local`, t] : n ? [`fallback-${o ?? "default"}`, "fallback"] : null;
81
+ }
82
+ function B(e) {
83
+ const { fileKey: r, token: t, providerId: o, hasFallback: n } = e;
84
+ return !!(t && r) && t && r ? [`https://api.figma.com/v1/files/${r}/variables/published`, t] : n ? [`fallback-${o ?? "default"}`, "fallback"] : null;
85
+ }
86
+ function F(e) {
87
+ const { fileKey: r, token: t, providerId: o, hasFallback: n } = e, a = [];
88
+ return t && r && (a.push([
89
+ `https://api.figma.com/v1/files/${r}/variables/local`,
90
+ t
91
+ ]), a.push([
92
+ `https://api.figma.com/v1/files/${r}/variables/published`,
93
+ t
94
+ ])), n && o && a.push([`fallback-${o}`, "fallback"]), a;
95
+ }
96
+ const K = () => {
97
+ const {
98
+ token: e,
99
+ fileKey: r,
100
+ fallbackFile: t,
101
+ parsedFallbackFile: o,
102
+ providerId: n,
103
+ swrConfig: a
104
+ } = d(), u = N({
105
+ fileKey: r,
106
+ token: e,
107
+ providerId: n,
108
+ hasFallback: !!(t || o)
109
+ });
110
+ return V(
111
+ u,
112
+ async (...s) => {
113
+ if (o)
114
+ return o;
115
+ if (t && typeof t == "object")
116
+ return t;
117
+ const [l, f] = Array.isArray(s[0]) ? s[0] : [s[0], s[1]];
118
+ if (!l || !f)
41
119
  throw new Error("Missing URL or token for live API request");
42
- return I(f, d);
120
+ return A(l, f);
43
121
  },
44
- n
122
+ a
45
123
  );
46
- }, N = () => {
47
- const { data: e } = C(), t = m(
124
+ }, H = () => {
125
+ const { data: e } = K(), r = p(
48
126
  () => e != null && e.meta ? Object.values(e.meta.variableCollections) : [],
49
127
  [e]
50
- ), r = m(
128
+ ), t = p(
51
129
  () => e != null && e.meta ? e.meta.variableCollections : {},
52
130
  [e]
53
131
  );
54
132
  return {
55
- collections: t,
56
- collectionsById: r
133
+ collections: r,
134
+ collectionsById: t
57
135
  };
58
- }, j = () => {
59
- const { data: e } = C();
60
- return m(() => {
61
- const t = [], r = {}, o = {};
136
+ }, Y = () => {
137
+ const { data: e } = K();
138
+ return p(() => {
139
+ const r = [], t = {}, o = {};
62
140
  if (e != null && e.meta)
63
141
  for (const n of Object.values(
64
142
  e.meta.variableCollections
65
143
  )) {
66
- t.push(...n.modes), r[n.id] = n.modes;
67
- for (const s of n.modes)
68
- o[s.modeId] = s;
144
+ r.push(...n.modes), t[n.id] = n.modes;
145
+ for (const a of n.modes)
146
+ o[a.modeId] = a;
69
147
  }
70
148
  return {
71
- modes: t,
72
- modesByCollectionId: r,
149
+ modes: r,
150
+ modesByCollectionId: t,
73
151
  modesById: o
74
152
  };
75
153
  }, [e]);
76
154
  };
77
- function B(e, t) {
78
- switch (t.type) {
155
+ function M(e, r) {
156
+ switch (r.type) {
79
157
  case "loading":
80
158
  return { ...e, status: "loading", error: null };
81
159
  case "success":
82
- return { ...e, status: "success", data: t.payload };
160
+ return { ...e, status: "success", data: r.payload };
83
161
  case "error":
84
- return { ...e, status: "error", error: t.payload };
162
+ return { ...e, status: "error", error: r.payload };
85
163
  default:
86
164
  return e;
87
165
  }
88
166
  }
89
- const y = (e) => {
90
- const t = {
167
+ const k = (e, r) => {
168
+ const { throwOnError: t = !1 } = {}, o = {
91
169
  status: "idle",
92
170
  data: null,
93
171
  error: null
94
- }, [r, o] = V(B, t), n = w(e), s = w(!0);
95
- return k(() => {
96
- n.current = e;
97
- }, [e]), k(() => (s.current = !0, () => {
98
- s.current = !1;
172
+ }, [n, a] = L(M, o), c = m(e), u = m({ throwOnError: t }), i = m(!0), s = m(0);
173
+ return g(() => {
174
+ c.current = e, u.current = { throwOnError: t };
175
+ }, [e, t]), g(() => (i.current = !0, () => {
176
+ i.current = !1;
99
177
  }), []), {
100
- mutate: _(
101
- async (a) => {
102
- if (s.current) {
103
- o({ type: "loading" });
104
- try {
105
- const l = await n.current(a);
106
- return s.current && o({ type: "success", payload: l }), l;
107
- } catch (l) {
108
- s.current && o({ type: "error", payload: l });
109
- return;
110
- }
178
+ mutate: T(
179
+ async (f) => {
180
+ if (!i.current)
181
+ return;
182
+ const w = ++s.current;
183
+ a({ type: "loading" });
184
+ try {
185
+ const v = await c.current(f);
186
+ return i.current && w === s.current && a({ type: "success", payload: v }), v;
187
+ } catch (v) {
188
+ const R = v;
189
+ if (i.current && w === s.current && a({ type: "error", payload: R }), u.current.throwOnError)
190
+ throw R;
191
+ return;
111
192
  }
112
193
  },
113
194
  []
114
- // Empty deps array - mutationFn is accessed via ref
195
+ // Empty deps array - mutationFn and options are accessed via refs
115
196
  ),
116
- ...r,
117
- isLoading: r.status === "loading",
118
- isSuccess: r.status === "success",
119
- isError: r.status === "error"
197
+ ...n,
198
+ isLoading: n.status === "loading",
199
+ isSuccess: n.status === "success",
200
+ isError: n.status === "error"
120
201
  };
121
- }, H = () => {
122
- const { token: e, fileKey: t } = u();
123
- return y(async (o) => {
202
+ }, z = () => {
203
+ const { token: e, fileKey: r } = d();
204
+ return k(async (o) => {
124
205
  if (!e)
125
- throw new Error(v);
126
- if (!t)
127
- throw new Error(p);
128
- return await E(b(t), e, "CREATE", {
206
+ throw new Error(b);
207
+ if (!r)
208
+ throw new Error(E);
209
+ return await y(h(r), e, "CREATE", {
129
210
  variables: [
130
211
  {
131
212
  action: "CREATE",
@@ -134,19 +215,19 @@ const y = (e) => {
134
215
  ]
135
216
  });
136
217
  });
137
- }, q = () => {
138
- const { token: e, fileKey: t } = u();
139
- return y(
218
+ }, X = () => {
219
+ const { token: e, fileKey: r } = d();
220
+ return k(
140
221
  async ({
141
222
  variableId: o,
142
223
  payload: n
143
224
  }) => {
144
225
  if (!e)
145
- throw new Error(v);
146
- if (!t)
147
- throw new Error(p);
148
- return await E(
149
- b(t),
226
+ throw new Error(b);
227
+ if (!r)
228
+ throw new Error(E);
229
+ return await y(
230
+ h(r),
150
231
  e,
151
232
  "UPDATE",
152
233
  {
@@ -161,14 +242,14 @@ const y = (e) => {
161
242
  );
162
243
  }
163
244
  );
164
- }, J = () => {
165
- const { token: e, fileKey: t } = u();
166
- return y(async (o) => {
245
+ }, Z = () => {
246
+ const { token: e, fileKey: r } = d();
247
+ return k(async (o) => {
167
248
  if (!e)
168
- throw new Error(v);
169
- if (!t)
170
- throw new Error(p);
171
- return await E(b(t), e, "DELETE", {
249
+ throw new Error(b);
250
+ if (!r)
251
+ throw new Error(E);
252
+ return await y(h(r), e, "DELETE", {
172
253
  variables: [
173
254
  {
174
255
  action: "DELETE",
@@ -177,98 +258,100 @@ const y = (e) => {
177
258
  ]
178
259
  });
179
260
  });
180
- }, Q = () => {
181
- const { token: e, fileKey: t } = u();
182
- return y(async (o) => {
261
+ }, ee = () => {
262
+ const { token: e, fileKey: r } = d();
263
+ return k(async (o) => {
183
264
  if (!e)
184
- throw new Error(v);
185
- if (!t)
186
- throw new Error(p);
187
- return await E(
188
- b(t),
265
+ throw new Error(b);
266
+ if (!r)
267
+ throw new Error(E);
268
+ return await y(
269
+ h(r),
189
270
  e,
190
271
  "UPDATE",
191
272
  o
192
273
  );
193
274
  });
194
- }, W = () => {
195
- const { mutate: e } = S(), { fileKey: t, providerId: r } = u();
275
+ }, re = () => {
276
+ const { mutate: e } = j(), { token: r, fileKey: t, fallbackFile: o, providerId: n } = d(), a = !!o;
196
277
  return {
197
278
  invalidate: () => {
198
- if (!t) return;
199
- const s = [
200
- `https://api.figma.com/v1/files/${t}/variables/local`,
201
- "token-placeholder"
202
- ];
203
- e(s);
204
- const c = [
205
- h(t),
206
- "token-placeholder"
207
- ];
208
- if (e(c), r) {
209
- const a = [`fallback-${r}`, "fallback"];
210
- e(a);
211
- }
279
+ const i = F({
280
+ fileKey: t,
281
+ token: r,
282
+ providerId: n,
283
+ hasFallback: a
284
+ });
285
+ for (const s of i)
286
+ e(s);
212
287
  },
213
288
  revalidate: () => {
214
- if (!t) return;
215
- const s = [
216
- `https://api.figma.com/v1/files/${t}/variables/local`,
217
- "token-placeholder"
218
- ];
219
- e(s, void 0, { revalidate: !0 });
220
- const c = [
221
- h(t),
222
- "token-placeholder"
223
- ];
224
- if (e(c, void 0, { revalidate: !0 }), r) {
225
- const a = [`fallback-${r}`, "fallback"];
226
- e(a, void 0, { revalidate: !0 });
227
- }
289
+ const i = F({
290
+ fileKey: t,
291
+ token: r,
292
+ providerId: n,
293
+ hasFallback: a
294
+ });
295
+ for (const s of i)
296
+ e(s, void 0, { revalidate: !0 });
228
297
  }
229
298
  };
230
- }, Y = () => {
231
- const { token: e, fileKey: t, fallbackFile: r, providerId: o, swrConfig: n } = u(), s = t ? h(t) : null, l = !!(e && s) ? [s, e] : !!r ? [`fallback-${o ?? "default"}`, "fallback"] : null;
232
- return A(
233
- l,
234
- async (...i) => {
235
- const [f, d] = Array.isArray(i[0]) ? i[0] : [i[0], i[1]];
236
- if (r)
237
- return typeof r == "string" ? JSON.parse(r) : r;
238
- if (!f || !d)
299
+ }, te = () => {
300
+ const {
301
+ token: e,
302
+ fileKey: r,
303
+ fallbackFile: t,
304
+ parsedFallbackFile: o,
305
+ providerId: n,
306
+ swrConfig: a
307
+ } = d(), u = B({
308
+ fileKey: r,
309
+ token: e,
310
+ providerId: n,
311
+ hasFallback: !!(t || o)
312
+ });
313
+ return V(
314
+ u,
315
+ async (...s) => {
316
+ if (o)
317
+ return o;
318
+ if (t && typeof t == "object")
319
+ return t;
320
+ const [l, f] = Array.isArray(s[0]) ? s[0] : [s[0], s[1]];
321
+ if (!l || !f)
239
322
  throw new Error("Missing URL or token for live API request");
240
- return I(f, d);
323
+ return A(l, f);
241
324
  },
242
- n
325
+ a
243
326
  );
244
327
  };
245
- function M(e) {
246
- return e instanceof P;
247
- }
248
328
  function U(e) {
249
- return M(e) ? e.statusCode : null;
329
+ return e instanceof D;
330
+ }
331
+ function $(e) {
332
+ return U(e) ? e.statusCode : null;
250
333
  }
251
- function z(e, t = "An error occurred") {
252
- return e instanceof Error ? e.message || t : typeof e == "string" ? e : t;
334
+ function oe(e, r = "An error occurred") {
335
+ return e instanceof Error ? e.message || r : typeof e == "string" ? e : r;
253
336
  }
254
- function X(e, t) {
255
- return U(e) === t;
337
+ function ne(e, r) {
338
+ return $(e) === r;
256
339
  }
257
340
  export {
258
- P as FigmaApiError,
259
- G as FigmaVarsProvider,
260
- te as filterVariables,
261
- z as getErrorMessage,
262
- U as getErrorStatus,
263
- X as hasErrorStatus,
264
- M as isFigmaApiError,
265
- Q as useBulkUpdateVariables,
266
- H as useCreateVariable,
267
- J as useDeleteVariable,
268
- W as useInvalidateVariables,
269
- Y as usePublishedVariables,
270
- q as useUpdateVariable,
271
- N as useVariableCollections,
272
- j as useVariableModes,
273
- C as useVariables
341
+ D as FigmaApiError,
342
+ W as FigmaVarsProvider,
343
+ ie as filterVariables,
344
+ oe as getErrorMessage,
345
+ $ as getErrorStatus,
346
+ ne as hasErrorStatus,
347
+ U as isFigmaApiError,
348
+ ee as useBulkUpdateVariables,
349
+ z as useCreateVariable,
350
+ Z as useDeleteVariable,
351
+ re as useInvalidateVariables,
352
+ te as usePublishedVariables,
353
+ X as useUpdateVariable,
354
+ H as useVariableCollections,
355
+ Y as useVariableModes,
356
+ K as useVariables
274
357
  };
@@ -41,6 +41,7 @@ export interface FigmaTokenContextType {
41
41
  /**
42
42
  * Optional fallback variable JSON file for offline or static use cases.
43
43
  * Allows FigmaVars to function without a live API request.
44
+ * @deprecated Use parsedFallbackFile instead. This is kept for backward compatibility.
44
45
  */
45
46
  fallbackFile?: LocalVariablesResponse | PublishedVariablesResponse | string;
46
47
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"contexts.d.ts","sourceRoot":"","sources":["../../src/types/contexts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,KAAK,EAAE,sBAAsB,EAAE,0BAA0B,EAAE,MAAM,OAAO,CAAA;AAE/E;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB;;;OAGG;IACH,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB;;;OAGG;IACH,YAAY,CAAC,EAAE,sBAAsB,GAAG,0BAA0B,GAAG,MAAM,CAAA;IAM3E;;;OAGG;IACH,SAAS,CAAC,EAAE,gBAAgB,GAAG,SAAS,CAAA;CACzC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAA;IACnB;;;OAGG;IACH,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB;;;OAGG;IACH,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB;;OAEG;IACH,YAAY,CAAC,EAAE,sBAAsB,GAAG,0BAA0B,GAAG,MAAM,CAAA;IAC3E;;;;;;;;;;;;;;;;;;OAkBG;IACH,SAAS,CAAC,EAAE,gBAAgB,CAAA;CAC7B"}
1
+ {"version":3,"file":"contexts.d.ts","sourceRoot":"","sources":["../../src/types/contexts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,KAAK,EAAE,sBAAsB,EAAE,0BAA0B,EAAE,MAAM,OAAO,CAAA;AAE/E;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB;;;OAGG;IACH,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB;;;;OAIG;IACH,YAAY,CAAC,EAAE,sBAAsB,GAAG,0BAA0B,GAAG,MAAM,CAAA;IAe3E;;;OAGG;IACH,SAAS,CAAC,EAAE,gBAAgB,GAAG,SAAS,CAAA;CACzC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAA;IACnB;;;OAGG;IACH,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB;;;OAGG;IACH,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB;;OAEG;IACH,YAAY,CAAC,EAAE,sBAAsB,GAAG,0BAA0B,GAAG,MAAM,CAAA;IAC3E;;;;;;;;;;;;;;;;;;OAkBG;IACH,SAAS,CAAC,EAAE,gBAAgB,CAAA;CAC7B"}
@@ -271,6 +271,8 @@ export interface FigmaError {
271
271
  * Extends the standard Error class to include HTTP status code information,
272
272
  * making it easier for consumers to handle different error types (401, 403, 404, 429, etc.).
273
273
  *
274
+ * For rate limit errors (429), includes retry-after information parsed from response headers.
275
+ *
274
276
  * @example
275
277
  * ```ts
276
278
  * import { FigmaApiError } from '@figma-vars/hooks';
@@ -283,6 +285,7 @@ export interface FigmaError {
283
285
  * // Handle authentication error
284
286
  * } else if (error.statusCode === 429) {
285
287
  * // Handle rate limit
288
+ * console.log(`Retry after ${error.retryAfter} seconds`);
286
289
  * }
287
290
  * }
288
291
  * }
@@ -293,6 +296,11 @@ export interface FigmaError {
293
296
  export declare class FigmaApiError extends Error {
294
297
  /** HTTP status code from the API response. */
295
298
  readonly statusCode: number;
296
- constructor(message: string, statusCode: number);
299
+ /**
300
+ * Retry-After header value in seconds (for 429 rate limit errors).
301
+ * Undefined if not a rate limit error or header not present.
302
+ */
303
+ readonly retryAfter: number | undefined;
304
+ constructor(message: string, statusCode: number, retryAfter?: number);
297
305
  }
298
306
  //# sourceMappingURL=figma.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"figma.d.ts","sourceRoot":"","sources":["../../src/types/figma.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAA;AAEnE;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,aAAa,GACrB,YAAY,GACZ,cAAc,GACd,eAAe,GACf,cAAc,GACd,KAAK,GACL,cAAc,GACd,SAAS,GACT,cAAc,GACd,aAAa,GACb,WAAW,GACX,aAAa,GACb,gBAAgB,GAChB,mBAAmB,GACnB,kBAAkB,GAClB,aAAa,GACb,YAAY,GACZ,iBAAiB,GACjB,WAAW,GACX,YAAY,GACZ,YAAY,GACZ,WAAW,GACX,cAAc,GACd,cAAc,CAAA;AAElB;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,KAAK;IACpB,uBAAuB;IACvB,CAAC,EAAE,MAAM,CAAA;IACT,yBAAyB;IACzB,CAAC,EAAE,MAAM,CAAA;IACT,wBAAwB;IACxB,CAAC,EAAE,MAAM,CAAA;IACT,mCAAmC;IACnC,CAAC,EAAE,MAAM,CAAA;CACV;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,aAAa;IAC5B,2EAA2E;IAC3E,IAAI,EAAE,gBAAgB,CAAA;IACtB,mDAAmD;IACnD,EAAE,EAAE,MAAM,CAAA;CACX;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,GAAG,aAAa,CAAA;AAE7E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAA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,qBAAa,aAAc,SAAQ,KAAK;IACtC,8CAA8C;IAC9C,SAAgB,UAAU,EAAE,MAAM,CAAA;IAClC;;;OAGG;IACH,SAAgB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;gBAElC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM;CAUrE"}
@@ -292,6 +292,20 @@ export interface MutationState<TData> {
292
292
  data: TData | null;
293
293
  error: Error | null;
294
294
  }
295
+ /**
296
+ * Options for configuring mutation behavior.
297
+ *
298
+ * @public
299
+ */
300
+ export interface MutationOptions {
301
+ /**
302
+ * If true, errors will be rethrown instead of being caught and stored in state.
303
+ * This allows callers to use try/catch for error handling.
304
+ *
305
+ * @default false
306
+ */
307
+ throwOnError?: boolean;
308
+ }
295
309
  /**
296
310
  * Return value of mutation hooks.
297
311
  *
@@ -1 +1 @@
1
- {"version":3,"file":"mutations.d.ts","sourceRoot":"","sources":["../../src/types/mutations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE5E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAA;IACZ,oBAAoB,EAAE,MAAM,CAAA;IAC5B,YAAY,EAAE,YAAY,CAAA;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,MAAM,CAAC,EAAE,aAAa,EAAE,CAAA;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACpC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,WAAW,qBAAqB;IACpC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,oBAAoB,CAAC,EAAE,OA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ChD,IAAI,EAAE,KAAK,GAAG,IAAI,CAAA;IAClB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAA;CACpB;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;OAKG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,cAAc,CAAC,KAAK,EAAE,QAAQ;IAC7C,MAAM,EAAE,CAAC,OAAO,EAAE,QAAQ,KAAK,OAAO,CAAC,KAAK,GAAG,SAAS,CAAC,CAAA;IACzD,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAA;IAChD,IAAI,EAAE,KAAK,GAAG,IAAI,CAAA;IAClB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAA;IACnB,SAAS,EAAE,OAAO,CAAA;IAClB,SAAS,EAAE,OAAO,CAAA;IAClB,OAAO,EAAE,OAAO,CAAA;CACjB"}
@@ -93,4 +93,50 @@ export declare function getErrorMessage(error: unknown, defaultMessage?: string)
93
93
  * @public
94
94
  */
95
95
  export declare function hasErrorStatus(error: unknown, statusCode: number): boolean;
96
+ /**
97
+ * Checks if an error represents a rate limit (429) response.
98
+ *
99
+ * @remarks
100
+ * Convenience function to check if an error is a rate limit error.
101
+ *
102
+ * @param error - The error to check.
103
+ * @returns `true` if the error is a rate limit error (429), `false` otherwise.
104
+ *
105
+ * @example
106
+ * ```tsx
107
+ * import { isRateLimited } from '@figma-vars/hooks';
108
+ *
109
+ * if (isRateLimited(error)) {
110
+ * // Handle rate limit, maybe retry after delay
111
+ * }
112
+ * ```
113
+ *
114
+ * @public
115
+ */
116
+ export declare function isRateLimited(error: unknown): boolean;
117
+ /**
118
+ * Gets the retry-after value in seconds from a rate limit error.
119
+ *
120
+ * @remarks
121
+ * Returns the number of seconds to wait before retrying, as specified in the Retry-After header.
122
+ * Returns `null` if the error is not a rate limit error or if no retry-after value is available.
123
+ *
124
+ * @param error - The error to extract retry-after from.
125
+ * @returns The number of seconds to wait, or `null` if not available.
126
+ *
127
+ * @example
128
+ * ```tsx
129
+ * import { getRetryAfter } from '@figma-vars/hooks';
130
+ *
131
+ * const retryAfter = getRetryAfter(error);
132
+ * if (retryAfter !== null) {
133
+ * setTimeout(() => {
134
+ * // Retry the request
135
+ * }, retryAfter * 1000);
136
+ * }
137
+ * ```
138
+ *
139
+ * @public
140
+ */
141
+ export declare function getRetryAfter(error: unknown): number | null;
96
142
  //# sourceMappingURL=errorHelpers.d.ts.map