UNPKG

1.92 kBTypeScriptView Raw
1import type { PrecompileOptions, PrecompileOptionsWithLexicalScope } from '../parser/tokenizer-event-handlers';
2import type { SourceLocation } from '../source/location';
3import type { Source } from '../source/source';
4import type { SourceSpan } from '../source/span';
5import type { BlockSymbolTable } from '../symbol-table';
6import type * as ASTv1 from '../v1/api';
7import type { Resolution } from './loose-resolution';
8import { SymbolTable } from '../symbol-table';
9import * as ASTv2 from './api';
10import { Builder } from './builders';
11export declare function normalize(source: Source, options?: PrecompileOptionsWithLexicalScope): [ast: ASTv2.Template, locals: string[]];
12/**
13 * A `BlockContext` represents the block that a particular AST node is contained inside of.
14 *
15 * `BlockContext` is aware of template-wide options (such as strict mode), as well as the bindings
16 * that are in-scope within that block.
17 *
18 * Concretely, it has the `PrecompileOptions` and current `SymbolTable`, and provides
19 * facilities for working with those options.
20 *
21 * `BlockContext` is stateless.
22 */
23export declare class BlockContext<Table extends SymbolTable = SymbolTable> {
24 readonly source: Source;
25 private readonly options;
26 readonly table: Table;
27 readonly builder: Builder;
28 constructor(source: Source, options: PrecompileOptions, table: Table);
29 get strict(): boolean;
30 loc(loc: SourceLocation): SourceSpan;
31 resolutionFor<N extends ASTv1.CallNode | ASTv1.PathExpression>(node: N, resolution: Resolution<N>): {
32 result: ASTv2.FreeVarResolution;
33 } | {
34 result: 'error';
35 path: string;
36 head: string;
37 };
38 isLexicalVar(variable: string): boolean;
39 isKeyword(name: string): boolean;
40 private isFreeVar;
41 hasBinding(name: string): boolean;
42 child(blockParams: string[]): BlockContext<BlockSymbolTable>;
43 customizeComponentName(input: string): string;
44}