| 
									
										
										
										
											2016-06-23 09:47:54 -07:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @license | 
					
						
							|  |  |  |  * Copyright Google Inc. All Rights Reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Use of this source code is governed by an MIT-style license that can be | 
					
						
							|  |  |  |  * found in the LICENSE file at https://angular.io/license
 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-21 13:36:42 -07:00
										 |  |  | import {ANALYZE_FOR_ENTRY_COMPONENTS, ChangeDetectionStrategy, ChangeDetectorRef, ComponentFactory, ComponentFactoryResolver, ComponentRef, ElementRef, Injector, LOCALE_ID, NgModuleFactory, NgModuleRef, QueryList, Renderer, SecurityContext, TRANSLATIONS_FORMAT, TemplateRef, ViewContainerRef, ViewEncapsulation, ɵCodegenComponentFactoryResolver, ɵEMPTY_ARRAY, ɵEMPTY_MAP, ɵNgModuleInjector, ɵand, ɵccf, ɵcrt, ɵdid, ɵeld, ɵinlineInterpolate, ɵinterpolate, ɵncd, ɵnov, ɵpad, ɵpid, ɵpod, ɵppd, ɵprd, ɵqud, ɵreflector, ɵregisterModuleFactory, ɵted, ɵunv, ɵvid} from '@angular/core'; | 
					
						
							| 
									
										
										
										
											2016-08-22 17:18:25 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-04 13:59:43 -08:00
										 |  |  | import {CompileIdentifierMetadata, CompileTokenMetadata} from './compile_metadata'; | 
					
						
							| 
									
										
										
										
											2016-01-06 14:13:44 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-14 13:33:06 -08:00
										 |  |  | const CORE = assetUrl('core'); | 
					
						
							| 
									
										
										
										
											2016-01-06 14:13:44 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-24 17:39:49 -07:00
										 |  |  | export interface IdentifierSpec { | 
					
						
							|  |  |  |   name: string; | 
					
						
							|  |  |  |   moduleUrl: string; | 
					
						
							|  |  |  |   runtime: any; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-06 14:13:44 -08:00
										 |  |  | export class Identifiers { | 
					
						
							| 
									
										
										
										
											2016-08-24 17:39:49 -07:00
										 |  |  |   static ANALYZE_FOR_ENTRY_COMPONENTS: IdentifierSpec = { | 
					
						
							| 
									
										
										
										
											2016-07-25 00:36:30 -07:00
										 |  |  |     name: 'ANALYZE_FOR_ENTRY_COMPONENTS', | 
					
						
							| 
									
										
										
										
											2017-02-14 13:33:06 -08:00
										 |  |  |     moduleUrl: CORE, | 
					
						
							| 
									
										
										
										
											2016-07-25 00:36:30 -07:00
										 |  |  |     runtime: ANALYZE_FOR_ENTRY_COMPONENTS | 
					
						
							| 
									
										
										
										
											2016-08-24 17:39:49 -07:00
										 |  |  |   }; | 
					
						
							| 
									
										
										
										
											2017-02-14 13:33:06 -08:00
										 |  |  |   static ElementRef: IdentifierSpec = {name: 'ElementRef', moduleUrl: CORE, runtime: ElementRef}; | 
					
						
							| 
									
										
										
										
											2017-03-14 16:26:17 -07:00
										 |  |  |   static NgModuleRef: IdentifierSpec = {name: 'NgModuleRef', moduleUrl: CORE, runtime: NgModuleRef}; | 
					
						
							| 
									
										
										
										
											2017-02-14 13:33:06 -08:00
										 |  |  |   static ViewContainerRef: | 
					
						
							|  |  |  |       IdentifierSpec = {name: 'ViewContainerRef', moduleUrl: CORE, runtime: ViewContainerRef}; | 
					
						
							|  |  |  |   static ChangeDetectorRef: | 
					
						
							|  |  |  |       IdentifierSpec = {name: 'ChangeDetectorRef', moduleUrl: CORE, runtime: ChangeDetectorRef}; | 
					
						
							|  |  |  |   static QueryList: IdentifierSpec = {name: 'QueryList', moduleUrl: CORE, runtime: QueryList}; | 
					
						
							|  |  |  |   static TemplateRef: IdentifierSpec = {name: 'TemplateRef', moduleUrl: CORE, runtime: TemplateRef}; | 
					
						
							| 
									
										
										
										
											2016-08-24 17:39:49 -07:00
										 |  |  |   static CodegenComponentFactoryResolver: IdentifierSpec = { | 
					
						
							| 
									
										
										
										
											2017-02-14 13:33:06 -08:00
										 |  |  |     name: 'ɵCodegenComponentFactoryResolver', | 
					
						
							|  |  |  |     moduleUrl: CORE, | 
					
						
							|  |  |  |     runtime: ɵCodegenComponentFactoryResolver | 
					
						
							| 
									
										
										
										
											2016-08-24 17:39:49 -07:00
										 |  |  |   }; | 
					
						
							|  |  |  |   static ComponentFactoryResolver: IdentifierSpec = { | 
					
						
							| 
									
										
										
										
											2016-06-22 14:06:23 -07:00
										 |  |  |     name: 'ComponentFactoryResolver', | 
					
						
							| 
									
										
										
										
											2017-02-14 13:33:06 -08:00
										 |  |  |     moduleUrl: CORE, | 
					
						
							| 
									
										
										
										
											2016-06-22 14:06:23 -07:00
										 |  |  |     runtime: ComponentFactoryResolver | 
					
						
							| 
									
										
										
										
											2016-08-24 17:39:49 -07:00
										 |  |  |   }; | 
					
						
							| 
									
										
										
										
											2017-02-14 13:33:06 -08:00
										 |  |  |   static ComponentFactory: | 
					
						
							|  |  |  |       IdentifierSpec = {name: 'ComponentFactory', moduleUrl: CORE, runtime: ComponentFactory}; | 
					
						
							|  |  |  |   static ComponentRef: | 
					
						
							|  |  |  |       IdentifierSpec = {name: 'ComponentRef', moduleUrl: CORE, runtime: ComponentRef}; | 
					
						
							|  |  |  |   static NgModuleFactory: | 
					
						
							|  |  |  |       IdentifierSpec = {name: 'NgModuleFactory', moduleUrl: CORE, runtime: NgModuleFactory}; | 
					
						
							| 
									
										
										
										
											2016-08-24 17:39:49 -07:00
										 |  |  |   static NgModuleInjector: IdentifierSpec = { | 
					
						
							| 
									
										
										
										
											2017-02-14 13:33:06 -08:00
										 |  |  |     name: 'ɵNgModuleInjector', | 
					
						
							|  |  |  |     moduleUrl: CORE, | 
					
						
							|  |  |  |     runtime: ɵNgModuleInjector, | 
					
						
							| 
									
										
										
										
											2016-08-24 17:39:49 -07:00
										 |  |  |   }; | 
					
						
							| 
									
										
										
										
											2016-09-01 13:46:08 -07:00
										 |  |  |   static RegisterModuleFactoryFn: IdentifierSpec = { | 
					
						
							| 
									
										
										
										
											2017-02-14 13:33:06 -08:00
										 |  |  |     name: 'ɵregisterModuleFactory', | 
					
						
							|  |  |  |     moduleUrl: CORE, | 
					
						
							|  |  |  |     runtime: ɵregisterModuleFactory, | 
					
						
							| 
									
										
										
										
											2016-09-01 13:46:08 -07:00
										 |  |  |   }; | 
					
						
							| 
									
										
										
										
											2017-02-14 13:33:06 -08:00
										 |  |  |   static Injector: IdentifierSpec = {name: 'Injector', moduleUrl: CORE, runtime: Injector}; | 
					
						
							|  |  |  |   static ViewEncapsulation: | 
					
						
							|  |  |  |       IdentifierSpec = {name: 'ViewEncapsulation', moduleUrl: CORE, runtime: ViewEncapsulation}; | 
					
						
							| 
									
										
										
										
											2016-08-24 17:39:49 -07:00
										 |  |  |   static ChangeDetectionStrategy: IdentifierSpec = { | 
					
						
							| 
									
										
										
										
											2016-01-06 14:13:44 -08:00
										 |  |  |     name: 'ChangeDetectionStrategy', | 
					
						
							| 
									
										
										
										
											2017-02-14 13:33:06 -08:00
										 |  |  |     moduleUrl: CORE, | 
					
						
							| 
									
										
										
										
											2016-08-29 08:52:25 -07:00
										 |  |  |     runtime: ChangeDetectionStrategy | 
					
						
							| 
									
										
										
										
											2016-08-24 17:39:49 -07:00
										 |  |  |   }; | 
					
						
							|  |  |  |   static SecurityContext: IdentifierSpec = { | 
					
						
							| 
									
										
											  
											
												feat: security implementation in Angular 2.
Summary:
This adds basic security hooks to Angular 2.
* `SecurityContext` is a private API between core, compiler, and
  platform-browser. `SecurityContext` communicates what context a value is used
  in across template parser, compiler, and sanitization at runtime.
* `SanitizationService` is the bare bones interface to sanitize values for a
  particular context.
* `SchemaElementRegistry.securityContext(tagName, attributeOrPropertyName)`
  determines the security context for an attribute or property (it turns out
  attributes and properties match for the purposes of sanitization).
Based on these hooks:
* `DomSchemaElementRegistry` decides what sanitization applies in a particular
  context.
* `DomSanitizationService` implements `SanitizationService` and adds *Safe
  Value*s, i.e. the ability to mark a value as safe and not requiring further
  sanitization.
* `url_sanitizer` and `style_sanitizer` sanitize URLs and Styles, respectively
  (surprise!).
`DomSanitizationService` is the default implementation bound for browser
applications, in the three contexts (browser rendering, web worker rendering,
server side rendering).
BREAKING CHANGES:
*** SECURITY WARNING ***
Angular 2 Release Candidates do not implement proper contextual escaping yet.
Make sure to correctly escape all values that go into the DOM.
*** SECURITY WARNING ***
Reviewers: IgorMinar
Differential Revision: https://reviews.angular.io/D103
											
										 
											2016-04-29 16:04:08 -07:00
										 |  |  |     name: 'SecurityContext', | 
					
						
							| 
									
										
										
										
											2017-02-14 13:33:06 -08:00
										 |  |  |     moduleUrl: CORE, | 
					
						
							| 
									
										
											  
											
												feat: security implementation in Angular 2.
Summary:
This adds basic security hooks to Angular 2.
* `SecurityContext` is a private API between core, compiler, and
  platform-browser. `SecurityContext` communicates what context a value is used
  in across template parser, compiler, and sanitization at runtime.
* `SanitizationService` is the bare bones interface to sanitize values for a
  particular context.
* `SchemaElementRegistry.securityContext(tagName, attributeOrPropertyName)`
  determines the security context for an attribute or property (it turns out
  attributes and properties match for the purposes of sanitization).
Based on these hooks:
* `DomSchemaElementRegistry` decides what sanitization applies in a particular
  context.
* `DomSanitizationService` implements `SanitizationService` and adds *Safe
  Value*s, i.e. the ability to mark a value as safe and not requiring further
  sanitization.
* `url_sanitizer` and `style_sanitizer` sanitize URLs and Styles, respectively
  (surprise!).
`DomSanitizationService` is the default implementation bound for browser
applications, in the three contexts (browser rendering, web worker rendering,
server side rendering).
BREAKING CHANGES:
*** SECURITY WARNING ***
Angular 2 Release Candidates do not implement proper contextual escaping yet.
Make sure to correctly escape all values that go into the DOM.
*** SECURITY WARNING ***
Reviewers: IgorMinar
Differential Revision: https://reviews.angular.io/D103
											
										 
											2016-04-29 16:04:08 -07:00
										 |  |  |     runtime: SecurityContext, | 
					
						
							| 
									
										
										
										
											2016-08-24 17:39:49 -07:00
										 |  |  |   }; | 
					
						
							| 
									
										
										
										
											2017-02-14 13:33:06 -08:00
										 |  |  |   static LOCALE_ID: IdentifierSpec = {name: 'LOCALE_ID', moduleUrl: CORE, runtime: LOCALE_ID}; | 
					
						
							|  |  |  |   static TRANSLATIONS_FORMAT: | 
					
						
							|  |  |  |       IdentifierSpec = {name: 'TRANSLATIONS_FORMAT', moduleUrl: CORE, runtime: TRANSLATIONS_FORMAT}; | 
					
						
							| 
									
										
										
										
											2017-02-27 23:08:19 -08:00
										 |  |  |   static inlineInterpolate: | 
					
						
							|  |  |  |       IdentifierSpec = {name: 'ɵinlineInterpolate', moduleUrl: CORE, runtime: ɵinlineInterpolate}; | 
					
						
							|  |  |  |   static interpolate: | 
					
						
							|  |  |  |       IdentifierSpec = {name: 'ɵinterpolate', moduleUrl: CORE, runtime: ɵinterpolate}; | 
					
						
							|  |  |  |   static EMPTY_ARRAY: | 
					
						
							| 
									
										
										
										
											2017-02-28 14:16:26 -08:00
										 |  |  |       IdentifierSpec = {name: 'ɵEMPTY_ARRAY', moduleUrl: CORE, runtime: ɵEMPTY_ARRAY}; | 
					
						
							|  |  |  |   static EMPTY_MAP: IdentifierSpec = {name: 'ɵEMPTY_MAP', moduleUrl: CORE, runtime: ɵEMPTY_MAP}; | 
					
						
							| 
									
										
										
										
											2017-02-27 23:08:19 -08:00
										 |  |  |   static Renderer: IdentifierSpec = {name: 'Renderer', moduleUrl: CORE, runtime: Renderer}; | 
					
						
							| 
									
										
										
										
											2017-02-27 13:28:41 -08:00
										 |  |  |   static viewDef: IdentifierSpec = {name: 'ɵvid', moduleUrl: CORE, runtime: ɵvid}; | 
					
						
							|  |  |  |   static elementDef: IdentifierSpec = {name: 'ɵeld', moduleUrl: CORE, runtime: ɵeld}; | 
					
						
							|  |  |  |   static anchorDef: IdentifierSpec = {name: 'ɵand', moduleUrl: CORE, runtime: ɵand}; | 
					
						
							|  |  |  |   static textDef: IdentifierSpec = {name: 'ɵted', moduleUrl: CORE, runtime: ɵted}; | 
					
						
							|  |  |  |   static directiveDef: IdentifierSpec = {name: 'ɵdid', moduleUrl: CORE, runtime: ɵdid}; | 
					
						
							|  |  |  |   static providerDef: IdentifierSpec = {name: 'ɵprd', moduleUrl: CORE, runtime: ɵprd}; | 
					
						
							|  |  |  |   static queryDef: IdentifierSpec = {name: 'ɵqud', moduleUrl: CORE, runtime: ɵqud}; | 
					
						
							|  |  |  |   static pureArrayDef: IdentifierSpec = {name: 'ɵpad', moduleUrl: CORE, runtime: ɵpad}; | 
					
						
							|  |  |  |   static pureObjectDef: IdentifierSpec = {name: 'ɵpod', moduleUrl: CORE, runtime: ɵpod}; | 
					
						
							|  |  |  |   static purePipeDef: IdentifierSpec = {name: 'ɵppd', moduleUrl: CORE, runtime: ɵppd}; | 
					
						
							|  |  |  |   static pipeDef: IdentifierSpec = {name: 'ɵpid', moduleUrl: CORE, runtime: ɵpid}; | 
					
						
							|  |  |  |   static nodeValue: IdentifierSpec = {name: 'ɵnov', moduleUrl: CORE, runtime: ɵnov}; | 
					
						
							|  |  |  |   static ngContentDef: IdentifierSpec = {name: 'ɵncd', moduleUrl: CORE, runtime: ɵncd}; | 
					
						
							|  |  |  |   static unwrapValue: IdentifierSpec = {name: 'ɵunv', moduleUrl: CORE, runtime: ɵunv}; | 
					
						
							| 
									
										
										
										
											2017-03-07 16:36:12 -08:00
										 |  |  |   static createRendererType2: IdentifierSpec = {name: 'ɵcrt', moduleUrl: CORE, runtime: ɵcrt}; | 
					
						
							|  |  |  |   static RendererType2: IdentifierSpec = { | 
					
						
							|  |  |  |     name: 'RendererType2', | 
					
						
							| 
									
										
										
										
											2017-02-17 08:56:49 -08:00
										 |  |  |     moduleUrl: CORE, | 
					
						
							|  |  |  |     // type only
 | 
					
						
							|  |  |  |     runtime: null | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  |   static ViewDefinition: IdentifierSpec = { | 
					
						
							| 
									
										
										
										
											2017-02-18 21:28:27 -08:00
										 |  |  |     name: 'ɵViewDefinition', | 
					
						
							| 
									
										
										
										
											2017-02-17 08:56:49 -08:00
										 |  |  |     moduleUrl: CORE, | 
					
						
							|  |  |  |     // type only
 | 
					
						
							|  |  |  |     runtime: null | 
					
						
							|  |  |  |   }; | 
					
						
							| 
									
										
										
										
											2017-02-27 13:28:41 -08:00
										 |  |  |   static createComponentFactory: IdentifierSpec = {name: 'ɵccf', moduleUrl: CORE, runtime: ɵccf}; | 
					
						
							| 
									
										
										
										
											2016-10-19 09:17:36 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export function assetUrl(pkg: string, path: string = null, type: string = 'src'): string { | 
					
						
							|  |  |  |   if (path == null) { | 
					
						
							| 
									
										
										
										
											2017-02-14 13:33:06 -08:00
										 |  |  |     return `@angular/${pkg}`; | 
					
						
							| 
									
										
										
										
											2016-10-19 09:17:36 -07:00
										 |  |  |   } else { | 
					
						
							| 
									
										
										
										
											2016-11-15 10:14:01 -08:00
										 |  |  |     return `@angular/${pkg}/${type}/${path}`; | 
					
						
							| 
									
										
										
										
											2016-10-19 09:17:36 -07:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2016-08-24 17:39:49 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export function resolveIdentifier(identifier: IdentifierSpec) { | 
					
						
							| 
									
										
										
										
											2017-02-14 13:33:06 -08:00
										 |  |  |   let name = identifier.name; | 
					
						
							| 
									
										
										
										
											2017-01-27 17:39:48 -08:00
										 |  |  |   return ɵreflector.resolveIdentifier(name, identifier.moduleUrl, null, identifier.runtime); | 
					
						
							| 
									
										
										
										
											2016-11-23 09:42:19 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-30 10:52:51 -08:00
										 |  |  | export function createIdentifier(identifier: IdentifierSpec): CompileIdentifierMetadata { | 
					
						
							| 
									
										
										
										
											2017-02-14 13:33:06 -08:00
										 |  |  |   return {reference: resolveIdentifier(identifier)}; | 
					
						
							| 
									
										
										
										
											2016-01-06 14:13:44 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export function identifierToken(identifier: CompileIdentifierMetadata): CompileTokenMetadata { | 
					
						
							| 
									
										
										
										
											2016-11-30 10:52:51 -08:00
										 |  |  |   return {identifier: identifier}; | 
					
						
							| 
									
										
										
										
											2016-01-06 14:13:44 -08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2016-08-24 17:39:49 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-23 09:42:19 -08:00
										 |  |  | export function createIdentifierToken(identifier: IdentifierSpec): CompileTokenMetadata { | 
					
						
							|  |  |  |   return identifierToken(createIdentifier(identifier)); | 
					
						
							| 
									
										
										
										
											2016-08-24 17:39:49 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-23 09:42:19 -08:00
										 |  |  | export function createEnumIdentifier( | 
					
						
							|  |  |  |     enumType: IdentifierSpec, name: string): CompileIdentifierMetadata { | 
					
						
							| 
									
										
										
										
											2017-02-14 13:33:06 -08:00
										 |  |  |   const resolvedEnum = ɵreflector.resolveEnum(resolveIdentifier(enumType), name); | 
					
						
							| 
									
										
										
										
											2016-11-30 10:52:51 -08:00
										 |  |  |   return {reference: resolvedEnum}; | 
					
						
							| 
									
										
										
										
											2016-08-30 18:07:40 -07:00
										 |  |  | } |