chore: move injector to being non-internal but private (#10339)
* chore: move injector to being non-internal but private * Add the new non-internal method to the public API.
This commit is contained in:
parent
b58e9ea775
commit
a67cc8229d
|
@ -44,13 +44,13 @@ export class RuntimeCompiler implements Compiler {
|
||||||
private _compiledNgModuleCache = new Map<Type, NgModuleFactory<any>>();
|
private _compiledNgModuleCache = new Map<Type, NgModuleFactory<any>>();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private _injector: Injector, private _metadataResolver: CompileMetadataResolver,
|
private __injector: Injector, private _metadataResolver: CompileMetadataResolver,
|
||||||
private _templateNormalizer: DirectiveNormalizer, private _templateParser: TemplateParser,
|
private _templateNormalizer: DirectiveNormalizer, private _templateParser: TemplateParser,
|
||||||
private _styleCompiler: StyleCompiler, private _viewCompiler: ViewCompiler,
|
private _styleCompiler: StyleCompiler, private _viewCompiler: ViewCompiler,
|
||||||
private _ngModuleCompiler: NgModuleCompiler, private _compilerConfig: CompilerConfig,
|
private _ngModuleCompiler: NgModuleCompiler, private _compilerConfig: CompilerConfig,
|
||||||
private _console: Console) {}
|
private _console: Console) {}
|
||||||
|
|
||||||
get injector(): Injector { return this._injector; }
|
get _injector(): Injector { return this.__injector; }
|
||||||
|
|
||||||
compileModuleSync<T>(moduleType: ConcreteType<T>): NgModuleFactory<T> {
|
compileModuleSync<T>(moduleType: ConcreteType<T>): NgModuleFactory<T> {
|
||||||
return this._compileModuleAndComponents(moduleType, true).syncResult;
|
return this._compileModuleAndComponents(moduleType, true).syncResult;
|
||||||
|
@ -381,7 +381,7 @@ class ModuleBoundCompiler implements Compiler, ComponentResolver {
|
||||||
private _delegate: RuntimeCompiler, private _ngModule: ConcreteType<any>,
|
private _delegate: RuntimeCompiler, private _ngModule: ConcreteType<any>,
|
||||||
private _parentComponentResolver: ComponentResolver, private _console: Console) {}
|
private _parentComponentResolver: ComponentResolver, private _console: Console) {}
|
||||||
|
|
||||||
get injector(): Injector { return this._delegate.injector; }
|
get _injector(): Injector { return this._delegate._injector; }
|
||||||
|
|
||||||
resolveComponent(component: Type|string): Promise<ComponentFactory<any>> {
|
resolveComponent(component: Type|string): Promise<ComponentFactory<any>> {
|
||||||
if (isString(component)) {
|
if (isString(component)) {
|
||||||
|
|
|
@ -41,10 +41,8 @@ export class ComponentStillLoadingError extends BaseException {
|
||||||
export class Compiler {
|
export class Compiler {
|
||||||
/**
|
/**
|
||||||
* Returns the injector with which the compiler has been created.
|
* Returns the injector with which the compiler has been created.
|
||||||
*
|
|
||||||
* @internal
|
|
||||||
*/
|
*/
|
||||||
get injector(): Injector {
|
get _injector(): Injector {
|
||||||
throw new BaseException(`Runtime compiler is not loaded. Tried to read the injector.`);
|
throw new BaseException(`Runtime compiler is not loaded. Tried to read the injector.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -168,7 +168,7 @@ export class TestBed implements Injector {
|
||||||
// Tests can inject things from the ng module and from the compiler,
|
// Tests can inject things from the ng module and from the compiler,
|
||||||
// but the ng module can't inject things from the compiler and vice versa.
|
// but the ng module can't inject things from the compiler and vice versa.
|
||||||
let result = this._moduleRef.injector.get(token, UNDEFINED);
|
let result = this._moduleRef.injector.get(token, UNDEFINED);
|
||||||
return result === UNDEFINED ? this._compiler.injector.get(token, notFoundValue) : result;
|
return result === UNDEFINED ? this._compiler._injector.get(token, notFoundValue) : result;
|
||||||
}
|
}
|
||||||
|
|
||||||
execute(tokens: any[], fn: Function): any {
|
execute(tokens: any[], fn: Function): any {
|
||||||
|
|
|
@ -237,6 +237,7 @@ export declare class CollectionChangeRecord {
|
||||||
|
|
||||||
/** @stable */
|
/** @stable */
|
||||||
export declare class Compiler {
|
export declare class Compiler {
|
||||||
|
_injector: Injector;
|
||||||
clearCache(): void;
|
clearCache(): void;
|
||||||
clearCacheFor(type: Type): void;
|
clearCacheFor(type: Type): void;
|
||||||
compileComponentAsync<T>(component: ConcreteType<T>, ngModule?: Type): Promise<ComponentFactory<T>>;
|
compileComponentAsync<T>(component: ConcreteType<T>, ngModule?: Type): Promise<ComponentFactory<T>>;
|
||||||
|
|
Loading…
Reference in New Issue