@o3r/style-dictionary 13.0.0-next.16 → 13.0.0-next.18
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@o3r/style-dictionary",
|
|
3
|
-
"version": "13.0.0-next.
|
|
3
|
+
"version": "13.0.0-next.18",
|
|
4
4
|
"deprecated": "This package will be removed in Otter v14. Please use @ama-styling/style-dictionary instead.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -42,15 +42,15 @@
|
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@angular-devkit/architect": "~0.2000.0",
|
|
44
44
|
"@angular-devkit/schematics": "~20.0.0",
|
|
45
|
-
"@o3r/schematics": "^13.0.0-next.
|
|
45
|
+
"@o3r/schematics": "^13.0.0-next.18",
|
|
46
46
|
"@schematics/angular": "~20.0.0",
|
|
47
47
|
"tslib": "^2.6.2"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@o3r/core": "^13.0.0-next.
|
|
51
|
-
"@o3r/schematics": "^13.0.0-next.
|
|
52
|
-
"@o3r/telemetry": "^13.0.0-next.
|
|
53
|
-
"style-dictionary": "^
|
|
50
|
+
"@o3r/core": "^13.0.0-next.18",
|
|
51
|
+
"@o3r/schematics": "^13.0.0-next.18",
|
|
52
|
+
"@o3r/telemetry": "^13.0.0-next.18",
|
|
53
|
+
"style-dictionary": "^5.0.0",
|
|
54
54
|
"type-fest": "^4.30.1"
|
|
55
55
|
},
|
|
56
56
|
"peerDependenciesMeta": {
|
|
@@ -73,15 +73,15 @@
|
|
|
73
73
|
"@babel/preset-typescript": "~7.27.0",
|
|
74
74
|
"@compodoc/compodoc": "^1.1.19",
|
|
75
75
|
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.0",
|
|
76
|
-
"@nx/eslint": "~21.
|
|
77
|
-
"@nx/eslint-plugin": "~21.
|
|
78
|
-
"@nx/jest": "~21.
|
|
79
|
-
"@nx/js": "~21.
|
|
80
|
-
"@o3r/build-helpers": "^13.0.0-next.
|
|
81
|
-
"@o3r/core": "^13.0.0-next.
|
|
82
|
-
"@o3r/eslint-plugin": "^13.0.0-next.
|
|
83
|
-
"@o3r/telemetry": "^13.0.0-next.
|
|
84
|
-
"@o3r/test-helpers": "^13.0.0-next.
|
|
76
|
+
"@nx/eslint": "~21.3.11",
|
|
77
|
+
"@nx/eslint-plugin": "~21.3.11",
|
|
78
|
+
"@nx/jest": "~21.3.11",
|
|
79
|
+
"@nx/js": "~21.3.11",
|
|
80
|
+
"@o3r/build-helpers": "^13.0.0-next.18",
|
|
81
|
+
"@o3r/core": "^13.0.0-next.18",
|
|
82
|
+
"@o3r/eslint-plugin": "^13.0.0-next.18",
|
|
83
|
+
"@o3r/telemetry": "^13.0.0-next.18",
|
|
84
|
+
"@o3r/test-helpers": "^13.0.0-next.18",
|
|
85
85
|
"@schematics/angular": "~20.0.0",
|
|
86
86
|
"@stylistic/eslint-plugin": "~3.1.0",
|
|
87
87
|
"@types/jest": "~29.5.2",
|
|
@@ -108,9 +108,9 @@
|
|
|
108
108
|
"jest-junit": "~16.0.0",
|
|
109
109
|
"jest-resolve": "~29.7.0",
|
|
110
110
|
"jsonc-eslint-parser": "~2.4.0",
|
|
111
|
-
"nx": "~21.
|
|
111
|
+
"nx": "~21.3.11",
|
|
112
112
|
"pid-from-port": "^1.1.3",
|
|
113
|
-
"style-dictionary": "~
|
|
113
|
+
"style-dictionary": "~5.0.0",
|
|
114
114
|
"ts-jest": "~29.3.0",
|
|
115
115
|
"ts-node": "~10.9.2",
|
|
116
116
|
"type-fest": "^4.30.1",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import StyleDictionary from 'style-dictionary';
|
|
1
2
|
import type { File, FormatFn } from 'style-dictionary/types';
|
|
2
3
|
/** Options to get file filters */
|
|
3
4
|
interface TargetFileOptions {
|
|
@@ -7,6 +8,8 @@ interface TargetFileOptions {
|
|
|
7
8
|
rootPath?: string;
|
|
8
9
|
/** Default file if not matching any rule */
|
|
9
10
|
defaultFile?: string;
|
|
11
|
+
/** styleDictionary instance */
|
|
12
|
+
styleDictionary?: StyleDictionary;
|
|
10
13
|
}
|
|
11
14
|
/** Mapping of the Design Tokens to a given file */
|
|
12
15
|
export interface FileRuleNode {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"target-file.filter.d.mts","sourceRoot":"","sources":["../../../src/filters/target-file.filter.mts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"target-file.filter.d.mts","sourceRoot":"","sources":["../../../src/filters/target-file.filter.mts"],"names":[],"mappings":"AAOA,OAAO,eAEN,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EACV,IAAI,EACJ,QAAQ,EACT,MAAM,wBAAwB,CAAC;AAQhC,kCAAkC;AAClC,UAAU,iBAAiB;IACzB,mCAAmC;IACnC,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC3B,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4CAA4C;IAC5C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+BAA+B;IAC/B,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC;AAED,mDAAmD;AACnD,MAAM,WAAW,YAAY;IAC3B,oDAAoD;IACpD,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,YAAY,CAAC;CACvC;AAgBD;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,WAAW,YAAY,EAAE,UAAU,iBAAiB,KAAG,IAAI,EAwCzF,CAAC"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { randomUUID, } from 'node:crypto';
|
|
1
2
|
import { normalize, resolve, } from 'node:path';
|
|
3
|
+
import StyleDictionary from 'style-dictionary';
|
|
4
|
+
import { OTTER_NAME_PREFIX, } from '../constants.mjs';
|
|
2
5
|
import { deflatten, } from '../helpers/config-deflatten.helpers.mjs';
|
|
3
6
|
const getPathMap = (rule, path = [], map = new Map()) => {
|
|
4
7
|
return Object.entries(rule)
|
|
@@ -18,27 +21,33 @@ const getPathMap = (rule, path = [], map = new Map()) => {
|
|
|
18
21
|
* @param options
|
|
19
22
|
*/
|
|
20
23
|
export const getTargetFiles = (fileRules, options) => {
|
|
24
|
+
const styleDictionary = options?.styleDictionary || StyleDictionary;
|
|
21
25
|
const flatterRules = deflatten(fileRules);
|
|
22
26
|
const fileMap = getPathMap(flatterRules);
|
|
23
27
|
const fileMapEntries = [...fileMap.entries()];
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
28
|
+
const files = fileMapEntries
|
|
29
|
+
.map(([filePath, nodes]) => {
|
|
30
|
+
const filter = (token) => nodes.some((path) => path.every((item, idx) => token.path[idx] === item));
|
|
31
|
+
const name = `${OTTER_NAME_PREFIX}/filter/${randomUUID()}`;
|
|
32
|
+
styleDictionary.registerFilter({ name, filter });
|
|
33
|
+
return {
|
|
34
|
+
destination: options?.rootPath ? resolve(options.rootPath, filePath) : filePath,
|
|
35
|
+
format: options?.format,
|
|
36
|
+
filter: name
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
if (options?.defaultFile) {
|
|
40
|
+
const filter = (token) => !fileMapEntries
|
|
41
|
+
.filter(([filePath]) => normalize(filePath) !== normalize(options.defaultFile))
|
|
42
|
+
.some(([, nodes]) => nodes.some((path) => path.every((item, idx) => token.path[idx] === item)));
|
|
43
|
+
const name = `${OTTER_NAME_PREFIX}/filter/${randomUUID()}`;
|
|
44
|
+
styleDictionary.registerFilter({ name, filter });
|
|
45
|
+
files.push({
|
|
46
|
+
destination: options.rootPath ? resolve(options.rootPath, options.defaultFile) : options.defaultFile,
|
|
47
|
+
format: options?.format,
|
|
48
|
+
filter: name
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return files;
|
|
43
52
|
};
|
|
44
53
|
//# sourceMappingURL=target-file.filter.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"target-file.filter.mjs","sourceRoot":"","sources":["../../../src/filters/target-file.filter.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,OAAO,GACR,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"target-file.filter.mjs","sourceRoot":"","sources":["../../../src/filters/target-file.filter.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,GACX,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,SAAS,EACT,OAAO,GACR,MAAM,WAAW,CAAC;AACnB,OAAO,eAEN,MAAM,kBAAkB,CAAC;AAK1B,OAAO,EACL,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,SAAS,GACV,MAAM,yCAAyC,CAAC;AAoBjD,MAAM,UAAU,GAAG,CAAC,IAAkB,EAAE,OAAiB,EAAE,EAAE,MAA+B,IAAI,GAAG,EAAE,EAA2B,EAAE;IAChI,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;SACxB,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,KAAK,aAAa,CAAC;SAC1C,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE;QAC7B,MAAM,WAAW,GAAG,CAAC,GAAG,IAAI,EAAE,IAAI,CAAC,CAAC;QACpC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,K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