@terrazzo/parser 0.10.1 → 0.10.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/CHANGELOG.md +6 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/build/index.ts +5 -1
- package/src/config.ts +7 -2
- package/src/index.ts +17 -17
- package/src/lint/index.ts +1 -1
- package/src/parse/alias.ts +2 -2
- package/src/parse/index.ts +4 -4
- package/src/parse/json.ts +2 -2
- package/src/parse/normalize.ts +2 -2
- package/src/parse/validate.ts +6 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@terrazzo/parser",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.2",
|
|
4
4
|
"description": "Parser/validator for the Design Tokens Community Group (DTCG) standard.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"picocolors": "^1.1.1",
|
|
43
43
|
"scule": "^1.3.0",
|
|
44
44
|
"wildcard-match": "^5.1.4",
|
|
45
|
-
"@terrazzo/token-tools": "^0.10.
|
|
45
|
+
"@terrazzo/token-tools": "^0.10.2"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"yaml-to-momoa": "^0.0.3"
|
package/src/build/index.ts
CHANGED
|
@@ -18,7 +18,11 @@ function validateTransformParams({
|
|
|
18
18
|
params,
|
|
19
19
|
logger,
|
|
20
20
|
pluginName,
|
|
21
|
-
}: {
|
|
21
|
+
}: {
|
|
22
|
+
params: TokenTransformed;
|
|
23
|
+
logger: Logger;
|
|
24
|
+
pluginName: string;
|
|
25
|
+
}): void {
|
|
22
26
|
const baseMessage: LogEntry = { group: 'plugin', label: pluginName, message: '' };
|
|
23
27
|
|
|
24
28
|
// validate value is valid for SINGLE_VALUE or MULTI_VALUE
|
package/src/config.ts
CHANGED
|
@@ -48,7 +48,12 @@ function normalizeTokens({
|
|
|
48
48
|
config,
|
|
49
49
|
logger,
|
|
50
50
|
cwd,
|
|
51
|
-
}: {
|
|
51
|
+
}: {
|
|
52
|
+
rawConfig: Config;
|
|
53
|
+
config: ConfigInit;
|
|
54
|
+
logger: Logger;
|
|
55
|
+
cwd: URL;
|
|
56
|
+
}) {
|
|
52
57
|
if (rawConfig.tokens === undefined) {
|
|
53
58
|
config.tokens = [
|
|
54
59
|
// @ts-ignore we’ll normalize in next step
|
|
@@ -89,7 +94,7 @@ function normalizeTokens({
|
|
|
89
94
|
}
|
|
90
95
|
try {
|
|
91
96
|
config.tokens[i] = new URL(filepath, cwd);
|
|
92
|
-
} catch
|
|
97
|
+
} catch {
|
|
93
98
|
logger.error({ group: 'config', label: 'tokens', message: `Invalid URL ${filepath}` });
|
|
94
99
|
}
|
|
95
100
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
export { default as build } from './build/index.js';
|
|
2
|
-
export * from './build/index.js';
|
|
3
|
-
|
|
4
|
-
export { default as defineConfig } from './config.js';
|
|
5
|
-
export * from './config.js';
|
|
6
|
-
|
|
7
|
-
export { default as lintRunner } from './lint/index.js';
|
|
8
|
-
export * from './lint/index.js';
|
|
9
|
-
|
|
10
|
-
export { default as Logger } from './logger.js';
|
|
11
|
-
export * from './logger.js';
|
|
12
|
-
|
|
13
|
-
export { default as parse } from './parse/index.js';
|
|
14
|
-
export * from './parse/index.js';
|
|
15
|
-
|
|
16
|
-
export * from './types.js';
|
|
17
|
-
|
|
18
1
|
export type {
|
|
19
2
|
AliasToken,
|
|
20
3
|
AliasValue,
|
|
@@ -91,3 +74,20 @@ export type {
|
|
|
91
74
|
TypographyValue,
|
|
92
75
|
TypographyValueNormalized,
|
|
93
76
|
} from '@terrazzo/token-tools';
|
|
77
|
+
|
|
78
|
+
export * from './build/index.js';
|
|
79
|
+
export { default as build } from './build/index.js';
|
|
80
|
+
|
|
81
|
+
export * from './config.js';
|
|
82
|
+
export { default as defineConfig } from './config.js';
|
|
83
|
+
|
|
84
|
+
export * from './lint/index.js';
|
|
85
|
+
export { default as lintRunner } from './lint/index.js';
|
|
86
|
+
|
|
87
|
+
export * from './logger.js';
|
|
88
|
+
export { default as Logger } from './logger.js';
|
|
89
|
+
|
|
90
|
+
export * from './parse/index.js';
|
|
91
|
+
export { default as parse } from './parse/index.js';
|
|
92
|
+
|
|
93
|
+
export * from './types.js';
|
package/src/lint/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type TokenNormalized
|
|
1
|
+
import { pluralize, type TokenNormalized } from '@terrazzo/token-tools';
|
|
2
2
|
import { merge } from 'merge-anything';
|
|
3
3
|
import type { LogEntry, default as Logger } from '../logger.js';
|
|
4
4
|
import type { ConfigInit } from '../types.js';
|
package/src/parse/alias.ts
CHANGED
|
@@ -2,14 +2,14 @@ import type { AnyNode, ArrayNode, ObjectNode } from '@humanwhocodes/momoa';
|
|
|
2
2
|
import {
|
|
3
3
|
type BorderTokenNormalized,
|
|
4
4
|
type GradientTokenNormalized,
|
|
5
|
+
isAlias,
|
|
6
|
+
parseAlias,
|
|
5
7
|
type ShadowTokenNormalized,
|
|
6
8
|
type StrokeStyleTokenNormalized,
|
|
7
9
|
type TokenNormalized,
|
|
8
10
|
type TokenNormalizedSet,
|
|
9
11
|
type TransitionTokenNormalized,
|
|
10
12
|
type TypographyTokenNormalized,
|
|
11
|
-
isAlias,
|
|
12
|
-
parseAlias,
|
|
13
13
|
} from '@terrazzo/token-tools';
|
|
14
14
|
import type Logger from '../logger.js';
|
|
15
15
|
import { getObjMembers } from './json.js';
|
package/src/parse/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type DocumentNode, type MemberNode, type ObjectNode
|
|
2
|
-
import { type Token, type TokenNormalized
|
|
1
|
+
import { type DocumentNode, evaluate, type MemberNode, type ObjectNode } from '@humanwhocodes/momoa';
|
|
2
|
+
import { pluralize, splitID, type Token, type TokenNormalized } from '@terrazzo/token-tools';
|
|
3
3
|
import type ytm from 'yaml-to-momoa';
|
|
4
4
|
import lintRunner from '../lint/index.js';
|
|
5
5
|
import Logger from '../logger.js';
|
|
@@ -7,11 +7,11 @@ import type { ConfigInit, InputSource } from '../types.js';
|
|
|
7
7
|
import applyAliases from './alias.js';
|
|
8
8
|
import { getObjMembers, parseJSON, replaceObjMembers, toMomoa, traverse } from './json.js';
|
|
9
9
|
import normalize from './normalize.js';
|
|
10
|
-
import validateTokenNode, { type Visitors
|
|
10
|
+
import validateTokenNode, { getInheritedType, type Visitors } from './validate.js';
|
|
11
11
|
|
|
12
12
|
export * from './alias.js';
|
|
13
|
-
export * from './normalize.js';
|
|
14
13
|
export * from './json.js';
|
|
14
|
+
export * from './normalize.js';
|
|
15
15
|
export * from './validate.js';
|
|
16
16
|
export { normalize, validateTokenNode };
|
|
17
17
|
|
package/src/parse/json.ts
CHANGED
|
@@ -2,11 +2,11 @@ import {
|
|
|
2
2
|
type AnyNode,
|
|
3
3
|
type DocumentNode,
|
|
4
4
|
type MemberNode,
|
|
5
|
+
parse as momoaParse,
|
|
5
6
|
type ObjectNode,
|
|
6
7
|
type ParseOptions,
|
|
7
|
-
type ValueNode,
|
|
8
|
-
parse as momoaParse,
|
|
9
8
|
print,
|
|
9
|
+
type ValueNode,
|
|
10
10
|
} from '@humanwhocodes/momoa';
|
|
11
11
|
import type yamlToMomoa from 'yaml-to-momoa';
|
|
12
12
|
import type Logger from '../logger.js';
|
package/src/parse/normalize.ts
CHANGED
|
@@ -5,12 +5,12 @@ import {
|
|
|
5
5
|
type FontFamilyValue,
|
|
6
6
|
type GradientStopNormalized,
|
|
7
7
|
type GradientValueNormalized,
|
|
8
|
+
isAlias,
|
|
9
|
+
parseColor,
|
|
8
10
|
type ShadowValueNormalized,
|
|
9
11
|
type Token,
|
|
10
12
|
type TransitionValue,
|
|
11
13
|
type TypographyValueNormalized,
|
|
12
|
-
isAlias,
|
|
13
|
-
parseColor,
|
|
14
14
|
} from '@terrazzo/token-tools';
|
|
15
15
|
|
|
16
16
|
export const FONT_WEIGHT_MAP = {
|
package/src/parse/validate.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type AnyNode,
|
|
3
|
+
evaluate,
|
|
3
4
|
type MemberNode,
|
|
4
5
|
type ObjectNode,
|
|
6
|
+
print,
|
|
5
7
|
type StringNode,
|
|
6
8
|
type ValueNode,
|
|
7
|
-
evaluate,
|
|
8
|
-
print,
|
|
9
9
|
} from '@humanwhocodes/momoa';
|
|
10
|
-
import { type Token, type TokenNormalized
|
|
10
|
+
import { isAlias, splitID, type Token, type TokenNormalized } from '@terrazzo/token-tools';
|
|
11
11
|
import wcmatch from 'wildcard-match';
|
|
12
12
|
import type Logger from '../logger.js';
|
|
13
13
|
import type { ConfigInit } from '../types.js';
|
|
@@ -559,10 +559,12 @@ export function validateStrokeStyle($value: ValueNode, node: AnyNode, { filename
|
|
|
559
559
|
} else {
|
|
560
560
|
validateDimension(element.value, node, { logger, src });
|
|
561
561
|
}
|
|
562
|
+
} else if (element.value.type === 'Object') {
|
|
563
|
+
validateDimension(element.value, node, { logger, src });
|
|
562
564
|
} else {
|
|
563
565
|
logger.error({
|
|
564
566
|
...baseMessage,
|
|
565
|
-
message:
|
|
567
|
+
message: `Expected array of dimensions, received ${element.value.type}.`,
|
|
566
568
|
node: element,
|
|
567
569
|
});
|
|
568
570
|
}
|