diff --git a/packages/core/BUILD.bazel b/packages/core/BUILD.bazel index d321ada18f..d867710bad 100644 --- a/packages/core/BUILD.bazel +++ b/packages/core/BUILD.bazel @@ -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", diff --git a/packages/core/src/application_ref.ts b/packages/core/src/application_ref.ts index ea3ab5cc2d..b7bbdb923f 100644 --- a/packages/core/src/application_ref.ts +++ b/packages/core/src/application_ref.ts @@ -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; diff --git a/packages/core/src/change_detection/change_detection_util.ts b/packages/core/src/change_detection/change_detection_util.ts index 60b36744d7..da963bb641 100644 --- a/packages/core/src/change_detection/change_detection_util.ts +++ b/packages/core/src/change_detection/change_detection_util.ts @@ -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); diff --git a/packages/core/src/change_detection/differs/default_iterable_differ.ts b/packages/core/src/change_detection/differs/default_iterable_differ.ts index 9cfccfd065..1d909df30b 100644 --- a/packages/core/src/change_detection/differs/default_iterable_differ.ts +++ b/packages/core/src/change_detection/differs/default_iterable_differ.ts @@ -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'; diff --git a/packages/core/src/change_detection/differs/default_keyvalue_differ.ts b/packages/core/src/change_detection/differs/default_keyvalue_differ.ts index 3408c7ad0f..b0d8f404b7 100644 --- a/packages/core/src/change_detection/differs/default_keyvalue_differ.ts +++ b/packages/core/src/change_detection/differs/default_keyvalue_differ.ts @@ -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'; diff --git a/packages/core/src/change_detection/differs/iterable_differs.ts b/packages/core/src/change_detection/differs/iterable_differs.ts index 958ba220b9..4fae01f8d9 100644 --- a/packages/core/src/change_detection/differs/iterable_differs.ts +++ b/packages/core/src/change_detection/differs/iterable_differs.ts @@ -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. * diff --git a/packages/core/src/core.ts b/packages/core/src/core.ts index ee0b21204c..ac379e2bb9 100644 --- a/packages/core/src/core.ts +++ b/packages/core/src/core.ts @@ -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'; diff --git a/packages/core/src/core_private_export.ts b/packages/core/src/core_private_export.ts index 3f2b6a889d..c7413fb0c1 100644 --- a/packages/core/src/core_private_export.ts +++ b/packages/core/src/core_private_export.ts @@ -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'; diff --git a/packages/core/src/core_render3_private_export.ts b/packages/core/src/core_render3_private_export.ts index c93944520c..c80ad949c9 100644 --- a/packages/core/src/core_render3_private_export.ts +++ b/packages/core/src/core_render3_private_export.ts @@ -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, diff --git a/packages/core/src/debug/debug_node.ts b/packages/core/src/debug/debug_node.ts index 54c2c6cd70..de2feda2c9 100644 --- a/packages/core/src/debug/debug_node.ts +++ b/packages/core/src/debug/debug_node.ts @@ -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 { diff --git a/packages/core/src/di.ts b/packages/core/src/di.ts index c1f5989466..bdbf20e97a 100644 --- a/packages/core/src/di.ts +++ b/packages/core/src/di.ts @@ -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'; diff --git a/packages/core/src/di/forward_ref.ts b/packages/core/src/di/forward_ref.ts index ad5b50908f..d1de311b54 100644 --- a/packages/core/src/di/forward_ref.ts +++ b/packages/core/src/di/forward_ref.ts @@ -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'; diff --git a/packages/core/src/di/injectable.ts b/packages/core/src/di/injectable.ts index fd2a5c3f5d..4e55b67dc4 100644 --- a/packages/core/src/di/injectable.ts +++ b/packages/core/src/di/injectable.ts @@ -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. * diff --git a/packages/core/src/di/injection_token.ts b/packages/core/src/di/injection_token.ts index 43ebde5302..3eb1966753 100644 --- a/packages/core/src/di/injection_token.ts +++ b/packages/core/src/di/injection_token.ts @@ -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. diff --git a/packages/core/src/di/injector.ts b/packages/core/src/di/injector.ts index 22a1b8161a..675d2fa78e 100644 --- a/packages/core/src/di/injector.ts +++ b/packages/core/src/di/injector.ts @@ -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(); diff --git a/packages/core/src/di/injector_compatibility.ts b/packages/core/src/di/injector_compatibility.ts index 3eb5b47c3e..c2b1db7116 100644 --- a/packages/core/src/di/injector_compatibility.ts +++ b/packages/core/src/di/injector_compatibility.ts @@ -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. * diff --git a/packages/core/src/di/interface/BUILD.bazel b/packages/core/src/di/interface/BUILD.bazel new file mode 100644 index 0000000000..79b06cb319 --- /dev/null +++ b/packages/core/src/di/interface/BUILD.bazel @@ -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", + ], +) diff --git a/packages/core/src/di/defs.ts b/packages/core/src/di/interface/defs.ts similarity index 93% rename from packages/core/src/di/defs.ts rename to packages/core/src/di/interface/defs.ts index ab82b2fcdd..5f5ba65187 100644 --- a/packages/core/src/di/defs.ts +++ b/packages/core/src/di/interface/defs.ts @@ -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(type: any): InjectableDef|null { */ export function getInjectorDef(type: any): InjectorDef|null { return type && type.hasOwnProperty(NG_INJECTOR_DEF) ? (type as any)[NG_INJECTOR_DEF] : null; -} \ No newline at end of file +} + +export const NG_INJECTABLE_DEF = getClosureSafeProperty({ngInjectableDef: getClosureSafeProperty}); +export const NG_INJECTOR_DEF = getClosureSafeProperty({ngInjectorDef: getClosureSafeProperty}); diff --git a/packages/core/src/di/provider.ts b/packages/core/src/di/interface/provider.ts similarity index 99% rename from packages/core/src/di/provider.ts rename to packages/core/src/di/interface/provider.ts index 7263eebe13..d78314457f 100644 --- a/packages/core/src/di/provider.ts +++ b/packages/core/src/di/interface/provider.ts @@ -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. diff --git a/packages/core/src/di/metadata.ts b/packages/core/src/di/metadata.ts index b3a0e72d8e..ba9a4e5b22 100644 --- a/packages/core/src/di/metadata.ts +++ b/packages/core/src/di/metadata.ts @@ -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. diff --git a/packages/core/src/di/r3_injector.ts b/packages/core/src/di/r3_injector.ts index c80731ded4..b24a5bfed4 100644 --- a/packages/core/src/di/r3_injector.ts +++ b/packages/core/src/di/r3_injector.ts @@ -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'; diff --git a/packages/core/src/di/reflective_errors.ts b/packages/core/src/di/reflective_errors.ts index c88ffa441d..156b40e69e 100644 --- a/packages/core/src/di/reflective_errors.ts +++ b/packages/core/src/di/reflective_errors.ts @@ -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'; diff --git a/packages/core/src/di/reflective_injector.ts b/packages/core/src/di/reflective_injector.ts index aa30e76ed2..8ce87b226f 100644 --- a/packages/core/src/di/reflective_injector.ts +++ b/packages/core/src/di/reflective_injector.ts @@ -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(); diff --git a/packages/core/src/di/reflective_key.ts b/packages/core/src/di/reflective_key.ts index 476f62906f..f7219f60f5 100644 --- a/packages/core/src/di/reflective_key.ts +++ b/packages/core/src/di/reflective_key.ts @@ -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'; diff --git a/packages/core/src/di/reflective_provider.ts b/packages/core/src/di/reflective_provider.ts index 3d4666e82d..f9a8c26e7b 100644 --- a/packages/core/src/di/reflective_provider.ts +++ b/packages/core/src/di/reflective_provider.ts @@ -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'; diff --git a/packages/core/src/di/scope.ts b/packages/core/src/di/scope.ts index e4a3badc71..240ee2af0b 100644 --- a/packages/core/src/di/scope.ts +++ b/packages/core/src/di/scope.ts @@ -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'; diff --git a/packages/core/src/di/util.ts b/packages/core/src/di/util.ts index e8828521d7..de0294beb7 100644 --- a/packages/core/src/di/util.ts +++ b/packages/core/src/di/util.ts @@ -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({provide: String, useValue: getClosureSafeProperty}); diff --git a/packages/core/src/error_handler.ts b/packages/core/src/error_handler.ts index a85273ccac..3dc1442ee0 100644 --- a/packages/core/src/error_handler.ts +++ b/packages/core/src/error_handler.ts @@ -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'; diff --git a/packages/core/src/errors.ts b/packages/core/src/errors.ts index 002dbe903d..74712bc004 100644 --- a/packages/core/src/errors.ts +++ b/packages/core/src/errors.ts @@ -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]; } diff --git a/packages/core/src/interface/BUILD.bazel b/packages/core/src/interface/BUILD.bazel new file mode 100644 index 0000000000..ccc87abff0 --- /dev/null +++ b/packages/core/src/interface/BUILD.bazel @@ -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", +) diff --git a/packages/core/src/type.ts b/packages/core/src/interface/type.ts similarity index 100% rename from packages/core/src/type.ts rename to packages/core/src/interface/type.ts diff --git a/packages/core/src/linker/compiler.ts b/packages/core/src/linker/compiler.ts index f5e8e4e1a8..d0bfaad9da 100644 --- a/packages/core/src/linker/compiler.ts +++ b/packages/core/src/linker/compiler.ts @@ -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'; diff --git a/packages/core/src/linker/component_factory.ts b/packages/core/src/linker/component_factory.ts index 660c45ea79..4ce743ca4a 100644 --- a/packages/core/src/linker/component_factory.ts +++ b/packages/core/src/linker/component_factory.ts @@ -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'; diff --git a/packages/core/src/linker/component_factory_resolver.ts b/packages/core/src/linker/component_factory_resolver.ts index ac1f0abbe4..7d925672a5 100644 --- a/packages/core/src/linker/component_factory_resolver.ts +++ b/packages/core/src/linker/component_factory_resolver.ts @@ -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'; diff --git a/packages/core/src/linker/ng_module_factory.ts b/packages/core/src/linker/ng_module_factory.ts index e307100003..043d450dac 100644 --- a/packages/core/src/linker/ng_module_factory.ts +++ b/packages/core/src/linker/ng_module_factory.ts @@ -7,7 +7,7 @@ */ import {Injector} from '../di/injector'; -import {Type} from '../type'; +import {Type} from '../interface/type'; import {ComponentFactoryResolver} from './component_factory_resolver'; diff --git a/packages/core/src/linker/ng_module_factory_loader.ts b/packages/core/src/linker/ng_module_factory_loader.ts index b6a678e6d6..13e57d8fd3 100644 --- a/packages/core/src/linker/ng_module_factory_loader.ts +++ b/packages/core/src/linker/ng_module_factory_loader.ts @@ -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. * diff --git a/packages/core/src/linker/query_list.ts b/packages/core/src/linker/query_list.ts index 9060cb6dbc..a3aec4360f 100644 --- a/packages/core/src/linker/query_list.ts +++ b/packages/core/src/linker/query_list.ts @@ -9,7 +9,7 @@ import {Observable} from 'rxjs'; import {EventEmitter} from '../event_emitter'; -import {getSymbolIterator} from '../util'; +import {getSymbolIterator} from '../util/symbol'; /** diff --git a/packages/core/src/metadata/di.ts b/packages/core/src/metadata/di.ts index b24498a57c..c22c146119 100644 --- a/packages/core/src/metadata/di.ts +++ b/packages/core/src/metadata/di.ts @@ -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'; /** diff --git a/packages/core/src/metadata/directives.ts b/packages/core/src/metadata/directives.ts index b0ef9538c2..e6ceea61b1 100644 --- a/packages/core/src/metadata/directives.ts +++ b/packages/core/src/metadata/directives.ts @@ -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'; diff --git a/packages/core/src/metadata/ng_module.ts b/packages/core/src/metadata/ng_module.ts index bcad7cdaa6..a171c2a720 100644 --- a/packages/core/src/metadata/ng_module.ts +++ b/packages/core/src/metadata/ng_module.ts @@ -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. * diff --git a/packages/core/src/profile/wtf_impl.ts b/packages/core/src/profile/wtf_impl.ts index 5714aebb30..ca2972d13c 100644 --- a/packages/core/src/profile/wtf_impl.ts +++ b/packages/core/src/profile/wtf_impl.ts @@ -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). diff --git a/packages/core/src/r3_symbols.ts b/packages/core/src/r3_symbols.ts index 7b8c72a138..e040915411 100644 --- a/packages/core/src/r3_symbols.ts +++ b/packages/core/src/r3_symbols.ts @@ -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. diff --git a/packages/core/src/reflection/platform_reflection_capabilities.ts b/packages/core/src/reflection/platform_reflection_capabilities.ts index 0fee368520..6d4ef3384c 100644 --- a/packages/core/src/reflection/platform_reflection_capabilities.ts +++ b/packages/core/src/reflection/platform_reflection_capabilities.ts @@ -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 { diff --git a/packages/core/src/reflection/reflection_capabilities.ts b/packages/core/src/reflection/reflection_capabilities.ts index ca3e397df9..c95112c140 100644 --- a/packages/core/src/reflection/reflection_capabilities.ts +++ b/packages/core/src/reflection/reflection_capabilities.ts @@ -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! */ diff --git a/packages/core/src/reflection/reflector.ts b/packages/core/src/reflection/reflector.ts index 678941f442..6d7b8634f0 100644 --- a/packages/core/src/reflection/reflector.ts +++ b/packages/core/src/reflection/reflector.ts @@ -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'; diff --git a/packages/core/src/render3/assert.ts b/packages/core/src/render3/assert.ts index 3b7bc99403..a05546be2c 100644 --- a/packages/core/src/render3/assert.ts +++ b/packages/core/src/render3/assert.ts @@ -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(actual: T, expected: T, msg: string) { - if (actual != expected) { - throwError(msg); - } -} - -export function assertNotEqual(actual: T, expected: T, msg: string) { - if (actual == expected) { - throwError(msg); - } -} - -export function assertSame(actual: T, expected: T, msg: string) { - if (actual !== expected) { - throwError(msg); - } -} - -export function assertLessThan(actual: T, expected: T, msg: string) { - if (actual >= expected) { - throwError(msg); - } -} - -export function assertGreaterThan(actual: T, expected: T, msg: string) { - if (actual <= expected) { - throwError(msg); - } -} - -export function assertNotDefined(actual: T, msg: string) { - if (actual != null) { - throwError(msg); - } -} - -export function assertDefined(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'); -} diff --git a/packages/core/src/render3/bindings.ts b/packages/core/src/render3/bindings.ts index 88f63a9bd2..8ddbca9da7 100644 --- a/packages/core/src/render3/bindings.ts +++ b/packages/core/src/render3/bindings.ts @@ -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'; diff --git a/packages/core/src/render3/component.ts b/packages/core/src/render3/component.ts index 30daba0a46..e1288eec33 100644 --- a/packages/core/src/render3/component.ts +++ b/packages/core/src/render3/component.ts @@ -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'; diff --git a/packages/core/src/render3/component_ref.ts b/packages/core/src/render3/component_ref.ts index cd571131c1..4bc2479416 100644 --- a/packages/core/src/render3/component_ref.ts +++ b/packages/core/src/render3/component_ref.ts @@ -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'; diff --git a/packages/core/src/render3/context_discovery.ts b/packages/core/src/render3/context_discovery.ts index 651f37cf20..c866403e67 100644 --- a/packages/core/src/render3/context_discovery.ts +++ b/packages/core/src/render3/context_discovery.ts @@ -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'; diff --git a/packages/core/src/render3/definition.ts b/packages/core/src/render3/definition.ts index dc6b0bd9da..a73e0bd9c3 100644 --- a/packages/core/src/render3/definition.ts +++ b/packages/core/src/render3/definition.ts @@ -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'; diff --git a/packages/core/src/render3/di.ts b/packages/core/src/render3/di.ts index 362ae8d2ea..0e409af616 100644 --- a/packages/core/src/render3/di.ts +++ b/packages/core/src/render3/di.ts @@ -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. * diff --git a/packages/core/src/render3/di_setup.ts b/packages/core/src/render3/di_setup.ts index a60f9c8f8b..9db9bcce86 100644 --- a/packages/core/src/render3/di_setup.ts +++ b/packages/core/src/render3/di_setup.ts @@ -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 '.'; diff --git a/packages/core/src/render3/discovery_utils.ts b/packages/core/src/render3/discovery_utils.ts index 08ccd32fc4..e58eb0ef84 100644 --- a/packages/core/src/render3/discovery_utils.ts +++ b/packages/core/src/render3/discovery_utils.ts @@ -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'; diff --git a/packages/core/src/render3/empty.ts b/packages/core/src/render3/empty.ts index 46dc61bdf6..a3870a64cd 100644 --- a/packages/core/src/render3/empty.ts +++ b/packages/core/src/render3/empty.ts @@ -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 diff --git a/packages/core/src/render3/features/inherit_definition_feature.ts b/packages/core/src/render3/features/inherit_definition_feature.ts index 5e2f7cc775..240769393b 100644 --- a/packages/core/src/render3/features/inherit_definition_feature.ts +++ b/packages/core/src/render3/features/inherit_definition_feature.ts @@ -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'; diff --git a/packages/core/src/render3/features/providers_feature.ts b/packages/core/src/render3/features/providers_feature.ts index 7ecca8807f..e95d389c5a 100644 --- a/packages/core/src/render3/features/providers_feature.ts +++ b/packages/core/src/render3/features/providers_feature.ts @@ -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'; diff --git a/packages/core/src/render3/fields.ts b/packages/core/src/render3/fields.ts index 3a187f0856..711166a3dc 100644 --- a/packages/core/src/render3/fields.ts +++ b/packages/core/src/render3/fields.ts @@ -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}); diff --git a/packages/core/src/render3/global_utils.ts b/packages/core/src/render3/global_utils.ts index 7abd6f9189..e52ed79ccd 100644 --- a/packages/core/src/render3/global_utils.ts +++ b/packages/core/src/render3/global_utils.ts @@ -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'; diff --git a/packages/core/src/render3/hooks.ts b/packages/core/src/render3/hooks.ts index c00146b3e9..5cdd95c648 100644 --- a/packages/core/src/render3/hooks.ts +++ b/packages/core/src/render3/hooks.ts @@ -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'; diff --git a/packages/core/src/render3/i18n.ts b/packages/core/src/render3/i18n.ts index 9d27b4b402..4d62e76c99 100644 --- a/packages/core/src/render3/i18n.ts +++ b/packages/core/src/render3/i18n.ts @@ -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'; diff --git a/packages/core/src/render3/instructions.ts b/packages/core/src/render3/instructions.ts index 65fd5b8d89..5aa343c5fb 100644 --- a/packages/core/src/render3/instructions.ts +++ b/packages/core/src/render3/instructions.ts @@ -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'; diff --git a/packages/core/src/render3/interfaces/definition.ts b/packages/core/src/render3/interfaces/definition.ts index 585cf49d69..2fa99bb932 100644 --- a/packages/core/src/render3/interfaces/definition.ts +++ b/packages/core/src/render3/interfaces/definition.ts @@ -7,7 +7,7 @@ */ import {ViewEncapsulation} from '../../core'; -import {Type} from '../../type'; +import {Type} from '../../interface/type'; import {CssSelectorList} from './projection'; diff --git a/packages/core/src/render3/interfaces/injector.ts b/packages/core/src/render3/interfaces/injector.ts index 64723e4243..dc1f660cb2 100644 --- a/packages/core/src/render3/interfaces/injector.ts +++ b/packages/core/src/render3/interfaces/injector.ts @@ -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'; diff --git a/packages/core/src/render3/interfaces/query.ts b/packages/core/src/render3/interfaces/query.ts index c69542a7de..9f8df300c2 100644 --- a/packages/core/src/render3/interfaces/query.ts +++ b/packages/core/src/render3/interfaces/query.ts @@ -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 { /** diff --git a/packages/core/src/render3/interfaces/view.ts b/packages/core/src/render3/interfaces/view.ts index cb95730705..88ab31b085 100644 --- a/packages/core/src/render3/interfaces/view.ts +++ b/packages/core/src/render3/interfaces/view.ts @@ -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. diff --git a/packages/core/src/render3/jit/compiler_facade.ts b/packages/core/src/render3/jit/compiler_facade.ts index 91a4b269c7..01205762c3 100644 --- a/packages/core/src/render3/jit/compiler_facade.ts +++ b/packages/core/src/render3/jit/compiler_facade.ts @@ -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'; diff --git a/packages/core/src/render3/jit/directive.ts b/packages/core/src/render3/jit/directive.ts index bb060abfee..26e4948689 100644 --- a/packages/core/src/render3/jit/directive.ts +++ b/packages/core/src/render3/jit/directive.ts @@ -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'; diff --git a/packages/core/src/render3/jit/environment.ts b/packages/core/src/render3/jit/environment.ts index 6caff12a66..0eccfc4b75 100644 --- a/packages/core/src/render3/jit/environment.ts +++ b/packages/core/src/render3/jit/environment.ts @@ -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'; diff --git a/packages/core/src/render3/jit/injectable.ts b/packages/core/src/render3/jit/injectable.ts index 26f8b823e0..7454f0eed0 100644 --- a/packages/core/src/render3/jit/injectable.ts +++ b/packages/core/src/render3/jit/injectable.ts @@ -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'; diff --git a/packages/core/src/render3/jit/module.ts b/packages/core/src/render3/jit/module.ts index 6585a17bb1..98c37b64f7 100644 --- a/packages/core/src/render3/jit/module.ts +++ b/packages/core/src/render3/jit/module.ts @@ -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'; diff --git a/packages/core/src/render3/jit/pipe.ts b/packages/core/src/render3/jit/pipe.ts index 01ef332667..a03f565db9 100644 --- a/packages/core/src/render3/jit/pipe.ts +++ b/packages/core/src/render3/jit/pipe.ts @@ -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'; diff --git a/packages/core/src/render3/jit/util.ts b/packages/core/src/render3/jit/util.ts index 0bcc8da424..0851486c10 100644 --- a/packages/core/src/render3/jit/util.ts +++ b/packages/core/src/render3/jit/util.ts @@ -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'; diff --git a/packages/core/src/render3/metadata.ts b/packages/core/src/render3/metadata.ts index 19988e1d2f..bfa8e65a64 100644 --- a/packages/core/src/render3/metadata.ts +++ b/packages/core/src/render3/metadata.ts @@ -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 { decorators?: any[]; diff --git a/packages/core/src/render3/ng_module_ref.ts b/packages/core/src/render3/ng_module_ref.ts index ed82ed08bc..d4944bb232 100644 --- a/packages/core/src/render3/ng_module_ref.ts +++ b/packages/core/src/render3/ng_module_ref.ts @@ -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'; diff --git a/packages/core/src/render3/node_assert.ts b/packages/core/src/render3/node_assert.ts index a6c6229e3e..dc3e6198f3 100644 --- a/packages/core/src/render3/node_assert.ts +++ b/packages/core/src/render3/node_assert.ts @@ -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) { diff --git a/packages/core/src/render3/node_selector_matcher.ts b/packages/core/src/render3/node_selector_matcher.ts index ed56726ec4..065233674c 100644 --- a/packages/core/src/render3/node_selector_matcher.ts +++ b/packages/core/src/render3/node_selector_matcher.ts @@ -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'; diff --git a/packages/core/src/render3/players.ts b/packages/core/src/render3/players.ts index b703ac1baa..438b24cb5e 100644 --- a/packages/core/src/render3/players.ts +++ b/packages/core/src/render3/players.ts @@ -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'; diff --git a/packages/core/src/render3/query.ts b/packages/core/src/render3/query.ts index e27f432b64..8189023351 100644 --- a/packages/core/src/render3/query.ts +++ b/packages/core/src/render3/query.ts @@ -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'; diff --git a/packages/core/src/render3/state.ts b/packages/core/src/render3/state.ts index a1d7f296f1..123208d331 100644 --- a/packages/core/src/render3/state.ts +++ b/packages/core/src/render3/state.ts @@ -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'; diff --git a/packages/core/src/render3/styling/class_and_style_bindings.ts b/packages/core/src/render3/styling/class_and_style_bindings.ts index a84d3b7041..7f4fb1465a 100644 --- a/packages/core/src/render3/styling/class_and_style_bindings.ts +++ b/packages/core/src/render3/styling/class_and_style_bindings.ts @@ -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. * diff --git a/packages/core/src/render3/styling/util.ts b/packages/core/src/render3/styling/util.ts index 16eb3d6e20..e2d9ee73c4 100644 --- a/packages/core/src/render3/styling/util.ts +++ b/packages/core/src/render3/styling/util.ts @@ -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'; diff --git a/packages/core/src/render3/util.ts b/packages/core/src/render3/util.ts index 440894bb26..583f30e517 100644 --- a/packages/core/src/render3/util.ts +++ b/packages/core/src/render3/util.ts @@ -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. * diff --git a/packages/core/src/render3/view_engine_compatibility.ts b/packages/core/src/render3/view_engine_compatibility.ts index 700188433f..5baa501305 100644 --- a/packages/core/src/render3/view_engine_compatibility.ts +++ b/packages/core/src/render3/view_engine_compatibility.ts @@ -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'; diff --git a/packages/core/src/sanitization/html_sanitizer.ts b/packages/core/src/sanitization/html_sanitizer.ts index 1606524cea..eb39f31a13 100644 --- a/packages/core/src/sanitization/html_sanitizer.ts +++ b/packages/core/src/sanitization/html_sanitizer.ts @@ -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'; diff --git a/packages/core/src/sanitization/style_sanitizer.ts b/packages/core/src/sanitization/style_sanitizer.ts index aef692fa89..62a6ecbe59 100644 --- a/packages/core/src/sanitization/style_sanitizer.ts +++ b/packages/core/src/sanitization/style_sanitizer.ts @@ -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'; diff --git a/packages/core/src/sanitization/url_sanitizer.ts b/packages/core/src/sanitization/url_sanitizer.ts index 205443d91b..9cd29e1bb5 100644 --- a/packages/core/src/sanitization/url_sanitizer.ts +++ b/packages/core/src/sanitization/url_sanitizer.ts @@ -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. diff --git a/packages/core/src/testability/testability.ts b/packages/core/src/testability/testability.ts index 229ca4f484..e555300bfb 100644 --- a/packages/core/src/testability/testability.ts +++ b/packages/core/src/testability/testability.ts @@ -7,7 +7,7 @@ */ import {Injectable} from '../di'; -import {scheduleMicroTask} from '../util'; +import {scheduleMicroTask} from '../util/microtask'; import {NgZone} from '../zone/ng_zone'; /** diff --git a/packages/core/src/util.ts b/packages/core/src/util.ts deleted file mode 100644 index 07a25685f8..0000000000 --- a/packages/core/src/util.ts +++ /dev/null @@ -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 = 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}; -} \ No newline at end of file diff --git a/packages/core/src/util/BUILD.bazel b/packages/core/src/util/BUILD.bazel new file mode 100644 index 0000000000..b1ffe3cc0d --- /dev/null +++ b/packages/core/src/util/BUILD.bazel @@ -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", + ], +) diff --git a/packages/core/src/util/WrappedValue.ts b/packages/core/src/util/WrappedValue.ts new file mode 100644 index 0000000000..48e5e3f76b --- /dev/null +++ b/packages/core/src/util/WrappedValue.ts @@ -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; } +} diff --git a/packages/core/src/util/assert.ts b/packages/core/src/util/assert.ts new file mode 100644 index 0000000000..16a2466040 --- /dev/null +++ b/packages/core/src/util/assert.ts @@ -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(actual: T, expected: T, msg: string) { + if (actual != expected) { + throwError(msg); + } +} + +export function assertNotEqual(actual: T, expected: T, msg: string) { + if (actual == expected) { + throwError(msg); + } +} + +export function assertSame(actual: T, expected: T, msg: string) { + if (actual !== expected) { + throwError(msg); + } +} + +export function assertLessThan(actual: T, expected: T, msg: string) { + if (actual >= expected) { + throwError(msg); + } +} + +export function assertGreaterThan(actual: T, expected: T, msg: string) { + if (actual <= expected) { + throwError(msg); + } +} + +export function assertNotDefined(actual: T, msg: string) { + if (actual != null) { + throwError(msg); + } +} + +export function assertDefined(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'); +} diff --git a/packages/core/src/util/closure.ts b/packages/core/src/util/closure.ts new file mode 100644 index 0000000000..de36d31b0d --- /dev/null +++ b/packages/core/src/util/closure.ts @@ -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}; +} \ No newline at end of file diff --git a/packages/core/src/util/comparison.ts b/packages/core/src/util/comparison.ts new file mode 100644 index 0000000000..e726d8fa8f --- /dev/null +++ b/packages/core/src/util/comparison.ts @@ -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); + } + } +} diff --git a/packages/core/src/util/decorators.ts b/packages/core/src/util/decorators.ts index 506579f24b..907f4b9695 100644 --- a/packages/core/src/util/decorators.ts +++ b/packages/core/src/util/decorators.ts @@ -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 diff --git a/packages/core/src/util/empty.ts b/packages/core/src/util/empty.ts new file mode 100644 index 0000000000..46dc61bdf6 --- /dev/null +++ b/packages/core/src/util/empty.ts @@ -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); +} diff --git a/packages/core/src/util/errors.ts b/packages/core/src/util/errors.ts new file mode 100644 index 0000000000..7f895c4420 --- /dev/null +++ b/packages/core/src/util/errors.ts @@ -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; +} diff --git a/packages/core/src/util/forward_ref.ts b/packages/core/src/util/forward_ref.ts new file mode 100644 index 0000000000..89e53dd337 --- /dev/null +++ b/packages/core/src/util/forward_ref.ts @@ -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 { + (forwardRefFn).__forward_ref__ = forwardRef; + (forwardRefFn).toString = function() { return stringify(this()); }; + return (>forwardRefFn); +} + +/** + * Lazily retrieves the reference value from a forwardRef. + * + * Acts as the identity function when given a non-forward-ref value. + * + * @usageNotes + * ### Example + * + * {@example core/di/ts/forward_ref/forward_ref_spec.ts region='resolve_forward_ref'} + * + * @see `forwardRef` + * @publicApi + */ +export function resolveForwardRef(type: T): T { + const fn: any = type; + if (typeof fn === 'function' && fn.hasOwnProperty(__forward_ref__) && + fn.__forward_ref__ === forwardRef) { + return fn(); + } else { + return type; + } +} diff --git a/packages/core/src/util/global.ts b/packages/core/src/util/global.ts new file mode 100644 index 0000000000..15674cc123 --- /dev/null +++ b/packages/core/src/util/global.ts @@ -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}; diff --git a/packages/core/src/is_dev_mode.ts b/packages/core/src/util/is_dev_mode.ts similarity index 100% rename from packages/core/src/is_dev_mode.ts rename to packages/core/src/util/is_dev_mode.ts diff --git a/packages/core/src/util/iterable.ts b/packages/core/src/util/iterable.ts new file mode 100644 index 0000000000..4f85e0cbdc --- /dev/null +++ b/packages/core/src/util/iterable.ts @@ -0,0 +1,49 @@ +/** + * @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 {getSymbolIterator} from './symbol'; + + +export function isListLikeIterable(obj: any): boolean { + if (!isJsObject(obj)) return false; + return Array.isArray(obj) || + (!(obj instanceof Map) && // JS Map are iterables but return entries as [k, v] + getSymbolIterator() in obj); // JS Iterable have a Symbol.iterator prop +} + +export function areIterablesEqual( + a: any, b: any, comparator: (a: any, b: any) => boolean): boolean { + const iterator1 = a[getSymbolIterator()](); + const iterator2 = b[getSymbolIterator()](); + + while (true) { + const item1 = iterator1.next(); + const item2 = iterator2.next(); + if (item1.done && item2.done) return true; + if (item1.done || item2.done) return false; + if (!comparator(item1.value, item2.value)) return false; + } +} + +export function iterateListLike(obj: any, fn: (p: any) => any) { + if (Array.isArray(obj)) { + for (let i = 0; i < obj.length; i++) { + fn(obj[i]); + } + } else { + const iterator = obj[getSymbolIterator()](); + let item: any; + while (!((item = iterator.next()).done)) { + fn(item.value); + } + } +} + +export function isJsObject(o: any): boolean { + return o !== null && (typeof o === 'function' || typeof o === 'object'); +} diff --git a/packages/core/src/util/microtask.ts b/packages/core/src/util/microtask.ts new file mode 100644 index 0000000000..40edbac49d --- /dev/null +++ b/packages/core/src/util/microtask.ts @@ -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 + */ + + +const promise: Promise = Promise.resolve(0); + +declare const Zone: any; + +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); + } +} diff --git a/packages/core/src/render3/ng_dev_mode.ts b/packages/core/src/util/ng_dev_mode.ts similarity index 100% rename from packages/core/src/render3/ng_dev_mode.ts rename to packages/core/src/util/ng_dev_mode.ts diff --git a/packages/core/src/util/stringify.ts b/packages/core/src/util/stringify.ts new file mode 100644 index 0000000000..0af107a1f4 --- /dev/null +++ b/packages/core/src/util/stringify.ts @@ -0,0 +1,38 @@ +/** + * @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 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); +} diff --git a/packages/core/src/util/symbol.ts b/packages/core/src/util/symbol.ts new file mode 100644 index 0000000000..71dc7edec7 --- /dev/null +++ b/packages/core/src/util/symbol.ts @@ -0,0 +1,32 @@ +/** + * @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 {global as _global} from './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; +} diff --git a/packages/core/src/view/entrypoint.ts b/packages/core/src/view/entrypoint.ts index ff2933baf1..7786cae734 100644 --- a/packages/core/src/view/entrypoint.ts +++ b/packages/core/src/view/entrypoint.ts @@ -7,9 +7,9 @@ */ import {Injector} from '../di/injector'; +import {Type} from '../interface/type'; import {ComponentFactory} from '../linker/component_factory'; import {NgModuleFactory, NgModuleRef} from '../linker/ng_module_factory'; -import {Type} from '../type'; import {initServicesIfNeeded} from './services'; import {NgModuleDefinition, NgModuleDefinitionFactory, NgModuleProviderDef, ProviderOverride, Services, ViewDefinition} from './types'; diff --git a/packages/core/src/view/errors.ts b/packages/core/src/view/errors.ts index 96df939fdd..d7ded67a01 100644 --- a/packages/core/src/view/errors.ts +++ b/packages/core/src/view/errors.ts @@ -6,8 +6,10 @@ * found in the LICENSE file at https://angular.io/license */ -import {ERROR_DEBUG_CONTEXT, ERROR_LOGGER, getDebugContext} from '../errors'; -import {DebugContext, ViewState} from './types'; +import {getDebugContext} from '../errors'; +import {ERROR_DEBUG_CONTEXT, ERROR_LOGGER} from '../util/errors'; + +import {DebugContext} from './types'; export function expressionChangedAfterItHasBeenCheckedError( context: DebugContext, oldValue: any, currValue: any, isFirstCheck: boolean): Error { diff --git a/packages/core/src/view/ng_module.ts b/packages/core/src/view/ng_module.ts index 50c3c6022b..cfd5462e92 100644 --- a/packages/core/src/view/ng_module.ts +++ b/packages/core/src/view/ng_module.ts @@ -6,13 +6,13 @@ * found in the LICENSE file at https://angular.io/license */ -import {InjectableDef, getInjectableDef} from '../di/defs'; import {resolveForwardRef} from '../di/forward_ref'; import {INJECTOR, Injector} from '../di/injector'; import {setCurrentInjector} from '../di/injector_compatibility'; +import {InjectableDef, getInjectableDef} from '../di/interface/defs'; import {APP_ROOT} from '../di/scope'; import {NgModuleRef} from '../linker/ng_module_factory'; -import {stringify} from '../util'; +import {stringify} from '../util/stringify'; import {DepDef, DepFlags, NgModuleData, NgModuleDefinition, NgModuleProviderDef, NodeFlags} from './types'; import {splitDepsDsl, tokenKey} from './util'; diff --git a/packages/core/src/view/provider.ts b/packages/core/src/view/provider.ts index 83e046ce53..0774765dca 100644 --- a/packages/core/src/view/provider.ts +++ b/packages/core/src/view/provider.ts @@ -12,8 +12,8 @@ import {ElementRef} from '../linker/element_ref'; import {TemplateRef} from '../linker/template_ref'; import {ViewContainerRef} from '../linker/view_container_ref'; import {Renderer as RendererV1, Renderer2} from '../render/api'; -import {stringify} from '../util'; import {isObservable} from '../util/lang'; +import {stringify} from '../util/stringify'; import {createChangeDetectorRef, createInjector, createRendererV1} from './refs'; import {BindingDef, BindingFlags, DepDef, DepFlags, NodeDef, NodeFlags, OutputDef, OutputType, ProviderData, QueryValueType, Services, ViewData, ViewFlags, ViewState, asElementData, asProviderData, shouldCallLifecycleInitHook} from './types'; diff --git a/packages/core/src/view/refs.ts b/packages/core/src/view/refs.ts index 0203fdd98a..4dcc5e2f78 100644 --- a/packages/core/src/view/refs.ts +++ b/packages/core/src/view/refs.ts @@ -10,6 +10,7 @@ import {ApplicationRef} from '../application_ref'; import {ChangeDetectorRef} from '../change_detection/change_detection'; import {Injector} from '../di/injector'; import {InjectFlags} from '../di/injector_compatibility'; +import {Type} from '../interface/type'; import {ComponentFactory, ComponentRef} from '../linker/component_factory'; import {ComponentFactoryBoundToModule, ComponentFactoryResolver} from '../linker/component_factory_resolver'; import {ElementRef} from '../linker/element_ref'; @@ -18,8 +19,7 @@ import {TemplateRef} from '../linker/template_ref'; import {ViewContainerRef} from '../linker/view_container_ref'; import {EmbeddedViewRef, InternalViewRef, ViewRef} from '../linker/view_ref'; import {Renderer as RendererV1, Renderer2} from '../render/api'; -import {Type} from '../type'; -import {stringify} from '../util'; +import {stringify} from '../util/stringify'; import {VERSION} from '../version'; import {callNgModuleLifecycle, initNgModule, resolveNgModuleDep} from './ng_module'; diff --git a/packages/core/src/view/services.ts b/packages/core/src/view/services.ts index 53e93f6b6d..7906b696c0 100644 --- a/packages/core/src/view/services.ts +++ b/packages/core/src/view/services.ts @@ -8,16 +8,17 @@ import {DebugElement__PRE_R3__, DebugNode__PRE_R3__, EventListener, getDebugNode, indexDebugNode, removeDebugNodeFromIndex} from '../debug/debug_node'; import {Injector} from '../di'; -import {InjectableDef, getInjectableDef} from '../di/defs'; import {InjectableType} from '../di/injectable'; +import {InjectableDef, getInjectableDef} from '../di/interface/defs'; import {ErrorHandler} from '../error_handler'; -import {isDevMode} from '../is_dev_mode'; +import {Type} from '../interface/type'; import {ComponentFactory} from '../linker/component_factory'; import {NgModuleRef} from '../linker/ng_module_factory'; import {Renderer2, RendererFactory2, RendererStyleFlags2, RendererType2} from '../render/api'; import {Sanitizer} from '../sanitization/security'; -import {Type} from '../type'; +import {isDevMode} from '../util/is_dev_mode'; import {normalizeDebugBindingName, normalizeDebugBindingValue} from '../util/ng_reflect'; + import {isViewDebugError, viewDestroyedError, viewWrappedDebugError} from './errors'; import {resolveDep} from './provider'; import {dirtyParentQueries, getQueryValue} from './query'; diff --git a/packages/core/src/view/types.ts b/packages/core/src/view/types.ts index 870a7df872..0f43c13274 100644 --- a/packages/core/src/view/types.ts +++ b/packages/core/src/view/types.ts @@ -8,6 +8,7 @@ import {Injector} from '../di'; import {ErrorHandler} from '../error_handler'; +import {Type} from '../interface/type'; import {ComponentFactory} from '../linker/component_factory'; import {NgModuleRef} from '../linker/ng_module_factory'; import {QueryList} from '../linker/query_list'; @@ -15,7 +16,7 @@ import {TemplateRef} from '../linker/template_ref'; import {ViewContainerRef} from '../linker/view_container_ref'; import {Renderer2, RendererFactory2, RendererType2} from '../render/api'; import {Sanitizer, SecurityContext} from '../sanitization/security'; -import {Type} from '../type'; + // ------------------------------------- diff --git a/packages/core/src/view/util.ts b/packages/core/src/view/util.ts index eade00199e..aaeec68753 100644 --- a/packages/core/src/view/util.ts +++ b/packages/core/src/view/util.ts @@ -10,7 +10,8 @@ import {WrappedValue, devModeEqual} from '../change_detection/change_detection'; import {SOURCE} from '../di/injector'; import {ViewEncapsulation} from '../metadata/view'; import {RendererType2} from '../render/api'; -import {looseIdentical, stringify} from '../util'; +import {looseIdentical} from '../util/comparison'; +import {stringify} from '../util/stringify'; import {expressionChangedAfterItHasBeenCheckedError} from './errors'; import {BindingDef, BindingFlags, Definition, DefinitionFactory, DepDef, DepFlags, ElementData, NodeDef, NodeFlags, QueryValueType, Services, ViewData, ViewDefinition, ViewDefinitionFactory, ViewFlags, ViewState, asElementData, asTextData} from './types'; diff --git a/packages/core/test/BUILD.bazel b/packages/core/test/BUILD.bazel index 8d066f005b..6a5e4a5fcc 100644 --- a/packages/core/test/BUILD.bazel +++ b/packages/core/test/BUILD.bazel @@ -19,6 +19,9 @@ ts_library( "//packages/compiler", "//packages/compiler/testing", "//packages/core", + "//packages/core/src/di/interface", + "//packages/core/src/interface", + "//packages/core/src/util", "//packages/core/testing", "//packages/platform-browser", "//packages/platform-browser-dynamic", diff --git a/packages/core/test/bundling/todo/bundle.golden_symbols.json b/packages/core/test/bundling/todo/bundle.golden_symbols.json index 3cc4e94ef6..c1e32f2570 100644 --- a/packages/core/test/bundling/todo/bundle.golden_symbols.json +++ b/packages/core/test/bundling/todo/bundle.golden_symbols.json @@ -906,13 +906,13 @@ "name": "isFactory" }, { - "name": "isJsObject" + "name": "isJsObject$1" }, { "name": "isLContainer" }, { - "name": "isListLikeIterable" + "name": "isListLikeIterable$1" }, { "name": "isNodeMatchingSelector" @@ -933,7 +933,7 @@ "name": "isStylingContext" }, { - "name": "iterateListLike" + "name": "iterateListLike$1" }, { "name": "leaveView" diff --git a/packages/core/test/change_detection/iterable.ts b/packages/core/test/change_detection/iterable.ts index b78de13bf9..97e2401bcd 100644 --- a/packages/core/test/change_detection/iterable.ts +++ b/packages/core/test/change_detection/iterable.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {getSymbolIterator} from '@angular/core/src/util'; +import {getSymbolIterator} from '@angular/core/src/util/symbol'; export class TestIterable { list: number[]; diff --git a/packages/core/test/change_detection/util.ts b/packages/core/test/change_detection/util.ts index 2a6b28f8d5..97d68f52dc 100644 --- a/packages/core/test/change_detection/util.ts +++ b/packages/core/test/change_detection/util.ts @@ -9,7 +9,8 @@ import {IterableChangeRecord, IterableChanges} from '@angular/core/src/change_detection/differs/iterable_differs'; import {KeyValueChangeRecord, KeyValueChanges} from '@angular/core/src/change_detection/differs/keyvalue_differs'; -import {looseIdentical, stringify} from '../../src/util'; +import {looseIdentical} from '../../src/util/comparison'; +import {stringify} from '../../src/util/stringify'; export function iterableDifferToString(iterableChanges: IterableChanges) { const collection: string[] = []; diff --git a/packages/core/test/di/r3_injector_spec.ts b/packages/core/test/di/r3_injector_spec.ts index df1311a75c..ad9eebad58 100644 --- a/packages/core/test/di/r3_injector_spec.ts +++ b/packages/core/test/di/r3_injector_spec.ts @@ -6,10 +6,10 @@ * found in the LICENSE file at https://angular.io/license */ -import {defineInjectable, defineInjector} from '../../src/di/defs'; import {InjectionToken} from '../../src/di/injection_token'; import {INJECTOR, Injector} from '../../src/di/injector'; import {inject} from '../../src/di/injector_compatibility'; +import {defineInjectable, defineInjector} from '../../src/di/interface/defs'; import {R3Injector, createInjector} from '../../src/di/r3_injector'; describe('InjectorDef-based createInjector()', () => { diff --git a/packages/core/test/di/reflective_injector_spec.ts b/packages/core/test/di/reflective_injector_spec.ts index 28bfc0aca7..139f8d1eab 100644 --- a/packages/core/test/di/reflective_injector_spec.ts +++ b/packages/core/test/di/reflective_injector_spec.ts @@ -11,7 +11,7 @@ import {ReflectiveInjector_} from '@angular/core/src/di/reflective_injector'; import {ResolvedReflectiveProvider_} from '@angular/core/src/di/reflective_provider'; import {getOriginalError} from '@angular/core/src/errors'; import {expect} from '@angular/platform-browser/testing/src/matchers'; -import {stringify} from '../../src/util'; +import {stringify} from '../../src/util/stringify'; class Engine {} diff --git a/packages/core/test/di/static_injector_spec.ts b/packages/core/test/di/static_injector_spec.ts index c00c8fa97c..1ae7386d7b 100644 --- a/packages/core/test/di/static_injector_spec.ts +++ b/packages/core/test/di/static_injector_spec.ts @@ -10,7 +10,7 @@ import {Inject, InjectionToken, Injector, Optional, ReflectiveKey, Self, SkipSel import {getOriginalError} from '@angular/core/src/errors'; import {expect} from '@angular/platform-browser/testing/src/matchers'; -import {stringify} from '../../src/util'; +import {stringify} from '../../src/util/stringify'; class Engine { static PROVIDER = {provide: Engine, useClass: Engine, deps: []}; diff --git a/packages/core/test/error_handler_spec.ts b/packages/core/test/error_handler_spec.ts index 69d4249544..682e7b582d 100644 --- a/packages/core/test/error_handler_spec.ts +++ b/packages/core/test/error_handler_spec.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {ERROR_DEBUG_CONTEXT, ERROR_LOGGER, ERROR_TYPE} from '@angular/core/src/errors'; +import {ERROR_DEBUG_CONTEXT, ERROR_LOGGER, ERROR_TYPE} from '@angular/core/src/util/errors'; import {ErrorHandler, wrappedError} from '../src/error_handler'; diff --git a/packages/core/test/linker/integration_spec.ts b/packages/core/test/linker/integration_spec.ts index ade34f8038..ae444e8fa9 100644 --- a/packages/core/test/linker/integration_spec.ts +++ b/packages/core/test/linker/integration_spec.ts @@ -24,7 +24,7 @@ import {dispatchEvent, el} from '@angular/platform-browser/testing/src/browser_u import {expect} from '@angular/platform-browser/testing/src/matchers'; import {fixmeIvy, modifiedInIvy, obsoleteInIvy} from '@angular/private/testing'; -import {stringify} from '../../src/util'; +import {stringify} from '../../src/util/stringify'; const ANCHOR_ELEMENT = new InjectionToken('AnchorElement'); diff --git a/packages/core/test/linker/ng_module_integration_spec.ts b/packages/core/test/linker/ng_module_integration_spec.ts index 239f415a99..36c52354dc 100644 --- a/packages/core/test/linker/ng_module_integration_spec.ts +++ b/packages/core/test/linker/ng_module_integration_spec.ts @@ -8,7 +8,7 @@ import {ANALYZE_FOR_ENTRY_COMPONENTS, CUSTOM_ELEMENTS_SCHEMA, Compiler, Component, ComponentFactoryResolver, Directive, HostBinding, Inject, Injectable, InjectionToken, Injector, Input, NgModule, NgModuleRef, Optional, Pipe, Provider, Self, Type, forwardRef, getModuleFactory, ɵivyEnabled as ivyEnabled} from '@angular/core'; import {Console} from '@angular/core/src/console'; -import {InjectableDef, defineInjectable} from '@angular/core/src/di/defs'; +import {InjectableDef, defineInjectable} from '@angular/core/src/di/interface/defs'; import {getNgModuleDef} from '@angular/core/src/render3/definition'; import {NgModuleData} from '@angular/core/src/view/types'; import {tokenKey} from '@angular/core/src/view/util'; @@ -18,7 +18,7 @@ import {fixmeIvy, modifiedInIvy, obsoleteInIvy} from '@angular/private/testing'; import {InternalNgModuleRef, NgModuleFactory} from '../../src/linker/ng_module_factory'; import {clearModulesForTest} from '../../src/linker/ng_module_factory_loader'; -import {stringify} from '../../src/util'; +import {stringify} from '../../src/util/stringify'; class Engine {} diff --git a/packages/core/test/linker/query_integration_spec.ts b/packages/core/test/linker/query_integration_spec.ts index e3d554d4a5..96919cef56 100644 --- a/packages/core/test/linker/query_integration_spec.ts +++ b/packages/core/test/linker/query_integration_spec.ts @@ -12,7 +12,7 @@ import {expect} from '@angular/platform-browser/testing/src/matchers'; import {fixmeIvy, ivyEnabled, modifiedInIvy} from '@angular/private/testing'; import {Subject} from 'rxjs'; -import {stringify} from '../../src/util'; +import {stringify} from '../../src/util/stringify'; describe('Query API', () => { diff --git a/packages/core/test/linker/system_ng_module_factory_loader_spec.ts b/packages/core/test/linker/system_ng_module_factory_loader_spec.ts index fbbaa0f591..ceb031c251 100644 --- a/packages/core/test/linker/system_ng_module_factory_loader_spec.ts +++ b/packages/core/test/linker/system_ng_module_factory_loader_spec.ts @@ -7,7 +7,7 @@ */ import {Compiler, SystemJsNgModuleLoader} from '@angular/core'; -import {global} from '@angular/core/src/util'; +import {global} from '@angular/core/src/util/global'; import {async} from '@angular/core/testing'; import {afterEach, beforeEach, describe, expect, it} from '@angular/core/testing/src/testing_internal'; diff --git a/packages/core/test/reflection/reflector_spec.ts b/packages/core/test/reflection/reflector_spec.ts index a8c2080e39..71f45b55eb 100644 --- a/packages/core/test/reflection/reflector_spec.ts +++ b/packages/core/test/reflection/reflector_spec.ts @@ -8,8 +8,8 @@ import {Reflector} from '@angular/core/src/reflection/reflection'; import {DELEGATE_CTOR, INHERITED_CLASS, INHERITED_CLASS_WITH_CTOR, ReflectionCapabilities} from '@angular/core/src/reflection/reflection_capabilities'; -import {global} from '@angular/core/src/util'; import {makeDecorator, makeParamDecorator, makePropDecorator} from '@angular/core/src/util/decorators'; +import {global} from '@angular/core/src/util/global'; interface ClassDecoratorFactory { (data: ClassDecorator): any; diff --git a/packages/core/test/render3/BUILD.bazel b/packages/core/test/render3/BUILD.bazel index 87237e1bb8..f57c278e75 100644 --- a/packages/core/test/render3/BUILD.bazel +++ b/packages/core/test/render3/BUILD.bazel @@ -22,6 +22,9 @@ ts_library( "//packages/common", "//packages/compiler", "//packages/core", + "//packages/core/src/di/interface", + "//packages/core/src/interface", + "//packages/core/src/util", "//packages/core/testing", "//packages/platform-browser", "//packages/platform-browser/animations", diff --git a/packages/core/test/render3/global_utils_spec.ts b/packages/core/test/render3/global_utils_spec.ts index 5e8d5ebf69..fe0c35994e 100644 --- a/packages/core/test/render3/global_utils_spec.ts +++ b/packages/core/test/render3/global_utils_spec.ts @@ -10,7 +10,7 @@ import {ɵmarkDirty as markDirty} from '@angular/core'; import {getComponent, getContext, getDirectives, getHostElement, getInjector, getListeners, getRootComponents, getViewComponent} from '../../src/render3/discovery_utils'; import {GLOBAL_PUBLISH_EXPANDO_KEY, GlobalDevModeContainer, publishDefaultGlobalUtils, publishGlobalUtil} from '../../src/render3/global_utils'; import {getPlayers} from '../../src/render3/players'; -import {global} from '../../src/util'; +import {global} from '../../src/util/global'; describe('global utils', () => { describe('publishGlobalUtil', () => { diff --git a/packages/core/test/render3/ivy/BUILD.bazel b/packages/core/test/render3/ivy/BUILD.bazel index 9f89287a01..efd2b58d8e 100644 --- a/packages/core/test/render3/ivy/BUILD.bazel +++ b/packages/core/test/render3/ivy/BUILD.bazel @@ -9,6 +9,7 @@ ts_library( deps = [ "//packages:types", "//packages/core", + "//packages/core/src/di/interface", ], ) diff --git a/packages/core/test/render3/ivy/jit_spec.ts b/packages/core/test/render3/ivy/jit_spec.ts index fe6f0fcff6..5978a05fab 100644 --- a/packages/core/test/render3/ivy/jit_spec.ts +++ b/packages/core/test/render3/ivy/jit_spec.ts @@ -8,9 +8,9 @@ import 'reflect-metadata'; import {ElementRef, QueryList} from '@angular/core'; -import {InjectorDef, defineInjectable} from '@angular/core/src/di/defs'; import {Injectable} from '@angular/core/src/di/injectable'; import {inject, setCurrentInjector} from '@angular/core/src/di/injector_compatibility'; +import {InjectorDef, defineInjectable} from '@angular/core/src/di/interface/defs'; import {ivyEnabled} from '@angular/core/src/ivy_switch'; import {ContentChild, ContentChildren, ViewChild, ViewChildren} from '@angular/core/src/metadata/di'; import {Component, Directive, HostBinding, HostListener, Input, Output, Pipe} from '@angular/core/src/metadata/directives'; diff --git a/packages/core/test/render3/metadata_spec.ts b/packages/core/test/render3/metadata_spec.ts index 26494a6e37..7a124d9ee1 100644 --- a/packages/core/test/render3/metadata_spec.ts +++ b/packages/core/test/render3/metadata_spec.ts @@ -6,8 +6,8 @@ * found in the LICENSE file at https://angular.io/license */ +import {Type} from '../../src/interface/type'; import {setClassMetadata} from '../../src/render3/metadata'; -import {Type} from '../../src/type'; interface Decorator { type: any; diff --git a/packages/core/test/render3/perfCounter_spec.ts b/packages/core/test/render3/perfCounter_spec.ts index b98b54ff3b..48f42784d0 100644 --- a/packages/core/test/render3/perfCounter_spec.ts +++ b/packages/core/test/render3/perfCounter_spec.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {ngDevModeResetPerfCounters} from '../../src/render3/ng_dev_mode'; +import {ngDevModeResetPerfCounters} from '../../src/util/ng_dev_mode'; beforeEach(ngDevModeResetPerfCounters); beforeEach(() => { diff --git a/packages/core/test/render3/render_util.ts b/packages/core/test/render3/render_util.ts index 64304962c3..ecc3a52c80 100644 --- a/packages/core/test/render3/render_util.ts +++ b/packages/core/test/render3/render_util.ts @@ -7,7 +7,7 @@ */ import {ChangeDetectorRef} from '@angular/core/src/change_detection/change_detector_ref'; -import {Provider} from '@angular/core/src/di/provider'; +import {Provider} from '@angular/core/src/di/interface/provider'; import {ElementRef} from '@angular/core/src/linker/element_ref'; import {TemplateRef} from '@angular/core/src/linker/template_ref'; import {ViewContainerRef} from '@angular/core/src/linker/view_container_ref'; @@ -17,6 +17,7 @@ import {stringifyElement} from '@angular/platform-browser/testing/src/browser_ut import {SWITCH_CHANGE_DETECTOR_REF_FACTORY__POST_R3__ as R3_CHANGE_DETECTOR_REF_FACTORY} from '../../src/change_detection/change_detector_ref'; import {Injector, SWITCH_INJECTOR_FACTORY__POST_R3__ as R3_INJECTOR_FACTORY} from '../../src/di/injector'; +import {Type} from '../../src/interface/type'; import {SWITCH_ELEMENT_REF_FACTORY__POST_R3__ as R3_ELEMENT_REF_FACTORY} from '../../src/linker/element_ref'; import {SWITCH_TEMPLATE_REF_FACTORY__POST_R3__ as R3_TEMPLATE_REF_FACTORY} from '../../src/linker/template_ref'; import {SWITCH_VIEW_CONTAINER_REF_FACTORY__POST_R3__ as R3_VIEW_CONTAINER_REF_FACTORY} from '../../src/linker/view_container_ref'; @@ -34,7 +35,6 @@ import {HEADER_OFFSET, LView} from '../../src/render3/interfaces/view'; import {destroyLView} from '../../src/render3/node_manipulation'; import {getRootView} from '../../src/render3/util'; import {Sanitizer} from '../../src/sanitization/security'; -import {Type} from '../../src/type'; import {getRendererFactory2} from './imported_renderer2'; diff --git a/packages/core/test/testability/testability_spec.ts b/packages/core/test/testability/testability_spec.ts index 6acd7884f3..7eb7a09303 100644 --- a/packages/core/test/testability/testability_spec.ts +++ b/packages/core/test/testability/testability_spec.ts @@ -13,7 +13,7 @@ import {NgZone} from '@angular/core/src/zone/ng_zone'; import {async, fakeAsync, flush, tick} from '@angular/core/testing'; import {SpyObject, beforeEach, describe, expect, it} from '@angular/core/testing/src/testing_internal'; -import {scheduleMicroTask} from '../../src/util'; +import {scheduleMicroTask} from '../../src/util/microtask'; // Schedules a microtasks (using a resolved promise .then()) function microTask(fn: Function): void { diff --git a/packages/core/test/util_spec.ts b/packages/core/test/util_spec.ts index cd11cbd9ed..2c31deb7f1 100644 --- a/packages/core/test/util_spec.ts +++ b/packages/core/test/util_spec.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {stringify} from '../src/util'; +import {stringify} from '../src/util/stringify'; { describe('stringify', () => { diff --git a/packages/core/test/view/BUILD.bazel b/packages/core/test/view/BUILD.bazel index 31f50eb1cf..e4b7fb7200 100644 --- a/packages/core/test/view/BUILD.bazel +++ b/packages/core/test/view/BUILD.bazel @@ -10,6 +10,9 @@ ts_library( ), deps = [ "//packages/core", + "//packages/core/src/di/interface", + "//packages/core/src/interface", + "//packages/core/src/util", "//packages/core/testing", "//packages/platform-browser", "//packages/private/testing", diff --git a/packages/core/test/view/ng_module_spec.ts b/packages/core/test/view/ng_module_spec.ts index 53f8a464f7..6b3cbc7687 100644 --- a/packages/core/test/view/ng_module_spec.ts +++ b/packages/core/test/view/ng_module_spec.ts @@ -7,14 +7,14 @@ */ import {NgModuleRef} from '@angular/core'; -import {InjectableDef, defineInjectable} from '@angular/core/src/di/defs'; import {INJECTOR, Injector} from '@angular/core/src/di/injector'; import {InjectFlags, inject} from '@angular/core/src/di/injector_compatibility'; -import {makePropDecorator} from '@angular/core/src/util/decorators'; +import {InjectableDef, defineInjectable} from '@angular/core/src/di/interface/defs'; import {NgModuleDefinition, NgModuleProviderDef, NodeFlags} from '@angular/core/src/view'; -import {moduleDef, moduleProvideDef, resolveNgModuleDep} from '@angular/core/src/view/ng_module'; +import {moduleDef} from '@angular/core/src/view/ng_module'; import {createNgModuleRef} from '@angular/core/src/view/refs'; import {tokenKey} from '@angular/core/src/view/util'; + import {APP_ROOT} from '../../src/di/scope'; class Foo {} diff --git a/packages/core/test/zone/ng_zone_spec.ts b/packages/core/test/zone/ng_zone_spec.ts index 10307a5bbd..5ed7c61ea9 100644 --- a/packages/core/test/zone/ng_zone_spec.ts +++ b/packages/core/test/zone/ng_zone_spec.ts @@ -10,7 +10,7 @@ import {EventEmitter, NgZone} from '@angular/core'; import {async, fakeAsync, flushMicrotasks} from '@angular/core/testing'; import {AsyncTestCompleter, Log, beforeEach, describe, expect, inject, it, xit} from '@angular/core/testing/src/testing_internal'; import {browserDetection} from '@angular/platform-browser/testing/src/browser_util'; -import {scheduleMicroTask} from '../../src/util'; +import {scheduleMicroTask} from '../../src/util/microtask'; import {NoopNgZone} from '../../src/zone/ng_zone'; const needsLongerTimers = browserDetection.isSlow || browserDetection.isEdge; diff --git a/packages/core/testing/src/testing_internal.ts b/packages/core/testing/src/testing_internal.ts index fdfb9b0f9b..1620e2d718 100644 --- a/packages/core/testing/src/testing_internal.ts +++ b/packages/core/testing/src/testing_internal.ts @@ -7,7 +7,7 @@ */ import {ɵisPromise as isPromise} from '@angular/core'; -import {global} from '@angular/core/src/util'; +import {global} from '@angular/core/src/util/global'; import {AsyncTestCompleter} from './async_test_completer'; import {getTestBed, inject} from './test_bed'; diff --git a/tools/public_api_guard/BUILD.bazel b/tools/public_api_guard/BUILD.bazel index 517993efa5..918bae387c 100644 --- a/tools/public_api_guard/BUILD.bazel +++ b/tools/public_api_guard/BUILD.bazel @@ -1,8 +1,31 @@ load("//tools/ts-api-guardian:index.bzl", "ts_api_guardian_test") load(":public_api_guard.bzl", "generate_targets") -generate_targets(glob(["*/**/*.d.ts"])) +generate_targets(glob( + ["*/**/*.d.ts"], + # exclude the following target because we have an explicit target for it bellow, see :core_api + exclude = ["core/core.d.ts"], +)) +# Explicit target because core is broken down into sub-packages. +# The ts_api_guardian rule does not know how to collect the .d.ts files from the sub-packages so we have to list it here explicitly. +# see: https://github.com/angular/angular/issues/28057 +ts_api_guardian_test( + name = "core_api", + actual = "angular/packages/core/core.d.ts", + data = ["//tools/public_api_guard:core/core.d.ts"] + [ + "//packages/core", + "//packages/core/src/di/interface", + "//packages/core/src/interface", + "//packages/core/src/util", + ], + golden = "angular/tools/public_api_guard/core/core.d.ts", + tags = [ + "fixme-ivy-aot", # ivy no longer emits generated index file + ], +) + +# explicit target because the d.ts file is nested in the core and not part of typical public d.ts api ts_api_guardian_test( name = "ng_global_utils_api", actual = "angular/packages/core/src/render3/global_utils_api.d.ts",