UNPKG

@angular/core

Version:

Angular - the core framework

1,152 lines (1,123 loc) 1.42 MB
/** * @license Angular v8.1.3 * (c) 2010-2019 Google LLC. https://angular.io/ * License: MIT */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('rxjs'), require('rxjs/operators')) : typeof define === 'function' && define.amd ? define('@angular/core', ['exports', 'rxjs', 'rxjs/operators'], factory) : (global = global || self, factory((global.ng = global.ng || {}, global.ng.core = {}), global.rxjs, global.rxjs.operators)); }(this, function (exports, rxjs, operators) { '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 = function(d, b) { 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]; }; return extendStatics(d, b); }; function __extends(d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); } var __assign = function() { __assign = Object.assign || function __assign(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; function __decorate(decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; } function __param(paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } } function __metadata(metadataKey, metadataValue) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); } function __values(o) { var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; if (m) return m.call(o); return { next: function () { if (o && i >= o.length) o = void 0; return { value: o && o[i++], done: !o }; } }; } function __read(o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; } function __spread() { for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); return ar; } /** * @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 ANNOTATIONS = '__annotations__'; var PARAMETERS = '__parameters__'; var PROP_METADATA = '__prop__metadata__'; /** * @suppress {globalThis} */ function makeDecorator(name, props, parentClass, additionalProcessing, typeFn) { var metaCtor = makeMetadataCtor(props); function DecoratorFactory() { var _a; var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } if (this instanceof DecoratorFactory) { metaCtor.call.apply(metaCtor, __spread([this], args)); return this; } var annotationInstance = new ((_a = DecoratorFactory).bind.apply(_a, __spread([void 0], args)))(); return function TypeDecorator(cls) { if (typeFn) typeFn.apply(void 0, __spread([cls], args)); // Use of Object.defineProperty is important since it creates non-enumerable property which // prevents the property is copied during subclassing. var annotations = cls.hasOwnProperty(ANNOTATIONS) ? cls[ANNOTATIONS] : Object.defineProperty(cls, ANNOTATIONS, { value: [] })[ANNOTATIONS]; annotations.push(annotationInstance); if (additionalProcessing) additionalProcessing(cls); return cls; }; } if (parentClass) { DecoratorFactory.prototype = Object.create(parentClass.prototype); } DecoratorFactory.prototype.ngMetadataName = name; DecoratorFactory.annotationCls = DecoratorFactory; return DecoratorFactory; } function makeMetadataCtor(props) { return function ctor() { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } if (props) { var values = props.apply(void 0, __spread(args)); for (var propName in values) { this[propName] = values[propName]; } } }; } function makeParamDecorator(name, props, parentClass) { var metaCtor = makeMetadataCtor(props); function ParamDecoratorFactory() { var _a; 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 annotationInstance = new ((_a = ParamDecoratorFactory).bind.apply(_a, __spread([void 0], args)))(); ParamDecorator.annotation = annotationInstance; return ParamDecorator; function ParamDecorator(cls, unusedKey, index) { // Use of Object.defineProperty is important since it creates non-enumerable property which // prevents the property is copied during subclassing. var parameters = cls.hasOwnProperty(PARAMETERS) ? cls[PARAMETERS] : Object.defineProperty(cls, PARAMETERS, { value: [] })[PARAMETERS]; // 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] || []).push(annotationInstance); return cls; } } if (parentClass) { ParamDecoratorFactory.prototype = Object.create(parentClass.prototype); } ParamDecoratorFactory.prototype.ngMetadataName = name; ParamDecoratorFactory.annotationCls = ParamDecoratorFactory; return ParamDecoratorFactory; } function makePropDecorator(name, props, parentClass, additionalProcessing) { var metaCtor = makeMetadataCtor(props); function PropDecoratorFactory() { var _a; 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 decoratorInstance = new ((_a = PropDecoratorFactory).bind.apply(_a, __spread([void 0], args)))(); function PropDecorator(target, name) { var constructor = target.constructor; // Use of Object.defineProperty is important since it creates non-enumerable property which // prevents the property is copied during subclassing. var meta = constructor.hasOwnProperty(PROP_METADATA) ? constructor[PROP_METADATA] : Object.defineProperty(constructor, PROP_METADATA, { value: {} })[PROP_METADATA]; meta[name] = meta.hasOwnProperty(name) && meta[name] || []; meta[name].unshift(decoratorInstance); if (additionalProcessing) additionalProcessing.apply(void 0, __spread([target, name], args)); } return PropDecorator; } if (parentClass) { PropDecoratorFactory.prototype = Object.create(parentClass.prototype); } PropDecoratorFactory.prototype.ngMetadataName = 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 */ var ɵ0 = function (token) { return ({ token: token }); }; /** * Inject decorator and metadata. * * @Annotation * @publicApi */ var Inject = makeParamDecorator('Inject', ɵ0); /** * Optional decorator and metadata. * * @Annotation * @publicApi */ var Optional = makeParamDecorator('Optional'); /** * Self decorator and metadata. * * @Annotation * @publicApi */ var Self = makeParamDecorator('Self'); /** * SkipSelf decorator and metadata. * * @Annotation * @publicApi */ var SkipSelf = makeParamDecorator('SkipSelf'); /** * Host decorator and metadata. * * @Annotation * @publicApi */ var Host = makeParamDecorator('Host'); var ɵ1 = function (attributeName) { return ({ attributeName: attributeName }); }; /** * Attribute decorator and metadata. * * @Annotation * @publicApi */ var Attribute = makeParamDecorator('Attribute', ɵ1); /** * @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 */ (function (InjectFlags) { // TODO(alxhub): make this 'const' when ngc no longer writes exports of it into ngfactory files. /** Check self and check parent injector if needed */ InjectFlags[InjectFlags["Default"] = 0] = "Default"; /** * Specifies that an injector should retrieve a dependency from any injector until reaching the * host element of the current component. (Only used with Element Injector) */ InjectFlags[InjectFlags["Host"] = 1] = "Host"; /** Don't ascend to ancestors of the node requesting injection. */ InjectFlags[InjectFlags["Self"] = 2] = "Self"; /** Skip the node that is requesting injection. */ InjectFlags[InjectFlags["SkipSelf"] = 4] = "SkipSelf"; /** Inject `defaultValue` instead if token not found. */ InjectFlags[InjectFlags["Optional"] = 8] = "Optional"; })(exports.InjectFlags || (exports.InjectFlags = {})); /** * @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 */ function getClosureSafeProperty(objWithPropertyToExtract) { for (var key in objWithPropertyToExtract) { if (objWithPropertyToExtract[key] === getClosureSafeProperty) { return key; } } throw Error('Could not find renamed property on target object.'); } /** * Sets properties on a target object from a source object, but only if * the property doesn't already exist on the target object. * @param target The target to set properties on * @param source The source of the property keys and values to set */ function fillProperties(target, source) { for (var key in source) { if (source.hasOwnProperty(key) && !target.hasOwnProperty(key)) { target[key] = source[key]; } } } /** * @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 */ /** * Construct an `InjectableDef` which defines how a token will be constructed by the DI system, and * in which injectors (if any) it will be available. * * This should be assigned to a static `ngInjectableDef` field on a type, which will then be an * `InjectableType`. * * Options: * * `providedIn` determines which injectors will include the injectable, by either associating it * with an `@NgModule` or other `InjectorType`, or by specifying that this injectable should be * provided in the `'root'` injector, which will be the application-level injector in most apps. * * `factory` gives the zero argument function which will create an instance of the injectable. * The factory can call `inject` to access the `Injector` and request injection of dependencies. * * @codeGenApi */ function ɵɵdefineInjectable(opts) { return { token: opts.token, providedIn: opts.providedIn || null, factory: opts.factory, value: undefined, }; } /** * @deprecated in v8, delete after v10. This API should be used only be generated code, and that * code should now use ɵɵdefineInjectable instead. * @publicApi */ var defineInjectable = ɵɵdefineInjectable; /** * Construct an `InjectorDef` which configures an injector. * * This should be assigned to a static `ngInjectorDef` field on a type, which will then be an * `InjectorType`. * * Options: * * * `factory`: an `InjectorType` is an instantiable type, so a zero argument `factory` function to * create the type must be provided. If that factory function needs to inject arguments, it can * use the `inject` function. * * `providers`: an optional array of providers to add to the injector. Each provider must * either have a factory or point to a type which has an `ngInjectableDef` static property (the * type must be an `InjectableType`). * * `imports`: an optional array of imports of other `InjectorType`s or `InjectorTypeWithModule`s * whose providers will also be added to the injector. Locally provided types will override * providers from imports. * * @publicApi */ function ɵɵdefineInjector(options) { return { factory: options.factory, providers: options.providers || [], imports: options.imports || [], }; } /** * Read the `ngInjectableDef` for `type` in a way which is immune to accidentally reading inherited * value. * * @param type A type which may have its own (non-inherited) `ngInjectableDef`. */ function getInjectableDef(type) { var def = type[NG_INJECTABLE_DEF]; // The definition read above may come from a base class. `hasOwnProperty` is not sufficient to // distinguish this case, as in older browsers (e.g. IE10) static property inheritance is // implemented by copying the properties. // // Instead, the ngInjectableDef's token is compared to the type, and if they don't match then the // property was not defined directly on the type itself, and was likely inherited. The definition // is only returned if the type matches the def.token. return def && def.token === type ? def : null; } /** * Read the `ngInjectableDef` for `type` or read the `ngInjectableDef` from one of its ancestors. * * @param type A type which may have `ngInjectableDef`, via inheritance. * * @deprecated Will be removed in v10, where an error will occur in the scenario if we find the * `ngInjectableDef` on an ancestor only. */ function getInheritedInjectableDef(type) { if (type && type[NG_INJECTABLE_DEF]) { // TODO(FW-1307): Re-add ngDevMode when closure can handle it // ngDevMode && console.warn("DEPRECATED: DI is instantiating a token \"" + type.name + "\" that inherits its @Injectable decorator but does not provide one itself.\n" + ("This will become an error in v10. Please add @Injectable() to the \"" + type.name + "\" class.")); return type[NG_INJECTABLE_DEF]; } else { return null; } } /** * Read the `ngInjectorDef` type in a way which is immune to accidentally reading inherited value. * * @param type type which may have `ngInjectorDef` */ function getInjectorDef(type) { return type && type.hasOwnProperty(NG_INJECTOR_DEF) ? type[NG_INJECTOR_DEF] : null; } var NG_INJECTABLE_DEF = getClosureSafeProperty({ ngInjectableDef: getClosureSafeProperty }); var NG_INJECTOR_DEF = getClosureSafeProperty({ ngInjectorDef: getClosureSafeProperty }); /** * @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 */ function stringify(token) { if (typeof token === 'string') { return token; } if (token instanceof Array) { return '[' + token.map(stringify).join(', ') + ']'; } if (token == null) { return '' + token; } if (token.overriddenName) { return "" + token.overriddenName; } if (token.name) { return "" + token.name; } var res = token.toString(); if (res == null) { return '' + res; } var 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 __forward_ref__ = getClosureSafeProperty({ __forward_ref__: getClosureSafeProperty }); /** * 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. * * @usageNotes * ### Example * {@example core/di/ts/forward_ref/forward_ref_spec.ts region='forward_ref'} * @publicApi */ 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. * * @usageNotes * ### Example * * {@example core/di/ts/forward_ref/forward_ref_spec.ts region='resolve_forward_ref'} * * @see `forwardRef` * @publicApi */ function resolveForwardRef(type) { var fn = type; if (typeof fn === 'function' && fn.hasOwnProperty(__forward_ref__) && fn.__forward_ref__ === forwardRef) { return fn(); } 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 __globalThis = typeof globalThis !== 'undefined' && globalThis; var __window = typeof window !== 'undefined' && window; var __self = typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope && self; var __global = typeof global !== 'undefined' && global; // Always use __globalThis if available, which is the spec-defined global variable across all // environments, then fallback to __global first, because in Node tests both __global and // __window may be defined and _global should be __global in that case. var _global = __globalThis || __global || __window || __self; /** * @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 R3ResolvedDependencyType; (function (R3ResolvedDependencyType) { R3ResolvedDependencyType[R3ResolvedDependencyType["Token"] = 0] = "Token"; R3ResolvedDependencyType[R3ResolvedDependencyType["Attribute"] = 1] = "Attribute"; })(R3ResolvedDependencyType || (R3ResolvedDependencyType = {})); /** * @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 */ function getCompilerFacade() { var globalNg = _global['ng']; if (!globalNg || !globalNg.ɵcompilerFacade) { throw new Error("Angular JIT compilation failed: '@angular/compiler' not loaded!\n" + " - JIT compilation is discouraged for production use-cases! Consider AOT mode instead.\n" + " - Did you bootstrap using '@angular/platform-browser-dynamic' or '@angular/platform-server'?\n" + " - Alternatively provide the compiler with 'import \"@angular/compiler\";' before bootstrapping."); } return globalNg.ɵcompilerFacade; } /** * @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 */ /** * 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 * parameterized 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. * ``` * * When creating an `InjectionToken`, you can optionally specify a factory function which returns * (possibly by creating) a default value of the parameterized type `T`. This sets up the * `InjectionToken` using this factory as a provider as if it was defined explicitly in the * application's root injector. If the factory function, which takes zero arguments, needs to inject * dependencies, it can do so using the `inject` function. See below for an example. * * Additionally, if a `factory` is specified you can also specify the `providedIn` option, which * overrides the above behavior and marks the token as belonging to a particular `@NgModule`. As * mentioned above, `'root'` is the default value for `providedIn`. * * @usageNotes * ### Basic Example * * ### Plain InjectionToken * * {@example core/di/ts/injector_spec.ts region='InjectionToken'} * * ### Tree-shakable InjectionToken * * {@example core/di/ts/injector_spec.ts region='ShakableInjectionToken'} * * * @publicApi */ var InjectionToken = /** @class */ (function () { function InjectionToken(_desc, options) { this._desc = _desc; /** @internal */ this.ngMetadataName = 'InjectionToken'; this.ngInjectableDef = undefined; if (typeof options == 'number') { // This is a special hack to assign __NG_ELEMENT_ID__ to this instance. // __NG_ELEMENT_ID__ is Used by Ivy to determine bloom filter id. // We are using it to assign `-1` which is used to identify `Injector`. this.__NG_ELEMENT_ID__ = options; } else if (options !== undefined) { this.ngInjectableDef = ɵɵdefineInjectable({ token: this, providedIn: options.providedIn || 'root', factory: options.factory, }); } } InjectionToken.prototype.toString = function () { return "InjectionToken " + this._desc; }; return InjectionToken; }()); /** * @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 */ /** * An InjectionToken that gets the current `Injector` for `createInjector()`-style injectors. * * Requesting this token instead of `Injector` allows `StaticInjector` to be tree-shaken from a * project. * * @publicApi */ var INJECTOR = new InjectionToken('INJECTOR', -1 // `-1` is used by Ivy DI system as special value to recognize it as `Injector`. ); var _THROW_IF_NOT_FOUND = new Object(); var THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND; var NG_TEMP_TOKEN_PATH = 'ngTempTokenPath'; var NG_TOKEN_PATH = 'ngTokenPath'; var NEW_LINE = /\n/gm; var NO_NEW_LINE = 'ɵ'; var SOURCE = '__source'; var ɵ0$1 = getClosureSafeProperty; var USE_VALUE = getClosureSafeProperty({ provide: String, useValue: ɵ0$1 }); /** * Current injector value used by `inject`. * - `undefined`: it is an error to call `inject` * - `null`: `inject` can be called but there is no injector (limp-mode). * - Injector instance: Use the injector for resolution. */ var _currentInjector = undefined; function setCurrentInjector(injector) { var former = _currentInjector; _currentInjector = injector; return former; } /** * Current implementation of inject. * * By default, it is `injectInjectorOnly`, which makes it `Injector`-only aware. It can be changed * to `directiveInject`, which brings in the `NodeInjector` system of ivy. It is designed this * way for two reasons: * 1. `Injector` should not depend on ivy logic. * 2. To maintain tree shake-ability we don't want to bring in unnecessary code. */ var _injectImplementation; /** * Sets the current inject implementation. */ function setInjectImplementation(impl) { var previous = _injectImplementation; _injectImplementation = impl; return previous; } function injectInjectorOnly(token, flags) { if (flags === void 0) { flags = exports.InjectFlags.Default; } if (_currentInjector === undefined) { throw new Error("inject() must be called from an injection context"); } else if (_currentInjector === null) { return injectRootLimpMode(token, undefined, flags); } else { return _currentInjector.get(token, flags & exports.InjectFlags.Optional ? null : undefined, flags); } } function ɵɵinject(token, flags) { if (flags === void 0) { flags = exports.InjectFlags.Default; } return (_injectImplementation || injectInjectorOnly)(token, flags); } /** * Injects a token from the currently active injector. * * Must be used in the context of a factory function such as one defined for an * `InjectionToken`. Throws an error if not called from such a context. * * Within such a factory function, using this function to request injection of a dependency * is faster and more type-safe than providing an additional array of dependencies * (as has been common with `useFactory` providers). * * @param token The injection token for the dependency to be injected. * @param flags Optional flags that control how injection is executed. * The flags correspond to injection strategies that can be specified with * parameter decorators `@Host`, `@Self`, `@SkipSef`, and `@Optional`. * @returns True if injection is successful, null otherwise. * * @usageNotes * * ### Example * * {@example core/di/ts/injector_spec.ts region='ShakableInjectionToken'} * * @publicApi */ var inject = ɵɵinject; /** * Injects `root` tokens in limp mode. * * If no injector exists, we can still inject tree-shakable providers which have `providedIn` set to * `"root"`. This is known as the limp mode injection. In such case the value is stored in the * `InjectableDef`. */ function injectRootLimpMode(token, notFoundValue, flags) { var injectableDef = getInjectableDef(token); if (injectableDef && injectableDef.providedIn == 'root') { return injectableDef.value === undefined ? injectableDef.value = injectableDef.factory() : injectableDef.value; } if (flags & exports.InjectFlags.Optional) return null; if (notFoundValue !== undefined) return notFoundValue; throw new Error("Injector: NOT_FOUND [" + stringify(token) + "]"); } function injectArgs(types) { var args = []; for (var i = 0; i < types.length; i++) { var arg = resolveForwardRef(types[i]); if (Array.isArray(arg)) { if (arg.length === 0) { throw new Error('Arguments array must have arguments.'); } var type = undefined; var flags = exports.InjectFlags.Default; for (var j = 0; j < arg.length; j++) { var meta = arg[j]; if (meta instanceof Optional || meta.ngMetadataName === 'Optional' || meta === Optional) { flags |= exports.InjectFlags.Optional; } else if (meta instanceof SkipSelf || meta.ngMetadataName === 'SkipSelf' || meta === SkipSelf) { flags |= exports.InjectFlags.SkipSelf; } else if (meta instanceof Self || meta.ngMetadataName === 'Self' || meta === Self) { flags |= exports.InjectFlags.Self; } else if (meta instanceof Inject || meta === Inject) { type = meta.token; } else { type = meta; } } args.push(ɵɵinject(type, flags)); } else { args.push(ɵɵinject(arg)); } } return args; } var NullInjector = /** @class */ (function () { function NullInjector() { } NullInjector.prototype.get = function (token, notFoundValue) { if (notFoundValue === void 0) { notFoundValue = THROW_IF_NOT_FOUND; } if (notFoundValue === THROW_IF_NOT_FOUND) { // Intentionally left behind: With dev tools open the debugger will stop here. There is no // reason why correctly written application should cause this exception. // TODO(misko): uncomment the next line once `ngDevMode` works with closure. // if(ngDevMode) debugger; var error = new Error("NullInjectorError: No provider for " + stringify(token) + "!"); error.name = 'NullInjectorError'; throw error; } return notFoundValue; }; return NullInjector; }()); function catchInjectorError(e, token, injectorErrorName, source) { var tokenPath = e[NG_TEMP_TOKEN_PATH]; if (token[SOURCE]) { tokenPath.unshift(token[SOURCE]); } e.message = formatError('\n' + e.message, tokenPath, injectorErrorName, source); e[NG_TOKEN_PATH] = tokenPath; e[NG_TEMP_TOKEN_PATH] = null; throw e; } function formatError(text, obj, injectorErrorName, source) { if (source === void 0) { source = null; } text = text && text.charAt(0) === '\n' && text.charAt(1) == NO_NEW_LINE ? text.substr(2) : text; var context = stringify(obj); if (obj instanceof Array) { context = obj.map(stringify).join(' -> '); } else if (typeof obj === 'object') { var parts = []; for (var key in obj) { if (obj.hasOwnProperty(key)) { var value = obj[key]; parts.push(key + ':' + (typeof value === 'string' ? JSON.stringify(value) : stringify(value))); } } context = "{" + parts.join(', ') + "}"; } return "" + injectorErrorName + (source ? '(' + source + ')' : '') + "[" + context + "]: " + text.replace(NEW_LINE, '\n '); } /** * @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 mapping of the @angular/core API surface used in generated expressions to the actual symbols. * * This should be kept up to date with the public exports of @angular/core. */ var angularCoreDiEnv = { 'ɵɵdefineInjectable': ɵɵdefineInjectable, 'ɵɵdefineInjector': ɵɵdefineInjector, 'ɵɵinject': ɵɵinject, 'ɵɵgetFactoryOf': getFactoryOf, }; function getFactoryOf(type) { var typeAny = type; var def = getInjectableDef(typeAny) || getInjectorDef(typeAny); if (!def || def.factory === undefined) { return null; } return def.factory; } /** * @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 */ /** * @description * * Represents a type that a Component or other object is instances of. * * An example of a `Type` is `MyCustomComponent` class, which in JavaScript is be represented by * the `MyCustomComponent` constructor function. * * @publicApi */ var Type = Function; 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: These regex has to hold even if the code is minified! */ var DELEGATE_CTOR = /^function\s+\S+\(\)\s*{[\s\S]+\.apply\(this,\s*arguments\)/; var INHERITED_CLASS = /^class\s+[A-Za-z\d$_]*\s*extends\s+[^{]+{/; var INHERITED_CLASS_WITH_CTOR = /^class\s+[A-Za-z\d$_]*\s*extends\s+[^{]+{[\s\S]*constructor\s*\(/; var INHERITED_CLASS_WITH_DELEGATE_CTOR = /^class\s+[A-Za-z\d$_]*\s*extends\s+[^{]+{[\s\S]*constructor\s*\(\)\s*{\s+super\(\.\.\.arguments\)/; /** * Determine whether a stringified type is a class which delegates its constructor * to its parent. * * This is not trivial since compiled code can actually contain a constructor function * even if the original source code did not. For instance, when the child class contains * an initialized instance property. */ function isDelegateCtor(typeStr) { return DELEGATE_CTOR.test(typeStr) || INHERITED_CLASS_WITH_DELEGATE_CTOR.test(typeStr) || (INHERITED_CLASS.test(typeStr) && !INHERITED_CLASS_WITH_CTOR.test(typeStr)); } var ReflectionCapabilities = /** @class */ (function () { function ReflectionCapabilities(reflect) { this._reflect = reflect || _global['Reflect']; } ReflectionCapabilities.prototype.isReflectionEnabled = function () { return true; }; 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, __spread([void 0], args)))(); }; }; /** @internal */ ReflectionCapabilities.prototype._zipTypesAndAnnotations = function (paramTypes, paramAnnotations) { var result; if (typeof paramTypes === 'undefined') { result = new Array(paramAnnotations.length); } else { result = new Array(paramTypes.length); } for (var 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] && paramTypes[i] != Object) { result[i] = [paramTypes[i]]; } else { result[i] = []; } if (paramAnnotations && paramAnnotations[i] != null) { result[i] = result[i].concat(paramAnnotations[i]); } } return result; }; ReflectionCapabilities.prototype._ownParameters = function (type, parentCtor) { var typeStr = type.toString(); // 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 (isDelegateCtor(typeStr)) { 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 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 ctorParameters = typeof tsickleCtorParams === 'function' ? tsickleCtorParams() : tsickleCtorParams; var paramTypes_1 = ctorParameters.map(function (ctorParam) { return ctorParam && ctorParam.type; }); var paramAnnotations_1 = ctorParameters.map(function (ctorParam) { return ctorParam && convertTsickleDecoratorIntoMetadata(ctorParam.decorators); }); return this._zipTypesAndAnnotations(paramTypes_1, paramAnnotations_1); } // API for metadata created by invoking the decorators. var paramAnnotations = type.hasOwnProperty(PARAMETERS) && type[PARAMETERS]; var paramTypes = this._reflect && this._reflect.getOwnMetadata && this._reflect.getOwnMetadata('design:paramtypes', type); if (paramTypes || paramAnnotations) { return this._zipTypesAndAnnotations(paramTypes, paramAnnotations); } // If a class has no decorators, at least create metadata // based on function.length. // Note: We know that this is a real constructor as we checked // the content of the constructor above. return new Array(type.length).fill(undefined); }; ReflectionCapabilities.prototype.parameters = function (type) { // Note: only report metadata if we have at least one class decorator // to stay in sync with the static reflector. if (!isType(type)) { return []; } var parentCtor = getParentCtor(type); var parameters = this._ownParameters(type, parentCtor); if (!parameters && parentCtor !== Object) { parameters = this.parameters(parentCtor); } return parameters || []; }; ReflectionCapabilities.prototype._ownAnnotations = function (typeOrFunc, parentCtor) { // Prefer the direct API. if (typeOrFunc.annotations && typeOrFunc.annotations !== parentCtor.annotations) { var annotations = typeOrFunc.annotations; if (typeof annotations === 'function' && annotations.annotations) { annotations = annotations.annotations; } return annotations; } // API of tsickle for lowering decorators to properties on the class. if (typeOrFunc.decorators && typeOrFunc.decorators !== parentCtor.decorators) { return convertTsickleDecoratorIntoMetadata(typeOrFunc.decorators); } // API for metadata created by invoking the decorators. if (typeOrFunc.hasOwnProperty(ANNOTATIONS)) { return typeOrFunc[ANNOTATIONS]; } return null; }; ReflectionCapabilities.prototype.annotations = function (typeOrFunc) { if (!isType(typeOrFunc)) { return []; } var parentCtor = getParentCtor(typeOrFunc); var ownAnnotations = this._ownAnnotations(typeOrFunc, parentCtor) || []; var parentAnnotations = parentCtor !== Object ? this.annotations(parentCtor) : []; return parentAnnotations.concat(ownAnnotations); }; ReflectionCapabilities.prototype._ownPropMetadata = function (typeOrFunc, parentCtor) { // Prefer the direct API. if (typeOrFunc.propMetadata && typeOrFunc.propMetadata !== parentCtor.propMetadata) { var propMetadata = typeOrFunc.propMetadata; if (typeof propMetadata === 'function' && propMetadata.propMetadata) { propMetadata = propMetadata.propMetadata; } return propMetadata; } // API of tsickle for lowering decorators to properties on the class. if (typeOrFunc.propDecorators && typeOrFunc.propDecorators !== parentCtor.propDecorators) { var propDecorators_1 = typeOrFunc.propDecorators; var propMetadata_1 = {}; Object.keys(propDecorators_1).forEach(function (prop) { propMetadata_1[prop] = convertTsickleDecoratorIntoMetadata(propDecorators_1[prop]); }); return propMetadata_1; } // API for metadata created by invoking the decorators. if (typeOrFunc.hasOwnProperty(PROP_METADATA)) { return typeOrFunc[PROP_METADATA]; } return null; }; ReflectionCapabilities.prototype.propMetadata = function (typeOrFunc) { if (!isType(typeOrFunc)) { return {}; } var parentCtor = getParentCtor(typeOrFunc); var propMetadata = {}; if (parentCtor !== Object) { var parentPropMetadata_1 = this.propMetadata(parentCtor); Object.keys(parentPropMetadata_1).forEach(function (propName) { propMetadata[propName] = parentPropMetadata_1[propName]; }); } var ownPropMetadata = this._ownPropMetadata(typeOrFunc, parentCtor); if (ownPropMetadata) { Object.keys(ownPropMetadata).forEach(function (propName) { var decorators = []; if (propMetadata.hasOwnProperty(propName)) { decorators.push.apply(decorators, __spread(propMetadata[propName])); } decorators.push.apply(decorators, __spread(ownPropMetadata[propName])); propMetadata[propName] = decorators; }); } return propMetadata; }; ReflectionCapabilities.prototype.ownPropMetadata = function (typeOrFunc) { if (!isType(typeOrFunc)) { return {}; } return this._ownPropMetadata(typeOrFunc, getParentCtor(typeOrFunc)) || {}; }; ReflectionCapabilities.prototype.hasLifecycleHook = function (type, lcProperty) { return type instanceof Type && lcProperty in type.prototype; }; ReflectionCapabilities.prototype.guards = function (type) { return {}; }; ReflectionCapabilities.prototype.getter = function (name) { return new Function('o', 'return o.' + name + ';'); }; ReflectionCapabilities.prototype.setter = function (name) { return new Function('o', 'v', 'return o.' + name + ' = v;'); }; ReflectionCapabilities.prototype.method = function (name) { var functionBody = "if (!o." + name + ") throw new Error('\"" + name + "\" is undefined');\n return o." + name + ".apply(o, args);"; return new Function('o', 'args', functionBody); }; // There is not a concept of import uri in Js, but this is useful in developing Dart applications. ReflectionCapabilities.prototype.importUri = function (type) { // StaticSymbol if (typeof type === 'object' && type['filePath']) { return type['filePath']; } // Runtime type return "./" + stringify(type); }; ReflectionCapabilities.prototype.resourceUri = function (type) { return "./" + stringify(type); }; ReflectionCapabilities.prototype.resolveIdentifier = function (name, moduleUrl, members, runtime) { return runtime; }; ReflectionCapabilities.prototype.resolveEnum = function (enumIdentifier, name) { return enumIdentifier[name]; }; return ReflectionCapabilities; }()); function convertTsickleDecoratorIntoMetadata(decoratorInvocations) { if (!decoratorInvocations) { return []; } return decoratorInvocations.map(function (decoratorInvocation) { var decoratorType = decoratorInvocation.type; var annotationCls = decoratorType.annotationCls; var annotationArgs = decoratorInvocation.args ? decoratorInvocation.args : []; return new (annotationCls.bind.apply(annotationCls, __spread([void 0], annotationArgs)))(); }); } function getParentCtor(ctor) { var parentProto = ctor.prototype ? Object.getPrototypeOf(ctor.prototype) : null; var parentCtor = parentProto ? parentProto.constructor : null; // Note: We always use `Object` as the null value // to simplify checking later on. return parentCtor || Object; } /** * @license * Copyright Google Inc. All Rights Reserved. * * Use o