| 
									
										
										
										
											2015-05-01 14:05:19 -07:00
										 |  |  | import {DynamicProtoChangeDetector, JitProtoChangeDetector} from './proto_change_detector'; | 
					
						
							|  |  |  | import {PipeFactory} from './pipes/pipe'; | 
					
						
							|  |  |  | import {PipeRegistry} from './pipes/pipe_registry'; | 
					
						
							|  |  |  | import {IterableChangesFactory} from './pipes/iterable_changes'; | 
					
						
							|  |  |  | import {KeyValueChangesFactory} from './pipes/keyvalue_changes'; | 
					
						
							| 
									
										
										
										
											2015-05-11 14:25:27 -07:00
										 |  |  | import {ObservablePipeFactory} from './pipes/observable_pipe'; | 
					
						
							|  |  |  | import {PromisePipeFactory} from './pipes/promise_pipe'; | 
					
						
							| 
									
										
										
										
											2015-05-14 10:14:26 -07:00
										 |  |  | import {UpperCaseFactory} from './pipes/uppercase_pipe'; | 
					
						
							|  |  |  | import {LowerCaseFactory} from './pipes/lowercase_pipe'; | 
					
						
							| 
									
										
										
										
											2015-05-18 09:24:52 -07:00
										 |  |  | import {JsonPipeFactory} from './pipes/json_pipe'; | 
					
						
							| 
									
										
										
										
											2015-05-01 14:05:19 -07:00
										 |  |  | import {NullPipeFactory} from './pipes/null_pipe'; | 
					
						
							| 
									
										
										
										
											2015-05-13 13:01:31 -07:00
										 |  |  | import {ChangeDetection, ProtoChangeDetector, ChangeDetectorDefinition} from './interfaces'; | 
					
						
							| 
									
										
										
										
											2015-05-01 14:05:19 -07:00
										 |  |  | import {Injectable} from 'angular2/src/di/decorators'; | 
					
						
							| 
									
										
										
										
											2015-05-13 13:25:18 -07:00
										 |  |  | import {List, StringMapWrapper} from 'angular2/src/facade/collection'; | 
					
						
							|  |  |  | import {isPresent, BaseException} from 'angular2/src/facade/lang'; | 
					
						
							| 
									
										
										
										
											2015-05-01 14:05:19 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Structural diffing for `Object`s and `Map`s. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @exportedAs angular2/pipes | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | export var keyValDiff: List < PipeFactory >= [new KeyValueChangesFactory(), new NullPipeFactory()]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Structural diffing for `Iterable` types such as `Array`s. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @exportedAs angular2/pipes | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | export var iterableDiff: List < | 
					
						
							|  |  |  |     PipeFactory >= [new IterableChangesFactory(), new NullPipeFactory()]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Async binding to such types as Observable. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @exportedAs angular2/pipes | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2015-05-11 14:25:27 -07:00
										 |  |  | export var async: List < | 
					
						
							|  |  |  |     PipeFactory >= [new ObservablePipeFactory(), new PromisePipeFactory(), new NullPipeFactory()]; | 
					
						
							| 
									
										
										
										
											2015-05-01 14:05:19 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-14 10:14:26 -07:00
										 |  |  | /** | 
					
						
							|  |  |  |  * Uppercase text transform. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @exportedAs angular2/pipes | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | export var uppercase: List < PipeFactory >= [new UpperCaseFactory(), new NullPipeFactory()]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Lowercase text transform. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @exportedAs angular2/pipes | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | export var lowercase: List < PipeFactory >= [new LowerCaseFactory(), new NullPipeFactory()]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-18 09:24:52 -07:00
										 |  |  | /** | 
					
						
							|  |  |  |  * Json stringify transform. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @exportedAs angular2/pipes | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | export var json: List < PipeFactory >= [new JsonPipeFactory(), new NullPipeFactory()]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-01 14:05:19 -07:00
										 |  |  | export var defaultPipes = { | 
					
						
							|  |  |  |   "iterableDiff": iterableDiff, | 
					
						
							|  |  |  |   "keyValDiff": keyValDiff, | 
					
						
							| 
									
										
										
										
											2015-05-14 10:14:26 -07:00
										 |  |  |   "async": async, | 
					
						
							|  |  |  |   "uppercase": uppercase, | 
					
						
							| 
									
										
										
										
											2015-05-18 09:24:52 -07:00
										 |  |  |   "lowercase": lowercase, | 
					
						
							|  |  |  |   "json": json | 
					
						
							| 
									
										
										
										
											2015-05-01 14:05:19 -07:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-13 13:25:18 -07:00
										 |  |  | export var preGeneratedProtoDetectors = {}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Implements change detection using a map of pregenerated proto detectors. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @exportedAs angular2/change_detection | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | export class PreGeneratedChangeDetection extends ChangeDetection { | 
					
						
							|  |  |  |   _dynamicChangeDetection: ChangeDetection; | 
					
						
							| 
									
										
										
										
											2015-05-20 09:48:15 -07:00
										 |  |  |   _protoChangeDetectorFactories: StringMap<string, Function>; | 
					
						
							| 
									
										
										
										
											2015-05-13 13:25:18 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   constructor(private registry: PipeRegistry, protoChangeDetectors?) { | 
					
						
							|  |  |  |     super(); | 
					
						
							|  |  |  |     this._dynamicChangeDetection = new DynamicChangeDetection(registry); | 
					
						
							| 
									
										
										
										
											2015-05-20 09:48:15 -07:00
										 |  |  |     this._protoChangeDetectorFactories = | 
					
						
							| 
									
										
										
										
											2015-05-13 13:25:18 -07:00
										 |  |  |         isPresent(protoChangeDetectors) ? protoChangeDetectors : preGeneratedProtoDetectors; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   createProtoChangeDetector(definition: ChangeDetectorDefinition): ProtoChangeDetector { | 
					
						
							|  |  |  |     var id = definition.id; | 
					
						
							| 
									
										
										
										
											2015-05-20 09:48:15 -07:00
										 |  |  |     if (StringMapWrapper.contains(this._protoChangeDetectorFactories, id)) { | 
					
						
							|  |  |  |       return StringMapWrapper.get(this._protoChangeDetectorFactories, id)(this.registry); | 
					
						
							| 
									
										
										
										
											2015-05-13 13:25:18 -07:00
										 |  |  |     } | 
					
						
							|  |  |  |     return this._dynamicChangeDetection.createProtoChangeDetector(definition); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-01 14:05:19 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Implements change detection that does not require `eval()`. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This is slower than {@link JitChangeDetection}. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @exportedAs angular2/change_detection | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | @Injectable() | 
					
						
							|  |  |  | export class DynamicChangeDetection extends ChangeDetection { | 
					
						
							| 
									
										
										
										
											2015-05-13 13:25:18 -07:00
										 |  |  |   constructor(private registry: PipeRegistry) { super(); } | 
					
						
							| 
									
										
										
										
											2015-05-01 14:05:19 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-13 13:25:18 -07:00
										 |  |  |   createProtoChangeDetector(definition: ChangeDetectorDefinition): ProtoChangeDetector { | 
					
						
							| 
									
										
										
										
											2015-05-13 13:01:31 -07:00
										 |  |  |     return new DynamicProtoChangeDetector(this.registry, definition); | 
					
						
							| 
									
										
										
										
											2015-05-01 14:05:19 -07:00
										 |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Implements faster change detection, by generating source code. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2015-05-22 13:28:09 -07:00
										 |  |  |  * This requires `eval()`. For change detection that does not require `eval()`, see | 
					
						
							|  |  |  |  * {@link DynamicChangeDetection}. | 
					
						
							| 
									
										
										
										
											2015-05-01 14:05:19 -07:00
										 |  |  |  * | 
					
						
							|  |  |  |  * @exportedAs angular2/change_detection | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | @Injectable() | 
					
						
							|  |  |  | export class JitChangeDetection extends ChangeDetection { | 
					
						
							|  |  |  |   constructor(public registry: PipeRegistry) { super(); } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-13 13:25:18 -07:00
										 |  |  |   createProtoChangeDetector(definition: ChangeDetectorDefinition): ProtoChangeDetector { | 
					
						
							| 
									
										
										
										
											2015-05-13 13:01:31 -07:00
										 |  |  |     return new JitProtoChangeDetector(this.registry, definition); | 
					
						
							| 
									
										
										
										
											2015-05-01 14:05:19 -07:00
										 |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export var defaultPipeRegistry: PipeRegistry = new PipeRegistry(defaultPipes); |