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.
- package/README.md +8 -5
- package/bin/style-dictionary.d.ts +8 -0
- package/bin/style-dictionary.js +38 -10
- package/examples/advanced/assets-base64-embed/package.json +1 -1
- package/examples/advanced/create-react-app/package.json +1 -1
- package/examples/advanced/create-react-native-app/package.json +1 -1
- package/examples/advanced/create-react-native-app/src/App.js +0 -1
- package/examples/advanced/custom-parser/package.json +1 -1
- package/examples/advanced/custom-parser/sd.config.js +3 -2
- package/examples/advanced/custom-transforms/README.md +1 -1
- package/examples/advanced/custom-transforms/build.js +11 -8
- package/examples/advanced/custom-transforms/package.json +1 -1
- package/examples/advanced/font-face-rules/package.json +1 -1
- package/examples/advanced/font-face-rules/sd.config.js +2 -1
- package/examples/advanced/format-helpers/package.json +1 -1
- package/examples/advanced/format-helpers/sd.config.js +3 -2
- package/examples/advanced/matching-build-files/config.js +15 -10
- package/examples/advanced/matching-build-files/package.json +1 -1
- package/examples/advanced/multi-brand-multi-platform/build.js +10 -7
- package/examples/advanced/multi-brand-multi-platform/package.json +1 -1
- package/examples/advanced/node-modules-as-config-and-properties/config.js +17 -12
- package/examples/advanced/node-modules-as-config-and-properties/package.json +1 -1
- package/examples/advanced/npm-module/package.json +1 -1
- package/examples/advanced/referencing_aliasing/package.json +1 -1
- package/examples/advanced/s3/package.json +1 -1
- package/examples/advanced/tailwind-preset/README.md +94 -0
- package/examples/advanced/tailwind-preset/config/filter.js +3 -0
- package/examples/advanced/tailwind-preset/config/filter.test.js +12 -0
- package/examples/advanced/tailwind-preset/config/format.js +60 -0
- package/examples/advanced/tailwind-preset/config/transform.js +21 -0
- package/examples/advanced/tailwind-preset/config/transform.test.js +37 -0
- package/examples/advanced/tailwind-preset/config.js +55 -0
- package/examples/advanced/tailwind-preset/demo/index.html +27 -0
- package/examples/advanced/tailwind-preset/demo/input.css +3 -0
- package/examples/advanced/tailwind-preset/package.json +18 -0
- package/examples/advanced/tailwind-preset/tailwind.config.js +11 -0
- package/examples/advanced/tailwind-preset/tokens/tokens.json +49 -0
- package/examples/advanced/tokens-deprecation/build.js +2 -1
- package/examples/advanced/tokens-deprecation/package.json +1 -1
- package/examples/advanced/transitive-transforms/package.json +1 -1
- package/examples/advanced/transitive-transforms/sd.config.js +12 -9
- package/examples/advanced/variables-in-outputs/package.json +1 -1
- package/examples/advanced/variables-in-outputs/sd.config.js +10 -5
- package/examples/advanced/yaml-tokens/package.json +1 -1
- package/examples/advanced/yaml-tokens/sd.config.js +3 -2
- package/lib/Register.d.ts +2 -2
- package/lib/Register.js +6 -3
- package/lib/StyleDictionary.d.ts +20 -18
- package/lib/StyleDictionary.js +89 -71
- package/lib/cleanActions.d.ts +1 -1
- package/lib/cleanDir.d.ts +1 -1
- package/lib/cleanDir.js +2 -1
- package/lib/cleanDirs.d.ts +1 -1
- package/lib/cleanFile.d.ts +1 -6
- package/lib/cleanFile.js +5 -2
- package/lib/cleanFiles.d.ts +1 -1
- package/lib/common/actions.d.ts +20 -1
- package/lib/common/actions.js +8 -4
- package/lib/common/filters.d.ts +7 -1
- package/lib/common/formatHelpers/createPropertyFormatter.d.ts +3 -1
- package/lib/common/formatHelpers/createPropertyFormatter.js +26 -19
- package/lib/common/formatHelpers/fileHeader.d.ts +1 -1
- package/lib/common/formatHelpers/fileHeader.js +4 -2
- package/lib/common/formatHelpers/formattedVariables.d.ts +3 -1
- package/lib/common/formatHelpers/formattedVariables.js +3 -1
- package/lib/common/formatHelpers/getTypeScriptType.d.ts +2 -2
- package/lib/common/formatHelpers/minifyDictionary.d.ts +1 -1
- package/lib/common/formatHelpers/setComposeObjectProperties.d.ts +1 -1
- package/lib/common/formatHelpers/setSwiftFileProperties.d.ts +1 -1
- package/lib/common/formatHelpers/sortByReference.d.ts +1 -1
- package/lib/common/formats.js +235 -162
- package/lib/common/templates/compose/object.kt.template.js +8 -4
- package/lib/common/templates/css/fonts.css.template.js +2 -2
- package/lib/common/templates/scss/map-flat.template.js +4 -3
- package/lib/common/transformGroups.d.ts +209 -1
- package/lib/common/transformGroups.js +139 -93
- package/lib/common/transforms.d.ts +961 -1
- package/lib/common/transforms.js +113 -111
- package/lib/enums/actions.d.ts +4 -0
- package/lib/enums/actions.js +4 -0
- package/lib/enums/commentPositions.d.ts +4 -0
- package/lib/enums/commentPositions.js +4 -0
- package/lib/enums/commentStyles.d.ts +5 -0
- package/lib/enums/commentStyles.js +5 -0
- package/lib/enums/fileHeaderCommentStyles.d.ts +5 -0
- package/lib/enums/fileHeaderCommentStyles.js +5 -0
- package/lib/enums/formats.d.ts +46 -0
- package/lib/enums/formats.js +50 -0
- package/lib/enums/index.d.ts +12 -0
- package/lib/enums/index.js +12 -0
- package/lib/enums/logBrokenReferenceLevels.d.ts +5 -0
- package/lib/enums/logBrokenReferenceLevels.js +4 -0
- package/lib/enums/logVerbosityLevels.d.ts +6 -0
- package/lib/enums/logVerbosityLevels.js +5 -0
- package/lib/enums/logWarningLevels.d.ts +5 -0
- package/lib/enums/logWarningLevels.js +5 -0
- package/lib/enums/propertyFormatNames.d.ts +6 -0
- package/lib/enums/propertyFormatNames.js +6 -0
- package/lib/enums/transformGroups.d.ts +17 -0
- package/lib/enums/transformGroups.js +17 -0
- package/lib/enums/transformTypes.d.ts +5 -0
- package/lib/enums/transformTypes.js +5 -0
- package/lib/enums/transforms.d.ts +57 -0
- package/lib/enums/transforms.js +57 -0
- package/lib/filterTokens.d.ts +1 -1
- package/lib/filterTokens.js +5 -0
- package/lib/fs.d.ts +1 -1
- package/lib/fs.js +1 -1
- package/lib/performActions.d.ts +1 -1
- package/lib/resolve.d.ts +1 -1
- package/lib/resolve.js +4 -3
- package/lib/transform/config.js +3 -2
- package/lib/transform/object.d.ts +1 -1
- package/lib/transform/token.d.ts +1 -9
- package/lib/transform/token.js +10 -3
- package/lib/utils/cleanActions.d.ts +1 -1
- package/lib/utils/combineJSON.d.ts +1 -1
- package/lib/utils/combineJSON.js +12 -32
- package/lib/utils/convertToBase64.d.ts +1 -1
- package/lib/utils/convertToDTCG.d.ts +3 -3
- package/lib/utils/convertTokenData.d.ts +30 -0
- package/lib/utils/convertTokenData.js +123 -0
- package/lib/utils/deepExtend.d.ts +1 -1
- package/lib/utils/deepmerge.d.ts +1 -1
- package/lib/utils/expandObjectTokens.d.ts +2 -2
- package/lib/utils/expandObjectTokens.js +1 -1
- package/lib/utils/flattenTokens.d.ts +9 -5
- package/lib/utils/flattenTokens.js +28 -16
- package/lib/utils/index.d.ts +2 -1
- package/lib/utils/index.js +3 -0
- package/lib/utils/loadFile.d.ts +13 -0
- package/lib/utils/loadFile.js +89 -0
- package/lib/utils/preprocess.d.ts +1 -1
- package/lib/utils/references/defaults.d.ts +5 -1
- package/lib/utils/references/getName.d.ts +1 -1
- package/lib/utils/references/getReferences.d.ts +1 -1
- package/lib/utils/references/outputReferencesTransformed.js +1 -1
- package/lib/utils/references/resolveReferences.d.ts +2 -2
- package/lib/utils/references/usesReferences.d.ts +1 -1
- package/package.json +27 -16
- package/types/Config.d.ts +9 -3
- package/types/DesignToken.d.ts +6 -0
- package/types/File.d.ts +6 -2
- package/types/Format.d.ts +4 -1
- package/types/Transform.d.ts +4 -3
package/lib/common/formats.js
CHANGED
|
@@ -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
|
|
34
|
-
import
|
|
35
|
-
import
|
|
36
|
-
import
|
|
37
|
-
import
|
|
38
|
-
import
|
|
39
|
-
import
|
|
40
|
-
import
|
|
41
|
-
import
|
|
42
|
-
import
|
|
43
|
-
import
|
|
44
|
-
import
|
|
45
|
-
import
|
|
46
|
-
import
|
|
47
|
-
import
|
|
48
|
-
import
|
|
49
|
-
import
|
|
50
|
-
import
|
|
51
|
-
import
|
|
52
|
-
import
|
|
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
|
-
|
|
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:
|
|
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
|
-
|
|
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:
|
|
238
|
+
commentStyle: long,
|
|
183
239
|
formatting: getFormattingCloneWithoutPrefix(formatting),
|
|
184
240
|
options,
|
|
185
241
|
});
|
|
186
|
-
return
|
|
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
|
-
|
|
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:
|
|
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:
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
309
|
+
commentStyle: short,
|
|
254
310
|
formatting: getFormattingCloneWithoutPrefix(formatting),
|
|
255
311
|
options,
|
|
256
312
|
});
|
|
257
313
|
return (
|
|
258
314
|
header +
|
|
259
315
|
formattedVariables({
|
|
260
|
-
format:
|
|
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
|
-
|
|
338
|
+
[scssIcons]: async function ({ dictionary, options, file, platform }) {
|
|
283
339
|
const { formatting } = options;
|
|
284
340
|
const header = await fileHeader({
|
|
285
341
|
file,
|
|
286
|
-
commentStyle:
|
|
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
|
-
|
|
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:
|
|
364
|
+
commentStyle: short,
|
|
309
365
|
formatting: getFormattingCloneWithoutPrefix(formatting),
|
|
310
366
|
options,
|
|
311
367
|
});
|
|
312
368
|
return (
|
|
313
369
|
header +
|
|
314
|
-
formattedVariables({
|
|
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
|
-
|
|
392
|
+
[lessIcons]: async function ({ dictionary, options, file, platform }) {
|
|
331
393
|
const { formatting } = options;
|
|
332
394
|
const header = await fileHeader({
|
|
333
395
|
file,
|
|
334
|
-
commentStyle:
|
|
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
|
-
|
|
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:
|
|
419
|
+
commentStyle: short,
|
|
358
420
|
formatting: getFormattingCloneWithoutPrefix(formatting),
|
|
359
421
|
options,
|
|
360
422
|
});
|
|
361
423
|
return (
|
|
362
424
|
header +
|
|
363
|
-
formattedVariables({
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
.
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
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
|
-
|
|
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
|
-
|
|
881
|
+
[androidResources]: async function ({ dictionary, file, options }) {
|
|
816
882
|
const { formatting } = options;
|
|
817
883
|
const header = await fileHeader({
|
|
818
884
|
file,
|
|
819
|
-
commentStyle:
|
|
885
|
+
commentStyle: xml,
|
|
820
886
|
formatting: getFormattingCloneWithoutPrefix(formatting),
|
|
821
887
|
options,
|
|
822
888
|
});
|
|
823
|
-
return
|
|
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:
|
|
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
|
-
|
|
916
|
+
[androidColors]: async function ({ dictionary, options, file }) {
|
|
851
917
|
const { formatting } = options;
|
|
852
918
|
const header = await fileHeader({
|
|
853
919
|
file,
|
|
854
|
-
commentStyle:
|
|
920
|
+
commentStyle: xml,
|
|
855
921
|
formatting: getFormattingCloneWithoutPrefix(formatting),
|
|
856
922
|
options,
|
|
857
923
|
});
|
|
858
|
-
return
|
|
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:
|
|
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
|
-
|
|
951
|
+
[androidDimens]: async function ({ dictionary, options, file }) {
|
|
886
952
|
const { formatting } = options;
|
|
887
953
|
const header = await fileHeader({
|
|
888
954
|
file,
|
|
889
|
-
commentStyle:
|
|
955
|
+
commentStyle: xml,
|
|
890
956
|
formatting: getFormattingCloneWithoutPrefix(formatting),
|
|
891
957
|
options,
|
|
892
958
|
});
|
|
893
|
-
return
|
|
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:
|
|
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
|
-
|
|
986
|
+
[androidFontDimens]: async function ({ dictionary, options, file }) {
|
|
921
987
|
const { formatting } = options;
|
|
922
988
|
const header = await fileHeader({
|
|
923
989
|
file,
|
|
924
|
-
commentStyle:
|
|
990
|
+
commentStyle: xml,
|
|
925
991
|
formatting: getFormattingCloneWithoutPrefix(formatting),
|
|
926
992
|
options,
|
|
927
993
|
});
|
|
928
|
-
return
|
|
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:
|
|
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
|
-
|
|
1023
|
+
[androidIntegers]: async function ({ dictionary, options, file }) {
|
|
958
1024
|
const { formatting } = options;
|
|
959
1025
|
const header = await fileHeader({
|
|
960
1026
|
file,
|
|
961
|
-
commentStyle:
|
|
1027
|
+
commentStyle: xml,
|
|
962
1028
|
formatting: getFormattingCloneWithoutPrefix(formatting),
|
|
963
1029
|
options,
|
|
964
1030
|
});
|
|
965
|
-
return
|
|
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:
|
|
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"></string>
|
|
991
1057
|
* ```
|
|
992
1058
|
*/
|
|
993
|
-
|
|
1059
|
+
[androidStrings]: async function ({ dictionary, options, file }) {
|
|
994
1060
|
const { formatting } = options;
|
|
995
1061
|
const header = await fileHeader({
|
|
996
1062
|
file,
|
|
997
|
-
commentStyle:
|
|
1063
|
+
commentStyle: xml,
|
|
998
1064
|
formatting: getFormattingCloneWithoutPrefix(formatting),
|
|
999
1065
|
options,
|
|
1000
1066
|
});
|
|
1001
|
-
return
|
|
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
|
-
|
|
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:
|
|
1118
|
+
commentStyle: short,
|
|
1053
1119
|
formatting: getFormattingCloneWithoutPrefix(formatting),
|
|
1054
1120
|
options,
|
|
1055
1121
|
});
|
|
1056
|
-
return
|
|
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
|
-
|
|
1141
|
+
[iosMacros]: async function ({ dictionary, options, file }) {
|
|
1076
1142
|
const { formatting } = options;
|
|
1077
1143
|
const header = await fileHeader({
|
|
1078
1144
|
file,
|
|
1079
|
-
commentStyle:
|
|
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
|
-
|
|
1159
|
+
[iosPlist]: async function ({ dictionary, options, file }) {
|
|
1094
1160
|
const { formatting } = options;
|
|
1095
1161
|
const header = await fileHeader({
|
|
1096
1162
|
file,
|
|
1097
|
-
commentStyle:
|
|
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
|
-
|
|
1177
|
+
[iosSingletonM]: async function ({ dictionary, options, file }) {
|
|
1112
1178
|
const { formatting } = options;
|
|
1113
1179
|
const header = await fileHeader({
|
|
1114
1180
|
file,
|
|
1115
|
-
commentStyle:
|
|
1181
|
+
commentStyle: short,
|
|
1116
1182
|
formatting: getFormattingCloneWithoutPrefix(formatting),
|
|
1117
1183
|
options,
|
|
1118
1184
|
});
|
|
1119
|
-
return
|
|
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
|
-
|
|
1195
|
+
[iosSingletonH]: async function ({ file, options }) {
|
|
1130
1196
|
const { formatting } = options;
|
|
1131
1197
|
const header = await fileHeader({
|
|
1132
1198
|
file,
|
|
1133
|
-
commentStyle:
|
|
1199
|
+
commentStyle: short,
|
|
1134
1200
|
formatting: getFormattingCloneWithoutPrefix(formatting),
|
|
1135
1201
|
options,
|
|
1136
1202
|
});
|
|
1137
|
-
return
|
|
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
|
-
|
|
1213
|
+
[iosStaticH]: async function ({ dictionary, file, options }) {
|
|
1148
1214
|
const { formatting } = options;
|
|
1149
1215
|
const header = await fileHeader({
|
|
1150
1216
|
file,
|
|
1151
|
-
commentStyle:
|
|
1217
|
+
commentStyle: short,
|
|
1152
1218
|
formatting: getFormattingCloneWithoutPrefix(formatting),
|
|
1153
1219
|
options,
|
|
1154
1220
|
});
|
|
1155
|
-
return
|
|
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
|
-
|
|
1231
|
+
[iosStaticM]: async function ({ dictionary, options, file }) {
|
|
1166
1232
|
const { formatting } = options;
|
|
1167
1233
|
const header = await fileHeader({
|
|
1168
1234
|
file,
|
|
1169
|
-
commentStyle:
|
|
1235
|
+
commentStyle: short,
|
|
1170
1236
|
formatting: getFormattingCloneWithoutPrefix(formatting),
|
|
1171
1237
|
options,
|
|
1172
1238
|
});
|
|
1173
|
-
return
|
|
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
|
-
|
|
1249
|
+
[iosColorsH]: async function ({ dictionary, options, file }) {
|
|
1184
1250
|
const { formatting } = options;
|
|
1185
1251
|
const header = await fileHeader({
|
|
1186
1252
|
file,
|
|
1187
|
-
commentStyle:
|
|
1253
|
+
commentStyle: short,
|
|
1188
1254
|
formatting: getFormattingCloneWithoutPrefix(formatting),
|
|
1189
1255
|
options,
|
|
1190
1256
|
});
|
|
1191
|
-
return
|
|
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
|
-
|
|
1267
|
+
[iosColorsM]: async function ({ dictionary, options, file }) {
|
|
1202
1268
|
const { formatting } = options;
|
|
1203
1269
|
const header = await fileHeader({
|
|
1204
1270
|
file,
|
|
1205
|
-
commentStyle:
|
|
1271
|
+
commentStyle: short,
|
|
1206
1272
|
formatting: getFormattingCloneWithoutPrefix(formatting),
|
|
1207
1273
|
options,
|
|
1208
1274
|
});
|
|
1209
|
-
return
|
|
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
|
-
|
|
1285
|
+
[iosStringsH]: async function ({ dictionary, file, options }) {
|
|
1220
1286
|
const { formatting } = options;
|
|
1221
1287
|
const header = await fileHeader({
|
|
1222
1288
|
file,
|
|
1223
|
-
commentStyle:
|
|
1289
|
+
commentStyle: short,
|
|
1224
1290
|
formatting: getFormattingCloneWithoutPrefix(formatting),
|
|
1225
1291
|
options,
|
|
1226
1292
|
});
|
|
1227
|
-
return
|
|
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
|
-
|
|
1303
|
+
[iosStringsM]: async function ({ dictionary, options, file }) {
|
|
1238
1304
|
const { formatting } = options;
|
|
1239
1305
|
const header = await fileHeader({
|
|
1240
1306
|
file,
|
|
1241
|
-
commentStyle:
|
|
1307
|
+
commentStyle: short,
|
|
1242
1308
|
formatting: getFormattingCloneWithoutPrefix(formatting),
|
|
1243
1309
|
options,
|
|
1244
1310
|
});
|
|
1245
|
-
return
|
|
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
|
-
|
|
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:
|
|
1355
|
+
commentStyle: short,
|
|
1290
1356
|
formatting: getFormattingCloneWithoutPrefix(formatting),
|
|
1291
1357
|
options,
|
|
1292
1358
|
});
|
|
1293
|
-
return
|
|
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
|
-
|
|
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:
|
|
1403
|
+
commentStyle: short,
|
|
1338
1404
|
formatting: getFormattingCloneWithoutPrefix(formatting),
|
|
1339
1405
|
options,
|
|
1340
1406
|
});
|
|
1341
|
-
return
|
|
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
|
-
|
|
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:
|
|
1462
|
+
commentStyle: short,
|
|
1397
1463
|
formatting: getFormattingCloneWithoutPrefix(formatting),
|
|
1398
1464
|
options,
|
|
1399
1465
|
});
|
|
1400
|
-
return
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
1690
|
+
commentStyle: short,
|
|
1624
1691
|
formatting: getFormattingCloneWithoutPrefix(formatting),
|
|
1625
1692
|
options,
|
|
1626
1693
|
});
|
|
1627
|
-
return
|
|
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[
|
|
1633
|
-
formats[
|
|
1634
|
-
formats[
|
|
1635
|
-
formats[
|
|
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;
|