@@ -1700,6 +1700,37 @@ export type GenerateFunction = (ast: AnyCssNode, options?: GenerateOptions) => s
1700
1700
*/
1701
1701
export const generate : GenerateFunction ;
1702
1702
1703
+ /**
1704
+ * Represents the context object passed to a Node's `generate` function.
1705
+ * @see https://github.com/csstree/csstree/blob/56afb6dd761149099cd3cdfb0a38e15e8cc0a71a/lib/generator/create.js#L86-L91
1706
+ */
1707
+ export interface GeneratorContext {
1708
+ /**
1709
+ * Tokenizes a string or node.
1710
+ * @param value - The value to tokenize.
1711
+ */
1712
+ tokenize ( value : string ) : void ;
1713
+
1714
+ /**
1715
+ * Processes a child node.
1716
+ * @param node - The child node to process.
1717
+ */
1718
+ node ( node : CssNode ) : void ;
1719
+
1720
+ /**
1721
+ * Processes all children of a node.
1722
+ * @param node - The parent node whose children are processed.
1723
+ */
1724
+ children ( node : CssNode ) : void ;
1725
+
1726
+ /**
1727
+ * Emits a token with a specific type and value.
1728
+ * @param type - The type of the token.
1729
+ * @param value - The value of the token.
1730
+ */
1731
+ token ( type : number , value : string ) : void ;
1732
+ }
1733
+
1703
1734
// ----------------------------------------------------------
1704
1735
// Walker
1705
1736
// ----------------------------------------------------------
@@ -2720,7 +2751,7 @@ interface NodeSyntaxConfig<T extends CssNodeCommon = CssNodeCommon> {
2720
2751
name : string ;
2721
2752
structure : StructureDefinition ;
2722
2753
parse ( this : ParserContext , ...args :Array < unknown > ) : T ;
2723
- generate ( this : ParserContext , node : T ) : void ;
2754
+ generate ( this : GeneratorContext , node : T ) : void ;
2724
2755
walkContext ?: string ;
2725
2756
}
2726
2757
0 commit comments