[6a3a178] | 1 | /**
|
---|
| 2 | * @license
|
---|
| 3 | * Copyright Google LLC All Rights Reserved.
|
---|
| 4 | *
|
---|
| 5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 6 | * found in the LICENSE file at https://angular.io/license
|
---|
| 7 | */
|
---|
| 8 | import { SecurityContext } from '../core';
|
---|
| 9 | import { AST, BindingType, BoundElementProperty, ParsedEvent, ParsedEventType } from '../expression_parser/ast';
|
---|
| 10 | import { I18nMeta } from '../i18n/i18n_ast';
|
---|
| 11 | import { ParseSourceSpan } from '../parse_util';
|
---|
| 12 | export interface Node {
|
---|
| 13 | sourceSpan: ParseSourceSpan;
|
---|
| 14 | visit<Result>(visitor: Visitor<Result>): Result;
|
---|
| 15 | }
|
---|
| 16 | /**
|
---|
| 17 | * This is an R3 `Node`-like wrapper for a raw `html.Comment` node. We do not currently
|
---|
| 18 | * require the implementation of a visitor for Comments as they are only collected at
|
---|
| 19 | * the top-level of the R3 AST, and only if `Render3ParseOptions['collectCommentNodes']`
|
---|
| 20 | * is true.
|
---|
| 21 | */
|
---|
| 22 | export declare class Comment implements Node {
|
---|
| 23 | value: string;
|
---|
| 24 | sourceSpan: ParseSourceSpan;
|
---|
| 25 | constructor(value: string, sourceSpan: ParseSourceSpan);
|
---|
| 26 | visit<Result>(_visitor: Visitor<Result>): Result;
|
---|
| 27 | }
|
---|
| 28 | export declare class Text implements Node {
|
---|
| 29 | value: string;
|
---|
| 30 | sourceSpan: ParseSourceSpan;
|
---|
| 31 | constructor(value: string, sourceSpan: ParseSourceSpan);
|
---|
| 32 | visit<Result>(visitor: Visitor<Result>): Result;
|
---|
| 33 | }
|
---|
| 34 | export declare class BoundText implements Node {
|
---|
| 35 | value: AST;
|
---|
| 36 | sourceSpan: ParseSourceSpan;
|
---|
| 37 | i18n?: I18nMeta | undefined;
|
---|
| 38 | constructor(value: AST, sourceSpan: ParseSourceSpan, i18n?: I18nMeta | undefined);
|
---|
| 39 | visit<Result>(visitor: Visitor<Result>): Result;
|
---|
| 40 | }
|
---|
| 41 | /**
|
---|
| 42 | * Represents a text attribute in the template.
|
---|
| 43 | *
|
---|
| 44 | * `valueSpan` may not be present in cases where there is no value `<div a></div>`.
|
---|
| 45 | * `keySpan` may also not be present for synthetic attributes from ICU expansions.
|
---|
| 46 | */
|
---|
| 47 | export declare class TextAttribute implements Node {
|
---|
| 48 | name: string;
|
---|
| 49 | value: string;
|
---|
| 50 | sourceSpan: ParseSourceSpan;
|
---|
| 51 | readonly keySpan: ParseSourceSpan | undefined;
|
---|
| 52 | valueSpan?: ParseSourceSpan | undefined;
|
---|
| 53 | i18n?: I18nMeta | undefined;
|
---|
| 54 | constructor(name: string, value: string, sourceSpan: ParseSourceSpan, keySpan: ParseSourceSpan | undefined, valueSpan?: ParseSourceSpan | undefined, i18n?: I18nMeta | undefined);
|
---|
| 55 | visit<Result>(visitor: Visitor<Result>): Result;
|
---|
| 56 | }
|
---|
| 57 | export declare class BoundAttribute implements Node {
|
---|
| 58 | name: string;
|
---|
| 59 | type: BindingType;
|
---|
| 60 | securityContext: SecurityContext;
|
---|
| 61 | value: AST;
|
---|
| 62 | unit: string | null;
|
---|
| 63 | sourceSpan: ParseSourceSpan;
|
---|
| 64 | readonly keySpan: ParseSourceSpan;
|
---|
| 65 | valueSpan: ParseSourceSpan | undefined;
|
---|
| 66 | i18n: I18nMeta | undefined;
|
---|
| 67 | constructor(name: string, type: BindingType, securityContext: SecurityContext, value: AST, unit: string | null, sourceSpan: ParseSourceSpan, keySpan: ParseSourceSpan, valueSpan: ParseSourceSpan | undefined, i18n: I18nMeta | undefined);
|
---|
| 68 | static fromBoundElementProperty(prop: BoundElementProperty, i18n?: I18nMeta): BoundAttribute;
|
---|
| 69 | visit<Result>(visitor: Visitor<Result>): Result;
|
---|
| 70 | }
|
---|
| 71 | export declare class BoundEvent implements Node {
|
---|
| 72 | name: string;
|
---|
| 73 | type: ParsedEventType;
|
---|
| 74 | handler: AST;
|
---|
| 75 | target: string | null;
|
---|
| 76 | phase: string | null;
|
---|
| 77 | sourceSpan: ParseSourceSpan;
|
---|
| 78 | handlerSpan: ParseSourceSpan;
|
---|
| 79 | readonly keySpan: ParseSourceSpan;
|
---|
| 80 | constructor(name: string, type: ParsedEventType, handler: AST, target: string | null, phase: string | null, sourceSpan: ParseSourceSpan, handlerSpan: ParseSourceSpan, keySpan: ParseSourceSpan);
|
---|
| 81 | static fromParsedEvent(event: ParsedEvent): BoundEvent;
|
---|
| 82 | visit<Result>(visitor: Visitor<Result>): Result;
|
---|
| 83 | }
|
---|
| 84 | export declare class Element implements Node {
|
---|
| 85 | name: string;
|
---|
| 86 | attributes: TextAttribute[];
|
---|
| 87 | inputs: BoundAttribute[];
|
---|
| 88 | outputs: BoundEvent[];
|
---|
| 89 | children: Node[];
|
---|
| 90 | references: Reference[];
|
---|
| 91 | sourceSpan: ParseSourceSpan;
|
---|
| 92 | startSourceSpan: ParseSourceSpan;
|
---|
| 93 | endSourceSpan: ParseSourceSpan | null;
|
---|
| 94 | i18n?: I18nMeta | undefined;
|
---|
| 95 | constructor(name: string, attributes: TextAttribute[], inputs: BoundAttribute[], outputs: BoundEvent[], children: Node[], references: Reference[], sourceSpan: ParseSourceSpan, startSourceSpan: ParseSourceSpan, endSourceSpan: ParseSourceSpan | null, i18n?: I18nMeta | undefined);
|
---|
| 96 | visit<Result>(visitor: Visitor<Result>): Result;
|
---|
| 97 | }
|
---|
| 98 | export declare class Template implements Node {
|
---|
| 99 | tagName: string;
|
---|
| 100 | attributes: TextAttribute[];
|
---|
| 101 | inputs: BoundAttribute[];
|
---|
| 102 | outputs: BoundEvent[];
|
---|
| 103 | templateAttrs: (BoundAttribute | TextAttribute)[];
|
---|
| 104 | children: Node[];
|
---|
| 105 | references: Reference[];
|
---|
| 106 | variables: Variable[];
|
---|
| 107 | sourceSpan: ParseSourceSpan;
|
---|
| 108 | startSourceSpan: ParseSourceSpan;
|
---|
| 109 | endSourceSpan: ParseSourceSpan | null;
|
---|
| 110 | i18n?: I18nMeta | undefined;
|
---|
| 111 | constructor(tagName: string, attributes: TextAttribute[], inputs: BoundAttribute[], outputs: BoundEvent[], templateAttrs: (BoundAttribute | TextAttribute)[], children: Node[], references: Reference[], variables: Variable[], sourceSpan: ParseSourceSpan, startSourceSpan: ParseSourceSpan, endSourceSpan: ParseSourceSpan | null, i18n?: I18nMeta | undefined);
|
---|
| 112 | visit<Result>(visitor: Visitor<Result>): Result;
|
---|
| 113 | }
|
---|
| 114 | export declare class Content implements Node {
|
---|
| 115 | selector: string;
|
---|
| 116 | attributes: TextAttribute[];
|
---|
| 117 | sourceSpan: ParseSourceSpan;
|
---|
| 118 | i18n?: I18nMeta | undefined;
|
---|
| 119 | readonly name = "ng-content";
|
---|
| 120 | constructor(selector: string, attributes: TextAttribute[], sourceSpan: ParseSourceSpan, i18n?: I18nMeta | undefined);
|
---|
| 121 | visit<Result>(visitor: Visitor<Result>): Result;
|
---|
| 122 | }
|
---|
| 123 | export declare class Variable implements Node {
|
---|
| 124 | name: string;
|
---|
| 125 | value: string;
|
---|
| 126 | sourceSpan: ParseSourceSpan;
|
---|
| 127 | readonly keySpan: ParseSourceSpan;
|
---|
| 128 | valueSpan?: ParseSourceSpan | undefined;
|
---|
| 129 | constructor(name: string, value: string, sourceSpan: ParseSourceSpan, keySpan: ParseSourceSpan, valueSpan?: ParseSourceSpan | undefined);
|
---|
| 130 | visit<Result>(visitor: Visitor<Result>): Result;
|
---|
| 131 | }
|
---|
| 132 | export declare class Reference implements Node {
|
---|
| 133 | name: string;
|
---|
| 134 | value: string;
|
---|
| 135 | sourceSpan: ParseSourceSpan;
|
---|
| 136 | readonly keySpan: ParseSourceSpan;
|
---|
| 137 | valueSpan?: ParseSourceSpan | undefined;
|
---|
| 138 | constructor(name: string, value: string, sourceSpan: ParseSourceSpan, keySpan: ParseSourceSpan, valueSpan?: ParseSourceSpan | undefined);
|
---|
| 139 | visit<Result>(visitor: Visitor<Result>): Result;
|
---|
| 140 | }
|
---|
| 141 | export declare class Icu implements Node {
|
---|
| 142 | vars: {
|
---|
| 143 | [name: string]: BoundText;
|
---|
| 144 | };
|
---|
| 145 | placeholders: {
|
---|
| 146 | [name: string]: Text | BoundText;
|
---|
| 147 | };
|
---|
| 148 | sourceSpan: ParseSourceSpan;
|
---|
| 149 | i18n?: I18nMeta | undefined;
|
---|
| 150 | constructor(vars: {
|
---|
| 151 | [name: string]: BoundText;
|
---|
| 152 | }, placeholders: {
|
---|
| 153 | [name: string]: Text | BoundText;
|
---|
| 154 | }, sourceSpan: ParseSourceSpan, i18n?: I18nMeta | undefined);
|
---|
| 155 | visit<Result>(visitor: Visitor<Result>): Result;
|
---|
| 156 | }
|
---|
| 157 | export interface Visitor<Result = any> {
|
---|
| 158 | visit?(node: Node): Result;
|
---|
| 159 | visitElement(element: Element): Result;
|
---|
| 160 | visitTemplate(template: Template): Result;
|
---|
| 161 | visitContent(content: Content): Result;
|
---|
| 162 | visitVariable(variable: Variable): Result;
|
---|
| 163 | visitReference(reference: Reference): Result;
|
---|
| 164 | visitTextAttribute(attribute: TextAttribute): Result;
|
---|
| 165 | visitBoundAttribute(attribute: BoundAttribute): Result;
|
---|
| 166 | visitBoundEvent(attribute: BoundEvent): Result;
|
---|
| 167 | visitText(text: Text): Result;
|
---|
| 168 | visitBoundText(text: BoundText): Result;
|
---|
| 169 | visitIcu(icu: Icu): Result;
|
---|
| 170 | }
|
---|
| 171 | export declare class NullVisitor implements Visitor<void> {
|
---|
| 172 | visitElement(element: Element): void;
|
---|
| 173 | visitTemplate(template: Template): void;
|
---|
| 174 | visitContent(content: Content): void;
|
---|
| 175 | visitVariable(variable: Variable): void;
|
---|
| 176 | visitReference(reference: Reference): void;
|
---|
| 177 | visitTextAttribute(attribute: TextAttribute): void;
|
---|
| 178 | visitBoundAttribute(attribute: BoundAttribute): void;
|
---|
| 179 | visitBoundEvent(attribute: BoundEvent): void;
|
---|
| 180 | visitText(text: Text): void;
|
---|
| 181 | visitBoundText(text: BoundText): void;
|
---|
| 182 | visitIcu(icu: Icu): void;
|
---|
| 183 | }
|
---|
| 184 | export declare class RecursiveVisitor implements Visitor<void> {
|
---|
| 185 | visitElement(element: Element): void;
|
---|
| 186 | visitTemplate(template: Template): void;
|
---|
| 187 | visitContent(content: Content): void;
|
---|
| 188 | visitVariable(variable: Variable): void;
|
---|
| 189 | visitReference(reference: Reference): void;
|
---|
| 190 | visitTextAttribute(attribute: TextAttribute): void;
|
---|
| 191 | visitBoundAttribute(attribute: BoundAttribute): void;
|
---|
| 192 | visitBoundEvent(attribute: BoundEvent): void;
|
---|
| 193 | visitText(text: Text): void;
|
---|
| 194 | visitBoundText(text: BoundText): void;
|
---|
| 195 | visitIcu(icu: Icu): void;
|
---|
| 196 | }
|
---|
| 197 | export declare class TransformVisitor implements Visitor<Node> {
|
---|
| 198 | visitElement(element: Element): Node;
|
---|
| 199 | visitTemplate(template: Template): Node;
|
---|
| 200 | visitContent(content: Content): Node;
|
---|
| 201 | visitVariable(variable: Variable): Node;
|
---|
| 202 | visitReference(reference: Reference): Node;
|
---|
| 203 | visitTextAttribute(attribute: TextAttribute): Node;
|
---|
| 204 | visitBoundAttribute(attribute: BoundAttribute): Node;
|
---|
| 205 | visitBoundEvent(attribute: BoundEvent): Node;
|
---|
| 206 | visitText(text: Text): Node;
|
---|
| 207 | visitBoundText(text: BoundText): Node;
|
---|
| 208 | visitIcu(icu: Icu): Node;
|
---|
| 209 | }
|
---|
| 210 | export declare function visitAll<Result>(visitor: Visitor<Result>, nodes: Node[]): Result[];
|
---|
| 211 | export declare function transformAll<Result extends Node>(visitor: Visitor<Node>, nodes: Result[]): Result[];
|
---|