style-dictionary 5.4.4 → 5.5.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.
@@ -12,6 +12,6 @@
12
12
  "author": "",
13
13
  "license": "Apache-2.0",
14
14
  "devDependencies": {
15
- "style-dictionary": "^5.4.4"
15
+ "style-dictionary": "^5.5.0"
16
16
  }
17
17
  }
@@ -12,7 +12,7 @@
12
12
  },
13
13
  "devDependencies": {
14
14
  "eslint-config-react-app": "^7.0.1",
15
- "style-dictionary": "^5.4.4"
15
+ "style-dictionary": "^5.5.0"
16
16
  },
17
17
  "resolutions": {
18
18
  "immer": "8.0.1",
@@ -29,7 +29,7 @@
29
29
  "eslint-config-react-app": "^7.0.1",
30
30
  "jest": "~25.2.6",
31
31
  "react-test-renderer": "~16.13.1",
32
- "style-dictionary": "^5.4.4"
32
+ "style-dictionary": "^5.5.0"
33
33
  },
34
34
  "jest": {
35
35
  "preset": "react-native"
@@ -10,6 +10,6 @@
10
10
  "author": "",
11
11
  "license": "Apache-2.0",
12
12
  "devDependencies": {
13
- "style-dictionary": "^5.4.4"
13
+ "style-dictionary": "^5.5.0"
14
14
  }
15
15
  }
@@ -16,6 +16,6 @@
16
16
  "author": "",
17
17
  "license": "Apache-2.0",
18
18
  "devDependencies": {
19
- "style-dictionary": "^5.4.4"
19
+ "style-dictionary": "^5.5.0"
20
20
  }
21
21
  }
@@ -9,6 +9,6 @@
9
9
  },
10
10
  "license": "Apache-2.0",
11
11
  "devDependencies": {
12
- "style-dictionary": "^5.4.4"
12
+ "style-dictionary": "^5.5.0"
13
13
  }
14
14
  }
@@ -11,6 +11,6 @@
11
11
  "author": "",
12
12
  "license": "Apache-2.0",
13
13
  "devDependencies": {
14
- "style-dictionary": "^5.4.4"
14
+ "style-dictionary": "^5.5.0"
15
15
  }
16
16
  }
@@ -17,6 +17,6 @@
17
17
  "author": "Kelly Harrop <kn.harrop@gmail.com>",
18
18
  "license": "Apache-2.0",
19
19
  "devDependencies": {
20
- "style-dictionary": "^5.4.4"
20
+ "style-dictionary": "^5.5.0"
21
21
  }
22
22
  }
@@ -16,6 +16,6 @@
16
16
  "author": "",
17
17
  "license": "Apache-2.0",
18
18
  "devDependencies": {
19
- "style-dictionary": "^5.4.4"
19
+ "style-dictionary": "^5.5.0"
20
20
  }
21
21
  }
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "homepage": "https://github.com/dbanksdesign/style-dictionary-node#readme",
22
22
  "devDependencies": {
23
- "style-dictionary": "^5.4.4",
23
+ "style-dictionary": "^5.5.0",
24
24
  "tinycolor2": "^1.4.1"
25
25
  }
26
26
  }
@@ -17,6 +17,6 @@
17
17
  "author": "",
18
18
  "license": "Apache-2.0",
19
19
  "devDependencies": {
20
- "style-dictionary": "^5.4.4"
20
+ "style-dictionary": "^5.5.0"
21
21
  }
22
22
  }
@@ -16,6 +16,6 @@
16
16
  "author": "",
17
17
  "license": "Apache-2.0",
18
18
  "devDependencies": {
19
- "style-dictionary": "^5.4.4"
19
+ "style-dictionary": "^5.5.0"
20
20
  }
21
21
  }
@@ -16,6 +16,6 @@
16
16
  "devDependencies": {
17
17
  "aws-sdk": "^2.7.21",
18
18
  "fs-extra": "^1.0.0",
19
- "style-dictionary": "^5.4.4"
19
+ "style-dictionary": "^5.5.0"
20
20
  }
21
21
  }
@@ -10,7 +10,7 @@
10
10
  },
11
11
  "license": "Apache-2.0",
12
12
  "devDependencies": {
13
- "style-dictionary": "^5.4.4",
13
+ "style-dictionary": "^5.5.0",
14
14
  "tailwindcss": "^3.4.15",
15
15
  "mocha": "^10.2.0",
16
16
  "chai": "^5.1.1"
@@ -16,6 +16,6 @@
16
16
  "author": "",
17
17
  "license": "Apache-2.0",
18
18
  "devDependencies": {
19
- "style-dictionary": "^5.4.4"
19
+ "style-dictionary": "^5.5.0"
20
20
  }
21
21
  }
@@ -12,6 +12,6 @@
12
12
  "license": "ISC",
13
13
  "devDependencies": {
14
14
  "colorjs.io": "^0.5.2",
15
- "style-dictionary": "^5.4.4"
15
+ "style-dictionary": "^5.5.0"
16
16
  }
17
17
  }
@@ -11,6 +11,6 @@
11
11
  "author": "",
12
12
  "license": "MIT",
13
13
  "devDependencies": {
14
- "style-dictionary": "^5.4.4"
14
+ "style-dictionary": "^5.5.0"
15
15
  }
16
16
  }
@@ -10,7 +10,7 @@
10
10
  "author": "",
11
11
  "license": "Apache-2.0",
12
12
  "devDependencies": {
13
- "style-dictionary": "^5.4.4",
13
+ "style-dictionary": "^5.5.0",
14
14
  "yaml": "^1.10.0"
15
15
  }
16
16
  }
@@ -67,7 +67,7 @@ export default class StyleDictionary extends Register {
67
67
  // Placeholder is transformed on prepublish -> see scripts/inject-version.js
68
68
  // Another option might be import pkg from './package.json' with { "type": "json" } which would work in both browser and node, but support is not there yet.
69
69
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#browser_compatibility
70
- static VERSION = '5.4.4';
70
+ static VERSION = '5.5.0';
71
71
 
72
72
  /** @returns {Config} */
73
73
  get options() {
@@ -646,6 +646,7 @@ export default class StyleDictionary extends Register {
646
646
  const { destination } = file || {};
647
647
  const filter = /** @type {Filter['filter']|undefined} */ (file.filter);
648
648
  let { format } = file || {};
649
+ const emitEmptyFiles = file.emitEmptyFiles ?? platform.emitEmptyFiles ?? false;
649
650
 
650
651
  if (typeof format !== 'function') throw new Error('Please enter a valid file format');
651
652
  if (destination !== undefined && typeof destination !== 'string')
@@ -677,6 +678,7 @@ export default class StyleDictionary extends Register {
677
678
 
678
679
  // if tokens object is empty, return without creating a file
679
680
  if (
681
+ !emitEmptyFiles &&
680
682
  Object.hasOwn(filteredTokens, 'tokens') &&
681
683
  Object.keys(filteredTokens.tokens).length === 0 &&
682
684
  filteredTokens.tokens.constructor === Object
@@ -38,13 +38,13 @@ export function isColor(token: Token, options: Config): boolean;
38
38
  * Note: the result could contain a unitless dimension
39
39
  * Historically in Style Dictionary, number tokens were defined as unitless dimension tokens
40
40
  * We can `deprecated` this and remove that in a breaking change, forcing users to change them to number tokens
41
- * @param {Token['value']} val
41
+ * @param {Token['value']} _val
42
42
  *
43
43
  * unit can be undefined for this utility method as well to support old dimension token values
44
44
  * which can be defined as unitless dimension tokens or numbers
45
45
  * @returns {{ value: string | number; unit: TokenTypeDimensionUnit | undefined }}
46
46
  */
47
- export function getTokenDimensionValue(val: Token["value"]): {
47
+ export function getTokenDimensionValue(_val: Token["value"]): {
48
48
  value: string | number;
49
49
  unit: TokenTypeDimensionUnit | undefined;
50
50
  };
@@ -381,13 +381,14 @@ function transformCubicBezierCSS(token, options) {
381
381
  * Note: the result could contain a unitless dimension
382
382
  * Historically in Style Dictionary, number tokens were defined as unitless dimension tokens
383
383
  * We can `deprecated` this and remove that in a breaking change, forcing users to change them to number tokens
384
- * @param {Token['value']} val
384
+ * @param {Token['value']} _val
385
385
  *
386
386
  * unit can be undefined for this utility method as well to support old dimension token values
387
387
  * which can be defined as unitless dimension tokens or numbers
388
388
  * @returns {{ value: string | number; unit: TokenTypeDimensionUnit | undefined }}
389
389
  */
390
- export function getTokenDimensionValue(val) {
390
+ export function getTokenDimensionValue(_val) {
391
+ let val = _val;
391
392
  /** @type {TokenTypeDimensionUnit | undefined} */
392
393
  let unit;
393
394
  const valueObj = typeof val === 'object' && !Array.isArray(val) && val !== null;
@@ -396,9 +397,14 @@ export function getTokenDimensionValue(val) {
396
397
  if (!valueObj) {
397
398
  // if it contains a unit -> split it into unit and val
398
399
  const unitMatch = `${val}`.match(/[^0-9.-]+$/);
399
- if (unitMatch) {
400
+
401
+ // try to get the value already without unit
402
+ const valWithoutUnit = `${val}`.replace(unitMatch?.[0] ?? '', '');
403
+
404
+ // guard that we can actually parse the value as a number
405
+ if (unitMatch && !Number.isNaN(parseFloat(valWithoutUnit))) {
400
406
  unit = /** @type {TokenTypeDimensionUnit} */ (unitMatch[0]);
401
- val = val.replace(unit, '');
407
+ val = valWithoutUnit;
402
408
  }
403
409
  }
404
410
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "style-dictionary",
3
- "version": "5.4.4",
3
+ "version": "5.5.0",
4
4
  "description": "Style once, use everywhere. A build system for creating cross-platform styles.",
5
5
  "keywords": [
6
6
  "style dictionary",
@@ -45,7 +45,7 @@
45
45
  "scripts": {
46
46
  "build": "node scripts/inject-version.js && tsc --emitDeclarationOnly",
47
47
  "docs:start": "astro dev --root ./docs",
48
- "docs:build": "astro check --root ./docs && astro build --root ./docs",
48
+ "docs:build": "astro check --root ./docs && astro build --root ./docs",
49
49
  "docs:preview": "astro preview --root ./docs",
50
50
  "format": "run-p format:*",
51
51
  "format:eslint": "eslint --fix \"**/*.js\"",
@@ -112,7 +112,11 @@
112
112
  ],
113
113
  "homepage": "https://styledictionary.com",
114
114
  "overrides": {
115
- "lodash": "4.17.23"
115
+ "esbuild": "^0.28.1",
116
+ "js-yaml": "^4.2.0",
117
+ "lodash": "^4.17.23",
118
+ "volar-service-yaml": "0.0.71",
119
+ "ws": "^8.21.0"
116
120
  },
117
121
  "dependencies": {
118
122
  "@bundled-es-modules/deepmerge": "^4.3.2",
@@ -148,7 +152,7 @@
148
152
  "@web/test-runner-commands": "^0.9.0",
149
153
  "@web/test-runner-playwright": "^0.11.0",
150
154
  "acorn": "^8.11.3",
151
- "astro": "^6.3.3",
155
+ "astro": "^6.4.8",
152
156
  "chai": "^6.2.2",
153
157
  "eslint": "^9.19.0",
154
158
  "eslint-plugin-mocha": "^10.5.0",
package/types/Config.d.ts CHANGED
@@ -76,6 +76,7 @@ export interface PlatformConfig {
76
76
  preprocessors?: string[];
77
77
  prefix?: string;
78
78
  buildPath?: string;
79
+ emitEmptyFiles?: boolean;
79
80
  files?: File[];
80
81
  actions?: string[] | Omit<Action, 'name'>[];
81
82
  options?: LocalOptions;
package/types/File.d.ts CHANGED
@@ -24,6 +24,7 @@ export interface File {
24
24
  destination?: string;
25
25
  format?: string | FormatFn;
26
26
  filter?: string | Partial<TransformedToken> | Filter['filter'];
27
+ emitEmptyFiles?: boolean;
27
28
  options?: LocalOptions;
28
29
  }
29
30
  export {};