@angular/compiler
Version:
Angular - the compiler library
1,737 lines (1,710 loc) • 1.18 MB
JavaScript
/**
* @license Angular v5.0.2
* (c) 2010-2017 Google, Inc. https://angular.io/
* License: MIT
*/
import { __assign, __extends } from 'tslib';
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @record
*/
function Inject() { }
var createInject = makeMetadataFactory('Inject', function (token) { return ({ token: token }); });
var createInjectionToken = makeMetadataFactory('InjectionToken', function (desc) { return ({ _desc: desc }); });
/**
* @record
*/
function Attribute() { }
var createAttribute = makeMetadataFactory('Attribute', function (attributeName) { return ({ attributeName: attributeName }); });
/**
* @record
*/
function Query() { }
var createContentChildren = makeMetadataFactory('ContentChildren', function (selector, data) {
if (data === void 0) { data = {}; }
return (__assign({ selector: selector, first: false, isViewQuery: false, descendants: false }, data));
});
var createContentChild = makeMetadataFactory('ContentChild', function (selector, data) {
if (data === void 0) { data = {}; }
return (__assign({ selector: selector, first: true, isViewQuery: false, descendants: true }, data));
});
var createViewChildren = makeMetadataFactory('ViewChildren', function (selector, data) {
if (data === void 0) { data = {}; }
return (__assign({ selector: selector, first: false, isViewQuery: true, descendants: true }, data));
});
var createViewChild = makeMetadataFactory('ViewChild', function (selector, data) {
return (__assign({ selector: selector, first: true, isViewQuery: true, descendants: true }, data));
});
/**
* @record
*/
function Directive() { }
var createDirective = makeMetadataFactory('Directive', function (dir) {
if (dir === void 0) { dir = {}; }
return dir;
});
/**
* @record
*/
function Component() { }
/** @enum {number} */
var ViewEncapsulation = {
Emulated: 0,
Native: 1,
None: 2,
};
ViewEncapsulation[ViewEncapsulation.Emulated] = "Emulated";
ViewEncapsulation[ViewEncapsulation.Native] = "Native";
ViewEncapsulation[ViewEncapsulation.None] = "None";
/** @enum {number} */
var ChangeDetectionStrategy = {
OnPush: 0,
Default: 1,
};
ChangeDetectionStrategy[ChangeDetectionStrategy.OnPush] = "OnPush";
ChangeDetectionStrategy[ChangeDetectionStrategy.Default] = "Default";
var createComponent = makeMetadataFactory('Component', function (c) {
if (c === void 0) { c = {}; }
return (__assign({ changeDetection: ChangeDetectionStrategy.Default }, c));
});
/**
* @record
*/
function Pipe() { }
var createPipe = makeMetadataFactory('Pipe', function (p) { return (__assign({ pure: true }, p)); });
/**
* @record
*/
function Input() { }
var createInput = makeMetadataFactory('Input', function (bindingPropertyName) { return ({ bindingPropertyName: bindingPropertyName }); });
/**
* @record
*/
function Output() { }
var createOutput = makeMetadataFactory('Output', function (bindingPropertyName) { return ({ bindingPropertyName: bindingPropertyName }); });
/**
* @record
*/
function HostBinding() { }
var createHostBinding = makeMetadataFactory('HostBinding', function (hostPropertyName) { return ({ hostPropertyName: hostPropertyName }); });
/**
* @record
*/
function HostListener() { }
var createHostListener = makeMetadataFactory('HostListener', function (eventName, args) { return ({ eventName: eventName, args: args }); });
/**
* @record
*/
function NgModule() { }
var createNgModule = makeMetadataFactory('NgModule', function (ngModule) { return ngModule; });
/**
* @record
*/
function ModuleWithProviders() { }
/**
* @record
*/
function SchemaMetadata() { }
var CUSTOM_ELEMENTS_SCHEMA = {
name: 'custom-elements'
};
var NO_ERRORS_SCHEMA = {
name: 'no-errors-schema'
};
var createOptional = makeMetadataFactory('Optional');
var createInjectable = makeMetadataFactory('Injectable');
var createSelf = makeMetadataFactory('Self');
var createSkipSelf = makeMetadataFactory('SkipSelf');
var createHost = makeMetadataFactory('Host');
var Type = Function;
/** @enum {number} */
var SecurityContext = {
NONE: 0,
HTML: 1,
STYLE: 2,
SCRIPT: 3,
URL: 4,
RESOURCE_URL: 5,
};
SecurityContext[SecurityContext.NONE] = "NONE";
SecurityContext[SecurityContext.HTML] = "HTML";
SecurityContext[SecurityContext.STYLE] = "STYLE";
SecurityContext[SecurityContext.SCRIPT] = "SCRIPT";
SecurityContext[SecurityContext.URL] = "URL";
SecurityContext[SecurityContext.RESOURCE_URL] = "RESOURCE_URL";
/** @enum {number} */
var NodeFlags = {
None: 0,
TypeElement: 1,
TypeText: 2,
ProjectedTemplate: 4,
CatRenderNode: 3,
TypeNgContent: 8,
TypePipe: 16,
TypePureArray: 32,
TypePureObject: 64,
TypePurePipe: 128,
CatPureExpression: 224,
TypeValueProvider: 256,
TypeClassProvider: 512,
TypeFactoryProvider: 1024,
TypeUseExistingProvider: 2048,
LazyProvider: 4096,
PrivateProvider: 8192,
TypeDirective: 16384,
Component: 32768,
CatProviderNoDirective: 3840,
CatProvider: 20224,
OnInit: 65536,
OnDestroy: 131072,
DoCheck: 262144,
OnChanges: 524288,
AfterContentInit: 1048576,
AfterContentChecked: 2097152,
AfterViewInit: 4194304,
AfterViewChecked: 8388608,
EmbeddedViews: 16777216,
ComponentView: 33554432,
TypeContentQuery: 67108864,
TypeViewQuery: 134217728,
StaticQuery: 268435456,
DynamicQuery: 536870912,
CatQuery: 201326592,
// mutually exclusive values...
Types: 201347067,
};
/** @enum {number} */
var DepFlags = {
None: 0,
SkipSelf: 1,
Optional: 2,
Value: 8,
};
/** @enum {number} */
var ArgumentType = { Inline: 0, Dynamic: 1, };
/** @enum {number} */
var BindingFlags = {
TypeElementAttribute: 1,
TypeElementClass: 2,
TypeElementStyle: 4,
TypeProperty: 8,
SyntheticProperty: 16,
SyntheticHostProperty: 32,
CatSyntheticProperty: 48,
// mutually exclusive values...
Types: 15,
};
/** @enum {number} */
var QueryBindingType = { First: 0, All: 1, };
/** @enum {number} */
var QueryValueType = {
ElementRef: 0,
RenderElement: 1,
TemplateRef: 2,
ViewContainerRef: 3,
Provider: 4,
};
/** @enum {number} */
var ViewFlags = {
None: 0,
OnPush: 2,
};
/** @enum {number} */
var MissingTranslationStrategy = {
Error: 0,
Warning: 1,
Ignore: 2,
};
MissingTranslationStrategy[MissingTranslationStrategy.Error] = "Error";
MissingTranslationStrategy[MissingTranslationStrategy.Warning] = "Warning";
MissingTranslationStrategy[MissingTranslationStrategy.Ignore] = "Ignore";
/**
* @record
*/
function MetadataFactory() { }
/**
* @template T
* @param {?} name
* @param {?=} props
* @return {?}
*/
function makeMetadataFactory(name, props) {
var /** @type {?} */ factory = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var /** @type {?} */ values = props ? props.apply(void 0, args) : {};
return __assign({ ngMetadataName: name }, values);
};
factory.isTypeOf = function (obj) { return obj && obj.ngMetadataName === name; };
factory.ngMetadataName = name;
return factory;
}
/**
* @record
*/
function Route() { }
var core = Object.freeze({
Inject: Inject,
createInject: createInject,
createInjectionToken: createInjectionToken,
Attribute: Attribute,
createAttribute: createAttribute,
Query: Query,
createContentChildren: createContentChildren,
createContentChild: createContentChild,
createViewChildren: createViewChildren,
createViewChild: createViewChild,
Directive: Directive,
createDirective: createDirective,
Component: Component,
ViewEncapsulation: ViewEncapsulation,
ChangeDetectionStrategy: ChangeDetectionStrategy,
createComponent: createComponent,
Pipe: Pipe,
createPipe: createPipe,
Input: Input,
createInput: createInput,
Output: Output,
createOutput: createOutput,
HostBinding: HostBinding,
createHostBinding: createHostBinding,
HostListener: HostListener,
createHostListener: createHostListener,
NgModule: NgModule,
createNgModule: createNgModule,
ModuleWithProviders: ModuleWithProviders,
SchemaMetadata: SchemaMetadata,
CUSTOM_ELEMENTS_SCHEMA: CUSTOM_ELEMENTS_SCHEMA,
NO_ERRORS_SCHEMA: NO_ERRORS_SCHEMA,
createOptional: createOptional,
createInjectable: createInjectable,
createSelf: createSelf,
createSkipSelf: createSkipSelf,
createHost: createHost,
Type: Type,
SecurityContext: SecurityContext,
NodeFlags: NodeFlags,
DepFlags: DepFlags,
ArgumentType: ArgumentType,
BindingFlags: BindingFlags,
QueryBindingType: QueryBindingType,
QueryValueType: QueryValueType,
ViewFlags: ViewFlags,
MissingTranslationStrategy: MissingTranslationStrategy,
MetadataFactory: MetadataFactory,
Route: Route
});
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var DASH_CASE_REGEXP = /-+([a-z0-9])/g;
/**
* @param {?} input
* @return {?}
*/
function dashCaseToCamelCase(input) {
return input.replace(DASH_CASE_REGEXP, function () {
var m = [];
for (var _i = 0; _i < arguments.length; _i++) {
m[_i] = arguments[_i];
}
return m[1].toUpperCase();
});
}
/**
* @param {?} input
* @param {?} defaultValues
* @return {?}
*/
function splitAtColon(input, defaultValues) {
return _splitAt(input, ':', defaultValues);
}
/**
* @param {?} input
* @param {?} defaultValues
* @return {?}
*/
function splitAtPeriod(input, defaultValues) {
return _splitAt(input, '.', defaultValues);
}
/**
* @param {?} input
* @param {?} character
* @param {?} defaultValues
* @return {?}
*/
function _splitAt(input, character, defaultValues) {
var /** @type {?} */ characterIndex = input.indexOf(character);
if (characterIndex == -1)
return defaultValues;
return [input.slice(0, characterIndex).trim(), input.slice(characterIndex + 1).trim()];
}
/**
* @param {?} value
* @param {?} visitor
* @param {?} context
* @return {?}
*/
function visitValue(value, visitor, context) {
if (Array.isArray(value)) {
return visitor.visitArray(/** @type {?} */ (value), context);
}
if (isStrictStringMap(value)) {
return visitor.visitStringMap(/** @type {?} */ (value), context);
}
if (value == null || typeof value == 'string' || typeof value == 'number' ||
typeof value == 'boolean') {
return visitor.visitPrimitive(value, context);
}
return visitor.visitOther(value, context);
}
/**
* @param {?} val
* @return {?}
*/
function isDefined(val) {
return val !== null && val !== undefined;
}
/**
* @template T
* @param {?} val
* @return {?}
*/
function noUndefined(val) {
return val === undefined ? /** @type {?} */ ((null)) : val;
}
/**
* @record
*/
var ValueTransformer = (function () {
function ValueTransformer() {
}
/**
* @param {?} arr
* @param {?} context
* @return {?}
*/
ValueTransformer.prototype.visitArray = /**
* @param {?} arr
* @param {?} context
* @return {?}
*/
function (arr, context) {
var _this = this;
return arr.map(function (value) { return visitValue(value, _this, context); });
};
/**
* @param {?} map
* @param {?} context
* @return {?}
*/
ValueTransformer.prototype.visitStringMap = /**
* @param {?} map
* @param {?} context
* @return {?}
*/
function (map, context) {
var _this = this;
var /** @type {?} */ result = {};
Object.keys(map).forEach(function (key) { result[key] = visitValue(map[key], _this, context); });
return result;
};
/**
* @param {?} value
* @param {?} context
* @return {?}
*/
ValueTransformer.prototype.visitPrimitive = /**
* @param {?} value
* @param {?} context
* @return {?}
*/
function (value, context) { return value; };
/**
* @param {?} value
* @param {?} context
* @return {?}
*/
ValueTransformer.prototype.visitOther = /**
* @param {?} value
* @param {?} context
* @return {?}
*/
function (value, context) { return value; };
return ValueTransformer;
}());
var SyncAsync = {
assertSync: function (value) {
if (isPromise(value)) {
throw new Error("Illegal state: value cannot be a promise");
}
return value;
},
then: function (value, cb) { return isPromise(value) ? value.then(cb) : cb(value); },
all: function (syncAsyncValues) {
return syncAsyncValues.some(isPromise) ? Promise.all(syncAsyncValues) : /** @type {?} */ (syncAsyncValues);
}
};
/**
* @param {?} msg
* @param {?=} parseErrors
* @return {?}
*/
function syntaxError(msg, parseErrors) {
var /** @type {?} */ error = Error(msg);
(/** @type {?} */ (error))[ERROR_SYNTAX_ERROR] = true;
if (parseErrors)
(/** @type {?} */ (error))[ERROR_PARSE_ERRORS] = parseErrors;
return error;
}
var ERROR_SYNTAX_ERROR = 'ngSyntaxError';
var ERROR_PARSE_ERRORS = 'ngParseErrors';
/**
* @param {?} error
* @return {?}
*/
function isSyntaxError(error) {
return (/** @type {?} */ (error))[ERROR_SYNTAX_ERROR];
}
/**
* @param {?} error
* @return {?}
*/
function getParseErrors(error) {
return (/** @type {?} */ (error))[ERROR_PARSE_ERRORS] || [];
}
/**
* @param {?} s
* @return {?}
*/
function escapeRegExp(s) {
return s.replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');
}
var STRING_MAP_PROTO = Object.getPrototypeOf({});
/**
* @param {?} obj
* @return {?}
*/
function isStrictStringMap(obj) {
return typeof obj === 'object' && obj !== null && Object.getPrototypeOf(obj) === STRING_MAP_PROTO;
}
/**
* @param {?} str
* @return {?}
*/
function utf8Encode(str) {
var /** @type {?} */ encoded = '';
for (var /** @type {?} */ index = 0; index < str.length; index++) {
var /** @type {?} */ codePoint = str.charCodeAt(index);
// decode surrogate
// see https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
if (codePoint >= 0xd800 && codePoint <= 0xdbff && str.length > (index + 1)) {
var /** @type {?} */ low = str.charCodeAt(index + 1);
if (low >= 0xdc00 && low <= 0xdfff) {
index++;
codePoint = ((codePoint - 0xd800) << 10) + low - 0xdc00 + 0x10000;
}
}
if (codePoint <= 0x7f) {
encoded += String.fromCharCode(codePoint);
}
else if (codePoint <= 0x7ff) {
encoded += String.fromCharCode(((codePoint >> 6) & 0x1F) | 0xc0, (codePoint & 0x3f) | 0x80);
}
else if (codePoint <= 0xffff) {
encoded += String.fromCharCode((codePoint >> 12) | 0xe0, ((codePoint >> 6) & 0x3f) | 0x80, (codePoint & 0x3f) | 0x80);
}
else if (codePoint <= 0x1fffff) {
encoded += String.fromCharCode(((codePoint >> 18) & 0x07) | 0xf0, ((codePoint >> 12) & 0x3f) | 0x80, ((codePoint >> 6) & 0x3f) | 0x80, (codePoint & 0x3f) | 0x80);
}
}
return encoded;
}
/**
* @record
*/
/**
* @param {?} token
* @return {?}
*/
function stringify(token) {
if (typeof token === 'string') {
return token;
}
if (token instanceof Array) {
return '[' + token.map(stringify).join(', ') + ']';
}
if (token == null) {
return '' + token;
}
if (token.overriddenName) {
return "" + token.overriddenName;
}
if (token.name) {
return "" + token.name;
}
var /** @type {?} */ res = token.toString();
if (res == null) {
return '' + res;
}
var /** @type {?} */ newLineIndex = res.indexOf('\n');
return newLineIndex === -1 ? res : res.substring(0, newLineIndex);
}
/**
* Lazily retrieves the reference value from a forwardRef.
* @param {?} type
* @return {?}
*/
function resolveForwardRef(type) {
if (typeof type === 'function' && type.hasOwnProperty('__forward_ref__')) {
return type();
}
else {
return type;
}
}
/**
* Determine if the argument is shaped like a Promise
* @param {?} obj
* @return {?}
*/
function isPromise(obj) {
// allow any Promise/A+ compliant thenable.
// It's up to the caller to ensure that obj.then conforms to the spec
return !!obj && typeof obj.then === 'function';
}
var Version = (function () {
function Version(full) {
this.full = full;
var /** @type {?} */ splits = full.split('.');
this.major = splits[0];
this.minor = splits[1];
this.patch = splits.slice(2).join('.');
}
return Version;
}());
/**
* @record
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @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
* Entry point for all public APIs of the common package.
*/
/**
* \@stable
*/
var VERSION = new Version('5.0.2');
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* An Abstract Syntax Tree node representing part of a parsed Angular template.
* @record
*/
/**
* A segment of text within the template.
*/
var TextAst = (function () {
function TextAst(value, ngContentIndex, sourceSpan) {
this.value = value;
this.ngContentIndex = ngContentIndex;
this.sourceSpan = sourceSpan;
}
/**
* @param {?} visitor
* @param {?} context
* @return {?}
*/
TextAst.prototype.visit = /**
* @param {?} visitor
* @param {?} context
* @return {?}
*/
function (visitor, context) { return visitor.visitText(this, context); };
return TextAst;
}());
/**
* A bound expression within the text of a template.
*/
var BoundTextAst = (function () {
function BoundTextAst(value, ngContentIndex, sourceSpan) {
this.value = value;
this.ngContentIndex = ngContentIndex;
this.sourceSpan = sourceSpan;
}
/**
* @param {?} visitor
* @param {?} context
* @return {?}
*/
BoundTextAst.prototype.visit = /**
* @param {?} visitor
* @param {?} context
* @return {?}
*/
function (visitor, context) {
return visitor.visitBoundText(this, context);
};
return BoundTextAst;
}());
/**
* A plain attribute on an element.
*/
var AttrAst = (function () {
function AttrAst(name, value, sourceSpan) {
this.name = name;
this.value = value;
this.sourceSpan = sourceSpan;
}
/**
* @param {?} visitor
* @param {?} context
* @return {?}
*/
AttrAst.prototype.visit = /**
* @param {?} visitor
* @param {?} context
* @return {?}
*/
function (visitor, context) { return visitor.visitAttr(this, context); };
return AttrAst;
}());
/**
* A binding for an element property (e.g. `[property]="expression"`) or an animation trigger (e.g.
* `[\@trigger]="stateExp"`)
*/
var BoundElementPropertyAst = (function () {
function BoundElementPropertyAst(name, type, securityContext, value, unit, sourceSpan) {
this.name = name;
this.type = type;
this.securityContext = securityContext;
this.value = value;
this.unit = unit;
this.sourceSpan = sourceSpan;
this.isAnimation = this.type === PropertyBindingType.Animation;
}
/**
* @param {?} visitor
* @param {?} context
* @return {?}
*/
BoundElementPropertyAst.prototype.visit = /**
* @param {?} visitor
* @param {?} context
* @return {?}
*/
function (visitor, context) {
return visitor.visitElementProperty(this, context);
};
return BoundElementPropertyAst;
}());
/**
* A binding for an element event (e.g. `(event)="handler()"`) or an animation trigger event (e.g.
* `(\@trigger.phase)="callback($event)"`).
*/
var BoundEventAst = (function () {
function BoundEventAst(name, target, phase, handler, sourceSpan) {
this.name = name;
this.target = target;
this.phase = phase;
this.handler = handler;
this.sourceSpan = sourceSpan;
this.fullName = BoundEventAst.calcFullName(this.name, this.target, this.phase);
this.isAnimation = !!this.phase;
}
/**
* @param {?} name
* @param {?} target
* @param {?} phase
* @return {?}
*/
BoundEventAst.calcFullName = /**
* @param {?} name
* @param {?} target
* @param {?} phase
* @return {?}
*/
function (name, target, phase) {
if (target) {
return target + ":" + name;
}
else if (phase) {
return "@" + name + "." + phase;
}
else {
return name;
}
};
/**
* @param {?} visitor
* @param {?} context
* @return {?}
*/
BoundEventAst.prototype.visit = /**
* @param {?} visitor
* @param {?} context
* @return {?}
*/
function (visitor, context) {
return visitor.visitEvent(this, context);
};
return BoundEventAst;
}());
/**
* A reference declaration on an element (e.g. `let someName="expression"`).
*/
var ReferenceAst = (function () {
function ReferenceAst(name, value, sourceSpan) {
this.name = name;
this.value = value;
this.sourceSpan = sourceSpan;
}
/**
* @param {?} visitor
* @param {?} context
* @return {?}
*/
ReferenceAst.prototype.visit = /**
* @param {?} visitor
* @param {?} context
* @return {?}
*/
function (visitor, context) {
return visitor.visitReference(this, context);
};
return ReferenceAst;
}());
/**
* A variable declaration on a <ng-template> (e.g. `var-someName="someLocalName"`).
*/
var VariableAst = (function () {
function VariableAst(name, value, sourceSpan) {
this.name = name;
this.value = value;
this.sourceSpan = sourceSpan;
}
/**
* @param {?} visitor
* @param {?} context
* @return {?}
*/
VariableAst.prototype.visit = /**
* @param {?} visitor
* @param {?} context
* @return {?}
*/
function (visitor, context) {
return visitor.visitVariable(this, context);
};
return VariableAst;
}());
/**
* An element declaration in a template.
*/
var ElementAst = (function () {
function ElementAst(name, attrs, inputs, outputs, references, directives, providers, hasViewContainer, queryMatches, children, ngContentIndex, sourceSpan, endSourceSpan) {
this.name = name;
this.attrs = attrs;
this.inputs = inputs;
this.outputs = outputs;
this.references = references;
this.directives = directives;
this.providers = providers;
this.hasViewContainer = hasViewContainer;
this.queryMatches = queryMatches;
this.children = children;
this.ngContentIndex = ngContentIndex;
this.sourceSpan = sourceSpan;
this.endSourceSpan = endSourceSpan;
}
/**
* @param {?} visitor
* @param {?} context
* @return {?}
*/
ElementAst.prototype.visit = /**
* @param {?} visitor
* @param {?} context
* @return {?}
*/
function (visitor, context) {
return visitor.visitElement(this, context);
};
return ElementAst;
}());
/**
* A `<ng-template>` element included in an Angular template.
*/
var EmbeddedTemplateAst = (function () {
function EmbeddedTemplateAst(attrs, outputs, references, variables, directives, providers, hasViewContainer, queryMatches, children, ngContentIndex, sourceSpan) {
this.attrs = attrs;
this.outputs = outputs;
this.references = references;
this.variables = variables;
this.directives = directives;
this.providers = providers;
this.hasViewContainer = hasViewContainer;
this.queryMatches = queryMatches;
this.children = children;
this.ngContentIndex = ngContentIndex;
this.sourceSpan = sourceSpan;
}
/**
* @param {?} visitor
* @param {?} context
* @return {?}
*/
EmbeddedTemplateAst.prototype.visit = /**
* @param {?} visitor
* @param {?} context
* @return {?}
*/
function (visitor, context) {
return visitor.visitEmbeddedTemplate(this, context);
};
return EmbeddedTemplateAst;
}());
/**
* A directive property with a bound value (e.g. `*ngIf="condition").
*/
var BoundDirectivePropertyAst = (function () {
function BoundDirectivePropertyAst(directiveName, templateName, value, sourceSpan) {
this.directiveName = directiveName;
this.templateName = templateName;
this.value = value;
this.sourceSpan = sourceSpan;
}
/**
* @param {?} visitor
* @param {?} context
* @return {?}
*/
BoundDirectivePropertyAst.prototype.visit = /**
* @param {?} visitor
* @param {?} context
* @return {?}
*/
function (visitor, context) {
return visitor.visitDirectiveProperty(this, context);
};
return BoundDirectivePropertyAst;
}());
/**
* A directive declared on an element.
*/
var DirectiveAst = (function () {
function DirectiveAst(directive, inputs, hostProperties, hostEvents, contentQueryStartId, sourceSpan) {
this.directive = directive;
this.inputs = inputs;
this.hostProperties = hostProperties;
this.hostEvents = hostEvents;
this.contentQueryStartId = contentQueryStartId;
this.sourceSpan = sourceSpan;
}
/**
* @param {?} visitor
* @param {?} context
* @return {?}
*/
DirectiveAst.prototype.visit = /**
* @param {?} visitor
* @param {?} context
* @return {?}
*/
function (visitor, context) {
return visitor.visitDirective(this, context);
};
return DirectiveAst;
}());
/**
* A provider declared on an element
*/
var ProviderAst = (function () {
function ProviderAst(token, multiProvider, eager, providers, providerType, lifecycleHooks, sourceSpan) {
this.token = token;
this.multiProvider = multiProvider;
this.eager = eager;
this.providers = providers;
this.providerType = providerType;
this.lifecycleHooks = lifecycleHooks;
this.sourceSpan = sourceSpan;
}
/**
* @param {?} visitor
* @param {?} context
* @return {?}
*/
ProviderAst.prototype.visit = /**
* @param {?} visitor
* @param {?} context
* @return {?}
*/
function (visitor, context) {
// No visit method in the visitor for now...
return null;
};
return ProviderAst;
}());
/** @enum {number} */
var ProviderAstType = {
PublicService: 0,
PrivateService: 1,
Component: 2,
Directive: 3,
Builtin: 4,
};
ProviderAstType[ProviderAstType.PublicService] = "PublicService";
ProviderAstType[ProviderAstType.PrivateService] = "PrivateService";
ProviderAstType[ProviderAstType.Component] = "Component";
ProviderAstType[ProviderAstType.Directive] = "Directive";
ProviderAstType[ProviderAstType.Builtin] = "Builtin";
/**
* Position where content is to be projected (instance of `<ng-content>` in a template).
*/
var NgContentAst = (function () {
function NgContentAst(index, ngContentIndex, sourceSpan) {
this.index = index;
this.ngContentIndex = ngContentIndex;
this.sourceSpan = sourceSpan;
}
/**
* @param {?} visitor
* @param {?} context
* @return {?}
*/
NgContentAst.prototype.visit = /**
* @param {?} visitor
* @param {?} context
* @return {?}
*/
function (visitor, context) {
return visitor.visitNgContent(this, context);
};
return NgContentAst;
}());
/** @enum {number} */
var PropertyBindingType = {
/**
* A normal binding to a property (e.g. `[property]="expression"`).
*/
Property: 0,
/**
* A binding to an element attribute (e.g. `[attr.name]="expression"`).
*/
Attribute: 1,
/**
* A binding to a CSS class (e.g. `[class.name]="condition"`).
*/
Class: 2,
/**
* A binding to a style rule (e.g. `[style.rule]="expression"`).
*/
Style: 3,
/**
* A binding to an animation reference (e.g. `[animate.key]="expression"`).
*/
Animation: 4,
};
PropertyBindingType[PropertyBindingType.Property] = "Property";
PropertyBindingType[PropertyBindingType.Attribute] = "Attribute";
PropertyBindingType[PropertyBindingType.Class] = "Class";
PropertyBindingType[PropertyBindingType.Style] = "Style";
PropertyBindingType[PropertyBindingType.Animation] = "Animation";
/**
* @record
*/
/**
* A visitor for {\@link TemplateAst} trees that will process each node.
* @record
*/
/**
* A visitor that accepts each node but doesn't do anything. It is intended to be used
* as the base class for a visitor that is only interested in a subset of the node types.
*/
var NullTemplateVisitor = (function () {
function NullTemplateVisitor() {
}
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
NullTemplateVisitor.prototype.visitNgContent = /**
* @param {?} ast
* @param {?} context
* @return {?}
*/
function (ast, context) { };
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
NullTemplateVisitor.prototype.visitEmbeddedTemplate = /**
* @param {?} ast
* @param {?} context
* @return {?}
*/
function (ast, context) { };
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
NullTemplateVisitor.prototype.visitElement = /**
* @param {?} ast
* @param {?} context
* @return {?}
*/
function (ast, context) { };
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
NullTemplateVisitor.prototype.visitReference = /**
* @param {?} ast
* @param {?} context
* @return {?}
*/
function (ast, context) { };
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
NullTemplateVisitor.prototype.visitVariable = /**
* @param {?} ast
* @param {?} context
* @return {?}
*/
function (ast, context) { };
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
NullTemplateVisitor.prototype.visitEvent = /**
* @param {?} ast
* @param {?} context
* @return {?}
*/
function (ast, context) { };
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
NullTemplateVisitor.prototype.visitElementProperty = /**
* @param {?} ast
* @param {?} context
* @return {?}
*/
function (ast, context) { };
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
NullTemplateVisitor.prototype.visitAttr = /**
* @param {?} ast
* @param {?} context
* @return {?}
*/
function (ast, context) { };
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
NullTemplateVisitor.prototype.visitBoundText = /**
* @param {?} ast
* @param {?} context
* @return {?}
*/
function (ast, context) { };
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
NullTemplateVisitor.prototype.visitText = /**
* @param {?} ast
* @param {?} context
* @return {?}
*/
function (ast, context) { };
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
NullTemplateVisitor.prototype.visitDirective = /**
* @param {?} ast
* @param {?} context
* @return {?}
*/
function (ast, context) { };
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
NullTemplateVisitor.prototype.visitDirectiveProperty = /**
* @param {?} ast
* @param {?} context
* @return {?}
*/
function (ast, context) { };
return NullTemplateVisitor;
}());
/**
* Base class that can be used to build a visitor that visits each node
* in an template ast recursively.
*/
var RecursiveTemplateAstVisitor = (function (_super) {
__extends(RecursiveTemplateAstVisitor, _super);
function RecursiveTemplateAstVisitor() {
return _super.call(this) || this;
}
// Nodes with children
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
RecursiveTemplateAstVisitor.prototype.visitEmbeddedTemplate = /**
* @param {?} ast
* @param {?} context
* @return {?}
*/
function (ast, context) {
return this.visitChildren(context, function (visit) {
visit(ast.attrs);
visit(ast.references);
visit(ast.variables);
visit(ast.directives);
visit(ast.providers);
visit(ast.children);
});
};
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
RecursiveTemplateAstVisitor.prototype.visitElement = /**
* @param {?} ast
* @param {?} context
* @return {?}
*/
function (ast, context) {
return this.visitChildren(context, function (visit) {
visit(ast.attrs);
visit(ast.inputs);
visit(ast.outputs);
visit(ast.references);
visit(ast.directives);
visit(ast.providers);
visit(ast.children);
});
};
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
RecursiveTemplateAstVisitor.prototype.visitDirective = /**
* @param {?} ast
* @param {?} context
* @return {?}
*/
function (ast, context) {
return this.visitChildren(context, function (visit) {
visit(ast.inputs);
visit(ast.hostProperties);
visit(ast.hostEvents);
});
};
/**
* @template T
* @param {?} context
* @param {?} cb
* @return {?}
*/
RecursiveTemplateAstVisitor.prototype.visitChildren = /**
* @template T
* @param {?} context
* @param {?} cb
* @return {?}
*/
function (context, cb) {
var /** @type {?} */ results = [];
var /** @type {?} */ t = this;
/**
* @template T
* @param {?} children
* @return {?}
*/
function visit(children) {
if (children && children.length)
results.push(templateVisitAll(t, children, context));
}
cb(visit);
return [].concat.apply([], results);
};
return RecursiveTemplateAstVisitor;
}(NullTemplateVisitor));
/**
* Visit every node in a list of {\@link TemplateAst}s with the given {\@link TemplateAstVisitor}.
* @param {?} visitor
* @param {?} asts
* @param {?=} context
* @return {?}
*/
function templateVisitAll(visitor, asts, context) {
if (context === void 0) { context = null; }
var /** @type {?} */ result = [];
var /** @type {?} */ visit = visitor.visit ?
function (ast) { return /** @type {?} */ ((visitor.visit))(ast, context) || ast.visit(visitor, context); } :
function (ast) { return ast.visit(visitor, context); };
asts.forEach(function (ast) {
var /** @type {?} */ astResult = visit(ast);
if (astResult) {
result.push(astResult);
}
});
return result;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var CompilerConfig = (function () {
function CompilerConfig(_a) {
var _b = _a === void 0 ? {} : _a, _c = _b.defaultEncapsulation, defaultEncapsulation = _c === void 0 ? ViewEncapsulation.Emulated : _c, _d = _b.useJit, useJit = _d === void 0 ? true : _d, _e = _b.jitDevMode, jitDevMode = _e === void 0 ? false : _e, _f = _b.missingTranslation, missingTranslation = _f === void 0 ? null : _f, enableLegacyTemplate = _b.enableLegacyTemplate, preserveWhitespaces = _b.preserveWhitespaces, strictInjectionParameters = _b.strictInjectionParameters;
this.defaultEncapsulation = defaultEncapsulation;
this.useJit = !!useJit;
this.jitDevMode = !!jitDevMode;
this.missingTranslation = missingTranslation;
this.enableLegacyTemplate = enableLegacyTemplate === true;
this.preserveWhitespaces = preserveWhitespacesDefault(noUndefined(preserveWhitespaces));
this.strictInjectionParameters = strictInjectionParameters === true;
}
return CompilerConfig;
}());
/**
* @param {?} preserveWhitespacesOption
* @param {?=} defaultSetting
* @return {?}
*/
function preserveWhitespacesDefault(preserveWhitespacesOption, defaultSetting) {
if (defaultSetting === void 0) { defaultSetting = true; }
return preserveWhitespacesOption === null ? defaultSetting : preserveWhitespacesOption;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* A token representing the a reference to a static type.
*
* This token is unique for a filePath and name and can be used as a hash table key.
*/
var StaticSymbol = (function () {
function StaticSymbol(filePath, name, members) {
this.filePath = filePath;
this.name = name;
this.members = members;
}
/**
* @return {?}
*/
StaticSymbol.prototype.assertNoMembers = /**
* @return {?}
*/
function () {
if (this.members.length) {
throw new Error("Illegal state: symbol without members expected, but got " + JSON.stringify(this) + ".");
}
};
return StaticSymbol;
}());
/**
* A cache of static symbol used by the StaticReflector to return the same symbol for the
* same symbol values.
*/
var StaticSymbolCache = (function () {
function StaticSymbolCache() {
this.cache = new Map();
}
/**
* @param {?} declarationFile
* @param {?} name
* @param {?=} members
* @return {?}
*/
StaticSymbolCache.prototype.get = /**
* @param {?} declarationFile
* @param {?} name
* @param {?=} members
* @return {?}
*/
function (declarationFile, name, members) {
members = members || [];
var /** @type {?} */ memberSuffix = members.length ? "." + members.join('.') : '';
var /** @type {?} */ key = "\"" + declarationFile + "\"." + name + memberSuffix;
var /** @type {?} */ result = this.cache.get(key);
if (!result) {
result = new StaticSymbol(declarationFile, name, members);
this.cache.set(key, result);
}
return result;
};
return StaticSymbolCache;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @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
*/
// group 0: "[prop] or (event) or @trigger"
// group 1: "prop" from "[prop]"
// group 2: "event" from "(event)"
// group 3: "@trigger" from "@trigger"
var HOST_REG_EXP = /^(?:(?:\[([^\]]+)\])|(?:\(([^\)]+)\)))|(\@[-\w]+)$/;
/**
* @param {?} name
* @return {?}
*/
function _sanitizeIdentifier(name) {
return name.replace(/\W/g, '_');
}
var _anonymousTypeIndex = 0;
/**
* @param {?} compileIdentifier
* @return {?}
*/
function identifierName(compileIdentifier) {
if (!compileIdentifier || !compileIdentifier.reference) {
return null;
}
var /** @type {?} */ ref = compileIdentifier.reference;
if (ref instanceof StaticSymbol) {
return ref.name;
}
if (ref['__anonymousType']) {
return ref['__anonymousType'];
}
var /** @type {?} */ identifier = stringify(ref);
if (identifier.indexOf('(') >= 0) {
// case: anonymous functions!
identifier = "anonymous_" + _anonymousTypeIndex++;
ref['__anonymousType'] = identifier;
}
else {
identifier = _sanitizeIdentifier(identifier);
}
return identifier;
}
/**
* @param {?} compileIdentifier
* @return {?}
*/
function identifierModuleUrl(compileIdentifier) {
var /** @type {?} */ ref = compileIdentifier.reference;
if (ref instanceof StaticSymbol) {
return ref.filePath;
}
// Runtime type
return "./" + stringify(ref);
}
/**
* @param {?} compType
* @param {?} embeddedTemplateIndex
* @return {?}
*/
function viewClassName(compType, embeddedTemplateIndex) {
return "View_" + identifierName({ reference: compType }) + "_" + embeddedTemplateIndex;
}
/**
* @param {?} compType
* @return {?}
*/
function rendererTypeName(compType) {
return "RenderType_" + identifierName({ reference: compType });
}
/**
* @param {?} compType
* @return {?}
*/
function hostViewClassName(compType) {
return "HostView_" + identifierName({ reference: compType });
}
/**
* @param {?} compType
* @return {?}
*/
function componentFactoryName(compType) {
return identifierName({ reference: compType }) + "NgFactory";
}
/**
* @record
*/
/**
* @record
*/
/** @enum {number} */
var CompileSummaryKind = {
Pipe: 0,
Directive: 1,
NgModule: 2,
Injectable: 3,
};
CompileSummaryKind[CompileSummaryKind.Pipe] = "Pipe";
CompileSummaryKind[CompileSummaryKind.Directive] = "Directive";
CompileSummaryKind[CompileSummaryKind.NgModule] = "NgModule";
CompileSummaryKind[CompileSummaryKind.Injectable] = "Injectable";
/**
* A CompileSummary is the data needed to use a directive / pipe / module
* in other modules / components. However, this data is not enough to compile
* the directive / module itself.
* @record
*/
/**
* @record
*/
/**
* @record
*/
/**
* @record
*/
/**
* @param {?} token
* @return {?}
*/
function tokenName(token) {
return token.value != null ? _sanitizeIdentifier(token.value) : identifierName(token.identifier);
}
/**
* @param {?} token
* @return {?}
*/
function tokenReference(token) {
if (token.identifier != null) {
return token.identifier.reference;
}
else {
return token.value;
}
}
/**
* @record
*/
/**
* Metadata regarding compilation of a type.
* @record
*/
/**
* @record
*/
/**
* Metadata about a stylesheet
*/
var CompileStylesheetMetadata = (function () {
function CompileStylesheetMetadata(_a) {
var _b = _a === void 0 ? {} : _a, moduleUrl = _b.moduleUrl, styles = _b.styles, styleUrls = _b.styleUrls;
this.moduleUrl = moduleUrl || null;
this.styles = _normalizeArray(styles);
this.styleUrls = _normalizeArray(styleUrls);
}
return CompileStylesheetMetadata;
}());
/**
* Summary Metadata regarding compilation of a template.
* @record
*/
/**
* Metadata regarding compilation of a template.
*/
var CompileTemplateMetadata = (function () {
function CompileTemplateMetadata(_a) {
var encapsulation = _a.encapsulation, template = _a.template, templateUrl = _a.templateUrl, htmlAst = _a.htmlAst, styles = _a.styles, styleUrls = _a.styleUrls, externalStylesheets = _a.externalStylesheets, animations = _a.animations, ngContentSelectors = _a.ngContentSelectors, interpolation = _a.interpolation, isInline = _a.isInline, preserveWhitespaces = _a.preserveWhitespaces;
this.encapsulation = encapsulation;
this.template = template;
this.templateUrl = templateUrl;
this.htmlAst = htmlAst;
this.styles = _normalizeArray(styles);
this.styleUrls = _normalizeArray(styleUrls);
this.externalStylesheets = _normalizeArray(externalStylesheets);
this.animations = animations ? flatten(animations) : [];
this.ngContentSelectors = ngContentSelectors || [];
if (interpolation && interpolation.length != 2) {
throw new Error("'interpolation' should have a start and an end symbol.");
}
this.interpolation = interpolation;
this.isInline = isInline;
this.preserveWhitespaces = preserveWhitespaces;
}
/**
* @return {?}
*/
CompileTemplateMetadata.prototype.toSummary = /**
* @return {?}
*/
function () {
return {
ngContentSelectors: this.ngContentSelectors,
encapsulation: this.encapsulation,
};
};
return CompileTemplateMetadata;
}());
/**
* @record
*/
/**
* @record
*/
/**
* Metadata regarding compilation of a directive.
*/
var CompileDirectiveMetadata = (function () {
function CompileDirectiveMetadata(_a) {
var isHost = _a.isHost, type = _a.type, isComponent = _a.isComponent, selector = _a.selector, exportAs = _a.exportAs, changeDetection = _a.changeDetection, inputs = _a.inputs, outputs = _a.outputs, hostListeners = _a.hostListeners, hostProperties = _a.hostProperties, hostAttributes = _a.hostAttributes, providers = _a.providers, viewProviders = _a.viewProviders, queries = _a.queries, viewQueries = _a.viewQueries, entryComponents = _a.entryComponents, template = _a.template, componentViewType = _a.componentViewType, rendererType = _a.rendererType, componentFactory = _a.componentFactory;
this.isHost = !!isHost;
this.type = type;
this.isComponent = isComponent;
this.selector = selector;
this.exportAs = exportAs;
this.changeDetection = changeDetection;
this.inputs = inputs;
this.outputs = outputs;
this.hostListeners = hostListeners;
this.hostProperties = hostProperties;
this.hostAttributes = hostAttributes;
this.providers = _normalizeArray(providers);
this.viewProviders = _normalizeArray(viewProviders);
this.queries = _normalizeArray(queries);
this.viewQueries = _normalizeArray(viewQueries);
this.entryComponents = _normalizeArray(entryComponents);
this.template = template;
this.componentViewType = componentViewType;
this.rendererType = rendererType;
this.componentFactory = componentFactory;
}
/**
* @param {?} __0
* @return {?}
*/
CompileDirectiveMetadata.create = /**
* @param {?} __0
* @return {?}
*/
function (_a) {
var isHost = _a.isHost, type = _a.type, isComponent = _a.isComponent, selector = _a.selector, exportAs = _a.exportAs, changeDetection = _a.changeDetection, inputs = _a.inputs, outputs = _a.outputs, host = _a.host, providers = _a.providers, viewProviders = _a.viewProviders, queries = _a.queries, viewQueries = _a.viewQueries, entryComponents = _a.entryComponents, template = _a.template, componentViewType = _a.componentViewType, rendererType = _a.rendererType, componentFactory = _a.componentFactory;
var /** @type {?} */ hostListeners = {};
var /** @type {?} */ hostProperties = {};
var /** @type {?} */ hostAttributes = {};
if (host != null) {
Object.keys(host).forEach(function (key) {
var /** @type {?} */ value = host[key];
var /** @type {?} */ matches = key.match(HOST_REG_EXP);
if (matches === null) {
hostAttributes[key] = value;
}
else if (matches[1] != null) {
hostProperties[matches[1]] = value;
}
else if (matches[2] != null) {
hostListeners[matches[2]] = value;
}
});
}
var /** @type {?} */ inputsMap = {};
if (inputs != null) {
inputs.forEach(function (bindConfig) {
// canonical syntax: `dirProp: elProp`
// if there is no `:`, use dirProp = elProp
var /** @type {?} */ parts = splitAtColon(bindConfig, [bindConfig, bindConfig]);
inputsMap[parts[0]] = parts[1];
});
}
var /** @type {?} */ outputsMap = {};
if (outputs != null) {
outputs.forEach(function (bindConfig) {
// canonical syntax: `dirProp: elProp`
// if there is no `:`, use dirProp = elProp
var /** @type {?} */ parts = splitAtColon(bindConfig, [bindConfig, bindConfig]);
outputsMap[parts[0]] = parts[1];
});
}
return new CompileDirectiveMetadata({
isHost: isHost,
type: type,
isComponent: !!isComponent, selector: selector, exportAs: exportAs, changeDetection: changeDetection,
inputs: inputsMap,
outputs: outputsMap,
hostListeners: hostListeners,
hostProperties: hostProperties,
hostAttributes: hostAttributes,
providers: providers,
viewProviders: viewProviders,
queries: queries,
viewQueries: viewQueries,
entryComponents: entryComponents,
template: template,
componentViewType: componentViewType,
rendererType: rendererType,
componentFactory: componentFactory,
});
};
/**
* @return {?}
*/
CompileDirectiveMetadata.prototype.toSummary = /**
* @return {?}
*/
function () {
return {
summaryKind: CompileSummaryKind.Directive,
type: this.type,
isComponent: this.isComponent,
selector: this.selector,
exportAs: this.exportAs,
inputs: this.inputs,
outputs: this.outputs,
hostListeners: this.hostListeners,
hostProperties: this.hostProperties,
hostAttributes: this.hostAttributes,
providers: this.providers,
viewProviders: this.viewProviders,
queries: this.queries,
viewQueries: this.viewQueries,
entryComponents: this.entryCo