style-dictionary 4.1.4 → 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.
- 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/custom-parser/package.json +1 -1
- package/examples/advanced/custom-transforms/package.json +1 -1
- package/examples/advanced/font-face-rules/package.json +1 -1
- package/examples/advanced/format-helpers/package.json +1 -1
- package/examples/advanced/matching-build-files/package.json +1 -1
- package/examples/advanced/multi-brand-multi-platform/package.json +1 -1
- 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/tokens-deprecation/package.json +1 -1
- package/examples/advanced/transitive-transforms/package.json +1 -1
- package/examples/advanced/variables-in-outputs/package.json +1 -1
- package/examples/advanced/yaml-tokens/package.json +1 -1
- package/lib/Register.d.ts +12 -12
- package/lib/Register.js +8 -8
- package/lib/StyleDictionary.d.ts +24 -24
- package/lib/StyleDictionary.js +15 -15
- package/lib/cleanActions.d.ts +9 -9
- package/lib/cleanActions.js +4 -4
- package/lib/cleanDir.d.ts +7 -7
- package/lib/cleanDir.js +3 -3
- package/lib/cleanDirs.d.ts +5 -5
- package/lib/cleanDirs.js +2 -2
- package/lib/cleanFile.d.ts +7 -7
- package/lib/cleanFile.js +3 -3
- package/lib/cleanFiles.d.ts +5 -5
- package/lib/cleanFiles.js +2 -2
- package/lib/common/actions.d.ts +3 -3
- package/lib/common/actions.js +3 -3
- package/lib/common/filters.d.ts +1 -1
- package/lib/common/filters.js +1 -1
- package/lib/common/formatHelpers/createPropertyFormatter.d.ts +8 -8
- package/lib/common/formatHelpers/createPropertyFormatter.js +5 -5
- package/lib/common/formatHelpers/fileHeader.d.ts +7 -7
- package/lib/common/formatHelpers/fileHeader.js +4 -4
- package/lib/common/formatHelpers/formattedVariables.d.ts +7 -7
- package/lib/common/formatHelpers/formattedVariables.js +5 -5
- package/lib/common/formatHelpers/getTypeScriptType.d.ts +5 -5
- package/lib/common/formatHelpers/getTypeScriptType.js +2 -2
- package/lib/common/formatHelpers/iconsWithPrefix.d.ts +6 -6
- package/lib/common/formatHelpers/iconsWithPrefix.js +3 -3
- package/lib/common/formatHelpers/minifyDictionary.d.ts +2 -2
- package/lib/common/formatHelpers/minifyDictionary.js +1 -1
- package/lib/common/formatHelpers/setComposeObjectProperties.d.ts +2 -2
- package/lib/common/formatHelpers/setComposeObjectProperties.js +1 -1
- package/lib/common/formatHelpers/setSwiftFileProperties.d.ts +2 -2
- package/lib/common/formatHelpers/setSwiftFileProperties.js +1 -1
- package/lib/common/formatHelpers/sortByReference.d.ts +2 -2
- package/lib/common/formatHelpers/sortByReference.js +2 -2
- package/lib/common/formats.d.ts +9 -6
- package/lib/common/formats.js +121 -26
- package/lib/common/templates/android/colors.template.d.ts +3 -3
- package/lib/common/templates/android/colors.template.js +3 -3
- package/lib/common/templates/android/dimens.template.d.ts +3 -3
- package/lib/common/templates/android/dimens.template.js +3 -3
- package/lib/common/templates/android/fontDimens.template.d.ts +3 -3
- package/lib/common/templates/android/fontDimens.template.js +3 -3
- package/lib/common/templates/android/integers.template.d.ts +3 -3
- package/lib/common/templates/android/integers.template.js +3 -3
- package/lib/common/templates/android/resources.template.d.ts +6 -6
- package/lib/common/templates/android/resources.template.js +6 -6
- package/lib/common/templates/android/strings.template.d.ts +3 -3
- package/lib/common/templates/android/strings.template.js +3 -3
- package/lib/common/templates/compose/object.kt.template.d.ts +3 -3
- package/lib/common/templates/compose/object.kt.template.js +3 -3
- package/lib/common/templates/css/fonts.css.template.d.ts +1 -1
- package/lib/common/templates/css/fonts.css.template.js +1 -1
- package/lib/common/templates/flutter/class.dart.template.d.ts +4 -4
- package/lib/common/templates/flutter/class.dart.template.js +4 -4
- package/lib/common/templates/ios/colors.h.template.d.ts +4 -4
- package/lib/common/templates/ios/colors.h.template.js +4 -4
- package/lib/common/templates/ios/colors.m.template.d.ts +4 -4
- package/lib/common/templates/ios/colors.m.template.js +4 -4
- package/lib/common/templates/ios/macros.template.d.ts +4 -4
- package/lib/common/templates/ios/macros.template.js +4 -4
- package/lib/common/templates/ios/plist.template.d.ts +4 -4
- package/lib/common/templates/ios/plist.template.js +4 -4
- package/lib/common/templates/ios/singleton.h.template.d.ts +3 -3
- package/lib/common/templates/ios/singleton.h.template.js +3 -3
- package/lib/common/templates/ios/singleton.m.template.d.ts +6 -6
- package/lib/common/templates/ios/singleton.m.template.js +6 -6
- package/lib/common/templates/ios/static.h.template.d.ts +4 -4
- package/lib/common/templates/ios/static.h.template.js +4 -4
- package/lib/common/templates/ios/static.m.template.d.ts +4 -4
- package/lib/common/templates/ios/static.m.template.js +4 -4
- package/lib/common/templates/ios/strings.h.template.d.ts +4 -4
- package/lib/common/templates/ios/strings.h.template.js +4 -4
- package/lib/common/templates/ios/strings.m.template.d.ts +5 -5
- package/lib/common/templates/ios/strings.m.template.js +5 -5
- package/lib/common/templates/ios-swift/any.swift.template.d.ts +4 -4
- package/lib/common/templates/ios-swift/any.swift.template.js +4 -4
- package/lib/common/templates/scss/map-deep.template.d.ts +4 -4
- package/lib/common/templates/scss/map-deep.template.js +4 -4
- package/lib/common/templates/scss/map-flat.template.d.ts +3 -3
- package/lib/common/templates/scss/map-flat.template.js +3 -3
- package/lib/common/transforms.d.ts +4 -4
- package/lib/common/transforms.js +4 -4
- package/lib/filterTokens.d.ts +6 -6
- package/lib/filterTokens.js +5 -5
- package/lib/fs-node.d.ts +2 -2
- package/lib/fs-node.js +1 -1
- package/lib/fs.d.ts +2 -2
- package/lib/fs.js +1 -1
- package/lib/performActions.d.ts +9 -9
- package/lib/performActions.js +4 -4
- package/lib/transform/config.d.ts +4 -4
- package/lib/transform/config.js +4 -4
- package/lib/transform/object.d.ts +15 -15
- package/lib/transform/object.js +7 -7
- package/lib/transform/token.d.ts +13 -13
- package/lib/transform/token.js +6 -6
- package/lib/transform/tokenSetup.d.ts +4 -4
- package/lib/transform/tokenSetup.js +2 -2
- package/lib/utils/cleanActions.d.ts +23 -0
- package/lib/utils/cleanActions.js +44 -0
- package/lib/utils/combineJSON.d.ts +5 -5
- package/lib/utils/combineJSON.js +4 -4
- package/lib/utils/convertToBase64.d.ts +3 -3
- package/lib/utils/convertToBase64.js +1 -1
- package/lib/utils/convertToDTCG.d.ts +3 -3
- package/lib/utils/convertToDTCG.js +2 -2
- package/lib/utils/createFormatArgs.d.ts +8 -8
- package/lib/utils/createFormatArgs.js +4 -4
- package/lib/utils/deepExtend.d.ts +4 -4
- package/lib/utils/deepExtend.js +2 -2
- package/lib/utils/expandObjectTokens.d.ts +9 -9
- package/lib/utils/expandObjectTokens.js +7 -7
- package/lib/utils/flattenTokens.d.ts +2 -2
- package/lib/utils/flattenTokens.js +2 -2
- package/lib/utils/index.d.ts +2 -1
- package/lib/utils/index.js +2 -0
- package/lib/utils/preprocess.d.ts +9 -9
- package/lib/utils/preprocess.js +4 -4
- package/lib/utils/references/createReferenceRegex.d.ts +2 -2
- package/lib/utils/references/createReferenceRegex.js +1 -1
- package/lib/utils/references/defaults.d.ts +1 -1
- package/lib/utils/references/defaults.js +1 -1
- package/lib/utils/references/getName.d.ts +3 -3
- package/lib/utils/references/getName.js +1 -1
- package/lib/utils/references/getReferences.d.ts +7 -7
- package/lib/utils/references/getReferences.js +3 -3
- package/lib/utils/references/getValueByPath.d.ts +4 -4
- package/lib/utils/references/getValueByPath.js +2 -2
- package/lib/utils/references/outputReferencesFilter.d.ts +4 -4
- package/lib/utils/references/outputReferencesFilter.js +2 -2
- package/lib/utils/references/outputReferencesTransformed.d.ts +4 -4
- package/lib/utils/references/outputReferencesTransformed.js +2 -2
- package/lib/utils/references/resolveReferences.d.ts +10 -10
- package/lib/utils/references/resolveReferences.js +4 -4
- package/lib/utils/references/usesReferences.d.ts +3 -3
- package/lib/utils/references/usesReferences.js +1 -1
- package/lib/utils/resolveObject.d.ts +4 -4
- package/lib/utils/resolveObject.js +3 -3
- package/lib/utils/stripMeta.d.ts +20 -0
- package/lib/utils/stripMeta.js +51 -0
- package/lib/utils/typeDtcgDelegate.d.ts +6 -6
- package/lib/utils/typeDtcgDelegate.js +3 -3
- package/package.json +4 -2
- package/types/Action.d.ts +3 -3
- package/types/Config.d.ts +8 -8
- package/types/File.d.ts +4 -4
- package/types/Filter.d.ts +2 -2
- package/types/Format.d.ts +3 -3
- package/types/Parser.d.ts +1 -1
- package/types/Preprocessor.d.ts +2 -2
- package/types/Transform.d.ts +4 -4
- package/types/index.d.ts +10 -10
|
@@ -14,10 +14,10 @@ import { getReferences } from '../../utils/references/getReferences.js';
|
|
|
14
14
|
import usesReferences from '../../utils/references/usesReferences.js';
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
* @typedef {import('../../../types/DesignToken.ts').TransformedToken} TransformedToken
|
|
18
|
-
* @typedef {import('../../../types/DesignToken.ts').Dictionary} Dictionary
|
|
19
|
-
* @typedef {import('../../../types/File.ts').FormattingOptions} Formatting
|
|
20
|
-
* @typedef {import('../../../types/Format.ts').OutputReferences} OutputReferences
|
|
17
|
+
* @typedef {import('../../../types/DesignToken.d.ts').TransformedToken} TransformedToken
|
|
18
|
+
* @typedef {import('../../../types/DesignToken.d.ts').Dictionary} Dictionary
|
|
19
|
+
* @typedef {import('../../../types/File.d.ts').FormattingOptions} Formatting
|
|
20
|
+
* @typedef {import('../../../types/Format.d.ts').OutputReferences} OutputReferences
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
23
|
/**
|
|
@@ -116,7 +116,7 @@ export function addComment(to_ret_token, comment, options) {
|
|
|
116
116
|
* @param {Formatting} [options.formatting] - Custom formatting properties that define parts of a declaration line in code. The configurable strings are: `prefix`, `indentation`, `separator`, `suffix`, `lineSeparator`, `fileHeaderTimestamp`, `header`, `footer`, `commentStyle` and `commentPosition`. Those are used to generate a line like this: `${indentation}${prefix}${token.name}${separator} ${prop.value}${suffix}`. The remaining formatting options are used for the fileHeader helper.
|
|
117
117
|
* @param {boolean} [options.themeable] [false] - Whether tokens should default to being themeable.
|
|
118
118
|
* @param {boolean} [options.usesDtcg] [false] - Whether DTCG token syntax should be uses.
|
|
119
|
-
* @returns {(token: import('../../../types/DesignToken.ts').TransformedToken) => string}
|
|
119
|
+
* @returns {(token: import('../../../types/DesignToken.d.ts').TransformedToken) => string}
|
|
120
120
|
*/
|
|
121
121
|
export default function createPropertyFormatter({
|
|
122
122
|
outputReferences = false,
|
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
* ```
|
|
25
25
|
*/
|
|
26
26
|
export default function fileHeader({ file, commentStyle, formatting, options }: {
|
|
27
|
-
file?: import("../../../types/File.ts").File | undefined;
|
|
27
|
+
file?: import("../../../types/File.d.ts").File | undefined;
|
|
28
28
|
commentStyle?: "short" | "long" | "xml" | undefined;
|
|
29
|
-
formatting?: import("../../../types/File.ts").FormattingOptions | undefined;
|
|
30
|
-
options?: import("../../../types/Config.ts").Config | undefined;
|
|
29
|
+
formatting?: import("../../../types/File.d.ts").FormattingOptions | undefined;
|
|
30
|
+
options?: import("../../../types/Config.d.ts").Config | undefined;
|
|
31
31
|
}): Promise<string>;
|
|
32
|
-
export type File = import("../../../types/File.ts").File;
|
|
33
|
-
export type FileHeader = import("../../../types/File.ts").FileHeader;
|
|
34
|
-
export type Formatting = import("../../../types/File.ts").FormattingOptions;
|
|
35
|
-
export type Config = import("../../../types/Config.ts").Config;
|
|
32
|
+
export type File = import("../../../types/File.d.ts").File;
|
|
33
|
+
export type FileHeader = import("../../../types/File.d.ts").FileHeader;
|
|
34
|
+
export type Formatting = import("../../../types/File.d.ts").FormattingOptions;
|
|
35
|
+
export type Config = import("../../../types/Config.d.ts").Config;
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
*
|
|
16
|
-
* @typedef {import('../../../types/File.ts').File} File
|
|
17
|
-
* @typedef {import('../../../types/File.ts').FileHeader} FileHeader
|
|
18
|
-
* @typedef {import('../../../types/File.ts').FormattingOptions} Formatting
|
|
19
|
-
* @typedef {import('../../../types/Config.ts').Config} Config
|
|
16
|
+
* @typedef {import('../../../types/File.d.ts').File} File
|
|
17
|
+
* @typedef {import('../../../types/File.d.ts').FileHeader} FileHeader
|
|
18
|
+
* @typedef {import('../../../types/File.d.ts').FormattingOptions} Formatting
|
|
19
|
+
* @typedef {import('../../../types/Config.d.ts').Config} Config
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
22
|
const lineSeparator = `\n`;
|
|
@@ -29,14 +29,14 @@
|
|
|
29
29
|
export default function formattedVariables({ format, dictionary, outputReferences, outputReferenceFallbacks, formatting, themeable, usesDtcg, }: {
|
|
30
30
|
format: string;
|
|
31
31
|
dictionary: Dictionary;
|
|
32
|
-
outputReferences?: import("../../../types/Format").OutputReferences | undefined;
|
|
32
|
+
outputReferences?: import("../../../types/Format.d.ts").OutputReferences | undefined;
|
|
33
33
|
outputReferenceFallbacks?: boolean | undefined;
|
|
34
|
-
formatting?: import("../../../types/File.ts").FormattingOptions | undefined;
|
|
34
|
+
formatting?: import("../../../types/File.d.ts").FormattingOptions | undefined;
|
|
35
35
|
themeable?: boolean | undefined;
|
|
36
36
|
usesDtcg?: boolean | undefined;
|
|
37
37
|
}): string;
|
|
38
|
-
export type Token = import("../../../types/DesignToken.ts").TransformedToken;
|
|
39
|
-
export type Tokens = import("../../../types/DesignToken.ts").TransformedTokens;
|
|
40
|
-
export type Formatting = import("../../../types/File.ts").FormattingOptions;
|
|
41
|
-
export type OutputReferences = import("../../../types/Format").OutputReferences;
|
|
42
|
-
export type Dictionary = import("../../../types/DesignToken.ts").Dictionary;
|
|
38
|
+
export type Token = import("../../../types/DesignToken.d.ts").TransformedToken;
|
|
39
|
+
export type Tokens = import("../../../types/DesignToken.d.ts").TransformedTokens;
|
|
40
|
+
export type Formatting = import("../../../types/File.d.ts").FormattingOptions;
|
|
41
|
+
export type OutputReferences = import("../../../types/Format.d.ts").OutputReferences;
|
|
42
|
+
export type Dictionary = import("../../../types/DesignToken.d.ts").Dictionary;
|
|
@@ -15,11 +15,11 @@ import createPropertyFormatter from './createPropertyFormatter.js';
|
|
|
15
15
|
import sortByReference from './sortByReference.js';
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
* @typedef {import('../../../types/DesignToken.ts').TransformedToken} Token
|
|
19
|
-
* @typedef {import('../../../types/DesignToken.ts').TransformedTokens} Tokens
|
|
20
|
-
* @typedef {import('../../../types/File.ts').FormattingOptions} Formatting
|
|
21
|
-
* @typedef {import('../../../types/Format').OutputReferences} OutputReferences
|
|
22
|
-
* @typedef {import('../../../types/DesignToken.ts').Dictionary} Dictionary
|
|
18
|
+
* @typedef {import('../../../types/DesignToken.d.ts').TransformedToken} Token
|
|
19
|
+
* @typedef {import('../../../types/DesignToken.d.ts').TransformedTokens} Tokens
|
|
20
|
+
* @typedef {import('../../../types/File.d.ts').FormattingOptions} Formatting
|
|
21
|
+
* @typedef {import('../../../types/Format.d.ts').OutputReferences} OutputReferences
|
|
22
|
+
* @typedef {import('../../../types/DesignToken.d.ts').Dictionary} Dictionary
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
const defaultFormatting = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef {import('../../../types/Config.ts').LocalOptions} Options
|
|
3
|
-
* @typedef {import('../../../types/Config.ts').Config} Config
|
|
2
|
+
* @typedef {import('../../../types/Config.d.ts').LocalOptions} Options
|
|
3
|
+
* @typedef {import('../../../types/Config.d.ts').Config} Config
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* Given some value, returns a basic valid TypeScript type for that value.
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
* @return {String} A valid name for a TypeScript type.
|
|
28
28
|
*
|
|
29
29
|
*/
|
|
30
|
-
export default function getTypeScriptType(value: any, options?: (import("../../../types/Config.ts").Config & {
|
|
30
|
+
export default function getTypeScriptType(value: any, options?: (import("../../../types/Config.d.ts").Config & {
|
|
31
31
|
outputStringLiterals?: boolean;
|
|
32
32
|
}) | undefined): string;
|
|
33
|
-
export type Options = import("../../../types/Config.ts").LocalOptions;
|
|
34
|
-
export type Config = import("../../../types/Config.ts").Config;
|
|
33
|
+
export type Options = import("../../../types/Config.d.ts").LocalOptions;
|
|
34
|
+
export type Config = import("../../../types/Config.d.ts").Config;
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* @typedef {import('../../../types/Config.ts').LocalOptions} Options
|
|
16
|
-
* @typedef {import('../../../types/Config.ts').Config} Config
|
|
15
|
+
* @typedef {import('../../../types/Config.d.ts').LocalOptions} Options
|
|
16
|
+
* @typedef {import('../../../types/Config.d.ts').Config} Config
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef {import('../../../types/DesignToken.ts').TransformedToken} Token
|
|
3
|
-
* @typedef {import('../../../types/Config.ts').Config} Options
|
|
4
|
-
* @typedef {import('../../../types/Config.ts').PlatformConfig} PlatformConfig
|
|
2
|
+
* @typedef {import('../../../types/DesignToken.d.ts').TransformedToken} Token
|
|
3
|
+
* @typedef {import('../../../types/Config.d.ts').Config} Options
|
|
4
|
+
* @typedef {import('../../../types/Config.d.ts').PlatformConfig} PlatformConfig
|
|
5
5
|
*/
|
|
6
6
|
/**
|
|
7
7
|
*
|
|
@@ -27,6 +27,6 @@
|
|
|
27
27
|
* ```
|
|
28
28
|
*/
|
|
29
29
|
export default function iconsWithPrefix(prefix: string, allTokens: Token[], options: Options, platform: PlatformConfig): string;
|
|
30
|
-
export type Token = import("../../../types/DesignToken.ts").TransformedToken;
|
|
31
|
-
export type Options = import("../../../types/Config.ts").Config;
|
|
32
|
-
export type PlatformConfig = import("../../../types/Config.ts").PlatformConfig;
|
|
30
|
+
export type Token = import("../../../types/DesignToken.d.ts").TransformedToken;
|
|
31
|
+
export type Options = import("../../../types/Config.d.ts").Config;
|
|
32
|
+
export type PlatformConfig = import("../../../types/Config.d.ts").PlatformConfig;
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* @typedef {import('../../../types/DesignToken.ts').TransformedToken} Token
|
|
16
|
-
* @typedef {import('../../../types/Config.ts').Config} Options
|
|
17
|
-
* @typedef {import('../../../types/Config.ts').PlatformConfig} PlatformConfig
|
|
15
|
+
* @typedef {import('../../../types/DesignToken.d.ts').TransformedToken} Token
|
|
16
|
+
* @typedef {import('../../../types/Config.d.ts').Config} Options
|
|
17
|
+
* @typedef {import('../../../types/Config.d.ts').PlatformConfig} PlatformConfig
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef {import('../../../types/DesignToken.ts').TransformedTokens} Tokens
|
|
2
|
+
* @typedef {import('../../../types/DesignToken.d.ts').TransformedTokens} Tokens
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
5
|
* Outputs an object stripping out everything except values
|
|
@@ -19,4 +19,4 @@
|
|
|
19
19
|
* ```
|
|
20
20
|
*/
|
|
21
21
|
export default function minifyDictionary(obj: Tokens, usesDtcg?: boolean | undefined): Tokens;
|
|
22
|
-
export type Tokens = import("../../../types/DesignToken.ts").TransformedTokens;
|
|
22
|
+
export type Tokens = import("../../../types/DesignToken.d.ts").TransformedTokens;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef {import('../../../types/Config.ts').LocalOptions} Options
|
|
2
|
+
* @typedef {import('../../../types/Config.d.ts').LocalOptions} Options
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
5
|
* Outputs an object for compose format configurations. Sets import.
|
|
@@ -11,4 +11,4 @@
|
|
|
11
11
|
export default function setComposeObjectProperties(options?: {
|
|
12
12
|
import?: string[];
|
|
13
13
|
} | undefined): Object;
|
|
14
|
-
export type Options = import("../../../types/Config.ts").LocalOptions;
|
|
14
|
+
export type Options = import("../../../types/Config.d.ts").LocalOptions;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef {import('../../../types/Config.ts').LocalOptions} Options
|
|
2
|
+
* @typedef {import('../../../types/Config.d.ts').LocalOptions} Options
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
5
|
* Outputs an object with swift format configurations. Sets import, object type and access control.
|
|
@@ -18,4 +18,4 @@ export default function setSwiftFileProperties(options: {
|
|
|
18
18
|
import?: string[];
|
|
19
19
|
accessControl?: string;
|
|
20
20
|
};
|
|
21
|
-
export type Options = import("../../../types/Config.ts").LocalOptions;
|
|
21
|
+
export type Options = import("../../../types/Config.d.ts").LocalOptions;
|
|
@@ -17,5 +17,5 @@ export default function sortByReference(tokens: Tokens, { unfilteredTokens, uses
|
|
|
17
17
|
unfilteredTokens?: Tokens;
|
|
18
18
|
usesDtcg?: boolean;
|
|
19
19
|
} | undefined): (a: Token, b: Token) => number;
|
|
20
|
-
export type Tokens = import("../../../types/DesignToken.ts").TransformedTokens;
|
|
21
|
-
export type Token = import("../../../types/DesignToken.ts").TransformedToken;
|
|
20
|
+
export type Tokens = import("../../../types/DesignToken.d.ts").TransformedTokens;
|
|
21
|
+
export type Token = import("../../../types/DesignToken.d.ts").TransformedToken;
|
|
@@ -15,8 +15,8 @@ import usesReferences from '../../utils/references/usesReferences.js';
|
|
|
15
15
|
import { getReferences } from '../../utils/references/getReferences.js';
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
* @typedef {import('../../../types/DesignToken.ts').TransformedTokens} Tokens
|
|
19
|
-
* @typedef {import('../../../types/DesignToken.ts').TransformedToken} Token
|
|
18
|
+
* @typedef {import('../../../types/DesignToken.d.ts').TransformedTokens} Tokens
|
|
19
|
+
* @typedef {import('../../../types/DesignToken.d.ts').TransformedToken} Token
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
22
|
const A_COMES_FIRST = -1;
|
package/lib/common/formats.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
export default formats;
|
|
2
|
-
export type Format = import("../../types/Format.ts").Format;
|
|
3
|
-
export type FormatArgs = import("../../types/Format.ts").FormatFnArguments;
|
|
4
|
-
export type FormattingOverrides = import("../../types/File").FormattingOverrides;
|
|
5
|
-
export type OutputReferences = import("../../types/Format.ts").OutputReferences;
|
|
6
|
-
export type Token = import("../../types/DesignToken.ts").TransformedToken;
|
|
7
|
-
export type Tokens = import("../../types/DesignToken.ts").TransformedTokens;
|
|
2
|
+
export type Format = import("../../types/Format.d.ts").Format;
|
|
3
|
+
export type FormatArgs = import("../../types/Format.d.ts").FormatFnArguments;
|
|
4
|
+
export type FormattingOverrides = import("../../types/File.d.ts").FormattingOverrides;
|
|
5
|
+
export type OutputReferences = import("../../types/Format.d.ts").OutputReferences;
|
|
6
|
+
export type Token = import("../../types/DesignToken.d.ts").TransformedToken;
|
|
7
|
+
export type Tokens = import("../../types/DesignToken.d.ts").TransformedTokens;
|
|
8
|
+
export type Config = import("../../types/Config.d.ts").Config;
|
|
9
|
+
export type LocalOptions = import("../../types/Config.d.ts").LocalOptions;
|
|
10
|
+
export type StripMetaOptions = import("../utils/stripMeta.js").StripMetaOptions;
|
|
8
11
|
/**
|
|
9
12
|
* @type {Record<string, Format['format']>}
|
|
10
13
|
*/
|
package/lib/common/formats.js
CHANGED
|
@@ -10,6 +10,11 @@
|
|
|
10
10
|
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
|
|
11
11
|
* and limitations under the License.
|
|
12
12
|
*/
|
|
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';
|
|
17
|
+
|
|
13
18
|
import {
|
|
14
19
|
fileHeader,
|
|
15
20
|
formattedVariables,
|
|
@@ -23,6 +28,8 @@ import {
|
|
|
23
28
|
setComposeObjectProperties,
|
|
24
29
|
} from './formatHelpers/index.js';
|
|
25
30
|
|
|
31
|
+
import { stripMeta as stripMetaUtil } from '../utils/stripMeta.js';
|
|
32
|
+
|
|
26
33
|
import androidColors from './templates/android/colors.template.js';
|
|
27
34
|
import androidDimens from './templates/android/dimens.template.js';
|
|
28
35
|
import androidFontDimens from './templates/android/fontDimens.template.js';
|
|
@@ -47,18 +54,58 @@ import macrosTemplate from './templates/ios/macros.template.js';
|
|
|
47
54
|
import plistTemplate from './templates/ios/plist.template.js';
|
|
48
55
|
|
|
49
56
|
/**
|
|
50
|
-
* @typedef {import('../../types/Format.ts').Format} Format
|
|
51
|
-
* @typedef {import('../../types/Format.ts').FormatFnArguments} FormatArgs
|
|
52
|
-
* @typedef {import('../../types/File').FormattingOverrides} FormattingOverrides
|
|
53
|
-
* @typedef {import('../../types/Format.ts').OutputReferences} OutputReferences
|
|
54
|
-
* @typedef {import('../../types/DesignToken.ts').TransformedToken} Token
|
|
55
|
-
* @typedef {import('../../types/DesignToken.ts').TransformedTokens} Tokens
|
|
57
|
+
* @typedef {import('../../types/Format.d.ts').Format} Format
|
|
58
|
+
* @typedef {import('../../types/Format.d.ts').FormatFnArguments} FormatArgs
|
|
59
|
+
* @typedef {import('../../types/File.d.ts').FormattingOverrides} FormattingOverrides
|
|
60
|
+
* @typedef {import('../../types/Format.d.ts').OutputReferences} OutputReferences
|
|
61
|
+
* @typedef {import('../../types/DesignToken.d.ts').TransformedToken} Token
|
|
62
|
+
* @typedef {import('../../types/DesignToken.d.ts').TransformedTokens} Tokens
|
|
63
|
+
* @typedef {import('../../types/Config.d.ts').Config} Config
|
|
64
|
+
* @typedef {import('../../types/Config.d.ts').LocalOptions} LocalOptions
|
|
65
|
+
* @typedef {import('../utils/stripMeta.js').StripMetaOptions} StripMetaOptions
|
|
56
66
|
*/
|
|
57
67
|
|
|
58
68
|
/**
|
|
59
69
|
* @namespace Formats
|
|
60
70
|
*/
|
|
61
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Strip meta properties from tokens object
|
|
74
|
+
*
|
|
75
|
+
* @param {Tokens} tokens
|
|
76
|
+
* @param {Config & LocalOptions & { stripMeta: boolean | StripMetaOptions}} options
|
|
77
|
+
*/
|
|
78
|
+
function stripMetaProps(tokens, options) {
|
|
79
|
+
const sdMetaProps = ['attributes', 'filePath', 'name', 'path', 'comment'];
|
|
80
|
+
const { stripMeta, usesDtcg } = options;
|
|
81
|
+
let opts = /** @type {StripMetaOptions} */ ({ usesDtcg });
|
|
82
|
+
|
|
83
|
+
if (stripMeta) {
|
|
84
|
+
if (stripMeta === true) {
|
|
85
|
+
opts.strip = sdMetaProps;
|
|
86
|
+
} else {
|
|
87
|
+
opts = {
|
|
88
|
+
usesDtcg: usesDtcg ?? false,
|
|
89
|
+
...stripMeta,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
tokens = stripMetaUtil(tokens, opts);
|
|
93
|
+
}
|
|
94
|
+
return tokens;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Prettier format JS contents
|
|
99
|
+
* @param {string} content
|
|
100
|
+
* @param {boolean} [ts] whether or not to use typescript
|
|
101
|
+
*/
|
|
102
|
+
async function formatJS(content, ts = false) {
|
|
103
|
+
return prettier.format(content, {
|
|
104
|
+
parser: ts ? `typescript` : `babel`,
|
|
105
|
+
plugins: [prettierPluginBabel, prettierPluginEstree, prettierPluginTypescript],
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
62
109
|
/**
|
|
63
110
|
* Remove prefix because the prefix option for createPropertyFormatter
|
|
64
111
|
* is not the same as the prefix inside header comment
|
|
@@ -343,7 +390,9 @@ const formats = {
|
|
|
343
390
|
formatting: getFormattingCloneWithoutPrefix(formatting),
|
|
344
391
|
options,
|
|
345
392
|
});
|
|
346
|
-
|
|
393
|
+
const content =
|
|
394
|
+
header + 'module.exports = ' + JSON.stringify(dictionary.tokens, null, 2) + ';\n';
|
|
395
|
+
return formatJS(content);
|
|
347
396
|
},
|
|
348
397
|
|
|
349
398
|
/**
|
|
@@ -365,7 +414,7 @@ const formats = {
|
|
|
365
414
|
formatting: getFormattingCloneWithoutPrefix(formatting),
|
|
366
415
|
options,
|
|
367
416
|
});
|
|
368
|
-
|
|
417
|
+
const content =
|
|
369
418
|
header +
|
|
370
419
|
'module.exports = ' +
|
|
371
420
|
'{\n' +
|
|
@@ -377,8 +426,8 @@ const formats = {
|
|
|
377
426
|
})
|
|
378
427
|
.join(',\n') +
|
|
379
428
|
'\n}' +
|
|
380
|
-
';\n'
|
|
381
|
-
);
|
|
429
|
+
';\n';
|
|
430
|
+
return formatJS(content);
|
|
382
431
|
},
|
|
383
432
|
|
|
384
433
|
/**
|
|
@@ -407,14 +456,14 @@ const formats = {
|
|
|
407
456
|
formatting: getFormattingCloneWithoutPrefix(formatting),
|
|
408
457
|
options,
|
|
409
458
|
});
|
|
410
|
-
|
|
459
|
+
const content =
|
|
411
460
|
header +
|
|
412
461
|
'var ' +
|
|
413
462
|
(file.options?.name || '_styleDictionary') +
|
|
414
463
|
' = ' +
|
|
415
464
|
JSON.stringify(dictionary.tokens, null, 2) +
|
|
416
|
-
';\n'
|
|
417
|
-
);
|
|
465
|
+
';\n';
|
|
466
|
+
return formatJS(content);
|
|
418
467
|
},
|
|
419
468
|
|
|
420
469
|
/**
|
|
@@ -455,7 +504,7 @@ const formats = {
|
|
|
455
504
|
formatting: getFormattingCloneWithoutPrefix(formatting),
|
|
456
505
|
options,
|
|
457
506
|
});
|
|
458
|
-
|
|
507
|
+
const content =
|
|
459
508
|
header +
|
|
460
509
|
'(function(root, factory) {\n' +
|
|
461
510
|
' if (typeof module === "object" && module.exports) {\n' +
|
|
@@ -475,8 +524,8 @@ const formats = {
|
|
|
475
524
|
' return ' +
|
|
476
525
|
JSON.stringify(dictionary.tokens, null, 2) +
|
|
477
526
|
';\n' +
|
|
478
|
-
'}))\n'
|
|
479
|
-
);
|
|
527
|
+
'}))\n';
|
|
528
|
+
return formatJS(content);
|
|
480
529
|
},
|
|
481
530
|
|
|
482
531
|
/**
|
|
@@ -516,7 +565,7 @@ const formats = {
|
|
|
516
565
|
formatting: getFormattingCloneWithoutPrefix(formatting),
|
|
517
566
|
options,
|
|
518
567
|
});
|
|
519
|
-
|
|
568
|
+
const content =
|
|
520
569
|
header +
|
|
521
570
|
dictionary.allTokens
|
|
522
571
|
.map(function (token) {
|
|
@@ -530,8 +579,48 @@ const formats = {
|
|
|
530
579
|
return to_ret;
|
|
531
580
|
})
|
|
532
581
|
.join('\n') +
|
|
533
|
-
'\n'
|
|
582
|
+
'\n';
|
|
583
|
+
return formatJS(content);
|
|
584
|
+
},
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* Creates a ES6 module with the whole style dictionary
|
|
588
|
+
*
|
|
589
|
+
* @memberof Formats
|
|
590
|
+
* @kind member
|
|
591
|
+
* @example
|
|
592
|
+
* ```js
|
|
593
|
+
* export default {
|
|
594
|
+
* "color": {
|
|
595
|
+
* "base": {
|
|
596
|
+
* "red": "#ff0000"
|
|
597
|
+
* }
|
|
598
|
+
* }
|
|
599
|
+
* }
|
|
600
|
+
* ```
|
|
601
|
+
*/
|
|
602
|
+
'javascript/esm': async function ({ dictionary, file, options }) {
|
|
603
|
+
const { formatting, minify = false } = options;
|
|
604
|
+
let { tokens } = dictionary;
|
|
605
|
+
tokens = stripMetaProps(
|
|
606
|
+
tokens,
|
|
607
|
+
/** @type {LocalOptions & Config & { stripMeta: boolean | StripMetaOptions}} */ (options),
|
|
608
|
+
);
|
|
609
|
+
|
|
610
|
+
const header = await fileHeader({
|
|
611
|
+
file,
|
|
612
|
+
formatting: getFormattingCloneWithoutPrefix(formatting),
|
|
613
|
+
options,
|
|
614
|
+
});
|
|
615
|
+
|
|
616
|
+
const dictionaryString = JSON.stringify(
|
|
617
|
+
minify ? minifyDictionary(tokens, options.usesDtcg) : tokens,
|
|
618
|
+
null,
|
|
619
|
+
2,
|
|
534
620
|
);
|
|
621
|
+
|
|
622
|
+
const content = `${header}export default ${dictionaryString};\n`;
|
|
623
|
+
return formatJS(content);
|
|
535
624
|
},
|
|
536
625
|
|
|
537
626
|
// TypeScript declarations
|
|
@@ -573,7 +662,7 @@ const formats = {
|
|
|
573
662
|
formatting: getFormattingCloneWithoutPrefix(formatting),
|
|
574
663
|
options,
|
|
575
664
|
});
|
|
576
|
-
|
|
665
|
+
const content =
|
|
577
666
|
header +
|
|
578
667
|
dictionary.allTokens
|
|
579
668
|
.map(function (token) {
|
|
@@ -588,8 +677,8 @@ const formats = {
|
|
|
588
677
|
return to_ret_token;
|
|
589
678
|
})
|
|
590
679
|
.join('\n') +
|
|
591
|
-
'\n'
|
|
592
|
-
);
|
|
680
|
+
'\n';
|
|
681
|
+
return formatJS(content, true);
|
|
593
682
|
},
|
|
594
683
|
|
|
595
684
|
/**
|
|
@@ -668,7 +757,7 @@ const formats = {
|
|
|
668
757
|
return type;
|
|
669
758
|
}
|
|
670
759
|
|
|
671
|
-
// TODO: find a browser+node compatible way to read from '../../types/DesignToken.ts'
|
|
760
|
+
// TODO: find a browser+node compatible way to read from '../../types/DesignToken.d.ts'
|
|
672
761
|
const designTokenInterface = `interface DesignToken {
|
|
673
762
|
${options.usesDtcg ? '$' : ''}value?: any;
|
|
674
763
|
${options.usesDtcg ? '$' : ''}type?: string;
|
|
@@ -695,7 +784,8 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
|
|
|
695
784
|
|
|
696
785
|
// JSON stringify will quote strings, because this is a type we need
|
|
697
786
|
// it unquoted.
|
|
698
|
-
|
|
787
|
+
const content = output.replace(/"DesignToken"/g, 'DesignToken') + '\n';
|
|
788
|
+
return formatJS(content, true);
|
|
699
789
|
},
|
|
700
790
|
|
|
701
791
|
// Android templates
|
|
@@ -1341,8 +1431,13 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
|
|
|
1341
1431
|
* }
|
|
1342
1432
|
* ```
|
|
1343
1433
|
*/
|
|
1344
|
-
json: function ({ dictionary }) {
|
|
1345
|
-
|
|
1434
|
+
json: function ({ dictionary, options }) {
|
|
1435
|
+
let { tokens } = dictionary;
|
|
1436
|
+
tokens = stripMetaProps(
|
|
1437
|
+
tokens,
|
|
1438
|
+
/** @type {LocalOptions & Config & { stripMeta: boolean | StripMetaOptions}} */ (options),
|
|
1439
|
+
);
|
|
1440
|
+
return JSON.stringify(tokens, null, 2) + '\n';
|
|
1346
1441
|
},
|
|
1347
1442
|
|
|
1348
1443
|
/**
|
|
@@ -1369,7 +1464,6 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
|
|
|
1369
1464
|
|
|
1370
1465
|
/**
|
|
1371
1466
|
* Creates a JSON nested file of the style dictionary.
|
|
1372
|
-
*
|
|
1373
1467
|
* @memberof Formats
|
|
1374
1468
|
* @kind member
|
|
1375
1469
|
* @example
|
|
@@ -1538,5 +1632,6 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
|
|
|
1538
1632
|
formats['json/nested'].nested = true;
|
|
1539
1633
|
formats['javascript/module'].nested = true;
|
|
1540
1634
|
formats['javascript/object'].nested = true;
|
|
1635
|
+
formats['javascript/esm'].nested = true;
|
|
1541
1636
|
|
|
1542
1637
|
export default formats;
|
|
@@ -4,6 +4,6 @@ declare function _default({ dictionary, options, header }: {
|
|
|
4
4
|
header: string;
|
|
5
5
|
}): string;
|
|
6
6
|
export default _default;
|
|
7
|
-
export type Dictionary = import("../../../../types/DesignToken.ts").Dictionary;
|
|
8
|
-
export type Config = import("../../../../types/Config.ts").Config;
|
|
9
|
-
export type LocalOptions = import("../../../../types/Config.ts").LocalOptions;
|
|
7
|
+
export type Dictionary = import("../../../../types/DesignToken.d.ts").Dictionary;
|
|
8
|
+
export type Config = import("../../../../types/Config.d.ts").Config;
|
|
9
|
+
export type LocalOptions = import("../../../../types/Config.d.ts").LocalOptions;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef {import('../../../../types/DesignToken.ts').Dictionary} Dictionary
|
|
3
|
-
* @typedef {import('../../../../types/Config.ts').Config} Config
|
|
4
|
-
* @typedef {import('../../../../types/Config.ts').LocalOptions} LocalOptions
|
|
2
|
+
* @typedef {import('../../../../types/DesignToken.d.ts').Dictionary} Dictionary
|
|
3
|
+
* @typedef {import('../../../../types/Config.d.ts').Config} Config
|
|
4
|
+
* @typedef {import('../../../../types/Config.d.ts').LocalOptions} LocalOptions
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -4,6 +4,6 @@ declare function _default({ dictionary, options, header }: {
|
|
|
4
4
|
header: string;
|
|
5
5
|
}): string;
|
|
6
6
|
export default _default;
|
|
7
|
-
export type Dictionary = import("../../../../types/DesignToken.ts").Dictionary;
|
|
8
|
-
export type Config = import("../../../../types/Config.ts").Config;
|
|
9
|
-
export type LocalOptions = import("../../../../types/Config.ts").LocalOptions;
|
|
7
|
+
export type Dictionary = import("../../../../types/DesignToken.d.ts").Dictionary;
|
|
8
|
+
export type Config = import("../../../../types/Config.d.ts").Config;
|
|
9
|
+
export type LocalOptions = import("../../../../types/Config.d.ts").LocalOptions;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef {import('../../../../types/DesignToken.ts').Dictionary} Dictionary
|
|
3
|
-
* @typedef {import('../../../../types/Config.ts').Config} Config
|
|
4
|
-
* @typedef {import('../../../../types/Config.ts').LocalOptions} LocalOptions
|
|
2
|
+
* @typedef {import('../../../../types/DesignToken.d.ts').Dictionary} Dictionary
|
|
3
|
+
* @typedef {import('../../../../types/Config.d.ts').Config} Config
|
|
4
|
+
* @typedef {import('../../../../types/Config.d.ts').LocalOptions} LocalOptions
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -4,6 +4,6 @@ declare function _default({ dictionary, options, header }: {
|
|
|
4
4
|
header: string;
|
|
5
5
|
}): string;
|
|
6
6
|
export default _default;
|
|
7
|
-
export type Dictionary = import("../../../../types/DesignToken.ts").Dictionary;
|
|
8
|
-
export type Config = import("../../../../types/Config.ts").Config;
|
|
9
|
-
export type LocalOptions = import("../../../../types/Config.ts").LocalOptions;
|
|
7
|
+
export type Dictionary = import("../../../../types/DesignToken.d.ts").Dictionary;
|
|
8
|
+
export type Config = import("../../../../types/Config.d.ts").Config;
|
|
9
|
+
export type LocalOptions = import("../../../../types/Config.d.ts").LocalOptions;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef {import('../../../../types/DesignToken.ts').Dictionary} Dictionary
|
|
3
|
-
* @typedef {import('../../../../types/Config.ts').Config} Config
|
|
4
|
-
* @typedef {import('../../../../types/Config.ts').LocalOptions} LocalOptions
|
|
2
|
+
* @typedef {import('../../../../types/DesignToken.d.ts').Dictionary} Dictionary
|
|
3
|
+
* @typedef {import('../../../../types/Config.d.ts').Config} Config
|
|
4
|
+
* @typedef {import('../../../../types/Config.d.ts').LocalOptions} LocalOptions
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
/**
|