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.
- 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-app/src/serviceWorker.js +4 -4
- 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-lock.json +3 -3
- 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/tailwind-preset/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/examples/basic/tokens/object-values.json +1 -1
- package/lib/StyleDictionary.js +1 -1
- package/lib/common/transforms.d.ts +4 -4
- package/lib/common/transforms.js +7 -5
- package/lib/utils/convertToBase64.js +5 -3
- package/lib/utils/convertToDTCG.d.ts +1 -1
- package/lib/utils/convertToDTCG.js +2 -2
- package/package.json +7 -7
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
|
|
13
13
|
const isLocalhost = Boolean(
|
|
14
14
|
window.location.hostname === 'localhost' ||
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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) {
|
|
@@ -1125,9 +1125,9 @@
|
|
|
1125
1125
|
"license": "MIT"
|
|
1126
1126
|
},
|
|
1127
1127
|
"node_modules/qs": {
|
|
1128
|
-
"version": "6.
|
|
1129
|
-
"resolved": "https://registry.npmjs.org/qs/-/qs-6.
|
|
1130
|
-
"integrity": "sha512-
|
|
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": {
|
package/lib/StyleDictionary.js
CHANGED
|
@@ -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.
|
|
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 |
|
|
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 |
|
|
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
|
package/lib/common/transforms.js
CHANGED
|
@@ -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 =
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
43
|
-
|
|
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").
|
|
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').
|
|
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.
|
|
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.
|
|
135
|
-
"@astrojs/starlight": "^0.
|
|
134
|
+
"@astrojs/check": "^0.9.9",
|
|
135
|
+
"@astrojs/starlight": "^0.39.2",
|
|
136
136
|
"@changesets/cli": "^2.27.1",
|
|
137
|
-
"@commitlint/cli": "^
|
|
138
|
-
"@commitlint/config-conventional": "^
|
|
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": "^
|
|
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.
|
|
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",
|