UNPKG

2.89 kBTypeScriptView Raw
1import type * as ASTv1 from '../v1/api';
2export declare const voidMap: Set<string>;
3export declare function getVoidTags(): string[];
4export interface PrinterOptions {
5 entityEncoding: ASTv1.EntityEncodingState;
6 /**
7 * Used to override the mechanism of printing a given AST.Node.
8 *
9 * This will generally only be useful to source -> source codemods
10 * where you would like to specialize/override the way a given node is
11 * printed (e.g. you would like to preserve as much of the original
12 * formatting as possible).
13 *
14 * When the provided override returns undefined, the default built in printing
15 * will be done for the AST.Node.
16 *
17 * @param ast the ast node to be printed
18 * @param options the options specified during the print() invocation
19 */
20 override?(ast: ASTv1.Node, options: PrinterOptions): void | string;
21}
22/**
23 * Examples when true:
24 * - link
25 * - liNK
26 *
27 * Examples when false:
28 * - Link (component)
29 */
30export declare function isVoidTag(tag: string): boolean;
31export default class Printer {
32 private buffer;
33 private options;
34 constructor(options: PrinterOptions);
35 handledByOverride(node: ASTv1.Node, ensureLeadingWhitespace?: boolean): boolean;
36 Node(node: ASTv1.Node): void;
37 Expression(expression: ASTv1.Expression): void;
38 Literal(literal: ASTv1.Literal): void;
39 TopLevelStatement(statement: ASTv1.TopLevelStatement | ASTv1.Template | ASTv1.AttrNode): void;
40 Template(template: ASTv1.Template): void;
41 Block(block: ASTv1.Block): void;
42 TopLevelStatements(statements: ASTv1.TopLevelStatement[]): void;
43 ElementNode(el: ASTv1.ElementNode): void;
44 OpenElementNode(el: ASTv1.ElementNode): void;
45 CloseElementNode(el: ASTv1.ElementNode): void;
46 AttrNode(attr: ASTv1.AttrNode): void;
47 AttrNodeValue(value: ASTv1.AttrNode['value']): void;
48 TextNode(text: ASTv1.TextNode, isAttr?: boolean): void;
49 MustacheStatement(mustache: ASTv1.MustacheStatement): void;
50 BlockStatement(block: ASTv1.BlockStatement): void;
51 BlockParams(blockParams: string[]): void;
52 ConcatStatement(concat: ASTv1.ConcatStatement): void;
53 MustacheCommentStatement(comment: ASTv1.MustacheCommentStatement): void;
54 ElementModifierStatement(mod: ASTv1.ElementModifierStatement): void;
55 CommentStatement(comment: ASTv1.CommentStatement): void;
56 PathExpression(path: ASTv1.PathExpression): void;
57 SubExpression(sexp: ASTv1.SubExpression): void;
58 Params(params: ASTv1.Expression[]): void;
59 Hash(hash: ASTv1.Hash): void;
60 HashPair(pair: ASTv1.HashPair): void;
61 StringLiteral(str: ASTv1.StringLiteral): void;
62 BooleanLiteral(bool: ASTv1.BooleanLiteral): void;
63 NumberLiteral(number: ASTv1.NumberLiteral): void;
64 UndefinedLiteral(node: ASTv1.UndefinedLiteral): void;
65 NullLiteral(node: ASTv1.NullLiteral): void;
66 print(node: ASTv1.Node): string;
67}