2015-03-20 15:37:09 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								library angular2.transform.template_compiler.generator;
							 | 
						
					
						
							
								
									
										
										
										
											2015-03-13 13:24:56 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import 'dart:async';
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import 'package:angular2/src/change_detection/parser/lexer.dart' as ng;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import 'package:angular2/src/change_detection/parser/parser.dart' as ng;
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-14 13:14:45 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import 'package:angular2/src/core/compiler/proto_view_factory.dart';
							 | 
						
					
						
							
								
									
										
										
										
											2015-07-24 15:28:44 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import 'package:angular2/src/dom/dom_adapter.dart';
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-01 17:29:58 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import 'package:angular2/src/render/api.dart';
							 | 
						
					
						
							
								
									
										
										
										
											2015-06-04 18:14:46 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import 'package:angular2/src/render/dom/compiler/compile_pipeline.dart';
							 | 
						
					
						
							
								
									
										
										
										
											2015-06-15 15:57:42 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import 'package:angular2/src/render/dom/compiler/style_inliner.dart';
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import 'package:angular2/src/render/dom/compiler/style_url_resolver.dart';
							 | 
						
					
						
							
								
									
										
										
										
											2015-06-24 10:43:36 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import 'package:angular2/src/render/dom/compiler/view_loader.dart';
							 | 
						
					
						
							
								
									
										
										
										
											2015-07-29 14:01:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import 'package:angular2/src/render/dom/schema/element_schema_registry.dart';
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import 'package:angular2/src/render/dom/schema/dom_element_schema_registry.dart';
							 | 
						
					
						
							
								
									
										
										
										
											2015-07-31 10:58:24 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import 'package:angular2/src/render/dom/template_cloner.dart';
							 | 
						
					
						
							
								
									
										
										
										
											2015-06-09 10:21:25 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import 'package:angular2/src/render/xhr.dart' show XHR;
							 | 
						
					
						
							
								
									
										
										
										
											2015-03-13 13:24:56 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import 'package:angular2/src/reflection/reflection.dart';
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-01 17:29:58 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import 'package:angular2/src/services/url_resolver.dart';
							 | 
						
					
						
							
								
									
										
										
										
											2015-03-13 13:24:56 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import 'package:angular2/src/transform/common/asset_reader.dart';
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-08 17:29:21 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import 'package:angular2/src/transform/common/xhr_impl.dart';
							 | 
						
					
						
							
								
									
										
										
										
											2015-03-13 13:24:56 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import 'package:barback/barback.dart';
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-14 13:14:45 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import 'change_detector_codegen.dart' as change;
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-01 17:29:58 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import 'compile_step_factory.dart';
							 | 
						
					
						
							
								
									
										
										
										
											2015-06-04 18:14:46 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import 'reflection_capabilities.dart';
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-14 13:14:45 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import 'reflector_register_codegen.dart' as reg;
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-05 10:31:21 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import 'view_definition_creator.dart';
							 | 
						
					
						
							
								
									
										
										
										
											2015-03-13 13:24:56 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2015-03-13 13:55:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								/// Reads the `.ng_deps.dart` file represented by `entryPoint` and parses any
							 | 
						
					
						
							
								
									
										
										
										
											2015-04-09 21:20:11 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								/// Angular 2 `View` annotations it declares to generate `getter`s,
							 | 
						
					
						
							
								
									
										
										
										
											2015-03-13 13:55:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								/// `setter`s, and `method`s that would otherwise be reflectively accessed.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								///
							 | 
						
					
						
							
								
									
										
										
										
											2015-04-17 13:01:07 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								/// This method assumes a {@link DomAdapter} has been registered.
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-14 13:14:45 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								Future<String> processTemplates(AssetReader reader, AssetId entryPoint,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    {bool generateRegistrations: true,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    bool generateChangeDetectors: true}) async {
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-05 10:31:21 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  var viewDefResults = await createViewDefinitions(reader, entryPoint);
							 | 
						
					
						
							
								
									
										
										
										
											2015-07-31 10:58:24 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  // Note: TemplateCloner(-1) never serializes Nodes into strings.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  // we might want to change this to TemplateCloner(0) to force the serialization
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  // later when the transformer also stores the proto view template.
							 | 
						
					
						
							
								
									
										
										
										
											2015-07-29 14:28:14 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  var extractor = new _TemplateExtractor(
							 | 
						
					
						
							
								
									
										
										
										
											2015-07-31 10:58:24 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      new DomElementSchemaRegistry(), new TemplateCloner(-1), new XhrImpl(reader, entryPoint));
							 | 
						
					
						
							
								
									
										
										
										
											2015-03-13 13:24:56 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-14 13:14:45 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  var registrations = new reg.Codegen();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  var changeDetectorClasses = new change.Codegen();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  for (var rType in viewDefResults.viewDefinitions.keys) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    var viewDefEntry = viewDefResults.viewDefinitions[rType];
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    var result = await extractor.extractTemplates(viewDefEntry.viewDef);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if (result == null) continue;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2015-06-04 18:14:46 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if (generateRegistrations) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      // TODO(kegluneq): Generate these getters & setters based on the
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      // `ProtoViewDto` rather than querying the `ReflectionCapabilities`.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      registrations.generate(result.recording);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-14 13:14:45 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if (result.protoView != null && generateChangeDetectors) {
							 | 
						
					
						
							
								
									
										
										
										
											2015-06-04 18:14:46 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      var saved = reflector.reflectionCapabilities;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      reflector.reflectionCapabilities = const NullReflectionCapabilities();
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-14 13:14:45 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      var defs = getChangeDetectorDefinitions(viewDefEntry.hostMetadata,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          result.protoView, viewDefEntry.viewDef.directives);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      for (var i = 0; i < defs.length; ++i) {
							 | 
						
					
						
							
								
									
										
										
										
											2015-06-04 15:53:16 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        changeDetectorClasses.generate('${rType.typeName}',
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-14 13:14:45 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            '_${rType.typeName}_ChangeDetector$i', defs[i]);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      }
							 | 
						
					
						
							
								
									
										
										
										
											2015-06-04 18:14:46 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      reflector.reflectionCapabilities = saved;
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-01 17:29:58 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							
								
									
										
										
										
											2015-03-19 09:16:01 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							
								
									
										
										
										
											2015-03-13 13:24:56 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-05 10:31:21 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  var code = viewDefResults.ngDeps.code;
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-14 13:14:45 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  if (registrations.isEmpty && changeDetectorClasses.isEmpty) return code;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  var importInjectIdx =
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      viewDefResults.ngDeps.lib != null ? viewDefResults.ngDeps.lib.end : 0;
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-05 10:31:21 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  var codeInjectIdx =
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      viewDefResults.ngDeps.registeredTypes.last.registerMethod.end;
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-29 16:34:51 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  var initInjectIdx = viewDefResults.ngDeps.setupMethod.end - 1;
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-14 13:14:45 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  return '${code.substring(0, importInjectIdx)}'
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      '${changeDetectorClasses.imports}'
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      '${code.substring(importInjectIdx, codeInjectIdx)}'
							 | 
						
					
						
							
								
									
										
										
										
											2015-03-13 13:24:56 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      '${registrations}'
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-29 16:34:51 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      '${code.substring(codeInjectIdx, initInjectIdx)}'
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      '${changeDetectorClasses.initialize}'
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      '${code.substring(initInjectIdx)}'
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-14 13:14:45 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      '$changeDetectorClasses';
							 | 
						
					
						
							
								
									
										
										
										
											2015-03-13 13:55:49 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2015-04-09 21:20:11 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								/// Extracts `template` and `url` values from `View` annotations, reads
							 | 
						
					
						
							
								
									
										
										
										
											2015-03-19 09:16:01 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								/// template code if necessary, and determines what values will be
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								/// reflectively accessed from that template.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								class _TemplateExtractor {
							 | 
						
					
						
							
								
									
										
										
										
											2015-06-04 18:14:46 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  final CompileStepFactory _factory;
							 | 
						
					
						
							
								
									
										
										
										
											2015-06-24 10:43:36 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  ViewLoader _loader;
							 | 
						
					
						
							
								
									
										
										
										
											2015-07-29 14:01:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  ElementSchemaRegistry _schemaRegistry;
							 | 
						
					
						
							
								
									
										
										
										
											2015-07-31 10:58:24 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  TemplateCloner _templateCloner;
							 | 
						
					
						
							
								
									
										
										
										
											2015-03-19 09:16:01 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2015-07-31 10:58:24 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  _TemplateExtractor(ElementSchemaRegistry schemaRegistry, TemplateCloner templateCloner, XHR xhr)
							 | 
						
					
						
							
								
									
										
										
										
											2015-06-15 15:57:42 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      : _factory = new CompileStepFactory(new ng.Parser(new ng.Lexer())) {
							 | 
						
					
						
							
								
									
										
										
										
											2015-07-27 14:15:02 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    var urlResolver = new UrlResolver();
							 | 
						
					
						
							
								
									
										
										
										
											2015-06-15 15:57:42 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    var styleUrlResolver = new StyleUrlResolver(urlResolver);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    var styleInliner = new StyleInliner(xhr, styleUrlResolver, urlResolver);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2015-06-24 10:43:36 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _loader = new ViewLoader(xhr, styleInliner, styleUrlResolver);
							 | 
						
					
						
							
								
									
										
										
										
											2015-07-29 14:01:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _schemaRegistry = schemaRegistry;
							 | 
						
					
						
							
								
									
										
										
										
											2015-07-31 10:58:24 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _templateCloner = templateCloner;
							 | 
						
					
						
							
								
									
										
										
										
											2015-06-15 15:57:42 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							
								
									
										
										
										
											2015-03-13 13:24:56 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-14 13:14:45 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  Future<_ExtractResult> extractTemplates(ViewDefinition viewDef) async {
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-01 17:29:58 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    // Check for "imperative views".
							 | 
						
					
						
							
								
									
										
										
										
											2015-06-10 14:40:24 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if (viewDef.template == null && viewDef.templateAbsUrl == null) return null;
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-01 17:29:58 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2015-07-24 15:28:44 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    var templateAndStyles = await _loader.load(viewDef);
							 | 
						
					
						
							
								
									
										
										
										
											2015-06-04 18:14:46 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // NOTE(kegluneq): Since this is a global, we must not have any async
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // operations between saving and restoring it, otherwise we can get into
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // a bad state. See issue #2359 for additional context.
							 | 
						
					
						
							
								
									
										
										
										
											2015-03-19 09:16:01 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    var savedReflectionCapabilities = reflector.reflectionCapabilities;
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-05 10:31:21 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    var recordingCapabilities = new RecordingReflectionCapabilities();
							 | 
						
					
						
							
								
									
										
										
										
											2015-03-19 09:16:01 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    reflector.reflectionCapabilities = recordingCapabilities;
							 | 
						
					
						
							
								
									
										
										
										
											2015-03-13 13:24:56 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2015-06-15 15:57:42 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    var pipeline = new CompilePipeline(_factory.createSteps(viewDef));
							 | 
						
					
						
							
								
									
										
										
										
											2015-06-04 18:14:46 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2015-07-29 14:28:14 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    var compileElements = pipeline.processElements(
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        DOM.createTemplate(templateAndStyles.template), ViewType.COMPONENT,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        viewDef);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    var protoViewDto =
							 | 
						
					
						
							
								
									
										
										
										
											2015-07-31 10:58:24 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        compileElements[0].inheritedProtoView.build(_schemaRegistry, _templateCloner);
							 | 
						
					
						
							
								
									
										
										
										
											2015-03-19 09:16:01 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    reflector.reflectionCapabilities = savedReflectionCapabilities;
							 | 
						
					
						
							
								
									
										
										
										
											2015-06-04 18:14:46 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2015-06-15 15:57:42 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    return new _ExtractResult(recordingCapabilities, protoViewDto);
							 | 
						
					
						
							
								
									
										
										
										
											2015-03-19 09:16:01 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							
								
									
										
										
										
											2015-03-13 13:24:56 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-14 13:14:45 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								class _ExtractResult {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  final RecordingReflectionCapabilities recording;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  final ProtoViewDto protoView;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  _ExtractResult(this.recording, this.protoView);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 |