1 | /**
|
2 | * @license Angular v2.4.0
|
3 | * (c) 2010-2016 Google, Inc. https://angular.io/
|
4 | * License: MIT
|
5 | */
|
6 | (function (global, factory) {
|
7 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('rxjs/Subject'), require('rxjs/Observable')) :
|
8 | typeof define === 'function' && define.amd ? define(['exports', 'rxjs/Subject', 'rxjs/Observable'], factory) :
|
9 | (factory((global.ng = global.ng || {}, global.ng.core = global.ng.core || {}),global.Rx,global.Rx));
|
10 | }(this, function (exports,rxjs_Subject,rxjs_Observable) { 'use strict';
|
11 |
|
12 | /**
|
13 | * @license
|
14 | * Copyright Google Inc. All Rights Reserved.
|
15 | *
|
16 | * Use of this source code is governed by an MIT-style license that can be
|
17 | * found in the LICENSE file at https://angular.io/license
|
18 | */
|
19 | var /** @type {?} */ globalScope;
|
20 | if (typeof window === 'undefined') {
|
21 | if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) {
|
22 | // TODO: Replace any with WorkerGlobalScope from lib.webworker.d.ts #3492
|
23 | globalScope = (self);
|
24 | }
|
25 | else {
|
26 | globalScope = (global);
|
27 | }
|
28 | }
|
29 | else {
|
30 | globalScope = (window);
|
31 | }
|
32 | /**
|
33 | * @param {?} fn
|
34 | * @return {?}
|
35 | */
|
36 | function scheduleMicroTask(fn) {
|
37 | Zone.current.scheduleMicroTask('scheduleMicrotask', fn);
|
38 | }
|
39 | // Need to declare a new variable for global here since TypeScript
|
40 | // exports the original value of the symbol.
|
41 | var /** @type {?} */ global$1 = globalScope;
|
42 | /**
|
43 | * @param {?} type
|
44 | * @return {?}
|
45 | */
|
46 | function getTypeNameForDebugging(type) {
|
47 | return type['name'] || typeof type;
|
48 | }
|
49 | // TODO: remove calls to assert in production environment
|
50 | // Note: Can't just export this and import in in other files
|
51 | // as `assert` is a reserved keyword in Dart
|
52 | global$1.assert = function assert(condition) {
|
53 | // TODO: to be fixed properly via #2830, noop for now
|
54 | };
|
55 | /**
|
56 | * @param {?} obj
|
57 | * @return {?}
|
58 | */
|
59 | function isPresent(obj) {
|
60 | return obj != null;
|
61 | }
|
62 | /**
|
63 | * @param {?} obj
|
64 | * @return {?}
|
65 | */
|
66 | function isBlank(obj) {
|
67 | return obj == null;
|
68 | }
|
69 | /**
|
70 | * @param {?} token
|
71 | * @return {?}
|
72 | */
|
73 | function stringify(token) {
|
74 | if (typeof token === 'string') {
|
75 | return token;
|
76 | }
|
77 | if (token == null) {
|
78 | return '' + token;
|
79 | }
|
80 | if (token.overriddenName) {
|
81 | return "" + token.overriddenName;
|
82 | }
|
83 | if (token.name) {
|
84 | return "" + token.name;
|
85 | }
|
86 | var /** @type {?} */ res = token.toString();
|
87 | var /** @type {?} */ newLineIndex = res.indexOf('\n');
|
88 | return newLineIndex === -1 ? res : res.substring(0, newLineIndex);
|
89 | }
|
90 | /**
|
91 | * @param {?} a
|
92 | * @param {?} b
|
93 | * @return {?}
|
94 | */
|
95 | function looseIdentical(a, b) {
|
96 | return a === b || typeof a === 'number' && typeof b === 'number' && isNaN(a) && isNaN(b);
|
97 | }
|
98 | /**
|
99 | * @param {?} o
|
100 | * @return {?}
|
101 | */
|
102 | function isJsObject(o) {
|
103 | return o !== null && (typeof o === 'function' || typeof o === 'object');
|
104 | }
|
105 | /**
|
106 | * @param {?} obj
|
107 | * @return {?}
|
108 | */
|
109 | function print(obj) {
|
110 | // tslint:disable-next-line:no-console
|
111 | console.log(obj);
|
112 | }
|
113 | /**
|
114 | * @param {?} obj
|
115 | * @return {?}
|
116 | */
|
117 | function warn(obj) {
|
118 | console.warn(obj);
|
119 | }
|
120 | var /** @type {?} */ _symbolIterator = null;
|
121 | /**
|
122 | * @return {?}
|
123 | */
|
124 | function getSymbolIterator() {
|
125 | if (!_symbolIterator) {
|
126 | if (((globalScope)).Symbol && Symbol.iterator) {
|
127 | _symbolIterator = Symbol.iterator;
|
128 | }
|
129 | else {
|
130 | // es6-shim specific logic
|
131 | var /** @type {?} */ keys = Object.getOwnPropertyNames(Map.prototype);
|
132 | for (var /** @type {?} */ i = 0; i < keys.length; ++i) {
|
133 | var /** @type {?} */ key = keys[i];
|
134 | if (key !== 'entries' && key !== 'size' &&
|
135 | ((Map)).prototype[key] === Map.prototype['entries']) {
|
136 | _symbolIterator = key;
|
137 | }
|
138 | }
|
139 | }
|
140 | }
|
141 | return _symbolIterator;
|
142 | }
|
143 | /**
|
144 | * @param {?} obj
|
145 | * @return {?}
|
146 | */
|
147 | function isPrimitive(obj) {
|
148 | return !isJsObject(obj);
|
149 | }
|
150 |
|
151 | var /** @type {?} */ _nextClassId = 0;
|
152 | var /** @type {?} */ Reflect = global$1.Reflect;
|
153 | /**
|
154 | * @param {?} annotation
|
155 | * @return {?}
|
156 | */
|
157 | function extractAnnotation(annotation) {
|
158 | if (typeof annotation === 'function' && annotation.hasOwnProperty('annotation')) {
|
159 | // it is a decorator, extract annotation
|
160 | annotation = annotation.annotation;
|
161 | }
|
162 | return annotation;
|
163 | }
|
164 | /**
|
165 | * @param {?} fnOrArray
|
166 | * @param {?} key
|
167 | * @return {?}
|
168 | */
|
169 | function applyParams(fnOrArray, key) {
|
170 | if (fnOrArray === Object || fnOrArray === String || fnOrArray === Function ||
|
171 | fnOrArray === Number || fnOrArray === Array) {
|
172 | throw new Error("Can not use native " + stringify(fnOrArray) + " as constructor");
|
173 | }
|
174 | if (typeof fnOrArray === 'function') {
|
175 | return fnOrArray;
|
176 | }
|
177 | if (Array.isArray(fnOrArray)) {
|
178 | var /** @type {?} */ annotations = fnOrArray;
|
179 | var /** @type {?} */ annoLength = annotations.length - 1;
|
180 | var /** @type {?} */ fn = fnOrArray[annoLength];
|
181 | if (typeof fn !== 'function') {
|
182 | throw new Error("Last position of Class method array must be Function in key " + key + " was '" + stringify(fn) + "'");
|
183 | }
|
184 | if (annoLength != fn.length) {
|
185 | throw new Error("Number of annotations (" + annoLength + ") does not match number of arguments (" + fn.length + ") in the function: " + stringify(fn));
|
186 | }
|
187 | var /** @type {?} */ paramsAnnotations = [];
|
188 | for (var /** @type {?} */ i = 0, /** @type {?} */ ii = annotations.length - 1; i < ii; i++) {
|
189 | var /** @type {?} */ paramAnnotations = [];
|
190 | paramsAnnotations.push(paramAnnotations);
|
191 | var /** @type {?} */ annotation = annotations[i];
|
192 | if (Array.isArray(annotation)) {
|
193 | for (var /** @type {?} */ j = 0; j < annotation.length; j++) {
|
194 | paramAnnotations.push(extractAnnotation(annotation[j]));
|
195 | }
|
196 | }
|
197 | else if (typeof annotation === 'function') {
|
198 | paramAnnotations.push(extractAnnotation(annotation));
|
199 | }
|
200 | else {
|
201 | paramAnnotations.push(annotation);
|
202 | }
|
203 | }
|
204 | Reflect.defineMetadata('parameters', paramsAnnotations, fn);
|
205 | return fn;
|
206 | }
|
207 | throw new Error("Only Function or Array is supported in Class definition for key '" + key + "' is '" + stringify(fnOrArray) + "'");
|
208 | }
|
209 | /**
|
210 | * Provides a way for expressing ES6 classes with parameter annotations in ES5.
|
211 | * *
|
212 | * ## Basic Example
|
213 | * *
|
214 | * ```
|
215 | * var Greeter = ng.Class({
|
216 | * constructor: function(name) {
|
217 | * this.name = name;
|
218 | * },
|
219 | * *
|
220 | * greet: function() {
|
221 | * alert('Hello ' + this.name + '!');
|
222 | * }
|
223 | * });
|
224 | * ```
|
225 | * *
|
226 | * is equivalent to ES6:
|
227 | * *
|
228 | * ```
|
229 | * class Greeter {
|
230 | * constructor(name) {
|
231 | * this.name = name;
|
232 | * }
|
233 | * *
|
234 | * greet() {
|
235 | * alert('Hello ' + this.name + '!');
|
236 | * }
|
237 | * }
|
238 | * ```
|
239 | * *
|
240 | * or equivalent to ES5:
|
241 | * *
|
242 | * ```
|
243 | * var Greeter = function (name) {
|
244 | * this.name = name;
|
245 | * }
|
246 | * *
|
247 | * Greeter.prototype.greet = function () {
|
248 | * alert('Hello ' + this.name + '!');
|
249 | * }
|
250 | * ```
|
251 | * *
|
252 | * ### Example with parameter annotations
|
253 | * *
|
254 | * ```
|
255 | * var MyService = ng.Class({
|
256 | * constructor: [String, [new Optional(), Service], function(name, myService) {
|
257 | * ...
|
258 | * }]
|
259 | * });
|
260 | * ```
|
261 | * *
|
262 | * is equivalent to ES6:
|
263 | * *
|
264 | * ```
|
265 | * class MyService {
|
266 | * constructor(name: string, @Optional() myService: Service) {
|
267 | * ...
|
268 | * }
|
269 | * }
|
270 | * ```
|
271 | * *
|
272 | * ### Example with inheritance
|
273 | * *
|
274 | * ```
|
275 | * var Shape = ng.Class({
|
276 | * constructor: (color) {
|
277 | * this.color = color;
|
278 | * }
|
279 | * });
|
280 | * *
|
281 | * var Square = ng.Class({
|
282 | * extends: Shape,
|
283 | * constructor: function(color, size) {
|
284 | * Shape.call(this, color);
|
285 | * this.size = size;
|
286 | * }
|
287 | * });
|
288 | * ```
|
289 | * @param {?} clsDef
|
290 | * @return {?}
|
291 | */
|
292 | function Class(clsDef) {
|
293 | var /** @type {?} */ constructor = applyParams(clsDef.hasOwnProperty('constructor') ? clsDef.constructor : undefined, 'constructor');
|
294 | var /** @type {?} */ proto = constructor.prototype;
|
295 | if (clsDef.hasOwnProperty('extends')) {
|
296 | if (typeof clsDef.extends === 'function') {
|
297 | ((constructor)).prototype = proto =
|
298 | Object.create(((clsDef.extends)).prototype);
|
299 | }
|
300 | else {
|
301 | throw new Error("Class definition 'extends' property must be a constructor function was: " + stringify(clsDef.extends));
|
302 | }
|
303 | }
|
304 | for (var key in clsDef) {
|
305 | if (key !== 'extends' && key !== 'prototype' && clsDef.hasOwnProperty(key)) {
|
306 | proto[key] = applyParams(clsDef[key], key);
|
307 | }
|
308 | }
|
309 | if (this && this.annotations instanceof Array) {
|
310 | Reflect.defineMetadata('annotations', this.annotations, constructor);
|
311 | }
|
312 | var /** @type {?} */ constructorName = constructor['name'];
|
313 | if (!constructorName || constructorName === 'constructor') {
|
314 | ((constructor))['overriddenName'] = "class" + _nextClassId++;
|
315 | }
|
316 | return (constructor);
|
317 | }
|
318 | /**
|
319 | * @param {?} name
|
320 | * @param {?} props
|
321 | * @param {?=} parentClass
|
322 | * @param {?=} chainFn
|
323 | * @return {?}
|
324 | */
|
325 | function makeDecorator(name, props, parentClass, chainFn) {
|
326 | if (chainFn === void 0) { chainFn = null; }
|
327 | var /** @type {?} */ metaCtor = makeMetadataCtor([props]);
|
328 | /**
|
329 | * @param {?} objOrType
|
330 | * @return {?}
|
331 | */
|
332 | function DecoratorFactory(objOrType) {
|
333 | if (!(Reflect && Reflect.getOwnMetadata)) {
|
334 | throw 'reflect-metadata shim is required when using class decorators';
|
335 | }
|
336 | if (this instanceof DecoratorFactory) {
|
337 | metaCtor.call(this, objOrType);
|
338 | return this;
|
339 | }
|
340 | var /** @type {?} */ annotationInstance = new ((DecoratorFactory))(objOrType);
|
341 | var /** @type {?} */ chainAnnotation = typeof this === 'function' && Array.isArray(this.annotations) ? this.annotations : [];
|
342 | chainAnnotation.push(annotationInstance);
|
343 | var /** @type {?} */ TypeDecorator = (function TypeDecorator(cls) {
|
344 | var /** @type {?} */ annotations = Reflect.getOwnMetadata('annotations', cls) || [];
|
345 | annotations.push(annotationInstance);
|
346 | Reflect.defineMetadata('annotations', annotations, cls);
|
347 | return cls;
|
348 | });
|
349 | TypeDecorator.annotations = chainAnnotation;
|
350 | TypeDecorator.Class = Class;
|
351 | if (chainFn)
|
352 | chainFn(TypeDecorator);
|
353 | return TypeDecorator;
|
354 | }
|
355 | if (parentClass) {
|
356 | DecoratorFactory.prototype = Object.create(parentClass.prototype);
|
357 | }
|
358 | DecoratorFactory.prototype.toString = function () { return ("@" + name); };
|
359 | ((DecoratorFactory)).annotationCls = DecoratorFactory;
|
360 | return DecoratorFactory;
|
361 | }
|
362 | /**
|
363 | * @param {?} props
|
364 | * @return {?}
|
365 | */
|
366 | function makeMetadataCtor(props) {
|
367 | return function ctor() {
|
368 | var _this = this;
|
369 | var args = [];
|
370 | for (var _i = 0; _i < arguments.length; _i++) {
|
371 | args[_i - 0] = arguments[_i];
|
372 | }
|
373 | props.forEach(function (prop, i) {
|
374 | var /** @type {?} */ argVal = args[i];
|
375 | if (Array.isArray(prop)) {
|
376 | // plain parameter
|
377 | _this[prop[0]] = argVal === undefined ? prop[1] : argVal;
|
378 | }
|
379 | else {
|
380 | for (var propName in prop) {
|
381 | _this[propName] =
|
382 | argVal && argVal.hasOwnProperty(propName) ? argVal[propName] : prop[propName];
|
383 | }
|
384 | }
|
385 | });
|
386 | };
|
387 | }
|
388 | /**
|
389 | * @param {?} name
|
390 | * @param {?} props
|
391 | * @param {?=} parentClass
|
392 | * @return {?}
|
393 | */
|
394 | function makeParamDecorator(name, props, parentClass) {
|
395 | var /** @type {?} */ metaCtor = makeMetadataCtor(props);
|
396 | /**
|
397 | * @param {...?} args
|
398 | * @return {?}
|
399 | */
|
400 | function ParamDecoratorFactory() {
|
401 | var args = [];
|
402 | for (var _i = 0; _i < arguments.length; _i++) {
|
403 | args[_i - 0] = arguments[_i];
|
404 | }
|
405 | if (this instanceof ParamDecoratorFactory) {
|
406 | metaCtor.apply(this, args);
|
407 | return this;
|
408 | }
|
409 | var /** @type {?} */ annotationInstance = new ((_a = ((ParamDecoratorFactory))).bind.apply(_a, [void 0].concat(args)))();
|
410 | ((ParamDecorator)).annotation = annotationInstance;
|
411 | return ParamDecorator;
|
412 | /**
|
413 | * @param {?} cls
|
414 | * @param {?} unusedKey
|
415 | * @param {?} index
|
416 | * @return {?}
|
417 | */
|
418 | function ParamDecorator(cls, unusedKey, index) {
|
419 | var /** @type {?} */ parameters = Reflect.getOwnMetadata('parameters', cls) || [];
|
420 | // there might be gaps if some in between parameters do not have annotations.
|
421 | // we pad with nulls.
|
422 | while (parameters.length <= index) {
|
423 | parameters.push(null);
|
424 | }
|
425 | parameters[index] = parameters[index] || [];
|
426 | parameters[index].push(annotationInstance);
|
427 | Reflect.defineMetadata('parameters', parameters, cls);
|
428 | return cls;
|
429 | }
|
430 | var _a;
|
431 | }
|
432 | if (parentClass) {
|
433 | ParamDecoratorFactory.prototype = Object.create(parentClass.prototype);
|
434 | }
|
435 | ParamDecoratorFactory.prototype.toString = function () { return ("@" + name); };
|
436 | ((ParamDecoratorFactory)).annotationCls = ParamDecoratorFactory;
|
437 | return ParamDecoratorFactory;
|
438 | }
|
439 | /**
|
440 | * @param {?} name
|
441 | * @param {?} props
|
442 | * @param {?=} parentClass
|
443 | * @return {?}
|
444 | */
|
445 | function makePropDecorator(name, props, parentClass) {
|
446 | var /** @type {?} */ metaCtor = makeMetadataCtor(props);
|
447 | /**
|
448 | * @param {...?} args
|
449 | * @return {?}
|
450 | */
|
451 | function PropDecoratorFactory() {
|
452 | var args = [];
|
453 | for (var _i = 0; _i < arguments.length; _i++) {
|
454 | args[_i - 0] = arguments[_i];
|
455 | }
|
456 | if (this instanceof PropDecoratorFactory) {
|
457 | metaCtor.apply(this, args);
|
458 | return this;
|
459 | }
|
460 | var /** @type {?} */ decoratorInstance = new ((_a = ((PropDecoratorFactory))).bind.apply(_a, [void 0].concat(args)))();
|
461 | return function PropDecorator(target, name) {
|
462 | var /** @type {?} */ meta = Reflect.getOwnMetadata('propMetadata', target.constructor) || {};
|
463 | meta[name] = meta.hasOwnProperty(name) && meta[name] || [];
|
464 | meta[name].unshift(decoratorInstance);
|
465 | Reflect.defineMetadata('propMetadata', meta, target.constructor);
|
466 | };
|
467 | var _a;
|
468 | }
|
469 | if (parentClass) {
|
470 | PropDecoratorFactory.prototype = Object.create(parentClass.prototype);
|
471 | }
|
472 | PropDecoratorFactory.prototype.toString = function () { return ("@" + name); };
|
473 | ((PropDecoratorFactory)).annotationCls = PropDecoratorFactory;
|
474 | return PropDecoratorFactory;
|
475 | }
|
476 |
|
477 | /**
|
478 | * Inject decorator and metadata.
|
479 | *
|
480 | * @stable
|
481 | * @Annotation
|
482 | */
|
483 | var /** @type {?} */ Inject = makeParamDecorator('Inject', [['token', undefined]]);
|
484 | /**
|
485 | * Optional decorator and metadata.
|
486 | *
|
487 | * @stable
|
488 | * @Annotation
|
489 | */
|
490 | var /** @type {?} */ Optional = makeParamDecorator('Optional', []);
|
491 | /**
|
492 | * Injectable decorator and metadata.
|
493 | *
|
494 | * @stable
|
495 | * @Annotation
|
496 | */
|
497 | var /** @type {?} */ Injectable = (makeDecorator('Injectable', []));
|
498 | /**
|
499 | * Self decorator and metadata.
|
500 | *
|
501 | * @stable
|
502 | * @Annotation
|
503 | */
|
504 | var /** @type {?} */ Self = makeParamDecorator('Self', []);
|
505 | /**
|
506 | * SkipSelf decorator and metadata.
|
507 | *
|
508 | * @stable
|
509 | * @Annotation
|
510 | */
|
511 | var /** @type {?} */ SkipSelf = makeParamDecorator('SkipSelf', []);
|
512 | /**
|
513 | * Host decorator and metadata.
|
514 | *
|
515 | * @stable
|
516 | * @Annotation
|
517 | */
|
518 | var /** @type {?} */ Host = makeParamDecorator('Host', []);
|
519 |
|
520 | /**
|
521 | * Creates a token that can be used in a DI Provider.
|
522 | *
|
523 | * ### Example ([live demo](http://plnkr.co/edit/Ys9ezXpj2Mnoy3Uc8KBp?p=preview))
|
524 | *
|
525 | * ```typescript
|
526 | * var t = new OpaqueToken("value");
|
527 | *
|
528 | * var injector = Injector.resolveAndCreate([
|
529 | * {provide: t, useValue: "bindingValue"}
|
530 | * ]);
|
531 | *
|
532 | * expect(injector.get(t)).toEqual("bindingValue");
|
533 | * ```
|
534 | *
|
535 | * Using an `OpaqueToken` is preferable to using strings as tokens because of possible collisions
|
536 | * caused by multiple providers using the same string as two different tokens.
|
537 | *
|
538 | * Using an `OpaqueToken` is preferable to using an `Object` as tokens because it provides better
|
539 | * error messages.
|
540 | * @stable
|
541 | */
|
542 | // so that metadata is gathered for this class
|
543 | var OpaqueToken = (function () {
|
544 | /**
|
545 | * @param {?} _desc
|
546 | */
|
547 | function OpaqueToken(_desc) {
|
548 | this._desc = _desc;
|
549 | }
|
550 | /**
|
551 | * @return {?}
|
552 | */
|
553 | OpaqueToken.prototype.toString = function () { return "Token " + this._desc; };
|
554 | OpaqueToken.decorators = [
|
555 | { type: Injectable },
|
556 | ];
|
557 | /** @nocollapse */
|
558 | OpaqueToken.ctorParameters = function () { return [
|
559 | null,
|
560 | ]; };
|
561 | return OpaqueToken;
|
562 | }());
|
563 |
|
564 | /**
|
565 | * This token can be used to create a virtual provider that will populate the
|
566 | * `entryComponents` fields of components and ng modules based on its `useValue`.
|
567 | * All components that are referenced in the `useValue` value (either directly
|
568 | * or in a nested array or map) will be added to the `entryComponents` property.
|
569 | *
|
570 | * ### Example
|
571 | * The following example shows how the router can populate the `entryComponents`
|
572 | * field of an NgModule based on the router configuration which refers
|
573 | * to components.
|
574 | *
|
575 | * ```typescript
|
576 | * // helper function inside the router
|
577 | * function provideRoutes(routes) {
|
578 | * return [
|
579 | * {provide: ROUTES, useValue: routes},
|
580 | * {provide: ANALYZE_FOR_ENTRY_COMPONENTS, useValue: routes, multi: true}
|
581 | * ];
|
582 | * }
|
583 | *
|
584 | * // user code
|
585 | * let routes = [
|
586 | * {path: '/root', component: RootComp},
|
587 | * {path: '/teams', component: TeamsComp}
|
588 | * ];
|
589 | *
|
590 | * @NgModule({
|
591 | * providers: [provideRoutes(routes)]
|
592 | * })
|
593 | * class ModuleWithRoutes {}
|
594 | * ```
|
595 | *
|
596 | * @experimental
|
597 | */
|
598 | var /** @type {?} */ ANALYZE_FOR_ENTRY_COMPONENTS = new OpaqueToken('AnalyzeForEntryComponents');
|
599 | /**
|
600 | * Attribute decorator and metadata.
|
601 | *
|
602 | * @stable
|
603 | * @Annotation
|
604 | */
|
605 | var /** @type {?} */ Attribute = makeParamDecorator('Attribute', [['attributeName', undefined]]);
|
606 | /**
|
607 | * Base class for query metadata.
|
608 | * *
|
609 | * See {@link ContentChildren}, {@link ContentChild}, {@link ViewChildren}, {@link ViewChild} for
|
610 | * more information.
|
611 | * *
|
612 | * @abstract
|
613 | */
|
614 | var Query = (function () {
|
615 | function Query() {
|
616 | }
|
617 | return Query;
|
618 | }());
|
619 | /**
|
620 | * ContentChildren decorator and metadata.
|
621 | *
|
622 | * @stable
|
623 | * @Annotation
|
624 | */
|
625 | var /** @type {?} */ ContentChildren = (makePropDecorator('ContentChildren', [
|
626 | ['selector', undefined], {
|
627 | first: false,
|
628 | isViewQuery: false,
|
629 | descendants: false,
|
630 | read: undefined,
|
631 | }
|
632 | ], Query));
|
633 | /**
|
634 | * @whatItDoes Configures a content query.
|
635 | *
|
636 | * @howToUse
|
637 | *
|
638 | * {@example core/di/ts/contentChild/content_child_howto.ts region='HowTo'}
|
639 | *
|
640 | * @description
|
641 | *
|
642 | * You can use ContentChild to get the first element or the directive matching the selector from the
|
643 | * content DOM. If the content DOM changes, and a new child matches the selector,
|
644 | * the property will be updated.
|
645 | *
|
646 | * Content queries are set before the `ngAfterContentInit` callback is called.
|
647 | *
|
648 | * **Metadata Properties**:
|
649 | *
|
650 | * * **selector** - the directive type or the name used for querying.
|
651 | * * **read** - read a different token from the queried element.
|
652 | *
|
653 | * Let's look at an example:
|
654 | *
|
655 | * {@example core/di/ts/contentChild/content_child_example.ts region='Component'}
|
656 | *
|
657 | * **npm package**: `@angular/core`
|
658 | *
|
659 | * @stable
|
660 | * @Annotation
|
661 | */
|
662 | var /** @type {?} */ ContentChild = makePropDecorator('ContentChild', [
|
663 | ['selector', undefined], {
|
664 | first: true,
|
665 | isViewQuery: false,
|
666 | descendants: true,
|
667 | read: undefined,
|
668 | }
|
669 | ], Query);
|
670 | /**
|
671 | * @whatItDoes Configures a view query.
|
672 | *
|
673 | * @howToUse
|
674 | *
|
675 | * {@example core/di/ts/viewChildren/view_children_howto.ts region='HowTo'}
|
676 | *
|
677 | * @description
|
678 | *
|
679 | * You can use ViewChildren to get the {@link QueryList} of elements or directives from the
|
680 | * view DOM. Any time a child element is added, removed, or moved, the query list will be updated,
|
681 | * and the changes observable of the query list will emit a new value.
|
682 | *
|
683 | * View queries are set before the `ngAfterViewInit` callback is called.
|
684 | *
|
685 | * **Metadata Properties**:
|
686 | *
|
687 | * * **selector** - the directive type or the name used for querying.
|
688 | * * **read** - read a different token from the queried elements.
|
689 | *
|
690 | * Let's look at an example:
|
691 | *
|
692 | * {@example core/di/ts/viewChildren/view_children_example.ts region='Component'}
|
693 | *
|
694 | * **npm package**: `@angular/core`
|
695 | *
|
696 | * @stable
|
697 | * @Annotation
|
698 | */
|
699 | var /** @type {?} */ ViewChildren = makePropDecorator('ViewChildren', [
|
700 | ['selector', undefined], {
|
701 | first: false,
|
702 | isViewQuery: true,
|
703 | descendants: true,
|
704 | read: undefined,
|
705 | }
|
706 | ], Query);
|
707 | /**
|
708 | * ViewChild decorator and metadata.
|
709 | *
|
710 | * @stable
|
711 | * @Annotation
|
712 | */
|
713 | var /** @type {?} */ ViewChild = makePropDecorator('ViewChild', [
|
714 | ['selector', undefined], {
|
715 | first: true,
|
716 | isViewQuery: true,
|
717 | descendants: true,
|
718 | read: undefined,
|
719 | }
|
720 | ], Query);
|
721 |
|
722 | var ChangeDetectionStrategy = {};
|
723 | ChangeDetectionStrategy.OnPush = 0;
|
724 | ChangeDetectionStrategy.Default = 1;
|
725 | ChangeDetectionStrategy[ChangeDetectionStrategy.OnPush] = "OnPush";
|
726 | ChangeDetectionStrategy[ChangeDetectionStrategy.Default] = "Default";
|
727 | var ChangeDetectorStatus = {};
|
728 | ChangeDetectorStatus.CheckOnce = 0;
|
729 | ChangeDetectorStatus.Checked = 1;
|
730 | ChangeDetectorStatus.CheckAlways = 2;
|
731 | ChangeDetectorStatus.Detached = 3;
|
732 | ChangeDetectorStatus.Errored = 4;
|
733 | ChangeDetectorStatus.Destroyed = 5;
|
734 | ChangeDetectorStatus[ChangeDetectorStatus.CheckOnce] = "CheckOnce";
|
735 | ChangeDetectorStatus[ChangeDetectorStatus.Checked] = "Checked";
|
736 | ChangeDetectorStatus[ChangeDetectorStatus.CheckAlways] = "CheckAlways";
|
737 | ChangeDetectorStatus[ChangeDetectorStatus.Detached] = "Detached";
|
738 | ChangeDetectorStatus[ChangeDetectorStatus.Errored] = "Errored";
|
739 | ChangeDetectorStatus[ChangeDetectorStatus.Destroyed] = "Destroyed";
|
740 | /**
|
741 | * @param {?} changeDetectionStrategy
|
742 | * @return {?}
|
743 | */
|
744 | function isDefaultChangeDetectionStrategy(changeDetectionStrategy) {
|
745 | return isBlank(changeDetectionStrategy) ||
|
746 | changeDetectionStrategy === ChangeDetectionStrategy.Default;
|
747 | }
|
748 |
|
749 | /**
|
750 | * Directive decorator and metadata.
|
751 | *
|
752 | * @stable
|
753 | * @Annotation
|
754 | */
|
755 | var /** @type {?} */ Directive = (makeDecorator('Directive', {
|
756 | selector: undefined,
|
757 | inputs: undefined,
|
758 | outputs: undefined,
|
759 | host: undefined,
|
760 | providers: undefined,
|
761 | exportAs: undefined,
|
762 | queries: undefined
|
763 | }));
|
764 | /**
|
765 | * Component decorator and metadata.
|
766 | *
|
767 | * @stable
|
768 | * @Annotation
|
769 | */
|
770 | var /** @type {?} */ Component = (makeDecorator('Component', {
|
771 | selector: undefined,
|
772 | inputs: undefined,
|
773 | outputs: undefined,
|
774 | host: undefined,
|
775 | exportAs: undefined,
|
776 | moduleId: undefined,
|
777 | providers: undefined,
|
778 | viewProviders: undefined,
|
779 | changeDetection: ChangeDetectionStrategy.Default,
|
780 | queries: undefined,
|
781 | templateUrl: undefined,
|
782 | template: undefined,
|
783 | styleUrls: undefined,
|
784 | styles: undefined,
|
785 | animations: undefined,
|
786 | encapsulation: undefined,
|
787 | interpolation: undefined,
|
788 | entryComponents: undefined
|
789 | }, Directive));
|
790 | /**
|
791 | * Pipe decorator and metadata.
|
792 | *
|
793 | * @stable
|
794 | * @Annotation
|
795 | */
|
796 | var /** @type {?} */ Pipe = (makeDecorator('Pipe', {
|
797 | name: undefined,
|
798 | pure: true,
|
799 | }));
|
800 | /**
|
801 | * Input decorator and metadata.
|
802 | *
|
803 | * @stable
|
804 | * @Annotation
|
805 | */
|
806 | var /** @type {?} */ Input = makePropDecorator('Input', [['bindingPropertyName', undefined]]);
|
807 | /**
|
808 | * Output decorator and metadata.
|
809 | *
|
810 | * @stable
|
811 | * @Annotation
|
812 | */
|
813 | var /** @type {?} */ Output = makePropDecorator('Output', [['bindingPropertyName', undefined]]);
|
814 | /**
|
815 | * HostBinding decorator and metadata.
|
816 | *
|
817 | * @stable
|
818 | * @Annotation
|
819 | */
|
820 | var /** @type {?} */ HostBinding = makePropDecorator('HostBinding', [['hostPropertyName', undefined]]);
|
821 | /**
|
822 | * HostListener decorator and metadata.
|
823 | *
|
824 | * @stable
|
825 | * @Annotation
|
826 | */
|
827 | var /** @type {?} */ HostListener = makePropDecorator('HostListener', [['eventName', undefined], ['args', []]]);
|
828 |
|
829 | /**
|
830 | * @license
|
831 | * Copyright Google Inc. All Rights Reserved.
|
832 | *
|
833 | * Use of this source code is governed by an MIT-style license that can be
|
834 | * found in the LICENSE file at https://angular.io/license
|
835 | */
|
836 | var LifecycleHooks = {};
|
837 | LifecycleHooks.OnInit = 0;
|
838 | LifecycleHooks.OnDestroy = 1;
|
839 | LifecycleHooks.DoCheck = 2;
|
840 | LifecycleHooks.OnChanges = 3;
|
841 | LifecycleHooks.AfterContentInit = 4;
|
842 | LifecycleHooks.AfterContentChecked = 5;
|
843 | LifecycleHooks.AfterViewInit = 6;
|
844 | LifecycleHooks.AfterViewChecked = 7;
|
845 | LifecycleHooks[LifecycleHooks.OnInit] = "OnInit";
|
846 | LifecycleHooks[LifecycleHooks.OnDestroy] = "OnDestroy";
|
847 | LifecycleHooks[LifecycleHooks.DoCheck] = "DoCheck";
|
848 | LifecycleHooks[LifecycleHooks.OnChanges] = "OnChanges";
|
849 | LifecycleHooks[LifecycleHooks.AfterContentInit] = "AfterContentInit";
|
850 | LifecycleHooks[LifecycleHooks.AfterContentChecked] = "AfterContentChecked";
|
851 | LifecycleHooks[LifecycleHooks.AfterViewInit] = "AfterViewInit";
|
852 | LifecycleHooks[LifecycleHooks.AfterViewChecked] = "AfterViewChecked";
|
853 | var /** @type {?} */ LIFECYCLE_HOOKS_VALUES = [
|
854 | LifecycleHooks.OnInit, LifecycleHooks.OnDestroy, LifecycleHooks.DoCheck, LifecycleHooks.OnChanges,
|
855 | LifecycleHooks.AfterContentInit, LifecycleHooks.AfterContentChecked, LifecycleHooks.AfterViewInit,
|
856 | LifecycleHooks.AfterViewChecked
|
857 | ];
|
858 | /**
|
859 | * {@example core/ts/metadata/lifecycle_hooks_spec.ts region='OnChanges'}
|
860 | * *
|
861 | * `ngOnChanges` is called right after the data-bound properties have been checked and before view
|
862 | * and content children are checked if at least one of them has changed.
|
863 | * The `changes` parameter contains the changed properties.
|
864 | * *
|
865 | * See {@linkDocs guide/lifecycle-hooks#onchanges "Lifecycle Hooks Guide"}.
|
866 | * *
|
867 | * @abstract
|
868 | */
|
869 | var OnChanges = (function () {
|
870 | function OnChanges() {
|
871 | }
|
872 | /**
|
873 | * @abstract
|
874 | * @param {?} changes
|
875 | * @return {?}
|
876 | */
|
877 | OnChanges.prototype.ngOnChanges = function (changes) { };
|
878 | return OnChanges;
|
879 | }());
|
880 | /**
|
881 | * initialized.
|
882 | * {@example core/ts/metadata/lifecycle_hooks_spec.ts region='OnInit'}
|
883 | * *
|
884 | * `ngOnInit` is called right after the directive's data-bound properties have been checked for the
|
885 | * first time, and before any of its children have been checked. It is invoked only once when the
|
886 | * directive is instantiated.
|
887 | * *
|
888 | * See {@linkDocs guide/lifecycle-hooks "Lifecycle Hooks Guide"}.
|
889 | * *
|
890 | * @abstract
|
891 | */
|
892 | var OnInit = (function () {
|
893 | function OnInit() {
|
894 | }
|
895 | /**
|
896 | * @abstract
|
897 | * @return {?}
|
898 | */
|
899 | OnInit.prototype.ngOnInit = function () { };
|
900 | return OnInit;
|
901 | }());
|
902 | /**
|
903 | * {@example core/ts/metadata/lifecycle_hooks_spec.ts region='DoCheck'}
|
904 | * *
|
905 | * `ngDoCheck` gets called to check the changes in the directives in addition to the default
|
906 | * algorithm. The default change detection algorithm looks for differences by comparing
|
907 | * bound-property values by reference across change detection runs.
|
908 | * *
|
909 | * Note that a directive typically should not use both `DoCheck` and {@link OnChanges} to respond to
|
910 | * changes on the same input, as `ngOnChanges` will continue to be called when the default change
|
911 | * detector detects changes.
|
912 | * *
|
913 | * See {@link KeyValueDiffers} and {@link IterableDiffers} for implementing custom dirty checking
|
914 | * for collections.
|
915 | * *
|
916 | * See {@linkDocs guide/lifecycle-hooks#docheck "Lifecycle Hooks Guide"}.
|
917 | * *
|
918 | * @abstract
|
919 | */
|
920 | var DoCheck = (function () {
|
921 | function DoCheck() {
|
922 | }
|
923 | /**
|
924 | * @abstract
|
925 | * @return {?}
|
926 | */
|
927 | DoCheck.prototype.ngDoCheck = function () { };
|
928 | return DoCheck;
|
929 | }());
|
930 | /**
|
931 | * {@example core/ts/metadata/lifecycle_hooks_spec.ts region='OnDestroy'}
|
932 | * *
|
933 | * `ngOnDestroy` callback is typically used for any custom cleanup that needs to occur when the
|
934 | * instance is destroyed.
|
935 | * *
|
936 | * See {@linkDocs guide/lifecycle-hooks "Lifecycle Hooks Guide"}.
|
937 | * *
|
938 | * @abstract
|
939 | */
|
940 | var OnDestroy = (function () {
|
941 | function OnDestroy() {
|
942 | }
|
943 | /**
|
944 | * @abstract
|
945 | * @return {?}
|
946 | */
|
947 | OnDestroy.prototype.ngOnDestroy = function () { };
|
948 | return OnDestroy;
|
949 | }());
|
950 | /**
|
951 | * *
|
952 | * initialized.
|
953 | * {@example core/ts/metadata/lifecycle_hooks_spec.ts region='AfterContentInit'}
|
954 | * *
|
955 | * See {@linkDocs guide/lifecycle-hooks#aftercontent "Lifecycle Hooks Guide"}.
|
956 | * *
|
957 | * @abstract
|
958 | */
|
959 | var AfterContentInit = (function () {
|
960 | function AfterContentInit() {
|
961 | }
|
962 | /**
|
963 | * @abstract
|
964 | * @return {?}
|
965 | */
|
966 | AfterContentInit.prototype.ngAfterContentInit = function () { };
|
967 | return AfterContentInit;
|
968 | }());
|
969 | /**
|
970 | * {@example core/ts/metadata/lifecycle_hooks_spec.ts region='AfterContentChecked'}
|
971 | * *
|
972 | * See {@linkDocs guide/lifecycle-hooks#aftercontent "Lifecycle Hooks Guide"}.
|
973 | * *
|
974 | * @abstract
|
975 | */
|
976 | var AfterContentChecked = (function () {
|
977 | function AfterContentChecked() {
|
978 | }
|
979 | /**
|
980 | * @abstract
|
981 | * @return {?}
|
982 | */
|
983 | AfterContentChecked.prototype.ngAfterContentChecked = function () { };
|
984 | return AfterContentChecked;
|
985 | }());
|
986 | /**
|
987 | * initialized.
|
988 | * {@example core/ts/metadata/lifecycle_hooks_spec.ts region='AfterViewInit'}
|
989 | * *
|
990 | * See {@linkDocs guide/lifecycle-hooks#afterview "Lifecycle Hooks Guide"}.
|
991 | * *
|
992 | * @abstract
|
993 | */
|
994 | var AfterViewInit = (function () {
|
995 | function AfterViewInit() {
|
996 | }
|
997 | /**
|
998 | * @abstract
|
999 | * @return {?}
|
1000 | */
|
1001 | AfterViewInit.prototype.ngAfterViewInit = function () { };
|
1002 | return AfterViewInit;
|
1003 | }());
|
1004 | /**
|
1005 | * {@example core/ts/metadata/lifecycle_hooks_spec.ts region='AfterViewChecked'}
|
1006 | * *
|
1007 | * See {@linkDocs guide/lifecycle-hooks#afterview "Lifecycle Hooks Guide"}.
|
1008 | * *
|
1009 | * @abstract
|
1010 | */
|
1011 | var AfterViewChecked = (function () {
|
1012 | function AfterViewChecked() {
|
1013 | }
|
1014 | /**
|
1015 | * @abstract
|
1016 | * @return {?}
|
1017 | */
|
1018 | AfterViewChecked.prototype.ngAfterViewChecked = function () { };
|
1019 | return AfterViewChecked;
|
1020 | }());
|
1021 |
|
1022 | /**
|
1023 | * Defines a schema that will allow:
|
1024 | * - any non-Angular elements with a `-` in their name,
|
1025 | * - any properties on elements with a `-` in their name which is the common rule for custom
|
1026 | * elements.
|
1027 | *
|
1028 | * @stable
|
1029 | */
|
1030 | var /** @type {?} */ CUSTOM_ELEMENTS_SCHEMA = {
|
1031 | name: 'custom-elements'
|
1032 | };
|
1033 | /**
|
1034 | * Defines a schema that will allow any property on any element.
|
1035 | *
|
1036 | * @experimental
|
1037 | */
|
1038 | var /** @type {?} */ NO_ERRORS_SCHEMA = {
|
1039 | name: 'no-errors-schema'
|
1040 | };
|
1041 | /**
|
1042 | * NgModule decorator and metadata.
|
1043 | *
|
1044 | * @stable
|
1045 | * @Annotation
|
1046 | */
|
1047 | var /** @type {?} */ NgModule = (makeDecorator('NgModule', {
|
1048 | providers: undefined,
|
1049 | declarations: undefined,
|
1050 | imports: undefined,
|
1051 | exports: undefined,
|
1052 | entryComponents: undefined,
|
1053 | bootstrap: undefined,
|
1054 | schemas: undefined,
|
1055 | id: undefined,
|
1056 | }));
|
1057 |
|
1058 | /**
|
1059 | * @license
|
1060 | * Copyright Google Inc. All Rights Reserved.
|
1061 | *
|
1062 | * Use of this source code is governed by an MIT-style license that can be
|
1063 | * found in the LICENSE file at https://angular.io/license
|
1064 | */
|
1065 | var ViewEncapsulation = {};
|
1066 | ViewEncapsulation.Emulated = 0;
|
1067 | ViewEncapsulation.Native = 1;
|
1068 | ViewEncapsulation.None = 2;
|
1069 | ViewEncapsulation[ViewEncapsulation.Emulated] = "Emulated";
|
1070 | ViewEncapsulation[ViewEncapsulation.Native] = "Native";
|
1071 | ViewEncapsulation[ViewEncapsulation.None] = "None";
|
1072 | /**
|
1073 | * Metadata properties available for configuring Views.
|
1074 | * *
|
1075 | * For details on the `@Component` annotation, see {@link Component}.
|
1076 | * *
|
1077 | * ### Example
|
1078 | * *
|
1079 | * ```
|
1080 | * selector: 'greet',
|
1081 | * template: 'Hello {{name}}!',
|
1082 | * })
|
1083 | * class Greet {
|
1084 | * name: string;
|
1085 | * *
|
1086 | * constructor() {
|
1087 | * this.name = 'World';
|
1088 | * }
|
1089 | * }
|
1090 | * ```
|
1091 | * *
|
1092 | * @deprecated Use Component instead.
|
1093 | * *
|
1094 | * {@link Component}
|
1095 | */
|
1096 | var ViewMetadata = (function () {
|
1097 | /**
|
1098 | * @param {?=} __0
|
1099 | */
|
1100 | function ViewMetadata(_a) {
|
1101 | var _b = _a === void 0 ? {} : _a, templateUrl = _b.templateUrl, template = _b.template, encapsulation = _b.encapsulation, styles = _b.styles, styleUrls = _b.styleUrls, animations = _b.animations, interpolation = _b.interpolation;
|
1102 | this.templateUrl = templateUrl;
|
1103 | this.template = template;
|
1104 | this.styleUrls = styleUrls;
|
1105 | this.styles = styles;
|
1106 | this.encapsulation = encapsulation;
|
1107 | this.animations = animations;
|
1108 | this.interpolation = interpolation;
|
1109 | }
|
1110 | return ViewMetadata;
|
1111 | }());
|
1112 |
|
1113 | /**
|
1114 | * *
|
1115 | */
|
1116 | var Version = (function () {
|
1117 | /**
|
1118 | * @param {?} full
|
1119 | */
|
1120 | function Version(full) {
|
1121 | this.full = full;
|
1122 | }
|
1123 | Object.defineProperty(Version.prototype, "major", {
|
1124 | /**
|
1125 | * @return {?}
|
1126 | */
|
1127 | get: function () { return this.full.split('.')[0]; },
|
1128 | enumerable: true,
|
1129 | configurable: true
|
1130 | });
|
1131 | Object.defineProperty(Version.prototype, "minor", {
|
1132 | /**
|
1133 | * @return {?}
|
1134 | */
|
1135 | get: function () { return this.full.split('.')[1]; },
|
1136 | enumerable: true,
|
1137 | configurable: true
|
1138 | });
|
1139 | Object.defineProperty(Version.prototype, "patch", {
|
1140 | /**
|
1141 | * @return {?}
|
1142 | */
|
1143 | get: function () { return this.full.split('.').slice(2).join('.'); },
|
1144 | enumerable: true,
|
1145 | configurable: true
|
1146 | });
|
1147 | return Version;
|
1148 | }());
|
1149 | /**
|
1150 | * @stable
|
1151 | */
|
1152 | var /** @type {?} */ VERSION = new Version('2.4.0');
|
1153 |
|
1154 | /**
|
1155 | * Allows to refer to references which are not yet defined.
|
1156 | * *
|
1157 | * For instance, `forwardRef` is used when the `token` which we need to refer to for the purposes of
|
1158 | * DI is declared,
|
1159 | * but not yet defined. It is also used when the `token` which we use when creating a query is not
|
1160 | * yet defined.
|
1161 | * *
|
1162 | * ### Example
|
1163 | * {@example core/di/ts/forward_ref/forward_ref_spec.ts region='forward_ref'}
|
1164 | * @param {?} forwardRefFn
|
1165 | * @return {?}
|
1166 | */
|
1167 | function forwardRef(forwardRefFn) {
|
1168 | ((forwardRefFn)).__forward_ref__ = forwardRef;
|
1169 | ((forwardRefFn)).toString = function () { return stringify(this()); };
|
1170 | return (((forwardRefFn)));
|
1171 | }
|
1172 | /**
|
1173 | * Lazily retrieves the reference value from a forwardRef.
|
1174 | * *
|
1175 | * Acts as the identity function when given a non-forward-ref value.
|
1176 | * *
|
1177 | * ### Example ([live demo](http://plnkr.co/edit/GU72mJrk1fiodChcmiDR?p=preview))
|
1178 | * *
|
1179 | * {@example core/di/ts/forward_ref/forward_ref_spec.ts region='resolve_forward_ref'}
|
1180 | * *
|
1181 | * See: {@link forwardRef}
|
1182 | * @param {?} type
|
1183 | * @return {?}
|
1184 | */
|
1185 | function resolveForwardRef(type) {
|
1186 | if (typeof type === 'function' && type.hasOwnProperty('__forward_ref__') &&
|
1187 | type.__forward_ref__ === forwardRef) {
|
1188 | return ((type))();
|
1189 | }
|
1190 | else {
|
1191 | return type;
|
1192 | }
|
1193 | }
|
1194 |
|
1195 | var __extends = (this && this.__extends) || function (d, b) {
|
1196 | for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
1197 | function __() { this.constructor = d; }
|
1198 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
1199 | };
|
1200 | /**
|
1201 | * @license undefined
|
1202 | * Copyright Google Inc. All Rights Reserved.
|
1203 | * *
|
1204 | * Use of this source code is governed by an MIT-style license that can be
|
1205 | * found in the LICENSE file at https://angular.io/license
|
1206 | * @return {?}
|
1207 | */
|
1208 | function unimplemented() {
|
1209 | throw new Error('unimplemented');
|
1210 | }
|
1211 | /**
|
1212 | * @stable
|
1213 | */
|
1214 | var BaseError = (function (_super) {
|
1215 | __extends(BaseError, _super);
|
1216 | /**
|
1217 | * @param {?} message
|
1218 | */
|
1219 | function BaseError(message) {
|
1220 | _super.call(this, message);
|
1221 | // Errors don't use current this, instead they create a new instance.
|
1222 | // We have to do forward all of our api to the nativeInstance.
|
1223 | // TODO(bradfordcsmith): Remove this hack when
|
1224 | // google/closure-compiler/issues/2102 is fixed.
|
1225 | var nativeError = new Error(message);
|
1226 | this._nativeError = nativeError;
|
1227 | }
|
1228 | Object.defineProperty(BaseError.prototype, "message", {
|
1229 | /**
|
1230 | * @return {?}
|
1231 | */
|
1232 | get: function () { return this._nativeError.message; },
|
1233 | /**
|
1234 | * @param {?} message
|
1235 | * @return {?}
|
1236 | */
|
1237 | set: function (message) { this._nativeError.message = message; },
|
1238 | enumerable: true,
|
1239 | configurable: true
|
1240 | });
|
1241 | Object.defineProperty(BaseError.prototype, "name", {
|
1242 | /**
|
1243 | * @return {?}
|
1244 | */
|
1245 | get: function () { return this._nativeError.name; },
|
1246 | enumerable: true,
|
1247 | configurable: true
|
1248 | });
|
1249 | Object.defineProperty(BaseError.prototype, "stack", {
|
1250 | /**
|
1251 | * @return {?}
|
1252 | */
|
1253 | get: function () { return ((this._nativeError)).stack; },
|
1254 | /**
|
1255 | * @param {?} value
|
1256 | * @return {?}
|
1257 | */
|
1258 | set: function (value) { ((this._nativeError)).stack = value; },
|
1259 | enumerable: true,
|
1260 | configurable: true
|
1261 | });
|
1262 | /**
|
1263 | * @return {?}
|
1264 | */
|
1265 | BaseError.prototype.toString = function () { return this._nativeError.toString(); };
|
1266 | return BaseError;
|
1267 | }(Error));
|
1268 | /**
|
1269 | * @stable
|
1270 | */
|
1271 | var WrappedError = (function (_super) {
|
1272 | __extends(WrappedError, _super);
|
1273 | /**
|
1274 | * @param {?} message
|
1275 | * @param {?} error
|
1276 | */
|
1277 | function WrappedError(message, error) {
|
1278 | _super.call(this, message + " caused by: " + (error instanceof Error ? error.message : error));
|
1279 | this.originalError = error;
|
1280 | }
|
1281 | Object.defineProperty(WrappedError.prototype, "stack", {
|
1282 | /**
|
1283 | * @return {?}
|
1284 | */
|
1285 | get: function () {
|
1286 | return (((this.originalError instanceof Error ? this.originalError : this._nativeError)))
|
1287 | .stack;
|
1288 | },
|
1289 | enumerable: true,
|
1290 | configurable: true
|
1291 | });
|
1292 | return WrappedError;
|
1293 | }(BaseError));
|
1294 |
|
1295 | var /** @type {?} */ _THROW_IF_NOT_FOUND = new Object();
|
1296 | var /** @type {?} */ THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND;
|
1297 | var _NullInjector = (function () {
|
1298 | function _NullInjector() {
|
1299 | }
|
1300 | /**
|
1301 | * @param {?} token
|
1302 | * @param {?=} notFoundValue
|
1303 | * @return {?}
|
1304 | */
|
1305 | _NullInjector.prototype.get = function (token, notFoundValue) {
|
1306 | if (notFoundValue === void 0) { notFoundValue = _THROW_IF_NOT_FOUND; }
|
1307 | if (notFoundValue === _THROW_IF_NOT_FOUND) {
|
1308 | throw new Error("No provider for " + stringify(token) + "!");
|
1309 | }
|
1310 | return notFoundValue;
|
1311 | };
|
1312 | return _NullInjector;
|
1313 | }());
|
1314 | /**
|
1315 | * ```
|
1316 | * const injector: Injector = ...;
|
1317 | * injector.get(...);
|
1318 | * ```
|
1319 | * *
|
1320 | * For more details, see the {@linkDocs guide/dependency-injection "Dependency Injection Guide"}.
|
1321 | * *
|
1322 | * ### Example
|
1323 | * *
|
1324 | * {@example core/di/ts/injector_spec.ts region='Injector'}
|
1325 | * *
|
1326 | * `Injector` returns itself when given `Injector` as a token:
|
1327 | * {@example core/di/ts/injector_spec.ts region='injectInjector'}
|
1328 | * *
|
1329 | * @abstract
|
1330 | */
|
1331 | var Injector = (function () {
|
1332 | function Injector() {
|
1333 | }
|
1334 | /**
|
1335 | * Retrieves an instance from the injector based on the provided token.
|
1336 | * If not found:
|
1337 | * - Throws {@link NoProviderError} if no `notFoundValue` that is not equal to
|
1338 | * Injector.THROW_IF_NOT_FOUND is given
|
1339 | * - Returns the `notFoundValue` otherwise
|
1340 | * @param {?} token
|
1341 | * @param {?=} notFoundValue
|
1342 | * @return {?}
|
1343 | */
|
1344 | Injector.prototype.get = function (token, notFoundValue) { return unimplemented(); };
|
1345 | Injector.THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND;
|
1346 | Injector.NULL = new _NullInjector();
|
1347 | return Injector;
|
1348 | }());
|
1349 |
|
1350 | /**
|
1351 | * @license
|
1352 | * Copyright Google Inc. All Rights Reserved.
|
1353 | *
|
1354 | * Use of this source code is governed by an MIT-style license that can be
|
1355 | * found in the LICENSE file at https://angular.io/license
|
1356 | */
|
1357 | var __extends$1 = (this && this.__extends) || function (d, b) {
|
1358 | for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
1359 | function __() { this.constructor = d; }
|
1360 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
1361 | };
|
1362 | /**
|
1363 | * @param {?} keys
|
1364 | * @return {?}
|
1365 | */
|
1366 | function findFirstClosedCycle(keys) {
|
1367 | var /** @type {?} */ res = [];
|
1368 | for (var /** @type {?} */ i = 0; i < keys.length; ++i) {
|
1369 | if (res.indexOf(keys[i]) > -1) {
|
1370 | res.push(keys[i]);
|
1371 | return res;
|
1372 | }
|
1373 | res.push(keys[i]);
|
1374 | }
|
1375 | return res;
|
1376 | }
|
1377 | /**
|
1378 | * @param {?} keys
|
1379 | * @return {?}
|
1380 | */
|
1381 | function constructResolvingPath(keys) {
|
1382 | if (keys.length > 1) {
|
1383 | var /** @type {?} */ reversed = findFirstClosedCycle(keys.slice().reverse());
|
1384 | var /** @type {?} */ tokenStrs = reversed.map(function (k) { return stringify(k.token); });
|
1385 | return ' (' + tokenStrs.join(' -> ') + ')';
|
1386 | }
|
1387 | return '';
|
1388 | }
|
1389 | /**
|
1390 | * Base class for all errors arising from misconfigured providers.
|
1391 | */
|
1392 | var AbstractProviderError = (function (_super) {
|
1393 | __extends$1(AbstractProviderError, _super);
|
1394 | /**
|
1395 | * @param {?} injector
|
1396 | * @param {?} key
|
1397 | * @param {?} constructResolvingMessage
|
1398 | */
|
1399 | function AbstractProviderError(injector, key, constructResolvingMessage) {
|
1400 | _super.call(this, 'DI Error');
|
1401 | this.keys = [key];
|
1402 | this.injectors = [injector];
|
1403 | this.constructResolvingMessage = constructResolvingMessage;
|
1404 | this.message = this.constructResolvingMessage(this.keys);
|
1405 | }
|
1406 | /**
|
1407 | * @param {?} injector
|
1408 | * @param {?} key
|
1409 | * @return {?}
|
1410 | */
|
1411 | AbstractProviderError.prototype.addKey = function (injector, key) {
|
1412 | this.injectors.push(injector);
|
1413 | this.keys.push(key);
|
1414 | this.message = this.constructResolvingMessage(this.keys);
|
1415 | };
|
1416 | return AbstractProviderError;
|
1417 | }(BaseError));
|
1418 | /**
|
1419 | * Thrown when trying to retrieve a dependency by key from {@link Injector}, but the
|
1420 | * {@link Injector} does not have a {@link Provider} for the given key.
|
1421 | * *
|
1422 | * ### Example ([live demo](http://plnkr.co/edit/vq8D3FRB9aGbnWJqtEPE?p=preview))
|
1423 | * *
|
1424 | * ```typescript
|
1425 | * class A {
|
1426 | * constructor(b:B) {}
|
1427 | * }
|
1428 | * *
|
1429 | * expect(() => Injector.resolveAndCreate([A])).toThrowError();
|
1430 | * ```
|
1431 | */
|
1432 | var NoProviderError = (function (_super) {
|
1433 | __extends$1(NoProviderError, _super);
|
1434 | /**
|
1435 | * @param {?} injector
|
1436 | * @param {?} key
|
1437 | */
|
1438 | function NoProviderError(injector, key) {
|
1439 | _super.call(this, injector, key, function (keys) {
|
1440 | var first = stringify(keys[0].token);
|
1441 | return "No provider for " + first + "!" + constructResolvingPath(keys);
|
1442 | });
|
1443 | }
|
1444 | return NoProviderError;
|
1445 | }(AbstractProviderError));
|
1446 | /**
|
1447 | * Thrown when dependencies form a cycle.
|
1448 | * *
|
1449 | * ### Example ([live demo](http://plnkr.co/edit/wYQdNos0Tzql3ei1EV9j?p=info))
|
1450 | * *
|
1451 | * ```typescript
|
1452 | * var injector = Injector.resolveAndCreate([
|
1453 | * {provide: "one", useFactory: (two) => "two", deps: [[new Inject("two")]]},
|
1454 | * {provide: "two", useFactory: (one) => "one", deps: [[new Inject("one")]]}
|
1455 | * ]);
|
1456 | * *
|
1457 | * expect(() => injector.get("one")).toThrowError();
|
1458 | * ```
|
1459 | * *
|
1460 | * Retrieving `A` or `B` throws a `CyclicDependencyError` as the graph above cannot be constructed.
|
1461 | */
|
1462 | var CyclicDependencyError = (function (_super) {
|
1463 | __extends$1(CyclicDependencyError, _super);
|
1464 | /**
|
1465 | * @param {?} injector
|
1466 | * @param {?} key
|
1467 | */
|
1468 | function CyclicDependencyError(injector, key) {
|
1469 | _super.call(this, injector, key, function (keys) {
|
1470 | return "Cannot instantiate cyclic dependency!" + constructResolvingPath(keys);
|
1471 | });
|
1472 | }
|
1473 | return CyclicDependencyError;
|
1474 | }(AbstractProviderError));
|
1475 | /**
|
1476 | * Thrown when a constructing type returns with an Error.
|
1477 | * *
|
1478 | * The `InstantiationError` class contains the original error plus the dependency graph which caused
|
1479 | * this object to be instantiated.
|
1480 | * *
|
1481 | * ### Example ([live demo](http://plnkr.co/edit/7aWYdcqTQsP0eNqEdUAf?p=preview))
|
1482 | * *
|
1483 | * ```typescript
|
1484 | * class A {
|
1485 | * constructor() {
|
1486 | * throw new Error('message');
|
1487 | * }
|
1488 | * }
|
1489 | * *
|
1490 | * var injector = Injector.resolveAndCreate([A]);
|
1491 | * try {
|
1492 | * injector.get(A);
|
1493 | * } catch (e) {
|
1494 | * expect(e instanceof InstantiationError).toBe(true);
|
1495 | * expect(e.originalException.message).toEqual("message");
|
1496 | * expect(e.originalStack).toBeDefined();
|
1497 | * }
|
1498 | * ```
|
1499 | */
|
1500 | var InstantiationError = (function (_super) {
|
1501 | __extends$1(InstantiationError, _super);
|
1502 | /**
|
1503 | * @param {?} injector
|
1504 | * @param {?} originalException
|
1505 | * @param {?} originalStack
|
1506 | * @param {?} key
|
1507 | */
|
1508 | function InstantiationError(injector, originalException, originalStack, key) {
|
1509 | _super.call(this, 'DI Error', originalException);
|
1510 | this.keys = [key];
|
1511 | this.injectors = [injector];
|
1512 | }
|
1513 | /**
|
1514 | * @param {?} injector
|
1515 | * @param {?} key
|
1516 | * @return {?}
|
1517 | */
|
1518 | InstantiationError.prototype.addKey = function (injector, key) {
|
1519 | this.injectors.push(injector);
|
1520 | this.keys.push(key);
|
1521 | };
|
1522 | Object.defineProperty(InstantiationError.prototype, "message", {
|
1523 | /**
|
1524 | * @return {?}
|
1525 | */
|
1526 | get: function () {
|
1527 | var /** @type {?} */ first = stringify(this.keys[0].token);
|
1528 | return this.originalError.message + ": Error during instantiation of " + first + "!" + constructResolvingPath(this.keys) + ".";
|
1529 | },
|
1530 | enumerable: true,
|
1531 | configurable: true
|
1532 | });
|
1533 | Object.defineProperty(InstantiationError.prototype, "causeKey", {
|
1534 | /**
|
1535 | * @return {?}
|
1536 | */
|
1537 | get: function () { return this.keys[0]; },
|
1538 | enumerable: true,
|
1539 | configurable: true
|
1540 | });
|
1541 | return InstantiationError;
|
1542 | }(WrappedError));
|
1543 | /**
|
1544 | * Thrown when an object other then {@link Provider} (or `Type`) is passed to {@link Injector}
|
1545 | * creation.
|
1546 | * *
|
1547 | * ### Example ([live demo](http://plnkr.co/edit/YatCFbPAMCL0JSSQ4mvH?p=preview))
|
1548 | * *
|
1549 | * ```typescript
|
1550 | * expect(() => Injector.resolveAndCreate(["not a type"])).toThrowError();
|
1551 | * ```
|
1552 | */
|
1553 | var InvalidProviderError = (function (_super) {
|
1554 | __extends$1(InvalidProviderError, _super);
|
1555 | /**
|
1556 | * @param {?} provider
|
1557 | */
|
1558 | function InvalidProviderError(provider) {
|
1559 | _super.call(this, "Invalid provider - only instances of Provider and Type are allowed, got: " + provider);
|
1560 | }
|
1561 | return InvalidProviderError;
|
1562 | }(BaseError));
|
1563 | /**
|
1564 | * Thrown when the class has no annotation information.
|
1565 | * *
|
1566 | * Lack of annotation information prevents the {@link Injector} from determining which dependencies
|
1567 | * need to be injected into the constructor.
|
1568 | * *
|
1569 | * ### Example ([live demo](http://plnkr.co/edit/rHnZtlNS7vJOPQ6pcVkm?p=preview))
|
1570 | * *
|
1571 | * ```typescript
|
1572 | * class A {
|
1573 | * constructor(b) {}
|
1574 | * }
|
1575 | * *
|
1576 | * expect(() => Injector.resolveAndCreate([A])).toThrowError();
|
1577 | * ```
|
1578 | * *
|
1579 | * This error is also thrown when the class not marked with {@link Injectable} has parameter types.
|
1580 | * *
|
1581 | * ```typescript
|
1582 | * class B {}
|
1583 | * *
|
1584 | * class A {
|
1585 | * constructor(b:B) {} // no information about the parameter types of A is available at runtime.
|
1586 | * }
|
1587 | * *
|
1588 | * expect(() => Injector.resolveAndCreate([A,B])).toThrowError();
|
1589 | * ```
|
1590 | */
|
1591 | var NoAnnotationError = (function (_super) {
|
1592 | __extends$1(NoAnnotationError, _super);
|
1593 | /**
|
1594 | * @param {?} typeOrFunc
|
1595 | * @param {?} params
|
1596 | */
|
1597 | function NoAnnotationError(typeOrFunc, params) {
|
1598 | _super.call(this, NoAnnotationError._genMessage(typeOrFunc, params));
|
1599 | }
|
1600 | /**
|
1601 | * @param {?} typeOrFunc
|
1602 | * @param {?} params
|
1603 | * @return {?}
|
1604 | */
|
1605 | NoAnnotationError._genMessage = function (typeOrFunc, params) {
|
1606 | var /** @type {?} */ signature = [];
|
1607 | for (var /** @type {?} */ i = 0, /** @type {?} */ ii = params.length; i < ii; i++) {
|
1608 | var /** @type {?} */ parameter = params[i];
|
1609 | if (!parameter || parameter.length == 0) {
|
1610 | signature.push('?');
|
1611 | }
|
1612 | else {
|
1613 | signature.push(parameter.map(stringify).join(' '));
|
1614 | }
|
1615 | }
|
1616 | return 'Cannot resolve all parameters for \'' + stringify(typeOrFunc) + '\'(' +
|
1617 | signature.join(', ') + '). ' +
|
1618 | 'Make sure that all the parameters are decorated with Inject or have valid type annotations and that \'' +
|
1619 | stringify(typeOrFunc) + '\' is decorated with Injectable.';
|
1620 | };
|
1621 | return NoAnnotationError;
|
1622 | }(BaseError));
|
1623 | /**
|
1624 | * Thrown when getting an object by index.
|
1625 | * *
|
1626 | * ### Example ([live demo](http://plnkr.co/edit/bRs0SX2OTQiJzqvjgl8P?p=preview))
|
1627 | * *
|
1628 | * ```typescript
|
1629 | * class A {}
|
1630 | * *
|
1631 | * var injector = Injector.resolveAndCreate([A]);
|
1632 | * *
|
1633 | * expect(() => injector.getAt(100)).toThrowError();
|
1634 | * ```
|
1635 | */
|
1636 | var OutOfBoundsError = (function (_super) {
|
1637 | __extends$1(OutOfBoundsError, _super);
|
1638 | /**
|
1639 | * @param {?} index
|
1640 | */
|
1641 | function OutOfBoundsError(index) {
|
1642 | _super.call(this, "Index " + index + " is out-of-bounds.");
|
1643 | }
|
1644 | return OutOfBoundsError;
|
1645 | }(BaseError));
|
1646 | /**
|
1647 | * Thrown when a multi provider and a regular provider are bound to the same token.
|
1648 | * *
|
1649 | * ### Example
|
1650 | * *
|
1651 | * ```typescript
|
1652 | * expect(() => Injector.resolveAndCreate([
|
1653 | * { provide: "Strings", useValue: "string1", multi: true},
|
1654 | * { provide: "Strings", useValue: "string2", multi: false}
|
1655 | * ])).toThrowError();
|
1656 | * ```
|
1657 | */
|
1658 | var MixingMultiProvidersWithRegularProvidersError = (function (_super) {
|
1659 | __extends$1(MixingMultiProvidersWithRegularProvidersError, _super);
|
1660 | /**
|
1661 | * @param {?} provider1
|
1662 | * @param {?} provider2
|
1663 | */
|
1664 | function MixingMultiProvidersWithRegularProvidersError(provider1, provider2) {
|
1665 | _super.call(this, 'Cannot mix multi providers and regular providers, got: ' + provider1.toString() + ' ' +
|
1666 | provider2.toString());
|
1667 | }
|
1668 | return MixingMultiProvidersWithRegularProvidersError;
|
1669 | }(BaseError));
|
1670 |
|
1671 | /**
|
1672 | * A unique object used for retrieving items from the {@link ReflectiveInjector}.
|
1673 | * *
|
1674 | * Keys have:
|
1675 | * - a system-wide unique `id`.
|
1676 | * - a `token`.
|
1677 | * *
|
1678 | * `Key` is used internally by {@link ReflectiveInjector} because its system-wide unique `id` allows
|
1679 | * the
|
1680 | * injector to store created objects in a more efficient way.
|
1681 | * *
|
1682 | * `Key` should not be created directly. {@link ReflectiveInjector} creates keys automatically when
|
1683 | * resolving
|
1684 | * providers.
|
1685 | */
|
1686 | var ReflectiveKey = (function () {
|
1687 | /**
|
1688 | * Private
|
1689 | * @param {?} token
|
1690 | * @param {?} id
|
1691 | */
|
1692 | function ReflectiveKey(token, id) {
|
1693 | this.token = token;
|
1694 | this.id = id;
|
1695 | if (!token) {
|
1696 | throw new Error('Token must be defined!');
|
1697 | }
|
1698 | }
|
1699 | Object.defineProperty(ReflectiveKey.prototype, "displayName", {
|
1700 | /**
|
1701 | * Returns a stringified token.
|
1702 | * @return {?}
|
1703 | */
|
1704 | get: function () { return stringify(this.token); },
|
1705 | enumerable: true,
|
1706 | configurable: true
|
1707 | });
|
1708 | /**
|
1709 | * Retrieves a `Key` for a token.
|
1710 | * @param {?} token
|
1711 | * @return {?}
|
1712 | */
|
1713 | ReflectiveKey.get = function (token) {
|
1714 | return _globalKeyRegistry.get(resolveForwardRef(token));
|
1715 | };
|
1716 | Object.defineProperty(ReflectiveKey, "numberOfKeys", {
|
1717 | /**
|
1718 | * @return {?} the number of keys registered in the system.
|
1719 | */
|
1720 | get: function () { return _globalKeyRegistry.numberOfKeys; },
|
1721 | enumerable: true,
|
1722 | configurable: true
|
1723 | });
|
1724 | return ReflectiveKey;
|
1725 | }());
|
1726 | /**
|
1727 | * @internal
|
1728 | */
|
1729 | var KeyRegistry = (function () {
|
1730 | function KeyRegistry() {
|
1731 | this._allKeys = new Map();
|
1732 | }
|
1733 | /**
|
1734 | * @param {?} token
|
1735 | * @return {?}
|
1736 | */
|
1737 | KeyRegistry.prototype.get = function (token) {
|
1738 | if (token instanceof ReflectiveKey)
|
1739 | return token;
|
1740 | if (this._allKeys.has(token)) {
|
1741 | return this._allKeys.get(token);
|
1742 | }
|
1743 | var /** @type {?} */ newKey = new ReflectiveKey(token, ReflectiveKey.numberOfKeys);
|
1744 | this._allKeys.set(token, newKey);
|
1745 | return newKey;
|
1746 | };
|
1747 | Object.defineProperty(KeyRegistry.prototype, "numberOfKeys", {
|
1748 | /**
|
1749 | * @return {?}
|
1750 | */
|
1751 | get: function () { return this._allKeys.size; },
|
1752 | enumerable: true,
|
1753 | configurable: true
|
1754 | });
|
1755 | return KeyRegistry;
|
1756 | }());
|
1757 | var /** @type {?} */ _globalKeyRegistry = new KeyRegistry();
|
1758 |
|
1759 | /**
|
1760 | * @license
|
1761 | * Copyright Google Inc. All Rights Reserved.
|
1762 | *
|
1763 | * Use of this source code is governed by an MIT-style license that can be
|
1764 | * found in the LICENSE file at https://angular.io/license
|
1765 | */
|
1766 | /**
|
1767 | * @whatItDoes Represents a type that a Component or other object is instances of.
|
1768 | *
|
1769 | * @description
|
1770 | *
|
1771 | * An example of a `Type` is `MyCustomComponent` class, which in JavaScript is be represented by
|
1772 | * the `MyCustomComponent` constructor function.
|
1773 | *
|
1774 | * @stable
|
1775 | */
|
1776 | var /** @type {?} */ Type = Function;
|
1777 |
|
1778 | /**
|
1779 | * Attention: This regex has to hold even if the code is minified!
|
1780 | */
|
1781 | var /** @type {?} */ DELEGATE_CTOR = /^function\s+\S+\(\)\s*{\s*("use strict";)?\s*(return\s+)?\S+\.apply\(this,\s*arguments\)/;
|
1782 | var ReflectionCapabilities = (function () {
|
1783 | /**
|
1784 | * @param {?=} reflect
|
1785 | */
|
1786 | function ReflectionCapabilities(reflect) {
|
1787 | this._reflect = reflect || global$1.Reflect;
|
1788 | }
|
1789 | /**
|
1790 | * @return {?}
|
1791 | */
|
1792 | ReflectionCapabilities.prototype.isReflectionEnabled = function () { return true; };
|
1793 | /**
|
1794 | * @param {?} t
|
1795 | * @return {?}
|
1796 | */
|
1797 | ReflectionCapabilities.prototype.factory = function (t) { return function () {
|
1798 | var args = [];
|
1799 | for (var _i = 0; _i < arguments.length; _i++) {
|
1800 | args[_i - 0] = arguments[_i];
|
1801 | }
|
1802 | return new (t.bind.apply(t, [void 0].concat(args)))();
|
1803 | }; };
|
1804 | /**
|
1805 | * @param {?} paramTypes
|
1806 | * @param {?} paramAnnotations
|
1807 | * @return {?}
|
1808 | */
|
1809 | ReflectionCapabilities.prototype._zipTypesAndAnnotations = function (paramTypes, paramAnnotations) {
|
1810 | var /** @type {?} */ result;
|
1811 | if (typeof paramTypes === 'undefined') {
|
1812 | result = new Array(paramAnnotations.length);
|
1813 | }
|
1814 | else {
|
1815 | result = new Array(paramTypes.length);
|
1816 | }
|
1817 | for (var /** @type {?} */ i = 0; i < result.length; i++) {
|
1818 | // TS outputs Object for parameters without types, while Traceur omits
|
1819 | // the annotations. For now we preserve the Traceur behavior to aid
|
1820 | // migration, but this can be revisited.
|
1821 | if (typeof paramTypes === 'undefined') {
|
1822 | result[i] = [];
|
1823 | }
|
1824 | else if (paramTypes[i] != Object) {
|
1825 | result[i] = [paramTypes[i]];
|
1826 | }
|
1827 | else {
|
1828 | result[i] = [];
|
1829 | }
|
1830 | if (paramAnnotations && isPresent(paramAnnotations[i])) {
|
1831 | result[i] = result[i].concat(paramAnnotations[i]);
|
1832 | }
|
1833 | }
|
1834 | return result;
|
1835 | };
|
1836 | /**
|
1837 | * @param {?} type
|
1838 | * @param {?} parentCtor
|
1839 | * @return {?}
|
1840 | */
|
1841 | ReflectionCapabilities.prototype._ownParameters = function (type, parentCtor) {
|
1842 | // If we have no decorators, we only have function.length as metadata.
|
1843 | // In that case, to detect whether a child class declared an own constructor or not,
|
1844 | // we need to look inside of that constructor to check whether it is
|
1845 | // just calling the parent.
|
1846 | // This also helps to work around for https://github.com/Microsoft/TypeScript/issues/12439
|
1847 | // that sets 'design:paramtypes' to []
|
1848 | // if a class inherits from another class but has no ctor declared itself.
|
1849 | if (DELEGATE_CTOR.exec(type.toString())) {
|
1850 | return null;
|
1851 | }
|
1852 | // Prefer the direct API.
|
1853 | if (((type)).parameters && ((type)).parameters !== parentCtor.parameters) {
|
1854 | return ((type)).parameters;
|
1855 | }
|
1856 | // API of tsickle for lowering decorators to properties on the class.
|
1857 | var /** @type {?} */ tsickleCtorParams = ((type)).ctorParameters;
|
1858 | if (tsickleCtorParams && tsickleCtorParams !== parentCtor.ctorParameters) {
|
1859 | // Newer tsickle uses a function closure
|
1860 | // Retain the non-function case for compatibility with older tsickle
|
1861 | var /** @type {?} */ ctorParameters = typeof tsickleCtorParams === 'function' ? tsickleCtorParams() : tsickleCtorParams;
|
1862 | var /** @type {?} */ paramTypes = ctorParameters.map(function (ctorParam) { return ctorParam && ctorParam.type; });
|
1863 | var /** @type {?} */ paramAnnotations = ctorParameters.map(function (ctorParam) {
|
1864 | return ctorParam && convertTsickleDecoratorIntoMetadata(ctorParam.decorators);
|
1865 | });
|
1866 | return this._zipTypesAndAnnotations(paramTypes, paramAnnotations);
|
1867 | }
|
1868 | // API for metadata created by invoking the decorators.
|
1869 | if (isPresent(this._reflect) && isPresent(this._reflect.getOwnMetadata)) {
|
1870 | var /** @type {?} */ paramAnnotations = this._reflect.getOwnMetadata('parameters', type);
|
1871 | var /** @type {?} */ paramTypes = this._reflect.getOwnMetadata('design:paramtypes', type);
|
1872 | if (paramTypes || paramAnnotations) {
|
1873 | return this._zipTypesAndAnnotations(paramTypes, paramAnnotations);
|
1874 | }
|
1875 | }
|
1876 | // If a class has no decorators, at least create metadata
|
1877 | // based on function.length.
|
1878 | // Note: We know that this is a real constructor as we checked
|
1879 | // the content of the constructor above.
|
1880 | return new Array(((type.length))).fill(undefined);
|
1881 | };
|
1882 | /**
|
1883 | * @param {?} type
|
1884 | * @return {?}
|
1885 | */
|
1886 | ReflectionCapabilities.prototype.parameters = function (type) {
|
1887 | // Note: only report metadata if we have at least one class decorator
|
1888 | // to stay in sync with the static reflector.
|
1889 | var /** @type {?} */ parentCtor = Object.getPrototypeOf(type.prototype).constructor;
|
1890 | var /** @type {?} */ parameters = this._ownParameters(type, parentCtor);
|
1891 | if (!parameters && parentCtor !== Object) {
|
1892 | parameters = this.parameters(parentCtor);
|
1893 | }
|
1894 | return parameters || [];
|
1895 | };
|
1896 | /**
|
1897 | * @param {?} typeOrFunc
|
1898 | * @param {?} parentCtor
|
1899 | * @return {?}
|
1900 | */
|
1901 | ReflectionCapabilities.prototype._ownAnnotations = function (typeOrFunc, parentCtor) {
|
1902 | // Prefer the direct API.
|
1903 | if (((typeOrFunc)).annotations && ((typeOrFunc)).annotations !== parentCtor.annotations) {
|
1904 | var /** @type {?} */ annotations = ((typeOrFunc)).annotations;
|
1905 | if (typeof annotations === 'function' && annotations.annotations) {
|
1906 | annotations = annotations.annotations;
|
1907 | }
|
1908 | return annotations;
|
1909 | }
|
1910 | // API of tsickle for lowering decorators to properties on the class.
|
1911 | if (((typeOrFunc)).decorators && ((typeOrFunc)).decorators !== parentCtor.decorators) {
|
1912 | return convertTsickleDecoratorIntoMetadata(((typeOrFunc)).decorators);
|
1913 | }
|
1914 | // API for metadata created by invoking the decorators.
|
1915 | if (this._reflect && this._reflect.getOwnMetadata) {
|
1916 | return this._reflect.getOwnMetadata('annotations', typeOrFunc);
|
1917 | }
|
1918 | };
|
1919 | /**
|
1920 | * @param {?} typeOrFunc
|
1921 | * @return {?}
|
1922 | */
|
1923 | ReflectionCapabilities.prototype.annotations = function (typeOrFunc) {
|
1924 | var /** @type {?} */ parentCtor = Object.getPrototypeOf(typeOrFunc.prototype).constructor;
|
1925 | var /** @type {?} */ ownAnnotations = this._ownAnnotations(typeOrFunc, parentCtor) || [];
|
1926 | var /** @type {?} */ parentAnnotations = parentCtor !== Object ? this.annotations(parentCtor) : [];
|
1927 | return parentAnnotations.concat(ownAnnotations);
|
1928 | };
|
1929 | /**
|
1930 | * @param {?} typeOrFunc
|
1931 | * @param {?} parentCtor
|
1932 | * @return {?}
|
1933 | */
|
1934 | ReflectionCapabilities.prototype._ownPropMetadata = function (typeOrFunc, parentCtor) {
|
1935 | // Prefer the direct API.
|
1936 | if (((typeOrFunc)).propMetadata &&
|
1937 | ((typeOrFunc)).propMetadata !== parentCtor.propMetadata) {
|
1938 | var /** @type {?} */ propMetadata = ((typeOrFunc)).propMetadata;
|
1939 | if (typeof propMetadata === 'function' && propMetadata.propMetadata) {
|
1940 | propMetadata = propMetadata.propMetadata;
|
1941 | }
|
1942 | return propMetadata;
|
1943 | }
|
1944 | // API of tsickle for lowering decorators to properties on the class.
|
1945 | if (((typeOrFunc)).propDecorators &&
|
1946 | ((typeOrFunc)).propDecorators !== parentCtor.propDecorators) {
|
1947 | var /** @type {?} */ propDecorators_1 = ((typeOrFunc)).propDecorators;
|
1948 | var /** @type {?} */ propMetadata_1 = ({});
|
1949 | Object.keys(propDecorators_1).forEach(function (prop) {
|
1950 | propMetadata_1[prop] = convertTsickleDecoratorIntoMetadata(propDecorators_1[prop]);
|
1951 | });
|
1952 | return propMetadata_1;
|
1953 | }
|
1954 | // API for metadata created by invoking the decorators.
|
1955 | if (this._reflect && this._reflect.getOwnMetadata) {
|
1956 | return this._reflect.getOwnMetadata('propMetadata', typeOrFunc);
|
1957 | }
|
1958 | };
|
1959 | /**
|
1960 | * @param {?} typeOrFunc
|
1961 | * @return {?}
|
1962 | */
|
1963 | ReflectionCapabilities.prototype.propMetadata = function (typeOrFunc) {
|
1964 | var /** @type {?} */ parentCtor = Object.getPrototypeOf(typeOrFunc.prototype).constructor;
|
1965 | var /** @type {?} */ propMetadata = {};
|
1966 | if (parentCtor !== Object) {
|
1967 | var /** @type {?} */ parentPropMetadata_1 = this.propMetadata(parentCtor);
|
1968 | Object.keys(parentPropMetadata_1).forEach(function (propName) {
|
1969 | propMetadata[propName] = parentPropMetadata_1[propName];
|
1970 | });
|
1971 | }
|
1972 | var /** @type {?} */ ownPropMetadata = this._ownPropMetadata(typeOrFunc, parentCtor);
|
1973 | if (ownPropMetadata) {
|
1974 | Object.keys(ownPropMetadata).forEach(function (propName) {
|
1975 | var /** @type {?} */ decorators = [];
|
1976 | if (propMetadata.hasOwnProperty(propName)) {
|
1977 | decorators.push.apply(decorators, propMetadata[propName]);
|
1978 | }
|
1979 | decorators.push.apply(decorators, ownPropMetadata[propName]);
|
1980 | propMetadata[propName] = decorators;
|
1981 | });
|
1982 | }
|
1983 | return propMetadata;
|
1984 | };
|
1985 | /**
|
1986 | * @param {?} type
|
1987 | * @param {?} lcProperty
|
1988 | * @return {?}
|
1989 | */
|
1990 | ReflectionCapabilities.prototype.hasLifecycleHook = function (type, lcProperty) {
|
1991 | return type instanceof Type && lcProperty in type.prototype;
|
1992 | };
|
1993 | /**
|
1994 | * @param {?} name
|
1995 | * @return {?}
|
1996 | */
|
1997 | ReflectionCapabilities.prototype.getter = function (name) { return ((new Function('o', 'return o.' + name + ';'))); };
|
1998 | /**
|
1999 | * @param {?} name
|
2000 | * @return {?}
|
2001 | */
|
2002 | ReflectionCapabilities.prototype.setter = function (name) {
|
2003 | return ((new Function('o', 'v', 'return o.' + name + ' = v;')));
|
2004 | };
|
2005 | /**
|
2006 | * @param {?} name
|
2007 | * @return {?}
|
2008 | */
|
2009 | ReflectionCapabilities.prototype.method = function (name) {
|
2010 | var /** @type {?} */ functionBody = "if (!o." + name + ") throw new Error('\"" + name + "\" is undefined');\n return o." + name + ".apply(o, args);";
|
2011 | return ((new Function('o', 'args', functionBody)));
|
2012 | };
|
2013 | /**
|
2014 | * @param {?} type
|
2015 | * @return {?}
|
2016 | */
|
2017 | ReflectionCapabilities.prototype.importUri = function (type) {
|
2018 | // StaticSymbol
|
2019 | if (typeof type === 'object' && type['filePath']) {
|
2020 | return type['filePath'];
|
2021 | }
|
2022 | // Runtime type
|
2023 | return "./" + stringify(type);
|
2024 | };
|
2025 | /**
|
2026 | * @param {?} name
|
2027 | * @param {?} moduleUrl
|
2028 | * @param {?} runtime
|
2029 | * @return {?}
|
2030 | */
|
2031 | ReflectionCapabilities.prototype.resolveIdentifier = function (name, moduleUrl, runtime) { return runtime; };
|
2032 | /**
|
2033 | * @param {?} enumIdentifier
|
2034 | * @param {?} name
|
2035 | * @return {?}
|
2036 | */
|
2037 | ReflectionCapabilities.prototype.resolveEnum = function (enumIdentifier, name) { return enumIdentifier[name]; };
|
2038 | return ReflectionCapabilities;
|
2039 | }());
|
2040 | /**
|
2041 | * @param {?} decoratorInvocations
|
2042 | * @return {?}
|
2043 | */
|
2044 | function convertTsickleDecoratorIntoMetadata(decoratorInvocations) {
|
2045 | if (!decoratorInvocations) {
|
2046 | return [];
|
2047 | }
|
2048 | return decoratorInvocations.map(function (decoratorInvocation) {
|
2049 | var /** @type {?} */ decoratorType = decoratorInvocation.type;
|
2050 | var /** @type {?} */ annotationCls = decoratorType.annotationCls;
|
2051 | var /** @type {?} */ annotationArgs = decoratorInvocation.args ? decoratorInvocation.args : [];
|
2052 | return new (annotationCls.bind.apply(annotationCls, [void 0].concat(annotationArgs)))();
|
2053 | });
|
2054 | }
|
2055 |
|
2056 | /**
|
2057 | * Provides read-only access to reflection data about symbols. Used internally by Angular
|
2058 | * to power dependency injection and compilation.
|
2059 | * @abstract
|
2060 | */
|
2061 | var ReflectorReader = (function () {
|
2062 | function ReflectorReader() {
|
2063 | }
|
2064 | /**
|
2065 | * @abstract
|
2066 | * @param {?} typeOrFunc
|
2067 | * @return {?}
|
2068 | */
|
2069 | ReflectorReader.prototype.parameters = function (typeOrFunc) { };
|
2070 | /**
|
2071 | * @abstract
|
2072 | * @param {?} typeOrFunc
|
2073 | * @return {?}
|
2074 | */
|
2075 | ReflectorReader.prototype.annotations = function (typeOrFunc) { };
|
2076 | /**
|
2077 | * @abstract
|
2078 | * @param {?} typeOrFunc
|
2079 | * @return {?}
|
2080 | */
|
2081 | ReflectorReader.prototype.propMetadata = function (typeOrFunc) { };
|
2082 | /**
|
2083 | * @abstract
|
2084 | * @param {?} typeOrFunc
|
2085 | * @return {?}
|
2086 | */
|
2087 | ReflectorReader.prototype.importUri = function (typeOrFunc) { };
|
2088 | /**
|
2089 | * @abstract
|
2090 | * @param {?} name
|
2091 | * @param {?} moduleUrl
|
2092 | * @param {?} runtime
|
2093 | * @return {?}
|
2094 | */
|
2095 | ReflectorReader.prototype.resolveIdentifier = function (name, moduleUrl, runtime) { };
|
2096 | /**
|
2097 | * @abstract
|
2098 | * @param {?} identifier
|
2099 | * @param {?} name
|
2100 | * @return {?}
|
2101 | */
|
2102 | ReflectorReader.prototype.resolveEnum = function (identifier, name) { };
|
2103 | return ReflectorReader;
|
2104 | }());
|
2105 |
|
2106 | /**
|
2107 | * @license
|
2108 | * Copyright Google Inc. All Rights Reserved.
|
2109 | *
|
2110 | * Use of this source code is governed by an MIT-style license that can be
|
2111 | * found in the LICENSE file at https://angular.io/license
|
2112 | */
|
2113 | var __extends$2 = (this && this.__extends) || function (d, b) {
|
2114 | for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
2115 | function __() { this.constructor = d; }
|
2116 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
2117 | };
|
2118 | /**
|
2119 | * Provides access to reflection data about symbols. Used internally by Angular
|
2120 | * to power dependency injection and compilation.
|
2121 | */
|
2122 | var Reflector = (function (_super) {
|
2123 | __extends$2(Reflector, _super);
|
2124 | /**
|
2125 | * @param {?} reflectionCapabilities
|
2126 | */
|
2127 | function Reflector(reflectionCapabilities) {
|
2128 | _super.call(this);
|
2129 | this.reflectionCapabilities = reflectionCapabilities;
|
2130 | }
|
2131 | /**
|
2132 | * @param {?} caps
|
2133 | * @return {?}
|
2134 | */
|
2135 | Reflector.prototype.updateCapabilities = function (caps) { this.reflectionCapabilities = caps; };
|
2136 | /**
|
2137 | * @param {?} type
|
2138 | * @return {?}
|
2139 | */
|
2140 | Reflector.prototype.factory = function (type) { return this.reflectionCapabilities.factory(type); };
|
2141 | /**
|
2142 | * @param {?} typeOrFunc
|
2143 | * @return {?}
|
2144 | */
|
2145 | Reflector.prototype.parameters = function (typeOrFunc) {
|
2146 | return this.reflectionCapabilities.parameters(typeOrFunc);
|
2147 | };
|
2148 | /**
|
2149 | * @param {?} typeOrFunc
|
2150 | * @return {?}
|
2151 | */
|
2152 | Reflector.prototype.annotations = function (typeOrFunc) {
|
2153 | return this.reflectionCapabilities.annotations(typeOrFunc);
|
2154 | };
|
2155 | /**
|
2156 | * @param {?} typeOrFunc
|
2157 | * @return {?}
|
2158 | */
|
2159 | Reflector.prototype.propMetadata = function (typeOrFunc) {
|
2160 | return this.reflectionCapabilities.propMetadata(typeOrFunc);
|
2161 | };
|
2162 | /**
|
2163 | * @param {?} type
|
2164 | * @param {?} lcProperty
|
2165 | * @return {?}
|
2166 | */
|
2167 | Reflector.prototype.hasLifecycleHook = function (type, lcProperty) {
|
2168 | return this.reflectionCapabilities.hasLifecycleHook(type, lcProperty);
|
2169 | };
|
2170 | /**
|
2171 | * @param {?} name
|
2172 | * @return {?}
|
2173 | */
|
2174 | Reflector.prototype.getter = function (name) { return this.reflectionCapabilities.getter(name); };
|
2175 | /**
|
2176 | * @param {?} name
|
2177 | * @return {?}
|
2178 | */
|
2179 | Reflector.prototype.setter = function (name) { return this.reflectionCapabilities.setter(name); };
|
2180 | /**
|
2181 | * @param {?} name
|
2182 | * @return {?}
|
2183 | */
|
2184 | Reflector.prototype.method = function (name) { return this.reflectionCapabilities.method(name); };
|
2185 | /**
|
2186 | * @param {?} type
|
2187 | * @return {?}
|
2188 | */
|
2189 | Reflector.prototype.importUri = function (type) { return this.reflectionCapabilities.importUri(type); };
|
2190 | /**
|
2191 | * @param {?} name
|
2192 | * @param {?} moduleUrl
|
2193 | * @param {?} runtime
|
2194 | * @return {?}
|
2195 | */
|
2196 | Reflector.prototype.resolveIdentifier = function (name, moduleUrl, runtime) {
|
2197 | return this.reflectionCapabilities.resolveIdentifier(name, moduleUrl, runtime);
|
2198 | };
|
2199 | /**
|
2200 | * @param {?} identifier
|
2201 | * @param {?} name
|
2202 | * @return {?}
|
2203 | */
|
2204 | Reflector.prototype.resolveEnum = function (identifier, name) {
|
2205 | return this.reflectionCapabilities.resolveEnum(identifier, name);
|
2206 | };
|
2207 | return Reflector;
|
2208 | }(ReflectorReader));
|
2209 |
|
2210 | /**
|
2211 | * The {@link Reflector} used internally in Angular to access metadata
|
2212 | * about symbols.
|
2213 | */
|
2214 | var /** @type {?} */ reflector = new Reflector(new ReflectionCapabilities());
|
2215 |
|
2216 | /**
|
2217 | * `Dependency` is used by the framework to extend DI.
|
2218 | * This is internal to Angular and should not be used directly.
|
2219 | */
|
2220 | var ReflectiveDependency = (function () {
|
2221 | /**
|
2222 | * @param {?} key
|
2223 | * @param {?} optional
|
2224 | * @param {?} lowerBoundVisibility
|
2225 | * @param {?} upperBoundVisibility
|
2226 | * @param {?} properties
|
2227 | */
|
2228 | function ReflectiveDependency(key, optional, lowerBoundVisibility, upperBoundVisibility, properties) {
|
2229 | this.key = key;
|
2230 | this.optional = optional;
|
2231 | this.lowerBoundVisibility = lowerBoundVisibility;
|
2232 | this.upperBoundVisibility = upperBoundVisibility;
|
2233 | this.properties = properties;
|
2234 | }
|
2235 | /**
|
2236 | * @param {?} key
|
2237 | * @return {?}
|
2238 | */
|
2239 | ReflectiveDependency.fromKey = function (key) {
|
2240 | return new ReflectiveDependency(key, false, null, null, []);
|
2241 | };
|
2242 | return ReflectiveDependency;
|
2243 | }());
|
2244 | var /** @type {?} */ _EMPTY_LIST = [];
|
2245 | var ResolvedReflectiveProvider_ = (function () {
|
2246 | /**
|
2247 | * @param {?} key
|
2248 | * @param {?} resolvedFactories
|
2249 | * @param {?} multiProvider
|
2250 | */
|
2251 | function ResolvedReflectiveProvider_(key, resolvedFactories, multiProvider) {
|
2252 | this.key = key;
|
2253 | this.resolvedFactories = resolvedFactories;
|
2254 | this.multiProvider = multiProvider;
|
2255 | }
|
2256 | Object.defineProperty(ResolvedReflectiveProvider_.prototype, "resolvedFactory", {
|
2257 | /**
|
2258 | * @return {?}
|
2259 | */
|
2260 | get: function () { return this.resolvedFactories[0]; },
|
2261 | enumerable: true,
|
2262 | configurable: true
|
2263 | });
|
2264 | return ResolvedReflectiveProvider_;
|
2265 | }());
|
2266 | /**
|
2267 | * An internal resolved representation of a factory function created by resolving {@link
|
2268 | * Provider}.
|
2269 | */
|
2270 | var ResolvedReflectiveFactory = (function () {
|
2271 | /**
|
2272 | * @param {?} factory
|
2273 | * @param {?} dependencies
|
2274 | */
|
2275 | function ResolvedReflectiveFactory(factory, dependencies) {
|
2276 | this.factory = factory;
|
2277 | this.dependencies = dependencies;
|
2278 | }
|
2279 | return ResolvedReflectiveFactory;
|
2280 | }());
|
2281 | /**
|
2282 | * Resolve a single provider.
|
2283 | * @param {?} provider
|
2284 | * @return {?}
|
2285 | */
|
2286 | function resolveReflectiveFactory(provider) {
|
2287 | var /** @type {?} */ factoryFn;
|
2288 | var /** @type {?} */ resolvedDeps;
|
2289 | if (provider.useClass) {
|
2290 | var /** @type {?} */ useClass = resolveForwardRef(provider.useClass);
|
2291 | factoryFn = reflector.factory(useClass);
|
2292 | resolvedDeps = _dependenciesFor(useClass);
|
2293 | }
|
2294 | else if (provider.useExisting) {
|
2295 | factoryFn = function (aliasInstance) { return aliasInstance; };
|
2296 | resolvedDeps = [ReflectiveDependency.fromKey(ReflectiveKey.get(provider.useExisting))];
|
2297 | }
|
2298 | else if (provider.useFactory) {
|
2299 | factoryFn = provider.useFactory;
|
2300 | resolvedDeps = constructDependencies(provider.useFactory, provider.deps);
|
2301 | }
|
2302 | else {
|
2303 | factoryFn = function () { return provider.useValue; };
|
2304 | resolvedDeps = _EMPTY_LIST;
|
2305 | }
|
2306 | return new ResolvedReflectiveFactory(factoryFn, resolvedDeps);
|
2307 | }
|
2308 | /**
|
2309 | * Converts the {@link Provider} into {@link ResolvedProvider}.
|
2310 | * *
|
2311 | * {@link Injector} internally only uses {@link ResolvedProvider}, {@link Provider} contains
|
2312 | * convenience provider syntax.
|
2313 | * @param {?} provider
|
2314 | * @return {?}
|
2315 | */
|
2316 | function resolveReflectiveProvider(provider) {
|
2317 | return new ResolvedReflectiveProvider_(ReflectiveKey.get(provider.provide), [resolveReflectiveFactory(provider)], provider.multi);
|
2318 | }
|
2319 | /**
|
2320 | * Resolve a list of Providers.
|
2321 | * @param {?} providers
|
2322 | * @return {?}
|
2323 | */
|
2324 | function resolveReflectiveProviders(providers) {
|
2325 | var /** @type {?} */ normalized = _normalizeProviders(providers, []);
|
2326 | var /** @type {?} */ resolved = normalized.map(resolveReflectiveProvider);
|
2327 | var /** @type {?} */ resolvedProviderMap = mergeResolvedReflectiveProviders(resolved, new Map());
|
2328 | return Array.from(resolvedProviderMap.values());
|
2329 | }
|
2330 | /**
|
2331 | * Merges a list of ResolvedProviders into a list where
|
2332 | * each key is contained exactly once and multi providers
|
2333 | * have been merged.
|
2334 | * @param {?} providers
|
2335 | * @param {?} normalizedProvidersMap
|
2336 | * @return {?}
|
2337 | */
|
2338 | function mergeResolvedReflectiveProviders(providers, normalizedProvidersMap) {
|
2339 | for (var /** @type {?} */ i = 0; i < providers.length; i++) {
|
2340 | var /** @type {?} */ provider = providers[i];
|
2341 | var /** @type {?} */ existing = normalizedProvidersMap.get(provider.key.id);
|
2342 | if (existing) {
|
2343 | if (provider.multiProvider !== existing.multiProvider) {
|
2344 | throw new MixingMultiProvidersWithRegularProvidersError(existing, provider);
|
2345 | }
|
2346 | if (provider.multiProvider) {
|
2347 | for (var /** @type {?} */ j = 0; j < provider.resolvedFactories.length; j++) {
|
2348 | existing.resolvedFactories.push(provider.resolvedFactories[j]);
|
2349 | }
|
2350 | }
|
2351 | else {
|
2352 | normalizedProvidersMap.set(provider.key.id, provider);
|
2353 | }
|
2354 | }
|
2355 | else {
|
2356 | var /** @type {?} */ resolvedProvider = void 0;
|
2357 | if (provider.multiProvider) {
|
2358 | resolvedProvider = new ResolvedReflectiveProvider_(provider.key, provider.resolvedFactories.slice(), provider.multiProvider);
|
2359 | }
|
2360 | else {
|
2361 | resolvedProvider = provider;
|
2362 | }
|
2363 | normalizedProvidersMap.set(provider.key.id, resolvedProvider);
|
2364 | }
|
2365 | }
|
2366 | return normalizedProvidersMap;
|
2367 | }
|
2368 | /**
|
2369 | * @param {?} providers
|
2370 | * @param {?} res
|
2371 | * @return {?}
|
2372 | */
|
2373 | function _normalizeProviders(providers, res) {
|
2374 | providers.forEach(function (b) {
|
2375 | if (b instanceof Type) {
|
2376 | res.push({ provide: b, useClass: b });
|
2377 | }
|
2378 | else if (b && typeof b == 'object' && ((b)).provide !== undefined) {
|
2379 | res.push(/** @type {?} */ (b));
|
2380 | }
|
2381 | else if (b instanceof Array) {
|
2382 | _normalizeProviders(b, res);
|
2383 | }
|
2384 | else {
|
2385 | throw new InvalidProviderError(b);
|
2386 | }
|
2387 | });
|
2388 | return res;
|
2389 | }
|
2390 | /**
|
2391 | * @param {?} typeOrFunc
|
2392 | * @param {?} dependencies
|
2393 | * @return {?}
|
2394 | */
|
2395 | function constructDependencies(typeOrFunc, dependencies) {
|
2396 | if (!dependencies) {
|
2397 | return _dependenciesFor(typeOrFunc);
|
2398 | }
|
2399 | else {
|
2400 | var /** @type {?} */ params_1 = dependencies.map(function (t) { return [t]; });
|
2401 | return dependencies.map(function (t) { return _extractToken(typeOrFunc, t, params_1); });
|
2402 | }
|
2403 | }
|
2404 | /**
|
2405 | * @param {?} typeOrFunc
|
2406 | * @return {?}
|
2407 | */
|
2408 | function _dependenciesFor(typeOrFunc) {
|
2409 | var /** @type {?} */ params = reflector.parameters(typeOrFunc);
|
2410 | if (!params)
|
2411 | return [];
|
2412 | if (params.some(function (p) { return p == null; })) {
|
2413 | throw new NoAnnotationError(typeOrFunc, params);
|
2414 | }
|
2415 | return params.map(function (p) { return _extractToken(typeOrFunc, p, params); });
|
2416 | }
|
2417 | /**
|
2418 | * @param {?} typeOrFunc
|
2419 | * @param {?} metadata
|
2420 | * @param {?} params
|
2421 | * @return {?}
|
2422 | */
|
2423 | function _extractToken(typeOrFunc, metadata, params) {
|
2424 | var /** @type {?} */ depProps = [];
|
2425 | var /** @type {?} */ token = null;
|
2426 | var /** @type {?} */ optional = false;
|
2427 | if (!Array.isArray(metadata)) {
|
2428 | if (metadata instanceof Inject) {
|
2429 | return _createDependency(metadata.token, optional, null, null, depProps);
|
2430 | }
|
2431 | else {
|
2432 | return _createDependency(metadata, optional, null, null, depProps);
|
2433 | }
|
2434 | }
|
2435 | var /** @type {?} */ lowerBoundVisibility = null;
|
2436 | var /** @type {?} */ upperBoundVisibility = null;
|
2437 | for (var /** @type {?} */ i = 0; i < metadata.length; ++i) {
|
2438 | var /** @type {?} */ paramMetadata = metadata[i];
|
2439 | if (paramMetadata instanceof Type) {
|
2440 | token = paramMetadata;
|
2441 | }
|
2442 | else if (paramMetadata instanceof Inject) {
|
2443 | token = paramMetadata.token;
|
2444 | }
|
2445 | else if (paramMetadata instanceof Optional) {
|
2446 | optional = true;
|
2447 | }
|
2448 | else if (paramMetadata instanceof Self) {
|
2449 | upperBoundVisibility = paramMetadata;
|
2450 | }
|
2451 | else if (paramMetadata instanceof Host) {
|
2452 | upperBoundVisibility = paramMetadata;
|
2453 | }
|
2454 | else if (paramMetadata instanceof SkipSelf) {
|
2455 | lowerBoundVisibility = paramMetadata;
|
2456 | }
|
2457 | }
|
2458 | token = resolveForwardRef(token);
|
2459 | if (token != null) {
|
2460 | return _createDependency(token, optional, lowerBoundVisibility, upperBoundVisibility, depProps);
|
2461 | }
|
2462 | else {
|
2463 | throw new NoAnnotationError(typeOrFunc, params);
|
2464 | }
|
2465 | }
|
2466 | /**
|
2467 | * @param {?} token
|
2468 | * @param {?} optional
|
2469 | * @param {?} lowerBoundVisibility
|
2470 | * @param {?} upperBoundVisibility
|
2471 | * @param {?} depProps
|
2472 | * @return {?}
|
2473 | */
|
2474 | function _createDependency(token, optional, lowerBoundVisibility, upperBoundVisibility, depProps) {
|
2475 | return new ReflectiveDependency(ReflectiveKey.get(token), optional, lowerBoundVisibility, upperBoundVisibility, depProps);
|
2476 | }
|
2477 |
|
2478 | // Threshold for the dynamic version
|
2479 | var /** @type {?} */ _MAX_CONSTRUCTION_COUNTER = 10;
|
2480 | var /** @type {?} */ UNDEFINED = new Object();
|
2481 | var ReflectiveProtoInjectorInlineStrategy = (function () {
|
2482 | /**
|
2483 | * @param {?} protoEI
|
2484 | * @param {?} providers
|
2485 | */
|
2486 | function ReflectiveProtoInjectorInlineStrategy(protoEI, providers) {
|
2487 | this.provider0 = null;
|
2488 | this.provider1 = null;
|
2489 | this.provider2 = null;
|
2490 | this.provider3 = null;
|
2491 | this.provider4 = null;
|
2492 | this.provider5 = null;
|
2493 | this.provider6 = null;
|
2494 | this.provider7 = null;
|
2495 | this.provider8 = null;
|
2496 | this.provider9 = null;
|
2497 | this.keyId0 = null;
|
2498 | this.keyId1 = null;
|
2499 | this.keyId2 = null;
|
2500 | this.keyId3 = null;
|
2501 | this.keyId4 = null;
|
2502 | this.keyId5 = null;
|
2503 | this.keyId6 = null;
|
2504 | this.keyId7 = null;
|
2505 | this.keyId8 = null;
|
2506 | this.keyId9 = null;
|
2507 | var length = providers.length;
|
2508 | if (length > 0) {
|
2509 | this.provider0 = providers[0];
|
2510 | this.keyId0 = providers[0].key.id;
|
2511 | }
|
2512 | if (length > 1) {
|
2513 | this.provider1 = providers[1];
|
2514 | this.keyId1 = providers[1].key.id;
|
2515 | }
|
2516 | if (length > 2) {
|
2517 | this.provider2 = providers[2];
|
2518 | this.keyId2 = providers[2].key.id;
|
2519 | }
|
2520 | if (length > 3) {
|
2521 | this.provider3 = providers[3];
|
2522 | this.keyId3 = providers[3].key.id;
|
2523 | }
|
2524 | if (length > 4) {
|
2525 | this.provider4 = providers[4];
|
2526 | this.keyId4 = providers[4].key.id;
|
2527 | }
|
2528 | if (length > 5) {
|
2529 | this.provider5 = providers[5];
|
2530 | this.keyId5 = providers[5].key.id;
|
2531 | }
|
2532 | if (length > 6) {
|
2533 | this.provider6 = providers[6];
|
2534 | this.keyId6 = providers[6].key.id;
|
2535 | }
|
2536 | if (length > 7) {
|
2537 | this.provider7 = providers[7];
|
2538 | this.keyId7 = providers[7].key.id;
|
2539 | }
|
2540 | if (length > 8) {
|
2541 | this.provider8 = providers[8];
|
2542 | this.keyId8 = providers[8].key.id;
|
2543 | }
|
2544 | if (length > 9) {
|
2545 | this.provider9 = providers[9];
|
2546 | this.keyId9 = providers[9].key.id;
|
2547 | }
|
2548 | }
|
2549 | /**
|
2550 | * @param {?} index
|
2551 | * @return {?}
|
2552 | */
|
2553 | ReflectiveProtoInjectorInlineStrategy.prototype.getProviderAtIndex = function (index) {
|
2554 | if (index == 0)
|
2555 | return this.provider0;
|
2556 | if (index == 1)
|
2557 | return this.provider1;
|
2558 | if (index == 2)
|
2559 | return this.provider2;
|
2560 | if (index == 3)
|
2561 | return this.provider3;
|
2562 | if (index == 4)
|
2563 | return this.provider4;
|
2564 | if (index == 5)
|
2565 | return this.provider5;
|
2566 | if (index == 6)
|
2567 | return this.provider6;
|
2568 | if (index == 7)
|
2569 | return this.provider7;
|
2570 | if (index == 8)
|
2571 | return this.provider8;
|
2572 | if (index == 9)
|
2573 | return this.provider9;
|
2574 | throw new OutOfBoundsError(index);
|
2575 | };
|
2576 | /**
|
2577 | * @param {?} injector
|
2578 | * @return {?}
|
2579 | */
|
2580 | ReflectiveProtoInjectorInlineStrategy.prototype.createInjectorStrategy = function (injector) {
|
2581 | return new ReflectiveInjectorInlineStrategy(injector, this);
|
2582 | };
|
2583 | return ReflectiveProtoInjectorInlineStrategy;
|
2584 | }());
|
2585 | var ReflectiveProtoInjectorDynamicStrategy = (function () {
|
2586 | /**
|
2587 | * @param {?} protoInj
|
2588 | * @param {?} providers
|
2589 | */
|
2590 | function ReflectiveProtoInjectorDynamicStrategy(protoInj, providers) {
|
2591 | this.providers = providers;
|
2592 | var len = providers.length;
|
2593 | this.keyIds = new Array(len);
|
2594 | for (var i = 0; i < len; i++) {
|
2595 | this.keyIds[i] = providers[i].key.id;
|
2596 | }
|
2597 | }
|
2598 | /**
|
2599 | * @param {?} index
|
2600 | * @return {?}
|
2601 | */
|
2602 | ReflectiveProtoInjectorDynamicStrategy.prototype.getProviderAtIndex = function (index) {
|
2603 | if (index < 0 || index >= this.providers.length) {
|
2604 | throw new OutOfBoundsError(index);
|
2605 | }
|
2606 | return this.providers[index];
|
2607 | };
|
2608 | /**
|
2609 | * @param {?} ei
|
2610 | * @return {?}
|
2611 | */
|
2612 | ReflectiveProtoInjectorDynamicStrategy.prototype.createInjectorStrategy = function (ei) {
|
2613 | return new ReflectiveInjectorDynamicStrategy(this, ei);
|
2614 | };
|
2615 | return ReflectiveProtoInjectorDynamicStrategy;
|
2616 | }());
|
2617 | var ReflectiveProtoInjector = (function () {
|
2618 | /**
|
2619 | * @param {?} providers
|
2620 | */
|
2621 | function ReflectiveProtoInjector(providers) {
|
2622 | this.numberOfProviders = providers.length;
|
2623 | this._strategy = providers.length > _MAX_CONSTRUCTION_COUNTER ?
|
2624 | new ReflectiveProtoInjectorDynamicStrategy(this, providers) :
|
2625 | new ReflectiveProtoInjectorInlineStrategy(this, providers);
|
2626 | }
|
2627 | /**
|
2628 | * @param {?} providers
|
2629 | * @return {?}
|
2630 | */
|
2631 | ReflectiveProtoInjector.fromResolvedProviders = function (providers) {
|
2632 | return new ReflectiveProtoInjector(providers);
|
2633 | };
|
2634 | /**
|
2635 | * @param {?} index
|
2636 | * @return {?}
|
2637 | */
|
2638 | ReflectiveProtoInjector.prototype.getProviderAtIndex = function (index) {
|
2639 | return this._strategy.getProviderAtIndex(index);
|
2640 | };
|
2641 | return ReflectiveProtoInjector;
|
2642 | }());
|
2643 | var ReflectiveInjectorInlineStrategy = (function () {
|
2644 | /**
|
2645 | * @param {?} injector
|
2646 | * @param {?} protoStrategy
|
2647 | */
|
2648 | function ReflectiveInjectorInlineStrategy(injector, protoStrategy) {
|
2649 | this.injector = injector;
|
2650 | this.protoStrategy = protoStrategy;
|
2651 | this.obj0 = UNDEFINED;
|
2652 | this.obj1 = UNDEFINED;
|
2653 | this.obj2 = UNDEFINED;
|
2654 | this.obj3 = UNDEFINED;
|
2655 | this.obj4 = UNDEFINED;
|
2656 | this.obj5 = UNDEFINED;
|
2657 | this.obj6 = UNDEFINED;
|
2658 | this.obj7 = UNDEFINED;
|
2659 | this.obj8 = UNDEFINED;
|
2660 | this.obj9 = UNDEFINED;
|
2661 | }
|
2662 | /**
|
2663 | * @return {?}
|
2664 | */
|
2665 | ReflectiveInjectorInlineStrategy.prototype.resetConstructionCounter = function () { this.injector._constructionCounter = 0; };
|
2666 | /**
|
2667 | * @param {?} provider
|
2668 | * @return {?}
|
2669 | */
|
2670 | ReflectiveInjectorInlineStrategy.prototype.instantiateProvider = function (provider) {
|
2671 | return this.injector._new(provider);
|
2672 | };
|
2673 | /**
|
2674 | * @param {?} keyId
|
2675 | * @return {?}
|
2676 | */
|
2677 | ReflectiveInjectorInlineStrategy.prototype.getObjByKeyId = function (keyId) {
|
2678 | var /** @type {?} */ p = this.protoStrategy;
|
2679 | var /** @type {?} */ inj = this.injector;
|
2680 | if (p.keyId0 === keyId) {
|
2681 | if (this.obj0 === UNDEFINED) {
|
2682 | this.obj0 = inj._new(p.provider0);
|
2683 | }
|
2684 | return this.obj0;
|
2685 | }
|
2686 | if (p.keyId1 === keyId) {
|
2687 | if (this.obj1 === UNDEFINED) {
|
2688 | this.obj1 = inj._new(p.provider1);
|
2689 | }
|
2690 | return this.obj1;
|
2691 | }
|
2692 | if (p.keyId2 === keyId) {
|
2693 | if (this.obj2 === UNDEFINED) {
|
2694 | this.obj2 = inj._new(p.provider2);
|
2695 | }
|
2696 | return this.obj2;
|
2697 | }
|
2698 | if (p.keyId3 === keyId) {
|
2699 | if (this.obj3 === UNDEFINED) {
|
2700 | this.obj3 = inj._new(p.provider3);
|
2701 | }
|
2702 | return this.obj3;
|
2703 | }
|
2704 | if (p.keyId4 === keyId) {
|
2705 | if (this.obj4 === UNDEFINED) {
|
2706 | this.obj4 = inj._new(p.provider4);
|
2707 | }
|
2708 | return this.obj4;
|
2709 | }
|
2710 | if (p.keyId5 === keyId) {
|
2711 | if (this.obj5 === UNDEFINED) {
|
2712 | this.obj5 = inj._new(p.provider5);
|
2713 | }
|
2714 | return this.obj5;
|
2715 | }
|
2716 | if (p.keyId6 === keyId) {
|
2717 | if (this.obj6 === UNDEFINED) {
|
2718 | this.obj6 = inj._new(p.provider6);
|
2719 | }
|
2720 | return this.obj6;
|
2721 | }
|
2722 | if (p.keyId7 === keyId) {
|
2723 | if (this.obj7 === UNDEFINED) {
|
2724 | this.obj7 = inj._new(p.provider7);
|
2725 | }
|
2726 | return this.obj7;
|
2727 | }
|
2728 | if (p.keyId8 === keyId) {
|
2729 | if (this.obj8 === UNDEFINED) {
|
2730 | this.obj8 = inj._new(p.provider8);
|
2731 | }
|
2732 | return this.obj8;
|
2733 | }
|
2734 | if (p.keyId9 === keyId) {
|
2735 | if (this.obj9 === UNDEFINED) {
|
2736 | this.obj9 = inj._new(p.provider9);
|
2737 | }
|
2738 | return this.obj9;
|
2739 | }
|
2740 | return UNDEFINED;
|
2741 | };
|
2742 | /**
|
2743 | * @param {?} index
|
2744 | * @return {?}
|
2745 | */
|
2746 | ReflectiveInjectorInlineStrategy.prototype.getObjAtIndex = function (index) {
|
2747 | if (index == 0)
|
2748 | return this.obj0;
|
2749 | if (index == 1)
|
2750 | return this.obj1;
|
2751 | if (index == 2)
|
2752 | return this.obj2;
|
2753 | if (index == 3)
|
2754 | return this.obj3;
|
2755 | if (index == 4)
|
2756 | return this.obj4;
|
2757 | if (index == 5)
|
2758 | return this.obj5;
|
2759 | if (index == 6)
|
2760 | return this.obj6;
|
2761 | if (index == 7)
|
2762 | return this.obj7;
|
2763 | if (index == 8)
|
2764 | return this.obj8;
|
2765 | if (index == 9)
|
2766 | return this.obj9;
|
2767 | throw new OutOfBoundsError(index);
|
2768 | };
|
2769 | /**
|
2770 | * @return {?}
|
2771 | */
|
2772 | ReflectiveInjectorInlineStrategy.prototype.getMaxNumberOfObjects = function () { return _MAX_CONSTRUCTION_COUNTER; };
|
2773 | return ReflectiveInjectorInlineStrategy;
|
2774 | }());
|
2775 | var ReflectiveInjectorDynamicStrategy = (function () {
|
2776 | /**
|
2777 | * @param {?} protoStrategy
|
2778 | * @param {?} injector
|
2779 | */
|
2780 | function ReflectiveInjectorDynamicStrategy(protoStrategy, injector) {
|
2781 | this.protoStrategy = protoStrategy;
|
2782 | this.injector = injector;
|
2783 | this.objs = new Array(protoStrategy.providers.length).fill(UNDEFINED);
|
2784 | }
|
2785 | /**
|
2786 | * @return {?}
|
2787 | */
|
2788 | ReflectiveInjectorDynamicStrategy.prototype.resetConstructionCounter = function () { this.injector._constructionCounter = 0; };
|
2789 | /**
|
2790 | * @param {?} provider
|
2791 | * @return {?}
|
2792 | */
|
2793 | ReflectiveInjectorDynamicStrategy.prototype.instantiateProvider = function (provider) {
|
2794 | return this.injector._new(provider);
|
2795 | };
|
2796 | /**
|
2797 | * @param {?} keyId
|
2798 | * @return {?}
|
2799 | */
|
2800 | ReflectiveInjectorDynamicStrategy.prototype.getObjByKeyId = function (keyId) {
|
2801 | var /** @type {?} */ p = this.protoStrategy;
|
2802 | for (var /** @type {?} */ i = 0; i < p.keyIds.length; i++) {
|
2803 | if (p.keyIds[i] === keyId) {
|
2804 | if (this.objs[i] === UNDEFINED) {
|
2805 | this.objs[i] = this.injector._new(p.providers[i]);
|
2806 | }
|
2807 | return this.objs[i];
|
2808 | }
|
2809 | }
|
2810 | return UNDEFINED;
|
2811 | };
|
2812 | /**
|
2813 | * @param {?} index
|
2814 | * @return {?}
|
2815 | */
|
2816 | ReflectiveInjectorDynamicStrategy.prototype.getObjAtIndex = function (index) {
|
2817 | if (index < 0 || index >= this.objs.length) {
|
2818 | throw new OutOfBoundsError(index);
|
2819 | }
|
2820 | return this.objs[index];
|
2821 | };
|
2822 | /**
|
2823 | * @return {?}
|
2824 | */
|
2825 | ReflectiveInjectorDynamicStrategy.prototype.getMaxNumberOfObjects = function () { return this.objs.length; };
|
2826 | return ReflectiveInjectorDynamicStrategy;
|
2827 | }());
|
2828 | /**
|
2829 | * A ReflectiveDependency injection container used for instantiating objects and resolving
|
2830 | * dependencies.
|
2831 | * *
|
2832 | * An `Injector` is a replacement for a `new` operator, which can automatically resolve the
|
2833 | * constructor dependencies.
|
2834 | * *
|
2835 | * In typical use, application code asks for the dependencies in the constructor and they are
|
2836 | * resolved by the `Injector`.
|
2837 | * *
|
2838 | * ### Example ([live demo](http://plnkr.co/edit/jzjec0?p=preview))
|
2839 | * *
|
2840 | * The following example creates an `Injector` configured to create `Engine` and `Car`.
|
2841 | * *
|
2842 | * ```typescript
|
2843 | * class Engine {
|
2844 | * }
|
2845 | * *
|
2846 | * class Car {
|
2847 | * constructor(public engine:Engine) {}
|
2848 | * }
|
2849 | * *
|
2850 | * var injector = ReflectiveInjector.resolveAndCreate([Car, Engine]);
|
2851 | * var car = injector.get(Car);
|
2852 | * expect(car instanceof Car).toBe(true);
|
2853 | * expect(car.engine instanceof Engine).toBe(true);
|
2854 | * ```
|
2855 | * *
|
2856 | * Notice, we don't use the `new` operator because we explicitly want to have the `Injector`
|
2857 | * resolve all of the object's dependencies automatically.
|
2858 | * *
|
2859 | * @abstract
|
2860 | */
|
2861 | var ReflectiveInjector = (function () {
|
2862 | function ReflectiveInjector() {
|
2863 | }
|
2864 | /**
|
2865 | * Turns an array of provider definitions into an array of resolved providers.
|
2866 | * *
|
2867 | * A resolution is a process of flattening multiple nested arrays and converting individual
|
2868 | * providers into an array of {@link ResolvedReflectiveProvider}s.
|
2869 | * *
|
2870 | * ### Example ([live demo](http://plnkr.co/edit/AiXTHi?p=preview))
|
2871 | * *
|
2872 | * ```typescript
|
2873 | * class Engine {
|
2874 | * }
|
2875 | * *
|
2876 | * class Car {
|
2877 | * constructor(public engine:Engine) {}
|
2878 | * }
|
2879 | * *
|
2880 | * var providers = ReflectiveInjector.resolve([Car, [[Engine]]]);
|
2881 | * *
|
2882 | * expect(providers.length).toEqual(2);
|
2883 | * *
|
2884 | * expect(providers[0] instanceof ResolvedReflectiveProvider).toBe(true);
|
2885 | * expect(providers[0].key.displayName).toBe("Car");
|
2886 | * expect(providers[0].dependencies.length).toEqual(1);
|
2887 | * expect(providers[0].factory).toBeDefined();
|
2888 | * *
|
2889 | * expect(providers[1].key.displayName).toBe("Engine");
|
2890 | * });
|
2891 | * ```
|
2892 | * *
|
2893 | * See {@link ReflectiveInjector#fromResolvedProviders} for more info.
|
2894 | * @param {?} providers
|
2895 | * @return {?}
|
2896 | */
|
2897 | ReflectiveInjector.resolve = function (providers) {
|
2898 | return resolveReflectiveProviders(providers);
|
2899 | };
|
2900 | /**
|
2901 | * Resolves an array of providers and creates an injector from those providers.
|
2902 | * *
|
2903 | * The passed-in providers can be an array of `Type`, {@link Provider},
|
2904 | * or a recursive array of more providers.
|
2905 | * *
|
2906 | * ### Example ([live demo](http://plnkr.co/edit/ePOccA?p=preview))
|
2907 | * *
|
2908 | * ```typescript
|
2909 | * class Engine {
|
2910 | * }
|
2911 | * *
|
2912 | * class Car {
|
2913 | * constructor(public engine:Engine) {}
|
2914 | * }
|
2915 | * *
|
2916 | * var injector = ReflectiveInjector.resolveAndCreate([Car, Engine]);
|
2917 | * expect(injector.get(Car) instanceof Car).toBe(true);
|
2918 | * ```
|
2919 | * *
|
2920 | * This function is slower than the corresponding `fromResolvedProviders`
|
2921 | * because it needs to resolve the passed-in providers first.
|
2922 | * See {@link Injector#resolve} and {@link Injector#fromResolvedProviders}.
|
2923 | * @param {?} providers
|
2924 | * @param {?=} parent
|
2925 | * @return {?}
|
2926 | */
|
2927 | ReflectiveInjector.resolveAndCreate = function (providers, parent) {
|
2928 | if (parent === void 0) { parent = null; }
|
2929 | var /** @type {?} */ ResolvedReflectiveProviders = ReflectiveInjector.resolve(providers);
|
2930 | return ReflectiveInjector.fromResolvedProviders(ResolvedReflectiveProviders, parent);
|
2931 | };
|
2932 | /**
|
2933 | * Creates an injector from previously resolved providers.
|
2934 | * *
|
2935 | * This API is the recommended way to construct injectors in performance-sensitive parts.
|
2936 | * *
|
2937 | * ### Example ([live demo](http://plnkr.co/edit/KrSMci?p=preview))
|
2938 | * *
|
2939 | * ```typescript
|
2940 | * class Engine {
|
2941 | * }
|
2942 | * *
|
2943 | * class Car {
|
2944 | * constructor(public engine:Engine) {}
|
2945 | * }
|
2946 | * *
|
2947 | * var providers = ReflectiveInjector.resolve([Car, Engine]);
|
2948 | * var injector = ReflectiveInjector.fromResolvedProviders(providers);
|
2949 | * expect(injector.get(Car) instanceof Car).toBe(true);
|
2950 | * ```
|
2951 | * @param {?} providers
|
2952 | * @param {?=} parent
|
2953 | * @return {?}
|
2954 | */
|
2955 | ReflectiveInjector.fromResolvedProviders = function (providers, parent) {
|
2956 | if (parent === void 0) { parent = null; }
|
2957 | return new ReflectiveInjector_(ReflectiveProtoInjector.fromResolvedProviders(providers), parent);
|
2958 | };
|
2959 | Object.defineProperty(ReflectiveInjector.prototype, "parent", {
|
2960 | /**
|
2961 | * Parent of this injector.
|
2962 | * *
|
2963 | * <!-- TODO: Add a link to the section of the user guide talking about hierarchical injection.
|
2964 | * -->
|
2965 | * *
|
2966 | * ### Example ([live demo](http://plnkr.co/edit/eosMGo?p=preview))
|
2967 | * *
|
2968 | * ```typescript
|
2969 | * var parent = ReflectiveInjector.resolveAndCreate([]);
|
2970 | * var child = parent.resolveAndCreateChild([]);
|
2971 | * expect(child.parent).toBe(parent);
|
2972 | * ```
|
2973 | * @return {?}
|
2974 | */
|
2975 | get: function () { return unimplemented(); },
|
2976 | enumerable: true,
|
2977 | configurable: true
|
2978 | });
|
2979 | /**
|
2980 | * Resolves an array of providers and creates a child injector from those providers.
|
2981 | * *
|
2982 | * <!-- TODO: Add a link to the section of the user guide talking about hierarchical injection.
|
2983 | * -->
|
2984 | * *
|
2985 | * The passed-in providers can be an array of `Type`, {@link Provider},
|
2986 | * or a recursive array of more providers.
|
2987 | * *
|
2988 | * ### Example ([live demo](http://plnkr.co/edit/opB3T4?p=preview))
|
2989 | * *
|
2990 | * ```typescript
|
2991 | * class ParentProvider {}
|
2992 | * class ChildProvider {}
|
2993 | * *
|
2994 | * var parent = ReflectiveInjector.resolveAndCreate([ParentProvider]);
|
2995 | * var child = parent.resolveAndCreateChild([ChildProvider]);
|
2996 | * *
|
2997 | * expect(child.get(ParentProvider) instanceof ParentProvider).toBe(true);
|
2998 | * expect(child.get(ChildProvider) instanceof ChildProvider).toBe(true);
|
2999 | * expect(child.get(ParentProvider)).toBe(parent.get(ParentProvider));
|
3000 | * ```
|
3001 | * *
|
3002 | * This function is slower than the corresponding `createChildFromResolved`
|
3003 | * because it needs to resolve the passed-in providers first.
|
3004 | * See {@link Injector#resolve} and {@link Injector#createChildFromResolved}.
|
3005 | * @param {?} providers
|
3006 | * @return {?}
|
3007 | */
|
3008 | ReflectiveInjector.prototype.resolveAndCreateChild = function (providers) { return unimplemented(); };
|
3009 | /**
|
3010 | * Creates a child injector from previously resolved providers.
|
3011 | * *
|
3012 | * <!-- TODO: Add a link to the section of the user guide talking about hierarchical injection.
|
3013 | * -->
|
3014 | * *
|
3015 | * This API is the recommended way to construct injectors in performance-sensitive parts.
|
3016 | * *
|
3017 | * ### Example ([live demo](http://plnkr.co/edit/VhyfjN?p=preview))
|
3018 | * *
|
3019 | * ```typescript
|
3020 | * class ParentProvider {}
|
3021 | * class ChildProvider {}
|
3022 | * *
|
3023 | * var parentProviders = ReflectiveInjector.resolve([ParentProvider]);
|
3024 | * var childProviders = ReflectiveInjector.resolve([ChildProvider]);
|
3025 | * *
|
3026 | * var parent = ReflectiveInjector.fromResolvedProviders(parentProviders);
|
3027 | * var child = parent.createChildFromResolved(childProviders);
|
3028 | * *
|
3029 | * expect(child.get(ParentProvider) instanceof ParentProvider).toBe(true);
|
3030 | * expect(child.get(ChildProvider) instanceof ChildProvider).toBe(true);
|
3031 | * expect(child.get(ParentProvider)).toBe(parent.get(ParentProvider));
|
3032 | * ```
|
3033 | * @param {?} providers
|
3034 | * @return {?}
|
3035 | */
|
3036 | ReflectiveInjector.prototype.createChildFromResolved = function (providers) {
|
3037 | return unimplemented();
|
3038 | };
|
3039 | /**
|
3040 | * Resolves a provider and instantiates an object in the context of the injector.
|
3041 | * *
|
3042 | * The created object does not get cached by the injector.
|
3043 | * *
|
3044 | * ### Example ([live demo](http://plnkr.co/edit/yvVXoB?p=preview))
|
3045 | * *
|
3046 | * ```typescript
|
3047 | * class Engine {
|
3048 | * }
|
3049 | * *
|
3050 | * class Car {
|
3051 | * constructor(public engine:Engine) {}
|
3052 | * }
|
3053 | * *
|
3054 | * var injector = ReflectiveInjector.resolveAndCreate([Engine]);
|
3055 | * *
|
3056 | * var car = injector.resolveAndInstantiate(Car);
|
3057 | * expect(car.engine).toBe(injector.get(Engine));
|
3058 | * expect(car).not.toBe(injector.resolveAndInstantiate(Car));
|
3059 | * ```
|
3060 | * @param {?} provider
|
3061 | * @return {?}
|
3062 | */
|
3063 | ReflectiveInjector.prototype.resolveAndInstantiate = function (provider) { return unimplemented(); };
|
3064 | /**
|
3065 | * Instantiates an object using a resolved provider in the context of the injector.
|
3066 | * *
|
3067 | * The created object does not get cached by the injector.
|
3068 | * *
|
3069 | * ### Example ([live demo](http://plnkr.co/edit/ptCImQ?p=preview))
|
3070 | * *
|
3071 | * ```typescript
|
3072 | * class Engine {
|
3073 | * }
|
3074 | * *
|
3075 | * class Car {
|
3076 | * constructor(public engine:Engine) {}
|
3077 | * }
|
3078 | * *
|
3079 | * var injector = ReflectiveInjector.resolveAndCreate([Engine]);
|
3080 | * var carProvider = ReflectiveInjector.resolve([Car])[0];
|
3081 | * var car = injector.instantiateResolved(carProvider);
|
3082 | * expect(car.engine).toBe(injector.get(Engine));
|
3083 | * expect(car).not.toBe(injector.instantiateResolved(carProvider));
|
3084 | * ```
|
3085 | * @param {?} provider
|
3086 | * @return {?}
|
3087 | */
|
3088 | ReflectiveInjector.prototype.instantiateResolved = function (provider) { return unimplemented(); };
|
3089 | /**
|
3090 | * @abstract
|
3091 | * @param {?} token
|
3092 | * @param {?=} notFoundValue
|
3093 | * @return {?}
|
3094 | */
|
3095 | ReflectiveInjector.prototype.get = function (token, notFoundValue) { };
|
3096 | return ReflectiveInjector;
|
3097 | }());
|
3098 | var ReflectiveInjector_ = (function () {
|
3099 | /**
|
3100 | * Private
|
3101 | * @param {?} _proto
|
3102 | * @param {?=} _parent
|
3103 | */
|
3104 | function ReflectiveInjector_(_proto /* ProtoInjector */, _parent) {
|
3105 | if (_parent === void 0) { _parent = null; }
|
3106 | /** @internal */
|
3107 | this._constructionCounter = 0;
|
3108 | this._proto = _proto;
|
3109 | this._parent = _parent;
|
3110 | this._strategy = _proto._strategy.createInjectorStrategy(this);
|
3111 | }
|
3112 | /**
|
3113 | * @param {?} token
|
3114 | * @param {?=} notFoundValue
|
3115 | * @return {?}
|
3116 | */
|
3117 | ReflectiveInjector_.prototype.get = function (token, notFoundValue) {
|
3118 | if (notFoundValue === void 0) { notFoundValue = THROW_IF_NOT_FOUND; }
|
3119 | return this._getByKey(ReflectiveKey.get(token), null, null, notFoundValue);
|
3120 | };
|
3121 | /**
|
3122 | * @param {?} index
|
3123 | * @return {?}
|
3124 | */
|
3125 | ReflectiveInjector_.prototype.getAt = function (index) { return this._strategy.getObjAtIndex(index); };
|
3126 | Object.defineProperty(ReflectiveInjector_.prototype, "parent", {
|
3127 | /**
|
3128 | * @return {?}
|
3129 | */
|
3130 | get: function () { return this._parent; },
|
3131 | enumerable: true,
|
3132 | configurable: true
|
3133 | });
|
3134 | Object.defineProperty(ReflectiveInjector_.prototype, "internalStrategy", {
|
3135 | /**
|
3136 | * Internal. Do not use.
|
3137 | * We return `any` not to export the InjectorStrategy type.
|
3138 | * @return {?}
|
3139 | */
|
3140 | get: function () { return this._strategy; },
|
3141 | enumerable: true,
|
3142 | configurable: true
|
3143 | });
|
3144 | /**
|
3145 | * @param {?} providers
|
3146 | * @return {?}
|
3147 | */
|
3148 | ReflectiveInjector_.prototype.resolveAndCreateChild = function (providers) {
|
3149 | var /** @type {?} */ ResolvedReflectiveProviders = ReflectiveInjector.resolve(providers);
|
3150 | return this.createChildFromResolved(ResolvedReflectiveProviders);
|
3151 | };
|
3152 | /**
|
3153 | * @param {?} providers
|
3154 | * @return {?}
|
3155 | */
|
3156 | ReflectiveInjector_.prototype.createChildFromResolved = function (providers) {
|
3157 | var /** @type {?} */ proto = new ReflectiveProtoInjector(providers);
|
3158 | var /** @type {?} */ inj = new ReflectiveInjector_(proto);
|
3159 | inj._parent = this;
|
3160 | return inj;
|
3161 | };
|
3162 | /**
|
3163 | * @param {?} provider
|
3164 | * @return {?}
|
3165 | */
|
3166 | ReflectiveInjector_.prototype.resolveAndInstantiate = function (provider) {
|
3167 | return this.instantiateResolved(ReflectiveInjector.resolve([provider])[0]);
|
3168 | };
|
3169 | /**
|
3170 | * @param {?} provider
|
3171 | * @return {?}
|
3172 | */
|
3173 | ReflectiveInjector_.prototype.instantiateResolved = function (provider) {
|
3174 | return this._instantiateProvider(provider);
|
3175 | };
|
3176 | /**
|
3177 | * @param {?} provider
|
3178 | * @return {?}
|
3179 | */
|
3180 | ReflectiveInjector_.prototype._new = function (provider) {
|
3181 | if (this._constructionCounter++ > this._strategy.getMaxNumberOfObjects()) {
|
3182 | throw new CyclicDependencyError(this, provider.key);
|
3183 | }
|
3184 | return this._instantiateProvider(provider);
|
3185 | };
|
3186 | /**
|
3187 | * @param {?} provider
|
3188 | * @return {?}
|
3189 | */
|
3190 | ReflectiveInjector_.prototype._instantiateProvider = function (provider) {
|
3191 | if (provider.multiProvider) {
|
3192 | var /** @type {?} */ res = new Array(provider.resolvedFactories.length);
|
3193 | for (var /** @type {?} */ i = 0; i < provider.resolvedFactories.length; ++i) {
|
3194 | res[i] = this._instantiate(provider, provider.resolvedFactories[i]);
|
3195 | }
|
3196 | return res;
|
3197 | }
|
3198 | else {
|
3199 | return this._instantiate(provider, provider.resolvedFactories[0]);
|
3200 | }
|
3201 | };
|
3202 | /**
|
3203 | * @param {?} provider
|
3204 | * @param {?} ResolvedReflectiveFactory
|
3205 | * @return {?}
|
3206 | */
|
3207 | ReflectiveInjector_.prototype._instantiate = function (provider, ResolvedReflectiveFactory) {
|
3208 | var /** @type {?} */ factory = ResolvedReflectiveFactory.factory;
|
3209 | var /** @type {?} */ deps = ResolvedReflectiveFactory.dependencies;
|
3210 | var /** @type {?} */ length = deps.length;
|
3211 | var /** @type {?} */ d0;
|
3212 | var /** @type {?} */ d1;
|
3213 | var /** @type {?} */ d2;
|
3214 | var /** @type {?} */ d3;
|
3215 | var /** @type {?} */ d4;
|
3216 | var /** @type {?} */ d5;
|
3217 | var /** @type {?} */ d6;
|
3218 | var /** @type {?} */ d7;
|
3219 | var /** @type {?} */ d8;
|
3220 | var /** @type {?} */ d9;
|
3221 | var /** @type {?} */ d10;
|
3222 | var /** @type {?} */ d11;
|
3223 | var /** @type {?} */ d12;
|
3224 | var /** @type {?} */ d13;
|
3225 | var /** @type {?} */ d14;
|
3226 | var /** @type {?} */ d15;
|
3227 | var /** @type {?} */ d16;
|
3228 | var /** @type {?} */ d17;
|
3229 | var /** @type {?} */ d18;
|
3230 | var /** @type {?} */ d19;
|
3231 | try {
|
3232 | d0 = length > 0 ? this._getByReflectiveDependency(provider, deps[0]) : null;
|
3233 | d1 = length > 1 ? this._getByReflectiveDependency(provider, deps[1]) : null;
|
3234 | d2 = length > 2 ? this._getByReflectiveDependency(provider, deps[2]) : null;
|
3235 | d3 = length > 3 ? this._getByReflectiveDependency(provider, deps[3]) : null;
|
3236 | d4 = length > 4 ? this._getByReflectiveDependency(provider, deps[4]) : null;
|
3237 | d5 = length > 5 ? this._getByReflectiveDependency(provider, deps[5]) : null;
|
3238 | d6 = length > 6 ? this._getByReflectiveDependency(provider, deps[6]) : null;
|
3239 | d7 = length > 7 ? this._getByReflectiveDependency(provider, deps[7]) : null;
|
3240 | d8 = length > 8 ? this._getByReflectiveDependency(provider, deps[8]) : null;
|
3241 | d9 = length > 9 ? this._getByReflectiveDependency(provider, deps[9]) : null;
|
3242 | d10 = length > 10 ? this._getByReflectiveDependency(provider, deps[10]) : null;
|
3243 | d11 = length > 11 ? this._getByReflectiveDependency(provider, deps[11]) : null;
|
3244 | d12 = length > 12 ? this._getByReflectiveDependency(provider, deps[12]) : null;
|
3245 | d13 = length > 13 ? this._getByReflectiveDependency(provider, deps[13]) : null;
|
3246 | d14 = length > 14 ? this._getByReflectiveDependency(provider, deps[14]) : null;
|
3247 | d15 = length > 15 ? this._getByReflectiveDependency(provider, deps[15]) : null;
|
3248 | d16 = length > 16 ? this._getByReflectiveDependency(provider, deps[16]) : null;
|
3249 | d17 = length > 17 ? this._getByReflectiveDependency(provider, deps[17]) : null;
|
3250 | d18 = length > 18 ? this._getByReflectiveDependency(provider, deps[18]) : null;
|
3251 | d19 = length > 19 ? this._getByReflectiveDependency(provider, deps[19]) : null;
|
3252 | }
|
3253 | catch (e) {
|
3254 | if (e instanceof AbstractProviderError || e instanceof InstantiationError) {
|
3255 | e.addKey(this, provider.key);
|
3256 | }
|
3257 | throw e;
|
3258 | }
|
3259 | var /** @type {?} */ obj;
|
3260 | try {
|
3261 | switch (length) {
|
3262 | case 0:
|
3263 | obj = factory();
|
3264 | break;
|
3265 | case 1:
|
3266 | obj = factory(d0);
|
3267 | break;
|
3268 | case 2:
|
3269 | obj = factory(d0, d1);
|
3270 | break;
|
3271 | case 3:
|
3272 | obj = factory(d0, d1, d2);
|
3273 | break;
|
3274 | case 4:
|
3275 | obj = factory(d0, d1, d2, d3);
|
3276 | break;
|
3277 | case 5:
|
3278 | obj = factory(d0, d1, d2, d3, d4);
|
3279 | break;
|
3280 | case 6:
|
3281 | obj = factory(d0, d1, d2, d3, d4, d5);
|
3282 | break;
|
3283 | case 7:
|
3284 | obj = factory(d0, d1, d2, d3, d4, d5, d6);
|
3285 | break;
|
3286 | case 8:
|
3287 | obj = factory(d0, d1, d2, d3, d4, d5, d6, d7);
|
3288 | break;
|
3289 | case 9:
|
3290 | obj = factory(d0, d1, d2, d3, d4, d5, d6, d7, d8);
|
3291 | break;
|
3292 | case 10:
|
3293 | obj = factory(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9);
|
3294 | break;
|
3295 | case 11:
|
3296 | obj = factory(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10);
|
3297 | break;
|
3298 | case 12:
|
3299 | obj = factory(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11);
|
3300 | break;
|
3301 | case 13:
|
3302 | obj = factory(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12);
|
3303 | break;
|
3304 | case 14:
|
3305 | obj = factory(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13);
|
3306 | break;
|
3307 | case 15:
|
3308 | obj = factory(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13, d14);
|
3309 | break;
|
3310 | case 16:
|
3311 | obj = factory(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13, d14, d15);
|
3312 | break;
|
3313 | case 17:
|
3314 | obj = factory(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13, d14, d15, d16);
|
3315 | break;
|
3316 | case 18:
|
3317 | obj = factory(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13, d14, d15, d16, d17);
|
3318 | break;
|
3319 | case 19:
|
3320 | obj = factory(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13, d14, d15, d16, d17, d18);
|
3321 | break;
|
3322 | case 20:
|
3323 | obj = factory(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13, d14, d15, d16, d17, d18, d19);
|
3324 | break;
|
3325 | default:
|
3326 | throw new Error("Cannot instantiate '" + provider.key.displayName + "' because it has more than 20 dependencies");
|
3327 | }
|
3328 | }
|
3329 | catch (e) {
|
3330 | throw new InstantiationError(this, e, e.stack, provider.key);
|
3331 | }
|
3332 | return obj;
|
3333 | };
|
3334 | /**
|
3335 | * @param {?} provider
|
3336 | * @param {?} dep
|
3337 | * @return {?}
|
3338 | */
|
3339 | ReflectiveInjector_.prototype._getByReflectiveDependency = function (provider, dep) {
|
3340 | return this._getByKey(dep.key, dep.lowerBoundVisibility, dep.upperBoundVisibility, dep.optional ? null : THROW_IF_NOT_FOUND);
|
3341 | };
|
3342 | /**
|
3343 | * @param {?} key
|
3344 | * @param {?} lowerBoundVisibility
|
3345 | * @param {?} upperBoundVisibility
|
3346 | * @param {?} notFoundValue
|
3347 | * @return {?}
|
3348 | */
|
3349 | ReflectiveInjector_.prototype._getByKey = function (key, lowerBoundVisibility, upperBoundVisibility, notFoundValue) {
|
3350 | if (key === INJECTOR_KEY) {
|
3351 | return this;
|
3352 | }
|
3353 | if (upperBoundVisibility instanceof Self) {
|
3354 | return this._getByKeySelf(key, notFoundValue);
|
3355 | }
|
3356 | else {
|
3357 | return this._getByKeyDefault(key, notFoundValue, lowerBoundVisibility);
|
3358 | }
|
3359 | };
|
3360 | /**
|
3361 | * @param {?} key
|
3362 | * @param {?} notFoundValue
|
3363 | * @return {?}
|
3364 | */
|
3365 | ReflectiveInjector_.prototype._throwOrNull = function (key, notFoundValue) {
|
3366 | if (notFoundValue !== THROW_IF_NOT_FOUND) {
|
3367 | return notFoundValue;
|
3368 | }
|
3369 | else {
|
3370 | throw new NoProviderError(this, key);
|
3371 | }
|
3372 | };
|
3373 | /**
|
3374 | * @param {?} key
|
3375 | * @param {?} notFoundValue
|
3376 | * @return {?}
|
3377 | */
|
3378 | ReflectiveInjector_.prototype._getByKeySelf = function (key, notFoundValue) {
|
3379 | var /** @type {?} */ obj = this._strategy.getObjByKeyId(key.id);
|
3380 | return (obj !== UNDEFINED) ? obj : this._throwOrNull(key, notFoundValue);
|
3381 | };
|
3382 | /**
|
3383 | * @param {?} key
|
3384 | * @param {?} notFoundValue
|
3385 | * @param {?} lowerBoundVisibility
|
3386 | * @return {?}
|
3387 | */
|
3388 | ReflectiveInjector_.prototype._getByKeyDefault = function (key, notFoundValue, lowerBoundVisibility) {
|
3389 | var /** @type {?} */ inj;
|
3390 | if (lowerBoundVisibility instanceof SkipSelf) {
|
3391 | inj = this._parent;
|
3392 | }
|
3393 | else {
|
3394 | inj = this;
|
3395 | }
|
3396 | while (inj instanceof ReflectiveInjector_) {
|
3397 | var /** @type {?} */ inj_ = (inj);
|
3398 | var /** @type {?} */ obj = inj_._strategy.getObjByKeyId(key.id);
|
3399 | if (obj !== UNDEFINED)
|
3400 | return obj;
|
3401 | inj = inj_._parent;
|
3402 | }
|
3403 | if (inj !== null) {
|
3404 | return inj.get(key.token, notFoundValue);
|
3405 | }
|
3406 | else {
|
3407 | return this._throwOrNull(key, notFoundValue);
|
3408 | }
|
3409 | };
|
3410 | Object.defineProperty(ReflectiveInjector_.prototype, "displayName", {
|
3411 | /**
|
3412 | * @return {?}
|
3413 | */
|
3414 | get: function () {
|
3415 | var /** @type {?} */ providers = _mapProviders(this, function (b) { return ' "' + b.key.displayName + '" '; })
|
3416 | .join(', ');
|
3417 | return "ReflectiveInjector(providers: [" + providers + "])";
|
3418 | },
|
3419 | enumerable: true,
|
3420 | configurable: true
|
3421 | });
|
3422 | /**
|
3423 | * @return {?}
|
3424 | */
|
3425 | ReflectiveInjector_.prototype.toString = function () { return this.displayName; };
|
3426 | return ReflectiveInjector_;
|
3427 | }());
|
3428 | var /** @type {?} */ INJECTOR_KEY = ReflectiveKey.get(Injector);
|
3429 | /**
|
3430 | * @param {?} injector
|
3431 | * @param {?} fn
|
3432 | * @return {?}
|
3433 | */
|
3434 | function _mapProviders(injector, fn) {
|
3435 | var /** @type {?} */ res = new Array(injector._proto.numberOfProviders);
|
3436 | for (var /** @type {?} */ i = 0; i < injector._proto.numberOfProviders; ++i) {
|
3437 | res[i] = fn(injector._proto.getProviderAtIndex(i));
|
3438 | }
|
3439 | return res;
|
3440 | }
|
3441 |
|
3442 | /**
|
3443 | * @license
|
3444 | * Copyright Google Inc. All Rights Reserved.
|
3445 | *
|
3446 | * Use of this source code is governed by an MIT-style license that can be
|
3447 | * found in the LICENSE file at https://angular.io/license
|
3448 | */
|
3449 | /**
|
3450 | * *
|
3451 | * *
|
3452 | * The default implementation of `ErrorHandler` prints error messages to the `console`. To
|
3453 | * intercept error handling, write a custom exception handler that replaces this default as
|
3454 | * appropriate for your app.
|
3455 | * *
|
3456 | * ### Example
|
3457 | * *
|
3458 | * ```
|
3459 | * class MyErrorHandler implements ErrorHandler {
|
3460 | * handleError(error) {
|
3461 | * // do something with the exception
|
3462 | * }
|
3463 | * }
|
3464 | * *
|
3465 | * providers: [{provide: ErrorHandler, useClass: MyErrorHandler}]
|
3466 | * })
|
3467 | * class MyModule {}
|
3468 | * ```
|
3469 | * *
|
3470 | */
|
3471 | var ErrorHandler = (function () {
|
3472 | /**
|
3473 | * @param {?=} rethrowError
|
3474 | */
|
3475 | function ErrorHandler(rethrowError) {
|
3476 | if (rethrowError === void 0) { rethrowError = true; }
|
3477 | /**
|
3478 | * @internal
|
3479 | */
|
3480 | this._console = console;
|
3481 | this.rethrowError = rethrowError;
|
3482 | }
|
3483 | /**
|
3484 | * @param {?} error
|
3485 | * @return {?}
|
3486 | */
|
3487 | ErrorHandler.prototype.handleError = function (error) {
|
3488 | var /** @type {?} */ originalError = this._findOriginalError(error);
|
3489 | var /** @type {?} */ originalStack = this._findOriginalStack(error);
|
3490 | var /** @type {?} */ context = this._findContext(error);
|
3491 | this._console.error("EXCEPTION: " + this._extractMessage(error));
|
3492 | if (originalError) {
|
3493 | this._console.error("ORIGINAL EXCEPTION: " + this._extractMessage(originalError));
|
3494 | }
|
3495 | if (originalStack) {
|
3496 | this._console.error('ORIGINAL STACKTRACE:');
|
3497 | this._console.error(originalStack);
|
3498 | }
|
3499 | if (context) {
|
3500 | this._console.error('ERROR CONTEXT:');
|
3501 | this._console.error(context);
|
3502 | }
|
3503 | // We rethrow exceptions, so operations like 'bootstrap' will result in an error
|
3504 | // when an error happens. If we do not rethrow, bootstrap will always succeed.
|
3505 | if (this.rethrowError)
|
3506 | throw error;
|
3507 | };
|
3508 | /**
|
3509 | * @param {?} error
|
3510 | * @return {?}
|
3511 | */
|
3512 | ErrorHandler.prototype._extractMessage = function (error) {
|
3513 | return error instanceof Error ? error.message : error.toString();
|
3514 | };
|
3515 | /**
|
3516 | * @param {?} error
|
3517 | * @return {?}
|
3518 | */
|
3519 | ErrorHandler.prototype._findContext = function (error) {
|
3520 | if (error) {
|
3521 | return error.context ? error.context :
|
3522 | this._findContext(((error)).originalError);
|
3523 | }
|
3524 | return null;
|
3525 | };
|
3526 | /**
|
3527 | * @param {?} error
|
3528 | * @return {?}
|
3529 | */
|
3530 | ErrorHandler.prototype._findOriginalError = function (error) {
|
3531 | var /** @type {?} */ e = ((error)).originalError;
|
3532 | while (e && ((e)).originalError) {
|
3533 | e = ((e)).originalError;
|
3534 | }
|
3535 | return e;
|
3536 | };
|
3537 | /**
|
3538 | * @param {?} error
|
3539 | * @return {?}
|
3540 | */
|
3541 | ErrorHandler.prototype._findOriginalStack = function (error) {
|
3542 | if (!(error instanceof Error))
|
3543 | return null;
|
3544 | var /** @type {?} */ e = error;
|
3545 | var /** @type {?} */ stack = e.stack;
|
3546 | while (e instanceof Error && ((e)).originalError) {
|
3547 | e = ((e)).originalError;
|
3548 | if (e instanceof Error && e.stack) {
|
3549 | stack = e.stack;
|
3550 | }
|
3551 | }
|
3552 | return stack;
|
3553 | };
|
3554 | return ErrorHandler;
|
3555 | }());
|
3556 |
|
3557 | /**
|
3558 | * Wraps Javascript Objects
|
3559 | */
|
3560 | var StringMapWrapper = (function () {
|
3561 | function StringMapWrapper() {
|
3562 | }
|
3563 | /**
|
3564 | * @param {?} m1
|
3565 | * @param {?} m2
|
3566 | * @return {?}
|
3567 | */
|
3568 | StringMapWrapper.merge = function (m1, m2) {
|
3569 | var /** @type {?} */ m = {};
|
3570 | for (var _i = 0, _a = Object.keys(m1); _i < _a.length; _i++) {
|
3571 | var k = _a[_i];
|
3572 | m[k] = m1[k];
|
3573 | }
|
3574 | for (var _b = 0, _c = Object.keys(m2); _b < _c.length; _b++) {
|
3575 | var k = _c[_b];
|
3576 | m[k] = m2[k];
|
3577 | }
|
3578 | return m;
|
3579 | };
|
3580 | /**
|
3581 | * @param {?} m1
|
3582 | * @param {?} m2
|
3583 | * @return {?}
|
3584 | */
|
3585 | StringMapWrapper.equals = function (m1, m2) {
|
3586 | var /** @type {?} */ k1 = Object.keys(m1);
|
3587 | var /** @type {?} */ k2 = Object.keys(m2);
|
3588 | if (k1.length != k2.length) {
|
3589 | return false;
|
3590 | }
|
3591 | for (var /** @type {?} */ i = 0; i < k1.length; i++) {
|
3592 | var /** @type {?} */ key = k1[i];
|
3593 | if (m1[key] !== m2[key]) {
|
3594 | return false;
|
3595 | }
|
3596 | }
|
3597 | return true;
|
3598 | };
|
3599 | return StringMapWrapper;
|
3600 | }());
|
3601 | var ListWrapper = (function () {
|
3602 | function ListWrapper() {
|
3603 | }
|
3604 | /**
|
3605 | * @param {?} arr
|
3606 | * @param {?} condition
|
3607 | * @return {?}
|
3608 | */
|
3609 | ListWrapper.findLast = function (arr, condition) {
|
3610 | for (var /** @type {?} */ i = arr.length - 1; i >= 0; i--) {
|
3611 | if (condition(arr[i])) {
|
3612 | return arr[i];
|
3613 | }
|
3614 | }
|
3615 | return null;
|
3616 | };
|
3617 | /**
|
3618 | * @param {?} list
|
3619 | * @param {?} items
|
3620 | * @return {?}
|
3621 | */
|
3622 | ListWrapper.removeAll = function (list, items) {
|
3623 | for (var /** @type {?} */ i = 0; i < items.length; ++i) {
|
3624 | var /** @type {?} */ index = list.indexOf(items[i]);
|
3625 | if (index > -1) {
|
3626 | list.splice(index, 1);
|
3627 | }
|
3628 | }
|
3629 | };
|
3630 | /**
|
3631 | * @param {?} list
|
3632 | * @param {?} el
|
3633 | * @return {?}
|
3634 | */
|
3635 | ListWrapper.remove = function (list, el) {
|
3636 | var /** @type {?} */ index = list.indexOf(el);
|
3637 | if (index > -1) {
|
3638 | list.splice(index, 1);
|
3639 | return true;
|
3640 | }
|
3641 | return false;
|
3642 | };
|
3643 | /**
|
3644 | * @param {?} a
|
3645 | * @param {?} b
|
3646 | * @return {?}
|
3647 | */
|
3648 | ListWrapper.equals = function (a, b) {
|
3649 | if (a.length != b.length)
|
3650 | return false;
|
3651 | for (var /** @type {?} */ i = 0; i < a.length; ++i) {
|
3652 | if (a[i] !== b[i])
|
3653 | return false;
|
3654 | }
|
3655 | return true;
|
3656 | };
|
3657 | /**
|
3658 | * @param {?} list
|
3659 | * @return {?}
|
3660 | */
|
3661 | ListWrapper.flatten = function (list) {
|
3662 | return list.reduce(function (flat, item) {
|
3663 | var /** @type {?} */ flatItem = Array.isArray(item) ? ListWrapper.flatten(item) : item;
|
3664 | return ((flat)).concat(flatItem);
|
3665 | }, []);
|
3666 | };
|
3667 | return ListWrapper;
|
3668 | }());
|
3669 | /**
|
3670 | * @param {?} obj
|
3671 | * @return {?}
|
3672 | */
|
3673 | function isListLikeIterable(obj) {
|
3674 | if (!isJsObject(obj))
|
3675 | return false;
|
3676 | return Array.isArray(obj) ||
|
3677 | (!(obj instanceof Map) &&
|
3678 | getSymbolIterator() in obj); // JS Iterable have a Symbol.iterator prop
|
3679 | }
|
3680 | /**
|
3681 | * @param {?} a
|
3682 | * @param {?} b
|
3683 | * @param {?} comparator
|
3684 | * @return {?}
|
3685 | */
|
3686 | function areIterablesEqual(a, b, comparator) {
|
3687 | var /** @type {?} */ iterator1 = a[getSymbolIterator()]();
|
3688 | var /** @type {?} */ iterator2 = b[getSymbolIterator()]();
|
3689 | while (true) {
|
3690 | var /** @type {?} */ item1 = iterator1.next();
|
3691 | var /** @type {?} */ item2 = iterator2.next();
|
3692 | if (item1.done && item2.done)
|
3693 | return true;
|
3694 | if (item1.done || item2.done)
|
3695 | return false;
|
3696 | if (!comparator(item1.value, item2.value))
|
3697 | return false;
|
3698 | }
|
3699 | }
|
3700 | /**
|
3701 | * @param {?} obj
|
3702 | * @param {?} fn
|
3703 | * @return {?}
|
3704 | */
|
3705 | function iterateListLike(obj, fn) {
|
3706 | if (Array.isArray(obj)) {
|
3707 | for (var /** @type {?} */ i = 0; i < obj.length; i++) {
|
3708 | fn(obj[i]);
|
3709 | }
|
3710 | }
|
3711 | else {
|
3712 | var /** @type {?} */ iterator = obj[getSymbolIterator()]();
|
3713 | var /** @type {?} */ item = void 0;
|
3714 | while (!((item = iterator.next()).done)) {
|
3715 | fn(item.value);
|
3716 | }
|
3717 | }
|
3718 | }
|
3719 |
|
3720 | /**
|
3721 | * @license undefined
|
3722 | * Copyright Google Inc. All Rights Reserved.
|
3723 | * *
|
3724 | * Use of this source code is governed by an MIT-style license that can be
|
3725 | * found in the LICENSE file at https://angular.io/license
|
3726 | * @param {?} obj
|
3727 | * @return {?}
|
3728 | */
|
3729 | function isPromise(obj) {
|
3730 | // allow any Promise/A+ compliant thenable.
|
3731 | // It's up to the caller to ensure that obj.then conforms to the spec
|
3732 | return !!obj && typeof obj.then === 'function';
|
3733 | }
|
3734 |
|
3735 | /**
|
3736 | * A function that will be executed when an application is initialized.
|
3737 | * @experimental
|
3738 | */
|
3739 | var /** @type {?} */ APP_INITIALIZER = new OpaqueToken('Application Initializer');
|
3740 | /**
|
3741 | * A class that reflects the state of running {@link APP_INITIALIZER}s.
|
3742 | * *
|
3743 | */
|
3744 | var ApplicationInitStatus = (function () {
|
3745 | /**
|
3746 | * @param {?} appInits
|
3747 | */
|
3748 | function ApplicationInitStatus(appInits) {
|
3749 | var _this = this;
|
3750 | this._done = false;
|
3751 | var asyncInitPromises = [];
|
3752 | if (appInits) {
|
3753 | for (var i = 0; i < appInits.length; i++) {
|
3754 | var initResult = appInits[i]();
|
3755 | if (isPromise(initResult)) {
|
3756 | asyncInitPromises.push(initResult);
|
3757 | }
|
3758 | }
|
3759 | }
|
3760 | this._donePromise = Promise.all(asyncInitPromises).then(function () { _this._done = true; });
|
3761 | if (asyncInitPromises.length === 0) {
|
3762 | this._done = true;
|
3763 | }
|
3764 | }
|
3765 | Object.defineProperty(ApplicationInitStatus.prototype, "done", {
|
3766 | /**
|
3767 | * @return {?}
|
3768 | */
|
3769 | get: function () { return this._done; },
|
3770 | enumerable: true,
|
3771 | configurable: true
|
3772 | });
|
3773 | Object.defineProperty(ApplicationInitStatus.prototype, "donePromise", {
|
3774 | /**
|
3775 | * @return {?}
|
3776 | */
|
3777 | get: function () { return this._donePromise; },
|
3778 | enumerable: true,
|
3779 | configurable: true
|
3780 | });
|
3781 | ApplicationInitStatus.decorators = [
|
3782 | { type: Injectable },
|
3783 | ];
|
3784 | /** @nocollapse */
|
3785 | ApplicationInitStatus.ctorParameters = function () { return [
|
3786 | { type: Array, decorators: [{ type: Inject, args: [APP_INITIALIZER,] }, { type: Optional },] },
|
3787 | ]; };
|
3788 | return ApplicationInitStatus;
|
3789 | }());
|
3790 |
|
3791 | /**
|
3792 | * A DI Token representing a unique string id assigned to the application by Angular and used
|
3793 | * primarily for prefixing application attributes and CSS styles when
|
3794 | * {@link ViewEncapsulation#Emulated} is being used.
|
3795 | *
|
3796 | * If you need to avoid randomly generated value to be used as an application id, you can provide
|
3797 | * a custom value via a DI provider <!-- TODO: provider --> configuring the root {@link Injector}
|
3798 | * using this token.
|
3799 | * @experimental
|
3800 | */
|
3801 | var /** @type {?} */ APP_ID = new OpaqueToken('AppId');
|
3802 | /**
|
3803 | * @return {?}
|
3804 | */
|
3805 | function _appIdRandomProviderFactory() {
|
3806 | return "" + _randomChar() + _randomChar() + _randomChar();
|
3807 | }
|
3808 | /**
|
3809 | * Providers that will generate a random APP_ID_TOKEN.
|
3810 | * @experimental
|
3811 | */
|
3812 | var /** @type {?} */ APP_ID_RANDOM_PROVIDER = {
|
3813 | provide: APP_ID,
|
3814 | useFactory: _appIdRandomProviderFactory,
|
3815 | deps: /** @type {?} */ ([]),
|
3816 | };
|
3817 | /**
|
3818 | * @return {?}
|
3819 | */
|
3820 | function _randomChar() {
|
3821 | return String.fromCharCode(97 + Math.floor(Math.random() * 25));
|
3822 | }
|
3823 | /**
|
3824 | * A function that will be executed when a platform is initialized.
|
3825 | * @experimental
|
3826 | */
|
3827 | var /** @type {?} */ PLATFORM_INITIALIZER = new OpaqueToken('Platform Initializer');
|
3828 | /**
|
3829 | * All callbacks provided via this token will be called for every component that is bootstrapped.
|
3830 | * Signature of the callback:
|
3831 | *
|
3832 | * `(componentRef: ComponentRef) => void`.
|
3833 | *
|
3834 | * @experimental
|
3835 | */
|
3836 | var /** @type {?} */ APP_BOOTSTRAP_LISTENER = new OpaqueToken('appBootstrapListener');
|
3837 | /**
|
3838 | * A token which indicates the root directory of the application
|
3839 | * @experimental
|
3840 | */
|
3841 | var /** @type {?} */ PACKAGE_ROOT_URL = new OpaqueToken('Application Packages Root URL');
|
3842 |
|
3843 | var Console = (function () {
|
3844 | function Console() {
|
3845 | }
|
3846 | /**
|
3847 | * @param {?} message
|
3848 | * @return {?}
|
3849 | */
|
3850 | Console.prototype.log = function (message) { print(message); };
|
3851 | /**
|
3852 | * @param {?} message
|
3853 | * @return {?}
|
3854 | */
|
3855 | Console.prototype.warn = function (message) { warn(message); };
|
3856 | Console.decorators = [
|
3857 | { type: Injectable },
|
3858 | ];
|
3859 | /** @nocollapse */
|
3860 | Console.ctorParameters = function () { return []; };
|
3861 | return Console;
|
3862 | }());
|
3863 |
|
3864 | /**
|
3865 | * @license
|
3866 | * Copyright Google Inc. All Rights Reserved.
|
3867 | *
|
3868 | * Use of this source code is governed by an MIT-style license that can be
|
3869 | * found in the LICENSE file at https://angular.io/license
|
3870 | */
|
3871 | var __extends$4 = (this && this.__extends) || function (d, b) {
|
3872 | for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
3873 | function __() { this.constructor = d; }
|
3874 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
3875 | };
|
3876 | /**
|
3877 | * Indicates that a component is still being loaded in a synchronous compile.
|
3878 | * *
|
3879 | */
|
3880 | var ComponentStillLoadingError = (function (_super) {
|
3881 | __extends$4(ComponentStillLoadingError, _super);
|
3882 | /**
|
3883 | * @param {?} compType
|
3884 | */
|
3885 | function ComponentStillLoadingError(compType) {
|
3886 | _super.call(this, "Can't compile synchronously as " + stringify(compType) + " is still being loaded!");
|
3887 | this.compType = compType;
|
3888 | }
|
3889 | return ComponentStillLoadingError;
|
3890 | }(BaseError));
|
3891 | /**
|
3892 | * Combination of NgModuleFactory and ComponentFactorys.
|
3893 | * *
|
3894 | */
|
3895 | var ModuleWithComponentFactories = (function () {
|
3896 | /**
|
3897 | * @param {?} ngModuleFactory
|
3898 | * @param {?} componentFactories
|
3899 | */
|
3900 | function ModuleWithComponentFactories(ngModuleFactory, componentFactories) {
|
3901 | this.ngModuleFactory = ngModuleFactory;
|
3902 | this.componentFactories = componentFactories;
|
3903 | }
|
3904 | return ModuleWithComponentFactories;
|
3905 | }());
|
3906 | /**
|
3907 | * @return {?}
|
3908 | */
|
3909 | function _throwError() {
|
3910 | throw new Error("Runtime compiler is not loaded");
|
3911 | }
|
3912 | /**
|
3913 | * Low-level service for running the angular compiler during runtime
|
3914 | * to create {@link ComponentFactory}s, which
|
3915 | * can later be used to create and render a Component instance.
|
3916 | * *
|
3917 | * Each `@NgModule` provides an own `Compiler` to its injector,
|
3918 | * that will use the directives/pipes of the ng module for compilation
|
3919 | * of components.
|
3920 | */
|
3921 | var Compiler = (function () {
|
3922 | function Compiler() {
|
3923 | }
|
3924 | /**
|
3925 | * Compiles the given NgModule and all of its components. All templates of the components listed
|
3926 | * in `entryComponents`
|
3927 | * have to be inlined. Otherwise throws a {@link ComponentStillLoadingError}.
|
3928 | * @param {?} moduleType
|
3929 | * @return {?}
|
3930 | */
|
3931 | Compiler.prototype.compileModuleSync = function (moduleType) { throw _throwError(); };
|
3932 | /**
|
3933 | * Compiles the given NgModule and all of its components
|
3934 | * @param {?} moduleType
|
3935 | * @return {?}
|
3936 | */
|
3937 | Compiler.prototype.compileModuleAsync = function (moduleType) { throw _throwError(); };
|
3938 | /**
|
3939 | * Same as {@link compileModuleSync} but also creates ComponentFactories for all components.
|
3940 | * @param {?} moduleType
|
3941 | * @return {?}
|
3942 | */
|
3943 | Compiler.prototype.compileModuleAndAllComponentsSync = function (moduleType) {
|
3944 | throw _throwError();
|
3945 | };
|
3946 | /**
|
3947 | * Same as {@link compileModuleAsync} but also creates ComponentFactories for all components.
|
3948 | * @param {?} moduleType
|
3949 | * @return {?}
|
3950 | */
|
3951 | Compiler.prototype.compileModuleAndAllComponentsAsync = function (moduleType) {
|
3952 | throw _throwError();
|
3953 | };
|
3954 | /**
|
3955 | * Exposes the CSS-style selectors that have been used in `ngContent` directives within
|
3956 | * the template of the given component.
|
3957 | * This is used by the `upgrade` library to compile the appropriate transclude content
|
3958 | * in the Angular 1 wrapper component.
|
3959 | * @param {?} component
|
3960 | * @return {?}
|
3961 | */
|
3962 | Compiler.prototype.getNgContentSelectors = function (component) { throw _throwError(); };
|
3963 | /**
|
3964 | * Clears all caches.
|
3965 | * @return {?}
|
3966 | */
|
3967 | Compiler.prototype.clearCache = function () { };
|
3968 | /**
|
3969 | * Clears the cache for the given component/ngModule.
|
3970 | * @param {?} type
|
3971 | * @return {?}
|
3972 | */
|
3973 | Compiler.prototype.clearCacheFor = function (type) { };
|
3974 | Compiler.decorators = [
|
3975 | { type: Injectable },
|
3976 | ];
|
3977 | /** @nocollapse */
|
3978 | Compiler.ctorParameters = function () { return []; };
|
3979 | return Compiler;
|
3980 | }());
|
3981 | /**
|
3982 | * Token to provide CompilerOptions in the platform injector.
|
3983 | *
|
3984 | * @experimental
|
3985 | */
|
3986 | var /** @type {?} */ COMPILER_OPTIONS = new OpaqueToken('compilerOptions');
|
3987 | /**
|
3988 | * A factory for creating a Compiler
|
3989 | * *
|
3990 | * @abstract
|
3991 | */
|
3992 | var CompilerFactory = (function () {
|
3993 | function CompilerFactory() {
|
3994 | }
|
3995 | /**
|
3996 | * @abstract
|
3997 | * @param {?=} options
|
3998 | * @return {?}
|
3999 | */
|
4000 | CompilerFactory.prototype.createCompiler = function (options) { };
|
4001 | return CompilerFactory;
|
4002 | }());
|
4003 |
|
4004 | /**
|
4005 | * @license
|
4006 | * Copyright Google Inc. All Rights Reserved.
|
4007 | *
|
4008 | * Use of this source code is governed by an MIT-style license that can be
|
4009 | * found in the LICENSE file at https://angular.io/license
|
4010 | */
|
4011 | /**
|
4012 | * A wrapper around a native element inside of a View.
|
4013 | *
|
4014 | * An `ElementRef` is backed by a render-specific element. In the browser, this is usually a DOM
|
4015 | * element.
|
4016 | *
|
4017 | * @security Permitting direct access to the DOM can make your application more vulnerable to
|
4018 | * XSS attacks. Carefully review any use of `ElementRef` in your code. For more detail, see the
|
4019 | * [Security Guide](http://g.co/ng/security).
|
4020 | *
|
4021 | * @stable
|
4022 | */
|
4023 | // Note: We don't expose things like `Injector`, `ViewContainer`, ... here,
|
4024 | // i.e. users have to ask for what they need. With that, we can build better analysis tools
|
4025 | // and could do better codegen in the future.
|
4026 | var ElementRef = (function () {
|
4027 | /**
|
4028 | * @param {?} nativeElement
|
4029 | */
|
4030 | function ElementRef(nativeElement) {
|
4031 | this.nativeElement = nativeElement;
|
4032 | }
|
4033 | return ElementRef;
|
4034 | }());
|
4035 |
|
4036 | /**
|
4037 | * @license
|
4038 | * Copyright Google Inc. All Rights Reserved.
|
4039 | *
|
4040 | * Use of this source code is governed by an MIT-style license that can be
|
4041 | * found in the LICENSE file at https://angular.io/license
|
4042 | */
|
4043 | var __extends$6 = (this && this.__extends) || function (d, b) {
|
4044 | for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
4045 | function __() { this.constructor = d; }
|
4046 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
4047 | };
|
4048 | /**
|
4049 | * Use by directives and components to emit custom Events.
|
4050 | * *
|
4051 | * ### Examples
|
4052 | * *
|
4053 | * In the following example, `Zippy` alternatively emits `open` and `close` events when its
|
4054 | * title gets clicked:
|
4055 | * *
|
4056 | * ```
|
4057 | * selector: 'zippy',
|
4058 | * template: `
|
4059 | * <div class="zippy">
|
4060 | * <div (click)="toggle()">Toggle</div>
|
4061 | * <div [hidden]="!visible">
|
4062 | * <ng-content></ng-content>
|
4063 | * </div>
|
4064 | * </div>`})
|
4065 | * export class Zippy {
|
4066 | * visible: boolean = true;
|
4067 | * @Output() open: EventEmitter<any> = new EventEmitter();
|
4068 | * @Output() close: EventEmitter<any> = new EventEmitter();
|
4069 | * *
|
4070 | * toggle() {
|
4071 | * this.visible = !this.visible;
|
4072 | * if (this.visible) {
|
4073 | * this.open.emit(null);
|
4074 | * } else {
|
4075 | * this.close.emit(null);
|
4076 | * }
|
4077 | * }
|
4078 | * }
|
4079 | * ```
|
4080 | * *
|
4081 | * The events payload can be accessed by the parameter `$event` on the components output event
|
4082 | * handler:
|
4083 | * *
|
4084 | * ```
|
4085 | * <zippy (open)="onOpen($event)" (close)="onClose($event)"></zippy>
|
4086 | * ```
|
4087 | * *
|
4088 | * Uses Rx.Observable but provides an adapter to make it work as specified here:
|
4089 | * https://github.com/jhusain/observable-spec
|
4090 | * *
|
4091 | * Once a reference implementation of the spec is available, switch to it.
|
4092 | */
|
4093 | var EventEmitter = (function (_super) {
|
4094 | __extends$6(EventEmitter, _super);
|
4095 | /**
|
4096 | * Creates an instance of [EventEmitter], which depending on [isAsync],
|
4097 | * delivers events synchronously or asynchronously.
|
4098 | * @param {?=} isAsync
|
4099 | */
|
4100 | function EventEmitter(isAsync) {
|
4101 | if (isAsync === void 0) { isAsync = false; }
|
4102 | _super.call(this);
|
4103 | this.__isAsync = isAsync;
|
4104 | }
|
4105 | /**
|
4106 | * @param {?=} value
|
4107 | * @return {?}
|
4108 | */
|
4109 | EventEmitter.prototype.emit = function (value) { _super.prototype.next.call(this, value); };
|
4110 | /**
|
4111 | * @param {?=} generatorOrNext
|
4112 | * @param {?=} error
|
4113 | * @param {?=} complete
|
4114 | * @return {?}
|
4115 | */
|
4116 | EventEmitter.prototype.subscribe = function (generatorOrNext, error, complete) {
|
4117 | var /** @type {?} */ schedulerFn;
|
4118 | var /** @type {?} */ errorFn = function (err) { return null; };
|
4119 | var /** @type {?} */ completeFn = function () { return null; };
|
4120 | if (generatorOrNext && typeof generatorOrNext === 'object') {
|
4121 | schedulerFn = this.__isAsync ? function (value) {
|
4122 | setTimeout(function () { return generatorOrNext.next(value); });
|
4123 | } : function (value) { generatorOrNext.next(value); };
|
4124 | if (generatorOrNext.error) {
|
4125 | errorFn = this.__isAsync ? function (err) { setTimeout(function () { return generatorOrNext.error(err); }); } :
|
4126 | function (err) { generatorOrNext.error(err); };
|
4127 | }
|
4128 | if (generatorOrNext.complete) {
|
4129 | completeFn = this.__isAsync ? function () { setTimeout(function () { return generatorOrNext.complete(); }); } :
|
4130 | function () { generatorOrNext.complete(); };
|
4131 | }
|
4132 | }
|
4133 | else {
|
4134 | schedulerFn = this.__isAsync ? function (value) { setTimeout(function () { return generatorOrNext(value); }); } :
|
4135 | function (value) { generatorOrNext(value); };
|
4136 | if (error) {
|
4137 | errorFn =
|
4138 | this.__isAsync ? function (err) { setTimeout(function () { return error(err); }); } : function (err) { error(err); };
|
4139 | }
|
4140 | if (complete) {
|
4141 | completeFn =
|
4142 | this.__isAsync ? function () { setTimeout(function () { return complete(); }); } : function () { complete(); };
|
4143 | }
|
4144 | }
|
4145 | return _super.prototype.subscribe.call(this, schedulerFn, errorFn, completeFn);
|
4146 | };
|
4147 | return EventEmitter;
|
4148 | }(rxjs_Subject.Subject));
|
4149 |
|
4150 | /**
|
4151 | * An injectable service for executing work inside or outside of the Angular zone.
|
4152 | * *
|
4153 | * The most common use of this service is to optimize performance when starting a work consisting of
|
4154 | * one or more asynchronous tasks that don't require UI updates or error handling to be handled by
|
4155 | * Angular. Such tasks can be kicked off via {@link runOutsideAngular} and if needed, these tasks
|
4156 | * can reenter the Angular zone via {@link run}.
|
4157 | * *
|
4158 | * <!-- TODO: add/fix links to:
|
4159 | * - docs explaining zones and the use of zones in Angular and change-detection
|
4160 | * - link to runOutsideAngular/run (throughout this file!)
|
4161 | * -->
|
4162 | * *
|
4163 | * ### Example
|
4164 | * ```
|
4165 | * import {Component, NgZone} from '@angular/core';
|
4166 | * import {NgIf} from '@angular/common';
|
4167 | * *
|
4168 | * selector: 'ng-zone-demo'.
|
4169 | * template: `
|
4170 | * <h2>Demo: NgZone</h2>
|
4171 | * *
|
4172 | * <p>Progress: {{progress}}%</p>
|
4173 | * <p *ngIf="progress >= 100">Done processing {{label}} of Angular zone!</p>
|
4174 | * *
|
4175 | * <button (click)="processWithinAngularZone()">Process within Angular zone</button>
|
4176 | * <button (click)="processOutsideOfAngularZone()">Process outside of Angular zone</button>
|
4177 | * `,
|
4178 | * })
|
4179 | * export class NgZoneDemo {
|
4180 | * progress: number = 0;
|
4181 | * label: string;
|
4182 | * *
|
4183 | * constructor(private _ngZone: NgZone) {}
|
4184 | * *
|
4185 | * // Loop inside the Angular zone
|
4186 | * // so the UI DOES refresh after each setTimeout cycle
|
4187 | * processWithinAngularZone() {
|
4188 | * this.label = 'inside';
|
4189 | * this.progress = 0;
|
4190 | * this._increaseProgress(() => console.log('Inside Done!'));
|
4191 | * }
|
4192 | * *
|
4193 | * // Loop outside of the Angular zone
|
4194 | * // so the UI DOES NOT refresh after each setTimeout cycle
|
4195 | * processOutsideOfAngularZone() {
|
4196 | * this.label = 'outside';
|
4197 | * this.progress = 0;
|
4198 | * this._ngZone.runOutsideAngular(() => {
|
4199 | * this._increaseProgress(() => {
|
4200 | * // reenter the Angular zone and display done
|
4201 | * this._ngZone.run(() => {console.log('Outside Done!') });
|
4202 | * }}));
|
4203 | * }
|
4204 | * *
|
4205 | * _increaseProgress(doneCallback: () => void) {
|
4206 | * this.progress += 1;
|
4207 | * console.log(`Current progress: ${this.progress}%`);
|
4208 | * *
|
4209 | * if (this.progress < 100) {
|
4210 | * window.setTimeout(() => this._increaseProgress(doneCallback)), 10)
|
4211 | * } else {
|
4212 | * doneCallback();
|
4213 | * }
|
4214 | * }
|
4215 | * }
|
4216 | * ```
|
4217 | */
|
4218 | var NgZone = (function () {
|
4219 | /**
|
4220 | * @param {?} __0
|
4221 | */
|
4222 | function NgZone(_a) {
|
4223 | var _b = _a.enableLongStackTrace, enableLongStackTrace = _b === void 0 ? false : _b;
|
4224 | this._hasPendingMicrotasks = false;
|
4225 | this._hasPendingMacrotasks = false;
|
4226 | this._isStable = true;
|
4227 | this._nesting = 0;
|
4228 | this._onUnstable = new EventEmitter(false);
|
4229 | this._onMicrotaskEmpty = new EventEmitter(false);
|
4230 | this._onStable = new EventEmitter(false);
|
4231 | this._onErrorEvents = new EventEmitter(false);
|
4232 | if (typeof Zone == 'undefined') {
|
4233 | throw new Error('Angular requires Zone.js prolyfill.');
|
4234 | }
|
4235 | Zone.assertZonePatched();
|
4236 | this.outer = this.inner = Zone.current;
|
4237 | if (Zone['wtfZoneSpec']) {
|
4238 | this.inner = this.inner.fork(Zone['wtfZoneSpec']);
|
4239 | }
|
4240 | if (enableLongStackTrace && Zone['longStackTraceZoneSpec']) {
|
4241 | this.inner = this.inner.fork(Zone['longStackTraceZoneSpec']);
|
4242 | }
|
4243 | this.forkInnerZoneWithAngularBehavior();
|
4244 | }
|
4245 | /**
|
4246 | * @return {?}
|
4247 | */
|
4248 | NgZone.isInAngularZone = function () { return Zone.current.get('isAngularZone') === true; };
|
4249 | /**
|
4250 | * @return {?}
|
4251 | */
|
4252 | NgZone.assertInAngularZone = function () {
|
4253 | if (!NgZone.isInAngularZone()) {
|
4254 | throw new Error('Expected to be in Angular Zone, but it is not!');
|
4255 | }
|
4256 | };
|
4257 | /**
|
4258 | * @return {?}
|
4259 | */
|
4260 | NgZone.assertNotInAngularZone = function () {
|
4261 | if (NgZone.isInAngularZone()) {
|
4262 | throw new Error('Expected to not be in Angular Zone, but it is!');
|
4263 | }
|
4264 | };
|
4265 | /**
|
4266 | * Executes the `fn` function synchronously within the Angular zone and returns value returned by
|
4267 | * the function.
|
4268 | * *
|
4269 | * Running functions via `run` allows you to reenter Angular zone from a task that was executed
|
4270 | * outside of the Angular zone (typically started via {@link runOutsideAngular}).
|
4271 | * *
|
4272 | * Any future tasks or microtasks scheduled from within this function will continue executing from
|
4273 | * within the Angular zone.
|
4274 | * *
|
4275 | * If a synchronous error happens it will be rethrown and not reported via `onError`.
|
4276 | * @param {?} fn
|
4277 | * @return {?}
|
4278 | */
|
4279 | NgZone.prototype.run = function (fn) { return this.inner.run(fn); };
|
4280 | /**
|
4281 | * Same as `run`, except that synchronous errors are caught and forwarded via `onError` and not
|
4282 | * rethrown.
|
4283 | * @param {?} fn
|
4284 | * @return {?}
|
4285 | */
|
4286 | NgZone.prototype.runGuarded = function (fn) { return this.inner.runGuarded(fn); };
|
4287 | /**
|
4288 | * Executes the `fn` function synchronously in Angular's parent zone and returns value returned by
|
4289 | * the function.
|
4290 | * *
|
4291 | * Running functions via `runOutsideAngular` allows you to escape Angular's zone and do work that
|
4292 | * doesn't trigger Angular change-detection or is subject to Angular's error handling.
|
4293 | * *
|
4294 | * Any future tasks or microtasks scheduled from within this function will continue executing from
|
4295 | * outside of the Angular zone.
|
4296 | * *
|
4297 | * Use {@link run} to reenter the Angular zone and do work that updates the application model.
|
4298 | * @param {?} fn
|
4299 | * @return {?}
|
4300 | */
|
4301 | NgZone.prototype.runOutsideAngular = function (fn) { return this.outer.run(fn); };
|
4302 | Object.defineProperty(NgZone.prototype, "onUnstable", {
|
4303 | /**
|
4304 | * Notifies when code enters Angular Zone. This gets fired first on VM Turn.
|
4305 | * @return {?}
|
4306 | */
|
4307 | get: function () { return this._onUnstable; },
|
4308 | enumerable: true,
|
4309 | configurable: true
|
4310 | });
|
4311 | Object.defineProperty(NgZone.prototype, "onMicrotaskEmpty", {
|
4312 | /**
|
4313 | * Notifies when there is no more microtasks enqueue in the current VM Turn.
|
4314 | * This is a hint for Angular to do change detection, which may enqueue more microtasks.
|
4315 | * For this reason this event can fire multiple times per VM Turn.
|
4316 | * @return {?}
|
4317 | */
|
4318 | get: function () { return this._onMicrotaskEmpty; },
|
4319 | enumerable: true,
|
4320 | configurable: true
|
4321 | });
|
4322 | Object.defineProperty(NgZone.prototype, "onStable", {
|
4323 | /**
|
4324 | * Notifies when the last `onMicrotaskEmpty` has run and there are no more microtasks, which
|
4325 | * implies we are about to relinquish VM turn.
|
4326 | * This event gets called just once.
|
4327 | * @return {?}
|
4328 | */
|
4329 | get: function () { return this._onStable; },
|
4330 | enumerable: true,
|
4331 | configurable: true
|
4332 | });
|
4333 | Object.defineProperty(NgZone.prototype, "onError", {
|
4334 | /**
|
4335 | * Notify that an error has been delivered.
|
4336 | * @return {?}
|
4337 | */
|
4338 | get: function () { return this._onErrorEvents; },
|
4339 | enumerable: true,
|
4340 | configurable: true
|
4341 | });
|
4342 | Object.defineProperty(NgZone.prototype, "isStable", {
|
4343 | /**
|
4344 | * Whether there are no outstanding microtasks or macrotasks.
|
4345 | * @return {?}
|
4346 | */
|
4347 | get: function () { return this._isStable; },
|
4348 | enumerable: true,
|
4349 | configurable: true
|
4350 | });
|
4351 | Object.defineProperty(NgZone.prototype, "hasPendingMicrotasks", {
|
4352 | /**
|
4353 | * @return {?}
|
4354 | */
|
4355 | get: function () { return this._hasPendingMicrotasks; },
|
4356 | enumerable: true,
|
4357 | configurable: true
|
4358 | });
|
4359 | Object.defineProperty(NgZone.prototype, "hasPendingMacrotasks", {
|
4360 | /**
|
4361 | * @return {?}
|
4362 | */
|
4363 | get: function () { return this._hasPendingMacrotasks; },
|
4364 | enumerable: true,
|
4365 | configurable: true
|
4366 | });
|
4367 | /**
|
4368 | * @return {?}
|
4369 | */
|
4370 | NgZone.prototype.checkStable = function () {
|
4371 | var _this = this;
|
4372 | if (this._nesting == 0 && !this._hasPendingMicrotasks && !this._isStable) {
|
4373 | try {
|
4374 | this._nesting++;
|
4375 | this._onMicrotaskEmpty.emit(null);
|
4376 | }
|
4377 | finally {
|
4378 | this._nesting--;
|
4379 | if (!this._hasPendingMicrotasks) {
|
4380 | try {
|
4381 | this.runOutsideAngular(function () { return _this._onStable.emit(null); });
|
4382 | }
|
4383 | finally {
|
4384 | this._isStable = true;
|
4385 | }
|
4386 | }
|
4387 | }
|
4388 | }
|
4389 | };
|
4390 | /**
|
4391 | * @return {?}
|
4392 | */
|
4393 | NgZone.prototype.forkInnerZoneWithAngularBehavior = function () {
|
4394 | var _this = this;
|
4395 | this.inner = this.inner.fork({
|
4396 | name: 'angular',
|
4397 | properties: /** @type {?} */ ({ 'isAngularZone': true }),
|
4398 | onInvokeTask: function (delegate, current, target, task, applyThis, applyArgs) {
|
4399 | try {
|
4400 | _this.onEnter();
|
4401 | return delegate.invokeTask(target, task, applyThis, applyArgs);
|
4402 | }
|
4403 | finally {
|
4404 | _this.onLeave();
|
4405 | }
|
4406 | },
|
4407 | onInvoke: function (delegate, current, target, callback, applyThis, applyArgs, source) {
|
4408 | try {
|
4409 | _this.onEnter();
|
4410 | return delegate.invoke(target, callback, applyThis, applyArgs, source);
|
4411 | }
|
4412 | finally {
|
4413 | _this.onLeave();
|
4414 | }
|
4415 | },
|
4416 | onHasTask: function (delegate, current, target, hasTaskState) {
|
4417 | delegate.hasTask(target, hasTaskState);
|
4418 | if (current === target) {
|
4419 | // We are only interested in hasTask events which originate from our zone
|
4420 | // (A child hasTask event is not interesting to us)
|
4421 | if (hasTaskState.change == 'microTask') {
|
4422 | _this.setHasMicrotask(hasTaskState.microTask);
|
4423 | }
|
4424 | else if (hasTaskState.change == 'macroTask') {
|
4425 | _this.setHasMacrotask(hasTaskState.macroTask);
|
4426 | }
|
4427 | }
|
4428 | },
|
4429 | onHandleError: function (delegate, current, target, error) {
|
4430 | delegate.handleError(target, error);
|
4431 | _this.triggerError(error);
|
4432 | return false;
|
4433 | }
|
4434 | });
|
4435 | };
|
4436 | /**
|
4437 | * @return {?}
|
4438 | */
|
4439 | NgZone.prototype.onEnter = function () {
|
4440 | this._nesting++;
|
4441 | if (this._isStable) {
|
4442 | this._isStable = false;
|
4443 | this._onUnstable.emit(null);
|
4444 | }
|
4445 | };
|
4446 | /**
|
4447 | * @return {?}
|
4448 | */
|
4449 | NgZone.prototype.onLeave = function () {
|
4450 | this._nesting--;
|
4451 | this.checkStable();
|
4452 | };
|
4453 | /**
|
4454 | * @param {?} hasMicrotasks
|
4455 | * @return {?}
|
4456 | */
|
4457 | NgZone.prototype.setHasMicrotask = function (hasMicrotasks) {
|
4458 | this._hasPendingMicrotasks = hasMicrotasks;
|
4459 | this.checkStable();
|
4460 | };
|
4461 | /**
|
4462 | * @param {?} hasMacrotasks
|
4463 | * @return {?}
|
4464 | */
|
4465 | NgZone.prototype.setHasMacrotask = function (hasMacrotasks) { this._hasPendingMacrotasks = hasMacrotasks; };
|
4466 | /**
|
4467 | * @param {?} error
|
4468 | * @return {?}
|
4469 | */
|
4470 | NgZone.prototype.triggerError = function (error) { this._onErrorEvents.emit(error); };
|
4471 | return NgZone;
|
4472 | }());
|
4473 |
|
4474 | var AnimationQueue = (function () {
|
4475 | /**
|
4476 | * @param {?} _zone
|
4477 | */
|
4478 | function AnimationQueue(_zone) {
|
4479 | this._zone = _zone;
|
4480 | this.entries = [];
|
4481 | }
|
4482 | /**
|
4483 | * @param {?} player
|
4484 | * @return {?}
|
4485 | */
|
4486 | AnimationQueue.prototype.enqueue = function (player) { this.entries.push(player); };
|
4487 | /**
|
4488 | * @return {?}
|
4489 | */
|
4490 | AnimationQueue.prototype.flush = function () {
|
4491 | var _this = this;
|
4492 | // given that each animation player may set aside
|
4493 | // microtasks and rely on DOM-based events, this
|
4494 | // will cause Angular to run change detection after
|
4495 | // each request. This sidesteps the issue. If a user
|
4496 | // hooks into an animation via (@anim.start) or (@anim.done)
|
4497 | // then those methods will automatically trigger change
|
4498 | // detection by wrapping themselves inside of a zone
|
4499 | if (this.entries.length) {
|
4500 | this._zone.runOutsideAngular(function () {
|
4501 | // this code is wrapped into a single promise such that the
|
4502 | // onStart and onDone player callbacks are triggered outside
|
4503 | // of the digest cycle of animations
|
4504 | Promise.resolve(null).then(function () { return _this._triggerAnimations(); });
|
4505 | });
|
4506 | }
|
4507 | };
|
4508 | /**
|
4509 | * @return {?}
|
4510 | */
|
4511 | AnimationQueue.prototype._triggerAnimations = function () {
|
4512 | NgZone.assertNotInAngularZone();
|
4513 | while (this.entries.length) {
|
4514 | var /** @type {?} */ player = this.entries.shift();
|
4515 | // in the event that an animation throws an error then we do
|
4516 | // not want to re-run animations on any previous animations
|
4517 | // if they have already been kicked off beforehand
|
4518 | if (!player.hasStarted()) {
|
4519 | player.play();
|
4520 | }
|
4521 | }
|
4522 | };
|
4523 | AnimationQueue.decorators = [
|
4524 | { type: Injectable },
|
4525 | ];
|
4526 | /** @nocollapse */
|
4527 | AnimationQueue.ctorParameters = function () { return [
|
4528 | { type: NgZone, },
|
4529 | ]; };
|
4530 | return AnimationQueue;
|
4531 | }());
|
4532 |
|
4533 | var DefaultIterableDifferFactory = (function () {
|
4534 | function DefaultIterableDifferFactory() {
|
4535 | }
|
4536 | /**
|
4537 | * @param {?} obj
|
4538 | * @return {?}
|
4539 | */
|
4540 | DefaultIterableDifferFactory.prototype.supports = function (obj) { return isListLikeIterable(obj); };
|
4541 | /**
|
4542 | * @param {?} cdRef
|
4543 | * @param {?=} trackByFn
|
4544 | * @return {?}
|
4545 | */
|
4546 | DefaultIterableDifferFactory.prototype.create = function (cdRef, trackByFn) {
|
4547 | return new DefaultIterableDiffer(trackByFn);
|
4548 | };
|
4549 | return DefaultIterableDifferFactory;
|
4550 | }());
|
4551 | var /** @type {?} */ trackByIdentity = function (index, item) { return item; };
|
4552 | /**
|
4553 | * @stable
|
4554 | */
|
4555 | var DefaultIterableDiffer = (function () {
|
4556 | /**
|
4557 | * @param {?=} _trackByFn
|
4558 | */
|
4559 | function DefaultIterableDiffer(_trackByFn) {
|
4560 | this._trackByFn = _trackByFn;
|
4561 | this._length = null;
|
4562 | this._collection = null;
|
4563 | this._linkedRecords = null;
|
4564 | this._unlinkedRecords = null;
|
4565 | this._previousItHead = null;
|
4566 | this._itHead = null;
|
4567 | this._itTail = null;
|
4568 | this._additionsHead = null;
|
4569 | this._additionsTail = null;
|
4570 | this._movesHead = null;
|
4571 | this._movesTail = null;
|
4572 | this._removalsHead = null;
|
4573 | this._removalsTail = null;
|
4574 | this._identityChangesHead = null;
|
4575 | this._identityChangesTail = null;
|
4576 | this._trackByFn = this._trackByFn || trackByIdentity;
|
4577 | }
|
4578 | Object.defineProperty(DefaultIterableDiffer.prototype, "collection", {
|
4579 | /**
|
4580 | * @return {?}
|
4581 | */
|
4582 | get: function () { return this._collection; },
|
4583 | enumerable: true,
|
4584 | configurable: true
|
4585 | });
|
4586 | Object.defineProperty(DefaultIterableDiffer.prototype, "length", {
|
4587 | /**
|
4588 | * @return {?}
|
4589 | */
|
4590 | get: function () { return this._length; },
|
4591 | enumerable: true,
|
4592 | configurable: true
|
4593 | });
|
4594 | /**
|
4595 | * @param {?} fn
|
4596 | * @return {?}
|
4597 | */
|
4598 | DefaultIterableDiffer.prototype.forEachItem = function (fn) {
|
4599 | var /** @type {?} */ record;
|
4600 | for (record = this._itHead; record !== null; record = record._next) {
|
4601 | fn(record);
|
4602 | }
|
4603 | };
|
4604 | /**
|
4605 | * @param {?} fn
|
4606 | * @return {?}
|
4607 | */
|
4608 | DefaultIterableDiffer.prototype.forEachOperation = function (fn) {
|
4609 | var /** @type {?} */ nextIt = this._itHead;
|
4610 | var /** @type {?} */ nextRemove = this._removalsHead;
|
4611 | var /** @type {?} */ addRemoveOffset = 0;
|
4612 | var /** @type {?} */ moveOffsets = null;
|
4613 | while (nextIt || nextRemove) {
|
4614 | // Figure out which is the next record to process
|
4615 | // Order: remove, add, move
|
4616 | var /** @type {?} */ record = !nextRemove ||
|
4617 | nextIt &&
|
4618 | nextIt.currentIndex < getPreviousIndex(nextRemove, addRemoveOffset, moveOffsets) ?
|
4619 | nextIt :
|
4620 | nextRemove;
|
4621 | var /** @type {?} */ adjPreviousIndex = getPreviousIndex(record, addRemoveOffset, moveOffsets);
|
4622 | var /** @type {?} */ currentIndex = record.currentIndex;
|
4623 | // consume the item, and adjust the addRemoveOffset and update moveDistance if necessary
|
4624 | if (record === nextRemove) {
|
4625 | addRemoveOffset--;
|
4626 | nextRemove = nextRemove._nextRemoved;
|
4627 | }
|
4628 | else {
|
4629 | nextIt = nextIt._next;
|
4630 | if (record.previousIndex == null) {
|
4631 | addRemoveOffset++;
|
4632 | }
|
4633 | else {
|
4634 | // INVARIANT: currentIndex < previousIndex
|
4635 | if (!moveOffsets)
|
4636 | moveOffsets = [];
|
4637 | var /** @type {?} */ localMovePreviousIndex = adjPreviousIndex - addRemoveOffset;
|
4638 | var /** @type {?} */ localCurrentIndex = currentIndex - addRemoveOffset;
|
4639 | if (localMovePreviousIndex != localCurrentIndex) {
|
4640 | for (var /** @type {?} */ i = 0; i < localMovePreviousIndex; i++) {
|
4641 | var /** @type {?} */ offset = i < moveOffsets.length ? moveOffsets[i] : (moveOffsets[i] = 0);
|
4642 | var /** @type {?} */ index = offset + i;
|
4643 | if (localCurrentIndex <= index && index < localMovePreviousIndex) {
|
4644 | moveOffsets[i] = offset + 1;
|
4645 | }
|
4646 | }
|
4647 | var /** @type {?} */ previousIndex = record.previousIndex;
|
4648 | moveOffsets[previousIndex] = localCurrentIndex - localMovePreviousIndex;
|
4649 | }
|
4650 | }
|
4651 | }
|
4652 | if (adjPreviousIndex !== currentIndex) {
|
4653 | fn(record, adjPreviousIndex, currentIndex);
|
4654 | }
|
4655 | }
|
4656 | };
|
4657 | /**
|
4658 | * @param {?} fn
|
4659 | * @return {?}
|
4660 | */
|
4661 | DefaultIterableDiffer.prototype.forEachPreviousItem = function (fn) {
|
4662 | var /** @type {?} */ record;
|
4663 | for (record = this._previousItHead; record !== null; record = record._nextPrevious) {
|
4664 | fn(record);
|
4665 | }
|
4666 | };
|
4667 | /**
|
4668 | * @param {?} fn
|
4669 | * @return {?}
|
4670 | */
|
4671 | DefaultIterableDiffer.prototype.forEachAddedItem = function (fn) {
|
4672 | var /** @type {?} */ record;
|
4673 | for (record = this._additionsHead; record !== null; record = record._nextAdded) {
|
4674 | fn(record);
|
4675 | }
|
4676 | };
|
4677 | /**
|
4678 | * @param {?} fn
|
4679 | * @return {?}
|
4680 | */
|
4681 | DefaultIterableDiffer.prototype.forEachMovedItem = function (fn) {
|
4682 | var /** @type {?} */ record;
|
4683 | for (record = this._movesHead; record !== null; record = record._nextMoved) {
|
4684 | fn(record);
|
4685 | }
|
4686 | };
|
4687 | /**
|
4688 | * @param {?} fn
|
4689 | * @return {?}
|
4690 | */
|
4691 | DefaultIterableDiffer.prototype.forEachRemovedItem = function (fn) {
|
4692 | var /** @type {?} */ record;
|
4693 | for (record = this._removalsHead; record !== null; record = record._nextRemoved) {
|
4694 | fn(record);
|
4695 | }
|
4696 | };
|
4697 | /**
|
4698 | * @param {?} fn
|
4699 | * @return {?}
|
4700 | */
|
4701 | DefaultIterableDiffer.prototype.forEachIdentityChange = function (fn) {
|
4702 | var /** @type {?} */ record;
|
4703 | for (record = this._identityChangesHead; record !== null; record = record._nextIdentityChange) {
|
4704 | fn(record);
|
4705 | }
|
4706 | };
|
4707 | /**
|
4708 | * @param {?} collection
|
4709 | * @return {?}
|
4710 | */
|
4711 | DefaultIterableDiffer.prototype.diff = function (collection) {
|
4712 | if (isBlank(collection))
|
4713 | collection = [];
|
4714 | if (!isListLikeIterable(collection)) {
|
4715 | throw new Error("Error trying to diff '" + collection + "'");
|
4716 | }
|
4717 | if (this.check(collection)) {
|
4718 | return this;
|
4719 | }
|
4720 | else {
|
4721 | return null;
|
4722 | }
|
4723 | };
|
4724 | /**
|
4725 | * @return {?}
|
4726 | */
|
4727 | DefaultIterableDiffer.prototype.onDestroy = function () { };
|
4728 | /**
|
4729 | * @param {?} collection
|
4730 | * @return {?}
|
4731 | */
|
4732 | DefaultIterableDiffer.prototype.check = function (collection) {
|
4733 | var _this = this;
|
4734 | this._reset();
|
4735 | var /** @type {?} */ record = this._itHead;
|
4736 | var /** @type {?} */ mayBeDirty = false;
|
4737 | var /** @type {?} */ index;
|
4738 | var /** @type {?} */ item;
|
4739 | var /** @type {?} */ itemTrackBy;
|
4740 | if (Array.isArray(collection)) {
|
4741 | var /** @type {?} */ list = collection;
|
4742 | this._length = collection.length;
|
4743 | for (var /** @type {?} */ index_1 = 0; index_1 < this._length; index_1++) {
|
4744 | item = list[index_1];
|
4745 | itemTrackBy = this._trackByFn(index_1, item);
|
4746 | if (record === null || !looseIdentical(record.trackById, itemTrackBy)) {
|
4747 | record = this._mismatch(record, item, itemTrackBy, index_1);
|
4748 | mayBeDirty = true;
|
4749 | }
|
4750 | else {
|
4751 | if (mayBeDirty) {
|
4752 | // TODO(misko): can we limit this to duplicates only?
|
4753 | record = this._verifyReinsertion(record, item, itemTrackBy, index_1);
|
4754 | }
|
4755 | if (!looseIdentical(record.item, item))
|
4756 | this._addIdentityChange(record, item);
|
4757 | }
|
4758 | record = record._next;
|
4759 | }
|
4760 | }
|
4761 | else {
|
4762 | index = 0;
|
4763 | iterateListLike(collection, function (item /** TODO #9100 */) {
|
4764 | itemTrackBy = _this._trackByFn(index, item);
|
4765 | if (record === null || !looseIdentical(record.trackById, itemTrackBy)) {
|
4766 | record = _this._mismatch(record, item, itemTrackBy, index);
|
4767 | mayBeDirty = true;
|
4768 | }
|
4769 | else {
|
4770 | if (mayBeDirty) {
|
4771 | // TODO(misko): can we limit this to duplicates only?
|
4772 | record = _this._verifyReinsertion(record, item, itemTrackBy, index);
|
4773 | }
|
4774 | if (!looseIdentical(record.item, item))
|
4775 | _this._addIdentityChange(record, item);
|
4776 | }
|
4777 | record = record._next;
|
4778 | index++;
|
4779 | });
|
4780 | this._length = index;
|
4781 | }
|
4782 | this._truncate(record);
|
4783 | this._collection = collection;
|
4784 | return this.isDirty;
|
4785 | };
|
4786 | Object.defineProperty(DefaultIterableDiffer.prototype, "isDirty", {
|
4787 | /**
|
4788 | * @return {?}
|
4789 | */
|
4790 | get: function () {
|
4791 | return this._additionsHead !== null || this._movesHead !== null ||
|
4792 | this._removalsHead !== null || this._identityChangesHead !== null;
|
4793 | },
|
4794 | enumerable: true,
|
4795 | configurable: true
|
4796 | });
|
4797 | /**
|
4798 | * Reset the state of the change objects to show no changes. This means set previousKey to
|
4799 | * currentKey, and clear all of the queues (additions, moves, removals).
|
4800 | * Set the previousIndexes of moved and added items to their currentIndexes
|
4801 | * Reset the list of additions, moves and removals
|
4802 | * *
|
4803 | * @return {?}
|
4804 | */
|
4805 | DefaultIterableDiffer.prototype._reset = function () {
|
4806 | if (this.isDirty) {
|
4807 | var /** @type {?} */ record = void 0;
|
4808 | var /** @type {?} */ nextRecord = void 0;
|
4809 | for (record = this._previousItHead = this._itHead; record !== null; record = record._next) {
|
4810 | record._nextPrevious = record._next;
|
4811 | }
|
4812 | for (record = this._additionsHead; record !== null; record = record._nextAdded) {
|
4813 | record.previousIndex = record.currentIndex;
|
4814 | }
|
4815 | this._additionsHead = this._additionsTail = null;
|
4816 | for (record = this._movesHead; record !== null; record = nextRecord) {
|
4817 | record.previousIndex = record.currentIndex;
|
4818 | nextRecord = record._nextMoved;
|
4819 | }
|
4820 | this._movesHead = this._movesTail = null;
|
4821 | this._removalsHead = this._removalsTail = null;
|
4822 | this._identityChangesHead = this._identityChangesTail = null;
|
4823 | }
|
4824 | };
|
4825 | /**
|
4826 | * This is the core function which handles differences between collections.
|
4827 | * *
|
4828 | * - `record` is the record which we saw at this position last time. If null then it is a new
|
4829 | * item.
|
4830 | * - `item` is the current item in the collection
|
4831 | * - `index` is the position of the item in the collection
|
4832 | * *
|
4833 | * @param {?} record
|
4834 | * @param {?} item
|
4835 | * @param {?} itemTrackBy
|
4836 | * @param {?} index
|
4837 | * @return {?}
|
4838 | */
|
4839 | DefaultIterableDiffer.prototype._mismatch = function (record, item, itemTrackBy, index) {
|
4840 | // The previous record after which we will append the current one.
|
4841 | var /** @type {?} */ previousRecord;
|
4842 | if (record === null) {
|
4843 | previousRecord = this._itTail;
|
4844 | }
|
4845 | else {
|
4846 | previousRecord = record._prev;
|
4847 | // Remove the record from the collection since we know it does not match the item.
|
4848 | this._remove(record);
|
4849 | }
|
4850 | // Attempt to see if we have seen the item before.
|
4851 | record = this._linkedRecords === null ? null : this._linkedRecords.get(itemTrackBy, index);
|
4852 | if (record !== null) {
|
4853 | // We have seen this before, we need to move it forward in the collection.
|
4854 | // But first we need to check if identity changed, so we can update in view if necessary
|
4855 | if (!looseIdentical(record.item, item))
|
4856 | this._addIdentityChange(record, item);
|
4857 | this._moveAfter(record, previousRecord, index);
|
4858 | }
|
4859 | else {
|
4860 | // Never seen it, check evicted list.
|
4861 | record = this._unlinkedRecords === null ? null : this._unlinkedRecords.get(itemTrackBy);
|
4862 | if (record !== null) {
|
4863 | // It is an item which we have evicted earlier: reinsert it back into the list.
|
4864 | // But first we need to check if identity changed, so we can update in view if necessary
|
4865 | if (!looseIdentical(record.item, item))
|
4866 | this._addIdentityChange(record, item);
|
4867 | this._reinsertAfter(record, previousRecord, index);
|
4868 | }
|
4869 | else {
|
4870 | // It is a new item: add it.
|
4871 | record =
|
4872 | this._addAfter(new CollectionChangeRecord(item, itemTrackBy), previousRecord, index);
|
4873 | }
|
4874 | }
|
4875 | return record;
|
4876 | };
|
4877 | /**
|
4878 | * This check is only needed if an array contains duplicates. (Short circuit of nothing dirty)
|
4879 | * *
|
4880 | * Use case: `[a, a]` => `[b, a, a]`
|
4881 | * *
|
4882 | * If we did not have this check then the insertion of `b` would:
|
4883 | * 1) evict first `a`
|
4884 | * 2) insert `b` at `0` index.
|
4885 | * 3) leave `a` at index `1` as is. <-- this is wrong!
|
4886 | * 3) reinsert `a` at index 2. <-- this is wrong!
|
4887 | * *
|
4888 | * The correct behavior is:
|
4889 | * 1) evict first `a`
|
4890 | * 2) insert `b` at `0` index.
|
4891 | * 3) reinsert `a` at index 1.
|
4892 | * 3) move `a` at from `1` to `2`.
|
4893 | * *
|
4894 | * *
|
4895 | * Double check that we have not evicted a duplicate item. We need to check if the item type may
|
4896 | * have already been removed:
|
4897 | * The insertion of b will evict the first 'a'. If we don't reinsert it now it will be reinserted
|
4898 | * at the end. Which will show up as the two 'a's switching position. This is incorrect, since a
|
4899 | * better way to think of it is as insert of 'b' rather then switch 'a' with 'b' and then add 'a'
|
4900 | * at the end.
|
4901 | * *
|
4902 | * @param {?} record
|
4903 | * @param {?} item
|
4904 | * @param {?} itemTrackBy
|
4905 | * @param {?} index
|
4906 | * @return {?}
|
4907 | */
|
4908 | DefaultIterableDiffer.prototype._verifyReinsertion = function (record, item, itemTrackBy, index) {
|
4909 | var /** @type {?} */ reinsertRecord = this._unlinkedRecords === null ? null : this._unlinkedRecords.get(itemTrackBy);
|
4910 | if (reinsertRecord !== null) {
|
4911 | record = this._reinsertAfter(reinsertRecord, record._prev, index);
|
4912 | }
|
4913 | else if (record.currentIndex != index) {
|
4914 | record.currentIndex = index;
|
4915 | this._addToMoves(record, index);
|
4916 | }
|
4917 | return record;
|
4918 | };
|
4919 | /**
|
4920 | * Get rid of any excess {@link CollectionChangeRecord}s from the previous collection
|
4921 | * *
|
4922 | * - `record` The first excess {@link CollectionChangeRecord}.
|
4923 | * *
|
4924 | * @param {?} record
|
4925 | * @return {?}
|
4926 | */
|
4927 | DefaultIterableDiffer.prototype._truncate = function (record) {
|
4928 | // Anything after that needs to be removed;
|
4929 | while (record !== null) {
|
4930 | var /** @type {?} */ nextRecord = record._next;
|
4931 | this._addToRemovals(this._unlink(record));
|
4932 | record = nextRecord;
|
4933 | }
|
4934 | if (this._unlinkedRecords !== null) {
|
4935 | this._unlinkedRecords.clear();
|
4936 | }
|
4937 | if (this._additionsTail !== null) {
|
4938 | this._additionsTail._nextAdded = null;
|
4939 | }
|
4940 | if (this._movesTail !== null) {
|
4941 | this._movesTail._nextMoved = null;
|
4942 | }
|
4943 | if (this._itTail !== null) {
|
4944 | this._itTail._next = null;
|
4945 | }
|
4946 | if (this._removalsTail !== null) {
|
4947 | this._removalsTail._nextRemoved = null;
|
4948 | }
|
4949 | if (this._identityChangesTail !== null) {
|
4950 | this._identityChangesTail._nextIdentityChange = null;
|
4951 | }
|
4952 | };
|
4953 | /**
|
4954 | * @param {?} record
|
4955 | * @param {?} prevRecord
|
4956 | * @param {?} index
|
4957 | * @return {?}
|
4958 | */
|
4959 | DefaultIterableDiffer.prototype._reinsertAfter = function (record, prevRecord, index) {
|
4960 | if (this._unlinkedRecords !== null) {
|
4961 | this._unlinkedRecords.remove(record);
|
4962 | }
|
4963 | var /** @type {?} */ prev = record._prevRemoved;
|
4964 | var /** @type {?} */ next = record._nextRemoved;
|
4965 | if (prev === null) {
|
4966 | this._removalsHead = next;
|
4967 | }
|
4968 | else {
|
4969 | prev._nextRemoved = next;
|
4970 | }
|
4971 | if (next === null) {
|
4972 | this._removalsTail = prev;
|
4973 | }
|
4974 | else {
|
4975 | next._prevRemoved = prev;
|
4976 | }
|
4977 | this._insertAfter(record, prevRecord, index);
|
4978 | this._addToMoves(record, index);
|
4979 | return record;
|
4980 | };
|
4981 | /**
|
4982 | * @param {?} record
|
4983 | * @param {?} prevRecord
|
4984 | * @param {?} index
|
4985 | * @return {?}
|
4986 | */
|
4987 | DefaultIterableDiffer.prototype._moveAfter = function (record, prevRecord, index) {
|
4988 | this._unlink(record);
|
4989 | this._insertAfter(record, prevRecord, index);
|
4990 | this._addToMoves(record, index);
|
4991 | return record;
|
4992 | };
|
4993 | /**
|
4994 | * @param {?} record
|
4995 | * @param {?} prevRecord
|
4996 | * @param {?} index
|
4997 | * @return {?}
|
4998 | */
|
4999 | DefaultIterableDiffer.prototype._addAfter = function (record, prevRecord, index) {
|
5000 | this._insertAfter(record, prevRecord, index);
|
5001 | if (this._additionsTail === null) {
|
5002 | // todo(vicb)
|
5003 | // assert(this._additionsHead === null);
|
5004 | this._additionsTail = this._additionsHead = record;
|
5005 | }
|
5006 | else {
|
5007 | // todo(vicb)
|
5008 | // assert(_additionsTail._nextAdded === null);
|
5009 | // assert(record._nextAdded === null);
|
5010 | this._additionsTail = this._additionsTail._nextAdded = record;
|
5011 | }
|
5012 | return record;
|
5013 | };
|
5014 | /**
|
5015 | * @param {?} record
|
5016 | * @param {?} prevRecord
|
5017 | * @param {?} index
|
5018 | * @return {?}
|
5019 | */
|
5020 | DefaultIterableDiffer.prototype._insertAfter = function (record, prevRecord, index) {
|
5021 | // todo(vicb)
|
5022 | // assert(record != prevRecord);
|
5023 | // assert(record._next === null);
|
5024 | // assert(record._prev === null);
|
5025 | var /** @type {?} */ next = prevRecord === null ? this._itHead : prevRecord._next;
|
5026 | // todo(vicb)
|
5027 | // assert(next != record);
|
5028 | // assert(prevRecord != record);
|
5029 | record._next = next;
|
5030 | record._prev = prevRecord;
|
5031 | if (next === null) {
|
5032 | this._itTail = record;
|
5033 | }
|
5034 | else {
|
5035 | next._prev = record;
|
5036 | }
|
5037 | if (prevRecord === null) {
|
5038 | this._itHead = record;
|
5039 | }
|
5040 | else {
|
5041 | prevRecord._next = record;
|
5042 | }
|
5043 | if (this._linkedRecords === null) {
|
5044 | this._linkedRecords = new _DuplicateMap();
|
5045 | }
|
5046 | this._linkedRecords.put(record);
|
5047 | record.currentIndex = index;
|
5048 | return record;
|
5049 | };
|
5050 | /**
|
5051 | * @param {?} record
|
5052 | * @return {?}
|
5053 | */
|
5054 | DefaultIterableDiffer.prototype._remove = function (record) {
|
5055 | return this._addToRemovals(this._unlink(record));
|
5056 | };
|
5057 | /**
|
5058 | * @param {?} record
|
5059 | * @return {?}
|
5060 | */
|
5061 | DefaultIterableDiffer.prototype._unlink = function (record) {
|
5062 | if (this._linkedRecords !== null) {
|
5063 | this._linkedRecords.remove(record);
|
5064 | }
|
5065 | var /** @type {?} */ prev = record._prev;
|
5066 | var /** @type {?} */ next = record._next;
|
5067 | // todo(vicb)
|
5068 | // assert((record._prev = null) === null);
|
5069 | // assert((record._next = null) === null);
|
5070 | if (prev === null) {
|
5071 | this._itHead = next;
|
5072 | }
|
5073 | else {
|
5074 | prev._next = next;
|
5075 | }
|
5076 | if (next === null) {
|
5077 | this._itTail = prev;
|
5078 | }
|
5079 | else {
|
5080 | next._prev = prev;
|
5081 | }
|
5082 | return record;
|
5083 | };
|
5084 | /**
|
5085 | * @param {?} record
|
5086 | * @param {?} toIndex
|
5087 | * @return {?}
|
5088 | */
|
5089 | DefaultIterableDiffer.prototype._addToMoves = function (record, toIndex) {
|
5090 | // todo(vicb)
|
5091 | // assert(record._nextMoved === null);
|
5092 | if (record.previousIndex === toIndex) {
|
5093 | return record;
|
5094 | }
|
5095 | if (this._movesTail === null) {
|
5096 | // todo(vicb)
|
5097 | // assert(_movesHead === null);
|
5098 | this._movesTail = this._movesHead = record;
|
5099 | }
|
5100 | else {
|
5101 | // todo(vicb)
|
5102 | // assert(_movesTail._nextMoved === null);
|
5103 | this._movesTail = this._movesTail._nextMoved = record;
|
5104 | }
|
5105 | return record;
|
5106 | };
|
5107 | /**
|
5108 | * @param {?} record
|
5109 | * @return {?}
|
5110 | */
|
5111 | DefaultIterableDiffer.prototype._addToRemovals = function (record) {
|
5112 | if (this._unlinkedRecords === null) {
|
5113 | this._unlinkedRecords = new _DuplicateMap();
|
5114 | }
|
5115 | this._unlinkedRecords.put(record);
|
5116 | record.currentIndex = null;
|
5117 | record._nextRemoved = null;
|
5118 | if (this._removalsTail === null) {
|
5119 | // todo(vicb)
|
5120 | // assert(_removalsHead === null);
|
5121 | this._removalsTail = this._removalsHead = record;
|
5122 | record._prevRemoved = null;
|
5123 | }
|
5124 | else {
|
5125 | // todo(vicb)
|
5126 | // assert(_removalsTail._nextRemoved === null);
|
5127 | // assert(record._nextRemoved === null);
|
5128 | record._prevRemoved = this._removalsTail;
|
5129 | this._removalsTail = this._removalsTail._nextRemoved = record;
|
5130 | }
|
5131 | return record;
|
5132 | };
|
5133 | /**
|
5134 | * @param {?} record
|
5135 | * @param {?} item
|
5136 | * @return {?}
|
5137 | */
|
5138 | DefaultIterableDiffer.prototype._addIdentityChange = function (record, item) {
|
5139 | record.item = item;
|
5140 | if (this._identityChangesTail === null) {
|
5141 | this._identityChangesTail = this._identityChangesHead = record;
|
5142 | }
|
5143 | else {
|
5144 | this._identityChangesTail = this._identityChangesTail._nextIdentityChange = record;
|
5145 | }
|
5146 | return record;
|
5147 | };
|
5148 | /**
|
5149 | * @return {?}
|
5150 | */
|
5151 | DefaultIterableDiffer.prototype.toString = function () {
|
5152 | var /** @type {?} */ list = [];
|
5153 | this.forEachItem(function (record /** TODO #9100 */) { return list.push(record); });
|
5154 | var /** @type {?} */ previous = [];
|
5155 | this.forEachPreviousItem(function (record /** TODO #9100 */) { return previous.push(record); });
|
5156 | var /** @type {?} */ additions = [];
|
5157 | this.forEachAddedItem(function (record /** TODO #9100 */) { return additions.push(record); });
|
5158 | var /** @type {?} */ moves = [];
|
5159 | this.forEachMovedItem(function (record /** TODO #9100 */) { return moves.push(record); });
|
5160 | var /** @type {?} */ removals = [];
|
5161 | this.forEachRemovedItem(function (record /** TODO #9100 */) { return removals.push(record); });
|
5162 | var /** @type {?} */ identityChanges = [];
|
5163 | this.forEachIdentityChange(function (record /** TODO #9100 */) { return identityChanges.push(record); });
|
5164 | return 'collection: ' + list.join(', ') + '\n' +
|
5165 | 'previous: ' + previous.join(', ') + '\n' +
|
5166 | 'additions: ' + additions.join(', ') + '\n' +
|
5167 | 'moves: ' + moves.join(', ') + '\n' +
|
5168 | 'removals: ' + removals.join(', ') + '\n' +
|
5169 | 'identityChanges: ' + identityChanges.join(', ') + '\n';
|
5170 | };
|
5171 | return DefaultIterableDiffer;
|
5172 | }());
|
5173 | /**
|
5174 | * @stable
|
5175 | */
|
5176 | var CollectionChangeRecord = (function () {
|
5177 | /**
|
5178 | * @param {?} item
|
5179 | * @param {?} trackById
|
5180 | */
|
5181 | function CollectionChangeRecord(item, trackById) {
|
5182 | this.item = item;
|
5183 | this.trackById = trackById;
|
5184 | this.currentIndex = null;
|
5185 | this.previousIndex = null;
|
5186 | /** @internal */
|
5187 | this._nextPrevious = null;
|
5188 | /** @internal */
|
5189 | this._prev = null;
|
5190 | /** @internal */
|
5191 | this._next = null;
|
5192 | /** @internal */
|
5193 | this._prevDup = null;
|
5194 | /** @internal */
|
5195 | this._nextDup = null;
|
5196 | /** @internal */
|
5197 | this._prevRemoved = null;
|
5198 | /** @internal */
|
5199 | this._nextRemoved = null;
|
5200 | /** @internal */
|
5201 | this._nextAdded = null;
|
5202 | /** @internal */
|
5203 | this._nextMoved = null;
|
5204 | /** @internal */
|
5205 | this._nextIdentityChange = null;
|
5206 | }
|
5207 | /**
|
5208 | * @return {?}
|
5209 | */
|
5210 | CollectionChangeRecord.prototype.toString = function () {
|
5211 | return this.previousIndex === this.currentIndex ? stringify(this.item) :
|
5212 | stringify(this.item) + '[' +
|
5213 | stringify(this.previousIndex) + '->' + stringify(this.currentIndex) + ']';
|
5214 | };
|
5215 | return CollectionChangeRecord;
|
5216 | }());
|
5217 | // A linked list of CollectionChangeRecords with the same CollectionChangeRecord.item
|
5218 | var _DuplicateItemRecordList = (function () {
|
5219 | function _DuplicateItemRecordList() {
|
5220 | /** @internal */
|
5221 | this._head = null;
|
5222 | /** @internal */
|
5223 | this._tail = null;
|
5224 | }
|
5225 | /**
|
5226 | * Append the record to the list of duplicates.
|
5227 | * *
|
5228 | * Note: by design all records in the list of duplicates hold the same value in record.item.
|
5229 | * @param {?} record
|
5230 | * @return {?}
|
5231 | */
|
5232 | _DuplicateItemRecordList.prototype.add = function (record) {
|
5233 | if (this._head === null) {
|
5234 | this._head = this._tail = record;
|
5235 | record._nextDup = null;
|
5236 | record._prevDup = null;
|
5237 | }
|
5238 | else {
|
5239 | // todo(vicb)
|
5240 | // assert(record.item == _head.item ||
|
5241 | // record.item is num && record.item.isNaN && _head.item is num && _head.item.isNaN);
|
5242 | this._tail._nextDup = record;
|
5243 | record._prevDup = this._tail;
|
5244 | record._nextDup = null;
|
5245 | this._tail = record;
|
5246 | }
|
5247 | };
|
5248 | /**
|
5249 | * @param {?} trackById
|
5250 | * @param {?} afterIndex
|
5251 | * @return {?}
|
5252 | */
|
5253 | _DuplicateItemRecordList.prototype.get = function (trackById, afterIndex) {
|
5254 | var /** @type {?} */ record;
|
5255 | for (record = this._head; record !== null; record = record._nextDup) {
|
5256 | if ((afterIndex === null || afterIndex < record.currentIndex) &&
|
5257 | looseIdentical(record.trackById, trackById)) {
|
5258 | return record;
|
5259 | }
|
5260 | }
|
5261 | return null;
|
5262 | };
|
5263 | /**
|
5264 | * Remove one {@link CollectionChangeRecord} from the list of duplicates.
|
5265 | * *
|
5266 | * Returns whether the list of duplicates is empty.
|
5267 | * @param {?} record
|
5268 | * @return {?}
|
5269 | */
|
5270 | _DuplicateItemRecordList.prototype.remove = function (record) {
|
5271 | // todo(vicb)
|
5272 | // assert(() {
|
5273 | // // verify that the record being removed is in the list.
|
5274 | // for (CollectionChangeRecord cursor = _head; cursor != null; cursor = cursor._nextDup) {
|
5275 | // if (identical(cursor, record)) return true;
|
5276 | // }
|
5277 | // return false;
|
5278 | //});
|
5279 | var /** @type {?} */ prev = record._prevDup;
|
5280 | var /** @type {?} */ next = record._nextDup;
|
5281 | if (prev === null) {
|
5282 | this._head = next;
|
5283 | }
|
5284 | else {
|
5285 | prev._nextDup = next;
|
5286 | }
|
5287 | if (next === null) {
|
5288 | this._tail = prev;
|
5289 | }
|
5290 | else {
|
5291 | next._prevDup = prev;
|
5292 | }
|
5293 | return this._head === null;
|
5294 | };
|
5295 | return _DuplicateItemRecordList;
|
5296 | }());
|
5297 | var _DuplicateMap = (function () {
|
5298 | function _DuplicateMap() {
|
5299 | this.map = new Map();
|
5300 | }
|
5301 | /**
|
5302 | * @param {?} record
|
5303 | * @return {?}
|
5304 | */
|
5305 | _DuplicateMap.prototype.put = function (record) {
|
5306 | var /** @type {?} */ key = record.trackById;
|
5307 | var /** @type {?} */ duplicates = this.map.get(key);
|
5308 | if (!duplicates) {
|
5309 | duplicates = new _DuplicateItemRecordList();
|
5310 | this.map.set(key, duplicates);
|
5311 | }
|
5312 | duplicates.add(record);
|
5313 | };
|
5314 | /**
|
5315 | * Retrieve the `value` using key. Because the CollectionChangeRecord value may be one which we
|
5316 | * have already iterated over, we use the afterIndex to pretend it is not there.
|
5317 | * *
|
5318 | * Use case: `[a, b, c, a, a]` if we are at index `3` which is the second `a` then asking if we
|
5319 | * have any more `a`s needs to return the last `a` not the first or second.
|
5320 | * @param {?} trackById
|
5321 | * @param {?=} afterIndex
|
5322 | * @return {?}
|
5323 | */
|
5324 | _DuplicateMap.prototype.get = function (trackById, afterIndex) {
|
5325 | if (afterIndex === void 0) { afterIndex = null; }
|
5326 | var /** @type {?} */ key = trackById;
|
5327 | var /** @type {?} */ recordList = this.map.get(key);
|
5328 | return recordList ? recordList.get(trackById, afterIndex) : null;
|
5329 | };
|
5330 | /**
|
5331 | * Removes a {@link CollectionChangeRecord} from the list of duplicates.
|
5332 | * *
|
5333 | * The list of duplicates also is removed from the map if it gets empty.
|
5334 | * @param {?} record
|
5335 | * @return {?}
|
5336 | */
|
5337 | _DuplicateMap.prototype.remove = function (record) {
|
5338 | var /** @type {?} */ key = record.trackById;
|
5339 | var /** @type {?} */ recordList = this.map.get(key);
|
5340 | // Remove the list of duplicates when it gets empty
|
5341 | if (recordList.remove(record)) {
|
5342 | this.map.delete(key);
|
5343 | }
|
5344 | return record;
|
5345 | };
|
5346 | Object.defineProperty(_DuplicateMap.prototype, "isEmpty", {
|
5347 | /**
|
5348 | * @return {?}
|
5349 | */
|
5350 | get: function () { return this.map.size === 0; },
|
5351 | enumerable: true,
|
5352 | configurable: true
|
5353 | });
|
5354 | /**
|
5355 | * @return {?}
|
5356 | */
|
5357 | _DuplicateMap.prototype.clear = function () { this.map.clear(); };
|
5358 | /**
|
5359 | * @return {?}
|
5360 | */
|
5361 | _DuplicateMap.prototype.toString = function () { return '_DuplicateMap(' + stringify(this.map) + ')'; };
|
5362 | return _DuplicateMap;
|
5363 | }());
|
5364 | /**
|
5365 | * @param {?} item
|
5366 | * @param {?} addRemoveOffset
|
5367 | * @param {?} moveOffsets
|
5368 | * @return {?}
|
5369 | */
|
5370 | function getPreviousIndex(item, addRemoveOffset, moveOffsets) {
|
5371 | var /** @type {?} */ previousIndex = item.previousIndex;
|
5372 | if (previousIndex === null)
|
5373 | return previousIndex;
|
5374 | var /** @type {?} */ moveOffset = 0;
|
5375 | if (moveOffsets && previousIndex < moveOffsets.length) {
|
5376 | moveOffset = moveOffsets[previousIndex];
|
5377 | }
|
5378 | return previousIndex + addRemoveOffset + moveOffset;
|
5379 | }
|
5380 |
|
5381 | var DefaultKeyValueDifferFactory = (function () {
|
5382 | function DefaultKeyValueDifferFactory() {
|
5383 | }
|
5384 | /**
|
5385 | * @param {?} obj
|
5386 | * @return {?}
|
5387 | */
|
5388 | DefaultKeyValueDifferFactory.prototype.supports = function (obj) { return obj instanceof Map || isJsObject(obj); };
|
5389 | /**
|
5390 | * @param {?} cdRef
|
5391 | * @return {?}
|
5392 | */
|
5393 | DefaultKeyValueDifferFactory.prototype.create = function (cdRef) { return new DefaultKeyValueDiffer(); };
|
5394 | return DefaultKeyValueDifferFactory;
|
5395 | }());
|
5396 | var DefaultKeyValueDiffer = (function () {
|
5397 | function DefaultKeyValueDiffer() {
|
5398 | this._records = new Map();
|
5399 | this._mapHead = null;
|
5400 | this._previousMapHead = null;
|
5401 | this._changesHead = null;
|
5402 | this._changesTail = null;
|
5403 | this._additionsHead = null;
|
5404 | this._additionsTail = null;
|
5405 | this._removalsHead = null;
|
5406 | this._removalsTail = null;
|
5407 | }
|
5408 | Object.defineProperty(DefaultKeyValueDiffer.prototype, "isDirty", {
|
5409 | /**
|
5410 | * @return {?}
|
5411 | */
|
5412 | get: function () {
|
5413 | return this._additionsHead !== null || this._changesHead !== null ||
|
5414 | this._removalsHead !== null;
|
5415 | },
|
5416 | enumerable: true,
|
5417 | configurable: true
|
5418 | });
|
5419 | /**
|
5420 | * @param {?} fn
|
5421 | * @return {?}
|
5422 | */
|
5423 | DefaultKeyValueDiffer.prototype.forEachItem = function (fn) {
|
5424 | var /** @type {?} */ record;
|
5425 | for (record = this._mapHead; record !== null; record = record._next) {
|
5426 | fn(record);
|
5427 | }
|
5428 | };
|
5429 | /**
|
5430 | * @param {?} fn
|
5431 | * @return {?}
|
5432 | */
|
5433 | DefaultKeyValueDiffer.prototype.forEachPreviousItem = function (fn) {
|
5434 | var /** @type {?} */ record;
|
5435 | for (record = this._previousMapHead; record !== null; record = record._nextPrevious) {
|
5436 | fn(record);
|
5437 | }
|
5438 | };
|
5439 | /**
|
5440 | * @param {?} fn
|
5441 | * @return {?}
|
5442 | */
|
5443 | DefaultKeyValueDiffer.prototype.forEachChangedItem = function (fn) {
|
5444 | var /** @type {?} */ record;
|
5445 | for (record = this._changesHead; record !== null; record = record._nextChanged) {
|
5446 | fn(record);
|
5447 | }
|
5448 | };
|
5449 | /**
|
5450 | * @param {?} fn
|
5451 | * @return {?}
|
5452 | */
|
5453 | DefaultKeyValueDiffer.prototype.forEachAddedItem = function (fn) {
|
5454 | var /** @type {?} */ record;
|
5455 | for (record = this._additionsHead; record !== null; record = record._nextAdded) {
|
5456 | fn(record);
|
5457 | }
|
5458 | };
|
5459 | /**
|
5460 | * @param {?} fn
|
5461 | * @return {?}
|
5462 | */
|
5463 | DefaultKeyValueDiffer.prototype.forEachRemovedItem = function (fn) {
|
5464 | var /** @type {?} */ record;
|
5465 | for (record = this._removalsHead; record !== null; record = record._nextRemoved) {
|
5466 | fn(record);
|
5467 | }
|
5468 | };
|
5469 | /**
|
5470 | * @param {?} map
|
5471 | * @return {?}
|
5472 | */
|
5473 | DefaultKeyValueDiffer.prototype.diff = function (map) {
|
5474 | if (!map) {
|
5475 | map = new Map();
|
5476 | }
|
5477 | else if (!(map instanceof Map || isJsObject(map))) {
|
5478 | throw new Error("Error trying to diff '" + map + "'");
|
5479 | }
|
5480 | return this.check(map) ? this : null;
|
5481 | };
|
5482 | /**
|
5483 | * @return {?}
|
5484 | */
|
5485 | DefaultKeyValueDiffer.prototype.onDestroy = function () { };
|
5486 | /**
|
5487 | * @param {?} map
|
5488 | * @return {?}
|
5489 | */
|
5490 | DefaultKeyValueDiffer.prototype.check = function (map) {
|
5491 | var _this = this;
|
5492 | this._reset();
|
5493 | var /** @type {?} */ records = this._records;
|
5494 | var /** @type {?} */ oldSeqRecord = this._mapHead;
|
5495 | var /** @type {?} */ lastOldSeqRecord = null;
|
5496 | var /** @type {?} */ lastNewSeqRecord = null;
|
5497 | var /** @type {?} */ seqChanged = false;
|
5498 | this._forEach(map, function (value, key) {
|
5499 | var /** @type {?} */ newSeqRecord;
|
5500 | if (oldSeqRecord && key === oldSeqRecord.key) {
|
5501 | newSeqRecord = oldSeqRecord;
|
5502 | _this._maybeAddToChanges(newSeqRecord, value);
|
5503 | }
|
5504 | else {
|
5505 | seqChanged = true;
|
5506 | if (oldSeqRecord !== null) {
|
5507 | _this._removeFromSeq(lastOldSeqRecord, oldSeqRecord);
|
5508 | _this._addToRemovals(oldSeqRecord);
|
5509 | }
|
5510 | if (records.has(key)) {
|
5511 | newSeqRecord = records.get(key);
|
5512 | _this._maybeAddToChanges(newSeqRecord, value);
|
5513 | }
|
5514 | else {
|
5515 | newSeqRecord = new KeyValueChangeRecord(key);
|
5516 | records.set(key, newSeqRecord);
|
5517 | newSeqRecord.currentValue = value;
|
5518 | _this._addToAdditions(newSeqRecord);
|
5519 | }
|
5520 | }
|
5521 | if (seqChanged) {
|
5522 | if (_this._isInRemovals(newSeqRecord)) {
|
5523 | _this._removeFromRemovals(newSeqRecord);
|
5524 | }
|
5525 | if (lastNewSeqRecord == null) {
|
5526 | _this._mapHead = newSeqRecord;
|
5527 | }
|
5528 | else {
|
5529 | lastNewSeqRecord._next = newSeqRecord;
|
5530 | }
|
5531 | }
|
5532 | lastOldSeqRecord = oldSeqRecord;
|
5533 | lastNewSeqRecord = newSeqRecord;
|
5534 | oldSeqRecord = oldSeqRecord && oldSeqRecord._next;
|
5535 | });
|
5536 | this._truncate(lastOldSeqRecord, oldSeqRecord);
|
5537 | return this.isDirty;
|
5538 | };
|
5539 | /**
|
5540 | * @return {?}
|
5541 | */
|
5542 | DefaultKeyValueDiffer.prototype._reset = function () {
|
5543 | if (this.isDirty) {
|
5544 | var /** @type {?} */ record = void 0;
|
5545 | // Record the state of the mapping
|
5546 | for (record = this._previousMapHead = this._mapHead; record !== null; record = record._next) {
|
5547 | record._nextPrevious = record._next;
|
5548 | }
|
5549 | for (record = this._changesHead; record !== null; record = record._nextChanged) {
|
5550 | record.previousValue = record.currentValue;
|
5551 | }
|
5552 | for (record = this._additionsHead; record != null; record = record._nextAdded) {
|
5553 | record.previousValue = record.currentValue;
|
5554 | }
|
5555 | this._changesHead = this._changesTail = null;
|
5556 | this._additionsHead = this._additionsTail = null;
|
5557 | this._removalsHead = this._removalsTail = null;
|
5558 | }
|
5559 | };
|
5560 | /**
|
5561 | * @param {?} lastRecord
|
5562 | * @param {?} record
|
5563 | * @return {?}
|
5564 | */
|
5565 | DefaultKeyValueDiffer.prototype._truncate = function (lastRecord, record) {
|
5566 | while (record !== null) {
|
5567 | if (lastRecord === null) {
|
5568 | this._mapHead = null;
|
5569 | }
|
5570 | else {
|
5571 | lastRecord._next = null;
|
5572 | }
|
5573 | var /** @type {?} */ nextRecord = record._next;
|
5574 | this._addToRemovals(record);
|
5575 | lastRecord = record;
|
5576 | record = nextRecord;
|
5577 | }
|
5578 | for (var /** @type {?} */ rec = this._removalsHead; rec !== null; rec = rec._nextRemoved) {
|
5579 | rec.previousValue = rec.currentValue;
|
5580 | rec.currentValue = null;
|
5581 | this._records.delete(rec.key);
|
5582 | }
|
5583 | };
|
5584 | /**
|
5585 | * @param {?} record
|
5586 | * @param {?} newValue
|
5587 | * @return {?}
|
5588 | */
|
5589 | DefaultKeyValueDiffer.prototype._maybeAddToChanges = function (record, newValue) {
|
5590 | if (!looseIdentical(newValue, record.currentValue)) {
|
5591 | record.previousValue = record.currentValue;
|
5592 | record.currentValue = newValue;
|
5593 | this._addToChanges(record);
|
5594 | }
|
5595 | };
|
5596 | /**
|
5597 | * @param {?} record
|
5598 | * @return {?}
|
5599 | */
|
5600 | DefaultKeyValueDiffer.prototype._isInRemovals = function (record) {
|
5601 | return record === this._removalsHead || record._nextRemoved !== null ||
|
5602 | record._prevRemoved !== null;
|
5603 | };
|
5604 | /**
|
5605 | * @param {?} record
|
5606 | * @return {?}
|
5607 | */
|
5608 | DefaultKeyValueDiffer.prototype._addToRemovals = function (record) {
|
5609 | if (this._removalsHead === null) {
|
5610 | this._removalsHead = this._removalsTail = record;
|
5611 | }
|
5612 | else {
|
5613 | this._removalsTail._nextRemoved = record;
|
5614 | record._prevRemoved = this._removalsTail;
|
5615 | this._removalsTail = record;
|
5616 | }
|
5617 | };
|
5618 | /**
|
5619 | * @param {?} prev
|
5620 | * @param {?} record
|
5621 | * @return {?}
|
5622 | */
|
5623 | DefaultKeyValueDiffer.prototype._removeFromSeq = function (prev, record) {
|
5624 | var /** @type {?} */ next = record._next;
|
5625 | if (prev === null) {
|
5626 | this._mapHead = next;
|
5627 | }
|
5628 | else {
|
5629 | prev._next = next;
|
5630 | }
|
5631 | record._next = null;
|
5632 | };
|
5633 | /**
|
5634 | * @param {?} record
|
5635 | * @return {?}
|
5636 | */
|
5637 | DefaultKeyValueDiffer.prototype._removeFromRemovals = function (record) {
|
5638 | var /** @type {?} */ prev = record._prevRemoved;
|
5639 | var /** @type {?} */ next = record._nextRemoved;
|
5640 | if (prev === null) {
|
5641 | this._removalsHead = next;
|
5642 | }
|
5643 | else {
|
5644 | prev._nextRemoved = next;
|
5645 | }
|
5646 | if (next === null) {
|
5647 | this._removalsTail = prev;
|
5648 | }
|
5649 | else {
|
5650 | next._prevRemoved = prev;
|
5651 | }
|
5652 | record._prevRemoved = record._nextRemoved = null;
|
5653 | };
|
5654 | /**
|
5655 | * @param {?} record
|
5656 | * @return {?}
|
5657 | */
|
5658 | DefaultKeyValueDiffer.prototype._addToAdditions = function (record) {
|
5659 | if (this._additionsHead === null) {
|
5660 | this._additionsHead = this._additionsTail = record;
|
5661 | }
|
5662 | else {
|
5663 | this._additionsTail._nextAdded = record;
|
5664 | this._additionsTail = record;
|
5665 | }
|
5666 | };
|
5667 | /**
|
5668 | * @param {?} record
|
5669 | * @return {?}
|
5670 | */
|
5671 | DefaultKeyValueDiffer.prototype._addToChanges = function (record) {
|
5672 | if (this._changesHead === null) {
|
5673 | this._changesHead = this._changesTail = record;
|
5674 | }
|
5675 | else {
|
5676 | this._changesTail._nextChanged = record;
|
5677 | this._changesTail = record;
|
5678 | }
|
5679 | };
|
5680 | /**
|
5681 | * @return {?}
|
5682 | */
|
5683 | DefaultKeyValueDiffer.prototype.toString = function () {
|
5684 | var /** @type {?} */ items = [];
|
5685 | var /** @type {?} */ previous = [];
|
5686 | var /** @type {?} */ changes = [];
|
5687 | var /** @type {?} */ additions = [];
|
5688 | var /** @type {?} */ removals = [];
|
5689 | var /** @type {?} */ record;
|
5690 | for (record = this._mapHead; record !== null; record = record._next) {
|
5691 | items.push(stringify(record));
|
5692 | }
|
5693 | for (record = this._previousMapHead; record !== null; record = record._nextPrevious) {
|
5694 | previous.push(stringify(record));
|
5695 | }
|
5696 | for (record = this._changesHead; record !== null; record = record._nextChanged) {
|
5697 | changes.push(stringify(record));
|
5698 | }
|
5699 | for (record = this._additionsHead; record !== null; record = record._nextAdded) {
|
5700 | additions.push(stringify(record));
|
5701 | }
|
5702 | for (record = this._removalsHead; record !== null; record = record._nextRemoved) {
|
5703 | removals.push(stringify(record));
|
5704 | }
|
5705 | return 'map: ' + items.join(', ') + '\n' +
|
5706 | 'previous: ' + previous.join(', ') + '\n' +
|
5707 | 'additions: ' + additions.join(', ') + '\n' +
|
5708 | 'changes: ' + changes.join(', ') + '\n' +
|
5709 | 'removals: ' + removals.join(', ') + '\n';
|
5710 | };
|
5711 | /**
|
5712 | * @param {?} obj
|
5713 | * @param {?} fn
|
5714 | * @return {?}
|
5715 | */
|
5716 | DefaultKeyValueDiffer.prototype._forEach = function (obj, fn) {
|
5717 | if (obj instanceof Map) {
|
5718 | obj.forEach(fn);
|
5719 | }
|
5720 | else {
|
5721 | Object.keys(obj).forEach(function (k) { return fn(obj[k], k); });
|
5722 | }
|
5723 | };
|
5724 | return DefaultKeyValueDiffer;
|
5725 | }());
|
5726 | /**
|
5727 | * @stable
|
5728 | */
|
5729 | var KeyValueChangeRecord = (function () {
|
5730 | /**
|
5731 | * @param {?} key
|
5732 | */
|
5733 | function KeyValueChangeRecord(key) {
|
5734 | this.key = key;
|
5735 | this.previousValue = null;
|
5736 | this.currentValue = null;
|
5737 | /** @internal */
|
5738 | this._nextPrevious = null;
|
5739 | /** @internal */
|
5740 | this._next = null;
|
5741 | /** @internal */
|
5742 | this._nextAdded = null;
|
5743 | /** @internal */
|
5744 | this._nextRemoved = null;
|
5745 | /** @internal */
|
5746 | this._prevRemoved = null;
|
5747 | /** @internal */
|
5748 | this._nextChanged = null;
|
5749 | }
|
5750 | /**
|
5751 | * @return {?}
|
5752 | */
|
5753 | KeyValueChangeRecord.prototype.toString = function () {
|
5754 | return looseIdentical(this.previousValue, this.currentValue) ?
|
5755 | stringify(this.key) :
|
5756 | (stringify(this.key) + '[' + stringify(this.previousValue) + '->' +
|
5757 | stringify(this.currentValue) + ']');
|
5758 | };
|
5759 | return KeyValueChangeRecord;
|
5760 | }());
|
5761 |
|
5762 | /**
|
5763 | * A repository of different iterable diffing strategies used by NgFor, NgClass, and others.
|
5764 | */
|
5765 | var IterableDiffers = (function () {
|
5766 | /**
|
5767 | * @param {?} factories
|
5768 | */
|
5769 | function IterableDiffers(factories) {
|
5770 | this.factories = factories;
|
5771 | }
|
5772 | /**
|
5773 | * @param {?} factories
|
5774 | * @param {?=} parent
|
5775 | * @return {?}
|
5776 | */
|
5777 | IterableDiffers.create = function (factories, parent) {
|
5778 | if (isPresent(parent)) {
|
5779 | var /** @type {?} */ copied = parent.factories.slice();
|
5780 | factories = factories.concat(copied);
|
5781 | return new IterableDiffers(factories);
|
5782 | }
|
5783 | else {
|
5784 | return new IterableDiffers(factories);
|
5785 | }
|
5786 | };
|
5787 | /**
|
5788 | * Takes an array of {@link IterableDifferFactory} and returns a provider used to extend the
|
5789 | * inherited {@link IterableDiffers} instance with the provided factories and return a new
|
5790 | * {@link IterableDiffers} instance.
|
5791 | * *
|
5792 | * The following example shows how to extend an existing list of factories,
|
5793 | * which will only be applied to the injector for this component and its children.
|
5794 | * This step is all that's required to make a new {@link IterableDiffer} available.
|
5795 | * *
|
5796 | * ### Example
|
5797 | * *
|
5798 | * ```
|
5799 | * viewProviders: [
|
5800 | * IterableDiffers.extend([new ImmutableListDiffer()])
|
5801 | * ]
|
5802 | * })
|
5803 | * ```
|
5804 | * @param {?} factories
|
5805 | * @return {?}
|
5806 | */
|
5807 | IterableDiffers.extend = function (factories) {
|
5808 | return {
|
5809 | provide: IterableDiffers,
|
5810 | useFactory: function (parent) {
|
5811 | if (!parent) {
|
5812 | // Typically would occur when calling IterableDiffers.extend inside of dependencies passed
|
5813 | // to
|
5814 | // bootstrap(), which would override default pipes instead of extending them.
|
5815 | throw new Error('Cannot extend IterableDiffers without a parent injector');
|
5816 | }
|
5817 | return IterableDiffers.create(factories, parent);
|
5818 | },
|
5819 | // Dependency technically isn't optional, but we can provide a better error message this way.
|
5820 | deps: [[IterableDiffers, new SkipSelf(), new Optional()]]
|
5821 | };
|
5822 | };
|
5823 | /**
|
5824 | * @param {?} iterable
|
5825 | * @return {?}
|
5826 | */
|
5827 | IterableDiffers.prototype.find = function (iterable) {
|
5828 | var /** @type {?} */ factory = this.factories.find(function (f) { return f.supports(iterable); });
|
5829 | if (isPresent(factory)) {
|
5830 | return factory;
|
5831 | }
|
5832 | else {
|
5833 | throw new Error("Cannot find a differ supporting object '" + iterable + "' of type '" + getTypeNameForDebugging(iterable) + "'");
|
5834 | }
|
5835 | };
|
5836 | return IterableDiffers;
|
5837 | }());
|
5838 |
|
5839 | /**
|
5840 | * A repository of different Map diffing strategies used by NgClass, NgStyle, and others.
|
5841 | */
|
5842 | var KeyValueDiffers = (function () {
|
5843 | /**
|
5844 | * @param {?} factories
|
5845 | */
|
5846 | function KeyValueDiffers(factories) {
|
5847 | this.factories = factories;
|
5848 | }
|
5849 | /**
|
5850 | * @param {?} factories
|
5851 | * @param {?=} parent
|
5852 | * @return {?}
|
5853 | */
|
5854 | KeyValueDiffers.create = function (factories, parent) {
|
5855 | if (isPresent(parent)) {
|
5856 | var /** @type {?} */ copied = parent.factories.slice();
|
5857 | factories = factories.concat(copied);
|
5858 | return new KeyValueDiffers(factories);
|
5859 | }
|
5860 | else {
|
5861 | return new KeyValueDiffers(factories);
|
5862 | }
|
5863 | };
|
5864 | /**
|
5865 | * Takes an array of {@link KeyValueDifferFactory} and returns a provider used to extend the
|
5866 | * inherited {@link KeyValueDiffers} instance with the provided factories and return a new
|
5867 | * {@link KeyValueDiffers} instance.
|
5868 | * *
|
5869 | * The following example shows how to extend an existing list of factories,
|
5870 | * which will only be applied to the injector for this component and its children.
|
5871 | * This step is all that's required to make a new {@link KeyValueDiffer} available.
|
5872 | * *
|
5873 | * ### Example
|
5874 | * *
|
5875 | * ```
|
5876 | * viewProviders: [
|
5877 | * KeyValueDiffers.extend([new ImmutableMapDiffer()])
|
5878 | * ]
|
5879 | * })
|
5880 | * ```
|
5881 | * @param {?} factories
|
5882 | * @return {?}
|
5883 | */
|
5884 | KeyValueDiffers.extend = function (factories) {
|
5885 | return {
|
5886 | provide: KeyValueDiffers,
|
5887 | useFactory: function (parent) {
|
5888 | if (!parent) {
|
5889 | // Typically would occur when calling KeyValueDiffers.extend inside of dependencies passed
|
5890 | // to
|
5891 | // bootstrap(), which would override default pipes instead of extending them.
|
5892 | throw new Error('Cannot extend KeyValueDiffers without a parent injector');
|
5893 | }
|
5894 | return KeyValueDiffers.create(factories, parent);
|
5895 | },
|
5896 | // Dependency technically isn't optional, but we can provide a better error message this way.
|
5897 | deps: [[KeyValueDiffers, new SkipSelf(), new Optional()]]
|
5898 | };
|
5899 | };
|
5900 | /**
|
5901 | * @param {?} kv
|
5902 | * @return {?}
|
5903 | */
|
5904 | KeyValueDiffers.prototype.find = function (kv) {
|
5905 | var /** @type {?} */ factory = this.factories.find(function (f) { return f.supports(kv); });
|
5906 | if (isPresent(factory)) {
|
5907 | return factory;
|
5908 | }
|
5909 | else {
|
5910 | throw new Error("Cannot find a differ supporting object '" + kv + "'");
|
5911 | }
|
5912 | };
|
5913 | return KeyValueDiffers;
|
5914 | }());
|
5915 |
|
5916 | var /** @type {?} */ UNINITIALIZED = {
|
5917 | toString: function () { return 'CD_INIT_VALUE'; }
|
5918 | };
|
5919 | /**
|
5920 | * @param {?} a
|
5921 | * @param {?} b
|
5922 | * @return {?}
|
5923 | */
|
5924 | function devModeEqual(a, b) {
|
5925 | if (isListLikeIterable(a) && isListLikeIterable(b)) {
|
5926 | return areIterablesEqual(a, b, devModeEqual);
|
5927 | }
|
5928 | else if (!isListLikeIterable(a) && !isPrimitive(a) && !isListLikeIterable(b) && !isPrimitive(b)) {
|
5929 | return true;
|
5930 | }
|
5931 | else {
|
5932 | return looseIdentical(a, b);
|
5933 | }
|
5934 | }
|
5935 | /**
|
5936 | * Indicates that the result of a {@link Pipe} transformation has changed even though the
|
5937 | * reference
|
5938 | * has not changed.
|
5939 | * *
|
5940 | * The wrapped value will be unwrapped by change detection, and the unwrapped value will be stored.
|
5941 | * *
|
5942 | * Example:
|
5943 | * *
|
5944 | * ```
|
5945 | * if (this._latestValue === this._latestReturnedValue) {
|
5946 | * return this._latestReturnedValue;
|
5947 | * } else {
|
5948 | * this._latestReturnedValue = this._latestValue;
|
5949 | * return WrappedValue.wrap(this._latestValue); // this will force update
|
5950 | * }
|
5951 | * ```
|
5952 | */
|
5953 | var WrappedValue = (function () {
|
5954 | /**
|
5955 | * @param {?} wrapped
|
5956 | */
|
5957 | function WrappedValue(wrapped) {
|
5958 | this.wrapped = wrapped;
|
5959 | }
|
5960 | /**
|
5961 | * @param {?} value
|
5962 | * @return {?}
|
5963 | */
|
5964 | WrappedValue.wrap = function (value) { return new WrappedValue(value); };
|
5965 | return WrappedValue;
|
5966 | }());
|
5967 | /**
|
5968 | * Helper class for unwrapping WrappedValue s
|
5969 | */
|
5970 | var ValueUnwrapper = (function () {
|
5971 | function ValueUnwrapper() {
|
5972 | this.hasWrappedValue = false;
|
5973 | }
|
5974 | /**
|
5975 | * @param {?} value
|
5976 | * @return {?}
|
5977 | */
|
5978 | ValueUnwrapper.prototype.unwrap = function (value) {
|
5979 | if (value instanceof WrappedValue) {
|
5980 | this.hasWrappedValue = true;
|
5981 | return value.wrapped;
|
5982 | }
|
5983 | return value;
|
5984 | };
|
5985 | /**
|
5986 | * @return {?}
|
5987 | */
|
5988 | ValueUnwrapper.prototype.reset = function () { this.hasWrappedValue = false; };
|
5989 | return ValueUnwrapper;
|
5990 | }());
|
5991 | /**
|
5992 | * Represents a basic change from a previous to a new value.
|
5993 | */
|
5994 | var SimpleChange = (function () {
|
5995 | /**
|
5996 | * @param {?} previousValue
|
5997 | * @param {?} currentValue
|
5998 | */
|
5999 | function SimpleChange(previousValue, currentValue) {
|
6000 | this.previousValue = previousValue;
|
6001 | this.currentValue = currentValue;
|
6002 | }
|
6003 | /**
|
6004 | * Check whether the new value is the first value assigned.
|
6005 | * @return {?}
|
6006 | */
|
6007 | SimpleChange.prototype.isFirstChange = function () { return this.previousValue === UNINITIALIZED; };
|
6008 | return SimpleChange;
|
6009 | }());
|
6010 |
|
6011 | /**
|
6012 | * @abstract
|
6013 | */
|
6014 | var ChangeDetectorRef = (function () {
|
6015 | function ChangeDetectorRef() {
|
6016 | }
|
6017 | /**
|
6018 | * Marks all {@link ChangeDetectionStrategy#OnPush} ancestors as to be checked.
|
6019 | * *
|
6020 | * <!-- TODO: Add a link to a chapter on OnPush components -->
|
6021 | * *
|
6022 | * ### Example ([live demo](http://plnkr.co/edit/GC512b?p=preview))
|
6023 | * *
|
6024 | * ```typescript
|
6025 | * selector: 'cmp',
|
6026 | * changeDetection: ChangeDetectionStrategy.OnPush,
|
6027 | * template: `Number of ticks: {{numberOfTicks}}`
|
6028 | * })
|
6029 | * class Cmp {
|
6030 | * numberOfTicks = 0;
|
6031 | * *
|
6032 | * constructor(ref: ChangeDetectorRef) {
|
6033 | * setInterval(() => {
|
6034 | * this.numberOfTicks ++
|
6035 | * // the following is required, otherwise the view will not be updated
|
6036 | * this.ref.markForCheck();
|
6037 | * }, 1000);
|
6038 | * }
|
6039 | * }
|
6040 | * *
|
6041 | * selector: 'app',
|
6042 | * changeDetection: ChangeDetectionStrategy.OnPush,
|
6043 | * template: `
|
6044 | * <cmp><cmp>
|
6045 | * `,
|
6046 | * })
|
6047 | * class App {
|
6048 | * }
|
6049 | * ```
|
6050 | * @abstract
|
6051 | * @return {?}
|
6052 | */
|
6053 | ChangeDetectorRef.prototype.markForCheck = function () { };
|
6054 | /**
|
6055 | * Detaches the change detector from the change detector tree.
|
6056 | * *
|
6057 | * The detached change detector will not be checked until it is reattached.
|
6058 | * *
|
6059 | * This can also be used in combination with {@link ChangeDetectorRef#detectChanges} to implement
|
6060 | * local change
|
6061 | * detection checks.
|
6062 | * *
|
6063 | * <!-- TODO: Add a link to a chapter on detach/reattach/local digest -->
|
6064 | * <!-- TODO: Add a live demo once ref.detectChanges is merged into master -->
|
6065 | * *
|
6066 | * ### Example
|
6067 | * *
|
6068 | * The following example defines a component with a large list of readonly data.
|
6069 | * Imagine the data changes constantly, many times per second. For performance reasons,
|
6070 | * we want to check and update the list every five seconds. We can do that by detaching
|
6071 | * the component's change detector and doing a local check every five seconds.
|
6072 | * *
|
6073 | * ```typescript
|
6074 | * class DataProvider {
|
6075 | * // in a real application the returned data will be different every time
|
6076 | * get data() {
|
6077 | * return [1,2,3,4,5];
|
6078 | * }
|
6079 | * }
|
6080 | * *
|
6081 | * selector: 'giant-list',
|
6082 | * template: `
|
6083 | * <li *ngFor="let d of dataProvider.data">Data {{d}}</lig>
|
6084 | * `,
|
6085 | * })
|
6086 | * class GiantList {
|
6087 | * constructor(private ref: ChangeDetectorRef, private dataProvider:DataProvider) {
|
6088 | * ref.detach();
|
6089 | * setInterval(() => {
|
6090 | * this.ref.detectChanges();
|
6091 | * }, 5000);
|
6092 | * }
|
6093 | * }
|
6094 | * *
|
6095 | * selector: 'app',
|
6096 | * providers: [DataProvider],
|
6097 | * template: `
|
6098 | * <giant-list><giant-list>
|
6099 | * `,
|
6100 | * })
|
6101 | * class App {
|
6102 | * }
|
6103 | * ```
|
6104 | * @abstract
|
6105 | * @return {?}
|
6106 | */
|
6107 | ChangeDetectorRef.prototype.detach = function () { };
|
6108 | /**
|
6109 | * Checks the change detector and its children.
|
6110 | * *
|
6111 | * This can also be used in combination with {@link ChangeDetectorRef#detach} to implement local
|
6112 | * change detection
|
6113 | * checks.
|
6114 | * *
|
6115 | * <!-- TODO: Add a link to a chapter on detach/reattach/local digest -->
|
6116 | * <!-- TODO: Add a live demo once ref.detectChanges is merged into master -->
|
6117 | * *
|
6118 | * ### Example
|
6119 | * *
|
6120 | * The following example defines a component with a large list of readonly data.
|
6121 | * Imagine, the data changes constantly, many times per second. For performance reasons,
|
6122 | * we want to check and update the list every five seconds.
|
6123 | * *
|
6124 | * We can do that by detaching the component's change detector and doing a local change detection
|
6125 | * check
|
6126 | * every five seconds.
|
6127 | * *
|
6128 | * See {@link ChangeDetectorRef#detach} for more information.
|
6129 | * @abstract
|
6130 | * @return {?}
|
6131 | */
|
6132 | ChangeDetectorRef.prototype.detectChanges = function () { };
|
6133 | /**
|
6134 | * Checks the change detector and its children, and throws if any changes are detected.
|
6135 | * *
|
6136 | * This is used in development mode to verify that running change detection doesn't introduce
|
6137 | * other changes.
|
6138 | * @abstract
|
6139 | * @return {?}
|
6140 | */
|
6141 | ChangeDetectorRef.prototype.checkNoChanges = function () { };
|
6142 | /**
|
6143 | * Reattach the change detector to the change detector tree.
|
6144 | * *
|
6145 | * This also marks OnPush ancestors as to be checked. This reattached change detector will be
|
6146 | * checked during the next change detection run.
|
6147 | * *
|
6148 | * <!-- TODO: Add a link to a chapter on detach/reattach/local digest -->
|
6149 | * *
|
6150 | * ### Example ([live demo](http://plnkr.co/edit/aUhZha?p=preview))
|
6151 | * *
|
6152 | * The following example creates a component displaying `live` data. The component will detach
|
6153 | * its change detector from the main change detector tree when the component's live property
|
6154 | * is set to false.
|
6155 | * *
|
6156 | * ```typescript
|
6157 | * class DataProvider {
|
6158 | * data = 1;
|
6159 | * *
|
6160 | * constructor() {
|
6161 | * setInterval(() => {
|
6162 | * this.data = this.data * 2;
|
6163 | * }, 500);
|
6164 | * }
|
6165 | * }
|
6166 | * *
|
6167 | * selector: 'live-data',
|
6168 | * inputs: ['live'],
|
6169 | * template: 'Data: {{dataProvider.data}}'
|
6170 | * })
|
6171 | * class LiveData {
|
6172 | * constructor(private ref: ChangeDetectorRef, private dataProvider:DataProvider) {}
|
6173 | * *
|
6174 | * set live(value) {
|
6175 | * if (value)
|
6176 | * this.ref.reattach();
|
6177 | * else
|
6178 | * this.ref.detach();
|
6179 | * }
|
6180 | * }
|
6181 | * *
|
6182 | * selector: 'app',
|
6183 | * providers: [DataProvider],
|
6184 | * template: `
|
6185 | * Live Update: <input type="checkbox" [(ngModel)]="live">
|
6186 | * <live-data [live]="live"><live-data>
|
6187 | * `,
|
6188 | * })
|
6189 | * class App {
|
6190 | * live = true;
|
6191 | * }
|
6192 | * ```
|
6193 | * @abstract
|
6194 | * @return {?}
|
6195 | */
|
6196 | ChangeDetectorRef.prototype.reattach = function () { };
|
6197 | return ChangeDetectorRef;
|
6198 | }());
|
6199 |
|
6200 | /**
|
6201 | * Structural diffing for `Object`s and `Map`s.
|
6202 | */
|
6203 | var /** @type {?} */ keyValDiff = [new DefaultKeyValueDifferFactory()];
|
6204 | /**
|
6205 | * Structural diffing for `Iterable` types such as `Array`s.
|
6206 | */
|
6207 | var /** @type {?} */ iterableDiff = [new DefaultIterableDifferFactory()];
|
6208 | var /** @type {?} */ defaultIterableDiffers = new IterableDiffers(iterableDiff);
|
6209 | var /** @type {?} */ defaultKeyValueDiffers = new KeyValueDiffers(keyValDiff);
|
6210 |
|
6211 | /**
|
6212 | * @experimental
|
6213 | */
|
6214 | // TODO (matsko): add typing for the animation function
|
6215 | var RenderComponentType = (function () {
|
6216 | /**
|
6217 | * @param {?} id
|
6218 | * @param {?} templateUrl
|
6219 | * @param {?} slotCount
|
6220 | * @param {?} encapsulation
|
6221 | * @param {?} styles
|
6222 | * @param {?} animations
|
6223 | */
|
6224 | function RenderComponentType(id, templateUrl, slotCount, encapsulation, styles, animations) {
|
6225 | this.id = id;
|
6226 | this.templateUrl = templateUrl;
|
6227 | this.slotCount = slotCount;
|
6228 | this.encapsulation = encapsulation;
|
6229 | this.styles = styles;
|
6230 | this.animations = animations;
|
6231 | }
|
6232 | return RenderComponentType;
|
6233 | }());
|
6234 | /**
|
6235 | * @abstract
|
6236 | */
|
6237 | var RenderDebugInfo = (function () {
|
6238 | function RenderDebugInfo() {
|
6239 | }
|
6240 | Object.defineProperty(RenderDebugInfo.prototype, "injector", {
|
6241 | /**
|
6242 | * @return {?}
|
6243 | */
|
6244 | get: function () { return unimplemented(); },
|
6245 | enumerable: true,
|
6246 | configurable: true
|
6247 | });
|
6248 | Object.defineProperty(RenderDebugInfo.prototype, "component", {
|
6249 | /**
|
6250 | * @return {?}
|
6251 | */
|
6252 | get: function () { return unimplemented(); },
|
6253 | enumerable: true,
|
6254 | configurable: true
|
6255 | });
|
6256 | Object.defineProperty(RenderDebugInfo.prototype, "providerTokens", {
|
6257 | /**
|
6258 | * @return {?}
|
6259 | */
|
6260 | get: function () { return unimplemented(); },
|
6261 | enumerable: true,
|
6262 | configurable: true
|
6263 | });
|
6264 | Object.defineProperty(RenderDebugInfo.prototype, "references", {
|
6265 | /**
|
6266 | * @return {?}
|
6267 | */
|
6268 | get: function () { return unimplemented(); },
|
6269 | enumerable: true,
|
6270 | configurable: true
|
6271 | });
|
6272 | Object.defineProperty(RenderDebugInfo.prototype, "context", {
|
6273 | /**
|
6274 | * @return {?}
|
6275 | */
|
6276 | get: function () { return unimplemented(); },
|
6277 | enumerable: true,
|
6278 | configurable: true
|
6279 | });
|
6280 | Object.defineProperty(RenderDebugInfo.prototype, "source", {
|
6281 | /**
|
6282 | * @return {?}
|
6283 | */
|
6284 | get: function () { return unimplemented(); },
|
6285 | enumerable: true,
|
6286 | configurable: true
|
6287 | });
|
6288 | return RenderDebugInfo;
|
6289 | }());
|
6290 | /**
|
6291 | * @abstract
|
6292 | */
|
6293 | var Renderer = (function () {
|
6294 | function Renderer() {
|
6295 | }
|
6296 | /**
|
6297 | * @abstract
|
6298 | * @param {?} selectorOrNode
|
6299 | * @param {?=} debugInfo
|
6300 | * @return {?}
|
6301 | */
|
6302 | Renderer.prototype.selectRootElement = function (selectorOrNode, debugInfo) { };
|
6303 | /**
|
6304 | * @abstract
|
6305 | * @param {?} parentElement
|
6306 | * @param {?} name
|
6307 | * @param {?=} debugInfo
|
6308 | * @return {?}
|
6309 | */
|
6310 | Renderer.prototype.createElement = function (parentElement, name, debugInfo) { };
|
6311 | /**
|
6312 | * @abstract
|
6313 | * @param {?} hostElement
|
6314 | * @return {?}
|
6315 | */
|
6316 | Renderer.prototype.createViewRoot = function (hostElement) { };
|
6317 | /**
|
6318 | * @abstract
|
6319 | * @param {?} parentElement
|
6320 | * @param {?=} debugInfo
|
6321 | * @return {?}
|
6322 | */
|
6323 | Renderer.prototype.createTemplateAnchor = function (parentElement, debugInfo) { };
|
6324 | /**
|
6325 | * @abstract
|
6326 | * @param {?} parentElement
|
6327 | * @param {?} value
|
6328 | * @param {?=} debugInfo
|
6329 | * @return {?}
|
6330 | */
|
6331 | Renderer.prototype.createText = function (parentElement, value, debugInfo) { };
|
6332 | /**
|
6333 | * @abstract
|
6334 | * @param {?} parentElement
|
6335 | * @param {?} nodes
|
6336 | * @return {?}
|
6337 | */
|
6338 | Renderer.prototype.projectNodes = function (parentElement, nodes) { };
|
6339 | /**
|
6340 | * @abstract
|
6341 | * @param {?} node
|
6342 | * @param {?} viewRootNodes
|
6343 | * @return {?}
|
6344 | */
|
6345 | Renderer.prototype.attachViewAfter = function (node, viewRootNodes) { };
|
6346 | /**
|
6347 | * @abstract
|
6348 | * @param {?} viewRootNodes
|
6349 | * @return {?}
|
6350 | */
|
6351 | Renderer.prototype.detachView = function (viewRootNodes) { };
|
6352 | /**
|
6353 | * @abstract
|
6354 | * @param {?} hostElement
|
6355 | * @param {?} viewAllNodes
|
6356 | * @return {?}
|
6357 | */
|
6358 | Renderer.prototype.destroyView = function (hostElement, viewAllNodes) { };
|
6359 | /**
|
6360 | * @abstract
|
6361 | * @param {?} renderElement
|
6362 | * @param {?} name
|
6363 | * @param {?} callback
|
6364 | * @return {?}
|
6365 | */
|
6366 | Renderer.prototype.listen = function (renderElement, name, callback) { };
|
6367 | /**
|
6368 | * @abstract
|
6369 | * @param {?} target
|
6370 | * @param {?} name
|
6371 | * @param {?} callback
|
6372 | * @return {?}
|
6373 | */
|
6374 | Renderer.prototype.listenGlobal = function (target, name, callback) { };
|
6375 | /**
|
6376 | * @abstract
|
6377 | * @param {?} renderElement
|
6378 | * @param {?} propertyName
|
6379 | * @param {?} propertyValue
|
6380 | * @return {?}
|
6381 | */
|
6382 | Renderer.prototype.setElementProperty = function (renderElement, propertyName, propertyValue) { };
|
6383 | /**
|
6384 | * @abstract
|
6385 | * @param {?} renderElement
|
6386 | * @param {?} attributeName
|
6387 | * @param {?} attributeValue
|
6388 | * @return {?}
|
6389 | */
|
6390 | Renderer.prototype.setElementAttribute = function (renderElement, attributeName, attributeValue) { };
|
6391 | /**
|
6392 | * Used only in debug mode to serialize property changes to dom nodes as attributes.
|
6393 | * @abstract
|
6394 | * @param {?} renderElement
|
6395 | * @param {?} propertyName
|
6396 | * @param {?} propertyValue
|
6397 | * @return {?}
|
6398 | */
|
6399 | Renderer.prototype.setBindingDebugInfo = function (renderElement, propertyName, propertyValue) { };
|
6400 | /**
|
6401 | * @abstract
|
6402 | * @param {?} renderElement
|
6403 | * @param {?} className
|
6404 | * @param {?} isAdd
|
6405 | * @return {?}
|
6406 | */
|
6407 | Renderer.prototype.setElementClass = function (renderElement, className, isAdd) { };
|
6408 | /**
|
6409 | * @abstract
|
6410 | * @param {?} renderElement
|
6411 | * @param {?} styleName
|
6412 | * @param {?} styleValue
|
6413 | * @return {?}
|
6414 | */
|
6415 | Renderer.prototype.setElementStyle = function (renderElement, styleName, styleValue) { };
|
6416 | /**
|
6417 | * @abstract
|
6418 | * @param {?} renderElement
|
6419 | * @param {?} methodName
|
6420 | * @param {?=} args
|
6421 | * @return {?}
|
6422 | */
|
6423 | Renderer.prototype.invokeElementMethod = function (renderElement, methodName, args) { };
|
6424 | /**
|
6425 | * @abstract
|
6426 | * @param {?} renderNode
|
6427 | * @param {?} text
|
6428 | * @return {?}
|
6429 | */
|
6430 | Renderer.prototype.setText = function (renderNode, text) { };
|
6431 | /**
|
6432 | * @abstract
|
6433 | * @param {?} element
|
6434 | * @param {?} startingStyles
|
6435 | * @param {?} keyframes
|
6436 | * @param {?} duration
|
6437 | * @param {?} delay
|
6438 | * @param {?} easing
|
6439 | * @param {?=} previousPlayers
|
6440 | * @return {?}
|
6441 | */
|
6442 | Renderer.prototype.animate = function (element, startingStyles, keyframes, duration, delay, easing, previousPlayers) { };
|
6443 | return Renderer;
|
6444 | }());
|
6445 | /**
|
6446 | * Injectable service that provides a low-level interface for modifying the UI.
|
6447 | * *
|
6448 | * Use this service to bypass Angular's templating and make custom UI changes that can't be
|
6449 | * expressed declaratively. For example if you need to set a property or an attribute whose name is
|
6450 | * not statically known, use {@link #setElementProperty} or {@link #setElementAttribute}
|
6451 | * respectively.
|
6452 | * *
|
6453 | * If you are implementing a custom renderer, you must implement this interface.
|
6454 | * *
|
6455 | * The default Renderer implementation is `DomRenderer`. Also available is `WebWorkerRenderer`.
|
6456 | * @abstract
|
6457 | */
|
6458 | var RootRenderer = (function () {
|
6459 | function RootRenderer() {
|
6460 | }
|
6461 | /**
|
6462 | * @abstract
|
6463 | * @param {?} componentType
|
6464 | * @return {?}
|
6465 | */
|
6466 | RootRenderer.prototype.renderComponent = function (componentType) { };
|
6467 | return RootRenderer;
|
6468 | }());
|
6469 |
|
6470 | var SecurityContext = {};
|
6471 | SecurityContext.NONE = 0;
|
6472 | SecurityContext.HTML = 1;
|
6473 | SecurityContext.STYLE = 2;
|
6474 | SecurityContext.SCRIPT = 3;
|
6475 | SecurityContext.URL = 4;
|
6476 | SecurityContext.RESOURCE_URL = 5;
|
6477 | SecurityContext[SecurityContext.NONE] = "NONE";
|
6478 | SecurityContext[SecurityContext.HTML] = "HTML";
|
6479 | SecurityContext[SecurityContext.STYLE] = "STYLE";
|
6480 | SecurityContext[SecurityContext.SCRIPT] = "SCRIPT";
|
6481 | SecurityContext[SecurityContext.URL] = "URL";
|
6482 | SecurityContext[SecurityContext.RESOURCE_URL] = "RESOURCE_URL";
|
6483 | /**
|
6484 | * Sanitizer is used by the views to sanitize potentially dangerous values.
|
6485 | * *
|
6486 | * @abstract
|
6487 | */
|
6488 | var Sanitizer = (function () {
|
6489 | function Sanitizer() {
|
6490 | }
|
6491 | /**
|
6492 | * @abstract
|
6493 | * @param {?} context
|
6494 | * @param {?} value
|
6495 | * @return {?}
|
6496 | */
|
6497 | Sanitizer.prototype.sanitize = function (context, value) { };
|
6498 | return Sanitizer;
|
6499 | }());
|
6500 |
|
6501 | /**
|
6502 | * @license
|
6503 | * Copyright Google Inc. All Rights Reserved.
|
6504 | *
|
6505 | * Use of this source code is governed by an MIT-style license that can be
|
6506 | * found in the LICENSE file at https://angular.io/license
|
6507 | */
|
6508 | var __extends$7 = (this && this.__extends) || function (d, b) {
|
6509 | for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
6510 | function __() { this.constructor = d; }
|
6511 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
6512 | };
|
6513 | /**
|
6514 | * An error thrown if application changes model breaking the top-down data flow.
|
6515 | * *
|
6516 | * This exception is only thrown in dev mode.
|
6517 | * *
|
6518 | * <!-- TODO: Add a link once the dev mode option is configurable -->
|
6519 | * *
|
6520 | * ### Example
|
6521 | * *
|
6522 | * ```typescript
|
6523 | * selector: 'parent',
|
6524 | * template: '<child [prop]="parentProp"></child>',
|
6525 | * })
|
6526 | * class Parent {
|
6527 | * parentProp = 'init';
|
6528 | * }
|
6529 | * *
|
6530 | * class Child {
|
6531 | * constructor(public parent: Parent) {}
|
6532 | * *
|
6533 | * set prop(v) {
|
6534 | * // this updates the parent property, which is disallowed during change detection
|
6535 | * // this will result in ExpressionChangedAfterItHasBeenCheckedError
|
6536 | * this.parent.parentProp = 'updated';
|
6537 | * }
|
6538 | * }
|
6539 | * ```
|
6540 | */
|
6541 | var ExpressionChangedAfterItHasBeenCheckedError = (function (_super) {
|
6542 | __extends$7(ExpressionChangedAfterItHasBeenCheckedError, _super);
|
6543 | /**
|
6544 | * @param {?} oldValue
|
6545 | * @param {?} currValue
|
6546 | */
|
6547 | function ExpressionChangedAfterItHasBeenCheckedError(oldValue, currValue) {
|
6548 | var msg = "Expression has changed after it was checked. Previous value: '" + oldValue + "'. Current value: '" + currValue + "'.";
|
6549 | if (oldValue === UNINITIALIZED) {
|
6550 | msg +=
|
6551 | " It seems like the view has been created after its parent and its children have been dirty checked." +
|
6552 | " Has it been created in a change detection hook ?";
|
6553 | }
|
6554 | _super.call(this, msg);
|
6555 | }
|
6556 | return ExpressionChangedAfterItHasBeenCheckedError;
|
6557 | }(BaseError));
|
6558 | /**
|
6559 | * Thrown when an exception was raised during view creation, change detection or destruction.
|
6560 | * *
|
6561 | * This error wraps the original exception to attach additional contextual information that can
|
6562 | * be useful for debugging.
|
6563 | */
|
6564 | var ViewWrappedError = (function (_super) {
|
6565 | __extends$7(ViewWrappedError, _super);
|
6566 | /**
|
6567 | * @param {?} originalError
|
6568 | * @param {?} context
|
6569 | */
|
6570 | function ViewWrappedError(originalError, context) {
|
6571 | _super.call(this, "Error in " + context.source, originalError);
|
6572 | this.context = context;
|
6573 | }
|
6574 | return ViewWrappedError;
|
6575 | }(WrappedError));
|
6576 | /**
|
6577 | * Thrown when a destroyed view is used.
|
6578 | * *
|
6579 | * This error indicates a bug in the framework.
|
6580 | * *
|
6581 | * This is an internal Angular error.
|
6582 | */
|
6583 | var ViewDestroyedError = (function (_super) {
|
6584 | __extends$7(ViewDestroyedError, _super);
|
6585 | /**
|
6586 | * @param {?} details
|
6587 | */
|
6588 | function ViewDestroyedError(details) {
|
6589 | _super.call(this, "Attempt to use a destroyed view: " + details);
|
6590 | }
|
6591 | return ViewDestroyedError;
|
6592 | }(BaseError));
|
6593 |
|
6594 | var ViewUtils = (function () {
|
6595 | /**
|
6596 | * @param {?} _renderer
|
6597 | * @param {?} sanitizer
|
6598 | * @param {?} animationQueue
|
6599 | */
|
6600 | function ViewUtils(_renderer, sanitizer, animationQueue) {
|
6601 | this._renderer = _renderer;
|
6602 | this.animationQueue = animationQueue;
|
6603 | this._nextCompTypeId = 0;
|
6604 | this.sanitizer = sanitizer;
|
6605 | }
|
6606 | /**
|
6607 | * @param {?} renderComponentType
|
6608 | * @return {?}
|
6609 | */
|
6610 | ViewUtils.prototype.renderComponent = function (renderComponentType) {
|
6611 | return this._renderer.renderComponent(renderComponentType);
|
6612 | };
|
6613 | ViewUtils.decorators = [
|
6614 | { type: Injectable },
|
6615 | ];
|
6616 | /** @nocollapse */
|
6617 | ViewUtils.ctorParameters = function () { return [
|
6618 | { type: RootRenderer, },
|
6619 | { type: Sanitizer, },
|
6620 | { type: AnimationQueue, },
|
6621 | ]; };
|
6622 | return ViewUtils;
|
6623 | }());
|
6624 | var /** @type {?} */ nextRenderComponentTypeId = 0;
|
6625 | /**
|
6626 | * @param {?} templateUrl
|
6627 | * @param {?} slotCount
|
6628 | * @param {?} encapsulation
|
6629 | * @param {?} styles
|
6630 | * @param {?} animations
|
6631 | * @return {?}
|
6632 | */
|
6633 | function createRenderComponentType(templateUrl, slotCount, encapsulation, styles, animations) {
|
6634 | return new RenderComponentType("" + nextRenderComponentTypeId++, templateUrl, slotCount, encapsulation, styles, animations);
|
6635 | }
|
6636 | /**
|
6637 | * @param {?} e
|
6638 | * @param {?} array
|
6639 | * @return {?}
|
6640 | */
|
6641 | function addToArray(e, array) {
|
6642 | array.push(e);
|
6643 | }
|
6644 | /**
|
6645 | * @param {?} valueCount
|
6646 | * @param {?} constAndInterp
|
6647 | * @return {?}
|
6648 | */
|
6649 | function interpolate(valueCount, constAndInterp) {
|
6650 | var /** @type {?} */ result = '';
|
6651 | for (var /** @type {?} */ i = 0; i < valueCount * 2; i = i + 2) {
|
6652 | result = result + constAndInterp[i] + _toStringWithNull(constAndInterp[i + 1]);
|
6653 | }
|
6654 | return result + constAndInterp[valueCount * 2];
|
6655 | }
|
6656 | /**
|
6657 | * @param {?} valueCount
|
6658 | * @param {?} c0
|
6659 | * @param {?} a1
|
6660 | * @param {?} c1
|
6661 | * @param {?=} a2
|
6662 | * @param {?=} c2
|
6663 | * @param {?=} a3
|
6664 | * @param {?=} c3
|
6665 | * @param {?=} a4
|
6666 | * @param {?=} c4
|
6667 | * @param {?=} a5
|
6668 | * @param {?=} c5
|
6669 | * @param {?=} a6
|
6670 | * @param {?=} c6
|
6671 | * @param {?=} a7
|
6672 | * @param {?=} c7
|
6673 | * @param {?=} a8
|
6674 | * @param {?=} c8
|
6675 | * @param {?=} a9
|
6676 | * @param {?=} c9
|
6677 | * @return {?}
|
6678 | */
|
6679 | function inlineInterpolate(valueCount, c0, a1, c1, a2, c2, a3, c3, a4, c4, a5, c5, a6, c6, a7, c7, a8, c8, a9, c9) {
|
6680 | switch (valueCount) {
|
6681 | case 1:
|
6682 | return c0 + _toStringWithNull(a1) + c1;
|
6683 | case 2:
|
6684 | return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2;
|
6685 | case 3:
|
6686 | return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) +
|
6687 | c3;
|
6688 | case 4:
|
6689 | return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) +
|
6690 | c3 + _toStringWithNull(a4) + c4;
|
6691 | case 5:
|
6692 | return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) +
|
6693 | c3 + _toStringWithNull(a4) + c4 + _toStringWithNull(a5) + c5;
|
6694 | case 6:
|
6695 | return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) +
|
6696 | c3 + _toStringWithNull(a4) + c4 + _toStringWithNull(a5) + c5 + _toStringWithNull(a6) + c6;
|
6697 | case 7:
|
6698 | return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) +
|
6699 | c3 + _toStringWithNull(a4) + c4 + _toStringWithNull(a5) + c5 + _toStringWithNull(a6) +
|
6700 | c6 + _toStringWithNull(a7) + c7;
|
6701 | case 8:
|
6702 | return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) +
|
6703 | c3 + _toStringWithNull(a4) + c4 + _toStringWithNull(a5) + c5 + _toStringWithNull(a6) +
|
6704 | c6 + _toStringWithNull(a7) + c7 + _toStringWithNull(a8) + c8;
|
6705 | case 9:
|
6706 | return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) +
|
6707 | c3 + _toStringWithNull(a4) + c4 + _toStringWithNull(a5) + c5 + _toStringWithNull(a6) +
|
6708 | c6 + _toStringWithNull(a7) + c7 + _toStringWithNull(a8) + c8 + _toStringWithNull(a9) + c9;
|
6709 | default:
|
6710 | throw new Error("Does not support more than 9 expressions");
|
6711 | }
|
6712 | }
|
6713 | /**
|
6714 | * @param {?} v
|
6715 | * @return {?}
|
6716 | */
|
6717 | function _toStringWithNull(v) {
|
6718 | return v != null ? v.toString() : '';
|
6719 | }
|
6720 | /**
|
6721 | * @param {?} throwOnChange
|
6722 | * @param {?} oldValue
|
6723 | * @param {?} newValue
|
6724 | * @return {?}
|
6725 | */
|
6726 | function checkBinding(throwOnChange, oldValue, newValue) {
|
6727 | if (throwOnChange) {
|
6728 | if (!devModeEqual(oldValue, newValue)) {
|
6729 | throw new ExpressionChangedAfterItHasBeenCheckedError(oldValue, newValue);
|
6730 | }
|
6731 | return false;
|
6732 | }
|
6733 | else {
|
6734 | return !looseIdentical(oldValue, newValue);
|
6735 | }
|
6736 | }
|
6737 | /**
|
6738 | * @param {?} input
|
6739 | * @param {?} value
|
6740 | * @return {?}
|
6741 | */
|
6742 | function castByValue(input, value) {
|
6743 | return (input);
|
6744 | }
|
6745 | var /** @type {?} */ EMPTY_ARRAY = [];
|
6746 | var /** @type {?} */ EMPTY_MAP = {};
|
6747 | /**
|
6748 | * @param {?} fn
|
6749 | * @return {?}
|
6750 | */
|
6751 | function pureProxy1(fn) {
|
6752 | var /** @type {?} */ result;
|
6753 | var /** @type {?} */ v0 = UNINITIALIZED;
|
6754 | return function (p0) {
|
6755 | if (!looseIdentical(v0, p0)) {
|
6756 | v0 = p0;
|
6757 | result = fn(p0);
|
6758 | }
|
6759 | return result;
|
6760 | };
|
6761 | }
|
6762 | /**
|
6763 | * @param {?} fn
|
6764 | * @return {?}
|
6765 | */
|
6766 | function pureProxy2(fn) {
|
6767 | var /** @type {?} */ result;
|
6768 | var /** @type {?} */ v0 = UNINITIALIZED;
|
6769 | var /** @type {?} */ v1 = UNINITIALIZED;
|
6770 | return function (p0, p1) {
|
6771 | if (!looseIdentical(v0, p0) || !looseIdentical(v1, p1)) {
|
6772 | v0 = p0;
|
6773 | v1 = p1;
|
6774 | result = fn(p0, p1);
|
6775 | }
|
6776 | return result;
|
6777 | };
|
6778 | }
|
6779 | /**
|
6780 | * @param {?} fn
|
6781 | * @return {?}
|
6782 | */
|
6783 | function pureProxy3(fn) {
|
6784 | var /** @type {?} */ result;
|
6785 | var /** @type {?} */ v0 = UNINITIALIZED;
|
6786 | var /** @type {?} */ v1 = UNINITIALIZED;
|
6787 | var /** @type {?} */ v2 = UNINITIALIZED;
|
6788 | return function (p0, p1, p2) {
|
6789 | if (!looseIdentical(v0, p0) || !looseIdentical(v1, p1) || !looseIdentical(v2, p2)) {
|
6790 | v0 = p0;
|
6791 | v1 = p1;
|
6792 | v2 = p2;
|
6793 | result = fn(p0, p1, p2);
|
6794 | }
|
6795 | return result;
|
6796 | };
|
6797 | }
|
6798 | /**
|
6799 | * @param {?} fn
|
6800 | * @return {?}
|
6801 | */
|
6802 | function pureProxy4(fn) {
|
6803 | var /** @type {?} */ result;
|
6804 | var /** @type {?} */ v0, /** @type {?} */ v1, /** @type {?} */ v2, /** @type {?} */ v3;
|
6805 | v0 = v1 = v2 = v3 = UNINITIALIZED;
|
6806 | return function (p0, p1, p2, p3) {
|
6807 | if (!looseIdentical(v0, p0) || !looseIdentical(v1, p1) || !looseIdentical(v2, p2) ||
|
6808 | !looseIdentical(v3, p3)) {
|
6809 | v0 = p0;
|
6810 | v1 = p1;
|
6811 | v2 = p2;
|
6812 | v3 = p3;
|
6813 | result = fn(p0, p1, p2, p3);
|
6814 | }
|
6815 | return result;
|
6816 | };
|
6817 | }
|
6818 | /**
|
6819 | * @param {?} fn
|
6820 | * @return {?}
|
6821 | */
|
6822 | function pureProxy5(fn) {
|
6823 | var /** @type {?} */ result;
|
6824 | var /** @type {?} */ v0, /** @type {?} */ v1, /** @type {?} */ v2, /** @type {?} */ v3, /** @type {?} */ v4;
|
6825 | v0 = v1 = v2 = v3 = v4 = UNINITIALIZED;
|
6826 | return function (p0, p1, p2, p3, p4) {
|
6827 | if (!looseIdentical(v0, p0) || !looseIdentical(v1, p1) || !looseIdentical(v2, p2) ||
|
6828 | !looseIdentical(v3, p3) || !looseIdentical(v4, p4)) {
|
6829 | v0 = p0;
|
6830 | v1 = p1;
|
6831 | v2 = p2;
|
6832 | v3 = p3;
|
6833 | v4 = p4;
|
6834 | result = fn(p0, p1, p2, p3, p4);
|
6835 | }
|
6836 | return result;
|
6837 | };
|
6838 | }
|
6839 | /**
|
6840 | * @param {?} fn
|
6841 | * @return {?}
|
6842 | */
|
6843 | function pureProxy6(fn) {
|
6844 | var /** @type {?} */ result;
|
6845 | var /** @type {?} */ v0, /** @type {?} */ v1, /** @type {?} */ v2, /** @type {?} */ v3, /** @type {?} */ v4, /** @type {?} */ v5;
|
6846 | v0 = v1 = v2 = v3 = v4 = v5 = UNINITIALIZED;
|
6847 | return function (p0, p1, p2, p3, p4, p5) {
|
6848 | if (!looseIdentical(v0, p0) || !looseIdentical(v1, p1) || !looseIdentical(v2, p2) ||
|
6849 | !looseIdentical(v3, p3) || !looseIdentical(v4, p4) || !looseIdentical(v5, p5)) {
|
6850 | v0 = p0;
|
6851 | v1 = p1;
|
6852 | v2 = p2;
|
6853 | v3 = p3;
|
6854 | v4 = p4;
|
6855 | v5 = p5;
|
6856 | result = fn(p0, p1, p2, p3, p4, p5);
|
6857 | }
|
6858 | return result;
|
6859 | };
|
6860 | }
|
6861 | /**
|
6862 | * @param {?} fn
|
6863 | * @return {?}
|
6864 | */
|
6865 | function pureProxy7(fn) {
|
6866 | var /** @type {?} */ result;
|
6867 | var /** @type {?} */ v0, /** @type {?} */ v1, /** @type {?} */ v2, /** @type {?} */ v3, /** @type {?} */ v4, /** @type {?} */ v5, /** @type {?} */ v6;
|
6868 | v0 = v1 = v2 = v3 = v4 = v5 = v6 = UNINITIALIZED;
|
6869 | return function (p0, p1, p2, p3, p4, p5, p6) {
|
6870 | if (!looseIdentical(v0, p0) || !looseIdentical(v1, p1) || !looseIdentical(v2, p2) ||
|
6871 | !looseIdentical(v3, p3) || !looseIdentical(v4, p4) || !looseIdentical(v5, p5) ||
|
6872 | !looseIdentical(v6, p6)) {
|
6873 | v0 = p0;
|
6874 | v1 = p1;
|
6875 | v2 = p2;
|
6876 | v3 = p3;
|
6877 | v4 = p4;
|
6878 | v5 = p5;
|
6879 | v6 = p6;
|
6880 | result = fn(p0, p1, p2, p3, p4, p5, p6);
|
6881 | }
|
6882 | return result;
|
6883 | };
|
6884 | }
|
6885 | /**
|
6886 | * @param {?} fn
|
6887 | * @return {?}
|
6888 | */
|
6889 | function pureProxy8(fn) {
|
6890 | var /** @type {?} */ result;
|
6891 | var /** @type {?} */ v0, /** @type {?} */ v1, /** @type {?} */ v2, /** @type {?} */ v3, /** @type {?} */ v4, /** @type {?} */ v5, /** @type {?} */ v6, /** @type {?} */ v7;
|
6892 | v0 = v1 = v2 = v3 = v4 = v5 = v6 = v7 = UNINITIALIZED;
|
6893 | return function (p0, p1, p2, p3, p4, p5, p6, p7) {
|
6894 | if (!looseIdentical(v0, p0) || !looseIdentical(v1, p1) || !looseIdentical(v2, p2) ||
|
6895 | !looseIdentical(v3, p3) || !looseIdentical(v4, p4) || !looseIdentical(v5, p5) ||
|
6896 | !looseIdentical(v6, p6) || !looseIdentical(v7, p7)) {
|
6897 | v0 = p0;
|
6898 | v1 = p1;
|
6899 | v2 = p2;
|
6900 | v3 = p3;
|
6901 | v4 = p4;
|
6902 | v5 = p5;
|
6903 | v6 = p6;
|
6904 | v7 = p7;
|
6905 | result = fn(p0, p1, p2, p3, p4, p5, p6, p7);
|
6906 | }
|
6907 | return result;
|
6908 | };
|
6909 | }
|
6910 | /**
|
6911 | * @param {?} fn
|
6912 | * @return {?}
|
6913 | */
|
6914 | function pureProxy9(fn) {
|
6915 | var /** @type {?} */ result;
|
6916 | var /** @type {?} */ v0, /** @type {?} */ v1, /** @type {?} */ v2, /** @type {?} */ v3, /** @type {?} */ v4, /** @type {?} */ v5, /** @type {?} */ v6, /** @type {?} */ v7, /** @type {?} */ v8;
|
6917 | v0 = v1 = v2 = v3 = v4 = v5 = v6 = v7 = v8 = UNINITIALIZED;
|
6918 | return function (p0, p1, p2, p3, p4, p5, p6, p7, p8) {
|
6919 | if (!looseIdentical(v0, p0) || !looseIdentical(v1, p1) || !looseIdentical(v2, p2) ||
|
6920 | !looseIdentical(v3, p3) || !looseIdentical(v4, p4) || !looseIdentical(v5, p5) ||
|
6921 | !looseIdentical(v6, p6) || !looseIdentical(v7, p7) || !looseIdentical(v8, p8)) {
|
6922 | v0 = p0;
|
6923 | v1 = p1;
|
6924 | v2 = p2;
|
6925 | v3 = p3;
|
6926 | v4 = p4;
|
6927 | v5 = p5;
|
6928 | v6 = p6;
|
6929 | v7 = p7;
|
6930 | v8 = p8;
|
6931 | result = fn(p0, p1, p2, p3, p4, p5, p6, p7, p8);
|
6932 | }
|
6933 | return result;
|
6934 | };
|
6935 | }
|
6936 | /**
|
6937 | * @param {?} fn
|
6938 | * @return {?}
|
6939 | */
|
6940 | function pureProxy10(fn) {
|
6941 | var /** @type {?} */ result;
|
6942 | var /** @type {?} */ v0, /** @type {?} */ v1, /** @type {?} */ v2, /** @type {?} */ v3, /** @type {?} */ v4, /** @type {?} */ v5, /** @type {?} */ v6, /** @type {?} */ v7, /** @type {?} */ v8, /** @type {?} */ v9;
|
6943 | v0 = v1 = v2 = v3 = v4 = v5 = v6 = v7 = v8 = v9 = UNINITIALIZED;
|
6944 | return function (p0, p1, p2, p3, p4, p5, p6, p7, p8, p9) {
|
6945 | if (!looseIdentical(v0, p0) || !looseIdentical(v1, p1) || !looseIdentical(v2, p2) ||
|
6946 | !looseIdentical(v3, p3) || !looseIdentical(v4, p4) || !looseIdentical(v5, p5) ||
|
6947 | !looseIdentical(v6, p6) || !looseIdentical(v7, p7) || !looseIdentical(v8, p8) ||
|
6948 | !looseIdentical(v9, p9)) {
|
6949 | v0 = p0;
|
6950 | v1 = p1;
|
6951 | v2 = p2;
|
6952 | v3 = p3;
|
6953 | v4 = p4;
|
6954 | v5 = p5;
|
6955 | v6 = p6;
|
6956 | v7 = p7;
|
6957 | v8 = p8;
|
6958 | v9 = p9;
|
6959 | result = fn(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
|
6960 | }
|
6961 | return result;
|
6962 | };
|
6963 | }
|
6964 | /**
|
6965 | * @param {?} renderer
|
6966 | * @param {?} el
|
6967 | * @param {?} changes
|
6968 | * @return {?}
|
6969 | */
|
6970 | function setBindingDebugInfoForChanges(renderer, el, changes) {
|
6971 | Object.keys(changes).forEach(function (propName) {
|
6972 | setBindingDebugInfo(renderer, el, propName, changes[propName].currentValue);
|
6973 | });
|
6974 | }
|
6975 | /**
|
6976 | * @param {?} renderer
|
6977 | * @param {?} el
|
6978 | * @param {?} propName
|
6979 | * @param {?} value
|
6980 | * @return {?}
|
6981 | */
|
6982 | function setBindingDebugInfo(renderer, el, propName, value) {
|
6983 | try {
|
6984 | renderer.setBindingDebugInfo(el, "ng-reflect-" + camelCaseToDashCase(propName), value ? value.toString() : null);
|
6985 | }
|
6986 | catch (e) {
|
6987 | renderer.setBindingDebugInfo(el, "ng-reflect-" + camelCaseToDashCase(propName), '[ERROR] Exception while trying to serialize the value');
|
6988 | }
|
6989 | }
|
6990 | var /** @type {?} */ CAMEL_CASE_REGEXP = /([A-Z])/g;
|
6991 | /**
|
6992 | * @param {?} input
|
6993 | * @return {?}
|
6994 | */
|
6995 | function camelCaseToDashCase(input) {
|
6996 | return input.replace(CAMEL_CASE_REGEXP, function () {
|
6997 | var m = [];
|
6998 | for (var _i = 0; _i < arguments.length; _i++) {
|
6999 | m[_i - 0] = arguments[_i];
|
7000 | }
|
7001 | return '-' + m[1].toLowerCase();
|
7002 | });
|
7003 | }
|
7004 | /**
|
7005 | * @param {?} renderer
|
7006 | * @param {?} parentElement
|
7007 | * @param {?} name
|
7008 | * @param {?} attrs
|
7009 | * @param {?=} debugInfo
|
7010 | * @return {?}
|
7011 | */
|
7012 | function createRenderElement(renderer, parentElement, name, attrs, debugInfo) {
|
7013 | var /** @type {?} */ el = renderer.createElement(parentElement, name, debugInfo);
|
7014 | for (var /** @type {?} */ i = 0; i < attrs.length; i += 2) {
|
7015 | renderer.setElementAttribute(el, attrs.get(i), attrs.get(i + 1));
|
7016 | }
|
7017 | return el;
|
7018 | }
|
7019 | /**
|
7020 | * @param {?} renderer
|
7021 | * @param {?} elementName
|
7022 | * @param {?} attrs
|
7023 | * @param {?} rootSelectorOrNode
|
7024 | * @param {?=} debugInfo
|
7025 | * @return {?}
|
7026 | */
|
7027 | function selectOrCreateRenderHostElement(renderer, elementName, attrs, rootSelectorOrNode, debugInfo) {
|
7028 | var /** @type {?} */ hostElement;
|
7029 | if (isPresent(rootSelectorOrNode)) {
|
7030 | hostElement = renderer.selectRootElement(rootSelectorOrNode, debugInfo);
|
7031 | for (var /** @type {?} */ i = 0; i < attrs.length; i += 2) {
|
7032 | renderer.setElementAttribute(hostElement, attrs.get(i), attrs.get(i + 1));
|
7033 | }
|
7034 | renderer.setElementAttribute(hostElement, 'ng-version', VERSION.full);
|
7035 | }
|
7036 | else {
|
7037 | hostElement = createRenderElement(renderer, null, elementName, attrs, debugInfo);
|
7038 | }
|
7039 | return hostElement;
|
7040 | }
|
7041 | /**
|
7042 | * @param {?} view
|
7043 | * @param {?} element
|
7044 | * @param {?} eventNamesAndTargets
|
7045 | * @param {?} listener
|
7046 | * @return {?}
|
7047 | */
|
7048 | function subscribeToRenderElement(view, element, eventNamesAndTargets, listener) {
|
7049 | var /** @type {?} */ disposables = createEmptyInlineArray(eventNamesAndTargets.length / 2);
|
7050 | for (var /** @type {?} */ i = 0; i < eventNamesAndTargets.length; i += 2) {
|
7051 | var /** @type {?} */ eventName = eventNamesAndTargets.get(i);
|
7052 | var /** @type {?} */ eventTarget = eventNamesAndTargets.get(i + 1);
|
7053 | var /** @type {?} */ disposable = void 0;
|
7054 | if (eventTarget) {
|
7055 | disposable = view.renderer.listenGlobal(eventTarget, eventName, listener.bind(view, eventTarget + ":" + eventName));
|
7056 | }
|
7057 | else {
|
7058 | disposable = view.renderer.listen(element, eventName, listener.bind(view, eventName));
|
7059 | }
|
7060 | disposables.set(i / 2, disposable);
|
7061 | }
|
7062 | return disposeInlineArray.bind(null, disposables);
|
7063 | }
|
7064 | /**
|
7065 | * @param {?} disposables
|
7066 | * @return {?}
|
7067 | */
|
7068 | function disposeInlineArray(disposables) {
|
7069 | for (var /** @type {?} */ i = 0; i < disposables.length; i++) {
|
7070 | disposables.get(i)();
|
7071 | }
|
7072 | }
|
7073 | /**
|
7074 | * @return {?}
|
7075 | */
|
7076 | function noop() { }
|
7077 | /**
|
7078 | * @param {?} length
|
7079 | * @return {?}
|
7080 | */
|
7081 | function createEmptyInlineArray(length) {
|
7082 | var /** @type {?} */ ctor;
|
7083 | if (length <= 2) {
|
7084 | ctor = InlineArray2;
|
7085 | }
|
7086 | else if (length <= 4) {
|
7087 | ctor = InlineArray4;
|
7088 | }
|
7089 | else if (length <= 8) {
|
7090 | ctor = InlineArray8;
|
7091 | }
|
7092 | else if (length <= 16) {
|
7093 | ctor = InlineArray16;
|
7094 | }
|
7095 | else {
|
7096 | ctor = InlineArrayDynamic;
|
7097 | }
|
7098 | return new ctor(length);
|
7099 | }
|
7100 | var InlineArray0 = (function () {
|
7101 | function InlineArray0() {
|
7102 | this.length = 0;
|
7103 | }
|
7104 | /**
|
7105 | * @param {?} index
|
7106 | * @return {?}
|
7107 | */
|
7108 | InlineArray0.prototype.get = function (index) { return undefined; };
|
7109 | /**
|
7110 | * @param {?} index
|
7111 | * @param {?} value
|
7112 | * @return {?}
|
7113 | */
|
7114 | InlineArray0.prototype.set = function (index, value) { };
|
7115 | return InlineArray0;
|
7116 | }());
|
7117 | var InlineArray2 = (function () {
|
7118 | /**
|
7119 | * @param {?} length
|
7120 | * @param {?=} _v0
|
7121 | * @param {?=} _v1
|
7122 | */
|
7123 | function InlineArray2(length, _v0, _v1) {
|
7124 | this.length = length;
|
7125 | this._v0 = _v0;
|
7126 | this._v1 = _v1;
|
7127 | }
|
7128 | /**
|
7129 | * @param {?} index
|
7130 | * @return {?}
|
7131 | */
|
7132 | InlineArray2.prototype.get = function (index) {
|
7133 | switch (index) {
|
7134 | case 0:
|
7135 | return this._v0;
|
7136 | case 1:
|
7137 | return this._v1;
|
7138 | default:
|
7139 | return undefined;
|
7140 | }
|
7141 | };
|
7142 | /**
|
7143 | * @param {?} index
|
7144 | * @param {?} value
|
7145 | * @return {?}
|
7146 | */
|
7147 | InlineArray2.prototype.set = function (index, value) {
|
7148 | switch (index) {
|
7149 | case 0:
|
7150 | this._v0 = value;
|
7151 | break;
|
7152 | case 1:
|
7153 | this._v1 = value;
|
7154 | break;
|
7155 | }
|
7156 | };
|
7157 | return InlineArray2;
|
7158 | }());
|
7159 | var InlineArray4 = (function () {
|
7160 | /**
|
7161 | * @param {?} length
|
7162 | * @param {?=} _v0
|
7163 | * @param {?=} _v1
|
7164 | * @param {?=} _v2
|
7165 | * @param {?=} _v3
|
7166 | */
|
7167 | function InlineArray4(length, _v0, _v1, _v2, _v3) {
|
7168 | this.length = length;
|
7169 | this._v0 = _v0;
|
7170 | this._v1 = _v1;
|
7171 | this._v2 = _v2;
|
7172 | this._v3 = _v3;
|
7173 | }
|
7174 | /**
|
7175 | * @param {?} index
|
7176 | * @return {?}
|
7177 | */
|
7178 | InlineArray4.prototype.get = function (index) {
|
7179 | switch (index) {
|
7180 | case 0:
|
7181 | return this._v0;
|
7182 | case 1:
|
7183 | return this._v1;
|
7184 | case 2:
|
7185 | return this._v2;
|
7186 | case 3:
|
7187 | return this._v3;
|
7188 | default:
|
7189 | return undefined;
|
7190 | }
|
7191 | };
|
7192 | /**
|
7193 | * @param {?} index
|
7194 | * @param {?} value
|
7195 | * @return {?}
|
7196 | */
|
7197 | InlineArray4.prototype.set = function (index, value) {
|
7198 | switch (index) {
|
7199 | case 0:
|
7200 | this._v0 = value;
|
7201 | break;
|
7202 | case 1:
|
7203 | this._v1 = value;
|
7204 | break;
|
7205 | case 2:
|
7206 | this._v2 = value;
|
7207 | break;
|
7208 | case 3:
|
7209 | this._v3 = value;
|
7210 | break;
|
7211 | }
|
7212 | };
|
7213 | return InlineArray4;
|
7214 | }());
|
7215 | var InlineArray8 = (function () {
|
7216 | /**
|
7217 | * @param {?} length
|
7218 | * @param {?=} _v0
|
7219 | * @param {?=} _v1
|
7220 | * @param {?=} _v2
|
7221 | * @param {?=} _v3
|
7222 | * @param {?=} _v4
|
7223 | * @param {?=} _v5
|
7224 | * @param {?=} _v6
|
7225 | * @param {?=} _v7
|
7226 | */
|
7227 | function InlineArray8(length, _v0, _v1, _v2, _v3, _v4, _v5, _v6, _v7) {
|
7228 | this.length = length;
|
7229 | this._v0 = _v0;
|
7230 | this._v1 = _v1;
|
7231 | this._v2 = _v2;
|
7232 | this._v3 = _v3;
|
7233 | this._v4 = _v4;
|
7234 | this._v5 = _v5;
|
7235 | this._v6 = _v6;
|
7236 | this._v7 = _v7;
|
7237 | }
|
7238 | /**
|
7239 | * @param {?} index
|
7240 | * @return {?}
|
7241 | */
|
7242 | InlineArray8.prototype.get = function (index) {
|
7243 | switch (index) {
|
7244 | case 0:
|
7245 | return this._v0;
|
7246 | case 1:
|
7247 | return this._v1;
|
7248 | case 2:
|
7249 | return this._v2;
|
7250 | case 3:
|
7251 | return this._v3;
|
7252 | case 4:
|
7253 | return this._v4;
|
7254 | case 5:
|
7255 | return this._v5;
|
7256 | case 6:
|
7257 | return this._v6;
|
7258 | case 7:
|
7259 | return this._v7;
|
7260 | default:
|
7261 | return undefined;
|
7262 | }
|
7263 | };
|
7264 | /**
|
7265 | * @param {?} index
|
7266 | * @param {?} value
|
7267 | * @return {?}
|
7268 | */
|
7269 | InlineArray8.prototype.set = function (index, value) {
|
7270 | switch (index) {
|
7271 | case 0:
|
7272 | this._v0 = value;
|
7273 | break;
|
7274 | case 1:
|
7275 | this._v1 = value;
|
7276 | break;
|
7277 | case 2:
|
7278 | this._v2 = value;
|
7279 | break;
|
7280 | case 3:
|
7281 | this._v3 = value;
|
7282 | break;
|
7283 | case 4:
|
7284 | this._v4 = value;
|
7285 | break;
|
7286 | case 5:
|
7287 | this._v5 = value;
|
7288 | break;
|
7289 | case 6:
|
7290 | this._v6 = value;
|
7291 | break;
|
7292 | case 7:
|
7293 | this._v7 = value;
|
7294 | break;
|
7295 | }
|
7296 | };
|
7297 | return InlineArray8;
|
7298 | }());
|
7299 | var InlineArray16 = (function () {
|
7300 | /**
|
7301 | * @param {?} length
|
7302 | * @param {?=} _v0
|
7303 | * @param {?=} _v1
|
7304 | * @param {?=} _v2
|
7305 | * @param {?=} _v3
|
7306 | * @param {?=} _v4
|
7307 | * @param {?=} _v5
|
7308 | * @param {?=} _v6
|
7309 | * @param {?=} _v7
|
7310 | * @param {?=} _v8
|
7311 | * @param {?=} _v9
|
7312 | * @param {?=} _v10
|
7313 | * @param {?=} _v11
|
7314 | * @param {?=} _v12
|
7315 | * @param {?=} _v13
|
7316 | * @param {?=} _v14
|
7317 | * @param {?=} _v15
|
7318 | */
|
7319 | function InlineArray16(length, _v0, _v1, _v2, _v3, _v4, _v5, _v6, _v7, _v8, _v9, _v10, _v11, _v12, _v13, _v14, _v15) {
|
7320 | this.length = length;
|
7321 | this._v0 = _v0;
|
7322 | this._v1 = _v1;
|
7323 | this._v2 = _v2;
|
7324 | this._v3 = _v3;
|
7325 | this._v4 = _v4;
|
7326 | this._v5 = _v5;
|
7327 | this._v6 = _v6;
|
7328 | this._v7 = _v7;
|
7329 | this._v8 = _v8;
|
7330 | this._v9 = _v9;
|
7331 | this._v10 = _v10;
|
7332 | this._v11 = _v11;
|
7333 | this._v12 = _v12;
|
7334 | this._v13 = _v13;
|
7335 | this._v14 = _v14;
|
7336 | this._v15 = _v15;
|
7337 | }
|
7338 | /**
|
7339 | * @param {?} index
|
7340 | * @return {?}
|
7341 | */
|
7342 | InlineArray16.prototype.get = function (index) {
|
7343 | switch (index) {
|
7344 | case 0:
|
7345 | return this._v0;
|
7346 | case 1:
|
7347 | return this._v1;
|
7348 | case 2:
|
7349 | return this._v2;
|
7350 | case 3:
|
7351 | return this._v3;
|
7352 | case 4:
|
7353 | return this._v4;
|
7354 | case 5:
|
7355 | return this._v5;
|
7356 | case 6:
|
7357 | return this._v6;
|
7358 | case 7:
|
7359 | return this._v7;
|
7360 | case 8:
|
7361 | return this._v8;
|
7362 | case 9:
|
7363 | return this._v9;
|
7364 | case 10:
|
7365 | return this._v10;
|
7366 | case 11:
|
7367 | return this._v11;
|
7368 | case 12:
|
7369 | return this._v12;
|
7370 | case 13:
|
7371 | return this._v13;
|
7372 | case 14:
|
7373 | return this._v14;
|
7374 | case 15:
|
7375 | return this._v15;
|
7376 | default:
|
7377 | return undefined;
|
7378 | }
|
7379 | };
|
7380 | /**
|
7381 | * @param {?} index
|
7382 | * @param {?} value
|
7383 | * @return {?}
|
7384 | */
|
7385 | InlineArray16.prototype.set = function (index, value) {
|
7386 | switch (index) {
|
7387 | case 0:
|
7388 | this._v0 = value;
|
7389 | break;
|
7390 | case 1:
|
7391 | this._v1 = value;
|
7392 | break;
|
7393 | case 2:
|
7394 | this._v2 = value;
|
7395 | break;
|
7396 | case 3:
|
7397 | this._v3 = value;
|
7398 | break;
|
7399 | case 4:
|
7400 | this._v4 = value;
|
7401 | break;
|
7402 | case 5:
|
7403 | this._v5 = value;
|
7404 | break;
|
7405 | case 6:
|
7406 | this._v6 = value;
|
7407 | break;
|
7408 | case 7:
|
7409 | this._v7 = value;
|
7410 | break;
|
7411 | case 8:
|
7412 | this._v8 = value;
|
7413 | break;
|
7414 | case 9:
|
7415 | this._v9 = value;
|
7416 | break;
|
7417 | case 10:
|
7418 | this._v10 = value;
|
7419 | break;
|
7420 | case 11:
|
7421 | this._v11 = value;
|
7422 | break;
|
7423 | case 12:
|
7424 | this._v12 = value;
|
7425 | break;
|
7426 | case 13:
|
7427 | this._v13 = value;
|
7428 | break;
|
7429 | case 14:
|
7430 | this._v14 = value;
|
7431 | break;
|
7432 | case 15:
|
7433 | this._v15 = value;
|
7434 | break;
|
7435 | }
|
7436 | };
|
7437 | return InlineArray16;
|
7438 | }());
|
7439 | var InlineArrayDynamic = (function () {
|
7440 | /**
|
7441 | * @param {?} length
|
7442 | * @param {...?} values
|
7443 | */
|
7444 | function InlineArrayDynamic(length) {
|
7445 | var values = [];
|
7446 | for (var _i = 1; _i < arguments.length; _i++) {
|
7447 | values[_i - 1] = arguments[_i];
|
7448 | }
|
7449 | this.length = length;
|
7450 | this._values = values;
|
7451 | }
|
7452 | /**
|
7453 | * @param {?} index
|
7454 | * @return {?}
|
7455 | */
|
7456 | InlineArrayDynamic.prototype.get = function (index) { return this._values[index]; };
|
7457 | /**
|
7458 | * @param {?} index
|
7459 | * @param {?} value
|
7460 | * @return {?}
|
7461 | */
|
7462 | InlineArrayDynamic.prototype.set = function (index, value) { this._values[index] = value; };
|
7463 | return InlineArrayDynamic;
|
7464 | }());
|
7465 | var /** @type {?} */ EMPTY_INLINE_ARRAY = new InlineArray0();
|
7466 |
|
7467 |
|
7468 | var view_utils = Object.freeze({
|
7469 | ViewUtils: ViewUtils,
|
7470 | createRenderComponentType: createRenderComponentType,
|
7471 | addToArray: addToArray,
|
7472 | interpolate: interpolate,
|
7473 | inlineInterpolate: inlineInterpolate,
|
7474 | checkBinding: checkBinding,
|
7475 | castByValue: castByValue,
|
7476 | EMPTY_ARRAY: EMPTY_ARRAY,
|
7477 | EMPTY_MAP: EMPTY_MAP,
|
7478 | pureProxy1: pureProxy1,
|
7479 | pureProxy2: pureProxy2,
|
7480 | pureProxy3: pureProxy3,
|
7481 | pureProxy4: pureProxy4,
|
7482 | pureProxy5: pureProxy5,
|
7483 | pureProxy6: pureProxy6,
|
7484 | pureProxy7: pureProxy7,
|
7485 | pureProxy8: pureProxy8,
|
7486 | pureProxy9: pureProxy9,
|
7487 | pureProxy10: pureProxy10,
|
7488 | setBindingDebugInfoForChanges: setBindingDebugInfoForChanges,
|
7489 | setBindingDebugInfo: setBindingDebugInfo,
|
7490 | createRenderElement: createRenderElement,
|
7491 | selectOrCreateRenderHostElement: selectOrCreateRenderHostElement,
|
7492 | subscribeToRenderElement: subscribeToRenderElement,
|
7493 | noop: noop,
|
7494 | InlineArray2: InlineArray2,
|
7495 | InlineArray4: InlineArray4,
|
7496 | InlineArray8: InlineArray8,
|
7497 | InlineArray16: InlineArray16,
|
7498 | InlineArrayDynamic: InlineArrayDynamic,
|
7499 | EMPTY_INLINE_ARRAY: EMPTY_INLINE_ARRAY
|
7500 | });
|
7501 |
|
7502 | /**
|
7503 | * @license
|
7504 | * Copyright Google Inc. All Rights Reserved.
|
7505 | *
|
7506 | * Use of this source code is governed by an MIT-style license that can be
|
7507 | * found in the LICENSE file at https://angular.io/license
|
7508 | */
|
7509 | var __extends$5 = (this && this.__extends) || function (d, b) {
|
7510 | for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
7511 | function __() { this.constructor = d; }
|
7512 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
7513 | };
|
7514 | /**
|
7515 | * Represents an instance of a Component created via a {@link ComponentFactory}.
|
7516 | * *
|
7517 | * `ComponentRef` provides access to the Component Instance as well other objects related to this
|
7518 | * Component Instance and allows you to destroy the Component Instance via the {@link #destroy}
|
7519 | * method.
|
7520 | * @abstract
|
7521 | */
|
7522 | var ComponentRef = (function () {
|
7523 | function ComponentRef() {
|
7524 | }
|
7525 | Object.defineProperty(ComponentRef.prototype, "location", {
|
7526 | /**
|
7527 | * Location of the Host Element of this Component Instance.
|
7528 | * @return {?}
|
7529 | */
|
7530 | get: function () { return unimplemented(); },
|
7531 | enumerable: true,
|
7532 | configurable: true
|
7533 | });
|
7534 | Object.defineProperty(ComponentRef.prototype, "injector", {
|
7535 | /**
|
7536 | * The injector on which the component instance exists.
|
7537 | * @return {?}
|
7538 | */
|
7539 | get: function () { return unimplemented(); },
|
7540 | enumerable: true,
|
7541 | configurable: true
|
7542 | });
|
7543 | Object.defineProperty(ComponentRef.prototype, "instance", {
|
7544 | /**
|
7545 | * The instance of the Component.
|
7546 | * @return {?}
|
7547 | */
|
7548 | get: function () { return unimplemented(); },
|
7549 | enumerable: true,
|
7550 | configurable: true
|
7551 | });
|
7552 | ;
|
7553 | Object.defineProperty(ComponentRef.prototype, "hostView", {
|
7554 | /**
|
7555 | * The {@link ViewRef} of the Host View of this Component instance.
|
7556 | * @return {?}
|
7557 | */
|
7558 | get: function () { return unimplemented(); },
|
7559 | enumerable: true,
|
7560 | configurable: true
|
7561 | });
|
7562 | ;
|
7563 | Object.defineProperty(ComponentRef.prototype, "changeDetectorRef", {
|
7564 | /**
|
7565 | * The {@link ChangeDetectorRef} of the Component instance.
|
7566 | * @return {?}
|
7567 | */
|
7568 | get: function () { return unimplemented(); },
|
7569 | enumerable: true,
|
7570 | configurable: true
|
7571 | });
|
7572 | Object.defineProperty(ComponentRef.prototype, "componentType", {
|
7573 | /**
|
7574 | * The component type.
|
7575 | * @return {?}
|
7576 | */
|
7577 | get: function () { return unimplemented(); },
|
7578 | enumerable: true,
|
7579 | configurable: true
|
7580 | });
|
7581 | /**
|
7582 | * Destroys the component instance and all of the data structures associated with it.
|
7583 | * @abstract
|
7584 | * @return {?}
|
7585 | */
|
7586 | ComponentRef.prototype.destroy = function () { };
|
7587 | /**
|
7588 | * Allows to register a callback that will be called when the component is destroyed.
|
7589 | * @abstract
|
7590 | * @param {?} callback
|
7591 | * @return {?}
|
7592 | */
|
7593 | ComponentRef.prototype.onDestroy = function (callback) { };
|
7594 | return ComponentRef;
|
7595 | }());
|
7596 | var ComponentRef_ = (function (_super) {
|
7597 | __extends$5(ComponentRef_, _super);
|
7598 | /**
|
7599 | * @param {?} _index
|
7600 | * @param {?} _parentView
|
7601 | * @param {?} _nativeElement
|
7602 | * @param {?} _component
|
7603 | */
|
7604 | function ComponentRef_(_index, _parentView, _nativeElement, _component) {
|
7605 | _super.call(this);
|
7606 | this._index = _index;
|
7607 | this._parentView = _parentView;
|
7608 | this._nativeElement = _nativeElement;
|
7609 | this._component = _component;
|
7610 | }
|
7611 | Object.defineProperty(ComponentRef_.prototype, "location", {
|
7612 | /**
|
7613 | * @return {?}
|
7614 | */
|
7615 | get: function () { return new ElementRef(this._nativeElement); },
|
7616 | enumerable: true,
|
7617 | configurable: true
|
7618 | });
|
7619 | Object.defineProperty(ComponentRef_.prototype, "injector", {
|
7620 | /**
|
7621 | * @return {?}
|
7622 | */
|
7623 | get: function () { return this._parentView.injector(this._index); },
|
7624 | enumerable: true,
|
7625 | configurable: true
|
7626 | });
|
7627 | Object.defineProperty(ComponentRef_.prototype, "instance", {
|
7628 | /**
|
7629 | * @return {?}
|
7630 | */
|
7631 | get: function () { return this._component; },
|
7632 | enumerable: true,
|
7633 | configurable: true
|
7634 | });
|
7635 | ;
|
7636 | Object.defineProperty(ComponentRef_.prototype, "hostView", {
|
7637 | /**
|
7638 | * @return {?}
|
7639 | */
|
7640 | get: function () { return this._parentView.ref; },
|
7641 | enumerable: true,
|
7642 | configurable: true
|
7643 | });
|
7644 | ;
|
7645 | Object.defineProperty(ComponentRef_.prototype, "changeDetectorRef", {
|
7646 | /**
|
7647 | * @return {?}
|
7648 | */
|
7649 | get: function () { return this._parentView.ref; },
|
7650 | enumerable: true,
|
7651 | configurable: true
|
7652 | });
|
7653 | ;
|
7654 | Object.defineProperty(ComponentRef_.prototype, "componentType", {
|
7655 | /**
|
7656 | * @return {?}
|
7657 | */
|
7658 | get: function () { return (this._component.constructor); },
|
7659 | enumerable: true,
|
7660 | configurable: true
|
7661 | });
|
7662 | /**
|
7663 | * @return {?}
|
7664 | */
|
7665 | ComponentRef_.prototype.destroy = function () { this._parentView.detachAndDestroy(); };
|
7666 | /**
|
7667 | * @param {?} callback
|
7668 | * @return {?}
|
7669 | */
|
7670 | ComponentRef_.prototype.onDestroy = function (callback) { this.hostView.onDestroy(callback); };
|
7671 | return ComponentRef_;
|
7672 | }(ComponentRef));
|
7673 | /**
|
7674 | * @stable
|
7675 | */
|
7676 | var ComponentFactory = (function () {
|
7677 | /**
|
7678 | * @param {?} selector
|
7679 | * @param {?} _viewClass
|
7680 | * @param {?} _componentType
|
7681 | */
|
7682 | function ComponentFactory(selector, _viewClass, _componentType) {
|
7683 | this.selector = selector;
|
7684 | this._viewClass = _viewClass;
|
7685 | this._componentType = _componentType;
|
7686 | }
|
7687 | Object.defineProperty(ComponentFactory.prototype, "componentType", {
|
7688 | /**
|
7689 | * @return {?}
|
7690 | */
|
7691 | get: function () { return this._componentType; },
|
7692 | enumerable: true,
|
7693 | configurable: true
|
7694 | });
|
7695 | /**
|
7696 | * Creates a new component.
|
7697 | * @param {?} injector
|
7698 | * @param {?=} projectableNodes
|
7699 | * @param {?=} rootSelectorOrNode
|
7700 | * @return {?}
|
7701 | */
|
7702 | ComponentFactory.prototype.create = function (injector, projectableNodes, rootSelectorOrNode) {
|
7703 | if (projectableNodes === void 0) { projectableNodes = null; }
|
7704 | if (rootSelectorOrNode === void 0) { rootSelectorOrNode = null; }
|
7705 | var /** @type {?} */ vu = injector.get(ViewUtils);
|
7706 | if (!projectableNodes) {
|
7707 | projectableNodes = [];
|
7708 | }
|
7709 | var /** @type {?} */ hostView = new this._viewClass(vu, null, null, null);
|
7710 | return hostView.createHostView(rootSelectorOrNode, injector, projectableNodes);
|
7711 | };
|
7712 | return ComponentFactory;
|
7713 | }());
|
7714 |
|
7715 | /**
|
7716 | * @license
|
7717 | * Copyright Google Inc. All Rights Reserved.
|
7718 | *
|
7719 | * Use of this source code is governed by an MIT-style license that can be
|
7720 | * found in the LICENSE file at https://angular.io/license
|
7721 | */
|
7722 | var __extends$8 = (this && this.__extends) || function (d, b) {
|
7723 | for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
7724 | function __() { this.constructor = d; }
|
7725 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
7726 | };
|
7727 | /**
|
7728 | * @stable
|
7729 | */
|
7730 | var NoComponentFactoryError = (function (_super) {
|
7731 | __extends$8(NoComponentFactoryError, _super);
|
7732 | /**
|
7733 | * @param {?} component
|
7734 | */
|
7735 | function NoComponentFactoryError(component) {
|
7736 | _super.call(this, "No component factory found for " + stringify(component));
|
7737 | this.component = component;
|
7738 | }
|
7739 | return NoComponentFactoryError;
|
7740 | }(BaseError));
|
7741 | var _NullComponentFactoryResolver = (function () {
|
7742 | function _NullComponentFactoryResolver() {
|
7743 | }
|
7744 | /**
|
7745 | * @param {?} component
|
7746 | * @return {?}
|
7747 | */
|
7748 | _NullComponentFactoryResolver.prototype.resolveComponentFactory = function (component) {
|
7749 | throw new NoComponentFactoryError(component);
|
7750 | };
|
7751 | return _NullComponentFactoryResolver;
|
7752 | }());
|
7753 | /**
|
7754 | * @abstract
|
7755 | */
|
7756 | var ComponentFactoryResolver = (function () {
|
7757 | function ComponentFactoryResolver() {
|
7758 | }
|
7759 | /**
|
7760 | * @abstract
|
7761 | * @param {?} component
|
7762 | * @return {?}
|
7763 | */
|
7764 | ComponentFactoryResolver.prototype.resolveComponentFactory = function (component) { };
|
7765 | ComponentFactoryResolver.NULL = new _NullComponentFactoryResolver();
|
7766 | return ComponentFactoryResolver;
|
7767 | }());
|
7768 | var CodegenComponentFactoryResolver = (function () {
|
7769 | /**
|
7770 | * @param {?} factories
|
7771 | * @param {?} _parent
|
7772 | */
|
7773 | function CodegenComponentFactoryResolver(factories, _parent) {
|
7774 | this._parent = _parent;
|
7775 | this._factories = new Map();
|
7776 | for (var i = 0; i < factories.length; i++) {
|
7777 | var factory = factories[i];
|
7778 | this._factories.set(factory.componentType, factory);
|
7779 | }
|
7780 | }
|
7781 | /**
|
7782 | * @param {?} component
|
7783 | * @return {?}
|
7784 | */
|
7785 | CodegenComponentFactoryResolver.prototype.resolveComponentFactory = function (component) {
|
7786 | var /** @type {?} */ result = this._factories.get(component);
|
7787 | if (!result) {
|
7788 | result = this._parent.resolveComponentFactory(component);
|
7789 | }
|
7790 | return result;
|
7791 | };
|
7792 | return CodegenComponentFactoryResolver;
|
7793 | }());
|
7794 |
|
7795 | var /** @type {?} */ trace;
|
7796 | var /** @type {?} */ events;
|
7797 | /**
|
7798 | * @return {?}
|
7799 | */
|
7800 | function detectWTF() {
|
7801 | var /** @type {?} */ wtf = ((global$1) /** TODO #9100 */)['wtf'];
|
7802 | if (wtf) {
|
7803 | trace = wtf['trace'];
|
7804 | if (trace) {
|
7805 | events = trace['events'];
|
7806 | return true;
|
7807 | }
|
7808 | }
|
7809 | return false;
|
7810 | }
|
7811 | /**
|
7812 | * @param {?} signature
|
7813 | * @param {?=} flags
|
7814 | * @return {?}
|
7815 | */
|
7816 | function createScope(signature, flags) {
|
7817 | if (flags === void 0) { flags = null; }
|
7818 | return events.createScope(signature, flags);
|
7819 | }
|
7820 | /**
|
7821 | * @param {?} scope
|
7822 | * @param {?=} returnValue
|
7823 | * @return {?}
|
7824 | */
|
7825 | function leave(scope, returnValue) {
|
7826 | trace.leaveScope(scope, returnValue);
|
7827 | return returnValue;
|
7828 | }
|
7829 | /**
|
7830 | * @param {?} rangeType
|
7831 | * @param {?} action
|
7832 | * @return {?}
|
7833 | */
|
7834 | function startTimeRange(rangeType, action) {
|
7835 | return trace.beginTimeRange(rangeType, action);
|
7836 | }
|
7837 | /**
|
7838 | * @param {?} range
|
7839 | * @return {?}
|
7840 | */
|
7841 | function endTimeRange(range) {
|
7842 | trace.endTimeRange(range);
|
7843 | }
|
7844 |
|
7845 | /**
|
7846 | * True if WTF is enabled.
|
7847 | */
|
7848 | var /** @type {?} */ wtfEnabled = detectWTF();
|
7849 | /**
|
7850 | * @param {?=} arg0
|
7851 | * @param {?=} arg1
|
7852 | * @return {?}
|
7853 | */
|
7854 | function noopScope(arg0, arg1) {
|
7855 | return null;
|
7856 | }
|
7857 | /**
|
7858 | * Create trace scope.
|
7859 | *
|
7860 | * Scopes must be strictly nested and are analogous to stack frames, but
|
7861 | * do not have to follow the stack frames. Instead it is recommended that they follow logical
|
7862 | * nesting. You may want to use
|
7863 | * [Event
|
7864 | * Signatures](http://google.github.io/tracing-framework/instrumenting-code.html#custom-events)
|
7865 | * as they are defined in WTF.
|
7866 | *
|
7867 | * Used to mark scope entry. The return value is used to leave the scope.
|
7868 | *
|
7869 | * var myScope = wtfCreateScope('MyClass#myMethod(ascii someVal)');
|
7870 | *
|
7871 | * someMethod() {
|
7872 | * var s = myScope('Foo'); // 'Foo' gets stored in tracing UI
|
7873 | * // DO SOME WORK HERE
|
7874 | * return wtfLeave(s, 123); // Return value 123
|
7875 | * }
|
7876 | *
|
7877 | * Note, adding try-finally block around the work to ensure that `wtfLeave` gets called can
|
7878 | * negatively impact the performance of your application. For this reason we recommend that
|
7879 | * you don't add them to ensure that `wtfLeave` gets called. In production `wtfLeave` is a noop and
|
7880 | * so try-finally block has no value. When debugging perf issues, skipping `wtfLeave`, do to
|
7881 | * exception, will produce incorrect trace, but presence of exception signifies logic error which
|
7882 | * needs to be fixed before the app should be profiled. Add try-finally only when you expect that
|
7883 | * an exception is expected during normal execution while profiling.
|
7884 | *
|
7885 | * @experimental
|
7886 | */
|
7887 | var /** @type {?} */ wtfCreateScope = wtfEnabled ? createScope : function (signature, flags) { return noopScope; };
|
7888 | /**
|
7889 | * Used to mark end of Scope.
|
7890 | *
|
7891 | * - `scope` to end.
|
7892 | * - `returnValue` (optional) to be passed to the WTF.
|
7893 | *
|
7894 | * Returns the `returnValue for easy chaining.
|
7895 | * @experimental
|
7896 | */
|
7897 | var /** @type {?} */ wtfLeave = wtfEnabled ? leave : function (s, r) { return r; };
|
7898 | /**
|
7899 | * Used to mark Async start. Async are similar to scope but they don't have to be strictly nested.
|
7900 | * The return value is used in the call to [endAsync]. Async ranges only work if WTF has been
|
7901 | * enabled.
|
7902 | *
|
7903 | * someMethod() {
|
7904 | * var s = wtfStartTimeRange('HTTP:GET', 'some.url');
|
7905 | * var future = new Future.delay(5).then((_) {
|
7906 | * wtfEndTimeRange(s);
|
7907 | * });
|
7908 | * }
|
7909 | * @experimental
|
7910 | */
|
7911 | var /** @type {?} */ wtfStartTimeRange = wtfEnabled ? startTimeRange : function (rangeType, action) { return null; };
|
7912 | /**
|
7913 | * Ends a async time range operation.
|
7914 | * [range] is the return value from [wtfStartTimeRange] Async ranges only work if WTF has been
|
7915 | * enabled.
|
7916 | * @experimental
|
7917 | */
|
7918 | var /** @type {?} */ wtfEndTimeRange = wtfEnabled ? endTimeRange : function (r) { return null; };
|
7919 |
|
7920 | /**
|
7921 | * The Testability service provides testing hooks that can be accessed from
|
7922 | * the browser and by services such as Protractor. Each bootstrapped Angular
|
7923 | * application on the page will have an instance of Testability.
|
7924 | */
|
7925 | var Testability = (function () {
|
7926 | /**
|
7927 | * @param {?} _ngZone
|
7928 | */
|
7929 | function Testability(_ngZone) {
|
7930 | this._ngZone = _ngZone;
|
7931 | /** @internal */
|
7932 | this._pendingCount = 0;
|
7933 | /** @internal */
|
7934 | this._isZoneStable = true;
|
7935 | /**
|
7936 | * Whether any work was done since the last 'whenStable' callback. This is
|
7937 | * useful to detect if this could have potentially destabilized another
|
7938 | * component while it is stabilizing.
|
7939 | * @internal
|
7940 | */
|
7941 | this._didWork = false;
|
7942 | /** @internal */
|
7943 | this._callbacks = [];
|
7944 | this._watchAngularEvents();
|
7945 | }
|
7946 | /**
|
7947 | * @return {?}
|
7948 | */
|
7949 | Testability.prototype._watchAngularEvents = function () {
|
7950 | var _this = this;
|
7951 | this._ngZone.onUnstable.subscribe({
|
7952 | next: function () {
|
7953 | _this._didWork = true;
|
7954 | _this._isZoneStable = false;
|
7955 | }
|
7956 | });
|
7957 | this._ngZone.runOutsideAngular(function () {
|
7958 | _this._ngZone.onStable.subscribe({
|
7959 | next: function () {
|
7960 | NgZone.assertNotInAngularZone();
|
7961 | scheduleMicroTask(function () {
|
7962 | _this._isZoneStable = true;
|
7963 | _this._runCallbacksIfReady();
|
7964 | });
|
7965 | }
|
7966 | });
|
7967 | });
|
7968 | };
|
7969 | /**
|
7970 | * @return {?}
|
7971 | */
|
7972 | Testability.prototype.increasePendingRequestCount = function () {
|
7973 | this._pendingCount += 1;
|
7974 | this._didWork = true;
|
7975 | return this._pendingCount;
|
7976 | };
|
7977 | /**
|
7978 | * @return {?}
|
7979 | */
|
7980 | Testability.prototype.decreasePendingRequestCount = function () {
|
7981 | this._pendingCount -= 1;
|
7982 | if (this._pendingCount < 0) {
|
7983 | throw new Error('pending async requests below zero');
|
7984 | }
|
7985 | this._runCallbacksIfReady();
|
7986 | return this._pendingCount;
|
7987 | };
|
7988 | /**
|
7989 | * @return {?}
|
7990 | */
|
7991 | Testability.prototype.isStable = function () {
|
7992 | return this._isZoneStable && this._pendingCount == 0 && !this._ngZone.hasPendingMacrotasks;
|
7993 | };
|
7994 | /**
|
7995 | * @return {?}
|
7996 | */
|
7997 | Testability.prototype._runCallbacksIfReady = function () {
|
7998 | var _this = this;
|
7999 | if (this.isStable()) {
|
8000 | // Schedules the call backs in a new frame so that it is always async.
|
8001 | scheduleMicroTask(function () {
|
8002 | while (_this._callbacks.length !== 0) {
|
8003 | (_this._callbacks.pop())(_this._didWork);
|
8004 | }
|
8005 | _this._didWork = false;
|
8006 | });
|
8007 | }
|
8008 | else {
|
8009 | // Not Ready
|
8010 | this._didWork = true;
|
8011 | }
|
8012 | };
|
8013 | /**
|
8014 | * @param {?} callback
|
8015 | * @return {?}
|
8016 | */
|
8017 | Testability.prototype.whenStable = function (callback) {
|
8018 | this._callbacks.push(callback);
|
8019 | this._runCallbacksIfReady();
|
8020 | };
|
8021 | /**
|
8022 | * @return {?}
|
8023 | */
|
8024 | Testability.prototype.getPendingRequestCount = function () { return this._pendingCount; };
|
8025 | /**
|
8026 | * @deprecated use findProviders
|
8027 | * @param {?} using
|
8028 | * @param {?} provider
|
8029 | * @param {?} exactMatch
|
8030 | * @return {?}
|
8031 | */
|
8032 | Testability.prototype.findBindings = function (using, provider, exactMatch) {
|
8033 | // TODO(juliemr): implement.
|
8034 | return [];
|
8035 | };
|
8036 | /**
|
8037 | * @param {?} using
|
8038 | * @param {?} provider
|
8039 | * @param {?} exactMatch
|
8040 | * @return {?}
|
8041 | */
|
8042 | Testability.prototype.findProviders = function (using, provider, exactMatch) {
|
8043 | // TODO(juliemr): implement.
|
8044 | return [];
|
8045 | };
|
8046 | Testability.decorators = [
|
8047 | { type: Injectable },
|
8048 | ];
|
8049 | /** @nocollapse */
|
8050 | Testability.ctorParameters = function () { return [
|
8051 | { type: NgZone, },
|
8052 | ]; };
|
8053 | return Testability;
|
8054 | }());
|
8055 | /**
|
8056 | * A global registry of {@link Testability} instances for specific elements.
|
8057 | */
|
8058 | var TestabilityRegistry = (function () {
|
8059 | function TestabilityRegistry() {
|
8060 | /** @internal */
|
8061 | this._applications = new Map();
|
8062 | _testabilityGetter.addToWindow(this);
|
8063 | }
|
8064 | /**
|
8065 | * @param {?} token
|
8066 | * @param {?} testability
|
8067 | * @return {?}
|
8068 | */
|
8069 | TestabilityRegistry.prototype.registerApplication = function (token, testability) {
|
8070 | this._applications.set(token, testability);
|
8071 | };
|
8072 | /**
|
8073 | * @param {?} elem
|
8074 | * @return {?}
|
8075 | */
|
8076 | TestabilityRegistry.prototype.getTestability = function (elem) { return this._applications.get(elem); };
|
8077 | /**
|
8078 | * @return {?}
|
8079 | */
|
8080 | TestabilityRegistry.prototype.getAllTestabilities = function () { return Array.from(this._applications.values()); };
|
8081 | /**
|
8082 | * @return {?}
|
8083 | */
|
8084 | TestabilityRegistry.prototype.getAllRootElements = function () { return Array.from(this._applications.keys()); };
|
8085 | /**
|
8086 | * @param {?} elem
|
8087 | * @param {?=} findInAncestors
|
8088 | * @return {?}
|
8089 | */
|
8090 | TestabilityRegistry.prototype.findTestabilityInTree = function (elem, findInAncestors) {
|
8091 | if (findInAncestors === void 0) { findInAncestors = true; }
|
8092 | return _testabilityGetter.findTestabilityInTree(this, elem, findInAncestors);
|
8093 | };
|
8094 | TestabilityRegistry.decorators = [
|
8095 | { type: Injectable },
|
8096 | ];
|
8097 | /** @nocollapse */
|
8098 | TestabilityRegistry.ctorParameters = function () { return []; };
|
8099 | return TestabilityRegistry;
|
8100 | }());
|
8101 | var _NoopGetTestability = (function () {
|
8102 | function _NoopGetTestability() {
|
8103 | }
|
8104 | /**
|
8105 | * @param {?} registry
|
8106 | * @return {?}
|
8107 | */
|
8108 | _NoopGetTestability.prototype.addToWindow = function (registry) { };
|
8109 | /**
|
8110 | * @param {?} registry
|
8111 | * @param {?} elem
|
8112 | * @param {?} findInAncestors
|
8113 | * @return {?}
|
8114 | */
|
8115 | _NoopGetTestability.prototype.findTestabilityInTree = function (registry, elem, findInAncestors) {
|
8116 | return null;
|
8117 | };
|
8118 | return _NoopGetTestability;
|
8119 | }());
|
8120 | /**
|
8121 | * Set the {@link GetTestability} implementation used by the Angular testing framework.
|
8122 | * @param {?} getter
|
8123 | * @return {?}
|
8124 | */
|
8125 | function setTestabilityGetter(getter) {
|
8126 | _testabilityGetter = getter;
|
8127 | }
|
8128 | var /** @type {?} */ _testabilityGetter = new _NoopGetTestability();
|
8129 |
|
8130 | /**
|
8131 | * @license
|
8132 | * Copyright Google Inc. All Rights Reserved.
|
8133 | *
|
8134 | * Use of this source code is governed by an MIT-style license that can be
|
8135 | * found in the LICENSE file at https://angular.io/license
|
8136 | */
|
8137 | var __extends$3 = (this && this.__extends) || function (d, b) {
|
8138 | for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
8139 | function __() { this.constructor = d; }
|
8140 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
8141 | };
|
8142 | var /** @type {?} */ _devMode = true;
|
8143 | var /** @type {?} */ _runModeLocked = false;
|
8144 | var /** @type {?} */ _platform;
|
8145 | /**
|
8146 | * Disable Angular's development mode, which turns off assertions and other
|
8147 | * checks within the framework.
|
8148 | * *
|
8149 | * One important assertion this disables verifies that a change detection pass
|
8150 | * does not result in additional changes to any bindings (also known as
|
8151 | * unidirectional data flow).
|
8152 | * *
|
8153 | * @return {?}
|
8154 | */
|
8155 | function enableProdMode() {
|
8156 | if (_runModeLocked) {
|
8157 | throw new Error('Cannot enable prod mode after platform setup.');
|
8158 | }
|
8159 | _devMode = false;
|
8160 | }
|
8161 | /**
|
8162 | * Returns whether Angular is in development mode. After called once,
|
8163 | * the value is locked and won't change any more.
|
8164 | * *
|
8165 | * By default, this is true, unless a user calls `enableProdMode` before calling this.
|
8166 | * *
|
8167 | * @return {?}
|
8168 | */
|
8169 | function isDevMode() {
|
8170 | _runModeLocked = true;
|
8171 | return _devMode;
|
8172 | }
|
8173 | /**
|
8174 | * A token for third-party components that can register themselves with NgProbe.
|
8175 | * *
|
8176 | */
|
8177 | var NgProbeToken = (function () {
|
8178 | /**
|
8179 | * @param {?} name
|
8180 | * @param {?} token
|
8181 | */
|
8182 | function NgProbeToken(name, token) {
|
8183 | this.name = name;
|
8184 | this.token = token;
|
8185 | }
|
8186 | return NgProbeToken;
|
8187 | }());
|
8188 | /**
|
8189 | * Creates a platform.
|
8190 | * Platforms have to be eagerly created via this function.
|
8191 | * *
|
8192 | * @param {?} injector
|
8193 | * @return {?}
|
8194 | */
|
8195 | function createPlatform(injector) {
|
8196 | if (_platform && !_platform.destroyed) {
|
8197 | throw new Error('There can be only one platform. Destroy the previous one to create a new one.');
|
8198 | }
|
8199 | _platform = injector.get(PlatformRef);
|
8200 | var /** @type {?} */ inits = (injector.get(PLATFORM_INITIALIZER, null));
|
8201 | if (inits)
|
8202 | inits.forEach(function (init) { return init(); });
|
8203 | return _platform;
|
8204 | }
|
8205 | /**
|
8206 | * Creates a factory for a platform
|
8207 | * *
|
8208 | * @param {?} parentPlatformFactory
|
8209 | * @param {?} name
|
8210 | * @param {?=} providers
|
8211 | * @return {?}
|
8212 | */
|
8213 | function createPlatformFactory(parentPlatformFactory, name, providers) {
|
8214 | if (providers === void 0) { providers = []; }
|
8215 | var /** @type {?} */ marker = new OpaqueToken("Platform: " + name);
|
8216 | return function (extraProviders) {
|
8217 | if (extraProviders === void 0) { extraProviders = []; }
|
8218 | if (!getPlatform()) {
|
8219 | if (parentPlatformFactory) {
|
8220 | parentPlatformFactory(providers.concat(extraProviders).concat({ provide: marker, useValue: true }));
|
8221 | }
|
8222 | else {
|
8223 | createPlatform(ReflectiveInjector.resolveAndCreate(providers.concat(extraProviders).concat({ provide: marker, useValue: true })));
|
8224 | }
|
8225 | }
|
8226 | return assertPlatform(marker);
|
8227 | };
|
8228 | }
|
8229 | /**
|
8230 | * Checks that there currently is a platform
|
8231 | * which contains the given token as a provider.
|
8232 | * *
|
8233 | * @param {?} requiredToken
|
8234 | * @return {?}
|
8235 | */
|
8236 | function assertPlatform(requiredToken) {
|
8237 | var /** @type {?} */ platform = getPlatform();
|
8238 | if (!platform) {
|
8239 | throw new Error('No platform exists!');
|
8240 | }
|
8241 | if (!platform.injector.get(requiredToken, null)) {
|
8242 | throw new Error('A platform with a different configuration has been created. Please destroy it first.');
|
8243 | }
|
8244 | return platform;
|
8245 | }
|
8246 | /**
|
8247 | * Destroy the existing platform.
|
8248 | * *
|
8249 | * @return {?}
|
8250 | */
|
8251 | function destroyPlatform() {
|
8252 | if (_platform && !_platform.destroyed) {
|
8253 | _platform.destroy();
|
8254 | }
|
8255 | }
|
8256 | /**
|
8257 | * Returns the current platform.
|
8258 | * *
|
8259 | * @return {?}
|
8260 | */
|
8261 | function getPlatform() {
|
8262 | return _platform && !_platform.destroyed ? _platform : null;
|
8263 | }
|
8264 | /**
|
8265 | * The Angular platform is the entry point for Angular on a web page. Each page
|
8266 | * has exactly one platform, and services (such as reflection) which are common
|
8267 | * to every Angular application running on the page are bound in its scope.
|
8268 | * *
|
8269 | * A page's platform is initialized implicitly when {@link bootstrap}() is called, or
|
8270 | * explicitly by calling {@link createPlatform}().
|
8271 | * *
|
8272 | * @abstract
|
8273 | */
|
8274 | var PlatformRef = (function () {
|
8275 | function PlatformRef() {
|
8276 | }
|
8277 | /**
|
8278 | * Creates an instance of an `@NgModule` for the given platform
|
8279 | * for offline compilation.
|
8280 | * *
|
8281 | * ## Simple Example
|
8282 | * *
|
8283 | * ```typescript
|
8284 | * my_module.ts:
|
8285 | * *
|
8286 | * imports: [BrowserModule]
|
8287 | * })
|
8288 | * class MyModule {}
|
8289 | * *
|
8290 | * main.ts:
|
8291 | * import {MyModuleNgFactory} from './my_module.ngfactory';
|
8292 | * import {platformBrowser} from '@angular/platform-browser';
|
8293 | * *
|
8294 | * let moduleRef = platformBrowser().bootstrapModuleFactory(MyModuleNgFactory);
|
8295 | * ```
|
8296 | * *
|
8297 | * @param {?} moduleFactory
|
8298 | * @return {?}
|
8299 | */
|
8300 | PlatformRef.prototype.bootstrapModuleFactory = function (moduleFactory) {
|
8301 | throw unimplemented();
|
8302 | };
|
8303 | /**
|
8304 | * Creates an instance of an `@NgModule` for a given platform using the given runtime compiler.
|
8305 | * *
|
8306 | * ## Simple Example
|
8307 | * *
|
8308 | * ```typescript
|
8309 | * imports: [BrowserModule]
|
8310 | * })
|
8311 | * class MyModule {}
|
8312 | * *
|
8313 | * let moduleRef = platformBrowser().bootstrapModule(MyModule);
|
8314 | * ```
|
8315 | * @param {?} moduleType
|
8316 | * @param {?=} compilerOptions
|
8317 | * @return {?}
|
8318 | */
|
8319 | PlatformRef.prototype.bootstrapModule = function (moduleType, compilerOptions) {
|
8320 | if (compilerOptions === void 0) { compilerOptions = []; }
|
8321 | throw unimplemented();
|
8322 | };
|
8323 | /**
|
8324 | * Register a listener to be called when the platform is disposed.
|
8325 | * @abstract
|
8326 | * @param {?} callback
|
8327 | * @return {?}
|
8328 | */
|
8329 | PlatformRef.prototype.onDestroy = function (callback) { };
|
8330 | Object.defineProperty(PlatformRef.prototype, "injector", {
|
8331 | /**
|
8332 | * Retrieve the platform {@link Injector}, which is the parent injector for
|
8333 | * every Angular application on the page and provides singleton providers.
|
8334 | * @return {?}
|
8335 | */
|
8336 | get: function () { throw unimplemented(); },
|
8337 | enumerable: true,
|
8338 | configurable: true
|
8339 | });
|
8340 | ;
|
8341 | /**
|
8342 | * Destroy the Angular platform and all Angular applications on the page.
|
8343 | * @abstract
|
8344 | * @return {?}
|
8345 | */
|
8346 | PlatformRef.prototype.destroy = function () { };
|
8347 | Object.defineProperty(PlatformRef.prototype, "destroyed", {
|
8348 | /**
|
8349 | * @return {?}
|
8350 | */
|
8351 | get: function () { throw unimplemented(); },
|
8352 | enumerable: true,
|
8353 | configurable: true
|
8354 | });
|
8355 | return PlatformRef;
|
8356 | }());
|
8357 | /**
|
8358 | * @param {?} errorHandler
|
8359 | * @param {?} callback
|
8360 | * @return {?}
|
8361 | */
|
8362 | function _callAndReportToErrorHandler(errorHandler, callback) {
|
8363 | try {
|
8364 | var /** @type {?} */ result = callback();
|
8365 | if (isPromise(result)) {
|
8366 | return result.catch(function (e) {
|
8367 | errorHandler.handleError(e);
|
8368 | // rethrow as the exception handler might not do it
|
8369 | throw e;
|
8370 | });
|
8371 | }
|
8372 | return result;
|
8373 | }
|
8374 | catch (e) {
|
8375 | errorHandler.handleError(e);
|
8376 | // rethrow as the exception handler might not do it
|
8377 | throw e;
|
8378 | }
|
8379 | }
|
8380 | var PlatformRef_ = (function (_super) {
|
8381 | __extends$3(PlatformRef_, _super);
|
8382 | /**
|
8383 | * @param {?} _injector
|
8384 | */
|
8385 | function PlatformRef_(_injector) {
|
8386 | _super.call(this);
|
8387 | this._injector = _injector;
|
8388 | this._modules = [];
|
8389 | this._destroyListeners = [];
|
8390 | this._destroyed = false;
|
8391 | }
|
8392 | /**
|
8393 | * @param {?} callback
|
8394 | * @return {?}
|
8395 | */
|
8396 | PlatformRef_.prototype.onDestroy = function (callback) { this._destroyListeners.push(callback); };
|
8397 | Object.defineProperty(PlatformRef_.prototype, "injector", {
|
8398 | /**
|
8399 | * @return {?}
|
8400 | */
|
8401 | get: function () { return this._injector; },
|
8402 | enumerable: true,
|
8403 | configurable: true
|
8404 | });
|
8405 | Object.defineProperty(PlatformRef_.prototype, "destroyed", {
|
8406 | /**
|
8407 | * @return {?}
|
8408 | */
|
8409 | get: function () { return this._destroyed; },
|
8410 | enumerable: true,
|
8411 | configurable: true
|
8412 | });
|
8413 | /**
|
8414 | * @return {?}
|
8415 | */
|
8416 | PlatformRef_.prototype.destroy = function () {
|
8417 | if (this._destroyed) {
|
8418 | throw new Error('The platform has already been destroyed!');
|
8419 | }
|
8420 | this._modules.slice().forEach(function (module) { return module.destroy(); });
|
8421 | this._destroyListeners.forEach(function (listener) { return listener(); });
|
8422 | this._destroyed = true;
|
8423 | };
|
8424 | /**
|
8425 | * @param {?} moduleFactory
|
8426 | * @return {?}
|
8427 | */
|
8428 | PlatformRef_.prototype.bootstrapModuleFactory = function (moduleFactory) {
|
8429 | return this._bootstrapModuleFactoryWithZone(moduleFactory, null);
|
8430 | };
|
8431 | /**
|
8432 | * @param {?} moduleFactory
|
8433 | * @param {?} ngZone
|
8434 | * @return {?}
|
8435 | */
|
8436 | PlatformRef_.prototype._bootstrapModuleFactoryWithZone = function (moduleFactory, ngZone) {
|
8437 | var _this = this;
|
8438 | // Note: We need to create the NgZone _before_ we instantiate the module,
|
8439 | // as instantiating the module creates some providers eagerly.
|
8440 | // So we create a mini parent injector that just contains the new NgZone and
|
8441 | // pass that as parent to the NgModuleFactory.
|
8442 | if (!ngZone)
|
8443 | ngZone = new NgZone({ enableLongStackTrace: isDevMode() });
|
8444 | // Attention: Don't use ApplicationRef.run here,
|
8445 | // as we want to be sure that all possible constructor calls are inside `ngZone.run`!
|
8446 | return ngZone.run(function () {
|
8447 | var /** @type {?} */ ngZoneInjector = ReflectiveInjector.resolveAndCreate([{ provide: NgZone, useValue: ngZone }], _this.injector);
|
8448 | var /** @type {?} */ moduleRef = (moduleFactory.create(ngZoneInjector));
|
8449 | var /** @type {?} */ exceptionHandler = moduleRef.injector.get(ErrorHandler, null);
|
8450 | if (!exceptionHandler) {
|
8451 | throw new Error('No ErrorHandler. Is platform module (BrowserModule) included?');
|
8452 | }
|
8453 | moduleRef.onDestroy(function () { return ListWrapper.remove(_this._modules, moduleRef); });
|
8454 | ngZone.onError.subscribe({ next: function (error) { exceptionHandler.handleError(error); } });
|
8455 | return _callAndReportToErrorHandler(exceptionHandler, function () {
|
8456 | var /** @type {?} */ initStatus = moduleRef.injector.get(ApplicationInitStatus);
|
8457 | return initStatus.donePromise.then(function () {
|
8458 | _this._moduleDoBootstrap(moduleRef);
|
8459 | return moduleRef;
|
8460 | });
|
8461 | });
|
8462 | });
|
8463 | };
|
8464 | /**
|
8465 | * @param {?} moduleType
|
8466 | * @param {?=} compilerOptions
|
8467 | * @return {?}
|
8468 | */
|
8469 | PlatformRef_.prototype.bootstrapModule = function (moduleType, compilerOptions) {
|
8470 | if (compilerOptions === void 0) { compilerOptions = []; }
|
8471 | return this._bootstrapModuleWithZone(moduleType, compilerOptions, null);
|
8472 | };
|
8473 | /**
|
8474 | * @param {?} moduleType
|
8475 | * @param {?=} compilerOptions
|
8476 | * @param {?} ngZone
|
8477 | * @param {?=} componentFactoryCallback
|
8478 | * @return {?}
|
8479 | */
|
8480 | PlatformRef_.prototype._bootstrapModuleWithZone = function (moduleType, compilerOptions, ngZone, componentFactoryCallback) {
|
8481 | var _this = this;
|
8482 | if (compilerOptions === void 0) { compilerOptions = []; }
|
8483 | var /** @type {?} */ compilerFactory = this.injector.get(CompilerFactory);
|
8484 | var /** @type {?} */ compiler = compilerFactory.createCompiler(Array.isArray(compilerOptions) ? compilerOptions : [compilerOptions]);
|
8485 | // ugly internal api hack: generate host component factories for all declared components and
|
8486 | // pass the factories into the callback - this is used by UpdateAdapter to get hold of all
|
8487 | // factories.
|
8488 | if (componentFactoryCallback) {
|
8489 | return compiler.compileModuleAndAllComponentsAsync(moduleType)
|
8490 | .then(function (_a) {
|
8491 | var ngModuleFactory = _a.ngModuleFactory, componentFactories = _a.componentFactories;
|
8492 | componentFactoryCallback(componentFactories);
|
8493 | return _this._bootstrapModuleFactoryWithZone(ngModuleFactory, ngZone);
|
8494 | });
|
8495 | }
|
8496 | return compiler.compileModuleAsync(moduleType)
|
8497 | .then(function (moduleFactory) { return _this._bootstrapModuleFactoryWithZone(moduleFactory, ngZone); });
|
8498 | };
|
8499 | /**
|
8500 | * @param {?} moduleRef
|
8501 | * @return {?}
|
8502 | */
|
8503 | PlatformRef_.prototype._moduleDoBootstrap = function (moduleRef) {
|
8504 | var /** @type {?} */ appRef = moduleRef.injector.get(ApplicationRef);
|
8505 | if (moduleRef.bootstrapFactories.length > 0) {
|
8506 | moduleRef.bootstrapFactories.forEach(function (compFactory) { return appRef.bootstrap(compFactory); });
|
8507 | }
|
8508 | else if (moduleRef.instance.ngDoBootstrap) {
|
8509 | moduleRef.instance.ngDoBootstrap(appRef);
|
8510 | }
|
8511 | else {
|
8512 | throw new Error(("The module " + stringify(moduleRef.instance.constructor) + " was bootstrapped, but it does not declare \"@NgModule.bootstrap\" components nor a \"ngDoBootstrap\" method. ") +
|
8513 | "Please define one of these.");
|
8514 | }
|
8515 | };
|
8516 | PlatformRef_.decorators = [
|
8517 | { type: Injectable },
|
8518 | ];
|
8519 | /** @nocollapse */
|
8520 | PlatformRef_.ctorParameters = function () { return [
|
8521 | { type: Injector, },
|
8522 | ]; };
|
8523 | return PlatformRef_;
|
8524 | }(PlatformRef));
|
8525 | /**
|
8526 | * A reference to an Angular application running on a page.
|
8527 | * *
|
8528 | * For more about Angular applications, see the documentation for {@link bootstrap}.
|
8529 | * *
|
8530 | * @abstract
|
8531 | */
|
8532 | var ApplicationRef = (function () {
|
8533 | function ApplicationRef() {
|
8534 | }
|
8535 | /**
|
8536 | * Bootstrap a new component at the root level of the application.
|
8537 | * *
|
8538 | * ### Bootstrap process
|
8539 | * *
|
8540 | * When bootstrapping a new root component into an application, Angular mounts the
|
8541 | * specified application component onto DOM elements identified by the [componentType]'s
|
8542 | * selector and kicks off automatic change detection to finish initializing the component.
|
8543 | * *
|
8544 | * ### Example
|
8545 | * {@example core/ts/platform/platform.ts region='longform'}
|
8546 | * @abstract
|
8547 | * @param {?} componentFactory
|
8548 | * @return {?}
|
8549 | */
|
8550 | ApplicationRef.prototype.bootstrap = function (componentFactory) { };
|
8551 | /**
|
8552 | * Invoke this method to explicitly process change detection and its side-effects.
|
8553 | * *
|
8554 | * In development mode, `tick()` also performs a second change detection cycle to ensure that no
|
8555 | * further changes are detected. If additional changes are picked up during this second cycle,
|
8556 | * bindings in the app have side-effects that cannot be resolved in a single change detection
|
8557 | * pass.
|
8558 | * In this case, Angular throws an error, since an Angular application can only have one change
|
8559 | * detection pass during which all change detection must complete.
|
8560 | * @abstract
|
8561 | * @return {?}
|
8562 | */
|
8563 | ApplicationRef.prototype.tick = function () { };
|
8564 | Object.defineProperty(ApplicationRef.prototype, "componentTypes", {
|
8565 | /**
|
8566 | * Get a list of component types registered to this application.
|
8567 | * This list is populated even before the component is created.
|
8568 | * @return {?}
|
8569 | */
|
8570 | get: function () { return (unimplemented()); },
|
8571 | enumerable: true,
|
8572 | configurable: true
|
8573 | });
|
8574 | ;
|
8575 | Object.defineProperty(ApplicationRef.prototype, "components", {
|
8576 | /**
|
8577 | * Get a list of components registered to this application.
|
8578 | * @return {?}
|
8579 | */
|
8580 | get: function () { return (unimplemented()); },
|
8581 | enumerable: true,
|
8582 | configurable: true
|
8583 | });
|
8584 | ;
|
8585 | /**
|
8586 | * Attaches a view so that it will be dirty checked.
|
8587 | * The view will be automatically detached when it is destroyed.
|
8588 | * This will throw if the view is already attached to a ViewContainer.
|
8589 | * @param {?} view
|
8590 | * @return {?}
|
8591 | */
|
8592 | ApplicationRef.prototype.attachView = function (view) { unimplemented(); };
|
8593 | /**
|
8594 | * Detaches a view from dirty checking again.
|
8595 | * @param {?} view
|
8596 | * @return {?}
|
8597 | */
|
8598 | ApplicationRef.prototype.detachView = function (view) { unimplemented(); };
|
8599 | Object.defineProperty(ApplicationRef.prototype, "viewCount", {
|
8600 | /**
|
8601 | * Returns the number of attached views.
|
8602 | * @return {?}
|
8603 | */
|
8604 | get: function () { return unimplemented(); },
|
8605 | enumerable: true,
|
8606 | configurable: true
|
8607 | });
|
8608 | return ApplicationRef;
|
8609 | }());
|
8610 | var ApplicationRef_ = (function (_super) {
|
8611 | __extends$3(ApplicationRef_, _super);
|
8612 | /**
|
8613 | * @param {?} _zone
|
8614 | * @param {?} _console
|
8615 | * @param {?} _injector
|
8616 | * @param {?} _exceptionHandler
|
8617 | * @param {?} _componentFactoryResolver
|
8618 | * @param {?} _initStatus
|
8619 | * @param {?} _testabilityRegistry
|
8620 | * @param {?} _testability
|
8621 | */
|
8622 | function ApplicationRef_(_zone, _console, _injector, _exceptionHandler, _componentFactoryResolver, _initStatus, _testabilityRegistry, _testability) {
|
8623 | var _this = this;
|
8624 | _super.call(this);
|
8625 | this._zone = _zone;
|
8626 | this._console = _console;
|
8627 | this._injector = _injector;
|
8628 | this._exceptionHandler = _exceptionHandler;
|
8629 | this._componentFactoryResolver = _componentFactoryResolver;
|
8630 | this._initStatus = _initStatus;
|
8631 | this._testabilityRegistry = _testabilityRegistry;
|
8632 | this._testability = _testability;
|
8633 | this._bootstrapListeners = [];
|
8634 | this._rootComponents = [];
|
8635 | this._rootComponentTypes = [];
|
8636 | this._views = [];
|
8637 | this._runningTick = false;
|
8638 | this._enforceNoNewChanges = false;
|
8639 | this._enforceNoNewChanges = isDevMode();
|
8640 | this._zone.onMicrotaskEmpty.subscribe({ next: function () { _this._zone.run(function () { _this.tick(); }); } });
|
8641 | }
|
8642 | /**
|
8643 | * @param {?} viewRef
|
8644 | * @return {?}
|
8645 | */
|
8646 | ApplicationRef_.prototype.attachView = function (viewRef) {
|
8647 | var /** @type {?} */ view = ((viewRef)).internalView;
|
8648 | this._views.push(view);
|
8649 | view.attachToAppRef(this);
|
8650 | };
|
8651 | /**
|
8652 | * @param {?} viewRef
|
8653 | * @return {?}
|
8654 | */
|
8655 | ApplicationRef_.prototype.detachView = function (viewRef) {
|
8656 | var /** @type {?} */ view = ((viewRef)).internalView;
|
8657 | ListWrapper.remove(this._views, view);
|
8658 | view.detach();
|
8659 | };
|
8660 | /**
|
8661 | * @param {?} componentOrFactory
|
8662 | * @return {?}
|
8663 | */
|
8664 | ApplicationRef_.prototype.bootstrap = function (componentOrFactory) {
|
8665 | var _this = this;
|
8666 | if (!this._initStatus.done) {
|
8667 | throw new Error('Cannot bootstrap as there are still asynchronous initializers running. Bootstrap components in the `ngDoBootstrap` method of the root module.');
|
8668 | }
|
8669 | var /** @type {?} */ componentFactory;
|
8670 | if (componentOrFactory instanceof ComponentFactory) {
|
8671 | componentFactory = componentOrFactory;
|
8672 | }
|
8673 | else {
|
8674 | componentFactory = this._componentFactoryResolver.resolveComponentFactory(componentOrFactory);
|
8675 | }
|
8676 | this._rootComponentTypes.push(componentFactory.componentType);
|
8677 | var /** @type {?} */ compRef = componentFactory.create(this._injector, [], componentFactory.selector);
|
8678 | compRef.onDestroy(function () { _this._unloadComponent(compRef); });
|
8679 | var /** @type {?} */ testability = compRef.injector.get(Testability, null);
|
8680 | if (testability) {
|
8681 | compRef.injector.get(TestabilityRegistry)
|
8682 | .registerApplication(compRef.location.nativeElement, testability);
|
8683 | }
|
8684 | this._loadComponent(compRef);
|
8685 | if (isDevMode()) {
|
8686 | this._console.log("Angular 2 is running in the development mode. Call enableProdMode() to enable the production mode.");
|
8687 | }
|
8688 | return compRef;
|
8689 | };
|
8690 | /**
|
8691 | * @param {?} componentRef
|
8692 | * @return {?}
|
8693 | */
|
8694 | ApplicationRef_.prototype._loadComponent = function (componentRef) {
|
8695 | this.attachView(componentRef.hostView);
|
8696 | this.tick();
|
8697 | this._rootComponents.push(componentRef);
|
8698 | // Get the listeners lazily to prevent DI cycles.
|
8699 | var /** @type {?} */ listeners = (this._injector.get(APP_BOOTSTRAP_LISTENER, [])
|
8700 | .concat(this._bootstrapListeners));
|
8701 | listeners.forEach(function (listener) { return listener(componentRef); });
|
8702 | };
|
8703 | /**
|
8704 | * @param {?} componentRef
|
8705 | * @return {?}
|
8706 | */
|
8707 | ApplicationRef_.prototype._unloadComponent = function (componentRef) {
|
8708 | this.detachView(componentRef.hostView);
|
8709 | ListWrapper.remove(this._rootComponents, componentRef);
|
8710 | };
|
8711 | /**
|
8712 | * @return {?}
|
8713 | */
|
8714 | ApplicationRef_.prototype.tick = function () {
|
8715 | if (this._runningTick) {
|
8716 | throw new Error('ApplicationRef.tick is called recursively');
|
8717 | }
|
8718 | var /** @type {?} */ scope = ApplicationRef_._tickScope();
|
8719 | try {
|
8720 | this._runningTick = true;
|
8721 | this._views.forEach(function (view) { return view.ref.detectChanges(); });
|
8722 | if (this._enforceNoNewChanges) {
|
8723 | this._views.forEach(function (view) { return view.ref.checkNoChanges(); });
|
8724 | }
|
8725 | }
|
8726 | finally {
|
8727 | this._runningTick = false;
|
8728 | wtfLeave(scope);
|
8729 | }
|
8730 | };
|
8731 | /**
|
8732 | * @return {?}
|
8733 | */
|
8734 | ApplicationRef_.prototype.ngOnDestroy = function () {
|
8735 | // TODO(alxhub): Dispose of the NgZone.
|
8736 | this._views.slice().forEach(function (view) { return view.destroy(); });
|
8737 | };
|
8738 | Object.defineProperty(ApplicationRef_.prototype, "viewCount", {
|
8739 | /**
|
8740 | * @return {?}
|
8741 | */
|
8742 | get: function () { return this._views.length; },
|
8743 | enumerable: true,
|
8744 | configurable: true
|
8745 | });
|
8746 | Object.defineProperty(ApplicationRef_.prototype, "componentTypes", {
|
8747 | /**
|
8748 | * @return {?}
|
8749 | */
|
8750 | get: function () { return this._rootComponentTypes; },
|
8751 | enumerable: true,
|
8752 | configurable: true
|
8753 | });
|
8754 | Object.defineProperty(ApplicationRef_.prototype, "components", {
|
8755 | /**
|
8756 | * @return {?}
|
8757 | */
|
8758 | get: function () { return this._rootComponents; },
|
8759 | enumerable: true,
|
8760 | configurable: true
|
8761 | });
|
8762 | /** @internal */
|
8763 | ApplicationRef_._tickScope = wtfCreateScope('ApplicationRef#tick()');
|
8764 | ApplicationRef_.decorators = [
|
8765 | { type: Injectable },
|
8766 | ];
|
8767 | /** @nocollapse */
|
8768 | ApplicationRef_.ctorParameters = function () { return [
|
8769 | { type: NgZone, },
|
8770 | { type: Console, },
|
8771 | { type: Injector, },
|
8772 | { type: ErrorHandler, },
|
8773 | { type: ComponentFactoryResolver, },
|
8774 | { type: ApplicationInitStatus, },
|
8775 | { type: TestabilityRegistry, decorators: [{ type: Optional },] },
|
8776 | { type: Testability, decorators: [{ type: Optional },] },
|
8777 | ]; };
|
8778 | return ApplicationRef_;
|
8779 | }(ApplicationRef));
|
8780 |
|
8781 | /**
|
8782 | * @license
|
8783 | * Copyright Google Inc. All Rights Reserved.
|
8784 | *
|
8785 | * Use of this source code is governed by an MIT-style license that can be
|
8786 | * found in the LICENSE file at https://angular.io/license
|
8787 | */
|
8788 | var __extends$9 = (this && this.__extends) || function (d, b) {
|
8789 | for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
8790 | function __() { this.constructor = d; }
|
8791 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
8792 | };
|
8793 | /**
|
8794 | * Represents an instance of an NgModule created via a {@link NgModuleFactory}.
|
8795 | * *
|
8796 | * `NgModuleRef` provides access to the NgModule Instance as well other objects related to this
|
8797 | * NgModule Instance.
|
8798 | * *
|
8799 | * @abstract
|
8800 | */
|
8801 | var NgModuleRef = (function () {
|
8802 | function NgModuleRef() {
|
8803 | }
|
8804 | Object.defineProperty(NgModuleRef.prototype, "injector", {
|
8805 | /**
|
8806 | * The injector that contains all of the providers of the NgModule.
|
8807 | * @return {?}
|
8808 | */
|
8809 | get: function () { return unimplemented(); },
|
8810 | enumerable: true,
|
8811 | configurable: true
|
8812 | });
|
8813 | Object.defineProperty(NgModuleRef.prototype, "componentFactoryResolver", {
|
8814 | /**
|
8815 | * The ComponentFactoryResolver to get hold of the ComponentFactories
|
8816 | * declared in the `entryComponents` property of the module.
|
8817 | * @return {?}
|
8818 | */
|
8819 | get: function () { return unimplemented(); },
|
8820 | enumerable: true,
|
8821 | configurable: true
|
8822 | });
|
8823 | Object.defineProperty(NgModuleRef.prototype, "instance", {
|
8824 | /**
|
8825 | * The NgModule instance.
|
8826 | * @return {?}
|
8827 | */
|
8828 | get: function () { return unimplemented(); },
|
8829 | enumerable: true,
|
8830 | configurable: true
|
8831 | });
|
8832 | /**
|
8833 | * Destroys the module instance and all of the data structures associated with it.
|
8834 | * @abstract
|
8835 | * @return {?}
|
8836 | */
|
8837 | NgModuleRef.prototype.destroy = function () { };
|
8838 | /**
|
8839 | * Allows to register a callback that will be called when the module is destroyed.
|
8840 | * @abstract
|
8841 | * @param {?} callback
|
8842 | * @return {?}
|
8843 | */
|
8844 | NgModuleRef.prototype.onDestroy = function (callback) { };
|
8845 | return NgModuleRef;
|
8846 | }());
|
8847 | /**
|
8848 | * @experimental
|
8849 | */
|
8850 | var NgModuleFactory = (function () {
|
8851 | /**
|
8852 | * @param {?} _injectorClass
|
8853 | * @param {?} _moduleType
|
8854 | */
|
8855 | function NgModuleFactory(_injectorClass, _moduleType) {
|
8856 | this._injectorClass = _injectorClass;
|
8857 | this._moduleType = _moduleType;
|
8858 | }
|
8859 | Object.defineProperty(NgModuleFactory.prototype, "moduleType", {
|
8860 | /**
|
8861 | * @return {?}
|
8862 | */
|
8863 | get: function () { return this._moduleType; },
|
8864 | enumerable: true,
|
8865 | configurable: true
|
8866 | });
|
8867 | /**
|
8868 | * @param {?} parentInjector
|
8869 | * @return {?}
|
8870 | */
|
8871 | NgModuleFactory.prototype.create = function (parentInjector) {
|
8872 | if (!parentInjector) {
|
8873 | parentInjector = Injector.NULL;
|
8874 | }
|
8875 | var /** @type {?} */ instance = new this._injectorClass(parentInjector);
|
8876 | instance.create();
|
8877 | return instance;
|
8878 | };
|
8879 | return NgModuleFactory;
|
8880 | }());
|
8881 | var /** @type {?} */ _UNDEFINED = new Object();
|
8882 | /**
|
8883 | * @abstract
|
8884 | */
|
8885 | var NgModuleInjector = (function (_super) {
|
8886 | __extends$9(NgModuleInjector, _super);
|
8887 | /**
|
8888 | * @param {?} parent
|
8889 | * @param {?} factories
|
8890 | * @param {?} bootstrapFactories
|
8891 | */
|
8892 | function NgModuleInjector(parent, factories, bootstrapFactories) {
|
8893 | _super.call(this, factories, parent.get(ComponentFactoryResolver, ComponentFactoryResolver.NULL));
|
8894 | this.parent = parent;
|
8895 | this.bootstrapFactories = bootstrapFactories;
|
8896 | this._destroyListeners = [];
|
8897 | this._destroyed = false;
|
8898 | }
|
8899 | /**
|
8900 | * @return {?}
|
8901 | */
|
8902 | NgModuleInjector.prototype.create = function () { this.instance = this.createInternal(); };
|
8903 | /**
|
8904 | * @abstract
|
8905 | * @return {?}
|
8906 | */
|
8907 | NgModuleInjector.prototype.createInternal = function () { };
|
8908 | /**
|
8909 | * @param {?} token
|
8910 | * @param {?=} notFoundValue
|
8911 | * @return {?}
|
8912 | */
|
8913 | NgModuleInjector.prototype.get = function (token, notFoundValue) {
|
8914 | if (notFoundValue === void 0) { notFoundValue = THROW_IF_NOT_FOUND; }
|
8915 | if (token === Injector || token === ComponentFactoryResolver) {
|
8916 | return this;
|
8917 | }
|
8918 | var /** @type {?} */ result = this.getInternal(token, _UNDEFINED);
|
8919 | return result === _UNDEFINED ? this.parent.get(token, notFoundValue) : result;
|
8920 | };
|
8921 | /**
|
8922 | * @abstract
|
8923 | * @param {?} token
|
8924 | * @param {?} notFoundValue
|
8925 | * @return {?}
|
8926 | */
|
8927 | NgModuleInjector.prototype.getInternal = function (token, notFoundValue) { };
|
8928 | Object.defineProperty(NgModuleInjector.prototype, "injector", {
|
8929 | /**
|
8930 | * @return {?}
|
8931 | */
|
8932 | get: function () { return this; },
|
8933 | enumerable: true,
|
8934 | configurable: true
|
8935 | });
|
8936 | Object.defineProperty(NgModuleInjector.prototype, "componentFactoryResolver", {
|
8937 | /**
|
8938 | * @return {?}
|
8939 | */
|
8940 | get: function () { return this; },
|
8941 | enumerable: true,
|
8942 | configurable: true
|
8943 | });
|
8944 | /**
|
8945 | * @return {?}
|
8946 | */
|
8947 | NgModuleInjector.prototype.destroy = function () {
|
8948 | if (this._destroyed) {
|
8949 | throw new Error("The ng module " + stringify(this.instance.constructor) + " has already been destroyed.");
|
8950 | }
|
8951 | this._destroyed = true;
|
8952 | this.destroyInternal();
|
8953 | this._destroyListeners.forEach(function (listener) { return listener(); });
|
8954 | };
|
8955 | /**
|
8956 | * @param {?} callback
|
8957 | * @return {?}
|
8958 | */
|
8959 | NgModuleInjector.prototype.onDestroy = function (callback) { this._destroyListeners.push(callback); };
|
8960 | /**
|
8961 | * @abstract
|
8962 | * @return {?}
|
8963 | */
|
8964 | NgModuleInjector.prototype.destroyInternal = function () { };
|
8965 | return NgModuleInjector;
|
8966 | }(CodegenComponentFactoryResolver));
|
8967 |
|
8968 | /**
|
8969 | * @license
|
8970 | * Copyright Google Inc. All Rights Reserved.
|
8971 | *
|
8972 | * Use of this source code is governed by an MIT-style license that can be
|
8973 | * found in the LICENSE file at https://angular.io/license
|
8974 | */
|
8975 | /**
|
8976 | * Used to load ng module factories.
|
8977 | * @abstract
|
8978 | */
|
8979 | var NgModuleFactoryLoader = (function () {
|
8980 | function NgModuleFactoryLoader() {
|
8981 | }
|
8982 | /**
|
8983 | * @abstract
|
8984 | * @param {?} path
|
8985 | * @return {?}
|
8986 | */
|
8987 | NgModuleFactoryLoader.prototype.load = function (path) { };
|
8988 | return NgModuleFactoryLoader;
|
8989 | }());
|
8990 | var /** @type {?} */ moduleFactories = new Map();
|
8991 | /**
|
8992 | * Registers a loaded module. Should only be called from generated NgModuleFactory code.
|
8993 | * @param {?} id
|
8994 | * @param {?} factory
|
8995 | * @return {?}
|
8996 | */
|
8997 | function registerModuleFactory(id, factory) {
|
8998 | var /** @type {?} */ existing = moduleFactories.get(id);
|
8999 | if (existing) {
|
9000 | throw new Error("Duplicate module registered for " + id + " - " + existing.moduleType.name + " vs " + factory.moduleType.name);
|
9001 | }
|
9002 | moduleFactories.set(id, factory);
|
9003 | }
|
9004 | /**
|
9005 | * Returns the NgModuleFactory with the given id, if it exists and has been loaded.
|
9006 | * Factories for modules that do not specify an `id` cannot be retrieved. Throws if the module
|
9007 | * cannot be found.
|
9008 | * @param {?} id
|
9009 | * @return {?}
|
9010 | */
|
9011 | function getModuleFactory(id) {
|
9012 | var /** @type {?} */ factory = moduleFactories.get(id);
|
9013 | if (!factory)
|
9014 | throw new Error("No module with ID " + id + " loaded");
|
9015 | return factory;
|
9016 | }
|
9017 |
|
9018 | /**
|
9019 | * An unmodifiable list of items that Angular keeps up to date when the state
|
9020 | * of the application changes.
|
9021 | * *
|
9022 | * The type of object that {@link Query} and {@link ViewQueryMetadata} provide.
|
9023 | * *
|
9024 | * Implements an iterable interface, therefore it can be used in both ES6
|
9025 | * javascript `for (var i of items)` loops as well as in Angular templates with
|
9026 | * `*ngFor="let i of myList"`.
|
9027 | * *
|
9028 | * Changes can be observed by subscribing to the changes `Observable`.
|
9029 | * *
|
9030 | * NOTE: In the future this class will implement an `Observable` interface.
|
9031 | * *
|
9032 | * ### Example ([live demo](http://plnkr.co/edit/RX8sJnQYl9FWuSCWme5z?p=preview))
|
9033 | * ```typescript
|
9034 | * class Container {
|
9035 | * @ViewChildren(Item) items:QueryList<Item>;
|
9036 | * }
|
9037 | * ```
|
9038 | */
|
9039 | var QueryList = (function () {
|
9040 | function QueryList() {
|
9041 | this._dirty = true;
|
9042 | this._results = [];
|
9043 | this._emitter = new EventEmitter();
|
9044 | }
|
9045 | Object.defineProperty(QueryList.prototype, "changes", {
|
9046 | /**
|
9047 | * @return {?}
|
9048 | */
|
9049 | get: function () { return this._emitter; },
|
9050 | enumerable: true,
|
9051 | configurable: true
|
9052 | });
|
9053 | Object.defineProperty(QueryList.prototype, "length", {
|
9054 | /**
|
9055 | * @return {?}
|
9056 | */
|
9057 | get: function () { return this._results.length; },
|
9058 | enumerable: true,
|
9059 | configurable: true
|
9060 | });
|
9061 | Object.defineProperty(QueryList.prototype, "first", {
|
9062 | /**
|
9063 | * @return {?}
|
9064 | */
|
9065 | get: function () { return this._results[0]; },
|
9066 | enumerable: true,
|
9067 | configurable: true
|
9068 | });
|
9069 | Object.defineProperty(QueryList.prototype, "last", {
|
9070 | /**
|
9071 | * @return {?}
|
9072 | */
|
9073 | get: function () { return this._results[this.length - 1]; },
|
9074 | enumerable: true,
|
9075 | configurable: true
|
9076 | });
|
9077 | /**
|
9078 | * See
|
9079 | * [Array.map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map)
|
9080 | * @param {?} fn
|
9081 | * @return {?}
|
9082 | */
|
9083 | QueryList.prototype.map = function (fn) { return this._results.map(fn); };
|
9084 | /**
|
9085 | * See
|
9086 | * [Array.filter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter)
|
9087 | * @param {?} fn
|
9088 | * @return {?}
|
9089 | */
|
9090 | QueryList.prototype.filter = function (fn) {
|
9091 | return this._results.filter(fn);
|
9092 | };
|
9093 | /**
|
9094 | * See
|
9095 | * [Array.find](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find)
|
9096 | * @param {?} fn
|
9097 | * @return {?}
|
9098 | */
|
9099 | QueryList.prototype.find = function (fn) { return this._results.find(fn); };
|
9100 | /**
|
9101 | * See
|
9102 | * [Array.reduce](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce)
|
9103 | * @param {?} fn
|
9104 | * @param {?} init
|
9105 | * @return {?}
|
9106 | */
|
9107 | QueryList.prototype.reduce = function (fn, init) {
|
9108 | return this._results.reduce(fn, init);
|
9109 | };
|
9110 | /**
|
9111 | * See
|
9112 | * [Array.forEach](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach)
|
9113 | * @param {?} fn
|
9114 | * @return {?}
|
9115 | */
|
9116 | QueryList.prototype.forEach = function (fn) { this._results.forEach(fn); };
|
9117 | /**
|
9118 | * See
|
9119 | * [Array.some](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some)
|
9120 | * @param {?} fn
|
9121 | * @return {?}
|
9122 | */
|
9123 | QueryList.prototype.some = function (fn) {
|
9124 | return this._results.some(fn);
|
9125 | };
|
9126 | /**
|
9127 | * @return {?}
|
9128 | */
|
9129 | QueryList.prototype.toArray = function () { return this._results.slice(); };
|
9130 | /**
|
9131 | * @return {?}
|
9132 | */
|
9133 | QueryList.prototype[getSymbolIterator()] = function () { return ((this._results))[getSymbolIterator()](); };
|
9134 | /**
|
9135 | * @return {?}
|
9136 | */
|
9137 | QueryList.prototype.toString = function () { return this._results.toString(); };
|
9138 | /**
|
9139 | * @param {?} res
|
9140 | * @return {?}
|
9141 | */
|
9142 | QueryList.prototype.reset = function (res) {
|
9143 | this._results = ListWrapper.flatten(res);
|
9144 | this._dirty = false;
|
9145 | };
|
9146 | /**
|
9147 | * @return {?}
|
9148 | */
|
9149 | QueryList.prototype.notifyOnChanges = function () { this._emitter.emit(this); };
|
9150 | /**
|
9151 | * internal
|
9152 | * @return {?}
|
9153 | */
|
9154 | QueryList.prototype.setDirty = function () { this._dirty = true; };
|
9155 | Object.defineProperty(QueryList.prototype, "dirty", {
|
9156 | /**
|
9157 | * internal
|
9158 | * @return {?}
|
9159 | */
|
9160 | get: function () { return this._dirty; },
|
9161 | enumerable: true,
|
9162 | configurable: true
|
9163 | });
|
9164 | return QueryList;
|
9165 | }());
|
9166 |
|
9167 | var /** @type {?} */ _SEPARATOR = '#';
|
9168 | var /** @type {?} */ FACTORY_CLASS_SUFFIX = 'NgFactory';
|
9169 | /**
|
9170 | * Configuration for SystemJsNgModuleLoader.
|
9171 | * token.
|
9172 | * *
|
9173 | * @abstract
|
9174 | */
|
9175 | var SystemJsNgModuleLoaderConfig = (function () {
|
9176 | function SystemJsNgModuleLoaderConfig() {
|
9177 | }
|
9178 | return SystemJsNgModuleLoaderConfig;
|
9179 | }());
|
9180 | var /** @type {?} */ DEFAULT_CONFIG = {
|
9181 | factoryPathPrefix: '',
|
9182 | factoryPathSuffix: '.ngfactory',
|
9183 | };
|
9184 | /**
|
9185 | * NgModuleFactoryLoader that uses SystemJS to load NgModuleFactory
|
9186 | */
|
9187 | var SystemJsNgModuleLoader = (function () {
|
9188 | /**
|
9189 | * @param {?} _compiler
|
9190 | * @param {?=} config
|
9191 | */
|
9192 | function SystemJsNgModuleLoader(_compiler, config) {
|
9193 | this._compiler = _compiler;
|
9194 | this._config = config || DEFAULT_CONFIG;
|
9195 | }
|
9196 | /**
|
9197 | * @param {?} path
|
9198 | * @return {?}
|
9199 | */
|
9200 | SystemJsNgModuleLoader.prototype.load = function (path) {
|
9201 | var /** @type {?} */ offlineMode = this._compiler instanceof Compiler;
|
9202 | return offlineMode ? this.loadFactory(path) : this.loadAndCompile(path);
|
9203 | };
|
9204 | /**
|
9205 | * @param {?} path
|
9206 | * @return {?}
|
9207 | */
|
9208 | SystemJsNgModuleLoader.prototype.loadAndCompile = function (path) {
|
9209 | var _this = this;
|
9210 | var _a = path.split(_SEPARATOR), module = _a[0], exportName = _a[1];
|
9211 | if (exportName === undefined) {
|
9212 | exportName = 'default';
|
9213 | }
|
9214 | return System.import(module)
|
9215 | .then(function (module) { return module[exportName]; })
|
9216 | .then(function (type) { return checkNotEmpty(type, module, exportName); })
|
9217 | .then(function (type) { return _this._compiler.compileModuleAsync(type); });
|
9218 | };
|
9219 | /**
|
9220 | * @param {?} path
|
9221 | * @return {?}
|
9222 | */
|
9223 | SystemJsNgModuleLoader.prototype.loadFactory = function (path) {
|
9224 | var _a = path.split(_SEPARATOR), module = _a[0], exportName = _a[1];
|
9225 | var /** @type {?} */ factoryClassSuffix = FACTORY_CLASS_SUFFIX;
|
9226 | if (exportName === undefined) {
|
9227 | exportName = 'default';
|
9228 | factoryClassSuffix = '';
|
9229 | }
|
9230 | return System.import(this._config.factoryPathPrefix + module + this._config.factoryPathSuffix)
|
9231 | .then(function (module) { return module[exportName + factoryClassSuffix]; })
|
9232 | .then(function (factory) { return checkNotEmpty(factory, module, exportName); });
|
9233 | };
|
9234 | SystemJsNgModuleLoader.decorators = [
|
9235 | { type: Injectable },
|
9236 | ];
|
9237 | /** @nocollapse */
|
9238 | SystemJsNgModuleLoader.ctorParameters = function () { return [
|
9239 | { type: Compiler, },
|
9240 | { type: SystemJsNgModuleLoaderConfig, decorators: [{ type: Optional },] },
|
9241 | ]; };
|
9242 | return SystemJsNgModuleLoader;
|
9243 | }());
|
9244 | /**
|
9245 | * @param {?} value
|
9246 | * @param {?} modulePath
|
9247 | * @param {?} exportName
|
9248 | * @return {?}
|
9249 | */
|
9250 | function checkNotEmpty(value, modulePath, exportName) {
|
9251 | if (!value) {
|
9252 | throw new Error("Cannot find '" + exportName + "' in '" + modulePath + "'");
|
9253 | }
|
9254 | return value;
|
9255 | }
|
9256 |
|
9257 | /**
|
9258 | * @license
|
9259 | * Copyright Google Inc. All Rights Reserved.
|
9260 | *
|
9261 | * Use of this source code is governed by an MIT-style license that can be
|
9262 | * found in the LICENSE file at https://angular.io/license
|
9263 | */
|
9264 | var __extends$10 = (this && this.__extends) || function (d, b) {
|
9265 | for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
9266 | function __() { this.constructor = d; }
|
9267 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
9268 | };
|
9269 | /**
|
9270 | * Represents an Embedded Template that can be used to instantiate Embedded Views.
|
9271 | * *
|
9272 | * You can access a `TemplateRef`, in two ways. Via a directive placed on a `<template>` element (or
|
9273 | * directive prefixed with `*`) and have the `TemplateRef` for this Embedded View injected into the
|
9274 | * constructor of the directive using the `TemplateRef` Token. Alternatively you can query for the
|
9275 | * `TemplateRef` from a Component or a Directive via {@link Query}.
|
9276 | * *
|
9277 | * To instantiate Embedded Views based on a Template, use
|
9278 | * {@link ViewContainerRef#createEmbeddedView}, which will create the View and attach it to the
|
9279 | * View Container.
|
9280 | * @abstract
|
9281 | */
|
9282 | var TemplateRef = (function () {
|
9283 | function TemplateRef() {
|
9284 | }
|
9285 | Object.defineProperty(TemplateRef.prototype, "elementRef", {
|
9286 | /**
|
9287 | * @return {?}
|
9288 | */
|
9289 | get: function () { return null; },
|
9290 | enumerable: true,
|
9291 | configurable: true
|
9292 | });
|
9293 | /**
|
9294 | * @abstract
|
9295 | * @param {?} context
|
9296 | * @return {?}
|
9297 | */
|
9298 | TemplateRef.prototype.createEmbeddedView = function (context) { };
|
9299 | return TemplateRef;
|
9300 | }());
|
9301 | var TemplateRef_ = (function (_super) {
|
9302 | __extends$10(TemplateRef_, _super);
|
9303 | /**
|
9304 | * @param {?} _parentView
|
9305 | * @param {?} _nodeIndex
|
9306 | * @param {?} _nativeElement
|
9307 | */
|
9308 | function TemplateRef_(_parentView, _nodeIndex, _nativeElement) {
|
9309 | _super.call(this);
|
9310 | this._parentView = _parentView;
|
9311 | this._nodeIndex = _nodeIndex;
|
9312 | this._nativeElement = _nativeElement;
|
9313 | }
|
9314 | /**
|
9315 | * @param {?} context
|
9316 | * @return {?}
|
9317 | */
|
9318 | TemplateRef_.prototype.createEmbeddedView = function (context) {
|
9319 | var /** @type {?} */ view = this._parentView.createEmbeddedViewInternal(this._nodeIndex);
|
9320 | view.create(context || ({}));
|
9321 | return view.ref;
|
9322 | };
|
9323 | Object.defineProperty(TemplateRef_.prototype, "elementRef", {
|
9324 | /**
|
9325 | * @return {?}
|
9326 | */
|
9327 | get: function () { return new ElementRef(this._nativeElement); },
|
9328 | enumerable: true,
|
9329 | configurable: true
|
9330 | });
|
9331 | return TemplateRef_;
|
9332 | }(TemplateRef));
|
9333 |
|
9334 | /**
|
9335 | * Represents a container where one or more Views can be attached.
|
9336 | * *
|
9337 | * The container can contain two kinds of Views. Host Views, created by instantiating a
|
9338 | * {@link Component} via {@link #createComponent}, and Embedded Views, created by instantiating an
|
9339 | * {@link TemplateRef Embedded Template} via {@link #createEmbeddedView}.
|
9340 | * *
|
9341 | * The location of the View Container within the containing View is specified by the Anchor
|
9342 | * `element`. Each View Container can have only one Anchor Element and each Anchor Element can only
|
9343 | * have a single View Container.
|
9344 | * *
|
9345 | * Root elements of Views attached to this container become siblings of the Anchor Element in
|
9346 | * the Rendered View.
|
9347 | * *
|
9348 | * To access a `ViewContainerRef` of an Element, you can either place a {@link Directive} injected
|
9349 | * with `ViewContainerRef` on the Element, or you obtain it via a {@link ViewChild} query.
|
9350 | * @abstract
|
9351 | */
|
9352 | var ViewContainerRef = (function () {
|
9353 | function ViewContainerRef() {
|
9354 | }
|
9355 | Object.defineProperty(ViewContainerRef.prototype, "element", {
|
9356 | /**
|
9357 | * Anchor element that specifies the location of this container in the containing View.
|
9358 | * <!-- TODO: rename to anchorElement -->
|
9359 | * @return {?}
|
9360 | */
|
9361 | get: function () { return (unimplemented()); },
|
9362 | enumerable: true,
|
9363 | configurable: true
|
9364 | });
|
9365 | Object.defineProperty(ViewContainerRef.prototype, "injector", {
|
9366 | /**
|
9367 | * @return {?}
|
9368 | */
|
9369 | get: function () { return (unimplemented()); },
|
9370 | enumerable: true,
|
9371 | configurable: true
|
9372 | });
|
9373 | Object.defineProperty(ViewContainerRef.prototype, "parentInjector", {
|
9374 | /**
|
9375 | * @return {?}
|
9376 | */
|
9377 | get: function () { return (unimplemented()); },
|
9378 | enumerable: true,
|
9379 | configurable: true
|
9380 | });
|
9381 | /**
|
9382 | * Destroys all Views in this container.
|
9383 | * @abstract
|
9384 | * @return {?}
|
9385 | */
|
9386 | ViewContainerRef.prototype.clear = function () { };
|
9387 | /**
|
9388 | * Returns the {@link ViewRef} for the View located in this container at the specified index.
|
9389 | * @abstract
|
9390 | * @param {?} index
|
9391 | * @return {?}
|
9392 | */
|
9393 | ViewContainerRef.prototype.get = function (index) { };
|
9394 | Object.defineProperty(ViewContainerRef.prototype, "length", {
|
9395 | /**
|
9396 | * Returns the number of Views currently attached to this container.
|
9397 | * @return {?}
|
9398 | */
|
9399 | get: function () { return (unimplemented()); },
|
9400 | enumerable: true,
|
9401 | configurable: true
|
9402 | });
|
9403 | ;
|
9404 | /**
|
9405 | * Instantiates an Embedded View based on the {@link TemplateRef `templateRef`} and inserts it
|
9406 | * into this container at the specified `index`.
|
9407 | * *
|
9408 | * If `index` is not specified, the new View will be inserted as the last View in the container.
|
9409 | * *
|
9410 | * Returns the {@link ViewRef} for the newly created View.
|
9411 | * @abstract
|
9412 | * @param {?} templateRef
|
9413 | * @param {?=} context
|
9414 | * @param {?=} index
|
9415 | * @return {?}
|
9416 | */
|
9417 | ViewContainerRef.prototype.createEmbeddedView = function (templateRef, context, index) { };
|
9418 | /**
|
9419 | * Instantiates a single {@link Component} and inserts its Host View into this container at the
|
9420 | * specified `index`.
|
9421 | * *
|
9422 | * The component is instantiated using its {@link ComponentFactory} which can be
|
9423 | * obtained via {@link ComponentFactoryResolver#resolveComponentFactory}.
|
9424 | * *
|
9425 | * If `index` is not specified, the new View will be inserted as the last View in the container.
|
9426 | * *
|
9427 | * You can optionally specify the {@link Injector} that will be used as parent for the Component.
|
9428 | * *
|
9429 | * Returns the {@link ComponentRef} of the Host View created for the newly instantiated Component.
|
9430 | * @abstract
|
9431 | * @param {?} componentFactory
|
9432 | * @param {?=} index
|
9433 | * @param {?=} injector
|
9434 | * @param {?=} projectableNodes
|
9435 | * @return {?}
|
9436 | */
|
9437 | ViewContainerRef.prototype.createComponent = function (componentFactory, index, injector, projectableNodes) { };
|
9438 | /**
|
9439 | * Inserts a View identified by a {@link ViewRef} into the container at the specified `index`.
|
9440 | * *
|
9441 | * If `index` is not specified, the new View will be inserted as the last View in the container.
|
9442 | * *
|
9443 | * Returns the inserted {@link ViewRef}.
|
9444 | * @abstract
|
9445 | * @param {?} viewRef
|
9446 | * @param {?=} index
|
9447 | * @return {?}
|
9448 | */
|
9449 | ViewContainerRef.prototype.insert = function (viewRef, index) { };
|
9450 | /**
|
9451 | * Moves a View identified by a {@link ViewRef} into the container at the specified `index`.
|
9452 | * *
|
9453 | * Returns the inserted {@link ViewRef}.
|
9454 | * @abstract
|
9455 | * @param {?} viewRef
|
9456 | * @param {?} currentIndex
|
9457 | * @return {?}
|
9458 | */
|
9459 | ViewContainerRef.prototype.move = function (viewRef, currentIndex) { };
|
9460 | /**
|
9461 | * Returns the index of the View, specified via {@link ViewRef}, within the current container or
|
9462 | * `-1` if this container doesn't contain the View.
|
9463 | * @abstract
|
9464 | * @param {?} viewRef
|
9465 | * @return {?}
|
9466 | */
|
9467 | ViewContainerRef.prototype.indexOf = function (viewRef) { };
|
9468 | /**
|
9469 | * Destroys a View attached to this container at the specified `index`.
|
9470 | * *
|
9471 | * If `index` is not specified, the last View in the container will be removed.
|
9472 | * @abstract
|
9473 | * @param {?=} index
|
9474 | * @return {?}
|
9475 | */
|
9476 | ViewContainerRef.prototype.remove = function (index) { };
|
9477 | /**
|
9478 | * Use along with {@link #insert} to move a View within the current container.
|
9479 | * *
|
9480 | * If the `index` param is omitted, the last {@link ViewRef} is detached.
|
9481 | * @abstract
|
9482 | * @param {?=} index
|
9483 | * @return {?}
|
9484 | */
|
9485 | ViewContainerRef.prototype.detach = function (index) { };
|
9486 | return ViewContainerRef;
|
9487 | }());
|
9488 | var ViewContainerRef_ = (function () {
|
9489 | /**
|
9490 | * @param {?} _element
|
9491 | */
|
9492 | function ViewContainerRef_(_element) {
|
9493 | this._element = _element;
|
9494 | /** @internal */
|
9495 | this._createComponentInContainerScope = wtfCreateScope('ViewContainerRef#createComponent()');
|
9496 | /** @internal */
|
9497 | this._insertScope = wtfCreateScope('ViewContainerRef#insert()');
|
9498 | /** @internal */
|
9499 | this._removeScope = wtfCreateScope('ViewContainerRef#remove()');
|
9500 | /** @internal */
|
9501 | this._detachScope = wtfCreateScope('ViewContainerRef#detach()');
|
9502 | }
|
9503 | /**
|
9504 | * @param {?} index
|
9505 | * @return {?}
|
9506 | */
|
9507 | ViewContainerRef_.prototype.get = function (index) { return this._element.nestedViews[index].ref; };
|
9508 | Object.defineProperty(ViewContainerRef_.prototype, "length", {
|
9509 | /**
|
9510 | * @return {?}
|
9511 | */
|
9512 | get: function () {
|
9513 | var /** @type {?} */ views = this._element.nestedViews;
|
9514 | return isPresent(views) ? views.length : 0;
|
9515 | },
|
9516 | enumerable: true,
|
9517 | configurable: true
|
9518 | });
|
9519 | Object.defineProperty(ViewContainerRef_.prototype, "element", {
|
9520 | /**
|
9521 | * @return {?}
|
9522 | */
|
9523 | get: function () { return this._element.elementRef; },
|
9524 | enumerable: true,
|
9525 | configurable: true
|
9526 | });
|
9527 | Object.defineProperty(ViewContainerRef_.prototype, "injector", {
|
9528 | /**
|
9529 | * @return {?}
|
9530 | */
|
9531 | get: function () { return this._element.injector; },
|
9532 | enumerable: true,
|
9533 | configurable: true
|
9534 | });
|
9535 | Object.defineProperty(ViewContainerRef_.prototype, "parentInjector", {
|
9536 | /**
|
9537 | * @return {?}
|
9538 | */
|
9539 | get: function () { return this._element.parentInjector; },
|
9540 | enumerable: true,
|
9541 | configurable: true
|
9542 | });
|
9543 | /**
|
9544 | * @param {?} templateRef
|
9545 | * @param {?=} context
|
9546 | * @param {?=} index
|
9547 | * @return {?}
|
9548 | */
|
9549 | ViewContainerRef_.prototype.createEmbeddedView = function (templateRef, context, index) {
|
9550 | if (context === void 0) { context = null; }
|
9551 | if (index === void 0) { index = -1; }
|
9552 | var /** @type {?} */ viewRef = templateRef.createEmbeddedView(context);
|
9553 | this.insert(viewRef, index);
|
9554 | return viewRef;
|
9555 | };
|
9556 | /**
|
9557 | * @param {?} componentFactory
|
9558 | * @param {?=} index
|
9559 | * @param {?=} injector
|
9560 | * @param {?=} projectableNodes
|
9561 | * @return {?}
|
9562 | */
|
9563 | ViewContainerRef_.prototype.createComponent = function (componentFactory, index, injector, projectableNodes) {
|
9564 | if (index === void 0) { index = -1; }
|
9565 | if (injector === void 0) { injector = null; }
|
9566 | if (projectableNodes === void 0) { projectableNodes = null; }
|
9567 | var /** @type {?} */ s = this._createComponentInContainerScope();
|
9568 | var /** @type {?} */ contextInjector = injector || this._element.parentInjector;
|
9569 | var /** @type {?} */ componentRef = componentFactory.create(contextInjector, projectableNodes);
|
9570 | this.insert(componentRef.hostView, index);
|
9571 | return wtfLeave(s, componentRef);
|
9572 | };
|
9573 | /**
|
9574 | * @param {?} viewRef
|
9575 | * @param {?=} index
|
9576 | * @return {?}
|
9577 | */
|
9578 | ViewContainerRef_.prototype.insert = function (viewRef, index) {
|
9579 | if (index === void 0) { index = -1; }
|
9580 | var /** @type {?} */ s = this._insertScope();
|
9581 | if (index == -1)
|
9582 | index = this.length;
|
9583 | var /** @type {?} */ viewRef_ = (viewRef);
|
9584 | this._element.attachView(viewRef_.internalView, index);
|
9585 | return wtfLeave(s, viewRef_);
|
9586 | };
|
9587 | /**
|
9588 | * @param {?} viewRef
|
9589 | * @param {?} currentIndex
|
9590 | * @return {?}
|
9591 | */
|
9592 | ViewContainerRef_.prototype.move = function (viewRef, currentIndex) {
|
9593 | var /** @type {?} */ s = this._insertScope();
|
9594 | if (currentIndex == -1)
|
9595 | return;
|
9596 | var /** @type {?} */ viewRef_ = (viewRef);
|
9597 | this._element.moveView(viewRef_.internalView, currentIndex);
|
9598 | return wtfLeave(s, viewRef_);
|
9599 | };
|
9600 | /**
|
9601 | * @param {?} viewRef
|
9602 | * @return {?}
|
9603 | */
|
9604 | ViewContainerRef_.prototype.indexOf = function (viewRef) {
|
9605 | return this._element.nestedViews.indexOf(((viewRef)).internalView);
|
9606 | };
|
9607 | /**
|
9608 | * @param {?=} index
|
9609 | * @return {?}
|
9610 | */
|
9611 | ViewContainerRef_.prototype.remove = function (index) {
|
9612 | if (index === void 0) { index = -1; }
|
9613 | var /** @type {?} */ s = this._removeScope();
|
9614 | if (index == -1)
|
9615 | index = this.length - 1;
|
9616 | var /** @type {?} */ view = this._element.detachView(index);
|
9617 | view.destroy();
|
9618 | // view is intentionally not returned to the client.
|
9619 | wtfLeave(s);
|
9620 | };
|
9621 | /**
|
9622 | * @param {?=} index
|
9623 | * @return {?}
|
9624 | */
|
9625 | ViewContainerRef_.prototype.detach = function (index) {
|
9626 | if (index === void 0) { index = -1; }
|
9627 | var /** @type {?} */ s = this._detachScope();
|
9628 | if (index == -1)
|
9629 | index = this.length - 1;
|
9630 | var /** @type {?} */ view = this._element.detachView(index);
|
9631 | return wtfLeave(s, view.ref);
|
9632 | };
|
9633 | /**
|
9634 | * @return {?}
|
9635 | */
|
9636 | ViewContainerRef_.prototype.clear = function () {
|
9637 | for (var /** @type {?} */ i = this.length - 1; i >= 0; i--) {
|
9638 | this.remove(i);
|
9639 | }
|
9640 | };
|
9641 | return ViewContainerRef_;
|
9642 | }());
|
9643 |
|
9644 | /**
|
9645 | * @license
|
9646 | * Copyright Google Inc. All Rights Reserved.
|
9647 | *
|
9648 | * Use of this source code is governed by an MIT-style license that can be
|
9649 | * found in the LICENSE file at https://angular.io/license
|
9650 | */
|
9651 | var __extends$11 = (this && this.__extends) || function (d, b) {
|
9652 | for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
9653 | function __() { this.constructor = d; }
|
9654 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
9655 | };
|
9656 | /**
|
9657 | * @abstract
|
9658 | */
|
9659 | var ViewRef = (function (_super) {
|
9660 | __extends$11(ViewRef, _super);
|
9661 | function ViewRef() {
|
9662 | _super.apply(this, arguments);
|
9663 | }
|
9664 | /**
|
9665 | * Destroys the view and all of the data structures associated with it.
|
9666 | * @abstract
|
9667 | * @return {?}
|
9668 | */
|
9669 | ViewRef.prototype.destroy = function () { };
|
9670 | Object.defineProperty(ViewRef.prototype, "destroyed", {
|
9671 | /**
|
9672 | * @return {?}
|
9673 | */
|
9674 | get: function () { return (unimplemented()); },
|
9675 | enumerable: true,
|
9676 | configurable: true
|
9677 | });
|
9678 | /**
|
9679 | * @abstract
|
9680 | * @param {?} callback
|
9681 | * @return {?}
|
9682 | */
|
9683 | ViewRef.prototype.onDestroy = function (callback) { };
|
9684 | return ViewRef;
|
9685 | }(ChangeDetectorRef));
|
9686 | /**
|
9687 | * Represents an Angular View.
|
9688 | * *
|
9689 | * <!-- TODO: move the next two paragraphs to the dev guide -->
|
9690 | * A View is a fundamental building block of the application UI. It is the smallest grouping of
|
9691 | * Elements which are created and destroyed together.
|
9692 | * *
|
9693 | * Properties of elements in a View can change, but the structure (number and order) of elements in
|
9694 | * a View cannot. Changing the structure of Elements can only be done by inserting, moving or
|
9695 | * removing nested Views via a {@link ViewContainerRef}. Each View can contain many View Containers.
|
9696 | * <!-- /TODO -->
|
9697 | * *
|
9698 | * ### Example
|
9699 | * *
|
9700 | * Given this template...
|
9701 | * *
|
9702 | * ```
|
9703 | * Count: {{items.length}}
|
9704 | * <ul>
|
9705 | * <li *ngFor="let item of items">{{item}}</li>
|
9706 | * </ul>
|
9707 | * ```
|
9708 | * *
|
9709 | * We have two {@link TemplateRef}s:
|
9710 | * *
|
9711 | * Outer {@link TemplateRef}:
|
9712 | * ```
|
9713 | * Count: {{items.length}}
|
9714 | * <ul>
|
9715 | * <template ngFor let-item [ngForOf]="items"></template>
|
9716 | * </ul>
|
9717 | * ```
|
9718 | * *
|
9719 | * Inner {@link TemplateRef}:
|
9720 | * ```
|
9721 | * <li>{{item}}</li>
|
9722 | * ```
|
9723 | * *
|
9724 | * Notice that the original template is broken down into two separate {@link TemplateRef}s.
|
9725 | * *
|
9726 | * The outer/inner {@link TemplateRef}s are then assembled into views like so:
|
9727 | * *
|
9728 | * ```
|
9729 | * <!-- ViewRef: outer-0 -->
|
9730 | * Count: 2
|
9731 | * <ul>
|
9732 | * <template view-container-ref></template>
|
9733 | * <!-- ViewRef: inner-1 --><li>first</li><!-- /ViewRef: inner-1 -->
|
9734 | * <!-- ViewRef: inner-2 --><li>second</li><!-- /ViewRef: inner-2 -->
|
9735 | * </ul>
|
9736 | * <!-- /ViewRef: outer-0 -->
|
9737 | * ```
|
9738 | * @abstract
|
9739 | */
|
9740 | var EmbeddedViewRef = (function (_super) {
|
9741 | __extends$11(EmbeddedViewRef, _super);
|
9742 | function EmbeddedViewRef() {
|
9743 | _super.apply(this, arguments);
|
9744 | }
|
9745 | Object.defineProperty(EmbeddedViewRef.prototype, "context", {
|
9746 | /**
|
9747 | * @return {?}
|
9748 | */
|
9749 | get: function () { return unimplemented(); },
|
9750 | enumerable: true,
|
9751 | configurable: true
|
9752 | });
|
9753 | Object.defineProperty(EmbeddedViewRef.prototype, "rootNodes", {
|
9754 | /**
|
9755 | * @return {?}
|
9756 | */
|
9757 | get: function () { return (unimplemented()); },
|
9758 | enumerable: true,
|
9759 | configurable: true
|
9760 | });
|
9761 | ;
|
9762 | return EmbeddedViewRef;
|
9763 | }(ViewRef));
|
9764 | var ViewRef_ = (function () {
|
9765 | /**
|
9766 | * @param {?} _view
|
9767 | * @param {?} animationQueue
|
9768 | */
|
9769 | function ViewRef_(_view, animationQueue) {
|
9770 | this._view = _view;
|
9771 | this.animationQueue = animationQueue;
|
9772 | this._view = _view;
|
9773 | this._originalMode = this._view.cdMode;
|
9774 | }
|
9775 | Object.defineProperty(ViewRef_.prototype, "internalView", {
|
9776 | /**
|
9777 | * @return {?}
|
9778 | */
|
9779 | get: function () { return this._view; },
|
9780 | enumerable: true,
|
9781 | configurable: true
|
9782 | });
|
9783 | Object.defineProperty(ViewRef_.prototype, "rootNodes", {
|
9784 | /**
|
9785 | * @return {?}
|
9786 | */
|
9787 | get: function () { return this._view.flatRootNodes; },
|
9788 | enumerable: true,
|
9789 | configurable: true
|
9790 | });
|
9791 | Object.defineProperty(ViewRef_.prototype, "context", {
|
9792 | /**
|
9793 | * @return {?}
|
9794 | */
|
9795 | get: function () { return this._view.context; },
|
9796 | enumerable: true,
|
9797 | configurable: true
|
9798 | });
|
9799 | Object.defineProperty(ViewRef_.prototype, "destroyed", {
|
9800 | /**
|
9801 | * @return {?}
|
9802 | */
|
9803 | get: function () { return this._view.destroyed; },
|
9804 | enumerable: true,
|
9805 | configurable: true
|
9806 | });
|
9807 | /**
|
9808 | * @return {?}
|
9809 | */
|
9810 | ViewRef_.prototype.markForCheck = function () { this._view.markPathToRootAsCheckOnce(); };
|
9811 | /**
|
9812 | * @return {?}
|
9813 | */
|
9814 | ViewRef_.prototype.detach = function () { this._view.cdMode = ChangeDetectorStatus.Detached; };
|
9815 | /**
|
9816 | * @return {?}
|
9817 | */
|
9818 | ViewRef_.prototype.detectChanges = function () {
|
9819 | this._view.detectChanges(false);
|
9820 | this.animationQueue.flush();
|
9821 | };
|
9822 | /**
|
9823 | * @return {?}
|
9824 | */
|
9825 | ViewRef_.prototype.checkNoChanges = function () { this._view.detectChanges(true); };
|
9826 | /**
|
9827 | * @return {?}
|
9828 | */
|
9829 | ViewRef_.prototype.reattach = function () {
|
9830 | this._view.cdMode = this._originalMode;
|
9831 | this.markForCheck();
|
9832 | };
|
9833 | /**
|
9834 | * @param {?} callback
|
9835 | * @return {?}
|
9836 | */
|
9837 | ViewRef_.prototype.onDestroy = function (callback) {
|
9838 | if (!this._view.disposables) {
|
9839 | this._view.disposables = [];
|
9840 | }
|
9841 | this._view.disposables.push(callback);
|
9842 | };
|
9843 | /**
|
9844 | * @return {?}
|
9845 | */
|
9846 | ViewRef_.prototype.destroy = function () { this._view.detachAndDestroy(); };
|
9847 | return ViewRef_;
|
9848 | }());
|
9849 |
|
9850 | /**
|
9851 | * @license
|
9852 | * Copyright Google Inc. All Rights Reserved.
|
9853 | *
|
9854 | * Use of this source code is governed by an MIT-style license that can be
|
9855 | * found in the LICENSE file at https://angular.io/license
|
9856 | */
|
9857 | var __extends$12 = (this && this.__extends) || function (d, b) {
|
9858 | for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
9859 | function __() { this.constructor = d; }
|
9860 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
9861 | };
|
9862 | var EventListener = (function () {
|
9863 | /**
|
9864 | * @param {?} name
|
9865 | * @param {?} callback
|
9866 | */
|
9867 | function EventListener(name, callback) {
|
9868 | this.name = name;
|
9869 | this.callback = callback;
|
9870 | }
|
9871 | ;
|
9872 | return EventListener;
|
9873 | }());
|
9874 | /**
|
9875 | * @experimental All debugging apis are currently experimental.
|
9876 | */
|
9877 | var DebugNode = (function () {
|
9878 | /**
|
9879 | * @param {?} nativeNode
|
9880 | * @param {?} parent
|
9881 | * @param {?} _debugInfo
|
9882 | */
|
9883 | function DebugNode(nativeNode, parent, _debugInfo) {
|
9884 | this._debugInfo = _debugInfo;
|
9885 | this.nativeNode = nativeNode;
|
9886 | if (parent && parent instanceof DebugElement) {
|
9887 | parent.addChild(this);
|
9888 | }
|
9889 | else {
|
9890 | this.parent = null;
|
9891 | }
|
9892 | this.listeners = [];
|
9893 | }
|
9894 | Object.defineProperty(DebugNode.prototype, "injector", {
|
9895 | /**
|
9896 | * @return {?}
|
9897 | */
|
9898 | get: function () { return this._debugInfo ? this._debugInfo.injector : null; },
|
9899 | enumerable: true,
|
9900 | configurable: true
|
9901 | });
|
9902 | Object.defineProperty(DebugNode.prototype, "componentInstance", {
|
9903 | /**
|
9904 | * @return {?}
|
9905 | */
|
9906 | get: function () { return this._debugInfo ? this._debugInfo.component : null; },
|
9907 | enumerable: true,
|
9908 | configurable: true
|
9909 | });
|
9910 | Object.defineProperty(DebugNode.prototype, "context", {
|
9911 | /**
|
9912 | * @return {?}
|
9913 | */
|
9914 | get: function () { return this._debugInfo ? this._debugInfo.context : null; },
|
9915 | enumerable: true,
|
9916 | configurable: true
|
9917 | });
|
9918 | Object.defineProperty(DebugNode.prototype, "references", {
|
9919 | /**
|
9920 | * @return {?}
|
9921 | */
|
9922 | get: function () {
|
9923 | return this._debugInfo ? this._debugInfo.references : null;
|
9924 | },
|
9925 | enumerable: true,
|
9926 | configurable: true
|
9927 | });
|
9928 | Object.defineProperty(DebugNode.prototype, "providerTokens", {
|
9929 | /**
|
9930 | * @return {?}
|
9931 | */
|
9932 | get: function () { return this._debugInfo ? this._debugInfo.providerTokens : null; },
|
9933 | enumerable: true,
|
9934 | configurable: true
|
9935 | });
|
9936 | Object.defineProperty(DebugNode.prototype, "source", {
|
9937 | /**
|
9938 | * @return {?}
|
9939 | */
|
9940 | get: function () { return this._debugInfo ? this._debugInfo.source : null; },
|
9941 | enumerable: true,
|
9942 | configurable: true
|
9943 | });
|
9944 | return DebugNode;
|
9945 | }());
|
9946 | /**
|
9947 | * @experimental All debugging apis are currently experimental.
|
9948 | */
|
9949 | var DebugElement = (function (_super) {
|
9950 | __extends$12(DebugElement, _super);
|
9951 | /**
|
9952 | * @param {?} nativeNode
|
9953 | * @param {?} parent
|
9954 | * @param {?} _debugInfo
|
9955 | */
|
9956 | function DebugElement(nativeNode, parent, _debugInfo) {
|
9957 | _super.call(this, nativeNode, parent, _debugInfo);
|
9958 | this.properties = {};
|
9959 | this.attributes = {};
|
9960 | this.classes = {};
|
9961 | this.styles = {};
|
9962 | this.childNodes = [];
|
9963 | this.nativeElement = nativeNode;
|
9964 | }
|
9965 | /**
|
9966 | * @param {?} child
|
9967 | * @return {?}
|
9968 | */
|
9969 | DebugElement.prototype.addChild = function (child) {
|
9970 | if (child) {
|
9971 | this.childNodes.push(child);
|
9972 | child.parent = this;
|
9973 | }
|
9974 | };
|
9975 | /**
|
9976 | * @param {?} child
|
9977 | * @return {?}
|
9978 | */
|
9979 | DebugElement.prototype.removeChild = function (child) {
|
9980 | var /** @type {?} */ childIndex = this.childNodes.indexOf(child);
|
9981 | if (childIndex !== -1) {
|
9982 | child.parent = null;
|
9983 | this.childNodes.splice(childIndex, 1);
|
9984 | }
|
9985 | };
|
9986 | /**
|
9987 | * @param {?} child
|
9988 | * @param {?} newChildren
|
9989 | * @return {?}
|
9990 | */
|
9991 | DebugElement.prototype.insertChildrenAfter = function (child, newChildren) {
|
9992 | var /** @type {?} */ siblingIndex = this.childNodes.indexOf(child);
|
9993 | if (siblingIndex !== -1) {
|
9994 | var /** @type {?} */ previousChildren = this.childNodes.slice(0, siblingIndex + 1);
|
9995 | var /** @type {?} */ nextChildren = this.childNodes.slice(siblingIndex + 1);
|
9996 | this.childNodes = previousChildren.concat(newChildren, nextChildren);
|
9997 | for (var /** @type {?} */ i = 0; i < newChildren.length; ++i) {
|
9998 | var /** @type {?} */ newChild = newChildren[i];
|
9999 | if (newChild.parent) {
|
10000 | newChild.parent.removeChild(newChild);
|
10001 | }
|
10002 | newChild.parent = this;
|
10003 | }
|
10004 | }
|
10005 | };
|
10006 | /**
|
10007 | * @param {?} predicate
|
10008 | * @return {?}
|
10009 | */
|
10010 | DebugElement.prototype.query = function (predicate) {
|
10011 | var /** @type {?} */ results = this.queryAll(predicate);
|
10012 | return results[0] || null;
|
10013 | };
|
10014 | /**
|
10015 | * @param {?} predicate
|
10016 | * @return {?}
|
10017 | */
|
10018 | DebugElement.prototype.queryAll = function (predicate) {
|
10019 | var /** @type {?} */ matches = [];
|
10020 | _queryElementChildren(this, predicate, matches);
|
10021 | return matches;
|
10022 | };
|
10023 | /**
|
10024 | * @param {?} predicate
|
10025 | * @return {?}
|
10026 | */
|
10027 | DebugElement.prototype.queryAllNodes = function (predicate) {
|
10028 | var /** @type {?} */ matches = [];
|
10029 | _queryNodeChildren(this, predicate, matches);
|
10030 | return matches;
|
10031 | };
|
10032 | Object.defineProperty(DebugElement.prototype, "children", {
|
10033 | /**
|
10034 | * @return {?}
|
10035 | */
|
10036 | get: function () {
|
10037 | return (this.childNodes.filter(function (node) { return node instanceof DebugElement; }));
|
10038 | },
|
10039 | enumerable: true,
|
10040 | configurable: true
|
10041 | });
|
10042 | /**
|
10043 | * @param {?} eventName
|
10044 | * @param {?} eventObj
|
10045 | * @return {?}
|
10046 | */
|
10047 | DebugElement.prototype.triggerEventHandler = function (eventName, eventObj) {
|
10048 | this.listeners.forEach(function (listener) {
|
10049 | if (listener.name == eventName) {
|
10050 | listener.callback(eventObj);
|
10051 | }
|
10052 | });
|
10053 | };
|
10054 | return DebugElement;
|
10055 | }(DebugNode));
|
10056 | /**
|
10057 | * @param {?} debugEls
|
10058 | * @return {?}
|
10059 | */
|
10060 | function asNativeElements(debugEls) {
|
10061 | return debugEls.map(function (el) { return el.nativeElement; });
|
10062 | }
|
10063 | /**
|
10064 | * @param {?} element
|
10065 | * @param {?} predicate
|
10066 | * @param {?} matches
|
10067 | * @return {?}
|
10068 | */
|
10069 | function _queryElementChildren(element, predicate, matches) {
|
10070 | element.childNodes.forEach(function (node) {
|
10071 | if (node instanceof DebugElement) {
|
10072 | if (predicate(node)) {
|
10073 | matches.push(node);
|
10074 | }
|
10075 | _queryElementChildren(node, predicate, matches);
|
10076 | }
|
10077 | });
|
10078 | }
|
10079 | /**
|
10080 | * @param {?} parentNode
|
10081 | * @param {?} predicate
|
10082 | * @param {?} matches
|
10083 | * @return {?}
|
10084 | */
|
10085 | function _queryNodeChildren(parentNode, predicate, matches) {
|
10086 | if (parentNode instanceof DebugElement) {
|
10087 | parentNode.childNodes.forEach(function (node) {
|
10088 | if (predicate(node)) {
|
10089 | matches.push(node);
|
10090 | }
|
10091 | if (node instanceof DebugElement) {
|
10092 | _queryNodeChildren(node, predicate, matches);
|
10093 | }
|
10094 | });
|
10095 | }
|
10096 | }
|
10097 | // Need to keep the nodes in a global Map so that multiple angular apps are supported.
|
10098 | var /** @type {?} */ _nativeNodeToDebugNode = new Map();
|
10099 | /**
|
10100 | * @param {?} nativeNode
|
10101 | * @return {?}
|
10102 | */
|
10103 | function getDebugNode(nativeNode) {
|
10104 | return _nativeNodeToDebugNode.get(nativeNode);
|
10105 | }
|
10106 | /**
|
10107 | * @param {?} node
|
10108 | * @return {?}
|
10109 | */
|
10110 | function indexDebugNode(node) {
|
10111 | _nativeNodeToDebugNode.set(node.nativeNode, node);
|
10112 | }
|
10113 | /**
|
10114 | * @param {?} node
|
10115 | * @return {?}
|
10116 | */
|
10117 | function removeDebugNodeFromIndex(node) {
|
10118 | _nativeNodeToDebugNode.delete(node.nativeNode);
|
10119 | }
|
10120 |
|
10121 | /**
|
10122 | * @return {?}
|
10123 | */
|
10124 | function _reflector() {
|
10125 | return reflector;
|
10126 | }
|
10127 | var /** @type {?} */ _CORE_PLATFORM_PROVIDERS = [
|
10128 | PlatformRef_,
|
10129 | { provide: PlatformRef, useExisting: PlatformRef_ },
|
10130 | { provide: Reflector, useFactory: _reflector, deps: [] },
|
10131 | { provide: ReflectorReader, useExisting: Reflector },
|
10132 | TestabilityRegistry,
|
10133 | Console,
|
10134 | ];
|
10135 | /**
|
10136 | * This platform has to be included in any other platform
|
10137 | *
|
10138 | * @experimental
|
10139 | */
|
10140 | var /** @type {?} */ platformCore = createPlatformFactory(null, 'core', _CORE_PLATFORM_PROVIDERS);
|
10141 |
|
10142 | /**
|
10143 | * @experimental i18n support is experimental.
|
10144 | */
|
10145 | var /** @type {?} */ LOCALE_ID = new OpaqueToken('LocaleId');
|
10146 | /**
|
10147 | * @experimental i18n support is experimental.
|
10148 | */
|
10149 | var /** @type {?} */ TRANSLATIONS = new OpaqueToken('Translations');
|
10150 | /**
|
10151 | * @experimental i18n support is experimental.
|
10152 | */
|
10153 | var /** @type {?} */ TRANSLATIONS_FORMAT = new OpaqueToken('TranslationsFormat');
|
10154 |
|
10155 | /**
|
10156 | * @return {?}
|
10157 | */
|
10158 | function _iterableDiffersFactory() {
|
10159 | return defaultIterableDiffers;
|
10160 | }
|
10161 | /**
|
10162 | * @return {?}
|
10163 | */
|
10164 | function _keyValueDiffersFactory() {
|
10165 | return defaultKeyValueDiffers;
|
10166 | }
|
10167 | /**
|
10168 | * This module includes the providers of @angular/core that are needed
|
10169 | * to bootstrap components via `ApplicationRef`.
|
10170 | * *
|
10171 | */
|
10172 | var ApplicationModule = (function () {
|
10173 | function ApplicationModule() {
|
10174 | }
|
10175 | ApplicationModule.decorators = [
|
10176 | { type: NgModule, args: [{
|
10177 | providers: [
|
10178 | ApplicationRef_,
|
10179 | { provide: ApplicationRef, useExisting: ApplicationRef_ },
|
10180 | ApplicationInitStatus,
|
10181 | Compiler,
|
10182 | APP_ID_RANDOM_PROVIDER,
|
10183 | ViewUtils,
|
10184 | AnimationQueue,
|
10185 | { provide: IterableDiffers, useFactory: _iterableDiffersFactory },
|
10186 | { provide: KeyValueDiffers, useFactory: _keyValueDiffersFactory },
|
10187 | { provide: LOCALE_ID, useValue: 'en-US' },
|
10188 | ]
|
10189 | },] },
|
10190 | ];
|
10191 | /** @nocollapse */
|
10192 | ApplicationModule.ctorParameters = function () { return []; };
|
10193 | return ApplicationModule;
|
10194 | }());
|
10195 |
|
10196 | /**
|
10197 | * @license
|
10198 | * Copyright Google Inc. All Rights Reserved.
|
10199 | *
|
10200 | * Use of this source code is governed by an MIT-style license that can be
|
10201 | * found in the LICENSE file at https://angular.io/license
|
10202 | */
|
10203 | var /** @type {?} */ FILL_STYLE_FLAG = 'true'; // TODO (matsko): change to boolean
|
10204 | var /** @type {?} */ ANY_STATE = '*';
|
10205 | var /** @type {?} */ DEFAULT_STATE = '*';
|
10206 | var /** @type {?} */ EMPTY_STATE = 'void';
|
10207 |
|
10208 | var AnimationGroupPlayer = (function () {
|
10209 | /**
|
10210 | * @param {?} _players
|
10211 | */
|
10212 | function AnimationGroupPlayer(_players) {
|
10213 | var _this = this;
|
10214 | this._players = _players;
|
10215 | this._onDoneFns = [];
|
10216 | this._onStartFns = [];
|
10217 | this._finished = false;
|
10218 | this._started = false;
|
10219 | this._destroyed = false;
|
10220 | this.parentPlayer = null;
|
10221 | var count = 0;
|
10222 | var total = this._players.length;
|
10223 | if (total == 0) {
|
10224 | scheduleMicroTask(function () { return _this._onFinish(); });
|
10225 | }
|
10226 | else {
|
10227 | this._players.forEach(function (player) {
|
10228 | player.parentPlayer = _this;
|
10229 | player.onDone(function () {
|
10230 | if (++count >= total) {
|
10231 | _this._onFinish();
|
10232 | }
|
10233 | });
|
10234 | });
|
10235 | }
|
10236 | }
|
10237 | /**
|
10238 | * @return {?}
|
10239 | */
|
10240 | AnimationGroupPlayer.prototype._onFinish = function () {
|
10241 | if (!this._finished) {
|
10242 | this._finished = true;
|
10243 | this._onDoneFns.forEach(function (fn) { return fn(); });
|
10244 | this._onDoneFns = [];
|
10245 | }
|
10246 | };
|
10247 | /**
|
10248 | * @return {?}
|
10249 | */
|
10250 | AnimationGroupPlayer.prototype.init = function () { this._players.forEach(function (player) { return player.init(); }); };
|
10251 | /**
|
10252 | * @param {?} fn
|
10253 | * @return {?}
|
10254 | */
|
10255 | AnimationGroupPlayer.prototype.onStart = function (fn) { this._onStartFns.push(fn); };
|
10256 | /**
|
10257 | * @param {?} fn
|
10258 | * @return {?}
|
10259 | */
|
10260 | AnimationGroupPlayer.prototype.onDone = function (fn) { this._onDoneFns.push(fn); };
|
10261 | /**
|
10262 | * @return {?}
|
10263 | */
|
10264 | AnimationGroupPlayer.prototype.hasStarted = function () { return this._started; };
|
10265 | /**
|
10266 | * @return {?}
|
10267 | */
|
10268 | AnimationGroupPlayer.prototype.play = function () {
|
10269 | if (!isPresent(this.parentPlayer)) {
|
10270 | this.init();
|
10271 | }
|
10272 | if (!this.hasStarted()) {
|
10273 | this._onStartFns.forEach(function (fn) { return fn(); });
|
10274 | this._onStartFns = [];
|
10275 | this._started = true;
|
10276 | }
|
10277 | this._players.forEach(function (player) { return player.play(); });
|
10278 | };
|
10279 | /**
|
10280 | * @return {?}
|
10281 | */
|
10282 | AnimationGroupPlayer.prototype.pause = function () { this._players.forEach(function (player) { return player.pause(); }); };
|
10283 | /**
|
10284 | * @return {?}
|
10285 | */
|
10286 | AnimationGroupPlayer.prototype.restart = function () { this._players.forEach(function (player) { return player.restart(); }); };
|
10287 | /**
|
10288 | * @return {?}
|
10289 | */
|
10290 | AnimationGroupPlayer.prototype.finish = function () {
|
10291 | this._onFinish();
|
10292 | this._players.forEach(function (player) { return player.finish(); });
|
10293 | };
|
10294 | /**
|
10295 | * @return {?}
|
10296 | */
|
10297 | AnimationGroupPlayer.prototype.destroy = function () {
|
10298 | if (!this._destroyed) {
|
10299 | this._onFinish();
|
10300 | this._players.forEach(function (player) { return player.destroy(); });
|
10301 | this._destroyed = true;
|
10302 | }
|
10303 | };
|
10304 | /**
|
10305 | * @return {?}
|
10306 | */
|
10307 | AnimationGroupPlayer.prototype.reset = function () {
|
10308 | this._players.forEach(function (player) { return player.reset(); });
|
10309 | this._destroyed = false;
|
10310 | this._finished = false;
|
10311 | this._started = false;
|
10312 | };
|
10313 | /**
|
10314 | * @param {?} p
|
10315 | * @return {?}
|
10316 | */
|
10317 | AnimationGroupPlayer.prototype.setPosition = function (p) {
|
10318 | this._players.forEach(function (player) { player.setPosition(p); });
|
10319 | };
|
10320 | /**
|
10321 | * @return {?}
|
10322 | */
|
10323 | AnimationGroupPlayer.prototype.getPosition = function () {
|
10324 | var /** @type {?} */ min = 0;
|
10325 | this._players.forEach(function (player) {
|
10326 | var /** @type {?} */ p = player.getPosition();
|
10327 | min = Math.min(p, min);
|
10328 | });
|
10329 | return min;
|
10330 | };
|
10331 | Object.defineProperty(AnimationGroupPlayer.prototype, "players", {
|
10332 | /**
|
10333 | * @return {?}
|
10334 | */
|
10335 | get: function () { return this._players; },
|
10336 | enumerable: true,
|
10337 | configurable: true
|
10338 | });
|
10339 | return AnimationGroupPlayer;
|
10340 | }());
|
10341 |
|
10342 | /**
|
10343 | * @license
|
10344 | * Copyright Google Inc. All Rights Reserved.
|
10345 | *
|
10346 | * Use of this source code is governed by an MIT-style license that can be
|
10347 | * found in the LICENSE file at https://angular.io/license
|
10348 | */
|
10349 | var AnimationKeyframe = (function () {
|
10350 | /**
|
10351 | * @param {?} offset
|
10352 | * @param {?} styles
|
10353 | */
|
10354 | function AnimationKeyframe(offset, styles) {
|
10355 | this.offset = offset;
|
10356 | this.styles = styles;
|
10357 | }
|
10358 | return AnimationKeyframe;
|
10359 | }());
|
10360 |
|
10361 | /**
|
10362 | * @abstract
|
10363 | */
|
10364 | var AnimationPlayer = (function () {
|
10365 | function AnimationPlayer() {
|
10366 | }
|
10367 | /**
|
10368 | * @abstract
|
10369 | * @param {?} fn
|
10370 | * @return {?}
|
10371 | */
|
10372 | AnimationPlayer.prototype.onDone = function (fn) { };
|
10373 | /**
|
10374 | * @abstract
|
10375 | * @param {?} fn
|
10376 | * @return {?}
|
10377 | */
|
10378 | AnimationPlayer.prototype.onStart = function (fn) { };
|
10379 | /**
|
10380 | * @abstract
|
10381 | * @return {?}
|
10382 | */
|
10383 | AnimationPlayer.prototype.init = function () { };
|
10384 | /**
|
10385 | * @abstract
|
10386 | * @return {?}
|
10387 | */
|
10388 | AnimationPlayer.prototype.hasStarted = function () { };
|
10389 | /**
|
10390 | * @abstract
|
10391 | * @return {?}
|
10392 | */
|
10393 | AnimationPlayer.prototype.play = function () { };
|
10394 | /**
|
10395 | * @abstract
|
10396 | * @return {?}
|
10397 | */
|
10398 | AnimationPlayer.prototype.pause = function () { };
|
10399 | /**
|
10400 | * @abstract
|
10401 | * @return {?}
|
10402 | */
|
10403 | AnimationPlayer.prototype.restart = function () { };
|
10404 | /**
|
10405 | * @abstract
|
10406 | * @return {?}
|
10407 | */
|
10408 | AnimationPlayer.prototype.finish = function () { };
|
10409 | /**
|
10410 | * @abstract
|
10411 | * @return {?}
|
10412 | */
|
10413 | AnimationPlayer.prototype.destroy = function () { };
|
10414 | /**
|
10415 | * @abstract
|
10416 | * @return {?}
|
10417 | */
|
10418 | AnimationPlayer.prototype.reset = function () { };
|
10419 | /**
|
10420 | * @abstract
|
10421 | * @param {?} p
|
10422 | * @return {?}
|
10423 | */
|
10424 | AnimationPlayer.prototype.setPosition = function (p) { };
|
10425 | /**
|
10426 | * @abstract
|
10427 | * @return {?}
|
10428 | */
|
10429 | AnimationPlayer.prototype.getPosition = function () { };
|
10430 | Object.defineProperty(AnimationPlayer.prototype, "parentPlayer", {
|
10431 | /**
|
10432 | * @return {?}
|
10433 | */
|
10434 | get: function () { throw new Error('NOT IMPLEMENTED: Base Class'); },
|
10435 | /**
|
10436 | * @param {?} player
|
10437 | * @return {?}
|
10438 | */
|
10439 | set: function (player) { throw new Error('NOT IMPLEMENTED: Base Class'); },
|
10440 | enumerable: true,
|
10441 | configurable: true
|
10442 | });
|
10443 | return AnimationPlayer;
|
10444 | }());
|
10445 | var NoOpAnimationPlayer = (function () {
|
10446 | function NoOpAnimationPlayer() {
|
10447 | var _this = this;
|
10448 | this._onDoneFns = [];
|
10449 | this._onStartFns = [];
|
10450 | this._started = false;
|
10451 | this.parentPlayer = null;
|
10452 | scheduleMicroTask(function () { return _this._onFinish(); });
|
10453 | }
|
10454 | /**
|
10455 | * @return {?}
|
10456 | */
|
10457 | NoOpAnimationPlayer.prototype._onFinish = function () {
|
10458 | this._onDoneFns.forEach(function (fn) { return fn(); });
|
10459 | this._onDoneFns = [];
|
10460 | };
|
10461 | /**
|
10462 | * @param {?} fn
|
10463 | * @return {?}
|
10464 | */
|
10465 | NoOpAnimationPlayer.prototype.onStart = function (fn) { this._onStartFns.push(fn); };
|
10466 | /**
|
10467 | * @param {?} fn
|
10468 | * @return {?}
|
10469 | */
|
10470 | NoOpAnimationPlayer.prototype.onDone = function (fn) { this._onDoneFns.push(fn); };
|
10471 | /**
|
10472 | * @return {?}
|
10473 | */
|
10474 | NoOpAnimationPlayer.prototype.hasStarted = function () { return this._started; };
|
10475 | /**
|
10476 | * @return {?}
|
10477 | */
|
10478 | NoOpAnimationPlayer.prototype.init = function () { };
|
10479 | /**
|
10480 | * @return {?}
|
10481 | */
|
10482 | NoOpAnimationPlayer.prototype.play = function () {
|
10483 | if (!this.hasStarted()) {
|
10484 | this._onStartFns.forEach(function (fn) { return fn(); });
|
10485 | this._onStartFns = [];
|
10486 | }
|
10487 | this._started = true;
|
10488 | };
|
10489 | /**
|
10490 | * @return {?}
|
10491 | */
|
10492 | NoOpAnimationPlayer.prototype.pause = function () { };
|
10493 | /**
|
10494 | * @return {?}
|
10495 | */
|
10496 | NoOpAnimationPlayer.prototype.restart = function () { };
|
10497 | /**
|
10498 | * @return {?}
|
10499 | */
|
10500 | NoOpAnimationPlayer.prototype.finish = function () { this._onFinish(); };
|
10501 | /**
|
10502 | * @return {?}
|
10503 | */
|
10504 | NoOpAnimationPlayer.prototype.destroy = function () { };
|
10505 | /**
|
10506 | * @return {?}
|
10507 | */
|
10508 | NoOpAnimationPlayer.prototype.reset = function () { };
|
10509 | /**
|
10510 | * @param {?} p
|
10511 | * @return {?}
|
10512 | */
|
10513 | NoOpAnimationPlayer.prototype.setPosition = function (p) { };
|
10514 | /**
|
10515 | * @return {?}
|
10516 | */
|
10517 | NoOpAnimationPlayer.prototype.getPosition = function () { return 0; };
|
10518 | return NoOpAnimationPlayer;
|
10519 | }());
|
10520 |
|
10521 | var AnimationSequencePlayer = (function () {
|
10522 | /**
|
10523 | * @param {?} _players
|
10524 | */
|
10525 | function AnimationSequencePlayer(_players) {
|
10526 | var _this = this;
|
10527 | this._players = _players;
|
10528 | this._currentIndex = 0;
|
10529 | this._onDoneFns = [];
|
10530 | this._onStartFns = [];
|
10531 | this._finished = false;
|
10532 | this._started = false;
|
10533 | this._destroyed = false;
|
10534 | this.parentPlayer = null;
|
10535 | this._players.forEach(function (player) { player.parentPlayer = _this; });
|
10536 | this._onNext(false);
|
10537 | }
|
10538 | /**
|
10539 | * @param {?} start
|
10540 | * @return {?}
|
10541 | */
|
10542 | AnimationSequencePlayer.prototype._onNext = function (start) {
|
10543 | var _this = this;
|
10544 | if (this._finished)
|
10545 | return;
|
10546 | if (this._players.length == 0) {
|
10547 | this._activePlayer = new NoOpAnimationPlayer();
|
10548 | scheduleMicroTask(function () { return _this._onFinish(); });
|
10549 | }
|
10550 | else if (this._currentIndex >= this._players.length) {
|
10551 | this._activePlayer = new NoOpAnimationPlayer();
|
10552 | this._onFinish();
|
10553 | }
|
10554 | else {
|
10555 | var /** @type {?} */ player = this._players[this._currentIndex++];
|
10556 | player.onDone(function () { return _this._onNext(true); });
|
10557 | this._activePlayer = player;
|
10558 | if (start) {
|
10559 | player.play();
|
10560 | }
|
10561 | }
|
10562 | };
|
10563 | /**
|
10564 | * @return {?}
|
10565 | */
|
10566 | AnimationSequencePlayer.prototype._onFinish = function () {
|
10567 | if (!this._finished) {
|
10568 | this._finished = true;
|
10569 | this._onDoneFns.forEach(function (fn) { return fn(); });
|
10570 | this._onDoneFns = [];
|
10571 | }
|
10572 | };
|
10573 | /**
|
10574 | * @return {?}
|
10575 | */
|
10576 | AnimationSequencePlayer.prototype.init = function () { this._players.forEach(function (player) { return player.init(); }); };
|
10577 | /**
|
10578 | * @param {?} fn
|
10579 | * @return {?}
|
10580 | */
|
10581 | AnimationSequencePlayer.prototype.onStart = function (fn) { this._onStartFns.push(fn); };
|
10582 | /**
|
10583 | * @param {?} fn
|
10584 | * @return {?}
|
10585 | */
|
10586 | AnimationSequencePlayer.prototype.onDone = function (fn) { this._onDoneFns.push(fn); };
|
10587 | /**
|
10588 | * @return {?}
|
10589 | */
|
10590 | AnimationSequencePlayer.prototype.hasStarted = function () { return this._started; };
|
10591 | /**
|
10592 | * @return {?}
|
10593 | */
|
10594 | AnimationSequencePlayer.prototype.play = function () {
|
10595 | if (!isPresent(this.parentPlayer)) {
|
10596 | this.init();
|
10597 | }
|
10598 | if (!this.hasStarted()) {
|
10599 | this._onStartFns.forEach(function (fn) { return fn(); });
|
10600 | this._onStartFns = [];
|
10601 | this._started = true;
|
10602 | }
|
10603 | this._activePlayer.play();
|
10604 | };
|
10605 | /**
|
10606 | * @return {?}
|
10607 | */
|
10608 | AnimationSequencePlayer.prototype.pause = function () { this._activePlayer.pause(); };
|
10609 | /**
|
10610 | * @return {?}
|
10611 | */
|
10612 | AnimationSequencePlayer.prototype.restart = function () {
|
10613 | this.reset();
|
10614 | if (this._players.length > 0) {
|
10615 | this._players[0].restart();
|
10616 | }
|
10617 | };
|
10618 | /**
|
10619 | * @return {?}
|
10620 | */
|
10621 | AnimationSequencePlayer.prototype.reset = function () {
|
10622 | this._players.forEach(function (player) { return player.reset(); });
|
10623 | this._destroyed = false;
|
10624 | this._finished = false;
|
10625 | this._started = false;
|
10626 | };
|
10627 | /**
|
10628 | * @return {?}
|
10629 | */
|
10630 | AnimationSequencePlayer.prototype.finish = function () {
|
10631 | this._onFinish();
|
10632 | this._players.forEach(function (player) { return player.finish(); });
|
10633 | };
|
10634 | /**
|
10635 | * @return {?}
|
10636 | */
|
10637 | AnimationSequencePlayer.prototype.destroy = function () {
|
10638 | if (!this._destroyed) {
|
10639 | this._onFinish();
|
10640 | this._players.forEach(function (player) { return player.destroy(); });
|
10641 | this._destroyed = true;
|
10642 | this._activePlayer = new NoOpAnimationPlayer();
|
10643 | }
|
10644 | };
|
10645 | /**
|
10646 | * @param {?} p
|
10647 | * @return {?}
|
10648 | */
|
10649 | AnimationSequencePlayer.prototype.setPosition = function (p) { this._players[0].setPosition(p); };
|
10650 | /**
|
10651 | * @return {?}
|
10652 | */
|
10653 | AnimationSequencePlayer.prototype.getPosition = function () { return this._players[0].getPosition(); };
|
10654 | Object.defineProperty(AnimationSequencePlayer.prototype, "players", {
|
10655 | /**
|
10656 | * @return {?}
|
10657 | */
|
10658 | get: function () { return this._players; },
|
10659 | enumerable: true,
|
10660 | configurable: true
|
10661 | });
|
10662 | return AnimationSequencePlayer;
|
10663 | }());
|
10664 |
|
10665 | /**
|
10666 | * @license
|
10667 | * Copyright Google Inc. All Rights Reserved.
|
10668 | *
|
10669 | * Use of this source code is governed by an MIT-style license that can be
|
10670 | * found in the LICENSE file at https://angular.io/license
|
10671 | */
|
10672 | var __extends$13 = (this && this.__extends) || function (d, b) {
|
10673 | for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
10674 | function __() { this.constructor = d; }
|
10675 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
10676 | };
|
10677 | /**
|
10678 | * @experimental Animation support is experimental.
|
10679 | */
|
10680 | var /** @type {?} */ AUTO_STYLE = '*';
|
10681 | /**
|
10682 | * Metadata representing the entry of animations.
|
10683 | * Instances of this class are provided via the animation DSL when the {@link trigger trigger
|
10684 | * animation function} is called.
|
10685 | * *
|
10686 | */
|
10687 | var AnimationEntryMetadata = (function () {
|
10688 | /**
|
10689 | * @param {?} name
|
10690 | * @param {?} definitions
|
10691 | */
|
10692 | function AnimationEntryMetadata(name, definitions) {
|
10693 | this.name = name;
|
10694 | this.definitions = definitions;
|
10695 | }
|
10696 | return AnimationEntryMetadata;
|
10697 | }());
|
10698 | /**
|
10699 | * @abstract
|
10700 | */
|
10701 | var AnimationStateMetadata = (function () {
|
10702 | function AnimationStateMetadata() {
|
10703 | }
|
10704 | return AnimationStateMetadata;
|
10705 | }());
|
10706 | /**
|
10707 | * Metadata representing the entry of animations.
|
10708 | * Instances of this class are provided via the animation DSL when the {@link state state animation
|
10709 | * function} is called.
|
10710 | * *
|
10711 | */
|
10712 | var AnimationStateDeclarationMetadata = (function (_super) {
|
10713 | __extends$13(AnimationStateDeclarationMetadata, _super);
|
10714 | /**
|
10715 | * @param {?} stateNameExpr
|
10716 | * @param {?} styles
|
10717 | */
|
10718 | function AnimationStateDeclarationMetadata(stateNameExpr, styles) {
|
10719 | _super.call(this);
|
10720 | this.stateNameExpr = stateNameExpr;
|
10721 | this.styles = styles;
|
10722 | }
|
10723 | return AnimationStateDeclarationMetadata;
|
10724 | }(AnimationStateMetadata));
|
10725 | /**
|
10726 | * Metadata representing the entry of animations.
|
10727 | * Instances of this class are provided via the animation DSL when the
|
10728 | * {@link transition transition animation function} is called.
|
10729 | * *
|
10730 | */
|
10731 | var AnimationStateTransitionMetadata = (function (_super) {
|
10732 | __extends$13(AnimationStateTransitionMetadata, _super);
|
10733 | /**
|
10734 | * @param {?} stateChangeExpr
|
10735 | * @param {?} steps
|
10736 | */
|
10737 | function AnimationStateTransitionMetadata(stateChangeExpr, steps) {
|
10738 | _super.call(this);
|
10739 | this.stateChangeExpr = stateChangeExpr;
|
10740 | this.steps = steps;
|
10741 | }
|
10742 | return AnimationStateTransitionMetadata;
|
10743 | }(AnimationStateMetadata));
|
10744 | /**
|
10745 | * @abstract
|
10746 | */
|
10747 | var AnimationMetadata = (function () {
|
10748 | function AnimationMetadata() {
|
10749 | }
|
10750 | return AnimationMetadata;
|
10751 | }());
|
10752 | /**
|
10753 | * Metadata representing the entry of animations.
|
10754 | * Instances of this class are provided via the animation DSL when the {@link keyframes keyframes
|
10755 | * animation function} is called.
|
10756 | * *
|
10757 | */
|
10758 | var AnimationKeyframesSequenceMetadata = (function (_super) {
|
10759 | __extends$13(AnimationKeyframesSequenceMetadata, _super);
|
10760 | /**
|
10761 | * @param {?} steps
|
10762 | */
|
10763 | function AnimationKeyframesSequenceMetadata(steps) {
|
10764 | _super.call(this);
|
10765 | this.steps = steps;
|
10766 | }
|
10767 | return AnimationKeyframesSequenceMetadata;
|
10768 | }(AnimationMetadata));
|
10769 | /**
|
10770 | * Metadata representing the entry of animations.
|
10771 | * Instances of this class are provided via the animation DSL when the {@link style style animation
|
10772 | * function} is called.
|
10773 | * *
|
10774 | */
|
10775 | var AnimationStyleMetadata = (function (_super) {
|
10776 | __extends$13(AnimationStyleMetadata, _super);
|
10777 | /**
|
10778 | * @param {?} styles
|
10779 | * @param {?=} offset
|
10780 | */
|
10781 | function AnimationStyleMetadata(styles, offset) {
|
10782 | if (offset === void 0) { offset = null; }
|
10783 | _super.call(this);
|
10784 | this.styles = styles;
|
10785 | this.offset = offset;
|
10786 | }
|
10787 | return AnimationStyleMetadata;
|
10788 | }(AnimationMetadata));
|
10789 | /**
|
10790 | * Metadata representing the entry of animations.
|
10791 | * Instances of this class are provided via the animation DSL when the {@link animate animate
|
10792 | * animation function} is called.
|
10793 | * *
|
10794 | */
|
10795 | var AnimationAnimateMetadata = (function (_super) {
|
10796 | __extends$13(AnimationAnimateMetadata, _super);
|
10797 | /**
|
10798 | * @param {?} timings
|
10799 | * @param {?} styles
|
10800 | */
|
10801 | function AnimationAnimateMetadata(timings, styles) {
|
10802 | _super.call(this);
|
10803 | this.timings = timings;
|
10804 | this.styles = styles;
|
10805 | }
|
10806 | return AnimationAnimateMetadata;
|
10807 | }(AnimationMetadata));
|
10808 | /**
|
10809 | * @abstract
|
10810 | */
|
10811 | var AnimationWithStepsMetadata = (function (_super) {
|
10812 | __extends$13(AnimationWithStepsMetadata, _super);
|
10813 | function AnimationWithStepsMetadata() {
|
10814 | _super.call(this);
|
10815 | }
|
10816 | Object.defineProperty(AnimationWithStepsMetadata.prototype, "steps", {
|
10817 | /**
|
10818 | * @return {?}
|
10819 | */
|
10820 | get: function () { throw new Error('NOT IMPLEMENTED: Base Class'); },
|
10821 | enumerable: true,
|
10822 | configurable: true
|
10823 | });
|
10824 | return AnimationWithStepsMetadata;
|
10825 | }(AnimationMetadata));
|
10826 | /**
|
10827 | * Metadata representing the entry of animations.
|
10828 | * Instances of this class are provided via the animation DSL when the {@link sequence sequence
|
10829 | * animation function} is called.
|
10830 | * *
|
10831 | */
|
10832 | var AnimationSequenceMetadata = (function (_super) {
|
10833 | __extends$13(AnimationSequenceMetadata, _super);
|
10834 | /**
|
10835 | * @param {?} _steps
|
10836 | */
|
10837 | function AnimationSequenceMetadata(_steps) {
|
10838 | _super.call(this);
|
10839 | this._steps = _steps;
|
10840 | }
|
10841 | Object.defineProperty(AnimationSequenceMetadata.prototype, "steps", {
|
10842 | /**
|
10843 | * @return {?}
|
10844 | */
|
10845 | get: function () { return this._steps; },
|
10846 | enumerable: true,
|
10847 | configurable: true
|
10848 | });
|
10849 | return AnimationSequenceMetadata;
|
10850 | }(AnimationWithStepsMetadata));
|
10851 | /**
|
10852 | * Metadata representing the entry of animations.
|
10853 | * Instances of this class are provided via the animation DSL when the {@link group group animation
|
10854 | * function} is called.
|
10855 | * *
|
10856 | */
|
10857 | var AnimationGroupMetadata = (function (_super) {
|
10858 | __extends$13(AnimationGroupMetadata, _super);
|
10859 | /**
|
10860 | * @param {?} _steps
|
10861 | */
|
10862 | function AnimationGroupMetadata(_steps) {
|
10863 | _super.call(this);
|
10864 | this._steps = _steps;
|
10865 | }
|
10866 | Object.defineProperty(AnimationGroupMetadata.prototype, "steps", {
|
10867 | /**
|
10868 | * @return {?}
|
10869 | */
|
10870 | get: function () { return this._steps; },
|
10871 | enumerable: true,
|
10872 | configurable: true
|
10873 | });
|
10874 | return AnimationGroupMetadata;
|
10875 | }(AnimationWithStepsMetadata));
|
10876 | /**
|
10877 | * `animate` is an animation-specific function that is designed to be used inside of Angular2's
|
10878 | * animation
|
10879 | * DSL language. If this information is new, please navigate to the
|
10880 | * {@link Component#animations-anchor component animations metadata
|
10881 | * page} to gain a better understanding of how animations in Angular2 are used.
|
10882 | * *
|
10883 | * `animate` specifies an animation step that will apply the provided `styles` data for a given
|
10884 | * amount of
|
10885 | * time based on the provided `timing` expression value. Calls to `animate` are expected to be
|
10886 | * used within {@link sequence an animation sequence}, {@link group group}, or {@link transition
|
10887 | * transition}.
|
10888 | * *
|
10889 | * ### Usage
|
10890 | * *
|
10891 | * The `animate` function accepts two input parameters: `timing` and `styles`:
|
10892 | * *
|
10893 | * - `timing` is a string based value that can be a combination of a duration with optional
|
10894 | * delay and easing values. The format for the expression breaks down to `duration delay easing`
|
10895 | * (therefore a value such as `1s 100ms ease-out` will be parse itself into `duration=1000,
|
10896 | * delay=100, easing=ease-out`.
|
10897 | * If a numeric value is provided then that will be used as the `duration` value in millisecond
|
10898 | * form.
|
10899 | * - `styles` is the style input data which can either be a call to {@link style style} or {@link
|
10900 | * keyframes keyframes}.
|
10901 | * If left empty then the styles from the destination state will be collected and used (this is
|
10902 | * useful when
|
10903 | * describing an animation step that will complete an animation by {@link
|
10904 | * transition#the-final-animate-call animating to the final state}).
|
10905 | * *
|
10906 | * ```typescript
|
10907 | * // various functions for specifying timing data
|
10908 | * animate(500, style(...))
|
10909 | * animate("1s", style(...))
|
10910 | * animate("100ms 0.5s", style(...))
|
10911 | * animate("5s ease", style(...))
|
10912 | * animate("5s 10ms cubic-bezier(.17,.67,.88,.1)", style(...))
|
10913 | * *
|
10914 | * // either style() of keyframes() can be used
|
10915 | * animate(500, style({ background: "red" }))
|
10916 | * animate(500, keyframes([
|
10917 | * style({ background: "blue" })),
|
10918 | * style({ background: "red" }))
|
10919 | * ])
|
10920 | * ```
|
10921 | * *
|
10922 | * ### Example ([live demo](http://plnkr.co/edit/Kez8XGWBxWue7qP7nNvF?p=preview))
|
10923 | * *
|
10924 | * {@example core/animation/ts/dsl/animation_example.ts region='Component'}
|
10925 | * *
|
10926 | * @param {?} timing
|
10927 | * @param {?=} styles
|
10928 | * @return {?}
|
10929 | */
|
10930 | function animate(timing, styles) {
|
10931 | if (styles === void 0) { styles = null; }
|
10932 | var /** @type {?} */ stylesEntry = styles;
|
10933 | if (!isPresent(stylesEntry)) {
|
10934 | var /** @type {?} */ EMPTY_STYLE = {};
|
10935 | stylesEntry = new AnimationStyleMetadata([EMPTY_STYLE], 1);
|
10936 | }
|
10937 | return new AnimationAnimateMetadata(timing, stylesEntry);
|
10938 | }
|
10939 | /**
|
10940 | * `group` is an animation-specific function that is designed to be used inside of Angular2's
|
10941 | * animation
|
10942 | * DSL language. If this information is new, please navigate to the
|
10943 | * {@link Component#animations-anchor component animations metadata
|
10944 | * page} to gain a better understanding of how animations in Angular2 are used.
|
10945 | * *
|
10946 | * `group` specifies a list of animation steps that are all run in parallel. Grouped animations
|
10947 | * are useful when a series of styles must be animated/closed off
|
10948 | * at different statrting/ending times.
|
10949 | * *
|
10950 | * The `group` function can either be used within a {@link sequence sequence} or a {@link transition
|
10951 | * transition}
|
10952 | * and it will only continue to the next instruction once all of the inner animation steps
|
10953 | * have completed.
|
10954 | * *
|
10955 | * ### Usage
|
10956 | * *
|
10957 | * The `steps` data that is passed into the `group` animation function can either consist
|
10958 | * of {@link style style} or {@link animate animate} function calls. Each call to `style()` or
|
10959 | * `animate()`
|
10960 | * within a group will be executed instantly (use {@link keyframes keyframes} or a
|
10961 | * {@link animate#usage animate() with a delay value} to offset styles to be applied at a later
|
10962 | * time).
|
10963 | * *
|
10964 | * ```typescript
|
10965 | * group([
|
10966 | * animate("1s", { background: "black" }))
|
10967 | * animate("2s", { color: "white" }))
|
10968 | * ])
|
10969 | * ```
|
10970 | * *
|
10971 | * ### Example ([live demo](http://plnkr.co/edit/Kez8XGWBxWue7qP7nNvF?p=preview))
|
10972 | * *
|
10973 | * {@example core/animation/ts/dsl/animation_example.ts region='Component'}
|
10974 | * *
|
10975 | * @param {?} steps
|
10976 | * @return {?}
|
10977 | */
|
10978 | function group(steps) {
|
10979 | return new AnimationGroupMetadata(steps);
|
10980 | }
|
10981 | /**
|
10982 | * `sequence` is an animation-specific function that is designed to be used inside of Angular2's
|
10983 | * animation
|
10984 | * DSL language. If this information is new, please navigate to the
|
10985 | * {@link Component#animations-anchor component animations metadata
|
10986 | * page} to gain a better understanding of how animations in Angular2 are used.
|
10987 | * *
|
10988 | * `sequence` Specifies a list of animation steps that are run one by one. (`sequence` is used
|
10989 | * by default when an array is passed as animation data into {@link transition transition}.)
|
10990 | * *
|
10991 | * The `sequence` function can either be used within a {@link group group} or a {@link transition
|
10992 | * transition}
|
10993 | * and it will only continue to the next instruction once each of the inner animation steps
|
10994 | * have completed.
|
10995 | * *
|
10996 | * To perform animation styling in parallel with other animation steps then
|
10997 | * have a look at the {@link group group} animation function.
|
10998 | * *
|
10999 | * ### Usage
|
11000 | * *
|
11001 | * The `steps` data that is passed into the `sequence` animation function can either consist
|
11002 | * of {@link style style} or {@link animate animate} function calls. A call to `style()` will apply
|
11003 | * the
|
11004 | * provided styling data immediately while a call to `animate()` will apply its styling
|
11005 | * data over a given time depending on its timing data.
|
11006 | * *
|
11007 | * ```typescript
|
11008 | * sequence([
|
11009 | * style({ opacity: 0 })),
|
11010 | * animate("1s", { opacity: 1 }))
|
11011 | * ])
|
11012 | * ```
|
11013 | * *
|
11014 | * ### Example ([live demo](http://plnkr.co/edit/Kez8XGWBxWue7qP7nNvF?p=preview))
|
11015 | * *
|
11016 | * {@example core/animation/ts/dsl/animation_example.ts region='Component'}
|
11017 | * *
|
11018 | * @param {?} steps
|
11019 | * @return {?}
|
11020 | */
|
11021 | function sequence(steps) {
|
11022 | return new AnimationSequenceMetadata(steps);
|
11023 | }
|
11024 | /**
|
11025 | * `style` is an animation-specific function that is designed to be used inside of Angular2's
|
11026 | * animation
|
11027 | * DSL language. If this information is new, please navigate to the
|
11028 | * {@link Component#animations-anchor component animations metadata
|
11029 | * page} to gain a better understanding of how animations in Angular2 are used.
|
11030 | * *
|
11031 | * `style` declares a key/value object containing CSS properties/styles that can then
|
11032 | * be used for {@link state animation states}, within an {@link sequence animation sequence}, or as
|
11033 | * styling data for both {@link animate animate} and {@link keyframes keyframes}.
|
11034 | * *
|
11035 | * ### Usage
|
11036 | * *
|
11037 | * `style` takes in a key/value string map as data and expects one or more CSS property/value
|
11038 | * pairs to be defined.
|
11039 | * *
|
11040 | * ```typescript
|
11041 | * // string values are used for css properties
|
11042 | * style({ background: "red", color: "blue" })
|
11043 | * *
|
11044 | * // numerical (pixel) values are also supported
|
11045 | * style({ width: 100, height: 0 })
|
11046 | * ```
|
11047 | * *
|
11048 | * #### Auto-styles (using `*`)
|
11049 | * *
|
11050 | * When an asterix (`*`) character is used as a value then it will be detected from the element
|
11051 | * being animated
|
11052 | * and applied as animation data when the animation starts.
|
11053 | * *
|
11054 | * This feature proves useful for a state depending on layout and/or environment factors; in such
|
11055 | * cases
|
11056 | * the styles are calculated just before the animation starts.
|
11057 | * *
|
11058 | * ```typescript
|
11059 | * // the steps below will animate from 0 to the
|
11060 | * // actual height of the element
|
11061 | * style({ height: 0 }),
|
11062 | * animate("1s", style({ height: "*" }))
|
11063 | * ```
|
11064 | * *
|
11065 | * ### Example ([live demo](http://plnkr.co/edit/Kez8XGWBxWue7qP7nNvF?p=preview))
|
11066 | * *
|
11067 | * {@example core/animation/ts/dsl/animation_example.ts region='Component'}
|
11068 | * *
|
11069 | * @param {?} tokens
|
11070 | * @return {?}
|
11071 | */
|
11072 | function style(tokens) {
|
11073 | var /** @type {?} */ input;
|
11074 | var /** @type {?} */ offset = null;
|
11075 | if (typeof tokens === 'string') {
|
11076 | input = [(tokens)];
|
11077 | }
|
11078 | else {
|
11079 | if (Array.isArray(tokens)) {
|
11080 | input = (tokens);
|
11081 | }
|
11082 | else {
|
11083 | input = [(tokens)];
|
11084 | }
|
11085 | input.forEach(function (entry) {
|
11086 | var /** @type {?} */ entryOffset = ((entry) /** TODO #9100 */)['offset'];
|
11087 | if (isPresent(entryOffset)) {
|
11088 | offset = offset == null ? parseFloat(entryOffset) : offset;
|
11089 | }
|
11090 | });
|
11091 | }
|
11092 | return new AnimationStyleMetadata(input, offset);
|
11093 | }
|
11094 | /**
|
11095 | * `state` is an animation-specific function that is designed to be used inside of Angular2's
|
11096 | * animation
|
11097 | * DSL language. If this information is new, please navigate to the
|
11098 | * {@link Component#animations-anchor component animations metadata
|
11099 | * page} to gain a better understanding of how animations in Angular2 are used.
|
11100 | * *
|
11101 | * `state` declares an animation state within the given trigger. When a state is
|
11102 | * active within a component then its associated styles will persist on
|
11103 | * the element that the trigger is attached to (even when the animation ends).
|
11104 | * *
|
11105 | * To animate between states, have a look at the animation {@link transition transition}
|
11106 | * DSL function. To register states to an animation trigger please have a look
|
11107 | * at the {@link trigger trigger} function.
|
11108 | * *
|
11109 | * #### The `void` state
|
11110 | * *
|
11111 | * The `void` state value is a reserved word that angular uses to determine when the element is not
|
11112 | * apart
|
11113 | * of the application anymore (e.g. when an `ngIf` evaluates to false then the state of the
|
11114 | * associated element
|
11115 | * is void).
|
11116 | * *
|
11117 | * #### The `*` (default) state
|
11118 | * *
|
11119 | * The `*` state (when styled) is a fallback state that will be used if
|
11120 | * the state that is being animated is not declared within the trigger.
|
11121 | * *
|
11122 | * ### Usage
|
11123 | * *
|
11124 | * `state` will declare an animation state with its associated styles
|
11125 | * within the given trigger.
|
11126 | * *
|
11127 | * - `stateNameExpr` can be one or more state names separated by commas.
|
11128 | * - `styles` refers to the {@link style styling data} that will be persisted on the element once
|
11129 | * the state
|
11130 | * has been reached.
|
11131 | * *
|
11132 | * ```typescript
|
11133 | * // "void" is a reserved name for a state and is used to represent
|
11134 | * // the state in which an element is detached from from the application.
|
11135 | * state("void", style({ height: 0 }))
|
11136 | * *
|
11137 | * // user-defined states
|
11138 | * state("closed", style({ height: 0 }))
|
11139 | * state("open, visible", style({ height: "*" }))
|
11140 | * ```
|
11141 | * *
|
11142 | * ### Example ([live demo](http://plnkr.co/edit/Kez8XGWBxWue7qP7nNvF?p=preview))
|
11143 | * *
|
11144 | * {@example core/animation/ts/dsl/animation_example.ts region='Component'}
|
11145 | * *
|
11146 | * @param {?} stateNameExpr
|
11147 | * @param {?} styles
|
11148 | * @return {?}
|
11149 | */
|
11150 | function state(stateNameExpr, styles) {
|
11151 | return new AnimationStateDeclarationMetadata(stateNameExpr, styles);
|
11152 | }
|
11153 | /**
|
11154 | * `keyframes` is an animation-specific function that is designed to be used inside of Angular2's
|
11155 | * animation
|
11156 | * DSL language. If this information is new, please navigate to the
|
11157 | * {@link Component#animations-anchor component animations metadata
|
11158 | * page} to gain a better understanding of how animations in Angular2 are used.
|
11159 | * *
|
11160 | * `keyframes` specifies a collection of {@link style style} entries each optionally characterized
|
11161 | * by an `offset` value.
|
11162 | * *
|
11163 | * ### Usage
|
11164 | * *
|
11165 | * The `keyframes` animation function is designed to be used alongside the {@link animate animate}
|
11166 | * animation function. Instead of applying animations from where they are
|
11167 | * currently to their destination, keyframes can describe how each style entry is applied
|
11168 | * and at what point within the animation arc (much like CSS Keyframe Animations do).
|
11169 | * *
|
11170 | * For each `style()` entry an `offset` value can be set. Doing so allows to specifiy at
|
11171 | * what percentage of the animate time the styles will be applied.
|
11172 | * *
|
11173 | * ```typescript
|
11174 | * // the provided offset values describe when each backgroundColor value is applied.
|
11175 | * animate("5s", keyframes([
|
11176 | * style({ backgroundColor: "red", offset: 0 }),
|
11177 | * style({ backgroundColor: "blue", offset: 0.2 }),
|
11178 | * style({ backgroundColor: "orange", offset: 0.3 }),
|
11179 | * style({ backgroundColor: "black", offset: 1 })
|
11180 | * ]))
|
11181 | * ```
|
11182 | * *
|
11183 | * Alternatively, if there are no `offset` values used within the style entries then the offsets
|
11184 | * will
|
11185 | * be calculated automatically.
|
11186 | * *
|
11187 | * ```typescript
|
11188 | * animate("5s", keyframes([
|
11189 | * style({ backgroundColor: "red" }) // offset = 0
|
11190 | * style({ backgroundColor: "blue" }) // offset = 0.33
|
11191 | * style({ backgroundColor: "orange" }) // offset = 0.66
|
11192 | * style({ backgroundColor: "black" }) // offset = 1
|
11193 | * ]))
|
11194 | * ```
|
11195 | * *
|
11196 | * ### Example ([live demo](http://plnkr.co/edit/Kez8XGWBxWue7qP7nNvF?p=preview))
|
11197 | * *
|
11198 | * {@example core/animation/ts/dsl/animation_example.ts region='Component'}
|
11199 | * *
|
11200 | * @param {?} steps
|
11201 | * @return {?}
|
11202 | */
|
11203 | function keyframes(steps) {
|
11204 | return new AnimationKeyframesSequenceMetadata(steps);
|
11205 | }
|
11206 | /**
|
11207 | * `transition` is an animation-specific function that is designed to be used inside of Angular2's
|
11208 | * animation
|
11209 | * DSL language. If this information is new, please navigate to the
|
11210 | * {@link Component#animations-anchor component animations metadata
|
11211 | * page} to gain a better understanding of how animations in Angular2 are used.
|
11212 | * *
|
11213 | * `transition` declares the {@link sequence sequence of animation steps} that will be run when the
|
11214 | * provided
|
11215 | * `stateChangeExpr` value is satisfied. The `stateChangeExpr` consists of a `state1 => state2`
|
11216 | * which consists
|
11217 | * of two known states (use an asterix (`*`) to refer to a dynamic starting and/or ending state).
|
11218 | * *
|
11219 | * Animation transitions are placed within an {@link trigger animation trigger}. For an transition
|
11220 | * to animate to
|
11221 | * a state value and persist its styles then one or more {@link state animation states} is expected
|
11222 | * to be defined.
|
11223 | * *
|
11224 | * ### Usage
|
11225 | * *
|
11226 | * An animation transition is kicked off the `stateChangeExpr` predicate evaluates to true based on
|
11227 | * what the
|
11228 | * previous state is and what the current state has become. In other words, if a transition is
|
11229 | * defined that
|
11230 | * matches the old/current state criteria then the associated animation will be triggered.
|
11231 | * *
|
11232 | * ```typescript
|
11233 | * // all transition/state changes are defined within an animation trigger
|
11234 | * trigger("myAnimationTrigger", [
|
11235 | * // if a state is defined then its styles will be persisted when the
|
11236 | * // animation has fully completed itself
|
11237 | * state("on", style({ background: "green" })),
|
11238 | * state("off", style({ background: "grey" })),
|
11239 | * *
|
11240 | * // a transition animation that will be kicked off when the state value
|
11241 | * // bound to "myAnimationTrigger" changes from "on" to "off"
|
11242 | * transition("on => off", animate(500)),
|
11243 | * *
|
11244 | * // it is also possible to do run the same animation for both directions
|
11245 | * transition("on <=> off", animate(500)),
|
11246 | * *
|
11247 | * // or to define multiple states pairs separated by commas
|
11248 | * transition("on => off, off => void", animate(500)),
|
11249 | * *
|
11250 | * // this is a catch-all state change for when an element is inserted into
|
11251 | * // the page and the destination state is unknown
|
11252 | * transition("void => *", [
|
11253 | * style({ opacity: 0 }),
|
11254 | * animate(500)
|
11255 | * ]),
|
11256 | * *
|
11257 | * // this will capture a state change between any states
|
11258 | * transition("* => *", animate("1s 0s")),
|
11259 | * ])
|
11260 | * ```
|
11261 | * *
|
11262 | * The template associated with this component will make use of the `myAnimationTrigger`
|
11263 | * animation trigger by binding to an element within its template code.
|
11264 | * *
|
11265 | * ```html
|
11266 | * <!-- somewhere inside of my-component-tpl.html -->
|
11267 | * <div [@myAnimationTrigger]="myStatusExp">...</div>
|
11268 | * ```
|
11269 | * *
|
11270 | * #### The final `animate` call
|
11271 | * *
|
11272 | * If the final step within the transition steps is a call to `animate()` that **only**
|
11273 | * uses a timing value with **no style data** then it will be automatically used as the final
|
11274 | * animation
|
11275 | * arc for the element to animate itself to the final state. This involves an automatic mix of
|
11276 | * adding/removing CSS styles so that the element will be in the exact state it should be for the
|
11277 | * applied state to be presented correctly.
|
11278 | * *
|
11279 | * ```
|
11280 | * // start off by hiding the element, but make sure that it animates properly to whatever state
|
11281 | * // is currently active for "myAnimationTrigger"
|
11282 | * transition("void => *", [
|
11283 | * style({ opacity: 0 }),
|
11284 | * animate(500)
|
11285 | * ])
|
11286 | * ```
|
11287 | * *
|
11288 | * ### Transition Aliases (`:enter` and `:leave`)
|
11289 | * *
|
11290 | * Given that enter (insertion) and leave (removal) animations are so common,
|
11291 | * the `transition` function accepts both `:enter` and `:leave` values which
|
11292 | * are aliases for the `void => *` and `* => void` state changes.
|
11293 | * *
|
11294 | * ```
|
11295 | * transition(":enter", [
|
11296 | * style({ opacity: 0 }),
|
11297 | * animate(500, style({ opacity: 1 }))
|
11298 | * ])
|
11299 | * transition(":leave", [
|
11300 | * animate(500, style({ opacity: 0 }))
|
11301 | * ])
|
11302 | * ```
|
11303 | * *
|
11304 | * ### Example ([live demo](http://plnkr.co/edit/Kez8XGWBxWue7qP7nNvF?p=preview))
|
11305 | * *
|
11306 | * {@example core/animation/ts/dsl/animation_example.ts region='Component'}
|
11307 | * *
|
11308 | * @param {?} stateChangeExpr
|
11309 | * @param {?} steps
|
11310 | * @return {?}
|
11311 | */
|
11312 | function transition(stateChangeExpr, steps) {
|
11313 | var /** @type {?} */ animationData = Array.isArray(steps) ? new AnimationSequenceMetadata(steps) : steps;
|
11314 | return new AnimationStateTransitionMetadata(stateChangeExpr, animationData);
|
11315 | }
|
11316 | /**
|
11317 | * `trigger` is an animation-specific function that is designed to be used inside of Angular2's
|
11318 | * animation
|
11319 | * DSL language. If this information is new, please navigate to the
|
11320 | * {@link Component#animations-anchor component animations metadata
|
11321 | * page} to gain a better understanding of how animations in Angular2 are used.
|
11322 | * *
|
11323 | * `trigger` Creates an animation trigger which will a list of {@link state state} and {@link
|
11324 | * transition transition}
|
11325 | * entries that will be evaluated when the expression bound to the trigger changes.
|
11326 | * *
|
11327 | * Triggers are registered within the component annotation data under the
|
11328 | * {@link Component#animations-anchor animations section}. An animation trigger can
|
11329 | * be placed on an element within a template by referencing the name of the
|
11330 | * trigger followed by the expression value that the trigger is bound to
|
11331 | * (in the form of `[@triggerName]="expression"`.
|
11332 | * *
|
11333 | * ### Usage
|
11334 | * *
|
11335 | * `trigger` will create an animation trigger reference based on the provided `name` value.
|
11336 | * The provided `animation` value is expected to be an array consisting of {@link state state} and
|
11337 | * {@link transition transition}
|
11338 | * declarations.
|
11339 | * *
|
11340 | * ```typescript
|
11341 | * selector: 'my-component',
|
11342 | * templateUrl: 'my-component-tpl.html',
|
11343 | * animations: [
|
11344 | * trigger("myAnimationTrigger", [
|
11345 | * state(...),
|
11346 | * state(...),
|
11347 | * transition(...),
|
11348 | * transition(...)
|
11349 | * ])
|
11350 | * ]
|
11351 | * })
|
11352 | * class MyComponent {
|
11353 | * myStatusExp = "something";
|
11354 | * }
|
11355 | * ```
|
11356 | * *
|
11357 | * The template associated with this component will make use of the `myAnimationTrigger`
|
11358 | * animation trigger by binding to an element within its template code.
|
11359 | * *
|
11360 | * ```html
|
11361 | * <!-- somewhere inside of my-component-tpl.html -->
|
11362 | * <div [@myAnimationTrigger]="myStatusExp">...</div>
|
11363 | * ```
|
11364 | * *
|
11365 | * ### Example ([live demo](http://plnkr.co/edit/Kez8XGWBxWue7qP7nNvF?p=preview))
|
11366 | * *
|
11367 | * {@example core/animation/ts/dsl/animation_example.ts region='Component'}
|
11368 | * *
|
11369 | * @param {?} name
|
11370 | * @param {?} animation
|
11371 | * @return {?}
|
11372 | */
|
11373 | function trigger(name, animation) {
|
11374 | return new AnimationEntryMetadata(name, animation);
|
11375 | }
|
11376 |
|
11377 | /**
|
11378 | * @param {?} previousStyles
|
11379 | * @param {?} newStyles
|
11380 | * @param {?=} nullValue
|
11381 | * @return {?}
|
11382 | */
|
11383 | function prepareFinalAnimationStyles(previousStyles, newStyles, nullValue) {
|
11384 | if (nullValue === void 0) { nullValue = null; }
|
11385 | var /** @type {?} */ finalStyles = {};
|
11386 | Object.keys(newStyles).forEach(function (prop) {
|
11387 | var /** @type {?} */ value = newStyles[prop];
|
11388 | finalStyles[prop] = value == AUTO_STYLE ? nullValue : value.toString();
|
11389 | });
|
11390 | Object.keys(previousStyles).forEach(function (prop) {
|
11391 | if (!isPresent(finalStyles[prop])) {
|
11392 | finalStyles[prop] = nullValue;
|
11393 | }
|
11394 | });
|
11395 | return finalStyles;
|
11396 | }
|
11397 | /**
|
11398 | * @param {?} collectedStyles
|
11399 | * @param {?} finalStateStyles
|
11400 | * @param {?} keyframes
|
11401 | * @return {?}
|
11402 | */
|
11403 | function balanceAnimationKeyframes(collectedStyles, finalStateStyles, keyframes) {
|
11404 | var /** @type {?} */ limit = keyframes.length - 1;
|
11405 | var /** @type {?} */ firstKeyframe = keyframes[0];
|
11406 | // phase 1: copy all the styles from the first keyframe into the lookup map
|
11407 | var /** @type {?} */ flatenedFirstKeyframeStyles = flattenStyles(firstKeyframe.styles.styles);
|
11408 | var /** @type {?} */ extraFirstKeyframeStyles = {};
|
11409 | var /** @type {?} */ hasExtraFirstStyles = false;
|
11410 | Object.keys(collectedStyles).forEach(function (prop) {
|
11411 | var /** @type {?} */ value = (collectedStyles[prop]);
|
11412 | // if the style is already defined in the first keyframe then
|
11413 | // we do not replace it.
|
11414 | if (!flatenedFirstKeyframeStyles[prop]) {
|
11415 | flatenedFirstKeyframeStyles[prop] = value;
|
11416 | extraFirstKeyframeStyles[prop] = value;
|
11417 | hasExtraFirstStyles = true;
|
11418 | }
|
11419 | });
|
11420 | var /** @type {?} */ keyframeCollectedStyles = StringMapWrapper.merge({}, flatenedFirstKeyframeStyles);
|
11421 | // phase 2: normalize the final keyframe
|
11422 | var /** @type {?} */ finalKeyframe = keyframes[limit];
|
11423 | finalKeyframe.styles.styles.unshift(finalStateStyles);
|
11424 | var /** @type {?} */ flatenedFinalKeyframeStyles = flattenStyles(finalKeyframe.styles.styles);
|
11425 | var /** @type {?} */ extraFinalKeyframeStyles = {};
|
11426 | var /** @type {?} */ hasExtraFinalStyles = false;
|
11427 | Object.keys(keyframeCollectedStyles).forEach(function (prop) {
|
11428 | if (!isPresent(flatenedFinalKeyframeStyles[prop])) {
|
11429 | extraFinalKeyframeStyles[prop] = AUTO_STYLE;
|
11430 | hasExtraFinalStyles = true;
|
11431 | }
|
11432 | });
|
11433 | if (hasExtraFinalStyles) {
|
11434 | finalKeyframe.styles.styles.push(extraFinalKeyframeStyles);
|
11435 | }
|
11436 | Object.keys(flatenedFinalKeyframeStyles).forEach(function (prop) {
|
11437 | if (!isPresent(flatenedFirstKeyframeStyles[prop])) {
|
11438 | extraFirstKeyframeStyles[prop] = AUTO_STYLE;
|
11439 | hasExtraFirstStyles = true;
|
11440 | }
|
11441 | });
|
11442 | if (hasExtraFirstStyles) {
|
11443 | firstKeyframe.styles.styles.push(extraFirstKeyframeStyles);
|
11444 | }
|
11445 | collectAndResolveStyles(collectedStyles, [finalStateStyles]);
|
11446 | return keyframes;
|
11447 | }
|
11448 | /**
|
11449 | * @param {?} styles
|
11450 | * @return {?}
|
11451 | */
|
11452 | function clearStyles(styles) {
|
11453 | var /** @type {?} */ finalStyles = {};
|
11454 | Object.keys(styles).forEach(function (key) { finalStyles[key] = null; });
|
11455 | return finalStyles;
|
11456 | }
|
11457 | /**
|
11458 | * @param {?} collection
|
11459 | * @param {?} styles
|
11460 | * @return {?}
|
11461 | */
|
11462 | function collectAndResolveStyles(collection, styles) {
|
11463 | return styles.map(function (entry) {
|
11464 | var /** @type {?} */ stylesObj = {};
|
11465 | Object.keys(entry).forEach(function (prop) {
|
11466 | var /** @type {?} */ value = entry[prop];
|
11467 | if (value == FILL_STYLE_FLAG) {
|
11468 | value = collection[prop];
|
11469 | if (!isPresent(value)) {
|
11470 | value = AUTO_STYLE;
|
11471 | }
|
11472 | }
|
11473 | collection[prop] = value;
|
11474 | stylesObj[prop] = value;
|
11475 | });
|
11476 | return stylesObj;
|
11477 | });
|
11478 | }
|
11479 | /**
|
11480 | * @param {?} element
|
11481 | * @param {?} renderer
|
11482 | * @param {?} styles
|
11483 | * @return {?}
|
11484 | */
|
11485 | function renderStyles(element, renderer, styles) {
|
11486 | Object.keys(styles).forEach(function (prop) { renderer.setElementStyle(element, prop, styles[prop]); });
|
11487 | }
|
11488 | /**
|
11489 | * @param {?} styles
|
11490 | * @return {?}
|
11491 | */
|
11492 | function flattenStyles(styles) {
|
11493 | var /** @type {?} */ finalStyles = {};
|
11494 | styles.forEach(function (entry) {
|
11495 | Object.keys(entry).forEach(function (prop) { finalStyles[prop] = (entry[prop]); });
|
11496 | });
|
11497 | return finalStyles;
|
11498 | }
|
11499 |
|
11500 | /**
|
11501 | * @license undefined
|
11502 | * Copyright Google Inc. All Rights Reserved.
|
11503 | * *
|
11504 | * Use of this source code is governed by an MIT-style license that can be
|
11505 | * found in the LICENSE file at https://angular.io/license
|
11506 | */
|
11507 | var AnimationStyles = (function () {
|
11508 | /**
|
11509 | * @param {?} styles
|
11510 | */
|
11511 | function AnimationStyles(styles) {
|
11512 | this.styles = styles;
|
11513 | }
|
11514 | return AnimationStyles;
|
11515 | }());
|
11516 |
|
11517 | /**
|
11518 | * An instance of this class is returned as an event parameter when an animation
|
11519 | * callback is captured for an animation either during the start or done phase.
|
11520 | * *
|
11521 | * ```typescript
|
11522 | * host: {
|
11523 | * '[@myAnimationTrigger]': 'someExpression',
|
11524 | * '(@myAnimationTrigger.start)': 'captureStartEvent($event)',
|
11525 | * '(@myAnimationTrigger.done)': 'captureDoneEvent($event)',
|
11526 | * },
|
11527 | * animations: [
|
11528 | * trigger("myAnimationTrigger", [
|
11529 | * // ...
|
11530 | * ])
|
11531 | * ]
|
11532 | * })
|
11533 | * class MyComponent {
|
11534 | * someExpression: any = false;
|
11535 | * captureStartEvent(event: AnimationTransitionEvent) {
|
11536 | * // the toState, fromState and totalTime data is accessible from the event variable
|
11537 | * }
|
11538 | * *
|
11539 | * captureDoneEvent(event: AnimationTransitionEvent) {
|
11540 | * // the toState, fromState and totalTime data is accessible from the event variable
|
11541 | * }
|
11542 | * }
|
11543 | * ```
|
11544 | * *
|
11545 | */
|
11546 | var AnimationTransitionEvent = (function () {
|
11547 | /**
|
11548 | * @param {?} __0
|
11549 | */
|
11550 | function AnimationTransitionEvent(_a) {
|
11551 | var fromState = _a.fromState, toState = _a.toState, totalTime = _a.totalTime, phaseName = _a.phaseName;
|
11552 | this.fromState = fromState;
|
11553 | this.toState = toState;
|
11554 | this.totalTime = totalTime;
|
11555 | this.phaseName = phaseName;
|
11556 | }
|
11557 | return AnimationTransitionEvent;
|
11558 | }());
|
11559 |
|
11560 | var AnimationTransition = (function () {
|
11561 | /**
|
11562 | * @param {?} _player
|
11563 | * @param {?} _fromState
|
11564 | * @param {?} _toState
|
11565 | * @param {?} _totalTime
|
11566 | */
|
11567 | function AnimationTransition(_player, _fromState, _toState, _totalTime) {
|
11568 | this._player = _player;
|
11569 | this._fromState = _fromState;
|
11570 | this._toState = _toState;
|
11571 | this._totalTime = _totalTime;
|
11572 | }
|
11573 | /**
|
11574 | * @param {?} phaseName
|
11575 | * @return {?}
|
11576 | */
|
11577 | AnimationTransition.prototype._createEvent = function (phaseName) {
|
11578 | return new AnimationTransitionEvent({
|
11579 | fromState: this._fromState,
|
11580 | toState: this._toState,
|
11581 | totalTime: this._totalTime,
|
11582 | phaseName: phaseName
|
11583 | });
|
11584 | };
|
11585 | /**
|
11586 | * @param {?} callback
|
11587 | * @return {?}
|
11588 | */
|
11589 | AnimationTransition.prototype.onStart = function (callback) {
|
11590 | var _this = this;
|
11591 | var /** @type {?} */ fn = (Zone.current.wrap(function () { return callback(_this._createEvent('start')); }, 'player.onStart'));
|
11592 | this._player.onStart(fn);
|
11593 | };
|
11594 | /**
|
11595 | * @param {?} callback
|
11596 | * @return {?}
|
11597 | */
|
11598 | AnimationTransition.prototype.onDone = function (callback) {
|
11599 | var _this = this;
|
11600 | var /** @type {?} */ fn = (Zone.current.wrap(function () { return callback(_this._createEvent('done')); }, 'player.onDone'));
|
11601 | this._player.onDone(fn);
|
11602 | };
|
11603 | return AnimationTransition;
|
11604 | }());
|
11605 |
|
11606 | var DebugDomRootRenderer = (function () {
|
11607 | /**
|
11608 | * @param {?} _delegate
|
11609 | */
|
11610 | function DebugDomRootRenderer(_delegate) {
|
11611 | this._delegate = _delegate;
|
11612 | }
|
11613 | /**
|
11614 | * @param {?} componentProto
|
11615 | * @return {?}
|
11616 | */
|
11617 | DebugDomRootRenderer.prototype.renderComponent = function (componentProto) {
|
11618 | return new DebugDomRenderer(this._delegate.renderComponent(componentProto));
|
11619 | };
|
11620 | return DebugDomRootRenderer;
|
11621 | }());
|
11622 | var DebugDomRenderer = (function () {
|
11623 | /**
|
11624 | * @param {?} _delegate
|
11625 | */
|
11626 | function DebugDomRenderer(_delegate) {
|
11627 | this._delegate = _delegate;
|
11628 | }
|
11629 | /**
|
11630 | * @param {?} selectorOrNode
|
11631 | * @param {?=} debugInfo
|
11632 | * @return {?}
|
11633 | */
|
11634 | DebugDomRenderer.prototype.selectRootElement = function (selectorOrNode, debugInfo) {
|
11635 | var /** @type {?} */ nativeEl = this._delegate.selectRootElement(selectorOrNode, debugInfo);
|
11636 | var /** @type {?} */ debugEl = new DebugElement(nativeEl, null, debugInfo);
|
11637 | indexDebugNode(debugEl);
|
11638 | return nativeEl;
|
11639 | };
|
11640 | /**
|
11641 | * @param {?} parentElement
|
11642 | * @param {?} name
|
11643 | * @param {?=} debugInfo
|
11644 | * @return {?}
|
11645 | */
|
11646 | DebugDomRenderer.prototype.createElement = function (parentElement, name, debugInfo) {
|
11647 | var /** @type {?} */ nativeEl = this._delegate.createElement(parentElement, name, debugInfo);
|
11648 | var /** @type {?} */ debugEl = new DebugElement(nativeEl, getDebugNode(parentElement), debugInfo);
|
11649 | debugEl.name = name;
|
11650 | indexDebugNode(debugEl);
|
11651 | return nativeEl;
|
11652 | };
|
11653 | /**
|
11654 | * @param {?} hostElement
|
11655 | * @return {?}
|
11656 | */
|
11657 | DebugDomRenderer.prototype.createViewRoot = function (hostElement) { return this._delegate.createViewRoot(hostElement); };
|
11658 | /**
|
11659 | * @param {?} parentElement
|
11660 | * @param {?=} debugInfo
|
11661 | * @return {?}
|
11662 | */
|
11663 | DebugDomRenderer.prototype.createTemplateAnchor = function (parentElement, debugInfo) {
|
11664 | var /** @type {?} */ comment = this._delegate.createTemplateAnchor(parentElement, debugInfo);
|
11665 | var /** @type {?} */ debugEl = new DebugNode(comment, getDebugNode(parentElement), debugInfo);
|
11666 | indexDebugNode(debugEl);
|
11667 | return comment;
|
11668 | };
|
11669 | /**
|
11670 | * @param {?} parentElement
|
11671 | * @param {?} value
|
11672 | * @param {?=} debugInfo
|
11673 | * @return {?}
|
11674 | */
|
11675 | DebugDomRenderer.prototype.createText = function (parentElement, value, debugInfo) {
|
11676 | var /** @type {?} */ text = this._delegate.createText(parentElement, value, debugInfo);
|
11677 | var /** @type {?} */ debugEl = new DebugNode(text, getDebugNode(parentElement), debugInfo);
|
11678 | indexDebugNode(debugEl);
|
11679 | return text;
|
11680 | };
|
11681 | /**
|
11682 | * @param {?} parentElement
|
11683 | * @param {?} nodes
|
11684 | * @return {?}
|
11685 | */
|
11686 | DebugDomRenderer.prototype.projectNodes = function (parentElement, nodes) {
|
11687 | var /** @type {?} */ debugParent = getDebugNode(parentElement);
|
11688 | if (isPresent(debugParent) && debugParent instanceof DebugElement) {
|
11689 | var /** @type {?} */ debugElement_1 = debugParent;
|
11690 | nodes.forEach(function (node) { debugElement_1.addChild(getDebugNode(node)); });
|
11691 | }
|
11692 | this._delegate.projectNodes(parentElement, nodes);
|
11693 | };
|
11694 | /**
|
11695 | * @param {?} node
|
11696 | * @param {?} viewRootNodes
|
11697 | * @return {?}
|
11698 | */
|
11699 | DebugDomRenderer.prototype.attachViewAfter = function (node, viewRootNodes) {
|
11700 | var /** @type {?} */ debugNode = getDebugNode(node);
|
11701 | if (isPresent(debugNode)) {
|
11702 | var /** @type {?} */ debugParent = debugNode.parent;
|
11703 | if (viewRootNodes.length > 0 && isPresent(debugParent)) {
|
11704 | var /** @type {?} */ debugViewRootNodes_1 = [];
|
11705 | viewRootNodes.forEach(function (rootNode) { return debugViewRootNodes_1.push(getDebugNode(rootNode)); });
|
11706 | debugParent.insertChildrenAfter(debugNode, debugViewRootNodes_1);
|
11707 | }
|
11708 | }
|
11709 | this._delegate.attachViewAfter(node, viewRootNodes);
|
11710 | };
|
11711 | /**
|
11712 | * @param {?} viewRootNodes
|
11713 | * @return {?}
|
11714 | */
|
11715 | DebugDomRenderer.prototype.detachView = function (viewRootNodes) {
|
11716 | viewRootNodes.forEach(function (node) {
|
11717 | var /** @type {?} */ debugNode = getDebugNode(node);
|
11718 | if (isPresent(debugNode) && isPresent(debugNode.parent)) {
|
11719 | debugNode.parent.removeChild(debugNode);
|
11720 | }
|
11721 | });
|
11722 | this._delegate.detachView(viewRootNodes);
|
11723 | };
|
11724 | /**
|
11725 | * @param {?} hostElement
|
11726 | * @param {?} viewAllNodes
|
11727 | * @return {?}
|
11728 | */
|
11729 | DebugDomRenderer.prototype.destroyView = function (hostElement, viewAllNodes) {
|
11730 | viewAllNodes = viewAllNodes || [];
|
11731 | viewAllNodes.forEach(function (node) { removeDebugNodeFromIndex(getDebugNode(node)); });
|
11732 | this._delegate.destroyView(hostElement, viewAllNodes);
|
11733 | };
|
11734 | /**
|
11735 | * @param {?} renderElement
|
11736 | * @param {?} name
|
11737 | * @param {?} callback
|
11738 | * @return {?}
|
11739 | */
|
11740 | DebugDomRenderer.prototype.listen = function (renderElement, name, callback) {
|
11741 | var /** @type {?} */ debugEl = getDebugNode(renderElement);
|
11742 | if (isPresent(debugEl)) {
|
11743 | debugEl.listeners.push(new EventListener(name, callback));
|
11744 | }
|
11745 | return this._delegate.listen(renderElement, name, callback);
|
11746 | };
|
11747 | /**
|
11748 | * @param {?} target
|
11749 | * @param {?} name
|
11750 | * @param {?} callback
|
11751 | * @return {?}
|
11752 | */
|
11753 | DebugDomRenderer.prototype.listenGlobal = function (target, name, callback) {
|
11754 | return this._delegate.listenGlobal(target, name, callback);
|
11755 | };
|
11756 | /**
|
11757 | * @param {?} renderElement
|
11758 | * @param {?} propertyName
|
11759 | * @param {?} propertyValue
|
11760 | * @return {?}
|
11761 | */
|
11762 | DebugDomRenderer.prototype.setElementProperty = function (renderElement, propertyName, propertyValue) {
|
11763 | var /** @type {?} */ debugEl = getDebugNode(renderElement);
|
11764 | if (isPresent(debugEl) && debugEl instanceof DebugElement) {
|
11765 | debugEl.properties[propertyName] = propertyValue;
|
11766 | }
|
11767 | this._delegate.setElementProperty(renderElement, propertyName, propertyValue);
|
11768 | };
|
11769 | /**
|
11770 | * @param {?} renderElement
|
11771 | * @param {?} attributeName
|
11772 | * @param {?} attributeValue
|
11773 | * @return {?}
|
11774 | */
|
11775 | DebugDomRenderer.prototype.setElementAttribute = function (renderElement, attributeName, attributeValue) {
|
11776 | var /** @type {?} */ debugEl = getDebugNode(renderElement);
|
11777 | if (isPresent(debugEl) && debugEl instanceof DebugElement) {
|
11778 | debugEl.attributes[attributeName] = attributeValue;
|
11779 | }
|
11780 | this._delegate.setElementAttribute(renderElement, attributeName, attributeValue);
|
11781 | };
|
11782 | /**
|
11783 | * @param {?} renderElement
|
11784 | * @param {?} propertyName
|
11785 | * @param {?} propertyValue
|
11786 | * @return {?}
|
11787 | */
|
11788 | DebugDomRenderer.prototype.setBindingDebugInfo = function (renderElement, propertyName, propertyValue) {
|
11789 | this._delegate.setBindingDebugInfo(renderElement, propertyName, propertyValue);
|
11790 | };
|
11791 | /**
|
11792 | * @param {?} renderElement
|
11793 | * @param {?} className
|
11794 | * @param {?} isAdd
|
11795 | * @return {?}
|
11796 | */
|
11797 | DebugDomRenderer.prototype.setElementClass = function (renderElement, className, isAdd) {
|
11798 | var /** @type {?} */ debugEl = getDebugNode(renderElement);
|
11799 | if (isPresent(debugEl) && debugEl instanceof DebugElement) {
|
11800 | debugEl.classes[className] = isAdd;
|
11801 | }
|
11802 | this._delegate.setElementClass(renderElement, className, isAdd);
|
11803 | };
|
11804 | /**
|
11805 | * @param {?} renderElement
|
11806 | * @param {?} styleName
|
11807 | * @param {?} styleValue
|
11808 | * @return {?}
|
11809 | */
|
11810 | DebugDomRenderer.prototype.setElementStyle = function (renderElement, styleName, styleValue) {
|
11811 | var /** @type {?} */ debugEl = getDebugNode(renderElement);
|
11812 | if (isPresent(debugEl) && debugEl instanceof DebugElement) {
|
11813 | debugEl.styles[styleName] = styleValue;
|
11814 | }
|
11815 | this._delegate.setElementStyle(renderElement, styleName, styleValue);
|
11816 | };
|
11817 | /**
|
11818 | * @param {?} renderElement
|
11819 | * @param {?} methodName
|
11820 | * @param {?=} args
|
11821 | * @return {?}
|
11822 | */
|
11823 | DebugDomRenderer.prototype.invokeElementMethod = function (renderElement, methodName, args) {
|
11824 | this._delegate.invokeElementMethod(renderElement, methodName, args);
|
11825 | };
|
11826 | /**
|
11827 | * @param {?} renderNode
|
11828 | * @param {?} text
|
11829 | * @return {?}
|
11830 | */
|
11831 | DebugDomRenderer.prototype.setText = function (renderNode, text) { this._delegate.setText(renderNode, text); };
|
11832 | /**
|
11833 | * @param {?} element
|
11834 | * @param {?} startingStyles
|
11835 | * @param {?} keyframes
|
11836 | * @param {?} duration
|
11837 | * @param {?} delay
|
11838 | * @param {?} easing
|
11839 | * @param {?=} previousPlayers
|
11840 | * @return {?}
|
11841 | */
|
11842 | DebugDomRenderer.prototype.animate = function (element, startingStyles, keyframes, duration, delay, easing, previousPlayers) {
|
11843 | if (previousPlayers === void 0) { previousPlayers = []; }
|
11844 | return this._delegate.animate(element, startingStyles, keyframes, duration, delay, easing, previousPlayers);
|
11845 | };
|
11846 | return DebugDomRenderer;
|
11847 | }());
|
11848 |
|
11849 | var ViewType = {};
|
11850 | ViewType.HOST = 0;
|
11851 | ViewType.COMPONENT = 1;
|
11852 | ViewType.EMBEDDED = 2;
|
11853 | ViewType[ViewType.HOST] = "HOST";
|
11854 | ViewType[ViewType.COMPONENT] = "COMPONENT";
|
11855 | ViewType[ViewType.EMBEDDED] = "EMBEDDED";
|
11856 |
|
11857 | var StaticNodeDebugInfo = (function () {
|
11858 | /**
|
11859 | * @param {?} providerTokens
|
11860 | * @param {?} componentToken
|
11861 | * @param {?} refTokens
|
11862 | */
|
11863 | function StaticNodeDebugInfo(providerTokens, componentToken, refTokens) {
|
11864 | this.providerTokens = providerTokens;
|
11865 | this.componentToken = componentToken;
|
11866 | this.refTokens = refTokens;
|
11867 | }
|
11868 | return StaticNodeDebugInfo;
|
11869 | }());
|
11870 | var DebugContext = (function () {
|
11871 | /**
|
11872 | * @param {?} _view
|
11873 | * @param {?} _nodeIndex
|
11874 | * @param {?} _tplRow
|
11875 | * @param {?} _tplCol
|
11876 | */
|
11877 | function DebugContext(_view, _nodeIndex, _tplRow, _tplCol) {
|
11878 | this._view = _view;
|
11879 | this._nodeIndex = _nodeIndex;
|
11880 | this._tplRow = _tplRow;
|
11881 | this._tplCol = _tplCol;
|
11882 | }
|
11883 | Object.defineProperty(DebugContext.prototype, "_staticNodeInfo", {
|
11884 | /**
|
11885 | * @return {?}
|
11886 | */
|
11887 | get: function () {
|
11888 | return isPresent(this._nodeIndex) ? this._view.staticNodeDebugInfos[this._nodeIndex] : null;
|
11889 | },
|
11890 | enumerable: true,
|
11891 | configurable: true
|
11892 | });
|
11893 | Object.defineProperty(DebugContext.prototype, "context", {
|
11894 | /**
|
11895 | * @return {?}
|
11896 | */
|
11897 | get: function () { return this._view.context; },
|
11898 | enumerable: true,
|
11899 | configurable: true
|
11900 | });
|
11901 | Object.defineProperty(DebugContext.prototype, "component", {
|
11902 | /**
|
11903 | * @return {?}
|
11904 | */
|
11905 | get: function () {
|
11906 | var /** @type {?} */ staticNodeInfo = this._staticNodeInfo;
|
11907 | if (isPresent(staticNodeInfo) && isPresent(staticNodeInfo.componentToken)) {
|
11908 | return this.injector.get(staticNodeInfo.componentToken);
|
11909 | }
|
11910 | return null;
|
11911 | },
|
11912 | enumerable: true,
|
11913 | configurable: true
|
11914 | });
|
11915 | Object.defineProperty(DebugContext.prototype, "componentRenderElement", {
|
11916 | /**
|
11917 | * @return {?}
|
11918 | */
|
11919 | get: function () {
|
11920 | var /** @type {?} */ componentView = this._view;
|
11921 | while (isPresent(componentView.parentView) && componentView.type !== ViewType.COMPONENT) {
|
11922 | componentView = (componentView.parentView);
|
11923 | }
|
11924 | return componentView.parentElement;
|
11925 | },
|
11926 | enumerable: true,
|
11927 | configurable: true
|
11928 | });
|
11929 | Object.defineProperty(DebugContext.prototype, "injector", {
|
11930 | /**
|
11931 | * @return {?}
|
11932 | */
|
11933 | get: function () { return this._view.injector(this._nodeIndex); },
|
11934 | enumerable: true,
|
11935 | configurable: true
|
11936 | });
|
11937 | Object.defineProperty(DebugContext.prototype, "renderNode", {
|
11938 | /**
|
11939 | * @return {?}
|
11940 | */
|
11941 | get: function () {
|
11942 | if (isPresent(this._nodeIndex) && this._view.allNodes) {
|
11943 | return this._view.allNodes[this._nodeIndex];
|
11944 | }
|
11945 | else {
|
11946 | return null;
|
11947 | }
|
11948 | },
|
11949 | enumerable: true,
|
11950 | configurable: true
|
11951 | });
|
11952 | Object.defineProperty(DebugContext.prototype, "providerTokens", {
|
11953 | /**
|
11954 | * @return {?}
|
11955 | */
|
11956 | get: function () {
|
11957 | var /** @type {?} */ staticNodeInfo = this._staticNodeInfo;
|
11958 | return isPresent(staticNodeInfo) ? staticNodeInfo.providerTokens : null;
|
11959 | },
|
11960 | enumerable: true,
|
11961 | configurable: true
|
11962 | });
|
11963 | Object.defineProperty(DebugContext.prototype, "source", {
|
11964 | /**
|
11965 | * @return {?}
|
11966 | */
|
11967 | get: function () {
|
11968 | return this._view.componentType.templateUrl + ":" + this._tplRow + ":" + this._tplCol;
|
11969 | },
|
11970 | enumerable: true,
|
11971 | configurable: true
|
11972 | });
|
11973 | Object.defineProperty(DebugContext.prototype, "references", {
|
11974 | /**
|
11975 | * @return {?}
|
11976 | */
|
11977 | get: function () {
|
11978 | var _this = this;
|
11979 | var /** @type {?} */ varValues = {};
|
11980 | var /** @type {?} */ staticNodeInfo = this._staticNodeInfo;
|
11981 | if (isPresent(staticNodeInfo)) {
|
11982 | var /** @type {?} */ refs_1 = staticNodeInfo.refTokens;
|
11983 | Object.keys(refs_1).forEach(function (refName) {
|
11984 | var /** @type {?} */ refToken = refs_1[refName];
|
11985 | var /** @type {?} */ varValue;
|
11986 | if (isBlank(refToken)) {
|
11987 | varValue = _this._view.allNodes ? _this._view.allNodes[_this._nodeIndex] : null;
|
11988 | }
|
11989 | else {
|
11990 | varValue = _this._view.injectorGet(refToken, _this._nodeIndex, null);
|
11991 | }
|
11992 | varValues[refName] = varValue;
|
11993 | });
|
11994 | }
|
11995 | return varValues;
|
11996 | },
|
11997 | enumerable: true,
|
11998 | configurable: true
|
11999 | });
|
12000 | return DebugContext;
|
12001 | }());
|
12002 |
|
12003 | var ViewAnimationMap = (function () {
|
12004 | function ViewAnimationMap() {
|
12005 | this._map = new Map();
|
12006 | this._allPlayers = [];
|
12007 | }
|
12008 | /**
|
12009 | * @param {?} element
|
12010 | * @param {?} animationName
|
12011 | * @return {?}
|
12012 | */
|
12013 | ViewAnimationMap.prototype.find = function (element, animationName) {
|
12014 | var /** @type {?} */ playersByAnimation = this._map.get(element);
|
12015 | if (isPresent(playersByAnimation)) {
|
12016 | return playersByAnimation[animationName];
|
12017 | }
|
12018 | };
|
12019 | /**
|
12020 | * @param {?} element
|
12021 | * @return {?}
|
12022 | */
|
12023 | ViewAnimationMap.prototype.findAllPlayersByElement = function (element) {
|
12024 | var /** @type {?} */ el = this._map.get(element);
|
12025 | return el ? Object.keys(el).map(function (k) { return el[k]; }) : [];
|
12026 | };
|
12027 | /**
|
12028 | * @param {?} element
|
12029 | * @param {?} animationName
|
12030 | * @param {?} player
|
12031 | * @return {?}
|
12032 | */
|
12033 | ViewAnimationMap.prototype.set = function (element, animationName, player) {
|
12034 | var /** @type {?} */ playersByAnimation = this._map.get(element);
|
12035 | if (!isPresent(playersByAnimation)) {
|
12036 | playersByAnimation = {};
|
12037 | }
|
12038 | var /** @type {?} */ existingEntry = playersByAnimation[animationName];
|
12039 | if (isPresent(existingEntry)) {
|
12040 | this.remove(element, animationName);
|
12041 | }
|
12042 | playersByAnimation[animationName] = player;
|
12043 | this._allPlayers.push(player);
|
12044 | this._map.set(element, playersByAnimation);
|
12045 | };
|
12046 | /**
|
12047 | * @return {?}
|
12048 | */
|
12049 | ViewAnimationMap.prototype.getAllPlayers = function () { return this._allPlayers; };
|
12050 | /**
|
12051 | * @param {?} element
|
12052 | * @param {?} animationName
|
12053 | * @param {?=} targetPlayer
|
12054 | * @return {?}
|
12055 | */
|
12056 | ViewAnimationMap.prototype.remove = function (element, animationName, targetPlayer) {
|
12057 | if (targetPlayer === void 0) { targetPlayer = null; }
|
12058 | var /** @type {?} */ playersByAnimation = this._map.get(element);
|
12059 | if (playersByAnimation) {
|
12060 | var /** @type {?} */ player = playersByAnimation[animationName];
|
12061 | if (!targetPlayer || player === targetPlayer) {
|
12062 | delete playersByAnimation[animationName];
|
12063 | var /** @type {?} */ index = this._allPlayers.indexOf(player);
|
12064 | this._allPlayers.splice(index, 1);
|
12065 | if (Object.keys(playersByAnimation).length === 0) {
|
12066 | this._map.delete(element);
|
12067 | }
|
12068 | }
|
12069 | }
|
12070 | };
|
12071 | return ViewAnimationMap;
|
12072 | }());
|
12073 |
|
12074 | var AnimationViewContext = (function () {
|
12075 | /**
|
12076 | * @param {?} _animationQueue
|
12077 | */
|
12078 | function AnimationViewContext(_animationQueue) {
|
12079 | this._animationQueue = _animationQueue;
|
12080 | this._players = new ViewAnimationMap();
|
12081 | }
|
12082 | /**
|
12083 | * @param {?} callback
|
12084 | * @return {?}
|
12085 | */
|
12086 | AnimationViewContext.prototype.onAllActiveAnimationsDone = function (callback) {
|
12087 | var /** @type {?} */ activeAnimationPlayers = this._players.getAllPlayers();
|
12088 | // we check for the length to avoid having GroupAnimationPlayer
|
12089 | // issue an unnecessary microtask when zero players are passed in
|
12090 | if (activeAnimationPlayers.length) {
|
12091 | new AnimationGroupPlayer(activeAnimationPlayers).onDone(function () { return callback(); });
|
12092 | }
|
12093 | else {
|
12094 | callback();
|
12095 | }
|
12096 | };
|
12097 | /**
|
12098 | * @param {?} element
|
12099 | * @param {?} animationName
|
12100 | * @param {?} player
|
12101 | * @return {?}
|
12102 | */
|
12103 | AnimationViewContext.prototype.queueAnimation = function (element, animationName, player) {
|
12104 | var _this = this;
|
12105 | this._animationQueue.enqueue(player);
|
12106 | this._players.set(element, animationName, player);
|
12107 | player.onDone(function () { return _this._players.remove(element, animationName, player); });
|
12108 | };
|
12109 | /**
|
12110 | * @param {?} element
|
12111 | * @param {?=} animationName
|
12112 | * @return {?}
|
12113 | */
|
12114 | AnimationViewContext.prototype.getAnimationPlayers = function (element, animationName) {
|
12115 | if (animationName === void 0) { animationName = null; }
|
12116 | var /** @type {?} */ players = [];
|
12117 | if (animationName) {
|
12118 | var /** @type {?} */ currentPlayer = this._players.find(element, animationName);
|
12119 | if (currentPlayer) {
|
12120 | _recursePlayers(currentPlayer, players);
|
12121 | }
|
12122 | }
|
12123 | else {
|
12124 | this._players.findAllPlayersByElement(element).forEach(function (player) { return _recursePlayers(player, players); });
|
12125 | }
|
12126 | return players;
|
12127 | };
|
12128 | return AnimationViewContext;
|
12129 | }());
|
12130 | /**
|
12131 | * @param {?} player
|
12132 | * @param {?} collectedPlayers
|
12133 | * @return {?}
|
12134 | */
|
12135 | function _recursePlayers(player, collectedPlayers) {
|
12136 | if ((player instanceof AnimationGroupPlayer) || (player instanceof AnimationSequencePlayer)) {
|
12137 | player.players.forEach(function (player) { return _recursePlayers(player, collectedPlayers); });
|
12138 | }
|
12139 | else {
|
12140 | collectedPlayers.push(player);
|
12141 | }
|
12142 | }
|
12143 |
|
12144 | /**
|
12145 | * @license
|
12146 | * Copyright Google Inc. All Rights Reserved.
|
12147 | *
|
12148 | * Use of this source code is governed by an MIT-style license that can be
|
12149 | * found in the LICENSE file at https://angular.io/license
|
12150 | */
|
12151 | var __extends$15 = (this && this.__extends) || function (d, b) {
|
12152 | for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
12153 | function __() { this.constructor = d; }
|
12154 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
12155 | };
|
12156 | var ElementInjector = (function (_super) {
|
12157 | __extends$15(ElementInjector, _super);
|
12158 | /**
|
12159 | * @param {?} _view
|
12160 | * @param {?} _nodeIndex
|
12161 | */
|
12162 | function ElementInjector(_view, _nodeIndex) {
|
12163 | _super.call(this);
|
12164 | this._view = _view;
|
12165 | this._nodeIndex = _nodeIndex;
|
12166 | }
|
12167 | /**
|
12168 | * @param {?} token
|
12169 | * @param {?=} notFoundValue
|
12170 | * @return {?}
|
12171 | */
|
12172 | ElementInjector.prototype.get = function (token, notFoundValue) {
|
12173 | if (notFoundValue === void 0) { notFoundValue = THROW_IF_NOT_FOUND; }
|
12174 | return this._view.injectorGet(token, this._nodeIndex, notFoundValue);
|
12175 | };
|
12176 | return ElementInjector;
|
12177 | }(Injector));
|
12178 |
|
12179 | /**
|
12180 | * @license
|
12181 | * Copyright Google Inc. All Rights Reserved.
|
12182 | *
|
12183 | * Use of this source code is governed by an MIT-style license that can be
|
12184 | * found in the LICENSE file at https://angular.io/license
|
12185 | */
|
12186 | var __extends$14 = (this && this.__extends) || function (d, b) {
|
12187 | for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
12188 | function __() { this.constructor = d; }
|
12189 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
12190 | };
|
12191 | var /** @type {?} */ _scope_check = wtfCreateScope("AppView#check(ascii id)");
|
12192 | /**
|
12193 | * @experimental
|
12194 | */
|
12195 | var /** @type {?} */ EMPTY_CONTEXT$1 = new Object();
|
12196 | var /** @type {?} */ UNDEFINED$1 = new Object();
|
12197 | /**
|
12198 | * Cost of making objects: http://jsperf.com/instantiate-size-of-object
|
12199 | * *
|
12200 | * @abstract
|
12201 | */
|
12202 | var AppView = (function () {
|
12203 | /**
|
12204 | * @param {?} clazz
|
12205 | * @param {?} componentType
|
12206 | * @param {?} type
|
12207 | * @param {?} viewUtils
|
12208 | * @param {?} parentView
|
12209 | * @param {?} parentIndex
|
12210 | * @param {?} parentElement
|
12211 | * @param {?} cdMode
|
12212 | * @param {?=} declaredViewContainer
|
12213 | */
|
12214 | function AppView(clazz, componentType, type, viewUtils, parentView, parentIndex, parentElement, cdMode, declaredViewContainer) {
|
12215 | if (declaredViewContainer === void 0) { declaredViewContainer = null; }
|
12216 | this.clazz = clazz;
|
12217 | this.componentType = componentType;
|
12218 | this.type = type;
|
12219 | this.viewUtils = viewUtils;
|
12220 | this.parentView = parentView;
|
12221 | this.parentIndex = parentIndex;
|
12222 | this.parentElement = parentElement;
|
12223 | this.cdMode = cdMode;
|
12224 | this.declaredViewContainer = declaredViewContainer;
|
12225 | this.numberOfChecks = 0;
|
12226 | this.ref = new ViewRef_(this, viewUtils.animationQueue);
|
12227 | if (type === ViewType.COMPONENT || type === ViewType.HOST) {
|
12228 | this.renderer = viewUtils.renderComponent(componentType);
|
12229 | }
|
12230 | else {
|
12231 | this.renderer = parentView.renderer;
|
12232 | }
|
12233 | this._directRenderer = this.renderer.directRenderer;
|
12234 | }
|
12235 | Object.defineProperty(AppView.prototype, "animationContext", {
|
12236 | /**
|
12237 | * @return {?}
|
12238 | */
|
12239 | get: function () {
|
12240 | if (!this._animationContext) {
|
12241 | this._animationContext = new AnimationViewContext(this.viewUtils.animationQueue);
|
12242 | }
|
12243 | return this._animationContext;
|
12244 | },
|
12245 | enumerable: true,
|
12246 | configurable: true
|
12247 | });
|
12248 | Object.defineProperty(AppView.prototype, "destroyed", {
|
12249 | /**
|
12250 | * @return {?}
|
12251 | */
|
12252 | get: function () { return this.cdMode === ChangeDetectorStatus.Destroyed; },
|
12253 | enumerable: true,
|
12254 | configurable: true
|
12255 | });
|
12256 | /**
|
12257 | * @param {?} context
|
12258 | * @return {?}
|
12259 | */
|
12260 | AppView.prototype.create = function (context) {
|
12261 | this.context = context;
|
12262 | return this.createInternal(null);
|
12263 | };
|
12264 | /**
|
12265 | * @param {?} rootSelectorOrNode
|
12266 | * @param {?} hostInjector
|
12267 | * @param {?} projectableNodes
|
12268 | * @return {?}
|
12269 | */
|
12270 | AppView.prototype.createHostView = function (rootSelectorOrNode, hostInjector, projectableNodes) {
|
12271 | this.context = (EMPTY_CONTEXT$1);
|
12272 | this._hasExternalHostElement = isPresent(rootSelectorOrNode);
|
12273 | this._hostInjector = hostInjector;
|
12274 | this._hostProjectableNodes = projectableNodes;
|
12275 | return this.createInternal(rootSelectorOrNode);
|
12276 | };
|
12277 | /**
|
12278 | * Overwritten by implementations.
|
12279 | * Returns the ComponentRef for the host element for ViewType.HOST.
|
12280 | * @param {?} rootSelectorOrNode
|
12281 | * @return {?}
|
12282 | */
|
12283 | AppView.prototype.createInternal = function (rootSelectorOrNode) { return null; };
|
12284 | /**
|
12285 | * Overwritten by implementations.
|
12286 | * @param {?} templateNodeIndex
|
12287 | * @return {?}
|
12288 | */
|
12289 | AppView.prototype.createEmbeddedViewInternal = function (templateNodeIndex) { return null; };
|
12290 | /**
|
12291 | * @param {?} lastRootNode
|
12292 | * @param {?} allNodes
|
12293 | * @param {?} disposables
|
12294 | * @return {?}
|
12295 | */
|
12296 | AppView.prototype.init = function (lastRootNode, allNodes, disposables) {
|
12297 | this.lastRootNode = lastRootNode;
|
12298 | this.allNodes = allNodes;
|
12299 | this.disposables = disposables;
|
12300 | if (this.type === ViewType.COMPONENT) {
|
12301 | this.dirtyParentQueriesInternal();
|
12302 | }
|
12303 | };
|
12304 | /**
|
12305 | * @param {?} token
|
12306 | * @param {?} nodeIndex
|
12307 | * @param {?=} notFoundValue
|
12308 | * @return {?}
|
12309 | */
|
12310 | AppView.prototype.injectorGet = function (token, nodeIndex, notFoundValue) {
|
12311 | if (notFoundValue === void 0) { notFoundValue = THROW_IF_NOT_FOUND; }
|
12312 | var /** @type {?} */ result = UNDEFINED$1;
|
12313 | var /** @type {?} */ view = this;
|
12314 | while (result === UNDEFINED$1) {
|
12315 | if (isPresent(nodeIndex)) {
|
12316 | result = view.injectorGetInternal(token, nodeIndex, UNDEFINED$1);
|
12317 | }
|
12318 | if (result === UNDEFINED$1 && view.type === ViewType.HOST) {
|
12319 | result = view._hostInjector.get(token, notFoundValue);
|
12320 | }
|
12321 | nodeIndex = view.parentIndex;
|
12322 | view = view.parentView;
|
12323 | }
|
12324 | return result;
|
12325 | };
|
12326 | /**
|
12327 | * Overwritten by implementations
|
12328 | * @param {?} token
|
12329 | * @param {?} nodeIndex
|
12330 | * @param {?} notFoundResult
|
12331 | * @return {?}
|
12332 | */
|
12333 | AppView.prototype.injectorGetInternal = function (token, nodeIndex, notFoundResult) {
|
12334 | return notFoundResult;
|
12335 | };
|
12336 | /**
|
12337 | * @param {?} nodeIndex
|
12338 | * @return {?}
|
12339 | */
|
12340 | AppView.prototype.injector = function (nodeIndex) { return new ElementInjector(this, nodeIndex); };
|
12341 | /**
|
12342 | * @return {?}
|
12343 | */
|
12344 | AppView.prototype.detachAndDestroy = function () {
|
12345 | if (this.viewContainer) {
|
12346 | this.viewContainer.detachView(this.viewContainer.nestedViews.indexOf(this));
|
12347 | }
|
12348 | else if (this.appRef) {
|
12349 | this.appRef.detachView(this.ref);
|
12350 | }
|
12351 | else if (this._hasExternalHostElement) {
|
12352 | this.detach();
|
12353 | }
|
12354 | this.destroy();
|
12355 | };
|
12356 | /**
|
12357 | * @return {?}
|
12358 | */
|
12359 | AppView.prototype.destroy = function () {
|
12360 | var _this = this;
|
12361 | if (this.cdMode === ChangeDetectorStatus.Destroyed) {
|
12362 | return;
|
12363 | }
|
12364 | var /** @type {?} */ hostElement = this.type === ViewType.COMPONENT ? this.parentElement : null;
|
12365 | if (this.disposables) {
|
12366 | for (var /** @type {?} */ i = 0; i < this.disposables.length; i++) {
|
12367 | this.disposables[i]();
|
12368 | }
|
12369 | }
|
12370 | this.destroyInternal();
|
12371 | this.dirtyParentQueriesInternal();
|
12372 | if (this._animationContext) {
|
12373 | this._animationContext.onAllActiveAnimationsDone(function () { return _this.renderer.destroyView(hostElement, _this.allNodes); });
|
12374 | }
|
12375 | else {
|
12376 | this.renderer.destroyView(hostElement, this.allNodes);
|
12377 | }
|
12378 | this.cdMode = ChangeDetectorStatus.Destroyed;
|
12379 | };
|
12380 | /**
|
12381 | * Overwritten by implementations
|
12382 | * @return {?}
|
12383 | */
|
12384 | AppView.prototype.destroyInternal = function () { };
|
12385 | /**
|
12386 | * Overwritten by implementations
|
12387 | * @return {?}
|
12388 | */
|
12389 | AppView.prototype.detachInternal = function () { };
|
12390 | /**
|
12391 | * @return {?}
|
12392 | */
|
12393 | AppView.prototype.detach = function () {
|
12394 | var _this = this;
|
12395 | this.detachInternal();
|
12396 | if (this._animationContext) {
|
12397 | this._animationContext.onAllActiveAnimationsDone(function () { return _this._renderDetach(); });
|
12398 | }
|
12399 | else {
|
12400 | this._renderDetach();
|
12401 | }
|
12402 | if (this.declaredViewContainer && this.declaredViewContainer !== this.viewContainer &&
|
12403 | this.declaredViewContainer.projectedViews) {
|
12404 | var /** @type {?} */ projectedViews = this.declaredViewContainer.projectedViews;
|
12405 | var /** @type {?} */ index = projectedViews.indexOf(this);
|
12406 | // perf: pop is faster than splice!
|
12407 | if (index >= projectedViews.length - 1) {
|
12408 | projectedViews.pop();
|
12409 | }
|
12410 | else {
|
12411 | projectedViews.splice(index, 1);
|
12412 | }
|
12413 | }
|
12414 | this.appRef = null;
|
12415 | this.viewContainer = null;
|
12416 | this.dirtyParentQueriesInternal();
|
12417 | };
|
12418 | /**
|
12419 | * @return {?}
|
12420 | */
|
12421 | AppView.prototype._renderDetach = function () {
|
12422 | if (this._directRenderer) {
|
12423 | this.visitRootNodesInternal(this._directRenderer.remove, null);
|
12424 | }
|
12425 | else {
|
12426 | this.renderer.detachView(this.flatRootNodes);
|
12427 | }
|
12428 | };
|
12429 | /**
|
12430 | * @param {?} appRef
|
12431 | * @return {?}
|
12432 | */
|
12433 | AppView.prototype.attachToAppRef = function (appRef) {
|
12434 | if (this.viewContainer) {
|
12435 | throw new Error('This view is already attached to a ViewContainer!');
|
12436 | }
|
12437 | this.appRef = appRef;
|
12438 | this.dirtyParentQueriesInternal();
|
12439 | };
|
12440 | /**
|
12441 | * @param {?} viewContainer
|
12442 | * @param {?} prevView
|
12443 | * @return {?}
|
12444 | */
|
12445 | AppView.prototype.attachAfter = function (viewContainer, prevView) {
|
12446 | if (this.appRef) {
|
12447 | throw new Error('This view is already attached directly to the ApplicationRef!');
|
12448 | }
|
12449 | this._renderAttach(viewContainer, prevView);
|
12450 | this.viewContainer = viewContainer;
|
12451 | if (this.declaredViewContainer && this.declaredViewContainer !== viewContainer) {
|
12452 | if (!this.declaredViewContainer.projectedViews) {
|
12453 | this.declaredViewContainer.projectedViews = [];
|
12454 | }
|
12455 | this.declaredViewContainer.projectedViews.push(this);
|
12456 | }
|
12457 | this.dirtyParentQueriesInternal();
|
12458 | };
|
12459 | /**
|
12460 | * @param {?} viewContainer
|
12461 | * @param {?} prevView
|
12462 | * @return {?}
|
12463 | */
|
12464 | AppView.prototype.moveAfter = function (viewContainer, prevView) {
|
12465 | this._renderAttach(viewContainer, prevView);
|
12466 | this.dirtyParentQueriesInternal();
|
12467 | };
|
12468 | /**
|
12469 | * @param {?} viewContainer
|
12470 | * @param {?} prevView
|
12471 | * @return {?}
|
12472 | */
|
12473 | AppView.prototype._renderAttach = function (viewContainer, prevView) {
|
12474 | var /** @type {?} */ prevNode = prevView ? prevView.lastRootNode : viewContainer.nativeElement;
|
12475 | if (this._directRenderer) {
|
12476 | var /** @type {?} */ nextSibling = this._directRenderer.nextSibling(prevNode);
|
12477 | if (nextSibling) {
|
12478 | this.visitRootNodesInternal(this._directRenderer.insertBefore, nextSibling);
|
12479 | }
|
12480 | else {
|
12481 | var /** @type {?} */ parentElement = this._directRenderer.parentElement(prevNode);
|
12482 | if (parentElement) {
|
12483 | this.visitRootNodesInternal(this._directRenderer.appendChild, parentElement);
|
12484 | }
|
12485 | }
|
12486 | }
|
12487 | else {
|
12488 | this.renderer.attachViewAfter(prevNode, this.flatRootNodes);
|
12489 | }
|
12490 | };
|
12491 | Object.defineProperty(AppView.prototype, "changeDetectorRef", {
|
12492 | /**
|
12493 | * @return {?}
|
12494 | */
|
12495 | get: function () { return this.ref; },
|
12496 | enumerable: true,
|
12497 | configurable: true
|
12498 | });
|
12499 | Object.defineProperty(AppView.prototype, "flatRootNodes", {
|
12500 | /**
|
12501 | * @return {?}
|
12502 | */
|
12503 | get: function () {
|
12504 | var /** @type {?} */ nodes = [];
|
12505 | this.visitRootNodesInternal(addToArray, nodes);
|
12506 | return nodes;
|
12507 | },
|
12508 | enumerable: true,
|
12509 | configurable: true
|
12510 | });
|
12511 | /**
|
12512 | * @param {?} parentElement
|
12513 | * @param {?} ngContentIndex
|
12514 | * @return {?}
|
12515 | */
|
12516 | AppView.prototype.projectNodes = function (parentElement, ngContentIndex) {
|
12517 | if (this._directRenderer) {
|
12518 | this.visitProjectedNodes(ngContentIndex, this._directRenderer.appendChild, parentElement);
|
12519 | }
|
12520 | else {
|
12521 | var /** @type {?} */ nodes = [];
|
12522 | this.visitProjectedNodes(ngContentIndex, addToArray, nodes);
|
12523 | this.renderer.projectNodes(parentElement, nodes);
|
12524 | }
|
12525 | };
|
12526 | /**
|
12527 | * @param {?} ngContentIndex
|
12528 | * @param {?} cb
|
12529 | * @param {?} c
|
12530 | * @return {?}
|
12531 | */
|
12532 | AppView.prototype.visitProjectedNodes = function (ngContentIndex, cb, c) {
|
12533 | switch (this.type) {
|
12534 | case ViewType.EMBEDDED:
|
12535 | this.parentView.visitProjectedNodes(ngContentIndex, cb, c);
|
12536 | break;
|
12537 | case ViewType.COMPONENT:
|
12538 | if (this.parentView.type === ViewType.HOST) {
|
12539 | var /** @type {?} */ nodes = this.parentView._hostProjectableNodes[ngContentIndex] || [];
|
12540 | for (var /** @type {?} */ i = 0; i < nodes.length; i++) {
|
12541 | cb(nodes[i], c);
|
12542 | }
|
12543 | }
|
12544 | else {
|
12545 | this.parentView.visitProjectableNodesInternal(this.parentIndex, ngContentIndex, cb, c);
|
12546 | }
|
12547 | break;
|
12548 | }
|
12549 | };
|
12550 | /**
|
12551 | * Overwritten by implementations
|
12552 | * @param {?} cb
|
12553 | * @param {?} c
|
12554 | * @return {?}
|
12555 | */
|
12556 | AppView.prototype.visitRootNodesInternal = function (cb, c) { };
|
12557 | /**
|
12558 | * Overwritten by implementations
|
12559 | * @param {?} nodeIndex
|
12560 | * @param {?} ngContentIndex
|
12561 | * @param {?} cb
|
12562 | * @param {?} c
|
12563 | * @return {?}
|
12564 | */
|
12565 | AppView.prototype.visitProjectableNodesInternal = function (nodeIndex, ngContentIndex, cb, c) { };
|
12566 | /**
|
12567 | * Overwritten by implementations
|
12568 | * @return {?}
|
12569 | */
|
12570 | AppView.prototype.dirtyParentQueriesInternal = function () { };
|
12571 | /**
|
12572 | * @param {?} throwOnChange
|
12573 | * @return {?}
|
12574 | */
|
12575 | AppView.prototype.internalDetectChanges = function (throwOnChange) {
|
12576 | if (this.cdMode !== ChangeDetectorStatus.Detached) {
|
12577 | this.detectChanges(throwOnChange);
|
12578 | }
|
12579 | };
|
12580 | /**
|
12581 | * @param {?} throwOnChange
|
12582 | * @return {?}
|
12583 | */
|
12584 | AppView.prototype.detectChanges = function (throwOnChange) {
|
12585 | var /** @type {?} */ s = _scope_check(this.clazz);
|
12586 | if (this.cdMode === ChangeDetectorStatus.Checked ||
|
12587 | this.cdMode === ChangeDetectorStatus.Errored)
|
12588 | return;
|
12589 | if (this.cdMode === ChangeDetectorStatus.Destroyed) {
|
12590 | this.throwDestroyedError('detectChanges');
|
12591 | }
|
12592 | this.detectChangesInternal(throwOnChange);
|
12593 | if (this.cdMode === ChangeDetectorStatus.CheckOnce)
|
12594 | this.cdMode = ChangeDetectorStatus.Checked;
|
12595 | this.numberOfChecks++;
|
12596 | wtfLeave(s);
|
12597 | };
|
12598 | /**
|
12599 | * Overwritten by implementations
|
12600 | * @param {?} throwOnChange
|
12601 | * @return {?}
|
12602 | */
|
12603 | AppView.prototype.detectChangesInternal = function (throwOnChange) { };
|
12604 | /**
|
12605 | * @return {?}
|
12606 | */
|
12607 | AppView.prototype.markAsCheckOnce = function () { this.cdMode = ChangeDetectorStatus.CheckOnce; };
|
12608 | /**
|
12609 | * @return {?}
|
12610 | */
|
12611 | AppView.prototype.markPathToRootAsCheckOnce = function () {
|
12612 | var /** @type {?} */ c = this;
|
12613 | while (isPresent(c) && c.cdMode !== ChangeDetectorStatus.Detached) {
|
12614 | if (c.cdMode === ChangeDetectorStatus.Checked) {
|
12615 | c.cdMode = ChangeDetectorStatus.CheckOnce;
|
12616 | }
|
12617 | if (c.type === ViewType.COMPONENT) {
|
12618 | c = c.parentView;
|
12619 | }
|
12620 | else {
|
12621 | c = c.viewContainer ? c.viewContainer.parentView : null;
|
12622 | }
|
12623 | }
|
12624 | };
|
12625 | /**
|
12626 | * @param {?} cb
|
12627 | * @return {?}
|
12628 | */
|
12629 | AppView.prototype.eventHandler = function (cb) {
|
12630 | return cb;
|
12631 | };
|
12632 | /**
|
12633 | * @param {?} details
|
12634 | * @return {?}
|
12635 | */
|
12636 | AppView.prototype.throwDestroyedError = function (details) { throw new ViewDestroyedError(details); };
|
12637 | return AppView;
|
12638 | }());
|
12639 | var DebugAppView = (function (_super) {
|
12640 | __extends$14(DebugAppView, _super);
|
12641 | /**
|
12642 | * @param {?} clazz
|
12643 | * @param {?} componentType
|
12644 | * @param {?} type
|
12645 | * @param {?} viewUtils
|
12646 | * @param {?} parentView
|
12647 | * @param {?} parentIndex
|
12648 | * @param {?} parentNode
|
12649 | * @param {?} cdMode
|
12650 | * @param {?} staticNodeDebugInfos
|
12651 | * @param {?=} declaredViewContainer
|
12652 | */
|
12653 | function DebugAppView(clazz, componentType, type, viewUtils, parentView, parentIndex, parentNode, cdMode, staticNodeDebugInfos, declaredViewContainer) {
|
12654 | if (declaredViewContainer === void 0) { declaredViewContainer = null; }
|
12655 | _super.call(this, clazz, componentType, type, viewUtils, parentView, parentIndex, parentNode, cdMode, declaredViewContainer);
|
12656 | this.staticNodeDebugInfos = staticNodeDebugInfos;
|
12657 | this._currentDebugContext = null;
|
12658 | }
|
12659 | /**
|
12660 | * @param {?} context
|
12661 | * @return {?}
|
12662 | */
|
12663 | DebugAppView.prototype.create = function (context) {
|
12664 | this._resetDebug();
|
12665 | try {
|
12666 | return _super.prototype.create.call(this, context);
|
12667 | }
|
12668 | catch (e) {
|
12669 | this._rethrowWithContext(e);
|
12670 | throw e;
|
12671 | }
|
12672 | };
|
12673 | /**
|
12674 | * @param {?} rootSelectorOrNode
|
12675 | * @param {?} injector
|
12676 | * @param {?=} projectableNodes
|
12677 | * @return {?}
|
12678 | */
|
12679 | DebugAppView.prototype.createHostView = function (rootSelectorOrNode, injector, projectableNodes) {
|
12680 | if (projectableNodes === void 0) { projectableNodes = null; }
|
12681 | this._resetDebug();
|
12682 | try {
|
12683 | return _super.prototype.createHostView.call(this, rootSelectorOrNode, injector, projectableNodes);
|
12684 | }
|
12685 | catch (e) {
|
12686 | this._rethrowWithContext(e);
|
12687 | throw e;
|
12688 | }
|
12689 | };
|
12690 | /**
|
12691 | * @param {?} token
|
12692 | * @param {?} nodeIndex
|
12693 | * @param {?=} notFoundResult
|
12694 | * @return {?}
|
12695 | */
|
12696 | DebugAppView.prototype.injectorGet = function (token, nodeIndex, notFoundResult) {
|
12697 | this._resetDebug();
|
12698 | try {
|
12699 | return _super.prototype.injectorGet.call(this, token, nodeIndex, notFoundResult);
|
12700 | }
|
12701 | catch (e) {
|
12702 | this._rethrowWithContext(e);
|
12703 | throw e;
|
12704 | }
|
12705 | };
|
12706 | /**
|
12707 | * @return {?}
|
12708 | */
|
12709 | DebugAppView.prototype.detach = function () {
|
12710 | this._resetDebug();
|
12711 | try {
|
12712 | _super.prototype.detach.call(this);
|
12713 | }
|
12714 | catch (e) {
|
12715 | this._rethrowWithContext(e);
|
12716 | throw e;
|
12717 | }
|
12718 | };
|
12719 | /**
|
12720 | * @return {?}
|
12721 | */
|
12722 | DebugAppView.prototype.destroy = function () {
|
12723 | this._resetDebug();
|
12724 | try {
|
12725 | _super.prototype.destroy.call(this);
|
12726 | }
|
12727 | catch (e) {
|
12728 | this._rethrowWithContext(e);
|
12729 | throw e;
|
12730 | }
|
12731 | };
|
12732 | /**
|
12733 | * @param {?} throwOnChange
|
12734 | * @return {?}
|
12735 | */
|
12736 | DebugAppView.prototype.detectChanges = function (throwOnChange) {
|
12737 | this._resetDebug();
|
12738 | try {
|
12739 | _super.prototype.detectChanges.call(this, throwOnChange);
|
12740 | }
|
12741 | catch (e) {
|
12742 | this._rethrowWithContext(e);
|
12743 | throw e;
|
12744 | }
|
12745 | };
|
12746 | /**
|
12747 | * @return {?}
|
12748 | */
|
12749 | DebugAppView.prototype._resetDebug = function () { this._currentDebugContext = null; };
|
12750 | /**
|
12751 | * @param {?} nodeIndex
|
12752 | * @param {?} rowNum
|
12753 | * @param {?} colNum
|
12754 | * @return {?}
|
12755 | */
|
12756 | DebugAppView.prototype.debug = function (nodeIndex, rowNum, colNum) {
|
12757 | return this._currentDebugContext = new DebugContext(this, nodeIndex, rowNum, colNum);
|
12758 | };
|
12759 | /**
|
12760 | * @param {?} e
|
12761 | * @return {?}
|
12762 | */
|
12763 | DebugAppView.prototype._rethrowWithContext = function (e) {
|
12764 | if (!(e instanceof ViewWrappedError)) {
|
12765 | if (!(e instanceof ExpressionChangedAfterItHasBeenCheckedError)) {
|
12766 | this.cdMode = ChangeDetectorStatus.Errored;
|
12767 | }
|
12768 | if (isPresent(this._currentDebugContext)) {
|
12769 | throw new ViewWrappedError(e, this._currentDebugContext);
|
12770 | }
|
12771 | }
|
12772 | };
|
12773 | /**
|
12774 | * @param {?} cb
|
12775 | * @return {?}
|
12776 | */
|
12777 | DebugAppView.prototype.eventHandler = function (cb) {
|
12778 | var _this = this;
|
12779 | var /** @type {?} */ superHandler = _super.prototype.eventHandler.call(this, cb);
|
12780 | return function (eventName, event) {
|
12781 | _this._resetDebug();
|
12782 | try {
|
12783 | return superHandler.call(_this, eventName, event);
|
12784 | }
|
12785 | catch (e) {
|
12786 | _this._rethrowWithContext(e);
|
12787 | throw e;
|
12788 | }
|
12789 | };
|
12790 | };
|
12791 | return DebugAppView;
|
12792 | }(AppView));
|
12793 |
|
12794 | /**
|
12795 | * A ViewContainer is created for elements that have a ViewContainerRef
|
12796 | * to keep track of the nested views.
|
12797 | */
|
12798 | var ViewContainer = (function () {
|
12799 | /**
|
12800 | * @param {?} index
|
12801 | * @param {?} parentIndex
|
12802 | * @param {?} parentView
|
12803 | * @param {?} nativeElement
|
12804 | */
|
12805 | function ViewContainer(index, parentIndex, parentView, nativeElement) {
|
12806 | this.index = index;
|
12807 | this.parentIndex = parentIndex;
|
12808 | this.parentView = parentView;
|
12809 | this.nativeElement = nativeElement;
|
12810 | }
|
12811 | Object.defineProperty(ViewContainer.prototype, "elementRef", {
|
12812 | /**
|
12813 | * @return {?}
|
12814 | */
|
12815 | get: function () { return new ElementRef(this.nativeElement); },
|
12816 | enumerable: true,
|
12817 | configurable: true
|
12818 | });
|
12819 | Object.defineProperty(ViewContainer.prototype, "vcRef", {
|
12820 | /**
|
12821 | * @return {?}
|
12822 | */
|
12823 | get: function () { return new ViewContainerRef_(this); },
|
12824 | enumerable: true,
|
12825 | configurable: true
|
12826 | });
|
12827 | Object.defineProperty(ViewContainer.prototype, "parentInjector", {
|
12828 | /**
|
12829 | * @return {?}
|
12830 | */
|
12831 | get: function () { return this.parentView.injector(this.parentIndex); },
|
12832 | enumerable: true,
|
12833 | configurable: true
|
12834 | });
|
12835 | Object.defineProperty(ViewContainer.prototype, "injector", {
|
12836 | /**
|
12837 | * @return {?}
|
12838 | */
|
12839 | get: function () { return this.parentView.injector(this.index); },
|
12840 | enumerable: true,
|
12841 | configurable: true
|
12842 | });
|
12843 | /**
|
12844 | * @param {?} throwOnChange
|
12845 | * @return {?}
|
12846 | */
|
12847 | ViewContainer.prototype.detectChangesInNestedViews = function (throwOnChange) {
|
12848 | if (this.nestedViews) {
|
12849 | for (var /** @type {?} */ i = 0; i < this.nestedViews.length; i++) {
|
12850 | this.nestedViews[i].detectChanges(throwOnChange);
|
12851 | }
|
12852 | }
|
12853 | };
|
12854 | /**
|
12855 | * @return {?}
|
12856 | */
|
12857 | ViewContainer.prototype.destroyNestedViews = function () {
|
12858 | if (this.nestedViews) {
|
12859 | for (var /** @type {?} */ i = 0; i < this.nestedViews.length; i++) {
|
12860 | this.nestedViews[i].destroy();
|
12861 | }
|
12862 | }
|
12863 | };
|
12864 | /**
|
12865 | * @param {?} cb
|
12866 | * @param {?} c
|
12867 | * @return {?}
|
12868 | */
|
12869 | ViewContainer.prototype.visitNestedViewRootNodes = function (cb, c) {
|
12870 | if (this.nestedViews) {
|
12871 | for (var /** @type {?} */ i = 0; i < this.nestedViews.length; i++) {
|
12872 | this.nestedViews[i].visitRootNodesInternal(cb, c);
|
12873 | }
|
12874 | }
|
12875 | };
|
12876 | /**
|
12877 | * @param {?} nestedViewClass
|
12878 | * @param {?} callback
|
12879 | * @return {?}
|
12880 | */
|
12881 | ViewContainer.prototype.mapNestedViews = function (nestedViewClass, callback) {
|
12882 | var /** @type {?} */ result = [];
|
12883 | if (this.nestedViews) {
|
12884 | for (var /** @type {?} */ i = 0; i < this.nestedViews.length; i++) {
|
12885 | var /** @type {?} */ nestedView = this.nestedViews[i];
|
12886 | if (nestedView.clazz === nestedViewClass) {
|
12887 | result.push(callback(nestedView));
|
12888 | }
|
12889 | }
|
12890 | }
|
12891 | if (this.projectedViews) {
|
12892 | for (var /** @type {?} */ i = 0; i < this.projectedViews.length; i++) {
|
12893 | var /** @type {?} */ projectedView = this.projectedViews[i];
|
12894 | if (projectedView.clazz === nestedViewClass) {
|
12895 | result.push(callback(projectedView));
|
12896 | }
|
12897 | }
|
12898 | }
|
12899 | return result;
|
12900 | };
|
12901 | /**
|
12902 | * @param {?} view
|
12903 | * @param {?} currentIndex
|
12904 | * @return {?}
|
12905 | */
|
12906 | ViewContainer.prototype.moveView = function (view, currentIndex) {
|
12907 | var /** @type {?} */ previousIndex = this.nestedViews.indexOf(view);
|
12908 | if (view.type === ViewType.COMPONENT) {
|
12909 | throw new Error("Component views can't be moved!");
|
12910 | }
|
12911 | var /** @type {?} */ nestedViews = this.nestedViews;
|
12912 | if (nestedViews == null) {
|
12913 | nestedViews = [];
|
12914 | this.nestedViews = nestedViews;
|
12915 | }
|
12916 | nestedViews.splice(previousIndex, 1);
|
12917 | nestedViews.splice(currentIndex, 0, view);
|
12918 | var /** @type {?} */ prevView = currentIndex > 0 ? nestedViews[currentIndex - 1] : null;
|
12919 | view.moveAfter(this, prevView);
|
12920 | };
|
12921 | /**
|
12922 | * @param {?} view
|
12923 | * @param {?} viewIndex
|
12924 | * @return {?}
|
12925 | */
|
12926 | ViewContainer.prototype.attachView = function (view, viewIndex) {
|
12927 | if (view.type === ViewType.COMPONENT) {
|
12928 | throw new Error("Component views can't be moved!");
|
12929 | }
|
12930 | var /** @type {?} */ nestedViews = this.nestedViews;
|
12931 | if (nestedViews == null) {
|
12932 | nestedViews = [];
|
12933 | this.nestedViews = nestedViews;
|
12934 | }
|
12935 | // perf: array.push is faster than array.splice!
|
12936 | if (viewIndex >= nestedViews.length) {
|
12937 | nestedViews.push(view);
|
12938 | }
|
12939 | else {
|
12940 | nestedViews.splice(viewIndex, 0, view);
|
12941 | }
|
12942 | var /** @type {?} */ prevView = viewIndex > 0 ? nestedViews[viewIndex - 1] : null;
|
12943 | view.attachAfter(this, prevView);
|
12944 | };
|
12945 | /**
|
12946 | * @param {?} viewIndex
|
12947 | * @return {?}
|
12948 | */
|
12949 | ViewContainer.prototype.detachView = function (viewIndex) {
|
12950 | var /** @type {?} */ view = this.nestedViews[viewIndex];
|
12951 | // perf: array.pop is faster than array.splice!
|
12952 | if (viewIndex >= this.nestedViews.length - 1) {
|
12953 | this.nestedViews.pop();
|
12954 | }
|
12955 | else {
|
12956 | this.nestedViews.splice(viewIndex, 1);
|
12957 | }
|
12958 | if (view.type === ViewType.COMPONENT) {
|
12959 | throw new Error("Component views can't be moved!");
|
12960 | }
|
12961 | view.detach();
|
12962 | return view;
|
12963 | };
|
12964 | return ViewContainer;
|
12965 | }());
|
12966 |
|
12967 | var /** @type {?} */ __core_private__ = {
|
12968 | isDefaultChangeDetectionStrategy: isDefaultChangeDetectionStrategy,
|
12969 | ChangeDetectorStatus: ChangeDetectorStatus,
|
12970 | constructDependencies: constructDependencies,
|
12971 | LifecycleHooks: LifecycleHooks,
|
12972 | LIFECYCLE_HOOKS_VALUES: LIFECYCLE_HOOKS_VALUES,
|
12973 | ReflectorReader: ReflectorReader,
|
12974 | CodegenComponentFactoryResolver: CodegenComponentFactoryResolver,
|
12975 | ComponentRef_: ComponentRef_,
|
12976 | ViewContainer: ViewContainer,
|
12977 | AppView: AppView,
|
12978 | DebugAppView: DebugAppView,
|
12979 | NgModuleInjector: NgModuleInjector,
|
12980 | registerModuleFactory: registerModuleFactory,
|
12981 | ViewType: ViewType,
|
12982 | view_utils: view_utils,
|
12983 | ViewMetadata: ViewMetadata,
|
12984 | DebugContext: DebugContext,
|
12985 | StaticNodeDebugInfo: StaticNodeDebugInfo,
|
12986 | devModeEqual: devModeEqual,
|
12987 | UNINITIALIZED: UNINITIALIZED,
|
12988 | ValueUnwrapper: ValueUnwrapper,
|
12989 | RenderDebugInfo: RenderDebugInfo,
|
12990 | TemplateRef_: TemplateRef_,
|
12991 | ReflectionCapabilities: ReflectionCapabilities,
|
12992 | makeDecorator: makeDecorator,
|
12993 | DebugDomRootRenderer: DebugDomRootRenderer,
|
12994 | Console: Console,
|
12995 | reflector: reflector,
|
12996 | Reflector: Reflector,
|
12997 | NoOpAnimationPlayer: NoOpAnimationPlayer,
|
12998 | AnimationPlayer: AnimationPlayer,
|
12999 | AnimationSequencePlayer: AnimationSequencePlayer,
|
13000 | AnimationGroupPlayer: AnimationGroupPlayer,
|
13001 | AnimationKeyframe: AnimationKeyframe,
|
13002 | prepareFinalAnimationStyles: prepareFinalAnimationStyles,
|
13003 | balanceAnimationKeyframes: balanceAnimationKeyframes,
|
13004 | flattenStyles: flattenStyles,
|
13005 | clearStyles: clearStyles,
|
13006 | renderStyles: renderStyles,
|
13007 | collectAndResolveStyles: collectAndResolveStyles,
|
13008 | APP_ID_RANDOM_PROVIDER: APP_ID_RANDOM_PROVIDER,
|
13009 | AnimationStyles: AnimationStyles,
|
13010 | ANY_STATE: ANY_STATE,
|
13011 | DEFAULT_STATE: DEFAULT_STATE,
|
13012 | EMPTY_STATE: EMPTY_STATE,
|
13013 | FILL_STYLE_FLAG: FILL_STYLE_FLAG,
|
13014 | ComponentStillLoadingError: ComponentStillLoadingError,
|
13015 | isPromise: isPromise,
|
13016 | AnimationTransition: AnimationTransition
|
13017 | };
|
13018 |
|
13019 | exports.createPlatform = createPlatform;
|
13020 | exports.assertPlatform = assertPlatform;
|
13021 | exports.destroyPlatform = destroyPlatform;
|
13022 | exports.getPlatform = getPlatform;
|
13023 | exports.PlatformRef = PlatformRef;
|
13024 | exports.ApplicationRef = ApplicationRef;
|
13025 | exports.enableProdMode = enableProdMode;
|
13026 | exports.isDevMode = isDevMode;
|
13027 | exports.createPlatformFactory = createPlatformFactory;
|
13028 | exports.NgProbeToken = NgProbeToken;
|
13029 | exports.APP_ID = APP_ID;
|
13030 | exports.PACKAGE_ROOT_URL = PACKAGE_ROOT_URL;
|
13031 | exports.PLATFORM_INITIALIZER = PLATFORM_INITIALIZER;
|
13032 | exports.APP_BOOTSTRAP_LISTENER = APP_BOOTSTRAP_LISTENER;
|
13033 | exports.APP_INITIALIZER = APP_INITIALIZER;
|
13034 | exports.ApplicationInitStatus = ApplicationInitStatus;
|
13035 | exports.DebugElement = DebugElement;
|
13036 | exports.DebugNode = DebugNode;
|
13037 | exports.asNativeElements = asNativeElements;
|
13038 | exports.getDebugNode = getDebugNode;
|
13039 | exports.Testability = Testability;
|
13040 | exports.TestabilityRegistry = TestabilityRegistry;
|
13041 | exports.setTestabilityGetter = setTestabilityGetter;
|
13042 | exports.TRANSLATIONS = TRANSLATIONS;
|
13043 | exports.TRANSLATIONS_FORMAT = TRANSLATIONS_FORMAT;
|
13044 | exports.LOCALE_ID = LOCALE_ID;
|
13045 | exports.ApplicationModule = ApplicationModule;
|
13046 | exports.wtfCreateScope = wtfCreateScope;
|
13047 | exports.wtfLeave = wtfLeave;
|
13048 | exports.wtfStartTimeRange = wtfStartTimeRange;
|
13049 | exports.wtfEndTimeRange = wtfEndTimeRange;
|
13050 | exports.Type = Type;
|
13051 | exports.EventEmitter = EventEmitter;
|
13052 | exports.ErrorHandler = ErrorHandler;
|
13053 | exports.AnimationTransitionEvent = AnimationTransitionEvent;
|
13054 | exports.AnimationPlayer = AnimationPlayer;
|
13055 | exports.Sanitizer = Sanitizer;
|
13056 | exports.SecurityContext = SecurityContext;
|
13057 | exports.ANALYZE_FOR_ENTRY_COMPONENTS = ANALYZE_FOR_ENTRY_COMPONENTS;
|
13058 | exports.Attribute = Attribute;
|
13059 | exports.ContentChild = ContentChild;
|
13060 | exports.ContentChildren = ContentChildren;
|
13061 | exports.Query = Query;
|
13062 | exports.ViewChild = ViewChild;
|
13063 | exports.ViewChildren = ViewChildren;
|
13064 | exports.Component = Component;
|
13065 | exports.Directive = Directive;
|
13066 | exports.HostBinding = HostBinding;
|
13067 | exports.HostListener = HostListener;
|
13068 | exports.Input = Input;
|
13069 | exports.Output = Output;
|
13070 | exports.Pipe = Pipe;
|
13071 | exports.AfterContentChecked = AfterContentChecked;
|
13072 | exports.AfterContentInit = AfterContentInit;
|
13073 | exports.AfterViewChecked = AfterViewChecked;
|
13074 | exports.AfterViewInit = AfterViewInit;
|
13075 | exports.DoCheck = DoCheck;
|
13076 | exports.OnChanges = OnChanges;
|
13077 | exports.OnDestroy = OnDestroy;
|
13078 | exports.OnInit = OnInit;
|
13079 | exports.CUSTOM_ELEMENTS_SCHEMA = CUSTOM_ELEMENTS_SCHEMA;
|
13080 | exports.NO_ERRORS_SCHEMA = NO_ERRORS_SCHEMA;
|
13081 | exports.NgModule = NgModule;
|
13082 | exports.ViewEncapsulation = ViewEncapsulation;
|
13083 | exports.Version = Version;
|
13084 | exports.VERSION = VERSION;
|
13085 | exports.Class = Class;
|
13086 | exports.forwardRef = forwardRef;
|
13087 | exports.resolveForwardRef = resolveForwardRef;
|
13088 | exports.Injector = Injector;
|
13089 | exports.ReflectiveInjector = ReflectiveInjector;
|
13090 | exports.ResolvedReflectiveFactory = ResolvedReflectiveFactory;
|
13091 | exports.ReflectiveKey = ReflectiveKey;
|
13092 | exports.OpaqueToken = OpaqueToken;
|
13093 | exports.Inject = Inject;
|
13094 | exports.Optional = Optional;
|
13095 | exports.Injectable = Injectable;
|
13096 | exports.Self = Self;
|
13097 | exports.SkipSelf = SkipSelf;
|
13098 | exports.Host = Host;
|
13099 | exports.NgZone = NgZone;
|
13100 | exports.RenderComponentType = RenderComponentType;
|
13101 | exports.Renderer = Renderer;
|
13102 | exports.RootRenderer = RootRenderer;
|
13103 | exports.COMPILER_OPTIONS = COMPILER_OPTIONS;
|
13104 | exports.Compiler = Compiler;
|
13105 | exports.CompilerFactory = CompilerFactory;
|
13106 | exports.ModuleWithComponentFactories = ModuleWithComponentFactories;
|
13107 | exports.ComponentFactory = ComponentFactory;
|
13108 | exports.ComponentRef = ComponentRef;
|
13109 | exports.ComponentFactoryResolver = ComponentFactoryResolver;
|
13110 | exports.ElementRef = ElementRef;
|
13111 | exports.NgModuleFactory = NgModuleFactory;
|
13112 | exports.NgModuleRef = NgModuleRef;
|
13113 | exports.NgModuleFactoryLoader = NgModuleFactoryLoader;
|
13114 | exports.getModuleFactory = getModuleFactory;
|
13115 | exports.QueryList = QueryList;
|
13116 | exports.SystemJsNgModuleLoader = SystemJsNgModuleLoader;
|
13117 | exports.SystemJsNgModuleLoaderConfig = SystemJsNgModuleLoaderConfig;
|
13118 | exports.TemplateRef = TemplateRef;
|
13119 | exports.ViewContainerRef = ViewContainerRef;
|
13120 | exports.EmbeddedViewRef = EmbeddedViewRef;
|
13121 | exports.ViewRef = ViewRef;
|
13122 | exports.ChangeDetectionStrategy = ChangeDetectionStrategy;
|
13123 | exports.ChangeDetectorRef = ChangeDetectorRef;
|
13124 | exports.CollectionChangeRecord = CollectionChangeRecord;
|
13125 | exports.DefaultIterableDiffer = DefaultIterableDiffer;
|
13126 | exports.IterableDiffers = IterableDiffers;
|
13127 | exports.KeyValueChangeRecord = KeyValueChangeRecord;
|
13128 | exports.KeyValueDiffers = KeyValueDiffers;
|
13129 | exports.SimpleChange = SimpleChange;
|
13130 | exports.WrappedValue = WrappedValue;
|
13131 | exports.platformCore = platformCore;
|
13132 | exports.__core_private__ = __core_private__;
|
13133 | exports.AUTO_STYLE = AUTO_STYLE;
|
13134 | exports.AnimationEntryMetadata = AnimationEntryMetadata;
|
13135 | exports.AnimationStateMetadata = AnimationStateMetadata;
|
13136 | exports.AnimationStateDeclarationMetadata = AnimationStateDeclarationMetadata;
|
13137 | exports.AnimationStateTransitionMetadata = AnimationStateTransitionMetadata;
|
13138 | exports.AnimationMetadata = AnimationMetadata;
|
13139 | exports.AnimationKeyframesSequenceMetadata = AnimationKeyframesSequenceMetadata;
|
13140 | exports.AnimationStyleMetadata = AnimationStyleMetadata;
|
13141 | exports.AnimationAnimateMetadata = AnimationAnimateMetadata;
|
13142 | exports.AnimationWithStepsMetadata = AnimationWithStepsMetadata;
|
13143 | exports.AnimationSequenceMetadata = AnimationSequenceMetadata;
|
13144 | exports.AnimationGroupMetadata = AnimationGroupMetadata;
|
13145 | exports.animate = animate;
|
13146 | exports.group = group;
|
13147 | exports.sequence = sequence;
|
13148 | exports.style = style;
|
13149 | exports.state = state;
|
13150 | exports.keyframes = keyframes;
|
13151 | exports.transition = transition;
|
13152 | exports.trigger = trigger;
|
13153 |
|
13154 | })); |
\ | No newline at end of file |