style-dictionary 5.4.2 → 5.4.4
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/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/utils/convertTokenData.js +4 -0
- 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
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.4';
|
|
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,
|
|
@@ -33,6 +33,10 @@ function convertToTokenObject(tokenArray) {
|
|
|
33
33
|
const obj = /** @type {Tokens} */ ({});
|
|
34
34
|
tokenArray.forEach((token) => {
|
|
35
35
|
const { key } = token;
|
|
36
|
+
// prototype pollution guard -> move to next token if key is malicious
|
|
37
|
+
if (key?.includes('__proto__')) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
36
40
|
const keyArr = /** @type {string} */ (key).replace('{', '').replace('}', '').split('.');
|
|
37
41
|
let slice = obj;
|
|
38
42
|
keyArr.forEach((k, i, arr) => {
|
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.4",
|
|
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';
|