@angular-eslint/bundled-angular-compiler 13.1.0 → 13.1.1-alpha.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +69 -50
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v13.2.2
2
+ * @license Angular v13.3.1
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */ /**
@@ -627,7 +627,7 @@ if(/^\d+$/.test(chunks[chunks.length-1])){postfix=chunks.pop();}let raw=chunks.s
627
627
  *
628
628
  * TODO(FW-1136): this is a temporary solution, we need to come up with a better way of working with
629
629
  * inputs that contain potentially unsafe chars.
630
- */const UNSAFE_OBJECT_KEY_NAME_REGEXP=/[-.]/;/** Name of the temporary to use during data binding */const TEMPORARY_NAME='_t';/** Name of the context parameter passed into a template function */const CONTEXT_NAME='ctx';/** Name of the RenderFlag passed into a template function */const RENDER_FLAGS='rf';/** The prefix reference variables */const REFERENCE_PREFIX='_r';/** The name of the implicit context reference */const IMPLICIT_REFERENCE='$implicit';/** Non bindable attribute name **/const NON_BINDABLE_ATTR='ngNonBindable';/** Name for the variable keeping track of the context returned by `ɵɵrestoreView`. */const RESTORED_VIEW_CONTEXT_NAME='restoredCtx';/**
630
+ */const UNSAFE_OBJECT_KEY_NAME_REGEXP=/[-.]/;/** Name of the temporary to use during data binding */const TEMPORARY_NAME='_t';/** Name of the context parameter passed into a template function */const CONTEXT_NAME='ctx';/** Name of the RenderFlag passed into a template function */const RENDER_FLAGS='rf';/** The prefix reference variables */const REFERENCE_PREFIX='_r';/** The name of the implicit context reference */const IMPLICIT_REFERENCE='$implicit';/** Non bindable attribute name **/const NON_BINDABLE_ATTR='ngNonBindable';/** Name for the variable keeping track of the context returned by `ɵɵrestoreView`. */const RESTORED_VIEW_CONTEXT_NAME='restoredCtx';/** Instructions that support chaining. */const CHAINABLE_INSTRUCTIONS=new Set([Identifiers.element,Identifiers.elementStart,Identifiers.elementEnd,Identifiers.elementContainer,Identifiers.elementContainerStart,Identifiers.elementContainerEnd,Identifiers.i18nExp,Identifiers.listener,Identifiers.classProp,Identifiers.syntheticHostListener,Identifiers.hostProperty,Identifiers.syntheticHostProperty,Identifiers.property,Identifiers.propertyInterpolate1,Identifiers.propertyInterpolate2,Identifiers.propertyInterpolate3,Identifiers.propertyInterpolate4,Identifiers.propertyInterpolate5,Identifiers.propertyInterpolate6,Identifiers.propertyInterpolate7,Identifiers.propertyInterpolate8,Identifiers.propertyInterpolateV,Identifiers.attribute,Identifiers.attributeInterpolate1,Identifiers.attributeInterpolate2,Identifiers.attributeInterpolate3,Identifiers.attributeInterpolate4,Identifiers.attributeInterpolate5,Identifiers.attributeInterpolate6,Identifiers.attributeInterpolate7,Identifiers.attributeInterpolate8,Identifiers.attributeInterpolateV,Identifiers.styleProp,Identifiers.stylePropInterpolate1,Identifiers.stylePropInterpolate2,Identifiers.stylePropInterpolate3,Identifiers.stylePropInterpolate4,Identifiers.stylePropInterpolate5,Identifiers.stylePropInterpolate6,Identifiers.stylePropInterpolate7,Identifiers.stylePropInterpolate8,Identifiers.stylePropInterpolateV,Identifiers.textInterpolate,Identifiers.textInterpolate1,Identifiers.textInterpolate2,Identifiers.textInterpolate3,Identifiers.textInterpolate4,Identifiers.textInterpolate5,Identifiers.textInterpolate6,Identifiers.textInterpolate7,Identifiers.textInterpolate8,Identifiers.textInterpolateV]);/** Generates a call to a single instruction. */function invokeInstruction(span,reference,params){return importExpr(reference,null,span).callFn(params,span);}/**
631
631
  * Creates an allocator for a temporary variable.
632
632
  *
633
633
  * A variable declaration is added to the statements the first time the allocator is invoked.
@@ -655,8 +655,7 @@ switch(query.predicate.forwardRef){case 0/* None */:case 2/* Unwrapped */:return
655
655
  * @return an object set up for directive matching. For attributes on the element/template, this
656
656
  * object maps a property name to its (static) value. For any bindings, this map simply maps the
657
657
  * property name to an empty string.
658
- */function getAttrsForDirectiveMatching(elOrTpl){const attributesMap={};if(elOrTpl instanceof Template&&elOrTpl.tagName!=='ng-template'){elOrTpl.templateAttrs.forEach(a=>attributesMap[a.name]='');}else {elOrTpl.attributes.forEach(a=>{if(!isI18nAttribute(a.name)){attributesMap[a.name]=a.value;}});elOrTpl.inputs.forEach(i=>{attributesMap[i.name]='';});elOrTpl.outputs.forEach(o=>{attributesMap[o.name]='';});}return attributesMap;}/** Returns a call expression to a chained instruction, e.g. `property(params[0])(params[1])`. */function chainedInstruction(reference,calls,span){let expression=importExpr(reference,null,span);if(calls.length>0){for(let i=0;i<calls.length;i++){expression=expression.callFn(calls[i],span);}}else {// Add a blank invocation, in case the `calls` array is empty.
659
- expression=expression.callFn([],span);}return expression;}/**
658
+ */function getAttrsForDirectiveMatching(elOrTpl){const attributesMap={};if(elOrTpl instanceof Template&&elOrTpl.tagName!=='ng-template'){elOrTpl.templateAttrs.forEach(a=>attributesMap[a.name]='');}else {elOrTpl.attributes.forEach(a=>{if(!isI18nAttribute(a.name)){attributesMap[a.name]=a.value;}});elOrTpl.inputs.forEach(i=>{attributesMap[i.name]='';});elOrTpl.outputs.forEach(o=>{attributesMap[o.name]='';});}return attributesMap;}/**
660
659
  * Gets the number of arguments expected to be passed to a generated instruction in the case of
661
660
  * interpolation instructions.
662
661
  * @param interpolation An interpolation ast
@@ -664,6 +663,14 @@ expression=expression.callFn([],span);}return expression;}/**
664
663
  // strings, we only pass one argument, to a special instruction like `propertyInterpolate` or
665
664
  // `textInterpolate`.
666
665
  return 1;}else {return expressions.length+strings.length;}}/**
666
+ * Generates the final instruction call statements based on the passed in configuration.
667
+ * Will try to chain instructions as much as possible, if chaining is supported.
668
+ */function getInstructionStatements(instructions){var _a;const statements=[];let pendingExpression=null;let pendingExpressionType=null;for(const current of instructions){const resolvedParams=(_a=typeof current.paramsOrFn==='function'?current.paramsOrFn():current.paramsOrFn)!==null&&_a!==void 0?_a:[];const params=Array.isArray(resolvedParams)?resolvedParams:[resolvedParams];// If the current instruction is the same as the previous one
669
+ // and it can be chained, add another call to the chain.
670
+ if(pendingExpressionType===current.reference&&CHAINABLE_INSTRUCTIONS.has(pendingExpressionType)){// We'll always have a pending expression when there's a pending expression type.
671
+ pendingExpression=pendingExpression.callFn(params,pendingExpression.sourceSpan);}else {if(pendingExpression!==null){statements.push(pendingExpression.toStmt());}pendingExpression=invokeInstruction(current.span,current.reference,params);pendingExpressionType=current.reference;}}// Since the current instruction adds the previous one to the statements,
672
+ // we may be left with the final one at the end that is still pending.
673
+ if(pendingExpression!==null){statements.push(pendingExpression.toStmt());}return statements;}/**
667
674
  * @license
668
675
  * Copyright Google LLC All Rights Reserved.
669
676
  *
@@ -1364,7 +1371,7 @@ return contextSelectorGroups.map(contextSelectors=>combineHostContextSelectors(c
1364
1371
  * Convert combinators like ::shadow and pseudo-elements like ::content
1365
1372
  * by replacing with space.
1366
1373
  */_convertShadowDOMSelectors(cssText){return _shadowDOMSelectorsRe.reduce((result,pattern)=>result.replace(pattern,' '),cssText);}// change a selector like 'div' to 'name div'
1367
- _scopeSelectors(cssText,scopeSelector,hostSelector){return processRules(cssText,rule=>{let selector=rule.selector;let content=rule.content;if(rule.selector[0]!=='@'){selector=this._scopeSelector(rule.selector,scopeSelector,hostSelector,this.strictStyling);}else if(rule.selector.startsWith('@media')||rule.selector.startsWith('@supports')||rule.selector.startsWith('@document')){content=this._scopeSelectors(rule.content,scopeSelector,hostSelector);}else if(rule.selector.startsWith('@font-face')||rule.selector.startsWith('@page')){content=this._stripScopingSelectors(rule.content);}return new CssRule(selector,content);});}/**
1374
+ _scopeSelectors(cssText,scopeSelector,hostSelector){return processRules(cssText,rule=>{let selector=rule.selector;let content=rule.content;if(rule.selector[0]!=='@'){selector=this._scopeSelector(rule.selector,scopeSelector,hostSelector,this.strictStyling);}else if(rule.selector.startsWith('@media')||rule.selector.startsWith('@supports')||rule.selector.startsWith('@document')||rule.selector.startsWith('@layer')){content=this._scopeSelectors(rule.content,scopeSelector,hostSelector);}else if(rule.selector.startsWith('@font-face')||rule.selector.startsWith('@page')){content=this._stripScopingSelectors(rule.content);}return new CssRule(selector,content);});}/**
1368
1375
  * Handle a css text that is within a rule that should not contain scope selectors by simply
1369
1376
  * removing them! An example of such a rule is `@font-face`.
1370
1377
  *
@@ -1714,7 +1721,7 @@ const quote=this._parseQuote(input,location,absoluteOffset);if(quote!=null){retu
1714
1721
  * @param templateUrl template filename if it's external, component filename if it's inline
1715
1722
  * @param absoluteKeyOffset start of the `templateKey`
1716
1723
  * @param absoluteValueOffset start of the `templateValue`
1717
- */parseTemplateBindings(templateKey,templateValue,templateUrl,absoluteKeyOffset,absoluteValueOffset){const tokens=this._lexer.tokenize(templateValue);const parser=new _ParseAST(templateValue,templateUrl,absoluteValueOffset,tokens,0/* None */,this.errors,0/* relative offset */);return parser.parseTemplateBindings({source:templateKey,span:new AbsoluteSourceSpan(absoluteKeyOffset,absoluteKeyOffset+templateKey.length)});}parseInterpolation(input,location,absoluteOffset,interpolationConfig=DEFAULT_INTERPOLATION_CONFIG){const{strings,expressions,offsets}=this.splitInterpolation(input,location,interpolationConfig);if(expressions.length===0)return null;const expressionNodes=[];for(let i=0;i<expressions.length;++i){const expressionText=expressions[i].text;const sourceToLex=this._stripComments(expressionText);const tokens=this._lexer.tokenize(sourceToLex);const ast=new _ParseAST(input,location,absoluteOffset,tokens,0/* None */,this.errors,offsets[i]).parseChain();expressionNodes.push(ast);}return this.createInterpolationAst(strings.map(s=>s.text),expressionNodes,input,location,absoluteOffset);}/**
1724
+ */parseTemplateBindings(templateKey,templateValue,templateUrl,absoluteKeyOffset,absoluteValueOffset){const tokens=this._lexer.tokenize(templateValue);const parser=new _ParseAST(templateValue,templateUrl,absoluteValueOffset,tokens,0/* None */,this.errors,0/* relative offset */);return parser.parseTemplateBindings({source:templateKey,span:new AbsoluteSourceSpan(absoluteKeyOffset,absoluteKeyOffset+templateKey.length)});}parseInterpolation(input,location,absoluteOffset,interpolatedTokens,interpolationConfig=DEFAULT_INTERPOLATION_CONFIG){const{strings,expressions,offsets}=this.splitInterpolation(input,location,interpolatedTokens,interpolationConfig);if(expressions.length===0)return null;const expressionNodes=[];for(let i=0;i<expressions.length;++i){const expressionText=expressions[i].text;const sourceToLex=this._stripComments(expressionText);const tokens=this._lexer.tokenize(sourceToLex);const ast=new _ParseAST(input,location,absoluteOffset,tokens,0/* None */,this.errors,offsets[i]).parseChain();expressionNodes.push(ast);}return this.createInterpolationAst(strings.map(s=>s.text),expressionNodes,input,location,absoluteOffset);}/**
1718
1725
  * Similar to `parseInterpolation`, but treats the provided string as a single expression
1719
1726
  * element that would normally appear within the interpolation prefix and suffix (`{{` and `}}`).
1720
1727
  * This is used for parsing the switch expression in ICUs.
@@ -1725,11 +1732,11 @@ return this.createInterpolationAst(strings,[ast],expression,location,absoluteOff
1725
1732
  * Returns `null` if there are no interpolations, otherwise a
1726
1733
  * `SplitInterpolation` with splits that look like
1727
1734
  * <raw text> <expression> <raw text> ... <raw text> <expression> <raw text>
1728
- */splitInterpolation(input,location,interpolationConfig=DEFAULT_INTERPOLATION_CONFIG){const strings=[];const expressions=[];const offsets=[];let i=0;let atInterpolation=false;let extendLastString=false;let{start:interpStart,end:interpEnd}=interpolationConfig;while(i<input.length){if(!atInterpolation){// parse until starting {{
1735
+ */splitInterpolation(input,location,interpolatedTokens,interpolationConfig=DEFAULT_INTERPOLATION_CONFIG){var _a;const strings=[];const expressions=[];const offsets=[];const inputToTemplateIndexMap=interpolatedTokens?getIndexMapForOriginalTemplate(interpolatedTokens):null;let i=0;let atInterpolation=false;let extendLastString=false;let{start:interpStart,end:interpEnd}=interpolationConfig;while(i<input.length){if(!atInterpolation){// parse until starting {{
1729
1736
  const start=i;i=input.indexOf(interpStart,i);if(i===-1){i=input.length;}const text=input.substring(start,i);strings.push({text,start,end:i});atInterpolation=true;}else {// parse from starting {{ to ending }} while ignoring content inside quotes.
1730
1737
  const fullStart=i;const exprStart=fullStart+interpStart.length;const exprEnd=this._getInterpolationEndIndex(input,interpEnd,exprStart);if(exprEnd===-1){// Could not find the end of the interpolation; do not parse an expression.
1731
1738
  // Instead we should extend the content on the last raw string.
1732
- atInterpolation=false;extendLastString=true;break;}const fullEnd=exprEnd+interpEnd.length;const text=input.substring(exprStart,exprEnd);if(text.trim().length===0){this._reportError('Blank expressions are not allowed in interpolated strings',input,`at column ${i} in`,location);}expressions.push({text,start:fullStart,end:fullEnd});offsets.push(exprStart);i=fullEnd;atInterpolation=false;}}if(!atInterpolation){// If we are now at a text section, add the remaining content as a raw string.
1739
+ atInterpolation=false;extendLastString=true;break;}const fullEnd=exprEnd+interpEnd.length;const text=input.substring(exprStart,exprEnd);if(text.trim().length===0){this._reportError('Blank expressions are not allowed in interpolated strings',input,`at column ${i} in`,location);}expressions.push({text,start:fullStart,end:fullEnd});const startInOriginalTemplate=(_a=inputToTemplateIndexMap===null||inputToTemplateIndexMap===void 0?void 0:inputToTemplateIndexMap.get(fullStart))!==null&&_a!==void 0?_a:fullStart;const offset=startInOriginalTemplate+interpStart.length;offsets.push(offset);i=fullEnd;atInterpolation=false;}}if(!atInterpolation){// If we are now at a text section, add the remaining content as a raw string.
1733
1740
  if(extendLastString){const piece=strings[strings.length-1];piece.text+=input.substring(i);piece.end=input.length;}else {strings.push({text:input.substring(i),start:i,end:input.length});}}return new SplitInterpolation(strings,expressions,offsets);}wrapLiteralPrimitive(input,location,absoluteOffset){const span=new ParseSpan(0,input==null?0:input.length);return new ASTWithSource(new LiteralPrimitive(span,span.toAbsolute(absoluteOffset),input),input,location,absoluteOffset,this.errors);}_stripComments(input){const i=this._commentStart(input);return i!=null?input.substring(0,i):input;}_commentStart(input){let outerQuote=null;for(let i=0;i<input.length-1;i++){const char=input.charCodeAt(i);const nextChar=input.charCodeAt(i+1);if(char===$SLASH&&nextChar==$SLASH&&outerQuote==null)return i;if(outerQuote===char){outerQuote=null;}else if(outerQuote==null&&isQuote(char)){outerQuote=char;}}return null;}_checkNoInterpolation(input,location,{start,end}){let startIndex=-1;let endIndex=-1;for(const charIndex of this._forEachUnquotedChar(input,0)){if(startIndex===-1){if(input.startsWith(start)){startIndex=charIndex;}}else {endIndex=this._getInterpolationEndIndex(input,end,charIndex);if(endIndex>-1){break;}}}if(startIndex>-1&&endIndex>-1){this._reportError(`Got interpolation (${start}${end}) where expression was expected`,input,`at column ${startIndex} in`,location);}}/**
1734
1741
  * Finds the index of the end of an interpolation expression
1735
1742
  * while ignoring comments and quoted content.
@@ -1929,6 +1936,18 @@ const key=this.expectTemplateBindingKey();let value=null;if(this.consumeOptional
1929
1936
  * If a production expects one of these token it increments the corresponding nesting count,
1930
1937
  * and then decrements it just prior to checking if the token is in the input.
1931
1938
  */skip(){let n=this.next;while(this.index<this.tokens.length&&!n.isCharacter($SEMICOLON)&&!n.isOperator('|')&&(this.rparensExpected<=0||!n.isCharacter($RPAREN))&&(this.rbracesExpected<=0||!n.isCharacter($RBRACE))&&(this.rbracketsExpected<=0||!n.isCharacter($RBRACKET))&&(!(this.context&ParseContextFlags.Writable)||!n.isOperator('='))){if(this.next.isError()){this.errors.push(new ParserError(this.next.toString(),this.input,this.locationText(),this.location));}this.advance();n=this.next;}}}class SimpleExpressionChecker extends RecursiveAstVisitor{constructor(){super(...arguments);this.errors=[];}visitPipe(){this.errors.push('pipes');}}/**
1939
+ * Computes the real offset in the original template for indexes in an interpolation.
1940
+ *
1941
+ * Because templates can have encoded HTML entities and the input passed to the parser at this stage
1942
+ * of the compiler is the _decoded_ value, we need to compute the real offset using the original
1943
+ * encoded values in the interpolated tokens. Note that this is only a special case handling for
1944
+ * `MlParserTokenType.ENCODED_ENTITY` token types. All other interpolated tokens are expected to
1945
+ * have parts which exactly match the input string for parsing the interpolation.
1946
+ *
1947
+ * @param interpolatedTokens The tokens for the interpolated value.
1948
+ *
1949
+ * @returns A map of index locations in the decoded template to indexes in the original template
1950
+ */function getIndexMapForOriginalTemplate(interpolatedTokens){let offsetMap=new Map();let consumedInOriginalTemplate=0;let consumedInInput=0;let tokenIndex=0;while(tokenIndex<interpolatedTokens.length){const currentToken=interpolatedTokens[tokenIndex];if(currentToken.type===9/* ENCODED_ENTITY */){const[decoded,encoded]=currentToken.parts;consumedInOriginalTemplate+=encoded.length;consumedInInput+=decoded.length;}else {const lengthOfParts=currentToken.parts.reduce((sum,current)=>sum+current.length,0);consumedInInput+=lengthOfParts;consumedInOriginalTemplate+=lengthOfParts;}offsetMap.set(consumedInInput,consumedInOriginalTemplate);tokenIndex++;}return offsetMap;}/**
1932
1951
  * @license
1933
1952
  * Copyright Google LLC All Rights Reserved.
1934
1953
  *
@@ -2276,7 +2295,7 @@ boundProps,sourceSpan);}else {this._reportError(`Value of the host property bind
2276
2295
  // Regardless, neither of these values are used in Ivy but are only here to satisfy the
2277
2296
  // function signature. This should likely be refactored in the future so that `sourceSpan`
2278
2297
  // isn't being used inaccurately.
2279
- this.parseEvent(propName,expression,/* isAssignmentEvent */false,sourceSpan,sourceSpan,[],targetEvents,sourceSpan);}else {this._reportError(`Value of the host listener "${propName}" needs to be a string representing an expression but got "${expression}" (${typeof expression})`,sourceSpan);}}return targetEvents;}parseInterpolation(value,sourceSpan){const sourceInfo=sourceSpan.start.toString();const absoluteOffset=sourceSpan.fullStart.offset;try{const ast=this._exprParser.parseInterpolation(value,sourceInfo,absoluteOffset,this._interpolationConfig);if(ast)this._reportExpressionParserErrors(ast.errors,sourceSpan);return ast;}catch(e){this._reportError(`${e}`,sourceSpan);return this._exprParser.wrapLiteralPrimitive('ERROR',sourceInfo,absoluteOffset);}}/**
2298
+ this.parseEvent(propName,expression,/* isAssignmentEvent */false,sourceSpan,sourceSpan,[],targetEvents,sourceSpan);}else {this._reportError(`Value of the host listener "${propName}" needs to be a string representing an expression but got "${expression}" (${typeof expression})`,sourceSpan);}}return targetEvents;}parseInterpolation(value,sourceSpan,interpolatedTokens){const sourceInfo=sourceSpan.start.toString();const absoluteOffset=sourceSpan.fullStart.offset;try{const ast=this._exprParser.parseInterpolation(value,sourceInfo,absoluteOffset,interpolatedTokens,this._interpolationConfig);if(ast)this._reportExpressionParserErrors(ast.errors,sourceSpan);return ast;}catch(e){this._reportError(`${e}`,sourceSpan);return this._exprParser.wrapLiteralPrimitive('ERROR',sourceInfo,absoluteOffset);}}/**
2280
2299
  * Similar to `parseInterpolation`, but treats the provided string as a single expression
2281
2300
  * element that would normally appear within the interpolation prefix and suffix (`{{` and `}}`).
2282
2301
  * This is used for parsing the switch expression in ICUs.
@@ -2306,7 +2325,7 @@ this.parseLiteralAttr(key,null/* value */,keySpan,absoluteValueOffset,undefined/
2306
2325
  * @param sourceSpan span of template binding relative to entire the template
2307
2326
  * @param absoluteKeyOffset start of the `tplKey`
2308
2327
  * @param absoluteValueOffset start of the `tplValue`
2309
- */_parseTemplateBindings(tplKey,tplValue,sourceSpan,absoluteKeyOffset,absoluteValueOffset){const sourceInfo=sourceSpan.start.toString();try{const bindingsResult=this._exprParser.parseTemplateBindings(tplKey,tplValue,sourceInfo,absoluteKeyOffset,absoluteValueOffset);this._reportExpressionParserErrors(bindingsResult.errors,sourceSpan);bindingsResult.warnings.forEach(warning=>{this._reportError(warning,sourceSpan,exports.ParseErrorLevel.WARNING);});return bindingsResult.templateBindings;}catch(e){this._reportError(`${e}`,sourceSpan);return [];}}parseLiteralAttr(name,value,sourceSpan,absoluteOffset,valueSpan,targetMatchableAttrs,targetProps,keySpan){if(isAnimationLabel(name)){name=name.substring(1);if(keySpan!==undefined){keySpan=moveParseSourceSpan(keySpan,new AbsoluteSourceSpan(keySpan.start.offset+1,keySpan.end.offset));}if(value){this._reportError(`Assigning animation triggers via @prop="exp" attributes with an expression is invalid.`+` Use property bindings (e.g. [@prop]="exp") or use an attribute without a value (e.g. @prop) instead.`,sourceSpan,exports.ParseErrorLevel.ERROR);}this._parseAnimation(name,value,sourceSpan,absoluteOffset,keySpan,valueSpan,targetMatchableAttrs,targetProps);}else {targetProps.push(new ParsedProperty(name,this._exprParser.wrapLiteralPrimitive(value,'',absoluteOffset),exports.ParsedPropertyType.LITERAL_ATTR,sourceSpan,keySpan,valueSpan));}}parsePropertyBinding(name,expression,isHost,sourceSpan,absoluteOffset,valueSpan,targetMatchableAttrs,targetProps,keySpan){if(name.length===0){this._reportError(`Property name is missing in binding`,sourceSpan);}let isAnimationProp=false;if(name.startsWith(ANIMATE_PROP_PREFIX)){isAnimationProp=true;name=name.substring(ANIMATE_PROP_PREFIX.length);if(keySpan!==undefined){keySpan=moveParseSourceSpan(keySpan,new AbsoluteSourceSpan(keySpan.start.offset+ANIMATE_PROP_PREFIX.length,keySpan.end.offset));}}else if(isAnimationLabel(name)){isAnimationProp=true;name=name.substring(1);if(keySpan!==undefined){keySpan=moveParseSourceSpan(keySpan,new AbsoluteSourceSpan(keySpan.start.offset+1,keySpan.end.offset));}}if(isAnimationProp){this._parseAnimation(name,expression,sourceSpan,absoluteOffset,keySpan,valueSpan,targetMatchableAttrs,targetProps);}else {this._parsePropertyAst(name,this._parseBinding(expression,isHost,valueSpan||sourceSpan,absoluteOffset),sourceSpan,keySpan,valueSpan,targetMatchableAttrs,targetProps);}}parsePropertyInterpolation(name,value,sourceSpan,valueSpan,targetMatchableAttrs,targetProps,keySpan){const expr=this.parseInterpolation(value,valueSpan||sourceSpan);if(expr){this._parsePropertyAst(name,expr,sourceSpan,keySpan,valueSpan,targetMatchableAttrs,targetProps);return true;}return false;}_parsePropertyAst(name,ast,sourceSpan,keySpan,valueSpan,targetMatchableAttrs,targetProps){targetMatchableAttrs.push([name,ast.source]);targetProps.push(new ParsedProperty(name,ast,exports.ParsedPropertyType.DEFAULT,sourceSpan,keySpan,valueSpan));}_parseAnimation(name,expression,sourceSpan,absoluteOffset,keySpan,valueSpan,targetMatchableAttrs,targetProps){if(name.length===0){this._reportError('Animation trigger is missing',sourceSpan);}// This will occur when a @trigger is not paired with an expression.
2328
+ */_parseTemplateBindings(tplKey,tplValue,sourceSpan,absoluteKeyOffset,absoluteValueOffset){const sourceInfo=sourceSpan.start.toString();try{const bindingsResult=this._exprParser.parseTemplateBindings(tplKey,tplValue,sourceInfo,absoluteKeyOffset,absoluteValueOffset);this._reportExpressionParserErrors(bindingsResult.errors,sourceSpan);bindingsResult.warnings.forEach(warning=>{this._reportError(warning,sourceSpan,exports.ParseErrorLevel.WARNING);});return bindingsResult.templateBindings;}catch(e){this._reportError(`${e}`,sourceSpan);return [];}}parseLiteralAttr(name,value,sourceSpan,absoluteOffset,valueSpan,targetMatchableAttrs,targetProps,keySpan){if(isAnimationLabel(name)){name=name.substring(1);if(keySpan!==undefined){keySpan=moveParseSourceSpan(keySpan,new AbsoluteSourceSpan(keySpan.start.offset+1,keySpan.end.offset));}if(value){this._reportError(`Assigning animation triggers via @prop="exp" attributes with an expression is invalid.`+` Use property bindings (e.g. [@prop]="exp") or use an attribute without a value (e.g. @prop) instead.`,sourceSpan,exports.ParseErrorLevel.ERROR);}this._parseAnimation(name,value,sourceSpan,absoluteOffset,keySpan,valueSpan,targetMatchableAttrs,targetProps);}else {targetProps.push(new ParsedProperty(name,this._exprParser.wrapLiteralPrimitive(value,'',absoluteOffset),exports.ParsedPropertyType.LITERAL_ATTR,sourceSpan,keySpan,valueSpan));}}parsePropertyBinding(name,expression,isHost,sourceSpan,absoluteOffset,valueSpan,targetMatchableAttrs,targetProps,keySpan){if(name.length===0){this._reportError(`Property name is missing in binding`,sourceSpan);}let isAnimationProp=false;if(name.startsWith(ANIMATE_PROP_PREFIX)){isAnimationProp=true;name=name.substring(ANIMATE_PROP_PREFIX.length);if(keySpan!==undefined){keySpan=moveParseSourceSpan(keySpan,new AbsoluteSourceSpan(keySpan.start.offset+ANIMATE_PROP_PREFIX.length,keySpan.end.offset));}}else if(isAnimationLabel(name)){isAnimationProp=true;name=name.substring(1);if(keySpan!==undefined){keySpan=moveParseSourceSpan(keySpan,new AbsoluteSourceSpan(keySpan.start.offset+1,keySpan.end.offset));}}if(isAnimationProp){this._parseAnimation(name,expression,sourceSpan,absoluteOffset,keySpan,valueSpan,targetMatchableAttrs,targetProps);}else {this._parsePropertyAst(name,this._parseBinding(expression,isHost,valueSpan||sourceSpan,absoluteOffset),sourceSpan,keySpan,valueSpan,targetMatchableAttrs,targetProps);}}parsePropertyInterpolation(name,value,sourceSpan,valueSpan,targetMatchableAttrs,targetProps,keySpan,interpolatedTokens){const expr=this.parseInterpolation(value,valueSpan||sourceSpan,interpolatedTokens);if(expr){this._parsePropertyAst(name,expr,sourceSpan,keySpan,valueSpan,targetMatchableAttrs,targetProps);return true;}return false;}_parsePropertyAst(name,ast,sourceSpan,keySpan,valueSpan,targetMatchableAttrs,targetProps){targetMatchableAttrs.push([name,ast.source]);targetProps.push(new ParsedProperty(name,ast,exports.ParsedPropertyType.DEFAULT,sourceSpan,keySpan,valueSpan));}_parseAnimation(name,expression,sourceSpan,absoluteOffset,keySpan,valueSpan,targetMatchableAttrs,targetProps){if(name.length===0){this._reportError('Animation trigger is missing',sourceSpan);}// This will occur when a @trigger is not paired with an expression.
2310
2329
  // For animations it is valid to not have an expression since */void
2311
2330
  // states will be applied by angular when the element is attached/detached
2312
2331
  const ast=this._parseBinding(expression||'undefined',false,valueSpan||sourceSpan,absoluteOffset);targetMatchableAttrs.push([name,ast.source]);targetProps.push(new ParsedProperty(name,ast,exports.ParsedPropertyType.ANIMATION,sourceSpan,keySpan,valueSpan));}_parseBinding(value,isHostBinding,sourceSpan,absoluteOffset){const sourceInfo=(sourceSpan&&sourceSpan.start||'(unknown)').toString();try{const ast=isHostBinding?this._exprParser.parseSimpleBinding(value,sourceInfo,absoluteOffset,this._interpolationConfig):this._exprParser.parseBinding(value,sourceInfo,absoluteOffset,this._interpolationConfig);if(ast)this._reportExpressionParserErrors(ast.errors,sourceSpan);return ast;}catch(e){this._reportError(`${e}`,sourceSpan);return this._exprParser.wrapLiteralPrimitive('ERROR',sourceInfo,absoluteOffset);}}createBoundElementProperty(elementSelector,boundProp,skipValidation=false,mapPropertyName=true){if(boundProp.isAnimation){return new BoundElementProperty(boundProp.name,4/* Animation */,SecurityContext.NONE,boundProp.expression,null,boundProp.sourceSpan,boundProp.keySpan,boundProp.valueSpan);}let unit=null;let bindingType=undefined;let boundPropertyName=null;const parts=boundProp.name.split(PROPERTY_PARTS_SEPARATOR);let securityContexts=undefined;// Check for special cases (prefix style, attr, class)
@@ -2374,7 +2393,7 @@ const attrs=this.extractAttributes(element.name,parsedProperties,i18nAttrsMeta);
2374
2393
  const attrs=this.extractAttributes('ng-template',templateParsedProperties,i18nAttrsMeta);const templateAttrs=[];attrs.literal.forEach(attr=>templateAttrs.push(attr));attrs.bound.forEach(attr=>templateAttrs.push(attr));const hoistedAttrs=parsedElement instanceof Element$1?{attributes:parsedElement.attributes,inputs:parsedElement.inputs,outputs:parsedElement.outputs}:{attributes:[],inputs:[],outputs:[]};// For <ng-template>s with structural directives on them, avoid passing i18n information to
2375
2394
  // the wrapping template to prevent unnecessary i18n instructions from being generated. The
2376
2395
  // necessary i18n meta information will be extracted from child elements.
2377
- const i18n=isTemplateElement&&isI18nRootElement?undefined:element.i18n;const name=parsedElement instanceof Template?null:parsedElement.name;parsedElement=new Template(name,hoistedAttrs.attributes,hoistedAttrs.inputs,hoistedAttrs.outputs,templateAttrs,[parsedElement],[/* no references */],templateVariables,element.sourceSpan,element.startSourceSpan,element.endSourceSpan,i18n);}if(isI18nRootElement){this.inI18nBlock=false;}return parsedElement;}visitAttribute(attribute){return new TextAttribute(attribute.name,attribute.value,attribute.sourceSpan,attribute.keySpan,attribute.valueSpan,attribute.i18n);}visitText(text){return this._visitTextWithInterpolation(text.value,text.sourceSpan,text.i18n);}visitExpansion(expansion){if(!expansion.i18n){// do not generate Icu in case it was created
2396
+ const i18n=isTemplateElement&&isI18nRootElement?undefined:element.i18n;const name=parsedElement instanceof Template?null:parsedElement.name;parsedElement=new Template(name,hoistedAttrs.attributes,hoistedAttrs.inputs,hoistedAttrs.outputs,templateAttrs,[parsedElement],[/* no references */],templateVariables,element.sourceSpan,element.startSourceSpan,element.endSourceSpan,i18n);}if(isI18nRootElement){this.inI18nBlock=false;}return parsedElement;}visitAttribute(attribute){return new TextAttribute(attribute.name,attribute.value,attribute.sourceSpan,attribute.keySpan,attribute.valueSpan,attribute.i18n);}visitText(text){return this._visitTextWithInterpolation(text.value,text.sourceSpan,text.tokens,text.i18n);}visitExpansion(expansion){if(!expansion.i18n){// do not generate Icu in case it was created
2378
2397
  // outside of i18n block in a template
2379
2398
  return null;}if(!isI18nRootNode(expansion.i18n)){throw new Error(`Invalid type "${expansion.i18n.constructor}" for "i18n" property of ${expansion.sourceSpan.toString()}. Expected a "Message"`);}const message=expansion.i18n;const vars={};const placeholders={};// extract VARs from ICUs - we process them separately while
2380
2399
  // assembling resulting message via goog.getMsg function, since
@@ -2384,11 +2403,11 @@ Object.keys(message.placeholders).forEach(key=>{const value=message.placeholders
2384
2403
  // (e.g. "VAR_SELECT "). These trailing spaces are not desirable, since they will later be
2385
2404
  // converted into `_` symbols while normalizing placeholder names, which might lead to
2386
2405
  // mismatches at runtime (i.e. placeholder will not be replaced with the correct value).
2387
- const formattedKey=key.trim();const ast=this.bindingParser.parseInterpolationExpression(value.text,value.sourceSpan);vars[formattedKey]=new BoundText(ast,value.sourceSpan);}else {placeholders[key]=this._visitTextWithInterpolation(value.text,value.sourceSpan);}});return new Icu$1(vars,placeholders,expansion.sourceSpan,message);}visitExpansionCase(expansionCase){return null;}visitComment(comment){if(this.options.collectCommentNodes){this.commentNodes.push(new Comment$1(comment.value||'',comment.sourceSpan));}return null;}// convert view engine `ParsedProperty` to a format suitable for IVY
2406
+ const formattedKey=key.trim();const ast=this.bindingParser.parseInterpolationExpression(value.text,value.sourceSpan);vars[formattedKey]=new BoundText(ast,value.sourceSpan);}else {placeholders[key]=this._visitTextWithInterpolation(value.text,value.sourceSpan,null);}});return new Icu$1(vars,placeholders,expansion.sourceSpan,message);}visitExpansionCase(expansionCase){return null;}visitComment(comment){if(this.options.collectCommentNodes){this.commentNodes.push(new Comment$1(comment.value||'',comment.sourceSpan));}return null;}// convert view engine `ParsedProperty` to a format suitable for IVY
2388
2407
  extractAttributes(elementName,properties,i18nPropsMeta){const bound=[];const literal=[];properties.forEach(prop=>{const i18n=i18nPropsMeta[prop.name];if(prop.isLiteral){literal.push(new TextAttribute(prop.name,prop.expression.source||'',prop.sourceSpan,prop.keySpan,prop.valueSpan,i18n));}else {// Note that validation is skipped and property mapping is disabled
2389
2408
  // due to the fact that we need to make sure a given prop is not an
2390
2409
  // input of a directive and directive matching happens at runtime.
2391
- const bep=this.bindingParser.createBoundElementProperty(elementName,prop,/* skipValidation */true,/* mapPropertyName */false);bound.push(BoundAttribute.fromBoundElementProperty(bep,i18n));}});return {bound,literal};}parseAttribute(isTemplateElement,attribute,matchableAttributes,parsedProperties,boundEvents,variables,references){const name=normalizeAttributeName(attribute.name);const value=attribute.value;const srcSpan=attribute.sourceSpan;const absoluteOffset=attribute.valueSpan?attribute.valueSpan.start.offset:srcSpan.start.offset;function createKeySpan(srcSpan,prefix,identifier){// We need to adjust the start location for the keySpan to account for the removed 'data-'
2410
+ const bep=this.bindingParser.createBoundElementProperty(elementName,prop,/* skipValidation */true,/* mapPropertyName */false);bound.push(BoundAttribute.fromBoundElementProperty(bep,i18n));}});return {bound,literal};}parseAttribute(isTemplateElement,attribute,matchableAttributes,parsedProperties,boundEvents,variables,references){var _a;const name=normalizeAttributeName(attribute.name);const value=attribute.value;const srcSpan=attribute.sourceSpan;const absoluteOffset=attribute.valueSpan?attribute.valueSpan.start.offset:srcSpan.start.offset;function createKeySpan(srcSpan,prefix,identifier){// We need to adjust the start location for the keySpan to account for the removed 'data-'
2392
2411
  // prefix from `normalizeAttributeName`.
2393
2412
  const normalizationAdjustment=attribute.name.length-name.length;const keySpanStart=srcSpan.start.moveBy(prefix.length+normalizationAdjustment);const keySpanEnd=keySpanStart.moveBy(identifier.length);return new ParseSourceSpan(keySpanStart,keySpanEnd,keySpanStart,identifier);}const bindParts=name.match(BIND_NAME_REGEXP);if(bindParts){if(bindParts[KW_BIND_IDX]!=null){const identifier=bindParts[IDENT_KW_IDX];const keySpan=createKeySpan(srcSpan,bindParts[KW_BIND_IDX],identifier);this.bindingParser.parsePropertyBinding(identifier,value,false,srcSpan,absoluteOffset,attribute.valueSpan,matchableAttributes,parsedProperties,keySpan);}else if(bindParts[KW_LET_IDX]){if(isTemplateElement){const identifier=bindParts[IDENT_KW_IDX];const keySpan=createKeySpan(srcSpan,bindParts[KW_LET_IDX],identifier);this.parseVariable(identifier,value,srcSpan,keySpan,attribute.valueSpan,variables);}else {this.reportError(`"let-" is only supported on ng-template elements.`,srcSpan);}}else if(bindParts[KW_REF_IDX]){const identifier=bindParts[IDENT_KW_IDX];const keySpan=createKeySpan(srcSpan,bindParts[KW_REF_IDX],identifier);this.parseReference(identifier,value,srcSpan,keySpan,attribute.valueSpan,references);}else if(bindParts[KW_ON_IDX]){const events=[];const identifier=bindParts[IDENT_KW_IDX];const keySpan=createKeySpan(srcSpan,bindParts[KW_ON_IDX],identifier);this.bindingParser.parseEvent(identifier,value,/* isAssignmentEvent */false,srcSpan,attribute.valueSpan||srcSpan,matchableAttributes,events,keySpan);addEvents(events,boundEvents);}else if(bindParts[KW_BINDON_IDX]){const identifier=bindParts[IDENT_KW_IDX];const keySpan=createKeySpan(srcSpan,bindParts[KW_BINDON_IDX],identifier);this.bindingParser.parsePropertyBinding(identifier,value,false,srcSpan,absoluteOffset,attribute.valueSpan,matchableAttributes,parsedProperties,keySpan);this.parseAssignmentEvent(identifier,value,srcSpan,attribute.valueSpan,matchableAttributes,boundEvents,keySpan);}else if(bindParts[KW_AT_IDX]){const keySpan=createKeySpan(srcSpan,'',name);this.bindingParser.parseLiteralAttr(name,value,srcSpan,absoluteOffset,attribute.valueSpan,matchableAttributes,parsedProperties,keySpan);}return true;}// We didn't see a kw-prefixed property binding, but we have not yet checked
2394
2413
  // for the []/()/[()] syntax.
@@ -2397,7 +2416,7 @@ let delims=null;if(name.startsWith(BINDING_DELIMS.BANANA_BOX.start)){delims=BIND
2397
2416
  // and the identifier in the binding was non-empty.
2398
2417
  // TODO(ayazhafiz): update this to handle malformed bindings.
2399
2418
  name.endsWith(delims.end)&&name.length>delims.start.length+delims.end.length){const identifier=name.substring(delims.start.length,name.length-delims.end.length);const keySpan=createKeySpan(srcSpan,delims.start,identifier);if(delims.start===BINDING_DELIMS.BANANA_BOX.start){this.bindingParser.parsePropertyBinding(identifier,value,false,srcSpan,absoluteOffset,attribute.valueSpan,matchableAttributes,parsedProperties,keySpan);this.parseAssignmentEvent(identifier,value,srcSpan,attribute.valueSpan,matchableAttributes,boundEvents,keySpan);}else if(delims.start===BINDING_DELIMS.PROPERTY.start){this.bindingParser.parsePropertyBinding(identifier,value,false,srcSpan,absoluteOffset,attribute.valueSpan,matchableAttributes,parsedProperties,keySpan);}else {const events=[];this.bindingParser.parseEvent(identifier,value,/* isAssignmentEvent */false,srcSpan,attribute.valueSpan||srcSpan,matchableAttributes,events,keySpan);addEvents(events,boundEvents);}return true;}// No explicit binding found.
2400
- const keySpan=createKeySpan(srcSpan,''/* prefix */,name);const hasBinding=this.bindingParser.parsePropertyInterpolation(name,value,srcSpan,attribute.valueSpan,matchableAttributes,parsedProperties,keySpan);return hasBinding;}_visitTextWithInterpolation(value,sourceSpan,i18n){const valueNoNgsp=replaceNgsp(value);const expr=this.bindingParser.parseInterpolation(valueNoNgsp,sourceSpan);return expr?new BoundText(expr,sourceSpan,i18n):new Text$3(valueNoNgsp,sourceSpan);}parseVariable(identifier,value,sourceSpan,keySpan,valueSpan,variables){if(identifier.indexOf('-')>-1){this.reportError(`"-" is not allowed in variable names`,sourceSpan);}else if(identifier.length===0){this.reportError(`Variable does not have a name`,sourceSpan);}variables.push(new Variable(identifier,value,sourceSpan,keySpan,valueSpan));}parseReference(identifier,value,sourceSpan,keySpan,valueSpan,references){if(identifier.indexOf('-')>-1){this.reportError(`"-" is not allowed in reference names`,sourceSpan);}else if(identifier.length===0){this.reportError(`Reference does not have a name`,sourceSpan);}else if(references.some(reference=>reference.name===identifier)){this.reportError(`Reference "#${identifier}" is defined more than once`,sourceSpan);}references.push(new Reference(identifier,value,sourceSpan,keySpan,valueSpan));}parseAssignmentEvent(name,expression,sourceSpan,valueSpan,targetMatchableAttrs,boundEvents,keySpan){const events=[];this.bindingParser.parseEvent(`${name}Change`,`${expression} =$event`,/* isAssignmentEvent */true,sourceSpan,valueSpan||sourceSpan,targetMatchableAttrs,events,keySpan);addEvents(events,boundEvents);}reportError(message,sourceSpan,level=exports.ParseErrorLevel.ERROR){this.errors.push(new ParseError(sourceSpan,message,level));}}class NonBindableVisitor{visitElement(ast){const preparsedElement=preparseElement(ast);if(preparsedElement.type===PreparsedElementType.SCRIPT||preparsedElement.type===PreparsedElementType.STYLE||preparsedElement.type===PreparsedElementType.STYLESHEET){// Skipping <script> for security reasons
2419
+ const keySpan=createKeySpan(srcSpan,''/* prefix */,name);const hasBinding=this.bindingParser.parsePropertyInterpolation(name,value,srcSpan,attribute.valueSpan,matchableAttributes,parsedProperties,keySpan,(_a=attribute.valueTokens)!==null&&_a!==void 0?_a:null);return hasBinding;}_visitTextWithInterpolation(value,sourceSpan,interpolatedTokens,i18n){const valueNoNgsp=replaceNgsp(value);const expr=this.bindingParser.parseInterpolation(valueNoNgsp,sourceSpan,interpolatedTokens);return expr?new BoundText(expr,sourceSpan,i18n):new Text$3(valueNoNgsp,sourceSpan);}parseVariable(identifier,value,sourceSpan,keySpan,valueSpan,variables){if(identifier.indexOf('-')>-1){this.reportError(`"-" is not allowed in variable names`,sourceSpan);}else if(identifier.length===0){this.reportError(`Variable does not have a name`,sourceSpan);}variables.push(new Variable(identifier,value,sourceSpan,keySpan,valueSpan));}parseReference(identifier,value,sourceSpan,keySpan,valueSpan,references){if(identifier.indexOf('-')>-1){this.reportError(`"-" is not allowed in reference names`,sourceSpan);}else if(identifier.length===0){this.reportError(`Reference does not have a name`,sourceSpan);}else if(references.some(reference=>reference.name===identifier)){this.reportError(`Reference "#${identifier}" is defined more than once`,sourceSpan);}references.push(new Reference(identifier,value,sourceSpan,keySpan,valueSpan));}parseAssignmentEvent(name,expression,sourceSpan,valueSpan,targetMatchableAttrs,boundEvents,keySpan){const events=[];this.bindingParser.parseEvent(`${name}Change`,`${expression} =$event`,/* isAssignmentEvent */true,sourceSpan,valueSpan||sourceSpan,targetMatchableAttrs,events,keySpan);addEvents(events,boundEvents);}reportError(message,sourceSpan,level=exports.ParseErrorLevel.ERROR){this.errors.push(new ParseError(sourceSpan,message,level));}}class NonBindableVisitor{visitElement(ast){const preparsedElement=preparseElement(ast);if(preparsedElement.type===PreparsedElementType.SCRIPT||preparsedElement.type===PreparsedElementType.STYLE||preparsedElement.type===PreparsedElementType.STYLESHEET){// Skipping <script> for security reasons
2401
2420
  // Skipping <style> and stylesheets as we already processed them
2402
2421
  // in the StyleCompiler
2403
2422
  return null;}const children=visitAll(this,ast.children,null);return new Element$1(ast.name,visitAll(this,ast.attrs),/* inputs */[],/* outputs */[],children,/* references */[],ast.sourceSpan,ast.startSourceSpan,ast.endSourceSpan);}visitComment(comment){return null;}visitAttribute(attribute){return new TextAttribute(attribute.name,attribute.value,attribute.sourceSpan,attribute.keySpan,attribute.valueSpan,attribute.i18n);}visitText(text){return new Text$3(text.value,text.sourceSpan);}visitExpansion(expansion){return null;}visitExpansionCase(expansionCase){return null;}}const NON_BINDABLE_VISITOR=new NonBindableVisitor();function normalizeAttributeName(attrName){return /^data-/i.test(attrName)?attrName.substring(5):attrName;}function addEvents(events,boundEvents){boundEvents.push(...events.map(e=>BoundEvent.fromParsedEvent(e)));}function isEmptyTextNode(node){return node instanceof Text&&node.value.trim().length==0;}function isCommentNode(node){return node instanceof Comment;}function textContents(node){if(node.children.length!==1||!(node.children[0]instanceof Text)){return null;}else {return node.children[0].value;}}/**
@@ -2697,8 +2716,8 @@ if(this._ngContentReservedSlots.length>1||this._ngContentReservedSlots[0]!=='*')
2697
2716
  // we *prepend* `projectionDef` to creation instructions block, to put it before
2698
2717
  // any `projection` instructions
2699
2718
  this.creationInstruction(null,Identifiers.projectionDef,parameters,/* prepend */true);}if(initI18nContext){this.i18nEnd(null,selfClosingI18nInstruction);}// Generate all the creation mode instructions (e.g. resolve bindings in listeners)
2700
- const creationStatements=this._creationCodeFns.map(fn=>fn());// Generate all the update mode instructions (e.g. resolve property or text bindings)
2701
- const updateStatements=this._updateCodeFns.map(fn=>fn());// Variable declaration must occur after binding resolution so we can generate context
2719
+ const creationStatements=getInstructionStatements(this._creationCodeFns);// Generate all the update mode instructions (e.g. resolve property or text bindings)
2720
+ const updateStatements=getInstructionStatements(this._updateCodeFns);// Variable declaration must occur after binding resolution so we can generate context
2702
2721
  // instructions that build on each other.
2703
2722
  // e.g. const b = nextContext().$implicit(); const b = nextContext();
2704
2723
  const creationVariables=this._bindingScope.viewSnapshotStatements();const updateVariables=this._bindingScope.variableDeclarations().concat(this._tempVariables);const creationBlock=creationStatements.length>0?[renderFlagCheckIfStmt(1/* Create */,creationVariables.concat(creationStatements))]:[];const updateBlock=updateStatements.length>0?[renderFlagCheckIfStmt(2/* Update */,updateVariables.concat(updateStatements))]:[];return fn(// i.e. (rf: RenderFlags, ctx: any)
@@ -2726,15 +2745,15 @@ params[key]=refs[0];}else {// ... otherwise we need to activate post-processing
2726
2745
  const placeholder=wrapI18nPlaceholder(`${I18N_ICU_MAPPING_PREFIX}${key}`);params[key]=literal(placeholder);icuMapping[key]=literalArr(refs);}});}// translation requires post processing in 2 cases:
2727
2746
  // - if we have placeholders with multiple values (ex. `START_DIV`: [�#1�, �#2�, ...])
2728
2747
  // - if we have multiple ICUs that refer to the same placeholder name
2729
- const needsPostprocessing=Array.from(placeholders.values()).some(value=>value.length>1)||Object.keys(icuMapping).length;let transformFn;if(needsPostprocessing){transformFn=raw=>{const args=[raw];if(Object.keys(icuMapping).length){args.push(mapLiteral(icuMapping,true));}return instruction(null,Identifiers.i18nPostprocess,args);};}this.i18nTranslate(meta,params,context.ref,transformFn);}}i18nStart(span=null,meta,selfClosing){const index=this.allocateDataSlot();this.i18n=this.i18nContext?this.i18nContext.forkChildContext(index,this.templateIndex,meta):new I18nContext(index,this.i18nGenerateMainBlockVar(),0,this.templateIndex,meta);// generate i18nStart instruction
2748
+ const needsPostprocessing=Array.from(placeholders.values()).some(value=>value.length>1)||Object.keys(icuMapping).length;let transformFn;if(needsPostprocessing){transformFn=raw=>{const args=[raw];if(Object.keys(icuMapping).length){args.push(mapLiteral(icuMapping,true));}return invokeInstruction(null,Identifiers.i18nPostprocess,args);};}this.i18nTranslate(meta,params,context.ref,transformFn);}}i18nStart(span=null,meta,selfClosing){const index=this.allocateDataSlot();this.i18n=this.i18nContext?this.i18nContext.forkChildContext(index,this.templateIndex,meta):new I18nContext(index,this.i18nGenerateMainBlockVar(),0,this.templateIndex,meta);// generate i18nStart instruction
2730
2749
  const{id,ref}=this.i18n;const params=[literal(index),this.addToConsts(ref)];if(id>0){// do not push 3rd argument (sub-block id)
2731
2750
  // into i18nStart call for top level i18n context
2732
2751
  params.push(literal(id));}this.creationInstruction(span,selfClosing?Identifiers.i18n:Identifiers.i18nStart,params);}i18nEnd(span=null,selfClosing){if(!this.i18n){throw new Error('i18nEnd is executed with no i18n context present');}if(this.i18nContext){this.i18nContext.reconcileChildContext(this.i18n);this.i18nUpdateRef(this.i18nContext);}else {this.i18nUpdateRef(this.i18n);}// setup accumulated bindings
2733
- const{index,bindings}=this.i18n;if(bindings.size){const chainBindings=[];bindings.forEach(binding=>{chainBindings.push({sourceSpan:span,value:()=>this.convertPropertyBinding(binding)});});// for i18n block, advance to the most recent element index (by taking the current number of
2752
+ const{index,bindings}=this.i18n;if(bindings.size){for(const binding of bindings){// for i18n block, advance to the most recent element index (by taking the current number of
2734
2753
  // elements and subtracting one) before invoking `i18nExp` instructions, to make sure the
2735
2754
  // necessary lifecycle hooks of components/directives are properly flushed.
2736
- this.updateInstructionChainWithAdvance(this.getConstCount()-1,Identifiers.i18nExp,chainBindings);this.updateInstruction(span,Identifiers.i18nApply,[literal(index)]);}if(!selfClosing){this.creationInstruction(span,Identifiers.i18nEnd);}this.i18n=null;// reset local i18n context
2737
- }i18nAttributesInstruction(nodeIndex,attrs,sourceSpan){let hasBindings=false;const i18nAttrArgs=[];const bindings=[];attrs.forEach(attr=>{const message=attr.i18n;const converted=attr.value.visit(this._valueConverter);this.allocateBindingSlots(converted);if(converted instanceof Interpolation){const placeholders=assembleBoundTextPlaceholders(message);const params=placeholdersToParams(placeholders);i18nAttrArgs.push(literal(attr.name),this.i18nTranslate(message,params));converted.expressions.forEach(expression=>{hasBindings=true;bindings.push({sourceSpan,value:()=>this.convertPropertyBinding(expression)});});}});if(bindings.length>0){this.updateInstructionChainWithAdvance(nodeIndex,Identifiers.i18nExp,bindings);}if(i18nAttrArgs.length>0){const index=literal(this.allocateDataSlot());const constIndex=this.addToConsts(literalArr(i18nAttrArgs));this.creationInstruction(sourceSpan,Identifiers.i18nAttributes,[index,constIndex]);if(hasBindings){this.updateInstruction(sourceSpan,Identifiers.i18nApply,[index]);}}}getNamespaceInstruction(namespaceKey){switch(namespaceKey){case'math':return Identifiers.namespaceMathML;case'svg':return Identifiers.namespaceSVG;default:return Identifiers.namespaceHTML;}}addNamespaceInstruction(nsInstruction,element){this._namespace=nsInstruction;this.creationInstruction(element.startSourceSpan,nsInstruction);}/**
2755
+ this.updateInstructionWithAdvance(this.getConstCount()-1,span,Identifiers.i18nExp,()=>this.convertPropertyBinding(binding));}this.updateInstruction(span,Identifiers.i18nApply,[literal(index)]);}if(!selfClosing){this.creationInstruction(span,Identifiers.i18nEnd);}this.i18n=null;// reset local i18n context
2756
+ }i18nAttributesInstruction(nodeIndex,attrs,sourceSpan){let hasBindings=false;const i18nAttrArgs=[];attrs.forEach(attr=>{const message=attr.i18n;const converted=attr.value.visit(this._valueConverter);this.allocateBindingSlots(converted);if(converted instanceof Interpolation){const placeholders=assembleBoundTextPlaceholders(message);const params=placeholdersToParams(placeholders);i18nAttrArgs.push(literal(attr.name),this.i18nTranslate(message,params));converted.expressions.forEach(expression=>{hasBindings=true;this.updateInstructionWithAdvance(nodeIndex,sourceSpan,Identifiers.i18nExp,()=>this.convertPropertyBinding(expression));});}});if(i18nAttrArgs.length>0){const index=literal(this.allocateDataSlot());const constIndex=this.addToConsts(literalArr(i18nAttrArgs));this.creationInstruction(sourceSpan,Identifiers.i18nAttributes,[index,constIndex]);if(hasBindings){this.updateInstruction(sourceSpan,Identifiers.i18nApply,[index]);}}}getNamespaceInstruction(namespaceKey){switch(namespaceKey){case'math':return Identifiers.namespaceMathML;case'svg':return Identifiers.namespaceSVG;default:return Identifiers.namespaceHTML;}}addNamespaceInstruction(nsInstruction,element){this._namespace=nsInstruction;this.creationInstruction(element.startSourceSpan,nsInstruction);}/**
2738
2757
  * Adds an update instruction for an interpolated property or attribute, such as
2739
2758
  * `prop="{{value}}"` or `attr.title="{{value}}"`
2740
2759
  */interpolatedUpdateInstruction(instruction,elementIndex,attrName,input,value,params){this.updateInstructionWithAdvance(elementIndex,input.sourceSpan,instruction,()=>[literal(attrName),...this.getUpdateInstructionArguments(value),...params]);}visitContent(ngContent){const slot=this.allocateDataSlot();const projectionSlotIdx=this._ngContentSelectorsOffset+this._ngContentReservedSlots.length;const parameters=[literal(slot)];this._ngContentReservedSlots.push(ngContent.selector);const nonContentSelectAttributes=ngContent.attributes.filter(attr=>attr.name.toLowerCase()!==NG_CONTENT_SELECT_ATTR);const attributes=this.getAttributeExpressions(ngContent.name,nonContentSelectAttributes,[],[]);if(attributes.length>0){parameters.push(literal(projectionSlotIdx),literalArr(attributes));}else if(projectionSlotIdx!==0){parameters.push(literal(projectionSlotIdx));}this.creationInstruction(ngContent.sourceSpan,Identifiers.projection,parameters);if(this.i18n){this.i18n.appendProjection(ngContent.i18n,slot);}}visitElement(element){var _a,_b;const elementIndex=this.allocateDataSlot();const stylingBuilder=new StylingBuilder(null);let isNonBindableMode=false;const isI18nRootElement=isI18nRootNode(element.i18n)&&!isSingleI18nIcu(element.i18n);const outputAttrs=[];const[namespaceKey,elementName]=splitNsName(element.name);const isNgContainer$1=isNgContainer(element.name);// Handle styling, i18n, ngNonBindable attributes
@@ -2747,7 +2766,7 @@ const refs=this.prepareRefsArray(element.references);parameters.push(this.addToC
2747
2766
  if(currentNamespace!==wasInNamespace){this.addNamespaceInstruction(currentNamespace,element);}if(this.i18n){this.i18n.appendElement(element.i18n,elementIndex);}// Note that we do not append text node instructions and ICUs inside i18n section,
2748
2767
  // so we exclude them while calculating whether current element has children
2749
2768
  const hasChildren=!isI18nRootElement&&this.i18n?!hasTextChildrenOnly(element.children):element.children.length>0;const createSelfClosingInstruction=!stylingBuilder.hasBindingsWithPipes&&element.outputs.length===0&&boundI18nAttrs.length===0&&!hasChildren;const createSelfClosingI18nInstruction=!createSelfClosingInstruction&&hasTextChildrenOnly(element.children);if(createSelfClosingInstruction){this.creationInstruction(element.sourceSpan,isNgContainer$1?Identifiers.elementContainer:Identifiers.element,trimTrailingNulls(parameters));}else {this.creationInstruction(element.startSourceSpan,isNgContainer$1?Identifiers.elementContainerStart:Identifiers.elementStart,trimTrailingNulls(parameters));if(isNonBindableMode){this.creationInstruction(element.startSourceSpan,Identifiers.disableBindings);}if(boundI18nAttrs.length>0){this.i18nAttributesInstruction(elementIndex,boundI18nAttrs,(_a=element.startSourceSpan)!==null&&_a!==void 0?_a:element.sourceSpan);}// Generate Listeners (outputs)
2750
- if(element.outputs.length>0){const listeners=element.outputs.map(outputAst=>({sourceSpan:outputAst.sourceSpan,params:this.prepareListenerParameter(element.name,outputAst,elementIndex)}));this.creationInstructionChain(Identifiers.listener,listeners);}// Note: it's important to keep i18n/i18nStart instructions after i18nAttributes and
2769
+ if(element.outputs.length>0){for(const outputAst of element.outputs){this.creationInstruction(outputAst.sourceSpan,Identifiers.listener,this.prepareListenerParameter(element.name,outputAst,elementIndex));}}// Note: it's important to keep i18n/i18nStart instructions after i18nAttributes and
2751
2770
  // listeners, to make sure i18nAttributes instruction targets current element at runtime.
2752
2771
  if(isI18nRootElement){this.i18nStart(element.startSourceSpan,element.i18n,createSelfClosingI18nInstruction);}}// the code here will collect all update-level styling instructions and add them to the
2753
2772
  // update block of the template function AOT code. Instructions like `styleProp`,
@@ -2766,18 +2785,18 @@ allOtherInputs.forEach(input=>{const inputType=input.type;if(inputType===4/* Ani
2766
2785
  // The reasoning for this is because the renderer should get each
2767
2786
  // synthetic binding value in the order of the array that they are
2768
2787
  // defined in...
2769
- const hasValue=value instanceof LiteralPrimitive?!!value.value:true;this.allocateBindingSlots(value);propertyBindings.push({name:prepareSyntheticPropertyName(input.name),sourceSpan:input.sourceSpan,value:()=>hasValue?this.convertPropertyBinding(value):emptyValueBindInstruction});}else {// we must skip attributes with associated i18n context, since these attributes are handled
2788
+ const hasValue=value instanceof LiteralPrimitive?!!value.value:true;this.allocateBindingSlots(value);propertyBindings.push({span:input.sourceSpan,paramsOrFn:getBindingFunctionParams(()=>hasValue?this.convertPropertyBinding(value):emptyValueBindInstruction,prepareSyntheticPropertyName(input.name))});}else {// we must skip attributes with associated i18n context, since these attributes are handled
2770
2789
  // separately and corresponding `i18nExp` and `i18nApply` instructions will be generated
2771
2790
  if(input.i18n)return;const value=input.value.visit(this._valueConverter);if(value!==undefined){const params=[];const[attrNamespace,attrName]=splitNsName(input.name);const isAttributeBinding=inputType===1/* Attribute */;const sanitizationRef=resolveSanitizationFn(input.securityContext,isAttributeBinding);if(sanitizationRef)params.push(sanitizationRef);if(attrNamespace){const namespaceLiteral=literal(attrNamespace);if(sanitizationRef){params.push(namespaceLiteral);}else {// If there wasn't a sanitization ref, we need to add
2772
2791
  // an extra param so that we can pass in the namespace.
2773
2792
  params.push(literal(null),namespaceLiteral);}}this.allocateBindingSlots(value);if(inputType===0/* Property */){if(value instanceof Interpolation){// prop="{{value}}" and friends
2774
2793
  this.interpolatedUpdateInstruction(getPropertyInterpolationExpression(value),elementIndex,attrName,input,value,params);}else {// [prop]="value"
2775
2794
  // Collect all the properties so that we can chain into a single function at the end.
2776
- propertyBindings.push({name:attrName,sourceSpan:input.sourceSpan,value:()=>this.convertPropertyBinding(value),params});}}else if(inputType===1/* Attribute */){if(value instanceof Interpolation&&getInterpolationArgsLength(value)>1){// attr.name="text{{value}}" and friends
2795
+ propertyBindings.push({span:input.sourceSpan,paramsOrFn:getBindingFunctionParams(()=>this.convertPropertyBinding(value),attrName,params)});}}else if(inputType===1/* Attribute */){if(value instanceof Interpolation&&getInterpolationArgsLength(value)>1){// attr.name="text{{value}}" and friends
2777
2796
  this.interpolatedUpdateInstruction(getAttributeInterpolationExpression(value),elementIndex,attrName,input,value,params);}else {const boundValue=value instanceof Interpolation?value.expressions[0]:value;// [attr.name]="value" or attr.name="{{value}}"
2778
2797
  // Collect the attribute bindings so that they can be chained at the end.
2779
- attributeBindings.push({name:attrName,sourceSpan:input.sourceSpan,value:()=>this.convertPropertyBinding(boundValue),params});}}else {// class prop
2780
- this.updateInstructionWithAdvance(elementIndex,input.sourceSpan,Identifiers.classProp,()=>{return [literal(elementIndex),literal(attrName),this.convertPropertyBinding(value),...params];});}}}});if(propertyBindings.length>0){this.updateInstructionChainWithAdvance(elementIndex,Identifiers.property,propertyBindings);}if(attributeBindings.length>0){this.updateInstructionChainWithAdvance(elementIndex,Identifiers.attribute,attributeBindings);}// Traverse element child nodes
2798
+ attributeBindings.push({span:input.sourceSpan,paramsOrFn:getBindingFunctionParams(()=>this.convertPropertyBinding(boundValue),attrName,params)});}}else {// class prop
2799
+ this.updateInstructionWithAdvance(elementIndex,input.sourceSpan,Identifiers.classProp,()=>{return [literal(elementIndex),literal(attrName),this.convertPropertyBinding(value),...params];});}}}});for(const propertyBinding of propertyBindings){this.updateInstructionWithAdvance(elementIndex,propertyBinding.span,Identifiers.property,propertyBinding.paramsOrFn);}for(const attributeBinding of attributeBindings){this.updateInstructionWithAdvance(elementIndex,attributeBinding.span,Identifiers.attribute,attributeBinding.paramsOrFn);}// Traverse element child nodes
2781
2800
  visitAll$1(this,element.children);if(!isI18nRootElement&&this.i18n){this.i18n.appendElement(element.i18n,elementIndex,true);}if(!createSelfClosingInstruction){// Finish element construction mode.
2782
2801
  const span=(_b=element.endSourceSpan)!==null&&_b!==void 0?_b:element.sourceSpan;if(isI18nRootElement){this.i18nEnd(span,createSelfClosingI18nInstruction);}if(isNonBindableMode){this.creationInstruction(span,Identifiers.enableBindings);}this.creationInstruction(span,isNgContainer$1?Identifiers.elementContainerEnd:Identifiers.elementEnd);}}visitTemplate(template){var _a;const NG_TEMPLATE_TAG_NAME='ng-template';const templateIndex=this.allocateDataSlot();if(this.i18n){this.i18n.appendTemplate(template.i18n,templateIndex);}const tagNameWithoutNamespace=template.tagName?splitNsName(template.tagName)[1]:template.tagName;const contextName=`${this.contextName}${template.tagName?'_'+sanitizeIdentifier(template.tagName):''}_${templateIndex}`;const templateName=`${contextName}_Template`;const parameters=[literal(templateIndex),variable(templateName),// We don't care about the tag's namespace here, because we infer
2783
2802
  // it based on the parent nodes inside the template instruction.
@@ -2797,7 +2816,7 @@ if(tagNameWithoutNamespace===NG_TEMPLATE_TAG_NAME){const[i18nInputs,inputs]=part
2797
2816
  // nested template function.
2798
2817
  if(i18nInputs.length>0){this.i18nAttributesInstruction(templateIndex,i18nInputs,(_a=template.startSourceSpan)!==null&&_a!==void 0?_a:template.sourceSpan);}// Add the input bindings
2799
2818
  if(inputs.length>0){this.templatePropertyBindings(templateIndex,inputs);}// Generate listeners for directive output
2800
- if(template.outputs.length>0){const listeners=template.outputs.map(outputAst=>({sourceSpan:outputAst.sourceSpan,params:this.prepareListenerParameter('ng_template',outputAst,templateIndex)}));this.creationInstructionChain(Identifiers.listener,listeners);}}}visitBoundText(text){if(this.i18n){const value=text.value.visit(this._valueConverter);this.allocateBindingSlots(value);if(value instanceof Interpolation){this.i18n.appendBoundText(text.i18n);this.i18nAppendBindings(value.expressions);}return;}const nodeIndex=this.allocateDataSlot();this.creationInstruction(text.sourceSpan,Identifiers.text,[literal(nodeIndex)]);const value=text.value.visit(this._valueConverter);this.allocateBindingSlots(value);if(value instanceof Interpolation){this.updateInstructionWithAdvance(nodeIndex,text.sourceSpan,getTextInterpolationExpression(value),()=>this.getUpdateInstructionArguments(value));}else {error('Text nodes should be interpolated and never bound directly.');}}visitText(text){// when a text element is located within a translatable
2819
+ for(const outputAst of template.outputs){this.creationInstruction(outputAst.sourceSpan,Identifiers.listener,this.prepareListenerParameter('ng_template',outputAst,templateIndex));}}}visitBoundText(text){if(this.i18n){const value=text.value.visit(this._valueConverter);this.allocateBindingSlots(value);if(value instanceof Interpolation){this.i18n.appendBoundText(text.i18n);this.i18nAppendBindings(value.expressions);}return;}const nodeIndex=this.allocateDataSlot();this.creationInstruction(text.sourceSpan,Identifiers.text,[literal(nodeIndex)]);const value=text.value.visit(this._valueConverter);this.allocateBindingSlots(value);if(value instanceof Interpolation){this.updateInstructionWithAdvance(nodeIndex,text.sourceSpan,getTextInterpolationExpression(value),()=>this.getUpdateInstructionArguments(value));}else {error('Text nodes should be interpolated and never bound directly.');}}visitText(text){// when a text element is located within a translatable
2801
2820
  // block, we exclude this text element from instructions set,
2802
2821
  // since it will be captured in i18n content and processed at runtime
2803
2822
  if(!this.i18n){this.creationInstruction(text.sourceSpan,Identifiers.text,[literal(this.allocateDataSlot()),literal(text.value)]);}}visitIcu(icu){let initWasInvoked=false;// if an ICU was created outside of i18n block, we still treat
@@ -2809,23 +2828,22 @@ const message=icu.i18n;// we always need post-processing function for ICUs, to m
2809
2828
  // `goog.getMsg` does not process ICUs and uses the `{PLACEHOLDER}` format for placeholders
2810
2829
  // inside ICUs)
2811
2830
  // - all ICU vars (such as `VAR_SELECT` or `VAR_PLURAL`) are replaced with correct values
2812
- const transformFn=raw=>{const params=Object.assign(Object.assign({},vars),placeholders);const formatted=i18nFormatPlaceholderNames(params,/* useCamelCase */false);return instruction(null,Identifiers.i18nPostprocess,[raw,mapLiteral(formatted,true)]);};// in case the whole i18n message is a single ICU - we do not need to
2831
+ const transformFn=raw=>{const params=Object.assign(Object.assign({},vars),placeholders);const formatted=i18nFormatPlaceholderNames(params,/* useCamelCase */false);return invokeInstruction(null,Identifiers.i18nPostprocess,[raw,mapLiteral(formatted,true)]);};// in case the whole i18n message is a single ICU - we do not need to
2813
2832
  // create a separate top-level translation, we can use the root ref instead
2814
2833
  // and make this ICU a top-level translation
2815
2834
  // note: ICU placeholders are replaced with actual values in `i18nPostprocess` function
2816
2835
  // separately, so we do not pass placeholders into `i18nTranslate` function.
2817
2836
  if(isSingleI18nIcu(i18n.meta)){this.i18nTranslate(message,/* placeholders */{},i18n.ref,transformFn);}else {// output ICU directly and keep ICU reference in context
2818
- const ref=this.i18nTranslate(message,/* placeholders */{},/* ref */undefined,transformFn);i18n.appendIcu(icuFromI18nMessage(message).name,ref);}if(initWasInvoked){this.i18nEnd(null,true);}return null;}allocateDataSlot(){return this._dataIndex++;}getConstCount(){return this._dataIndex;}getVarCount(){return this._pureFunctionSlots;}getConsts(){return this._constants;}getNgContentSelectors(){return this._ngContentReservedSlots.length?this.constantPool.getConstLiteral(asLiteral(this._ngContentReservedSlots),true):null;}bindingContext(){return `${this._bindingContext++}`;}templatePropertyBindings(templateIndex,attrs){const propertyBindings=[];attrs.forEach(input=>{if(input instanceof BoundAttribute){const value=input.value.visit(this._valueConverter);if(value!==undefined){this.allocateBindingSlots(value);if(value instanceof Interpolation){// Params typically contain attribute namespace and value sanitizer, which is applicable
2837
+ const ref=this.i18nTranslate(message,/* placeholders */{},/* ref */undefined,transformFn);i18n.appendIcu(icuFromI18nMessage(message).name,ref);}if(initWasInvoked){this.i18nEnd(null,true);}return null;}allocateDataSlot(){return this._dataIndex++;}getConstCount(){return this._dataIndex;}getVarCount(){return this._pureFunctionSlots;}getConsts(){return this._constants;}getNgContentSelectors(){return this._ngContentReservedSlots.length?this.constantPool.getConstLiteral(asLiteral(this._ngContentReservedSlots),true):null;}bindingContext(){return `${this._bindingContext++}`;}templatePropertyBindings(templateIndex,attrs){const propertyBindings=[];for(const input of attrs){if(!(input instanceof BoundAttribute)){continue;}const value=input.value.visit(this._valueConverter);if(value===undefined){continue;}this.allocateBindingSlots(value);if(value instanceof Interpolation){// Params typically contain attribute namespace and value sanitizer, which is applicable
2819
2838
  // for regular HTML elements, but not applicable for <ng-template> (since props act as
2820
2839
  // inputs to directives), so keep params array empty.
2821
2840
  const params=[];// prop="{{value}}" case
2822
2841
  this.interpolatedUpdateInstruction(getPropertyInterpolationExpression(value),templateIndex,input.name,input,value,params);}else {// [prop]="value" case
2823
- propertyBindings.push({name:input.name,sourceSpan:input.sourceSpan,value:()=>this.convertPropertyBinding(value)});}}}});if(propertyBindings.length>0){this.updateInstructionChainWithAdvance(templateIndex,Identifiers.property,propertyBindings);}}// Bindings must only be resolved after all local refs have been visited, so all
2842
+ propertyBindings.push({span:input.sourceSpan,paramsOrFn:getBindingFunctionParams(()=>this.convertPropertyBinding(value),input.name)});}}for(const propertyBinding of propertyBindings){this.updateInstructionWithAdvance(templateIndex,propertyBinding.span,Identifiers.property,propertyBinding.paramsOrFn);}}// Bindings must only be resolved after all local refs have been visited, so all
2824
2843
  // instructions are queued in callbacks that execute once the initial pass has completed.
2825
2844
  // Otherwise, we wouldn't be able to support local refs that are defined after their
2826
2845
  // bindings. e.g. {{ foo }} <div #foo></div>
2827
- instructionFn(fns,span,reference,paramsOrFn,prepend=false){fns[prepend?'unshift':'push'](()=>{const params=Array.isArray(paramsOrFn)?paramsOrFn:paramsOrFn();return instruction(span,reference,params).toStmt();});}processStylingUpdateInstruction(elementIndex,instruction){let allocateBindingSlots=0;if(instruction){const calls=[];instruction.calls.forEach(call=>{allocateBindingSlots+=call.allocateBindingSlots;calls.push({sourceSpan:call.sourceSpan,value:()=>{return call.params(value=>call.supportsInterpolation&&value instanceof Interpolation?this.getUpdateInstructionArguments(value):this.convertPropertyBinding(value));}});});this.updateInstructionChainWithAdvance(elementIndex,instruction.reference,calls);}return allocateBindingSlots;}creationInstruction(span,reference,paramsOrFn,prepend){this.instructionFn(this._creationCodeFns,span,reference,paramsOrFn||[],prepend);}creationInstructionChain(reference,calls){const span=calls.length?calls[0].sourceSpan:null;this._creationCodeFns.push(()=>{return chainedInstruction(reference,calls.map(call=>call.params()),span).toStmt();});}updateInstructionWithAdvance(nodeIndex,span,reference,paramsOrFn){this.addAdvanceInstructionIfNecessary(nodeIndex,span);this.updateInstruction(span,reference,paramsOrFn);}updateInstruction(span,reference,paramsOrFn){this.instructionFn(this._updateCodeFns,span,reference,paramsOrFn||[]);}updateInstructionChain(reference,bindings){const span=bindings.length?bindings[0].sourceSpan:null;this._updateCodeFns.push(()=>{const calls=bindings.map(property=>{const value=property.value();const fnParams=Array.isArray(value)?value:[value];if(property.params){fnParams.push(...property.params);}if(property.name){// We want the property name to always be the first function parameter.
2828
- fnParams.unshift(literal(property.name));}return fnParams;});return chainedInstruction(reference,calls,span).toStmt();});}updateInstructionChainWithAdvance(nodeIndex,reference,bindings){this.addAdvanceInstructionIfNecessary(nodeIndex,bindings.length?bindings[0].sourceSpan:null);this.updateInstructionChain(reference,bindings);}addAdvanceInstructionIfNecessary(nodeIndex,span){if(nodeIndex!==this._currentIndex){const delta=nodeIndex-this._currentIndex;if(delta<1){throw new Error('advance instruction can only go forwards');}this.instructionFn(this._updateCodeFns,span,Identifiers.advance,[literal(delta)]);this._currentIndex=nodeIndex;}}allocatePureFunctionSlots(numSlots){const originalSlots=this._pureFunctionSlots;this._pureFunctionSlots+=numSlots;return originalSlots;}allocateBindingSlots(value){this._bindingSlots+=value instanceof Interpolation?value.expressions.length:1;}/**
2846
+ instructionFn(fns,span,reference,paramsOrFn,prepend=false){fns[prepend?'unshift':'push']({span,reference,paramsOrFn});}processStylingUpdateInstruction(elementIndex,instruction){let allocateBindingSlots=0;if(instruction){for(const call of instruction.calls){allocateBindingSlots+=call.allocateBindingSlots;this.updateInstructionWithAdvance(elementIndex,call.sourceSpan,instruction.reference,()=>call.params(value=>call.supportsInterpolation&&value instanceof Interpolation?this.getUpdateInstructionArguments(value):this.convertPropertyBinding(value)));}}return allocateBindingSlots;}creationInstruction(span,reference,paramsOrFn,prepend){this.instructionFn(this._creationCodeFns,span,reference,paramsOrFn||[],prepend);}updateInstructionWithAdvance(nodeIndex,span,reference,paramsOrFn){this.addAdvanceInstructionIfNecessary(nodeIndex,span);this.updateInstruction(span,reference,paramsOrFn);}updateInstruction(span,reference,paramsOrFn){this.instructionFn(this._updateCodeFns,span,reference,paramsOrFn||[]);}addAdvanceInstructionIfNecessary(nodeIndex,span){if(nodeIndex!==this._currentIndex){const delta=nodeIndex-this._currentIndex;if(delta<1){throw new Error('advance instruction can only go forwards');}this.instructionFn(this._updateCodeFns,span,Identifiers.advance,[literal(delta)]);this._currentIndex=nodeIndex;}}allocatePureFunctionSlots(numSlots){const originalSlots=this._pureFunctionSlots;this._pureFunctionSlots+=numSlots;return originalSlots;}allocateBindingSlots(value){this._bindingSlots+=value instanceof Interpolation?value.expressions.length:1;}/**
2829
2847
  * Gets an expression that refers to the implicit receiver. The implicit
2830
2848
  * receiver is always the root level context.
2831
2849
  */getImplicitReceiverExpr(){if(this._implicitReceiverExpr){return this._implicitReceiverExpr;}return this._implicitReceiverExpr=this.level===0?variable(CONTEXT_NAME):this._bindingScope.getOrCreateSharedContextVar(0);}convertPropertyBinding(value){const convertedPropertyBinding=convertPropertyBinding(this,this.getImplicitReceiverExpr(),value,this.bindingContext());const valExpr=convertedPropertyBinding.currValExpr;this._tempVariables.push(...convertedPropertyBinding.stmts);return valExpr;}/**
@@ -2889,7 +2907,7 @@ const literal=literalArr(values);return getLiteralFactory(this.constantPool,lite
2889
2907
  // calls to literal factories that compose the literal and will cache intermediate
2890
2908
  // values.
2891
2909
  const literal=literalMap(values.map((value,index)=>({key:map.keys[index].key,value,quoted:map.keys[index].quoted})));return getLiteralFactory(this.constantPool,literal,this.allocatePureFunctionSlots);});}}// Pipes always have at least one parameter, the value they operate on
2892
- const pipeBindingIdentifiers=[Identifiers.pipeBind1,Identifiers.pipeBind2,Identifiers.pipeBind3,Identifiers.pipeBind4];function pipeBindingCallInfo(args){const identifier=pipeBindingIdentifiers[args.length];return {identifier:identifier||Identifiers.pipeBindV,isVarLength:!identifier};}const pureFunctionIdentifiers=[Identifiers.pureFunction0,Identifiers.pureFunction1,Identifiers.pureFunction2,Identifiers.pureFunction3,Identifiers.pureFunction4,Identifiers.pureFunction5,Identifiers.pureFunction6,Identifiers.pureFunction7,Identifiers.pureFunction8];function pureFunctionCallInfo(args){const identifier=pureFunctionIdentifiers[args.length];return {identifier:identifier||Identifiers.pureFunctionV,isVarLength:!identifier};}function instruction(span,reference,params){return importExpr(reference,null,span).callFn(params,span);}// e.g. x(2);
2910
+ const pipeBindingIdentifiers=[Identifiers.pipeBind1,Identifiers.pipeBind2,Identifiers.pipeBind3,Identifiers.pipeBind4];function pipeBindingCallInfo(args){const identifier=pipeBindingIdentifiers[args.length];return {identifier:identifier||Identifiers.pipeBindV,isVarLength:!identifier};}const pureFunctionIdentifiers=[Identifiers.pureFunction0,Identifiers.pureFunction1,Identifiers.pureFunction2,Identifiers.pureFunction3,Identifiers.pureFunction4,Identifiers.pureFunction5,Identifiers.pureFunction6,Identifiers.pureFunction7,Identifiers.pureFunction8];function pureFunctionCallInfo(args){const identifier=pureFunctionIdentifiers[args.length];return {identifier:identifier||Identifiers.pureFunctionV,isVarLength:!identifier};}// e.g. x(2);
2893
2911
  function generateNextContextExpr(relativeLevelDiff){return importExpr(Identifiers.nextContext).callFn(relativeLevelDiff>1?[literal(relativeLevelDiff)]:[]);}function getLiteralFactory(constantPool,literal$1,allocateSlots){const{literalFactory,literalFactoryArguments}=constantPool.getLiteralFactory(literal$1);// Allocate 1 slot for the result plus 1 per argument
2894
2912
  const startSlot=allocateSlots(1+literalFactoryArguments.length);const{identifier,isVarLength}=pureFunctionCallInfo(literalFactoryArguments);// Literal factories are pure functions that only need to be re-invoked when the parameters
2895
2913
  // change.
@@ -2934,10 +2952,10 @@ return [lhs.set(generateNextContextExpr(relativeLevel)).toConstDecl()];},declare
2934
2952
  // If the context object changes in update mode, the reference will be incorrect, because
2935
2953
  // it was established during creation.
2936
2954
  if(this.isListenerScope()){if(!this.parent.restoreViewVariable){// parent saves variable to generate a shared `const $s$ = getCurrentView();` instruction
2937
- this.parent.restoreViewVariable=variable(this.parent.freshReferenceName());}this.restoreViewVariable=this.parent.restoreViewVariable;}}restoreViewStatement(){const statements=[];if(this.restoreViewVariable){const restoreCall=instruction(null,Identifiers.restoreView,[this.restoreViewVariable]);// Either `const restoredCtx = restoreView($state$);` or `restoreView($state$);`
2955
+ this.parent.restoreViewVariable=variable(this.parent.freshReferenceName());}this.restoreViewVariable=this.parent.restoreViewVariable;}}restoreViewStatement(){const statements=[];if(this.restoreViewVariable){const restoreCall=invokeInstruction(null,Identifiers.restoreView,[this.restoreViewVariable]);// Either `const restoredCtx = restoreView($state$);` or `restoreView($state$);`
2938
2956
  // depending on whether it is being used.
2939
2957
  statements.push(this.usesRestoredViewContext?variable(RESTORED_VIEW_CONTEXT_NAME).set(restoreCall).toConstDecl():restoreCall.toStmt());}return statements;}viewSnapshotStatements(){// const $state$ = getCurrentView();
2940
- return this.restoreViewVariable?[this.restoreViewVariable.set(instruction(null,Identifiers.getCurrentView,[])).toConstDecl()]:[];}isListenerScope(){return this.parent&&this.parent.bindingLevel===this.bindingLevel;}variableDeclarations(){let currentContextLevel=0;return Array.from(this.map.values()).filter(value=>value.declare).sort((a,b)=>b.retrievalLevel-a.retrievalLevel||b.priority-a.priority).reduce((stmts,value)=>{const levelDiff=this.bindingLevel-value.retrievalLevel;const currStmts=value.declareLocalCallback(this,levelDiff-currentContextLevel);currentContextLevel=levelDiff;return stmts.concat(currStmts);},[]);}freshReferenceName(){let current=this;// Find the top scope as it maintains the global reference count
2958
+ return this.restoreViewVariable?[this.restoreViewVariable.set(invokeInstruction(null,Identifiers.getCurrentView,[])).toConstDecl()]:[];}isListenerScope(){return this.parent&&this.parent.bindingLevel===this.bindingLevel;}variableDeclarations(){let currentContextLevel=0;return Array.from(this.map.values()).filter(value=>value.declare).sort((a,b)=>b.retrievalLevel-a.retrievalLevel||b.priority-a.priority).reduce((stmts,value)=>{const levelDiff=this.bindingLevel-value.retrievalLevel;const currStmts=value.declareLocalCallback(this,levelDiff-currentContextLevel);currentContextLevel=levelDiff;return stmts.concat(currStmts);},[]);}freshReferenceName(){let current=this;// Find the top scope as it maintains the global reference count
2941
2959
  while(current.parent)current=current.parent;const ref=`${REFERENCE_PREFIX}${current.referenceNameIndex++}`;return ref;}hasRestoreViewVariable(){return !!this.restoreViewVariable;}notifyRestoredViewContextUse(){this.usesRestoredViewContext=true;}}/**
2942
2960
  * Creates a `CssSelector` given a tag name and a map of attributes
2943
2961
  */function createCssSelector(elementName,attributes){const cssSelector=new CssSelector();const elementNameNoNs=splitNsName(elementName)[1];cssSelector.setElement(elementNameNoNs);Object.getOwnPropertyNames(attributes).forEach(name=>{const nameNoNs=splitNsName(name)[1];const value=attributes[name];cssSelector.addAttribute(nameNoNs,value);if(name.toLowerCase()==='class'){const classes=value.trim().split(/\s+/);classes.forEach(className=>cssSelector.addClassName(className));}});return cssSelector;}/**
@@ -2974,7 +2992,8 @@ if(i18nMetaVisitor.hasI18nMeta){rootNodes=visitAll(new I18nMetaVisitor(interpola
2974
2992
  // values because the style algorithm knows internally what props are subject
2975
2993
  // to sanitization (only [attr.style] values are explicitly sanitized)
2976
2994
  return isAttribute?importExpr(Identifiers.sanitizeStyle):null;case SecurityContext.URL:return importExpr(Identifiers.sanitizeUrl);case SecurityContext.RESOURCE_URL:return importExpr(Identifiers.sanitizeResourceUrl);default:return null;}}function trustedConstAttribute(tagName,attr){const value=asLiteral(attr.value);if(isTrustedTypesSink(tagName,attr.name)){switch(elementRegistry.securityContext(tagName,attr.name,/* isAttribute */true)){case SecurityContext.HTML:return taggedTemplate(importExpr(Identifiers.trustConstantHtml),new TemplateLiteral([new TemplateLiteralElement(attr.value)],[]),undefined,attr.valueSpan);// NB: no SecurityContext.SCRIPT here, as the corresponding tags are stripped by the compiler.
2977
- case SecurityContext.RESOURCE_URL:return taggedTemplate(importExpr(Identifiers.trustConstantResourceUrl),new TemplateLiteral([new TemplateLiteralElement(attr.value)],[]),undefined,attr.valueSpan);default:return value;}}else {return value;}}function isSingleElementTemplate(children){return children.length===1&&children[0]instanceof Element$1;}function isTextNode(node){return node instanceof Text$3||node instanceof BoundText||node instanceof Icu$1;}function hasTextChildrenOnly(children){return children.every(isTextNode);}/** Name of the global variable that is used to determine if we use Closure translations or not */const NG_I18N_CLOSURE_MODE='ngI18nClosureMode';/**
2995
+ case SecurityContext.RESOURCE_URL:return taggedTemplate(importExpr(Identifiers.trustConstantResourceUrl),new TemplateLiteral([new TemplateLiteralElement(attr.value)],[]),undefined,attr.valueSpan);default:return value;}}else {return value;}}function isSingleElementTemplate(children){return children.length===1&&children[0]instanceof Element$1;}function isTextNode(node){return node instanceof Text$3||node instanceof BoundText||node instanceof Icu$1;}function hasTextChildrenOnly(children){return children.every(isTextNode);}function getBindingFunctionParams(deferredParams,name,eagerParams){return ()=>{const value=deferredParams();const fnParams=Array.isArray(value)?value:[value];if(eagerParams){fnParams.push(...eagerParams);}if(name){// We want the property name to always be the first function parameter.
2996
+ fnParams.unshift(literal(name));}return fnParams;};}/** Name of the global variable that is used to determine if we use Closure translations or not */const NG_I18N_CLOSURE_MODE='ngI18nClosureMode';/**
2978
2997
  * Generate statements that define a given translation message.
2979
2998
  *
2980
2999
  * ```
@@ -3071,20 +3090,20 @@ const selectorForType=meta.selector!==null?meta.selector.replace(/\n/g,''):null;
3071
3090
  function createViewQueriesFunction(viewQueries,constantPool,name){const createStatements=[];const updateStatements=[];const tempAllocator=temporaryAllocator(updateStatements,TEMPORARY_NAME);viewQueries.forEach(query=>{// creation, e.g. r3.viewQuery(somePredicate, true);
3072
3091
  const queryDefinition=importExpr(Identifiers.viewQuery).callFn(prepareQueryParams(query,constantPool));createStatements.push(queryDefinition.toStmt());// update, e.g. (r3.queryRefresh(tmp = r3.loadQuery()) && (ctx.someDir = tmp));
3073
3092
  const temporary=tempAllocator();const getQueryList=importExpr(Identifiers.loadQuery).callFn([]);const refresh=importExpr(Identifiers.queryRefresh).callFn([temporary.set(getQueryList)]);const updateDirective=variable(CONTEXT_NAME).prop(query.propertyName).set(query.first?temporary.prop('first'):temporary);updateStatements.push(refresh.and(updateDirective).toStmt());});const viewQueryFnName=name?`${name}_Query`:null;return fn([new FnParam(RENDER_FLAGS,NUMBER_TYPE),new FnParam(CONTEXT_NAME,null)],[renderFlagCheckIfStmt(1/* Create */,createStatements),renderFlagCheckIfStmt(2/* Update */,updateStatements)],INFERRED_TYPE,null,viewQueryFnName);}// Return a host binding function or null if one is not necessary.
3074
- function createHostBindingsFunction(hostBindingsMetadata,typeSourceSpan,bindingParser,constantPool,selector,name,definitionMap){const bindingContext=variable(CONTEXT_NAME);const styleBuilder=new StylingBuilder(bindingContext);const{styleAttr,classAttr}=hostBindingsMetadata.specialAttributes;if(styleAttr!==undefined){styleBuilder.registerStyleAttr(styleAttr);}if(classAttr!==undefined){styleBuilder.registerClassAttr(classAttr);}const createStatements=[];const updateStatements=[];const hostBindingSourceSpan=typeSourceSpan;// Calculate host event bindings
3075
- const eventBindings=bindingParser.createDirectiveHostEventAsts(hostBindingsMetadata.listeners,hostBindingSourceSpan);if(eventBindings&&eventBindings.length){const listeners=createHostListeners(eventBindings,name);createStatements.push(...listeners);}// Calculate the host property bindings
3093
+ function createHostBindingsFunction(hostBindingsMetadata,typeSourceSpan,bindingParser,constantPool,selector,name,definitionMap){const bindingContext=variable(CONTEXT_NAME);const styleBuilder=new StylingBuilder(bindingContext);const{styleAttr,classAttr}=hostBindingsMetadata.specialAttributes;if(styleAttr!==undefined){styleBuilder.registerStyleAttr(styleAttr);}if(classAttr!==undefined){styleBuilder.registerClassAttr(classAttr);}const createInstructions=[];const updateInstructions=[];const updateVariables=[];const hostBindingSourceSpan=typeSourceSpan;// Calculate host event bindings
3094
+ const eventBindings=bindingParser.createDirectiveHostEventAsts(hostBindingsMetadata.listeners,hostBindingSourceSpan);if(eventBindings&&eventBindings.length){createInstructions.push(...createHostListeners(eventBindings,name));}// Calculate the host property bindings
3076
3095
  const bindings=bindingParser.createBoundHostProperties(hostBindingsMetadata.properties,hostBindingSourceSpan);const allOtherBindings=[];// We need to calculate the total amount of binding slots required by
3077
3096
  // all the instructions together before any value conversions happen.
3078
3097
  // Value conversions may require additional slots for interpolation and
3079
3098
  // bindings with pipes. These calculates happen after this block.
3080
3099
  let totalHostVarsCount=0;bindings&&bindings.forEach(binding=>{const stylingInputWasSet=styleBuilder.registerInputBasedOnName(binding.name,binding.expression,hostBindingSourceSpan);if(stylingInputWasSet){totalHostVarsCount+=MIN_STYLING_BINDING_SLOTS_REQUIRED;}else {allOtherBindings.push(binding);totalHostVarsCount++;}});let valueConverter;const getValueConverter=()=>{if(!valueConverter){const hostVarsCountFn=numSlots=>{const originalVarsCount=totalHostVarsCount;totalHostVarsCount+=numSlots;return originalVarsCount;};valueConverter=new ValueConverter(constantPool,()=>error('Unexpected node'),// new nodes are illegal here
3081
3100
  hostVarsCountFn,()=>error('Unexpected pipe'));// pipes are illegal here
3082
- }return valueConverter;};const propertyBindings=[];const attributeBindings=[];const syntheticHostBindings=[];allOtherBindings.forEach(binding=>{// resolve literal arrays and literal objects
3101
+ }return valueConverter;};const propertyBindings=[];const attributeBindings=[];const syntheticHostBindings=[];for(const binding of allOtherBindings){// resolve literal arrays and literal objects
3083
3102
  const value=binding.expression.visit(getValueConverter());const bindingExpr=bindingFn(bindingContext,value);const{bindingName,instruction,isAttribute}=getBindingNameAndInstruction(binding);const securityContexts=bindingParser.calcPossibleSecurityContexts(selector,bindingName,isAttribute).filter(context=>context!==SecurityContext.NONE);let sanitizerFn=null;if(securityContexts.length){if(securityContexts.length===2&&securityContexts.indexOf(SecurityContext.URL)>-1&&securityContexts.indexOf(SecurityContext.RESOURCE_URL)>-1){// Special case for some URL attributes (such as "src" and "href") that may be a part
3084
3103
  // of different security contexts. In this case we use special sanitization function and
3085
3104
  // select the actual sanitizer at runtime based on a tag name that is provided while
3086
3105
  // invoking sanitization function.
3087
- sanitizerFn=importExpr(Identifiers.sanitizeUrlOrResourceUrl);}else {sanitizerFn=resolveSanitizationFn(securityContexts[0],isAttribute);}}const instructionParams=[literal(bindingName),bindingExpr.currValExpr];if(sanitizerFn){instructionParams.push(sanitizerFn);}updateStatements.push(...bindingExpr.stmts);if(instruction===Identifiers.hostProperty){propertyBindings.push(instructionParams);}else if(instruction===Identifiers.attribute){attributeBindings.push(instructionParams);}else if(instruction===Identifiers.syntheticHostProperty){syntheticHostBindings.push(instructionParams);}else {updateStatements.push(importExpr(instruction).callFn(instructionParams).toStmt());}});if(propertyBindings.length>0){updateStatements.push(chainedInstruction(Identifiers.hostProperty,propertyBindings).toStmt());}if(attributeBindings.length>0){updateStatements.push(chainedInstruction(Identifiers.attribute,attributeBindings).toStmt());}if(syntheticHostBindings.length>0){updateStatements.push(chainedInstruction(Identifiers.syntheticHostProperty,syntheticHostBindings).toStmt());}// since we're dealing with directives/components and both have hostBinding
3106
+ sanitizerFn=importExpr(Identifiers.sanitizeUrlOrResourceUrl);}else {sanitizerFn=resolveSanitizationFn(securityContexts[0],isAttribute);}}const instructionParams=[literal(bindingName),bindingExpr.currValExpr];if(sanitizerFn){instructionParams.push(sanitizerFn);}updateVariables.push(...bindingExpr.stmts);if(instruction===Identifiers.hostProperty){propertyBindings.push(instructionParams);}else if(instruction===Identifiers.attribute){attributeBindings.push(instructionParams);}else if(instruction===Identifiers.syntheticHostProperty){syntheticHostBindings.push(instructionParams);}else {updateInstructions.push({reference:instruction,paramsOrFn:instructionParams,span:null});}}for(const bindingParams of propertyBindings){updateInstructions.push({reference:Identifiers.hostProperty,paramsOrFn:bindingParams,span:null});}for(const bindingParams of attributeBindings){updateInstructions.push({reference:Identifiers.attribute,paramsOrFn:bindingParams,span:null});}for(const bindingParams of syntheticHostBindings){updateInstructions.push({reference:Identifiers.syntheticHostProperty,paramsOrFn:bindingParams,span:null});}// since we're dealing with directives/components and both have hostBinding
3088
3107
  // functions, we need to generate a special hostAttrs instruction that deals
3089
3108
  // with both the assignment of styling as well as static attributes to the host
3090
3109
  // element. The instruction below will instruct all initial styling (styling
@@ -3094,13 +3113,13 @@ sanitizerFn=importExpr(Identifiers.sanitizeUrlOrResourceUrl);}else {sanitizerFn=
3094
3113
  const hostAttrs=convertAttributesToExpressions(hostBindingsMetadata.attributes);styleBuilder.assignHostAttrs(hostAttrs,definitionMap);if(styleBuilder.hasBindings){// finally each binding that was registered in the statement above will need to be added to
3095
3114
  // the update block of a component/directive templateFn/hostBindingsFn so that the bindings
3096
3115
  // are evaluated and updated for the element.
3097
- styleBuilder.buildUpdateLevelInstructions(getValueConverter()).forEach(instruction=>{if(instruction.calls.length>0){const calls=[];instruction.calls.forEach(call=>{// we subtract a value of `1` here because the binding slot was already allocated
3116
+ styleBuilder.buildUpdateLevelInstructions(getValueConverter()).forEach(instruction=>{for(const call of instruction.calls){// we subtract a value of `1` here because the binding slot was already allocated
3098
3117
  // at the top of this method when all the input bindings were counted.
3099
- totalHostVarsCount+=Math.max(call.allocateBindingSlots-MIN_STYLING_BINDING_SLOTS_REQUIRED,0);calls.push(convertStylingCall(call,bindingContext,bindingFn));});updateStatements.push(chainedInstruction(instruction.reference,calls).toStmt());}});}if(totalHostVarsCount){definitionMap.set('hostVars',literal(totalHostVarsCount));}if(createStatements.length>0||updateStatements.length>0){const hostBindingsFnName=name?`${name}_HostBindings`:null;const statements=[];if(createStatements.length>0){statements.push(renderFlagCheckIfStmt(1/* Create */,createStatements));}if(updateStatements.length>0){statements.push(renderFlagCheckIfStmt(2/* Update */,updateStatements));}return fn([new FnParam(RENDER_FLAGS,NUMBER_TYPE),new FnParam(CONTEXT_NAME,null)],statements,INFERRED_TYPE,null,hostBindingsFnName);}return null;}function bindingFn(implicit,value){return convertPropertyBinding(null,implicit,value,'b');}function convertStylingCall(call,bindingContext,bindingFn){return call.params(value=>bindingFn(bindingContext,value).currValExpr);}function getBindingNameAndInstruction(binding){let bindingName=binding.name;let instruction;// Check to see if this is an attr binding or a property binding
3118
+ totalHostVarsCount+=Math.max(call.allocateBindingSlots-MIN_STYLING_BINDING_SLOTS_REQUIRED,0);updateInstructions.push({reference:instruction.reference,paramsOrFn:convertStylingCall(call,bindingContext,bindingFn),span:null});}});}if(totalHostVarsCount){definitionMap.set('hostVars',literal(totalHostVarsCount));}if(createInstructions.length>0||updateInstructions.length>0){const hostBindingsFnName=name?`${name}_HostBindings`:null;const statements=[];if(createInstructions.length>0){statements.push(renderFlagCheckIfStmt(1/* Create */,getInstructionStatements(createInstructions)));}if(updateInstructions.length>0){statements.push(renderFlagCheckIfStmt(2/* Update */,updateVariables.concat(getInstructionStatements(updateInstructions))));}return fn([new FnParam(RENDER_FLAGS,NUMBER_TYPE),new FnParam(CONTEXT_NAME,null)],statements,INFERRED_TYPE,null,hostBindingsFnName);}return null;}function bindingFn(implicit,value){return convertPropertyBinding(null,implicit,value,'b');}function convertStylingCall(call,bindingContext,bindingFn){return call.params(value=>bindingFn(bindingContext,value).currValExpr);}function getBindingNameAndInstruction(binding){let bindingName=binding.name;let instruction;// Check to see if this is an attr binding or a property binding
3100
3119
  const attrMatches=bindingName.match(ATTR_REGEX);if(attrMatches){bindingName=attrMatches[1];instruction=Identifiers.attribute;}else {if(binding.isAnimation){bindingName=prepareSyntheticPropertyName(bindingName);// host bindings that have a synthetic property (e.g. @foo) should always be rendered
3101
3120
  // in the context of the component and not the parent. Therefore there is a special
3102
3121
  // compatibility instruction available for this purpose.
3103
- instruction=Identifiers.syntheticHostProperty;}else {instruction=Identifiers.hostProperty;}}return {bindingName,instruction,isAttribute:!!attrMatches};}function createHostListeners(eventBindings,name){const listeners=[];const syntheticListeners=[];const instructions=[];eventBindings.forEach(binding=>{let bindingName=binding.name&&sanitizeIdentifier(binding.name);const bindingFnName=binding.type===1/* Animation */?prepareSyntheticListenerFunctionName(bindingName,binding.targetOrPhase):bindingName;const handlerName=name&&bindingName?`${name}_${bindingFnName}_HostBindingHandler`:null;const params=prepareEventListenerParameters(BoundEvent.fromParsedEvent(binding),handlerName);if(binding.type==1/* Animation */){syntheticListeners.push(params);}else {listeners.push(params);}});if(syntheticListeners.length>0){instructions.push(chainedInstruction(Identifiers.syntheticHostListener,syntheticListeners).toStmt());}if(listeners.length>0){instructions.push(chainedInstruction(Identifiers.listener,listeners).toStmt());}return instructions;}const HOST_REG_EXP=/^(?:\[([^\]]+)\])|(?:\(([^\)]+)\))$/;function parseHostBindings(host){const attributes={};const listeners={};const properties={};const specialAttributes={};for(const key of Object.keys(host)){const value=host[key];const matches=key.match(HOST_REG_EXP);if(matches===null){switch(key){case'class':if(typeof value!=='string'){// TODO(alxhub): make this a diagnostic.
3122
+ instruction=Identifiers.syntheticHostProperty;}else {instruction=Identifiers.hostProperty;}}return {bindingName,instruction,isAttribute:!!attrMatches};}function createHostListeners(eventBindings,name){const listenerParams=[];const syntheticListenerParams=[];const instructions=[];for(const binding of eventBindings){let bindingName=binding.name&&sanitizeIdentifier(binding.name);const bindingFnName=binding.type===1/* Animation */?prepareSyntheticListenerFunctionName(bindingName,binding.targetOrPhase):bindingName;const handlerName=name&&bindingName?`${name}_${bindingFnName}_HostBindingHandler`:null;const params=prepareEventListenerParameters(BoundEvent.fromParsedEvent(binding),handlerName);if(binding.type==1/* Animation */){syntheticListenerParams.push(params);}else {listenerParams.push(params);}}for(const params of syntheticListenerParams){instructions.push({reference:Identifiers.syntheticHostListener,paramsOrFn:params,span:null});}for(const params of listenerParams){instructions.push({reference:Identifiers.listener,paramsOrFn:params,span:null});}return instructions;}const HOST_REG_EXP=/^(?:\[([^\]]+)\])|(?:\(([^\)]+)\))$/;function parseHostBindings(host){const attributes={};const listeners={};const properties={};const specialAttributes={};for(const key of Object.keys(host)){const value=host[key];const matches=key.match(HOST_REG_EXP);if(matches===null){switch(key){case'class':if(typeof value!=='string'){// TODO(alxhub): make this a diagnostic.
3104
3123
  throw new Error(`Class binding must be string`);}specialAttributes.classAttr=value;break;case'style':if(typeof value!=='string'){// TODO(alxhub): make this a diagnostic.
3105
3124
  throw new Error(`Style binding must be string`);}specialAttributes.styleAttr=value;break;default:if(typeof value==='string'){attributes[key]=literal(value);}else {attributes[key]=value;}}}else if(matches[1/* Binding */]!=null){if(typeof value!=='string'){// TODO(alxhub): make this a diagnostic.
3106
3125
  throw new Error(`Property binding must be string`);}// synthetic properties (the ones that have a `@` as a prefix)
@@ -3176,7 +3195,7 @@ bindings.properties[ann.hostPropertyName||field]=getSafePropertyAccessString('th
3176
3195
  *
3177
3196
  * Use of this source code is governed by an MIT-style license that can be
3178
3197
  * found in the LICENSE file at https://angular.io/license
3179
- */const VERSION=new Version('13.2.2');/**
3198
+ */const VERSION=new Version('13.3.1');/**
3180
3199
  * @license
3181
3200
  * Copyright Google LLC All Rights Reserved.
3182
3201
  *
@@ -3525,7 +3544,7 @@ const fnCall=importExpr(Identifiers.setClassMetadata).callFn([metadata.type,meta
3525
3544
  * declaration.
3526
3545
  *
3527
3546
  * Do not include any prerelease in these versions as they are ignored.
3528
- */const MINIMUM_PARTIAL_LINKER_VERSION$6='12.0.0';function compileDeclareClassMetadata(metadata){const definitionMap=new DefinitionMap();definitionMap.set('minVersion',literal(MINIMUM_PARTIAL_LINKER_VERSION$6));definitionMap.set('version',literal('13.2.2'));definitionMap.set('ngImport',importExpr(Identifiers.core));definitionMap.set('type',metadata.type);definitionMap.set('decorators',metadata.decorators);definitionMap.set('ctorParameters',metadata.ctorParameters);definitionMap.set('propDecorators',metadata.propDecorators);return importExpr(Identifiers.declareClassMetadata).callFn([definitionMap.toLiteralMap()]);}/**
3547
+ */const MINIMUM_PARTIAL_LINKER_VERSION$6='12.0.0';function compileDeclareClassMetadata(metadata){const definitionMap=new DefinitionMap();definitionMap.set('minVersion',literal(MINIMUM_PARTIAL_LINKER_VERSION$6));definitionMap.set('version',literal('13.3.1'));definitionMap.set('ngImport',importExpr(Identifiers.core));definitionMap.set('type',metadata.type);definitionMap.set('decorators',metadata.decorators);definitionMap.set('ctorParameters',metadata.ctorParameters);definitionMap.set('propDecorators',metadata.propDecorators);return importExpr(Identifiers.declareClassMetadata).callFn([definitionMap.toLiteralMap()]);}/**
3529
3548
  * @license
3530
3549
  * Copyright Google LLC All Rights Reserved.
3531
3550
  *
@@ -3566,7 +3585,7 @@ return literal('invalid');}else if(deps===null){return literal(null);}else {retu
3566
3585
  */function compileDeclareDirectiveFromMetadata(meta){const definitionMap=createDirectiveDefinitionMap(meta);const expression=importExpr(Identifiers.declareDirective).callFn([definitionMap.toLiteralMap()]);const type=createDirectiveType(meta);return {expression,type,statements:[]};}/**
3567
3586
  * Gathers the declaration fields for a directive into a `DefinitionMap`. This allows for reusing
3568
3587
  * this logic for components, as they extend the directive metadata.
3569
- */function createDirectiveDefinitionMap(meta){const definitionMap=new DefinitionMap();definitionMap.set('minVersion',literal(MINIMUM_PARTIAL_LINKER_VERSION$5));definitionMap.set('version',literal('13.2.2'));// e.g. `type: MyDirective`
3588
+ */function createDirectiveDefinitionMap(meta){const definitionMap=new DefinitionMap();definitionMap.set('minVersion',literal(MINIMUM_PARTIAL_LINKER_VERSION$5));definitionMap.set('version',literal('13.3.1'));// e.g. `type: MyDirective`
3570
3589
  definitionMap.set('type',meta.internalType);// e.g. `selector: 'some-dir'`
3571
3590
  if(meta.selector!==null){definitionMap.set('selector',literal(meta.selector));}definitionMap.set('inputs',conditionallyCreateMapObjectLiteral(meta.inputs,true));definitionMap.set('outputs',conditionallyCreateMapObjectLiteral(meta.outputs));definitionMap.set('host',compileHostMetadata(meta.host));definitionMap.set('providers',meta.providers);if(meta.queries.length>0){definitionMap.set('queries',literalArr(meta.queries.map(compileQuery)));}if(meta.viewQueries.length>0){definitionMap.set('viewQueries',literalArr(meta.viewQueries.map(compileQuery)));}if(meta.exportAs!==null){definitionMap.set('exportAs',asLiteral(meta.exportAs));}if(meta.usesInheritance){definitionMap.set('usesInheritance',literal(true));}if(meta.lifecycle.usesOnChanges){definitionMap.set('usesOnChanges',literal(true));}definitionMap.set('ngImport',importExpr(Identifiers.core));return definitionMap;}/**
3572
3591
  * Compiles the metadata of a single query into its partial declaration form as declared
@@ -3615,7 +3634,7 @@ const contents=templateInfo.content;const file=new ParseSourceFile(contents,temp
3615
3634
  * declaration.
3616
3635
  *
3617
3636
  * Do not include any prerelease in these versions as they are ignored.
3618
- */const MINIMUM_PARTIAL_LINKER_VERSION$4='12.0.0';function compileDeclareFactoryFunction(meta){const definitionMap=new DefinitionMap();definitionMap.set('minVersion',literal(MINIMUM_PARTIAL_LINKER_VERSION$4));definitionMap.set('version',literal('13.2.2'));definitionMap.set('ngImport',importExpr(Identifiers.core));definitionMap.set('type',meta.internalType);definitionMap.set('deps',compileDependencies(meta.deps));definitionMap.set('target',importExpr(Identifiers.FactoryTarget).prop(exports.FactoryTarget[meta.target]));return {expression:importExpr(Identifiers.declareFactory).callFn([definitionMap.toLiteralMap()]),statements:[],type:createFactoryType(meta)};}/**
3637
+ */const MINIMUM_PARTIAL_LINKER_VERSION$4='12.0.0';function compileDeclareFactoryFunction(meta){const definitionMap=new DefinitionMap();definitionMap.set('minVersion',literal(MINIMUM_PARTIAL_LINKER_VERSION$4));definitionMap.set('version',literal('13.3.1'));definitionMap.set('ngImport',importExpr(Identifiers.core));definitionMap.set('type',meta.internalType);definitionMap.set('deps',compileDependencies(meta.deps));definitionMap.set('target',importExpr(Identifiers.FactoryTarget).prop(exports.FactoryTarget[meta.target]));return {expression:importExpr(Identifiers.declareFactory).callFn([definitionMap.toLiteralMap()]),statements:[],type:createFactoryType(meta)};}/**
3619
3638
  * @license
3620
3639
  * Copyright Google LLC All Rights Reserved.
3621
3640
  *
@@ -3631,7 +3650,7 @@ const contents=templateInfo.content;const file=new ParseSourceFile(contents,temp
3631
3650
  * Compile a Injectable declaration defined by the `R3InjectableMetadata`.
3632
3651
  */function compileDeclareInjectableFromMetadata(meta){const definitionMap=createInjectableDefinitionMap(meta);const expression=importExpr(Identifiers.declareInjectable).callFn([definitionMap.toLiteralMap()]);const type=createInjectableType(meta);return {expression,type,statements:[]};}/**
3633
3652
  * Gathers the declaration fields for a Injectable into a `DefinitionMap`.
3634
- */function createInjectableDefinitionMap(meta){const definitionMap=new DefinitionMap();definitionMap.set('minVersion',literal(MINIMUM_PARTIAL_LINKER_VERSION$3));definitionMap.set('version',literal('13.2.2'));definitionMap.set('ngImport',importExpr(Identifiers.core));definitionMap.set('type',meta.internalType);// Only generate providedIn property if it has a non-null value
3653
+ */function createInjectableDefinitionMap(meta){const definitionMap=new DefinitionMap();definitionMap.set('minVersion',literal(MINIMUM_PARTIAL_LINKER_VERSION$3));definitionMap.set('version',literal('13.3.1'));definitionMap.set('ngImport',importExpr(Identifiers.core));definitionMap.set('type',meta.internalType);// Only generate providedIn property if it has a non-null value
3635
3654
  if(meta.providedIn!==undefined){const providedIn=convertFromMaybeForwardRefExpression(meta.providedIn);if(providedIn.value!==null){definitionMap.set('providedIn',providedIn);}}if(meta.useClass!==undefined){definitionMap.set('useClass',convertFromMaybeForwardRefExpression(meta.useClass));}if(meta.useExisting!==undefined){definitionMap.set('useExisting',convertFromMaybeForwardRefExpression(meta.useExisting));}if(meta.useValue!==undefined){definitionMap.set('useValue',convertFromMaybeForwardRefExpression(meta.useValue));}// Factories do not contain `ForwardRef`s since any types are already wrapped in a function call
3636
3655
  // so the types will not be eagerly evaluated. Therefore we do not need to process this expression
3637
3656
  // with `convertFromProviderExpression()`.
@@ -3649,7 +3668,7 @@ if(meta.useFactory!==undefined){definitionMap.set('useFactory',meta.useFactory);
3649
3668
  * Do not include any prerelease in these versions as they are ignored.
3650
3669
  */const MINIMUM_PARTIAL_LINKER_VERSION$2='12.0.0';function compileDeclareInjectorFromMetadata(meta){const definitionMap=createInjectorDefinitionMap(meta);const expression=importExpr(Identifiers.declareInjector).callFn([definitionMap.toLiteralMap()]);const type=createInjectorType(meta);return {expression,type,statements:[]};}/**
3651
3670
  * Gathers the declaration fields for an Injector into a `DefinitionMap`.
3652
- */function createInjectorDefinitionMap(meta){const definitionMap=new DefinitionMap();definitionMap.set('minVersion',literal(MINIMUM_PARTIAL_LINKER_VERSION$2));definitionMap.set('version',literal('13.2.2'));definitionMap.set('ngImport',importExpr(Identifiers.core));definitionMap.set('type',meta.internalType);definitionMap.set('providers',meta.providers);if(meta.imports.length>0){definitionMap.set('imports',literalArr(meta.imports));}return definitionMap;}/**
3671
+ */function createInjectorDefinitionMap(meta){const definitionMap=new DefinitionMap();definitionMap.set('minVersion',literal(MINIMUM_PARTIAL_LINKER_VERSION$2));definitionMap.set('version',literal('13.3.1'));definitionMap.set('ngImport',importExpr(Identifiers.core));definitionMap.set('type',meta.internalType);definitionMap.set('providers',meta.providers);if(meta.imports.length>0){definitionMap.set('imports',literalArr(meta.imports));}return definitionMap;}/**
3653
3672
  * @license
3654
3673
  * Copyright Google LLC All Rights Reserved.
3655
3674
  *
@@ -3663,7 +3682,7 @@ if(meta.useFactory!==undefined){definitionMap.set('useFactory',meta.useFactory);
3663
3682
  * Do not include any prerelease in these versions as they are ignored.
3664
3683
  */const MINIMUM_PARTIAL_LINKER_VERSION$1='12.0.0';function compileDeclareNgModuleFromMetadata(meta){const definitionMap=createNgModuleDefinitionMap(meta);const expression=importExpr(Identifiers.declareNgModule).callFn([definitionMap.toLiteralMap()]);const type=createNgModuleType(meta);return {expression,type,statements:[]};}/**
3665
3684
  * Gathers the declaration fields for an NgModule into a `DefinitionMap`.
3666
- */function createNgModuleDefinitionMap(meta){const definitionMap=new DefinitionMap();definitionMap.set('minVersion',literal(MINIMUM_PARTIAL_LINKER_VERSION$1));definitionMap.set('version',literal('13.2.2'));definitionMap.set('ngImport',importExpr(Identifiers.core));definitionMap.set('type',meta.internalType);// We only generate the keys in the metadata if the arrays contain values.
3685
+ */function createNgModuleDefinitionMap(meta){const definitionMap=new DefinitionMap();definitionMap.set('minVersion',literal(MINIMUM_PARTIAL_LINKER_VERSION$1));definitionMap.set('version',literal('13.3.1'));definitionMap.set('ngImport',importExpr(Identifiers.core));definitionMap.set('type',meta.internalType);// We only generate the keys in the metadata if the arrays contain values.
3667
3686
  // We must wrap the arrays inside a function if any of the values are a forward reference to a
3668
3687
  // not-yet-declared class. This is to support JIT execution of the `ɵɵngDeclareNgModule()` call.
3669
3688
  // In the linker these wrappers are stripped and then reapplied for the `ɵɵdefineNgModule()` call.
@@ -3683,7 +3702,7 @@ if(meta.bootstrap.length>0){definitionMap.set('bootstrap',refsToArray(meta.boots
3683
3702
  * Compile a Pipe declaration defined by the `R3PipeMetadata`.
3684
3703
  */function compileDeclarePipeFromMetadata(meta){const definitionMap=createPipeDefinitionMap(meta);const expression=importExpr(Identifiers.declarePipe).callFn([definitionMap.toLiteralMap()]);const type=createPipeType(meta);return {expression,type,statements:[]};}/**
3685
3704
  * Gathers the declaration fields for a Pipe into a `DefinitionMap`.
3686
- */function createPipeDefinitionMap(meta){const definitionMap=new DefinitionMap();definitionMap.set('minVersion',literal(MINIMUM_PARTIAL_LINKER_VERSION));definitionMap.set('version',literal('13.2.2'));definitionMap.set('ngImport',importExpr(Identifiers.core));// e.g. `type: MyPipe`
3705
+ */function createPipeDefinitionMap(meta){const definitionMap=new DefinitionMap();definitionMap.set('minVersion',literal(MINIMUM_PARTIAL_LINKER_VERSION));definitionMap.set('version',literal('13.3.1'));definitionMap.set('ngImport',importExpr(Identifiers.core));// e.g. `type: MyPipe`
3687
3706
  definitionMap.set('type',meta.internalType);// e.g. `name: "myPipe"`
3688
3707
  definitionMap.set('name',literal(meta.pipeName));if(meta.pure===false){// e.g. `pure: false`
3689
3708
  definitionMap.set('pure',literal(meta.pure));}return definitionMap;}/**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular-eslint/bundled-angular-compiler",
3
- "version": "13.1.0",
3
+ "version": "13.1.1-alpha.11+38bf7a3",
4
4
  "description": "A CJS bundled version of @angular/compiler",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -15,5 +15,5 @@
15
15
  "package.json",
16
16
  "README.md"
17
17
  ],
18
- "gitHead": "4c11177e66cb54ba8d548ad7068990679c0c7e93"
18
+ "gitHead": "38bf7a3d921dfd0f7467e5f27ffa01f2373d1ea2"
19
19
  }