refactor(TemplateLoader): rename to ViewLoader
This commit is contained in:
parent
b89c0672e6
commit
356c927d12
|
@ -5,7 +5,7 @@
|
|||
* This module provides advanced support for extending dom strategy.
|
||||
*/
|
||||
|
||||
export * from './src/render/dom/compiler/template_loader';
|
||||
export * from './src/render/dom/compiler/view_loader';
|
||||
export * from './src/render/dom/shadow_dom/shadow_dom_strategy';
|
||||
export * from './src/render/dom/shadow_dom/native_shadow_dom_strategy';
|
||||
export * from './src/render/dom/shadow_dom/emulated_scoped_shadow_dom_strategy';
|
||||
|
|
|
@ -24,7 +24,7 @@ import {
|
|||
defaultPipeRegistry
|
||||
} from 'angular2/change_detection';
|
||||
import {ExceptionHandler} from './exception_handler';
|
||||
import {TemplateLoader} from 'angular2/src/render/dom/compiler/template_loader';
|
||||
import {ViewLoader} from 'angular2/src/render/dom/compiler/view_loader';
|
||||
import {StyleUrlResolver} from 'angular2/src/render/dom/compiler/style_url_resolver';
|
||||
import {StyleInliner} from 'angular2/src/render/dom/compiler/style_inliner';
|
||||
import {TemplateResolver} from './compiler/template_resolver';
|
||||
|
@ -121,7 +121,7 @@ function _injectorBindings(appComponentType): List<Type | Binding | List<any>> {
|
|||
TemplateResolver,
|
||||
bind(PipeRegistry).toValue(defaultPipeRegistry),
|
||||
bind(ChangeDetection).toClass(bestChangeDetection),
|
||||
TemplateLoader,
|
||||
ViewLoader,
|
||||
DirectiveResolver,
|
||||
Parser,
|
||||
Lexer,
|
||||
|
|
|
@ -13,7 +13,7 @@ import {
|
|||
RenderProtoViewRef
|
||||
} from '../../api';
|
||||
import {CompilePipeline} from './compile_pipeline';
|
||||
import {TemplateLoader} from 'angular2/src/render/dom/compiler/template_loader';
|
||||
import {ViewLoader} from 'angular2/src/render/dom/compiler/view_loader';
|
||||
import {CompileStepFactory, DefaultStepFactory} from './compile_step_factory';
|
||||
import {Parser} from 'angular2/change_detection';
|
||||
import {ShadowDomStrategy} from '../shadow_dom/shadow_dom_strategy';
|
||||
|
@ -24,12 +24,10 @@ import {ShadowDomStrategy} from '../shadow_dom/shadow_dom_strategy';
|
|||
* the CompilePipeline and the CompileSteps.
|
||||
*/
|
||||
export class DomCompiler extends RenderCompiler {
|
||||
constructor(public _stepFactory: CompileStepFactory, public _templateLoader: TemplateLoader) {
|
||||
super();
|
||||
}
|
||||
constructor(public _stepFactory: CompileStepFactory, public _viewLoader: ViewLoader) { super(); }
|
||||
|
||||
compile(view: ViewDefinition): Promise<ProtoViewDto> {
|
||||
var tplPromise = this._templateLoader.load(view);
|
||||
var tplPromise = this._viewLoader.load(view);
|
||||
return PromiseWrapper.then(
|
||||
tplPromise, (el) => this._compileTemplate(view, el, ViewType.COMPONENT), (e) => {
|
||||
throw new BaseException(`Failed to load the template for "${view.componentId}" : ${e}`);
|
||||
|
@ -59,8 +57,7 @@ export class DomCompiler extends RenderCompiler {
|
|||
|
||||
@Injectable()
|
||||
export class DefaultDomCompiler extends DomCompiler {
|
||||
constructor(parser: Parser, shadowDomStrategy: ShadowDomStrategy,
|
||||
templateLoader: TemplateLoader) {
|
||||
super(new DefaultStepFactory(parser, shadowDomStrategy), templateLoader);
|
||||
constructor(parser: Parser, shadowDomStrategy: ShadowDomStrategy, viewLoader: ViewLoader) {
|
||||
super(new DefaultStepFactory(parser, shadowDomStrategy), viewLoader);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import {StyleUrlResolver} from './style_url_resolver';
|
|||
* TODO: Make public API once we are more confident in this approach.
|
||||
*/
|
||||
@Injectable()
|
||||
export class TemplateLoader {
|
||||
export class ViewLoader {
|
||||
_cache: Map<string, Promise<string>> = new Map();
|
||||
|
||||
constructor(private _xhr: XHR, private _styleInliner: StyleInliner,
|
|
@ -11,7 +11,7 @@ import {
|
|||
defaultPipeRegistry
|
||||
} from 'angular2/change_detection';
|
||||
import {ExceptionHandler} from 'angular2/src/core/exception_handler';
|
||||
import {TemplateLoader} from 'angular2/src/render/dom/compiler/template_loader';
|
||||
import {ViewLoader} from 'angular2/src/render/dom/compiler/view_loader';
|
||||
import {TemplateResolver} from 'angular2/src/core/compiler/template_resolver';
|
||||
import {DirectiveResolver} from 'angular2/src/core/compiler/directive_resolver';
|
||||
import {DynamicComponentLoader} from 'angular2/src/core/compiler/dynamic_component_loader';
|
||||
|
@ -104,7 +104,7 @@ function _getAppBindings() {
|
|||
bind(TemplateResolver).toClass(MockTemplateResolver),
|
||||
bind(PipeRegistry).toValue(defaultPipeRegistry),
|
||||
bind(ChangeDetection).toClass(DynamicChangeDetection),
|
||||
TemplateLoader,
|
||||
ViewLoader,
|
||||
DynamicComponentLoader,
|
||||
DirectiveResolver,
|
||||
Parser,
|
||||
|
|
|
@ -9,7 +9,7 @@ import 'package:angular2/src/render/api.dart';
|
|||
import 'package:angular2/src/render/dom/compiler/compile_pipeline.dart';
|
||||
import 'package:angular2/src/render/dom/compiler/style_inliner.dart';
|
||||
import 'package:angular2/src/render/dom/compiler/style_url_resolver.dart';
|
||||
import 'package:angular2/src/render/dom/compiler/template_loader.dart';
|
||||
import 'package:angular2/src/render/dom/compiler/view_loader.dart';
|
||||
import 'package:angular2/src/render/xhr.dart' show XHR;
|
||||
import 'package:angular2/src/reflection/reflection.dart';
|
||||
import 'package:angular2/src/services/url_resolver.dart';
|
||||
|
@ -81,7 +81,7 @@ Future<String> processTemplates(AssetReader reader, AssetId entryPoint,
|
|||
/// reflectively accessed from that template.
|
||||
class _TemplateExtractor {
|
||||
final CompileStepFactory _factory;
|
||||
TemplateLoader _loader;
|
||||
ViewLoader _loader;
|
||||
|
||||
_TemplateExtractor(XHR xhr)
|
||||
: _factory = new CompileStepFactory(new ng.Parser(new ng.Lexer())) {
|
||||
|
@ -90,7 +90,7 @@ class _TemplateExtractor {
|
|||
var styleUrlResolver = new StyleUrlResolver(urlResolver);
|
||||
var styleInliner = new StyleInliner(xhr, styleUrlResolver, urlResolver);
|
||||
|
||||
_loader = new TemplateLoader(xhr, styleInliner, styleUrlResolver);
|
||||
_loader = new ViewLoader(xhr, styleInliner, styleUrlResolver);
|
||||
}
|
||||
|
||||
Future<_ExtractResult> extractTemplates(ViewDefinition viewDef) async {
|
||||
|
|
|
@ -133,8 +133,7 @@ export function main() {
|
|||
cmpUrlMapper.setComponentUrl(MainComponent, '/cmp/main.js');
|
||||
captureTemplate(new viewAnn.View({templateUrl: 'tpl/main.html'}))
|
||||
.then((renderTpl) => {
|
||||
expect(renderTpl.templateAbsUrl)
|
||||
.toEqual('http://www.app.com/cmp/tpl/main.html');
|
||||
expect(renderTpl.templateAbsUrl).toEqual('http://www.app.com/cmp/tpl/main.html');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
@ -144,10 +143,8 @@ export function main() {
|
|||
captureTemplate(new viewAnn.View({styleUrls: ['css/1.css', 'css/2.css']}))
|
||||
.then((renderTpl) => {
|
||||
expect(renderTpl.styleAbsUrls)
|
||||
.toEqual([
|
||||
'http://www.app.com/cmp/css/1.css',
|
||||
'http://www.app.com/cmp/css/2.css'
|
||||
]);
|
||||
.toEqual(
|
||||
['http://www.app.com/cmp/css/1.css', 'http://www.app.com/cmp/css/2.css']);
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
|
|
@ -22,7 +22,7 @@ import {CompileElement} from 'angular2/src/render/dom/compiler/compile_element';
|
|||
import {CompileStep} from 'angular2/src/render/dom/compiler/compile_step';
|
||||
import {CompileStepFactory} from 'angular2/src/render/dom/compiler/compile_step_factory';
|
||||
import {CompileControl} from 'angular2/src/render/dom/compiler/compile_control';
|
||||
import {TemplateLoader} from 'angular2/src/render/dom/compiler/template_loader';
|
||||
import {ViewLoader} from 'angular2/src/render/dom/compiler/view_loader';
|
||||
|
||||
import {resolveInternalDomProtoView} from 'angular2/src/render/dom/view/proto_view';
|
||||
|
||||
|
@ -34,7 +34,7 @@ export function runCompilerCommonTests() {
|
|||
if (isBlank(urlData)) {
|
||||
urlData = new Map();
|
||||
}
|
||||
var tplLoader = new FakeTemplateLoader(urlData);
|
||||
var tplLoader = new FakeViewLoader(urlData);
|
||||
mockStepFactory = new MockStepFactory([new MockStep(processClosure)]);
|
||||
return new DomCompiler(mockStepFactory, tplLoader);
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ var EMPTY_STEP = (parent, current, control) => {
|
|||
}
|
||||
};
|
||||
|
||||
class FakeTemplateLoader extends TemplateLoader {
|
||||
class FakeViewLoader extends ViewLoader {
|
||||
_urlData: Map<string, string>;
|
||||
constructor(urlData) {
|
||||
super(null, null, null);
|
||||
|
|
|
@ -7,9 +7,7 @@ export function main() {
|
|||
describe('StyleUrlResolver', () => {
|
||||
let styleUrlResolver;
|
||||
|
||||
beforeEach(() => {
|
||||
styleUrlResolver = new StyleUrlResolver(new UrlResolver());
|
||||
});
|
||||
beforeEach(() => { styleUrlResolver = new StyleUrlResolver(new UrlResolver()); });
|
||||
|
||||
it('should resolve "url()" urls', () => {
|
||||
var css = `
|
||||
|
|
|
@ -11,7 +11,7 @@ import {
|
|||
xit,
|
||||
} from 'angular2/test_lib';
|
||||
import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||
import {TemplateLoader} from 'angular2/src/render/dom/compiler/template_loader';
|
||||
import {ViewLoader} from 'angular2/src/render/dom/compiler/view_loader';
|
||||
import {StyleInliner} from 'angular2/src/render/dom/compiler/style_inliner';
|
||||
import {StyleUrlResolver} from 'angular2/src/render/dom/compiler/style_url_resolver';
|
||||
import {UrlResolver} from 'angular2/src/services/url_resolver';
|
||||
|
@ -23,7 +23,7 @@ import {XHR} from 'angular2/src/render/xhr';
|
|||
import {MockXHR} from 'angular2/src/render/xhr_mock';
|
||||
|
||||
export function main() {
|
||||
describe('TemplateLoader', () => {
|
||||
describe('ViewLoader', () => {
|
||||
var loader, xhr, styleUrlResolver, urlResolver;
|
||||
|
||||
beforeEach(() => {
|
||||
|
@ -31,7 +31,7 @@ export function main() {
|
|||
urlResolver = new UrlResolver();
|
||||
styleUrlResolver = new StyleUrlResolver(urlResolver);
|
||||
let styleInliner = new StyleInliner(xhr, styleUrlResolver, urlResolver);
|
||||
loader = new TemplateLoader(xhr, styleInliner, styleUrlResolver);
|
||||
loader = new ViewLoader(xhr, styleInliner, styleUrlResolver);
|
||||
});
|
||||
|
||||
describe('html', () => {
|
||||
|
@ -71,7 +71,7 @@ export function main() {
|
|||
xhr.reply('http://ng.io/foo.css', '/* foo.css */');
|
||||
|
||||
let styleInliner = new StyleInliner(xhr, styleUrlResolver, urlResolver);
|
||||
let loader = new TemplateLoader(xhr, styleInliner, styleUrlResolver);
|
||||
let loader = new ViewLoader(xhr, styleInliner, styleUrlResolver);
|
||||
|
||||
var view = new ViewDefinition({templateAbsUrl: 'http://ng.io/foo.html'});
|
||||
loader.load(view).then((el) => {
|
||||
|
@ -168,7 +168,7 @@ export function main() {
|
|||
xhr.reply('http://ng.io/foo.css', '/* foo.css */');
|
||||
|
||||
let styleInliner = new StyleInliner(xhr, styleUrlResolver, urlResolver);
|
||||
let loader = new TemplateLoader(xhr, styleInliner, styleUrlResolver);
|
||||
let loader = new ViewLoader(xhr, styleInliner, styleUrlResolver);
|
||||
|
||||
var view = new ViewDefinition(
|
||||
{templateAbsUrl: 'http://ng.io/foo.html', styles: ['@import "foo.css";']});
|
|
@ -13,7 +13,7 @@ import {DirectiveResolver} from 'angular2/src/core/compiler/directive_resolver';
|
|||
|
||||
import * as viewModule from 'angular2/src/core/annotations_impl/view';
|
||||
import {Component, Directive, View} from 'angular2/angular2';
|
||||
import {TemplateLoader} from 'angular2/src/render/dom/compiler/template_loader';
|
||||
import {ViewLoader} from 'angular2/src/render/dom/compiler/view_loader';
|
||||
import {TemplateResolver} from 'angular2/src/core/compiler/template_resolver';
|
||||
import {UrlResolver} from 'angular2/src/services/url_resolver';
|
||||
import {AppRootUrl} from 'angular2/src/services/app_root_url';
|
||||
|
@ -38,7 +38,7 @@ export function main() {
|
|||
var urlResolver = new UrlResolver();
|
||||
var shadowDomStrategy = new NativeShadowDomStrategy();
|
||||
var renderCompiler = new rc.DefaultDomCompiler(new Parser(new Lexer()), shadowDomStrategy,
|
||||
new TemplateLoader(null, null, null));
|
||||
new ViewLoader(null, null, null));
|
||||
var compiler = new Compiler(
|
||||
reader, cache, templateResolver, new ComponentUrlMapper(), urlResolver, renderCompiler,
|
||||
new ProtoViewFactory(new DynamicChangeDetection(null)), new FakeAppRootUrl());
|
||||
|
|
Loading…
Reference in New Issue