@@ -668,9 +668,12 @@ export function traverseToken({
668668 existingVariables,
669669 isPrimitivesFile = false ,
670670} : TraverseTokenParams ) : void {
671+ console . log ( `DEBUG traverseToken - ENTER: key="${ key } ", hasValue=${ object . $value !== undefined } , type=${ object . $type || type } , isPrimitivesFile=${ isPrimitivesFile } ` ) ;
672+
671673 const resolvedType = ( type || object . $type ) as DTCGTokenType | undefined ;
672674
673675 if ( key . charAt ( 0 ) === "$" ) {
676+ console . log ( `DEBUG traverseToken - SKIPPING key starting with $: "${ key } "` ) ;
674677 return ;
675678 }
676679
@@ -681,6 +684,7 @@ export function traverseToken({
681684 const modeExtensions = object . $extensions ?. mode ;
682685
683686 if ( object . $value !== undefined ) {
687+ console . log ( `DEBUG traverseToken - Processing token with $value: "${ finalKey } "` ) ;
684688 const value = object . $value ;
685689
686690 if ( isAlias ( value ) ) {
@@ -691,6 +695,7 @@ export function traverseToken({
691695 . replace ( / [ { } ] / g, "" ) ;
692696
693697 const allTokens = { ...existingVariables , ...tokens } ;
698+ console . log ( `DEBUG traverseToken - Alias check: "${ finalKey } " -> "${ valueKey } ", found=${ ! ! allTokens [ valueKey ] } ` ) ;
694699
695700 if ( allTokens [ valueKey ] ) {
696701
@@ -746,6 +751,7 @@ export function traverseToken({
746751 } ,
747752 } ;
748753 } else {
754+ console . log ( `DEBUG traverseToken - Creating mode-aware alias token: "${ finalKey } "` ) ;
749755 tokens [ finalKey ] = createVariableAlias (
750756 collection ,
751757 modeId ,
@@ -759,21 +765,26 @@ export function traverseToken({
759765 : undefined ,
760766 existingVariables ,
761767 ) ;
768+ console . log ( `DEBUG traverseToken - SUCCESS: Created mode-aware alias token "${ finalKey } "` ) ;
762769 }
763770 } else {
771+ // Token is mode-agnostic but collection has modes - pass modeIds to set value for ALL modes
772+ console . log ( `DEBUG traverseToken - Creating mode-agnostic alias token: "${ finalKey } " with modeIds` ) ;
764773 tokens [ finalKey ] = createVariableAlias (
765774 collection ,
766775 modeId ,
767776 finalKey ,
768777 valueKey ,
769778 allTokens ,
770779 scopes ,
771- undefined ,
780+ modeIds , // Pass modeIds even without modeExtensions
772781 undefined ,
773782 existingVariables ,
774783 ) ;
784+ console . log ( `DEBUG traverseToken - SUCCESS: Created mode-agnostic alias token "${ finalKey } "` ) ;
775785 }
776786 } else {
787+ console . log ( `DEBUG traverseToken - Adding to aliases: "${ finalKey } " -> "${ valueKey } " (target not found yet)` ) ;
777788 aliases [ finalKey ] = {
778789 key : finalKey ,
779790 type : resolvedType ,
@@ -830,6 +841,7 @@ export function traverseToken({
830841 }
831842 }
832843
844+ console . log ( `DEBUG traverseToken - Creating color token: "${ finalKey } "` ) ;
833845 tokens [ finalKey ] = createToken (
834846 collection ,
835847 modeId ,
@@ -842,6 +854,7 @@ export function traverseToken({
842854 modeIds ,
843855 colorModeValues ,
844856 ) ;
857+ console . log ( `DEBUG traverseToken - SUCCESS: Created color token "${ finalKey } "` ) ;
845858 } else if ( resolvedType === "number" || resolvedType === "dimension" ) {
846859
847860
@@ -883,6 +896,7 @@ export function traverseToken({
883896 }
884897 }
885898
899+ console . log ( `DEBUG traverseToken - Creating number/dimension token: "${ finalKey } " with value ${ numericValue } ` ) ;
886900 tokens [ finalKey ] = createToken (
887901 collection ,
888902 modeId ,
@@ -895,10 +909,13 @@ export function traverseToken({
895909 modeIds ,
896910 numberModeValues ,
897911 ) ;
912+ console . log ( `DEBUG traverseToken - SUCCESS: Created number/dimension token "${ finalKey } "` ) ;
898913 } else {
899- console . log ( " unsupported type" , resolvedType , object ) ;
914+ console . log ( `DEBUG traverseToken - unsupported type for " ${ finalKey } ":` , resolvedType , object ) ;
900915 }
901916 } else if ( typeof object === "object" && object !== null ) {
917+ const childKeys = Object . keys ( object ) . filter ( k => ! k . startsWith ( '$' ) ) ;
918+ console . log ( `DEBUG traverseToken - Recursing into "${ finalKey } " with ${ childKeys . length } children: ${ childKeys . slice ( 0 , 5 ) . join ( ', ' ) } ${ childKeys . length > 5 ? '...' : '' } ` ) ;
902919 Object . entries ( object ) . forEach ( ( [ key2 , object2 ] ) => {
903920 if ( key2 . charAt ( 0 ) !== "$" ) {
904921 const newKey = finalKey ? `${ finalKey } /${ key2 } ` : key2 ;
@@ -916,7 +933,10 @@ export function traverseToken({
916933 } ) ;
917934 }
918935 } ) ;
936+ } else {
937+ console . log ( `DEBUG traverseToken - SKIPPING "${ finalKey } ": not an object and no $value` ) ;
919938 }
939+ console . log ( `DEBUG traverseToken - EXIT: "${ finalKey } "` ) ;
920940}
921941
922942export async function processAliases ( {
0 commit comments