UNPKG

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