style-dictionary 5.1.3 → 5.1.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/StyleDictionary.js +1 -1
- package/lib/common/transforms.js +3 -1
- package/lib/transform/token.js +17 -13
- package/package.json +1 -1
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.1.
|
|
70
|
+
static VERSION = '5.1.4';
|
|
71
71
|
|
|
72
72
|
/** @returns {Config} */
|
|
73
73
|
get options() {
|
package/lib/common/transforms.js
CHANGED
|
@@ -105,7 +105,9 @@ function wrapValueWithDoubleQuote(token, options) {
|
|
|
105
105
|
* @returns {string}
|
|
106
106
|
*/
|
|
107
107
|
function throwSizeError(name, value, unitType) {
|
|
108
|
-
throw
|
|
108
|
+
throw new Error(
|
|
109
|
+
`Invalid Number: '${name}: ${value}' is not a valid number, cannot transform to '${unitType}' \n`,
|
|
110
|
+
);
|
|
109
111
|
}
|
|
110
112
|
|
|
111
113
|
/**
|
package/lib/transform/token.js
CHANGED
|
@@ -46,20 +46,24 @@ async function _transformTokenWrapper(transform, token, config, options, vol) {
|
|
|
46
46
|
try {
|
|
47
47
|
to_ret = await transform.transform(token, config, options, vol);
|
|
48
48
|
} catch (e) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
50
|
+
const transformError = createErrorMessage(
|
|
51
|
+
token,
|
|
52
|
+
e instanceof Error ? e : new Error(message),
|
|
53
|
+
transform.name,
|
|
54
|
+
!!options?.usesDtcg,
|
|
55
|
+
);
|
|
56
|
+
// collect the errors so we can warn the user at the end of the run
|
|
57
|
+
GroupMessages.add(TRANSFORM_ERRORS, transformError);
|
|
53
58
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
59
|
+
// Return a sensible fallback value
|
|
60
|
+
switch (transform.type) {
|
|
61
|
+
case 'attribute':
|
|
62
|
+
return token.attributes;
|
|
63
|
+
case 'name':
|
|
64
|
+
return token.name;
|
|
65
|
+
case 'value':
|
|
66
|
+
return options.usesDtcg ? token.$value : token.value;
|
|
63
67
|
}
|
|
64
68
|
}
|
|
65
69
|
return to_ret;
|