style-dictionary 3.9.0 → 3.9.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/README.md +1 -1
- package/examples/advanced/assets-base64-embed/package.json +1 -1
- package/examples/advanced/auto-rebuild-watcher/package.json +1 -1
- package/examples/advanced/component-cti/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-file-header/package.json +1 -1
- package/examples/advanced/custom-filters/package.json +1 -1
- package/examples/advanced/custom-formats-with-templates/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/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/common/formatHelpers/createPropertyFormatter.js +4 -1
- package/lib/utils/combineJSON.js +16 -14
- package/package.json +2 -2
- package/types/FormatHelpers.d.ts +5 -4
- package/examples/complete/ios/README.md +0 -29
package/README.md
CHANGED
|
@@ -316,7 +316,7 @@ Rather than starting our own spinoff tool, we much prefer bringing Style-Diction
|
|
|
316
316
|
|
|
317
317
|
I think it's important to stress that it is our shared vision to keep Style-Dictionary as an agnostic (so not "Tokens Studio"-specific) and flexible tool. As Tokens Studio, while we are highly incentivized to see this project progress further to strengthen our product journey, we value the open source community highly and want to make sure this library remains the go-to tool for exporting Design Tokens, whether you use Tokens Studio or not.
|
|
318
318
|
|
|
319
|
-
We are very open to feedback and collaboration, feel free to reach out to us in [our Slack](https://
|
|
319
|
+
We are very open to feedback and collaboration, feel free to reach out to us in [our Slack](https://join.slack.com/t/tokens-studio/shared_invite/zt-1p8ea3m6t-C163oJcN9g3~YZTKRgo2hg) -> `style-dictionary-v4` channel!
|
|
320
320
|
|
|
321
321
|
## Mascot
|
|
322
322
|
|
|
@@ -184,7 +184,10 @@ function createPropertyFormatter({
|
|
|
184
184
|
// because Style Dictionary resolved this in the resolution step.
|
|
185
185
|
// Here we are undoing that by replacing the value with
|
|
186
186
|
// the reference's name
|
|
187
|
-
|
|
187
|
+
|
|
188
|
+
// Safe way to check if object contains a property.
|
|
189
|
+
// below can be replaced with the new safe Object.hasOwn() in evergreen browsers / Node 16.9.0 onwards
|
|
190
|
+
if (Object.prototype.hasOwnProperty.call(ref, 'value') && Object.prototype.hasOwnProperty.call(ref, 'name')) {
|
|
188
191
|
const replaceFunc = function() {
|
|
189
192
|
if (format === 'css') {
|
|
190
193
|
if (outputReferenceFallbacks) {
|
package/lib/utils/combineJSON.js
CHANGED
|
@@ -11,18 +11,18 @@
|
|
|
11
11
|
* and limitations under the License.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
require(
|
|
14
|
+
require("json5/lib/register");
|
|
15
15
|
require.extensions[".jsonc"] = require("./jsonc").register;
|
|
16
16
|
|
|
17
|
-
var
|
|
18
|
-
deepExtend = require(
|
|
19
|
-
path = require(
|
|
20
|
-
fs = require(
|
|
17
|
+
var { globSync } = require("glob"),
|
|
18
|
+
deepExtend = require("./deepExtend"),
|
|
19
|
+
path = require("path"),
|
|
20
|
+
fs = require("fs");
|
|
21
21
|
|
|
22
22
|
function traverseObj(obj, fn) {
|
|
23
23
|
for (let key in obj) {
|
|
24
24
|
fn.apply(null, [obj, key, obj[key]]);
|
|
25
|
-
if (obj[key] && typeof obj[key] ===
|
|
25
|
+
if (obj[key] && typeof obj[key] === "object") {
|
|
26
26
|
traverseObj(obj[key], fn);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -39,12 +39,14 @@ function traverseObj(obj, fn) {
|
|
|
39
39
|
* @param {Object[]} [parsers=[]] - Custom file parsers
|
|
40
40
|
* @returns {Object}
|
|
41
41
|
*/
|
|
42
|
-
function combineJSON(arr, deep, collision, source, parsers=[]) {
|
|
43
|
-
var i,
|
|
42
|
+
function combineJSON(arr, deep, collision, source, parsers = []) {
|
|
43
|
+
var i,
|
|
44
|
+
files = [],
|
|
44
45
|
to_ret = {};
|
|
45
46
|
|
|
46
47
|
for (i = 0; i < arr.length; i++) {
|
|
47
|
-
|
|
48
|
+
// Reverse to avoid introducing a breaking change
|
|
49
|
+
var new_files = globSync(arr[i], { posix: true }).reverse();
|
|
48
50
|
files = files.concat(new_files);
|
|
49
51
|
}
|
|
50
52
|
|
|
@@ -61,11 +63,11 @@ function combineJSON(arr, deep, collision, source, parsers=[]) {
|
|
|
61
63
|
|
|
62
64
|
// Iterate over custom parsers, if the file path matches the parser's
|
|
63
65
|
// pattern regex, use it's parse function to generate the object
|
|
64
|
-
parsers.forEach(({pattern, parse}) => {
|
|
66
|
+
parsers.forEach(({ pattern, parse }) => {
|
|
65
67
|
if (resolvedPath.match(pattern)) {
|
|
66
68
|
file_content = parse({
|
|
67
|
-
contents: fs.readFileSync(resolvedPath, {encoding:
|
|
68
|
-
filePath: resolvedPath
|
|
69
|
+
contents: fs.readFileSync(resolvedPath, { encoding: "UTF-8" }),
|
|
70
|
+
filePath: resolvedPath,
|
|
69
71
|
});
|
|
70
72
|
}
|
|
71
73
|
});
|
|
@@ -75,13 +77,13 @@ function combineJSON(arr, deep, collision, source, parsers=[]) {
|
|
|
75
77
|
file_content = deepExtend([file_content, require(resolvedPath)]);
|
|
76
78
|
}
|
|
77
79
|
} catch (e) {
|
|
78
|
-
e.message =
|
|
80
|
+
e.message = "Failed to load or parse JSON or JS Object: " + e.message;
|
|
79
81
|
throw e;
|
|
80
82
|
}
|
|
81
83
|
|
|
82
84
|
// Add some side data on each property to make filtering easier
|
|
83
85
|
traverseObj(file_content, (obj) => {
|
|
84
|
-
if (obj.hasOwnProperty(
|
|
86
|
+
if (obj.hasOwnProperty("value") && !obj.filePath) {
|
|
85
87
|
obj.filePath = filePath;
|
|
86
88
|
|
|
87
89
|
obj.isSource = source || source === undefined ? true : false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "style-dictionary",
|
|
3
|
-
"version": "3.9.
|
|
3
|
+
"version": "3.9.2",
|
|
4
4
|
"description": "Style once, use everywhere. A build system for creating cross-platform styles.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"style dictionary",
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
"change-case": "^4.1.2",
|
|
123
123
|
"commander": "^8.3.0",
|
|
124
124
|
"fs-extra": "^10.0.0",
|
|
125
|
-
"glob": "^
|
|
125
|
+
"glob": "^10.3.10",
|
|
126
126
|
"json5": "^2.2.2",
|
|
127
127
|
"jsonc-parser": "^3.0.0",
|
|
128
128
|
"lodash": "^4.17.15",
|
package/types/FormatHelpers.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ import { File } from "./File";
|
|
|
19
19
|
export interface LineFormatting {
|
|
20
20
|
prefix?: string;
|
|
21
21
|
commentStyle?: "short" | "long" | "none";
|
|
22
|
+
commentPosition?: "inline" | "above";
|
|
22
23
|
indentation?: string;
|
|
23
24
|
separator?: string;
|
|
24
25
|
suffix?: string;
|
|
@@ -53,7 +54,7 @@ export interface FormattedVariablesArgs {
|
|
|
53
54
|
|
|
54
55
|
export interface FormatHelpers {
|
|
55
56
|
createPropertyFormatter: (
|
|
56
|
-
args: TokenFormatterArgs
|
|
57
|
+
args: TokenFormatterArgs,
|
|
57
58
|
) => (token: TransformedToken) => string;
|
|
58
59
|
fileHeader: (args: FileHeaderArgs) => string;
|
|
59
60
|
formattedVariables: (args: FormattedVariablesArgs) => string;
|
|
@@ -62,15 +63,15 @@ export interface FormatHelpers {
|
|
|
62
63
|
iconsWithPrefix: (
|
|
63
64
|
prefix: string,
|
|
64
65
|
allTokens: DesignToken[],
|
|
65
|
-
options: object
|
|
66
|
+
options: object,
|
|
66
67
|
) => string;
|
|
67
68
|
sortByReference: (
|
|
68
|
-
dictionary: Dictionary
|
|
69
|
+
dictionary: Dictionary,
|
|
69
70
|
) => (a: TransformedToken, b: TransformedToken) => number;
|
|
70
71
|
sortByName: (a: DesignToken, b: DesignToken) => number;
|
|
71
72
|
setSwiftFileProperties: (
|
|
72
73
|
options: object,
|
|
73
74
|
objectType: string,
|
|
74
|
-
transformGroup: string
|
|
75
|
+
transformGroup: string,
|
|
75
76
|
) => string;
|
|
76
77
|
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# StyleDictionary
|
|
2
|
-
|
|
3
|
-
[](https://travis-ci.org/Danny Banks/StyleDictionary)
|
|
4
|
-
[](http://cocoapods.org/pods/StyleDictionary)
|
|
5
|
-
[](http://cocoapods.org/pods/StyleDictionary)
|
|
6
|
-
[](http://cocoapods.org/pods/StyleDictionary)
|
|
7
|
-
|
|
8
|
-
## Example
|
|
9
|
-
|
|
10
|
-
To run the example project, clone the repo, and run `pod install` from the Example directory first.
|
|
11
|
-
|
|
12
|
-
## Requirements
|
|
13
|
-
|
|
14
|
-
## Installation
|
|
15
|
-
|
|
16
|
-
StyleDictionary is available through [CocoaPods](http://cocoapods.org). To install
|
|
17
|
-
it, you can add the following line to your Podfile:
|
|
18
|
-
|
|
19
|
-
```ruby
|
|
20
|
-
pod "StyleDictionary"
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## Author
|
|
24
|
-
|
|
25
|
-
Danny Banks, djb@amazon.com
|
|
26
|
-
|
|
27
|
-
## License
|
|
28
|
-
|
|
29
|
-
StyleDictionary is available under the MIT license. See the LICENSE file for more info.
|