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
@@ -0,0 +1,46 @@
1
+ export namespace formats {
2
+ let androidColors: "android/colors";
3
+ let androidDimens: "android/dimens";
4
+ let androidFontDimens: "android/fontDimens";
5
+ let androidIntegers: "android/integers";
6
+ let androidResources: "android/resources";
7
+ let androidStrings: "android/strings";
8
+ let composeObject: "compose/object";
9
+ let cssVariables: "css/variables";
10
+ let cssFonts: "css/fonts.css";
11
+ let flutterClassDart: "flutter/class.dart";
12
+ let iosColorsH: "ios/colors.h";
13
+ let iosColorsM: "ios/colors.m";
14
+ let iosMacros: "ios/macros";
15
+ let iosPlist: "ios/plist";
16
+ let iosSingletonH: "ios/singleton.h";
17
+ let iosSingletonM: "ios/singleton.m";
18
+ let iosStaticH: "ios/static.h";
19
+ let iosStaticM: "ios/static.m";
20
+ let iosStringsH: "ios/strings.h";
21
+ let iosStringsM: "ios/strings.m";
22
+ let iosSwiftAnySwift: "ios-swift/any.swift";
23
+ let iosSwiftClassSwift: "ios-swift/class.swift";
24
+ let iosSwiftEnumSwift: "ios-swift/enum.swift";
25
+ let javascriptEs6: "javascript/es6";
26
+ let javascriptEsm: "javascript/esm";
27
+ let javascriptModule: "javascript/module";
28
+ let javascriptModuleFlat: "javascript/module-flat";
29
+ let javascriptObject: "javascript/object";
30
+ let javascriptUmd: "javascript/umd";
31
+ let json: "json";
32
+ let jsonAsset: "json/asset";
33
+ let jsonNested: "json/nested";
34
+ let jsonFlat: "json/flat";
35
+ let sketchPalette: "sketchPalette";
36
+ let sketchPaletteV2: "sketch/palette/v2";
37
+ let lessIcons: "less/icons";
38
+ let lessVariables: "less/variables";
39
+ let scssIcons: "scss/icons";
40
+ let scssMapDeep: "scss/map-deep";
41
+ let scssMapFlat: "scss/map-flat";
42
+ let scssVariables: "scss/variables";
43
+ let stylusVariables: "stylus/variables";
44
+ let typescriptEs6Declarations: "typescript/es6-declarations";
45
+ let typescriptModuleDeclarations: "typescript/module-declarations";
46
+ }
@@ -0,0 +1,50 @@
1
+ export const formats = {
2
+ androidColors: /** @type {'android/colors'} */ ('android/colors'),
3
+ androidDimens: /** @type {'android/dimens'} */ ('android/dimens'),
4
+ androidFontDimens: /** @type {'android/fontDimens'} */ ('android/fontDimens'),
5
+ androidIntegers: /** @type {'android/integers'} */ ('android/integers'),
6
+ androidResources: /** @type {'android/resources'} */ ('android/resources'),
7
+ androidStrings: /** @type {'android/strings'} */ ('android/strings'),
8
+ composeObject: /** @type {'compose/object'} */ ('compose/object'),
9
+ cssVariables: /** @type {'css/variables'} */ ('css/variables'),
10
+ cssFonts: /** @type {'css/fonts.css'} */ ('css/fonts.css'),
11
+ flutterClassDart: /** @type {'flutter/class.dart'} */ ('flutter/class.dart'),
12
+ iosColorsH: /** @type {'ios/colors.h'} */ ('ios/colors.h'),
13
+ iosColorsM: /** @type {'ios/colors.m'} */ ('ios/colors.m'),
14
+ iosMacros: /** @type {'ios/macros'} */ ('ios/macros'),
15
+ iosPlist: /** @type {'ios/plist'} */ ('ios/plist'),
16
+ iosSingletonH: /** @type {'ios/singleton.h'} */ ('ios/singleton.h'),
17
+ iosSingletonM: /** @type {'ios/singleton.m'} */ ('ios/singleton.m'),
18
+ iosStaticH: /** @type {'ios/static.h'} */ ('ios/static.h'),
19
+ iosStaticM: /** @type {'ios/static.m'} */ ('ios/static.m'),
20
+ iosStringsH: /** @type {'ios/strings.h'} */ ('ios/strings.h'),
21
+ iosStringsM: /** @type {'ios/strings.m'} */ ('ios/strings.m'),
22
+ iosSwiftAnySwift: /** @type {'ios-swift/any.swift'} */ ('ios-swift/any.swift'),
23
+ iosSwiftClassSwift: /** @type {'ios-swift/class.swift'} */ ('ios-swift/class.swift'),
24
+ iosSwiftEnumSwift: /** @type {'ios-swift/enum.swift'} */ ('ios-swift/enum.swift'),
25
+ javascriptEs6: /** @type {'javascript/es6'} */ ('javascript/es6'),
26
+ javascriptEsm: /** @type {'javascript/esm'} */ ('javascript/esm'),
27
+ javascriptModule: /** @type {'javascript/module'} */ ('javascript/module'),
28
+ javascriptModuleFlat: /** @type {'javascript/module-flat'} */ ('javascript/module-flat'),
29
+ javascriptObject: /** @type {'javascript/object'} */ ('javascript/object'),
30
+ javascriptUmd: /** @type {'javascript/umd'} */ ('javascript/umd'),
31
+ json: /** @type {'json'} */ ('json'),
32
+ jsonAsset: /** @type {'json/asset'} */ ('json/asset'),
33
+ jsonNested: /** @type {'json/nested'} */ ('json/nested'),
34
+ jsonFlat: /** @type {'json/flat'} */ ('json/flat'),
35
+ sketchPalette: /** @type {'sketchPalette'} */ ('sketchPalette'),
36
+ sketchPaletteV2: /** @type {'sketch/palette/v2'} */ ('sketch/palette/v2'),
37
+ lessIcons: /** @type {'less/icons'} */ ('less/icons'),
38
+ lessVariables: /** @type {'less/variables'} */ ('less/variables'),
39
+ scssIcons: /** @type {'scss/icons'} */ ('scss/icons'),
40
+ scssMapDeep: /** @type {'scss/map-deep'} */ ('scss/map-deep'),
41
+ scssMapFlat: /** @type {'scss/map-flat'} */ ('scss/map-flat'),
42
+ scssVariables: /** @type {'scss/variables'} */ ('scss/variables'),
43
+ stylusVariables: /** @type {'stylus/variables'} */ ('stylus/variables'),
44
+ typescriptEs6Declarations: /** @type {'typescript/es6-declarations'} */ (
45
+ 'typescript/es6-declarations'
46
+ ),
47
+ typescriptModuleDeclarations: /** @type {'typescript/module-declarations'} */ (
48
+ 'typescript/module-declarations'
49
+ ),
50
+ };
@@ -0,0 +1,12 @@
1
+ export { actions } from "./actions.js";
2
+ export { logWarningLevels } from "./logWarningLevels.js";
3
+ export { logVerbosityLevels } from "./logVerbosityLevels.js";
4
+ export { logBrokenReferenceLevels } from "./logBrokenReferenceLevels.js";
5
+ export { commentStyles } from "./commentStyles.js";
6
+ export { commentPositions } from "./commentPositions.js";
7
+ export { fileHeaderCommentStyles } from "./fileHeaderCommentStyles.js";
8
+ export { formats } from "./formats.js";
9
+ export { transformGroups } from "./transformGroups.js";
10
+ export { transforms } from "./transforms.js";
11
+ export { transformTypes } from "./transformTypes.js";
12
+ export { propertyFormatNames } from "./propertyFormatNames.js";
@@ -0,0 +1,12 @@
1
+ export { actions } from './actions.js';
2
+ export { logWarningLevels } from './logWarningLevels.js';
3
+ export { logVerbosityLevels } from './logVerbosityLevels.js';
4
+ export { logBrokenReferenceLevels } from './logBrokenReferenceLevels.js';
5
+ export { commentStyles } from './commentStyles.js';
6
+ export { commentPositions } from './commentPositions.js';
7
+ export { fileHeaderCommentStyles } from './fileHeaderCommentStyles.js';
8
+ export { formats } from './formats.js';
9
+ export { transformGroups } from './transformGroups.js';
10
+ export { transforms } from './transforms.js';
11
+ export { transformTypes } from './transformTypes.js';
12
+ export { propertyFormatNames } from './propertyFormatNames.js';
@@ -0,0 +1,5 @@
1
+ export namespace logBrokenReferenceLevels {
2
+ let _throw: "throw";
3
+ export { _throw as throw };
4
+ export let console: "console";
5
+ }
@@ -0,0 +1,4 @@
1
+ export const logBrokenReferenceLevels = {
2
+ throw: /** @type {'throw'} */ ('throw'),
3
+ console: /** @type {'console'} */ ('console'),
4
+ };
@@ -0,0 +1,6 @@
1
+ export namespace logVerbosityLevels {
2
+ let _default: "default";
3
+ export { _default as default };
4
+ export let silent: "silent";
5
+ export let verbose: "verbose";
6
+ }
@@ -0,0 +1,5 @@
1
+ export const logVerbosityLevels = {
2
+ default: /** @type {'default'} */ ('default'),
3
+ silent: /** @type {'silent'} */ ('silent'),
4
+ verbose: /** @type {'verbose'} */ ('verbose'),
5
+ };
@@ -0,0 +1,5 @@
1
+ export namespace logWarningLevels {
2
+ let warn: "warn";
3
+ let error: "error";
4
+ let disabled: "disabled";
5
+ }
@@ -0,0 +1,5 @@
1
+ export const logWarningLevels = {
2
+ warn: /** @type {'warn'} */ ('warn'),
3
+ error: /** @type {'error'} */ ('error'),
4
+ disabled: /** @type {'disabled'} */ ('disabled'),
5
+ };
@@ -0,0 +1,6 @@
1
+ export namespace propertyFormatNames {
2
+ let css: "css";
3
+ let sass: "sass";
4
+ let less: "less";
5
+ let stylus: "stylus";
6
+ }
@@ -0,0 +1,6 @@
1
+ export const propertyFormatNames = {
2
+ css: /** @type {'css'} */ ('css'),
3
+ sass: /** @type {'sass'} */ ('sass'),
4
+ less: /** @type {'less'} */ ('less'),
5
+ stylus: /** @type {'stylus'} */ ('stylus'),
6
+ };
@@ -0,0 +1,17 @@
1
+ export namespace transformGroups {
2
+ let web: "web";
3
+ let js: "js";
4
+ let scss: "scss";
5
+ let css: "css";
6
+ let less: "less";
7
+ let html: "html";
8
+ let android: "android";
9
+ let compose: "compose";
10
+ let ios: "ios";
11
+ let iosSwift: "ios-swift";
12
+ let iosSwiftSeparate: "ios-swift-separate";
13
+ let assets: "assets";
14
+ let flutter: "flutter";
15
+ let flutterSeparate: "flutter-separate";
16
+ let reactNative: "react-native";
17
+ }
@@ -0,0 +1,17 @@
1
+ export const transformGroups = {
2
+ web: /** @type {'web'} */ ('web'),
3
+ js: /** @type {'js'} */ ('js'),
4
+ scss: /** @type {'scss'} */ ('scss'),
5
+ css: /** @type {'css'} */ ('css'),
6
+ less: /** @type {'less'} */ ('less'),
7
+ html: /** @type {'html'} */ ('html'),
8
+ android: /** @type {'android'} */ ('android'),
9
+ compose: /** @type {'compose'} */ ('compose'),
10
+ ios: /** @type {'ios'} */ ('ios'),
11
+ iosSwift: /** @type {'ios-swift'} */ ('ios-swift'),
12
+ iosSwiftSeparate: /** @type {'ios-swift-separate'} */ ('ios-swift-separate'),
13
+ assets: /** @type {'assets'} */ ('assets'),
14
+ flutter: /** @type {'flutter'} */ ('flutter'),
15
+ flutterSeparate: /** @type {'flutter-separate'} */ ('flutter-separate'),
16
+ reactNative: /** @type {'react-native'} */ ('react-native'),
17
+ };
@@ -0,0 +1,5 @@
1
+ export namespace transformTypes {
2
+ let attribute: "attribute";
3
+ let name: "name";
4
+ let value: "value";
5
+ }
@@ -0,0 +1,5 @@
1
+ export const transformTypes = {
2
+ attribute: /** @type {'attribute'} */ ('attribute'),
3
+ name: /** @type {'name'} */ ('name'),
4
+ value: /** @type {'value'} */ ('value'),
5
+ };
@@ -0,0 +1,57 @@
1
+ export namespace transforms {
2
+ let attributeCti: "attribute/cti";
3
+ let attributeColor: "attribute/color";
4
+ let nameHuman: "name/human";
5
+ let nameCamel: "name/camel";
6
+ let nameKebab: "name/kebab";
7
+ let nameSnake: "name/snake";
8
+ let nameConstant: "name/constant";
9
+ let namePascal: "name/pascal";
10
+ let colorRgb: "color/rgb";
11
+ let colorHsl: "color/hsl";
12
+ let colorHsl4: "color/hsl-4";
13
+ let colorHex: "color/hex";
14
+ let colorHex8: "color/hex8";
15
+ let colorHex8android: "color/hex8android";
16
+ let colorComposeColor: "color/composeColor";
17
+ let colorUIColor: "color/UIColor";
18
+ let colorUIColorSwift: "color/UIColorSwift";
19
+ let colorColorSwiftUI: "color/ColorSwiftUI";
20
+ let colorCss: "color/css";
21
+ let colorSketch: "color/sketch";
22
+ let sizeSp: "size/sp";
23
+ let sizeDp: "size/dp";
24
+ let sizeObject: "size/object";
25
+ let sizeRemToSp: "size/remToSp";
26
+ let sizeRemToDp: "size/remToDp";
27
+ let sizePx: "size/px";
28
+ let sizeRem: "size/rem";
29
+ let sizeRemToPt: "size/remToPt";
30
+ let sizeComposeRemToSp: "size/compose/remToSp";
31
+ let sizeComposeRemToDp: "size/compose/remToDp";
32
+ let sizeComposeEm: "size/compose/em";
33
+ let sizeSwiftRemToCGFloat: "size/swift/remToCGFloat";
34
+ let sizeRemToPx: "size/remToPx";
35
+ let sizePxToRem: "size/pxToRem";
36
+ let htmlIcon: "html/icon";
37
+ let contentQuote: "content/quote";
38
+ let contentObjCLiteral: "content/objC/literal";
39
+ let contentSwiftLiteral: "content/swift/literal";
40
+ let timeSeconds: "time/seconds";
41
+ let fontFamilyCss: "fontFamily/css";
42
+ let cubicBezierCss: "cubicBezier/css";
43
+ let strokeStyleCssShorthand: "strokeStyle/css/shorthand";
44
+ let borderCssShorthand: "border/css/shorthand";
45
+ let typographyCssShorthand: "typography/css/shorthand";
46
+ let transitionCssShorthand: "transition/css/shorthand";
47
+ let shadowCssShorthand: "shadow/css/shorthand";
48
+ let assetUrl: "asset/url";
49
+ let assetBase64: "asset/base64";
50
+ let assetPath: "asset/path";
51
+ let assetObjCLiteral: "asset/objC/literal";
52
+ let assetSwiftLiteral: "asset/swift/literal";
53
+ let colorHex8flutter: "color/hex8flutter";
54
+ let contentFlutterLiteral: "content/flutter/literal";
55
+ let assetFlutterLiteral: "asset/flutter/literal";
56
+ let sizeFlutterRemToDouble: "size/flutter/remToDouble";
57
+ }
@@ -0,0 +1,57 @@
1
+ export const transforms = {
2
+ attributeCti: /** @type {'attribute/cti'} */ ('attribute/cti'),
3
+ attributeColor: /** @type {'attribute/color'} */ ('attribute/color'),
4
+ nameHuman: /** @type {'name/human'} */ ('name/human'),
5
+ nameCamel: /** @type {'name/camel'} */ ('name/camel'),
6
+ nameKebab: /** @type {'name/kebab'} */ ('name/kebab'),
7
+ nameSnake: /** @type {'name/snake'} */ ('name/snake'),
8
+ nameConstant: /** @type {'name/constant'} */ ('name/constant'),
9
+ namePascal: /** @type {'name/pascal'} */ ('name/pascal'),
10
+ colorRgb: /** @type {'color/rgb'} */ ('color/rgb'),
11
+ colorHsl: /** @type {'color/hsl'} */ ('color/hsl'),
12
+ colorHsl4: /** @type {'color/hsl-4'} */ ('color/hsl-4'),
13
+ colorHex: /** @type {'color/hex'} */ ('color/hex'),
14
+ colorHex8: /** @type {'color/hex8'} */ ('color/hex8'),
15
+ colorHex8android: /** @type {'color/hex8android'} */ ('color/hex8android'),
16
+ colorComposeColor: /** @type {'color/composeColor'} */ ('color/composeColor'),
17
+ colorUIColor: /** @type {'color/UIColor'} */ ('color/UIColor'),
18
+ colorUIColorSwift: /** @type {'color/UIColorSwift'} */ ('color/UIColorSwift'),
19
+ colorColorSwiftUI: /** @type {'color/ColorSwiftUI'} */ ('color/ColorSwiftUI'),
20
+ colorCss: /** @type {'color/css'} */ ('color/css'),
21
+ colorSketch: /** @type {'color/sketch'} */ ('color/sketch'),
22
+ sizeSp: /** @type {'size/sp'} */ ('size/sp'),
23
+ sizeDp: /** @type {'size/dp'} */ ('size/dp'),
24
+ sizeObject: /** @type {'size/object'} */ ('size/object'),
25
+ sizeRemToSp: /** @type {'size/remToSp'} */ ('size/remToSp'),
26
+ sizeRemToDp: /** @type {'size/remToDp'} */ ('size/remToDp'),
27
+ sizePx: /** @type {'size/px'} */ ('size/px'),
28
+ sizeRem: /** @type {'size/rem'} */ ('size/rem'),
29
+ sizeRemToPt: /** @type {'size/remToPt'} */ ('size/remToPt'),
30
+ sizeComposeRemToSp: /** @type {'size/compose/remToSp'} */ ('size/compose/remToSp'),
31
+ sizeComposeRemToDp: /** @type {'size/compose/remToDp'} */ ('size/compose/remToDp'),
32
+ sizeComposeEm: /** @type {'size/compose/em'} */ ('size/compose/em'),
33
+ sizeSwiftRemToCGFloat: /** @type {'size/swift/remToCGFloat'} */ ('size/swift/remToCGFloat'),
34
+ sizeRemToPx: /** @type {'size/remToPx'} */ ('size/remToPx'),
35
+ sizePxToRem: /** @type {'size/pxToRem'} */ ('size/pxToRem'),
36
+ htmlIcon: /** @type {'html/icon'} */ ('html/icon'),
37
+ contentQuote: /** @type {'content/quote'} */ ('content/quote'),
38
+ contentObjCLiteral: /** @type {'content/objC/literal'} */ ('content/objC/literal'),
39
+ contentSwiftLiteral: /** @type {'content/swift/literal'} */ ('content/swift/literal'),
40
+ timeSeconds: /** @type {'time/seconds'} */ ('time/seconds'),
41
+ fontFamilyCss: /** @type {'fontFamily/css'} */ ('fontFamily/css'),
42
+ cubicBezierCss: /** @type {'cubicBezier/css'} */ ('cubicBezier/css'),
43
+ strokeStyleCssShorthand: /** @type {'strokeStyle/css/shorthand'} */ ('strokeStyle/css/shorthand'),
44
+ borderCssShorthand: /** @type {'border/css/shorthand'} */ ('border/css/shorthand'),
45
+ typographyCssShorthand: /** @type {'typography/css/shorthand'} */ ('typography/css/shorthand'),
46
+ transitionCssShorthand: /** @type {'transition/css/shorthand'} */ ('transition/css/shorthand'),
47
+ shadowCssShorthand: /** @type {'shadow/css/shorthand'} */ ('shadow/css/shorthand'),
48
+ assetUrl: /** @type {'asset/url'} */ ('asset/url'),
49
+ assetBase64: /** @type {'asset/base64'} */ ('asset/base64'),
50
+ assetPath: /** @type {'asset/path'} */ ('asset/path'),
51
+ assetObjCLiteral: /** @type {'asset/objC/literal'} */ ('asset/objC/literal'),
52
+ assetSwiftLiteral: /** @type {'asset/swift/literal'} */ ('asset/swift/literal'),
53
+ colorHex8flutter: /** @type {'color/hex8flutter'} */ ('color/hex8flutter'),
54
+ contentFlutterLiteral: /** @type {'content/flutter/literal'} */ ('content/flutter/literal'),
55
+ assetFlutterLiteral: /** @type {'asset/flutter/literal'} */ ('asset/flutter/literal'),
56
+ sizeFlutterRemToDouble: /** @type {'size/flutter/remToDouble'} */ ('size/flutter/remToDouble'),
57
+ };
@@ -11,7 +11,7 @@
11
11
  * tokens that matched the filter (or the original dictionary if no filter
12
12
  * function was provided).
13
13
  */
14
- export default function filterTokens(dictionary: Dictionary, filter?: ((token: import("../types/DesignToken.d.ts").TransformedToken, options: import("../types/Config.d.ts").Config) => boolean | Promise<boolean>) | undefined, options?: import("../types/Config.d.ts").Config | undefined): Promise<Dictionary>;
14
+ export default function filterTokens(dictionary: Dictionary, filter?: Filter["filter"], options?: Config): Promise<Dictionary>;
15
15
  export type Dictionary = import("../types/DesignToken.d.ts").Dictionary;
16
16
  export type Tokens = import("../types/DesignToken.d.ts").TransformedTokens;
17
17
  export type Token = import("../types/DesignToken.d.ts").TransformedToken;
@@ -11,6 +11,7 @@
11
11
  * and limitations under the License.
12
12
  */
13
13
  import isPlainObject from 'is-plain-obj';
14
+ import { convertTokenData } from './utils/convertTokenData.js';
14
15
 
15
16
  /**
16
17
  * @typedef {import('../types/DesignToken.d.ts').Dictionary} Dictionary
@@ -96,10 +97,14 @@ export default async function filterTokens(dictionary, filter, options = {}) {
96
97
  } else {
97
98
  const allTokens = await asyncFilter(dictionary.allTokens ?? [], filter, options);
98
99
  const tokens = await filterTokenObject(dictionary.tokens, filter, options);
100
+ const tokenMap = /** @type {Map<string,Token>} */ (
101
+ convertTokenData(allTokens, { output: 'map' })
102
+ );
99
103
 
100
104
  return {
101
105
  allTokens,
102
106
  tokens,
107
+ tokenMap,
103
108
  };
104
109
  }
105
110
  }
package/lib/fs.d.ts CHANGED
@@ -7,5 +7,5 @@
7
7
  * cast the default import to type of Volume by first casting to unknown...
8
8
  */
9
9
  export let fs: Volume;
10
- export function setFs(_fs: Volume, isNodeFS?: boolean | undefined): void;
10
+ export function setFs(_fs: Volume, isNodeFS?: boolean): void;
11
11
  export type Volume = import("../types/Volume.d.ts").Volume;
package/lib/fs.js CHANGED
@@ -1,4 +1,4 @@
1
- import memfs from '@bundled-es-modules/memfs';
1
+ import { fs as memfs } from '@bundled-es-modules/memfs';
2
2
 
3
3
  /**
4
4
  * @typedef {import('../types/Volume.d.ts').Volume} Volume
@@ -15,7 +15,7 @@
15
15
  * @param {Config} options
16
16
  * @param {Volume} [vol]
17
17
  */
18
- export default function performActions(dictionary: Dictionary, platform: PlatformConfig, options: Config, vol?: import("../types/Volume.d.ts").Volume | undefined): Promise<void[] | undefined>;
18
+ export default function performActions(dictionary: Dictionary, platform: PlatformConfig, options: Config, vol?: Volume): Promise<void[] | undefined>;
19
19
  export type Volume = import("../types/Volume.d.ts").Volume;
20
20
  export type Dictionary = import("../types/DesignToken.d.ts").Dictionary;
21
21
  export type PlatformConfig = import("../types/Config.d.ts").PlatformConfig;
package/lib/resolve.d.ts CHANGED
@@ -1 +1 @@
1
- export function resolve(path: string, customVolumeUsed?: boolean | undefined): string;
1
+ export function resolve(path: string, customVolumeUsed?: boolean): string;
package/lib/resolve.js CHANGED
@@ -1,4 +1,5 @@
1
- import { posix, win32 } from 'path-unified';
1
+ import { resolve as resolvePosix } from 'path-unified/posix';
2
+ import { resolve as resolveWin32 } from 'path-unified/win32';
2
3
  import { isNode } from './utils/isNode.js';
3
4
 
4
5
  /**
@@ -13,7 +14,7 @@ export const resolve = (path, customVolumeUsed = false) => {
13
14
  return path;
14
15
  }
15
16
  if (isNode && process?.platform === 'win32') {
16
- return win32.resolve(path);
17
+ return resolveWin32(path);
17
18
  }
18
- return posix.resolve(path);
19
+ return resolvePosix(path);
19
20
  };
@@ -16,6 +16,7 @@ import deepExtend from '../utils/deepExtend.js';
16
16
  import GroupMessages from '../utils/groupMessages.js';
17
17
  import { deepmerge } from '../utils/deepmerge.js';
18
18
  import chalk from 'chalk';
19
+ import { logWarningLevels, logVerbosityLevels } from '../enums/index.js';
19
20
 
20
21
  /**
21
22
  * @typedef {import('../StyleDictionary.js').default} StyleDictionary
@@ -197,9 +198,9 @@ None of ${transform_warnings} match the name of a registered transform.
197
198
  /** @param {string} action */ function (action) {
198
199
  if (typeof dictionary.hooks.actions?.[action].undo !== 'function') {
199
200
  const message = `${action} action does not have a clean function!`;
200
- if (to_ret.log?.warnings === 'error') {
201
+ if (to_ret.log?.warnings === logWarningLevels.error) {
201
202
  throw new Error(message);
202
- } else if (to_ret.log?.verbosity !== 'silent') {
203
+ } else if (to_ret.log?.verbosity !== logVerbosityLevels.silent) {
203
204
  // eslint-disable-next-line no-console
204
205
  console.log(chalk.rgb(255, 140, 0).bold(message));
205
206
  }
@@ -26,7 +26,7 @@
26
26
  export default function transformObject(obj: Tokens | TransformedTokens, config: PlatformConfig, options: Config, { transformedPropRefs, deferredPropValueTransforms }?: {
27
27
  transformedPropRefs?: string[];
28
28
  deferredPropValueTransforms?: string[];
29
- } | undefined, path?: string[] | undefined, transformedObj?: Record<string, import("../../types/DesignToken.d.ts").DesignToken | import("../../types/DesignToken.d.ts").PreprocessedTokens | import("../../types/DesignToken.d.ts").TransformedToken | import("../../types/DesignToken.d.ts").TransformedTokens> | undefined, volume?: import("../../types/Volume.d.ts").Volume | undefined): Promise<TransformedTokens>;
29
+ }, path?: string[], transformedObj?: Record<string, Tokens | TransformedTokens | Token | TransformedToken>, volume?: Volume): Promise<TransformedTokens>;
30
30
  export type Volume = import("../../types/Volume.d.ts").Volume;
31
31
  export type Tokens = import("../../types/DesignToken.d.ts").PreprocessedTokens;
32
32
  export type TransformedTokens = import("../../types/DesignToken.d.ts").TransformedTokens;
@@ -1,11 +1,3 @@
1
- /**
2
- * @typedef {import('../../types/Volume.d.ts').Volume} Volume
3
- * @typedef {import('../../types/DesignToken.d.ts').TransformedToken} Token
4
- * @typedef {import('../../types/Config.d.ts').PlatformConfig} PlatformConfig
5
- * @typedef {import('../../types/Config.d.ts').Config} Config
6
- * @typedef {import('../../types/Transform.d.ts').Transform} Transform
7
- * @typedef {import('../../types/Transform.d.ts').NameTransform} NameTransform
8
- */
9
1
  /**
10
2
  * Applies all transforms to a token. This is a pure function,
11
3
  * it returns a new token object rather than mutating it inline.
@@ -16,7 +8,7 @@
16
8
  * @param {Volume} [vol]
17
9
  * @returns {Promise<Token|undefined>} - A new property object with transforms applied.
18
10
  */
19
- export default function transformToken(token: Token, config: PlatformConfig, options: Config, vol?: import("../../types/Volume.d.ts").Volume | undefined): Promise<Token | undefined>;
11
+ export default function transformToken(token: Token, config: PlatformConfig, options: Config, vol?: Volume): Promise<Token | undefined>;
20
12
  export type Volume = import("../../types/Volume.d.ts").Volume;
21
13
  export type Token = import("../../types/DesignToken.d.ts").TransformedToken;
22
14
  export type PlatformConfig = import("../../types/Config.d.ts").PlatformConfig;
@@ -12,6 +12,7 @@
12
12
  */
13
13
 
14
14
  import usesReferences from '../utils/references/usesReferences.js';
15
+ import { transformTypes } from '../enums/index.js';
15
16
 
16
17
  /**
17
18
  * @typedef {import('../../types/Volume.d.ts').Volume} Volume
@@ -22,6 +23,12 @@ import usesReferences from '../utils/references/usesReferences.js';
22
23
  * @typedef {import('../../types/Transform.d.ts').NameTransform} NameTransform
23
24
  */
24
25
 
26
+ const {
27
+ value: transformTypeValue,
28
+ name: transformTypeName,
29
+ attribute: transformTypeAttribute,
30
+ } = transformTypes;
31
+
25
32
  /**
26
33
  * Applies all transforms to a token. This is a pure function,
27
34
  * it returns a new token object rather than mutating it inline.
@@ -41,7 +48,7 @@ export default async function transformToken(token, config, options, vol) {
41
48
  const transform = transforms[i];
42
49
 
43
50
  if (!transform.filter || transform.filter(to_ret, options)) {
44
- if (transform.type === 'name') {
51
+ if (transform.type === transformTypeName) {
45
52
  to_ret.name = await /** @type {Omit<NameTransform, "name">} */ (transform).transform(
46
53
  to_ret,
47
54
  config,
@@ -52,7 +59,7 @@ export default async function transformToken(token, config, options, vol) {
52
59
  // Don't try to transform the value if it is referencing another value
53
60
  // Only try to transform if the value is not a string or if it has '{}'
54
61
  if (
55
- transform.type === 'value' &&
62
+ transform.type === transformTypeValue &&
56
63
  !usesReferences(options.usesDtcg ? token.$value : token.value, config)
57
64
  ) {
58
65
  // Only transform non-referenced values (from original)
@@ -72,7 +79,7 @@ export default async function transformToken(token, config, options, vol) {
72
79
  }
73
80
  }
74
81
 
75
- if (transform.type === 'attribute')
82
+ if (transform.type === transformTypeAttribute)
76
83
  to_ret.attributes = Object.assign(
77
84
  {},
78
85
  to_ret.attributes,
@@ -16,7 +16,7 @@
16
16
  * @param {Config} options
17
17
  * @param {Volume} [vol]
18
18
  */
19
- export default function cleanActions(dictionary: Dictionary, platform: PlatformConfig, options: Config, vol?: import("../../types/Volume.d.ts").Volume | undefined): Promise<void[] | undefined>;
19
+ export default function cleanActions(dictionary: Dictionary, platform: PlatformConfig, options: Config, vol?: Volume): Promise<void[] | undefined>;
20
20
  export type Volume = import("../../types/Volume.d.ts").Volume;
21
21
  export type Dictionary = import("../../types/DesignToken.d.ts").Dictionary;
22
22
  export type PlatformConfig = import("../../types/Config.d.ts").PlatformConfig;
@@ -11,7 +11,7 @@
11
11
  * @param {Volume} [vol] - Filesystem volume to use
12
12
  * @returns {Promise<{tokens: Tokens, usesDtcg: boolean|undefined }>}
13
13
  */
14
- export default function combineJSON(arr: string[], deep?: boolean | undefined, collision?: Function | undefined, source?: boolean | undefined, parsers?: Record<string, Omit<import("../../types/Parser.d.ts").Parser, "name">> | undefined, usesDtcg?: boolean | undefined, vol?: import("../../types/Volume.d.ts").Volume | undefined): Promise<{
14
+ export default function combineJSON(arr: string[], deep?: boolean, collision?: Function, source?: boolean, parsers?: Record<string, Omit<Parser, "name">>, usesDtcg?: boolean, vol?: Volume): Promise<{
15
15
  tokens: Tokens;
16
16
  usesDtcg: boolean | undefined;
17
17
  }>;
@@ -11,14 +11,13 @@
11
11
  * and limitations under the License.
12
12
  */
13
13
 
14
- import JSON5 from 'json5';
15
14
  import { globSync } from '@bundled-es-modules/glob';
16
- import { extname } from 'path-unified';
17
15
  import { fs } from 'style-dictionary/fs';
18
16
  import { resolve } from '../resolve.js';
19
17
  import deepExtend from './deepExtend.js';
20
18
  import { detectDtcgSyntax } from './detectDtcgSyntax.js';
21
19
  import { isNode } from './isNode.js';
20
+ import { loadFile } from './loadFile.js';
22
21
 
23
22
  /**
24
23
  * @typedef {import('../../types/Volume.d.ts').Volume} Volume
@@ -87,40 +86,21 @@ export default async function combineJSON(
87
86
  const filePath = files[i];
88
87
  const resolvedPath = resolve(filePath, vol?.__custom_fs__);
89
88
  let file_content = null;
90
- try {
91
- for (const { pattern, parser } of Object.values(parsers)) {
92
- if (filePath.match(pattern)) {
93
- file_content = await parser({
94
- contents: /** @type {string} */ (volume.readFileSync(resolvedPath, 'utf-8')),
95
- filePath: resolvedPath,
96
- });
97
- }
98
- }
99
89
 
100
- // If there is no file_content then no custom parser ran on that file
101
- if (!file_content) {
102
- if (['.js', '.mjs'].includes(extname(filePath))) {
103
- let resolvedPath = resolve(filePath, vol?.__custom_fs__);
104
- // eslint-disable-next-line no-undef
105
- if (isNode && process?.platform === 'win32') {
106
- // Windows FS compatibility. If in browser, we use an FS shim which doesn't require this Windows workaround
107
- resolvedPath = new URL(`file:///${resolvedPath}`).href;
108
- }
109
- file_content = (await import(/* @vite-ignore */ /* webpackIgnore: true */ resolvedPath))
110
- .default;
111
- } else {
112
- file_content = JSON5.parse(
113
- /** @type {string} */ (volume.readFileSync(resolvedPath, 'utf-8')),
114
- );
115
- }
116
- }
117
- } catch (e) {
118
- if (e instanceof Error) {
119
- e.message = 'Failed to load or parse JSON or JS Object: ' + e.message;
120
- throw e;
90
+ for (const { pattern, parser } of Object.values(parsers)) {
91
+ if (filePath.match(pattern)) {
92
+ file_content = await parser({
93
+ contents: /** @type {string} */ (volume.readFileSync(resolvedPath, 'utf-8')),
94
+ filePath: resolvedPath,
95
+ });
121
96
  }
122
97
  }
123
98
 
99
+ // If there is no file_content then no custom parser ran on that file
100
+ if (!file_content) {
101
+ file_content = /** @type {Tokens} */ (await loadFile(filePath, vol));
102
+ }
103
+
124
104
  if (file_content) {
125
105
  if (usesDtcg === undefined) {
126
106
  usesDtcg = detectDtcgSyntax(file_content);