/** * @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 {Injectable, InjectionToken} from '../di'; import {MissingTranslationStrategy} from '../i18n/tokens'; import {ViewEncapsulation} from '../metadata'; import {Type} from '../type'; import {ComponentFactory} from './component_factory'; import {NgModuleFactory} from './ng_module_factory'; /** * Combination of NgModuleFactory and ComponentFactorys. * * @experimental */ export class ModuleWithComponentFactories { constructor( public ngModuleFactory: NgModuleFactory, public componentFactories: ComponentFactory[]) {} } function _throwError() { throw new Error(`Runtime compiler is not loaded`); } /** * Low-level service for running the angular compiler during runtime * to create {@link ComponentFactory}s, which * can later be used to create and render a Component instance. * * Each `@NgModule` provides an own `Compiler` to its injector, * that will use the directives/pipes of the ng module for compilation * of components. * @stable */ @Injectable() export class Compiler { /** * Compiles the given NgModule and all of its components. All templates of the components listed * in `entryComponents` have to be inlined. */ compileModuleSync(moduleType: Type): NgModuleFactory { throw _throwError(); } /** * Compiles the given NgModule and all of its components */ compileModuleAsync(moduleType: Type): Promise> { throw _throwError(); } /** * Same as {@link #compileModuleSync} but also creates ComponentFactories for all components. */ compileModuleAndAllComponentsSync(moduleType: Type): ModuleWithComponentFactories { throw _throwError(); } /** * Same as {@link #compileModuleAsync} but also creates ComponentFactories for all components. */ compileModuleAndAllComponentsAsync(moduleType: Type): Promise> { throw _throwError(); } /** * Exposes the CSS-style selectors that have been used in `ngContent` directives within * the template of the given component. * This is used by the `upgrade` library to compile the appropriate transclude content * in the AngularJS wrapper component. * * @deprecated since v4. Use ComponentFactory.ngContentSelectors instead. */ getNgContentSelectors(component: Type): string[] { throw _throwError(); } /** * Clears all caches. */ clearCache(): void {} /** * Clears the cache for the given component/ngModule. */ clearCacheFor(type: Type) {} } /** * Options for creating a compiler * * @experimental */ export type CompilerOptions = { /** * @deprecated since v4 this option has no effect anymore. */ useDebug?: boolean, useJit?: boolean, defaultEncapsulation?: ViewEncapsulation, providers?: any[], missingTranslation?: MissingTranslationStrategy, // Whether to support the `