@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.
- package/README.md +417 -173
- package/dist/api/fetcher.d.ts +32 -1
- package/dist/api/fetcher.d.ts.map +1 -1
- package/dist/api/index.d.ts +2 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/mutator.d.ts +36 -9
- package/dist/api/mutator.d.ts.map +1 -1
- package/dist/constants/index.d.ts +2 -28
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/contexts/FigmaTokenContext.d.ts.map +1 -1
- package/dist/contexts/FigmaVarsProvider.d.ts +3 -1
- package/dist/contexts/FigmaVarsProvider.d.ts.map +1 -1
- package/dist/contexts/index.d.ts +1 -1
- package/dist/contexts/index.d.ts.map +1 -1
- package/dist/contexts/useFigmaTokenContext.d.ts.map +1 -1
- package/dist/core/index.d.cts +8 -0
- package/dist/core/index.d.ts +8 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core.cjs +1 -0
- package/dist/core.d.cts +2 -0
- package/dist/core.d.ts +2 -0
- package/dist/core.mjs +20 -0
- package/dist/hooks/index.d.ts +64 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/useBulkUpdateVariables.d.ts.map +1 -1
- package/dist/hooks/useCollectionById.d.ts +31 -0
- package/dist/hooks/useCollectionById.d.ts.map +1 -0
- package/dist/hooks/useCreateVariable.d.ts.map +1 -1
- package/dist/hooks/useDeleteVariable.d.ts.map +1 -1
- package/dist/hooks/useFigmaToken.d.ts.map +1 -1
- package/dist/hooks/useInvalidateVariables.d.ts +34 -0
- package/dist/hooks/useInvalidateVariables.d.ts.map +1 -0
- package/dist/hooks/useModesByCollection.d.ts +34 -0
- package/dist/hooks/useModesByCollection.d.ts.map +1 -0
- package/dist/hooks/usePublishedVariables.d.ts +42 -0
- package/dist/hooks/usePublishedVariables.d.ts.map +1 -0
- package/dist/hooks/useUpdateVariable.d.ts.map +1 -1
- package/dist/hooks/useVariableById.d.ts +31 -0
- package/dist/hooks/useVariableById.d.ts.map +1 -0
- package/dist/hooks/useVariableCollections.d.ts.map +1 -1
- package/dist/hooks/useVariableModes.d.ts.map +1 -1
- package/dist/hooks/useVariables.d.ts +3 -1
- package/dist/hooks/useVariables.d.ts.map +1 -1
- package/dist/index-5ZyKWuYv.cjs +1 -0
- package/dist/index-ClHLYVvu.js +142 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +9 -4
- package/dist/index.d.ts +9 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +319 -163
- package/dist/types/contexts.d.ts +30 -3
- package/dist/types/contexts.d.ts.map +1 -1
- package/dist/types/figma.d.ts +64 -3
- package/dist/types/figma.d.ts.map +1 -1
- package/dist/types/hooks.d.ts.map +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/mutations.d.ts +18 -4
- package/dist/types/mutations.d.ts.map +1 -1
- package/dist/utils/errorHelpers.d.ts +142 -0
- package/dist/utils/errorHelpers.d.ts.map +1 -0
- package/dist/utils/filterVariables.d.ts.map +1 -1
- package/dist/utils/index.d.ts +3 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/swrKeys.d.ts +24 -0
- package/dist/utils/swrKeys.d.ts.map +1 -0
- package/dist/utils/typeGuards.d.ts +50 -0
- package/dist/utils/typeGuards.d.ts.map +1 -0
- package/package.json +75 -31
- package/scripts/export-variables.mjs +101 -0
- package/dist/index.d.mts +0 -2
package/dist/types/figma.d.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*
|
|
12
12
|
* @public
|
|
13
13
|
*/
|
|
14
|
-
export type ResolvedType =
|
|
14
|
+
export type ResolvedType = 'BOOLEAN' | 'FLOAT' | 'STRING' | 'COLOR';
|
|
15
15
|
/**
|
|
16
16
|
* Enum of all valid Figma variable scopes.
|
|
17
17
|
*
|
|
@@ -26,7 +26,7 @@ export type ResolvedType = "BOOLEAN" | "FLOAT" | "STRING" | "COLOR";
|
|
|
26
26
|
*
|
|
27
27
|
* @public
|
|
28
28
|
*/
|
|
29
|
-
export type VariableScope =
|
|
29
|
+
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';
|
|
30
30
|
/**
|
|
31
31
|
* RGBA color value used by Figma variables of type COLOR.
|
|
32
32
|
*
|
|
@@ -66,7 +66,7 @@ export interface Color {
|
|
|
66
66
|
*/
|
|
67
67
|
export interface VariableAlias {
|
|
68
68
|
/** Type identifier for variable alias objects. Always 'VARIABLE_ALIAS'. */
|
|
69
|
-
type:
|
|
69
|
+
type: 'VARIABLE_ALIAS';
|
|
70
70
|
/** The referenced variable's Figma variable ID. */
|
|
71
71
|
id: string;
|
|
72
72
|
}
|
|
@@ -216,6 +216,28 @@ export interface LocalVariablesResponse {
|
|
|
216
216
|
variables: Record<string, FigmaVariable>;
|
|
217
217
|
};
|
|
218
218
|
}
|
|
219
|
+
export interface PublishedVariable {
|
|
220
|
+
id: string;
|
|
221
|
+
subscribed_id: string;
|
|
222
|
+
name: string;
|
|
223
|
+
key: string;
|
|
224
|
+
variableCollectionId: string;
|
|
225
|
+
resolvedType: ResolvedType;
|
|
226
|
+
updatedAt: string;
|
|
227
|
+
}
|
|
228
|
+
export interface PublishedVariableCollection {
|
|
229
|
+
id: string;
|
|
230
|
+
subscribed_id: string;
|
|
231
|
+
name: string;
|
|
232
|
+
key: string;
|
|
233
|
+
updatedAt: string;
|
|
234
|
+
}
|
|
235
|
+
export interface PublishedVariablesResponse {
|
|
236
|
+
meta: {
|
|
237
|
+
variableCollections: Record<string, PublishedVariableCollection>;
|
|
238
|
+
variables: Record<string, PublishedVariable>;
|
|
239
|
+
};
|
|
240
|
+
}
|
|
219
241
|
/**
|
|
220
242
|
* Standard error response shape for Figma API error objects.
|
|
221
243
|
*
|
|
@@ -242,4 +264,43 @@ export interface FigmaError {
|
|
|
242
264
|
/** Human-readable error message describing the failure. */
|
|
243
265
|
message: string;
|
|
244
266
|
}
|
|
267
|
+
/**
|
|
268
|
+
* Custom Error class for Figma API errors that preserves HTTP status codes.
|
|
269
|
+
*
|
|
270
|
+
* @remarks
|
|
271
|
+
* Extends the standard Error class to include HTTP status code information,
|
|
272
|
+
* making it easier for consumers to handle different error types (401, 403, 404, 429, etc.).
|
|
273
|
+
*
|
|
274
|
+
* For rate limit errors (429), includes retry-after information parsed from response headers.
|
|
275
|
+
*
|
|
276
|
+
* @example
|
|
277
|
+
* ```ts
|
|
278
|
+
* import { FigmaApiError } from '@figma-vars/hooks';
|
|
279
|
+
*
|
|
280
|
+
* try {
|
|
281
|
+
* await fetcher(url, token);
|
|
282
|
+
* } catch (error) {
|
|
283
|
+
* if (error instanceof FigmaApiError) {
|
|
284
|
+
* if (error.statusCode === 401) {
|
|
285
|
+
* // Handle authentication error
|
|
286
|
+
* } else if (error.statusCode === 429) {
|
|
287
|
+
* // Handle rate limit
|
|
288
|
+
* console.log(`Retry after ${error.retryAfter} seconds`);
|
|
289
|
+
* }
|
|
290
|
+
* }
|
|
291
|
+
* }
|
|
292
|
+
* ```
|
|
293
|
+
*
|
|
294
|
+
* @public
|
|
295
|
+
*/
|
|
296
|
+
export declare class FigmaApiError extends Error {
|
|
297
|
+
/** HTTP status code from the API response. */
|
|
298
|
+
readonly statusCode: number;
|
|
299
|
+
/**
|
|
300
|
+
* Retry-After header value in seconds (for 429 rate limit errors).
|
|
301
|
+
* Undefined if not a rate limit error or header not present.
|
|
302
|
+
*/
|
|
303
|
+
readonly retryAfter: number | undefined;
|
|
304
|
+
constructor(message: string, statusCode: number, retryAfter?: number);
|
|
305
|
+
}
|
|
245
306
|
//# sourceMappingURL=figma.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"figma.d.ts","sourceRoot":"","sources":["../../src/types/figma.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"figma.d.ts","sourceRoot":"","sources":["../../src/types/figma.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAA;AAEnE;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,aAAa,GACrB,YAAY,GACZ,cAAc,GACd,eAAe,GACf,cAAc,GACd,KAAK,GACL,cAAc,GACd,SAAS,GACT,cAAc,GACd,aAAa,GACb,WAAW,GACX,aAAa,GACb,gBAAgB,GAChB,mBAAmB,GACnB,kBAAkB,GAClB,aAAa,GACb,YAAY,GACZ,iBAAiB,GACjB,WAAW,GACX,YAAY,GACZ,YAAY,GACZ,WAAW,GACX,cAAc,GACd,cAAc,CAAA;AAElB;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,KAAK;IACpB,uBAAuB;IACvB,CAAC,EAAE,MAAM,CAAA;IACT,yBAAyB;IACzB,CAAC,EAAE,MAAM,CAAA;IACT,wBAAwB;IACxB,CAAC,EAAE,MAAM,CAAA;IACT,mCAAmC;IACnC,CAAC,EAAE,MAAM,CAAA;CACV;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,aAAa;IAC5B,2EAA2E;IAC3E,IAAI,EAAE,gBAAgB,CAAA;IACtB,mDAAmD;IACnD,EAAE,EAAE,MAAM,CAAA;CACX;AAED;;;;;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":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/types/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAC3C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAExD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,WAAW,kBAAkB;IACjC,8CAA8C;IAC9C,UAAU,EAAE,MAAM,CAAA;IAClB,mEAAmE;IACnE,OAAO,EAAE,qBAAqB,CAAA;CAC/B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,WAAW,sBAAsB;IACrC,0DAA0D;IAC1D,KAAK,EAAE,YAAY,EAAE,CAAA;IACrB,sEAAsE;IACtE,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,CAAC,CAAA;IACnD,sDAAsD;IACtD,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;CACxC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,cAAc,aAAa,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ResolvedType, VariableScope, VariableValue } from './figma';
|
|
1
|
+
import { ResolvedType, VariableScope, VariableValue } from './figma.js';
|
|
2
2
|
/**
|
|
3
3
|
* Payload for creating a new Figma variable in a specific collection.
|
|
4
4
|
*
|
|
@@ -80,7 +80,7 @@ export interface UpdateVariablePayload {
|
|
|
80
80
|
*
|
|
81
81
|
* @public
|
|
82
82
|
*/
|
|
83
|
-
export type VariableAction =
|
|
83
|
+
export type VariableAction = 'CREATE' | 'UPDATE' | 'DELETE';
|
|
84
84
|
/**
|
|
85
85
|
* Represents a change operation on a Figma variable collection.
|
|
86
86
|
*
|
|
@@ -288,10 +288,24 @@ export interface BulkUpdateResponse {
|
|
|
288
288
|
* @public
|
|
289
289
|
*/
|
|
290
290
|
export interface MutationState<TData> {
|
|
291
|
-
status:
|
|
291
|
+
status: 'idle' | 'loading' | 'success' | 'error';
|
|
292
292
|
data: TData | null;
|
|
293
293
|
error: Error | null;
|
|
294
294
|
}
|
|
295
|
+
/**
|
|
296
|
+
* Options for configuring mutation behavior.
|
|
297
|
+
*
|
|
298
|
+
* @public
|
|
299
|
+
*/
|
|
300
|
+
export interface MutationOptions {
|
|
301
|
+
/**
|
|
302
|
+
* If true, errors will be rethrown instead of being caught and stored in state.
|
|
303
|
+
* This allows callers to use try/catch for error handling.
|
|
304
|
+
*
|
|
305
|
+
* @default false
|
|
306
|
+
*/
|
|
307
|
+
throwOnError?: boolean;
|
|
308
|
+
}
|
|
295
309
|
/**
|
|
296
310
|
* Return value of mutation hooks.
|
|
297
311
|
*
|
|
@@ -305,7 +319,7 @@ export interface MutationState<TData> {
|
|
|
305
319
|
*/
|
|
306
320
|
export interface MutationResult<TData, TPayload> {
|
|
307
321
|
mutate: (payload: TPayload) => Promise<TData | undefined>;
|
|
308
|
-
status:
|
|
322
|
+
status: 'idle' | 'loading' | 'success' | 'error';
|
|
309
323
|
data: TData | null;
|
|
310
324
|
error: Error | null;
|
|
311
325
|
isLoading: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mutations.d.ts","sourceRoot":"","sources":["../../src/types/mutations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"mutations.d.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,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAA;IAChD,IAAI,EAAE,KAAK,GAAG,IAAI,CAAA;IAClB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAA;CACpB;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;OAKG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,cAAc,CAAC,KAAK,EAAE,QAAQ;IAC7C,MAAM,EAAE,CAAC,OAAO,EAAE,QAAQ,KAAK,OAAO,CAAC,KAAK,GAAG,SAAS,CAAC,CAAA;IACzD,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAA;IAChD,IAAI,EAAE,KAAK,GAAG,IAAI,CAAA;IAClB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAA;IACnB,SAAS,EAAE,OAAO,CAAA;IAClB,SAAS,EAAE,OAAO,CAAA;IAClB,OAAO,EAAE,OAAO,CAAA;CACjB"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { FigmaApiError } from '../types/figma';
|
|
2
|
+
/**
|
|
3
|
+
* Type guard to check if an error is a FigmaApiError instance.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Use this to safely check if an error has HTTP status code information before accessing `statusCode`.
|
|
7
|
+
*
|
|
8
|
+
* @param error - The error to check.
|
|
9
|
+
* @returns `true` if the error is a FigmaApiError, `false` otherwise.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* import { isFigmaApiError } from '@figma-vars/hooks';
|
|
14
|
+
*
|
|
15
|
+
* try {
|
|
16
|
+
* await mutate(payload);
|
|
17
|
+
* } catch (error) {
|
|
18
|
+
* if (isFigmaApiError(error)) {
|
|
19
|
+
* if (error.statusCode === 401) {
|
|
20
|
+
* // Handle authentication error
|
|
21
|
+
* } else if (error.statusCode === 429) {
|
|
22
|
+
* // Handle rate limit
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
export declare function isFigmaApiError(error: unknown): error is FigmaApiError;
|
|
31
|
+
/**
|
|
32
|
+
* Extracts the HTTP status code from an error, if available.
|
|
33
|
+
*
|
|
34
|
+
* @remarks
|
|
35
|
+
* Returns the status code from FigmaApiError, or `null` if the error doesn't have status information.
|
|
36
|
+
*
|
|
37
|
+
* @param error - The error to extract status code from.
|
|
38
|
+
* @returns The HTTP status code, or `null` if not available.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```tsx
|
|
42
|
+
* import { getErrorStatus } from '@figma-vars/hooks';
|
|
43
|
+
*
|
|
44
|
+
* const status = getErrorStatus(error);
|
|
45
|
+
* if (status === 401) {
|
|
46
|
+
* // Handle unauthorized
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @public
|
|
51
|
+
*/
|
|
52
|
+
export declare function getErrorStatus(error: unknown): number | null;
|
|
53
|
+
/**
|
|
54
|
+
* Extracts a human-readable error message from an error.
|
|
55
|
+
*
|
|
56
|
+
* @remarks
|
|
57
|
+
* Returns the error message, falling back to a default message if the error doesn't have one.
|
|
58
|
+
*
|
|
59
|
+
* @param error - The error to extract message from.
|
|
60
|
+
* @param defaultMessage - Optional default message if error has no message. Defaults to "An error occurred".
|
|
61
|
+
* @returns The error message string.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```tsx
|
|
65
|
+
* import { getErrorMessage } from '@figma-vars/hooks';
|
|
66
|
+
*
|
|
67
|
+
* const message = getErrorMessage(error);
|
|
68
|
+
* toast.error(message);
|
|
69
|
+
* ```
|
|
70
|
+
*
|
|
71
|
+
* @public
|
|
72
|
+
*/
|
|
73
|
+
export declare function getErrorMessage(error: unknown, defaultMessage?: string): string;
|
|
74
|
+
/**
|
|
75
|
+
* Checks if an error represents a specific HTTP status code.
|
|
76
|
+
*
|
|
77
|
+
* @remarks
|
|
78
|
+
* Convenience function to check if an error has a specific status code.
|
|
79
|
+
*
|
|
80
|
+
* @param error - The error to check.
|
|
81
|
+
* @param statusCode - The HTTP status code to check for.
|
|
82
|
+
* @returns `true` if the error has the specified status code, `false` otherwise.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```tsx
|
|
86
|
+
* import { hasErrorStatus } from '@figma-vars/hooks';
|
|
87
|
+
*
|
|
88
|
+
* if (hasErrorStatus(error, 401)) {
|
|
89
|
+
* // Handle unauthorized
|
|
90
|
+
* }
|
|
91
|
+
* ```
|
|
92
|
+
*
|
|
93
|
+
* @public
|
|
94
|
+
*/
|
|
95
|
+
export declare function hasErrorStatus(error: unknown, statusCode: number): boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Checks if an error represents a rate limit (429) response.
|
|
98
|
+
*
|
|
99
|
+
* @remarks
|
|
100
|
+
* Convenience function to check if an error is a rate limit error.
|
|
101
|
+
*
|
|
102
|
+
* @param error - The error to check.
|
|
103
|
+
* @returns `true` if the error is a rate limit error (429), `false` otherwise.
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```tsx
|
|
107
|
+
* import { isRateLimited } from '@figma-vars/hooks';
|
|
108
|
+
*
|
|
109
|
+
* if (isRateLimited(error)) {
|
|
110
|
+
* // Handle rate limit, maybe retry after delay
|
|
111
|
+
* }
|
|
112
|
+
* ```
|
|
113
|
+
*
|
|
114
|
+
* @public
|
|
115
|
+
*/
|
|
116
|
+
export declare function isRateLimited(error: unknown): boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Gets the retry-after value in seconds from a rate limit error.
|
|
119
|
+
*
|
|
120
|
+
* @remarks
|
|
121
|
+
* Returns the number of seconds to wait before retrying, as specified in the Retry-After header.
|
|
122
|
+
* Returns `null` if the error is not a rate limit error or if no retry-after value is available.
|
|
123
|
+
*
|
|
124
|
+
* @param error - The error to extract retry-after from.
|
|
125
|
+
* @returns The number of seconds to wait, or `null` if not available.
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```tsx
|
|
129
|
+
* import { getRetryAfter } from '@figma-vars/hooks';
|
|
130
|
+
*
|
|
131
|
+
* const retryAfter = getRetryAfter(error);
|
|
132
|
+
* if (retryAfter !== null) {
|
|
133
|
+
* setTimeout(() => {
|
|
134
|
+
* // Retry the request
|
|
135
|
+
* }, retryAfter * 1000);
|
|
136
|
+
* }
|
|
137
|
+
* ```
|
|
138
|
+
*
|
|
139
|
+
* @public
|
|
140
|
+
*/
|
|
141
|
+
export declare function getRetryAfter(error: unknown): number | null;
|
|
142
|
+
//# sourceMappingURL=errorHelpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errorHelpers.d.ts","sourceRoot":"","sources":["../../src/utils/errorHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAEtE;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAK5D;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,OAAO,EACd,cAAc,SAAsB,GACnC,MAAM,CAQR;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAE1E;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAErD;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAK3D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filterVariables.d.ts","sourceRoot":"","sources":["../../src/utils/filterVariables.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"filterVariables.d.ts","sourceRoot":"","sources":["../../src/utils/filterVariables.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAExD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,aAAa,EAAE,EAC1B,QAAQ,EAAE;IAAE,YAAY,CAAC,EAAE,YAAY,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GACvD,aAAa,EAAE,CAQjB"}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
13
|
* ```ts
|
|
14
|
-
* import { filterVariables } from '@figma-vars/hooks/utils';
|
|
14
|
+
* import { filterVariables, isFigmaApiError } from '@figma-vars/hooks/utils';
|
|
15
15
|
*
|
|
16
16
|
* const filtered = filterVariables(allVariables, { resolvedType: 'COLOR' });
|
|
17
17
|
* ```
|
|
@@ -19,4 +19,6 @@
|
|
|
19
19
|
* @public
|
|
20
20
|
*/
|
|
21
21
|
export { filterVariables } from './filterVariables';
|
|
22
|
+
export { isFigmaApiError, getErrorStatus, getErrorMessage, hasErrorStatus, isRateLimited, getRetryAfter, } from './errorHelpers';
|
|
23
|
+
export { isLocalVariablesResponse, isPublishedVariablesResponse, } from './typeGuards';
|
|
22
24
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EACL,eAAe,EACf,cAAc,EACd,eAAe,EACf,cAAc,EACd,aAAa,EACb,aAAa,GACd,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EACL,wBAAwB,EACxB,4BAA4B,GAC7B,MAAM,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared utilities for constructing SWR cache keys consistently across hooks.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Centralizes key construction logic to prevent mismatches between fetch hooks
|
|
6
|
+
* and invalidation utilities. Ensures that invalidation keys match the keys
|
|
7
|
+
* used by useSWR in fetch hooks.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Parameters for constructing a published variables SWR key.
|
|
13
|
+
*/
|
|
14
|
+
export interface PublishedVariablesKeyParams {
|
|
15
|
+
/** Figma file key, or null if not available */
|
|
16
|
+
fileKey: string | null;
|
|
17
|
+
/** Figma Personal Access Token, or null if not available */
|
|
18
|
+
token: string | null;
|
|
19
|
+
/** Provider instance ID for fallback cache scoping */
|
|
20
|
+
providerId: string | undefined;
|
|
21
|
+
/** Whether fallback file is available */
|
|
22
|
+
hasFallback: boolean;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=swrKeys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swrKeys.d.ts","sourceRoot":"","sources":["../../src/utils/swrKeys.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAgBH;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,+CAA+C;IAC/C,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,4DAA4D;IAC5D,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,sDAAsD;IACtD,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;IAC9B,yCAAyC;IACzC,WAAW,EAAE,OAAO,CAAA;CACrB"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { LocalVariablesResponse, PublishedVariablesResponse } from '../types/figma';
|
|
2
|
+
/**
|
|
3
|
+
* Runtime type guard to check if data matches LocalVariablesResponse structure.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Use this to validate fallback files or API responses at runtime before casting.
|
|
7
|
+
* Validates the essential structure: meta object with variableCollections and variables.
|
|
8
|
+
*
|
|
9
|
+
* @param data - The data to validate
|
|
10
|
+
* @returns `true` if data matches LocalVariablesResponse structure
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { isLocalVariablesResponse } from '@figma-vars/hooks';
|
|
15
|
+
*
|
|
16
|
+
* if (isLocalVariablesResponse(fallbackData)) {
|
|
17
|
+
* // Safe to use as LocalVariablesResponse
|
|
18
|
+
* } else {
|
|
19
|
+
* console.error('Invalid fallback file structure');
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
export declare function isLocalVariablesResponse(data: unknown): data is LocalVariablesResponse;
|
|
26
|
+
/**
|
|
27
|
+
* Runtime type guard to check if data matches PublishedVariablesResponse structure.
|
|
28
|
+
*
|
|
29
|
+
* @remarks
|
|
30
|
+
* Use this to validate fallback files or API responses at runtime before casting.
|
|
31
|
+
* Validates the essential structure: meta object with variableCollections and variables.
|
|
32
|
+
*
|
|
33
|
+
* @param data - The data to validate
|
|
34
|
+
* @returns `true` if data matches PublishedVariablesResponse structure
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* import { isPublishedVariablesResponse } from '@figma-vars/hooks';
|
|
39
|
+
*
|
|
40
|
+
* if (isPublishedVariablesResponse(fallbackData)) {
|
|
41
|
+
* // Safe to use as PublishedVariablesResponse
|
|
42
|
+
* } else {
|
|
43
|
+
* console.error('Invalid fallback file structure');
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @public
|
|
48
|
+
*/
|
|
49
|
+
export declare function isPublishedVariablesResponse(data: unknown): data is PublishedVariablesResponse;
|
|
50
|
+
//# sourceMappingURL=typeGuards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeGuards.d.ts","sourceRoot":"","sources":["../../src/utils/typeGuards.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,sBAAsB,EACtB,0BAA0B,EAC3B,MAAM,aAAa,CAAA;AAEpB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,OAAO,GACZ,IAAI,IAAI,sBAAsB,CA0BhC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,OAAO,GACZ,IAAI,IAAI,0BAA0B,CA0BpC"}
|
package/package.json
CHANGED
|
@@ -1,15 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@figma-vars/hooks",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Typed React hooks for managing Figma Variables, modes, tokens, and bindings via API.",
|
|
5
5
|
"author": "Mark Learst",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "dist/index.cjs",
|
|
9
9
|
"module": "dist/index.mjs",
|
|
10
|
+
"types": "dist/index.d.ts",
|
|
11
|
+
"typesVersions": {
|
|
12
|
+
"*": {
|
|
13
|
+
"core": [
|
|
14
|
+
"dist/core.d.ts"
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
},
|
|
10
18
|
"files": [
|
|
11
|
-
"dist"
|
|
19
|
+
"dist",
|
|
20
|
+
"scripts"
|
|
12
21
|
],
|
|
22
|
+
"bin": {
|
|
23
|
+
"figma-vars-export": "./scripts/export-variables.mjs"
|
|
24
|
+
},
|
|
13
25
|
"keywords": [
|
|
14
26
|
"figma",
|
|
15
27
|
"figma variables",
|
|
@@ -34,9 +46,36 @@
|
|
|
34
46
|
"engines": {
|
|
35
47
|
"node": ">=20.0.0"
|
|
36
48
|
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"dev": "vite",
|
|
51
|
+
"build": "tsc && vite build",
|
|
52
|
+
"postbuild": "cp dist/index.d.ts dist/index.d.cts || copy dist/index.d.ts dist/index.d.cts && cp dist/core.d.ts dist/core.d.cts || copy dist/core.d.ts dist/core.d.cts && cp dist/core/index.d.ts dist/core/index.d.cts || copy dist/core\\index.d.ts dist/core\\index.d.cts",
|
|
53
|
+
"prepublishOnly": "pnpm build",
|
|
54
|
+
"lint": "biome format --write .",
|
|
55
|
+
"format": "prettier --write .",
|
|
56
|
+
"format:check": "prettier --check .",
|
|
57
|
+
"preview": "vite preview",
|
|
58
|
+
"test": "vitest",
|
|
59
|
+
"test:ui": "vitest --ui",
|
|
60
|
+
"test:coverage": "vitest run --coverage",
|
|
61
|
+
"test:watch": "vitest watch",
|
|
62
|
+
"postversion": "git push && git push --tags",
|
|
63
|
+
"create:docs": "npx typedoc src/index.ts --out docs-site/api",
|
|
64
|
+
"check:publint": "publint",
|
|
65
|
+
"check:attw": "attw --pack .",
|
|
66
|
+
"check:size": "size-limit",
|
|
67
|
+
"check:release": "pnpm run build && pnpm run check:publint && pnpm run check:attw && pnpm run check:size",
|
|
68
|
+
"prepare": "husky"
|
|
69
|
+
},
|
|
70
|
+
"lint-staged": {
|
|
71
|
+
"*.{js,jsx,ts,tsx,json,md}": [
|
|
72
|
+
"prettier --write"
|
|
73
|
+
]
|
|
74
|
+
},
|
|
37
75
|
"peerDependencies": {
|
|
38
|
-
"react": "^
|
|
39
|
-
"react-dom": "^
|
|
76
|
+
"react": "^19.2.3",
|
|
77
|
+
"react-dom": "^19.2.3",
|
|
78
|
+
"swr": "^2.3.7"
|
|
40
79
|
},
|
|
41
80
|
"sideEffects": false,
|
|
42
81
|
"exports": {
|
|
@@ -50,6 +89,17 @@
|
|
|
50
89
|
"default": "./dist/index.cjs"
|
|
51
90
|
},
|
|
52
91
|
"default": "./dist/index.mjs"
|
|
92
|
+
},
|
|
93
|
+
"./core": {
|
|
94
|
+
"import": {
|
|
95
|
+
"types": "./dist/core/index.d.ts",
|
|
96
|
+
"default": "./dist/core.mjs"
|
|
97
|
+
},
|
|
98
|
+
"require": {
|
|
99
|
+
"types": "./dist/core/index.d.cts",
|
|
100
|
+
"default": "./dist/core.cjs"
|
|
101
|
+
},
|
|
102
|
+
"default": "./dist/core.mjs"
|
|
53
103
|
}
|
|
54
104
|
},
|
|
55
105
|
"publishConfig": {
|
|
@@ -60,6 +110,16 @@
|
|
|
60
110
|
"type": "github",
|
|
61
111
|
"url": "https://github.com/sponsors/marklearst"
|
|
62
112
|
},
|
|
113
|
+
"pnpm": {
|
|
114
|
+
"overrides": {
|
|
115
|
+
"vite": "^6.3.5"
|
|
116
|
+
},
|
|
117
|
+
"onlyBuiltDependencies": [
|
|
118
|
+
"@biomejs/biome",
|
|
119
|
+
"esbuild"
|
|
120
|
+
]
|
|
121
|
+
},
|
|
122
|
+
"packageManager": "pnpm@10.15.0",
|
|
63
123
|
"devDependencies": {
|
|
64
124
|
"@arethetypeswrong/cli": "^0.17.0",
|
|
65
125
|
"@biomejs/biome": "^1.9.4",
|
|
@@ -67,17 +127,21 @@
|
|
|
67
127
|
"@testing-library/jest-dom": "^6.6.3",
|
|
68
128
|
"@testing-library/react": "^16.3.0",
|
|
69
129
|
"@types/node": "^24.0.3",
|
|
70
|
-
"@types/react": "^19.
|
|
71
|
-
"@types/react-dom": "^19.
|
|
130
|
+
"@types/react": "^19.2.7",
|
|
131
|
+
"@types/react-dom": "^19.2.3",
|
|
72
132
|
"@vitejs/plugin-react": "^4.5.2",
|
|
73
133
|
"@vitest/coverage-v8": "^2.0.5",
|
|
74
134
|
"@vitest/ui": "2.1.9",
|
|
75
135
|
"dotenv": "^16.5.0",
|
|
136
|
+
"husky": "^9.1.7",
|
|
76
137
|
"jsdom": "^26.1.0",
|
|
138
|
+
"lint-staged": "^16.1.5",
|
|
139
|
+
"prettier": "^3.6.2",
|
|
77
140
|
"publint": "^0.3.1",
|
|
78
|
-
"react": "^19.
|
|
79
|
-
"react-dom": "^19.
|
|
141
|
+
"react": "^19.2.3",
|
|
142
|
+
"react-dom": "^19.2.3",
|
|
80
143
|
"size-limit": "^11.1.5",
|
|
144
|
+
"swr": "^2.3.7",
|
|
81
145
|
"typescript": "~5.8.3",
|
|
82
146
|
"vite": "^6.3.5",
|
|
83
147
|
"vite-plugin-dts": "^4.5.4",
|
|
@@ -87,9 +151,7 @@
|
|
|
87
151
|
"directories": {
|
|
88
152
|
"doc": "docs"
|
|
89
153
|
},
|
|
90
|
-
"dependencies": {
|
|
91
|
-
"swr": "^2.3.3"
|
|
92
|
-
},
|
|
154
|
+
"dependencies": {},
|
|
93
155
|
"size-limit": [
|
|
94
156
|
{
|
|
95
157
|
"name": "modern ESM entry",
|
|
@@ -97,23 +159,5 @@
|
|
|
97
159
|
"import": "{ useVariables }",
|
|
98
160
|
"limit": "10 kB"
|
|
99
161
|
}
|
|
100
|
-
]
|
|
101
|
-
|
|
102
|
-
"dev": "vite",
|
|
103
|
-
"build": "tsc && vite build",
|
|
104
|
-
"postbuild": "cp dist/index.d.ts dist/index.d.cts || copy dist/index.d.ts dist/index.d.cts",
|
|
105
|
-
"lint": "biome format --write .",
|
|
106
|
-
"format": "biome format --write .",
|
|
107
|
-
"preview": "vite preview",
|
|
108
|
-
"test": "vitest",
|
|
109
|
-
"test:ui": "vitest --ui",
|
|
110
|
-
"test:coverage": "vitest run --coverage",
|
|
111
|
-
"test:watch": "vitest watch",
|
|
112
|
-
"postversion": "git push && git push --tags",
|
|
113
|
-
"create:docs": "npx typedoc src/index.ts --out docs-site/api",
|
|
114
|
-
"check:publint": "publint",
|
|
115
|
-
"check:attw": "attw --pack .",
|
|
116
|
-
"check:size": "size-limit",
|
|
117
|
-
"check:release": "pnpm run build && pnpm run check:publint && pnpm run check:attw && pnpm run check:size"
|
|
118
|
-
}
|
|
119
|
-
}
|
|
162
|
+
]
|
|
163
|
+
}
|