terrazzo-plugin-figma-json 0.1.1 → 0.3.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 +113 -10
- package/dist/build/aliases.d.ts +80 -0
- package/dist/build/aliases.d.ts.map +1 -0
- package/dist/build/helpers.d.ts +52 -0
- package/dist/build/helpers.d.ts.map +1 -0
- package/dist/build/index.d.ts +11 -0
- package/dist/build/index.d.ts.map +1 -0
- package/dist/build/output.d.ts +28 -0
- package/dist/build/output.d.ts.map +1 -0
- package/dist/build/source-maps.d.ts +20 -0
- package/dist/build/source-maps.d.ts.map +1 -0
- package/dist/build/types.d.ts +69 -0
- package/dist/build/types.d.ts.map +1 -0
- package/dist/constants.d.ts +2 -14
- package/dist/constants.d.ts.map +1 -1
- package/dist/converters/border.d.ts +12 -0
- package/dist/converters/border.d.ts.map +1 -0
- package/dist/converters/color.d.ts +4 -0
- package/dist/converters/color.d.ts.map +1 -1
- package/dist/converters/dimension.d.ts +4 -0
- package/dist/converters/dimension.d.ts.map +1 -1
- package/dist/converters/duration.d.ts +4 -0
- package/dist/converters/duration.d.ts.map +1 -1
- package/dist/converters/font-family.d.ts +4 -0
- package/dist/converters/font-family.d.ts.map +1 -1
- package/dist/converters/font-weight.d.ts +4 -0
- package/dist/converters/font-weight.d.ts.map +1 -1
- package/dist/converters/gradient.d.ts +12 -0
- package/dist/converters/gradient.d.ts.map +1 -0
- package/dist/converters/index.d.ts +6 -0
- package/dist/converters/index.d.ts.map +1 -1
- package/dist/converters/line-height.d.ts +4 -0
- package/dist/converters/line-height.d.ts.map +1 -1
- package/dist/converters/number.d.ts +4 -0
- package/dist/converters/number.d.ts.map +1 -1
- package/dist/converters/shadow.d.ts +15 -0
- package/dist/converters/shadow.d.ts.map +1 -0
- package/dist/converters/typography.d.ts +4 -0
- package/dist/converters/typography.d.ts.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +833 -345
- package/dist/index.js.map +1 -1
- package/dist/lint/figma-unsupported-type.d.ts +16 -0
- package/dist/lint/figma-unsupported-type.d.ts.map +1 -0
- package/dist/lint/index.d.ts +2 -0
- package/dist/lint/index.d.ts.map +1 -0
- package/dist/transform.d.ts +3 -1
- package/dist/transform.d.ts.map +1 -1
- package/dist/types.d.ts +38 -9
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +61 -31
- package/dist/utils.d.ts.map +1 -1
- package/package.json +5 -5
- package/dist/build.d.ts +0 -18
- package/dist/build.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -4,18 +4,16 @@ A [Terrazzo](https://terrazzo.app) plugin that converts W3C DTCG design tokens i
|
|
|
4
4
|
|
|
5
5
|
## Requirements
|
|
6
6
|
|
|
7
|
-
This plugin requires Terrazzo 2.0
|
|
7
|
+
This plugin requires Terrazzo 2.0:
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
npm install @terrazzo/cli
|
|
10
|
+
npm install @terrazzo/cli
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
## Installation
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
16
|
npm install terrazzo-plugin-figma-json
|
|
17
|
-
# or
|
|
18
|
-
pnpm add terrazzo-plugin-figma-json
|
|
19
17
|
```
|
|
20
18
|
|
|
21
19
|
## Basic Usage
|
|
@@ -61,11 +59,11 @@ With a resolver file, the plugin splits output by resolver sets and modifier con
|
|
|
61
59
|
|
|
62
60
|
```
|
|
63
61
|
dist/
|
|
64
|
-
├── primitive.figma.json # From "primitive" set
|
|
65
|
-
├── semantic.figma.json # From "semantic" set
|
|
66
|
-
├── colorScheme-light.figma.json
|
|
67
|
-
├── colorScheme-dark.figma.json
|
|
68
|
-
└── breakpoint-small.figma.json
|
|
62
|
+
├── primitive.tokens.figma.json # From "primitive" set
|
|
63
|
+
├── semantic.tokens.figma.json # From "semantic" set
|
|
64
|
+
├── colorScheme-light.tokens.figma.json
|
|
65
|
+
├── colorScheme-dark.tokens.figma.json
|
|
66
|
+
└── breakpoint-small.tokens.figma.json
|
|
69
67
|
```
|
|
70
68
|
|
|
71
69
|
Without a resolver, all tokens are output to a single file (`tokens.figma.json` by default).
|
|
@@ -81,6 +79,9 @@ Without a resolver, all tokens are output to a single file (`tokens.figma.json`
|
|
|
81
79
|
| `fontWeight` | Number or String | Values pass through with validation |
|
|
82
80
|
| `number` | Number or Boolean | Numbers pass through; use `com.figma.type: "boolean"` for booleans |
|
|
83
81
|
| `typography` | Split tokens | Split into fontFamily, fontSize, fontWeight, lineHeight, letterSpacing |
|
|
82
|
+
| `shadow` | Split tokens | Split into color, offsetX, offsetY, blur, spread; indexed for multiple layers (`inset` not applicable in Figma) |
|
|
83
|
+
| `border` | Split tokens (partial) | Split into color, width (`style` not applicable in Figma) |
|
|
84
|
+
| `gradient` | Split tokens (partial) | Stop colors extracted (`position` not applicable in Figma) |
|
|
84
85
|
|
|
85
86
|
### Typography Token Splitting
|
|
86
87
|
|
|
@@ -121,11 +122,113 @@ Figma doesn't support composite typography tokens, so they're automatically spli
|
|
|
121
122
|
|
|
122
123
|
Note: `lineHeight` is converted from a unitless multiplier to absolute px (see [Figma Limitations](#figma-limitations)).
|
|
123
124
|
|
|
125
|
+
### Shadow Token Splitting
|
|
126
|
+
|
|
127
|
+
Shadow tokens are split into individual sub-tokens. Array shadows (multiple layers) use indexed prefixes.
|
|
128
|
+
|
|
129
|
+
**Input:**
|
|
130
|
+
```json
|
|
131
|
+
{
|
|
132
|
+
"shadow": {
|
|
133
|
+
"$type": "shadow",
|
|
134
|
+
"medium": {
|
|
135
|
+
"$value": {
|
|
136
|
+
"color": { "colorSpace": "srgb", "components": [0, 0, 0], "alpha": 0.2 },
|
|
137
|
+
"offsetX": { "value": 0, "unit": "px" },
|
|
138
|
+
"offsetY": { "value": 4, "unit": "px" },
|
|
139
|
+
"blur": { "value": 8, "unit": "px" },
|
|
140
|
+
"spread": { "value": 0, "unit": "px" }
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
**Output:**
|
|
148
|
+
```json
|
|
149
|
+
{
|
|
150
|
+
"shadow": {
|
|
151
|
+
"medium": {
|
|
152
|
+
"color": { "$type": "color", "$value": { "colorSpace": "srgb", "components": [0, 0, 0], "alpha": 0.2 } },
|
|
153
|
+
"offsetX": { "$type": "dimension", "$value": { "value": 0, "unit": "px" } },
|
|
154
|
+
"offsetY": { "$type": "dimension", "$value": { "value": 4, "unit": "px" } },
|
|
155
|
+
"blur": { "$type": "dimension", "$value": { "value": 8, "unit": "px" } },
|
|
156
|
+
"spread": { "$type": "dimension", "$value": { "value": 0, "unit": "px" } }
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Note: Single shadows produce flat sub-tokens. Multiple shadow layers (arrays with 2+ items) use indexed prefixes (`0.color`, `0.offsetX`, ..., `1.color`, etc.). The `inset` property is dropped since variables cannot be applied to inset shadows in Figma.
|
|
163
|
+
|
|
164
|
+
### Border Token Splitting (Partial)
|
|
165
|
+
|
|
166
|
+
Border tokens are partially split — only `color` and `width` are extracted. The `style` property is dropped since variables cannot be applied to border style in Figma.
|
|
167
|
+
|
|
168
|
+
**Input:**
|
|
169
|
+
```json
|
|
170
|
+
{
|
|
171
|
+
"border": {
|
|
172
|
+
"$type": "border",
|
|
173
|
+
"default": {
|
|
174
|
+
"$value": {
|
|
175
|
+
"color": { "colorSpace": "srgb", "components": [0.8, 0.8, 0.8] },
|
|
176
|
+
"width": { "value": 1, "unit": "px" },
|
|
177
|
+
"style": "solid"
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
**Output:**
|
|
185
|
+
```json
|
|
186
|
+
{
|
|
187
|
+
"border": {
|
|
188
|
+
"default": {
|
|
189
|
+
"color": { "$type": "color", "$value": { "colorSpace": "srgb", "components": [0.8, 0.8, 0.8], "alpha": 1 } },
|
|
190
|
+
"width": { "$type": "dimension", "$value": { "value": 1, "unit": "px" } }
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Gradient Token Splitting (Partial)
|
|
197
|
+
|
|
198
|
+
Gradient tokens are partially split — only stop colors are extracted. Stop `position` values are dropped since variables cannot be applied to gradient stop positions in Figma.
|
|
199
|
+
|
|
200
|
+
**Input:**
|
|
201
|
+
```json
|
|
202
|
+
{
|
|
203
|
+
"gradient": {
|
|
204
|
+
"$type": "gradient",
|
|
205
|
+
"primary": {
|
|
206
|
+
"$value": [
|
|
207
|
+
{ "color": { "colorSpace": "srgb", "components": [1, 0, 0] }, "position": 0 },
|
|
208
|
+
{ "color": { "colorSpace": "srgb", "components": [0, 0, 1] }, "position": 1 }
|
|
209
|
+
]
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
**Output:**
|
|
216
|
+
```json
|
|
217
|
+
{
|
|
218
|
+
"gradient": {
|
|
219
|
+
"primary": {
|
|
220
|
+
"0": { "color": { "$type": "color", "$value": { "colorSpace": "srgb", "components": [1, 0, 0], "alpha": 1 } } },
|
|
221
|
+
"1": { "color": { "$type": "color", "$value": { "colorSpace": "srgb", "components": [0, 0, 1], "alpha": 1 } } }
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
```
|
|
226
|
+
|
|
124
227
|
## Unsupported Token Types
|
|
125
228
|
|
|
126
229
|
The following DTCG token types are **not supported** by Figma and will be skipped:
|
|
127
230
|
|
|
128
|
-
- `
|
|
231
|
+
- `transition`, `strokeStyle`, `cubicBezier`
|
|
129
232
|
|
|
130
233
|
## Alias Handling
|
|
131
234
|
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { TokenNormalized } from '@terrazzo/parser';
|
|
2
|
+
import type { SupportedType } from '../constants.js';
|
|
3
|
+
import type { PartialAliasOf } from '../types.js';
|
|
4
|
+
import type { AliasReferenceOptions, ParsedTokenValue } from './types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Extract partialAliasOf from a token if present.
|
|
7
|
+
* This property is added by terrazzo parser for composite tokens but not in public types.
|
|
8
|
+
*
|
|
9
|
+
* @param token - The token object to inspect
|
|
10
|
+
* @returns The partialAliasOf record mapping sub-properties to alias targets, or undefined
|
|
11
|
+
*/
|
|
12
|
+
export declare function getPartialAliasOf(token: unknown): PartialAliasOf | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Get the correct alias reference for a composite sub-property.
|
|
15
|
+
* When a composite property references another composite token of the same type,
|
|
16
|
+
* the alias needs to point to the corresponding sub-token.
|
|
17
|
+
*
|
|
18
|
+
* @param aliasOf - The raw alias target token ID, or undefined if not an alias
|
|
19
|
+
* @param propertyName - The sub-property name (e.g., "color", "width")
|
|
20
|
+
* @param allTokens - Map of all tokens for type checking
|
|
21
|
+
* @param parentType - The parent composite token's type (e.g., "border", "shadow")
|
|
22
|
+
* @returns The resolved alias target (with sub-property suffix if needed), or undefined
|
|
23
|
+
*/
|
|
24
|
+
export declare function getSubTokenAlias(aliasOf: string | undefined, propertyName: string, allTokens: Record<string, {
|
|
25
|
+
$type?: string;
|
|
26
|
+
}> | undefined, parentType: SupportedType): string | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Compute the direct alias target for a simple (non-composite) token.
|
|
29
|
+
*
|
|
30
|
+
* @param token - The normalized token to inspect
|
|
31
|
+
* @returns The direct alias target token ID, or undefined if the token is not an alias
|
|
32
|
+
*/
|
|
33
|
+
export declare function getDirectAliasTarget(token: TokenNormalized): string | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* For tokens without a direct alias, check if all sub-property references
|
|
36
|
+
* in partialAliasOf point to the same token. If so, the token can be treated
|
|
37
|
+
* as a unified alias to that single target.
|
|
38
|
+
*
|
|
39
|
+
* This handles cases like JSON pointer references where individual sub-properties
|
|
40
|
+
* (e.g., colorSpace, components[0], components[1], etc.) all reference the same
|
|
41
|
+
* source token.
|
|
42
|
+
*
|
|
43
|
+
* Works for any token type with partialAliasOf — colors, borders, shadows, etc.
|
|
44
|
+
*
|
|
45
|
+
* @param token - The normalized token to inspect
|
|
46
|
+
* @returns The unified alias target token ID, or undefined if refs are mixed or absent
|
|
47
|
+
*/
|
|
48
|
+
export declare function getUnifiedPartialAlias(token: TokenNormalized): string | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* Compute the alias target for a token, considering direct aliases and
|
|
51
|
+
* unified partial aliases (where all sub-property refs point to the same token).
|
|
52
|
+
*
|
|
53
|
+
* @param token - The normalized token to inspect
|
|
54
|
+
* @returns The alias target token ID, or undefined if the token is not an alias
|
|
55
|
+
*/
|
|
56
|
+
export declare function computeAliasTarget(token: TokenNormalized): string | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Compute alias targets for each sub-property of a composite token.
|
|
59
|
+
*
|
|
60
|
+
* @param token - The normalized composite token
|
|
61
|
+
* @param subTokenSuffixes - Array of sub-property suffixes to resolve (e.g., ["color", "width"])
|
|
62
|
+
* @param allTokens - Map of all tokens for type checking during alias resolution
|
|
63
|
+
* @returns Map from sub-property suffix to alias target token ID (or undefined if not aliased)
|
|
64
|
+
*/
|
|
65
|
+
export declare function computeSubTokenAliases(token: TokenNormalized, subTokenSuffixes: string[], allTokens: Record<string, TokenNormalized> | undefined): Map<string, string | undefined>;
|
|
66
|
+
/**
|
|
67
|
+
* Resolve an alias reference and return a new ParsedTokenValue with the
|
|
68
|
+
* appropriate $value or $extensions set.
|
|
69
|
+
*
|
|
70
|
+
* - Same-file references: Sets $value to curly brace syntax (e.g., "{color.primary}")
|
|
71
|
+
* - Cross-file references: Keeps resolved $value and adds com.figma.aliasData extension
|
|
72
|
+
*
|
|
73
|
+
* Returns the original value unchanged if no alias handling applies.
|
|
74
|
+
*
|
|
75
|
+
* @param parsedValue - The parsed token value to potentially augment with alias info
|
|
76
|
+
* @param options - Alias resolution options including target, source context, and reference maps
|
|
77
|
+
* @returns A new ParsedTokenValue with alias reference syntax or extension, or the original value unchanged
|
|
78
|
+
*/
|
|
79
|
+
export declare function withAliasReference(parsedValue: ParsedTokenValue, { aliasOf, sourceName, tokenSources, tokenOutputPaths, preserveReferences }: AliasReferenceOptions): ParsedTokenValue;
|
|
80
|
+
//# sourceMappingURL=aliases.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aliases.d.ts","sourceRoot":"","sources":["../../src/build/aliases.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAyB,MAAM,aAAa,CAAC;AAGzE,OAAO,KAAK,EAAE,qBAAqB,EAAE,gBAAgB,EAAc,MAAM,YAAY,CAAC;AAEtF;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,GAAG,SAAS,CAQ5E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,SAAS,EACzD,UAAU,EAAE,aAAa,GACxB,MAAM,GAAG,SAAS,CASpB;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,GAAG,SAAS,CAc/E;AAuBD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,GAAG,SAAS,CAsBjF;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,GAAG,SAAS,CAE7E;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,eAAe,EACtB,gBAAgB,EAAE,MAAM,EAAE,EAC1B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,GAAG,SAAS,GACrD,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAWjC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,gBAAgB,EAC7B,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,EAAE,qBAAqB,GACjG,gBAAgB,CAgDlB"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Resolver } from '@terrazzo/parser';
|
|
2
|
+
import type { ParsedTokenValue } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Set a nested property on an object using dot-notation path.
|
|
5
|
+
* Creates intermediate objects as needed.
|
|
6
|
+
* Note: this intentionally mutates `obj` for efficient output tree construction.
|
|
7
|
+
*
|
|
8
|
+
* @param obj - The object to modify
|
|
9
|
+
* @param path - Dot-notation path (e.g., "color.primary.base")
|
|
10
|
+
* @param value - The value to set at the path
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* const obj = {};
|
|
14
|
+
* setNestedProperty(obj, "color.primary", { $value: "#ff0000" });
|
|
15
|
+
* // obj = { color: { primary: { $value: "#ff0000" } } }
|
|
16
|
+
*/
|
|
17
|
+
export declare function setNestedProperty(obj: Record<string, unknown>, path: string, value: unknown): void;
|
|
18
|
+
/**
|
|
19
|
+
* Convert $root in a token ID to root for Figma compatibility.
|
|
20
|
+
* DTCG uses $root for default values, but Figma doesn't support $ in names.
|
|
21
|
+
*
|
|
22
|
+
* @param path - The token path that may contain ".$root" segments
|
|
23
|
+
* @returns The path with ".$root" replaced by ".root"
|
|
24
|
+
*/
|
|
25
|
+
export declare function normalizeRootInPath(path: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Check if this resolver is the auto-generated default (no user-defined resolver file).
|
|
28
|
+
* The default resolver has only an "allTokens" set and a "tzMode" modifier with "." context.
|
|
29
|
+
*
|
|
30
|
+
* @param resolverSource - The resolver source configuration to inspect
|
|
31
|
+
* @returns True if this is the auto-generated default resolver
|
|
32
|
+
*/
|
|
33
|
+
export declare function isDefaultResolver(resolverSource: NonNullable<Resolver['source']>): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Build a default input from the resolver's first permutation.
|
|
36
|
+
*
|
|
37
|
+
* @param resolver - The terrazzo resolver instance
|
|
38
|
+
* @returns The first permutation input object, or an empty object if none exist
|
|
39
|
+
*/
|
|
40
|
+
export declare function getDefaultInput(resolver: Resolver): Record<string, string>;
|
|
41
|
+
/**
|
|
42
|
+
* Return a new ParsedTokenValue with $description and filtered $extensions added.
|
|
43
|
+
*
|
|
44
|
+
* @param parsedValue - The parsed token value to augment
|
|
45
|
+
* @param token - The source token containing $description and $extensions metadata
|
|
46
|
+
* @returns A new ParsedTokenValue with description and Figma-specific extensions merged in
|
|
47
|
+
*/
|
|
48
|
+
export declare function withTokenMetadata(parsedValue: ParsedTokenValue, token: {
|
|
49
|
+
$description?: string;
|
|
50
|
+
$extensions?: Record<string, unknown>;
|
|
51
|
+
}): ParsedTokenValue;
|
|
52
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/build/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAGjD,OAAO,KAAK,EAAyB,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE1E;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAkBlG;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAExD;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,cAAc,EAAE,WAAW,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,GAAG,OAAO,CAsB1F;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAG1E;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,gBAAgB,EAC7B,KAAK,EAAE;IAAE,YAAY,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GACtE,gBAAgB,CAqBlB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { BuildOptions } from './types.js';
|
|
2
|
+
export type { BuildOptions } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Build the Figma-compatible JSON output from transformed tokens.
|
|
5
|
+
* Uses the resolver to determine output file structure.
|
|
6
|
+
*
|
|
7
|
+
* @param options - Build options including getTransforms, exclude patterns, tokenName, preserveReferences, and resolver
|
|
8
|
+
* @returns Map of output name to JSON string (e.g., "primitive" → "{...}", "default" for single-file output)
|
|
9
|
+
*/
|
|
10
|
+
export default function buildFigmaJson({ getTransforms, exclude, tokenName, preserveReferences, resolver, }: BuildOptions): Map<string, string>;
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/build/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAc,MAAM,YAAY,CAAC;AAE3D,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EACrC,aAAa,EACb,OAAO,EACP,SAAS,EACT,kBAAyB,EACzB,QAAQ,GACT,EAAE,YAAY,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAgKpC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { TokenNormalized } from '@terrazzo/parser';
|
|
2
|
+
import type { FigmaJsonPluginOptions } from '../types.js';
|
|
3
|
+
import type { SourceInfo } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Process a single transform and place it in the output object.
|
|
6
|
+
* Handles both simple tokens (string value) and composite tokens (Record<string, string> value).
|
|
7
|
+
*
|
|
8
|
+
* Alias resolution is computed here from the token metadata (transform.token)
|
|
9
|
+
* rather than from embedded internal metadata in the value.
|
|
10
|
+
*
|
|
11
|
+
* Note: this intentionally mutates `output` via setNestedProperty for efficient
|
|
12
|
+
* output tree construction.
|
|
13
|
+
*
|
|
14
|
+
* @param transform - The transform result containing the token and its transformed value
|
|
15
|
+
* @param output - The mutable output object to place the token into (mutated in place)
|
|
16
|
+
* @param sourceName - The current source/context name for alias resolution
|
|
17
|
+
* @param tokenName - Optional custom function to control the output token name
|
|
18
|
+
* @param tokenOutputPaths - Map of token IDs to their output paths
|
|
19
|
+
* @param tokenSources - Map of token IDs to their source info for cross-file alias resolution
|
|
20
|
+
* @param preserveReferences - Whether to preserve alias references in output
|
|
21
|
+
* @param shouldExclude - Function to check if a token ID should be excluded
|
|
22
|
+
* @param allTokens - Map of all tokens for composite alias resolution
|
|
23
|
+
*/
|
|
24
|
+
export declare function processTransform(transform: {
|
|
25
|
+
token: TokenNormalized;
|
|
26
|
+
value: string | Record<string, string>;
|
|
27
|
+
}, output: Record<string, unknown>, sourceName: string, tokenName: FigmaJsonPluginOptions['tokenName'], tokenOutputPaths: Map<string, string>, tokenSources: Map<string, SourceInfo[]>, preserveReferences: boolean, shouldExclude: (id: string) => boolean, allTokens: Record<string, TokenNormalized> | undefined): void;
|
|
28
|
+
//# sourceMappingURL=output.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/build/output.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAI1D,OAAO,KAAK,EAAoB,UAAU,EAAE,MAAM,YAAY,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE;IACT,KAAK,EAAE,eAAe,CAAC;IACvB,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACxC,EACD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,sBAAsB,CAAC,WAAW,CAAC,EAC9C,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EACrC,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC,EACvC,kBAAkB,EAAE,OAAO,EAC3B,aAAa,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,EACtC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,GAAG,SAAS,GACrD,IAAI,CA2EN"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Resolver } from '@terrazzo/parser';
|
|
2
|
+
import type { TokenIdInfo, TokenSourceMaps } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Extract token IDs from a resolver group (token definitions).
|
|
5
|
+
* Recursively walks the group structure to find all token IDs.
|
|
6
|
+
*
|
|
7
|
+
* @param group - The resolver group object containing nested token definitions
|
|
8
|
+
* @param prefix - Dot-notation prefix for building full token paths (used in recursion)
|
|
9
|
+
* @returns Array of token ID info objects with normalized IDs and output paths
|
|
10
|
+
*/
|
|
11
|
+
export declare function extractTokenIds(group: Record<string, unknown>, prefix?: string): TokenIdInfo[];
|
|
12
|
+
/**
|
|
13
|
+
* Build maps tracking which tokens belong to which sources.
|
|
14
|
+
* Processes both sets and modifier contexts from the resolver source.
|
|
15
|
+
*
|
|
16
|
+
* @param resolverSource - The resolver source configuration containing sets and modifiers
|
|
17
|
+
* @returns Token source maps with tokenSources, tokenOutputPaths, and allContexts
|
|
18
|
+
*/
|
|
19
|
+
export declare function buildTokenSourceMaps(resolverSource: NonNullable<Resolver['source']>): TokenSourceMaps;
|
|
20
|
+
//# sourceMappingURL=source-maps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-maps.d.ts","sourceRoot":"","sources":["../../src/build/source-maps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAc,WAAW,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE3E;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,SAAK,GAAG,WAAW,EAAE,CAsB1F;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,cAAc,EAAE,WAAW,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,GAAG,eAAe,CAqErG"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { BuildHookOptions, Resolver } from '@terrazzo/parser';
|
|
2
|
+
import type { FigmaJsonPluginOptions } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Options for the build function.
|
|
5
|
+
*/
|
|
6
|
+
export interface BuildOptions {
|
|
7
|
+
exclude: FigmaJsonPluginOptions['exclude'];
|
|
8
|
+
tokenName?: FigmaJsonPluginOptions['tokenName'];
|
|
9
|
+
getTransforms: BuildHookOptions['getTransforms'];
|
|
10
|
+
preserveReferences?: FigmaJsonPluginOptions['preserveReferences'];
|
|
11
|
+
resolver: Resolver;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Token source tracking info — records which resolver set or modifier context
|
|
15
|
+
* a token belongs to.
|
|
16
|
+
*/
|
|
17
|
+
export interface SourceInfo {
|
|
18
|
+
source: string;
|
|
19
|
+
isModifier: boolean;
|
|
20
|
+
modifierName?: string;
|
|
21
|
+
contextName?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Token ID info including the output path (which may differ from the
|
|
25
|
+
* normalized ID due to $root renaming).
|
|
26
|
+
*/
|
|
27
|
+
export interface TokenIdInfo {
|
|
28
|
+
id: string;
|
|
29
|
+
outputPath: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Options for alias reference resolution.
|
|
33
|
+
*/
|
|
34
|
+
export interface AliasReferenceOptions {
|
|
35
|
+
aliasOf: string;
|
|
36
|
+
sourceName: string;
|
|
37
|
+
tokenSources: Map<string, SourceInfo[]>;
|
|
38
|
+
tokenOutputPaths: Map<string, string>;
|
|
39
|
+
preserveReferences: boolean;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Figma extensions object shape for build output.
|
|
43
|
+
*/
|
|
44
|
+
export interface FigmaOutputExtensions {
|
|
45
|
+
'com.figma.type'?: string;
|
|
46
|
+
'com.figma.aliasData'?: {
|
|
47
|
+
targetVariableSetName: string;
|
|
48
|
+
targetVariableName: string;
|
|
49
|
+
};
|
|
50
|
+
[key: string]: unknown;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Shape of a parsed transform value after JSON.parse.
|
|
54
|
+
*/
|
|
55
|
+
export interface ParsedTokenValue {
|
|
56
|
+
$type: string;
|
|
57
|
+
$value: unknown;
|
|
58
|
+
$description?: string;
|
|
59
|
+
$extensions?: FigmaOutputExtensions;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Result of building token source maps from a resolver.
|
|
63
|
+
*/
|
|
64
|
+
export interface TokenSourceMaps {
|
|
65
|
+
tokenSources: Map<string, SourceInfo[]>;
|
|
66
|
+
tokenOutputPaths: Map<string, string>;
|
|
67
|
+
allContexts: Set<string>;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/build/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAE1D;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,sBAAsB,CAAC,SAAS,CAAC,CAAC;IAC3C,SAAS,CAAC,EAAE,sBAAsB,CAAC,WAAW,CAAC,CAAC;IAChD,aAAa,EAAE,gBAAgB,CAAC,eAAe,CAAC,CAAC;IACjD,kBAAkB,CAAC,EAAE,sBAAsB,CAAC,oBAAoB,CAAC,CAAC;IAClE,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;IACxC,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,kBAAkB,EAAE,OAAO,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,qBAAqB,CAAC,EAAE;QACtB,qBAAqB,EAAE,MAAM,CAAC;QAC9B,kBAAkB,EAAE,MAAM,CAAC;KAC5B,CAAC;IACF,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,qBAAqB,CAAC;CACrC;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;IACxC,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC1B"}
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,26 +1,14 @@
|
|
|
1
1
|
export declare const PLUGIN_NAME = "terrazzo-plugin-figma-json";
|
|
2
2
|
export declare const FORMAT_ID = "figma-json";
|
|
3
|
-
/**
|
|
4
|
-
* Internal metadata property keys used for token processing.
|
|
5
|
-
* These are added during transform and removed during build.
|
|
6
|
-
*/
|
|
7
|
-
export declare const INTERNAL_KEYS: {
|
|
8
|
-
/** Target token ID for alias references */
|
|
9
|
-
readonly ALIAS_OF: "_aliasOf";
|
|
10
|
-
/** Parent token ID for split sub-tokens (e.g., typography) */
|
|
11
|
-
readonly SPLIT_FROM: "_splitFrom";
|
|
12
|
-
/** Token ID for split sub-tokens */
|
|
13
|
-
readonly TOKEN_ID: "_tokenId";
|
|
14
|
-
};
|
|
15
3
|
/**
|
|
16
4
|
* Token types supported by Figma.
|
|
17
5
|
*/
|
|
18
|
-
export declare const SUPPORTED_TYPES: readonly ["color", "dimension", "duration", "fontFamily", "fontWeight", "number", "typography"];
|
|
6
|
+
export declare const SUPPORTED_TYPES: readonly ["color", "dimension", "duration", "fontFamily", "fontWeight", "number", "typography", "shadow", "border", "gradient"];
|
|
19
7
|
export type SupportedType = (typeof SUPPORTED_TYPES)[number];
|
|
20
8
|
/**
|
|
21
9
|
* Token types that are not supported by Figma and will be dropped with a warning.
|
|
22
10
|
*/
|
|
23
|
-
export declare const UNSUPPORTED_TYPES: readonly ["
|
|
11
|
+
export declare const UNSUPPORTED_TYPES: readonly ["transition", "strokeStyle", "cubicBezier"];
|
|
24
12
|
export type UnsupportedType = (typeof UNSUPPORTED_TYPES)[number];
|
|
25
13
|
/**
|
|
26
14
|
* Color spaces that Figma natively supports.
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,+BAA+B,CAAC;AAExD,eAAO,MAAM,SAAS,eAAe,CAAC;AAEtC
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,+BAA+B,CAAC;AAExD,eAAO,MAAM,SAAS,eAAe,CAAC;AAEtC;;GAEG;AACH,eAAO,MAAM,eAAe,iIAWlB,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE7D;;GAEG;AACH,eAAO,MAAM,iBAAiB,uDAAwD,CAAC;AAEvF,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEjE;;GAEG;AACH,eAAO,MAAM,kBAAkB,0BAA2B,CAAC;AAE3D,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ConverterContext, ConverterResult } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Convert a DTCG border value to Figma-compatible format.
|
|
4
|
+
* Border tokens are partially split into individual sub-tokens.
|
|
5
|
+
* Only color and width are supported; style is dropped.
|
|
6
|
+
*
|
|
7
|
+
* @param value - The DTCG border value (object with color, width, and optional style)
|
|
8
|
+
* @param context - Converter context with logger and plugin options
|
|
9
|
+
* @returns Split result with color and width sub-tokens, or skip indicator for invalid values
|
|
10
|
+
*/
|
|
11
|
+
export declare function convertBorder(value: unknown, context: ConverterContext): ConverterResult;
|
|
12
|
+
//# sourceMappingURL=border.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"border.d.ts","sourceRoot":"","sources":["../../src/converters/border.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAY,MAAM,aAAa,CAAC;AAK/E;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB,GAAG,eAAe,CAsDxF"}
|
|
@@ -19,6 +19,10 @@ import type { ConverterContext, ConverterResult } from '../types.js';
|
|
|
19
19
|
* components: [0.7, 0.15, 150]
|
|
20
20
|
* }, context);
|
|
21
21
|
* // => { value: { colorSpace: "srgb", components: [...], alpha: 1 } }
|
|
22
|
+
*
|
|
23
|
+
* @param value - The DTCG color value to convert (should match DTCGColorValue structure)
|
|
24
|
+
* @param context - Converter context with logger and plugin options
|
|
25
|
+
* @returns Converted color value in sRGB or HSL, or skip indicator for invalid values
|
|
22
26
|
*/
|
|
23
27
|
export declare function convertColor(value: unknown, context: ConverterContext): ConverterResult;
|
|
24
28
|
//# sourceMappingURL=color.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../src/converters/color.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAkB,MAAM,aAAa,CAAC;AAoDrF
|
|
1
|
+
{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../src/converters/color.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAkB,MAAM,aAAa,CAAC;AAoDrF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB,GAAG,eAAe,CAoFvF"}
|
|
@@ -12,6 +12,10 @@ import type { ConverterContext, ConverterResult } from '../types.js';
|
|
|
12
12
|
* // rem values are converted to px (default base: 16px)
|
|
13
13
|
* convertDimension({ value: 1.5, unit: "rem" }, context);
|
|
14
14
|
* // => { value: { value: 24, unit: "px" } }
|
|
15
|
+
*
|
|
16
|
+
* @param value - The DTCG dimension value to convert (should match DTCGDimensionValue structure)
|
|
17
|
+
* @param context - Converter context with logger and plugin options (includes remBasePx)
|
|
18
|
+
* @returns Converted dimension in px units, or skip indicator for unsupported units
|
|
15
19
|
*/
|
|
16
20
|
export declare function convertDimension(value: unknown, context: ConverterContext): ConverterResult;
|
|
17
21
|
//# sourceMappingURL=dimension.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dimension.d.ts","sourceRoot":"","sources":["../../src/converters/dimension.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGrE
|
|
1
|
+
{"version":3,"file":"dimension.d.ts","sourceRoot":"","sources":["../../src/converters/dimension.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGrE;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB,GAAG,eAAe,CAoD3F"}
|
|
@@ -12,6 +12,10 @@ import type { ConverterContext, ConverterResult } from '../types.js';
|
|
|
12
12
|
* // ms values are converted to s
|
|
13
13
|
* convertDuration({ value: 500, unit: "ms" }, context);
|
|
14
14
|
* // => { value: { value: 0.5, unit: "s" } }
|
|
15
|
+
*
|
|
16
|
+
* @param value - The DTCG duration value to convert (should match DTCGDurationValue structure)
|
|
17
|
+
* @param context - Converter context with logger and plugin options
|
|
18
|
+
* @returns Converted duration in seconds, or skip indicator for unsupported units
|
|
15
19
|
*/
|
|
16
20
|
export declare function convertDuration(value: unknown, context: ConverterContext): ConverterResult;
|
|
17
21
|
//# sourceMappingURL=duration.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"duration.d.ts","sourceRoot":"","sources":["../../src/converters/duration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGrE
|
|
1
|
+
{"version":3,"file":"duration.d.ts","sourceRoot":"","sources":["../../src/converters/duration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGrE;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB,GAAG,eAAe,CAoD1F"}
|
|
@@ -12,6 +12,10 @@ import type { ConverterContext, ConverterResult } from '../types.js';
|
|
|
12
12
|
* // Arrays are truncated to the first element
|
|
13
13
|
* convertFontFamily(["Inter", "Helvetica", "sans-serif"], context);
|
|
14
14
|
* // => { value: "Inter" } (with warning about dropped fallbacks)
|
|
15
|
+
*
|
|
16
|
+
* @param value - The DTCG fontFamily value (string or string array)
|
|
17
|
+
* @param context - Converter context with logger and plugin options
|
|
18
|
+
* @returns Single font family string, or skip indicator for invalid values
|
|
15
19
|
*/
|
|
16
20
|
export declare function convertFontFamily(value: unknown, context: ConverterContext): ConverterResult;
|
|
17
21
|
//# sourceMappingURL=font-family.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"font-family.d.ts","sourceRoot":"","sources":["../../src/converters/font-family.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAErE
|
|
1
|
+
{"version":3,"file":"font-family.d.ts","sourceRoot":"","sources":["../../src/converters/font-family.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAErE;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB,GAAG,eAAe,CAqC5F"}
|
|
@@ -12,6 +12,10 @@ import type { ConverterContext, ConverterResult } from '../types.js';
|
|
|
12
12
|
* // String aliases pass through if valid
|
|
13
13
|
* convertFontWeight("bold", context);
|
|
14
14
|
* // => { value: "bold" }
|
|
15
|
+
*
|
|
16
|
+
* @param value - The DTCG fontWeight value (number 1-1000 or string alias like "bold")
|
|
17
|
+
* @param context - Converter context with logger and plugin options
|
|
18
|
+
* @returns Font weight value with outputType set to 'number' or 'string', or skip indicator for invalid values
|
|
15
19
|
*/
|
|
16
20
|
export declare function convertFontWeight(value: unknown, context: ConverterContext): ConverterResult;
|
|
17
21
|
//# sourceMappingURL=font-weight.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"font-weight.d.ts","sourceRoot":"","sources":["../../src/converters/font-weight.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AA0BrE
|
|
1
|
+
{"version":3,"file":"font-weight.d.ts","sourceRoot":"","sources":["../../src/converters/font-weight.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AA0BrE;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB,GAAG,eAAe,CAqC5F"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ConverterContext, ConverterResult } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Convert a DTCG gradient value to Figma-compatible format.
|
|
4
|
+
* Gradient tokens are partially split: only stop colors are extracted.
|
|
5
|
+
* Stop positions are dropped since they can't be represented as Figma variables.
|
|
6
|
+
*
|
|
7
|
+
* @param value - The DTCG gradient value (array of gradient stops with color and position)
|
|
8
|
+
* @param context - Converter context with logger and plugin options
|
|
9
|
+
* @returns Split result with color sub-tokens for each stop, or skip indicator for invalid values
|
|
10
|
+
*/
|
|
11
|
+
export declare function convertGradient(value: unknown, context: ConverterContext): ConverterResult;
|
|
12
|
+
//# sourceMappingURL=gradient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gradient.d.ts","sourceRoot":"","sources":["../../src/converters/gradient.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAY,MAAM,aAAa,CAAC;AAI/E;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB,GAAG,eAAe,CAmD1F"}
|
|
@@ -7,10 +7,16 @@ import type { ConverterContext, ConverterResult } from '../types.js';
|
|
|
7
7
|
export type Converter = (value: unknown, context: ConverterContext) => ConverterResult;
|
|
8
8
|
/**
|
|
9
9
|
* Check if a token type is supported by Figma.
|
|
10
|
+
*
|
|
11
|
+
* @param type - The DTCG token type string
|
|
12
|
+
* @returns True if the type is one of the Figma-supported token types
|
|
10
13
|
*/
|
|
11
14
|
export declare function isSupportedType(type: string): type is SupportedType;
|
|
12
15
|
/**
|
|
13
16
|
* Check if a value is an alias reference (curly brace syntax).
|
|
17
|
+
*
|
|
18
|
+
* @param value - The value to check
|
|
19
|
+
* @returns True if value is a string wrapped in curly braces (e.g., "{color.primary}")
|
|
14
20
|
*/
|
|
15
21
|
export declare function isAlias(value: unknown): value is string;
|
|
16
22
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/converters/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAgC,KAAK,aAAa,EAAqB,MAAM,iBAAiB,CAAC;AACtG,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/converters/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAgC,KAAK,aAAa,EAAqB,MAAM,iBAAiB,CAAC;AACtG,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAYrE;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB,KAAK,eAAe,CAAC;AAkBvF;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,aAAa,CAEnE;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAEvD;AAiDD;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB,GAAG,eAAe,CAiD/G"}
|