style-dictionary 4.2.0 → 4.3.1

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 (145) hide show
  1. package/README.md +8 -5
  2. package/bin/style-dictionary.d.ts +8 -0
  3. package/bin/style-dictionary.js +38 -10
  4. package/examples/advanced/assets-base64-embed/package.json +1 -1
  5. package/examples/advanced/create-react-app/package.json +1 -1
  6. package/examples/advanced/create-react-native-app/package.json +1 -1
  7. package/examples/advanced/create-react-native-app/src/App.js +0 -1
  8. package/examples/advanced/custom-parser/package.json +1 -1
  9. package/examples/advanced/custom-parser/sd.config.js +3 -2
  10. package/examples/advanced/custom-transforms/README.md +1 -1
  11. package/examples/advanced/custom-transforms/build.js +11 -8
  12. package/examples/advanced/custom-transforms/package.json +1 -1
  13. package/examples/advanced/font-face-rules/package.json +1 -1
  14. package/examples/advanced/font-face-rules/sd.config.js +2 -1
  15. package/examples/advanced/format-helpers/package.json +1 -1
  16. package/examples/advanced/format-helpers/sd.config.js +3 -2
  17. package/examples/advanced/matching-build-files/config.js +15 -10
  18. package/examples/advanced/matching-build-files/package.json +1 -1
  19. package/examples/advanced/multi-brand-multi-platform/build.js +10 -7
  20. package/examples/advanced/multi-brand-multi-platform/package.json +1 -1
  21. package/examples/advanced/node-modules-as-config-and-properties/config.js +17 -12
  22. package/examples/advanced/node-modules-as-config-and-properties/package.json +1 -1
  23. package/examples/advanced/npm-module/package.json +1 -1
  24. package/examples/advanced/referencing_aliasing/package.json +1 -1
  25. package/examples/advanced/s3/package.json +1 -1
  26. package/examples/advanced/tailwind-preset/README.md +94 -0
  27. package/examples/advanced/tailwind-preset/config/filter.js +3 -0
  28. package/examples/advanced/tailwind-preset/config/filter.test.js +12 -0
  29. package/examples/advanced/tailwind-preset/config/format.js +60 -0
  30. package/examples/advanced/tailwind-preset/config/transform.js +21 -0
  31. package/examples/advanced/tailwind-preset/config/transform.test.js +37 -0
  32. package/examples/advanced/tailwind-preset/config.js +55 -0
  33. package/examples/advanced/tailwind-preset/demo/index.html +27 -0
  34. package/examples/advanced/tailwind-preset/demo/input.css +3 -0
  35. package/examples/advanced/tailwind-preset/package.json +18 -0
  36. package/examples/advanced/tailwind-preset/tailwind.config.js +11 -0
  37. package/examples/advanced/tailwind-preset/tokens/tokens.json +49 -0
  38. package/examples/advanced/tokens-deprecation/build.js +2 -1
  39. package/examples/advanced/tokens-deprecation/package.json +1 -1
  40. package/examples/advanced/transitive-transforms/package.json +1 -1
  41. package/examples/advanced/transitive-transforms/sd.config.js +12 -9
  42. package/examples/advanced/variables-in-outputs/package.json +1 -1
  43. package/examples/advanced/variables-in-outputs/sd.config.js +10 -5
  44. package/examples/advanced/yaml-tokens/package.json +1 -1
  45. package/examples/advanced/yaml-tokens/sd.config.js +3 -2
  46. package/lib/Register.d.ts +2 -2
  47. package/lib/Register.js +6 -3
  48. package/lib/StyleDictionary.d.ts +20 -18
  49. package/lib/StyleDictionary.js +89 -71
  50. package/lib/cleanActions.d.ts +1 -1
  51. package/lib/cleanDir.d.ts +1 -1
  52. package/lib/cleanDir.js +2 -1
  53. package/lib/cleanDirs.d.ts +1 -1
  54. package/lib/cleanFile.d.ts +1 -6
  55. package/lib/cleanFile.js +5 -2
  56. package/lib/cleanFiles.d.ts +1 -1
  57. package/lib/common/actions.d.ts +20 -1
  58. package/lib/common/actions.js +8 -4
  59. package/lib/common/filters.d.ts +7 -1
  60. package/lib/common/formatHelpers/createPropertyFormatter.d.ts +3 -1
  61. package/lib/common/formatHelpers/createPropertyFormatter.js +26 -19
  62. package/lib/common/formatHelpers/fileHeader.d.ts +1 -1
  63. package/lib/common/formatHelpers/fileHeader.js +4 -2
  64. package/lib/common/formatHelpers/formattedVariables.d.ts +3 -1
  65. package/lib/common/formatHelpers/formattedVariables.js +3 -1
  66. package/lib/common/formatHelpers/getTypeScriptType.d.ts +2 -2
  67. package/lib/common/formatHelpers/minifyDictionary.d.ts +1 -1
  68. package/lib/common/formatHelpers/setComposeObjectProperties.d.ts +1 -1
  69. package/lib/common/formatHelpers/setSwiftFileProperties.d.ts +1 -1
  70. package/lib/common/formatHelpers/sortByReference.d.ts +1 -1
  71. package/lib/common/formats.js +235 -162
  72. package/lib/common/templates/compose/object.kt.template.js +8 -4
  73. package/lib/common/templates/css/fonts.css.template.js +2 -2
  74. package/lib/common/templates/scss/map-flat.template.js +4 -3
  75. package/lib/common/transformGroups.d.ts +209 -1
  76. package/lib/common/transformGroups.js +139 -93
  77. package/lib/common/transforms.d.ts +961 -1
  78. package/lib/common/transforms.js +113 -111
  79. package/lib/enums/actions.d.ts +4 -0
  80. package/lib/enums/actions.js +4 -0
  81. package/lib/enums/commentPositions.d.ts +4 -0
  82. package/lib/enums/commentPositions.js +4 -0
  83. package/lib/enums/commentStyles.d.ts +5 -0
  84. package/lib/enums/commentStyles.js +5 -0
  85. package/lib/enums/fileHeaderCommentStyles.d.ts +5 -0
  86. package/lib/enums/fileHeaderCommentStyles.js +5 -0
  87. package/lib/enums/formats.d.ts +46 -0
  88. package/lib/enums/formats.js +50 -0
  89. package/lib/enums/index.d.ts +12 -0
  90. package/lib/enums/index.js +12 -0
  91. package/lib/enums/logBrokenReferenceLevels.d.ts +5 -0
  92. package/lib/enums/logBrokenReferenceLevels.js +4 -0
  93. package/lib/enums/logVerbosityLevels.d.ts +6 -0
  94. package/lib/enums/logVerbosityLevels.js +5 -0
  95. package/lib/enums/logWarningLevels.d.ts +5 -0
  96. package/lib/enums/logWarningLevels.js +5 -0
  97. package/lib/enums/propertyFormatNames.d.ts +6 -0
  98. package/lib/enums/propertyFormatNames.js +6 -0
  99. package/lib/enums/transformGroups.d.ts +17 -0
  100. package/lib/enums/transformGroups.js +17 -0
  101. package/lib/enums/transformTypes.d.ts +5 -0
  102. package/lib/enums/transformTypes.js +5 -0
  103. package/lib/enums/transforms.d.ts +57 -0
  104. package/lib/enums/transforms.js +57 -0
  105. package/lib/filterTokens.d.ts +1 -1
  106. package/lib/filterTokens.js +5 -0
  107. package/lib/fs.d.ts +1 -1
  108. package/lib/fs.js +1 -1
  109. package/lib/performActions.d.ts +1 -1
  110. package/lib/resolve.d.ts +1 -1
  111. package/lib/resolve.js +4 -3
  112. package/lib/transform/config.js +3 -2
  113. package/lib/transform/object.d.ts +1 -1
  114. package/lib/transform/token.d.ts +1 -9
  115. package/lib/transform/token.js +10 -3
  116. package/lib/utils/cleanActions.d.ts +1 -1
  117. package/lib/utils/combineJSON.d.ts +1 -1
  118. package/lib/utils/combineJSON.js +12 -32
  119. package/lib/utils/convertToBase64.d.ts +1 -1
  120. package/lib/utils/convertToDTCG.d.ts +3 -3
  121. package/lib/utils/convertTokenData.d.ts +30 -0
  122. package/lib/utils/convertTokenData.js +123 -0
  123. package/lib/utils/deepExtend.d.ts +1 -1
  124. package/lib/utils/deepmerge.d.ts +1 -1
  125. package/lib/utils/expandObjectTokens.d.ts +2 -2
  126. package/lib/utils/expandObjectTokens.js +1 -1
  127. package/lib/utils/flattenTokens.d.ts +9 -5
  128. package/lib/utils/flattenTokens.js +28 -16
  129. package/lib/utils/index.d.ts +2 -1
  130. package/lib/utils/index.js +3 -0
  131. package/lib/utils/loadFile.d.ts +13 -0
  132. package/lib/utils/loadFile.js +89 -0
  133. package/lib/utils/preprocess.d.ts +1 -1
  134. package/lib/utils/references/defaults.d.ts +5 -1
  135. package/lib/utils/references/getName.d.ts +1 -1
  136. package/lib/utils/references/getReferences.d.ts +1 -1
  137. package/lib/utils/references/outputReferencesTransformed.js +1 -1
  138. package/lib/utils/references/resolveReferences.d.ts +2 -2
  139. package/lib/utils/references/usesReferences.d.ts +1 -1
  140. package/package.json +27 -16
  141. package/types/Config.d.ts +9 -3
  142. package/types/DesignToken.d.ts +6 -0
  143. package/types/File.d.ts +6 -2
  144. package/types/Format.d.ts +4 -1
  145. package/types/Transform.d.ts +4 -3
@@ -11,9 +11,9 @@
11
11
  * and limitations under the License.
12
12
  */
13
13
  import * as prettier from 'prettier/standalone';
14
- import prettierPluginBabel from 'prettier/plugins/babel';
15
- import prettierPluginEstree from 'prettier/plugins/estree';
16
- import prettierPluginTypescript from 'prettier/plugins/typescript';
14
+ import * as prettierPluginBabel from 'prettier/plugins/babel';
15
+ import * as prettierPluginEstree from 'prettier/plugins/estree';
16
+ import * as prettierPluginTypescript from 'prettier/plugins/typescript';
17
17
 
18
18
  import {
19
19
  fileHeader,
@@ -30,28 +30,34 @@ import {
30
30
 
31
31
  import { stripMeta as stripMetaUtil } from '../utils/stripMeta.js';
32
32
 
33
- import androidColors from './templates/android/colors.template.js';
34
- import androidDimens from './templates/android/dimens.template.js';
35
- import androidFontDimens from './templates/android/fontDimens.template.js';
36
- import androidIntegers from './templates/android/integers.template.js';
37
- import androidResources from './templates/android/resources.template.js';
38
- import androidStrings from './templates/android/strings.template.js';
39
- import composeObject from './templates/compose/object.kt.template.js';
40
- import cssFonts from './templates/css/fonts.css.template.js';
41
- import flutterClassDart from './templates/flutter/class.dart.template.js';
42
- import iosColorsH from './templates/ios/colors.h.template.js';
43
- import iosColorsM from './templates/ios/colors.m.template.js';
44
- import iosSingletonH from './templates/ios/singleton.h.template.js';
45
- import iosSingletonM from './templates/ios/singleton.m.template.js';
46
- import iosStaticH from './templates/ios/static.h.template.js';
47
- import iosStaticM from './templates/ios/static.m.template.js';
48
- import iosStringsH from './templates/ios/strings.h.template.js';
49
- import iosStringsM from './templates/ios/strings.m.template.js';
50
- import iosSwiftAny from './templates/ios-swift/any.swift.template.js';
51
- import scssMapDeep from './templates/scss/map-deep.template.js';
52
- import scssMapFlat from './templates/scss/map-flat.template.js';
33
+ import androidColorsTemplate from './templates/android/colors.template.js';
34
+ import androidDimensTemplate from './templates/android/dimens.template.js';
35
+ import androidFontDimensTemplate from './templates/android/fontDimens.template.js';
36
+ import androidIntegersTemplate from './templates/android/integers.template.js';
37
+ import androidResourcesTemplate from './templates/android/resources.template.js';
38
+ import androidStringsTemplate from './templates/android/strings.template.js';
39
+ import composeObjectTemplate from './templates/compose/object.kt.template.js';
40
+ import cssFontsTemplate from './templates/css/fonts.css.template.js';
41
+ import flutterClassDartTemplate from './templates/flutter/class.dart.template.js';
42
+ import iosColorsHTemplate from './templates/ios/colors.h.template.js';
43
+ import iosColorsMTemplate from './templates/ios/colors.m.template.js';
44
+ import iosSingletonHTemplate from './templates/ios/singleton.h.template.js';
45
+ import iosSingletonMTemplate from './templates/ios/singleton.m.template.js';
46
+ import iosStaticHTemplate from './templates/ios/static.h.template.js';
47
+ import iosStaticMTemplate from './templates/ios/static.m.template.js';
48
+ import iosStringsHTemplate from './templates/ios/strings.h.template.js';
49
+ import iosStringsMTemplate from './templates/ios/strings.m.template.js';
50
+ import iosSwiftAnyTemplate from './templates/ios-swift/any.swift.template.js';
51
+ import scssMapDeepTemplate from './templates/scss/map-deep.template.js';
52
+ import scssMapFlatTemplate from './templates/scss/map-flat.template.js';
53
53
  import macrosTemplate from './templates/ios/macros.template.js';
54
54
  import plistTemplate from './templates/ios/plist.template.js';
55
+ import {
56
+ commentStyles,
57
+ fileHeaderCommentStyles,
58
+ formats as fileFormats,
59
+ propertyFormatNames,
60
+ } from '../enums/index.js';
55
61
 
56
62
  /**
57
63
  * @typedef {import('../../types/Format.d.ts').Format} Format
@@ -65,6 +71,56 @@ import plistTemplate from './templates/ios/plist.template.js';
65
71
  * @typedef {import('../utils/stripMeta.js').StripMetaOptions} StripMetaOptions
66
72
  */
67
73
 
74
+ const { none } = commentStyles;
75
+ const { long, short, xml } = fileHeaderCommentStyles;
76
+ const { css, sass, less, stylus } = propertyFormatNames;
77
+ const {
78
+ cssVariables,
79
+ cssFonts,
80
+ scssMapFlat,
81
+ scssMapDeep,
82
+ scssVariables,
83
+ scssIcons,
84
+ lessVariables,
85
+ lessIcons,
86
+ stylusVariables,
87
+ javascriptEs6,
88
+ javascriptEsm,
89
+ javascriptModule,
90
+ javascriptModuleFlat,
91
+ javascriptObject,
92
+ javascriptUmd,
93
+ typescriptEs6Declarations,
94
+ typescriptModuleDeclarations,
95
+ androidResources,
96
+ androidColors,
97
+ androidDimens,
98
+ androidFontDimens,
99
+ androidIntegers,
100
+ androidStrings,
101
+ composeObject,
102
+ iosMacros,
103
+ iosPlist,
104
+ iosSingletonM,
105
+ iosSingletonH,
106
+ iosStaticH,
107
+ iosStaticM,
108
+ iosColorsH,
109
+ iosColorsM,
110
+ iosStringsH,
111
+ iosStringsM,
112
+ iosSwiftClassSwift,
113
+ iosSwiftEnumSwift,
114
+ iosSwiftAnySwift,
115
+ json,
116
+ jsonAsset,
117
+ jsonNested,
118
+ jsonFlat,
119
+ sketchPalette,
120
+ sketchPaletteV2,
121
+ flutterClassDart,
122
+ } = fileFormats;
123
+
68
124
  /**
69
125
  * @namespace Formats
70
126
  */
@@ -136,7 +192,7 @@ const formats = {
136
192
  * }
137
193
  * ```
138
194
  */
139
- 'css/variables': async function ({ dictionary, options = {}, file }) {
195
+ [cssVariables]: async function ({ dictionary, options = {}, file }) {
140
196
  const selector = options.selector ? options.selector : `:root`;
141
197
  const { outputReferences, outputReferenceFallbacks, usesDtcg, formatting } = options;
142
198
  const header = await fileHeader({
@@ -148,7 +204,7 @@ const formats = {
148
204
  header +
149
205
  `${selector} {\n` +
150
206
  formattedVariables({
151
- format: 'css',
207
+ format: css,
152
208
  dictionary,
153
209
  outputReferences,
154
210
  outputReferenceFallbacks,
@@ -174,16 +230,16 @@ const formats = {
174
230
  * )
175
231
  * ```
176
232
  */
177
- 'scss/map-flat': async function ({ dictionary, options, file }) {
233
+ [scssMapFlat]: async function ({ dictionary, options, file }) {
178
234
  const { allTokens } = dictionary;
179
235
  const { formatting } = options;
180
236
  const header = await fileHeader({
181
237
  file,
182
- commentStyle: 'long',
238
+ commentStyle: long,
183
239
  formatting: getFormattingCloneWithoutPrefix(formatting),
184
240
  options,
185
241
  });
186
- return scssMapFlat({ allTokens, options, header });
242
+ return scssMapFlatTemplate({ allTokens, options, header });
187
243
  },
188
244
 
189
245
  /**
@@ -208,12 +264,12 @@ const formats = {
208
264
  * )
209
265
  * ```
210
266
  */
211
- 'scss/map-deep': async function ({ dictionary, options, file }) {
267
+ [scssMapDeep]: async function ({ dictionary, options, file }) {
212
268
  // Default the "themeable" option to true for backward compatibility.
213
269
  const { outputReferences, themeable = true, formatting, usesDtcg } = options;
214
270
  const header = await fileHeader({
215
271
  file,
216
- commentStyle: 'long',
272
+ commentStyle: long,
217
273
  formatting: getFormattingCloneWithoutPrefix(formatting),
218
274
  options,
219
275
  });
@@ -221,7 +277,7 @@ const formats = {
221
277
  '\n' +
222
278
  header +
223
279
  formattedVariables({
224
- format: 'sass',
280
+ format: sass,
225
281
  dictionary,
226
282
  outputReferences,
227
283
  themeable,
@@ -229,7 +285,7 @@ const formats = {
229
285
  usesDtcg,
230
286
  }) +
231
287
  '\n' +
232
- scssMapDeep({ dictionary, options })
288
+ scssMapDeepTemplate({ dictionary, options })
233
289
  );
234
290
  },
235
291
 
@@ -246,18 +302,18 @@ const formats = {
246
302
  * $color-background-alt: #eeeeee !default;
247
303
  * ```
248
304
  */
249
- 'scss/variables': async function ({ dictionary, options, file }) {
305
+ [scssVariables]: async function ({ dictionary, options, file }) {
250
306
  const { outputReferences, themeable = false, formatting, usesDtcg } = options;
251
307
  const header = await fileHeader({
252
308
  file,
253
- commentStyle: 'short',
309
+ commentStyle: short,
254
310
  formatting: getFormattingCloneWithoutPrefix(formatting),
255
311
  options,
256
312
  });
257
313
  return (
258
314
  header +
259
315
  formattedVariables({
260
- format: 'sass',
316
+ format: sass,
261
317
  dictionary,
262
318
  outputReferences,
263
319
  themeable,
@@ -279,11 +335,11 @@ const formats = {
279
335
  * .icon.email:before { content:$content-icon-email; }
280
336
  * ```
281
337
  */
282
- 'scss/icons': async function ({ dictionary, options, file, platform }) {
338
+ [scssIcons]: async function ({ dictionary, options, file, platform }) {
283
339
  const { formatting } = options;
284
340
  const header = await fileHeader({
285
341
  file,
286
- commentStyle: 'short',
342
+ commentStyle: short,
287
343
  formatting: getFormattingCloneWithoutPrefix(formatting),
288
344
  options,
289
345
  });
@@ -301,17 +357,23 @@ const formats = {
301
357
  * \@color-background-alt: #eeeeee;
302
358
  * ```
303
359
  */
304
- 'less/variables': async function ({ dictionary, options, file }) {
360
+ [lessVariables]: async function ({ dictionary, options, file }) {
305
361
  const { outputReferences, formatting, usesDtcg } = options;
306
362
  const header = await fileHeader({
307
363
  file,
308
- commentStyle: 'short',
364
+ commentStyle: short,
309
365
  formatting: getFormattingCloneWithoutPrefix(formatting),
310
366
  options,
311
367
  });
312
368
  return (
313
369
  header +
314
- formattedVariables({ format: 'less', dictionary, outputReferences, formatting, usesDtcg }) +
370
+ formattedVariables({
371
+ format: less,
372
+ dictionary,
373
+ outputReferences,
374
+ formatting,
375
+ usesDtcg,
376
+ }) +
315
377
  '\n'
316
378
  );
317
379
  },
@@ -327,11 +389,11 @@ const formats = {
327
389
  * .icon.email:before { content:\@content-icon-email; }
328
390
  * ```
329
391
  */
330
- 'less/icons': async function ({ dictionary, options, file, platform }) {
392
+ [lessIcons]: async function ({ dictionary, options, file, platform }) {
331
393
  const { formatting } = options;
332
394
  const header = await fileHeader({
333
395
  file,
334
- commentStyle: 'short',
396
+ commentStyle: short,
335
397
  formatting: getFormattingCloneWithoutPrefix(formatting),
336
398
  options,
337
399
  });
@@ -349,18 +411,24 @@ const formats = {
349
411
  * $color-background-alt= #eeeeee;
350
412
  * ```
351
413
  */
352
- 'stylus/variables': async function ({ dictionary, options, file, platform }) {
414
+ [stylusVariables]: async function ({ dictionary, options, file, platform }) {
353
415
  const { formatting, usesDtcg } = options;
354
416
  const outputReferences = !!platform.options?.outputReferences;
355
417
  const header = await fileHeader({
356
418
  file,
357
- commentStyle: 'short',
419
+ commentStyle: short,
358
420
  formatting: getFormattingCloneWithoutPrefix(formatting),
359
421
  options,
360
422
  });
361
423
  return (
362
424
  header +
363
- formattedVariables({ format: 'stylus', dictionary, outputReferences, formatting, usesDtcg }) +
425
+ formattedVariables({
426
+ format: stylus,
427
+ dictionary,
428
+ outputReferences,
429
+ formatting,
430
+ usesDtcg,
431
+ }) +
364
432
  '\n'
365
433
  );
366
434
  },
@@ -383,7 +451,7 @@ const formats = {
383
451
  * }
384
452
  * ```
385
453
  */
386
- 'javascript/module': async function ({ dictionary, file, options }) {
454
+ [javascriptModule]: async function ({ dictionary, file, options }) {
387
455
  const { formatting } = options;
388
456
  const header = await fileHeader({
389
457
  file,
@@ -407,7 +475,7 @@ const formats = {
407
475
  *}
408
476
  *```
409
477
  */
410
- 'javascript/module-flat': async function ({ dictionary, file, options }) {
478
+ [javascriptModuleFlat]: async function ({ dictionary, file, options }) {
411
479
  const { formatting } = options;
412
480
  const header = await fileHeader({
413
481
  file,
@@ -449,7 +517,7 @@ const formats = {
449
517
  * }
450
518
  * ```
451
519
  */
452
- 'javascript/object': async function ({ dictionary, file, options }) {
520
+ [javascriptObject]: async function ({ dictionary, file, options }) {
453
521
  const { formatting } = options;
454
522
  const header = await fileHeader({
455
523
  file,
@@ -496,7 +564,7 @@ const formats = {
496
564
  * }))
497
565
  * ```
498
566
  */
499
- 'javascript/umd': async function ({ dictionary, file, options }) {
567
+ [javascriptUmd]: async function ({ dictionary, file, options }) {
500
568
  const name = file.options?.name || '_styleDictionary';
501
569
  const { formatting } = options;
502
570
  const header = await fileHeader({
@@ -558,28 +626,25 @@ const formats = {
558
626
  * export const ColorBackgroundAlt = '#fcfcfcfc';
559
627
  * ```
560
628
  */
561
- 'javascript/es6': async function ({ dictionary, file, options }) {
629
+ [javascriptEs6]: async function ({ dictionary, file, options }) {
562
630
  const { formatting } = options;
563
631
  const header = await fileHeader({
564
632
  file,
565
633
  formatting: getFormattingCloneWithoutPrefix(formatting),
566
634
  options,
567
635
  });
568
- const content =
569
- header +
570
- dictionary.allTokens
571
- .map(function (token) {
572
- let to_ret =
573
- 'export const ' +
574
- token.name +
575
- ' = ' +
576
- JSON.stringify(options.usesDtcg ? token.$value : token.value) +
577
- ';';
578
- if (token.comment) to_ret = to_ret.concat(' // ' + token.comment);
579
- return to_ret;
580
- })
581
- .join('\n') +
582
- '\n';
636
+ const content = [
637
+ header,
638
+ dictionary.allTokens.map((token) => {
639
+ const value = JSON.stringify(options.usesDtcg ? token.$value : token.value);
640
+ const comment = options.usesDtcg ? token.$description : token.comment;
641
+ const to_ret = `export const ${token.name} = ${value};`;
642
+
643
+ return comment ? to_ret.concat(`// ${comment}`) : to_ret;
644
+ }),
645
+ ]
646
+ .flat()
647
+ .join('\n');
583
648
  return formatJS(content);
584
649
  },
585
650
 
@@ -599,7 +664,7 @@ const formats = {
599
664
  * }
600
665
  * ```
601
666
  */
602
- 'javascript/esm': async function ({ dictionary, file, options }) {
667
+ [javascriptEsm]: async function ({ dictionary, file, options }) {
603
668
  const { formatting, minify = false } = options;
604
669
  let { tokens } = dictionary;
605
670
  tokens = stripMetaProps(
@@ -655,29 +720,30 @@ const formats = {
655
720
  * export const ColorBackgroundAlt : string;
656
721
  * ```
657
722
  */
658
- 'typescript/es6-declarations': async function ({ dictionary, file, options }) {
723
+ [typescriptEs6Declarations]: async function ({ dictionary, file, options }) {
659
724
  const { formatting } = options;
660
725
  const header = await fileHeader({
661
726
  file,
662
727
  formatting: getFormattingCloneWithoutPrefix(formatting),
663
728
  options,
664
729
  });
665
- const content =
666
- header +
667
- dictionary.allTokens
668
- .map(function (token) {
669
- let to_ret_token = '';
670
- if (token.comment) to_ret_token += '/** ' + token.comment + ' */\n';
671
- to_ret_token +=
672
- 'export const ' +
673
- token.name +
674
- ' : ' +
675
- getTypeScriptType(options.usesDtcg ? token.$value : token.value, options) +
676
- ';';
677
- return to_ret_token;
678
- })
679
- .join('\n') +
680
- '\n';
730
+ const content = [
731
+ header,
732
+ dictionary.allTokens.map((token) => {
733
+ const typescriptType = getTypeScriptType(
734
+ options.usesDtcg ? token.$value : token.value,
735
+ options,
736
+ );
737
+ const comment = options.usesDtcg ? token.$description : token.comment;
738
+
739
+ return [
740
+ `${comment ? `/** ${comment} */` : ''}`,
741
+ `export const ${token.name} : ${typescriptType};`,
742
+ ].join('\n');
743
+ }),
744
+ ]
745
+ .flat()
746
+ .join('');
681
747
  return formatJS(content, true);
682
748
  },
683
749
 
@@ -734,7 +800,7 @@ const formats = {
734
800
  * });
735
801
  * ```
736
802
  */
737
- 'typescript/module-declarations': async function ({ dictionary, file, options }) {
803
+ [typescriptModuleDeclarations]: async function ({ dictionary, file, options }) {
738
804
  const { moduleName = `tokens` } = options;
739
805
  /**
740
806
  * @param {Tokens} obj
@@ -812,15 +878,15 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
812
878
  * <dimen name="size_font_base">14sp</color>
813
879
  * ```
814
880
  */
815
- 'android/resources': async function ({ dictionary, file, options }) {
881
+ [androidResources]: async function ({ dictionary, file, options }) {
816
882
  const { formatting } = options;
817
883
  const header = await fileHeader({
818
884
  file,
819
- commentStyle: 'xml',
885
+ commentStyle: xml,
820
886
  formatting: getFormattingCloneWithoutPrefix(formatting),
821
887
  options,
822
888
  });
823
- return androidResources({ dictionary, file, header, options });
889
+ return androidResourcesTemplate({ dictionary, file, header, options });
824
890
  },
825
891
 
826
892
  /**
@@ -830,7 +896,7 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
830
896
  * instead of this format:
831
897
  *
832
898
  * ```javascript
833
- * format: 'android/resources',
899
+ * format: formats.androidResources,
834
900
  * filter: {
835
901
  * attributes: { category: 'color' }
836
902
  * }
@@ -847,15 +913,15 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
847
913
  * <color name="color_base_red_60">#ffe19d9c</color>
848
914
  * ```
849
915
  */
850
- 'android/colors': async function ({ dictionary, options, file }) {
916
+ [androidColors]: async function ({ dictionary, options, file }) {
851
917
  const { formatting } = options;
852
918
  const header = await fileHeader({
853
919
  file,
854
- commentStyle: 'xml',
920
+ commentStyle: xml,
855
921
  formatting: getFormattingCloneWithoutPrefix(formatting),
856
922
  options,
857
923
  });
858
- return androidColors({ dictionary, options, header });
924
+ return androidColorsTemplate({ dictionary, options, header });
859
925
  },
860
926
 
861
927
  /**
@@ -865,7 +931,7 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
865
931
  * instead of this format:
866
932
  *
867
933
  * ```javascript
868
- * format: 'android/resources',
934
+ * format: formats.androidResources,
869
935
  * filter: {
870
936
  * attributes: { category: 'size' }
871
937
  * }
@@ -882,15 +948,15 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
882
948
  * <dimen name="size_padding_medium">15.00dp</dimen>
883
949
  * ```
884
950
  */
885
- 'android/dimens': async function ({ dictionary, options, file }) {
951
+ [androidDimens]: async function ({ dictionary, options, file }) {
886
952
  const { formatting } = options;
887
953
  const header = await fileHeader({
888
954
  file,
889
- commentStyle: 'xml',
955
+ commentStyle: xml,
890
956
  formatting: getFormattingCloneWithoutPrefix(formatting),
891
957
  options,
892
958
  });
893
- return androidDimens({ dictionary, options, header });
959
+ return androidDimensTemplate({ dictionary, options, header });
894
960
  },
895
961
 
896
962
  /**
@@ -900,7 +966,7 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
900
966
  * instead of this format:
901
967
  *
902
968
  * ```javascript
903
- * format: 'android/resources',
969
+ * format: formats.androidResources,
904
970
  * filter: {
905
971
  * attributes: { category: 'size' }
906
972
  * }
@@ -917,15 +983,15 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
917
983
  * <dimen name="size_font_medium">15.00sp</dimen>
918
984
  * ```
919
985
  */
920
- 'android/fontDimens': async function ({ dictionary, options, file }) {
986
+ [androidFontDimens]: async function ({ dictionary, options, file }) {
921
987
  const { formatting } = options;
922
988
  const header = await fileHeader({
923
989
  file,
924
- commentStyle: 'xml',
990
+ commentStyle: xml,
925
991
  formatting: getFormattingCloneWithoutPrefix(formatting),
926
992
  options,
927
993
  });
928
- return androidFontDimens({ dictionary, options, header });
994
+ return androidFontDimensTemplate({ dictionary, options, header });
929
995
  },
930
996
 
931
997
  /**
@@ -936,7 +1002,7 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
936
1002
  * instead of this format:
937
1003
  *
938
1004
  * ```javascript
939
- * format: 'android/resources',
1005
+ * format: formats.androidResources,
940
1006
  * filter: {
941
1007
  * attributes: { category: 'time' }
942
1008
  * }
@@ -954,15 +1020,15 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
954
1020
  * <integer name="time_duration_long">4000</integer>
955
1021
  * ```
956
1022
  */
957
- 'android/integers': async function ({ dictionary, options, file }) {
1023
+ [androidIntegers]: async function ({ dictionary, options, file }) {
958
1024
  const { formatting } = options;
959
1025
  const header = await fileHeader({
960
1026
  file,
961
- commentStyle: 'xml',
1027
+ commentStyle: xml,
962
1028
  formatting: getFormattingCloneWithoutPrefix(formatting),
963
1029
  options,
964
1030
  });
965
- return androidIntegers({ dictionary, options, header });
1031
+ return androidIntegersTemplate({ dictionary, options, header });
966
1032
  },
967
1033
 
968
1034
  /**
@@ -973,7 +1039,7 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
973
1039
  * instead of this format:
974
1040
  *
975
1041
  * ```javascript
976
- * format: 'android/resources',
1042
+ * format: formats.androidResources,
977
1043
  * filter: {
978
1044
  * attributes: { category: 'content' }
979
1045
  * }
@@ -990,15 +1056,15 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
990
1056
  * <string name="content_icon_chevron_up">&#xE003;</string>
991
1057
  * ```
992
1058
  */
993
- 'android/strings': async function ({ dictionary, options, file }) {
1059
+ [androidStrings]: async function ({ dictionary, options, file }) {
994
1060
  const { formatting } = options;
995
1061
  const header = await fileHeader({
996
1062
  file,
997
- commentStyle: 'xml',
1063
+ commentStyle: xml,
998
1064
  formatting: getFormattingCloneWithoutPrefix(formatting),
999
1065
  options,
1000
1066
  });
1001
- return androidStrings({ dictionary, options, header });
1067
+ return androidStringsTemplate({ dictionary, options, header });
1002
1068
  },
1003
1069
 
1004
1070
  // Compose templates
@@ -1025,7 +1091,7 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
1025
1091
  * }
1026
1092
  * ```
1027
1093
  */
1028
- 'compose/object': async function ({ dictionary, options, file }) {
1094
+ [composeObject]: async function ({ dictionary, options, file }) {
1029
1095
  const { allTokens, tokens, unfilteredTokens } = dictionary;
1030
1096
  const { outputReferences, formatting, usesDtcg } = options;
1031
1097
  const formatProperty = createPropertyFormatter({
@@ -1033,7 +1099,7 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
1033
1099
  dictionary,
1034
1100
  formatting: {
1035
1101
  suffix: '',
1036
- commentStyle: 'none', // We will add the comment in the format template
1102
+ commentStyle: /** @type {'short' | 'long' | 'none'} */ (none), // We will add the comment in the format template
1037
1103
  ...formatting,
1038
1104
  },
1039
1105
  usesDtcg,
@@ -1049,11 +1115,11 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
1049
1115
  options = setComposeObjectProperties(options);
1050
1116
  const header = await fileHeader({
1051
1117
  file,
1052
- commentStyle: 'short',
1118
+ commentStyle: short,
1053
1119
  formatting: getFormattingCloneWithoutPrefix(formatting),
1054
1120
  options,
1055
1121
  });
1056
- return composeObject({ allTokens: sortedTokens, options, formatProperty, header });
1122
+ return composeObjectTemplate({ allTokens: sortedTokens, options, formatProperty, header });
1057
1123
  },
1058
1124
 
1059
1125
  // iOS templates
@@ -1072,11 +1138,11 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
1072
1138
  * #define SizeFontTiny 176.00f
1073
1139
  * ```
1074
1140
  */
1075
- 'ios/macros': async function ({ dictionary, options, file }) {
1141
+ [iosMacros]: async function ({ dictionary, options, file }) {
1076
1142
  const { formatting } = options;
1077
1143
  const header = await fileHeader({
1078
1144
  file,
1079
- commentStyle: 'short',
1145
+ commentStyle: short,
1080
1146
  formatting: getFormattingCloneWithoutPrefix(formatting),
1081
1147
  options,
1082
1148
  });
@@ -1090,11 +1156,11 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
1090
1156
  * @kind member
1091
1157
  * @todo Fix this template and add example and usage
1092
1158
  */
1093
- 'ios/plist': async function ({ dictionary, options, file }) {
1159
+ [iosPlist]: async function ({ dictionary, options, file }) {
1094
1160
  const { formatting } = options;
1095
1161
  const header = await fileHeader({
1096
1162
  file,
1097
- commentStyle: 'xml',
1163
+ commentStyle: xml,
1098
1164
  formatting: getFormattingCloneWithoutPrefix(formatting),
1099
1165
  options,
1100
1166
  });
@@ -1108,15 +1174,15 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
1108
1174
  * @kind member
1109
1175
  * @todo Add example and usage
1110
1176
  */
1111
- 'ios/singleton.m': async function ({ dictionary, options, file }) {
1177
+ [iosSingletonM]: async function ({ dictionary, options, file }) {
1112
1178
  const { formatting } = options;
1113
1179
  const header = await fileHeader({
1114
1180
  file,
1115
- commentStyle: 'short',
1181
+ commentStyle: short,
1116
1182
  formatting: getFormattingCloneWithoutPrefix(formatting),
1117
1183
  options,
1118
1184
  });
1119
- return iosSingletonM({ dictionary, options, file, header });
1185
+ return iosSingletonMTemplate({ dictionary, options, file, header });
1120
1186
  },
1121
1187
 
1122
1188
  /**
@@ -1126,15 +1192,15 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
1126
1192
  * @kind member
1127
1193
  * @todo Add example and usage
1128
1194
  */
1129
- 'ios/singleton.h': async function ({ file, options }) {
1195
+ [iosSingletonH]: async function ({ file, options }) {
1130
1196
  const { formatting } = options;
1131
1197
  const header = await fileHeader({
1132
1198
  file,
1133
- commentStyle: 'short',
1199
+ commentStyle: short,
1134
1200
  formatting: getFormattingCloneWithoutPrefix(formatting),
1135
1201
  options,
1136
1202
  });
1137
- return iosSingletonH({ file, options, header });
1203
+ return iosSingletonHTemplate({ file, options, header });
1138
1204
  },
1139
1205
 
1140
1206
  /**
@@ -1144,15 +1210,15 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
1144
1210
  * @kind member
1145
1211
  * @todo Add example and usage
1146
1212
  */
1147
- 'ios/static.h': async function ({ dictionary, file, options }) {
1213
+ [iosStaticH]: async function ({ dictionary, file, options }) {
1148
1214
  const { formatting } = options;
1149
1215
  const header = await fileHeader({
1150
1216
  file,
1151
- commentStyle: 'short',
1217
+ commentStyle: short,
1152
1218
  formatting: getFormattingCloneWithoutPrefix(formatting),
1153
1219
  options,
1154
1220
  });
1155
- return iosStaticH({ dictionary, file, options, header });
1221
+ return iosStaticHTemplate({ dictionary, file, options, header });
1156
1222
  },
1157
1223
 
1158
1224
  /**
@@ -1162,15 +1228,15 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
1162
1228
  * @kind member
1163
1229
  * @todo Add example and usage
1164
1230
  */
1165
- 'ios/static.m': async function ({ dictionary, options, file }) {
1231
+ [iosStaticM]: async function ({ dictionary, options, file }) {
1166
1232
  const { formatting } = options;
1167
1233
  const header = await fileHeader({
1168
1234
  file,
1169
- commentStyle: 'short',
1235
+ commentStyle: short,
1170
1236
  formatting: getFormattingCloneWithoutPrefix(formatting),
1171
1237
  options,
1172
1238
  });
1173
- return iosStaticM({ dictionary, options, file, header });
1239
+ return iosStaticMTemplate({ dictionary, options, file, header });
1174
1240
  },
1175
1241
 
1176
1242
  /**
@@ -1180,15 +1246,15 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
1180
1246
  * @kind memberx
1181
1247
  * @todo Add example and usage
1182
1248
  */
1183
- 'ios/colors.h': async function ({ dictionary, options, file }) {
1249
+ [iosColorsH]: async function ({ dictionary, options, file }) {
1184
1250
  const { formatting } = options;
1185
1251
  const header = await fileHeader({
1186
1252
  file,
1187
- commentStyle: 'short',
1253
+ commentStyle: short,
1188
1254
  formatting: getFormattingCloneWithoutPrefix(formatting),
1189
1255
  options,
1190
1256
  });
1191
- return iosColorsH({ dictionary, file, options, header });
1257
+ return iosColorsHTemplate({ dictionary, file, options, header });
1192
1258
  },
1193
1259
 
1194
1260
  /**
@@ -1198,15 +1264,15 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
1198
1264
  * @kind member
1199
1265
  * @todo Add example and usage
1200
1266
  */
1201
- 'ios/colors.m': async function ({ dictionary, options, file }) {
1267
+ [iosColorsM]: async function ({ dictionary, options, file }) {
1202
1268
  const { formatting } = options;
1203
1269
  const header = await fileHeader({
1204
1270
  file,
1205
- commentStyle: 'short',
1271
+ commentStyle: short,
1206
1272
  formatting: getFormattingCloneWithoutPrefix(formatting),
1207
1273
  options,
1208
1274
  });
1209
- return iosColorsM({ dictionary, options, file, header });
1275
+ return iosColorsMTemplate({ dictionary, options, file, header });
1210
1276
  },
1211
1277
 
1212
1278
  /**
@@ -1216,15 +1282,15 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
1216
1282
  * @kind member
1217
1283
  * @todo Add example and usage
1218
1284
  */
1219
- 'ios/strings.h': async function ({ dictionary, file, options }) {
1285
+ [iosStringsH]: async function ({ dictionary, file, options }) {
1220
1286
  const { formatting } = options;
1221
1287
  const header = await fileHeader({
1222
1288
  file,
1223
- commentStyle: 'short',
1289
+ commentStyle: short,
1224
1290
  formatting: getFormattingCloneWithoutPrefix(formatting),
1225
1291
  options,
1226
1292
  });
1227
- return iosStringsH({ dictionary, file, options, header });
1293
+ return iosStringsHTemplate({ dictionary, file, options, header });
1228
1294
  },
1229
1295
 
1230
1296
  /**
@@ -1234,15 +1300,15 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
1234
1300
  * @kind member
1235
1301
  * @todo Add example and usage
1236
1302
  */
1237
- 'ios/strings.m': async function ({ dictionary, options, file }) {
1303
+ [iosStringsM]: async function ({ dictionary, options, file }) {
1238
1304
  const { formatting } = options;
1239
1305
  const header = await fileHeader({
1240
1306
  file,
1241
- commentStyle: 'short',
1307
+ commentStyle: short,
1242
1308
  formatting: getFormattingCloneWithoutPrefix(formatting),
1243
1309
  options,
1244
1310
  });
1245
- return iosStringsM({ dictionary, options, file, header });
1311
+ return iosStringsMTemplate({ dictionary, options, file, header });
1246
1312
  },
1247
1313
 
1248
1314
  /**
@@ -1264,7 +1330,7 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
1264
1330
  * }
1265
1331
  * ```
1266
1332
  */
1267
- 'ios-swift/class.swift': async function ({ dictionary, options, file, platform }) {
1333
+ [iosSwiftClassSwift]: async function ({ dictionary, options, file, platform }) {
1268
1334
  const { allTokens, tokens, unfilteredTokens } = dictionary;
1269
1335
  const { outputReferences, formatting, usesDtcg } = options;
1270
1336
  options = setSwiftFileProperties(options, 'class', platform.transformGroup);
@@ -1286,11 +1352,11 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
1286
1352
  }
1287
1353
  const header = await fileHeader({
1288
1354
  file,
1289
- commentStyle: 'short',
1355
+ commentStyle: short,
1290
1356
  formatting: getFormattingCloneWithoutPrefix(formatting),
1291
1357
  options,
1292
1358
  });
1293
- return iosSwiftAny({ allTokens: sortedTokens, file, options, formatProperty, header });
1359
+ return iosSwiftAnyTemplate({ allTokens: sortedTokens, file, options, formatProperty, header });
1294
1360
  },
1295
1361
 
1296
1362
  /**
@@ -1312,7 +1378,7 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
1312
1378
  * }
1313
1379
  * ```
1314
1380
  */
1315
- 'ios-swift/enum.swift': async function ({ dictionary, options, file, platform }) {
1381
+ [iosSwiftEnumSwift]: async function ({ dictionary, options, file, platform }) {
1316
1382
  const { allTokens, tokens, unfilteredTokens } = dictionary;
1317
1383
  const { outputReferences, formatting, usesDtcg } = options;
1318
1384
  options = setSwiftFileProperties(options, 'enum', platform.transformGroup);
@@ -1334,11 +1400,11 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
1334
1400
  }
1335
1401
  const header = await fileHeader({
1336
1402
  file,
1337
- commentStyle: 'short',
1403
+ commentStyle: short,
1338
1404
  formatting: getFormattingCloneWithoutPrefix(formatting),
1339
1405
  options,
1340
1406
  });
1341
- return iosSwiftAny({ allTokens: sortedTokens, file, options, formatProperty, header });
1407
+ return iosSwiftAnyTemplate({ allTokens: sortedTokens, file, options, formatProperty, header });
1342
1408
  },
1343
1409
 
1344
1410
  /**
@@ -1371,7 +1437,7 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
1371
1437
  * }
1372
1438
  * ```
1373
1439
  */
1374
- 'ios-swift/any.swift': async function ({ dictionary, options, file, platform }) {
1440
+ [iosSwiftAnySwift]: async function ({ dictionary, options, file, platform }) {
1375
1441
  const { allTokens, tokens, unfilteredTokens } = dictionary;
1376
1442
  const { outputReferences, formatting, usesDtcg } = options;
1377
1443
  options = setSwiftFileProperties(options, options.objectType, platform.transformGroup);
@@ -1393,11 +1459,11 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
1393
1459
  }
1394
1460
  const header = await fileHeader({
1395
1461
  file,
1396
- commentStyle: 'short',
1462
+ commentStyle: short,
1397
1463
  formatting: getFormattingCloneWithoutPrefix(formatting),
1398
1464
  options,
1399
1465
  });
1400
- return iosSwiftAny({ allTokens: sortedTokens, file, options, formatProperty, header });
1466
+ return iosSwiftAnyTemplate({ allTokens: sortedTokens, file, options, formatProperty, header });
1401
1467
  },
1402
1468
 
1403
1469
  // Css templates
@@ -1409,7 +1475,7 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
1409
1475
  * @kind member
1410
1476
  * @todo Add example and usage
1411
1477
  */
1412
- 'css/fonts.css': ({ dictionary }) => cssFonts(dictionary.tokens),
1478
+ [cssFonts]: ({ dictionary }) => cssFontsTemplate(dictionary.tokens),
1413
1479
 
1414
1480
  // Web templates
1415
1481
 
@@ -1431,7 +1497,7 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
1431
1497
  * }
1432
1498
  * ```
1433
1499
  */
1434
- json: function ({ dictionary, options }) {
1500
+ [json]: function ({ dictionary, options }) {
1435
1501
  let { tokens } = dictionary;
1436
1502
  tokens = stripMetaProps(
1437
1503
  tokens,
@@ -1458,7 +1524,7 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
1458
1524
  * }
1459
1525
  * ```
1460
1526
  */
1461
- 'json/asset': function ({ dictionary }) {
1527
+ [jsonAsset]: function ({ dictionary }) {
1462
1528
  return JSON.stringify({ asset: dictionary.tokens.asset }, null, 2);
1463
1529
  },
1464
1530
 
@@ -1477,7 +1543,7 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
1477
1543
  * }
1478
1544
  * ```
1479
1545
  */
1480
- 'json/nested': function ({ dictionary, options }) {
1546
+ [jsonNested]: function ({ dictionary, options }) {
1481
1547
  return JSON.stringify(minifyDictionary(dictionary.tokens, options.usesDtcg), null, 2) + '\n';
1482
1548
  },
1483
1549
 
@@ -1493,7 +1559,7 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
1493
1559
  * }
1494
1560
  * ```
1495
1561
  */
1496
- 'json/flat': function ({ dictionary, options }) {
1562
+ [jsonFlat]: function ({ dictionary, options }) {
1497
1563
  return (
1498
1564
  '{\n' +
1499
1565
  dictionary.allTokens
@@ -1526,7 +1592,7 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
1526
1592
  * }
1527
1593
  * ```
1528
1594
  */
1529
- 'sketch/palette': function ({ dictionary, options }) {
1595
+ [sketchPalette]: function ({ dictionary, options }) {
1530
1596
  const to_ret = {
1531
1597
  compatibleVersion: '1.0',
1532
1598
  pluginVersion: '1.1',
@@ -1563,7 +1629,7 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
1563
1629
  * }
1564
1630
  * ```
1565
1631
  */
1566
- 'sketch/palette/v2': function ({ dictionary, options }) {
1632
+ [sketchPaletteV2]: function ({ dictionary, options }) {
1567
1633
  const to_ret = {
1568
1634
  compatibleVersion: '2.0',
1569
1635
  pluginVersion: '2.2',
@@ -1589,6 +1655,7 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
1589
1655
  * @typedef {Object} flutterClassOpts
1590
1656
  * @property {boolean} [flutterClassOpts.showFileHeader=true] - Whether or not to include a comment that has the build date
1591
1657
  * @property {OutputReferences} [flutterClassOpts.outputReferences=false] - Whether or not to keep [references](/#/formats?id=references-in-output-files) (a -> b -> c) in the output.
1658
+ * @property {String} [flutterClassOpts.className] - The name of the generated Dart Class
1592
1659
  * @param {FormatArgs & { options?: flutterClassOpts }} options
1593
1660
  * @example
1594
1661
  * ```dart
@@ -1602,7 +1669,7 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
1602
1669
  * static const contentFontFamily1 = "NewJune";
1603
1670
  * ```
1604
1671
  */
1605
- 'flutter/class.dart': async function ({ dictionary, options, file }) {
1672
+ [flutterClassDart]: async function ({ dictionary, options, file }) {
1606
1673
  const { allTokens, tokens, unfilteredTokens } = dictionary;
1607
1674
  const { outputReferences, formatting, usesDtcg } = options;
1608
1675
  const formatProperty = createPropertyFormatter({
@@ -1620,18 +1687,24 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
1620
1687
  }
1621
1688
  const header = await fileHeader({
1622
1689
  file,
1623
- commentStyle: 'short',
1690
+ commentStyle: short,
1624
1691
  formatting: getFormattingCloneWithoutPrefix(formatting),
1625
1692
  options,
1626
1693
  });
1627
- return flutterClassDart({ allTokens: sortedTokens, file, options, formatProperty, header });
1694
+ return flutterClassDartTemplate({
1695
+ allTokens: sortedTokens,
1696
+ file,
1697
+ options,
1698
+ formatProperty,
1699
+ header,
1700
+ });
1628
1701
  },
1629
1702
  };
1630
1703
 
1631
1704
  // Mark which formats are nested
1632
- formats['json/nested'].nested = true;
1633
- formats['javascript/module'].nested = true;
1634
- formats['javascript/object'].nested = true;
1635
- formats['javascript/esm'].nested = true;
1705
+ formats[jsonNested].nested = true;
1706
+ formats[javascriptModule].nested = true;
1707
+ formats[javascriptObject].nested = true;
1708
+ formats[javascriptEsm].nested = true;
1636
1709
 
1637
1710
  export default formats;