@figma-vars/hooks 3.0.0-beta.1 → 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 (70) hide show
  1. package/README.md +417 -173
  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 +36 -9
  7. package/dist/api/mutator.d.ts.map +1 -1
  8. package/dist/constants/index.d.ts +2 -28
  9. package/dist/constants/index.d.ts.map +1 -1
  10. package/dist/contexts/FigmaTokenContext.d.ts.map +1 -1
  11. package/dist/contexts/FigmaVarsProvider.d.ts +3 -1
  12. package/dist/contexts/FigmaVarsProvider.d.ts.map +1 -1
  13. package/dist/contexts/index.d.ts +1 -1
  14. package/dist/contexts/index.d.ts.map +1 -1
  15. package/dist/contexts/useFigmaTokenContext.d.ts.map +1 -1
  16. package/dist/core/index.d.cts +8 -0
  17. package/dist/core/index.d.ts +8 -0
  18. package/dist/core/index.d.ts.map +1 -0
  19. package/dist/core.cjs +1 -0
  20. package/dist/core.d.cts +2 -0
  21. package/dist/core.d.ts +2 -0
  22. package/dist/core.mjs +20 -0
  23. package/dist/hooks/index.d.ts +64 -0
  24. package/dist/hooks/index.d.ts.map +1 -1
  25. package/dist/hooks/useBulkUpdateVariables.d.ts.map +1 -1
  26. package/dist/hooks/useCollectionById.d.ts +31 -0
  27. package/dist/hooks/useCollectionById.d.ts.map +1 -0
  28. package/dist/hooks/useCreateVariable.d.ts.map +1 -1
  29. package/dist/hooks/useDeleteVariable.d.ts.map +1 -1
  30. package/dist/hooks/useFigmaToken.d.ts.map +1 -1
  31. package/dist/hooks/useInvalidateVariables.d.ts +34 -0
  32. package/dist/hooks/useInvalidateVariables.d.ts.map +1 -0
  33. package/dist/hooks/useModesByCollection.d.ts +34 -0
  34. package/dist/hooks/useModesByCollection.d.ts.map +1 -0
  35. package/dist/hooks/usePublishedVariables.d.ts +42 -0
  36. package/dist/hooks/usePublishedVariables.d.ts.map +1 -0
  37. package/dist/hooks/useUpdateVariable.d.ts.map +1 -1
  38. package/dist/hooks/useVariableById.d.ts +31 -0
  39. package/dist/hooks/useVariableById.d.ts.map +1 -0
  40. package/dist/hooks/useVariableCollections.d.ts.map +1 -1
  41. package/dist/hooks/useVariableModes.d.ts.map +1 -1
  42. package/dist/hooks/useVariables.d.ts +3 -1
  43. package/dist/hooks/useVariables.d.ts.map +1 -1
  44. package/dist/index-5ZyKWuYv.cjs +1 -0
  45. package/dist/index-ClHLYVvu.js +142 -0
  46. package/dist/index.cjs +1 -1
  47. package/dist/index.d.cts +9 -4
  48. package/dist/index.d.ts +9 -4
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/index.mjs +319 -163
  51. package/dist/types/contexts.d.ts +30 -3
  52. package/dist/types/contexts.d.ts.map +1 -1
  53. package/dist/types/figma.d.ts +64 -3
  54. package/dist/types/figma.d.ts.map +1 -1
  55. package/dist/types/hooks.d.ts.map +1 -1
  56. package/dist/types/index.d.ts.map +1 -1
  57. package/dist/types/mutations.d.ts +18 -4
  58. package/dist/types/mutations.d.ts.map +1 -1
  59. package/dist/utils/errorHelpers.d.ts +142 -0
  60. package/dist/utils/errorHelpers.d.ts.map +1 -0
  61. package/dist/utils/filterVariables.d.ts.map +1 -1
  62. package/dist/utils/index.d.ts +3 -1
  63. package/dist/utils/index.d.ts.map +1 -1
  64. package/dist/utils/swrKeys.d.ts +24 -0
  65. package/dist/utils/swrKeys.d.ts.map +1 -0
  66. package/dist/utils/typeGuards.d.ts +50 -0
  67. package/dist/utils/typeGuards.d.ts.map +1 -0
  68. package/package.json +75 -31
  69. package/scripts/export-variables.mjs +101 -0
  70. package/dist/index.d.mts +0 -2
@@ -1,3 +1,22 @@
1
+ /**
2
+ * Options for configuring fetcher behavior.
3
+ *
4
+ * @public
5
+ */
6
+ export interface FetcherOptions {
7
+ /**
8
+ * Optional AbortSignal to cancel the request.
9
+ */
10
+ signal?: AbortSignal;
11
+ /**
12
+ * Optional timeout in milliseconds. Creates an AbortSignal internally if provided.
13
+ */
14
+ timeout?: number;
15
+ /**
16
+ * Optional fetch implementation override (useful for testing or custom fetch implementations).
17
+ */
18
+ fetch?: typeof fetch;
19
+ }
1
20
  /**
2
21
  * Low-level utility to fetch data from the Figma Variables REST API with authentication.
3
22
  *
@@ -6,13 +25,17 @@
6
25
  * Parses JSON responses and throws detailed errors for failed requests.
7
26
  * Intended for internal use by hooks but can be used directly for custom API interactions.
8
27
  *
28
+ * Supports request cancellation via AbortSignal and timeout handling.
29
+ *
9
30
  * @param url - The full Figma REST API endpoint URL (e.g., 'https://api.figma.com/v1/files/{file_key}/variables').
10
31
  * @param token - Figma Personal Access Token (PAT) for authentication.
32
+ * @param options - Optional configuration for abort signal, timeout, or custom fetch implementation.
11
33
  *
12
34
  * @returns A Promise resolving to the parsed JSON response from the Figma API.
13
35
  *
14
36
  * @throws Throws an Error if the token is not provided.
15
37
  * @throws Throws an Error if the HTTP response is not ok, including the message returned by the Figma API or a default error message.
38
+ * @throws Throws an AbortError if the request is aborted or times out.
16
39
  *
17
40
  * @example
18
41
  * ```ts
@@ -23,7 +46,15 @@
23
46
  * const data = await fetcher(url, token);
24
47
  * return data;
25
48
  * }
49
+ *
50
+ * // With timeout:
51
+ * const data = await fetcher(url, token, { timeout: 5000 });
52
+ *
53
+ * // With abort signal:
54
+ * const controller = new AbortController();
55
+ * const data = await fetcher(url, token, { signal: controller.signal });
56
+ * controller.abort(); // Cancel the request
26
57
  * ```
27
58
  */
28
- export declare function fetcher<TResponse = unknown>(url: string, token: string): Promise<TResponse>;
59
+ export declare function fetcher<TResponse = unknown>(url: string, token: string, options?: FetcherOptions): Promise<TResponse>;
29
60
  //# sourceMappingURL=fetcher.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fetcher.d.ts","sourceRoot":"","sources":["../../src/api/fetcher.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAsB,OAAO,CAAC,SAAS,GAAG,OAAO,EAC/C,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,SAAS,CAAC,CA2BpB"}
1
+ {"version":3,"file":"fetcher.d.ts","sourceRoot":"","sources":["../../src/api/fetcher.ts"],"names":[],"mappings":"AAWA;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,KAAK,CAAA;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAsB,OAAO,CAAC,SAAS,GAAG,OAAO,EAC/C,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,SAAS,CAAC,CA0FpB"}
@@ -23,4 +23,6 @@
23
23
  */
24
24
  export { fetcher } from './fetcher';
25
25
  export { mutator } from './mutator';
26
+ export type { FetcherOptions } from './fetcher';
27
+ export type { MutatorOptions } from './mutator';
26
28
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AACrC,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA"}
@@ -1,4 +1,23 @@
1
- import { VariableAction } from '../types/mutations';
1
+ import { VariableAction, BulkUpdatePayload } from '../types/mutations.js';
2
+ /**
3
+ * Options for configuring mutator behavior.
4
+ *
5
+ * @public
6
+ */
7
+ export interface MutatorOptions {
8
+ /**
9
+ * Optional AbortSignal to cancel the request.
10
+ */
11
+ signal?: AbortSignal;
12
+ /**
13
+ * Optional timeout in milliseconds. Creates an AbortSignal internally if provided.
14
+ */
15
+ timeout?: number;
16
+ /**
17
+ * Optional fetch implementation override (useful for testing or custom fetch implementations).
18
+ */
19
+ fetch?: typeof fetch;
20
+ }
2
21
  /**
3
22
  * Low-level utility to send authenticated POST, PUT, or DELETE requests to the Figma Variables REST API.
4
23
  *
@@ -7,28 +26,36 @@ import { VariableAction } from '../types/mutations';
7
26
  * It handles JSON serialization of the request body, parses JSON responses, and propagates detailed errors.
8
27
  * Intended primarily for internal use by mutation hooks, but also suitable for direct custom API mutations.
9
28
  *
10
- * @typeParam T - The expected response type returned from the Figma API.
29
+ * Supports request cancellation via AbortSignal and timeout handling.
30
+ *
31
+ * @typeParam TResponse - The expected response type returned from the Figma API.
11
32
  * @param url - The full Figma REST API endpoint URL (e.g., 'https://api.figma.com/v1/files/{file_key}/variables').
12
33
  * @param token - Figma Personal Access Token (PAT) used for authentication.
13
34
  * @param action - The action for the mutation: 'CREATE', 'UPDATE', or 'DELETE'.
14
- * @param body - Optional request payload sent as a JSON string.
35
+ * @param body - Optional request payload. For bulk operations, use BulkUpdatePayload. For individual operations, use objects with `variables` array.
36
+ * @param options - Optional configuration for abort signal, timeout, or custom fetch implementation.
15
37
  *
16
38
  * @returns A Promise resolving to the parsed JSON response from the Figma API.
17
39
  *
18
- * @throws Throws an Error if the token is not provided.
19
- * @throws Throws an Error if the HTTP response is unsuccessful, including the error message from the API or a default message.
40
+ * @throws Throws a FigmaApiError if the token is not provided or if the HTTP response is unsuccessful.
41
+ * @throws Throws an AbortError if the request is aborted or times out.
20
42
  *
21
43
  * @example
22
44
  * ```ts
23
45
  * import { mutator } from '@figma-vars/hooks/api';
24
46
  *
25
47
  * async function updateVariable(fileKey: string, token: string, variableId: string) {
26
- * const url = `https://api.figma.com/v1/files/${fileKey}/variables/${variableId}`;
27
- * const payload = { name: 'Updated Name' };
28
- * const result = await mutator(url, token, 'PUT', payload);
48
+ * const url = `https://api.figma.com/v1/files/${fileKey}/variables`;
49
+ * const payload = { variables: [{ action: 'UPDATE', id: variableId, name: 'Updated Name' }] };
50
+ * const result = await mutator(url, token, 'UPDATE', payload);
29
51
  * return result;
30
52
  * }
53
+ *
54
+ * // With timeout:
55
+ * const result = await mutator(url, token, 'UPDATE', payload, { timeout: 5000 });
31
56
  * ```
32
57
  */
33
- export declare function mutator<TResponse = unknown, TBody extends Record<string, unknown> = Record<string, unknown>>(url: string, token: string, action: VariableAction, body?: TBody): Promise<TResponse>;
58
+ export declare function mutator<TResponse = unknown>(url: string, token: string, action: VariableAction, body?: BulkUpdatePayload | {
59
+ variables?: Array<Record<string, unknown>>;
60
+ } | Record<string, unknown>, options?: MutatorOptions): Promise<TResponse>;
34
61
  //# sourceMappingURL=mutator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mutator.d.ts","sourceRoot":"","sources":["../../src/api/mutator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAsB,OAAO,CAAC,SAAS,GAAG,OAAO,EAAE,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChH,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,cAAc,EACtB,IAAI,CAAC,EAAE,KAAK,GACX,OAAO,CAAC,SAAS,CAAC,CAqCpB"}
1
+ {"version":3,"file":"mutator.d.ts","sourceRoot":"","sources":["../../src/api/mutator.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAG3E;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,KAAK,CAAA;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAsB,OAAO,CAAC,SAAS,GAAG,OAAO,EAC/C,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,cAAc,EACtB,IAAI,CAAC,EACD,iBAAiB,GACjB;IAAE,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;CAAE,GAC9C,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC3B,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,SAAS,CAAC,CAyGpB"}
@@ -11,34 +11,8 @@
11
11
  */
12
12
  export declare const FIGMA_API_BASE_URL = "https://api.figma.com";
13
13
  export declare const FIGMA_FILES_ENDPOINT = "https://api.figma.com/v1/files";
14
- /**
15
- * Builds the Figma Variables endpoint URL for a given file key.
16
- *
17
- * @param fileKey - The unique key of the Figma file.
18
- * @returns The URL string to access variables in the specified file.
19
- *
20
- * @example
21
- * ```ts
22
- * const url = FIGMA_VARIABLES_ENDPOINT('your-file-key')
23
- * ```
24
- */
25
- export declare const FIGMA_VARIABLES_ENDPOINT: (fileKey: string) => string;
26
- /**
27
- * The base endpoint for creating new variables via POST requests.
28
- */
29
- export declare const FIGMA_POST_VARIABLES_ENDPOINT = "https://api.figma.com/v1/variables";
30
- /**
31
- * Builds the URL to access a specific Figma variable by its ID.
32
- *
33
- * @param variableId - The unique ID of the Figma variable.
34
- * @returns The URL string to access the variable.
35
- *
36
- * @example
37
- * ```ts
38
- * const url = FIGMA_VARIABLE_BY_ID_ENDPOINT('variable-id')
39
- * ```
40
- */
41
- export declare const FIGMA_VARIABLE_BY_ID_ENDPOINT: (variableId: string) => string;
14
+ export declare const FIGMA_PUBLISHED_VARIABLES_PATH: (fileKey: string) => string;
15
+ export declare const FIGMA_FILE_VARIABLES_PATH: (fileKey: string) => string;
42
16
  /**
43
17
  * Builds the URL to fetch local variables for a given Figma file.
44
18
  *
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,eAAO,MAAM,kBAAkB,0BAA0B,CAAC;AAE1D,eAAO,MAAM,oBAAoB,mCAAmC,CAAC;AAIrE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,wBAAwB,GAAI,SAAS,MAAM,WACR,CAAC;AAEjD;;GAEG;AACH,eAAO,MAAM,6BAA6B,uCAAmC,CAAC;AAE9E;;;;;;;;;;GAUG;AACH,eAAO,MAAM,6BAA6B,GAAI,YAAY,MAAM,WACX,CAAC;AAEtD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,8BAA8B,GAAI,SAAS,MAAM,WACR,CAAC;AAEvD;;GAEG;AACH,eAAO,MAAM,iBAAiB,qBAAqB,CAAC;AAEpD;;GAEG;AACH,eAAO,MAAM,kBAAkB,kBAAkB,CAAC;AAElD;;GAEG;AACH,eAAO,MAAM,wBAAwB,mCAAmC,CAAC;AAEzE;;GAEG;AACH,eAAO,MAAM,iCAAiC,8DAA2D,CAAC;AAE1G;;GAEG;AACH,eAAO,MAAM,4BAA4B,mCAAmC,CAAC;AAE7E;;GAEG;AACH,eAAO,MAAM,gCAAgC,qCAAqC,CAAC;AAEnF;;GAEG;AACH,eAAO,MAAM,gCAAgC,qCAAqC,CAAC;AAEnF;;GAEG;AACH,eAAO,MAAM,gCAAgC,qCAAqC,CAAC;AAEnF;;GAEG;AACH,eAAO,MAAM,iCAAiC,8DACe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,eAAO,MAAM,kBAAkB,0BAA0B,CAAA;AAEzD,eAAO,MAAM,oBAAoB,mCAAmC,CAAA;AAEpE,eAAO,MAAM,8BAA8B,GAAI,SAAS,MAAM,WAClB,CAAA;AAE5C,eAAO,MAAM,yBAAyB,GAAI,SAAS,MAAM,WACvB,CAAA;AAElC;;;;;;;;;;GAUG;AACH,eAAO,MAAM,8BAA8B,GAAI,SAAS,MAAM,WACR,CAAA;AAEtD;;GAEG;AACH,eAAO,MAAM,iBAAiB,qBAAqB,CAAA;AAEnD;;GAEG;AACH,eAAO,MAAM,kBAAkB,kBAAkB,CAAA;AAEjD;;GAEG;AACH,eAAO,MAAM,wBAAwB,mCAAmC,CAAA;AAExE;;GAEG;AACH,eAAO,MAAM,iCAAiC,8DAA2D,CAAA;AAEzG;;GAEG;AACH,eAAO,MAAM,4BAA4B,mCAAmC,CAAA;AAE5E;;GAEG;AACH,eAAO,MAAM,gCAAgC,qCACT,CAAA;AAEpC;;GAEG;AACH,eAAO,MAAM,gCAAgC,qCACT,CAAA;AAEpC;;GAEG;AACH,eAAO,MAAM,gCAAgC,qCACT,CAAA;AAEpC;;GAEG;AACH,eAAO,MAAM,iCAAiC,8DACe,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"FigmaTokenContext.d.ts","sourceRoot":"","sources":["../../src/contexts/FigmaTokenContext.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAE5D,eAAO,MAAM,iBAAiB,4DAA8D,CAAC"}
1
+ {"version":3,"file":"FigmaTokenContext.d.ts","sourceRoot":"","sources":["../../src/contexts/FigmaTokenContext.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAA;AAE3D,eAAO,MAAM,iBAAiB,4DAElB,CAAA"}
@@ -7,6 +7,8 @@ import { FigmaVarsProviderProps } from '../types/contexts';
7
7
  *
8
8
  * This is the central source of truth for Figma authentication and file context within the app.
9
9
  *
10
+ * Fallback JSON files are parsed once during provider initialization to avoid repeated parsing and provide early validation.
11
+ *
10
12
  * @example
11
13
  * ```tsx
12
14
  * import { FigmaVarsProvider } from '@figma-vars/hooks/contexts';
@@ -22,5 +24,5 @@ import { FigmaVarsProviderProps } from '../types/contexts';
22
24
  *
23
25
  * @public
24
26
  */
25
- export declare const FigmaVarsProvider: ({ children, token, fileKey, fallbackFile, }: FigmaVarsProviderProps) => import("react/jsx-runtime").JSX.Element;
27
+ export declare const FigmaVarsProvider: ({ children, token, fileKey, fallbackFile, swrConfig, }: FigmaVarsProviderProps) => import("react/jsx-runtime").JSX.Element;
26
28
  //# sourceMappingURL=FigmaVarsProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FigmaVarsProvider.d.ts","sourceRoot":"","sources":["../../src/contexts/FigmaVarsProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAyB,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAGpF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,iBAAiB,GAAI,6CAK/B,sBAAsB,4CAUxB,CAAC"}
1
+ {"version":3,"file":"FigmaVarsProvider.d.ts","sourceRoot":"","sources":["../../src/contexts/FigmaVarsProvider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,sBAAsB,EACvB,MAAM,gBAAgB,CAAA;AAIvB;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,iBAAiB,GAAI,wDAM/B,sBAAsB,4CAqFxB,CAAA"}
@@ -18,7 +18,7 @@
18
18
  * }
19
19
  * ```
20
20
  */
21
- export { FigmaVarsProvider, } from './FigmaVarsProvider';
21
+ export { FigmaVarsProvider } from './FigmaVarsProvider';
22
22
  export { useFigmaTokenContext } from './useFigmaTokenContext';
23
23
  export { FigmaTokenContext } from './FigmaTokenContext';
24
24
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contexts/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EACL,iBAAiB,GAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contexts/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"useFigmaTokenContext.d.ts","sourceRoot":"","sources":["../../src/contexts/useFigmaTokenContext.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAE5D,eAAO,MAAM,oBAAoB,QAAO,qBAMvC,CAAC"}
1
+ {"version":3,"file":"useFigmaTokenContext.d.ts","sourceRoot":"","sources":["../../src/contexts/useFigmaTokenContext.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAA;AAE3D,eAAO,MAAM,oBAAoB,QAAO,qBAQvC,CAAA"}
@@ -0,0 +1,8 @@
1
+ import { fetcher } from '../api/fetcher.js';
2
+ import { mutator } from '../api/mutator.js';
3
+ import { filterVariables } from '../utils/filterVariables.js';
4
+ export { fetcher, mutator, filterVariables };
5
+ export * from '../constants/index.js';
6
+ export type * from '../types/figma.js';
7
+ export type * from '../types/mutations.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,8 @@
1
+ import { fetcher } from '../api/fetcher.js';
2
+ import { mutator } from '../api/mutator.js';
3
+ import { filterVariables } from '../utils/filterVariables.js';
4
+ export { fetcher, mutator, filterVariables };
5
+ export * from '../constants/index.js';
6
+ export type * from '../types/figma.js';
7
+ export type * from '../types/mutations.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAE7D,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,CAAA;AAC5C,cAAc,uBAAuB,CAAA;AACrC,mBAAmB,mBAAmB,CAAA;AACtC,mBAAmB,uBAAuB,CAAA"}
package/dist/core.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("./index-5ZyKWuYv.cjs");exports.CONTENT_TYPE_JSON=_.CONTENT_TYPE_JSON;exports.ERROR_MSG_BULK_UPDATE_FAILED=_.ERROR_MSG_BULK_UPDATE_FAILED;exports.ERROR_MSG_CREATE_VARIABLE_FAILED=_.ERROR_MSG_CREATE_VARIABLE_FAILED;exports.ERROR_MSG_DELETE_VARIABLE_FAILED=_.ERROR_MSG_DELETE_VARIABLE_FAILED;exports.ERROR_MSG_FETCH_FIGMA_DATA_FAILED=_.ERROR_MSG_FETCH_FIGMA_DATA_FAILED;exports.ERROR_MSG_TOKEN_FILE_KEY_REQUIRED=_.ERROR_MSG_TOKEN_FILE_KEY_REQUIRED;exports.ERROR_MSG_TOKEN_REQUIRED=_.ERROR_MSG_TOKEN_REQUIRED;exports.ERROR_MSG_UPDATE_VARIABLE_FAILED=_.ERROR_MSG_UPDATE_VARIABLE_FAILED;exports.FIGMA_API_BASE_URL=_.FIGMA_API_BASE_URL;exports.FIGMA_FILES_ENDPOINT=_.FIGMA_FILES_ENDPOINT;exports.FIGMA_FILE_VARIABLES_PATH=_.FIGMA_FILE_VARIABLES_PATH;exports.FIGMA_LOCAL_VARIABLES_ENDPOINT=_.FIGMA_LOCAL_VARIABLES_ENDPOINT;exports.FIGMA_PUBLISHED_VARIABLES_PATH=_.FIGMA_PUBLISHED_VARIABLES_PATH;exports.FIGMA_TOKEN_HEADER=_.FIGMA_TOKEN_HEADER;exports.fetcher=_.fetcher;exports.filterVariables=_.filterVariables;exports.mutator=_.mutator;
@@ -0,0 +1,2 @@
1
+ export * from './core/index'
2
+ export {}
package/dist/core.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './core/index'
2
+ export {}
package/dist/core.mjs ADDED
@@ -0,0 +1,20 @@
1
+ import { C as A, j as R, k as I, l as a, o as L, a as s, E as F, n as T, d as D, e as O, F as G, h as M, g as S, i as N, f as B, c as P, m as U } from "./index-ClHLYVvu.js";
2
+ export {
3
+ A as CONTENT_TYPE_JSON,
4
+ R as ERROR_MSG_BULK_UPDATE_FAILED,
5
+ I as ERROR_MSG_CREATE_VARIABLE_FAILED,
6
+ a as ERROR_MSG_DELETE_VARIABLE_FAILED,
7
+ L as ERROR_MSG_FETCH_FIGMA_DATA_FAILED,
8
+ s as ERROR_MSG_TOKEN_FILE_KEY_REQUIRED,
9
+ F as ERROR_MSG_TOKEN_REQUIRED,
10
+ T as ERROR_MSG_UPDATE_VARIABLE_FAILED,
11
+ D as FIGMA_API_BASE_URL,
12
+ O as FIGMA_FILES_ENDPOINT,
13
+ G as FIGMA_FILE_VARIABLES_PATH,
14
+ M as FIGMA_LOCAL_VARIABLES_ENDPOINT,
15
+ S as FIGMA_PUBLISHED_VARIABLES_PATH,
16
+ N as FIGMA_TOKEN_HEADER,
17
+ B as fetcher,
18
+ P as filterVariables,
19
+ U as mutator
20
+ };
@@ -141,4 +141,68 @@ export { useDeleteVariable } from './useDeleteVariable';
141
141
  * @public
142
142
  */
143
143
  export { useBulkUpdateVariables } from './useBulkUpdateVariables';
144
+ export { useInvalidateVariables } from './useInvalidateVariables';
145
+ /**
146
+ * React hook to fetch published Figma Variables from a file.
147
+ *
148
+ * @remarks
149
+ * Fetches variables that have been published to a library. Published variables
150
+ * are shared across files and represent the source of truth for design tokens.
151
+ *
152
+ * @see {@link https://www.figma.com/developers/api#variables | Figma Variables API}
153
+ *
154
+ * @example
155
+ * ```tsx
156
+ * import { usePublishedVariables } from '@figma-vars/hooks';
157
+ * const { data, isLoading } = usePublishedVariables();
158
+ * ```
159
+ *
160
+ * @public
161
+ */
162
+ export { usePublishedVariables } from './usePublishedVariables';
163
+ /**
164
+ * React hook to select a single variable by ID from loaded Figma variables data.
165
+ *
166
+ * @remarks
167
+ * Returns the variable with the specified ID, or undefined if not found.
168
+ *
169
+ * @example
170
+ * ```tsx
171
+ * import { useVariableById } from '@figma-vars/hooks';
172
+ * const variable = useVariableById('VariableID:123:456');
173
+ * ```
174
+ *
175
+ * @public
176
+ */
177
+ export { useVariableById } from './useVariableById';
178
+ /**
179
+ * React hook to select a single variable collection by ID from loaded Figma variables data.
180
+ *
181
+ * @remarks
182
+ * Returns the collection with the specified ID, or undefined if not found.
183
+ *
184
+ * @example
185
+ * ```tsx
186
+ * import { useCollectionById } from '@figma-vars/hooks';
187
+ * const collection = useCollectionById('VariableCollectionId:123:456');
188
+ * ```
189
+ *
190
+ * @public
191
+ */
192
+ export { useCollectionById } from './useCollectionById';
193
+ /**
194
+ * React hook to select modes for a specific variable collection.
195
+ *
196
+ * @remarks
197
+ * Returns an array of modes belonging to the specified collection.
198
+ *
199
+ * @example
200
+ * ```tsx
201
+ * import { useModesByCollection } from '@figma-vars/hooks';
202
+ * const modes = useModesByCollection('VariableCollectionId:123:456');
203
+ * ```
204
+ *
205
+ * @public
206
+ */
207
+ export { useModesByCollection } from './useModesByCollection';
144
208
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC/D;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAA;AACrE;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzD;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAC9D;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAC3D;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAC3D;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAC3D;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAA;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAA;AACrE;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAA;AACnE;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAC3D;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"useBulkUpdateVariables.d.ts","sourceRoot":"","sources":["../../src/hooks/useBulkUpdateVariables.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAOzD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,sBAAsB,4EAclC,CAAC"}
1
+ {"version":3,"file":"useBulkUpdateVariables.d.ts","sourceRoot":"","sources":["../../src/hooks/useBulkUpdateVariables.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAQxD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,sBAAsB,4EAiBlC,CAAA"}
@@ -0,0 +1,31 @@
1
+ import { FigmaCollection } from 'types';
2
+ /**
3
+ * React hook that selects a single variable collection by ID from loaded Figma variables data.
4
+ *
5
+ * @remarks
6
+ * Returns the collection with the specified ID, or `undefined` if not found.
7
+ * Useful for accessing a specific collection without manually mapping through all collections.
8
+ *
9
+ * @param collectionId - The ID of the collection to retrieve.
10
+ * @returns The collection object, or `undefined` if not found.
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * import { useCollectionById } from '@figma-vars/hooks';
15
+ *
16
+ * function CollectionDetails({ collectionId }: { collectionId: string }) {
17
+ * const collection = useCollectionById(collectionId);
18
+ *
19
+ * if (!collection) return <div>Collection not found</div>;
20
+ *
21
+ * return <div>
22
+ * <h2>{collection.name}</h2>
23
+ * <p>Variables: {collection.variableIds.length}</p>
24
+ * </div>;
25
+ * }
26
+ * ```
27
+ *
28
+ * @public
29
+ */
30
+ export declare const useCollectionById: (collectionId: string) => FigmaCollection | undefined;
31
+ //# sourceMappingURL=useCollectionById.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCollectionById.d.ts","sourceRoot":"","sources":["../../src/hooks/useCollectionById.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,OAAO,CAAA;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,iBAAiB,GAC5B,cAAc,MAAM,KACnB,eAAe,GAAG,SAMpB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"useCreateVariable.d.ts","sourceRoot":"","sources":["../../src/hooks/useCreateVariable.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAO7D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,iBAAiB,gFAc7B,CAAC"}
1
+ {"version":3,"file":"useCreateVariable.d.ts","sourceRoot":"","sources":["../../src/hooks/useCreateVariable.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AAQ5D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,iBAAiB,gFAmB7B,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"useDeleteVariable.d.ts","sourceRoot":"","sources":["../../src/hooks/useDeleteVariable.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,iBAAiB,oDAc7B,CAAC"}
1
+ {"version":3,"file":"useDeleteVariable.d.ts","sourceRoot":"","sources":["../../src/hooks/useDeleteVariable.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,iBAAiB,oDAmB7B,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"useFigmaToken.d.ts","sourceRoot":"","sources":["../../src/hooks/useFigmaToken.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;GAkBG;AACH,QAAA,MAAM,aAAa,QAAO,MAAM,GAAG,IAGlC,CAAC;AAEF,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"useFigmaToken.d.ts","sourceRoot":"","sources":["../../src/hooks/useFigmaToken.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;GAkBG;AACH,QAAA,MAAM,aAAa,QAAO,MAAM,GAAG,IAGlC,CAAA;AAED,eAAe,aAAa,CAAA"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Hook that provides cache invalidation utilities for Figma variables.
3
+ *
4
+ * @remarks
5
+ * Returns functions to invalidate and revalidate SWR cache for variables hooks.
6
+ * Use this after mutations to ensure fresh data is fetched.
7
+ *
8
+ * Supports both live API usage (with token and fileKey) and fallback-only usage
9
+ * (with fallbackFile but no fileKey).
10
+ *
11
+ * @returns Object with `invalidate` and `revalidate` functions.
12
+ *
13
+ * @example
14
+ * ```tsx
15
+ * import { useInvalidateVariables, useUpdateVariable } from '@figma-vars/hooks';
16
+ *
17
+ * function UpdateButton() {
18
+ * const { mutate } = useUpdateVariable();
19
+ * const { invalidate } = useInvalidateVariables();
20
+ *
21
+ * const handleUpdate = async () => {
22
+ * await mutate({ variableId: 'id', payload: { name: 'New Name' } });
23
+ * invalidate(); // Refetch all variable queries
24
+ * };
25
+ * }
26
+ * ```
27
+ *
28
+ * @public
29
+ */
30
+ export declare const useInvalidateVariables: () => {
31
+ invalidate: () => void;
32
+ revalidate: () => void;
33
+ };
34
+ //# sourceMappingURL=useInvalidateVariables.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useInvalidateVariables.d.ts","sourceRoot":"","sources":["../../src/hooks/useInvalidateVariables.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,sBAAsB;;;CAoDlC,CAAA"}
@@ -0,0 +1,34 @@
1
+ import { VariableMode } from 'types';
2
+ /**
3
+ * React hook that selects modes for a specific variable collection.
4
+ *
5
+ * @remarks
6
+ * Returns an array of modes belonging to the specified collection, or an empty array if not found.
7
+ * Useful for filtering modes by collection without manually accessing modesByCollectionId.
8
+ *
9
+ * @param collectionId - The ID of the collection to get modes for.
10
+ * @returns An array of VariableMode objects for the collection, or an empty array if not found.
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * import { useModesByCollection } from '@figma-vars/hooks';
15
+ *
16
+ * function CollectionModes({ collectionId }: { collectionId: string }) {
17
+ * const modes = useModesByCollection(collectionId);
18
+ *
19
+ * if (!modes.length) return <div>No modes found</div>;
20
+ *
21
+ * return (
22
+ * <ul>
23
+ * {modes.map(mode => (
24
+ * <li key={mode.modeId}>{mode.name}</li>
25
+ * ))}
26
+ * </ul>
27
+ * );
28
+ * }
29
+ * ```
30
+ *
31
+ * @public
32
+ */
33
+ export declare const useModesByCollection: (collectionId: string) => VariableMode[];
34
+ //# sourceMappingURL=useModesByCollection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useModesByCollection.d.ts","sourceRoot":"","sources":["../../src/hooks/useModesByCollection.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAEzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,oBAAoB,GAAI,cAAc,MAAM,KAAG,YAAY,EAMvE,CAAA"}
@@ -0,0 +1,42 @@
1
+ import { PublishedVariablesResponse } from '../types/figma';
2
+ /**
3
+ * Hook to fetch published Figma Variables from a file.
4
+ *
5
+ * @remarks
6
+ * This hook fetches variables that have been published to a library in Figma.
7
+ * Published variables are shared across files and represent the "source of truth"
8
+ * for design tokens in a design system. Use this hook when you need to access
9
+ * variables that are consumed from a library, rather than local file variables.
10
+ *
11
+ * **When to use:**
12
+ * - Fetching design tokens from a published library
13
+ * - Building design system dashboards that track published tokens
14
+ * - Monitoring changes to shared variables across a design system
15
+ * - Validating consistency between published and local variables
16
+ *
17
+ * **Rate Limiting:**
18
+ * The Figma API has rate limits. Published variables are typically more stable
19
+ * than local variables, so they can be cached longer. SWR handles caching and
20
+ * revalidation automatically, but be mindful of frequent refetches in production.
21
+ *
22
+ * @returns SWR response object with `data`, `error`, `isLoading`, and `isValidating`.
23
+ *
24
+ * @public
25
+ *
26
+ * @example
27
+ * ```tsx
28
+ * import { usePublishedVariables } from '@figma-vars/hooks';
29
+ *
30
+ * function LibraryTokens() {
31
+ * const { data, isLoading, error } = usePublishedVariables();
32
+ *
33
+ * if (isLoading) return <div>Loading published variables...</div>;
34
+ * if (error) return <div>Error: {error.message}</div>;
35
+ *
36
+ * const variables = Object.values(data?.meta.variables ?? {});
37
+ * return <ul>{variables.map(v => <li key={v.id}>{v.name}</li>)}</ul>;
38
+ * }
39
+ * ```
40
+ */
41
+ export declare const usePublishedVariables: () => import('swr').SWRResponse<PublishedVariablesResponse, any, import('swr').SWRConfiguration<PublishedVariablesResponse, any, import('swr').BareFetcher<PublishedVariablesResponse>> | undefined>;
42
+ //# sourceMappingURL=usePublishedVariables.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePublishedVariables.d.ts","sourceRoot":"","sources":["../../src/hooks/usePublishedVariables.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAA;AAI7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,qBAAqB,sMA+CjC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"useUpdateVariable.d.ts","sourceRoot":"","sources":["../../src/hooks/useUpdateVariable.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAI7D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,iBAAiB;gBAGoB,MAAM;aAAW,qBAAqB;EAavF,CAAC"}
1
+ {"version":3,"file":"useUpdateVariable.d.ts","sourceRoot":"","sources":["../../src/hooks/useUpdateVariable.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AAQ5D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,iBAAiB;gBAOZ,MAAM;aACT,qBAAqB;EAyBnC,CAAA"}
@@ -0,0 +1,31 @@
1
+ import { FigmaVariable } from 'types';
2
+ /**
3
+ * React hook that selects a single variable by ID from loaded Figma variables data.
4
+ *
5
+ * @remarks
6
+ * Returns the variable with the specified ID, or `undefined` if not found.
7
+ * Useful for accessing a specific variable without manually mapping through all variables.
8
+ *
9
+ * @param variableId - The ID of the variable to retrieve.
10
+ * @returns The variable object, or `undefined` if not found.
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * import { useVariableById } from '@figma-vars/hooks';
15
+ *
16
+ * function VariableDetails({ variableId }: { variableId: string }) {
17
+ * const variable = useVariableById(variableId);
18
+ *
19
+ * if (!variable) return <div>Variable not found</div>;
20
+ *
21
+ * return <div>
22
+ * <h2>{variable.name}</h2>
23
+ * <p>Type: {variable.resolvedType}</p>
24
+ * </div>;
25
+ * }
26
+ * ```
27
+ *
28
+ * @public
29
+ */
30
+ export declare const useVariableById: (variableId: string) => FigmaVariable | undefined;
31
+ //# sourceMappingURL=useVariableById.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useVariableById.d.ts","sourceRoot":"","sources":["../../src/hooks/useVariableById.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAE1C;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,eAAe,GAC1B,YAAY,MAAM,KACjB,aAAa,GAAG,SASlB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"useVariableCollections.d.ts","sourceRoot":"","sources":["../../src/hooks/useVariableCollections.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAE7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,sBAAsB;;;CAiBlC,CAAC"}
1
+ {"version":3,"file":"useVariableCollections.d.ts","sourceRoot":"","sources":["../../src/hooks/useVariableCollections.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,OAAO,CAAA;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,sBAAsB;;;CAiBlC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"useVariableModes.d.ts","sourceRoot":"","sources":["../../src/hooks/useVariableModes.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,gBAAgB,QAAO,sBAwBnC,CAAC"}
1
+ {"version":3,"file":"useVariableModes.d.ts","sourceRoot":"","sources":["../../src/hooks/useVariableModes.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,gBAAgB,QAAO,sBA0BnC,CAAA"}
@@ -4,7 +4,9 @@ import { LocalVariablesResponse } from '../types/figma';
4
4
  *
5
5
  * @remarks
6
6
  * This hook uses SWR for caching and revalidation. It fetches the variables for the
7
- * file key provided via the FigmaVarsProvider context.
7
+ * file key provided via the FigmaVarsProvider context. If a fallbackFile is provided,
8
+ * it will use that instead of making an API request, which is useful for users without
9
+ * Figma Enterprise accounts or for offline development.
8
10
  *
9
11
  * @returns SWR response object with `data`, `error`, `isLoading`, and `isValidating`.
10
12
  *