Skip to content

Commit 3a095b8

Browse files
committed
checkpoint
1 parent ee010b3 commit 3a095b8

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

src/loader/merge.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,11 @@ export const mergeFormats = (formats: Format[], root?: RawObject, inheritedType?
7070

7171
if (subFormats.length > 0) {
7272
// Pass along the current node's effective type so children can inherit it.
73-
value = mergeFormats(subFormats as Format[], effectiveRoot, getNodeType());
73+
const sub = mergeFormats(subFormats as Format[], effectiveRoot, getNodeType()) as unknown as RawObject;
74+
// Leaf token: unwrap to the resolved value so callers get the value
75+
// directly (e.g. tokens["box-shadow"].panel → shadow array, not { $type, $value }).
76+
// Group nodes have no $value and pass through as-is.
77+
value = "$value" in sub ? sub.$value : sub;
7478
} else if (hasLeaf) {
7579
// Deeply resolve aliases and $ref objects inside $value.
7680
value = key === "$value" ? resolveDeep(leafValue, effectiveRoot) : leafValue;

src/scratch.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,11 @@ const resolverURL = new URL("../src/test/example/design-tokens.resolver.json", i
44

55
const { tokens } = load(resolverURL);
66

7-
// $ref objects and alias strings inside composite $value should be fully resolved
8-
const shadow = (tokens as any)["box-shadow"].panel.$value;
9-
console.log(JSON.stringify(shadow, null, 2));
7+
// Leaf token: should be the resolved value directly, no $type/$value wrapper
8+
console.log("panel shadow:", JSON.stringify((tokens as any)["box-shadow"].panel, null, 2));
109

11-
// Spot-check: components should be an array, not a { $ref: "…" } object
12-
const components = shadow[0].color.components;
13-
console.log("components resolved:", Array.isArray(components), components);
10+
// Group node: should still be a navigable object
11+
console.log("box-shadow group $type:", (tokens as any)["box-shadow"].$type);
1412

15-
// Alias resolution: "{base.zero}" inside the shadow value should be a dimension object
16-
const offsetY = shadow[0].offsetY;
17-
console.log("offsetY resolved:", offsetY);
13+
// Alias resolution inside the value
14+
console.log("panel[0].offsetX:", (tokens as any)["box-shadow"].panel[0].offsetX);

0 commit comments

Comments
 (0)