refactor(compiler): remove private exports

All of `@angular/compiler` is private, so we can export
everything we need directly.
This commit is contained in:
Tobias Bosch 2016-10-18 08:03:49 -07:00 committed by Alex Rickabaugh
parent a8815d6b08
commit acda82c1ed
10 changed files with 68 additions and 254 deletions

View File

@ -17,7 +17,6 @@ import * as path from 'path';
import * as ts from 'typescript';
import {PathMappedReflectorHost} from './path_mapped_reflector_host';
import {CompileMetadataResolver, DirectiveNormalizer, DomElementSchemaRegistry, HtmlParser, Lexer, NgModuleCompiler, Parser, StyleCompiler, TemplateParser, TypeScriptEmitter, ViewCompiler} from './private_import_compiler';
import {Console} from './private_import_core';
import {ReflectorHost, ReflectorHostContext} from './reflector_host';
import {StaticAndDynamicReflectionCapabilities} from './static_reflection_capabilities';
@ -173,27 +172,27 @@ export class CodeGenerator {
const staticReflector = new StaticReflector(reflectorHost);
StaticAndDynamicReflectionCapabilities.install(staticReflector);
const htmlParser =
new compiler.I18NHtmlParser(new HtmlParser(), transContent, cliOptions.i18nFormat);
new compiler.I18NHtmlParser(new compiler.HtmlParser(), transContent, cliOptions.i18nFormat);
const config = new compiler.CompilerConfig({
genDebugInfo: options.debug === true,
defaultEncapsulation: ViewEncapsulation.Emulated,
logBindingUpdate: false,
useJit: false
});
const normalizer = new DirectiveNormalizer(resourceLoader, urlResolver, htmlParser, config);
const expressionParser = new Parser(new Lexer());
const elementSchemaRegistry = new DomElementSchemaRegistry();
const normalizer = new compiler.DirectiveNormalizer(resourceLoader, urlResolver, htmlParser, config);
const expressionParser = new compiler.Parser(new compiler.Lexer());
const elementSchemaRegistry = new compiler.DomElementSchemaRegistry();
const console = new Console();
const tmplParser =
new TemplateParser(expressionParser, elementSchemaRegistry, htmlParser, console, []);
const resolver = new CompileMetadataResolver(
new compiler.TemplateParser(expressionParser, elementSchemaRegistry, htmlParser, console, []);
const resolver = new compiler.CompileMetadataResolver(
new compiler.NgModuleResolver(staticReflector),
new compiler.DirectiveResolver(staticReflector), new compiler.PipeResolver(staticReflector),
elementSchemaRegistry, staticReflector);
// TODO(vicb): do not pass cliOptions.i18nFormat here
const offlineCompiler = new compiler.OfflineCompiler(
resolver, normalizer, tmplParser, new StyleCompiler(urlResolver), new ViewCompiler(config),
new NgModuleCompiler(), new TypeScriptEmitter(reflectorHost), cliOptions.locale,
resolver, normalizer, tmplParser, new compiler.StyleCompiler(urlResolver), new compiler.ViewCompiler(config),
new compiler.NgModuleCompiler(), new compiler.TypeScriptEmitter(reflectorHost), cliOptions.locale,
cliOptions.i18nFormat);
return new CodeGenerator(

View File

@ -21,7 +21,6 @@ import {Component, NgModule, ViewEncapsulation} from '@angular/core';
import * as path from 'path';
import * as ts from 'typescript';
import * as tsc from '@angular/tsc-wrapped';
import {CompileMetadataResolver, DirectiveNormalizer, DomElementSchemaRegistry, HtmlParser, Lexer, NgModuleCompiler, Parser, StyleCompiler, TemplateParser, TypeScriptEmitter, ViewCompiler, ParseError} from './private_import_compiler';
import {Console} from './private_import_core';
import {ReflectorHost, ReflectorHostContext} from './reflector_host';
import {StaticAndDynamicReflectionCapabilities} from './static_reflection_capabilities';
@ -63,8 +62,8 @@ export class Extractor {
constructor(
private program: ts.Program, public host: ts.CompilerHost,
private staticReflector: StaticReflector, private messageBundle: compiler.MessageBundle,
private reflectorHost: ReflectorHost, private metadataResolver: CompileMetadataResolver,
private directiveNormalizer: DirectiveNormalizer,
private reflectorHost: ReflectorHost, private metadataResolver: compiler.CompileMetadataResolver,
private directiveNormalizer: compiler.DirectiveNormalizer,
private compiler: compiler.OfflineCompiler) {}
private readFileMetadata(absSourcePath: string): FileMetadata {
@ -106,7 +105,7 @@ export class Extractor {
return ngModules;
}, <StaticSymbol[]>[]);
const analyzedNgModules = this.compiler.analyzeModules(ngModules);
const errors: ParseError[] = [];
const errors: compiler.ParseError[] = [];
let bundlePromise =
Promise
@ -168,19 +167,19 @@ export class Extractor {
useJit: false
});
const normalizer = new DirectiveNormalizer(resourceLoader, urlResolver, htmlParser, config);
const expressionParser = new Parser(new Lexer());
const elementSchemaRegistry = new DomElementSchemaRegistry();
const normalizer = new compiler.DirectiveNormalizer(resourceLoader, urlResolver, htmlParser, config);
const expressionParser = new compiler.Parser(new compiler.Lexer());
const elementSchemaRegistry = new compiler.DomElementSchemaRegistry();
const console = new Console();
const tmplParser =
new TemplateParser(expressionParser, elementSchemaRegistry, htmlParser, console, []);
const resolver = new CompileMetadataResolver(
new compiler.TemplateParser(expressionParser, elementSchemaRegistry, htmlParser, console, []);
const resolver = new compiler.CompileMetadataResolver(
new compiler.NgModuleResolver(staticReflector),
new compiler.DirectiveResolver(staticReflector), new compiler.PipeResolver(staticReflector),
elementSchemaRegistry, staticReflector);
const offlineCompiler = new compiler.OfflineCompiler(
resolver, normalizer, tmplParser, new StyleCompiler(urlResolver), new ViewCompiler(config),
new NgModuleCompiler(), new TypeScriptEmitter(reflectorHost), null, null);
resolver, normalizer, tmplParser, new compiler.StyleCompiler(urlResolver), new compiler.ViewCompiler(config),
new compiler.NgModuleCompiler(), new compiler.TypeScriptEmitter(reflectorHost), null, null);
// TODO(vicb): implicit tags & attributes
let messageBundle = new compiler.MessageBundle(htmlParser, [], {});

View File

@ -1,54 +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
*/
import {__compiler_private__ as _} from '@angular/compiler';
export type AssetUrl = typeof _._AssetUrl;
export var AssetUrl: typeof _.AssetUrl = _.AssetUrl;
export type ImportGenerator = typeof _._ImportGenerator;
export var ImportGenerator: typeof _.ImportGenerator = _.ImportGenerator;
export type CompileMetadataResolver = typeof _._CompileMetadataResolver;
export var CompileMetadataResolver: typeof _.CompileMetadataResolver = _.CompileMetadataResolver;
export type HtmlParser = typeof _._HtmlParser;
export var HtmlParser: typeof _.HtmlParser = _.HtmlParser;
export type ParseError = typeof _._ParseError;
export var ParseError: typeof _.ParseError = _.ParseError;
export type InterpolationConfig = typeof _._InterpolationConfig;
export var InterpolationConfig: typeof _.InterpolationConfig = _.InterpolationConfig;
export type DirectiveNormalizer = typeof _._DirectiveNormalizer;
export var DirectiveNormalizer: typeof _.DirectiveNormalizer = _.DirectiveNormalizer;
export type Lexer = typeof _._Lexer;
export var Lexer: typeof _.Lexer = _.Lexer;
export type Parser = typeof _._Parser;
export var Parser: typeof _.Parser = _.Parser;
export type TemplateParser = typeof _._TemplateParser;
export var TemplateParser: typeof _.TemplateParser = _.TemplateParser;
export type DomElementSchemaRegistry = typeof _._DomElementSchemaRegistry;
export var DomElementSchemaRegistry: typeof _.DomElementSchemaRegistry = _.DomElementSchemaRegistry;
export type StyleCompiler = typeof _._StyleCompiler;
export var StyleCompiler: typeof _.StyleCompiler = _.StyleCompiler;
export type ViewCompiler = typeof _._ViewCompiler;
export var ViewCompiler: typeof _.ViewCompiler = _.ViewCompiler;
export type NgModuleCompiler = typeof _._NgModuleCompiler;
export var NgModuleCompiler: typeof _.NgModuleCompiler = _.NgModuleCompiler;
export type TypeScriptEmitter = typeof _._TypeScriptEmitter;
export var TypeScriptEmitter: typeof _.TypeScriptEmitter = _.TypeScriptEmitter;

View File

@ -6,12 +6,12 @@
* found in the LICENSE file at https://angular.io/license
*/
import {AssetUrl, ImportGenerator} from '@angular/compiler';
import {AngularCompilerOptions, MetadataCollector, ModuleMetadata} from '@angular/tsc-wrapped';
import * as fs from 'fs';
import * as path from 'path';
import * as ts from 'typescript';
import {AssetUrl, ImportGenerator} from './private_import_compiler';
import {StaticReflectorHost, StaticSymbol} from './static_reflector';
const EXT = /(\.ts|\.d\.ts|\.js|\.jsx|\.tsx)$/;

View File

@ -21,6 +21,36 @@
* </p>
* </div>
*/
export * from './src/index';
export * from './src/template_parser/template_ast';
export {TEMPLATE_TRANSFORMS} from './src/template_parser/template_parser';
export {CompilerConfig, RenderTypes} from './src/config';
export * from './src/compile_metadata';
export * from './src/offline_compiler';
export {RuntimeCompiler} from './src/runtime_compiler';
export * from './src/url_resolver';
export * from './src/resource_loader';
export * from './src/compiler';
export {DirectiveResolver} from './src/directive_resolver';
export {PipeResolver} from './src/pipe_resolver';
export {NgModuleResolver} from './src/ng_module_resolver';
export {DEFAULT_INTERPOLATION_CONFIG, InterpolationConfig} from './src/ml_parser/interpolation_config';
export {ElementSchemaRegistry} from './src/schema/element_schema_registry';
export * from './src/i18n/index';
export * from './src/template_parser/template_ast';
export * from './src/directive_normalizer';
export * from './src/expression_parser/lexer';
export * from './src/expression_parser/parser';
export * from './src/metadata_resolver';
export * from './src/ml_parser/html_parser';
export * from './src/ml_parser/interpolation_config';
export {NgModuleCompiler} from './src/ng_module_compiler';
export * from './src/output/path_util';
export * from './src/output/ts_emitter';
export * from './src/parse_util';
export * from './src/schema/dom_element_schema_registry';
export * from './src/selector';
export * from './src/style_compiler';
export * from './src/template_parser/template_parser';
export {ViewCompiler} from './src/view_compiler/view_compiler';
// This file only reexports content of the `src` folder. Keep it that way.

View File

@ -8,39 +8,26 @@
import {COMPILER_OPTIONS, Compiler, CompilerFactory, CompilerOptions, Inject, Injectable, Optional, PLATFORM_INITIALIZER, PlatformRef, Provider, ReflectiveInjector, TRANSLATIONS, TRANSLATIONS_FORMAT, Type, ViewEncapsulation, createPlatformFactory, isDevMode, platformCore} from '@angular/core';
export * from './template_parser/template_ast';
export {TEMPLATE_TRANSFORMS} from './template_parser/template_parser';
export {CompilerConfig, RenderTypes} from './config';
export * from './compile_metadata';
export * from './offline_compiler';
export {RuntimeCompiler} from './runtime_compiler';
export * from './url_resolver';
export * from './resource_loader';
export {DirectiveResolver} from './directive_resolver';
export {PipeResolver} from './pipe_resolver';
export {NgModuleResolver} from './ng_module_resolver';
import {TemplateParser} from './template_parser/template_parser';
import {HtmlParser} from './ml_parser/html_parser';
import {DirectiveNormalizer} from './directive_normalizer';
import {CompileMetadataResolver} from './metadata_resolver';
import {StyleCompiler} from './style_compiler';
import {ViewCompiler} from './view_compiler/view_compiler';
import {NgModuleCompiler} from './ng_module_compiler';
import {CompilerConfig} from './config';
import {RuntimeCompiler} from './runtime_compiler';
import {ElementSchemaRegistry} from './schema/element_schema_registry';
import {DomElementSchemaRegistry} from './schema/dom_element_schema_registry';
import {UrlResolver, DEFAULT_PACKAGE_URL_PROVIDER} from './url_resolver';
import {Parser} from './expression_parser/parser';
import {Lexer} from './expression_parser/lexer';
import {DirectiveNormalizer} from './directive_normalizer';
import {DirectiveResolver} from './directive_resolver';
import {PipeResolver} from './pipe_resolver';
import {NgModuleResolver} from './ng_module_resolver';
import {Console, Reflector, reflector, ReflectorReader, ReflectionCapabilities} from './private_import_core';
import {ResourceLoader} from './resource_loader';
import {Lexer} from './expression_parser/lexer';
import {Parser} from './expression_parser/parser';
import * as i18n from './i18n/index';
import {CompileMetadataResolver} from './metadata_resolver';
import {HtmlParser} from './ml_parser/html_parser';
import {NgModuleCompiler} from './ng_module_compiler';
import {NgModuleResolver} from './ng_module_resolver';
import {PipeResolver} from './pipe_resolver';
import {Console, ReflectionCapabilities, Reflector, ReflectorReader, reflector} from './private_import_core';
import {ResourceLoader} from './resource_loader';
import {RuntimeCompiler} from './runtime_compiler';
import {DomElementSchemaRegistry} from './schema/dom_element_schema_registry';
import {ElementSchemaRegistry} from './schema/element_schema_registry';
import {StyleCompiler} from './style_compiler';
import {TemplateParser} from './template_parser/template_parser';
import {DEFAULT_PACKAGE_URL_PROVIDER, UrlResolver} from './url_resolver';
import {ViewCompiler} from './view_compiler/view_compiler';
const _NO_RESOURCE_LOADER: ResourceLoader = {
get(url: string): Promise<string>{

View File

@ -1,20 +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
*/
/**
* @module
* @description
* Starting point to import all compiler APIs.
*/
export {COMPILER_PROVIDERS, CompileDiDependencyMetadata, CompileDirectiveMetadata, CompileFactoryMetadata, CompileIdentifierMetadata, CompileMetadataWithIdentifier, CompilePipeMetadata, CompileProviderMetadata, CompileQueryMetadata, CompileTemplateMetadata, CompileTokenMetadata, CompileTypeMetadata, CompilerConfig, DEFAULT_PACKAGE_URL_PROVIDER, DirectiveResolver, NgModuleResolver, OfflineCompiler, PipeResolver, RenderTypes, ResourceLoader, RuntimeCompiler, SourceModule, TEMPLATE_TRANSFORMS, UrlResolver, createOfflineCompileUrlResolver, platformCoreDynamic} from './compiler';
export {DEFAULT_INTERPOLATION_CONFIG, InterpolationConfig} from './ml_parser/interpolation_config';
export {ElementSchemaRegistry} from './schema/element_schema_registry';
export * from './i18n/index';
export * from './template_parser/template_ast';
export * from './private_export';

View File

@ -1,112 +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
*/
import * as directive_normalizer from './directive_normalizer';
import * as lexer from './expression_parser/lexer';
import * as parser from './expression_parser/parser';
import * as metadata_resolver from './metadata_resolver';
import * as html_parser from './ml_parser/html_parser';
import * as interpolation_config from './ml_parser/interpolation_config';
import * as ng_module_compiler from './ng_module_compiler';
import * as path_util from './output/path_util';
import * as ts_emitter from './output/ts_emitter';
import * as parse_util from './parse_util';
import * as dom_element_schema_registry from './schema/dom_element_schema_registry';
import * as selector from './selector';
import * as style_compiler from './style_compiler';
import * as template_parser from './template_parser/template_parser';
import * as view_compiler from './view_compiler/view_compiler';
export const __compiler_private__: {
_SelectorMatcher?: selector.SelectorMatcher; SelectorMatcher: typeof selector.SelectorMatcher;
_CssSelector?: selector.CssSelector;
CssSelector: typeof selector.CssSelector;
_AssetUrl?: path_util.AssetUrl;
AssetUrl: typeof path_util.AssetUrl;
_ImportGenerator?: path_util.ImportGenerator;
ImportGenerator: typeof path_util.ImportGenerator;
_CompileMetadataResolver?: metadata_resolver.CompileMetadataResolver;
CompileMetadataResolver: typeof metadata_resolver.CompileMetadataResolver;
_HtmlParser?: html_parser.HtmlParser;
HtmlParser: typeof html_parser.HtmlParser;
_InterpolationConfig?: interpolation_config.InterpolationConfig;
InterpolationConfig: typeof interpolation_config.InterpolationConfig;
_DirectiveNormalizer?: directive_normalizer.DirectiveNormalizer;
DirectiveNormalizer: typeof directive_normalizer.DirectiveNormalizer;
_Lexer?: lexer.Lexer;
Lexer: typeof lexer.Lexer;
_Parser?: parser.Parser;
Parser: typeof parser.Parser;
_ParseLocation?: parse_util.ParseLocation;
ParseLocation: typeof parse_util.ParseLocation;
_ParseError?: parse_util.ParseError;
ParseError: typeof parse_util.ParseError;
_ParseErrorLevel?: parse_util.ParseErrorLevel;
ParseErrorLevel: typeof parse_util.ParseErrorLevel;
_ParseSourceFile?: parse_util.ParseSourceFile;
ParseSourceFile: typeof parse_util.ParseSourceFile;
_ParseSourceSpan?: parse_util.ParseSourceSpan;
ParseSourceSpan: typeof parse_util.ParseSourceSpan;
_TemplateParser?: template_parser.TemplateParser;
TemplateParser: typeof template_parser.TemplateParser;
_TemplateParseResult?: template_parser.TemplateParseResult;
_DomElementSchemaRegistry?: dom_element_schema_registry.DomElementSchemaRegistry;
DomElementSchemaRegistry: typeof dom_element_schema_registry.DomElementSchemaRegistry;
_StyleCompiler?: style_compiler.StyleCompiler;
StyleCompiler: typeof style_compiler.StyleCompiler;
_ViewCompiler?: view_compiler.ViewCompiler;
ViewCompiler: typeof view_compiler.ViewCompiler;
_NgModuleCompiler?: ng_module_compiler.NgModuleCompiler;
NgModuleCompiler: typeof ng_module_compiler.NgModuleCompiler;
_TypeScriptEmitter?: ts_emitter.TypeScriptEmitter;
TypeScriptEmitter: typeof ts_emitter.TypeScriptEmitter;
} = {
SelectorMatcher: selector.SelectorMatcher,
CssSelector: selector.CssSelector,
AssetUrl: path_util.AssetUrl,
ImportGenerator: path_util.ImportGenerator,
CompileMetadataResolver: metadata_resolver.CompileMetadataResolver,
HtmlParser: html_parser.HtmlParser,
InterpolationConfig: interpolation_config.InterpolationConfig,
DirectiveNormalizer: directive_normalizer.DirectiveNormalizer,
Lexer: lexer.Lexer,
Parser: parser.Parser,
ParseLocation: parse_util.ParseLocation,
ParseError: parse_util.ParseError,
ParseErrorLevel: parse_util.ParseErrorLevel,
ParseSourceFile: parse_util.ParseSourceFile,
ParseSourceSpan: parse_util.ParseSourceSpan,
TemplateParser: template_parser.TemplateParser,
DomElementSchemaRegistry: dom_element_schema_registry.DomElementSchemaRegistry,
StyleCompiler: style_compiler.StyleCompiler,
ViewCompiler: view_compiler.ViewCompiler,
NgModuleCompiler: ng_module_compiler.NgModuleCompiler,
TypeScriptEmitter: ts_emitter.TypeScriptEmitter
};

View File

@ -11,7 +11,7 @@ const parse5 = require('parse5');
import {ListWrapper} from '../src/facade/collection';
import {DomAdapter, setRootDomAdapter} from './private_import_platform-browser';
import {isPresent, isBlank, global, setValueOnPath} from '../src/facade/lang';
import {SelectorMatcher, CssSelector} from './private_import_compiler';
import {SelectorMatcher, CssSelector} from '@angular/compiler';
let treeAdapter: any;

View File

@ -1,15 +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
*/
import {__compiler_private__ as _c} from '@angular/compiler';
export type SelectorMatcher = typeof _c.SelectorMatcher;
export var SelectorMatcher: typeof _c.SelectorMatcher = _c.SelectorMatcher;
export type CssSelector = typeof _c.CssSelector;
export var CssSelector: typeof _c.CssSelector = _c.CssSelector;