1 | import type { Dict, Maybe, Nullable } from '@glimmer/interfaces';
|
2 | import type { SourceLocation, SourcePosition } from '../source/location';
|
3 | import type * as ASTv1 from './api';
|
4 | import { SourceSpan } from '../source/span';
|
5 | export type BuilderHead = string | ASTv1.CallableExpression;
|
6 | export type TagDescriptor = string | ASTv1.PathExpression | {
|
7 | path: ASTv1.PathExpression;
|
8 | selfClosing?: boolean;
|
9 | } | {
|
10 | name: string;
|
11 | selfClosing?: boolean;
|
12 | };
|
13 | declare function buildMustache(path: BuilderHead | ASTv1.Literal, params?: ASTv1.Expression[], hash?: ASTv1.Hash, trusting?: boolean, loc?: SourceLocation, strip?: ASTv1.StripFlags): ASTv1.MustacheStatement;
|
14 | type PossiblyDeprecatedBlock = ASTv1.Block | ASTv1.Template;
|
15 | declare function buildBlock(path: BuilderHead, params: Nullable<ASTv1.Expression[]>, hash: Nullable<ASTv1.Hash>, _defaultBlock: PossiblyDeprecatedBlock, _elseBlock?: Nullable<PossiblyDeprecatedBlock>, loc?: SourceLocation, openStrip?: ASTv1.StripFlags, inverseStrip?: ASTv1.StripFlags, closeStrip?: ASTv1.StripFlags): ASTv1.BlockStatement;
|
16 | declare function buildElementModifier(path: BuilderHead, params?: ASTv1.Expression[], hash?: ASTv1.Hash, loc?: Nullable<SourceLocation>): ASTv1.ElementModifierStatement;
|
17 | declare function buildComment(value: string, loc?: SourceLocation): ASTv1.CommentStatement;
|
18 | declare function buildMustacheComment(value: string, loc?: SourceLocation): ASTv1.MustacheCommentStatement;
|
19 | declare function buildConcat(parts: (ASTv1.TextNode | ASTv1.MustacheStatement)[], loc?: SourceLocation): ASTv1.ConcatStatement;
|
20 | export type ElementParts = ['attrs', ...AttrSexp[]] | ['modifiers', ...ModifierSexp[]] | ['body', ...ASTv1.Statement[]] | ['comments', ...ElementComment[]] | ['as', ...string[]] | ['loc', SourceLocation];
|
21 | export type PathSexp = string | ['path', string, LocSexp?];
|
22 | export type ModifierSexp = string | [PathSexp, LocSexp?] | [PathSexp, ASTv1.Expression[], LocSexp?] | [PathSexp, ASTv1.Expression[], Dict<ASTv1.Expression>, LocSexp?];
|
23 | export type AttrSexp = [string, ASTv1.AttrNode['value'] | string, LocSexp?];
|
24 | export type LocSexp = ['loc', SourceLocation];
|
25 | export type ElementComment = ASTv1.MustacheCommentStatement | SourceLocation | string;
|
26 | export type SexpValue = string | ASTv1.Expression[] | Dict<ASTv1.Expression> | LocSexp | PathSexp | undefined;
|
27 | export interface BuildElementOptions {
|
28 | attrs?: ASTv1.AttrNode[];
|
29 | modifiers?: ASTv1.ElementModifierStatement[];
|
30 | children?: ASTv1.Statement[];
|
31 | comments?: ASTv1.MustacheCommentStatement[];
|
32 | blockParams?: ASTv1.VarHead[] | string[];
|
33 | openTag?: SourceLocation;
|
34 | closeTag?: Maybe<SourceLocation>;
|
35 | loc?: SourceLocation;
|
36 | }
|
37 | declare function buildElement(tag: TagDescriptor, options?: BuildElementOptions): ASTv1.ElementNode;
|
38 | declare function buildAttr(name: string, value: ASTv1.AttrValue, loc?: SourceLocation): ASTv1.AttrNode;
|
39 | declare function buildText(chars?: string, loc?: SourceLocation): ASTv1.TextNode;
|
40 | declare function buildSexpr(path: BuilderHead, params?: ASTv1.Expression[], hash?: ASTv1.Hash, loc?: SourceLocation): ASTv1.SubExpression;
|
41 | declare function buildThis(loc?: SourceLocation): ASTv1.ThisHead;
|
42 | declare function buildAtName(name: string, loc?: SourceLocation): ASTv1.AtHead;
|
43 | declare function buildVar(name: string, loc?: SourceLocation): ASTv1.VarHead;
|
44 | declare function buildHeadFromString(original: string, loc?: SourceLocation): ASTv1.PathHead;
|
45 | declare function buildCleanPath(head: ASTv1.PathHead, tail?: string[], loc?: SourceLocation): ASTv1.PathExpression;
|
46 | declare function buildPath(path: ASTv1.PathExpression | string | {
|
47 | head: string;
|
48 | tail: string[];
|
49 | }, loc?: SourceLocation): ASTv1.PathExpression;
|
50 | declare function buildPath(path: BuilderHead, loc?: SourceLocation): ASTv1.CallableExpression;
|
51 | declare function buildPath(path: BuilderHead | ASTv1.Literal | ASTv1.Expression, loc?: SourceLocation): ASTv1.Expression;
|
52 | declare function buildLiteral<T extends ASTv1.Literal>(type: T['type'], value: T['value'], loc?: SourceLocation): T;
|
53 | declare function buildHash(pairs?: ASTv1.HashPair[], loc?: SourceLocation): ASTv1.Hash;
|
54 | declare function buildPair(key: string, value: ASTv1.Expression, loc?: SourceLocation): ASTv1.HashPair;
|
55 | declare function buildProgram(body?: ASTv1.Statement[], blockParams?: string[], loc?: SourceLocation): ASTv1.Template | ASTv1.Block;
|
56 | declare function buildBlockItself(body?: ASTv1.Statement[], params?: Array<ASTv1.VarHead | string>, chained?: boolean, loc?: SourceLocation): ASTv1.Block;
|
57 | declare function buildTemplate(body?: ASTv1.Statement[], blockParams?: string[], loc?: SourceLocation): ASTv1.Template;
|
58 | declare function buildPosition(line: number, column: number): SourcePosition;
|
59 | declare function buildLoc(loc: Nullable<SourceLocation>): SourceSpan;
|
60 | declare function buildLoc(startLine: number, startColumn: number, endLine?: number, endColumn?: number, source?: string): SourceSpan;
|
61 | declare const _default: {
|
62 | mustache: typeof buildMustache;
|
63 | block: typeof buildBlock;
|
64 | comment: typeof buildComment;
|
65 | mustacheComment: typeof buildMustacheComment;
|
66 | element: typeof buildElement;
|
67 | elementModifier: typeof buildElementModifier;
|
68 | attr: typeof buildAttr;
|
69 | text: typeof buildText;
|
70 | sexpr: typeof buildSexpr;
|
71 | concat: typeof buildConcat;
|
72 | hash: typeof buildHash;
|
73 | pair: typeof buildPair;
|
74 | literal: typeof buildLiteral;
|
75 | program: typeof buildProgram;
|
76 | blockItself: typeof buildBlockItself;
|
77 | template: typeof buildTemplate;
|
78 | loc: typeof buildLoc;
|
79 | pos: typeof buildPosition;
|
80 | path: typeof buildPath;
|
81 | fullPath: typeof buildCleanPath;
|
82 | head: typeof buildHeadFromString;
|
83 | at: typeof buildAtName;
|
84 | var: typeof buildVar;
|
85 | this: typeof buildThis;
|
86 | string: (value: string) => ASTv1.StringLiteral;
|
87 | boolean: (value: boolean) => ASTv1.BooleanLiteral;
|
88 | number: (value: number) => ASTv1.NumberLiteral;
|
89 | undefined(): ASTv1.UndefinedLiteral;
|
90 | null(): ASTv1.NullLiteral;
|
91 | };
|
92 | export default _default;
|