UNPKG

@angular/core

Version:

Angular - the core framework

1,622 lines (1,616 loc) • 495 kB
/** * @license Angular v4.4.3 * (c) 2010-2017 Google, Inc. https://angular.io/ * License: MIT */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('rxjs/Observable'), require('rxjs/observable/merge'), require('rxjs/operator/share'), require('rxjs/Subject')) : typeof define === 'function' && define.amd ? define(['exports', 'rxjs/Observable', 'rxjs/observable/merge', 'rxjs/operator/share', 'rxjs/Subject'], factory) : (factory((global.ng = global.ng || {}, global.ng.core = global.ng.core || {}),global.Rx,global.Rx.Observable,global.Rx.Observable.prototype,global.Rx)); }(this, (function (exports,rxjs_Observable,rxjs_observable_merge,rxjs_operator_share,rxjs_Subject) { 'use strict'; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ /* global Reflect, Promise */ var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; function __extends(d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); } /** * @license Angular v4.4.3 * (c) 2010-2017 Google, Inc. https://angular.io/ * License: MIT */ /** * Creates a token that can be used in a DI Provider. * * ### Example ([live demo](http://plnkr.co/edit/Ys9ezXpj2Mnoy3Uc8KBp?p=preview)) * * ```typescript * var t = new OpaqueToken("value"); * * var injector = Injector.resolveAndCreate([ * {provide: t, useValue: "bindingValue"} * ]); * * expect(injector.get(t)).toEqual("bindingValue"); * ``` * * Using an `OpaqueToken` is preferable to using strings as tokens because of possible collisions * caused by multiple providers using the same string as two different tokens. * * Using an `OpaqueToken` is preferable to using an `Object` as tokens because it provides better * error messages. * @deprecated since v4.0.0 because it does not support type information, use `InjectionToken<?>` * instead. */ var OpaqueToken = (function () { /** * @param {?} _desc */ function OpaqueToken(_desc) { this._desc = _desc; } /** * @return {?} */ OpaqueToken.prototype.toString = function () { return "Token " + this._desc; }; return OpaqueToken; }()); /** * Creates a token that can be used in a DI Provider. * * Use an `InjectionToken` whenever the type you are injecting is not reified (does not have a * runtime representation) such as when injecting an interface, callable type, array or * parametrized type. * * `InjectionToken` is parameterized on `T` which is the type of object which will be returned by * the `Injector`. This provides additional level of type safety. * * ``` * interface MyInterface {...} * var myInterface = injector.get(new InjectionToken<MyInterface>('SomeToken')); * // myInterface is inferred to be MyInterface. * ``` * * ### Example * * {\@example core/di/ts/injector_spec.ts region='InjectionToken'} * * \@stable */ var InjectionToken = (function (_super) { __extends(InjectionToken, _super); /** * @param {?} desc */ function InjectionToken(desc) { return _super.call(this, desc) || this; } /** * @return {?} */ InjectionToken.prototype.toString = function () { return "InjectionToken " + this._desc; }; return InjectionToken; }(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 */ var __window = typeof window !== 'undefined' && window; var __self = typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope && self; var __global = typeof global !== 'undefined' && global; var _global = __window || __global || __self; var _symbolIterator = null; /** * @return {?} */ function getSymbolIterator() { if (!_symbolIterator) { var /** @type {?} */ Symbol = _global['Symbol']; if (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 {?} fn * @return {?} */ function scheduleMicroTask(fn) { Zone.current.scheduleMicroTask('scheduleMicrotask', fn); } /** * @param {?} a * @param {?} b * @return {?} */ function looseIdentical(a, b) { return a === b || typeof a === 'number' && typeof b === 'number' && isNaN(a) && isNaN(b); } /** * @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(); if (res == null) { return '' + res; } var /** @type {?} */ newLineIndex = res.indexOf('\n'); return newLineIndex === -1 ? res : res.substring(0, newLineIndex); } /** * @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$1 = _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$1.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; * } * }); * ``` * @suppress {globalThis} * \@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 /** @type {?} */ key in clsDef) { if (key !== 'extends' && key !== 'prototype' && clsDef.hasOwnProperty(key)) { proto[key] = applyParams(clsDef[key], key); } } if (this && this.annotations instanceof Array) { Reflect$1.defineMetadata('annotations', this.annotations, constructor); } var /** @type {?} */ constructorName = constructor['name']; if (!constructorName || constructorName === 'constructor') { ((constructor))['overriddenName'] = "class" + _nextClassId++; } return (constructor); } /** * @suppress {globalThis} * @param {?} name * @param {?=} props * @param {?=} parentClass * @param {?=} chainFn * @return {?} */ function makeDecorator(name, props, parentClass, chainFn) { var /** @type {?} */ metaCtor = makeMetadataCtor(props); /** * @param {?} objOrType * @return {?} */ function DecoratorFactory(objOrType) { if (!(Reflect$1 && Reflect$1.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$1.getOwnMetadata('annotations', cls) || []; annotations.push(annotationInstance); Reflect$1.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 args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } if (props) { var /** @type {?} */ values = props.apply(void 0, args); for (var /** @type {?} */ propName in values) { this[propName] = values[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] = arguments[_i]; } if (this instanceof ParamDecoratorFactory) { metaCtor.apply(this, args); return this; } var /** @type {?} */ annotationInstance = new (((ParamDecoratorFactory)).bind.apply(((ParamDecoratorFactory)), [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$1.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] || []; /** @type {?} */ ((parameters[index])).push(annotationInstance); Reflect$1.defineMetadata('parameters', parameters, cls); return cls; } } 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] = arguments[_i]; } if (this instanceof PropDecoratorFactory) { metaCtor.apply(this, args); return this; } var /** @type {?} */ decoratorInstance = new (((PropDecoratorFactory)).bind.apply(((PropDecoratorFactory)), [void 0].concat(args)))(); return function PropDecorator(target, name) { var /** @type {?} */ meta = Reflect$1.getOwnMetadata('propMetadata', target.constructor) || {}; meta[name] = meta.hasOwnProperty(name) && meta[name] || []; meta[name].unshift(decoratorInstance); Reflect$1.defineMetadata('propMetadata', meta, target.constructor); }; } 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 */ /** * 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 InjectionToken('AnalyzeForEntryComponents'); /** * Attribute decorator and metadata. * * \@stable * \@Annotation */ var Attribute = makeParamDecorator('Attribute', function (attributeName) { return ({ attributeName: attributeName }); }); /** * 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', function (selector, data) { if (data === void 0) { data = {}; } return (Object.assign({ selector: selector, first: false, isViewQuery: false, descendants: false }, data)); }, Query); /** * ContentChild decorator and metadata. * * \@stable * \@Annotation */ var ContentChild = makePropDecorator('ContentChild', function (selector, data) { if (data === void 0) { data = {}; } return (Object.assign({ selector: selector, first: true, isViewQuery: false, descendants: true }, data)); }, Query); /** * ViewChildren decorator and metadata. * * \@stable * \@Annotation */ var ViewChildren = makePropDecorator('ViewChildren', function (selector, data) { if (data === void 0) { data = {}; } return (Object.assign({ selector: selector, first: false, isViewQuery: true, descendants: true }, data)); }, Query); /** * ViewChild decorator and metadata. * * \@stable * \@Annotation */ var ViewChild = makePropDecorator('ViewChild', function (selector, data) { return (Object.assign({ selector: selector, first: true, isViewQuery: true, descendants: true }, data)); }, Query); 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 changeDetectionStrategy == null || 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', function (dir) { if (dir === void 0) { dir = {}; } return dir; }); /** * Component decorator and metadata. * * \@stable * \@Annotation */ var Component = makeDecorator('Component', function (c) { if (c === void 0) { c = {}; } return (Object.assign({ changeDetection: ChangeDetectionStrategy.Default }, c)); }, Directive); /** * Pipe decorator and metadata. * * \@stable * \@Annotation */ var Pipe = makeDecorator('Pipe', function (p) { return (Object.assign({ pure: true }, p)); }); /** * Input decorator and metadata. * * \@stable * \@Annotation */ var Input = makePropDecorator('Input', function (bindingPropertyName) { return ({ bindingPropertyName: bindingPropertyName }); }); /** * Output decorator and metadata. * * \@stable * \@Annotation */ var Output = makePropDecorator('Output', function (bindingPropertyName) { return ({ bindingPropertyName: bindingPropertyName }); }); /** * HostBinding decorator and metadata. * * \@stable * \@Annotation */ var HostBinding = makePropDecorator('HostBinding', function (hostPropertyName) { return ({ hostPropertyName: hostPropertyName }); }); /** * HostListener decorator and metadata. * * \@stable * \@Annotation */ var HostListener = makePropDecorator('HostListener', function (eventName, args) { return ({ eventName: eventName, args: 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 */ /** * 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 */ var CUSTOM_ELEMENTS_SCHEMA = { name: 'custom-elements' }; /** * Defines a schema that will allow any property on any element. * * \@experimental */ var NO_ERRORS_SCHEMA = { name: 'no-errors-schema' }; /** * NgModule decorator and metadata. * * \@stable * \@Annotation */ var NgModule = makeDecorator('NgModule', function (ngModule) { return ngModule; }); 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 {?=} opts */ function ViewMetadata(opts) { if (opts === void 0) { opts = {}; } this.templateUrl = opts.templateUrl; this.template = opts.template; this.styleUrls = opts.styleUrls; this.styles = opts.styles; this.encapsulation = opts.encapsulation; this.animations = opts.animations; this.interpolation = opts.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('4.4.3'); /** * @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', function (token) { return ({ token: token }); }); /** * 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 */ /** * 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 an error if no `notFoundValue` that is not equal to * Injector.THROW_IF_NOT_FOUND is given * - Returns the `notFoundValue` otherwise * @abstract * @template T * @param {?} token * @param {?=} notFoundValue * @return {?} */ Injector.prototype.get = function (token, notFoundValue) { }; /** * @deprecated from v4.0.0 use Type<T> or InjectionToken<T> * @suppress {duplicate} * @abstract * @param {?} token * @param {?=} notFoundValue * @return {?} */ Injector.prototype.get = function (token, notFoundValue) { }; return Injector; }()); Injector.THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND; Injector.NULL = new _NullInjector(); /** * @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 ERROR_COMPONENT_TYPE = 'ngComponentType'; var ERROR_DEBUG_CONTEXT = 'ngDebugContext'; var ERROR_ORIGINAL_ERROR = 'ngOriginalError'; var ERROR_LOGGER = 'ngErrorLogger'; /** * @param {?} error * @return {?} */ /** * @param {?} error * @return {?} */ function getDebugContext(error) { return ((error))[ERROR_DEBUG_CONTEXT]; } /** * @param {?} error * @return {?} */ function getOriginalError(error) { return ((error))[ERROR_ORIGINAL_ERROR]; } /** * @param {?} error * @return {?} */ function getErrorLogger(error) { return ((error))[ERROR_LOGGER] || defaultErrorLogger; } /** * @param {?} console * @param {...?} values * @return {?} */ function defaultErrorLogger(console) { var values = []; for (var _i = 1; _i < arguments.length; _i++) { values[_i - 1] = arguments[_i]; } console.error.apply(console, values); } /** * @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 Provides a hook for centralized exception handling. * * \@description * * The default implementation of `ErrorHandler` prints error messages to the `console`. To * intercept error handling, write a custom exception handler that replaces this default as * appropriate for your app. * * ### Example * * ``` * class MyErrorHandler implements ErrorHandler { * handleError(error) { * // do something with the exception * } * } * * \@NgModule({ * providers: [{provide: ErrorHandler, useClass: MyErrorHandler}] * }) * class MyModule {} * ``` * * \@stable */ var ErrorHandler = (function () { /** * @param {?=} deprecatedParameter */ function ErrorHandler( /** * @deprecated since v4.0 parameter no longer has an effect, as ErrorHandler will never * rethrow. */ deprecatedParameter) { /** * \@internal */ this._console = console; } /** * @param {?} error * @return {?} */ ErrorHandler.prototype.handleError = function (error) { var /** @type {?} */ originalError = this._findOriginalError(error); var /** @type {?} */ context = this._findContext(error); // Note: Browser consoles show the place from where console.error was called. // We can use this to give users additional information about the error. var /** @type {?} */ errorLogger = getErrorLogger(error); errorLogger(this._console, "ERROR", error); if (originalError) { errorLogger(this._console, "ORIGINAL ERROR", originalError); } if (context) { errorLogger(this._console, 'ERROR CONTEXT', context); } }; /** * \@internal * @param {?} error * @return {?} */ ErrorHandler.prototype._findContext = function (error) { if (error) { return getDebugContext(error) ? getDebugContext(error) : this._findContext(getOriginalError(error)); } return null; }; /** * \@internal * @param {?} error * @return {?} */ ErrorHandler.prototype._findOriginalError = function (error) { var /** @type {?} */ e = getOriginalError(error); while (e && getOriginalError(e)) { e = getOriginalError(e); } return e; }; return ErrorHandler; }()); /** * @param {?} message * @param {?} originalError * @return {?} */ function wrappedError(message, originalError) { var /** @type {?} */ msg = message + " caused by: " + (originalError instanceof Error ? originalError.message : originalError); var /** @type {?} */ error = Error(msg); ((error))[ERROR_ORIGINAL_ERROR] = originalError; return error; } /** * @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 */ /** * @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 ''; } /** * @param {?} injector * @param {?} key * @param {?} constructResolvingMessage * @param {?=} originalError * @return {?} */ function injectionError(injector, key, constructResolvingMessage, originalError) { var /** @type {?} */ keys = [key]; var /** @type {?} */ errMsg = constructResolvingMessage(keys); var /** @type {?} */ error = ((originalError ? wrappedError(errMsg, originalError) : Error(errMsg))); error.addKey = addKey; error.keys = keys; error.injectors = [injector]; error.constructResolvingMessage = constructResolvingMessage; ((error))[ERROR_ORIGINAL_ERROR] = originalError; return error; } /** * @this {?} * @param {?} injector * @param {?} key * @return {?} */ function addKey(injector, key) { this.injectors.push(injector); this.keys.push(key); // Note: This updated message won't be reflected in the `.stack` property this.message = this.constructResolvingMessage(this.keys); } /** * 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(); * ``` * @param {?} injector * @param {?} key * @return {?} */ function noProviderError(injector, key) { return injectionError(injector, key, function (keys) { var /** @type {?} */ first = stringify(keys[0].token); return "No provider for " + first + "!" + constructResolvingPath(keys); }); } /** * 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. * @param {?} injector * @param {?} key * @return {?} */ function cyclicDependencyError(injector, key) { return injectionError(injector, key, function (keys) { return "Cannot instantiate cyclic dependency!" + constructResolvingPath(keys); }); } /** * 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(); * } * ``` * @param {?} injector * @param {?} originalException * @param {?} originalStack * @param {?} key * @return {?} */ function instantiationError(injector, originalException, originalStack, key) { return injectionError(injector, key, function (keys) { var /** @type {?} */ first = stringify(keys[0].token); return originalException.message + ": Error during instantiation of " + first + "!" + constructResolvingPath(keys) + "."; }, originalException); } /** * 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(); * ``` * @param {?} provider * @return {?} */ function invalidProviderError(provider) { return Error("Invalid provider - only instances of Provider and Type are allowed, got: " + provider); } /** * 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 * @param {?} typeOrFunc * @param {?} params * @return {?} */ function noAnnotationError(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 Error('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.'); } /** * 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 * @param {?} index * @return {?} */ function outOfBoundsError(index) { return Error("Index " + index + " is out-of-bounds."); } /** * 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(); * ``` * @param {?} provider1 * @param {?} provider2 * @return {?} */ function mixingMultiProvidersWithRegularProvidersError(provider1, provider2) { return Error("Cannot mix multi providers and regular providers, got: " + provider1 + " " + provider2); } /** * @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", { /** * @return {?} */ get: function () { return this._allKeys.size; }, enumerable: true, configurable: true }); return KeyRegistry; }()); var _globalKeyRegistry = new KeyRegistry(); /** * \@whatItDoes Represents a type that a Component or other object is instances of. * * \@description * * An example of a `Type` is `MyCustomComponent` class, which in JavaScript is be represented by * the `MyCustomComponent` constructor function. * * \@stable */ var Type = Function; /** * @param {?} v * @return {?} */ function isType(v) { return typeof v === 'function'; } /** * @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 */ /** * Attention: This regex has to hold even if the code is minified! */ var DELEGATE_CTOR = /^function\s+\S+\(\)\s*{[\s\S]+\.apply\(this,\s*arguments\)/; var ReflectionCapabilities = (function () { /** * @param {?=} reflect */ function ReflectionCapabilities(reflect) { this._reflect = reflect || _global['Reflect']; } /** * @return {?} */ ReflectionCapabilities.prototype.isReflectionEnabled = function () { return true; }; /** * @template T * @param {?} t * @return {?} */ ReflectionCapabilities.prototype.factory = function (t) { return function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } return new (t.bind.apply(t, [void 0].concat(args)))(); }; }; /** * \@internal * @param {?} paramTypes * @param {?} paramAnnotations * @return {?} */ ReflectionCapabilities.prototype._zipTypesAndAnnotations = function (paramTypes, paramAnnotations) { var /** @type {?} */ result; if (typeof paramTypes === 'undefined') { result = new Array(paramAnnotations.length); } else { result = new Array(paramTypes.length); } for (var /** @type {?} */ i = 0; i < result.length; i++) { // TS outputs Object for parameters without types, while Traceur omits // the annotations. For now we preserve the Traceur behavior to aid // migration, but this can be revisited. if (typeof paramTypes === 'undefined') { result[i] = []; } else if (paramTypes[i] != Object) { result[i] = [paramTypes[i]]; } else { result[i] = []; } if (paramAnnotations && paramAnnotations[i] != null) { result[i] = result[i].concat(paramAnnotations[i]); } } return result; }; /** * @param {?} type * @param {?} parentCtor * @return {?} */ ReflectionCapabilities.prototype._ownParameters = function (type, parentCtor) { // If we have no decorators, we only have function.length as metadata. // In that case, to detect whether a child class declared an own constructor or not, // we need to look inside of that constructor to check whether it is // just calling the parent. // This also helps to work around for https://github.com/Microsoft/TypeScript/issues/12439 // that sets 'design:paramtypes' to [] // if a class inherits from another class but has no ctor declared itself. if (DELEGATE_CTOR.exec(type.toString())) { return null; } // Prefer the direct API. if (((type)).parameters && ((type)).parameters !== parentCtor.parameters) { return ((type)).parameters; } // API of tsickle for lowering decorators to properties on the class. var /** @type {?} */ tsickleCtorParams = ((type)).ctorParameters; if (tsickleCtorParams && tsickleCtorParams !== parentCtor.ctorParameters) { // Newer tsickle uses a function closure // Retain the non-function case for compatibility with older tsickle var /** @type {?} */ ctorParameters = typeof tsickleCtorParams === 'function' ? tsickleCtorParams() : tsickleCtorParams; var /** @type {?} */ paramTypes = ctorParameters.map(function (ctorParam) { return ctorParam && ctorParam.type; }); var /** @type {?} */ paramAnnotations = ctorParameters.map(function (ctorParam) { return ctorParam && convertTsickleDecoratorIntoMetadata(ctorParam.decorators); }); return this._zipTypesAndAnnotations(paramTypes, paramAnnotations); } // API for metadata created by invoking the decorators. if (this._reflect != null && this._reflect.getOwnMetadata != null) { var /** @type {?} */ paramAnnotations = this._reflect.getOwnMetadata('parameters', type); var /** @type {?} */ paramTypes = this._reflect.getOwnMetadata('design:paramtypes', type); if (paramTypes || paramAnnotations) { return this._zipTypesAndAnnotations(paramTypes, paramAnnotations); } } // If a class has no de