@figma-vars/hooks 3.0.0 → 3.1.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 +55 -5
- package/dist/api/fetcher.d.ts +32 -1
- package/dist/api/fetcher.d.ts.map +1 -1
- package/dist/api/index.d.ts +2 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/mutator.d.ts +27 -1
- package/dist/api/mutator.d.ts.map +1 -1
- package/dist/contexts/FigmaVarsProvider.d.ts +2 -0
- package/dist/contexts/FigmaVarsProvider.d.ts.map +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.mjs +1 -1
- package/dist/hooks/index.d.ts +45 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/useCollectionById.d.ts +31 -0
- package/dist/hooks/useCollectionById.d.ts.map +1 -0
- package/dist/hooks/useInvalidateVariables.d.ts +3 -0
- package/dist/hooks/useInvalidateVariables.d.ts.map +1 -1
- package/dist/hooks/useModesByCollection.d.ts +34 -0
- package/dist/hooks/useModesByCollection.d.ts.map +1 -0
- package/dist/hooks/usePublishedVariables.d.ts.map +1 -1
- package/dist/hooks/useVariableById.d.ts +31 -0
- package/dist/hooks/useVariableById.d.ts.map +1 -0
- package/dist/hooks/useVariables.d.ts.map +1 -1
- package/dist/index-5ZyKWuYv.cjs +1 -0
- package/dist/index-ClHLYVvu.js +142 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +250 -167
- package/dist/types/contexts.d.ts +1 -0
- package/dist/types/contexts.d.ts.map +1 -1
- package/dist/types/figma.d.ts +9 -1
- package/dist/types/figma.d.ts.map +1 -1
- package/dist/types/mutations.d.ts +14 -0
- package/dist/types/mutations.d.ts.map +1 -1
- package/dist/utils/errorHelpers.d.ts +46 -0
- package/dist/utils/errorHelpers.d.ts.map +1 -1
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/swrKeys.d.ts +24 -0
- package/dist/utils/swrKeys.d.ts.map +1 -0
- package/dist/utils/typeGuards.d.ts +50 -0
- package/dist/utils/typeGuards.d.ts.map +1 -0
- package/package.json +1 -1
- package/dist/index-BIUpDTdr.cjs +0 -1
- package/dist/index-Cd4HQQHO.js +0 -94
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("react/jsx-runtime"),u=require("react"),m=require("swr"),i=require("./index-5ZyKWuYv.cjs"),k=u.createContext(void 0);function A(e){if(typeof e!="object"||e===null)return!1;const r=e;if(typeof r.meta!="object"||r.meta===null)return!1;const t=r.meta;return!(typeof t.variableCollections!="object"||t.variableCollections===null||typeof t.variables!="object"||t.variables===null)}function _(e){if(A(e))return e}const V=({children:e,token:r,fileKey:t,fallbackFile:o,swrConfig:s})=>{const a=u.useId(),l=u.useMemo(()=>`figma-vars-provider-${a}`,[a]),f=u.useMemo(()=>{if(o){if(typeof o=="object"){const n=_(o);if(n)return n;process.env.NODE_ENV!=="production"&&console.warn("[figma-vars-hooks] fallbackFile object does not match expected Figma Variables API response structure. Expected { meta: { variableCollections: {...}, variables: {...} } }");return}if(typeof o=="string")try{const n=JSON.parse(o),d=_(n);if(d)return d;process.env.NODE_ENV!=="production"&&console.warn("[figma-vars-hooks] Parsed fallbackFile JSON does not match expected Figma Variables API response structure. Expected { meta: { variableCollections: {...}, variables: {...} } }");return}catch(n){process.env.NODE_ENV!=="production"&&console.error(`[figma-vars-hooks] Failed to parse fallbackFile JSON: ${n instanceof Error?n.message:"Unknown error"}`);return}}},[o]),c=u.useMemo(()=>{const n={token:r,fileKey:t,providerId:l,...s!==void 0&&{swrConfig:s}};return o===void 0?n:{...n,fallbackFile:o,parsedFallbackFile:f}},[r,t,o,f,l,s]);return g.jsx(k.Provider,{value:c,children:e})},b=()=>{const e=u.useContext(k);if(e===void 0)throw new Error("useFigmaTokenContext must be used within a FigmaVarsProvider");return e};function M(e){const{fileKey:r,token:t,providerId:o,hasFallback:s}=e;return!!(t&&r)&&t&&r?[`https://api.figma.com/v1/files/${r}/variables/local`,t]:s?[`fallback-${o??"default"}`,"fallback"]:null}function O(e){const{fileKey:r,token:t,providerId:o,hasFallback:s}=e;return!!(t&&r)&&t&&r?[`https://api.figma.com/v1/files/${r}/variables/published`,t]:s?[`fallback-${o??"default"}`,"fallback"]:null}function I(e){const{fileKey:r,token:t,providerId:o,hasFallback:s}=e,a=[];return t&&r&&(a.push([`https://api.figma.com/v1/files/${r}/variables/local`,t]),a.push([`https://api.figma.com/v1/files/${r}/variables/published`,t])),s&&o&&a.push([`fallback-${o}`,"fallback"]),a}const R=()=>{const{token:e,fileKey:r,fallbackFile:t,parsedFallbackFile:o,providerId:s,swrConfig:a}=b(),f=M({fileKey:r,token:e,providerId:s,hasFallback:!!(t||o)});return m(f,async(...n)=>{if(o)return o;if(t&&typeof t=="object")return t;const[d,E]=Array.isArray(n[0])?n[0]:[n[0],n[1]];if(!d||!E)throw new Error("Missing URL or token for live API request");return i.fetcher(d,E)},a)},S=()=>{const{data:e}=R(),r=u.useMemo(()=>e!=null&&e.meta?Object.values(e.meta.variableCollections):[],[e]),t=u.useMemo(()=>e!=null&&e.meta?e.meta.variableCollections:{},[e]);return{collections:r,collectionsById:t}},K=()=>{const{data:e}=R();return u.useMemo(()=>{const r=[],t={},o={};if(e!=null&&e.meta)for(const s of Object.values(e.meta.variableCollections)){r.push(...s.modes),t[s.id]=s.modes;for(const a of s.modes)o[a.modeId]=a}return{modes:r,modesByCollectionId:t,modesById:o}},[e])};function T(e,r){switch(r.type){case"loading":return{...e,status:"loading",error:null};case"success":return{...e,status:"success",data:r.payload};case"error":return{...e,status:"error",error:r.payload};default:return e}}const v=(e,r)=>{const{throwOnError:t=!1}={},o={status:"idle",data:null,error:null},[s,a]=u.useReducer(T,o),l=u.useRef(e),f=u.useRef({throwOnError:t}),c=u.useRef(!0),n=u.useRef(0);return u.useEffect(()=>{l.current=e,f.current={throwOnError:t}},[e,t]),u.useEffect(()=>(c.current=!0,()=>{c.current=!1}),[]),{mutate:u.useCallback(async E=>{if(!c.current)return;const y=++n.current;a({type:"loading"});try{const p=await l.current(E);return c.current&&y===n.current&&a({type:"success",payload:p}),p}catch(p){const h=p;if(c.current&&y===n.current&&a({type:"error",payload:h}),f.current.throwOnError)throw h;return}},[]),...s,isLoading:s.status==="loading",isSuccess:s.status==="success",isError:s.status==="error"}},C=()=>{const{token:e,fileKey:r}=b();return v(async o=>{if(!e)throw new Error(i.ERROR_MSG_TOKEN_REQUIRED);if(!r)throw new Error(i.ERROR_MSG_TOKEN_FILE_KEY_REQUIRED);return await i.mutator(i.FIGMA_FILE_VARIABLES_PATH(r),e,"CREATE",{variables:[{action:"CREATE",...o}]})})},L=()=>{const{token:e,fileKey:r}=b();return v(async({variableId:o,payload:s})=>{if(!e)throw new Error(i.ERROR_MSG_TOKEN_REQUIRED);if(!r)throw new Error(i.ERROR_MSG_TOKEN_FILE_KEY_REQUIRED);return await i.mutator(i.FIGMA_FILE_VARIABLES_PATH(r),e,"UPDATE",{variables:[{action:"UPDATE",id:o,...s}]})})},P=()=>{const{token:e,fileKey:r}=b();return v(async o=>{if(!e)throw new Error(i.ERROR_MSG_TOKEN_REQUIRED);if(!r)throw new Error(i.ERROR_MSG_TOKEN_FILE_KEY_REQUIRED);return await i.mutator(i.FIGMA_FILE_VARIABLES_PATH(r),e,"DELETE",{variables:[{action:"DELETE",id:o}]})})},D=()=>{const{token:e,fileKey:r}=b();return v(async o=>{if(!e)throw new Error(i.ERROR_MSG_TOKEN_REQUIRED);if(!r)throw new Error(i.ERROR_MSG_TOKEN_FILE_KEY_REQUIRED);return await i.mutator(i.FIGMA_FILE_VARIABLES_PATH(r),e,"UPDATE",o)})},U=()=>{const{mutate:e}=m.useSWRConfig(),{token:r,fileKey:t,fallbackFile:o,providerId:s}=b(),a=!!o;return{invalidate:()=>{const c=I({fileKey:t,token:r,providerId:s,hasFallback:a});for(const n of c)e(n)},revalidate:()=>{const c=I({fileKey:t,token:r,providerId:s,hasFallback:a});for(const n of c)e(n,void 0,{revalidate:!0})}}},N=()=>{const{token:e,fileKey:r,fallbackFile:t,parsedFallbackFile:o,providerId:s,swrConfig:a}=b(),f=O({fileKey:r,token:e,providerId:s,hasFallback:!!(t||o)});return m(f,async(...n)=>{if(o)return o;if(t&&typeof t=="object")return t;const[d,E]=Array.isArray(n[0])?n[0]:[n[0],n[1]];if(!d||!E)throw new Error("Missing URL or token for live API request");return i.fetcher(d,E)},a)};function w(e){return e instanceof i.FigmaApiError}function F(e){return w(e)?e.statusCode:null}function j(e,r="An error occurred"){return e instanceof Error?e.message||r:typeof e=="string"?e:r}function B(e,r){return F(e)===r}exports.FigmaApiError=i.FigmaApiError;exports.filterVariables=i.filterVariables;exports.FigmaVarsProvider=V;exports.getErrorMessage=j;exports.getErrorStatus=F;exports.hasErrorStatus=B;exports.isFigmaApiError=w;exports.useBulkUpdateVariables=D;exports.useCreateVariable=C;exports.useDeleteVariable=P;exports.useInvalidateVariables=U;exports.usePublishedVariables=N;exports.useUpdateVariable=L;exports.useVariableCollections=S;exports.useVariableModes=K;exports.useVariables=R;
|
package/dist/index.mjs
CHANGED
|
@@ -1,131 +1,212 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import
|
|
4
|
-
import { f as
|
|
5
|
-
import {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
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:
|
|
11
|
-
fileKey:
|
|
22
|
+
token: r,
|
|
23
|
+
fileKey: t,
|
|
12
24
|
fallbackFile: o,
|
|
13
25
|
swrConfig: n
|
|
14
26
|
}) => {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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 ?
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
|
120
|
+
return A(l, f);
|
|
43
121
|
},
|
|
44
|
-
|
|
122
|
+
a
|
|
45
123
|
);
|
|
46
|
-
},
|
|
47
|
-
const { data: e } =
|
|
124
|
+
}, H = () => {
|
|
125
|
+
const { data: e } = K(), r = p(
|
|
48
126
|
() => e != null && e.meta ? Object.values(e.meta.variableCollections) : [],
|
|
49
127
|
[e]
|
|
50
|
-
),
|
|
128
|
+
), t = p(
|
|
51
129
|
() => e != null && e.meta ? e.meta.variableCollections : {},
|
|
52
130
|
[e]
|
|
53
131
|
);
|
|
54
132
|
return {
|
|
55
|
-
collections:
|
|
56
|
-
collectionsById:
|
|
133
|
+
collections: r,
|
|
134
|
+
collectionsById: t
|
|
57
135
|
};
|
|
58
|
-
},
|
|
59
|
-
const { data: e } =
|
|
60
|
-
return
|
|
61
|
-
const
|
|
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
|
-
|
|
67
|
-
for (const
|
|
68
|
-
o[
|
|
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:
|
|
72
|
-
modesByCollectionId:
|
|
149
|
+
modes: r,
|
|
150
|
+
modesByCollectionId: t,
|
|
73
151
|
modesById: o
|
|
74
152
|
};
|
|
75
153
|
}, [e]);
|
|
76
154
|
};
|
|
77
|
-
function
|
|
78
|
-
switch (
|
|
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:
|
|
160
|
+
return { ...e, status: "success", data: r.payload };
|
|
83
161
|
case "error":
|
|
84
|
-
return { ...e, status: "error", error:
|
|
162
|
+
return { ...e, status: "error", error: r.payload };
|
|
85
163
|
default:
|
|
86
164
|
return e;
|
|
87
165
|
}
|
|
88
166
|
}
|
|
89
|
-
const
|
|
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
|
-
}, [
|
|
95
|
-
return
|
|
96
|
-
|
|
97
|
-
}, [e]),
|
|
98
|
-
|
|
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 (
|
|
102
|
-
if (
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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
|
|
195
|
+
// Empty deps array - mutationFn and options are accessed via refs
|
|
115
196
|
),
|
|
116
|
-
...
|
|
117
|
-
isLoading:
|
|
118
|
-
isSuccess:
|
|
119
|
-
isError:
|
|
197
|
+
...n,
|
|
198
|
+
isLoading: n.status === "loading",
|
|
199
|
+
isSuccess: n.status === "success",
|
|
200
|
+
isError: n.status === "error"
|
|
120
201
|
};
|
|
121
|
-
},
|
|
122
|
-
const { token: e, fileKey:
|
|
123
|
-
return
|
|
202
|
+
}, z = () => {
|
|
203
|
+
const { token: e, fileKey: r } = d();
|
|
204
|
+
return k(async (o) => {
|
|
124
205
|
if (!e)
|
|
125
|
-
throw new Error(
|
|
126
|
-
if (!
|
|
127
|
-
throw new Error(
|
|
128
|
-
return await
|
|
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
|
-
},
|
|
138
|
-
const { token: e, fileKey:
|
|
139
|
-
return
|
|
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(
|
|
146
|
-
if (!
|
|
147
|
-
throw new Error(
|
|
148
|
-
return await
|
|
149
|
-
|
|
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
|
-
},
|
|
165
|
-
const { token: e, fileKey:
|
|
166
|
-
return
|
|
245
|
+
}, Z = () => {
|
|
246
|
+
const { token: e, fileKey: r } = d();
|
|
247
|
+
return k(async (o) => {
|
|
167
248
|
if (!e)
|
|
168
|
-
throw new Error(
|
|
169
|
-
if (!
|
|
170
|
-
throw new Error(
|
|
171
|
-
return await
|
|
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
|
-
},
|
|
181
|
-
const { token: e, fileKey:
|
|
182
|
-
return
|
|
261
|
+
}, ee = () => {
|
|
262
|
+
const { token: e, fileKey: r } = d();
|
|
263
|
+
return k(async (o) => {
|
|
183
264
|
if (!e)
|
|
184
|
-
throw new Error(
|
|
185
|
-
if (!
|
|
186
|
-
throw new Error(
|
|
187
|
-
return await
|
|
188
|
-
|
|
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
|
-
},
|
|
195
|
-
const { mutate: e } =
|
|
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
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
const
|
|
205
|
-
|
|
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
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
const
|
|
221
|
-
|
|
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
|
-
},
|
|
231
|
-
const {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
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
|
|
323
|
+
return A(l, f);
|
|
241
324
|
},
|
|
242
|
-
|
|
325
|
+
a
|
|
243
326
|
);
|
|
244
327
|
};
|
|
245
|
-
function M(e) {
|
|
246
|
-
return e instanceof P;
|
|
247
|
-
}
|
|
248
328
|
function U(e) {
|
|
249
|
-
return
|
|
329
|
+
return e instanceof D;
|
|
330
|
+
}
|
|
331
|
+
function $(e) {
|
|
332
|
+
return U(e) ? e.statusCode : null;
|
|
250
333
|
}
|
|
251
|
-
function
|
|
252
|
-
return e instanceof Error ? e.message ||
|
|
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
|
|
255
|
-
return
|
|
337
|
+
function ne(e, r) {
|
|
338
|
+
return $(e) === r;
|
|
256
339
|
}
|
|
257
340
|
export {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
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
|
};
|
package/dist/types/contexts.d.ts
CHANGED
|
@@ -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
|
|
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"}
|
package/dist/types/figma.d.ts
CHANGED
|
@@ -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
|
-
|
|
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,G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mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,2BAA2B,CAAC,CAAA;QAChE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAA;KAC7C,CAAA;CACF;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,UAAU;IACzB,kDAAkD;IAClD,UAAU,EAAE,MAAM,CAAA;IAClB,2DAA2D;IAC3D,OAAO,EAAE,MAAM,CAAA;CAChB;AAED
|
|
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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IAChC,EAAE,EAAE,MAAM,CAAA;IACV,aAAa,EAAE,MAAM,CAAA;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;IACX,oBAAoB,EAAE,MAAM,CAAA;IAC5B,YAAY,EAAE,YAAY,CAAA;IAC1B,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,2BAA2B;IAC1C,EAAE,EAAE,MAAM,CAAA;IACV,aAAa,EAAE,MAAM,CAAA;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;IACX,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE;QACJ,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,2BAA2B,CAAC,CAAA;QAChE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAA;KAC7C,CAAA;CACF;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,UAAU;IACzB,kDAAkD;IAClD,UAAU,EAAE,MAAM,CAAA;IAClB,2DAA2D;IAC3D,OAAO,EAAE,MAAM,CAAA;CAChB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,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,OAAO,CAAA;IAC9B,MAAM,CAAC,EAAE,aAAa,EAAE,CAAA;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACpC;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAA;AAE3D;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,WAAW,wBAAwB;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