ionic-angular
Version:
A powerful framework for building mobile and progressive web apps with JavaScript and Angular 2
1,747 lines (1,716 loc) • 2.44 MB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.ionicBundle = global.ionicBundle || {})));
}(this, (function (exports) { 'use strict';
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var globalScope;
if (typeof window === 'undefined') {
if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) {
// TODO: Replace any with WorkerGlobalScope from lib.webworker.d.ts #3492
globalScope = (self);
}
else {
globalScope = (global);
}
}
else {
globalScope = (window);
}
/**
* @param {?} fn
* @return {?}
*/
function scheduleMicroTask(fn) {
Zone.current.scheduleMicroTask('scheduleMicrotask', fn);
}
// Need to declare a new variable for global here since TypeScript
// exports the original value of the symbol.
var _global = globalScope;
/**
* @param {?} type
* @return {?}
*/
function getTypeNameForDebugging(type) {
return type['name'] || typeof type;
}
// TODO: remove calls to assert in production environment
// Note: Can't just export this and import in in other files
// as `assert` is a reserved keyword in Dart
_global.assert = function assert(condition) {
// TODO: to be fixed properly via #2830, noop for now
};
/**
* @param {?} obj
* @return {?}
*/
function isPresent(obj) {
return obj != null;
}
/**
* @param {?} obj
* @return {?}
*/
function isBlank(obj) {
return obj == null;
}
/**
* @param {?} obj
* @return {?}
*/
/**
* @param {?} token
* @return {?}
*/
function stringify(token) {
if (typeof token === 'string') {
return token;
}
if (token == null) {
return '' + token;
}
if (token.overriddenName) {
return "" + token.overriddenName;
}
if (token.name) {
return "" + token.name;
}
var /** @type {?} */ res = token.toString();
var /** @type {?} */ newLineIndex = res.indexOf('\n');
return newLineIndex === -1 ? res : res.substring(0, newLineIndex);
}
/**
* @param {?} a
* @param {?} b
* @return {?}
*/
function looseIdentical(a, b) {
return a === b || typeof a === 'number' && typeof b === 'number' && isNaN(a) && isNaN(b);
}
/**
* @param {?} o
* @return {?}
*/
function isJsObject(o) {
return o !== null && (typeof o === 'function' || typeof o === 'object');
}
/**
* @param {?} obj
* @return {?}
*/
function print(obj) {
// tslint:disable-next-line:no-console
console.log(obj);
}
/**
* @param {?} obj
* @return {?}
*/
function warn(obj) {
console.warn(obj);
}
/**
* @param {?} global
* @param {?} path
* @param {?} value
* @return {?}
*/
var _symbolIterator = null;
/**
* @return {?}
*/
function getSymbolIterator() {
if (!_symbolIterator) {
if (((globalScope)).Symbol && Symbol.iterator) {
_symbolIterator = Symbol.iterator;
}
else {
// es6-shim specific logic
var /** @type {?} */ keys = Object.getOwnPropertyNames(Map.prototype);
for (var /** @type {?} */ i = 0; i < keys.length; ++i) {
var /** @type {?} */ key = keys[i];
if (key !== 'entries' && key !== 'size' &&
((Map)).prototype[key] === Map.prototype['entries']) {
_symbolIterator = key;
}
}
}
}
return _symbolIterator;
}
/**
* @param {?} obj
* @return {?}
*/
function isPrimitive(obj) {
return !isJsObject(obj);
}
/**
* @param {?} s
* @return {?}
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var _nextClassId = 0;
var Reflect = _global.Reflect;
/**
* @param {?} annotation
* @return {?}
*/
function extractAnnotation(annotation) {
if (typeof annotation === 'function' && annotation.hasOwnProperty('annotation')) {
// it is a decorator, extract annotation
annotation = annotation.annotation;
}
return annotation;
}
/**
* @param {?} fnOrArray
* @param {?} key
* @return {?}
*/
function applyParams(fnOrArray, key) {
if (fnOrArray === Object || fnOrArray === String || fnOrArray === Function ||
fnOrArray === Number || fnOrArray === Array) {
throw new Error("Can not use native " + stringify(fnOrArray) + " as constructor");
}
if (typeof fnOrArray === 'function') {
return fnOrArray;
}
if (Array.isArray(fnOrArray)) {
var /** @type {?} */ annotations = fnOrArray;
var /** @type {?} */ annoLength = annotations.length - 1;
var /** @type {?} */ fn = fnOrArray[annoLength];
if (typeof fn !== 'function') {
throw new Error("Last position of Class method array must be Function in key " + key + " was '" + stringify(fn) + "'");
}
if (annoLength != fn.length) {
throw new Error("Number of annotations (" + annoLength + ") does not match number of arguments (" + fn.length + ") in the function: " + stringify(fn));
}
var /** @type {?} */ paramsAnnotations = [];
for (var /** @type {?} */ i = 0, /** @type {?} */ ii = annotations.length - 1; i < ii; i++) {
var /** @type {?} */ paramAnnotations = [];
paramsAnnotations.push(paramAnnotations);
var /** @type {?} */ annotation = annotations[i];
if (Array.isArray(annotation)) {
for (var /** @type {?} */ j = 0; j < annotation.length; j++) {
paramAnnotations.push(extractAnnotation(annotation[j]));
}
}
else if (typeof annotation === 'function') {
paramAnnotations.push(extractAnnotation(annotation));
}
else {
paramAnnotations.push(annotation);
}
}
Reflect.defineMetadata('parameters', paramsAnnotations, fn);
return fn;
}
throw new Error("Only Function or Array is supported in Class definition for key '" + key + "' is '" + stringify(fnOrArray) + "'");
}
/**
* Provides a way for expressing ES6 classes with parameter annotations in ES5.
*
* ## Basic Example
*
* ```
* var Greeter = ng.Class({
* constructor: function(name) {
* this.name = name;
* },
*
* greet: function() {
* alert('Hello ' + this.name + '!');
* }
* });
* ```
*
* is equivalent to ES6:
*
* ```
* class Greeter {
* constructor(name) {
* this.name = name;
* }
*
* greet() {
* alert('Hello ' + this.name + '!');
* }
* }
* ```
*
* or equivalent to ES5:
*
* ```
* var Greeter = function (name) {
* this.name = name;
* }
*
* Greeter.prototype.greet = function () {
* alert('Hello ' + this.name + '!');
* }
* ```
*
* ### Example with parameter annotations
*
* ```
* var MyService = ng.Class({
* constructor: [String, [new Optional(), Service], function(name, myService) {
* ...
* }]
* });
* ```
*
* is equivalent to ES6:
*
* ```
* class MyService {
* constructor(name: string, \@Optional() myService: Service) {
* ...
* }
* }
* ```
*
* ### Example with inheritance
*
* ```
* var Shape = ng.Class({
* constructor: (color) {
* this.color = color;
* }
* });
*
* var Square = ng.Class({
* extends: Shape,
* constructor: function(color, size) {
* Shape.call(this, color);
* this.size = size;
* }
* });
* ```
* \@stable
* @param {?} clsDef
* @return {?}
*/
function Class(clsDef) {
var /** @type {?} */ constructor = applyParams(clsDef.hasOwnProperty('constructor') ? clsDef.constructor : undefined, 'constructor');
var /** @type {?} */ proto = constructor.prototype;
if (clsDef.hasOwnProperty('extends')) {
if (typeof clsDef.extends === 'function') {
((constructor)).prototype = proto =
Object.create(((clsDef.extends)).prototype);
}
else {
throw new Error("Class definition 'extends' property must be a constructor function was: " + stringify(clsDef.extends));
}
}
for (var key in clsDef) {
if (key !== 'extends' && key !== 'prototype' && clsDef.hasOwnProperty(key)) {
proto[key] = applyParams(clsDef[key], key);
}
}
if (this && this.annotations instanceof Array) {
Reflect.defineMetadata('annotations', this.annotations, constructor);
}
var /** @type {?} */ constructorName = constructor['name'];
if (!constructorName || constructorName === 'constructor') {
((constructor))['overriddenName'] = "class" + _nextClassId++;
}
return (constructor);
}
/**
* @param {?} name
* @param {?} props
* @param {?=} parentClass
* @param {?=} chainFn
* @return {?}
*/
function makeDecorator(name, props, parentClass, chainFn) {
if (chainFn === void 0) { chainFn = null; }
var /** @type {?} */ metaCtor = makeMetadataCtor([props]);
/**
* @param {?} objOrType
* @return {?}
*/
function DecoratorFactory(objOrType) {
if (!(Reflect && Reflect.getOwnMetadata)) {
throw 'reflect-metadata shim is required when using class decorators';
}
if (this instanceof DecoratorFactory) {
metaCtor.call(this, objOrType);
return this;
}
var /** @type {?} */ annotationInstance = new ((DecoratorFactory))(objOrType);
var /** @type {?} */ chainAnnotation = typeof this === 'function' && Array.isArray(this.annotations) ? this.annotations : [];
chainAnnotation.push(annotationInstance);
var /** @type {?} */ TypeDecorator = (function TypeDecorator(cls) {
var /** @type {?} */ annotations = Reflect.getOwnMetadata('annotations', cls) || [];
annotations.push(annotationInstance);
Reflect.defineMetadata('annotations', annotations, cls);
return cls;
});
TypeDecorator.annotations = chainAnnotation;
TypeDecorator.Class = Class;
if (chainFn)
chainFn(TypeDecorator);
return TypeDecorator;
}
if (parentClass) {
DecoratorFactory.prototype = Object.create(parentClass.prototype);
}
DecoratorFactory.prototype.toString = function () { return ("@" + name); };
((DecoratorFactory)).annotationCls = DecoratorFactory;
return DecoratorFactory;
}
/**
* @param {?} props
* @return {?}
*/
function makeMetadataCtor(props) {
return function ctor() {
var _this = this;
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
}
props.forEach(function (prop, i) {
var /** @type {?} */ argVal = args[i];
if (Array.isArray(prop)) {
// plain parameter
_this[prop[0]] = argVal === undefined ? prop[1] : argVal;
}
else {
for (var propName in prop) {
_this[propName] =
argVal && argVal.hasOwnProperty(propName) ? argVal[propName] : prop[propName];
}
}
});
};
}
/**
* @param {?} name
* @param {?} props
* @param {?=} parentClass
* @return {?}
*/
function makeParamDecorator(name, props, parentClass) {
var /** @type {?} */ metaCtor = makeMetadataCtor(props);
/**
* @param {...?} args
* @return {?}
*/
function ParamDecoratorFactory() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
}
if (this instanceof ParamDecoratorFactory) {
metaCtor.apply(this, args);
return this;
}
var /** @type {?} */ annotationInstance = new ((_a = ((ParamDecoratorFactory))).bind.apply(_a, [void 0].concat(args)))();
((ParamDecorator)).annotation = annotationInstance;
return ParamDecorator;
/**
* @param {?} cls
* @param {?} unusedKey
* @param {?} index
* @return {?}
*/
function ParamDecorator(cls, unusedKey, index) {
var /** @type {?} */ parameters = Reflect.getOwnMetadata('parameters', cls) || [];
// there might be gaps if some in between parameters do not have annotations.
// we pad with nulls.
while (parameters.length <= index) {
parameters.push(null);
}
parameters[index] = parameters[index] || [];
parameters[index].push(annotationInstance);
Reflect.defineMetadata('parameters', parameters, cls);
return cls;
}
var _a;
}
if (parentClass) {
ParamDecoratorFactory.prototype = Object.create(parentClass.prototype);
}
ParamDecoratorFactory.prototype.toString = function () { return ("@" + name); };
((ParamDecoratorFactory)).annotationCls = ParamDecoratorFactory;
return ParamDecoratorFactory;
}
/**
* @param {?} name
* @param {?} props
* @param {?=} parentClass
* @return {?}
*/
function makePropDecorator(name, props, parentClass) {
var /** @type {?} */ metaCtor = makeMetadataCtor(props);
/**
* @param {...?} args
* @return {?}
*/
function PropDecoratorFactory() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
}
if (this instanceof PropDecoratorFactory) {
metaCtor.apply(this, args);
return this;
}
var /** @type {?} */ decoratorInstance = new ((_a = ((PropDecoratorFactory))).bind.apply(_a, [void 0].concat(args)))();
return function PropDecorator(target, name) {
var /** @type {?} */ meta = Reflect.getOwnMetadata('propMetadata', target.constructor) || {};
meta[name] = meta.hasOwnProperty(name) && meta[name] || [];
meta[name].unshift(decoratorInstance);
Reflect.defineMetadata('propMetadata', meta, target.constructor);
};
var _a;
}
if (parentClass) {
PropDecoratorFactory.prototype = Object.create(parentClass.prototype);
}
PropDecoratorFactory.prototype.toString = function () { return ("@" + name); };
((PropDecoratorFactory)).annotationCls = PropDecoratorFactory;
return PropDecoratorFactory;
}
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* Inject decorator and metadata.
*
* @stable
* @Annotation
*/
var Inject = makeParamDecorator('Inject', [['token', undefined]]);
/**
* Optional decorator and metadata.
*
* @stable
* @Annotation
*/
var Optional = makeParamDecorator('Optional', []);
/**
* Injectable decorator and metadata.
*
* @stable
* @Annotation
*/
var Injectable = (makeDecorator('Injectable', []));
/**
* Self decorator and metadata.
*
* @stable
* @Annotation
*/
var Self = makeParamDecorator('Self', []);
/**
* SkipSelf decorator and metadata.
*
* @stable
* @Annotation
*/
var SkipSelf = makeParamDecorator('SkipSelf', []);
/**
* Host decorator and metadata.
*
* @stable
* @Annotation
*/
var Host = makeParamDecorator('Host', []);
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var OpaqueToken = (function () {
/**
* @param {?} _desc
*/
function OpaqueToken(_desc) {
this._desc = _desc;
}
/**
* @return {?}
*/
OpaqueToken.prototype.toString = function () { return "Token " + this._desc; };
OpaqueToken.decorators = [
{ type: Injectable },
];
/** @nocollapse */
OpaqueToken.ctorParameters = function () { return [
null,
]; };
return OpaqueToken;
}());
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* This token can be used to create a virtual provider that will populate the
* `entryComponents` fields of components and ng modules based on its `useValue`.
* All components that are referenced in the `useValue` value (either directly
* or in a nested array or map) will be added to the `entryComponents` property.
*
* ### Example
* The following example shows how the router can populate the `entryComponents`
* field of an NgModule based on the router configuration which refers
* to components.
*
* ```typescript
* // helper function inside the router
* function provideRoutes(routes) {
* return [
* {provide: ROUTES, useValue: routes},
* {provide: ANALYZE_FOR_ENTRY_COMPONENTS, useValue: routes, multi: true}
* ];
* }
*
* // user code
* let routes = [
* {path: '/root', component: RootComp},
* {path: '/teams', component: TeamsComp}
* ];
*
* @NgModule({
* providers: [provideRoutes(routes)]
* })
* class ModuleWithRoutes {}
* ```
*
* @experimental
*/
var ANALYZE_FOR_ENTRY_COMPONENTS = new OpaqueToken('AnalyzeForEntryComponents');
/**
* Attribute decorator and metadata.
*
* @stable
* @Annotation
*/
var Attribute = makeParamDecorator('Attribute', [['attributeName', undefined]]);
/**
* Base class for query metadata.
*
* See {\@link ContentChildren}, {\@link ContentChild}, {\@link ViewChildren}, {\@link ViewChild} for
* more information.
*
* \@stable
* @abstract
*/
var Query = (function () {
function Query() {
}
return Query;
}());
/**
* ContentChildren decorator and metadata.
*
* @stable
* @Annotation
*/
var ContentChildren = (makePropDecorator('ContentChildren', [
['selector', undefined], {
first: false,
isViewQuery: false,
descendants: false,
read: undefined,
}
], Query));
/**
* ContentChild decorator and metadata.
*
* @stable
* @Annotation
*/
var ContentChild = makePropDecorator('ContentChild', [
['selector', undefined], {
first: true,
isViewQuery: false,
descendants: true,
read: undefined,
}
], Query);
/**
* ViewChildren decorator and metadata.
*
* @stable
* @Annotation
*/
var ViewChildren = makePropDecorator('ViewChildren', [
['selector', undefined], {
first: false,
isViewQuery: true,
descendants: true,
read: undefined,
}
], Query);
/**
* ViewChild decorator and metadata.
*
* @stable
* @Annotation
*/
var ViewChild = makePropDecorator('ViewChild', [
['selector', undefined], {
first: true,
isViewQuery: true,
descendants: true,
read: undefined,
}
], Query);
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var ChangeDetectionStrategy = {};
ChangeDetectionStrategy.OnPush = 0;
ChangeDetectionStrategy.Default = 1;
ChangeDetectionStrategy[ChangeDetectionStrategy.OnPush] = "OnPush";
ChangeDetectionStrategy[ChangeDetectionStrategy.Default] = "Default";
var ChangeDetectorStatus = {};
ChangeDetectorStatus.CheckOnce = 0;
ChangeDetectorStatus.Checked = 1;
ChangeDetectorStatus.CheckAlways = 2;
ChangeDetectorStatus.Detached = 3;
ChangeDetectorStatus.Errored = 4;
ChangeDetectorStatus.Destroyed = 5;
ChangeDetectorStatus[ChangeDetectorStatus.CheckOnce] = "CheckOnce";
ChangeDetectorStatus[ChangeDetectorStatus.Checked] = "Checked";
ChangeDetectorStatus[ChangeDetectorStatus.CheckAlways] = "CheckAlways";
ChangeDetectorStatus[ChangeDetectorStatus.Detached] = "Detached";
ChangeDetectorStatus[ChangeDetectorStatus.Errored] = "Errored";
ChangeDetectorStatus[ChangeDetectorStatus.Destroyed] = "Destroyed";
/**
* @param {?} changeDetectionStrategy
* @return {?}
*/
function isDefaultChangeDetectionStrategy(changeDetectionStrategy) {
return isBlank(changeDetectionStrategy) ||
changeDetectionStrategy === ChangeDetectionStrategy.Default;
}
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* Directive decorator and metadata.
*
* @stable
* @Annotation
*/
var Directive = (makeDecorator('Directive', {
selector: undefined,
inputs: undefined,
outputs: undefined,
host: undefined,
providers: undefined,
exportAs: undefined,
queries: undefined
}));
/**
* Component decorator and metadata.
*
* @stable
* @Annotation
*/
var Component = (makeDecorator('Component', {
selector: undefined,
inputs: undefined,
outputs: undefined,
host: undefined,
exportAs: undefined,
moduleId: undefined,
providers: undefined,
viewProviders: undefined,
changeDetection: ChangeDetectionStrategy.Default,
queries: undefined,
templateUrl: undefined,
template: undefined,
styleUrls: undefined,
styles: undefined,
animations: undefined,
encapsulation: undefined,
interpolation: undefined,
entryComponents: undefined
}, Directive));
/**
* Pipe decorator and metadata.
*
* @stable
* @Annotation
*/
var Pipe = (makeDecorator('Pipe', {
name: undefined,
pure: true,
}));
/**
* Input decorator and metadata.
*
* @stable
* @Annotation
*/
var Input = makePropDecorator('Input', [['bindingPropertyName', undefined]]);
/**
* Output decorator and metadata.
*
* @stable
* @Annotation
*/
var Output = makePropDecorator('Output', [['bindingPropertyName', undefined]]);
/**
* HostBinding decorator and metadata.
*
* @stable
* @Annotation
*/
var HostBinding = makePropDecorator('HostBinding', [['hostPropertyName', undefined]]);
/**
* HostListener decorator and metadata.
*
* @stable
* @Annotation
*/
var HostListener = makePropDecorator('HostListener', [['eventName', undefined], ['args', []]]);
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var LifecycleHooks = {};
LifecycleHooks.OnInit = 0;
LifecycleHooks.OnDestroy = 1;
LifecycleHooks.DoCheck = 2;
LifecycleHooks.OnChanges = 3;
LifecycleHooks.AfterContentInit = 4;
LifecycleHooks.AfterContentChecked = 5;
LifecycleHooks.AfterViewInit = 6;
LifecycleHooks.AfterViewChecked = 7;
LifecycleHooks[LifecycleHooks.OnInit] = "OnInit";
LifecycleHooks[LifecycleHooks.OnDestroy] = "OnDestroy";
LifecycleHooks[LifecycleHooks.DoCheck] = "DoCheck";
LifecycleHooks[LifecycleHooks.OnChanges] = "OnChanges";
LifecycleHooks[LifecycleHooks.AfterContentInit] = "AfterContentInit";
LifecycleHooks[LifecycleHooks.AfterContentChecked] = "AfterContentChecked";
LifecycleHooks[LifecycleHooks.AfterViewInit] = "AfterViewInit";
LifecycleHooks[LifecycleHooks.AfterViewChecked] = "AfterViewChecked";
var LIFECYCLE_HOOKS_VALUES = [
LifecycleHooks.OnInit, LifecycleHooks.OnDestroy, LifecycleHooks.DoCheck, LifecycleHooks.OnChanges,
LifecycleHooks.AfterContentInit, LifecycleHooks.AfterContentChecked, LifecycleHooks.AfterViewInit,
LifecycleHooks.AfterViewChecked
];
/**
* \@whatItDoes Lifecycle hook that is called when any data-bound property of a directive changes.
* \@howToUse
* {\@example core/ts/metadata/lifecycle_hooks_spec.ts region='OnChanges'}
*
* \@description
* `ngOnChanges` is called right after the data-bound properties have been checked and before view
* and content children are checked if at least one of them has changed.
* The `changes` parameter contains the changed properties.
*
* See {\@linkDocs guide/lifecycle-hooks#onchanges "Lifecycle Hooks Guide"}.
*
* \@stable
* @abstract
*/
/**
* \@whatItDoes Lifecycle hook that is called after data-bound properties of a directive are
* initialized.
* \@howToUse
* {\@example core/ts/metadata/lifecycle_hooks_spec.ts region='OnInit'}
*
* \@description
* `ngOnInit` is called right after the directive's data-bound properties have been checked for the
* first time, and before any of its children have been checked. It is invoked only once when the
* directive is instantiated.
*
* See {\@linkDocs guide/lifecycle-hooks "Lifecycle Hooks Guide"}.
*
* \@stable
* @abstract
*/
/**
* \@whatItDoes Lifecycle hook that is called when Angular dirty checks a directive.
* \@howToUse
* {\@example core/ts/metadata/lifecycle_hooks_spec.ts region='DoCheck'}
*
* \@description
* `ngDoCheck` gets called to check the changes in the directives in addition to the default
* algorithm. The default change detection algorithm looks for differences by comparing
* bound-property values by reference across change detection runs.
*
* Note that a directive typically should not use both `DoCheck` and {\@link OnChanges} to respond to
* changes on the same input, as `ngOnChanges` will continue to be called when the default change
* detector detects changes.
*
* See {\@link KeyValueDiffers} and {\@link IterableDiffers} for implementing custom dirty checking
* for collections.
*
* See {\@linkDocs guide/lifecycle-hooks#docheck "Lifecycle Hooks Guide"}.
*
* \@stable
* @abstract
*/
/**
* \@whatItDoes Lifecycle hook that is called when a directive, pipe or service is destroyed.
* \@howToUse
* {\@example core/ts/metadata/lifecycle_hooks_spec.ts region='OnDestroy'}
*
* \@description
* `ngOnDestroy` callback is typically used for any custom cleanup that needs to occur when the
* instance is destroyed.
*
* See {\@linkDocs guide/lifecycle-hooks "Lifecycle Hooks Guide"}.
*
* \@stable
* @abstract
*/
/**
*
* \@whatItDoes Lifecycle hook that is called after a directive's content has been fully
* initialized.
* \@howToUse
* {\@example core/ts/metadata/lifecycle_hooks_spec.ts region='AfterContentInit'}
*
* \@description
* See {\@linkDocs guide/lifecycle-hooks#aftercontent "Lifecycle Hooks Guide"}.
*
* \@stable
* @abstract
*/
/**
* \@whatItDoes Lifecycle hook that is called after every check of a directive's content.
* \@howToUse
* {\@example core/ts/metadata/lifecycle_hooks_spec.ts region='AfterContentChecked'}
*
* \@description
* See {\@linkDocs guide/lifecycle-hooks#aftercontent "Lifecycle Hooks Guide"}.
*
* \@stable
* @abstract
*/
/**
* \@whatItDoes Lifecycle hook that is called after a component's view has been fully
* initialized.
* \@howToUse
* {\@example core/ts/metadata/lifecycle_hooks_spec.ts region='AfterViewInit'}
*
* \@description
* See {\@linkDocs guide/lifecycle-hooks#afterview "Lifecycle Hooks Guide"}.
*
* \@stable
* @abstract
*/
/**
* \@whatItDoes Lifecycle hook that is called after every check of a component's view.
* \@howToUse
* {\@example core/ts/metadata/lifecycle_hooks_spec.ts region='AfterViewChecked'}
*
* \@description
* See {\@linkDocs guide/lifecycle-hooks#afterview "Lifecycle Hooks Guide"}.
*
* \@stable
* @abstract
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* Defines a schema that will allow:
* - any non-Angular elements with a `-` in their name,
* - any properties on elements with a `-` in their name which is the common rule for custom
* elements.
*
* @stable
*/
/**
* Defines a schema that will allow any property on any element.
*
* @experimental
*/
/**
* NgModule decorator and metadata.
*
* @stable
* @Annotation
*/
var NgModule = (makeDecorator('NgModule', {
providers: undefined,
declarations: undefined,
imports: undefined,
exports: undefined,
entryComponents: undefined,
bootstrap: undefined,
schemas: undefined,
id: undefined,
}));
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var ViewEncapsulation = {};
ViewEncapsulation.Emulated = 0;
ViewEncapsulation.Native = 1;
ViewEncapsulation.None = 2;
ViewEncapsulation[ViewEncapsulation.Emulated] = "Emulated";
ViewEncapsulation[ViewEncapsulation.Native] = "Native";
ViewEncapsulation[ViewEncapsulation.None] = "None";
/**
* Metadata properties available for configuring Views.
*
* For details on the `\@Component` annotation, see {\@link Component}.
*
* ### Example
*
* ```
* \@Component({
* selector: 'greet',
* template: 'Hello {{name}}!',
* })
* class Greet {
* name: string;
*
* constructor() {
* this.name = 'World';
* }
* }
* ```
*
* @deprecated Use Component instead.
*
* {\@link Component}
*/
var ViewMetadata = (function () {
/**
* @param {?=} __0
*/
function ViewMetadata(_a) {
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;
this.templateUrl = templateUrl;
this.template = template;
this.styleUrls = styleUrls;
this.styles = styles;
this.encapsulation = encapsulation;
this.animations = animations;
this.interpolation = interpolation;
}
return ViewMetadata;
}());
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* \@whatItDoes Represents the version of Angular
*
* \@stable
*/
var Version = (function () {
/**
* @param {?} full
*/
function Version(full) {
this.full = full;
}
Object.defineProperty(Version.prototype, "major", {
/**
* @return {?}
*/
get: function () { return this.full.split('.')[0]; },
enumerable: true,
configurable: true
});
Object.defineProperty(Version.prototype, "minor", {
/**
* @return {?}
*/
get: function () { return this.full.split('.')[1]; },
enumerable: true,
configurable: true
});
Object.defineProperty(Version.prototype, "patch", {
/**
* @return {?}
*/
get: function () { return this.full.split('.').slice(2).join('.'); },
enumerable: true,
configurable: true
});
return Version;
}());
/**
* @stable
*/
var VERSION = new Version('2.4.8');
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
// Public API for util
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* Allows to refer to references which are not yet defined.
*
* For instance, `forwardRef` is used when the `token` which we need to refer to for the purposes of
* DI is declared,
* but not yet defined. It is also used when the `token` which we use when creating a query is not
* yet defined.
*
* ### Example
* {\@example core/di/ts/forward_ref/forward_ref_spec.ts region='forward_ref'}
* \@experimental
* @param {?} forwardRefFn
* @return {?}
*/
function forwardRef(forwardRefFn) {
((forwardRefFn)).__forward_ref__ = forwardRef;
((forwardRefFn)).toString = function () { return stringify(this()); };
return (((forwardRefFn)));
}
/**
* Lazily retrieves the reference value from a forwardRef.
*
* Acts as the identity function when given a non-forward-ref value.
*
* ### Example ([live demo](http://plnkr.co/edit/GU72mJrk1fiodChcmiDR?p=preview))
*
* {\@example core/di/ts/forward_ref/forward_ref_spec.ts region='resolve_forward_ref'}
*
* See: {\@link forwardRef}
* \@experimental
* @param {?} type
* @return {?}
*/
function resolveForwardRef(type) {
if (typeof type === 'function' && type.hasOwnProperty('__forward_ref__') &&
type.__forward_ref__ === forwardRef) {
return ((type))();
}
else {
return type;
}
}
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var _THROW_IF_NOT_FOUND = new Object();
var THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND;
var _NullInjector = (function () {
function _NullInjector() {
}
/**
* @param {?} token
* @param {?=} notFoundValue
* @return {?}
*/
_NullInjector.prototype.get = function (token, notFoundValue) {
if (notFoundValue === void 0) { notFoundValue = _THROW_IF_NOT_FOUND; }
if (notFoundValue === _THROW_IF_NOT_FOUND) {
throw new Error("No provider for " + stringify(token) + "!");
}
return notFoundValue;
};
return _NullInjector;
}());
/**
* \@whatItDoes Injector interface
* \@howToUse
* ```
* const injector: Injector = ...;
* injector.get(...);
* ```
*
* \@description
* For more details, see the {\@linkDocs guide/dependency-injection "Dependency Injection Guide"}.
*
* ### Example
*
* {\@example core/di/ts/injector_spec.ts region='Injector'}
*
* `Injector` returns itself when given `Injector` as a token:
* {\@example core/di/ts/injector_spec.ts region='injectInjector'}
*
* \@stable
* @abstract
*/
var Injector = (function () {
function Injector() {
}
/**
* Retrieves an instance from the injector based on the provided token.
* If not found:
* - Throws {\@link NoProviderError} if no `notFoundValue` that is not equal to
* Injector.THROW_IF_NOT_FOUND is given
* - Returns the `notFoundValue` otherwise
* @abstract
* @param {?} token
* @param {?=} notFoundValue
* @return {?}
*/
Injector.prototype.get = function (token, notFoundValue) { };
Injector.THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND;
Injector.NULL = new _NullInjector();
return Injector;
}());
var __extends$1 = (undefined && undefined.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
/**
* Convenience to throw an Error with 'unimplemented' as the message.
* @return {?}
*/
/**
* \@stable
*/
var BaseError = (function (_super) {
__extends$1(BaseError, _super);
/**
* @param {?} message
*/
function BaseError(message) {
_super.call(this, message);
// Errors don't use current this, instead they create a new instance.
// We have to do forward all of our api to the nativeInstance.
// TODO(bradfordcsmith): Remove this hack when
// google/closure-compiler/issues/2102 is fixed.
var nativeError = new Error(message);
this._nativeError = nativeError;
}
Object.defineProperty(BaseError.prototype, "message", {
/**
* @return {?}
*/
get: function () { return this._nativeError.message; },
/**
* @param {?} message
* @return {?}
*/
set: function (message) { this._nativeError.message = message; },
enumerable: true,
configurable: true
});
Object.defineProperty(BaseError.prototype, "name", {
/**
* @return {?}
*/
get: function () { return this._nativeError.name; },
enumerable: true,
configurable: true
});
Object.defineProperty(BaseError.prototype, "stack", {
/**
* @return {?}
*/
get: function () { return ((this._nativeError)).stack; },
/**
* @param {?} value
* @return {?}
*/
set: function (value) { ((this._nativeError)).stack = value; },
enumerable: true,
configurable: true
});
/**
* @return {?}
*/
BaseError.prototype.toString = function () { return this._nativeError.toString(); };
return BaseError;
}(Error));
/**
* \@stable
*/
var WrappedError = (function (_super) {
__extends$1(WrappedError, _super);
/**
* @param {?} message
* @param {?} error
*/
function WrappedError(message, error) {
_super.call(this, message + " caused by: " + (error instanceof Error ? error.message : error));
this.originalError = error;
}
Object.defineProperty(WrappedError.prototype, "stack", {
/**
* @return {?}
*/
get: function () {
return (((this.originalError instanceof Error ? this.originalError : this._nativeError)))
.stack;
},
enumerable: true,
configurable: true
});
return WrappedError;
}(BaseError));
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var __extends = (undefined && undefined.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
/**
* @param {?} keys
* @return {?}
*/
function findFirstClosedCycle(keys) {
var /** @type {?} */ res = [];
for (var /** @type {?} */ i = 0; i < keys.length; ++i) {
if (res.indexOf(keys[i]) > -1) {
res.push(keys[i]);
return res;
}
res.push(keys[i]);
}
return res;
}
/**
* @param {?} keys
* @return {?}
*/
function constructResolvingPath(keys) {
if (keys.length > 1) {
var /** @type {?} */ reversed = findFirstClosedCycle(keys.slice().reverse());
var /** @type {?} */ tokenStrs = reversed.map(function (k) { return stringify(k.token); });
return ' (' + tokenStrs.join(' -> ') + ')';
}
return '';
}
/**
* Base class for all errors arising from misconfigured providers.
* \@stable
*/
var AbstractProviderError = (function (_super) {
__extends(AbstractProviderError, _super);
/**
* @param {?} injector
* @param {?} key
* @param {?} constructResolvingMessage
*/
function AbstractProviderError(injector, key, constructResolvingMessage) {
_super.call(this, 'DI Error');
this.keys = [key];
this.injectors = [injector];
this.constructResolvingMessage = constructResolvingMessage;
this.message = this.constructResolvingMessage(this.keys);
}
/**
* @param {?} injector
* @param {?} key
* @return {?}
*/
AbstractProviderError.prototype.addKey = function (injector, key) {
this.injectors.push(injector);
this.keys.push(key);
this.message = this.constructResolvingMessage(this.keys);
};
return AbstractProviderError;
}(BaseError));
/**
* Thrown when trying to retrieve a dependency by key from {\@link Injector}, but the
* {\@link Injector} does not have a {\@link Provider} for the given key.
*
* ### Example ([live demo](http://plnkr.co/edit/vq8D3FRB9aGbnWJqtEPE?p=preview))
*
* ```typescript
* class A {
* constructor(b:B) {}
* }
*
* expect(() => Injector.resolveAndCreate([A])).toThrowError();
* ```
* \@stable
*/
var NoProviderError = (function (_super) {
__extends(NoProviderError, _super);
/**
* @param {?} injector
* @param {?} key
*/
function NoProviderError(injector, key) {
_super.call(this, injector, key, function (keys) {
var first = stringify(keys[0].token);
return "No provider for " + first + "!" + constructResolvingPath(keys);
});
}
return NoProviderError;
}(AbstractProviderError));
/**
* Thrown when dependencies form a cycle.
*
* ### Example ([live demo](http://plnkr.co/edit/wYQdNos0Tzql3ei1EV9j?p=info))
*
* ```typescript
* var injector = Injector.resolveAndCreate([
* {provide: "one", useFactory: (two) => "two", deps: [[new Inject("two")]]},
* {provide: "two", useFactory: (one) => "one", deps: [[new Inject("one")]]}
* ]);
*
* expect(() => injector.get("one")).toThrowError();
* ```
*
* Retrieving `A` or `B` throws a `CyclicDependencyError` as the graph above cannot be constructed.
* \@stable
*/
var CyclicDependencyError = (function (_super) {
__extends(CyclicDependencyError, _super);
/**
* @param {?} injector
* @param {?} key
*/
function CyclicDependencyError(injector, key) {
_super.call(this, injector, key, function (keys) {
return "Cannot instantiate cyclic dependency!" + constructResolvingPath(keys);
});
}
return CyclicDependencyError;
}(AbstractProviderError));
/**
* Thrown when a constructing type returns with an Error.
*
* The `InstantiationError` class contains the original error plus the dependency graph which caused
* this object to be instantiated.
*
* ### Example ([live demo](http://plnkr.co/edit/7aWYdcqTQsP0eNqEdUAf?p=preview))
*
* ```typescript
* class A {
* constructor() {
* throw new Error('message');
* }
* }
*
* var injector = Injector.resolveAndCreate([A]);
* try {
* injector.get(A);
* } catch (e) {
* expect(e instanceof InstantiationError).toBe(true);
* expect(e.originalException.message).toEqual("message");
* expect(e.originalStack).toBeDefined();
* }
* ```
* \@stable
*/
var InstantiationError = (function (_super) {
__extends(InstantiationError, _super);
/**
* @param {?} injector
* @param {?} originalException
* @param {?} originalStack
* @param {?} key
*/
function InstantiationError(injector, originalException, originalStack, key) {
_super.call(this, 'DI Error', originalException);
this.keys = [key];
this.injectors = [injector];
}
/**
* @param {?} injector
* @param {?} key
* @return {?}
*/
InstantiationError.prototype.addKey = function (injector, key) {
this.injectors.push(injector);
this.keys.push(key);
};
Object.defineProperty(InstantiationError.prototype, "message", {
/**
* @return {?}
*/
get: function () {
var /** @type {?} */ first = stringify(this.keys[0].token);
return this.originalError.message + ": Error during instantiation of " + first + "!" + constructResolvingPath(this.keys) + ".";
},
enumerable: true,
configurable: true
});
Object.defineProperty(InstantiationError.prototype, "causeKey", {
/**
* @return {?}
*/
get: function () { return this.keys[0]; },
enumerable: true,
configurable: true
});
return InstantiationError;
}(WrappedError));
/**
* Thrown when an object other then {\@link Provider} (or `Type`) is passed to {\@link Injector}
* creation.
*
* ### Example ([live demo](http://plnkr.co/edit/YatCFbPAMCL0JSSQ4mvH?p=preview))
*
* ```typescript
* expect(() => Injector.resolveAndCreate(["not a type"])).toThrowError();
* ```
* \@stable
*/
var InvalidProviderError = (function (_super) {
__extends(InvalidProviderError, _super);
/**
* @param {?} provider
*/
function InvalidProviderError(provider) {
_super.call(this, "Invalid provider - only instances of Provider and Type are allowed, got: " + provider);
}
return InvalidProviderError;
}(BaseError));
/**
* Thrown when the class has no annotation information.
*
* Lack of annotation information prevents the {\@link Injector} from determining which dependencies
* need to be injected into the constructor.
*
* ### Example ([live demo](http://plnkr.co/edit/rHnZtlNS7vJOPQ6pcVkm?p=preview))
*
* ```typescript
* class A {
* constructor(b) {}
* }
*
* expect(() => Injector.resolveAndCreate([A])).toThrowError();
* ```
*
* This error is also thrown when the class not marked with {\@link Injectable} has parameter types.
*
* ```typescript
* class B {}
*
* class A {
* constructor(b:B) {} // no information about the parameter types of A is available at runtime.
* }
*
* expect(() => Injector.resolveAndCreate([A,B])).toThrowError();
* ```
* \@stable
*/
var NoAnnotationError = (function (_super) {
__extends(NoAnnotationError, _super);
/**
* @param {?} typeOrFunc
* @param {?} params
*/
function NoAnnotationError(typeOrFunc, params) {
_super.call(this, NoAnnotationError._genMessage(typeOrFunc, params));
}
/**
* @param {?} typeOrFunc
* @param {?} params
* @return {?}
*/
NoAnnotationError._genMessage = function (typeOrFunc, params) {
var /** @type {?} */ signature = [];
for (var /** @type {?} */ i = 0, /** @type {?} */ ii = params.length; i < ii; i++) {
var /** @type {?} */ parameter = params[i];
if (!parameter || parameter.length == 0) {
signature.push('?');
}
else {
signature.push(parameter.map(stringify).join(' '));
}
}
return 'Cannot resolve all parameters for \'' + stringify(typeOrFunc) + '\'(' +
signature.join(', ') + '). ' +
'Make sure that all the parameters are decorated with Inject or have valid type annotations and that \'' +
stringify(typeOrFunc) + '\' is decorated with Injectable.';
};
return NoAnnotationError;
}(BaseError));
/**
* Thrown when getting an object by index.
*
* ### Example ([live demo](http://plnkr.co/edit/bRs0SX2OTQiJzqvjgl8P?p=preview))
*
* ```typescript
* class A {}
*
* var injector = Injector.resolveAndCreate([A]);
*
* expect(() => injector.getAt(100)).toThrowError();
* ```
* \@stable
*/
var OutOfBoundsError = (function (_super) {
__extends(OutOfBoundsError, _super);
/**
* @param {?} index
*/
function OutOfBoundsError(index) {
_super.call(this, "Index " + index + " is out-of-bounds.");
}
return OutOfBoundsError;
}(BaseError));
/**
* Thrown when a multi provider and a regular provider are bound to the same token.
*
* ### Example
*
* ```typescript
* expect(() => Injector.resolveAndCreate([
* { provide: "Strings", useValue: "string1", multi: true},
* { provide: "Strings", useValue: "string2", multi: false}
* ])).toThrowError();
* ```
*/
var MixingMultiProvidersWithRegularProvidersError = (function (_super) {
__extends(MixingMultiProvidersWithRegularProvidersError, _super);
/**
* @param {?} provider1
* @param {?} provider2
*/
function MixingMultiProvidersWithRegularProvidersError(provider1, provider2) {
_super.call(this, 'Cannot mix multi providers and regular providers, got: ' + provider1.toString() + ' ' +
provider2.toString());
}
return MixingMultiProvidersWithRegularProvidersError;
}(BaseError));
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* A unique object used for retrieving items from the {\@link ReflectiveInjector}.
*
* Keys have:
* - a system-wide unique `id`.
* - a `token`.
*
* `Key` is used internally by {\@link ReflectiveInjector} because its system-wide unique `id` allows
* the
* injector to store created objects in a more efficient way.
*
* `Key` should not be created directly. {\@link ReflectiveInjector} creates keys automatically when
* resolving
* providers.
* \@experimental
*/
var ReflectiveKey = (function () {
/**
* Private
* @param {?} token
* @param {?} id
*/
function ReflectiveKey(token, id) {
this.token = token;
this.id = id;
if (!token) {
throw new Error('Token must be defined!');
}
}
Object.defineProperty(ReflectiveKey.prototype, "displayName", {
/**
* Returns a stringified token.
* @return {?}
*/
get: function () { return stringify(this.token); },
enumerable: true,
configurable: true
});
/**
* Retrieves a `Key` for a token.
* @param {?} token
* @return {?}
*/
ReflectiveKey.get = function (token) {
return _globalKeyRegistry.get(resolveForwardRef(token));
};
Object.defineProperty(ReflectiveKey, "numberOfKeys", {
/**
* @return {?} the number of keys registered in the system.
*/
get: function () { return _globalKeyRegistry.numberOfKeys; },
enumerable: true,
configurable: true
});
return ReflectiveKey;
}());
/**
* \@internal
*/
var KeyRegistry = (function () {
function KeyRegistry() {
this._allKeys = new Map();
}
/**
* @param {?} token
* @return {?}
*/
KeyRegistry.prototype.get = function (token) {
if (token instanceof ReflectiveKey)
return token;
if (this._allKeys.has(token)) {
return this._allKeys.get(token);
}
var /** @type {?} */ newKey = new ReflectiveKey(token, ReflectiveKey.numberOfKeys);
this._allKeys.set(token, newKey);
return newKey;
};
Object.defineProperty(KeyRegistry.prototype, "numberOfKeys", {
/**
* @re