UNPKG

@angular/core

Version:

Angular - the core framework

1,487 lines (1,463 loc) 1.59 MB
/** * @license Angular v8.2.9 * (c) 2010-2019 Google LLC. https://angular.io/ * License: MIT */ import { Subject, Subscription, Observable, merge as merge$1 } from 'rxjs'; import { share } from 'rxjs/operators'; /** * @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 */ const ANNOTATIONS = '__annotations__'; const PARAMETERS = '__parameters__'; const PROP_METADATA = '__prop__metadata__'; /** * @suppress {globalThis} */ function makeDecorator(name, props, parentClass, additionalProcessing, typeFn) { const metaCtor = makeMetadataCtor(props); function DecoratorFactory(...args) { if (this instanceof DecoratorFactory) { metaCtor.call(this, ...args); return this; } const annotationInstance = new DecoratorFactory(...args); return function TypeDecorator(cls) { if (typeFn) typeFn(cls, ...args); // Use of Object.defineProperty is important since it creates non-enumerable property which // prevents the property is copied during subclassing. const 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(...args) { if (props) { const values = props(...args); for (const propName in values) { this[propName] = values[propName]; } } }; } function makeParamDecorator(name, props, parentClass) { const metaCtor = makeMetadataCtor(props); function ParamDecoratorFactory(...args) { if (this instanceof ParamDecoratorFactory) { metaCtor.apply(this, args); return this; } const annotationInstance = new ParamDecoratorFactory(...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. const 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) { const metaCtor = makeMetadataCtor(props); function PropDecoratorFactory(...args) { if (this instanceof PropDecoratorFactory) { metaCtor.apply(this, args); return this; } const decoratorInstance = new PropDecoratorFactory(...args); function PropDecorator(target, name) { const constructor = target.constructor; // Use of Object.defineProperty is important since it creates non-enumerable property which // prevents the property is copied during subclassing. const 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(target, name, ...args); } return PropDecorator; } if (parentClass) { PropDecoratorFactory.prototype = Object.create(parentClass.prototype); } PropDecoratorFactory.prototype.ngMetadataName = name; PropDecoratorFactory.annotationCls = PropDecoratorFactory; return PropDecoratorFactory; } /** * @fileoverview added by tsickle * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * Type of the Inject decorator / constructor function. * * \@publicApi * @record */ function InjectDecorator() { } // WARNING: interface has both a type and a value, skipping emit const ɵ0 = /** * @param {?} token * @return {?} */ (token) => ({ token }); /** * Inject decorator and metadata. * * \@Annotation * \@publicApi * @type {?} */ const Inject = makeParamDecorator('Inject', (ɵ0)); /** * Type of the Optional decorator / constructor function. * * \@publicApi * @record */ function OptionalDecorator() { } // WARNING: interface has both a type and a value, skipping emit /** * Optional decorator and metadata. * * \@Annotation * \@publicApi * @type {?} */ const Optional = makeParamDecorator('Optional'); /** * Type of the Self decorator / constructor function. * * \@publicApi * @record */ function SelfDecorator() { } // WARNING: interface has both a type and a value, skipping emit /** * Self decorator and metadata. * * \@Annotation * \@publicApi * @type {?} */ const Self = makeParamDecorator('Self'); /** * Type of the SkipSelf decorator / constructor function. * * \@publicApi * @record */ function SkipSelfDecorator() { } // WARNING: interface has both a type and a value, skipping emit /** * SkipSelf decorator and metadata. * * \@Annotation * \@publicApi * @type {?} */ const SkipSelf = makeParamDecorator('SkipSelf'); /** * Type of the Host decorator / constructor function. * * \@publicApi * @record */ function HostDecorator() { } // WARNING: interface has both a type and a value, skipping emit /** * Host decorator and metadata. * * \@Annotation * \@publicApi * @type {?} */ const Host = makeParamDecorator('Host'); /** * Type of the Attribute decorator / constructor function. * * \@publicApi * @record */ function AttributeDecorator() { } // WARNING: interface has both a type and a value, skipping emit const ɵ1 = /** * @param {?=} attributeName * @return {?} */ (attributeName) => ({ attributeName }); /** * Attribute decorator and metadata. * * \@Annotation * \@publicApi * @type {?} */ const 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 */ /** * Injection flags for DI. * * @publicApi */ var InjectFlags; (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"; })(InjectFlags || (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 (let 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 (const 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 */ const 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) { const 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; } const NG_INJECTABLE_DEF = getClosureSafeProperty({ ngInjectableDef: getClosureSafeProperty }); const 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}`; } const res = token.toString(); if (res == null) { return '' + res; } const newLineIndex = res.indexOf('\n'); return newLineIndex === -1 ? res : res.substring(0, newLineIndex); } /** * @fileoverview added by tsickle * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * An interface that a function passed into {\@link forwardRef} has to implement. * * \@usageNotes * ### Example * * {\@example core/di/ts/forward_ref/forward_ref_spec.ts region='forward_ref_fn'} * \@publicApi * @record */ function ForwardRefFn() { } /** @type {?} */ const __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 * @param {?} forwardRefFn * @return {?} */ function forwardRef(forwardRefFn) { ((/** @type {?} */ (forwardRefFn))).__forward_ref__ = forwardRef; ((/** @type {?} */ (forwardRefFn))).toString = (/** * @return {?} */ function () { return stringify(this()); }); return ((/** @type {?} */ ((/** @type {?} */ (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 * @template T * @param {?} type * @return {?} */ function resolveForwardRef(type) { /** @type {?} */ const 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 */ const __globalThis = typeof globalThis !== 'undefined' && globalThis; const __window = typeof window !== 'undefined' && window; const __self = typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope && self; const __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. const _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["ChangeDetectorRef"] = 2] = "ChangeDetectorRef"; })(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() { const 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; } /** * @fileoverview added by tsickle * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * 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 * @template T */ class InjectionToken { /** * @param {?} _desc * @param {?=} options */ constructor(_desc, options) { this._desc = _desc; /** * \@internal */ this.ngMetadataName = 'InjectionToken'; /** @nocollapse */ 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`. ((/** @type {?} */ (this))).__NG_ELEMENT_ID__ = options; } else if (options !== undefined) { /** @nocollapse */ this.ngInjectableDef = ɵɵdefineInjectable({ token: this, providedIn: options.providedIn || 'root', factory: options.factory, }); } } /** * @return {?} */ toString() { return `InjectionToken ${this._desc}`; } } if (false) { /** * \@internal * @type {?} */ InjectionToken.prototype.ngMetadataName; /** @type {?} */ InjectionToken.prototype.ngInjectableDef; /** * @type {?} * @protected */ InjectionToken.prototype._desc; } /** * @record * @template T */ function InjectableDefToken() { } if (false) { /** @type {?} */ InjectableDefToken.prototype.ngInjectableDef; } /** * @fileoverview added by tsickle * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * 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 * @type {?} */ const INJECTOR = new InjectionToken('INJECTOR', (/** @type {?} */ (-1))); /** @type {?} */ const _THROW_IF_NOT_FOUND = new Object(); /** @type {?} */ const THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND; /** @type {?} */ const NG_TEMP_TOKEN_PATH = 'ngTempTokenPath'; /** @type {?} */ const NG_TOKEN_PATH = 'ngTokenPath'; /** @type {?} */ const NEW_LINE = /\n/gm; /** @type {?} */ const NO_NEW_LINE = 'ɵ'; /** @type {?} */ const SOURCE = '__source'; const ɵ0$1 = getClosureSafeProperty; /** @type {?} */ const 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. * @type {?} */ let _currentInjector = undefined; /** * @param {?} injector * @return {?} */ function setCurrentInjector(injector) { /** @type {?} */ const 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. * @type {?} */ let _injectImplementation; /** * Sets the current inject implementation. * @param {?} impl * @return {?} */ function setInjectImplementation(impl) { /** @type {?} */ const previous = _injectImplementation; _injectImplementation = impl; return previous; } /** * @template T * @param {?} token * @param {?=} flags * @return {?} */ function injectInjectorOnly(token, flags = 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 & InjectFlags.Optional ? null : undefined, flags); } } /** * @template T * @param {?} token * @param {?=} flags * @return {?} */ function ɵɵinject(token, flags = 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`. * \@return True if injection is successful, null otherwise. * * \@usageNotes * * ### Example * * {\@example core/di/ts/injector_spec.ts region='ShakableInjectionToken'} * * \@publicApi * @type {?} */ const 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`. * @template T * @param {?} token * @param {?} notFoundValue * @param {?} flags * @return {?} */ function injectRootLimpMode(token, notFoundValue, flags) { /** @type {?} */ const injectableDef = getInjectableDef(token); if (injectableDef && injectableDef.providedIn == 'root') { return injectableDef.value === undefined ? injectableDef.value = injectableDef.factory() : injectableDef.value; } if (flags & InjectFlags.Optional) return null; if (notFoundValue !== undefined) return notFoundValue; throw new Error(`Injector: NOT_FOUND [${stringify(token)}]`); } /** * @param {?} types * @return {?} */ function injectArgs(types) { /** @type {?} */ const args = []; for (let i = 0; i < types.length; i++) { /** @type {?} */ const arg = resolveForwardRef(types[i]); if (Array.isArray(arg)) { if (arg.length === 0) { throw new Error('Arguments array must have arguments.'); } /** @type {?} */ let type = undefined; /** @type {?} */ let flags = InjectFlags.Default; for (let j = 0; j < arg.length; j++) { /** @type {?} */ const meta = arg[j]; if (meta instanceof Optional || meta.ngMetadataName === 'Optional' || meta === Optional) { flags |= InjectFlags.Optional; } else if (meta instanceof SkipSelf || meta.ngMetadataName === 'SkipSelf' || meta === SkipSelf) { flags |= InjectFlags.SkipSelf; } else if (meta instanceof Self || meta.ngMetadataName === 'Self' || meta === Self) { flags |= InjectFlags.Self; } else if (meta instanceof Inject || meta === Inject) { type = meta.token; } else { type = meta; } } args.push(ɵɵinject((/** @type {?} */ (type)), flags)); } else { args.push(ɵɵinject(arg)); } } return args; } class NullInjector { /** * @param {?} token * @param {?=} notFoundValue * @return {?} */ get(token, 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; /** @type {?} */ const error = new Error(`NullInjectorError: No provider for ${stringify(token)}!`); error.name = 'NullInjectorError'; throw error; } return notFoundValue; } } /** * @param {?} e * @param {?} token * @param {?} injectorErrorName * @param {?} source * @return {?} */ function catchInjectorError(e, token, injectorErrorName, source) { /** @type {?} */ const 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; } /** * @param {?} text * @param {?} obj * @param {?} injectorErrorName * @param {?=} source * @return {?} */ function formatError(text, obj, injectorErrorName, source = null) { text = text && text.charAt(0) === '\n' && text.charAt(1) == NO_NEW_LINE ? text.substr(2) : text; /** @type {?} */ let context = stringify(obj); if (obj instanceof Array) { context = obj.map(stringify).join(' -> '); } else if (typeof obj === 'object') { /** @type {?} */ let parts = (/** @type {?} */ ([])); for (let key in obj) { if (obj.hasOwnProperty(key)) { /** @type {?} */ let 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 ')}`; } /** * @fileoverview added by tsickle * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * 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. * @type {?} */ const angularCoreDiEnv = { 'ɵɵdefineInjectable': ɵɵdefineInjectable, 'ɵɵdefineInjector': ɵɵdefineInjector, 'ɵɵinject': ɵɵinject, 'ɵɵgetFactoryOf': getFactoryOf, }; /** * @template T * @param {?} type * @return {?} */ function getFactoryOf(type) { /** @type {?} */ const typeAny = (/** @type {?} */ (type)); /** @type {?} */ const def = getInjectableDef(typeAny) || getInjectorDef(typeAny); if (!def || def.factory === undefined) { return null; } return def.factory; } /** * @fileoverview added by tsickle * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @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 */ /** * Represents an instance of an NgModule created via a {\@link NgModuleFactory}. * * `NgModuleRef` provides access to the NgModule Instance as well other objects related to this * NgModule Instance. * * \@publicApi * @abstract * @template T */ class NgModuleRef { } if (false) { /** * The injector that contains all of the providers of the NgModule. * @abstract * @return {?} */ NgModuleRef.prototype.injector = function () { }; /** * The ComponentFactoryResolver to get hold of the ComponentFactories * declared in the `entryComponents` property of the module. * @abstract * @return {?} */ NgModuleRef.prototype.componentFactoryResolver = function () { }; /** * The NgModule instance. * @abstract * @return {?} */ NgModuleRef.prototype.instance = function () { }; /** * Destroys the module instance and all of the data structures associated with it. * @abstract * @return {?} */ NgModuleRef.prototype.destroy = function () { }; /** * Allows to register a callback that will be called when the module is destroyed. * @abstract * @param {?} callback * @return {?} */ NgModuleRef.prototype.onDestroy = function (callback) { }; } /** * @record * @template T */ function InternalNgModuleRef() { } if (false) { /** @type {?} */ InternalNgModuleRef.prototype._bootstrapComponents; } /** * \@publicApi * @abstract * @template T */ class NgModuleFactory { } if (false) { /** * @abstract * @return {?} */ NgModuleFactory.prototype.moduleType = function () { }; /** * @abstract * @param {?} parentInjector * @return {?} */ NgModuleFactory.prototype.create = function (parentInjector) { }; } /** * @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 */ /** * Equivalent to ES6 spread, add each item to an array. * * @param items The items to add * @param arr The array to which you want to add the items */ function addAllToArray(items, arr) { for (let i = 0; i < items.length; i++) { arr.push(items[i]); } } /** * Flattens an array. */ function flatten(list, dst) { if (dst === undefined) dst = list; for (let i = 0; i < list.length; i++) { let item = list[i]; if (Array.isArray(item)) { // we need to inline it. if (dst === list) { // Our assumption that the list was already flat was wrong and // we need to clone flat since we need to write to it. dst = list.slice(0, i); } flatten(item, dst); } else if (dst !== list) { dst.push(item); } } return dst; } function deepForEach(input, fn) { input.forEach(value => Array.isArray(value) ? deepForEach(value, fn) : fn(value)); } function addToArray(arr, index, value) { // perf: array.push is faster than array.splice! if (index >= arr.length) { arr.push(value); } else { arr.splice(index, 0, value); } } function removeFromArray(arr, index) { // perf: array.pop is faster than array.splice! if (index >= arr.length - 1) { return arr.pop(); } else { return arr.splice(index, 1)[0]; } } /** * @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 assertNumber(actual, msg) { if (typeof actual != 'number') { throwError(msg); } } function assertEqual(actual, expected, msg) { if (actual != expected) { throwError(msg); } } function assertNotEqual(actual, expected, msg) { if (actual == expected) { throwError(msg); } } function assertSame(actual, expected, msg) { if (actual !== expected) { throwError(msg); } } function assertNotSame(actual, expected, msg) { if (actual === expected) { throwError(msg); } } function assertLessThan(actual, expected, msg) { if (actual >= expected) { throwError(msg); } } function assertGreaterThan(actual, expected, msg) { if (actual <= expected) { throwError(msg); } } function assertNotDefined(actual, msg) { if (actual != null) { throwError(msg); } } function assertDefined(actual, msg) { if (actual == null) { throwError(msg); } } function throwError(msg) { // tslint:disable-next-line debugger; // Left intentionally for better debugger experience. throw new Error(`ASSERTION ERROR: ${msg}`); } function assertDomNode(node) { // If we're in a worker, `Node` will not be defined. assertEqual((typeof Node !== 'undefined' && node instanceof Node) || (typeof node === 'object' && node != null && node.constructor.name === 'WebWorkerRenderNode'), true, `The provided value must be an instance of a DOM Node but got ${stringify(node)}`); } function assertDataInRange(arr, index) { const maxLen = arr ? arr.length : 0; assertLessThan(index, maxLen, `Index expected to be less than ${maxLen} but got ${index}`); } /** * @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 ngDevModeResetPerfCounters() { const locationString = typeof location !== 'undefined' ? location.toString() : ''; const newCounters = { namedConstructors: locationString.indexOf('ngDevMode=namedConstructors') != -1, firstTemplatePass: 0, tNode: 0, tView: 0, rendererCreateTextNode: 0, rendererSetText: 0, rendererCreateElement: 0, rendererAddEventListener: 0, rendererSetAttribute: 0, rendererRemoveAttribute: 0, rendererSetProperty: 0, rendererSetClassName: 0, rendererAddClass: 0, rendererRemoveClass: 0, rendererSetStyle: 0, rendererRemoveStyle: 0, rendererDestroy: 0, rendererDestroyNode: 0, rendererMoveNode: 0, rendererRemoveNode: 0, rendererAppendChild: 0, rendererInsertBefore: 0, rendererCreateComment: 0, styleMap: 0, styleMapCacheMiss: 0, classMap: 0, classMapCacheMiss: 0, styleProp: 0, stylePropCacheMiss: 0, classProp: 0, classPropCacheMiss: 0, flushStyling: 0, classesApplied: 0, stylesApplied: 0, stylingWritePersistedState: 0, stylingReadPersistedState: 0, }; // Make sure to refer to ngDevMode as ['ngDevMode'] for closure. const allowNgDevModeTrue = locationString.indexOf('ngDevMode=false') === -1; _global['ngDevMode'] = allowNgDevModeTrue && newCounters; return newCounters; } /** * This checks to see if the `ngDevMode` has been set. If yes, * then we honor it, otherwise we default to dev mode with additional checks. * * The idea is that unless we are doing production build where we explicitly * set `ngDevMode == false` we should be helping the developer by providing * as much early warning and errors as possible. * * NOTE: changes to the `ngDevMode` name must be synced with `compiler-cli/src/tooling.ts`. */ if (typeof ngDevMode === 'undefined' || ngDevMode) { ngDevModeResetPerfCounters(); } /** * @fileoverview added by tsickle * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @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 */ /** @enum {number} */ const ChangeDetectionStrategy = { /** * Use the `CheckOnce` strategy, meaning that automatic change detection is deactivated * until reactivated by setting the strategy to `Default` (`CheckAlways`). * Change detection can still be explicitly invoked. * This strategy applies to all child directives and cannot be overridden. */ OnPush: 0, /** * Use the default `CheckAlways` strategy, in which change detection is automatic until * explicitly deactivated. */ Default: 1, }; ChangeDetectionStrategy[ChangeDetectionStrategy.OnPush] = 'OnPush'; ChangeDetectionStrategy[ChangeDetectionStrategy.Default] = 'Default'; /** @enum {number} */ const ChangeDetectorStatus = { /** * A state in which, after calling `detectChanges()`, the change detector * state becomes `Checked`, and must be explicitly invoked or reactivated. */ CheckOnce: 0, /** * A state in which change detection is skipped until the change detector mode * becomes `CheckOnce`. */ Checked: 1, /** * A state in which change detection continues automatically until explicitly * deactivated. */ CheckAlways: 2, /** * A state in which a change detector sub tree is not a part of the main tree and * should be skipped. */ Detached: 3, /** * Indicates that the change detector encountered an error checking a binding * or calling a directive lifecycle method and is now in an inconsistent state. Change * detectors in this state do not detect changes. */ Errored: 4, /** * Indicates that the change detector has been destroyed. */ 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'; /** * Reports whether a given strategy is currently the default for change detection. * @see `ChangeDetectorStatus` / `ChangeDetectorRef` * @param {?} changeDetectionStrategy The strategy to check. * @return {?} True if the given strategy is the current default, false otherwise. */ function isDefaultChangeDetectionStrategy(changeDetectionStrategy) { return changeDetectionStrategy == null || changeDetectionStrategy === ChangeDetectionStrategy.Default; } /** * @fileoverview added by tsickle * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @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 */ /** @enum {number} */ const ViewEncapsulation = { /** * Emulate `Native` scoping of styles by adding an attribute containing surrogate id to the Host * Element and pre-processing the style rules provided via {@link Component#styles styles} or * {@link Component#styleUrls styleUrls}, and adding the new Host Element attribute to all * selectors. * * This is the default option. */ Emulated: 0, /** * @deprecated v6.1.0 - use {ViewEncapsulation.ShadowDom} instead. * Use the native encapsulation mechanism of the renderer. * * For the DOM this means using the deprecated [Shadow DOM * v0](https://w3c.github.io/webcomponents/spec/shadow/) and * creating a ShadowRoot for Component's Host Element. */ Native: 1, /** * Don't provide any template or style encapsulation. */ None: 2, /** * Use Shadow DOM to encapsulate styles. * * For the DOM this means using modern [Shadow * DOM](https://w3c.github.io/webcomponents/spec/shadow/) and * creating a ShadowRoot for Component's Host Element. */ ShadowDom: 3, }; ViewEncapsulation[ViewEncapsulation.Emulated] = 'Emulated'; ViewEncapsulation[ViewEncapsulation.Native] = 'Native'; ViewEncapsulation[ViewEncapsulation.None] = 'None'; ViewEncapsulation[ViewEncapsulation.ShadowDom] = 'ShadowDom'; /** * @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 */ /** * Convince closure compiler that the wrapped function has no side-effects. * * Closure compiler always assumes that `toString` has no side-effects. We use this quirk to * allow us to execute a function but have closure compiler mark the call as no-side-effects. * It is important that the return value for the `noSideEffects` function be assigned * to something which is retained otherwise the call to `noSideEffects` will be removed by closure * compiler. */ function noSideEffects(fn) { return '' + { toString: fn }; } /** * @fileoverview added by tsickle * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * This file contains reuseable "empty" symbols that can be used as default return values * in different parts of the rendering code. Because the same symbols are returned, this * allows for identity checks against these values to be consistently used by the framework * code. * @type {?} */ const EMPTY_OBJ = {}; /** @type {?} */ const EMPTY_ARRAY = []; // freezing the values prevents any code from accidentally inserting new values in if (typeof ngDevMode !== 'undefined' && ngDevMode) { // These property accesses can be ignored because ngDevMode will be set to false // when optimizing code and the whole if statement will be dropped. // tslint:disable-next-line:no-toplevel-property-access Object.freeze(EMPTY_OBJ); // tslint:disable-next-line:no-toplevel-property-access Object.freeze(EMPTY_ARRAY); } /** * @fileoverview added by tsickle * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** @type {?} */ const NG_COMPONENT_DEF = getClosureSafeProperty({ ngComponentDef: getClosureSafeProperty }); /** @type {?} */ const NG_DIRECTIVE_DEF = getClosureSafeProperty({ ngDirectiveDef: getClosureSafeProperty }); /** @type {?} */ const NG_PIPE_DEF = getClosureSafeProperty({ ngPipeDef: getClosureSafeProperty }); /** @type {?} */ const NG_MODULE_DEF = getClosureSafeProperty({ ngModuleDef: getClosureSafeProperty }); /** @type {?} */ const NG_LOCALE_ID_DEF = getClosureSafeProperty({ ngLocaleIdDef: getClosureSafeProperty }); /** @type {?} */ const NG_BASE_DEF = getClosureSafeProperty({ ngBaseDef: getClosureSafeProperty }); // TODO(misko): This is wrong. The NG_ELEMENT_ID should never be minified. /** * If a directive is diPublic, bloomAdd sets a property on the type with this constant as * the key and the directive's unique ID as the value. This allows us to map directives to their * bloom filter bit for DI. * @type {?} */ const NG_ELEMENT_ID = getClosureSafeProperty({ __NG_ELEMENT_ID__: getClosureSafeProperty }); /** * @fileoverview added by tsickle * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** @type {?} */ let _renderCompCount = 0; /** * Create a component definition object. * * * # Example * ``` * class MyDirective { * // Generated by Angular Template Compiler * // [Symbol] syntax will not be supported by TypeScript until v2.7 * static ngComponentDef = defineComponent({ * ... * }); * } * ``` * \@codeGenApi * @template T * @param {?} componentDefinition * @return {?} */ function ɵɵdefineComponent(componentDefinition) { /** @type {?} */ const type = componentDefinition.type; /** @type {?} */ const typePrototype = type.prototype; /** @type {?} */ const declaredInputs = (/** @type {?} */ ({})); /** @type {?} */ const def = { type: type, providersResolver: null, consts: componentDefinition.consts, vars: componentDefinition.vars, factory: componentDefinition.factory, template: componentDefinition.template || (/** @type {?} */ (null)), ngContentSelectors: componentDefinition.ngContentSelectors, hostBindings: componentDefinition.hostBindings || null, contentQueries: componentDefinition.contentQueries || null, declaredInputs: declaredInputs, inputs: (/** @type {?} */ (null)), // assigned in noSideEffects outputs: (/** @type {?} */ (null)), // assigned in noSideEffects exportAs: componentDefinition.exportAs || null, onChanges: null, onInit: typePrototype.ngOnInit || null, doCheck: typePrototype.ngDoCheck || null, afterContentInit: typePrototype.ngAfterContentInit || null, afterContentChecked: typePrototype.ngAfterContentChecked || null, afterViewInit: typePrototype.ngAfterViewInit || null, afterViewChecked: typePrototype.ngAfterViewChecked || null, onDestroy: typePrototype.ngOnDestroy || null, onPush: componentDefinition.changeDetection === ChangeDetectionStrategy.OnPush, directiveDefs: (/** @type {?} */ (null)), // assigned in noSideEffects pipeDefs: (/** @type {?} */ (null)), // assigned in noSideEffects selectors: componentDefinition.selectors, viewQuery: componentDefinition.viewQuery || null, features: (/** @type {?} */ (componentDefinition.features)) || null, data: componentDefinition.data || {}, // TODO(misko): convert ViewEncapsulation into const enum