UNPKG

14.4 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright Google Inc. 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 */
8import { StaticSymbol } from './aot/static_symbol';
9import { ChangeDetectionStrategy, SchemaMetadata, Type, ViewEncapsulation } from './core';
10import { LifecycleHooks } from './lifecycle_reflector';
11import { ParseTreeResult as HtmlParseTreeResult } from './ml_parser/parser';
12export declare function sanitizeIdentifier(name: string): string;
13export declare function identifierName(compileIdentifier: CompileIdentifierMetadata | null | undefined): string | null;
14export declare function identifierModuleUrl(compileIdentifier: CompileIdentifierMetadata): string;
15export declare function viewClassName(compType: any, embeddedTemplateIndex: number): string;
16export declare function rendererTypeName(compType: any): string;
17export declare function hostViewClassName(compType: any): string;
18export declare function componentFactoryName(compType: any): string;
19export interface ProxyClass {
20 setDelegate(delegate: any): void;
21}
22export interface CompileIdentifierMetadata {
23 reference: any;
24}
25export declare enum CompileSummaryKind {
26 Pipe = 0,
27 Directive = 1,
28 NgModule = 2,
29 Injectable = 3
30}
31/**
32 * A CompileSummary is the data needed to use a directive / pipe / module
33 * in other modules / components. However, this data is not enough to compile
34 * the directive / module itself.
35 */
36export interface CompileTypeSummary {
37 summaryKind: CompileSummaryKind | null;
38 type: CompileTypeMetadata;
39}
40export interface CompileDiDependencyMetadata {
41 isAttribute?: boolean;
42 isSelf?: boolean;
43 isHost?: boolean;
44 isSkipSelf?: boolean;
45 isOptional?: boolean;
46 isValue?: boolean;
47 token?: CompileTokenMetadata;
48 value?: any;
49}
50export interface CompileProviderMetadata {
51 token: CompileTokenMetadata;
52 useClass?: CompileTypeMetadata;
53 useValue?: any;
54 useExisting?: CompileTokenMetadata;
55 useFactory?: CompileFactoryMetadata;
56 deps?: CompileDiDependencyMetadata[];
57 multi?: boolean;
58}
59export interface CompileFactoryMetadata extends CompileIdentifierMetadata {
60 diDeps: CompileDiDependencyMetadata[];
61 reference: any;
62}
63export declare function tokenName(token: CompileTokenMetadata): string | null;
64export declare function tokenReference(token: CompileTokenMetadata): any;
65export interface CompileTokenMetadata {
66 value?: any;
67 identifier?: CompileIdentifierMetadata | CompileTypeMetadata;
68}
69export interface CompileInjectableMetadata {
70 symbol: StaticSymbol;
71 type: CompileTypeMetadata;
72 providedIn?: StaticSymbol;
73 useValue?: any;
74 useClass?: StaticSymbol;
75 useExisting?: StaticSymbol;
76 useFactory?: StaticSymbol;
77 deps?: any[];
78}
79/**
80 * Metadata regarding compilation of a type.
81 */
82export interface CompileTypeMetadata extends CompileIdentifierMetadata {
83 diDeps: CompileDiDependencyMetadata[];
84 lifecycleHooks: LifecycleHooks[];
85 reference: any;
86}
87export interface CompileQueryMetadata {
88 selectors: Array<CompileTokenMetadata>;
89 descendants: boolean;
90 first: boolean;
91 propertyName: string;
92 read: CompileTokenMetadata;
93 static?: boolean;
94}
95/**
96 * Metadata about a stylesheet
97 */
98export declare class CompileStylesheetMetadata {
99 moduleUrl: string | null;
100 styles: string[];
101 styleUrls: string[];
102 constructor({ moduleUrl, styles, styleUrls }?: {
103 moduleUrl?: string;
104 styles?: string[];
105 styleUrls?: string[];
106 });
107}
108/**
109 * Summary Metadata regarding compilation of a template.
110 */
111export interface CompileTemplateSummary {
112 ngContentSelectors: string[];
113 encapsulation: ViewEncapsulation | null;
114 styles: string[];
115 animations: any[] | null;
116}
117/**
118 * Metadata regarding compilation of a template.
119 */
120export declare class CompileTemplateMetadata {
121 encapsulation: ViewEncapsulation | null;
122 template: string | null;
123 templateUrl: string | null;
124 htmlAst: HtmlParseTreeResult | null;
125 isInline: boolean;
126 styles: string[];
127 styleUrls: string[];
128 externalStylesheets: CompileStylesheetMetadata[];
129 animations: any[];
130 ngContentSelectors: string[];
131 interpolation: [string, string] | null;
132 preserveWhitespaces: boolean;
133 constructor({ encapsulation, template, templateUrl, htmlAst, styles, styleUrls, externalStylesheets, animations, ngContentSelectors, interpolation, isInline, preserveWhitespaces }: {
134 encapsulation: ViewEncapsulation | null;
135 template: string | null;
136 templateUrl: string | null;
137 htmlAst: HtmlParseTreeResult | null;
138 styles: string[];
139 styleUrls: string[];
140 externalStylesheets: CompileStylesheetMetadata[];
141 ngContentSelectors: string[];
142 animations: any[];
143 interpolation: [string, string] | null;
144 isInline: boolean;
145 preserveWhitespaces: boolean;
146 });
147 toSummary(): CompileTemplateSummary;
148}
149export interface CompileEntryComponentMetadata {
150 componentType: any;
151 componentFactory: StaticSymbol | object;
152}
153export interface CompileDirectiveSummary extends CompileTypeSummary {
154 type: CompileTypeMetadata;
155 isComponent: boolean;
156 selector: string | null;
157 exportAs: string | null;
158 inputs: {
159 [key: string]: string;
160 };
161 outputs: {
162 [key: string]: string;
163 };
164 hostListeners: {
165 [key: string]: string;
166 };
167 hostProperties: {
168 [key: string]: string;
169 };
170 hostAttributes: {
171 [key: string]: string;
172 };
173 providers: CompileProviderMetadata[];
174 viewProviders: CompileProviderMetadata[];
175 queries: CompileQueryMetadata[];
176 guards: {
177 [key: string]: any;
178 };
179 viewQueries: CompileQueryMetadata[];
180 entryComponents: CompileEntryComponentMetadata[];
181 changeDetection: ChangeDetectionStrategy | null;
182 template: CompileTemplateSummary | null;
183 componentViewType: StaticSymbol | ProxyClass | null;
184 rendererType: StaticSymbol | object | null;
185 componentFactory: StaticSymbol | object | null;
186}
187/**
188 * Metadata regarding compilation of a directive.
189 */
190export declare class CompileDirectiveMetadata {
191 static create({ isHost, type, isComponent, selector, exportAs, changeDetection, inputs, outputs, host, providers, viewProviders, queries, guards, viewQueries, entryComponents, template, componentViewType, rendererType, componentFactory }: {
192 isHost: boolean;
193 type: CompileTypeMetadata;
194 isComponent: boolean;
195 selector: string | null;
196 exportAs: string | null;
197 changeDetection: ChangeDetectionStrategy | null;
198 inputs: string[];
199 outputs: string[];
200 host: {
201 [key: string]: string;
202 };
203 providers: CompileProviderMetadata[];
204 viewProviders: CompileProviderMetadata[];
205 queries: CompileQueryMetadata[];
206 guards: {
207 [key: string]: any;
208 };
209 viewQueries: CompileQueryMetadata[];
210 entryComponents: CompileEntryComponentMetadata[];
211 template: CompileTemplateMetadata;
212 componentViewType: StaticSymbol | ProxyClass | null;
213 rendererType: StaticSymbol | object | null;
214 componentFactory: StaticSymbol | object | null;
215 }): CompileDirectiveMetadata;
216 isHost: boolean;
217 type: CompileTypeMetadata;
218 isComponent: boolean;
219 selector: string | null;
220 exportAs: string | null;
221 changeDetection: ChangeDetectionStrategy | null;
222 inputs: {
223 [key: string]: string;
224 };
225 outputs: {
226 [key: string]: string;
227 };
228 hostListeners: {
229 [key: string]: string;
230 };
231 hostProperties: {
232 [key: string]: string;
233 };
234 hostAttributes: {
235 [key: string]: string;
236 };
237 providers: CompileProviderMetadata[];
238 viewProviders: CompileProviderMetadata[];
239 queries: CompileQueryMetadata[];
240 guards: {
241 [key: string]: any;
242 };
243 viewQueries: CompileQueryMetadata[];
244 entryComponents: CompileEntryComponentMetadata[];
245 template: CompileTemplateMetadata | null;
246 componentViewType: StaticSymbol | ProxyClass | null;
247 rendererType: StaticSymbol | object | null;
248 componentFactory: StaticSymbol | object | null;
249 constructor({ isHost, type, isComponent, selector, exportAs, changeDetection, inputs, outputs, hostListeners, hostProperties, hostAttributes, providers, viewProviders, queries, guards, viewQueries, entryComponents, template, componentViewType, rendererType, componentFactory }: {
250 isHost: boolean;
251 type: CompileTypeMetadata;
252 isComponent: boolean;
253 selector: string | null;
254 exportAs: string | null;
255 changeDetection: ChangeDetectionStrategy | null;
256 inputs: {
257 [key: string]: string;
258 };
259 outputs: {
260 [key: string]: string;
261 };
262 hostListeners: {
263 [key: string]: string;
264 };
265 hostProperties: {
266 [key: string]: string;
267 };
268 hostAttributes: {
269 [key: string]: string;
270 };
271 providers: CompileProviderMetadata[];
272 viewProviders: CompileProviderMetadata[];
273 queries: CompileQueryMetadata[];
274 guards: {
275 [key: string]: any;
276 };
277 viewQueries: CompileQueryMetadata[];
278 entryComponents: CompileEntryComponentMetadata[];
279 template: CompileTemplateMetadata | null;
280 componentViewType: StaticSymbol | ProxyClass | null;
281 rendererType: StaticSymbol | object | null;
282 componentFactory: StaticSymbol | object | null;
283 });
284 toSummary(): CompileDirectiveSummary;
285}
286export interface CompilePipeSummary extends CompileTypeSummary {
287 type: CompileTypeMetadata;
288 name: string;
289 pure: boolean;
290}
291export declare class CompilePipeMetadata {
292 type: CompileTypeMetadata;
293 name: string;
294 pure: boolean;
295 constructor({ type, name, pure }: {
296 type: CompileTypeMetadata;
297 name: string;
298 pure: boolean;
299 });
300 toSummary(): CompilePipeSummary;
301}
302export interface CompileNgModuleSummary extends CompileTypeSummary {
303 type: CompileTypeMetadata;
304 exportedDirectives: CompileIdentifierMetadata[];
305 exportedPipes: CompileIdentifierMetadata[];
306 entryComponents: CompileEntryComponentMetadata[];
307 providers: {
308 provider: CompileProviderMetadata;
309 module: CompileIdentifierMetadata;
310 }[];
311 modules: CompileTypeMetadata[];
312}
313export declare class CompileShallowModuleMetadata {
314 type: CompileTypeMetadata;
315 rawExports: any;
316 rawImports: any;
317 rawProviders: any;
318}
319/**
320 * Metadata regarding compilation of a module.
321 */
322export declare class CompileNgModuleMetadata {
323 type: CompileTypeMetadata;
324 declaredDirectives: CompileIdentifierMetadata[];
325 exportedDirectives: CompileIdentifierMetadata[];
326 declaredPipes: CompileIdentifierMetadata[];
327 exportedPipes: CompileIdentifierMetadata[];
328 entryComponents: CompileEntryComponentMetadata[];
329 bootstrapComponents: CompileIdentifierMetadata[];
330 providers: CompileProviderMetadata[];
331 importedModules: CompileNgModuleSummary[];
332 exportedModules: CompileNgModuleSummary[];
333 schemas: SchemaMetadata[];
334 id: string | null;
335 transitiveModule: TransitiveCompileNgModuleMetadata;
336 constructor({ type, providers, declaredDirectives, exportedDirectives, declaredPipes, exportedPipes, entryComponents, bootstrapComponents, importedModules, exportedModules, schemas, transitiveModule, id }: {
337 type: CompileTypeMetadata;
338 providers: CompileProviderMetadata[];
339 declaredDirectives: CompileIdentifierMetadata[];
340 exportedDirectives: CompileIdentifierMetadata[];
341 declaredPipes: CompileIdentifierMetadata[];
342 exportedPipes: CompileIdentifierMetadata[];
343 entryComponents: CompileEntryComponentMetadata[];
344 bootstrapComponents: CompileIdentifierMetadata[];
345 importedModules: CompileNgModuleSummary[];
346 exportedModules: CompileNgModuleSummary[];
347 transitiveModule: TransitiveCompileNgModuleMetadata;
348 schemas: SchemaMetadata[];
349 id: string | null;
350 });
351 toSummary(): CompileNgModuleSummary;
352}
353export declare class TransitiveCompileNgModuleMetadata {
354 directivesSet: Set<any>;
355 directives: CompileIdentifierMetadata[];
356 exportedDirectivesSet: Set<any>;
357 exportedDirectives: CompileIdentifierMetadata[];
358 pipesSet: Set<any>;
359 pipes: CompileIdentifierMetadata[];
360 exportedPipesSet: Set<any>;
361 exportedPipes: CompileIdentifierMetadata[];
362 modulesSet: Set<any>;
363 modules: CompileTypeMetadata[];
364 entryComponentsSet: Set<any>;
365 entryComponents: CompileEntryComponentMetadata[];
366 providers: {
367 provider: CompileProviderMetadata;
368 module: CompileIdentifierMetadata;
369 }[];
370 addProvider(provider: CompileProviderMetadata, module: CompileIdentifierMetadata): void;
371 addDirective(id: CompileIdentifierMetadata): void;
372 addExportedDirective(id: CompileIdentifierMetadata): void;
373 addPipe(id: CompileIdentifierMetadata): void;
374 addExportedPipe(id: CompileIdentifierMetadata): void;
375 addModule(id: CompileTypeMetadata): void;
376 addEntryComponent(ec: CompileEntryComponentMetadata): void;
377}
378export declare class ProviderMeta {
379 token: any;
380 useClass: Type | null;
381 useValue: any;
382 useExisting: any;
383 useFactory: Function | null;
384 dependencies: Object[] | null;
385 multi: boolean;
386 constructor(token: any, { useClass, useValue, useExisting, useFactory, deps, multi }: {
387 useClass?: Type;
388 useValue?: any;
389 useExisting?: any;
390 useFactory?: Function | null;
391 deps?: Object[] | null;
392 multi?: boolean;
393 });
394}
395export declare function flatten<T>(list: Array<T | T[]>): T[];
396export declare function templateSourceUrl(ngModuleType: CompileIdentifierMetadata, compMeta: {
397 type: CompileIdentifierMetadata;
398}, templateMeta: {
399 isInline: boolean;
400 templateUrl: string | null;
401}): string;
402export declare function sharedStylesheetJitUrl(meta: CompileStylesheetMetadata, id: number): string;
403export declare function ngModuleJitUrl(moduleMeta: CompileNgModuleMetadata): string;
404export declare function templateJitUrl(ngModuleType: CompileIdentifierMetadata, compMeta: CompileDirectiveMetadata): string;