2016-04-28 20:50:03 -04:00
|
|
|
import {isBlank} from '../src/facade/lang';
|
|
|
|
import {unimplemented} from '../src/facade/exceptions';
|
2016-01-06 17:13:44 -05:00
|
|
|
import {Identifiers} from './identifiers';
|
|
|
|
import {CompileIdentifierMetadata} from './compile_metadata';
|
2016-04-02 19:34:44 -04:00
|
|
|
import {ViewEncapsulation} from '@angular/core';
|
2016-01-06 17:13:44 -05:00
|
|
|
|
|
|
|
export class CompilerConfig {
|
|
|
|
public renderTypes: RenderTypes;
|
2016-05-26 16:08:39 -04:00
|
|
|
public interpolateRegexp: RegExp;
|
2016-04-02 19:34:44 -04:00
|
|
|
public defaultEncapsulation: ViewEncapsulation;
|
|
|
|
|
2016-01-06 17:13:44 -05:00
|
|
|
constructor(public genDebugInfo: boolean, public logBindingUpdate: boolean,
|
2016-04-02 19:34:44 -04:00
|
|
|
public useJit: boolean, renderTypes: RenderTypes = null,
|
|
|
|
interpolateRegexp: RegExp = null, defaultEncapsulation: ViewEncapsulation = null) {
|
2016-01-06 17:13:44 -05:00
|
|
|
if (isBlank(renderTypes)) {
|
|
|
|
renderTypes = new DefaultRenderTypes();
|
|
|
|
}
|
|
|
|
this.renderTypes = renderTypes;
|
2016-05-26 16:08:39 -04:00
|
|
|
if (isBlank(interpolateRegexp)) {
|
|
|
|
interpolateRegexp = DEFAULT_INTERPOLATE_REGEXP;
|
|
|
|
}
|
|
|
|
this.interpolateRegexp = interpolateRegexp;
|
2016-04-02 19:34:44 -04:00
|
|
|
if (isBlank(defaultEncapsulation)) {
|
|
|
|
defaultEncapsulation = ViewEncapsulation.Emulated;
|
|
|
|
}
|
|
|
|
this.defaultEncapsulation = defaultEncapsulation;
|
2016-01-06 17:13:44 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Types used for the renderer.
|
|
|
|
* Can be replaced to specialize the generated output to a specific renderer
|
|
|
|
* to help tree shaking.
|
|
|
|
*/
|
|
|
|
export abstract class RenderTypes {
|
|
|
|
get renderer(): CompileIdentifierMetadata { return unimplemented(); }
|
|
|
|
get renderText(): CompileIdentifierMetadata { return unimplemented(); }
|
|
|
|
get renderElement(): CompileIdentifierMetadata { return unimplemented(); }
|
|
|
|
get renderComment(): CompileIdentifierMetadata { return unimplemented(); }
|
|
|
|
get renderNode(): CompileIdentifierMetadata { return unimplemented(); }
|
|
|
|
get renderEvent(): CompileIdentifierMetadata { return unimplemented(); }
|
|
|
|
}
|
|
|
|
|
|
|
|
export class DefaultRenderTypes implements RenderTypes {
|
|
|
|
renderer = Identifiers.Renderer;
|
|
|
|
renderText = null;
|
|
|
|
renderElement = null;
|
|
|
|
renderComment = null;
|
|
|
|
renderNode = null;
|
|
|
|
renderEvent = null;
|
|
|
|
}
|
2016-05-26 16:08:39 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A regexp pattern used to interpolate in default.
|
|
|
|
*/
|
|
|
|
export var DEFAULT_INTERPOLATE_REGEXP = /\{\{([\s\S]*?)\}\}/g;
|