@terrazzo/parser 0.10.3 → 0.10.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/CHANGELOG.md +6 -0
- package/dist/index.d.ts +0 -26
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +91 -113
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/lib/code-frame.ts +2 -2
- package/src/parse/index.ts +12 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@terrazzo/parser",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.4",
|
|
4
4
|
"description": "Parser/validator for the Design Tokens Community Group (DTCG) standard.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"directory": "./packages/parser/"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@humanwhocodes/momoa": "^3.3.
|
|
37
|
+
"@humanwhocodes/momoa": "^3.3.9",
|
|
38
38
|
"@types/babel__code-frame": "^7.0.6",
|
|
39
|
-
"@types/culori": "^4.0.
|
|
39
|
+
"@types/culori": "^4.0.1",
|
|
40
40
|
"culori": "^4.0.2",
|
|
41
41
|
"merge-anything": "^5.1.7",
|
|
42
42
|
"picocolors": "^1.1.1",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@terrazzo/token-tools": "^0.10.3"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"yaml-to-momoa": "^0.0.
|
|
48
|
+
"yaml-to-momoa": "^0.0.6"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"build": "rolldown -c && attw --profile esm-only --pack .",
|
package/src/lib/code-frame.ts
CHANGED
|
@@ -62,9 +62,9 @@ export interface Options {
|
|
|
62
62
|
*/
|
|
63
63
|
function getMarkerLines(loc: NodeLocation, source: string[], opts: Options = {} as Options) {
|
|
64
64
|
const startLoc = {
|
|
65
|
-
// @ts-
|
|
65
|
+
// @ts-expect-error this is fine
|
|
66
66
|
column: 0,
|
|
67
|
-
// @ts-
|
|
67
|
+
// @ts-expect-error this is fine
|
|
68
68
|
line: -1,
|
|
69
69
|
...loc.start,
|
|
70
70
|
} as Location;
|
package/src/parse/index.ts
CHANGED
|
@@ -256,8 +256,18 @@ async function parseSingle(
|
|
|
256
256
|
const inheritedTypeNode = computeInheritedProperty(node, '$type', { subpath, inherited: $typeInheritance });
|
|
257
257
|
if (node.value.type === 'Object') {
|
|
258
258
|
const $value = node.value.members.find((m) => m.name.type === 'String' && m.name.value === '$value');
|
|
259
|
-
|
|
260
|
-
|
|
259
|
+
|
|
260
|
+
// Call transform using either inherited type or token-level type
|
|
261
|
+
let typeNode = inheritedTypeNode;
|
|
262
|
+
if (!typeNode) {
|
|
263
|
+
const local$type = node.value.members.find((m) => m.name.type === 'String' && m.name.value === '$type');
|
|
264
|
+
if (local$type) {
|
|
265
|
+
typeNode = local$type as MemberNode;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
if ($value && typeNode?.value.type === 'String' && transform?.[typeNode.value.value]) {
|
|
270
|
+
const result = transform[typeNode.value.value]?.(evaluate(node.value), subpath.join('.'), node);
|
|
261
271
|
if (result) {
|
|
262
272
|
node.value = parseJSON(result).body;
|
|
263
273
|
}
|