style-dictionary 5.4.1 → 5.4.3
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-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/lib/Register.js +50 -32
- package/lib/StyleDictionary.js +16 -16
- package/lib/common/transforms.d.ts +4 -4
- package/lib/common/transforms.js +4 -5
- package/lib/utils/deepmerge.d.ts +1 -1
- package/lib/utils/deepmerge.js +4 -2
- package/package.json +3 -4
- package/types/typeless-modules/bundled-deepmerge.d.ts +0 -1
|
@@ -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/Register.js
CHANGED
|
@@ -163,11 +163,14 @@ export class Register {
|
|
|
163
163
|
this.deleteExistingHook(target, 'transformGroups', name);
|
|
164
164
|
|
|
165
165
|
// make sure to trigger the setter
|
|
166
|
-
target.hooks = deepmerge(
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
166
|
+
target.hooks = deepmerge(
|
|
167
|
+
target.hooks,
|
|
168
|
+
/** @type {Partial<Required<Hooks>>} */ ({
|
|
169
|
+
transformGroups: {
|
|
170
|
+
[name]: transforms,
|
|
171
|
+
},
|
|
172
|
+
}),
|
|
173
|
+
);
|
|
171
174
|
return target;
|
|
172
175
|
}
|
|
173
176
|
|
|
@@ -200,11 +203,14 @@ export class Register {
|
|
|
200
203
|
this.deleteExistingHook(target, 'formats', name);
|
|
201
204
|
|
|
202
205
|
// make sure to trigger the setter
|
|
203
|
-
target.hooks = deepmerge(
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
206
|
+
target.hooks = deepmerge(
|
|
207
|
+
target.hooks,
|
|
208
|
+
/** @type {Partial<Required<Hooks>>} */ ({
|
|
209
|
+
formats: {
|
|
210
|
+
[name]: formatFn,
|
|
211
|
+
},
|
|
212
|
+
}),
|
|
213
|
+
);
|
|
208
214
|
return target;
|
|
209
215
|
}
|
|
210
216
|
|
|
@@ -275,11 +281,14 @@ export class Register {
|
|
|
275
281
|
this.deleteExistingHook(target, 'filters', name);
|
|
276
282
|
|
|
277
283
|
// make sure to trigger the setter
|
|
278
|
-
target.hooks = deepmerge(
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
284
|
+
target.hooks = deepmerge(
|
|
285
|
+
target.hooks,
|
|
286
|
+
/** @type {Partial<Required<Hooks>>} */ ({
|
|
287
|
+
filters: {
|
|
288
|
+
[name]: filterFn,
|
|
289
|
+
},
|
|
290
|
+
}),
|
|
291
|
+
);
|
|
283
292
|
return target;
|
|
284
293
|
}
|
|
285
294
|
|
|
@@ -314,14 +323,17 @@ export class Register {
|
|
|
314
323
|
this.deleteExistingHook(target, 'parsers', name);
|
|
315
324
|
|
|
316
325
|
// make sure to trigger the setter
|
|
317
|
-
target.hooks = deepmerge(
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
326
|
+
target.hooks = deepmerge(
|
|
327
|
+
target.hooks,
|
|
328
|
+
/** @type {Partial<Required<Hooks>>} */ ({
|
|
329
|
+
parsers: {
|
|
330
|
+
[name]: {
|
|
331
|
+
pattern,
|
|
332
|
+
parser: parserFn,
|
|
333
|
+
},
|
|
322
334
|
},
|
|
323
|
-
},
|
|
324
|
-
|
|
335
|
+
}),
|
|
336
|
+
);
|
|
325
337
|
return target;
|
|
326
338
|
}
|
|
327
339
|
|
|
@@ -356,11 +368,14 @@ export class Register {
|
|
|
356
368
|
this.deleteExistingHook(target, 'preprocessors', name);
|
|
357
369
|
|
|
358
370
|
// make sure to trigger the setter
|
|
359
|
-
target.hooks = deepmerge(
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
371
|
+
target.hooks = deepmerge(
|
|
372
|
+
target.hooks,
|
|
373
|
+
/** @type {Partial<Required<Hooks>>} */ ({
|
|
374
|
+
preprocessors: {
|
|
375
|
+
[name]: preprocessor,
|
|
376
|
+
},
|
|
377
|
+
}),
|
|
378
|
+
);
|
|
364
379
|
return target;
|
|
365
380
|
}
|
|
366
381
|
|
|
@@ -393,11 +408,14 @@ export class Register {
|
|
|
393
408
|
this.deleteExistingHook(target, 'fileHeaders', name);
|
|
394
409
|
|
|
395
410
|
// make sure to trigger the setter
|
|
396
|
-
target.hooks = deepmerge(
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
411
|
+
target.hooks = deepmerge(
|
|
412
|
+
target.hooks,
|
|
413
|
+
/** @type {Partial<Required<Hooks>>} */ ({
|
|
414
|
+
fileHeaders: {
|
|
415
|
+
[name]: fileHeader,
|
|
416
|
+
},
|
|
417
|
+
}),
|
|
418
|
+
);
|
|
401
419
|
return target;
|
|
402
420
|
}
|
|
403
421
|
}
|
package/lib/StyleDictionary.js
CHANGED
|
@@ -67,17 +67,17 @@ 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.3';
|
|
71
71
|
|
|
72
72
|
/** @returns {Config} */
|
|
73
73
|
get options() {
|
|
74
74
|
// merge locally registered things with options
|
|
75
75
|
// so that when we extend, we include registered things
|
|
76
76
|
const opts = deepmerge(
|
|
77
|
-
{
|
|
77
|
+
/** @type {Partial<Config>} */ ({
|
|
78
78
|
hooks: this.hooks,
|
|
79
|
-
},
|
|
80
|
-
this._options ?? {},
|
|
79
|
+
}),
|
|
80
|
+
/** @type {Partial<Config>} */ (this._options ?? {}),
|
|
81
81
|
);
|
|
82
82
|
return opts;
|
|
83
83
|
}
|
|
@@ -184,18 +184,6 @@ export default class StyleDictionary extends Register {
|
|
|
184
184
|
* @returns {Promise<StyleDictionary>}
|
|
185
185
|
*/
|
|
186
186
|
async extend(config = this.config, opts = {}) {
|
|
187
|
-
// by default, if extend is called it means extending the current instance
|
|
188
|
-
// with a new instance without mutating the original
|
|
189
|
-
if (!opts.mutateOriginal) {
|
|
190
|
-
const newSD = new StyleDictionary(deepmerge(this.options, config), {
|
|
191
|
-
init: false,
|
|
192
|
-
verbosity: opts.verbosity,
|
|
193
|
-
warnings: opts.warnings,
|
|
194
|
-
volume: opts.volume,
|
|
195
|
-
});
|
|
196
|
-
return newSD.init(opts);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
187
|
/** @type {Config} */
|
|
200
188
|
let options;
|
|
201
189
|
/** @type {Tokens} */
|
|
@@ -213,6 +201,18 @@ export default class StyleDictionary extends Register {
|
|
|
213
201
|
options = config;
|
|
214
202
|
}
|
|
215
203
|
|
|
204
|
+
// by default, if extend is called it means extending the current instance
|
|
205
|
+
// with a new instance without mutating the original
|
|
206
|
+
if (!opts.mutateOriginal) {
|
|
207
|
+
const newSD = new StyleDictionary(deepmerge(this.options, options), {
|
|
208
|
+
init: false,
|
|
209
|
+
verbosity: opts.verbosity,
|
|
210
|
+
warnings: opts.warnings,
|
|
211
|
+
volume: opts.volume,
|
|
212
|
+
});
|
|
213
|
+
return newSD.init(opts);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
216
|
this.log = {
|
|
217
217
|
// our defaults
|
|
218
218
|
...this.log,
|
|
@@ -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
|
|
@@ -1207,7 +1206,7 @@ export default {
|
|
|
1207
1206
|
if (nonParsed.unit !== undefined) {
|
|
1208
1207
|
return `${nonParsed.value}${nonParsed.unit}`;
|
|
1209
1208
|
}
|
|
1210
|
-
if (parsedVal === 0) return
|
|
1209
|
+
if (parsedVal === 0) return nonParsed.value;
|
|
1211
1210
|
|
|
1212
1211
|
return `${parsedVal}rem`;
|
|
1213
1212
|
},
|
|
@@ -1468,7 +1467,7 @@ export default {
|
|
|
1468
1467
|
const baseFont = getBasePxFontSize(config);
|
|
1469
1468
|
if (isNaN(parsedVal))
|
|
1470
1469
|
throwSizeError(token.name, options.usesDtcg ? token.$value : token.value, 'rem');
|
|
1471
|
-
if (parsedVal === 0) return
|
|
1470
|
+
if (parsedVal === 0) return nonParsed.value;
|
|
1472
1471
|
|
|
1473
1472
|
return `${parsedVal / baseFont}rem`;
|
|
1474
1473
|
},
|
package/lib/utils/deepmerge.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export function deepmerge(target:
|
|
1
|
+
export function deepmerge<T>(target: Partial<T>, source: Partial<T>, dedupeArrays?: boolean): T;
|
package/lib/utils/deepmerge.js
CHANGED
|
@@ -3,9 +3,11 @@ import isPlainObject from 'is-plain-obj';
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Wrapper around deepmerge that merges only plain objects and arrays
|
|
6
|
-
* @
|
|
7
|
-
* @param {
|
|
6
|
+
* @template T
|
|
7
|
+
* @param {Partial<T>} target
|
|
8
|
+
* @param {Partial<T>} source
|
|
8
9
|
* @param {boolean} [dedupeArrays]
|
|
10
|
+
* @returns {T}
|
|
9
11
|
*/
|
|
10
12
|
export const deepmerge = (target, source, dedupeArrays = true) => {
|
|
11
13
|
return _deepmerge(target, source, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "style-dictionary",
|
|
3
|
-
"version": "5.4.
|
|
3
|
+
"version": "5.4.3",
|
|
4
4
|
"description": "Style once, use everywhere. A build system for creating cross-platform styles.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"style dictionary",
|
|
@@ -112,11 +112,10 @@
|
|
|
112
112
|
],
|
|
113
113
|
"homepage": "https://styledictionary.com",
|
|
114
114
|
"overrides": {
|
|
115
|
-
"tmp": "0.2.5",
|
|
116
115
|
"lodash": "4.17.23"
|
|
117
116
|
},
|
|
118
117
|
"dependencies": {
|
|
119
|
-
"@bundled-es-modules/deepmerge": "^4.3.
|
|
118
|
+
"@bundled-es-modules/deepmerge": "^4.3.2",
|
|
120
119
|
"@bundled-es-modules/glob": "^13.0.6",
|
|
121
120
|
"@bundled-es-modules/memfs": "^4.17.0",
|
|
122
121
|
"@zip.js/zip.js": "^2.7.44",
|
|
@@ -173,7 +172,7 @@
|
|
|
173
172
|
"starlight-links-validator": "^0.24.0",
|
|
174
173
|
"typescript": "^5.7.2",
|
|
175
174
|
"unist-util-visit": "^5.0.0",
|
|
176
|
-
"uuid": "^
|
|
175
|
+
"uuid": "^14.0.0",
|
|
177
176
|
"yaml": "^2.3.4"
|
|
178
177
|
}
|
|
179
178
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
declare module '@bundled-es-modules/deepmerge';
|