style-dictionary 4.1.3 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. package/examples/advanced/assets-base64-embed/package.json +1 -1
  2. package/examples/advanced/create-react-app/package.json +1 -1
  3. package/examples/advanced/create-react-native-app/package.json +1 -1
  4. package/examples/advanced/custom-parser/package.json +1 -1
  5. package/examples/advanced/custom-transforms/package.json +1 -1
  6. package/examples/advanced/font-face-rules/package.json +1 -1
  7. package/examples/advanced/format-helpers/package.json +1 -1
  8. package/examples/advanced/matching-build-files/package.json +1 -1
  9. package/examples/advanced/multi-brand-multi-platform/package.json +1 -1
  10. package/examples/advanced/node-modules-as-config-and-properties/package.json +1 -1
  11. package/examples/advanced/npm-module/package.json +1 -1
  12. package/examples/advanced/referencing_aliasing/package.json +1 -1
  13. package/examples/advanced/s3/package.json +1 -1
  14. package/examples/advanced/tokens-deprecation/package.json +1 -1
  15. package/examples/advanced/transitive-transforms/package.json +1 -1
  16. package/examples/advanced/variables-in-outputs/package.json +1 -1
  17. package/examples/advanced/yaml-tokens/package.json +1 -1
  18. package/lib/Register.d.ts +12 -12
  19. package/lib/Register.js +8 -8
  20. package/lib/StyleDictionary.d.ts +24 -24
  21. package/lib/StyleDictionary.js +18 -16
  22. package/lib/cleanActions.d.ts +9 -9
  23. package/lib/cleanActions.js +4 -4
  24. package/lib/cleanDir.d.ts +7 -7
  25. package/lib/cleanDir.js +3 -3
  26. package/lib/cleanDirs.d.ts +5 -5
  27. package/lib/cleanDirs.js +2 -2
  28. package/lib/cleanFile.d.ts +7 -7
  29. package/lib/cleanFile.js +3 -3
  30. package/lib/cleanFiles.d.ts +5 -5
  31. package/lib/cleanFiles.js +2 -2
  32. package/lib/common/actions.d.ts +3 -3
  33. package/lib/common/actions.js +3 -3
  34. package/lib/common/filters.d.ts +1 -1
  35. package/lib/common/filters.js +1 -1
  36. package/lib/common/formatHelpers/createPropertyFormatter.d.ts +8 -8
  37. package/lib/common/formatHelpers/createPropertyFormatter.js +5 -5
  38. package/lib/common/formatHelpers/fileHeader.d.ts +7 -7
  39. package/lib/common/formatHelpers/fileHeader.js +4 -4
  40. package/lib/common/formatHelpers/formattedVariables.d.ts +7 -7
  41. package/lib/common/formatHelpers/formattedVariables.js +5 -5
  42. package/lib/common/formatHelpers/getTypeScriptType.d.ts +5 -5
  43. package/lib/common/formatHelpers/getTypeScriptType.js +2 -2
  44. package/lib/common/formatHelpers/iconsWithPrefix.d.ts +6 -6
  45. package/lib/common/formatHelpers/iconsWithPrefix.js +3 -3
  46. package/lib/common/formatHelpers/minifyDictionary.d.ts +2 -2
  47. package/lib/common/formatHelpers/minifyDictionary.js +1 -1
  48. package/lib/common/formatHelpers/setComposeObjectProperties.d.ts +2 -2
  49. package/lib/common/formatHelpers/setComposeObjectProperties.js +1 -1
  50. package/lib/common/formatHelpers/setSwiftFileProperties.d.ts +2 -2
  51. package/lib/common/formatHelpers/setSwiftFileProperties.js +1 -1
  52. package/lib/common/formatHelpers/sortByReference.d.ts +2 -2
  53. package/lib/common/formatHelpers/sortByReference.js +9 -4
  54. package/lib/common/formats.d.ts +9 -6
  55. package/lib/common/formats.js +121 -26
  56. package/lib/common/templates/android/colors.template.d.ts +3 -3
  57. package/lib/common/templates/android/colors.template.js +3 -3
  58. package/lib/common/templates/android/dimens.template.d.ts +3 -3
  59. package/lib/common/templates/android/dimens.template.js +3 -3
  60. package/lib/common/templates/android/fontDimens.template.d.ts +3 -3
  61. package/lib/common/templates/android/fontDimens.template.js +3 -3
  62. package/lib/common/templates/android/integers.template.d.ts +3 -3
  63. package/lib/common/templates/android/integers.template.js +3 -3
  64. package/lib/common/templates/android/resources.template.d.ts +6 -6
  65. package/lib/common/templates/android/resources.template.js +6 -6
  66. package/lib/common/templates/android/strings.template.d.ts +3 -3
  67. package/lib/common/templates/android/strings.template.js +3 -3
  68. package/lib/common/templates/compose/object.kt.template.d.ts +3 -3
  69. package/lib/common/templates/compose/object.kt.template.js +3 -3
  70. package/lib/common/templates/css/fonts.css.template.d.ts +1 -1
  71. package/lib/common/templates/css/fonts.css.template.js +1 -1
  72. package/lib/common/templates/flutter/class.dart.template.d.ts +4 -4
  73. package/lib/common/templates/flutter/class.dart.template.js +4 -4
  74. package/lib/common/templates/ios/colors.h.template.d.ts +4 -4
  75. package/lib/common/templates/ios/colors.h.template.js +4 -4
  76. package/lib/common/templates/ios/colors.m.template.d.ts +4 -4
  77. package/lib/common/templates/ios/colors.m.template.js +4 -4
  78. package/lib/common/templates/ios/macros.template.d.ts +4 -4
  79. package/lib/common/templates/ios/macros.template.js +4 -4
  80. package/lib/common/templates/ios/plist.template.d.ts +4 -4
  81. package/lib/common/templates/ios/plist.template.js +4 -4
  82. package/lib/common/templates/ios/singleton.h.template.d.ts +3 -3
  83. package/lib/common/templates/ios/singleton.h.template.js +3 -3
  84. package/lib/common/templates/ios/singleton.m.template.d.ts +6 -6
  85. package/lib/common/templates/ios/singleton.m.template.js +6 -6
  86. package/lib/common/templates/ios/static.h.template.d.ts +4 -4
  87. package/lib/common/templates/ios/static.h.template.js +4 -4
  88. package/lib/common/templates/ios/static.m.template.d.ts +4 -4
  89. package/lib/common/templates/ios/static.m.template.js +4 -4
  90. package/lib/common/templates/ios/strings.h.template.d.ts +4 -4
  91. package/lib/common/templates/ios/strings.h.template.js +4 -4
  92. package/lib/common/templates/ios/strings.m.template.d.ts +5 -5
  93. package/lib/common/templates/ios/strings.m.template.js +5 -5
  94. package/lib/common/templates/ios-swift/any.swift.template.d.ts +4 -4
  95. package/lib/common/templates/ios-swift/any.swift.template.js +4 -4
  96. package/lib/common/templates/scss/map-deep.template.d.ts +4 -4
  97. package/lib/common/templates/scss/map-deep.template.js +4 -4
  98. package/lib/common/templates/scss/map-flat.template.d.ts +3 -3
  99. package/lib/common/templates/scss/map-flat.template.js +3 -3
  100. package/lib/common/transformGroups.js +2 -2
  101. package/lib/common/transforms.d.ts +4 -4
  102. package/lib/common/transforms.js +4 -4
  103. package/lib/filterTokens.d.ts +6 -6
  104. package/lib/filterTokens.js +5 -5
  105. package/lib/fs-node.d.ts +2 -2
  106. package/lib/fs-node.js +1 -1
  107. package/lib/fs.d.ts +2 -2
  108. package/lib/fs.js +1 -1
  109. package/lib/performActions.d.ts +9 -9
  110. package/lib/performActions.js +4 -4
  111. package/lib/resolve.js +2 -1
  112. package/lib/transform/config.d.ts +4 -4
  113. package/lib/transform/config.js +4 -4
  114. package/lib/transform/object.d.ts +15 -15
  115. package/lib/transform/object.js +7 -7
  116. package/lib/transform/token.d.ts +13 -13
  117. package/lib/transform/token.js +6 -6
  118. package/lib/transform/tokenSetup.d.ts +4 -4
  119. package/lib/transform/tokenSetup.js +2 -2
  120. package/lib/utils/cleanActions.d.ts +23 -0
  121. package/lib/utils/cleanActions.js +44 -0
  122. package/lib/utils/combineJSON.d.ts +5 -5
  123. package/lib/utils/combineJSON.js +7 -6
  124. package/lib/utils/convertToBase64.d.ts +5 -5
  125. package/lib/utils/convertToBase64.js +32 -9
  126. package/lib/utils/convertToDTCG.d.ts +3 -3
  127. package/lib/utils/convertToDTCG.js +2 -2
  128. package/lib/utils/createFormatArgs.d.ts +8 -8
  129. package/lib/utils/createFormatArgs.js +4 -4
  130. package/lib/utils/deepExtend.d.ts +4 -4
  131. package/lib/utils/deepExtend.js +2 -2
  132. package/lib/utils/expandObjectTokens.d.ts +9 -9
  133. package/lib/utils/expandObjectTokens.js +7 -7
  134. package/lib/utils/flattenTokens.d.ts +2 -2
  135. package/lib/utils/flattenTokens.js +2 -2
  136. package/lib/utils/index.d.ts +2 -1
  137. package/lib/utils/index.js +2 -0
  138. package/lib/utils/isNode.d.ts +1 -0
  139. package/lib/utils/isNode.js +1 -0
  140. package/lib/utils/preprocess.d.ts +10 -8
  141. package/lib/utils/preprocess.js +5 -4
  142. package/lib/utils/references/createReferenceRegex.d.ts +2 -2
  143. package/lib/utils/references/createReferenceRegex.js +1 -1
  144. package/lib/utils/references/defaults.d.ts +1 -1
  145. package/lib/utils/references/defaults.js +1 -1
  146. package/lib/utils/references/getName.d.ts +3 -3
  147. package/lib/utils/references/getName.js +1 -1
  148. package/lib/utils/references/getReferences.d.ts +7 -7
  149. package/lib/utils/references/getReferences.js +3 -3
  150. package/lib/utils/references/getValueByPath.d.ts +4 -4
  151. package/lib/utils/references/getValueByPath.js +2 -2
  152. package/lib/utils/references/outputReferencesFilter.d.ts +4 -4
  153. package/lib/utils/references/outputReferencesFilter.js +2 -2
  154. package/lib/utils/references/outputReferencesTransformed.d.ts +4 -4
  155. package/lib/utils/references/outputReferencesTransformed.js +2 -2
  156. package/lib/utils/references/resolveReferences.d.ts +10 -10
  157. package/lib/utils/references/resolveReferences.js +4 -4
  158. package/lib/utils/references/usesReferences.d.ts +3 -3
  159. package/lib/utils/references/usesReferences.js +1 -1
  160. package/lib/utils/resolveObject.d.ts +4 -4
  161. package/lib/utils/resolveObject.js +3 -3
  162. package/lib/utils/stripMeta.d.ts +20 -0
  163. package/lib/utils/stripMeta.js +51 -0
  164. package/lib/utils/typeDtcgDelegate.d.ts +6 -6
  165. package/lib/utils/typeDtcgDelegate.js +3 -3
  166. package/package.json +5 -2
  167. package/types/Action.d.ts +3 -3
  168. package/types/Config.d.ts +8 -8
  169. package/types/File.d.ts +4 -4
  170. package/types/Filter.d.ts +2 -2
  171. package/types/Format.d.ts +3 -3
  172. package/types/Parser.d.ts +1 -1
  173. package/types/Preprocessor.d.ts +3 -3
  174. package/types/Transform.d.ts +4 -4
  175. package/types/index.d.ts +10 -10
@@ -18,10 +18,10 @@ import convertToBase64 from '../utils/convertToBase64.js';
18
18
  import GroupMessages from '../utils/groupMessages.js';
19
19
 
20
20
  /**
21
- * @typedef {import('../../types/Transform.ts').Transform} Transform
22
- * @typedef {import('../../types/DesignToken.ts').TransformedToken} Token
23
- * @typedef {import('../../types/Config.ts').PlatformConfig} PlatformConfig
24
- * @typedef {import('../../types/Config.ts').Config} Config
21
+ * @typedef {import('../../types/Transform.d.ts').Transform} Transform
22
+ * @typedef {import('../../types/DesignToken.d.ts').TransformedToken} Token
23
+ * @typedef {import('../../types/Config.d.ts').PlatformConfig} PlatformConfig
24
+ * @typedef {import('../../types/Config.d.ts').Config} Config
25
25
  */
26
26
 
27
27
  const UNKNOWN_CSS_FONT_PROPS_WARNINGS = GroupMessages.GROUP.UnknownCSSFontProperties;
@@ -11,9 +11,9 @@
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.ts").TransformedToken, options: import("../types/Config.ts").Config) => boolean | Promise<boolean>) | undefined, options?: import("../types/Config.ts").Config | undefined): Promise<Dictionary>;
15
- export type Dictionary = import("../types/DesignToken.ts").Dictionary;
16
- export type Tokens = import("../types/DesignToken.ts").TransformedTokens;
17
- export type Token = import("../types/DesignToken.ts").TransformedToken;
18
- export type Filter = import("../types/Filter.ts").Filter;
19
- export type Config = import("../types/Config.ts").Config;
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>;
15
+ export type Dictionary = import("../types/DesignToken.d.ts").Dictionary;
16
+ export type Tokens = import("../types/DesignToken.d.ts").TransformedTokens;
17
+ export type Token = import("../types/DesignToken.d.ts").TransformedToken;
18
+ export type Filter = import("../types/Filter.d.ts").Filter;
19
+ export type Config = import("../types/Config.d.ts").Config;
@@ -13,11 +13,11 @@
13
13
  import isPlainObject from 'is-plain-obj';
14
14
 
15
15
  /**
16
- * @typedef {import('../types/DesignToken.ts').Dictionary} Dictionary
17
- * @typedef {import('../types/DesignToken.ts').TransformedTokens} Tokens
18
- * @typedef {import('../types/DesignToken.ts').TransformedToken} Token
19
- * @typedef {import('../types/Filter.ts').Filter} Filter
20
- * @typedef {import('../types/Config.ts').Config} Config
16
+ * @typedef {import('../types/DesignToken.d.ts').Dictionary} Dictionary
17
+ * @typedef {import('../types/DesignToken.d.ts').TransformedTokens} Tokens
18
+ * @typedef {import('../types/DesignToken.d.ts').TransformedToken} Token
19
+ * @typedef {import('../types/Filter.d.ts').Filter} Filter
20
+ * @typedef {import('../types/Config.d.ts').Config} Config
21
21
  */
22
22
 
23
23
  /**
package/lib/fs-node.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { fs } from './fs.js';
2
2
  /**
3
- * @param {import('../types/Volume.ts').Volume} v
3
+ * @param {import('../types/Volume.d.ts').Volume} v
4
4
  */
5
- export function setFs(v: import("../types/Volume.ts").Volume): void;
5
+ export function setFs(v: import("../types/Volume.d.ts").Volume): void;
6
6
  export { fs };
package/lib/fs-node.js CHANGED
@@ -4,7 +4,7 @@ import { setFs as _setFs, fs } from './fs.js';
4
4
  _setFs(_fs, true);
5
5
 
6
6
  /**
7
- * @param {import('../types/Volume.ts').Volume} v
7
+ * @param {import('../types/Volume.d.ts').Volume} v
8
8
  */
9
9
  const setFs = (v) => {
10
10
  // TODO: add a custom test process that tests NodeJS env with memfs FS shim,
package/lib/fs.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @typedef {import('../types/Volume.ts').Volume} Volume
2
+ * @typedef {import('../types/Volume.d.ts').Volume} Volume
3
3
  */
4
4
  /**
5
5
  * Allow to be overridden by setter, set default to memfs for browser env, node:fs for node env
@@ -8,4 +8,4 @@
8
8
  */
9
9
  export let fs: Volume;
10
10
  export function setFs(_fs: Volume, isNodeFS?: boolean | undefined): void;
11
- export type Volume = import("../types/Volume.ts").Volume;
11
+ export type Volume = import("../types/Volume.d.ts").Volume;
package/lib/fs.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import memfs from '@bundled-es-modules/memfs';
2
2
 
3
3
  /**
4
- * @typedef {import('../types/Volume.ts').Volume} Volume
4
+ * @typedef {import('../types/Volume.d.ts').Volume} Volume
5
5
  */
6
6
 
7
7
  /**
@@ -1,8 +1,8 @@
1
1
  /**
2
- * @typedef {import('../types/Volume.ts').Volume} Volume
3
- * @typedef {import('../types/DesignToken.ts').Dictionary} Dictionary
4
- * @typedef {import('../types/Config.ts').PlatformConfig} PlatformConfig
5
- * @typedef {import('../types/Config.ts').Config} Config
2
+ * @typedef {import('../types/Volume.d.ts').Volume} Volume
3
+ * @typedef {import('../types/DesignToken.d.ts').Dictionary} Dictionary
4
+ * @typedef {import('../types/Config.d.ts').PlatformConfig} PlatformConfig
5
+ * @typedef {import('../types/Config.d.ts').Config} Config
6
6
  */
7
7
  /**
8
8
  * Performs any actions in a platform config. Pretty
@@ -15,8 +15,8 @@
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.ts").Volume | undefined): Promise<void[] | undefined>;
19
- export type Volume = import("../types/Volume.ts").Volume;
20
- export type Dictionary = import("../types/DesignToken.ts").Dictionary;
21
- export type PlatformConfig = import("../types/Config.ts").PlatformConfig;
22
- export type Config = import("../types/Config.ts").Config;
18
+ export default function performActions(dictionary: Dictionary, platform: PlatformConfig, options: Config, vol?: import("../types/Volume.d.ts").Volume | undefined): Promise<void[] | undefined>;
19
+ export type Volume = import("../types/Volume.d.ts").Volume;
20
+ export type Dictionary = import("../types/DesignToken.d.ts").Dictionary;
21
+ export type PlatformConfig = import("../types/Config.d.ts").PlatformConfig;
22
+ export type Config = import("../types/Config.d.ts").Config;
@@ -13,10 +13,10 @@
13
13
  import { fs } from 'style-dictionary/fs';
14
14
 
15
15
  /**
16
- * @typedef {import('../types/Volume.ts').Volume} Volume
17
- * @typedef {import('../types/DesignToken.ts').Dictionary} Dictionary
18
- * @typedef {import('../types/Config.ts').PlatformConfig} PlatformConfig
19
- * @typedef {import('../types/Config.ts').Config} Config
16
+ * @typedef {import('../types/Volume.d.ts').Volume} Volume
17
+ * @typedef {import('../types/DesignToken.d.ts').Dictionary} Dictionary
18
+ * @typedef {import('../types/Config.d.ts').PlatformConfig} PlatformConfig
19
+ * @typedef {import('../types/Config.d.ts').Config} Config
20
20
  */
21
21
 
22
22
  /**
package/lib/resolve.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { posix, win32 } from 'path-unified';
2
+ import { isNode } from './utils/isNode.js';
2
3
 
3
4
  /**
4
5
  * If we're on Windows AND we're not in browser context, use win32 resolve (with \'s)
@@ -11,7 +12,7 @@ export const resolve = (path, customVolumeUsed = false) => {
11
12
  if (customVolumeUsed) {
12
13
  return path;
13
14
  }
14
- if (process?.platform === 'win32' && typeof window !== 'object') {
15
+ if (isNode && process?.platform === 'win32') {
15
16
  return win32.resolve(path);
16
17
  }
17
18
  return posix.resolve(path);
@@ -10,7 +10,7 @@
10
10
  */
11
11
  export default function transformConfig(platformConfig: PlatformConfig, dictionary: StyleDictionary, platformName: string): PlatformConfig;
12
12
  export type StyleDictionary = import("../StyleDictionary.js").default;
13
- export type Transform = import("../../types/Transform.ts").Transform;
14
- export type File = import("../../types/File.ts").File;
15
- export type Action = import("../../types/Action.ts").Action;
16
- export type PlatformConfig = import("../../types/Config.ts").PlatformConfig;
13
+ export type Transform = import("../../types/Transform.d.ts").Transform;
14
+ export type File = import("../../types/File.d.ts").File;
15
+ export type Action = import("../../types/Action.d.ts").Action;
16
+ export type PlatformConfig = import("../../types/Config.d.ts").PlatformConfig;
@@ -19,10 +19,10 @@ import chalk from 'chalk';
19
19
 
20
20
  /**
21
21
  * @typedef {import('../StyleDictionary.js').default} StyleDictionary
22
- * @typedef {import('../../types/Transform.ts').Transform} Transform
23
- * @typedef {import('../../types/File.ts').File} File
24
- * @typedef {import('../../types/Action.ts').Action} Action
25
- * @typedef {import('../../types/Config.ts').PlatformConfig} PlatformConfig
22
+ * @typedef {import('../../types/Transform.d.ts').Transform} Transform
23
+ * @typedef {import('../../types/File.d.ts').File} File
24
+ * @typedef {import('../../types/Action.d.ts').Action} Action
25
+ * @typedef {import('../../types/Config.d.ts').PlatformConfig} PlatformConfig
26
26
  */
27
27
 
28
28
  const MISSING_TRANSFORM_ERRORS = GroupMessages.GROUP.MissingRegisterTransformErrors;
@@ -1,11 +1,11 @@
1
1
  /**
2
- * @typedef {import('../../types/Volume.ts').Volume} Volume
3
- * @typedef {import('../../types/DesignToken.ts').PreprocessedTokens} Tokens
4
- * @typedef {import('../../types/DesignToken.ts').TransformedTokens} TransformedTokens
5
- * @typedef {import('../../types/DesignToken.ts').DesignToken} Token
6
- * @typedef {import('../../types/DesignToken.ts').TransformedToken} TransformedToken
7
- * @typedef {import('../../types/Config.ts').PlatformConfig} PlatformConfig
8
- * @typedef {import('../../types/Config.ts').Config} Config
2
+ * @typedef {import('../../types/Volume.d.ts').Volume} Volume
3
+ * @typedef {import('../../types/DesignToken.d.ts').PreprocessedTokens} Tokens
4
+ * @typedef {import('../../types/DesignToken.d.ts').TransformedTokens} TransformedTokens
5
+ * @typedef {import('../../types/DesignToken.d.ts').DesignToken} Token
6
+ * @typedef {import('../../types/DesignToken.d.ts').TransformedToken} TransformedToken
7
+ * @typedef {import('../../types/Config.d.ts').PlatformConfig} PlatformConfig
8
+ * @typedef {import('../../types/Config.d.ts').Config} Config
9
9
  */
10
10
  /**
11
11
  * Applies transforms on all tokens. This
@@ -26,11 +26,11 @@
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.ts").DesignToken | import("../../types/DesignToken.ts").PreprocessedTokens | import("../../types/DesignToken.ts").TransformedToken | import("../../types/DesignToken.ts").TransformedTokens> | undefined, volume?: import("../../types/Volume.ts").Volume | undefined): Promise<TransformedTokens>;
30
- export type Volume = import("../../types/Volume.ts").Volume;
31
- export type Tokens = import("../../types/DesignToken.ts").PreprocessedTokens;
32
- export type TransformedTokens = import("../../types/DesignToken.ts").TransformedTokens;
33
- export type Token = import("../../types/DesignToken.ts").DesignToken;
34
- export type TransformedToken = import("../../types/DesignToken.ts").TransformedToken;
35
- export type PlatformConfig = import("../../types/Config.ts").PlatformConfig;
36
- export type Config = import("../../types/Config.ts").Config;
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>;
30
+ export type Volume = import("../../types/Volume.d.ts").Volume;
31
+ export type Tokens = import("../../types/DesignToken.d.ts").PreprocessedTokens;
32
+ export type TransformedTokens = import("../../types/DesignToken.d.ts").TransformedTokens;
33
+ export type Token = import("../../types/DesignToken.d.ts").DesignToken;
34
+ export type TransformedToken = import("../../types/DesignToken.d.ts").TransformedToken;
35
+ export type PlatformConfig = import("../../types/Config.d.ts").PlatformConfig;
36
+ export type Config = import("../../types/Config.d.ts").Config;
@@ -18,13 +18,13 @@ import transformToken from './token.js';
18
18
  import tokenSetup from './tokenSetup.js';
19
19
 
20
20
  /**
21
- * @typedef {import('../../types/Volume.ts').Volume} Volume
22
- * @typedef {import('../../types/DesignToken.ts').PreprocessedTokens} Tokens
23
- * @typedef {import('../../types/DesignToken.ts').TransformedTokens} TransformedTokens
24
- * @typedef {import('../../types/DesignToken.ts').DesignToken} Token
25
- * @typedef {import('../../types/DesignToken.ts').TransformedToken} TransformedToken
26
- * @typedef {import('../../types/Config.ts').PlatformConfig} PlatformConfig
27
- * @typedef {import('../../types/Config.ts').Config} Config
21
+ * @typedef {import('../../types/Volume.d.ts').Volume} Volume
22
+ * @typedef {import('../../types/DesignToken.d.ts').PreprocessedTokens} Tokens
23
+ * @typedef {import('../../types/DesignToken.d.ts').TransformedTokens} TransformedTokens
24
+ * @typedef {import('../../types/DesignToken.d.ts').DesignToken} Token
25
+ * @typedef {import('../../types/DesignToken.d.ts').TransformedToken} TransformedToken
26
+ * @typedef {import('../../types/Config.d.ts').PlatformConfig} PlatformConfig
27
+ * @typedef {import('../../types/Config.d.ts').Config} Config
28
28
  */
29
29
 
30
30
  /**
@@ -1,10 +1,10 @@
1
1
  /**
2
- * @typedef {import('../../types/Volume.ts').Volume} Volume
3
- * @typedef {import('../../types/DesignToken.ts').TransformedToken} Token
4
- * @typedef {import('../../types/Config.ts').PlatformConfig} PlatformConfig
5
- * @typedef {import('../../types/Config.ts').Config} Config
6
- * @typedef {import('../../types/Transform.ts').Transform} Transform
7
- * @typedef {import('../../types/Transform.ts').NameTransform} NameTransform
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
8
  */
9
9
  /**
10
10
  * Applies all transforms to a token. This is a pure function,
@@ -16,10 +16,10 @@
16
16
  * @param {Volume} [vol]
17
17
  * @returns {Promise<Token|undefined>} - A new property object with transforms applied.
18
18
  */
19
- export default function transformToken(token: Token, config: PlatformConfig, options: Config, vol?: import("../../types/Volume.ts").Volume | undefined): Promise<Token | undefined>;
20
- export type Volume = import("../../types/Volume.ts").Volume;
21
- export type Token = import("../../types/DesignToken.ts").TransformedToken;
22
- export type PlatformConfig = import("../../types/Config.ts").PlatformConfig;
23
- export type Config = import("../../types/Config.ts").Config;
24
- export type Transform = import("../../types/Transform.ts").Transform;
25
- export type NameTransform = import("../../types/Transform.ts").NameTransform;
19
+ export default function transformToken(token: Token, config: PlatformConfig, options: Config, vol?: import("../../types/Volume.d.ts").Volume | undefined): Promise<Token | undefined>;
20
+ export type Volume = import("../../types/Volume.d.ts").Volume;
21
+ export type Token = import("../../types/DesignToken.d.ts").TransformedToken;
22
+ export type PlatformConfig = import("../../types/Config.d.ts").PlatformConfig;
23
+ export type Config = import("../../types/Config.d.ts").Config;
24
+ export type Transform = import("../../types/Transform.d.ts").Transform;
25
+ export type NameTransform = import("../../types/Transform.d.ts").NameTransform;
@@ -14,12 +14,12 @@
14
14
  import usesReferences from '../utils/references/usesReferences.js';
15
15
 
16
16
  /**
17
- * @typedef {import('../../types/Volume.ts').Volume} Volume
18
- * @typedef {import('../../types/DesignToken.ts').TransformedToken} Token
19
- * @typedef {import('../../types/Config.ts').PlatformConfig} PlatformConfig
20
- * @typedef {import('../../types/Config.ts').Config} Config
21
- * @typedef {import('../../types/Transform.ts').Transform} Transform
22
- * @typedef {import('../../types/Transform.ts').NameTransform} NameTransform
17
+ * @typedef {import('../../types/Volume.d.ts').Volume} Volume
18
+ * @typedef {import('../../types/DesignToken.d.ts').TransformedToken} Token
19
+ * @typedef {import('../../types/Config.d.ts').PlatformConfig} PlatformConfig
20
+ * @typedef {import('../../types/Config.d.ts').Config} Config
21
+ * @typedef {import('../../types/Transform.d.ts').Transform} Transform
22
+ * @typedef {import('../../types/Transform.d.ts').NameTransform} NameTransform
23
23
  */
24
24
 
25
25
  /**
@@ -1,6 +1,6 @@
1
1
  /**
2
- * @typedef {import('../../types/DesignToken.ts').DesignToken} Token
3
- * @typedef {import('../../types/DesignToken.ts').TransformedToken} TransformedToken
2
+ * @typedef {import('../../types/DesignToken.d.ts').DesignToken} Token
3
+ * @typedef {import('../../types/DesignToken.d.ts').TransformedToken} TransformedToken
4
4
  */
5
5
  /**
6
6
  * Takes a token object, a leaf node in a tokens object, and
@@ -14,5 +14,5 @@
14
14
  * @returns {TransformedToken} - A new object that is setup and ready to go.
15
15
  */
16
16
  export default function tokenSetup(token: Token | TransformedToken, name: string, path: string[]): TransformedToken;
17
- export type Token = import("../../types/DesignToken.ts").DesignToken;
18
- export type TransformedToken = import("../../types/DesignToken.ts").TransformedToken;
17
+ export type Token = import("../../types/DesignToken.d.ts").DesignToken;
18
+ export type TransformedToken = import("../../types/DesignToken.d.ts").TransformedToken;
@@ -14,8 +14,8 @@
14
14
  import isPlainObject from 'is-plain-obj';
15
15
 
16
16
  /**
17
- * @typedef {import('../../types/DesignToken.ts').DesignToken} Token
18
- * @typedef {import('../../types/DesignToken.ts').TransformedToken} TransformedToken
17
+ * @typedef {import('../../types/DesignToken.d.ts').DesignToken} Token
18
+ * @typedef {import('../../types/DesignToken.d.ts').TransformedToken} TransformedToken
19
19
  */
20
20
 
21
21
  /**
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @typedef {import('../../types/Volume.d.ts').Volume} Volume
3
+ * @typedef {import('../../types/DesignToken.d.ts').Dictionary} Dictionary
4
+ * @typedef {import('../../types/Config.d.ts').PlatformConfig} PlatformConfig
5
+ * @typedef {import('../../types/Config.d.ts').Config} Config
6
+ */
7
+ /**
8
+ * Performs the undo of any actions defined in a platform. Pretty
9
+ * simple really. Actions should be an array of functions,
10
+ * the calling function should map the functions accordingly.
11
+ * @static
12
+ * @private
13
+ * @memberof module:style-dictionary
14
+ * @param {Dictionary} dictionary
15
+ * @param {PlatformConfig} platform
16
+ * @param {Config} options
17
+ * @param {Volume} [vol]
18
+ */
19
+ export default function cleanActions(dictionary: Dictionary, platform: PlatformConfig, options: Config, vol?: import("../../types/Volume.d.ts").Volume | undefined): Promise<void[] | undefined>;
20
+ export type Volume = import("../../types/Volume.d.ts").Volume;
21
+ export type Dictionary = import("../../types/DesignToken.d.ts").Dictionary;
22
+ export type PlatformConfig = import("../../types/Config.d.ts").PlatformConfig;
23
+ export type Config = import("../../types/Config.d.ts").Config;
@@ -0,0 +1,44 @@
1
+ /*
2
+ * Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
5
+ * the License. A copy of the License is located at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
10
+ * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
11
+ * and limitations under the License.
12
+ */
13
+ import { fs } from 'style-dictionary/fs';
14
+
15
+ /**
16
+ * @typedef {import('../../types/Volume.d.ts').Volume} Volume
17
+ * @typedef {import('../../types/DesignToken.d.ts').Dictionary} Dictionary
18
+ * @typedef {import('../../types/Config.d.ts').PlatformConfig} PlatformConfig
19
+ * @typedef {import('../../types/Config.d.ts').Config} Config
20
+ */
21
+
22
+ /**
23
+ * Performs the undo of any actions defined in a platform. Pretty
24
+ * simple really. Actions should be an array of functions,
25
+ * the calling function should map the functions accordingly.
26
+ * @static
27
+ * @private
28
+ * @memberof module:style-dictionary
29
+ * @param {Dictionary} dictionary
30
+ * @param {PlatformConfig} platform
31
+ * @param {Config} options
32
+ * @param {Volume} [vol]
33
+ */
34
+ export default async function cleanActions(dictionary, platform, options, vol = fs) {
35
+ if (platform.actions) {
36
+ return Promise.all(
37
+ platform.actions.map((action) => {
38
+ if (typeof action !== 'string' && typeof action.undo === 'function') {
39
+ return action.undo(dictionary, platform, options, vol);
40
+ }
41
+ }),
42
+ );
43
+ }
44
+ }
@@ -11,11 +11,11 @@
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.ts").Parser, "name">> | undefined, usesDtcg?: boolean | undefined, vol?: import("../../types/Volume.ts").Volume | undefined): Promise<{
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<{
15
15
  tokens: Tokens;
16
16
  usesDtcg: boolean | undefined;
17
17
  }>;
18
- export type Volume = import("../../types/Volume.ts").Volume;
19
- export type Tokens = import("../../types/DesignToken.ts").DesignTokens;
20
- export type Token = import("../../types/DesignToken.ts").DesignToken;
21
- export type Parser = import("../../types/Parser.ts").Parser;
18
+ export type Volume = import("../../types/Volume.d.ts").Volume;
19
+ export type Tokens = import("../../types/DesignToken.d.ts").DesignTokens;
20
+ export type Token = import("../../types/DesignToken.d.ts").DesignToken;
21
+ export type Parser = import("../../types/Parser.d.ts").Parser;
@@ -18,12 +18,13 @@ import { fs } from 'style-dictionary/fs';
18
18
  import { resolve } from '../resolve.js';
19
19
  import deepExtend from './deepExtend.js';
20
20
  import { detectDtcgSyntax } from './detectDtcgSyntax.js';
21
+ import { isNode } from './isNode.js';
21
22
 
22
23
  /**
23
- * @typedef {import('../../types/Volume.ts').Volume} Volume
24
- * @typedef {import('../../types/DesignToken.ts').DesignTokens} Tokens
25
- * @typedef {import('../../types/DesignToken.ts').DesignToken} Token
26
- * @typedef {import('../../types/Parser.ts').Parser} Parser
24
+ * @typedef {import('../../types/Volume.d.ts').Volume} Volume
25
+ * @typedef {import('../../types/DesignToken.d.ts').DesignTokens} Tokens
26
+ * @typedef {import('../../types/DesignToken.d.ts').DesignToken} Token
27
+ * @typedef {import('../../types/Parser.d.ts').Parser} Parser
27
28
  */
28
29
 
29
30
  /**
@@ -76,7 +77,7 @@ export default async function combineJSON(
76
77
  files = files.concat(new_files);
77
78
  }
78
79
 
79
- if (typeof window === 'object') {
80
+ if (!isNode) {
80
81
  // adjust for browser env glob results have leading slash
81
82
  // make sure we dont remove these in Node, that would break absolute paths!!
82
83
  files = files.map((f) => f.replace(/^\//, ''));
@@ -101,7 +102,7 @@ export default async function combineJSON(
101
102
  if (['.js', '.mjs'].includes(extname(filePath))) {
102
103
  let resolvedPath = resolve(filePath, vol?.__custom_fs__);
103
104
  // eslint-disable-next-line no-undef
104
- if (typeof window !== 'object' && process?.platform === 'win32') {
105
+ if (isNode && process?.platform === 'win32') {
105
106
  // Windows FS compatibility. If in browser, we use an FS shim which doesn't require this Windows workaround
106
107
  resolvedPath = new URL(`file:///${resolvedPath}`).href;
107
108
  }
@@ -1,13 +1,13 @@
1
1
  /**
2
- * @typedef {import('../../types/Volume.ts').Volume} Volume
2
+ * @typedef {import('../../types/Volume.d.ts').Volume} Volume
3
3
  * Takes a file and converts it to a base64 string.
4
4
  * @private
5
- * @param {String} filePath - Path to the file you want base64'd
5
+ * @param {string} filePath - Path to the file you want base64'd
6
6
  * @param {Volume} [vol]
7
- * @returns {String}
7
+ * @returns {Promise<string>}
8
8
  */
9
- export default function convertToBase64(filePath: string, vol?: import("../../types/Volume.ts").Volume | undefined): string;
9
+ export default function convertToBase64(filePath: string, vol?: import("../../types/Volume.d.ts").Volume | undefined): Promise<string>;
10
10
  /**
11
11
  * Takes a file and converts it to a base64 string.
12
12
  */
13
- export type Volume = import("../../types/Volume.ts").Volume;
13
+ export type Volume = import("../../types/Volume.d.ts").Volume;
@@ -13,20 +13,43 @@
13
13
 
14
14
  import { fs } from 'style-dictionary/fs';
15
15
  import { resolve } from '../resolve.js';
16
+ import { isNode } from './isNode.js';
16
17
 
17
18
  /**
18
- * @typedef {import('../../types/Volume.ts').Volume} Volume
19
+ * @param {Buffer} buffer
20
+ * @returns {string|Promise<string>}
21
+ */
22
+ function toBase64(buffer) {
23
+ if (isNode) {
24
+ // Node.js environment
25
+ return buffer.toString('base64');
26
+ } else {
27
+ // Browser environment
28
+ return new Promise((resolve, reject) => {
29
+ const blob = new Blob([buffer], { type: 'application/octet-stream' });
30
+ const reader = new FileReader();
31
+ reader.onloadend = () => {
32
+ const base64String = /** @type {string } */ (reader.result).split(',')[1];
33
+ resolve(base64String);
34
+ };
35
+ reader.onerror = reject;
36
+ reader.readAsDataURL(blob);
37
+ });
38
+ }
39
+ }
40
+
41
+ /**
42
+ * @typedef {import('../../types/Volume.d.ts').Volume} Volume
19
43
  * Takes a file and converts it to a base64 string.
20
44
  * @private
21
- * @param {String} filePath - Path to the file you want base64'd
45
+ * @param {string} filePath - Path to the file you want base64'd
22
46
  * @param {Volume} [vol]
23
- * @returns {String}
47
+ * @returns {Promise<string>}
24
48
  */
25
- export default function convertToBase64(filePath, vol = fs) {
49
+ export default async function convertToBase64(filePath, vol = fs) {
26
50
  if (typeof filePath !== 'string') throw new Error('Token filePath name must be a string');
27
-
28
- const body = /** @type {string} */ (
29
- vol.readFileSync(resolve(filePath, vol.__custom_fs__), 'utf-8')
30
- );
31
- return btoa(body);
51
+ // typecast to Buffer because we know that without specifying encoding, this returns a Buffer
52
+ // @ts-expect-error requires encoding options, this is a mistake in memfs types definition
53
+ const body = /** @type {Buffer} */ (vol.readFileSync(resolve(filePath, vol.__custom_fs__)));
54
+ return toBase64(body);
32
55
  }
@@ -4,7 +4,7 @@
4
4
  */
5
5
  export function convertToDTCG(dictionary: DesignTokens, opts?: {
6
6
  applyTypesToGroup?: boolean;
7
- } | undefined): import("../../types/DesignToken.ts").DesignTokens;
7
+ } | undefined): import("../../types/DesignToken.d.ts").DesignTokens;
8
8
  /**
9
9
  * @param {Entry} entry
10
10
  */
@@ -34,5 +34,5 @@ export function convertZIPToDTCG(blobOrPath: Blob | string, opts?: {
34
34
  applyTypesToGroup?: boolean;
35
35
  } | undefined): Promise<Blob>;
36
36
  export type Entry = import("@zip.js/zip.js").Entry;
37
- export type DesignToken = import("../../types/DesignToken.ts").DesignToken;
38
- export type DesignTokens = import("../../types/DesignToken.ts").DesignTokens;
37
+ export type DesignToken = import("../../types/DesignToken.d.ts").DesignToken;
38
+ export type DesignTokens = import("../../types/DesignToken.d.ts").DesignTokens;
@@ -11,8 +11,8 @@ import { fs } from 'style-dictionary/fs';
11
11
 
12
12
  /**
13
13
  * @typedef {import('@zip.js/zip.js').Entry} Entry
14
- * @typedef {import('../../types/DesignToken.ts').DesignToken} DesignToken
15
- * @typedef {import('../../types/DesignToken.ts').DesignTokens} DesignTokens
14
+ * @typedef {import('../../types/DesignToken.d.ts').DesignToken} DesignToken
15
+ * @typedef {import('../../types/DesignToken.d.ts').DesignTokens} DesignTokens
16
16
  */
17
17
 
18
18
  /**
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * @typedef {import('../../types/DesignToken.js').Dictionary} Dictionary
3
- * @typedef {import('../../types/Config.ts').PlatformConfig} PlatformConfig
4
- * @typedef {import('../../types/Config.ts').Config} Options
5
- * @typedef {import('../../types/File.ts').File} File
6
- * @typedef {import('../../types/Format.ts').FormatFnArguments} FormatFnArguments
3
+ * @typedef {import('../../types/Config.d.ts').PlatformConfig} PlatformConfig
4
+ * @typedef {import('../../types/Config.d.ts').Config} Options
5
+ * @typedef {import('../../types/File.d.ts').File} File
6
+ * @typedef {import('../../types/Format.d.ts').FormatFnArguments} FormatFnArguments
7
7
  *
8
8
 
9
9
  /**
@@ -11,10 +11,10 @@
11
11
  */
12
12
  export default function createFormatArgs({ dictionary, platform, options, file }: FormatFnArguments): FormatFnArguments & Dictionary;
13
13
  export type Dictionary = import("../../types/DesignToken.js").Dictionary;
14
- export type PlatformConfig = import("../../types/Config.ts").PlatformConfig;
15
- export type Options = import("../../types/Config.ts").Config;
16
- export type File = import("../../types/File.ts").File;
14
+ export type PlatformConfig = import("../../types/Config.d.ts").PlatformConfig;
15
+ export type Options = import("../../types/Config.d.ts").Config;
16
+ export type File = import("../../types/File.d.ts").File;
17
17
  /**
18
18
  * /**
19
19
  */
20
- export type FormatFnArguments = import("../../types/Format.ts").FormatFnArguments;
20
+ export type FormatFnArguments = import("../../types/Format.d.ts").FormatFnArguments;
@@ -15,10 +15,10 @@ import deepExtend from './deepExtend.js';
15
15
 
16
16
  /**
17
17
  * @typedef {import('../../types/DesignToken.js').Dictionary} Dictionary
18
- * @typedef {import('../../types/Config.ts').PlatformConfig} PlatformConfig
19
- * @typedef {import('../../types/Config.ts').Config} Options
20
- * @typedef {import('../../types/File.ts').File} File
21
- * @typedef {import('../../types/Format.ts').FormatFnArguments} FormatFnArguments
18
+ * @typedef {import('../../types/Config.d.ts').PlatformConfig} PlatformConfig
19
+ * @typedef {import('../../types/Config.d.ts').Config} Options
20
+ * @typedef {import('../../types/File.d.ts').File} File
21
+ * @typedef {import('../../types/Format.d.ts').FormatFnArguments} FormatFnArguments
22
22
  *
23
23
 
24
24
  /**