build: extract interface and util sub compilation from core (#28028)
PR Close #28028
This commit is contained in:
parent
b05baa59e0
commit
885f1af509
|
@ -13,6 +13,9 @@ ng_module(
|
|||
module_name = "@angular/core",
|
||||
deps = [
|
||||
"//packages:types",
|
||||
"//packages/core/src/di/interface",
|
||||
"//packages/core/src/interface",
|
||||
"//packages/core/src/util",
|
||||
"@ngdeps//zone.js",
|
||||
"@rxjs",
|
||||
"@rxjs//operators",
|
||||
|
|
|
@ -14,7 +14,7 @@ import {APP_BOOTSTRAP_LISTENER, PLATFORM_INITIALIZER} from './application_tokens
|
|||
import {Console} from './console';
|
||||
import {Injectable, InjectionToken, Injector, StaticProvider} from './di';
|
||||
import {ErrorHandler} from './error_handler';
|
||||
import {isDevMode} from './is_dev_mode';
|
||||
import {Type} from './interface/type';
|
||||
import {CompilerFactory, CompilerOptions} from './linker/compiler';
|
||||
import {ComponentFactory, ComponentRef} from './linker/component_factory';
|
||||
import {ComponentFactoryBoundToModule, ComponentFactoryResolver} from './linker/component_factory_resolver';
|
||||
|
@ -24,9 +24,10 @@ import {WtfScopeFn, wtfCreateScope, wtfLeave} from './profile/profile';
|
|||
import {assertNgModuleType} from './render3/assert';
|
||||
import {NgModuleFactory as R3NgModuleFactory} from './render3/ng_module_ref';
|
||||
import {Testability, TestabilityRegistry} from './testability/testability';
|
||||
import {Type} from './type';
|
||||
import {scheduleMicroTask, stringify} from './util';
|
||||
import {isDevMode} from './util/is_dev_mode';
|
||||
import {isPromise} from './util/lang';
|
||||
import {scheduleMicroTask} from './util/microtask';
|
||||
import {stringify} from './util/stringify';
|
||||
import {NgZone, NoopNgZone} from './zone/ng_zone';
|
||||
|
||||
let _platform: PlatformRef;
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {getSymbolIterator, looseIdentical} from '../util';
|
||||
import {looseIdentical} from '../util/comparison';
|
||||
import {getSymbolIterator} from '../util/symbol';
|
||||
|
||||
export function devModeEqual(a: any, b: any): boolean {
|
||||
const isListLikeIterableA = isListLikeIterable(a);
|
||||
|
|
|
@ -6,8 +6,10 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {looseIdentical, stringify} from '../../util';
|
||||
import {looseIdentical} from '../../util/comparison';
|
||||
import {stringify} from '../../util/stringify';
|
||||
import {isListLikeIterable, iterateListLike} from '../change_detection_util';
|
||||
|
||||
import {IterableChangeRecord, IterableChanges, IterableDiffer, IterableDifferFactory, NgIterable, TrackByFunction} from './iterable_differs';
|
||||
|
||||
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {looseIdentical, stringify} from '../../util';
|
||||
import {looseIdentical} from '../../util/comparison';
|
||||
import {stringify} from '../../util/stringify';
|
||||
import {isJsObject} from '../change_detection_util';
|
||||
import {KeyValueChangeRecord, KeyValueChanges, KeyValueDiffer, KeyValueDifferFactory} from './keyvalue_differs';
|
||||
|
||||
|
|
|
@ -6,12 +6,13 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {defineInjectable} from '../../di/defs';
|
||||
import {defineInjectable} from '../../di/interface/defs';
|
||||
import {StaticProvider} from '../../di/interface/provider';
|
||||
import {Optional, SkipSelf} from '../../di/metadata';
|
||||
import {StaticProvider} from '../../di/provider';
|
||||
import {DefaultIterableDifferFactory} from '../differs/default_iterable_differ';
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* A type describing supported iterable types.
|
||||
*
|
||||
|
|
|
@ -16,7 +16,7 @@ export * from './version';
|
|||
export {TypeDecorator} from './util/decorators';
|
||||
export * from './di';
|
||||
export {createPlatform, assertPlatform, destroyPlatform, getPlatform, PlatformRef, ApplicationRef, createPlatformFactory, NgProbeToken} from './application_ref';
|
||||
export {enableProdMode, isDevMode} from './is_dev_mode';
|
||||
export {enableProdMode, isDevMode} from './util/is_dev_mode';
|
||||
export {APP_ID, PACKAGE_ROOT_URL, PLATFORM_INITIALIZER, PLATFORM_ID, APP_BOOTSTRAP_LISTENER} from './application_tokens';
|
||||
export {APP_INITIALIZER, ApplicationInitStatus} from './application_init';
|
||||
export * from './zone';
|
||||
|
@ -29,7 +29,7 @@ export * from './platform_core_providers';
|
|||
export {TRANSLATIONS, TRANSLATIONS_FORMAT, LOCALE_ID, MissingTranslationStrategy} from './i18n/tokens';
|
||||
export {ApplicationModule} from './application_module';
|
||||
export {wtfCreateScope, wtfLeave, wtfStartTimeRange, wtfEndTimeRange, WtfScopeFn} from './profile/profile';
|
||||
export {Type} from './type';
|
||||
export {Type} from './interface/type';
|
||||
export {EventEmitter} from './event_emitter';
|
||||
export {ErrorHandler} from './error_handler';
|
||||
export * from './core_private_export';
|
||||
|
|
|
@ -13,8 +13,8 @@ export {devModeEqual as ɵdevModeEqual} from './change_detection/change_detectio
|
|||
export {isListLikeIterable as ɵisListLikeIterable} from './change_detection/change_detection_util';
|
||||
export {ChangeDetectorStatus as ɵChangeDetectorStatus, isDefaultChangeDetectionStrategy as ɵisDefaultChangeDetectionStrategy} from './change_detection/constants';
|
||||
export {Console as ɵConsole} from './console';
|
||||
export {InjectableDef as ɵInjectableDef, InjectorDef as ɵInjectorDef, getInjectableDef as ɵgetInjectableDef} from './di/defs';
|
||||
export {inject as ɵinject, setCurrentInjector as ɵsetCurrentInjector} from './di/injector_compatibility';
|
||||
export {InjectableDef as ɵInjectableDef, InjectorDef as ɵInjectorDef, getInjectableDef as ɵgetInjectableDef} from './di/interface/defs';
|
||||
export {APP_ROOT as ɵAPP_ROOT} from './di/scope';
|
||||
export {ivyEnabled as ɵivyEnabled} from './ivy_switch';
|
||||
export {ComponentFactory as ɵComponentFactory} from './linker/component_factory';
|
||||
|
@ -26,7 +26,9 @@ export {DirectRenderer as ɵDirectRenderer, RenderDebugInfo as ɵRenderDebugInfo
|
|||
export {_sanitizeHtml as ɵ_sanitizeHtml} from './sanitization/html_sanitizer';
|
||||
export {_sanitizeStyle as ɵ_sanitizeStyle} from './sanitization/style_sanitizer';
|
||||
export {_sanitizeUrl as ɵ_sanitizeUrl} from './sanitization/url_sanitizer';
|
||||
export {global as ɵglobal, looseIdentical as ɵlooseIdentical, stringify as ɵstringify} from './util';
|
||||
export {global as ɵglobal} from './util/global';
|
||||
export {looseIdentical as ɵlooseIdentical,} from './util/comparison';
|
||||
export {stringify as ɵstringify} from './util/stringify';
|
||||
export {makeDecorator as ɵmakeDecorator} from './util/decorators';
|
||||
export {isObservable as ɵisObservable, isPromise as ɵisPromise} from './util/lang';
|
||||
export {clearOverrides as ɵclearOverrides, initServicesIfNeeded as ɵinitServicesIfNeeded, overrideComponentView as ɵoverrideComponentView, overrideProvider as ɵoverrideProvider} from './view/index';
|
||||
|
|
|
@ -171,13 +171,16 @@ export {
|
|||
NG_ELEMENT_ID as ɵNG_ELEMENT_ID,
|
||||
NG_COMPONENT_DEF as ɵNG_COMPONENT_DEF,
|
||||
NG_DIRECTIVE_DEF as ɵNG_DIRECTIVE_DEF,
|
||||
NG_INJECTABLE_DEF as ɵNG_INJECTABLE_DEF,
|
||||
NG_INJECTOR_DEF as ɵNG_INJECTOR_DEF,
|
||||
NG_PIPE_DEF as ɵNG_PIPE_DEF,
|
||||
NG_MODULE_DEF as ɵNG_MODULE_DEF,
|
||||
NG_BASE_DEF as ɵNG_BASE_DEF
|
||||
} from './render3/fields';
|
||||
|
||||
export {
|
||||
NG_INJECTABLE_DEF as ɵNG_INJECTABLE_DEF,
|
||||
NG_INJECTOR_DEF as ɵNG_INJECTOR_DEF,
|
||||
} from './di/interface/defs';
|
||||
|
||||
export {
|
||||
Player as ɵPlayer,
|
||||
PlayerFactory as ɵPlayerFactory,
|
||||
|
|
|
@ -7,13 +7,13 @@
|
|||
*/
|
||||
|
||||
import {Injector} from '../di';
|
||||
import {assertDomNode} from '../render3/assert';
|
||||
import {getComponent, getContext, getInjectionTokens, getInjector, getListeners, getLocalRefs, isBrowserEvents, loadLContext, loadLContextFromNode} from '../render3/discovery_utils';
|
||||
import {TNode} from '../render3/interfaces/node';
|
||||
import {StylingIndex} from '../render3/interfaces/styling';
|
||||
import {TVIEW} from '../render3/interfaces/view';
|
||||
import {getProp, getValue, isClassBasedValue} from '../render3/styling/class_and_style_bindings';
|
||||
import {getStylingContext} from '../render3/styling/util';
|
||||
import {assertDomNode} from '../util/assert';
|
||||
import {DebugContext} from '../view/index';
|
||||
|
||||
export class EventListener {
|
||||
|
|
|
@ -13,13 +13,13 @@
|
|||
*/
|
||||
|
||||
export * from './di/metadata';
|
||||
export {InjectableType, InjectorType, defineInjectable, defineInjector} from './di/defs';
|
||||
export {InjectableType, InjectorType, defineInjectable, defineInjector} from './di/interface/defs';
|
||||
export {forwardRef, resolveForwardRef, ForwardRefFn} from './di/forward_ref';
|
||||
export {Injectable, InjectableDecorator, InjectableProvider} from './di/injectable';
|
||||
export {INJECTOR, Injector} from './di/injector';
|
||||
export {inject, InjectFlags} from './di/injector_compatibility';
|
||||
export {ReflectiveInjector} from './di/reflective_injector';
|
||||
export {StaticProvider, ValueProvider, ConstructorSansProvider, ExistingProvider, FactoryProvider, Provider, TypeProvider, ClassProvider} from './di/provider';
|
||||
export {StaticProvider, ValueProvider, ConstructorSansProvider, ExistingProvider, FactoryProvider, Provider, TypeProvider, ClassProvider} from './di/interface/provider';
|
||||
export {createInjector} from './di/r3_injector';
|
||||
export {ResolvedReflectiveFactory, ResolvedReflectiveProvider} from './di/reflective_provider';
|
||||
export {ReflectiveKey} from './di/reflective_key';
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Type} from '../type';
|
||||
import {stringify} from '../util';
|
||||
import {Type} from '../interface/type';
|
||||
import {getClosureSafeProperty} from '../util/property';
|
||||
import {stringify} from '../util/stringify';
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -6,15 +6,16 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Type} from '../interface/type';
|
||||
import {compileInjectable as render3CompileInjectable} from '../render3/jit/injectable';
|
||||
import {Type} from '../type';
|
||||
import {TypeDecorator, makeDecorator} from '../util/decorators';
|
||||
|
||||
import {InjectableDef, InjectableType, defineInjectable, getInjectableDef} from './defs';
|
||||
import {ClassSansProvider, ConstructorSansProvider, ExistingSansProvider, FactorySansProvider, StaticClassSansProvider, ValueSansProvider} from './provider';
|
||||
import {InjectableDef, InjectableType, defineInjectable, getInjectableDef} from './interface/defs';
|
||||
import {ClassSansProvider, ConstructorSansProvider, ExistingSansProvider, FactorySansProvider, StaticClassSansProvider, ValueSansProvider} from './interface/provider';
|
||||
import {convertInjectableProviderToFactory} from './util';
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Injectable providers used in `@Injectable` decorator.
|
||||
*
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Type} from '../type';
|
||||
import {Type} from '../interface/type';
|
||||
|
||||
import {defineInjectable} from './defs';
|
||||
import {defineInjectable} from './interface/defs';
|
||||
|
||||
/**
|
||||
* Creates a token that can be used in a DI Provider.
|
||||
|
|
|
@ -6,18 +6,18 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Type} from '../interface/type';
|
||||
import {injectInjector} from '../render3/di';
|
||||
import {Type} from '../type';
|
||||
import {stringify} from '../util';
|
||||
import {noop} from '../util/noop';
|
||||
import {getClosureSafeProperty} from '../util/property';
|
||||
import {stringify} from '../util/stringify';
|
||||
|
||||
import {defineInjectable} from './defs';
|
||||
import {resolveForwardRef} from './forward_ref';
|
||||
import {InjectionToken} from './injection_token';
|
||||
import {InjectFlags, inject} from './injector_compatibility';
|
||||
import {defineInjectable} from './interface/defs';
|
||||
import {ConstructorProvider, ExistingProvider, FactoryProvider, StaticClassProvider, StaticProvider, ValueProvider} from './interface/provider';
|
||||
import {Inject, Optional, Self, SkipSelf} from './metadata';
|
||||
import {ConstructorProvider, ExistingProvider, FactoryProvider, StaticClassProvider, StaticProvider, ValueProvider} from './provider';
|
||||
|
||||
export const SOURCE = '__source';
|
||||
const _THROW_IF_NOT_FOUND = new Object();
|
||||
|
|
|
@ -6,14 +6,15 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Type} from '../type';
|
||||
import {stringify} from '../util';
|
||||
import {Type} from '../interface/type';
|
||||
import {stringify} from '../util/stringify';
|
||||
|
||||
import {InjectableDef, getInjectableDef} from './defs';
|
||||
import {InjectionToken} from './injection_token';
|
||||
import {Injector} from './injector';
|
||||
import {InjectableDef, getInjectableDef} from './interface/defs';
|
||||
import {Inject, Optional, Self, SkipSelf} from './metadata';
|
||||
|
||||
|
||||
/**
|
||||
* Injection flags for DI.
|
||||
*
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package(default_visibility = [
|
||||
"//packages/core:__subpackages__",
|
||||
"//tools/public_api_guard:__pkg__",
|
||||
])
|
||||
|
||||
load("//tools:defaults.bzl", "ts_library")
|
||||
|
||||
ts_library(
|
||||
name = "interface",
|
||||
srcs = glob(
|
||||
[
|
||||
"**/*.ts",
|
||||
],
|
||||
),
|
||||
module_name = "@angular/core/di/interface",
|
||||
deps = [
|
||||
"//packages/core/src/interface",
|
||||
"//packages/core/src/util",
|
||||
"@rxjs",
|
||||
"@rxjs//operators",
|
||||
],
|
||||
)
|
|
@ -6,10 +6,11 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {NG_INJECTABLE_DEF, NG_INJECTOR_DEF} from '../render3/fields';
|
||||
import {Type} from '../type';
|
||||
import {Type} from '../../interface/type';
|
||||
import {getClosureSafeProperty} from '../../util/property';
|
||||
import {ClassProvider, ConstructorProvider, ExistingProvider, FactoryProvider, StaticClassProvider, ValueProvider} from './provider';
|
||||
|
||||
|
||||
import {ClassProvider, ClassSansProvider, ConstructorProvider, ConstructorSansProvider, ExistingProvider, ExistingSansProvider, FactoryProvider, FactorySansProvider, StaticClassProvider, StaticClassSansProvider, ValueProvider, ValueSansProvider} from './provider';
|
||||
|
||||
/**
|
||||
* Information about how a type or `InjectionToken` interfaces with the DI system.
|
||||
|
@ -178,4 +179,7 @@ export function getInjectableDef<T>(type: any): InjectableDef<T>|null {
|
|||
*/
|
||||
export function getInjectorDef<T>(type: any): InjectorDef<T>|null {
|
||||
return type && type.hasOwnProperty(NG_INJECTOR_DEF) ? (type as any)[NG_INJECTOR_DEF] : null;
|
||||
}
|
||||
}
|
||||
|
||||
export const NG_INJECTABLE_DEF = getClosureSafeProperty({ngInjectableDef: getClosureSafeProperty});
|
||||
export const NG_INJECTOR_DEF = getClosureSafeProperty({ngInjectorDef: getClosureSafeProperty});
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Type} from '../type';
|
||||
import {Type} from '../../interface/type';
|
||||
|
||||
/**
|
||||
* Configures the `Injector` to return a value for a token.
|
|
@ -6,12 +6,14 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ClassSansProvider, ConstructorProvider, ConstructorSansProvider, ExistingProvider, ExistingSansProvider, FactoryProvider, FactorySansProvider, StaticClassProvider, StaticClassSansProvider, ValueProvider, ValueSansProvider} from '../di/provider';
|
||||
import {Type} from '../interface/type';
|
||||
import {ReflectionCapabilities} from '../reflection/reflection_capabilities';
|
||||
import {Type} from '../type';
|
||||
import {makeDecorator, makeParamDecorator} from '../util/decorators';
|
||||
import {EMPTY_ARRAY} from '../view/util';
|
||||
|
||||
import {ClassSansProvider, ConstructorProvider, ConstructorSansProvider, ExistingProvider, ExistingSansProvider, FactoryProvider, FactorySansProvider, StaticClassProvider, StaticClassSansProvider, ValueProvider, ValueSansProvider} from './interface/provider';
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Type of the Inject decorator / constructor function.
|
||||
|
|
|
@ -6,16 +6,16 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Type} from '../interface/type';
|
||||
import {OnDestroy} from '../metadata/lifecycle_hooks';
|
||||
import {Type} from '../type';
|
||||
import {stringify} from '../util';
|
||||
import {stringify} from '../util/stringify';
|
||||
|
||||
import {InjectableDef, InjectableType, InjectorType, InjectorTypeWithProviders, getInjectableDef, getInjectorDef} from './defs';
|
||||
import {resolveForwardRef} from './forward_ref';
|
||||
import {InjectionToken} from './injection_token';
|
||||
import {INJECTOR, Injector, NullInjector, THROW_IF_NOT_FOUND, USE_VALUE} from './injector';
|
||||
import {InjectFlags, inject, injectArgs, setCurrentInjector} from './injector_compatibility';
|
||||
import {ClassProvider, ConstructorProvider, ExistingProvider, FactoryProvider, Provider, StaticClassProvider, StaticProvider, TypeProvider, ValueProvider} from './provider';
|
||||
import {InjectableDef, InjectableType, InjectorType, InjectorTypeWithProviders, getInjectableDef, getInjectorDef} from './interface/defs';
|
||||
import {ClassProvider, ConstructorProvider, ExistingProvider, FactoryProvider, Provider, StaticClassProvider, StaticProvider, TypeProvider, ValueProvider} from './interface/provider';
|
||||
import {APP_ROOT} from './scope';
|
||||
|
||||
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
*/
|
||||
|
||||
import {wrappedError} from '../error_handler';
|
||||
import {ERROR_ORIGINAL_ERROR, getOriginalError} from '../errors';
|
||||
import {Type} from '../type';
|
||||
import {stringify} from '../util';
|
||||
import {Type} from '../interface/type';
|
||||
import {ERROR_ORIGINAL_ERROR} from '../util/errors';
|
||||
import {stringify} from '../util/stringify';
|
||||
|
||||
import {ReflectiveInjector} from './reflective_injector';
|
||||
import {ReflectiveKey} from './reflective_key';
|
||||
|
|
|
@ -7,12 +7,13 @@
|
|||
*/
|
||||
|
||||
import {Injector, THROW_IF_NOT_FOUND} from './injector';
|
||||
import {Provider} from './interface/provider';
|
||||
import {Self, SkipSelf} from './metadata';
|
||||
import {Provider} from './provider';
|
||||
import {cyclicDependencyError, instantiationError, noProviderError, outOfBoundsError} from './reflective_errors';
|
||||
import {ReflectiveKey} from './reflective_key';
|
||||
import {ReflectiveDependency, ResolvedReflectiveFactory, ResolvedReflectiveProvider, resolveReflectiveProviders} from './reflective_provider';
|
||||
|
||||
|
||||
// Threshold for the dynamic version
|
||||
const UNDEFINED = new Object();
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {stringify} from '../util';
|
||||
import {stringify} from '../util/stringify';
|
||||
import {resolveForwardRef} from './forward_ref';
|
||||
|
||||
|
||||
|
|
|
@ -6,13 +6,13 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Type} from '../interface/type';
|
||||
import {reflector} from '../reflection/reflection';
|
||||
import {Type} from '../type';
|
||||
|
||||
import {resolveForwardRef} from './forward_ref';
|
||||
import {InjectionToken} from './injection_token';
|
||||
import {ClassProvider, ExistingProvider, FactoryProvider, Provider, TypeProvider, ValueProvider} from './interface/provider';
|
||||
import {Inject, Optional, Self, SkipSelf} from './metadata';
|
||||
import {ClassProvider, ExistingProvider, FactoryProvider, Provider, TypeProvider, ValueProvider} from './provider';
|
||||
import {invalidProviderError, mixingMultiProvidersWithRegularProvidersError, noAnnotationError} from './reflective_errors';
|
||||
import {ReflectiveKey} from './reflective_key';
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Type} from '../type';
|
||||
import {Type} from '../interface/type';
|
||||
import {InjectionToken} from './injection_token';
|
||||
|
||||
|
||||
|
|
|
@ -6,12 +6,12 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Type} from '../interface/type';
|
||||
import {ReflectionCapabilities} from '../reflection/reflection_capabilities';
|
||||
import {Type} from '../type';
|
||||
import {getClosureSafeProperty} from '../util/property';
|
||||
|
||||
import {inject, injectArgs} from './injector_compatibility';
|
||||
import {ClassSansProvider, ConstructorSansProvider, ExistingSansProvider, FactorySansProvider, StaticClassSansProvider, ValueProvider, ValueSansProvider} from './provider';
|
||||
import {ClassSansProvider, ConstructorSansProvider, ExistingSansProvider, FactorySansProvider, StaticClassSansProvider, ValueProvider, ValueSansProvider} from './interface/provider';
|
||||
|
||||
const USE_VALUE =
|
||||
getClosureSafeProperty<ValueProvider>({provide: String, useValue: getClosureSafeProperty});
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ERROR_ORIGINAL_ERROR, getDebugContext, getErrorLogger, getOriginalError} from './errors';
|
||||
import {getDebugContext, getErrorLogger, getOriginalError} from './errors';
|
||||
import {ERROR_ORIGINAL_ERROR} from './util/errors';
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -6,14 +6,9 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ERROR_DEBUG_CONTEXT, ERROR_LOGGER, ERROR_ORIGINAL_ERROR, ERROR_TYPE} from './util/errors';
|
||||
import {DebugContext} from './view';
|
||||
|
||||
export const ERROR_TYPE = 'ngType';
|
||||
export const ERROR_DEBUG_CONTEXT = 'ngDebugContext';
|
||||
export const ERROR_ORIGINAL_ERROR = 'ngOriginalError';
|
||||
export const ERROR_LOGGER = 'ngErrorLogger';
|
||||
|
||||
|
||||
export function getType(error: Error): Function {
|
||||
return (error as any)[ERROR_TYPE];
|
||||
}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package(default_visibility = [
|
||||
"//packages/core:__subpackages__",
|
||||
"//tools/public_api_guard:__pkg__",
|
||||
])
|
||||
|
||||
load("//tools:defaults.bzl", "ts_library")
|
||||
|
||||
ts_library(
|
||||
name = "interface",
|
||||
srcs = glob(
|
||||
[
|
||||
"*.ts",
|
||||
],
|
||||
),
|
||||
module_name = "@angular/core/interface",
|
||||
)
|
|
@ -8,11 +8,11 @@
|
|||
|
||||
import {Injectable} from '../di/injectable';
|
||||
import {InjectionToken} from '../di/injection_token';
|
||||
import {StaticProvider} from '../di/provider';
|
||||
import {StaticProvider} from '../di/interface/provider';
|
||||
import {MissingTranslationStrategy} from '../i18n/tokens';
|
||||
import {Type} from '../interface/type';
|
||||
import {ViewEncapsulation} from '../metadata';
|
||||
import {NgModuleFactory as NgModuleFactoryR3} from '../render3/ng_module_ref';
|
||||
import {Type} from '../type';
|
||||
|
||||
import {ComponentFactory} from './component_factory';
|
||||
import {NgModuleFactory} from './ng_module_factory';
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import {ChangeDetectorRef} from '../change_detection/change_detection';
|
||||
import {Injector} from '../di/injector';
|
||||
import {Type} from '../type';
|
||||
import {Type} from '../interface/type';
|
||||
|
||||
import {ElementRef} from './element_ref';
|
||||
import {NgModuleRef} from './ng_module_factory';
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
*/
|
||||
|
||||
import {Injector} from '../di/injector';
|
||||
import {Type} from '../type';
|
||||
import {stringify} from '../util';
|
||||
import {Type} from '../interface/type';
|
||||
import {stringify} from '../util/stringify';
|
||||
|
||||
import {ComponentFactory, ComponentRef} from './component_factory';
|
||||
import {NgModuleRef} from './ng_module_factory';
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import {Injector} from '../di/injector';
|
||||
import {Type} from '../type';
|
||||
import {Type} from '../interface/type';
|
||||
|
||||
import {ComponentFactoryResolver} from './component_factory_resolver';
|
||||
|
||||
|
|
|
@ -6,11 +6,13 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Type} from '../interface/type';
|
||||
import {NgModuleFactory as R3NgModuleFactory, NgModuleType} from '../render3/ng_module_ref';
|
||||
import {Type} from '../type';
|
||||
import {stringify} from '../util';
|
||||
import {stringify} from '../util/stringify';
|
||||
|
||||
import {NgModuleFactory} from './ng_module_factory';
|
||||
|
||||
|
||||
/**
|
||||
* Used to load ng module factories.
|
||||
*
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
import {Observable} from 'rxjs';
|
||||
|
||||
import {EventEmitter} from '../event_emitter';
|
||||
import {getSymbolIterator} from '../util';
|
||||
import {getSymbolIterator} from '../util/symbol';
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import {InjectionToken} from '../di/injection_token';
|
||||
import {Type} from '../type';
|
||||
import {Type} from '../interface/type';
|
||||
import {makeParamDecorator, makePropDecorator} from '../util/decorators';
|
||||
|
||||
/**
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
|
||||
import {ChangeDetectionStrategy} from '../change_detection/constants';
|
||||
import {Provider} from '../di';
|
||||
import {Type} from '../interface/type';
|
||||
import {NG_BASE_DEF} from '../render3/fields';
|
||||
import {compileComponent as render3CompileComponent, compileDirective as render3CompileDirective} from '../render3/jit/directive';
|
||||
import {compilePipe as render3CompilePipe} from '../render3/jit/pipe';
|
||||
import {Type} from '../type';
|
||||
import {TypeDecorator, makeDecorator, makePropDecorator} from '../util/decorators';
|
||||
import {noop} from '../util/noop';
|
||||
import {fillProperties} from '../util/property';
|
||||
|
|
|
@ -7,14 +7,15 @@
|
|||
*/
|
||||
|
||||
import {ApplicationRef} from '../application_ref';
|
||||
import {InjectorType, defineInjector} from '../di/defs';
|
||||
import {Provider} from '../di/provider';
|
||||
import {InjectorType, defineInjector} from '../di/interface/defs';
|
||||
import {Provider} from '../di/interface/provider';
|
||||
import {convertInjectableProviderToFactory} from '../di/util';
|
||||
import {Type} from '../interface/type';
|
||||
import {NgModuleType} from '../render3';
|
||||
import {compileNgModule as render3CompileNgModule} from '../render3/jit/module';
|
||||
import {Type} from '../type';
|
||||
import {TypeDecorator, makeDecorator} from '../util/decorators';
|
||||
|
||||
|
||||
/**
|
||||
* Represents the expansion of an `NgModule` into its scopes.
|
||||
*
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {global} from '../util';
|
||||
import {global} from '../util/global';
|
||||
|
||||
/**
|
||||
* A scope function for the Web Tracing Framework (WTF).
|
||||
|
|
|
@ -21,14 +21,15 @@
|
|||
* The below symbols are used for @Injectable and @NgModule compilation.
|
||||
*/
|
||||
|
||||
export {InjectableDef, InjectorDef, defineInjectable, defineInjector} from './di/defs';
|
||||
export {inject} from './di/injector_compatibility';
|
||||
export {InjectableDef, InjectorDef, defineInjectable, defineInjector} from './di/interface/defs';
|
||||
export {NgModuleDef, NgModuleDefWithMeta} from './metadata/ng_module';
|
||||
export {defineNgModule} from './render3/definition';
|
||||
export {setClassMetadata} from './render3/metadata';
|
||||
export {NgModuleFactory} from './render3/ng_module_ref';
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The existence of this constant (in this particular file) informs the Angular compiler that the
|
||||
* current program is actually @angular/core, which needs to be compiled specially.
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Type} from '../type';
|
||||
import {Type} from '../interface/type';
|
||||
import {GetterFn, MethodFn, SetterFn} from './types';
|
||||
|
||||
export interface PlatformReflectionCapabilities {
|
||||
|
|
|
@ -6,14 +6,16 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Type, isType} from '../type';
|
||||
import {global, stringify} from '../util';
|
||||
import {Type, isType} from '../interface/type';
|
||||
import {ANNOTATIONS, PARAMETERS, PROP_METADATA} from '../util/decorators';
|
||||
import {global} from '../util/global';
|
||||
import {stringify} from '../util/stringify';
|
||||
|
||||
import {PlatformReflectionCapabilities} from './platform_reflection_capabilities';
|
||||
import {GetterFn, MethodFn, SetterFn} from './types';
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Attention: These regex has to hold even if the code is minified!
|
||||
*/
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Type} from '../type';
|
||||
import {Type} from '../interface/type';
|
||||
import {PlatformReflectionCapabilities} from './platform_reflection_capabilities';
|
||||
import {GetterFn, MethodFn, SetterFn} from './types';
|
||||
|
||||
|
|
|
@ -6,61 +6,12 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {assertDefined, assertEqual, throwError} from '../util/assert';
|
||||
|
||||
import {getComponentDef, getNgModuleDef} from './definition';
|
||||
import {TNode} from './interfaces/node';
|
||||
import {LView} from './interfaces/view';
|
||||
|
||||
// The functions in this file verify that the assumptions we are making
|
||||
// about state in an instruction are correct before implementing any logic.
|
||||
// They are meant only to be called in dev mode as sanity checks.
|
||||
|
||||
export function assertNumber(actual: any, msg: string) {
|
||||
if (typeof actual != 'number') {
|
||||
throwError(msg);
|
||||
}
|
||||
}
|
||||
|
||||
export function assertEqual<T>(actual: T, expected: T, msg: string) {
|
||||
if (actual != expected) {
|
||||
throwError(msg);
|
||||
}
|
||||
}
|
||||
|
||||
export function assertNotEqual<T>(actual: T, expected: T, msg: string) {
|
||||
if (actual == expected) {
|
||||
throwError(msg);
|
||||
}
|
||||
}
|
||||
|
||||
export function assertSame<T>(actual: T, expected: T, msg: string) {
|
||||
if (actual !== expected) {
|
||||
throwError(msg);
|
||||
}
|
||||
}
|
||||
|
||||
export function assertLessThan<T>(actual: T, expected: T, msg: string) {
|
||||
if (actual >= expected) {
|
||||
throwError(msg);
|
||||
}
|
||||
}
|
||||
|
||||
export function assertGreaterThan<T>(actual: T, expected: T, msg: string) {
|
||||
if (actual <= expected) {
|
||||
throwError(msg);
|
||||
}
|
||||
}
|
||||
|
||||
export function assertNotDefined<T>(actual: T, msg: string) {
|
||||
if (actual != null) {
|
||||
throwError(msg);
|
||||
}
|
||||
}
|
||||
|
||||
export function assertDefined<T>(actual: T, msg: string) {
|
||||
if (actual == null) {
|
||||
throwError(msg);
|
||||
}
|
||||
}
|
||||
|
||||
export function assertComponentType(
|
||||
actual: any,
|
||||
|
@ -80,17 +31,6 @@ export function assertNgModuleType(
|
|||
}
|
||||
}
|
||||
|
||||
function throwError(msg: string): never {
|
||||
// tslint:disable-next-line
|
||||
debugger; // Left intentionally for better debugger experience.
|
||||
throw new Error(`ASSERTION ERROR: ${msg}`);
|
||||
}
|
||||
|
||||
export function assertDomNode(node: any) {
|
||||
assertEqual(node instanceof Node, true, 'The provided value must be an instance of a DOM Node');
|
||||
}
|
||||
|
||||
|
||||
export function assertPreviousIsParent(isParent: boolean) {
|
||||
assertEqual(isParent, true, 'previousOrParentTNode should be a parent');
|
||||
}
|
||||
|
@ -104,7 +44,3 @@ export function assertDataNext(lView: LView, index: number, arr?: any[]) {
|
|||
assertEqual(
|
||||
arr.length, index, `index ${index} expected to be at the end of arr (length ${arr.length})`);
|
||||
}
|
||||
|
||||
export function assertDataInRange(arr: any[], index: number) {
|
||||
assertLessThan(index, arr ? arr.length : 0, 'index expected to be a valid data index');
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import {devModeEqual} from '../change_detection/change_detection_util';
|
||||
|
||||
import {assertDataInRange, assertLessThan, assertNotEqual} from './assert';
|
||||
import {assertDataInRange, assertLessThan, assertNotEqual} from '../util/assert';
|
||||
import {throwErrorIfNoChangesMode} from './errors';
|
||||
import {BINDING_INDEX, LView} from './interfaces/view';
|
||||
import {getCheckNoChangesMode, isCreationMode} from './state';
|
||||
|
|
|
@ -11,8 +11,9 @@
|
|||
import {Type} from '../core';
|
||||
import {Injector} from '../di/injector';
|
||||
import {Sanitizer} from '../sanitization/security';
|
||||
import {assertDefined} from '../util/assert';
|
||||
|
||||
import {assertComponentType, assertDefined} from './assert';
|
||||
import {assertComponentType} from './assert';
|
||||
import {getComponentDef} from './definition';
|
||||
import {diPublicInInjector, getOrCreateNodeInjectorForNode} from './di';
|
||||
import {publishDefaultGlobalUtils} from './global_utils';
|
||||
|
|
|
@ -10,15 +10,17 @@ import {ChangeDetectorRef as ViewEngine_ChangeDetectorRef} from '../change_detec
|
|||
import {InjectionToken} from '../di/injection_token';
|
||||
import {Injector} from '../di/injector';
|
||||
import {inject} from '../di/injector_compatibility';
|
||||
import {Type} from '../interface/type';
|
||||
import {ComponentFactory as viewEngine_ComponentFactory, ComponentRef as viewEngine_ComponentRef} from '../linker/component_factory';
|
||||
import {ComponentFactoryResolver as viewEngine_ComponentFactoryResolver} from '../linker/component_factory_resolver';
|
||||
import {ElementRef as viewEngine_ElementRef} from '../linker/element_ref';
|
||||
import {NgModuleRef as viewEngine_NgModuleRef} from '../linker/ng_module_factory';
|
||||
import {RendererFactory2} from '../render/api';
|
||||
import {Sanitizer} from '../sanitization/security';
|
||||
import {Type} from '../type';
|
||||
import {assertDefined} from '../util/assert';
|
||||
import {VERSION} from '../version';
|
||||
import {assertComponentType, assertDefined} from './assert';
|
||||
|
||||
import {assertComponentType} from './assert';
|
||||
import {LifecycleHooksFeature, createRootComponent, createRootComponentView, createRootContext} from './component';
|
||||
import {getComponentDef} from './definition';
|
||||
import {NodeInjector} from './di';
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
* 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
|
||||
*/
|
||||
import './ng_dev_mode';
|
||||
import {assertDomNode} from './assert';
|
||||
import '../util/ng_dev_mode';
|
||||
import {assertDomNode} from '../util/assert';
|
||||
import {EMPTY_ARRAY} from './empty';
|
||||
import {LContext, MONKEY_PATCH_KEY_NAME} from './interfaces/context';
|
||||
import {TNode, TNodeFlags} from './interfaces/node';
|
||||
|
|
|
@ -6,13 +6,15 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import './ng_dev_mode';
|
||||
import '../util/ng_dev_mode';
|
||||
|
||||
import {ChangeDetectionStrategy} from '../change_detection/constants';
|
||||
import {Mutable, Type} from '../interface/type';
|
||||
import {NgModuleDef} from '../metadata/ng_module';
|
||||
import {ViewEncapsulation} from '../metadata/view';
|
||||
import {Mutable, Type} from '../type';
|
||||
import {noSideEffects, stringify} from '../util';
|
||||
import {noSideEffects} from '../util/closure';
|
||||
import {stringify} from '../util/stringify';
|
||||
|
||||
import {EMPTY_ARRAY, EMPTY_OBJ} from './empty';
|
||||
import {NG_COMPONENT_DEF, NG_DIRECTIVE_DEF, NG_MODULE_DEF, NG_PIPE_DEF} from './fields';
|
||||
import {BaseDef, ComponentDef, ComponentDefFeature, ComponentQuery, ComponentTemplate, ComponentType, DirectiveDef, DirectiveDefFeature, DirectiveType, DirectiveTypesOrFactory, HostBindingsFunction, PipeDef, PipeType, PipeTypesOrFactory} from './interfaces/definition';
|
||||
|
|
|
@ -6,13 +6,13 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {getInjectableDef, getInjectorDef} from '../di/defs';
|
||||
import {InjectionToken} from '../di/injection_token';
|
||||
import {Injector} from '../di/injector';
|
||||
import {InjectFlags, injectRootLimpMode, setInjectImplementation} from '../di/injector_compatibility';
|
||||
import {Type} from '../type';
|
||||
import {getInjectableDef, getInjectorDef} from '../di/interface/defs';
|
||||
import {Type} from '../interface/type';
|
||||
|
||||
import {assertDefined, assertEqual} from './assert';
|
||||
import {assertDefined, assertEqual} from '../util/assert';
|
||||
import {getComponentDef, getDirectiveDef, getPipeDef} from './definition';
|
||||
import {NG_ELEMENT_ID} from './fields';
|
||||
import {DirectiveDef} from './interfaces/definition';
|
||||
|
@ -24,6 +24,7 @@ import {getLView, getPreviousOrParentTNode, setTNodeAndViewData} from './state';
|
|||
import {findComponentView, getParentInjectorIndex, getParentInjectorView, hasParentInjector, isComponent, isComponentDef, stringify} from './util';
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Defines if the call to `inject` should include `viewProviders` in its resolution.
|
||||
*
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
|
||||
import {resolveForwardRef} from '../di/forward_ref';
|
||||
import {Provider} from '../di/provider';
|
||||
import {Provider} from '../di/interface/provider';
|
||||
import {isTypeProvider, providerToFactory} from '../di/r3_injector';
|
||||
|
||||
import {DirectiveDef} from '.';
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import {Injector} from '../di/injector';
|
||||
|
||||
import {assertDefined} from './assert';
|
||||
import {assertDefined} from '../util/assert';
|
||||
import {discoverLocalRefs, getComponentAtNodeIndex, getDirectivesAtNodeIndex, getLContext} from './context_discovery';
|
||||
import {NodeInjector} from './di';
|
||||
import {LContext} from './interfaces/context';
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
*/
|
||||
import './ng_dev_mode';
|
||||
import '../util/ng_dev_mode';
|
||||
|
||||
/**
|
||||
* This file contains reuseable "empty" symbols that can be used as default return values
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Type} from '../../type';
|
||||
import {Type} from '../../interface/type';
|
||||
import {fillProperties} from '../../util/property';
|
||||
import {EMPTY_ARRAY, EMPTY_OBJ} from '../empty';
|
||||
import {ComponentDef, DirectiveDef, DirectiveDefFeature, RenderFlags} from '../interfaces/definition';
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
*/
|
||||
import {Provider} from '../../di/provider';
|
||||
import {Provider} from '../../di/interface/provider';
|
||||
import {providersResolver} from '../di_setup';
|
||||
import {DirectiveDef} from '../interfaces/definition';
|
||||
|
||||
|
|
|
@ -10,8 +10,6 @@ import {getClosureSafeProperty} from '../util/property';
|
|||
|
||||
export const NG_COMPONENT_DEF = getClosureSafeProperty({ngComponentDef: getClosureSafeProperty});
|
||||
export const NG_DIRECTIVE_DEF = getClosureSafeProperty({ngDirectiveDef: getClosureSafeProperty});
|
||||
export const NG_INJECTABLE_DEF = getClosureSafeProperty({ngInjectableDef: getClosureSafeProperty});
|
||||
export const NG_INJECTOR_DEF = getClosureSafeProperty({ngInjectorDef: getClosureSafeProperty});
|
||||
export const NG_PIPE_DEF = getClosureSafeProperty({ngPipeDef: getClosureSafeProperty});
|
||||
export const NG_MODULE_DEF = getClosureSafeProperty({ngModuleDef: getClosureSafeProperty});
|
||||
export const NG_BASE_DEF = getClosureSafeProperty({ngBaseDef: getClosureSafeProperty});
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
* 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
|
||||
*/
|
||||
import {global} from '../util';
|
||||
import {assertDefined} from '../util/assert';
|
||||
import {global} from '../util/global';
|
||||
|
||||
import {assertDefined} from './assert';
|
||||
import {getComponent, getContext, getDirectives, getHostElement, getInjector, getListeners, getPlayers, getRootComponents, getViewComponent, markDirty} from './global_utils_api';
|
||||
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {assertEqual} from './assert';
|
||||
import {assertEqual} from '../util/assert';
|
||||
import {DirectiveDef} from './interfaces/definition';
|
||||
import {TNode} from './interfaces/node';
|
||||
import {FLAGS, HookData, LView, LViewFlags, TView} from './interfaces/view';
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
import {SRCSET_ATTRS, URI_ATTRS, VALID_ATTRS, VALID_ELEMENTS, getTemplateContent} from '../sanitization/html_sanitizer';
|
||||
import {InertBodyHelper} from '../sanitization/inert_body';
|
||||
import {_sanitizeUrl, sanitizeSrcset} from '../sanitization/url_sanitizer';
|
||||
import {assertDefined, assertEqual, assertGreaterThan} from './assert';
|
||||
import {assertDefined, assertEqual, assertGreaterThan} from '../util/assert';
|
||||
import {attachPatchData} from './context_discovery';
|
||||
import {allocExpando, createNodeAtIndex, elementAttribute, load, textBinding} from './instructions';
|
||||
import {LContainer, NATIVE} from './interfaces/container';
|
||||
|
|
|
@ -10,13 +10,14 @@ import {resolveForwardRef} from '../di/forward_ref';
|
|||
import {InjectionToken} from '../di/injection_token';
|
||||
import {Injector} from '../di/injector';
|
||||
import {InjectFlags} from '../di/injector_compatibility';
|
||||
import {Type} from '../interface/type';
|
||||
import {QueryList} from '../linker';
|
||||
import {Sanitizer} from '../sanitization/security';
|
||||
import {StyleSanitizeFn} from '../sanitization/style_sanitizer';
|
||||
import {Type} from '../type';
|
||||
import {assertDataInRange, assertDefined, assertEqual, assertLessThan, assertNotEqual} from '../util/assert';
|
||||
import {normalizeDebugBindingName, normalizeDebugBindingValue} from '../util/ng_reflect';
|
||||
|
||||
import {assertDataInRange, assertDefined, assertEqual, assertHasParent, assertLessThan, assertNotEqual, assertPreviousIsParent} from './assert';
|
||||
import {assertHasParent, assertPreviousIsParent} from './assert';
|
||||
import {bindingUpdated, bindingUpdated2, bindingUpdated3, bindingUpdated4} from './bindings';
|
||||
import {attachPatchData, getComponentViewByInstance} from './context_discovery';
|
||||
import {diPublicInInjector, getNodeInjectable, getOrCreateInjectable, getOrCreateNodeInjectorForNode, injectAttributeImpl} from './di';
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import {ViewEncapsulation} from '../../core';
|
||||
import {Type} from '../../type';
|
||||
import {Type} from '../../interface/type';
|
||||
import {CssSelectorList} from './projection';
|
||||
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import {InjectionToken} from '../../di/injection_token';
|
||||
import {InjectFlags} from '../../di/injector_compatibility';
|
||||
import {Type} from '../../type';
|
||||
import {Type} from '../../interface/type';
|
||||
import {TElementNode} from './node';
|
||||
import {LView, TData} from './view';
|
||||
|
||||
|
|
|
@ -6,10 +6,12 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Type} from '../../interface/type';
|
||||
import {QueryList} from '../../linker';
|
||||
import {Type} from '../../type';
|
||||
|
||||
import {TContainerNode, TElementContainerNode, TElementNode, TNode} from './node';
|
||||
|
||||
|
||||
/** Used for tracking queries (e.g. ViewChild, ContentChild). */
|
||||
export interface LQueries {
|
||||
/**
|
||||
|
|
|
@ -8,9 +8,10 @@
|
|||
|
||||
import {InjectionToken} from '../../di/injection_token';
|
||||
import {Injector} from '../../di/injector';
|
||||
import {Type} from '../../interface/type';
|
||||
import {QueryList} from '../../linker';
|
||||
import {Sanitizer} from '../../sanitization/security';
|
||||
import {Type} from '../../type';
|
||||
|
||||
import {LContainer} from './container';
|
||||
import {ComponentDef, ComponentQuery, ComponentTemplate, DirectiveDef, DirectiveDefList, HostBindingsFunction, PipeDef, PipeDefList} from './definition';
|
||||
import {I18nUpdateOpCodes, TI18n} from './i18n';
|
||||
|
@ -21,6 +22,7 @@ import {RElement, Renderer3, RendererFactory3} from './renderer';
|
|||
import {StylingContext} from './styling';
|
||||
|
||||
|
||||
|
||||
// Below are constants for LView indices to help us look up LView members
|
||||
// without having to remember the specific indices.
|
||||
// Uglify will inline these when minifying so there shouldn't be a cost.
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
*/
|
||||
import {global} from '../../util';
|
||||
import {global} from '../../util/global';
|
||||
import {CompilerFacade, ExportedCompilerFacade} from './compiler_facade_interface';
|
||||
export * from './compiler_facade_interface';
|
||||
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
|
||||
import {ComponentType} from '..';
|
||||
import {resolveForwardRef} from '../../di/forward_ref';
|
||||
import {Type} from '../../interface/type';
|
||||
import {Query} from '../../metadata/di';
|
||||
import {Component, Directive} from '../../metadata/directives';
|
||||
import {componentNeedsResolution, maybeQueueResolutionOfComponentResources} from '../../metadata/resource_loading';
|
||||
import {ViewEncapsulation} from '../../metadata/view';
|
||||
import {Type} from '../../type';
|
||||
import {EMPTY_ARRAY, EMPTY_OBJ} from '../empty';
|
||||
import {NG_COMPONENT_DEF, NG_DIRECTIVE_DEF} from '../fields';
|
||||
import {stringify} from '../util';
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {defineInjectable, defineInjector,} from '../../di/defs';
|
||||
import {defineInjectable, defineInjector,} from '../../di/interface/defs';
|
||||
import {inject} from '../../di/injector_compatibility';
|
||||
import * as r3 from '../index';
|
||||
import * as sanitization from '../../sanitization/sanitization';
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
*/
|
||||
|
||||
import {Injectable} from '../../di/injectable';
|
||||
import {ClassSansProvider, ExistingSansProvider, FactorySansProvider, ValueProvider, ValueSansProvider} from '../../di/provider';
|
||||
import {Type} from '../../type';
|
||||
import {NG_INJECTABLE_DEF} from '../../di/interface/defs';
|
||||
import {ClassSansProvider, ExistingSansProvider, FactorySansProvider, ValueProvider, ValueSansProvider} from '../../di/interface/provider';
|
||||
import {Type} from '../../interface/type';
|
||||
import {getClosureSafeProperty} from '../../util/property';
|
||||
import {NG_INJECTABLE_DEF} from '../fields';
|
||||
|
||||
import {R3InjectableMetadataFacade, getCompilerFacade} from './compiler_facade';
|
||||
import {angularCoreEnv} from './environment';
|
||||
|
|
|
@ -7,13 +7,14 @@
|
|||
*/
|
||||
|
||||
import {resolveForwardRef} from '../../di/forward_ref';
|
||||
import {NG_INJECTOR_DEF} from '../../di/interface/defs';
|
||||
import {Type} from '../../interface/type';
|
||||
import {registerNgModuleType} from '../../linker/ng_module_factory_loader';
|
||||
import {Component} from '../../metadata';
|
||||
import {ModuleWithProviders, NgModule, NgModuleDef, NgModuleTransitiveScopes} from '../../metadata/ng_module';
|
||||
import {Type} from '../../type';
|
||||
import {assertDefined} from '../assert';
|
||||
import {assertDefined} from '../../util/assert';
|
||||
import {getComponentDef, getDirectiveDef, getNgModuleDef, getPipeDef} from '../definition';
|
||||
import {NG_COMPONENT_DEF, NG_DIRECTIVE_DEF, NG_INJECTOR_DEF, NG_MODULE_DEF, NG_PIPE_DEF} from '../fields';
|
||||
import {NG_COMPONENT_DEF, NG_DIRECTIVE_DEF, NG_MODULE_DEF, NG_PIPE_DEF} from '../fields';
|
||||
import {ComponentDef} from '../interfaces/definition';
|
||||
import {NgModuleType} from '../ng_module_ref';
|
||||
import {stringify} from '../util';
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Type} from '../../interface/type';
|
||||
import {Pipe} from '../../metadata/directives';
|
||||
import {Type} from '../../type';
|
||||
import {NG_PIPE_DEF} from '../fields';
|
||||
import {stringify} from '../util';
|
||||
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
*/
|
||||
|
||||
import {Host, Inject, Optional, Self, SkipSelf} from '../../di/metadata';
|
||||
import {Type} from '../../interface/type';
|
||||
import {Attribute} from '../../metadata/di';
|
||||
import {ReflectionCapabilities} from '../../reflection/reflection_capabilities';
|
||||
import {Type} from '../../type';
|
||||
|
||||
import {CompilerFacade, R3DependencyMetadataFacade, getCompilerFacade} from './compiler_facade';
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Type} from '../type';
|
||||
import {Type} from '../interface/type';
|
||||
|
||||
interface TypeWithMetadata extends Type<any> {
|
||||
decorators?: any[];
|
||||
|
|
|
@ -8,15 +8,15 @@
|
|||
|
||||
import {INJECTOR, Injector} from '../di/injector';
|
||||
import {InjectFlags} from '../di/injector_compatibility';
|
||||
import {StaticProvider} from '../di/provider';
|
||||
import {StaticProvider} from '../di/interface/provider';
|
||||
import {createInjector} from '../di/r3_injector';
|
||||
import {Type} from '../interface/type';
|
||||
import {ComponentFactoryResolver as viewEngine_ComponentFactoryResolver} from '../linker/component_factory_resolver';
|
||||
import {InternalNgModuleRef, NgModuleFactory as viewEngine_NgModuleFactory, NgModuleRef as viewEngine_NgModuleRef} from '../linker/ng_module_factory';
|
||||
import {NgModuleDef} from '../metadata/ng_module';
|
||||
import {Type} from '../type';
|
||||
import {stringify} from '../util';
|
||||
import {assertDefined} from '../util/assert';
|
||||
import {stringify} from '../util/stringify';
|
||||
|
||||
import {assertDefined} from './assert';
|
||||
import {ComponentFactoryResolver} from './component_ref';
|
||||
import {getNgModuleDef} from './definition';
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {assertDefined, assertEqual} from './assert';
|
||||
import {assertDefined, assertEqual} from '../util/assert';
|
||||
import {TNode, TNodeType} from './interfaces/node';
|
||||
|
||||
export function assertNodeType(tNode: TNode, type: TNodeType) {
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import './ng_dev_mode';
|
||||
import '../util/ng_dev_mode';
|
||||
|
||||
import {assertDefined, assertNotEqual} from './assert';
|
||||
import {assertDefined, assertNotEqual} from '../util/assert';
|
||||
import {AttributeMarker, TAttributes, TNode, TNodeType, unusedValueExportToPlacateAjd as unused1} from './interfaces/node';
|
||||
import {CssSelector, CssSelectorList, NG_PROJECT_AS_ATTR_NAME, SelectorFlags, unusedValueExportToPlacateAjd as unused2} from './interfaces/projection';
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
*/
|
||||
import './ng_dev_mode';
|
||||
import '../util/ng_dev_mode';
|
||||
|
||||
import {getLContext} from './context_discovery';
|
||||
import {getRootContext} from './discovery_utils';
|
||||
|
|
|
@ -8,16 +8,14 @@
|
|||
|
||||
// We are temporarily importing the existing viewEngine_from core so we can be sure we are
|
||||
// correctly implementing its interfaces for backwards compatibility.
|
||||
import {Observable} from 'rxjs';
|
||||
|
||||
import {EventEmitter} from '../event_emitter';
|
||||
import {Type} from '../interface/type';
|
||||
import {ElementRef as ViewEngine_ElementRef} from '../linker/element_ref';
|
||||
import {QueryList} from '../linker/query_list';
|
||||
import {TemplateRef as ViewEngine_TemplateRef} from '../linker/template_ref';
|
||||
import {Type} from '../type';
|
||||
import {getSymbolIterator} from '../util';
|
||||
import {assertDefined, assertEqual} from '../util/assert';
|
||||
|
||||
import {assertDefined, assertEqual, assertPreviousIsParent} from './assert';
|
||||
import {assertPreviousIsParent} from './assert';
|
||||
import {getNodeInjectable, locateDirectiveOrProvider} from './di';
|
||||
import {NG_ELEMENT_ID} from './fields';
|
||||
import {store, storeCleanupWithContext} from './instructions';
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {assertDefined} from './assert';
|
||||
import {assertDefined} from '../util/assert';
|
||||
import {executeHooks} from './hooks';
|
||||
import {ComponentDef, DirectiveDef} from './interfaces/definition';
|
||||
import {TElementNode, TNode, TNodeFlags, TViewNode} from './interfaces/node';
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
import {StyleSanitizeFn} from '../../sanitization/style_sanitizer';
|
||||
import {assertNotEqual} from '../assert';
|
||||
import {assertNotEqual} from '../../util/assert';
|
||||
import {EMPTY_ARRAY, EMPTY_OBJ} from '../empty';
|
||||
import {AttributeMarker, TAttributes} from '../interfaces/node';
|
||||
import {BindingStore, BindingType, Player, PlayerBuilder, PlayerFactory, PlayerIndex} from '../interfaces/player';
|
||||
|
@ -20,6 +20,7 @@ import {BoundPlayerFactory} from './player_factory';
|
|||
import {addPlayerInternal, allocPlayerContext, createEmptyStylingContext, getPlayerContext} from './util';
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This file includes the code to power all styling-binding operations in Angular.
|
||||
*
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
*/
|
||||
import '../ng_dev_mode';
|
||||
import '../../util/ng_dev_mode';
|
||||
|
||||
import {StyleSanitizeFn} from '../../sanitization/style_sanitizer';
|
||||
import {getLContext} from '../context_discovery';
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {global} from '../util';
|
||||
import {assertDataInRange, assertDefined, assertGreaterThan, assertLessThan} from '../util/assert';
|
||||
import {global} from '../util/global';
|
||||
|
||||
import {assertDataInRange, assertDefined, assertGreaterThan, assertLessThan} from './assert';
|
||||
import {ACTIVE_INDEX, LCONTAINER_LENGTH, LContainer} from './interfaces/container';
|
||||
import {LContext, MONKEY_PATCH_KEY_NAME} from './interfaces/context';
|
||||
import {ComponentDef, DirectiveDef} from './interfaces/definition';
|
||||
|
@ -18,6 +18,7 @@ import {GlobalTargetName, GlobalTargetResolver, RComment, RElement, RText} from
|
|||
import {StylingContext} from './interfaces/styling';
|
||||
import {CONTEXT, DECLARATION_VIEW, FLAGS, HEADER_OFFSET, HOST, HOST_NODE, LView, LViewFlags, PARENT, RootContext, TData, TVIEW, TView} from './interfaces/view';
|
||||
|
||||
|
||||
/**
|
||||
* Returns whether the values are different from a change detection stand point.
|
||||
*
|
||||
|
|
|
@ -15,7 +15,7 @@ import {TemplateRef as ViewEngine_TemplateRef} from '../linker/template_ref';
|
|||
import {ViewContainerRef as ViewEngine_ViewContainerRef} from '../linker/view_container_ref';
|
||||
import {EmbeddedViewRef as viewEngine_EmbeddedViewRef, ViewRef as viewEngine_ViewRef} from '../linker/view_ref';
|
||||
import {Renderer2} from '../render/api';
|
||||
import {assertDefined, assertGreaterThan, assertLessThan} from './assert';
|
||||
import {assertDefined, assertGreaterThan, assertLessThan} from '../util/assert';
|
||||
import {NodeInjector, getParentInjectorLocation} from './di';
|
||||
import {addToViewTree, createEmbeddedViewAndNode, createLContainer, renderEmbeddedTemplate} from './instructions';
|
||||
import {ACTIVE_INDEX, LContainer, NATIVE, VIEWS} from './interfaces/container';
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {isDevMode} from '../is_dev_mode';
|
||||
import {isDevMode} from '../util/is_dev_mode';
|
||||
import {InertBodyHelper} from './inert_body';
|
||||
import {_sanitizeUrl, sanitizeSrcset} from './url_sanitizer';
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {isDevMode} from '../is_dev_mode';
|
||||
import {isDevMode} from '../util/is_dev_mode';
|
||||
import {_sanitizeUrl} from './url_sanitizer';
|
||||
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {isDevMode} from '../is_dev_mode';
|
||||
import {isDevMode} from '../util/is_dev_mode';
|
||||
|
||||
/**
|
||||
* A pattern that recognizes a commonly useful subset of URLs that are safe.
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import {Injectable} from '../di';
|
||||
import {scheduleMicroTask} from '../util';
|
||||
import {scheduleMicroTask} from '../util/microtask';
|
||||
import {NgZone} from '../zone/ng_zone';
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,111 +0,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
|
||||
*/
|
||||
|
||||
// TODO(jteplitz602): Load WorkerGlobalScope from lib.webworker.d.ts file #3492
|
||||
declare var WorkerGlobalScope: any /** TODO #9100 */;
|
||||
// CommonJS / Node have global context exposed as "global" variable.
|
||||
// We don't want to include the whole node.d.ts this this compilation unit so we'll just fake
|
||||
// the global "global" var for now.
|
||||
declare var global: any /** TODO #9100 */;
|
||||
const __window = typeof window !== 'undefined' && window;
|
||||
const __self = typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' &&
|
||||
self instanceof WorkerGlobalScope && self;
|
||||
const __global = typeof global !== 'undefined' && global;
|
||||
|
||||
// Check __global first, because in Node tests both __global and __window may be defined and _global
|
||||
// should be __global in that case.
|
||||
const _global: {[name: string]: any} = __global || __window || __self;
|
||||
|
||||
const promise: Promise<any> = Promise.resolve(0);
|
||||
/**
|
||||
* Attention: whenever providing a new value, be sure to add an
|
||||
* entry into the corresponding `....externs.js` file,
|
||||
* so that closure won't use that global for its purposes.
|
||||
*/
|
||||
export {_global as global};
|
||||
|
||||
// When Symbol.iterator doesn't exist, retrieves the key used in es6-shim
|
||||
declare const Symbol: any;
|
||||
let _symbolIterator: any = null;
|
||||
export function getSymbolIterator(): string|symbol {
|
||||
if (!_symbolIterator) {
|
||||
const Symbol = _global['Symbol'];
|
||||
if (Symbol && Symbol.iterator) {
|
||||
_symbolIterator = Symbol.iterator;
|
||||
} else {
|
||||
// es6-shim specific logic
|
||||
const keys = Object.getOwnPropertyNames(Map.prototype);
|
||||
for (let i = 0; i < keys.length; ++i) {
|
||||
const key = keys[i];
|
||||
if (key !== 'entries' && key !== 'size' &&
|
||||
(Map as any).prototype[key] === Map.prototype['entries']) {
|
||||
_symbolIterator = key;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return _symbolIterator;
|
||||
}
|
||||
|
||||
export function scheduleMicroTask(fn: Function) {
|
||||
if (typeof Zone === 'undefined') {
|
||||
// use promise to schedule microTask instead of use Zone
|
||||
promise.then(() => { fn && fn.apply(null, null); });
|
||||
} else {
|
||||
Zone.current.scheduleMicroTask('scheduleMicrotask', fn);
|
||||
}
|
||||
}
|
||||
|
||||
// JS has NaN !== NaN
|
||||
export function looseIdentical(a: any, b: any): boolean {
|
||||
return a === b || typeof a === 'number' && typeof b === 'number' && isNaN(a) && isNaN(b);
|
||||
}
|
||||
|
||||
export function stringify(token: any): string {
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
export function noSideEffects(fn: () => void): string {
|
||||
return '' + {toString: fn};
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package(default_visibility = [
|
||||
"//packages/core:__subpackages__",
|
||||
"//tools/public_api_guard:__pkg__",
|
||||
])
|
||||
|
||||
load("//tools:defaults.bzl", "ts_library")
|
||||
|
||||
ts_library(
|
||||
name = "util",
|
||||
srcs = glob(
|
||||
[
|
||||
"**/*.ts",
|
||||
],
|
||||
),
|
||||
module_name = "@angular/core/util",
|
||||
deps = [
|
||||
"//packages/core/src/interface",
|
||||
"@rxjs",
|
||||
"@rxjs//operators",
|
||||
],
|
||||
)
|
|
@ -0,0 +1,46 @@
|
|||
/**
|
||||
* @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
|
||||
*/
|
||||
|
||||
/**
|
||||
* Indicates that the result of a {@link Pipe} transformation has changed even though the
|
||||
* reference has not changed.
|
||||
*
|
||||
* Wrapped values are unwrapped automatically during the change detection, and the unwrapped value
|
||||
* is stored.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ```
|
||||
* if (this._latestValue === this._latestReturnedValue) {
|
||||
* return this._latestReturnedValue;
|
||||
* } else {
|
||||
* this._latestReturnedValue = this._latestValue;
|
||||
* return WrappedValue.wrap(this._latestValue); // this will force update
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @publicApi
|
||||
*/
|
||||
export class WrappedValue {
|
||||
/** @deprecated from 5.3, use `unwrap()` instead - will switch to protected */
|
||||
wrapped: any;
|
||||
|
||||
constructor(value: any) { this.wrapped = value; }
|
||||
|
||||
/** Creates a wrapped value. */
|
||||
static wrap(value: any): WrappedValue { return new WrappedValue(value); }
|
||||
|
||||
/**
|
||||
* Returns the underlying value of a wrapped value.
|
||||
* Returns the given `value` when it is not wrapped.
|
||||
**/
|
||||
static unwrap(value: any): any { return WrappedValue.isWrapped(value) ? value.wrapped : value; }
|
||||
|
||||
/** Returns true if `value` is a wrapped value. */
|
||||
static isWrapped(value: any): value is WrappedValue { return value instanceof WrappedValue; }
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
/**
|
||||
* @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
|
||||
*/
|
||||
|
||||
// The functions in this file verify that the assumptions we are making
|
||||
// about state in an instruction are correct before implementing any logic.
|
||||
// They are meant only to be called in dev mode as sanity checks.
|
||||
|
||||
export function assertNumber(actual: any, msg: string) {
|
||||
if (typeof actual != 'number') {
|
||||
throwError(msg);
|
||||
}
|
||||
}
|
||||
|
||||
export function assertEqual<T>(actual: T, expected: T, msg: string) {
|
||||
if (actual != expected) {
|
||||
throwError(msg);
|
||||
}
|
||||
}
|
||||
|
||||
export function assertNotEqual<T>(actual: T, expected: T, msg: string) {
|
||||
if (actual == expected) {
|
||||
throwError(msg);
|
||||
}
|
||||
}
|
||||
|
||||
export function assertSame<T>(actual: T, expected: T, msg: string) {
|
||||
if (actual !== expected) {
|
||||
throwError(msg);
|
||||
}
|
||||
}
|
||||
|
||||
export function assertLessThan<T>(actual: T, expected: T, msg: string) {
|
||||
if (actual >= expected) {
|
||||
throwError(msg);
|
||||
}
|
||||
}
|
||||
|
||||
export function assertGreaterThan<T>(actual: T, expected: T, msg: string) {
|
||||
if (actual <= expected) {
|
||||
throwError(msg);
|
||||
}
|
||||
}
|
||||
|
||||
export function assertNotDefined<T>(actual: T, msg: string) {
|
||||
if (actual != null) {
|
||||
throwError(msg);
|
||||
}
|
||||
}
|
||||
|
||||
export function assertDefined<T>(actual: T, msg: string) {
|
||||
if (actual == null) {
|
||||
throwError(msg);
|
||||
}
|
||||
}
|
||||
|
||||
export function throwError(msg: string): never {
|
||||
// tslint:disable-next-line
|
||||
debugger; // Left intentionally for better debugger experience.
|
||||
throw new Error(`ASSERTION ERROR: ${msg}`);
|
||||
}
|
||||
|
||||
export function assertDomNode(node: any) {
|
||||
assertEqual(node instanceof Node, true, 'The provided value must be an instance of a DOM Node');
|
||||
}
|
||||
|
||||
|
||||
export function assertDataInRange(arr: any[], index: number) {
|
||||
assertLessThan(index, arr ? arr.length : 0, 'index expected to be a valid data index');
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
/**
|
||||
* @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.
|
||||
*/
|
||||
export function noSideEffects(fn: () => void): string {
|
||||
return '' + {toString: fn};
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
/**
|
||||
* @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
|
||||
*/
|
||||
|
||||
import {areIterablesEqual, isListLikeIterable} from './iterable';
|
||||
|
||||
|
||||
// JS has NaN !== NaN
|
||||
export function looseIdentical(a: any, b: any): boolean {
|
||||
return a === b || typeof a === 'number' && typeof b === 'number' && isNaN(a) && isNaN(b);
|
||||
}
|
||||
|
||||
export function devModeEqual(a: any, b: any): boolean {
|
||||
const isListLikeIterableA = isListLikeIterable(a);
|
||||
const isListLikeIterableB = isListLikeIterable(b);
|
||||
if (isListLikeIterableA && isListLikeIterableB) {
|
||||
return areIterablesEqual(a, b, devModeEqual);
|
||||
} else {
|
||||
const isAObject = a && (typeof a === 'object' || typeof a === 'function');
|
||||
const isBObject = b && (typeof b === 'object' || typeof b === 'function');
|
||||
if (!isListLikeIterableA && isAObject && !isListLikeIterableB && isBObject) {
|
||||
return true;
|
||||
} else {
|
||||
return looseIdentical(a, b);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Type} from '../type';
|
||||
import {Type} from '../interface/type';
|
||||
|
||||
/**
|
||||
* An interface implemented by all Angular type decorators, which allows them to be used as ES7
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
/**
|
||||
* @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
|
||||
*/
|
||||
import './ng_dev_mode';
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
export const EMPTY_OBJ: {} = {};
|
||||
export const EMPTY_ARRAY: any[] = [];
|
||||
|
||||
// freezing the values prevents any code from accidentally inserting new values in
|
||||
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
|
||||
Object.freeze(EMPTY_OBJ);
|
||||
Object.freeze(EMPTY_ARRAY);
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
/**
|
||||
* @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
|
||||
*/
|
||||
|
||||
export const ERROR_TYPE = 'ngType';
|
||||
export const ERROR_DEBUG_CONTEXT = 'ngDebugContext';
|
||||
export const ERROR_ORIGINAL_ERROR = 'ngOriginalError';
|
||||
export const ERROR_LOGGER = 'ngErrorLogger';
|
||||
|
||||
|
||||
export function wrappedError(message: string, originalError: any): Error {
|
||||
const msg =
|
||||
`${message} caused by: ${originalError instanceof Error ? originalError.message: originalError }`;
|
||||
const error = Error(msg);
|
||||
(error as any)[ERROR_ORIGINAL_ERROR] = originalError;
|
||||
return error;
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
/**
|
||||
* @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
|
||||
*/
|
||||
|
||||
import {Type} from '../interface/type';
|
||||
import {getClosureSafeProperty} from './property';
|
||||
import {stringify} from './stringify';
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
export interface ForwardRefFn { (): any; }
|
||||
|
||||
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
|
||||
*/
|
||||
export function forwardRef(forwardRefFn: ForwardRefFn): Type<any> {
|
||||
(<any>forwardRefFn).__forward_ref__ = forwardRef;
|
||||
(<any>forwardRefFn).toString = function() { return stringify(this()); };
|
||||
return (<Type<any>><any>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
|
||||
*/
|
||||
export function resolveForwardRef<T>(type: T): T {
|
||||
const fn: any = type;
|
||||
if (typeof fn === 'function' && fn.hasOwnProperty(__forward_ref__) &&
|
||||
fn.__forward_ref__ === forwardRef) {
|
||||
return fn();
|
||||
} else {
|
||||
return type;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
/**
|
||||
* @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
|
||||
*/
|
||||
|
||||
// TODO(jteplitz602): Load WorkerGlobalScope from lib.webworker.d.ts file #3492
|
||||
declare var WorkerGlobalScope: any /** TODO #9100 */;
|
||||
// CommonJS / Node have global context exposed as "global" variable.
|
||||
// We don't want to include the whole node.d.ts this this compilation unit so we'll just fake
|
||||
// the global "global" var for now.
|
||||
declare var global: any /** TODO #9100 */;
|
||||
const __window = typeof window !== 'undefined' && window;
|
||||
const __self = typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' &&
|
||||
self instanceof WorkerGlobalScope && self;
|
||||
const __global = typeof global !== 'undefined' && global;
|
||||
|
||||
// Check __global first, because in Node tests both __global and __window may be defined and _global
|
||||
// should be __global in that case.
|
||||
const _global: {[name: string]: any} = __global || __window || __self;
|
||||
|
||||
/**
|
||||
* Attention: whenever providing a new value, be sure to add an
|
||||
* entry into the corresponding `....externs.js` file,
|
||||
* so that closure won't use that global for its purposes.
|
||||
*/
|
||||
export {_global as global};
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue