style-dictionary 5.4.0 → 5.4.2

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 (28) 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-app/src/serviceWorker.js +4 -4
  4. package/examples/advanced/create-react-native-app/package.json +1 -1
  5. package/examples/advanced/custom-parser/package.json +1 -1
  6. package/examples/advanced/custom-transforms/package.json +1 -1
  7. package/examples/advanced/font-face-rules/package.json +1 -1
  8. package/examples/advanced/format-helpers/package.json +1 -1
  9. package/examples/advanced/matching-build-files/package.json +1 -1
  10. package/examples/advanced/multi-brand-multi-platform/package.json +1 -1
  11. package/examples/advanced/node-modules-as-config-and-properties/package-lock.json +3 -3
  12. package/examples/advanced/node-modules-as-config-and-properties/package.json +1 -1
  13. package/examples/advanced/npm-module/package.json +1 -1
  14. package/examples/advanced/referencing_aliasing/package.json +1 -1
  15. package/examples/advanced/s3/package.json +1 -1
  16. package/examples/advanced/tailwind-preset/package.json +1 -1
  17. package/examples/advanced/tokens-deprecation/package.json +1 -1
  18. package/examples/advanced/transitive-transforms/package.json +1 -1
  19. package/examples/advanced/variables-in-outputs/package.json +1 -1
  20. package/examples/advanced/yaml-tokens/package.json +1 -1
  21. package/examples/basic/tokens/object-values.json +1 -1
  22. package/lib/StyleDictionary.js +1 -1
  23. package/lib/common/transforms.d.ts +4 -4
  24. package/lib/common/transforms.js +7 -5
  25. package/lib/utils/convertToBase64.js +5 -3
  26. package/lib/utils/convertToDTCG.d.ts +1 -1
  27. package/lib/utils/convertToDTCG.js +2 -2
  28. package/package.json +7 -7
@@ -12,6 +12,6 @@
12
12
  "author": "",
13
13
  "license": "Apache-2.0",
14
14
  "devDependencies": {
15
- "style-dictionary": "^5.4.0"
15
+ "style-dictionary": "^5.4.2"
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.0"
15
+ "style-dictionary": "^5.4.2"
16
16
  },
17
17
  "resolutions": {
18
18
  "immer": "8.0.1",
@@ -12,10 +12,10 @@
12
12
 
13
13
  const isLocalhost = Boolean(
14
14
  window.location.hostname === 'localhost' ||
15
- // [::1] is the IPv6 localhost address.
16
- window.location.hostname === '[::1]' ||
17
- // 127.0.0.1/8 is considered localhost for IPv4.
18
- window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/),
15
+ // [::1] is the IPv6 localhost address.
16
+ window.location.hostname === '[::1]' ||
17
+ // 127.0.0.1/8 is considered localhost for IPv4.
18
+ window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/),
19
19
  );
20
20
 
21
21
  export function register(config) {
@@ -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.0"
32
+ "style-dictionary": "^5.4.2"
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.0"
13
+ "style-dictionary": "^5.4.2"
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.0"
19
+ "style-dictionary": "^5.4.2"
20
20
  }
21
21
  }
@@ -9,6 +9,6 @@
9
9
  },
10
10
  "license": "Apache-2.0",
11
11
  "devDependencies": {
12
- "style-dictionary": "^5.4.0"
12
+ "style-dictionary": "^5.4.2"
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.0"
14
+ "style-dictionary": "^5.4.2"
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.0"
20
+ "style-dictionary": "^5.4.2"
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.0"
19
+ "style-dictionary": "^5.4.2"
20
20
  }
21
21
  }
@@ -1125,9 +1125,9 @@
1125
1125
  "license": "MIT"
1126
1126
  },
1127
1127
  "node_modules/qs": {
1128
- "version": "6.14.2",
1129
- "resolved": "https://registry.npmjs.org/qs/-/qs-6.14.2.tgz",
1130
- "integrity": "sha512-V/yCWTTF7VJ9hIh18Ugr2zhJMP01MY7c5kh4J870L7imm6/DIzBsNLTXzMwUA3yZ5b/KBqLx8Kp3uRvd7xSe3Q==",
1128
+ "version": "6.15.2",
1129
+ "resolved": "https://registry.npmjs.org/qs/-/qs-6.15.2.tgz",
1130
+ "integrity": "sha512-Rzq0KEyX/w/tEybncDgdkZrJgVUsUMk3xjh3t5bv3S1HTAtg+uOYt72+ZfwiQwKdysThkTBdL/rTi6HDmX9Ddw==",
1131
1131
  "dev": true,
1132
1132
  "license": "BSD-3-Clause",
1133
1133
  "dependencies": {
@@ -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.0",
23
+ "style-dictionary": "^5.4.2",
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.0"
20
+ "style-dictionary": "^5.4.2"
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.0"
19
+ "style-dictionary": "^5.4.2"
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.0"
19
+ "style-dictionary": "^5.4.2"
20
20
  }
21
21
  }
@@ -10,7 +10,7 @@
10
10
  },
11
11
  "license": "Apache-2.0",
12
12
  "devDependencies": {
13
- "style-dictionary": "^5.4.0",
13
+ "style-dictionary": "^5.4.2",
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.0"
19
+ "style-dictionary": "^5.4.2"
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.0"
15
+ "style-dictionary": "^5.4.2"
16
16
  }
17
17
  }
@@ -11,6 +11,6 @@
11
11
  "author": "",
12
12
  "license": "MIT",
13
13
  "devDependencies": {
14
- "style-dictionary": "^5.4.0"
14
+ "style-dictionary": "^5.4.2"
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.0",
13
+ "style-dictionary": "^5.4.2",
14
14
  "yaml": "^1.10.0"
15
15
  }
16
16
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "text": {
2
+ "composite-examples": {
3
3
  "typography": {
4
4
  "$type": "typography",
5
5
  "heading": {
@@ -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.0';
70
+ static VERSION = '5.4.2';
71
71
 
72
72
  /** @returns {Config} */
73
73
  get options() {
@@ -42,10 +42,10 @@ export function isColor(token: Token, options: Config): boolean;
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
- * @returns {{ value: number; unit: TokenTypeDimensionUnit | undefined }}
45
+ * @returns {{ value: string | number; unit: TokenTypeDimensionUnit | undefined }}
46
46
  */
47
47
  export function getTokenDimensionValue(val: Token["value"]): {
48
- value: number;
48
+ value: string | number;
49
49
  unit: TokenTypeDimensionUnit | undefined;
50
50
  };
51
51
  declare const _default: {
@@ -591,7 +591,7 @@ declare const _default: {
591
591
  "size/rem": {
592
592
  type: "value";
593
593
  filter: (token: import("../../types/DesignToken.d.ts").TransformedToken, options: import("../../types/Config.d.ts").Config) => boolean;
594
- transform: (token: import("../../types/DesignToken.d.ts").TransformedToken, _: import("../../types/Config.d.ts").PlatformConfig, options: import("../../types/Config.d.ts").Config) => string | 0;
594
+ transform: (token: import("../../types/DesignToken.d.ts").TransformedToken, _: import("../../types/Config.d.ts").PlatformConfig, options: import("../../types/Config.d.ts").Config) => string | number;
595
595
  };
596
596
  /**
597
597
  * Scales the number by 16 (or the value of 'basePxFontSize' on the platform in your config) and adds 'f' to the end.
@@ -754,7 +754,7 @@ declare const _default: {
754
754
  "size/pxToRem": {
755
755
  type: "value";
756
756
  filter: (token: import("../../types/DesignToken.d.ts").TransformedToken, options: import("../../types/Config.d.ts").Config) => boolean;
757
- transform: (token: import("../../types/DesignToken.d.ts").TransformedToken, config: import("../../types/Config.d.ts").PlatformConfig, options: import("../../types/Config.d.ts").Config) => string | 0;
757
+ transform: (token: import("../../types/DesignToken.d.ts").TransformedToken, config: import("../../types/Config.d.ts").PlatformConfig, options: import("../../types/Config.d.ts").Config) => string | number;
758
758
  };
759
759
  /**
760
760
  * Scales the number by 16 (or the value of 'basePxFontSize' on the platform in your config) to get to points for Flutter
@@ -385,7 +385,7 @@ function transformCubicBezierCSS(token, options) {
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
- * @returns {{ value: number; unit: TokenTypeDimensionUnit | undefined }}
388
+ * @returns {{ value: string | number; unit: TokenTypeDimensionUnit | undefined }}
389
389
  */
390
390
  export function getTokenDimensionValue(val) {
391
391
  /** @type {TokenTypeDimensionUnit | undefined} */
@@ -398,9 +398,8 @@ export function getTokenDimensionValue(val) {
398
398
  const unitMatch = `${val}`.match(/[^0-9.-]+$/);
399
399
  if (unitMatch) {
400
400
  unit = /** @type {TokenTypeDimensionUnit} */ (unitMatch[0]);
401
- val = parseFloat(val.replace(/([^0-9]+$)/, ''));
401
+ val = val.replace(unit, '');
402
402
  }
403
- val = parseFloat(val);
404
403
  }
405
404
 
406
405
  return valueObj
@@ -1201,10 +1200,13 @@ export default {
1201
1200
  const parsedVal = parseFloat(`${nonParsed.value}`);
1202
1201
  if (isNaN(parsedVal))
1203
1202
  throwSizeError(token.name, options.usesDtcg ? token.$value : token.value, 'rem');
1204
- if (parsedVal === 0) return 0;
1203
+ // Preserve the unit when one was explicitly provided. Must run before the
1204
+ // unitless-zero short-circuit below, otherwise a value like `"0em"` loses
1205
+ // its unit and falls through to the number `0` branch.
1205
1206
  if (nonParsed.unit !== undefined) {
1206
1207
  return `${nonParsed.value}${nonParsed.unit}`;
1207
1208
  }
1209
+ if (parsedVal === 0) return nonParsed.value;
1208
1210
 
1209
1211
  return `${parsedVal}rem`;
1210
1212
  },
@@ -1465,7 +1467,7 @@ export default {
1465
1467
  const baseFont = getBasePxFontSize(config);
1466
1468
  if (isNaN(parsedVal))
1467
1469
  throwSizeError(token.name, options.usesDtcg ? token.$value : token.value, 'rem');
1468
- if (parsedVal === 0) return 0;
1470
+ if (parsedVal === 0) return nonParsed.value;
1469
1471
 
1470
1472
  return `${parsedVal / baseFont}rem`;
1471
1473
  },
@@ -6,7 +6,7 @@ import { isNode } from './isNode.js';
6
6
  // FS to handle posix/win32 path conversion.
7
7
 
8
8
  /**
9
- * @param {Buffer} buffer
9
+ * @param {Buffer<ArrayBuffer>} buffer
10
10
  * @returns {string|Promise<string>}
11
11
  */
12
12
  function toBase64(buffer) {
@@ -39,7 +39,9 @@ function toBase64(buffer) {
39
39
  export default async function convertToBase64(filePath, vol = fs) {
40
40
  if (typeof filePath !== 'string') throw new Error('Token filePath name must be a string');
41
41
  // typecast to Buffer because we know that without specifying encoding, this returns a Buffer
42
- // @ts-expect-error requires encoding options, this is a mistake in memfs types definition
43
- const body = /** @type {Buffer} */ (vol.readFileSync(resolve(filePath, vol.__custom_fs__)));
42
+ const body = /** @type {Buffer<ArrayBuffer>} */ (
43
+ // @ts-expect-error requires encoding options, this is a mistake in memfs types definition
44
+ vol.readFileSync(resolve(filePath, vol.__custom_fs__))
45
+ );
44
46
  return toBase64(body);
45
47
  }
@@ -33,6 +33,6 @@ export function convertJSONToDTCG(blobOrPath: Blob | string, opts?: {
33
33
  export function convertZIPToDTCG(blobOrPath: Blob | string, opts?: {
34
34
  applyTypesToGroup?: boolean;
35
35
  }): Promise<Blob>;
36
- export type Entry = import("@zip.js/zip.js").Entry;
36
+ export type Entry = import("@zip.js/zip.js").FileEntry;
37
37
  export type DesignToken = import("../../types/DesignToken.d.ts").DesignToken;
38
38
  export type DesignTokens = import("../../types/DesignToken.d.ts").DesignTokens;
@@ -10,7 +10,7 @@ import {
10
10
  import { fs } from 'style-dictionary/fs';
11
11
 
12
12
  /**
13
- * @typedef {import('@zip.js/zip.js').Entry} Entry
13
+ * @typedef {import('@zip.js/zip.js').FileEntry} Entry
14
14
  * @typedef {import('../../types/DesignToken.d.ts').DesignToken} DesignToken
15
15
  * @typedef {import('../../types/DesignToken.d.ts').DesignTokens} DesignTokens
16
16
  */
@@ -141,7 +141,7 @@ export async function writeZIP(zipEntries) {
141
141
  */
142
142
  async function blobify(blobOrPath, type) {
143
143
  if (typeof blobOrPath === 'string') {
144
- const buf = await fs.promises.readFile(blobOrPath);
144
+ const buf = /** @type {Buffer<ArrayBuffer>} */ (await fs.promises.readFile(blobOrPath));
145
145
  return new Blob([buf], { type });
146
146
  }
147
147
  return blobOrPath;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "style-dictionary",
3
- "version": "5.4.0",
3
+ "version": "5.4.2",
4
4
  "description": "Style once, use everywhere. A build system for creating cross-platform styles.",
5
5
  "keywords": [
6
6
  "style dictionary",
@@ -131,11 +131,11 @@
131
131
  "tinycolor2": "^1.6.0"
132
132
  },
133
133
  "devDependencies": {
134
- "@astrojs/check": "^0.9.4",
135
- "@astrojs/starlight": "^0.34.3",
134
+ "@astrojs/check": "^0.9.9",
135
+ "@astrojs/starlight": "^0.39.2",
136
136
  "@changesets/cli": "^2.27.1",
137
- "@commitlint/cli": "^18.4.3",
138
- "@commitlint/config-conventional": "^18.4.3",
137
+ "@commitlint/cli": "^21.0.1",
138
+ "@commitlint/config-conventional": "^21.0.1",
139
139
  "@esm-bundle/chai-as-promised": "^7.1.1",
140
140
  "@rollup/browser": "^4.13.1",
141
141
  "@rollup/plugin-virtual": "^3.0.2",
@@ -149,7 +149,7 @@
149
149
  "@web/test-runner-commands": "^0.9.0",
150
150
  "@web/test-runner-playwright": "^0.11.0",
151
151
  "acorn": "^8.11.3",
152
- "astro": "^5.13.2",
152
+ "astro": "^6.3.3",
153
153
  "chai": "^6.2.2",
154
154
  "eslint": "^9.19.0",
155
155
  "eslint-plugin-mocha": "^10.5.0",
@@ -170,7 +170,7 @@
170
170
  "sass": "^1.69.5",
171
171
  "semver": "^7.6.3",
172
172
  "sharp": "^0.32.5",
173
- "starlight-links-validator": "^0.16.0",
173
+ "starlight-links-validator": "^0.24.0",
174
174
  "typescript": "^5.7.2",
175
175
  "unist-util-visit": "^5.0.0",
176
176
  "uuid": "^9.0.1",