-
-
Notifications
You must be signed in to change notification settings - Fork 0
docs: update CHANGELOG and README for v4.0.0 release #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -6,6 +6,184 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | |||||
|
|
||||||
| ## [Unreleased] | ||||||
|
|
||||||
| ## 4.0.0 (2025-12-29) | ||||||
|
|
||||||
| ### ⚠️ BREAKING CHANGES | ||||||
|
|
||||||
| #### **`useFigmaToken` Export Changed** | ||||||
|
|
||||||
| `useFigmaToken` is now a **named export** instead of a default export for consistency with the rest of the library: | ||||||
|
|
||||||
| ```tsx | ||||||
| // Before (3.x) - NO LONGER WORKS | ||||||
| import useFigmaToken from '@figma-vars/hooks' | ||||||
|
|
||||||
| // After (4.0) - USE THIS | ||||||
| import { useFigmaToken } from '@figma-vars/hooks' | ||||||
| ``` | ||||||
|
|
||||||
| **Why?** Named exports enable better tree-shaking, align with other hooks in the library, and support future package splitting. | ||||||
|
|
||||||
| ### ✨ Added - New Utilities | ||||||
|
|
||||||
| #### **`withRetry()` - Automatic Retry with Exponential Backoff** | ||||||
|
|
||||||
| New utility for wrapping async operations with automatic retry logic, especially useful for rate-limited API calls: | ||||||
|
|
||||||
| ```ts | ||||||
| import { withRetry } from '@figma-vars/hooks' | ||||||
|
|
||||||
| const fetchWithRetry = withRetry(() => fetcher('/api/endpoint', token), { | ||||||
| maxRetries: 3, | ||||||
| initialDelayMs: 1000, | ||||||
| backoffMultiplier: 2, | ||||||
| maxDelayMs: 30000, | ||||||
| retryOnlyRateLimits: true, // Only retry 429 errors | ||||||
| onRetry: (attempt, delayMs, error) => { | ||||||
| console.log(`Retry ${attempt} after ${delayMs}ms`) | ||||||
| }, | ||||||
| }) | ||||||
|
|
||||||
| const data = await fetchWithRetry() | ||||||
| ``` | ||||||
|
|
||||||
| **Features:** | ||||||
|
|
||||||
| - Respects `Retry-After` header from Figma API | ||||||
| - Configurable exponential backoff | ||||||
| - Optional callback for retry notifications | ||||||
| - Can retry all errors or only rate limits (429) | ||||||
|
|
||||||
| #### **`redactToken()` - Safe Token Logging** | ||||||
|
|
||||||
| New utility to safely redact Figma tokens for logging or display: | ||||||
|
|
||||||
| ```ts | ||||||
| import { redactToken } from '@figma-vars/hooks' | ||||||
|
|
||||||
| redactToken('figd_abc123xyz789secret') | ||||||
| // Returns: 'figd_***...***cret' | ||||||
|
Comment on lines
+64
to
+65
|
||||||
|
|
||||||
| redactToken('short', { prefixLength: 2, suffixLength: 2 }) | ||||||
| // Returns: '***...***' (too short, fully redacted) | ||||||
|
||||||
| // Returns: '***...***' (too short, fully redacted) | |
| // Returns: '*****' (too short, fully redacted) |
Copilot
AI
Dec 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return value for null is incorrect. According to the actual implementation in src/utils/redactToken.ts, redactToken(null) returns '[no token]', not an empty string ''. The default emptyPlaceholder is '[no token]'.
| redactToken(null) // Returns: '' | |
| redactToken(null) // Returns: '[no token]' |
Copilot
AI
Dec 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default value for suffixLength is incorrect. According to the actual implementation in src/utils/redactToken.ts, the default visibleEnd is 3, not 5. The documentation should say "Characters to show at end (default: 3)".
| - `suffixLength` - Characters to show at end (default: 5) | |
| - `suffixLength` - Characters to show at end (default: 3) |
Copilot
AI
Dec 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter names are incorrect. According to the actual implementation in src/utils/redactToken.ts, the options are named visibleStart and visibleEnd, not prefixLength and suffixLength. Also, there is no redactionString option in the actual implementation.
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -10,24 +10,25 @@ A fast, typed React 19.2.3 hooks library for the Figma Variables API: fetch, upd | |||||||
|
|
||||||||
| Built for the modern web, this library provides a suite of hooks to fetch, manage, and mutate your design tokens/variables, making it easy to sync them between Figma and your React applications, Storybooks, or design system dashboards. | ||||||||
|
|
||||||||
|  | ||||||||
|  | ||||||||
| [](https://codecov.io/gh/marklearst/figma-vars-hooks) | ||||||||
|  | ||||||||
|  | ||||||||
|  | ||||||||
|  | ||||||||
|
|
||||||||
| ## 📌 Why 3.1.1 | ||||||||
|
|
||||||||
| - ✨ **New DX Features**: SWR configuration support, error handling utilities, cache invalidation helpers | ||||||||
| - 🔧 **React 19.2 Ready**: Optimized hooks with proper cleanup and stable function references | ||||||||
| - 🛡️ **Better Error Handling**: `FigmaApiError` class with HTTP status codes for better error differentiation | ||||||||
| - ✅ **Type Safety**: Removed unsafe type assertions, improved type definitions throughout | ||||||||
| - 🚀 **Performance**: Hardened SWR usage (stable keys, `null` to disable, cleaner fallback handling) | ||||||||
| | Package | Quality | Activity | | ||||||||
| | --------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | | ||||||||
| | [](https://www.npmjs.com/package/@figma-vars/hooks) |  |  | | ||||||||
| |  | [](https://codecov.io/gh/marklearst/figma-vars-hooks) |  | | ||||||||
| |  |  |  | | ||||||||
| |  |  | | | ||||||||
|
|
||||||||
| ## 📌 Why 4.0.0 | ||||||||
|
|
||||||||
| - ✨ **New Utilities**: `withRetry()` for automatic retry with exponential backoff, `redactToken()` for safe logging | ||||||||
| - 🔧 **Flexible API**: `baseUrl` option for fetcher/mutator, `caseInsensitive` option for filterVariables | ||||||||
| - 🛡️ **Better Error Handling**: Improved parsing for non-JSON API responses (HTML, plain text) | ||||||||
| - 🐛 **Critical Bug Fix**: SWR cache keys now correctly separate fallback and live data | ||||||||
| - 📚 **Improved Docs**: Comprehensive mutation return type documentation with examples | ||||||||
| - 📦 **Modern Tooling**: Node 20+ toolchain, strict TypeScript, and ESM-first packaging with CJS interop | ||||||||
| - 🖥️ **CLI Export Tool**: Automate variable exports with `figma-vars-export` for CI/CD (Enterprise required) | ||||||||
|
|
||||||||
| > ⚠️ **Breaking Change**: `useFigmaToken` is now a named export. See [Migration Guide](#-migration-guide-3x--40). | ||||||||
|
|
||||||||
| ## 🚀 Features at a Glance | ||||||||
|
|
||||||||
| - **Modern React 19.2 hooks** for variables, collections, modes, and published variables | ||||||||
|
|
@@ -424,11 +425,13 @@ Customize SWR behavior globally through the provider: | |||||||
|
|
||||||||
| ### Utilities | ||||||||
|
|
||||||||
| - **Filtering**: `filterVariables` (filter by type, name, etc.) | ||||||||
| - **Error Handling**: `isFigmaApiError`, `getErrorStatus`, `getErrorMessage`, `hasErrorStatus` | ||||||||
| - **Filtering**: `filterVariables` (filter by type, name, with optional `caseInsensitive` matching) | ||||||||
| - **Retry**: `withRetry` (automatic retry with exponential backoff for rate limits) | ||||||||
| - **Security**: `redactToken` (safely redact tokens for logging/display) | ||||||||
|
Comment on lines
+429
to
+430
|
||||||||
| - **Retry**: `withRetry` (automatic retry with exponential backoff for rate limits) | |
| - **Security**: `redactToken` (safely redact tokens for logging/display) |
Copilot
AI
Dec 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new error handling utilities isRateLimited and getRetryAfter are documented in the API cheat sheet but are not exported from the main package entry point (src/index.ts). These should be added to the exports at lines 86-92 for users to access them.
| - **Error Handling**: `isFigmaApiError`, `getErrorStatus`, `getErrorMessage`, `hasErrorStatus`, `isRateLimited`, `getRetryAfter` | |
| - **Error Handling**: `isFigmaApiError`, `getErrorStatus`, `getErrorMessage`, `hasErrorStatus` |
Copilot
AI
Dec 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example output is incorrect. According to the actual implementation in src/utils/redactToken.ts, redactToken would return 'figd_***...ret' (showing 5 chars at start and 3 at end by default), not 'figd_...***cret' (4 chars at end). The default visibleEnd is 3, not 4.
| // Output: "Using token: figd_***...***cret" | |
| // Output: "Using token: figd_***...***ret" |
Copilot
AI
Dec 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The import import { withRetry, fetcher } from '@figma-vars/hooks' will fail. withRetry is not exported from the main package entry point (src/index.ts), and fetcher is only available from '@figma-vars/hooks/core'. The correct import should be import { fetcher } from '@figma-vars/hooks/core' and import { withRetry } from '@figma-vars/hooks/utils' (or add these to main exports).
| import { withRetry, fetcher } from '@figma-vars/hooks' | |
| import { fetcher } from '@figma-vars/hooks/core' | |
| import { withRetry } from '@figma-vars/hooks/utils' |
Copilot
AI
Dec 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The migration guide assumes useFigmaToken is exported from the main package, but it's not present in src/index.ts. Users following this guide will get an import error. Either add useFigmaToken to the exports in src/index.ts line 57-67, or clarify in the documentation that this hook is not part of the public API.
Copilot
AI
Dec 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The import statement import { withRetry, redactToken, filterVariables } from '@figma-vars/hooks' will fail because withRetry and redactToken are not exported from the main package entry point (src/index.ts). Users need to either import from '@figma-vars/hooks/utils' or these utilities need to be added to the main exports.
| import { withRetry, redactToken, filterVariables } from '@figma-vars/hooks' | |
| import { filterVariables } from '@figma-vars/hooks' | |
| import { withRetry, redactToken } from '@figma-vars/hooks/utils' |
Copilot
AI
Dec 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example output is incorrect. According to the actual implementation in src/utils/redactToken.ts, redactToken would return 'figd_***...ret' (showing 5 chars at start and 3 at end by default), not 'figd_...***cret' (4 chars at end). The default visibleEnd is 3, not 4.
| console.log('Token:', redactToken(token)) // "figd_***...***cret" | |
| console.log('Token:', redactToken(token)) // "figd_***...***ret" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The breaking change documentation claims
useFigmaTokenis now a named export, but this hook is not exported from the main package entry point (src/index.ts). Users trying to import it as shown will get an error. Either add the export to src/index.ts, or update the documentation to clarify this hook is not part of the public API.