@figma-vars/hooks 1.1.0 → 1.2.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/contexts/FigmaTokenContext.d.ts +39 -1
- package/dist/figma-vars-hooks.js +661 -775
- package/dist/figma-vars-hooks.umd.cjs +6 -6
- package/dist/hooks/useFigmaToken.d.ts +11 -0
- package/dist/hooks/useVariableCollections.d.ts +20 -7
- package/dist/hooks/useVariableModes.d.ts +12 -4
- package/dist/hooks/useVariables.d.ts +18 -7
- package/dist/index.d.ts +4 -6
- package/dist/mutations/bulkUpdateVariables.d.ts +25 -7
- package/dist/mutations/createVariable.d.ts +26 -7
- package/dist/mutations/deleteVariable.d.ts +19 -7
- package/dist/mutations/updateVariable.d.ts +26 -7
- package/dist/types/figma.d.ts +63 -0
- package/dist/types/hooks.d.ts +6 -13
- package/dist/types/mutations.d.ts +54 -16
- package/dist/utils/fetcher.d.ts +13 -0
- package/dist/utils/filterVariables.d.ts +26 -0
- package/package.json +1 -1
- package/dist/utils/authHelpers.d.ts +0 -4
- package/dist/utils/fetchHelpers.d.ts +0 -10
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(I,p){typeof exports=="object"&&typeof module<"u"?p(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],p):(I=typeof globalThis<"u"?globalThis:I||self,p(I.FigmaVarsHooks={},I.require$$0))})(this,function(I,p){"use strict";var he={exports:{}},ue={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
9
|
+
*/var Ye;function dt(){if(Ye)return ue;Ye=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(o,s,a){var u=null;if(a!==void 0&&(u=""+a),s.key!==void 0&&(u=""+s.key),"key"in s){a={};for(var h in s)h!=="key"&&(a[h]=s[h])}else a=s;return s=a.ref,{$$typeof:e,type:o,key:u,ref:s!==void 0?s:null,props:a}}return ue.Fragment=t,ue.jsx=n,ue.jsxs=n,ue}var le={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var
|
|
17
|
+
*/var Ge;function mt(){return Ge||(Ge=1,process.env.NODE_ENV!=="production"&&function(){function e(r){if(r==null)return null;if(typeof r=="function")return r.$$typeof===F?null:r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case d:return"Fragment";case i:return"Profiler";case L:return"StrictMode";case y:return"Suspense";case P:return"SuspenseList";case ne:return"Activity"}if(typeof r=="object")switch(typeof r.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),r.$$typeof){case v:return"Portal";case oe:return(r.displayName||"Context")+".Provider";case G:return(r._context.displayName||"Context")+".Consumer";case H:var l=r.render;return r=r.displayName,r||(r=l.displayName||l.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case te:return l=r.displayName||null,l!==null?l:e(r.type)||"Memo";case O:l=r._payload,r=r._init;try{return e(r(l))}catch{}}return null}function t(r){return""+r}function n(r){try{t(r);var l=!1}catch{l=!0}if(l){l=console;var S=l.error,b=typeof Symbol=="function"&&Symbol.toStringTag&&r[Symbol.toStringTag]||r.constructor.name||"Object";return S.call(l,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",b),t(r)}}function o(r){if(r===d)return"<>";if(typeof r=="object"&&r!==null&&r.$$typeof===O)return"<...>";try{var l=e(r);return l?"<"+l+">":"<...>"}catch{return"<...>"}}function s(){var r=B.A;return r===null?null:r.getOwner()}function a(){return Error("react-stack-top-frame")}function u(r){if(J.call(r,"key")){var l=Object.getOwnPropertyDescriptor(r,"key").get;if(l&&l.isReactWarning)return!1}return r.key!==void 0}function h(r,l){function S(){se||(se=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",l))}S.isReactWarning=!0,Object.defineProperty(r,"key",{get:S,configurable:!0})}function _(){var r=e(this.type);return me[r]||(me[r]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),r=this.props.ref,r!==void 0?r:null}function C(r,l,S,b,M,V,ae,ie){return S=V.ref,r={$$typeof:c,type:r,key:l,props:V,_owner:M},(S!==void 0?S:null)!==null?Object.defineProperty(r,"ref",{enumerable:!1,get:_}):Object.defineProperty(r,"ref",{enumerable:!1,value:null}),r._store={},Object.defineProperty(r._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(r,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(r,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:ae}),Object.defineProperty(r,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:ie}),Object.freeze&&(Object.freeze(r.props),Object.freeze(r)),r}function w(r,l,S,b,M,V,ae,ie){var A=l.children;if(A!==void 0)if(b)if(N(A)){for(b=0;b<A.length;b++)f(A[b]);Object.freeze&&Object.freeze(A)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else f(A);if(J.call(l,"key")){A=e(r);var re=Object.keys(l).filter(function(Re){return Re!=="key"});b=0<re.length?"{key: someKey, "+re.join(": ..., ")+": ...}":"{key: someKey}",pe[A+b]||(re=0<re.length?"{"+re.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
18
|
let props = %s;
|
|
19
19
|
<%s {...props} />
|
|
20
20
|
React keys must be passed directly to JSX without using spread:
|
|
21
21
|
let props = %s;
|
|
22
|
-
<%s key={someKey} {...props} />`,
|
|
22
|
+
<%s key={someKey} {...props} />`,b,A,re,A),pe[A+b]=!0)}if(A=null,S!==void 0&&(n(S),A=""+S),u(l)&&(n(l.key),A=""+l.key),"key"in l){S={};for(var q in l)q!=="key"&&(S[q]=l[q])}else S=l;return A&&h(S,typeof r=="function"?r.displayName||r.name||"Unknown":r),C(r,A,V,M,s(),S,ae,ie)}function f(r){typeof r=="object"&&r!==null&&r.$$typeof===c&&r._store&&(r._store.validated=1)}var m=p,c=Symbol.for("react.transitional.element"),v=Symbol.for("react.portal"),d=Symbol.for("react.fragment"),L=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),G=Symbol.for("react.consumer"),oe=Symbol.for("react.context"),H=Symbol.for("react.forward_ref"),y=Symbol.for("react.suspense"),P=Symbol.for("react.suspense_list"),te=Symbol.for("react.memo"),O=Symbol.for("react.lazy"),ne=Symbol.for("react.activity"),F=Symbol.for("react.client.reference"),B=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,J=Object.prototype.hasOwnProperty,N=Array.isArray,K=console.createTask?console.createTask:function(){return null};m={"react-stack-bottom-frame":function(r){return r()}};var se,me={},Ee=m["react-stack-bottom-frame"].bind(m,a)(),z=K(o(a)),pe={};le.Fragment=d,le.jsx=function(r,l,S,b,M){var V=1e4>B.recentlyCreatedOwnerStacks++;return w(r,l,S,!1,b,M,V?Error("react-stack-top-frame"):Ee,V?K(o(r)):z)},le.jsxs=function(r,l,S,b,M){var V=1e4>B.recentlyCreatedOwnerStacks++;return w(r,l,S,!0,b,M,V?Error("react-stack-top-frame"):Ee,V?K(o(r)):z)}}()),le}var He;function Et(){return He||(He=1,process.env.NODE_ENV==="production"?he.exports=dt():he.exports=mt()),he.exports}var pt=Et();const Be=p.createContext(void 0),ht=({children:e,token:t,fileKey:n})=>pt.jsx(Be.Provider,{value:{token:t,fileKey:n},children:e}),Je=()=>{const e=p.useContext(Be);if(e===void 0)throw new Error("useFigmaTokenContext must be used within a FigmaVarsProvider");return e},vt=()=>{const{token:e}=Je();return e};var ve={exports:{}},Oe={};/**
|
|
23
23
|
* @license React
|
|
24
24
|
* use-sync-external-store-shim.production.js
|
|
25
25
|
*
|
|
@@ -27,7 +27,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
27
27
|
*
|
|
28
28
|
* This source code is licensed under the MIT license found in the
|
|
29
29
|
* LICENSE file in the root directory of this source tree.
|
|
30
|
-
*/var
|
|
30
|
+
*/var Ke;function St(){if(Ke)return Oe;Ke=1;var e=p;function t(f,m){return f===m&&(f!==0||1/f===1/m)||f!==f&&m!==m}var n=typeof Object.is=="function"?Object.is:t,o=e.useState,s=e.useEffect,a=e.useLayoutEffect,u=e.useDebugValue;function h(f,m){var c=m(),v=o({inst:{value:c,getSnapshot:m}}),d=v[0].inst,L=v[1];return a(function(){d.value=c,d.getSnapshot=m,_(d)&&L({inst:d})},[f,c,m]),s(function(){return _(d)&&L({inst:d}),f(function(){_(d)&&L({inst:d})})},[f]),u(c),c}function _(f){var m=f.getSnapshot;f=f.value;try{var c=m();return!n(f,c)}catch{return!0}}function C(f,m){return m()}var w=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?C:h;return Oe.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:w,Oe}var Te={};/**
|
|
31
31
|
* @license React
|
|
32
32
|
* use-sync-external-store-shim.development.js
|
|
33
33
|
*
|
|
@@ -35,4 +35,4 @@ React keys must be passed directly to JSX without using spread:
|
|
|
35
35
|
*
|
|
36
36
|
* This source code is licensed under the MIT license found in the
|
|
37
37
|
* LICENSE file in the root directory of this source tree.
|
|
38
|
-
*/var Ze;function bt(){return Ze||(Ze=1,process.env.NODE_ENV!=="production"&&function(){function e(u,_){return u===_&&(u!==0||1/u===1/_)||u!==u&&_!==_}function n(u,_){g||o.startTransition===void 0||(g=!0,console.error("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."));var E=_();if(!m){var V=_();a(E,V)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),m=!0)}V=i({inst:{value:E,getSnapshot:_}});var c=V[0].inst,Y=V[1];return p(function(){c.value=E,c.getSnapshot=_,t(c)&&Y({inst:c})},[u,E,_]),d(function(){return t(c)&&Y({inst:c}),u(function(){t(c)&&Y({inst:c})})},[u]),S(E),E}function t(u){var _=u.getSnapshot;u=u.value;try{var E=_();return!a(u,E)}catch{return!0}}function r(u,_){return _()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var o=f,a=typeof Object.is=="function"?Object.is:e,i=o.useState,d=o.useEffect,p=o.useLayoutEffect,S=o.useDebugValue,g=!1,m=!1,v=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?r:n;Te.useSyncExternalStore=o.useSyncExternalStore!==void 0?o.useSyncExternalStore:v,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),Te}var Qe;function Rt(){return Qe||(Qe=1,process.env.NODE_ENV==="production"?Se.exports=_t():Se.exports=bt()),Se.exports}var Ot=Rt();const qe=0,$e=1,et=2,tt=3;var nt=Object.prototype.hasOwnProperty;function we(e,n){var t,r;if(e===n)return!0;if(e&&n&&(t=e.constructor)===n.constructor){if(t===Date)return e.getTime()===n.getTime();if(t===RegExp)return e.toString()===n.toString();if(t===Array){if((r=e.length)===n.length)for(;r--&&we(e[r],n[r]););return r===-1}if(!t||typeof e=="object"){r=0;for(t in e)if(nt.call(e,t)&&++r&&!nt.call(n,t)||!(t in n)||!we(e[t],n[t]))return!1;return Object.keys(n).length===r}}return e!==e&&n!==n}const z=new WeakMap,ee=()=>{},L=ee(),ye=Object,h=e=>e===L,G=e=>typeof e=="function",te=(e,n)=>({...e,...n}),rt=e=>G(e.then),Ae={},he={},Ce="undefined",de=typeof window!=Ce,ke=typeof document!=Ce,Tt=de&&"Deno"in window,wt=()=>de&&typeof window.requestAnimationFrame!=Ce,ot=(e,n)=>{const t=z.get(e);return[()=>!h(n)&&e.get(n)||Ae,r=>{if(!h(n)){const o=e.get(n);n in he||(he[n]=o),t[5](n,te(o,r),o||Ae)}},t[6],()=>!h(n)&&n in he?he[n]:!h(n)&&e.get(n)||Ae]};let De=!0;const yt=()=>De,[Ie,Le]=de&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[ee,ee],At=()=>{const e=ke&&document.visibilityState;return h(e)||e!=="hidden"},Ct=e=>(ke&&document.addEventListener("visibilitychange",e),Ie("focus",e),()=>{ke&&document.removeEventListener("visibilitychange",e),Le("focus",e)}),kt=e=>{const n=()=>{De=!0,e()},t=()=>{De=!1};return Ie("online",n),Ie("offline",t),()=>{Le("online",n),Le("offline",t)}},Dt={isOnline:yt,isVisible:At},It={initFocus:Ct,initReconnect:kt},st=!f.useId,me=!de||Tt,Lt=e=>wt()?window.requestAnimationFrame(e):setTimeout(e,1),Ve=me?f.useEffect:f.useLayoutEffect,Fe=typeof navigator<"u"&&navigator.connection,at=!me&&Fe&&(["slow-2g","2g"].includes(Fe.effectiveType)||Fe.saveData),_e=new WeakMap,Pe=(e,n)=>ye.prototype.toString.call(e)===`[object ${n}]`;let Vt=0;const je=e=>{const n=typeof e,t=Pe(e,"Date"),r=Pe(e,"RegExp"),o=Pe(e,"Object");let a,i;if(ye(e)===e&&!t&&!r){if(a=_e.get(e),a)return a;if(a=++Vt+"~",_e.set(e,a),Array.isArray(e)){for(a="@",i=0;i<e.length;i++)a+=je(e[i])+",";_e.set(e,a)}if(o){a="#";const d=ye.keys(e).sort();for(;!h(i=d.pop());)h(e[i])||(a+=i+":"+je(e[i])+",");_e.set(e,a)}}else a=t?e.toJSON():n=="symbol"?e.toString():n=="string"?JSON.stringify(e):""+e;return a},Ne=e=>{if(G(e))try{e=e()}catch{e=""}const n=e;return e=typeof e=="string"?e:(Array.isArray(e)?e.length:e)?je(e):"",[e,n]};let Ft=0;const xe=()=>++Ft;async function it(...e){const[n,t,r,o]=e,a=te({populateCache:!0,throwOnError:!0},typeof o=="boolean"?{revalidate:o}:o||{});let i=a.populateCache;const d=a.rollbackOnError;let p=a.optimisticData;const S=v=>typeof d=="function"?d(v):d!==!1,g=a.throwOnError;if(G(t)){const v=t,u=[],_=n.keys();for(const E of _)!/^\$(inf|sub)\$/.test(E)&&v(n.get(E)._k)&&u.push(E);return Promise.all(u.map(m))}return m(t);async function m(v){const[u]=Ne(v);if(!u)return;const[_,E]=ot(n,u),[V,c,Y,se]=z.get(n),B=()=>{const N=V[u];return(G(a.revalidate)?a.revalidate(_().data,v):a.revalidate!==!1)&&(delete Y[u],delete se[u],N&&N[0])?N[0](et).then(()=>_().data):_().data};if(e.length<3)return B();let C=r,F;const ne=xe();c[u]=[ne,0];const O=!h(p),re=_(),x=re.data,H=re._c,J=h(H)?x:H;if(O&&(p=G(p)?p(J,x):p,E({data:p,_c:J})),G(C))try{C=C(J)}catch(N){F=N}if(C&&rt(C))if(C=await C.catch(N=>{F=N}),ne!==c[u][0]){if(F)throw F;return C}else F&&O&&S(F)&&(i=!0,E({data:J,_c:L}));if(i&&!F)if(G(i)){const N=i(C,J);E({data:N,error:L,_c:L})}else E({data:C,error:L,_c:L});if(c[u][1]=xe(),Promise.resolve(B()).then(()=>{E({_c:L})}),F){if(g)throw F;return}return C}}const ct=(e,n)=>{for(const t in e)e[t][0]&&e[t][0](n)},Pt=(e,n)=>{if(!z.has(e)){const t=te(It,n),r=Object.create(null),o=it.bind(L,e);let a=ee;const i=Object.create(null),d=(g,m)=>{const v=i[g]||[];return i[g]=v,v.push(m),()=>v.splice(v.indexOf(m),1)},p=(g,m,v)=>{e.set(g,m);const u=i[g];if(u)for(const _ of u)_(m,v)},S=()=>{if(!z.has(e)&&(z.set(e,[r,Object.create(null),Object.create(null),Object.create(null),o,p,d]),!me)){const g=t.initFocus(setTimeout.bind(L,ct.bind(L,r,qe))),m=t.initReconnect(setTimeout.bind(L,ct.bind(L,r,$e)));a=()=>{g&&g(),m&&m(),z.delete(e)}}};return S(),[e,o,S,a]}return[e,z.get(e)[4]]},jt=(e,n,t,r,o)=>{const a=t.errorRetryCount,i=o.retryCount,d=~~((Math.random()+.5)*(1<<(i<8?i:8)))*t.errorRetryInterval;!h(a)&&i>a||setTimeout(r,d,o)},Nt=we,[ut,xt]=Pt(new Map),Mt=te({onLoadingSlow:ee,onSuccess:ee,onError:ee,onErrorRetry:jt,onDiscarded:ee,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:at?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:at?5e3:3e3,compare:Nt,isPaused:()=>!1,cache:ut,mutate:xt,fallback:{}},Dt),Ut=(e,n)=>{const t=te(e,n);if(n){const{use:r,fallback:o}=e,{use:a,fallback:i}=n;r&&a&&(t.use=r.concat(a)),o&&i&&(t.fallback=te(o,i))}return t},Wt=f.createContext({}),Gt="$inf$",lt=de&&window.__SWR_DEVTOOLS_USE__,Yt=lt?window.__SWR_DEVTOOLS_USE__:[],Bt=()=>{lt&&(window.__SWR_DEVTOOLS_REACT__=f)},Ht=e=>G(e[1])?[e[0],e[1],e[2]||{}]:[e[0],null,(e[1]===null?e[2]:e[1])||{}],Jt=()=>te(Mt,f.useContext(Wt)),Kt=e=>(n,t,r)=>e(n,t&&((...a)=>{const[i]=Ne(n),[,,,d]=z.get(ut);if(i.startsWith(Gt))return t(...a);const p=d[i];return h(p)?t(...a):(delete d[i],p)}),r),zt=Yt.concat(Kt),Xt=e=>function(...t){const r=Jt(),[o,a,i]=Ht(t),d=Ut(r,i);let p=e;const{use:S}=d,g=(S||[]).concat(zt);for(let m=g.length;m--;)p=g[m](p);return p(o,a||d.fetcher||null,d)},Zt=(e,n,t)=>{const r=n[e]||(n[e]=[]);return r.push(t),()=>{const o=r.indexOf(t);o>=0&&(r[o]=r[r.length-1],r.pop())}};Bt();const Me=f.use||(e=>{switch(e.status){case"pending":throw e;case"fulfilled":return e.value;case"rejected":throw e.reason;default:throw e.status="pending",e.then(n=>{e.status="fulfilled",e.value=n},n=>{e.status="rejected",e.reason=n}),e}}),Ue={dedupe:!0},We=Xt((e,n,t)=>{const{cache:r,compare:o,suspense:a,fallbackData:i,revalidateOnMount:d,revalidateIfStale:p,refreshInterval:S,refreshWhenHidden:g,refreshWhenOffline:m,keepPreviousData:v}=t,[u,_,E,V]=z.get(r),[c,Y]=Ne(e),se=f.useRef(!1),B=f.useRef(!1),C=f.useRef(c),F=f.useRef(n),ne=f.useRef(t),O=()=>ne.current,re=()=>O().isVisible()&&O().isOnline(),[x,H,J,N]=ot(r,c),K=f.useRef({}).current,ae=h(i)?h(t.fallback)?L:t.fallback[c]:i,Ee=(T,R)=>{for(const I in K){const y=I;if(y==="data"){if(!o(T[y],R[y])&&(!h(T[y])||!o(P,R[y])))return!1}else if(R[y]!==T[y])return!1}return!0},pe=f.useMemo(()=>{const T=!c||!n?!1:h(d)?O().isPaused()||a?!1:p!==!1:d,R=j=>{const Q=te(j);return delete Q._k,T?{isValidating:!0,isLoading:!0,...Q}:Q},I=x(),y=N(),W=R(I),ue=I===y?W:R(y);let D=W;return[()=>{const j=R(x());return Ee(j,D)?(D.data=j.data,D.isLoading=j.isLoading,D.isValidating=j.isValidating,D.error=j.error,D):(D=j,j)},()=>ue]},[r,c]),X=Ot.useSyncExternalStore(f.useCallback(T=>J(c,(R,I)=>{Ee(I,R)||T()}),[r,c]),pe[0],pe[1]),ve=!se.current,s=u[c]&&u[c].length>0,l=X.data,b=h(l)?ae&&rt(ae)?Me(ae):ae:l,w=X.error,M=f.useRef(b),P=v?h(l)?h(M.current)?b:M.current:l:b,ie=s&&!h(w)?!1:ve&&!h(d)?d:O().isPaused()?!1:a?h(b)?!1:p:h(b)||p,ce=!!(c&&n&&ve&&ie),k=h(X.isValidating)?ce:X.isValidating,oe=h(X.isLoading)?ce:X.isLoading,Z=f.useCallback(async T=>{const R=F.current;if(!c||!R||B.current||O().isPaused())return!1;let I,y,W=!0;const ue=T||{},D=!E[c]||!ue.dedupe,j=()=>st?!B.current&&c===C.current&&se.current:c===C.current,Q={isValidating:!1,isLoading:!1},ft=()=>{H(Q)},dt=()=>{const U=E[c];U&&U[1]===y&&delete E[c]},mt={isValidating:!0};h(x().data)&&(mt.isLoading=!0);try{if(D&&(H(mt),t.loadingTimeout&&h(x().data)&&setTimeout(()=>{W&&j()&&O().onLoadingSlow(c,t)},t.loadingTimeout),E[c]=[R(Y),xe()]),[I,y]=E[c],I=await I,D&&setTimeout(dt,t.dedupingInterval),!E[c]||E[c][1]!==y)return D&&j()&&O().onDiscarded(c),!1;Q.error=L;const U=_[c];if(!h(U)&&(y<=U[0]||y<=U[1]||U[1]===0))return ft(),D&&j()&&O().onDiscarded(c),!1;const q=x().data;Q.data=o(q,I)?q:I,D&&j()&&O().onSuccess(I,c,t)}catch(U){dt();const q=O(),{shouldRetryOnError:Ye}=q;q.isPaused()||(Q.error=U,D&&j()&&(q.onError(U,c,q),(Ye===!0||G(Ye)&&Ye(U))&&(!O().revalidateOnFocus||!O().revalidateOnReconnect||re())&&q.onErrorRetry(U,c,q,dn=>{const Be=u[c];Be&&Be[0]&&Be[0](tt,dn)},{retryCount:(ue.retryCount||0)+1,dedupe:!0})))}return W=!1,ft(),!0},[c,r]),Re=f.useCallback((...T)=>it(r,C.current,...T),[]);if(Ve(()=>{F.current=n,ne.current=t,h(l)||(M.current=l)}),Ve(()=>{if(!c)return;const T=Z.bind(L,Ue);let R=0;O().revalidateOnFocus&&(R=Date.now()+O().focusThrottleInterval);const y=Zt(c,u,(W,ue={})=>{if(W==qe){const D=Date.now();O().revalidateOnFocus&&D>R&&re()&&(R=D+O().focusThrottleInterval,T())}else if(W==$e)O().revalidateOnReconnect&&re()&&T();else{if(W==et)return Z();if(W==tt)return Z(ue)}});return B.current=!1,C.current=c,se.current=!0,H({_k:Y}),ie&&(h(b)||me?T():Lt(T)),()=>{B.current=!0,y()}},[c]),Ve(()=>{let T;function R(){const y=G(S)?S(x().data):S;y&&T!==-1&&(T=setTimeout(I,y))}function I(){!x().error&&(g||O().isVisible())&&(m||O().isOnline())?Z(Ue).then(R):R()}return R(),()=>{T&&(clearTimeout(T),T=-1)}},[S,g,m,c]),f.useDebugValue(P),a&&h(b)&&c){if(!st&&me)throw new Error("Fallback data is required when using Suspense in SSR.");F.current=n,ne.current=t,B.current=!1;const T=V[c];if(!h(T)){const R=Re(T);Me(R)}if(h(w)){const R=Z(Ue);h(P)||(R.status="fulfilled",R.value=!0),Me(R)}else throw w}return{mutate:Re,get data(){return K.data=!0,P},get error(){return K.error=!0,w},get isValidating(){return K.isValidating=!0,k},get isLoading(){return K.isLoading=!0,oe}}}),Qt=()=>null,be=async(e,n={method:"GET"})=>{throw new Error("Figma API token is not available.")},qt="https://api.figma.com/v1/files",Ge=e=>`${qt}/${e}/variables`,$t=e=>{const n=$(),{data:t,error:r,isLoading:o,isValidating:a}=We(n?Ge(e):null,be),i=t!=null&&t.meta?Object.values(t.meta.variables):[],d=t!=null&&t.meta?t.meta.variables:{};return{variables:i,variablesById:d,isLoading:o,isValidating:a,error:r??(t&&"message"in t?new Error(t.message):null)}},en=e=>{const n=$(),{data:t,error:r,isLoading:o,isValidating:a}=We(n?Ge(e):null,be),i=t!=null&&t.meta?Object.values(t.meta.variableCollections):[],d=t!=null&&t.meta?t.meta.variableCollections:{};return{collections:i,collectionsById:d,isLoading:o,isValidating:a,error:r??(t&&"message"in t?new Error(t.message):null)}},tn=e=>{const n=$(),{data:t,error:r,isLoading:o,isValidating:a}=We(n?Ge(e):null,be),i=[],d={},p={};if(t!=null&&t.meta)for(const S of Object.values(t.meta.variableCollections)){i.push(...S.modes),d[S.id]=S.modes;for(const g of S.modes)p[g.modeId]=g}return{modes:i,modesByCollectionId:d,modesById:p,isLoading:o,isValidating:a,error:r??(t&&"message"in t?new Error(t.message):null)}};async function nn(e,n,t){const r=`https://api.figma.com/v1/files/${n}/variables`;try{const o=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json","X-FIGMA-TOKEN":e},body:JSON.stringify(t)}),a=await o.json();return o.ok?{error:!1,status:o.status,meta:a.meta}:{error:!0,status:o.status,message:a.message||"Failed to perform bulk update."}}catch(o){return{error:!0,status:500,message:o instanceof Error?o.message:"An unknown error occurred."}}}const rn=()=>{const e=$(),[n,t]=f.useState(!1),[r,o]=f.useState(null),[a,i]=f.useState(null);return{bulkUpdate:f.useCallback(async(p,S)=>{if(!e){o("Figma API token is not provided.");return}t(!0),o(null);const g=await nn(e,p,S);i(g),g.error&&o(g.message||"An error occurred during the bulk update."),t(!1)},[e]),loading:n,error:r,data:a}};async function on(e,n){const t="https://api.figma.com/v1/variables";try{const r=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json","X-FIGMA-TOKEN":e},body:JSON.stringify(n)});if(!r.ok){const a=await r.json();return{error:!0,status:r.status,message:a.message||"Failed to create Figma variable"}}const o=await r.json();return{error:!1,status:r.status,variable:o}}catch(r){return{error:!0,status:500,message:r instanceof Error?r.message:"An unknown error occurred"}}}const sn=()=>{const e=$(),[n,t]=f.useState(!1),[r,o]=f.useState(null),[a,i]=f.useState(null);return{createVariable:f.useCallback(async p=>{if(!e){o("Figma API token is not provided.");return}t(!0),o(null);const S=await on(e,p);i(S),S.error&&o(S.message||"An error occurred."),t(!1)},[e]),loading:n,error:r,data:a}};async function an(e,n){const t=`https://api.figma.com/v1/variables/${n}`;try{const r=await fetch(t,{method:"DELETE",headers:{"Content-Type":"application/json","X-FIGMA-TOKEN":e}});if(!r.ok){const o=await r.json();return{error:!0,status:r.status,message:o.message||"Failed to delete Figma variable"}}return{error:!1,status:r.status}}catch(r){return{error:!0,status:500,message:r instanceof Error?r.message:"An unknown error occurred"}}}const cn=()=>{const e=$(),[n,t]=f.useState(!1),[r,o]=f.useState(null),[a,i]=f.useState(null);return{deleteVariable:f.useCallback(async p=>{if(!e){o("Figma API token is not provided.");return}t(!0),o(null);const S=await an(e,p);i(S),S.error&&o(S.message||"An error occurred."),t(!1)},[e]),loading:n,error:r,data:a}};async function un(e,n,t){const r=`https://api.figma.com/v1/variables/${n}`;try{const o=await fetch(r,{method:"PUT",headers:{"Content-Type":"application/json","X-FIGMA-TOKEN":e},body:JSON.stringify(t)});if(!o.ok){const a=await o.json();return{error:!0,status:o.status,message:a.message||"Failed to update Figma variable"}}return{error:!1,status:o.status}}catch(o){return{error:!0,status:500,message:o instanceof Error?o.message:"An unknown error occurred"}}}const ln=()=>{const e=$(),[n,t]=f.useState(!1),[r,o]=f.useState(null),[a,i]=f.useState(null);return{updateVariable:f.useCallback(async(p,S)=>{if(!e){o("Figma API token is not provided.");return}t(!0),o(null);const g=await un(e,p,S);i(g),g.error&&o(g.message||"An error occurred."),t(!1)},[e]),loading:n,error:r,data:a}};function fn(e,n){return e.filter(t=>{let r=!0;return n.resolvedType&&(r=r&&t.resolvedType===n.resolvedType),n.name&&(r=r&&t.name.includes(n.name)),r})}A.FigmaVarsProvider=St,A.fetchWithAuth=be,A.filterVariables=fn,A.getFigmaToken=Qt,A.useBulkUpdateVariables=rn,A.useCreateVariable=sn,A.useDeleteVariable=cn,A.useFigmaToken=$,A.useUpdateVariable=ln,A.useVariableCollections=en,A.useVariableModes=tn,A.useVariables=$t,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})});
|
|
38
|
+
*/var Xe;function _t(){return Xe||(Xe=1,process.env.NODE_ENV!=="production"&&function(){function e(c,v){return c===v&&(c!==0||1/c===1/v)||c!==c&&v!==v}function t(c,v){w||s.startTransition===void 0||(w=!0,console.error("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."));var d=v();if(!f){var L=v();a(d,L)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),f=!0)}L=u({inst:{value:d,getSnapshot:v}});var i=L[0].inst,G=L[1];return _(function(){i.value=d,i.getSnapshot=v,n(i)&&G({inst:i})},[c,d,v]),h(function(){return n(i)&&G({inst:i}),c(function(){n(i)&&G({inst:i})})},[c]),C(d),d}function n(c){var v=c.getSnapshot;c=c.value;try{var d=v();return!a(c,d)}catch{return!0}}function o(c,v){return v()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var s=p,a=typeof Object.is=="function"?Object.is:e,u=s.useState,h=s.useEffect,_=s.useLayoutEffect,C=s.useDebugValue,w=!1,f=!1,m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?o:t;Te.useSyncExternalStore=s.useSyncExternalStore!==void 0?s.useSyncExternalStore:m,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),Te}var ze;function Rt(){return ze||(ze=1,process.env.NODE_ENV==="production"?ve.exports=St():ve.exports=_t()),ve.exports}var Ot=Rt();const qe=0,Ze=1,Qe=2,$e=3;var et=Object.prototype.hasOwnProperty;function we(e,t){var n,o;if(e===t)return!0;if(e&&t&&(n=e.constructor)===t.constructor){if(n===Date)return e.getTime()===t.getTime();if(n===RegExp)return e.toString()===t.toString();if(n===Array){if((o=e.length)===t.length)for(;o--&&we(e[o],t[o]););return o===-1}if(!n||typeof e=="object"){o=0;for(n in e)if(et.call(e,n)&&++o&&!et.call(t,n)||!(n in t)||!we(e[n],t[n]))return!1;return Object.keys(t).length===o}}return e!==e&&t!==t}const X=new WeakMap,$=()=>{},k=$(),be=Object,E=e=>e===k,Y=e=>typeof e=="function",ee=(e,t)=>({...e,...t}),tt=e=>Y(e.then),ge={},Se={},ye="undefined",fe=typeof window!=ye,Ae=typeof document!=ye,Tt=fe&&"Deno"in window,wt=()=>fe&&typeof window.requestAnimationFrame!=ye,nt=(e,t)=>{const n=X.get(e);return[()=>!E(t)&&e.get(t)||ge,o=>{if(!E(t)){const s=e.get(t);t in Se||(Se[t]=s),n[5](t,ee(s,o),s||ge)}},n[6],()=>!E(t)&&t in Se?Se[t]:!E(t)&&e.get(t)||ge]};let Ce=!0;const bt=()=>Ce,[De,Ie]=fe&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[$,$],gt=()=>{const e=Ae&&document.visibilityState;return E(e)||e!=="hidden"},yt=e=>(Ae&&document.addEventListener("visibilitychange",e),De("focus",e),()=>{Ae&&document.removeEventListener("visibilitychange",e),Ie("focus",e)}),At=e=>{const t=()=>{Ce=!0,e()},n=()=>{Ce=!1};return De("online",t),De("offline",n),()=>{Ie("online",t),Ie("offline",n)}},Ct={isOnline:bt,isVisible:gt},Dt={initFocus:yt,initReconnect:At},rt=!p.useId,de=!fe||Tt,It=e=>wt()?window.requestAnimationFrame(e):setTimeout(e,1),je=de?p.useEffect:p.useLayoutEffect,ke=typeof navigator<"u"&&navigator.connection,ot=!de&&ke&&(["slow-2g","2g"].includes(ke.effectiveType)||ke.saveData),_e=new WeakMap,Le=(e,t)=>be.prototype.toString.call(e)===`[object ${t}]`;let jt=0;const Pe=e=>{const t=typeof e,n=Le(e,"Date"),o=Le(e,"RegExp"),s=Le(e,"Object");let a,u;if(be(e)===e&&!n&&!o){if(a=_e.get(e),a)return a;if(a=++jt+"~",_e.set(e,a),Array.isArray(e)){for(a="@",u=0;u<e.length;u++)a+=Pe(e[u])+",";_e.set(e,a)}if(s){a="#";const h=be.keys(e).sort();for(;!E(u=h.pop());)E(e[u])||(a+=u+":"+Pe(e[u])+",");_e.set(e,a)}}else a=n?e.toJSON():t=="symbol"?e.toString():t=="string"?JSON.stringify(e):""+e;return a},Ve=e=>{if(Y(e))try{e=e()}catch{e=""}const t=e;return e=typeof e=="string"?e:(Array.isArray(e)?e.length:e)?Pe(e):"",[e,t]};let kt=0;const xe=()=>++kt;async function st(...e){const[t,n,o,s]=e,a=ee({populateCache:!0,throwOnError:!0},typeof s=="boolean"?{revalidate:s}:s||{});let u=a.populateCache;const h=a.rollbackOnError;let _=a.optimisticData;const C=m=>typeof h=="function"?h(m):h!==!1,w=a.throwOnError;if(Y(n)){const m=n,c=[],v=t.keys();for(const d of v)!/^\$(inf|sub)\$/.test(d)&&m(t.get(d)._k)&&c.push(d);return Promise.all(c.map(f))}return f(n);async function f(m){const[c]=Ve(m);if(!c)return;const[v,d]=nt(t,c),[L,i,G,oe]=X.get(t),H=()=>{const N=L[c];return(Y(a.revalidate)?a.revalidate(v().data,m):a.revalidate!==!1)&&(delete G[c],delete oe[c],N&&N[0])?N[0](Qe).then(()=>v().data):v().data};if(e.length<3)return H();let y=o,P;const te=xe();i[c]=[te,0];const O=!E(_),ne=v(),F=ne.data,B=ne._c,J=E(B)?F:B;if(O&&(_=Y(_)?_(J,F):_,d({data:_,_c:J})),Y(y))try{y=y(J)}catch(N){P=N}if(y&&tt(y))if(y=await y.catch(N=>{P=N}),te!==i[c][0]){if(P)throw P;return y}else P&&O&&C(P)&&(u=!0,d({data:J,_c:k}));if(u&&!P)if(Y(u)){const N=u(y,J);d({data:N,error:k,_c:k})}else d({data:y,error:k,_c:k});if(i[c][1]=xe(),Promise.resolve(H()).then(()=>{d({_c:k})}),P){if(w)throw P;return}return y}}const at=(e,t)=>{for(const n in e)e[n][0]&&e[n][0](t)},Lt=(e,t)=>{if(!X.has(e)){const n=ee(Dt,t),o=Object.create(null),s=st.bind(k,e);let a=$;const u=Object.create(null),h=(w,f)=>{const m=u[w]||[];return u[w]=m,m.push(f),()=>m.splice(m.indexOf(f),1)},_=(w,f,m)=>{e.set(w,f);const c=u[w];if(c)for(const v of c)v(f,m)},C=()=>{if(!X.has(e)&&(X.set(e,[o,Object.create(null),Object.create(null),Object.create(null),s,_,h]),!de)){const w=n.initFocus(setTimeout.bind(k,at.bind(k,o,qe))),f=n.initReconnect(setTimeout.bind(k,at.bind(k,o,Ze)));a=()=>{w&&w(),f&&f(),X.delete(e)}}};return C(),[e,s,C,a]}return[e,X.get(e)[4]]},Pt=(e,t,n,o,s)=>{const a=n.errorRetryCount,u=s.retryCount,h=~~((Math.random()+.5)*(1<<(u<8?u:8)))*n.errorRetryInterval;!E(a)&&u>a||setTimeout(o,h,s)},Vt=we,[it,xt]=Lt(new Map),Nt=ee({onLoadingSlow:$,onSuccess:$,onError:$,onErrorRetry:Pt,onDiscarded:$,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:ot?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:ot?5e3:3e3,compare:Vt,isPaused:()=>!1,cache:it,mutate:xt,fallback:{}},Ct),Ft=(e,t)=>{const n=ee(e,t);if(t){const{use:o,fallback:s}=e,{use:a,fallback:u}=t;o&&a&&(n.use=o.concat(a)),s&&u&&(n.fallback=ee(s,u))}return n},Mt=p.createContext({}),Ut="$inf$",ct=fe&&window.__SWR_DEVTOOLS_USE__,Wt=ct?window.__SWR_DEVTOOLS_USE__:[],Yt=()=>{ct&&(window.__SWR_DEVTOOLS_REACT__=p)},Gt=e=>Y(e[1])?[e[0],e[1],e[2]||{}]:[e[0],null,(e[1]===null?e[2]:e[1])||{}],Ht=()=>ee(Nt,p.useContext(Mt)),Bt=e=>(t,n,o)=>e(t,n&&((...a)=>{const[u]=Ve(t),[,,,h]=X.get(it);if(u.startsWith(Ut))return n(...a);const _=h[u];return E(_)?n(...a):(delete h[u],_)}),o),Jt=Wt.concat(Bt),Kt=e=>function(...n){const o=Ht(),[s,a,u]=Gt(n),h=Ft(o,u);let _=e;const{use:C}=h,w=(C||[]).concat(Jt);for(let f=w.length;f--;)_=w[f](_);return _(s,a||h.fetcher||null,h)},Xt=(e,t,n)=>{const o=t[e]||(t[e]=[]);return o.push(n),()=>{const s=o.indexOf(n);s>=0&&(o[s]=o[o.length-1],o.pop())}};Yt();const Ne=p.use||(e=>{switch(e.status){case"pending":throw e;case"fulfilled":return e.value;case"rejected":throw e.reason;default:throw e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t},t=>{e.status="rejected",e.reason=t}),e}}),Fe={dedupe:!0},zt=Kt((e,t,n)=>{const{cache:o,compare:s,suspense:a,fallbackData:u,revalidateOnMount:h,revalidateIfStale:_,refreshInterval:C,refreshWhenHidden:w,refreshWhenOffline:f,keepPreviousData:m}=n,[c,v,d,L]=X.get(o),[i,G]=Ve(e),oe=p.useRef(!1),H=p.useRef(!1),y=p.useRef(i),P=p.useRef(t),te=p.useRef(n),O=()=>te.current,ne=()=>O().isVisible()&&O().isOnline(),[F,B,J,N]=nt(o,i),K=p.useRef({}).current,se=E(u)?E(n.fallback)?k:n.fallback[i]:u,me=(T,R)=>{for(const j in K){const g=j;if(g==="data"){if(!s(T[g],R[g])&&(!E(T[g])||!s(V,R[g])))return!1}else if(R[g]!==T[g])return!1}return!0},Ee=p.useMemo(()=>{const T=!i||!t?!1:E(h)?O().isPaused()||a?!1:_!==!1:h,R=x=>{const Z=ee(x);return delete Z._k,T?{isValidating:!0,isLoading:!0,...Z}:Z},j=F(),g=N(),W=R(j),ce=j===g?W:R(g);let D=W;return[()=>{const x=R(F());return me(x,D)?(D.data=x.data,D.isLoading=x.isLoading,D.isValidating=x.isValidating,D.error=x.error,D):(D=x,x)},()=>ce]},[o,i]),z=Ot.useSyncExternalStore(p.useCallback(T=>J(i,(R,j)=>{me(j,R)||T()}),[o,i]),Ee[0],Ee[1]),pe=!oe.current,r=c[i]&&c[i].length>0,l=z.data,S=E(l)?se&&tt(se)?Ne(se):se:l,b=z.error,M=p.useRef(S),V=m?E(l)?E(M.current)?S:M.current:l:S,ae=r&&!E(b)?!1:pe&&!E(h)?h:O().isPaused()?!1:a?E(S)?!1:_:E(S)||_,ie=!!(i&&t&&pe&&ae),A=E(z.isValidating)?ie:z.isValidating,re=E(z.isLoading)?ie:z.isLoading,q=p.useCallback(async T=>{const R=P.current;if(!i||!R||H.current||O().isPaused())return!1;let j,g,W=!0;const ce=T||{},D=!d[i]||!ce.dedupe,x=()=>rt?!H.current&&i===y.current&&oe.current:i===y.current,Z={isValidating:!1,isLoading:!1},ut=()=>{B(Z)},lt=()=>{const U=d[i];U&&U[1]===g&&delete d[i]},ft={isValidating:!0};E(F().data)&&(ft.isLoading=!0);try{if(D&&(B(ft),n.loadingTimeout&&E(F().data)&&setTimeout(()=>{W&&x()&&O().onLoadingSlow(i,n)},n.loadingTimeout),d[i]=[R(G),xe()]),[j,g]=d[i],j=await j,D&&setTimeout(lt,n.dedupingInterval),!d[i]||d[i][1]!==g)return D&&x()&&O().onDiscarded(i),!1;Z.error=k;const U=v[i];if(!E(U)&&(g<=U[0]||g<=U[1]||U[1]===0))return ut(),D&&x()&&O().onDiscarded(i),!1;const Q=F().data;Z.data=s(Q,j)?Q:j,D&&x()&&O().onSuccess(j,i,n)}catch(U){lt();const Q=O(),{shouldRetryOnError:Ue}=Q;Q.isPaused()||(Z.error=U,D&&x()&&(Q.onError(U,i,Q),(Ue===!0||Y(Ue)&&Ue(U))&&(!O().revalidateOnFocus||!O().revalidateOnReconnect||ne())&&Q.onErrorRetry(U,i,Q,on=>{const We=c[i];We&&We[0]&&We[0]($e,on)},{retryCount:(ce.retryCount||0)+1,dedupe:!0})))}return W=!1,ut(),!0},[i,o]),Re=p.useCallback((...T)=>st(o,y.current,...T),[]);if(je(()=>{P.current=t,te.current=n,E(l)||(M.current=l)}),je(()=>{if(!i)return;const T=q.bind(k,Fe);let R=0;O().revalidateOnFocus&&(R=Date.now()+O().focusThrottleInterval);const g=Xt(i,c,(W,ce={})=>{if(W==qe){const D=Date.now();O().revalidateOnFocus&&D>R&&ne()&&(R=D+O().focusThrottleInterval,T())}else if(W==Ze)O().revalidateOnReconnect&&ne()&&T();else{if(W==Qe)return q();if(W==$e)return q(ce)}});return H.current=!1,y.current=i,oe.current=!0,B({_k:G}),ae&&(E(S)||de?T():It(T)),()=>{H.current=!0,g()}},[i]),je(()=>{let T;function R(){const g=Y(C)?C(F().data):C;g&&T!==-1&&(T=setTimeout(j,g))}function j(){!F().error&&(w||O().isVisible())&&(f||O().isOnline())?q(Fe).then(R):R()}return R(),()=>{T&&(clearTimeout(T),T=-1)}},[C,w,f,i]),p.useDebugValue(V),a&&E(S)&&i){if(!rt&&de)throw new Error("Fallback data is required when using Suspense in SSR.");P.current=t,te.current=n,H.current=!1;const T=L[i];if(!E(T)){const R=Re(T);Ne(R)}if(E(b)){const R=q(Fe);E(V)||(R.status="fulfilled",R.value=!0),Ne(R)}else throw b}return{mutate:Re,get data(){return K.data=!0,V},get error(){return K.error=!0,b},get isValidating(){return K.isValidating=!0,A},get isLoading(){return K.isLoading=!0,re}}}),qt=async(e,t)=>{if(!t)throw new Error("A Figma API token is required to make this request.");const n=await fetch(e,{headers:{"X-FIGMA-TOKEN":t,"Content-Type":"application/json"}});if(!n.ok){const o=await n.json();throw new Error(o.message||"An error occurred while fetching data from the Figma API.")}return n.json()},Me=()=>{const{token:e,fileKey:t}=Je(),n=t?`https://api.figma.com/v1/files/${t}/variables/local`:null,{data:o,error:s,isLoading:a,isValidating:u}=zt(e&&n?[n,e]:null,qt);return{data:o,isLoading:a,isValidating:u,error:s}},Zt=()=>{const{data:e}=Me(),t=p.useMemo(()=>e!=null&&e.meta?Object.values(e.meta.variableCollections):[],[e]),n=p.useMemo(()=>e!=null&&e.meta?e.meta.variableCollections:{},[e]);return{collections:t,collectionsById:n}},Qt=()=>{const{data:e}=Me();return p.useMemo(()=>{const t=[],n={},o={};if(e!=null&&e.meta)for(const s of Object.values(e.meta.variableCollections)){t.push(...s.modes),n[s.id]=s.modes;for(const a of s.modes)o[a.modeId]=a}return{modes:t,modesByCollectionId:n,modesById:o}},[e])},$t=async(e,t,n)=>{if(!e||!t)throw new Error("A Figma API token and file key are required.");const o=`https://api.figma.com/v1/files/${t}/variables`,s=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json","X-FIGMA-TOKEN":e},body:JSON.stringify(n)}),a=await s.json();if(!s.ok)throw new Error(a.message||"Failed to perform bulk update.");return a},en=async(e,t)=>{if(!e)throw new Error("A Figma API token is required.");const n=await fetch("https://api.figma.com/v1/variables",{method:"POST",headers:{"Content-Type":"application/json","X-FIGMA-TOKEN":e},body:JSON.stringify(t)});if(!n.ok){const o=await n.json();throw new Error(o.message||"Failed to create Figma variable.")}return n.json()},tn=async(e,t)=>{if(!e)throw new Error("A Figma API token is required.");const n=`https://api.figma.com/v1/variables/${t}`,o=await fetch(n,{method:"DELETE",headers:{"Content-Type":"application/json","X-FIGMA-TOKEN":e}});if(!o.ok){const s=await o.json();throw new Error(s.message||"Failed to delete Figma variable.")}},nn=async(e,t,n)=>{if(!e)throw new Error("A Figma API token is required.");const o=`https://api.figma.com/v1/variables/${t}`,s=await fetch(o,{method:"PUT",headers:{"Content-Type":"application/json","X-FIGMA-TOKEN":e},body:JSON.stringify(n)});if(!s.ok){const a=await s.json();throw new Error(a.message||"Failed to update Figma variable.")}};function rn(e,t){return e.filter(n=>{let o=!0;return t.resolvedType&&(o=o&&n.resolvedType===t.resolvedType),t.name&&(o=o&&n.name.includes(t.name)),o})}I.FigmaVarsProvider=ht,I.bulkUpdateVariables=$t,I.createVariable=en,I.deleteVariable=tn,I.filterVariables=rn,I.updateVariable=nn,I.useFigmaToken=vt,I.useVariableCollections=Zt,I.useVariableModes=Qt,I.useVariables=Me,Object.defineProperty(I,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Retrieves the Figma API token from the FigmaVarsProvider.
|
|
3
3
|
* This hook must be used within a component wrapped by FigmaVarsProvider.
|
|
4
|
+
*
|
|
5
|
+
* @returns The Figma Personal Access Token, or `null` if it has not been provided.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```tsx
|
|
9
|
+
* const MyComponent = () => {
|
|
10
|
+
* const figmaToken = useFigmaToken();
|
|
11
|
+
* // Now you can use the token for manual API calls if needed.
|
|
12
|
+
* return <div>...</div>;
|
|
13
|
+
* };
|
|
14
|
+
* ```
|
|
4
15
|
*/
|
|
5
16
|
declare const useFigmaToken: () => string | null;
|
|
6
17
|
export default useFigmaToken;
|
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
import { FigmaCollection } from 'types';
|
|
2
2
|
/**
|
|
3
|
-
* A hook to
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* A convenience hook to access the variable collections from the data fetched by `useVariables`.
|
|
4
|
+
* This hook does not perform its own data fetching; it's a lightweight selector on the main data source.
|
|
5
|
+
*
|
|
6
|
+
* It's recommended to use this hook when you only need collection data to avoid re-rendering components unnecessarily when other parts of the Figma data change.
|
|
7
|
+
*
|
|
8
|
+
* @returns An object containing the collections as an array (`collections`) and as a map by ID (`collectionsById`).
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* const { collections } = useVariableCollections();
|
|
13
|
+
*
|
|
14
|
+
* return (
|
|
15
|
+
* <ul>
|
|
16
|
+
* {collections.map(collection => (
|
|
17
|
+
* <li key={collection.id}>{collection.name}</li>
|
|
18
|
+
* ))}
|
|
19
|
+
* </ul>
|
|
20
|
+
* );
|
|
21
|
+
* ```
|
|
6
22
|
*/
|
|
7
|
-
export declare const useVariableCollections: (
|
|
23
|
+
export declare const useVariableCollections: () => {
|
|
8
24
|
collections: FigmaCollection[];
|
|
9
25
|
collectionsById: Record<string, FigmaCollection>;
|
|
10
|
-
isLoading: boolean;
|
|
11
|
-
isValidating: boolean;
|
|
12
|
-
error: any;
|
|
13
26
|
};
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { UseVariableModesResult } from '../types/hooks';
|
|
2
2
|
/**
|
|
3
|
-
* A hook to
|
|
3
|
+
* A convenience hook to access and process variable modes from the data fetched by `useVariables`.
|
|
4
|
+
* This hook does not perform its own data fetching; it's a lightweight selector that memoizes the processed mode data.
|
|
4
5
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
6
|
+
* Use this hook when you need mode data, structured for easy access.
|
|
7
|
+
*
|
|
8
|
+
* @returns An object containing all modes as an array (`modes`), modes grouped by collection ID (`modesByCollectionId`), and modes indexed by their own ID (`modesById`).
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* const { modesById } = useVariableModes();
|
|
13
|
+
* const lightMode = modesById['mode-123'];
|
|
14
|
+
* ```
|
|
7
15
|
*/
|
|
8
|
-
export declare const useVariableModes: (
|
|
16
|
+
export declare const useVariableModes: () => UseVariableModesResult;
|
|
@@ -1,13 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LocalVariablesResponse } from 'types';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* The primary hook for fetching all local variables, collections, and modes for the file specified in the `FigmaVarsProvider`.
|
|
4
|
+
* This hook serves as the foundation for other data hooks like `useVariableCollections` and `useVariableModes`.
|
|
4
5
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
6
|
+
* It uses `swr` for efficient data fetching, caching, and revalidation.
|
|
7
|
+
*
|
|
8
|
+
* @returns An object containing the raw API response (`data`), loading state (`isLoading`), validation state (`isValidating`), and any errors (`error`).
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* const { data, isLoading, error } = useVariables();
|
|
13
|
+
*
|
|
14
|
+
* if (isLoading) return <div>Loading...</div>;
|
|
15
|
+
* if (error) return <div>Error: {error.message}</div>;
|
|
16
|
+
*
|
|
17
|
+
* const collections = Object.values(data?.meta.variableCollections ?? {});
|
|
18
|
+
* ```
|
|
7
19
|
*/
|
|
8
|
-
export declare const useVariables: (
|
|
9
|
-
|
|
10
|
-
variablesById: Record<string, FigmaVariable>;
|
|
20
|
+
export declare const useVariables: () => {
|
|
21
|
+
data: LocalVariablesResponse | undefined;
|
|
11
22
|
isLoading: boolean;
|
|
12
23
|
isValidating: boolean;
|
|
13
24
|
error: any;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,12 +2,10 @@ export { default as useFigmaToken } from './hooks/useFigmaToken';
|
|
|
2
2
|
export { useVariables } from './hooks/useVariables';
|
|
3
3
|
export { useVariableCollections } from './hooks/useVariableCollections';
|
|
4
4
|
export { useVariableModes } from './hooks/useVariableModes';
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
5
|
+
export { bulkUpdateVariables } from './mutations/bulkUpdateVariables';
|
|
6
|
+
export { createVariable } from './mutations/createVariable';
|
|
7
|
+
export { deleteVariable } from './mutations/deleteVariable';
|
|
8
|
+
export { updateVariable } from './mutations/updateVariable';
|
|
9
9
|
export * from './types';
|
|
10
10
|
export * from './utils/filterVariables';
|
|
11
|
-
export * from './utils/fetchHelpers';
|
|
12
|
-
export * from './utils/authHelpers';
|
|
13
11
|
export { FigmaVarsProvider } from './contexts/FigmaTokenContext';
|
|
@@ -1,7 +1,25 @@
|
|
|
1
|
-
import { BulkUpdatePayload
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { BulkUpdatePayload } from '../types/mutations';
|
|
2
|
+
/**
|
|
3
|
+
* Performs a bulk update of variables in a Figma file.
|
|
4
|
+
* This endpoint can be used to create, update, or delete multiple variables in a single API call.
|
|
5
|
+
*
|
|
6
|
+
* @param token - The Figma Personal Access Token.
|
|
7
|
+
* @param fileKey - The key of the Figma file where the variables reside.
|
|
8
|
+
* @param payload - The bulk update payload, containing arrays of variables to create, update, and/or delete.
|
|
9
|
+
* @returns A promise that resolves with the metadata from the Figma API about the bulk operation.
|
|
10
|
+
* @throws Will throw an error if the fetch call fails or if the API returns an error response.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const payload = {
|
|
15
|
+
* create: [{ name: "new-var", variableCollectionId: "VC:1:1", resolvedType: "FLOAT" }],
|
|
16
|
+
* update: [{ id: "VariableID:123:456", name: "updated-name" }],
|
|
17
|
+
* delete: ["VariableID:789:101"]
|
|
18
|
+
* };
|
|
19
|
+
*
|
|
20
|
+
* bulkUpdateVariables("your-token", "your-file-key", payload)
|
|
21
|
+
* .then(response => console.log("Bulk update successful:", response))
|
|
22
|
+
* .catch(error => console.error(error));
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare const bulkUpdateVariables: (token: string, fileKey: string, payload: BulkUpdatePayload) => Promise<any>;
|
|
@@ -1,7 +1,26 @@
|
|
|
1
|
-
import { CreateVariablePayload
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { CreateVariablePayload } from '../types/mutations';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a new variable in a Figma file.
|
|
4
|
+
*
|
|
5
|
+
* This function sends a POST request to the Figma API to create a new variable.
|
|
6
|
+
* It requires a valid Figma token with `file_variables:write` scope.
|
|
7
|
+
*
|
|
8
|
+
* @param token - The Figma Personal Access Token.
|
|
9
|
+
* @param payload - The data for the new variable, including its name, collection ID, and type.
|
|
10
|
+
* @returns A promise that resolves with the created variable data from the Figma API.
|
|
11
|
+
* @throws Will throw an error if the fetch call fails or if the API returns an error response.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const newVariableData = {
|
|
16
|
+
* name: "new-color",
|
|
17
|
+
* variableCollectionId: "VariableCollectionId:1:1",
|
|
18
|
+
* resolvedType: "COLOR"
|
|
19
|
+
* };
|
|
20
|
+
*
|
|
21
|
+
* createVariable("your-figma-token", newVariableData)
|
|
22
|
+
* .then(result => console.log("Variable created:", result))
|
|
23
|
+
* .catch(error => console.error(error));
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare const createVariable: (token: string, payload: CreateVariablePayload) => Promise<any>;
|
|
@@ -1,7 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Deletes a variable from a Figma file.
|
|
3
|
+
*
|
|
4
|
+
* This function sends a DELETE request to the Figma API to remove a single variable.
|
|
5
|
+
* It requires a valid Figma token with `file_variables:write` scope.
|
|
6
|
+
*
|
|
7
|
+
* @param token - The Figma Personal Access Token.
|
|
8
|
+
* @param variableId - The ID of the variable to delete.
|
|
9
|
+
* @returns A promise that resolves when the variable has been successfully deleted. The Figma API returns no content on a successful DELETE.
|
|
10
|
+
* @throws Will throw an error if the fetch call fails or if the API returns an error response.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* deleteVariable("your-figma-token", "VariableID:1:1")
|
|
15
|
+
* .then(() => console.log("Variable deleted successfully"))
|
|
16
|
+
* .catch(error => console.error(error));
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare const deleteVariable: (token: string, variableId: string) => Promise<void>;
|
|
@@ -1,7 +1,26 @@
|
|
|
1
|
-
import { UpdateVariablePayload
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { UpdateVariablePayload } from '../types/mutations';
|
|
2
|
+
/**
|
|
3
|
+
* Updates an existing variable in a Figma file.
|
|
4
|
+
*
|
|
5
|
+
* This function sends a PUT request to the Figma API to modify a single variable.
|
|
6
|
+
* It requires a valid Figma token with `file_variables:write` scope.
|
|
7
|
+
*
|
|
8
|
+
* @param token - The Figma Personal Access Token.
|
|
9
|
+
* @param variableId - The ID of the variable to update.
|
|
10
|
+
* @param payload - The data to update for the variable.
|
|
11
|
+
* @returns A promise that resolves when the variable has been successfully updated. The Figma API returns no content on a successful PUT.
|
|
12
|
+
* @throws Will throw an error if the fetch call fails or if the API returns an error response.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* const updatedData = {
|
|
17
|
+
* name: "new-color-name",
|
|
18
|
+
* description: "An updated description"
|
|
19
|
+
* };
|
|
20
|
+
*
|
|
21
|
+
* updateVariable("your-figma-token", "VariableID:1:1", updatedData)
|
|
22
|
+
* .then(() => console.log("Variable updated successfully"))
|
|
23
|
+
* .catch(error => console.error(error));
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare const updateVariable: (token: string, variableId: string, payload: UpdateVariablePayload) => Promise<void>;
|
package/dist/types/figma.d.ts
CHANGED
|
@@ -1,48 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The resolved type of a Figma variable.
|
|
3
|
+
*/
|
|
1
4
|
export type ResolvedType = 'BOOLEAN' | 'FLOAT' | 'STRING' | 'COLOR';
|
|
5
|
+
/**
|
|
6
|
+
* The scopes where a Figma variable can be applied.
|
|
7
|
+
* `ALL_SCOPES` is a general-purpose scope. Other values restrict the variable to specific properties.
|
|
8
|
+
*/
|
|
2
9
|
export type VariableScope = 'ALL_SCOPES' | 'TEXT_CONTENT' | 'CORNER_RADIUS' | 'WIDTH_HEIGHT' | 'GAP' | 'STROKE_FLOAT' | 'OPACITY' | 'EFFECT_FLOAT' | 'FONT_WEIGHT' | 'FONT_SIZE' | 'LINE_HEIGHT' | 'LETTER_SPACING' | 'PARAGRAPH_SPACING' | 'PARAGRAPH_INDENT' | 'FONT_FAMILY' | 'FONT_STYLE' | 'FONT_VARIATIONS' | 'ALL_FILLS' | 'FRAME_FILL' | 'SHAPE_FILL' | 'TEXT_FILL' | 'STROKE_COLOR' | 'EFFECT_COLOR';
|
|
10
|
+
/**
|
|
11
|
+
* Represents a color in RGBA format.
|
|
12
|
+
*/
|
|
3
13
|
export interface Color {
|
|
14
|
+
/** The red channel value (0-1). */
|
|
4
15
|
r: number;
|
|
16
|
+
/** The green channel value (0-1). */
|
|
5
17
|
g: number;
|
|
18
|
+
/** The blue channel value (0-1). */
|
|
6
19
|
b: number;
|
|
20
|
+
/** The alpha (opacity) channel value (0-1). */
|
|
7
21
|
a: number;
|
|
8
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Represents an alias to another Figma variable.
|
|
25
|
+
* This is used when a variable's value is set to reference another variable.
|
|
26
|
+
*/
|
|
9
27
|
export interface VariableAlias {
|
|
28
|
+
/** The type of the value, indicating it's a variable alias. */
|
|
10
29
|
type: 'VARIABLE_ALIAS';
|
|
30
|
+
/** The ID of the variable being referenced. */
|
|
11
31
|
id: string;
|
|
12
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* The possible value types for a variable in a specific mode.
|
|
35
|
+
* It can be a primitive value, a color object, or an alias to another variable.
|
|
36
|
+
*/
|
|
13
37
|
export type VariableValue = string | boolean | number | Color | VariableAlias;
|
|
38
|
+
/**
|
|
39
|
+
* Represents a single Figma variable.
|
|
40
|
+
*/
|
|
14
41
|
export interface FigmaVariable {
|
|
42
|
+
/** The unique identifier for the variable. */
|
|
15
43
|
id: string;
|
|
44
|
+
/** The name of the variable. */
|
|
16
45
|
name: string;
|
|
46
|
+
/** The ID of the collection this variable belongs to. */
|
|
17
47
|
variableCollectionId: string;
|
|
48
|
+
/** The underlying data type of the variable. */
|
|
18
49
|
resolvedType: ResolvedType;
|
|
50
|
+
/** A map of mode IDs to the variable's value in that mode. */
|
|
19
51
|
valuesByMode: Record<string, VariableValue>;
|
|
52
|
+
/** The description of the variable, as set in Figma. */
|
|
20
53
|
description: string;
|
|
54
|
+
/** Whether the variable is hidden when publishing the library. */
|
|
21
55
|
hiddenFromPublishing: boolean;
|
|
56
|
+
/** The scopes in which this variable can be used. */
|
|
22
57
|
scopes: VariableScope[];
|
|
58
|
+
/** Platform-specific code syntax for this variable (e.g., for Web, iOS, Android). */
|
|
23
59
|
codeSyntax: Record<string, string>;
|
|
60
|
+
/** The timestamp of the last update. */
|
|
24
61
|
updatedAt: string;
|
|
25
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Represents a single mode within a variable collection.
|
|
65
|
+
*/
|
|
26
66
|
export interface VariableMode {
|
|
67
|
+
/** The unique identifier for the mode. */
|
|
27
68
|
modeId: string;
|
|
69
|
+
/** The name of the mode (e.g., "Light", "Dark"). */
|
|
28
70
|
name: string;
|
|
29
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* Represents a collection of Figma variables, which can contain multiple modes.
|
|
74
|
+
*/
|
|
30
75
|
export interface FigmaCollection {
|
|
76
|
+
/** The unique identifier for the collection. */
|
|
31
77
|
id: string;
|
|
78
|
+
/** The name of the collection (e.g., "Brand Colors"). */
|
|
32
79
|
name: string;
|
|
80
|
+
/** An array of modes available in this collection. */
|
|
33
81
|
modes: VariableMode[];
|
|
82
|
+
/** The ID of the default mode for this collection. */
|
|
34
83
|
defaultModeId: string;
|
|
84
|
+
/** An array of variable IDs that belong to this collection. */
|
|
35
85
|
variableIds: string[];
|
|
86
|
+
/** Whether the collection is hidden when publishing the library. */
|
|
36
87
|
hiddenFromPublishing: boolean;
|
|
88
|
+
/** The timestamp of the last update. */
|
|
37
89
|
updatedAt: string;
|
|
38
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* The structure of the successful response from the Figma API's `/v1/files/{file_key}/variables/local` endpoint.
|
|
93
|
+
*/
|
|
39
94
|
export interface LocalVariablesResponse {
|
|
95
|
+
/** Contains the metadata about the variables and collections. */
|
|
40
96
|
meta: {
|
|
97
|
+
/** A map of collection IDs to `FigmaCollection` objects. */
|
|
41
98
|
variableCollections: Record<string, FigmaCollection>;
|
|
99
|
+
/** A map of variable IDs to `FigmaVariable` objects. */
|
|
42
100
|
variables: Record<string, FigmaVariable>;
|
|
43
101
|
};
|
|
44
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* A generic error shape for failed Figma API requests.
|
|
105
|
+
*/
|
|
45
106
|
export interface FigmaError {
|
|
107
|
+
/** The HTTP status code of the error. */
|
|
46
108
|
statusCode: number;
|
|
109
|
+
/** The error message from the API. */
|
|
47
110
|
message: string;
|
|
48
111
|
}
|
package/dist/types/hooks.d.ts
CHANGED
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
import { VariableMode } from './figma';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
error: Error | null;
|
|
6
|
-
}
|
|
2
|
+
/**
|
|
3
|
+
* The return type for the `useVariableModes` hook.
|
|
4
|
+
*/
|
|
7
5
|
export interface UseVariableModesResult {
|
|
6
|
+
/** A flat array of all modes across all collections. */
|
|
8
7
|
modes: VariableMode[];
|
|
8
|
+
/** A map of collection IDs to an array of modes belonging to that collection. */
|
|
9
9
|
modesByCollectionId: Record<string, VariableMode[]>;
|
|
10
|
+
/** A map of mode IDs to the corresponding mode object for quick lookups. */
|
|
10
11
|
modesById: Record<string, VariableMode>;
|
|
11
|
-
isLoading: boolean;
|
|
12
|
-
isValidating: boolean;
|
|
13
|
-
error: Error | null;
|
|
14
|
-
}
|
|
15
|
-
export interface SyncStatus {
|
|
16
|
-
isSyncing: boolean;
|
|
17
|
-
lastSynced: Date | null;
|
|
18
|
-
error: string | null;
|
|
19
12
|
}
|