@angular-eslint/bundled-angular-compiler 13.0.0-alpha.0 → 13.0.1
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.
- package/CHANGELOG.md +14 -0
- package/dist/index.js +136 -140
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,20 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [13.0.1](https://github.com/angular-eslint/angular-eslint/compare/v13.0.0...v13.0.1) (2021-11-19)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @angular-eslint/bundled-angular-compiler
|
|
9
|
+
|
|
10
|
+
# [13.0.0](https://github.com/angular-eslint/angular-eslint/compare/v12.7.0...v13.0.0) (2021-11-18)
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
- angular-eslint v13 ([#780](https://github.com/angular-eslint/angular-eslint/issues/780)) ([f7ce631](https://github.com/angular-eslint/angular-eslint/commit/f7ce631524dd7834a422a5ac93a4c0534f9f23fa))
|
|
15
|
+
|
|
16
|
+
# [12.7.0](https://github.com/angular-eslint/angular-eslint/compare/v12.6.1...v12.7.0) (2021-11-18)
|
|
17
|
+
|
|
18
|
+
**Note:** Version bump only for package @angular-eslint/bundled-angular-compiler
|
|
19
|
+
|
|
6
20
|
## [12.6.1](https://github.com/angular-eslint/angular-eslint/compare/v12.6.0...v12.6.1) (2021-10-26)
|
|
7
21
|
|
|
8
22
|
**Note:** Version bump only for package @angular-eslint/bundled-angular-compiler
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v13.0.
|
|
2
|
+
* @license Angular v13.0.2
|
|
3
3
|
* (c) 2010-2021 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/ /**
|
|
@@ -262,6 +262,94 @@ const _global=__global||__window||__self;function newArray(size,value){const lis
|
|
|
262
262
|
* @param conditionFn Condition function that is called for each item in a given array and returns a
|
|
263
263
|
* boolean value.
|
|
264
264
|
*/function partitionArray(arr,conditionFn){const truthy=[];const falsy=[];for(const item of arr){(conditionFn(item)?truthy:falsy).push(item);}return [truthy,falsy];}/**
|
|
265
|
+
* @license
|
|
266
|
+
* Copyright Google LLC All Rights Reserved.
|
|
267
|
+
*
|
|
268
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
269
|
+
* found in the LICENSE file at https://angular.io/license
|
|
270
|
+
*/ // https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit
|
|
271
|
+
const VERSION$1=3;const JS_B64_PREFIX='# sourceMappingURL=data:application/json;base64,';class SourceMapGenerator{constructor(file=null){this.file=file;this.sourcesContent=new Map();this.lines=[];this.lastCol0=0;this.hasMappings=false;}// The content is `null` when the content is expected to be loaded using the URL
|
|
272
|
+
addSource(url,content=null){if(!this.sourcesContent.has(url)){this.sourcesContent.set(url,content);}return this;}addLine(){this.lines.push([]);this.lastCol0=0;return this;}addMapping(col0,sourceUrl,sourceLine0,sourceCol0){if(!this.currentLine){throw new Error(`A line must be added before mappings can be added`);}if(sourceUrl!=null&&!this.sourcesContent.has(sourceUrl)){throw new Error(`Unknown source file "${sourceUrl}"`);}if(col0==null){throw new Error(`The column in the generated code must be provided`);}if(col0<this.lastCol0){throw new Error(`Mapping should be added in output order`);}if(sourceUrl&&(sourceLine0==null||sourceCol0==null)){throw new Error(`The source location must be provided when a source url is provided`);}this.hasMappings=true;this.lastCol0=col0;this.currentLine.push({col0,sourceUrl,sourceLine0,sourceCol0});return this;}/**
|
|
273
|
+
* @internal strip this from published d.ts files due to
|
|
274
|
+
* https://github.com/microsoft/TypeScript/issues/36216
|
|
275
|
+
*/get currentLine(){return this.lines.slice(-1)[0];}toJSON(){if(!this.hasMappings){return null;}const sourcesIndex=new Map();const sources=[];const sourcesContent=[];Array.from(this.sourcesContent.keys()).forEach((url,i)=>{sourcesIndex.set(url,i);sources.push(url);sourcesContent.push(this.sourcesContent.get(url)||null);});let mappings='';let lastCol0=0;let lastSourceIndex=0;let lastSourceLine0=0;let lastSourceCol0=0;this.lines.forEach(segments=>{lastCol0=0;mappings+=segments.map(segment=>{// zero-based starting column of the line in the generated code
|
|
276
|
+
let segAsStr=toBase64VLQ(segment.col0-lastCol0);lastCol0=segment.col0;if(segment.sourceUrl!=null){// zero-based index into the “sources” list
|
|
277
|
+
segAsStr+=toBase64VLQ(sourcesIndex.get(segment.sourceUrl)-lastSourceIndex);lastSourceIndex=sourcesIndex.get(segment.sourceUrl);// the zero-based starting line in the original source
|
|
278
|
+
segAsStr+=toBase64VLQ(segment.sourceLine0-lastSourceLine0);lastSourceLine0=segment.sourceLine0;// the zero-based starting column in the original source
|
|
279
|
+
segAsStr+=toBase64VLQ(segment.sourceCol0-lastSourceCol0);lastSourceCol0=segment.sourceCol0;}return segAsStr;}).join(',');mappings+=';';});mappings=mappings.slice(0,-1);return {'file':this.file||'','version':VERSION$1,'sourceRoot':'','sources':sources,'sourcesContent':sourcesContent,'mappings':mappings};}toJsComment(){return this.hasMappings?'//'+JS_B64_PREFIX+toBase64String(JSON.stringify(this,null,0)):'';}}function toBase64String(value){let b64='';const encoded=utf8Encode(value);for(let i=0;i<encoded.length;){const i1=encoded[i++];const i2=i<encoded.length?encoded[i++]:null;const i3=i<encoded.length?encoded[i++]:null;b64+=toBase64Digit(i1>>2);b64+=toBase64Digit((i1&3)<<4|(i2===null?0:i2>>4));b64+=i2===null?'=':toBase64Digit((i2&15)<<2|(i3===null?0:i3>>6));b64+=i2===null||i3===null?'=':toBase64Digit(i3&63);}return b64;}function toBase64VLQ(value){value=value<0?(-value<<1)+1:value<<1;let out='';do{let digit=value&31;value=value>>5;if(value>0){digit=digit|32;}out+=toBase64Digit(digit);}while(value>0);return out;}const B64_DIGITS='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';function toBase64Digit(value){if(value<0||value>=64){throw new Error(`Can only encode value in the range [0, 63]`);}return B64_DIGITS[value];}/**
|
|
280
|
+
* @license
|
|
281
|
+
* Copyright Google LLC All Rights Reserved.
|
|
282
|
+
*
|
|
283
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
284
|
+
* found in the LICENSE file at https://angular.io/license
|
|
285
|
+
*/const _SINGLE_QUOTE_ESCAPE_STRING_RE=/'|\\|\n|\r|\$/g;const _LEGAL_IDENTIFIER_RE=/^[$A-Z_][0-9A-Z_$]*$/i;const _INDENT_WITH=' ';const CATCH_ERROR_VAR$1=variable('error',null,null);const CATCH_STACK_VAR$1=variable('stack',null,null);class _EmittedLine{constructor(indent){this.indent=indent;this.partsLength=0;this.parts=[];this.srcSpans=[];}}class EmitterVisitorContext{constructor(_indent){this._indent=_indent;this._classes=[];this._preambleLineCount=0;this._lines=[new _EmittedLine(_indent)];}static createRoot(){return new EmitterVisitorContext(0);}/**
|
|
286
|
+
* @internal strip this from published d.ts files due to
|
|
287
|
+
* https://github.com/microsoft/TypeScript/issues/36216
|
|
288
|
+
*/get _currentLine(){return this._lines[this._lines.length-1];}println(from,lastPart=''){this.print(from||null,lastPart,true);}lineIsEmpty(){return this._currentLine.parts.length===0;}lineLength(){return this._currentLine.indent*_INDENT_WITH.length+this._currentLine.partsLength;}print(from,part,newLine=false){if(part.length>0){this._currentLine.parts.push(part);this._currentLine.partsLength+=part.length;this._currentLine.srcSpans.push(from&&from.sourceSpan||null);}if(newLine){this._lines.push(new _EmittedLine(this._indent));}}removeEmptyLastLine(){if(this.lineIsEmpty()){this._lines.pop();}}incIndent(){this._indent++;if(this.lineIsEmpty()){this._currentLine.indent=this._indent;}}decIndent(){this._indent--;if(this.lineIsEmpty()){this._currentLine.indent=this._indent;}}pushClass(clazz){this._classes.push(clazz);}popClass(){return this._classes.pop();}get currentClass(){return this._classes.length>0?this._classes[this._classes.length-1]:null;}toSource(){return this.sourceLines.map(l=>l.parts.length>0?_createIndent(l.indent)+l.parts.join(''):'').join('\n');}toSourceMapGenerator(genFilePath,startsAtLine=0){const map=new SourceMapGenerator(genFilePath);let firstOffsetMapped=false;const mapFirstOffsetIfNeeded=()=>{if(!firstOffsetMapped){// Add a single space so that tools won't try to load the file from disk.
|
|
289
|
+
// Note: We are using virtual urls like `ng:///`, so we have to
|
|
290
|
+
// provide a content here.
|
|
291
|
+
map.addSource(genFilePath,' ').addMapping(0,genFilePath,0,0);firstOffsetMapped=true;}};for(let i=0;i<startsAtLine;i++){map.addLine();mapFirstOffsetIfNeeded();}this.sourceLines.forEach((line,lineIdx)=>{map.addLine();const spans=line.srcSpans;const parts=line.parts;let col0=line.indent*_INDENT_WITH.length;let spanIdx=0;// skip leading parts without source spans
|
|
292
|
+
while(spanIdx<spans.length&&!spans[spanIdx]){col0+=parts[spanIdx].length;spanIdx++;}if(spanIdx<spans.length&&lineIdx===0&&col0===0){firstOffsetMapped=true;}else {mapFirstOffsetIfNeeded();}while(spanIdx<spans.length){const span=spans[spanIdx];const source=span.start.file;const sourceLine=span.start.line;const sourceCol=span.start.col;map.addSource(source.url,source.content).addMapping(col0,source.url,sourceLine,sourceCol);col0+=parts[spanIdx].length;spanIdx++;// assign parts without span or the same span to the previous segment
|
|
293
|
+
while(spanIdx<spans.length&&(span===spans[spanIdx]||!spans[spanIdx])){col0+=parts[spanIdx].length;spanIdx++;}}});return map;}setPreambleLineCount(count){return this._preambleLineCount=count;}spanOf(line,column){const emittedLine=this._lines[line-this._preambleLineCount];if(emittedLine){let columnsLeft=column-_createIndent(emittedLine.indent).length;for(let partIndex=0;partIndex<emittedLine.parts.length;partIndex++){const part=emittedLine.parts[partIndex];if(part.length>columnsLeft){return emittedLine.srcSpans[partIndex];}columnsLeft-=part.length;}}return null;}/**
|
|
294
|
+
* @internal strip this from published d.ts files due to
|
|
295
|
+
* https://github.com/microsoft/TypeScript/issues/36216
|
|
296
|
+
*/get sourceLines(){if(this._lines.length&&this._lines[this._lines.length-1].parts.length===0){return this._lines.slice(0,-1);}return this._lines;}}class AbstractEmitterVisitor{constructor(_escapeDollarInStrings){this._escapeDollarInStrings=_escapeDollarInStrings;}printLeadingComments(stmt,ctx){if(stmt.leadingComments===undefined){return;}for(const comment of stmt.leadingComments){if(comment instanceof JSDocComment){ctx.print(stmt,`/*${comment.toString()}*/`,comment.trailingNewline);}else {if(comment.multiline){ctx.print(stmt,`/* ${comment.text} */`,comment.trailingNewline);}else {comment.text.split('\n').forEach(line=>{ctx.println(stmt,`// ${line}`);});}}}}visitExpressionStmt(stmt,ctx){this.printLeadingComments(stmt,ctx);stmt.expr.visitExpression(this,ctx);ctx.println(stmt,';');return null;}visitReturnStmt(stmt,ctx){this.printLeadingComments(stmt,ctx);ctx.print(stmt,`return `);stmt.value.visitExpression(this,ctx);ctx.println(stmt,';');return null;}visitIfStmt(stmt,ctx){this.printLeadingComments(stmt,ctx);ctx.print(stmt,`if (`);stmt.condition.visitExpression(this,ctx);ctx.print(stmt,`) {`);const hasElseCase=stmt.falseCase!=null&&stmt.falseCase.length>0;if(stmt.trueCase.length<=1&&!hasElseCase){ctx.print(stmt,` `);this.visitAllStatements(stmt.trueCase,ctx);ctx.removeEmptyLastLine();ctx.print(stmt,` `);}else {ctx.println();ctx.incIndent();this.visitAllStatements(stmt.trueCase,ctx);ctx.decIndent();if(hasElseCase){ctx.println(stmt,`} else {`);ctx.incIndent();this.visitAllStatements(stmt.falseCase,ctx);ctx.decIndent();}}ctx.println(stmt,`}`);return null;}visitThrowStmt(stmt,ctx){this.printLeadingComments(stmt,ctx);ctx.print(stmt,`throw `);stmt.error.visitExpression(this,ctx);ctx.println(stmt,`;`);return null;}visitWriteVarExpr(expr,ctx){const lineWasEmpty=ctx.lineIsEmpty();if(!lineWasEmpty){ctx.print(expr,'(');}ctx.print(expr,`${expr.name} = `);expr.value.visitExpression(this,ctx);if(!lineWasEmpty){ctx.print(expr,')');}return null;}visitWriteKeyExpr(expr,ctx){const lineWasEmpty=ctx.lineIsEmpty();if(!lineWasEmpty){ctx.print(expr,'(');}expr.receiver.visitExpression(this,ctx);ctx.print(expr,`[`);expr.index.visitExpression(this,ctx);ctx.print(expr,`] = `);expr.value.visitExpression(this,ctx);if(!lineWasEmpty){ctx.print(expr,')');}return null;}visitWritePropExpr(expr,ctx){const lineWasEmpty=ctx.lineIsEmpty();if(!lineWasEmpty){ctx.print(expr,'(');}expr.receiver.visitExpression(this,ctx);ctx.print(expr,`.${expr.name} = `);expr.value.visitExpression(this,ctx);if(!lineWasEmpty){ctx.print(expr,')');}return null;}visitInvokeFunctionExpr(expr,ctx){expr.fn.visitExpression(this,ctx);ctx.print(expr,`(`);this.visitAllExpressions(expr.args,ctx,',');ctx.print(expr,`)`);return null;}visitTaggedTemplateExpr(expr,ctx){expr.tag.visitExpression(this,ctx);ctx.print(expr,'`'+expr.template.elements[0].rawText);for(let i=1;i<expr.template.elements.length;i++){ctx.print(expr,'${');expr.template.expressions[i-1].visitExpression(this,ctx);ctx.print(expr,`}${expr.template.elements[i].rawText}`);}ctx.print(expr,'`');return null;}visitWrappedNodeExpr(ast,ctx){throw new Error('Abstract emitter cannot visit WrappedNodeExpr.');}visitTypeofExpr(expr,ctx){ctx.print(expr,'typeof ');expr.expr.visitExpression(this,ctx);}visitReadVarExpr(ast,ctx){let varName=ast.name;if(ast.builtin!=null){switch(ast.builtin){case exports.BuiltinVar.Super:varName='super';break;case exports.BuiltinVar.This:varName='this';break;case exports.BuiltinVar.CatchError:varName=CATCH_ERROR_VAR$1.name;break;case exports.BuiltinVar.CatchStack:varName=CATCH_STACK_VAR$1.name;break;default:throw new Error(`Unknown builtin variable ${ast.builtin}`);}}ctx.print(ast,varName);return null;}visitInstantiateExpr(ast,ctx){ctx.print(ast,`new `);ast.classExpr.visitExpression(this,ctx);ctx.print(ast,`(`);this.visitAllExpressions(ast.args,ctx,',');ctx.print(ast,`)`);return null;}visitLiteralExpr(ast,ctx){const value=ast.value;if(typeof value==='string'){ctx.print(ast,escapeIdentifier(value,this._escapeDollarInStrings));}else {ctx.print(ast,`${value}`);}return null;}visitLocalizedString(ast,ctx){const head=ast.serializeI18nHead();ctx.print(ast,'$localize `'+head.raw);for(let i=1;i<ast.messageParts.length;i++){ctx.print(ast,'${');ast.expressions[i-1].visitExpression(this,ctx);ctx.print(ast,`}${ast.serializeI18nTemplatePart(i).raw}`);}ctx.print(ast,'`');return null;}visitConditionalExpr(ast,ctx){ctx.print(ast,`(`);ast.condition.visitExpression(this,ctx);ctx.print(ast,'? ');ast.trueCase.visitExpression(this,ctx);ctx.print(ast,': ');ast.falseCase.visitExpression(this,ctx);ctx.print(ast,`)`);return null;}visitNotExpr(ast,ctx){ctx.print(ast,'!');ast.condition.visitExpression(this,ctx);return null;}visitAssertNotNullExpr(ast,ctx){ast.condition.visitExpression(this,ctx);return null;}visitUnaryOperatorExpr(ast,ctx){let opStr;switch(ast.operator){case exports.UnaryOperator.Plus:opStr='+';break;case exports.UnaryOperator.Minus:opStr='-';break;default:throw new Error(`Unknown operator ${ast.operator}`);}if(ast.parens)ctx.print(ast,`(`);ctx.print(ast,opStr);ast.expr.visitExpression(this,ctx);if(ast.parens)ctx.print(ast,`)`);return null;}visitBinaryOperatorExpr(ast,ctx){let opStr;switch(ast.operator){case exports.BinaryOperator.Equals:opStr='==';break;case exports.BinaryOperator.Identical:opStr='===';break;case exports.BinaryOperator.NotEquals:opStr='!=';break;case exports.BinaryOperator.NotIdentical:opStr='!==';break;case exports.BinaryOperator.And:opStr='&&';break;case exports.BinaryOperator.BitwiseAnd:opStr='&';break;case exports.BinaryOperator.Or:opStr='||';break;case exports.BinaryOperator.Plus:opStr='+';break;case exports.BinaryOperator.Minus:opStr='-';break;case exports.BinaryOperator.Divide:opStr='/';break;case exports.BinaryOperator.Multiply:opStr='*';break;case exports.BinaryOperator.Modulo:opStr='%';break;case exports.BinaryOperator.Lower:opStr='<';break;case exports.BinaryOperator.LowerEquals:opStr='<=';break;case exports.BinaryOperator.Bigger:opStr='>';break;case exports.BinaryOperator.BiggerEquals:opStr='>=';break;case exports.BinaryOperator.NullishCoalesce:opStr='??';break;default:throw new Error(`Unknown operator ${ast.operator}`);}if(ast.parens)ctx.print(ast,`(`);ast.lhs.visitExpression(this,ctx);ctx.print(ast,` ${opStr} `);ast.rhs.visitExpression(this,ctx);if(ast.parens)ctx.print(ast,`)`);return null;}visitReadPropExpr(ast,ctx){ast.receiver.visitExpression(this,ctx);ctx.print(ast,`.`);ctx.print(ast,ast.name);return null;}visitReadKeyExpr(ast,ctx){ast.receiver.visitExpression(this,ctx);ctx.print(ast,`[`);ast.index.visitExpression(this,ctx);ctx.print(ast,`]`);return null;}visitLiteralArrayExpr(ast,ctx){ctx.print(ast,`[`);this.visitAllExpressions(ast.entries,ctx,',');ctx.print(ast,`]`);return null;}visitLiteralMapExpr(ast,ctx){ctx.print(ast,`{`);this.visitAllObjects(entry=>{ctx.print(ast,`${escapeIdentifier(entry.key,this._escapeDollarInStrings,entry.quoted)}:`);entry.value.visitExpression(this,ctx);},ast.entries,ctx,',');ctx.print(ast,`}`);return null;}visitCommaExpr(ast,ctx){ctx.print(ast,'(');this.visitAllExpressions(ast.parts,ctx,',');ctx.print(ast,')');return null;}visitAllExpressions(expressions,ctx,separator){this.visitAllObjects(expr=>expr.visitExpression(this,ctx),expressions,ctx,separator);}visitAllObjects(handler,expressions,ctx,separator){let incrementedIndent=false;for(let i=0;i<expressions.length;i++){if(i>0){if(ctx.lineLength()>80){ctx.print(null,separator,true);if(!incrementedIndent){// continuation are marked with double indent.
|
|
297
|
+
ctx.incIndent();ctx.incIndent();incrementedIndent=true;}}else {ctx.print(null,separator,false);}}handler(expressions[i]);}if(incrementedIndent){// continuation are marked with double indent.
|
|
298
|
+
ctx.decIndent();ctx.decIndent();}}visitAllStatements(statements,ctx){statements.forEach(stmt=>stmt.visitStatement(this,ctx));}}function escapeIdentifier(input,escapeDollar,alwaysQuote=true){if(input==null){return null;}const body=input.replace(_SINGLE_QUOTE_ESCAPE_STRING_RE,(...match)=>{if(match[0]=='$'){return escapeDollar?'\\$':'$';}else if(match[0]=='\n'){return '\\n';}else if(match[0]=='\r'){return '\\r';}else {return `\\${match[0]}`;}});const requiresQuotes=alwaysQuote||!_LEGAL_IDENTIFIER_RE.test(body);return requiresQuotes?`'${body}'`:body;}function _createIndent(count){let res='';for(let i=0;i<count;i++){res+=_INDENT_WITH;}return res;}/**
|
|
299
|
+
* @license
|
|
300
|
+
* Copyright Google LLC All Rights Reserved.
|
|
301
|
+
*
|
|
302
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
303
|
+
* found in the LICENSE file at https://angular.io/license
|
|
304
|
+
*/function typeWithParameters(type,numParams){if(numParams===0){return expressionType(type);}const params=[];for(let i=0;i<numParams;i++){params.push(DYNAMIC_TYPE);}return expressionType(type,undefined,params);}const ANIMATE_SYMBOL_PREFIX='@';function prepareSyntheticPropertyName(name){return `${ANIMATE_SYMBOL_PREFIX}${name}`;}function prepareSyntheticListenerName(name,phase){return `${ANIMATE_SYMBOL_PREFIX}${name}.${phase}`;}function getSafePropertyAccessString(accessor,name){const escapedName=escapeIdentifier(name,false,false);return escapedName!==name?`${accessor}[${escapedName}]`:`${accessor}.${name}`;}function prepareSyntheticListenerFunctionName(name,phase){return `animation_${name}_${phase}`;}function jitOnlyGuardedExpression(expr){return guardedExpression('ngJitMode',expr);}function devOnlyGuardedExpression(expr){return guardedExpression('ngDevMode',expr);}function guardedExpression(guard,expr){const guardExpr=new ExternalExpr({name:guard,moduleName:null});const guardNotDefined=new BinaryOperatorExpr(exports.BinaryOperator.Identical,new TypeofExpr(guardExpr),literal('undefined'));const guardUndefinedOrTrue=new BinaryOperatorExpr(exports.BinaryOperator.Or,guardNotDefined,guardExpr,/* type */undefined,/* sourceSpan */undefined,true);return new BinaryOperatorExpr(exports.BinaryOperator.And,guardUndefinedOrTrue,expr);}function wrapReference(value){const wrapped=new WrappedNodeExpr(value);return {value:wrapped,type:wrapped};}function refsToArray(refs,shouldForwardDeclare){const values=literalArr(refs.map(ref=>ref.value));return shouldForwardDeclare?fn([],[new ReturnStatement(values)]):values;}function createMayBeForwardRefExpression(expression,forwardRef){return {expression,forwardRef};}/**
|
|
305
|
+
* Convert a `MaybeForwardRefExpression` to an `Expression`, possibly wrapping its expression in a
|
|
306
|
+
* `forwardRef()` call.
|
|
307
|
+
*
|
|
308
|
+
* If `MaybeForwardRefExpression.forwardRef` is `ForwardRefHandling.Unwrapped` then the expression
|
|
309
|
+
* was originally wrapped in a `forwardRef()` call to prevent the value from being eagerly evaluated
|
|
310
|
+
* in the code.
|
|
311
|
+
*
|
|
312
|
+
* See `packages/compiler-cli/src/ngtsc/annotations/src/injectable.ts` and
|
|
313
|
+
* `packages/compiler/src/jit_compiler_facade.ts` for more information.
|
|
314
|
+
*/function convertFromMaybeForwardRefExpression({expression,forwardRef}){switch(forwardRef){case 0/* None */:case 1/* Wrapped */:return expression;case 2/* Unwrapped */:return generateForwardRef(expression);}}/**
|
|
315
|
+
* Generate an expression that has the given `expr` wrapped in the following form:
|
|
316
|
+
*
|
|
317
|
+
* ```
|
|
318
|
+
* forwardRef(() => expr)
|
|
319
|
+
* ```
|
|
320
|
+
*/function generateForwardRef(expr){return importExpr(Identifiers$1.forwardRef).callFn([fn([],[new ReturnStatement(expr)])]);}var R3FactoryDelegateType;(function(R3FactoryDelegateType){R3FactoryDelegateType[R3FactoryDelegateType["Class"]=0]="Class";R3FactoryDelegateType[R3FactoryDelegateType["Function"]=1]="Function";})(R3FactoryDelegateType||(R3FactoryDelegateType={}));exports.FactoryTarget = void 0;(function(FactoryTarget){FactoryTarget[FactoryTarget["Directive"]=0]="Directive";FactoryTarget[FactoryTarget["Component"]=1]="Component";FactoryTarget[FactoryTarget["Injectable"]=2]="Injectable";FactoryTarget[FactoryTarget["Pipe"]=3]="Pipe";FactoryTarget[FactoryTarget["NgModule"]=4]="NgModule";})(exports.FactoryTarget||(exports.FactoryTarget={}));/**
|
|
321
|
+
* Construct a factory function expression for the given `R3FactoryMetadata`.
|
|
322
|
+
*/function compileFactoryFunction(meta){const t=variable('t');let baseFactoryVar=null;// The type to instantiate via constructor invocation. If there is no delegated factory, meaning
|
|
323
|
+
// this type is always created by constructor invocation, then this is the type-to-create
|
|
324
|
+
// parameter provided by the user (t) if specified, or the current type if not. If there is a
|
|
325
|
+
// delegated factory (which is used to create the current type) then this is only the type-to-
|
|
326
|
+
// create parameter (t).
|
|
327
|
+
const typeForCtor=!isDelegatedFactoryMetadata(meta)?new BinaryOperatorExpr(exports.BinaryOperator.Or,t,meta.internalType):t;let ctorExpr=null;if(meta.deps!==null){// There is a constructor (either explicitly or implicitly defined).
|
|
328
|
+
if(meta.deps!=='invalid'){ctorExpr=new InstantiateExpr(typeForCtor,injectDependencies(meta.deps,meta.target));}}else {// There is no constructor, use the base class' factory to construct typeForCtor.
|
|
329
|
+
baseFactoryVar=variable(`ɵ${meta.name}_BaseFactory`);ctorExpr=baseFactoryVar.callFn([typeForCtor]);}const body=[];let retExpr=null;function makeConditionalFactory(nonCtorExpr){const r=variable('r');body.push(r.set(NULL_EXPR).toDeclStmt());const ctorStmt=ctorExpr!==null?r.set(ctorExpr).toStmt():importExpr(Identifiers$1.invalidFactory).callFn([]).toStmt();body.push(ifStmt(t,[ctorStmt],[r.set(nonCtorExpr).toStmt()]));return r;}if(isDelegatedFactoryMetadata(meta)){// This type is created with a delegated factory. If a type parameter is not specified, call
|
|
330
|
+
// the factory instead.
|
|
331
|
+
const delegateArgs=injectDependencies(meta.delegateDeps,meta.target);// Either call `new delegate(...)` or `delegate(...)` depending on meta.delegateType.
|
|
332
|
+
const factoryExpr=new(meta.delegateType===R3FactoryDelegateType.Class?InstantiateExpr:InvokeFunctionExpr)(meta.delegate,delegateArgs);retExpr=makeConditionalFactory(factoryExpr);}else if(isExpressionFactoryMetadata(meta)){// TODO(alxhub): decide whether to lower the value here or in the caller
|
|
333
|
+
retExpr=makeConditionalFactory(meta.expression);}else {retExpr=ctorExpr;}if(retExpr===null){// The expression cannot be formed so render an `ɵɵinvalidFactory()` call.
|
|
334
|
+
body.push(importExpr(Identifiers$1.invalidFactory).callFn([]).toStmt());}else if(baseFactoryVar!==null){// This factory uses a base factory, so call `ɵɵgetInheritedFactory()` to compute it.
|
|
335
|
+
const getInheritedFactoryCall=importExpr(Identifiers$1.getInheritedFactory).callFn([meta.internalType]);// Memoize the base factoryFn: `baseFactory || (baseFactory = ɵɵgetInheritedFactory(...))`
|
|
336
|
+
const baseFactory=new BinaryOperatorExpr(exports.BinaryOperator.Or,baseFactoryVar,baseFactoryVar.set(getInheritedFactoryCall));body.push(new ReturnStatement(baseFactory.callFn([typeForCtor])));}else {// This is straightforward factory, just return it.
|
|
337
|
+
body.push(new ReturnStatement(retExpr));}let factoryFn=fn([new FnParam('t',DYNAMIC_TYPE)],body,INFERRED_TYPE,undefined,`${meta.name}_Factory`);if(baseFactoryVar!==null){// There is a base factory variable so wrap its declaration along with the factory function into
|
|
338
|
+
// an IIFE.
|
|
339
|
+
factoryFn=fn([],[new DeclareVarStmt(baseFactoryVar.name),new ReturnStatement(factoryFn)]).callFn([],/* sourceSpan */undefined,/* pure */true);}return {expression:factoryFn,statements:[],type:createFactoryType(meta)};}function createFactoryType(meta){const ctorDepsType=meta.deps!==null&&meta.deps!=='invalid'?createCtorDepsType(meta.deps):NONE_TYPE;return expressionType(importExpr(Identifiers$1.FactoryDeclaration,[typeWithParameters(meta.type.type,meta.typeArgumentCount),ctorDepsType]));}function injectDependencies(deps,target){return deps.map((dep,index)=>compileInjectDependency(dep,target,index));}function compileInjectDependency(dep,target,index){// Interpret the dependency according to its resolved type.
|
|
340
|
+
if(dep.token===null){return importExpr(Identifiers$1.invalidFactoryDep).callFn([literal(index)]);}else if(dep.attributeNameType===null){// Build up the injection flags according to the metadata.
|
|
341
|
+
const flags=0/* Default */|(dep.self?2/* Self */:0)|(dep.skipSelf?4/* SkipSelf */:0)|(dep.host?1/* Host */:0)|(dep.optional?8/* Optional */:0)|(target===exports.FactoryTarget.Pipe?16/* ForPipe */:0);// If this dependency is optional or otherwise has non-default flags, then additional
|
|
342
|
+
// parameters describing how to inject the dependency must be passed to the inject function
|
|
343
|
+
// that's being used.
|
|
344
|
+
let flagsParam=flags!==0/* Default */||dep.optional?literal(flags):null;// Build up the arguments to the injectFn call.
|
|
345
|
+
const injectArgs=[dep.token];if(flagsParam){injectArgs.push(flagsParam);}const injectFn=getInjectFn(target);return importExpr(injectFn).callFn(injectArgs);}else {// The `dep.attributeTypeName` value is defined, which indicates that this is an `@Attribute()`
|
|
346
|
+
// type dependency. For the generated JS we still want to use the `dep.token` value in case the
|
|
347
|
+
// name given for the attribute is not a string literal. For example given `@Attribute(foo())`,
|
|
348
|
+
// we want to generate `ɵɵinjectAttribute(foo())`.
|
|
349
|
+
//
|
|
350
|
+
// The `dep.attributeTypeName` is only actually used (in `createCtorDepType()`) to generate
|
|
351
|
+
// typings.
|
|
352
|
+
return importExpr(Identifiers$1.injectAttribute).callFn([dep.token]);}}function createCtorDepsType(deps){let hasTypes=false;const attributeTypes=deps.map(dep=>{const type=createCtorDepType(dep);if(type!==null){hasTypes=true;return type;}else {return literal(null);}});if(hasTypes){return expressionType(literalArr(attributeTypes));}else {return NONE_TYPE;}}function createCtorDepType(dep){const entries=[];if(dep.attributeNameType!==null){entries.push({key:'attribute',value:dep.attributeNameType,quoted:false});}if(dep.optional){entries.push({key:'optional',value:literal(true),quoted:false});}if(dep.host){entries.push({key:'host',value:literal(true),quoted:false});}if(dep.self){entries.push({key:'self',value:literal(true),quoted:false});}if(dep.skipSelf){entries.push({key:'skipSelf',value:literal(true),quoted:false});}return entries.length>0?literalMap(entries):null;}function isDelegatedFactoryMetadata(meta){return meta.delegateType!==undefined;}function isExpressionFactoryMetadata(meta){return meta.expression!==undefined;}function getInjectFn(target){switch(target){case exports.FactoryTarget.Component:case exports.FactoryTarget.Directive:case exports.FactoryTarget.Pipe:return Identifiers$1.directiveInject;case exports.FactoryTarget.NgModule:case exports.FactoryTarget.Injectable:default:return Identifiers$1.inject;}}/**
|
|
265
353
|
* @license
|
|
266
354
|
* Copyright Google LLC All Rights Reserved.
|
|
267
355
|
*
|
|
@@ -548,7 +636,8 @@ quoted:UNSAFE_OBJECT_KEY_NAME_REGEXP.test(minifiedName),value:keepDeclared&&need
|
|
|
548
636
|
*/function trimTrailingNulls(parameters){while(isNull(parameters[parameters.length-1])){parameters.pop();}return parameters;}function getQueryPredicate(query,constantPool){if(Array.isArray(query.predicate)){let predicate=[];query.predicate.forEach(selector=>{// Each item in predicates array may contain strings with comma-separated refs
|
|
549
637
|
// (for ex. 'ref, ref1, ..., refN'), thus we extract individual refs and store them
|
|
550
638
|
// as separate array entities
|
|
551
|
-
const selectors=selector.split(',').map(token=>literal(token.trim()));predicate.push(...selectors);});return constantPool.getConstLiteral(literalArr(predicate),true);}else {
|
|
639
|
+
const selectors=selector.split(',').map(token=>literal(token.trim()));predicate.push(...selectors);});return constantPool.getConstLiteral(literalArr(predicate),true);}else {// The original predicate may have been wrapped in a `forwardRef()` call.
|
|
640
|
+
switch(query.predicate.forwardRef){case 0/* None */:case 2/* Unwrapped */:return query.predicate.expression;case 1/* Wrapped */:return importExpr(Identifiers$1.resolveForwardRef).callFn([query.predicate.expression]);}}}/**
|
|
552
641
|
* A representation for an object literal used during codegen of definition objects. The generic
|
|
553
642
|
* type `T` allows to reference a documented type of the generated structure, such that the
|
|
554
643
|
* property names that are set can be resolved to their documented declaration.
|
|
@@ -574,109 +663,7 @@ return 1;}else {return expressions.length+strings.length;}}/**
|
|
|
574
663
|
*
|
|
575
664
|
* Use of this source code is governed by an MIT-style license that can be
|
|
576
665
|
* found in the LICENSE file at https://angular.io/license
|
|
577
|
-
*/
|
|
578
|
-
* Creates an array literal expression from the given array, mapping all values to an expression
|
|
579
|
-
* using the provided mapping function. If the array is empty or null, then null is returned.
|
|
580
|
-
*
|
|
581
|
-
* @param values The array to transfer into literal array expression.
|
|
582
|
-
* @param mapper The logic to use for creating an expression for the array's values.
|
|
583
|
-
* @returns An array literal expression representing `values`, or null if `values` is empty or
|
|
584
|
-
* is itself null.
|
|
585
|
-
*/function toOptionalLiteralArray(values,mapper){if(values===null||values.length===0){return null;}return literalArr(values.map(value=>mapper(value)));}/**
|
|
586
|
-
* Creates an object literal expression from the given object, mapping all values to an expression
|
|
587
|
-
* using the provided mapping function. If the object has no keys, then null is returned.
|
|
588
|
-
*
|
|
589
|
-
* @param object The object to transfer into an object literal expression.
|
|
590
|
-
* @param mapper The logic to use for creating an expression for the object's values.
|
|
591
|
-
* @returns An object literal expression representing `object`, or null if `object` does not have
|
|
592
|
-
* any keys.
|
|
593
|
-
*/function toOptionalLiteralMap(object,mapper){const entries=Object.keys(object).map(key=>{const value=object[key];return {key,value:mapper(value),quoted:true};});if(entries.length>0){return literalMap(entries);}else {return null;}}function compileDependencies(deps){if(deps==='invalid'){// The `deps` can be set to the string "invalid" by the `unwrapConstructorDependencies()`
|
|
594
|
-
// function, which tries to convert `ConstructorDeps` into `R3DependencyMetadata[]`.
|
|
595
|
-
return literal('invalid');}else if(deps===null){return literal(null);}else {return literalArr(deps.map(compileDependency));}}function compileDependency(dep){const depMeta=new DefinitionMap();depMeta.set('token',dep.token);if(dep.attributeNameType!==null){depMeta.set('attribute',literal(true));}if(dep.host){depMeta.set('host',literal(true));}if(dep.optional){depMeta.set('optional',literal(true));}if(dep.self){depMeta.set('self',literal(true));}if(dep.skipSelf){depMeta.set('skipSelf',literal(true));}return depMeta.toLiteralMap();}/**
|
|
596
|
-
* Generate an expression that has the given `expr` wrapped in the following form:
|
|
597
|
-
*
|
|
598
|
-
* ```
|
|
599
|
-
* forwardRef(() => expr)
|
|
600
|
-
* ```
|
|
601
|
-
*/function generateForwardRef(expr){return importExpr(Identifiers$1.forwardRef).callFn([fn([],[new ReturnStatement(expr)])]);}/**
|
|
602
|
-
* @license
|
|
603
|
-
* Copyright Google LLC All Rights Reserved.
|
|
604
|
-
*
|
|
605
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
606
|
-
* found in the LICENSE file at https://angular.io/license
|
|
607
|
-
*/ // https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit
|
|
608
|
-
const VERSION$1=3;const JS_B64_PREFIX='# sourceMappingURL=data:application/json;base64,';class SourceMapGenerator{constructor(file=null){this.file=file;this.sourcesContent=new Map();this.lines=[];this.lastCol0=0;this.hasMappings=false;}// The content is `null` when the content is expected to be loaded using the URL
|
|
609
|
-
addSource(url,content=null){if(!this.sourcesContent.has(url)){this.sourcesContent.set(url,content);}return this;}addLine(){this.lines.push([]);this.lastCol0=0;return this;}addMapping(col0,sourceUrl,sourceLine0,sourceCol0){if(!this.currentLine){throw new Error(`A line must be added before mappings can be added`);}if(sourceUrl!=null&&!this.sourcesContent.has(sourceUrl)){throw new Error(`Unknown source file "${sourceUrl}"`);}if(col0==null){throw new Error(`The column in the generated code must be provided`);}if(col0<this.lastCol0){throw new Error(`Mapping should be added in output order`);}if(sourceUrl&&(sourceLine0==null||sourceCol0==null)){throw new Error(`The source location must be provided when a source url is provided`);}this.hasMappings=true;this.lastCol0=col0;this.currentLine.push({col0,sourceUrl,sourceLine0,sourceCol0});return this;}/**
|
|
610
|
-
* @internal strip this from published d.ts files due to
|
|
611
|
-
* https://github.com/microsoft/TypeScript/issues/36216
|
|
612
|
-
*/get currentLine(){return this.lines.slice(-1)[0];}toJSON(){if(!this.hasMappings){return null;}const sourcesIndex=new Map();const sources=[];const sourcesContent=[];Array.from(this.sourcesContent.keys()).forEach((url,i)=>{sourcesIndex.set(url,i);sources.push(url);sourcesContent.push(this.sourcesContent.get(url)||null);});let mappings='';let lastCol0=0;let lastSourceIndex=0;let lastSourceLine0=0;let lastSourceCol0=0;this.lines.forEach(segments=>{lastCol0=0;mappings+=segments.map(segment=>{// zero-based starting column of the line in the generated code
|
|
613
|
-
let segAsStr=toBase64VLQ(segment.col0-lastCol0);lastCol0=segment.col0;if(segment.sourceUrl!=null){// zero-based index into the “sources” list
|
|
614
|
-
segAsStr+=toBase64VLQ(sourcesIndex.get(segment.sourceUrl)-lastSourceIndex);lastSourceIndex=sourcesIndex.get(segment.sourceUrl);// the zero-based starting line in the original source
|
|
615
|
-
segAsStr+=toBase64VLQ(segment.sourceLine0-lastSourceLine0);lastSourceLine0=segment.sourceLine0;// the zero-based starting column in the original source
|
|
616
|
-
segAsStr+=toBase64VLQ(segment.sourceCol0-lastSourceCol0);lastSourceCol0=segment.sourceCol0;}return segAsStr;}).join(',');mappings+=';';});mappings=mappings.slice(0,-1);return {'file':this.file||'','version':VERSION$1,'sourceRoot':'','sources':sources,'sourcesContent':sourcesContent,'mappings':mappings};}toJsComment(){return this.hasMappings?'//'+JS_B64_PREFIX+toBase64String(JSON.stringify(this,null,0)):'';}}function toBase64String(value){let b64='';const encoded=utf8Encode(value);for(let i=0;i<encoded.length;){const i1=encoded[i++];const i2=i<encoded.length?encoded[i++]:null;const i3=i<encoded.length?encoded[i++]:null;b64+=toBase64Digit(i1>>2);b64+=toBase64Digit((i1&3)<<4|(i2===null?0:i2>>4));b64+=i2===null?'=':toBase64Digit((i2&15)<<2|(i3===null?0:i3>>6));b64+=i2===null||i3===null?'=':toBase64Digit(i3&63);}return b64;}function toBase64VLQ(value){value=value<0?(-value<<1)+1:value<<1;let out='';do{let digit=value&31;value=value>>5;if(value>0){digit=digit|32;}out+=toBase64Digit(digit);}while(value>0);return out;}const B64_DIGITS='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';function toBase64Digit(value){if(value<0||value>=64){throw new Error(`Can only encode value in the range [0, 63]`);}return B64_DIGITS[value];}/**
|
|
617
|
-
* @license
|
|
618
|
-
* Copyright Google LLC All Rights Reserved.
|
|
619
|
-
*
|
|
620
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
621
|
-
* found in the LICENSE file at https://angular.io/license
|
|
622
|
-
*/const _SINGLE_QUOTE_ESCAPE_STRING_RE=/'|\\|\n|\r|\$/g;const _LEGAL_IDENTIFIER_RE=/^[$A-Z_][0-9A-Z_$]*$/i;const _INDENT_WITH=' ';const CATCH_ERROR_VAR$1=variable('error',null,null);const CATCH_STACK_VAR$1=variable('stack',null,null);class _EmittedLine{constructor(indent){this.indent=indent;this.partsLength=0;this.parts=[];this.srcSpans=[];}}class EmitterVisitorContext{constructor(_indent){this._indent=_indent;this._classes=[];this._preambleLineCount=0;this._lines=[new _EmittedLine(_indent)];}static createRoot(){return new EmitterVisitorContext(0);}/**
|
|
623
|
-
* @internal strip this from published d.ts files due to
|
|
624
|
-
* https://github.com/microsoft/TypeScript/issues/36216
|
|
625
|
-
*/get _currentLine(){return this._lines[this._lines.length-1];}println(from,lastPart=''){this.print(from||null,lastPart,true);}lineIsEmpty(){return this._currentLine.parts.length===0;}lineLength(){return this._currentLine.indent*_INDENT_WITH.length+this._currentLine.partsLength;}print(from,part,newLine=false){if(part.length>0){this._currentLine.parts.push(part);this._currentLine.partsLength+=part.length;this._currentLine.srcSpans.push(from&&from.sourceSpan||null);}if(newLine){this._lines.push(new _EmittedLine(this._indent));}}removeEmptyLastLine(){if(this.lineIsEmpty()){this._lines.pop();}}incIndent(){this._indent++;if(this.lineIsEmpty()){this._currentLine.indent=this._indent;}}decIndent(){this._indent--;if(this.lineIsEmpty()){this._currentLine.indent=this._indent;}}pushClass(clazz){this._classes.push(clazz);}popClass(){return this._classes.pop();}get currentClass(){return this._classes.length>0?this._classes[this._classes.length-1]:null;}toSource(){return this.sourceLines.map(l=>l.parts.length>0?_createIndent(l.indent)+l.parts.join(''):'').join('\n');}toSourceMapGenerator(genFilePath,startsAtLine=0){const map=new SourceMapGenerator(genFilePath);let firstOffsetMapped=false;const mapFirstOffsetIfNeeded=()=>{if(!firstOffsetMapped){// Add a single space so that tools won't try to load the file from disk.
|
|
626
|
-
// Note: We are using virtual urls like `ng:///`, so we have to
|
|
627
|
-
// provide a content here.
|
|
628
|
-
map.addSource(genFilePath,' ').addMapping(0,genFilePath,0,0);firstOffsetMapped=true;}};for(let i=0;i<startsAtLine;i++){map.addLine();mapFirstOffsetIfNeeded();}this.sourceLines.forEach((line,lineIdx)=>{map.addLine();const spans=line.srcSpans;const parts=line.parts;let col0=line.indent*_INDENT_WITH.length;let spanIdx=0;// skip leading parts without source spans
|
|
629
|
-
while(spanIdx<spans.length&&!spans[spanIdx]){col0+=parts[spanIdx].length;spanIdx++;}if(spanIdx<spans.length&&lineIdx===0&&col0===0){firstOffsetMapped=true;}else {mapFirstOffsetIfNeeded();}while(spanIdx<spans.length){const span=spans[spanIdx];const source=span.start.file;const sourceLine=span.start.line;const sourceCol=span.start.col;map.addSource(source.url,source.content).addMapping(col0,source.url,sourceLine,sourceCol);col0+=parts[spanIdx].length;spanIdx++;// assign parts without span or the same span to the previous segment
|
|
630
|
-
while(spanIdx<spans.length&&(span===spans[spanIdx]||!spans[spanIdx])){col0+=parts[spanIdx].length;spanIdx++;}}});return map;}setPreambleLineCount(count){return this._preambleLineCount=count;}spanOf(line,column){const emittedLine=this._lines[line-this._preambleLineCount];if(emittedLine){let columnsLeft=column-_createIndent(emittedLine.indent).length;for(let partIndex=0;partIndex<emittedLine.parts.length;partIndex++){const part=emittedLine.parts[partIndex];if(part.length>columnsLeft){return emittedLine.srcSpans[partIndex];}columnsLeft-=part.length;}}return null;}/**
|
|
631
|
-
* @internal strip this from published d.ts files due to
|
|
632
|
-
* https://github.com/microsoft/TypeScript/issues/36216
|
|
633
|
-
*/get sourceLines(){if(this._lines.length&&this._lines[this._lines.length-1].parts.length===0){return this._lines.slice(0,-1);}return this._lines;}}class AbstractEmitterVisitor{constructor(_escapeDollarInStrings){this._escapeDollarInStrings=_escapeDollarInStrings;}printLeadingComments(stmt,ctx){if(stmt.leadingComments===undefined){return;}for(const comment of stmt.leadingComments){if(comment instanceof JSDocComment){ctx.print(stmt,`/*${comment.toString()}*/`,comment.trailingNewline);}else {if(comment.multiline){ctx.print(stmt,`/* ${comment.text} */`,comment.trailingNewline);}else {comment.text.split('\n').forEach(line=>{ctx.println(stmt,`// ${line}`);});}}}}visitExpressionStmt(stmt,ctx){this.printLeadingComments(stmt,ctx);stmt.expr.visitExpression(this,ctx);ctx.println(stmt,';');return null;}visitReturnStmt(stmt,ctx){this.printLeadingComments(stmt,ctx);ctx.print(stmt,`return `);stmt.value.visitExpression(this,ctx);ctx.println(stmt,';');return null;}visitIfStmt(stmt,ctx){this.printLeadingComments(stmt,ctx);ctx.print(stmt,`if (`);stmt.condition.visitExpression(this,ctx);ctx.print(stmt,`) {`);const hasElseCase=stmt.falseCase!=null&&stmt.falseCase.length>0;if(stmt.trueCase.length<=1&&!hasElseCase){ctx.print(stmt,` `);this.visitAllStatements(stmt.trueCase,ctx);ctx.removeEmptyLastLine();ctx.print(stmt,` `);}else {ctx.println();ctx.incIndent();this.visitAllStatements(stmt.trueCase,ctx);ctx.decIndent();if(hasElseCase){ctx.println(stmt,`} else {`);ctx.incIndent();this.visitAllStatements(stmt.falseCase,ctx);ctx.decIndent();}}ctx.println(stmt,`}`);return null;}visitThrowStmt(stmt,ctx){this.printLeadingComments(stmt,ctx);ctx.print(stmt,`throw `);stmt.error.visitExpression(this,ctx);ctx.println(stmt,`;`);return null;}visitWriteVarExpr(expr,ctx){const lineWasEmpty=ctx.lineIsEmpty();if(!lineWasEmpty){ctx.print(expr,'(');}ctx.print(expr,`${expr.name} = `);expr.value.visitExpression(this,ctx);if(!lineWasEmpty){ctx.print(expr,')');}return null;}visitWriteKeyExpr(expr,ctx){const lineWasEmpty=ctx.lineIsEmpty();if(!lineWasEmpty){ctx.print(expr,'(');}expr.receiver.visitExpression(this,ctx);ctx.print(expr,`[`);expr.index.visitExpression(this,ctx);ctx.print(expr,`] = `);expr.value.visitExpression(this,ctx);if(!lineWasEmpty){ctx.print(expr,')');}return null;}visitWritePropExpr(expr,ctx){const lineWasEmpty=ctx.lineIsEmpty();if(!lineWasEmpty){ctx.print(expr,'(');}expr.receiver.visitExpression(this,ctx);ctx.print(expr,`.${expr.name} = `);expr.value.visitExpression(this,ctx);if(!lineWasEmpty){ctx.print(expr,')');}return null;}visitInvokeFunctionExpr(expr,ctx){expr.fn.visitExpression(this,ctx);ctx.print(expr,`(`);this.visitAllExpressions(expr.args,ctx,',');ctx.print(expr,`)`);return null;}visitTaggedTemplateExpr(expr,ctx){expr.tag.visitExpression(this,ctx);ctx.print(expr,'`'+expr.template.elements[0].rawText);for(let i=1;i<expr.template.elements.length;i++){ctx.print(expr,'${');expr.template.expressions[i-1].visitExpression(this,ctx);ctx.print(expr,`}${expr.template.elements[i].rawText}`);}ctx.print(expr,'`');return null;}visitWrappedNodeExpr(ast,ctx){throw new Error('Abstract emitter cannot visit WrappedNodeExpr.');}visitTypeofExpr(expr,ctx){ctx.print(expr,'typeof ');expr.expr.visitExpression(this,ctx);}visitReadVarExpr(ast,ctx){let varName=ast.name;if(ast.builtin!=null){switch(ast.builtin){case exports.BuiltinVar.Super:varName='super';break;case exports.BuiltinVar.This:varName='this';break;case exports.BuiltinVar.CatchError:varName=CATCH_ERROR_VAR$1.name;break;case exports.BuiltinVar.CatchStack:varName=CATCH_STACK_VAR$1.name;break;default:throw new Error(`Unknown builtin variable ${ast.builtin}`);}}ctx.print(ast,varName);return null;}visitInstantiateExpr(ast,ctx){ctx.print(ast,`new `);ast.classExpr.visitExpression(this,ctx);ctx.print(ast,`(`);this.visitAllExpressions(ast.args,ctx,',');ctx.print(ast,`)`);return null;}visitLiteralExpr(ast,ctx){const value=ast.value;if(typeof value==='string'){ctx.print(ast,escapeIdentifier(value,this._escapeDollarInStrings));}else {ctx.print(ast,`${value}`);}return null;}visitLocalizedString(ast,ctx){const head=ast.serializeI18nHead();ctx.print(ast,'$localize `'+head.raw);for(let i=1;i<ast.messageParts.length;i++){ctx.print(ast,'${');ast.expressions[i-1].visitExpression(this,ctx);ctx.print(ast,`}${ast.serializeI18nTemplatePart(i).raw}`);}ctx.print(ast,'`');return null;}visitConditionalExpr(ast,ctx){ctx.print(ast,`(`);ast.condition.visitExpression(this,ctx);ctx.print(ast,'? ');ast.trueCase.visitExpression(this,ctx);ctx.print(ast,': ');ast.falseCase.visitExpression(this,ctx);ctx.print(ast,`)`);return null;}visitNotExpr(ast,ctx){ctx.print(ast,'!');ast.condition.visitExpression(this,ctx);return null;}visitAssertNotNullExpr(ast,ctx){ast.condition.visitExpression(this,ctx);return null;}visitUnaryOperatorExpr(ast,ctx){let opStr;switch(ast.operator){case exports.UnaryOperator.Plus:opStr='+';break;case exports.UnaryOperator.Minus:opStr='-';break;default:throw new Error(`Unknown operator ${ast.operator}`);}if(ast.parens)ctx.print(ast,`(`);ctx.print(ast,opStr);ast.expr.visitExpression(this,ctx);if(ast.parens)ctx.print(ast,`)`);return null;}visitBinaryOperatorExpr(ast,ctx){let opStr;switch(ast.operator){case exports.BinaryOperator.Equals:opStr='==';break;case exports.BinaryOperator.Identical:opStr='===';break;case exports.BinaryOperator.NotEquals:opStr='!=';break;case exports.BinaryOperator.NotIdentical:opStr='!==';break;case exports.BinaryOperator.And:opStr='&&';break;case exports.BinaryOperator.BitwiseAnd:opStr='&';break;case exports.BinaryOperator.Or:opStr='||';break;case exports.BinaryOperator.Plus:opStr='+';break;case exports.BinaryOperator.Minus:opStr='-';break;case exports.BinaryOperator.Divide:opStr='/';break;case exports.BinaryOperator.Multiply:opStr='*';break;case exports.BinaryOperator.Modulo:opStr='%';break;case exports.BinaryOperator.Lower:opStr='<';break;case exports.BinaryOperator.LowerEquals:opStr='<=';break;case exports.BinaryOperator.Bigger:opStr='>';break;case exports.BinaryOperator.BiggerEquals:opStr='>=';break;case exports.BinaryOperator.NullishCoalesce:opStr='??';break;default:throw new Error(`Unknown operator ${ast.operator}`);}if(ast.parens)ctx.print(ast,`(`);ast.lhs.visitExpression(this,ctx);ctx.print(ast,` ${opStr} `);ast.rhs.visitExpression(this,ctx);if(ast.parens)ctx.print(ast,`)`);return null;}visitReadPropExpr(ast,ctx){ast.receiver.visitExpression(this,ctx);ctx.print(ast,`.`);ctx.print(ast,ast.name);return null;}visitReadKeyExpr(ast,ctx){ast.receiver.visitExpression(this,ctx);ctx.print(ast,`[`);ast.index.visitExpression(this,ctx);ctx.print(ast,`]`);return null;}visitLiteralArrayExpr(ast,ctx){ctx.print(ast,`[`);this.visitAllExpressions(ast.entries,ctx,',');ctx.print(ast,`]`);return null;}visitLiteralMapExpr(ast,ctx){ctx.print(ast,`{`);this.visitAllObjects(entry=>{ctx.print(ast,`${escapeIdentifier(entry.key,this._escapeDollarInStrings,entry.quoted)}:`);entry.value.visitExpression(this,ctx);},ast.entries,ctx,',');ctx.print(ast,`}`);return null;}visitCommaExpr(ast,ctx){ctx.print(ast,'(');this.visitAllExpressions(ast.parts,ctx,',');ctx.print(ast,')');return null;}visitAllExpressions(expressions,ctx,separator){this.visitAllObjects(expr=>expr.visitExpression(this,ctx),expressions,ctx,separator);}visitAllObjects(handler,expressions,ctx,separator){let incrementedIndent=false;for(let i=0;i<expressions.length;i++){if(i>0){if(ctx.lineLength()>80){ctx.print(null,separator,true);if(!incrementedIndent){// continuation are marked with double indent.
|
|
634
|
-
ctx.incIndent();ctx.incIndent();incrementedIndent=true;}}else {ctx.print(null,separator,false);}}handler(expressions[i]);}if(incrementedIndent){// continuation are marked with double indent.
|
|
635
|
-
ctx.decIndent();ctx.decIndent();}}visitAllStatements(statements,ctx){statements.forEach(stmt=>stmt.visitStatement(this,ctx));}}function escapeIdentifier(input,escapeDollar,alwaysQuote=true){if(input==null){return null;}const body=input.replace(_SINGLE_QUOTE_ESCAPE_STRING_RE,(...match)=>{if(match[0]=='$'){return escapeDollar?'\\$':'$';}else if(match[0]=='\n'){return '\\n';}else if(match[0]=='\r'){return '\\r';}else {return `\\${match[0]}`;}});const requiresQuotes=alwaysQuote||!_LEGAL_IDENTIFIER_RE.test(body);return requiresQuotes?`'${body}'`:body;}function _createIndent(count){let res='';for(let i=0;i<count;i++){res+=_INDENT_WITH;}return res;}/**
|
|
636
|
-
* @license
|
|
637
|
-
* Copyright Google LLC All Rights Reserved.
|
|
638
|
-
*
|
|
639
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
640
|
-
* found in the LICENSE file at https://angular.io/license
|
|
641
|
-
*/function typeWithParameters(type,numParams){if(numParams===0){return expressionType(type);}const params=[];for(let i=0;i<numParams;i++){params.push(DYNAMIC_TYPE);}return expressionType(type,undefined,params);}const ANIMATE_SYMBOL_PREFIX='@';function prepareSyntheticPropertyName(name){return `${ANIMATE_SYMBOL_PREFIX}${name}`;}function prepareSyntheticListenerName(name,phase){return `${ANIMATE_SYMBOL_PREFIX}${name}.${phase}`;}function getSafePropertyAccessString(accessor,name){const escapedName=escapeIdentifier(name,false,false);return escapedName!==name?`${accessor}[${escapedName}]`:`${accessor}.${name}`;}function prepareSyntheticListenerFunctionName(name,phase){return `animation_${name}_${phase}`;}function jitOnlyGuardedExpression(expr){return guardedExpression('ngJitMode',expr);}function devOnlyGuardedExpression(expr){return guardedExpression('ngDevMode',expr);}function guardedExpression(guard,expr){const guardExpr=new ExternalExpr({name:guard,moduleName:null});const guardNotDefined=new BinaryOperatorExpr(exports.BinaryOperator.Identical,new TypeofExpr(guardExpr),literal('undefined'));const guardUndefinedOrTrue=new BinaryOperatorExpr(exports.BinaryOperator.Or,guardNotDefined,guardExpr,/* type */undefined,/* sourceSpan */undefined,true);return new BinaryOperatorExpr(exports.BinaryOperator.And,guardUndefinedOrTrue,expr);}function wrapReference(value){const wrapped=new WrappedNodeExpr(value);return {value:wrapped,type:wrapped};}function refsToArray(refs,shouldForwardDeclare){const values=literalArr(refs.map(ref=>ref.value));return shouldForwardDeclare?fn([],[new ReturnStatement(values)]):values;}var R3FactoryDelegateType;(function(R3FactoryDelegateType){R3FactoryDelegateType[R3FactoryDelegateType["Class"]=0]="Class";R3FactoryDelegateType[R3FactoryDelegateType["Function"]=1]="Function";})(R3FactoryDelegateType||(R3FactoryDelegateType={}));exports.FactoryTarget = void 0;(function(FactoryTarget){FactoryTarget[FactoryTarget["Directive"]=0]="Directive";FactoryTarget[FactoryTarget["Component"]=1]="Component";FactoryTarget[FactoryTarget["Injectable"]=2]="Injectable";FactoryTarget[FactoryTarget["Pipe"]=3]="Pipe";FactoryTarget[FactoryTarget["NgModule"]=4]="NgModule";})(exports.FactoryTarget||(exports.FactoryTarget={}));/**
|
|
642
|
-
* Construct a factory function expression for the given `R3FactoryMetadata`.
|
|
643
|
-
*/function compileFactoryFunction(meta){const t=variable('t');let baseFactoryVar=null;// The type to instantiate via constructor invocation. If there is no delegated factory, meaning
|
|
644
|
-
// this type is always created by constructor invocation, then this is the type-to-create
|
|
645
|
-
// parameter provided by the user (t) if specified, or the current type if not. If there is a
|
|
646
|
-
// delegated factory (which is used to create the current type) then this is only the type-to-
|
|
647
|
-
// create parameter (t).
|
|
648
|
-
const typeForCtor=!isDelegatedFactoryMetadata(meta)?new BinaryOperatorExpr(exports.BinaryOperator.Or,t,meta.internalType):t;let ctorExpr=null;if(meta.deps!==null){// There is a constructor (either explicitly or implicitly defined).
|
|
649
|
-
if(meta.deps!=='invalid'){ctorExpr=new InstantiateExpr(typeForCtor,injectDependencies(meta.deps,meta.target));}}else {// There is no constructor, use the base class' factory to construct typeForCtor.
|
|
650
|
-
baseFactoryVar=variable(`ɵ${meta.name}_BaseFactory`);ctorExpr=baseFactoryVar.callFn([typeForCtor]);}const body=[];let retExpr=null;function makeConditionalFactory(nonCtorExpr){const r=variable('r');body.push(r.set(NULL_EXPR).toDeclStmt());const ctorStmt=ctorExpr!==null?r.set(ctorExpr).toStmt():importExpr(Identifiers$1.invalidFactory).callFn([]).toStmt();body.push(ifStmt(t,[ctorStmt],[r.set(nonCtorExpr).toStmt()]));return r;}if(isDelegatedFactoryMetadata(meta)){// This type is created with a delegated factory. If a type parameter is not specified, call
|
|
651
|
-
// the factory instead.
|
|
652
|
-
const delegateArgs=injectDependencies(meta.delegateDeps,meta.target);// Either call `new delegate(...)` or `delegate(...)` depending on meta.delegateType.
|
|
653
|
-
const factoryExpr=new(meta.delegateType===R3FactoryDelegateType.Class?InstantiateExpr:InvokeFunctionExpr)(meta.delegate,delegateArgs);retExpr=makeConditionalFactory(factoryExpr);}else if(isExpressionFactoryMetadata(meta)){// TODO(alxhub): decide whether to lower the value here or in the caller
|
|
654
|
-
retExpr=makeConditionalFactory(meta.expression);}else {retExpr=ctorExpr;}if(retExpr===null){// The expression cannot be formed so render an `ɵɵinvalidFactory()` call.
|
|
655
|
-
body.push(importExpr(Identifiers$1.invalidFactory).callFn([]).toStmt());}else if(baseFactoryVar!==null){// This factory uses a base factory, so call `ɵɵgetInheritedFactory()` to compute it.
|
|
656
|
-
const getInheritedFactoryCall=importExpr(Identifiers$1.getInheritedFactory).callFn([meta.internalType]);// Memoize the base factoryFn: `baseFactory || (baseFactory = ɵɵgetInheritedFactory(...))`
|
|
657
|
-
const baseFactory=new BinaryOperatorExpr(exports.BinaryOperator.Or,baseFactoryVar,baseFactoryVar.set(getInheritedFactoryCall));body.push(new ReturnStatement(baseFactory.callFn([typeForCtor])));}else {// This is straightforward factory, just return it.
|
|
658
|
-
body.push(new ReturnStatement(retExpr));}let factoryFn=fn([new FnParam('t',DYNAMIC_TYPE)],body,INFERRED_TYPE,undefined,`${meta.name}_Factory`);if(baseFactoryVar!==null){// There is a base factory variable so wrap its declaration along with the factory function into
|
|
659
|
-
// an IIFE.
|
|
660
|
-
factoryFn=fn([],[new DeclareVarStmt(baseFactoryVar.name),new ReturnStatement(factoryFn)]).callFn([],/* sourceSpan */undefined,/* pure */true);}return {expression:factoryFn,statements:[],type:createFactoryType(meta)};}function createFactoryType(meta){const ctorDepsType=meta.deps!==null&&meta.deps!=='invalid'?createCtorDepsType(meta.deps):NONE_TYPE;return expressionType(importExpr(Identifiers$1.FactoryDeclaration,[typeWithParameters(meta.type.type,meta.typeArgumentCount),ctorDepsType]));}function injectDependencies(deps,target){return deps.map((dep,index)=>compileInjectDependency(dep,target,index));}function compileInjectDependency(dep,target,index){// Interpret the dependency according to its resolved type.
|
|
661
|
-
if(dep.token===null){return importExpr(Identifiers$1.invalidFactoryDep).callFn([literal(index)]);}else if(dep.attributeNameType===null){// Build up the injection flags according to the metadata.
|
|
662
|
-
const flags=0/* Default */|(dep.self?2/* Self */:0)|(dep.skipSelf?4/* SkipSelf */:0)|(dep.host?1/* Host */:0)|(dep.optional?8/* Optional */:0)|(target===exports.FactoryTarget.Pipe?16/* ForPipe */:0);// If this dependency is optional or otherwise has non-default flags, then additional
|
|
663
|
-
// parameters describing how to inject the dependency must be passed to the inject function
|
|
664
|
-
// that's being used.
|
|
665
|
-
let flagsParam=flags!==0/* Default */||dep.optional?literal(flags):null;// Build up the arguments to the injectFn call.
|
|
666
|
-
const injectArgs=[dep.token];if(flagsParam){injectArgs.push(flagsParam);}const injectFn=getInjectFn(target);return importExpr(injectFn).callFn(injectArgs);}else {// The `dep.attributeTypeName` value is defined, which indicates that this is an `@Attribute()`
|
|
667
|
-
// type dependency. For the generated JS we still want to use the `dep.token` value in case the
|
|
668
|
-
// name given for the attribute is not a string literal. For example given `@Attribute(foo())`,
|
|
669
|
-
// we want to generate `ɵɵinjectAttribute(foo())`.
|
|
670
|
-
//
|
|
671
|
-
// The `dep.attributeTypeName` is only actually used (in `createCtorDepType()`) to generate
|
|
672
|
-
// typings.
|
|
673
|
-
return importExpr(Identifiers$1.injectAttribute).callFn([dep.token]);}}function createCtorDepsType(deps){let hasTypes=false;const attributeTypes=deps.map(dep=>{const type=createCtorDepType(dep);if(type!==null){hasTypes=true;return type;}else {return literal(null);}});if(hasTypes){return expressionType(literalArr(attributeTypes));}else {return NONE_TYPE;}}function createCtorDepType(dep){const entries=[];if(dep.attributeNameType!==null){entries.push({key:'attribute',value:dep.attributeNameType,quoted:false});}if(dep.optional){entries.push({key:'optional',value:literal(true),quoted:false});}if(dep.host){entries.push({key:'host',value:literal(true),quoted:false});}if(dep.self){entries.push({key:'self',value:literal(true),quoted:false});}if(dep.skipSelf){entries.push({key:'skipSelf',value:literal(true),quoted:false});}return entries.length>0?literalMap(entries):null;}function isDelegatedFactoryMetadata(meta){return meta.delegateType!==undefined;}function isExpressionFactoryMetadata(meta){return meta.expression!==undefined;}function getInjectFn(target){switch(target){case exports.FactoryTarget.Component:case exports.FactoryTarget.Directive:case exports.FactoryTarget.Pipe:return Identifiers$1.directiveInject;case exports.FactoryTarget.NgModule:case exports.FactoryTarget.Injectable:default:return Identifiers$1.inject;}}/**
|
|
674
|
-
* @license
|
|
675
|
-
* Copyright Google LLC All Rights Reserved.
|
|
676
|
-
*
|
|
677
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
678
|
-
* found in the LICENSE file at https://angular.io/license
|
|
679
|
-
*/function createR3ProviderExpression(expression,isForwardRef){return {expression,isForwardRef};}function compileInjectable(meta,resolveForwardRefs){let result=null;const factoryMeta={name:meta.name,type:meta.type,internalType:meta.internalType,typeArgumentCount:meta.typeArgumentCount,deps:[],target:exports.FactoryTarget.Injectable};if(meta.useClass!==undefined){// meta.useClass has two modes of operation. Either deps are specified, in which case `new` is
|
|
666
|
+
*/function compileInjectable(meta,resolveForwardRefs){let result=null;const factoryMeta={name:meta.name,type:meta.type,internalType:meta.internalType,typeArgumentCount:meta.typeArgumentCount,deps:[],target:exports.FactoryTarget.Injectable};if(meta.useClass!==undefined){// meta.useClass has two modes of operation. Either deps are specified, in which case `new` is
|
|
680
667
|
// used to instantiate the class with dependencies injected, or deps are not specified and
|
|
681
668
|
// the factory of the class is used to instantiate it.
|
|
682
669
|
//
|
|
@@ -688,7 +675,7 @@ result=compileFactoryFunction(Object.assign(Object.assign({},factoryMeta),{deleg
|
|
|
688
675
|
// value is undefined.
|
|
689
676
|
result=compileFactoryFunction(Object.assign(Object.assign({},factoryMeta),{expression:meta.useValue.expression}));}else if(meta.useExisting!==undefined){// useExisting is an `inject` call on the existing token.
|
|
690
677
|
result=compileFactoryFunction(Object.assign(Object.assign({},factoryMeta),{expression:importExpr(Identifiers$1.inject).callFn([meta.useExisting.expression])}));}else {result={statements:[],expression:delegateToFactory(meta.type.value,meta.internalType,resolveForwardRefs)};}const token=meta.internalType;const injectableProps=new DefinitionMap();injectableProps.set('token',token);injectableProps.set('factory',result.expression);// Only generate providedIn property if it has a non-null value
|
|
691
|
-
if(meta.providedIn.expression.value!==null){injectableProps.set('providedIn',
|
|
678
|
+
if(meta.providedIn.expression.value!==null){injectableProps.set('providedIn',convertFromMaybeForwardRefExpression(meta.providedIn));}const expression=importExpr(Identifiers$1.ɵɵdefineInjectable).callFn([injectableProps.toLiteralMap()],undefined,true);return {expression,type:createInjectableType(meta),statements:result.statements};}function createInjectableType(meta){return new ExpressionType(importExpr(Identifiers$1.InjectableDeclaration,[typeWithParameters(meta.type.type,meta.typeArgumentCount)]));}function delegateToFactory(type,internalType,unwrapForwardRefs){if(type.node===internalType.node){// The types are the same, so we can simply delegate directly to the type's factory.
|
|
692
679
|
// ```
|
|
693
680
|
// factory: type.ɵfac
|
|
694
681
|
// ```
|
|
@@ -1111,7 +1098,7 @@ this.usesImplicitReceiver=prevUsesImplicitReceiver;this.addImplicitReceiverAcces
|
|
|
1111
1098
|
const receiver=ast.name;const value=ast.value instanceof PropertyRead?ast.value.name:undefined;throw new Error(`Cannot assign value "${value}" to template variable "${receiver}". Template variables are read-only.`);}}}// If no local expression could be produced, use the original receiver's
|
|
1112
1099
|
// property as the target.
|
|
1113
1100
|
if(varExpr===null){varExpr=receiver.prop(ast.name,this.convertSourceSpan(ast.span));}return convertToStatementIfNeeded(mode,varExpr.set(this._visit(ast.value,_Mode.Expression)));}visitSafePropertyRead(ast,mode){return this.convertSafeAccess(ast,this.leftMostSafeNode(ast),mode);}visitSafeKeyedRead(ast,mode){return this.convertSafeAccess(ast,this.leftMostSafeNode(ast),mode);}visitAll(asts,mode){return asts.map(ast=>this._visit(ast,mode));}visitQuote(ast,mode){throw new Error(`Quotes are not supported for evaluation!
|
|
1114
|
-
Statement: ${ast.uninterpretedExpression} located at ${ast.location}`);}visitCall(ast,mode){const convertedArgs=this.visitAll(ast.args,_Mode.Expression);if(ast instanceof BuiltinFunctionCall){return convertToStatementIfNeeded(mode,ast.converter(convertedArgs));}const receiver=ast.receiver;if(receiver instanceof PropertyRead&&receiver.receiver instanceof ImplicitReceiver&&!(receiver.receiver instanceof ThisReceiver)&&receiver.name==='$any'){if(convertedArgs.length!==1){throw new Error(`Invalid call to $any, expected 1 argument but received ${convertedArgs.length||'none'}`);}return convertToStatementIfNeeded(mode,convertedArgs[0].cast(DYNAMIC_TYPE,this.convertSourceSpan(ast.span)));}const
|
|
1101
|
+
Statement: ${ast.uninterpretedExpression} located at ${ast.location}`);}visitCall(ast,mode){const leftMostSafe=this.leftMostSafeNode(ast);if(leftMostSafe){return this.convertSafeAccess(ast,leftMostSafe,mode);}const convertedArgs=this.visitAll(ast.args,_Mode.Expression);if(ast instanceof BuiltinFunctionCall){return convertToStatementIfNeeded(mode,ast.converter(convertedArgs));}const receiver=ast.receiver;if(receiver instanceof PropertyRead&&receiver.receiver instanceof ImplicitReceiver&&!(receiver.receiver instanceof ThisReceiver)&&receiver.name==='$any'){if(convertedArgs.length!==1){throw new Error(`Invalid call to $any, expected 1 argument but received ${convertedArgs.length||'none'}`);}return convertToStatementIfNeeded(mode,convertedArgs[0].cast(DYNAMIC_TYPE,this.convertSourceSpan(ast.span)));}const call=this._visit(receiver,_Mode.Expression).callFn(convertedArgs,this.convertSourceSpan(ast.span));return convertToStatementIfNeeded(mode,call);}_visit(ast,mode){const result=this._resultMap.get(ast);if(result)return result;return (this._nodeMap.get(ast)||ast).visit(this,mode);}convertSafeAccess(ast,leftMostSafe,mode){// If the expression contains a safe access node on the left it needs to be converted to
|
|
1115
1102
|
// an expression that guards the access to the member by checking the receiver for blank. As
|
|
1116
1103
|
// execution proceeds from left to right, the left most part of the expression must be guarded
|
|
1117
1104
|
// first but, because member access is left associative, the right side of the expression is at
|
|
@@ -3437,16 +3424,18 @@ const meta=Object.assign(Object.assign(Object.assign({},facade),convertDirective
|
|
|
3437
3424
|
*/jitExpression(def,context,sourceUrl,preStatements){// The ConstantPool may contain Statements which declare variables used in the final expression.
|
|
3438
3425
|
// Therefore, its statements need to precede the actual JIT operation. The final statement is a
|
|
3439
3426
|
// declaration of $def which is set to the expression being compiled.
|
|
3440
|
-
const statements=[...preStatements,new DeclareVarStmt('$def',def,undefined,[exports.StmtModifier.Exported])];const res=this.jitEvaluator.evaluateStatements(sourceUrl,statements,new R3JitReflector(context),/* enableSourceMaps */true);return res['$def'];}}const USE_CLASS=Object.keys({useClass:null})[0];const USE_FACTORY=Object.keys({useFactory:null})[0];const USE_VALUE$1=Object.keys({useValue:null})[0];const USE_EXISTING=Object.keys({useExisting:null})[0];function convertToR3QueryMetadata(facade){return Object.assign(Object.assign({},facade),{predicate:
|
|
3441
|
-
|
|
3427
|
+
const statements=[...preStatements,new DeclareVarStmt('$def',def,undefined,[exports.StmtModifier.Exported])];const res=this.jitEvaluator.evaluateStatements(sourceUrl,statements,new R3JitReflector(context),/* enableSourceMaps */true);return res['$def'];}}const USE_CLASS=Object.keys({useClass:null})[0];const USE_FACTORY=Object.keys({useFactory:null})[0];const USE_VALUE$1=Object.keys({useValue:null})[0];const USE_EXISTING=Object.keys({useExisting:null})[0];function convertToR3QueryMetadata(facade){return Object.assign(Object.assign({},facade),{predicate:convertQueryPredicate(facade.predicate),read:facade.read?new WrappedNodeExpr(facade.read):null,static:facade.static,emitDistinctChangesOnly:facade.emitDistinctChangesOnly});}function convertQueryDeclarationToMetadata(declaration){var _a,_b,_c,_d;return {propertyName:declaration.propertyName,first:(_a=declaration.first)!==null&&_a!==void 0?_a:false,predicate:convertQueryPredicate(declaration.predicate),descendants:(_b=declaration.descendants)!==null&&_b!==void 0?_b:false,read:declaration.read?new WrappedNodeExpr(declaration.read):null,static:(_c=declaration.static)!==null&&_c!==void 0?_c:false,emitDistinctChangesOnly:(_d=declaration.emitDistinctChangesOnly)!==null&&_d!==void 0?_d:true};}function convertQueryPredicate(predicate){return Array.isArray(predicate)?// The predicate is an array of strings so pass it through.
|
|
3428
|
+
predicate:// The predicate is a type - assume that we will need to unwrap any `forwardRef()` calls.
|
|
3429
|
+
createMayBeForwardRefExpression(new WrappedNodeExpr(predicate),1/* Wrapped */);}function convertDirectiveFacadeToMetadata(facade){const inputsFromMetadata=parseInputOutputs(facade.inputs||[]);const outputsFromMetadata=parseInputOutputs(facade.outputs||[]);const propMetadata=facade.propMetadata;const inputsFromType={};const outputsFromType={};for(const field in propMetadata){if(propMetadata.hasOwnProperty(field)){propMetadata[field].forEach(ann=>{if(isInput(ann)){inputsFromType[field]=ann.bindingPropertyName?[ann.bindingPropertyName,field]:field;}else if(isOutput(ann)){outputsFromType[field]=ann.bindingPropertyName||field;}});}}return Object.assign(Object.assign({},facade),{typeArgumentCount:0,typeSourceSpan:facade.typeSourceSpan,type:wrapReference(facade.type),internalType:new WrappedNodeExpr(facade.type),deps:null,host:extractHostBindings(facade.propMetadata,facade.typeSourceSpan,facade.host),inputs:Object.assign(Object.assign({},inputsFromMetadata),inputsFromType),outputs:Object.assign(Object.assign({},outputsFromMetadata),outputsFromType),queries:facade.queries.map(convertToR3QueryMetadata),providers:facade.providers!=null?new WrappedNodeExpr(facade.providers):null,viewQueries:facade.viewQueries.map(convertToR3QueryMetadata),fullInheritance:false});}function convertDeclareDirectiveFacadeToMetadata(declaration,typeSourceSpan){var _a,_b,_c,_d,_e,_f,_g,_h;return {name:declaration.type.name,type:wrapReference(declaration.type),typeSourceSpan,internalType:new WrappedNodeExpr(declaration.type),selector:(_a=declaration.selector)!==null&&_a!==void 0?_a:null,inputs:(_b=declaration.inputs)!==null&&_b!==void 0?_b:{},outputs:(_c=declaration.outputs)!==null&&_c!==void 0?_c:{},host:convertHostDeclarationToMetadata(declaration.host),queries:((_d=declaration.queries)!==null&&_d!==void 0?_d:[]).map(convertQueryDeclarationToMetadata),viewQueries:((_e=declaration.viewQueries)!==null&&_e!==void 0?_e:[]).map(convertQueryDeclarationToMetadata),providers:declaration.providers!==undefined?new WrappedNodeExpr(declaration.providers):null,exportAs:(_f=declaration.exportAs)!==null&&_f!==void 0?_f:null,usesInheritance:(_g=declaration.usesInheritance)!==null&&_g!==void 0?_g:false,lifecycle:{usesOnChanges:(_h=declaration.usesOnChanges)!==null&&_h!==void 0?_h:false},deps:null,typeArgumentCount:0,fullInheritance:false};}function convertHostDeclarationToMetadata(host={}){var _a,_b,_c;return {attributes:convertOpaqueValuesToExpressions((_a=host.attributes)!==null&&_a!==void 0?_a:{}),listeners:(_b=host.listeners)!==null&&_b!==void 0?_b:{},properties:(_c=host.properties)!==null&&_c!==void 0?_c:{},specialAttributes:{classAttr:host.classAttribute,styleAttr:host.styleAttribute}};}function convertOpaqueValuesToExpressions(obj){const result={};for(const key of Object.keys(obj)){result[key]=new WrappedNodeExpr(obj[key]);}return result;}function convertDeclareComponentFacadeToMetadata(declaration,typeSourceSpan,sourceMapUrl){var _a,_b,_c,_d,_e,_f;const{template,interpolation}=parseJitTemplate(declaration.template,declaration.type.name,sourceMapUrl,(_a=declaration.preserveWhitespaces)!==null&&_a!==void 0?_a:false,declaration.interpolation);return Object.assign(Object.assign({},convertDeclareDirectiveFacadeToMetadata(declaration,typeSourceSpan)),{template,styles:(_b=declaration.styles)!==null&&_b!==void 0?_b:[],directives:((_c=declaration.components)!==null&&_c!==void 0?_c:[]).concat((_d=declaration.directives)!==null&&_d!==void 0?_d:[]).map(convertUsedDirectiveDeclarationToMetadata),pipes:convertUsedPipesToMetadata(declaration.pipes),viewProviders:declaration.viewProviders!==undefined?new WrappedNodeExpr(declaration.viewProviders):null,animations:declaration.animations!==undefined?new WrappedNodeExpr(declaration.animations):null,changeDetection:(_e=declaration.changeDetection)!==null&&_e!==void 0?_e:exports.ChangeDetectionStrategy.Default,encapsulation:(_f=declaration.encapsulation)!==null&&_f!==void 0?_f:exports.ViewEncapsulation.Emulated,interpolation,declarationListEmitMode:2/* ClosureResolved */,relativeContextFilePath:'',i18nUseExternalIds:true});}function convertUsedDirectiveDeclarationToMetadata(declaration){var _a,_b,_c;return {selector:declaration.selector,type:new WrappedNodeExpr(declaration.type),inputs:(_a=declaration.inputs)!==null&&_a!==void 0?_a:[],outputs:(_b=declaration.outputs)!==null&&_b!==void 0?_b:[],exportAs:(_c=declaration.exportAs)!==null&&_c!==void 0?_c:null};}function convertUsedPipesToMetadata(declaredPipes){const pipes=new Map();if(declaredPipes===undefined){return pipes;}for(const pipeName of Object.keys(declaredPipes)){const pipeType=declaredPipes[pipeName];pipes.set(pipeName,new WrappedNodeExpr(pipeType));}return pipes;}function parseJitTemplate(template,typeName,sourceMapUrl,preserveWhitespaces,interpolation){const interpolationConfig=interpolation?InterpolationConfig.fromArray(interpolation):DEFAULT_INTERPOLATION_CONFIG;// Parse the template and check for errors.
|
|
3430
|
+
const parsed=parseTemplate(template,sourceMapUrl,{preserveWhitespaces,interpolationConfig});if(parsed.errors!==null){const errors=parsed.errors.map(err=>err.toString()).join(', ');throw new Error(`Errors during JIT compilation of template for ${typeName}: ${errors}`);}return {template:parsed,interpolation:interpolationConfig};}/**
|
|
3442
3431
|
* Convert the expression, if present to an `R3ProviderExpression`.
|
|
3443
3432
|
*
|
|
3444
3433
|
* In JIT mode we do not want the compiler to wrap the expression in a `forwardRef()` call because,
|
|
3445
3434
|
* if it is referencing a type that has not yet been defined, it will have already been wrapped in
|
|
3446
3435
|
* a `forwardRef()` - either by the application developer or during partial-compilation. Thus we can
|
|
3447
|
-
*
|
|
3448
|
-
*/function convertToProviderExpression(obj,property){if(obj.hasOwnProperty(property)){return
|
|
3449
|
-
return
|
|
3436
|
+
* use `ForwardRefHandling.None`.
|
|
3437
|
+
*/function convertToProviderExpression(obj,property){if(obj.hasOwnProperty(property)){return createMayBeForwardRefExpression(new WrappedNodeExpr(obj[property]),0/* None */);}else {return undefined;}}function wrapExpression(obj,property){if(obj.hasOwnProperty(property)){return new WrappedNodeExpr(obj[property]);}else {return undefined;}}function computeProvidedIn(providedIn){const expression=typeof providedIn==='function'?new WrappedNodeExpr(providedIn):new LiteralExpr(providedIn!==null&&providedIn!==void 0?providedIn:null);// See `convertToProviderExpression()` for why this uses `ForwardRefHandling.None`.
|
|
3438
|
+
return createMayBeForwardRefExpression(expression,0/* None */);}function convertR3DependencyMetadataArray(facades){return facades==null?null:facades.map(convertR3DependencyMetadata);}function convertR3DependencyMetadata(facade){const isAttributeDep=facade.attribute!=null;// both `null` and `undefined`
|
|
3450
3439
|
const rawToken=facade.token===null?null:new WrappedNodeExpr(facade.token);// In JIT mode, if the dep is an `@Attribute()` then we use the attribute name given in
|
|
3451
3440
|
// `attribute` rather than the `token`.
|
|
3452
3441
|
const token=isAttributeDep?new WrappedNodeExpr(facade.attribute):rawToken;return createR3DependencyMetadata(token,isAttributeDep,facade.host,facade.optional,facade.self,facade.skipSelf);}function convertR3DeclareDependencyMetadata(facade){var _a,_b,_c,_d,_e;const isAttributeDep=(_a=facade.attribute)!==null&&_a!==void 0?_a:false;const token=facade.token===null?null:new WrappedNodeExpr(facade.token);return createR3DependencyMetadata(token,isAttributeDep,(_b=facade.host)!==null&&_b!==void 0?_b:false,(_c=facade.optional)!==null&&_c!==void 0?_c:false,(_d=facade.self)!==null&&_d!==void 0?_d:false,(_e=facade.skipSelf)!==null&&_e!==void 0?_e:false);}function createR3DependencyMetadata(token,isAttributeDep,host,optional,self,skipSelf){// If the dep is an `@Attribute()` the `attributeNameType` ought to be the `unknown` type.
|
|
@@ -3464,7 +3453,7 @@ bindings.properties[ann.hostPropertyName||field]=getSafePropertyAccessString('th
|
|
|
3464
3453
|
*
|
|
3465
3454
|
* Use of this source code is governed by an MIT-style license that can be
|
|
3466
3455
|
* found in the LICENSE file at https://angular.io/license
|
|
3467
|
-
*/const VERSION=new Version('13.0.
|
|
3456
|
+
*/const VERSION=new Version('13.0.2');/**
|
|
3468
3457
|
* @license
|
|
3469
3458
|
* Copyright Google LLC All Rights Reserved.
|
|
3470
3459
|
*
|
|
@@ -4600,7 +4589,31 @@ const fnCall=importExpr(Identifiers$1.setClassMetadata).callFn([metadata.type,me
|
|
|
4600
4589
|
* declaration.
|
|
4601
4590
|
*
|
|
4602
4591
|
* Do not include any prerelease in these versions as they are ignored.
|
|
4603
|
-
*/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.0.
|
|
4592
|
+
*/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.0.2'));definitionMap.set('ngImport',importExpr(Identifiers$1.core));definitionMap.set('type',metadata.type);definitionMap.set('decorators',metadata.decorators);definitionMap.set('ctorParameters',metadata.ctorParameters);definitionMap.set('propDecorators',metadata.propDecorators);return importExpr(Identifiers$1.declareClassMetadata).callFn([definitionMap.toLiteralMap()]);}/**
|
|
4593
|
+
* @license
|
|
4594
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4595
|
+
*
|
|
4596
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
4597
|
+
* found in the LICENSE file at https://angular.io/license
|
|
4598
|
+
*/ /**
|
|
4599
|
+
* Creates an array literal expression from the given array, mapping all values to an expression
|
|
4600
|
+
* using the provided mapping function. If the array is empty or null, then null is returned.
|
|
4601
|
+
*
|
|
4602
|
+
* @param values The array to transfer into literal array expression.
|
|
4603
|
+
* @param mapper The logic to use for creating an expression for the array's values.
|
|
4604
|
+
* @returns An array literal expression representing `values`, or null if `values` is empty or
|
|
4605
|
+
* is itself null.
|
|
4606
|
+
*/function toOptionalLiteralArray(values,mapper){if(values===null||values.length===0){return null;}return literalArr(values.map(value=>mapper(value)));}/**
|
|
4607
|
+
* Creates an object literal expression from the given object, mapping all values to an expression
|
|
4608
|
+
* using the provided mapping function. If the object has no keys, then null is returned.
|
|
4609
|
+
*
|
|
4610
|
+
* @param object The object to transfer into an object literal expression.
|
|
4611
|
+
* @param mapper The logic to use for creating an expression for the object's values.
|
|
4612
|
+
* @returns An object literal expression representing `object`, or null if `object` does not have
|
|
4613
|
+
* any keys.
|
|
4614
|
+
*/function toOptionalLiteralMap(object,mapper){const entries=Object.keys(object).map(key=>{const value=object[key];return {key,value:mapper(value),quoted:true};});if(entries.length>0){return literalMap(entries);}else {return null;}}function compileDependencies(deps){if(deps==='invalid'){// The `deps` can be set to the string "invalid" by the `unwrapConstructorDependencies()`
|
|
4615
|
+
// function, which tries to convert `ConstructorDeps` into `R3DependencyMetadata[]`.
|
|
4616
|
+
return literal('invalid');}else if(deps===null){return literal(null);}else {return literalArr(deps.map(compileDependency));}}function compileDependency(dep){const depMeta=new DefinitionMap();depMeta.set('token',dep.token);if(dep.attributeNameType!==null){depMeta.set('attribute',literal(true));}if(dep.host){depMeta.set('host',literal(true));}if(dep.optional){depMeta.set('optional',literal(true));}if(dep.self){depMeta.set('self',literal(true));}if(dep.skipSelf){depMeta.set('skipSelf',literal(true));}return depMeta.toLiteralMap();}/**
|
|
4604
4617
|
* @license
|
|
4605
4618
|
* Copyright Google LLC All Rights Reserved.
|
|
4606
4619
|
*
|
|
@@ -4617,12 +4630,12 @@ const fnCall=importExpr(Identifiers$1.setClassMetadata).callFn([metadata.type,me
|
|
|
4617
4630
|
*/function compileDeclareDirectiveFromMetadata(meta){const definitionMap=createDirectiveDefinitionMap(meta);const expression=importExpr(Identifiers$1.declareDirective).callFn([definitionMap.toLiteralMap()]);const type=createDirectiveType(meta);return {expression,type,statements:[]};}/**
|
|
4618
4631
|
* Gathers the declaration fields for a directive into a `DefinitionMap`. This allows for reusing
|
|
4619
4632
|
* this logic for components, as they extend the directive metadata.
|
|
4620
|
-
*/function createDirectiveDefinitionMap(meta){const definitionMap=new DefinitionMap();definitionMap.set('minVersion',literal(MINIMUM_PARTIAL_LINKER_VERSION$5));definitionMap.set('version',literal('13.0.
|
|
4633
|
+
*/function createDirectiveDefinitionMap(meta){const definitionMap=new DefinitionMap();definitionMap.set('minVersion',literal(MINIMUM_PARTIAL_LINKER_VERSION$5));definitionMap.set('version',literal('13.0.2'));// e.g. `type: MyDirective`
|
|
4621
4634
|
definitionMap.set('type',meta.internalType);// e.g. `selector: 'some-dir'`
|
|
4622
4635
|
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$1.core));return definitionMap;}/**
|
|
4623
4636
|
* Compiles the metadata of a single query into its partial declaration form as declared
|
|
4624
4637
|
* by `R3DeclareQueryMetadata`.
|
|
4625
|
-
*/function compileQuery(query){const meta=new DefinitionMap();meta.set('propertyName',literal(query.propertyName));if(query.first){meta.set('first',literal(true));}meta.set('predicate',Array.isArray(query.predicate)?asLiteral(query.predicate):query.predicate);if(!query.emitDistinctChangesOnly){// `emitDistinctChangesOnly` is special because we expect it to be `true`.
|
|
4638
|
+
*/function compileQuery(query){const meta=new DefinitionMap();meta.set('propertyName',literal(query.propertyName));if(query.first){meta.set('first',literal(true));}meta.set('predicate',Array.isArray(query.predicate)?asLiteral(query.predicate):convertFromMaybeForwardRefExpression(query.predicate));if(!query.emitDistinctChangesOnly){// `emitDistinctChangesOnly` is special because we expect it to be `true`.
|
|
4626
4639
|
// Therefore we explicitly emit the field, and explicitly place it only when it's `false`.
|
|
4627
4640
|
meta.set('emitDistinctChangesOnly',literal(false));}if(query.descendants){meta.set('descendants',literal(true));}meta.set('read',query.read);if(query.static){meta.set('static',literal(true));}return meta.toLiteralMap();}/**
|
|
4628
4641
|
* Compiles the host metadata into its partial declaration form as declared
|
|
@@ -4666,7 +4679,7 @@ const contents=templateInfo.content;const file=new ParseSourceFile(contents,temp
|
|
|
4666
4679
|
* declaration.
|
|
4667
4680
|
*
|
|
4668
4681
|
* Do not include any prerelease in these versions as they are ignored.
|
|
4669
|
-
*/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.0.
|
|
4682
|
+
*/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.0.2'));definitionMap.set('ngImport',importExpr(Identifiers$1.core));definitionMap.set('type',meta.internalType);definitionMap.set('deps',compileDependencies(meta.deps));definitionMap.set('target',importExpr(Identifiers$1.FactoryTarget).prop(exports.FactoryTarget[meta.target]));return {expression:importExpr(Identifiers$1.declareFactory).callFn([definitionMap.toLiteralMap()]),statements:[],type:createFactoryType(meta)};}/**
|
|
4670
4683
|
* @license
|
|
4671
4684
|
* Copyright Google LLC All Rights Reserved.
|
|
4672
4685
|
*
|
|
@@ -4682,28 +4695,11 @@ const contents=templateInfo.content;const file=new ParseSourceFile(contents,temp
|
|
|
4682
4695
|
* Compile a Injectable declaration defined by the `R3InjectableMetadata`.
|
|
4683
4696
|
*/function compileDeclareInjectableFromMetadata(meta){const definitionMap=createInjectableDefinitionMap(meta);const expression=importExpr(Identifiers$1.declareInjectable).callFn([definitionMap.toLiteralMap()]);const type=createInjectableType(meta);return {expression,type,statements:[]};}/**
|
|
4684
4697
|
* Gathers the declaration fields for a Injectable into a `DefinitionMap`.
|
|
4685
|
-
*/function createInjectableDefinitionMap(meta){const definitionMap=new DefinitionMap();definitionMap.set('minVersion',literal(MINIMUM_PARTIAL_LINKER_VERSION$3));definitionMap.set('version',literal('13.0.
|
|
4686
|
-
if(meta.providedIn!==undefined){const providedIn=
|
|
4698
|
+
*/function createInjectableDefinitionMap(meta){const definitionMap=new DefinitionMap();definitionMap.set('minVersion',literal(MINIMUM_PARTIAL_LINKER_VERSION$3));definitionMap.set('version',literal('13.0.2'));definitionMap.set('ngImport',importExpr(Identifiers$1.core));definitionMap.set('type',meta.internalType);// Only generate providedIn property if it has a non-null value
|
|
4699
|
+
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
|
|
4687
4700
|
// so the types will not be eagerly evaluated. Therefore we do not need to process this expression
|
|
4688
4701
|
// with `convertFromProviderExpression()`.
|
|
4689
4702
|
if(meta.useFactory!==undefined){definitionMap.set('useFactory',meta.useFactory);}if(meta.deps!==undefined){definitionMap.set('deps',literalArr(meta.deps.map(compileDependency)));}return definitionMap;}/**
|
|
4690
|
-
* Convert an `R3ProviderExpression` to an `Expression`, possibly wrapping its expression in a
|
|
4691
|
-
* `forwardRef()` call.
|
|
4692
|
-
*
|
|
4693
|
-
* If `R3ProviderExpression.isForwardRef` is true then the expression was originally wrapped in a
|
|
4694
|
-
* `forwardRef()` call to prevent the value from being eagerly evaluated in the code.
|
|
4695
|
-
*
|
|
4696
|
-
* Normally, the linker will statically process the code, putting the `expression` inside a factory
|
|
4697
|
-
* function so the `forwardRef()` wrapper is not evaluated before it has been defined. But if the
|
|
4698
|
-
* partial declaration is evaluated by the JIT compiler the `forwardRef()` call is still needed to
|
|
4699
|
-
* prevent eager evaluation of the `expression`.
|
|
4700
|
-
*
|
|
4701
|
-
* So in partial declarations, expressions that could be forward-refs are wrapped in `forwardRef()`
|
|
4702
|
-
* calls, and this is then unwrapped in the linker as necessary.
|
|
4703
|
-
*
|
|
4704
|
-
* See `packages/compiler-cli/src/ngtsc/annotations/src/injectable.ts` and
|
|
4705
|
-
* `packages/compiler/src/jit_compiler_facade.ts` for more information.
|
|
4706
|
-
*/function convertFromProviderExpression({expression,isForwardRef}){return isForwardRef?generateForwardRef(expression):expression;}/**
|
|
4707
4703
|
* @license
|
|
4708
4704
|
* Copyright Google LLC All Rights Reserved.
|
|
4709
4705
|
*
|
|
@@ -4717,7 +4713,7 @@ if(meta.useFactory!==undefined){definitionMap.set('useFactory',meta.useFactory);
|
|
|
4717
4713
|
* Do not include any prerelease in these versions as they are ignored.
|
|
4718
4714
|
*/const MINIMUM_PARTIAL_LINKER_VERSION$2='12.0.0';function compileDeclareInjectorFromMetadata(meta){const definitionMap=createInjectorDefinitionMap(meta);const expression=importExpr(Identifiers$1.declareInjector).callFn([definitionMap.toLiteralMap()]);const type=createInjectorType(meta);return {expression,type,statements:[]};}/**
|
|
4719
4715
|
* Gathers the declaration fields for an Injector into a `DefinitionMap`.
|
|
4720
|
-
*/function createInjectorDefinitionMap(meta){const definitionMap=new DefinitionMap();definitionMap.set('minVersion',literal(MINIMUM_PARTIAL_LINKER_VERSION$2));definitionMap.set('version',literal('13.0.
|
|
4716
|
+
*/function createInjectorDefinitionMap(meta){const definitionMap=new DefinitionMap();definitionMap.set('minVersion',literal(MINIMUM_PARTIAL_LINKER_VERSION$2));definitionMap.set('version',literal('13.0.2'));definitionMap.set('ngImport',importExpr(Identifiers$1.core));definitionMap.set('type',meta.internalType);definitionMap.set('providers',meta.providers);if(meta.imports.length>0){definitionMap.set('imports',literalArr(meta.imports));}return definitionMap;}/**
|
|
4721
4717
|
* @license
|
|
4722
4718
|
* Copyright Google LLC All Rights Reserved.
|
|
4723
4719
|
*
|
|
@@ -4731,7 +4727,7 @@ if(meta.useFactory!==undefined){definitionMap.set('useFactory',meta.useFactory);
|
|
|
4731
4727
|
* Do not include any prerelease in these versions as they are ignored.
|
|
4732
4728
|
*/const MINIMUM_PARTIAL_LINKER_VERSION$1='12.0.0';function compileDeclareNgModuleFromMetadata(meta){const definitionMap=createNgModuleDefinitionMap(meta);const expression=importExpr(Identifiers$1.declareNgModule).callFn([definitionMap.toLiteralMap()]);const type=createNgModuleType(meta);return {expression,type,statements:[]};}/**
|
|
4733
4729
|
* Gathers the declaration fields for an NgModule into a `DefinitionMap`.
|
|
4734
|
-
*/function createNgModuleDefinitionMap(meta){const definitionMap=new DefinitionMap();definitionMap.set('minVersion',literal(MINIMUM_PARTIAL_LINKER_VERSION$1));definitionMap.set('version',literal('13.0.
|
|
4730
|
+
*/function createNgModuleDefinitionMap(meta){const definitionMap=new DefinitionMap();definitionMap.set('minVersion',literal(MINIMUM_PARTIAL_LINKER_VERSION$1));definitionMap.set('version',literal('13.0.2'));definitionMap.set('ngImport',importExpr(Identifiers$1.core));definitionMap.set('type',meta.internalType);// We only generate the keys in the metadata if the arrays contain values.
|
|
4735
4731
|
// We must wrap the arrays inside a function if any of the values are a forward reference to a
|
|
4736
4732
|
// not-yet-declared class. This is to support JIT execution of the `ɵɵngDeclareNgModule()` call.
|
|
4737
4733
|
// In the linker these wrappers are stripped and then reapplied for the `ɵɵdefineNgModule()` call.
|
|
@@ -4751,7 +4747,7 @@ if(meta.bootstrap.length>0){definitionMap.set('bootstrap',refsToArray(meta.boots
|
|
|
4751
4747
|
* Compile a Pipe declaration defined by the `R3PipeMetadata`.
|
|
4752
4748
|
*/function compileDeclarePipeFromMetadata(meta){const definitionMap=createPipeDefinitionMap(meta);const expression=importExpr(Identifiers$1.declarePipe).callFn([definitionMap.toLiteralMap()]);const type=createPipeType(meta);return {expression,type,statements:[]};}/**
|
|
4753
4749
|
* Gathers the declaration fields for a Pipe into a `DefinitionMap`.
|
|
4754
|
-
*/function createPipeDefinitionMap(meta){const definitionMap=new DefinitionMap();definitionMap.set('minVersion',literal(MINIMUM_PARTIAL_LINKER_VERSION));definitionMap.set('version',literal('13.0.
|
|
4750
|
+
*/function createPipeDefinitionMap(meta){const definitionMap=new DefinitionMap();definitionMap.set('minVersion',literal(MINIMUM_PARTIAL_LINKER_VERSION));definitionMap.set('version',literal('13.0.2'));definitionMap.set('ngImport',importExpr(Identifiers$1.core));// e.g. `type: MyPipe`
|
|
4755
4751
|
definitionMap.set('type',meta.internalType);// e.g. `name: "myPipe"`
|
|
4756
4752
|
definitionMap.set('name',literal(meta.pipeName));if(meta.pure===false){// e.g. `pure: false`
|
|
4757
4753
|
definitionMap.set('pure',literal(meta.pure));}return definitionMap;}/**
|
|
@@ -5006,8 +5002,8 @@ exports.createAotUrlResolver = createAotUrlResolver;
|
|
|
5006
5002
|
exports.createElementCssSelector = createElementCssSelector;
|
|
5007
5003
|
exports.createInjectableType = createInjectableType;
|
|
5008
5004
|
exports.createLoweredSymbol = createLoweredSymbol;
|
|
5005
|
+
exports.createMayBeForwardRefExpression = createMayBeForwardRefExpression;
|
|
5009
5006
|
exports.createOfflineCompileUrlResolver = createOfflineCompileUrlResolver;
|
|
5010
|
-
exports.createR3ProviderExpression = createR3ProviderExpression;
|
|
5011
5007
|
exports.createUrlResolverWithoutPackagePrefix = createUrlResolverWithoutPackagePrefix;
|
|
5012
5008
|
exports.debugOutputAstAsTypeScript = debugOutputAstAsTypeScript;
|
|
5013
5009
|
exports.devOnlyGuardedExpression = devOnlyGuardedExpression;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-eslint/bundled-angular-compiler",
|
|
3
|
-
"version": "13.0.
|
|
3
|
+
"version": "13.0.1",
|
|
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": "
|
|
18
|
+
"gitHead": "e2006e5e9c99e5a943d1a999e0efa5247d29ec24"
|
|
19
19
|
}
|