1 | import { Dict, Option } from '@glimmer/interfaces';
|
2 | export declare type BuilderParams = BuilderExpression[];
|
3 | export declare type BuilderHash = Option<Dict<BuilderExpression>>;
|
4 | export declare type BuilderBlockHash = BuilderHash | {
|
5 | as: string | string[];
|
6 | };
|
7 | export declare type BuilderBlocks = Dict<BuilderBlock>;
|
8 | export declare type BuilderAttrs = Dict<BuilderAttr>;
|
9 | export interface NormalizedParams extends Recursive<readonly NormalizedExpression[]> {
|
10 | }
|
11 | export interface NormalizedHash extends Recursive<Dict<NormalizedExpression>> {
|
12 | }
|
13 | export interface NormalizedBlock extends Recursive<NormalizedStatement[]> {
|
14 | }
|
15 | export interface NormalizedBlocks extends Recursive<Dict<NormalizedBlock>> {
|
16 | }
|
17 | export interface NormalizedAttrs extends Recursive<Dict<NormalizedAttr>> {
|
18 | }
|
19 | export declare type NormalizedAttr = HeadKind.Splat | NormalizedExpression;
|
20 | export interface NormalizedElement {
|
21 | name: string;
|
22 | attrs: Option<NormalizedAttrs>;
|
23 | block: Option<NormalizedBlock>;
|
24 | }
|
25 | export interface NormalizedAngleInvocation {
|
26 | head: NormalizedExpression;
|
27 | attrs: Option<NormalizedAttrs>;
|
28 | block: Option<NormalizedBlock>;
|
29 | }
|
30 | export declare const enum HeadKind {
|
31 | Block = "Block",
|
32 | Call = "Call",
|
33 | Element = "Element",
|
34 | AppendPath = "AppendPath",
|
35 | AppendExpr = "AppendExpr",
|
36 | Literal = "Literal",
|
37 | Modifier = "Modifier",
|
38 | DynamicComponent = "DynamicComponent",
|
39 | Comment = "Comment",
|
40 | Splat = "Splat"
|
41 | }
|
42 | export declare enum VariableKind {
|
43 | Local = "Local",
|
44 | Free = "Free",
|
45 | Arg = "Arg",
|
46 | Block = "Block",
|
47 | This = "This"
|
48 | }
|
49 | export interface Variable {
|
50 | kind: VariableKind;
|
51 | name: string;
|
52 | }
|
53 | export interface Path {
|
54 | variable: Variable;
|
55 | tail: string[];
|
56 | }
|
57 | export interface AppendExpr {
|
58 | kind: HeadKind.AppendExpr;
|
59 | expr: NormalizedExpression;
|
60 | trusted: boolean;
|
61 | }
|
62 | export interface AppendPath {
|
63 | kind: HeadKind.AppendPath;
|
64 | path: Path;
|
65 | trusted: boolean;
|
66 | }
|
67 | export declare type NormalizedStatement = {
|
68 | kind: HeadKind.Call;
|
69 | path: Path;
|
70 | params: Option<NormalizedParams>;
|
71 | hash: Option<NormalizedHash>;
|
72 | trusted: boolean;
|
73 | } | {
|
74 | kind: HeadKind.Block;
|
75 | path: Path;
|
76 | params: Option<NormalizedParams>;
|
77 | hash: Option<NormalizedHash>;
|
78 | blockParams: Option<string[]>;
|
79 | blocks: NormalizedBlocks;
|
80 | } | {
|
81 | kind: HeadKind.Element;
|
82 | name: string;
|
83 | attrs: NormalizedAttrs;
|
84 | block: NormalizedBlock;
|
85 | } | {
|
86 | kind: HeadKind.Comment;
|
87 | value: string;
|
88 | } | {
|
89 | kind: HeadKind.Literal;
|
90 | value: string;
|
91 | } | AppendPath | AppendExpr | {
|
92 | kind: HeadKind.Modifier;
|
93 | params: NormalizedParams;
|
94 | hash: Option<NormalizedHash>;
|
95 | } | {
|
96 | kind: HeadKind.DynamicComponent;
|
97 | expr: NormalizedExpression;
|
98 | hash: Option<NormalizedHash>;
|
99 | block: NormalizedBlock;
|
100 | };
|
101 | export declare function normalizeStatement(statement: BuilderStatement): NormalizedStatement;
|
102 | export declare type SugaryArrayStatement = BuilderCallExpression | BuilderElement | BuilderBlockStatement;
|
103 | export declare function normalizeSugaryArrayStatement(statement: SugaryArrayStatement): NormalizedStatement;
|
104 | export declare function normalizePathHead(whole: string): Variable;
|
105 | export declare type BuilderBlockStatement = [string, BuilderBlock | BuilderBlocks] | [string, BuilderParams | BuilderBlockHash, BuilderBlock | BuilderBlocks] | [string, BuilderParams, BuilderBlockHash, BuilderBlock | BuilderBlocks];
|
106 | export interface NormalizedBuilderBlockStatement {
|
107 | head: Path;
|
108 | params: Option<NormalizedParams>;
|
109 | hash: Option<NormalizedHash>;
|
110 | blockParams: Option<string[]>;
|
111 | blocks: NormalizedBlocks;
|
112 | }
|
113 | export declare function normalizeBuilderBlockStatement(statement: BuilderBlockStatement): NormalizedBuilderBlockStatement;
|
114 | export declare function entries<D extends Dict>(dict: D, callback: <K extends keyof D>(key: K, value: D[K]) => void): void;
|
115 | export declare type BuilderElement = [string] | [string, BuilderAttrs, BuilderBlock] | [string, BuilderBlock] | [string, BuilderAttrs];
|
116 | export declare type BuilderComment = [Builder.Comment, string];
|
117 | export declare type InvocationElement = [string] | [string, BuilderAttrs, BuilderBlock] | [string, BuilderBlock] | [string, BuilderAttrs];
|
118 | export declare function isElement(input: [string, ...unknown[]]): input is BuilderElement;
|
119 | export declare function extractElement(input: string): Option<string>;
|
120 | export declare function extractAngleInvocation(input: string): Option<string>;
|
121 | export declare function isAngleInvocation(input: [string, ...unknown[]]): input is InvocationElement;
|
122 | export declare function isBlock(input: [string, ...unknown[]]): input is BuilderBlockStatement;
|
123 | export declare const enum Builder {
|
124 | Literal = 0,
|
125 | Comment = 1,
|
126 | Append = 2,
|
127 | Modifier = 3,
|
128 | DynamicComponent = 4,
|
129 | Get = 5,
|
130 | Concat = 6,
|
131 | HasBlock = 7,
|
132 | HasBlockParams = 8
|
133 | }
|
134 | export declare type VerboseStatement = [Builder.Literal, string] | [Builder.Comment, string] | [Builder.Append, BuilderExpression, true] | [Builder.Append, BuilderExpression] | [Builder.Modifier, Params, Hash] | [Builder.DynamicComponent, BuilderExpression, Hash, BuilderBlock];
|
135 | export declare type BuilderStatement = VerboseStatement | SugaryArrayStatement | TupleBuilderExpression | string;
|
136 | export declare type BuilderAttr = 'splat' | BuilderExpression;
|
137 | export declare type TupleBuilderExpression = [Builder.Literal, string | boolean | null | undefined] | [Builder.Get, string] | [Builder.Get, string, string[]] | [Builder.Concat, ...any[]] | [Builder.HasBlock, string] | [Builder.HasBlockParams, string] | BuilderCallExpression;
|
138 | declare type Recursive<T> = T;
|
139 | interface Params extends Recursive<BuilderParams> {
|
140 | }
|
141 | interface Hash extends Recursive<Dict<BuilderExpression>> {
|
142 | }
|
143 | export declare const enum ExpressionKind {
|
144 | Literal = "Literal",
|
145 | Call = "Call",
|
146 | Get = "Get",
|
147 | Concat = "Concat",
|
148 | HasBlock = "HasBlock",
|
149 | HasBlockParams = "HasBlockParams"
|
150 | }
|
151 | export interface NormalizedCallExpression {
|
152 | type: ExpressionKind.Call;
|
153 | path: Path;
|
154 | params: Option<NormalizedParams>;
|
155 | hash: Option<NormalizedHash>;
|
156 | }
|
157 | export interface NormalizedPath {
|
158 | type: ExpressionKind.Get;
|
159 | path: Path;
|
160 | }
|
161 | export interface NormalizedConcat {
|
162 | type: ExpressionKind.Concat;
|
163 | params: Recursive<[NormalizedExpression, ...NormalizedExpression[]]>;
|
164 | }
|
165 | export declare type NormalizedExpression = {
|
166 | type: ExpressionKind.Literal;
|
167 | value: null | undefined | boolean | string | number;
|
168 | } | NormalizedCallExpression | NormalizedPath | NormalizedConcat | {
|
169 | type: ExpressionKind.HasBlock;
|
170 | name: string;
|
171 | } | {
|
172 | type: ExpressionKind.HasBlockParams;
|
173 | name: string;
|
174 | };
|
175 | export declare function normalizeAppendExpression(expression: BuilderExpression, forceTrusted?: boolean): AppendExpr | AppendPath;
|
176 | export declare function normalizeExpression(expression: BuilderExpression): NormalizedExpression;
|
177 | export declare type BuilderExpression = TupleBuilderExpression | BuilderCallExpression | null | undefined | boolean | string | number;
|
178 | export declare function isBuilderExpression(expr: BuilderExpression | BuilderCallExpression): expr is TupleBuilderExpression | BuilderCallExpression;
|
179 | export declare function isTupleBuilderExpression(expr: BuilderExpression | BuilderCallExpression): expr is TupleBuilderExpression;
|
180 | export declare function isLiteral(expr: BuilderExpression | BuilderCallExpression): expr is [Builder.Literal, string | boolean | undefined];
|
181 | export declare function statementIsExpression(statement: BuilderStatement): statement is TupleBuilderExpression;
|
182 | export declare function isBuilderCallExpression(value: TupleBuilderExpression | BuilderCallExpression): value is BuilderCallExpression;
|
183 | export interface MiniBuilderBlock extends Recursive<BuilderStatement[]> {
|
184 | }
|
185 | export declare type BuilderBlock = MiniBuilderBlock;
|
186 | export declare type BuilderCallExpression = [string] | [string, Params | Hash] | [string, Params, Hash];
|
187 | export declare function normalizeParams(input: Params): NormalizedParams;
|
188 | export declare function normalizeHash(input: Option<Hash>): Option<NormalizedHash>;
|
189 | export declare function normalizeCallExpression(expr: BuilderCallExpression): NormalizedCallExpression;
|
190 | export {};
|
191 |
|
\ | No newline at end of file |