refactor(ivy): create Injector interface; remove dependency on Ivy (#28066)

This change is a prerequasity for a later change which will turn the
'di' into its own bazel package. In order to do that we have to:
- have `Injector` type be importable by Ivy. This means that we need
  to create `Injector` as a pure type in `interface` folder which is
  already a bazel package which Ivy can depend on.
- Remove the dependency of `class Injector` on Ivy so that it can be
  compiled in isolation. We do that by using `-1` as special value for
  `__NG_ELEMENT_ID__` which tells the Ivy `NodeInjector` than
  `Injector` is being requested.

PR Close #28066
This commit is contained in:
Misko Hevery
2019-01-10 23:45:02 -08:00
committed by Andrew Kushnir
parent e082fc24b2
commit fca185e191
26 changed files with 151 additions and 97 deletions

View File

@ -6,7 +6,7 @@
"name": "CIRCULAR$1"
},
{
"name": "EMPTY_ARRAY$1"
"name": "EMPTY_ARRAY$2"
},
{
"name": "EmptyErrorImpl"
@ -33,7 +33,7 @@
"name": "NOT_YET"
},
{
"name": "NULL_INJECTOR$2"
"name": "NULL_INJECTOR$1"
},
{
"name": "NullInjector"
@ -63,7 +63,7 @@
"name": "THROW_IF_NOT_FOUND"
},
{
"name": "USE_VALUE"
"name": "USE_VALUE$2"
},
{
"name": "UnsubscriptionErrorImpl"

View File

@ -16,7 +16,7 @@ import {getLView} from '@angular/core/src/render3/state';
import {stringifyElement} from '@angular/platform-browser/testing/src/browser_util';
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 {Injector} 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';
@ -368,7 +368,6 @@ export function enableIvyInjectableFactories() {
R3_VIEW_CONTAINER_REF_FACTORY(ViewContainerRef, ElementRef);
(ChangeDetectorRef as any)[NG_ELEMENT_ID] = () => R3_CHANGE_DETECTOR_REF_FACTORY();
(Renderer2 as any)[NG_ELEMENT_ID] = () => R3_RENDERER2_FACTORY();
(Injector as any)[NG_ELEMENT_ID] = () => R3_INJECTOR_FACTORY();
}
export class MockRendererFactory implements RendererFactory3 {

View File

@ -7,8 +7,8 @@
*/
import {NgModuleRef} from '@angular/core';
import {InjectFlags, inject} from '@angular/core/src/di';
import {INJECTOR, Injector} from '@angular/core/src/di/injector';
import {InjectFlags, inject} from '@angular/core/src/di/injector_compatibility';
import {InjectableDef, defineInjectable} from '@angular/core/src/di/interface/defs';
import {NgModuleDefinition, NgModuleProviderDef, NodeFlags} from '@angular/core/src/view';
import {moduleDef} from '@angular/core/src/view/ng_module';