@angular/language-service 8.0.0-rc.5 → 8.0.3

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v8.0.0-rc.5
2
+ * @license Angular v8.0.3
3
3
  * (c) 2010-2019 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -7481,6 +7481,9 @@ define(['exports', 'path', 'typescript', 'fs'], function (exports, path, ts, fs)
7481
7481
  var actionStmts = [];
7482
7482
  flattenStatements(actionWithoutBuiltins.visit(visitor, _Mode.Statement), actionStmts);
7483
7483
  prependTemporaryDecls(visitor.temporaryCount, bindingId, actionStmts);
7484
+ if (visitor.usesImplicitReceiver) {
7485
+ localResolver.notifyImplicitReceiverUse();
7486
+ }
7484
7487
  var lastIndex = actionStmts.length - 1;
7485
7488
  var preventDefaultVar = null;
7486
7489
  if (lastIndex >= 0) {
@@ -7528,6 +7531,9 @@ define(['exports', 'path', 'typescript', 'fs'], function (exports, path, ts, fs)
7528
7531
  var visitor = new _AstToIrVisitor(localResolver, implicitReceiver, bindingId, interpolationFunction);
7529
7532
  var outputExpr = expressionWithoutBuiltins.visit(visitor, _Mode.Expression);
7530
7533
  var stmts = getStatementsFromVisitor(visitor, bindingId);
7534
+ if (visitor.usesImplicitReceiver) {
7535
+ localResolver.notifyImplicitReceiverUse();
7536
+ }
7531
7537
  if (visitor.temporaryCount === 0 && form == BindingForm.TrySimple) {
7532
7538
  return new ConvertPropertyBindingResult([], outputExpr);
7533
7539
  }
@@ -7553,6 +7559,9 @@ define(['exports', 'path', 'typescript', 'fs'], function (exports, path, ts, fs)
7553
7559
  function convertUpdateArguments(localResolver, contextVariableExpression, expressionWithArgumentsToExtract, bindingId) {
7554
7560
  var visitor = new _AstToIrVisitor(localResolver, contextVariableExpression, bindingId, undefined);
7555
7561
  var outputExpr = expressionWithArgumentsToExtract.visit(visitor, _Mode.Expression);
7562
+ if (visitor.usesImplicitReceiver) {
7563
+ localResolver.notifyImplicitReceiverUse();
7564
+ }
7556
7565
  var stmts = getStatementsFromVisitor(visitor, bindingId);
7557
7566
  // Removing the first argument, because it was a length for ViewEngine, not Ivy.
7558
7567
  var args = outputExpr.args.slice(1);
@@ -7652,6 +7661,7 @@ define(['exports', 'path', 'typescript', 'fs'], function (exports, path, ts, fs)
7652
7661
  this._resultMap = new Map();
7653
7662
  this._currentTemporary = 0;
7654
7663
  this.temporaryCount = 0;
7664
+ this.usesImplicitReceiver = false;
7655
7665
  }
7656
7666
  _AstToIrVisitor.prototype.visitBinary = function (ast, mode) {
7657
7667
  var op;
@@ -7731,6 +7741,7 @@ define(['exports', 'path', 'typescript', 'fs'], function (exports, path, ts, fs)
7731
7741
  };
7732
7742
  _AstToIrVisitor.prototype.visitImplicitReceiver = function (ast, mode) {
7733
7743
  ensureExpressionMode(mode, ast);
7744
+ this.usesImplicitReceiver = true;
7734
7745
  return this._implicitReceiver;
7735
7746
  };
7736
7747
  _AstToIrVisitor.prototype.visitInterpolation = function (ast, mode) {
@@ -7794,11 +7805,15 @@ define(['exports', 'path', 'typescript', 'fs'], function (exports, path, ts, fs)
7794
7805
  }
7795
7806
  else {
7796
7807
  var args = this.visitAll(ast.args, _Mode.Expression);
7808
+ var prevUsesImplicitReceiver = this.usesImplicitReceiver;
7797
7809
  var result = null;
7798
7810
  var receiver = this._visit(ast.receiver, _Mode.Expression);
7799
7811
  if (receiver === this._implicitReceiver) {
7800
7812
  var varExpr = this._getLocal(ast.name);
7801
7813
  if (varExpr) {
7814
+ // Restore the previous "usesImplicitReceiver" state since the implicit
7815
+ // receiver has been replaced with a resolved local expression.
7816
+ this.usesImplicitReceiver = prevUsesImplicitReceiver;
7802
7817
  result = varExpr.callFn(args);
7803
7818
  }
7804
7819
  }
@@ -7821,9 +7836,15 @@ define(['exports', 'path', 'typescript', 'fs'], function (exports, path, ts, fs)
7821
7836
  }
7822
7837
  else {
7823
7838
  var result = null;
7839
+ var prevUsesImplicitReceiver = this.usesImplicitReceiver;
7824
7840
  var receiver = this._visit(ast.receiver, _Mode.Expression);
7825
7841
  if (receiver === this._implicitReceiver) {
7826
7842
  result = this._getLocal(ast.name);
7843
+ if (result) {
7844
+ // Restore the previous "usesImplicitReceiver" state since the implicit
7845
+ // receiver has been replaced with a resolved local expression.
7846
+ this.usesImplicitReceiver = prevUsesImplicitReceiver;
7847
+ }
7827
7848
  }
7828
7849
  if (result == null) {
7829
7850
  result = receiver.prop(ast.name);
@@ -7833,6 +7854,7 @@ define(['exports', 'path', 'typescript', 'fs'], function (exports, path, ts, fs)
7833
7854
  };
7834
7855
  _AstToIrVisitor.prototype.visitPropertyWrite = function (ast, mode) {
7835
7856
  var receiver = this._visit(ast.receiver, _Mode.Expression);
7857
+ var prevUsesImplicitReceiver = this.usesImplicitReceiver;
7836
7858
  var varExpr = null;
7837
7859
  if (receiver === this._implicitReceiver) {
7838
7860
  var localExpr = this._getLocal(ast.name);
@@ -7842,6 +7864,9 @@ define(['exports', 'path', 'typescript', 'fs'], function (exports, path, ts, fs)
7842
7864
  // to a 'context.property' value and will be used as the target of the
7843
7865
  // write expression.
7844
7866
  varExpr = localExpr;
7867
+ // Restore the previous "usesImplicitReceiver" state since the implicit
7868
+ // receiver has been replaced with a resolved local expression.
7869
+ this.usesImplicitReceiver = prevUsesImplicitReceiver;
7845
7870
  }
7846
7871
  else {
7847
7872
  // Otherwise it's an error.
@@ -7903,7 +7928,7 @@ define(['exports', 'path', 'typescript', 'fs'], function (exports, path, ts, fs)
7903
7928
  // / \ / \
7904
7929
  // . c . e
7905
7930
  // / \ / \
7906
- // a b , d
7931
+ // a b . d
7907
7932
  // / \
7908
7933
  // . c
7909
7934
  // / \
@@ -8062,6 +8087,7 @@ define(['exports', 'path', 'typescript', 'fs'], function (exports, path, ts, fs)
8062
8087
  var DefaultLocalResolver = /** @class */ (function () {
8063
8088
  function DefaultLocalResolver() {
8064
8089
  }
8090
+ DefaultLocalResolver.prototype.notifyImplicitReceiverUse = function () { };
8065
8091
  DefaultLocalResolver.prototype.getLocal = function (name) {
8066
8092
  if (name === EventHandlerVars.event.name) {
8067
8093
  return EventHandlerVars.event;
@@ -15386,8 +15412,6 @@ define(['exports', 'path', 'typescript', 'fs'], function (exports, path, ts, fs)
15386
15412
  * Use of this source code is governed by an MIT-style license that can be
15387
15413
  * found in the LICENSE file at https://angular.io/license
15388
15414
  */
15389
- // Default selector used by `<ng-content>` if none specified
15390
- var DEFAULT_NG_CONTENT_SELECTOR = '*';
15391
15415
  // Selector attribute name of `<ng-content>`
15392
15416
  var NG_CONTENT_SELECT_ATTR$1 = 'select';
15393
15417
  // Attribute name of `ngProjectAs`.
@@ -15399,14 +15423,17 @@ define(['exports', 'path', 'typescript', 'fs'], function (exports, path, ts, fs)
15399
15423
  function renderFlagCheckIfStmt(flags, statements) {
15400
15424
  return ifStmt(variable(RENDER_FLAGS).bitwiseAnd(literal(flags), null, false), statements);
15401
15425
  }
15402
- function prepareEventListenerParameters(eventAst, bindingContext, handlerName, scope) {
15426
+ function prepareEventListenerParameters(eventAst, handlerName, scope) {
15403
15427
  if (handlerName === void 0) { handlerName = null; }
15404
15428
  if (scope === void 0) { scope = null; }
15405
15429
  var type = eventAst.type, name = eventAst.name, target = eventAst.target, phase = eventAst.phase, handler = eventAst.handler;
15406
15430
  if (target && !GLOBAL_TARGET_RESOLVERS.has(target)) {
15407
15431
  throw new Error("Unexpected global target '" + target + "' defined for '" + name + "' event.\n Supported list of global targets: " + Array.from(GLOBAL_TARGET_RESOLVERS.keys()) + ".");
15408
15432
  }
15409
- var bindingExpr = convertActionBinding(scope, bindingContext, handler, 'b', function () { return error('Unexpected interpolation'); }, eventAst.handlerSpan);
15433
+ var implicitReceiverExpr = (scope === null || scope.bindingLevel === 0) ?
15434
+ variable(CONTEXT_NAME) :
15435
+ scope.getOrCreateSharedContextVar(0);
15436
+ var bindingExpr = convertActionBinding(scope, implicitReceiverExpr, handler, 'b', function () { return error('Unexpected interpolation'); }, eventAst.handlerSpan);
15410
15437
  var statements = [];
15411
15438
  if (scope) {
15412
15439
  statements.push.apply(statements, __spread(scope.restoreViewStatement()));
@@ -15478,13 +15505,16 @@ define(['exports', 'path', 'typescript', 'fs'], function (exports, path, ts, fs)
15478
15505
  this._pureFunctionSlots = 0;
15479
15506
  // Number of binding slots
15480
15507
  this._bindingSlots = 0;
15481
- // Whether the template includes <ng-content> tags.
15482
- this._hasNgContent = false;
15483
- // Selectors found in the <ng-content> tags in the template.
15484
- this._ngContentSelectors = [];
15508
+ // Projection slots found in the template. Projection slots can distribute projected
15509
+ // nodes based on a selector, or can just use the wildcard selector to match
15510
+ // all nodes which aren't matching any selector.
15511
+ this._ngContentReservedSlots = [];
15485
15512
  // Number of non-default selectors found in all parent templates of this template. We need to
15486
- // track it to properly adjust projection bucket index in the `projection` instruction.
15513
+ // track it to properly adjust projection slot index in the `projection` instruction.
15487
15514
  this._ngContentSelectorsOffset = 0;
15515
+ // Expression that should be used as implicit receiver when converting template
15516
+ // expressions to output AST.
15517
+ this._implicitReceiverExpr = null;
15488
15518
  // These should be handled in the template or element directly.
15489
15519
  this.visitReference = invalid$1;
15490
15520
  this.visitVariable = invalid$1;
@@ -15557,15 +15587,17 @@ define(['exports', 'path', 'typescript', 'fs'], function (exports, path, ts, fs)
15557
15587
  // Nested templates must be processed before creation instructions so template()
15558
15588
  // instructions can be generated with the correct internal const count.
15559
15589
  this._nestedTemplateFns.forEach(function (buildTemplateFn) { return buildTemplateFn(); });
15560
- // Output the `projectionDef` instruction when some `<ng-content>` are present.
15561
- // The `projectionDef` instruction only emitted for the component template and it is skipped for
15562
- // nested templates (<ng-template> tags).
15563
- if (this.level === 0 && this._hasNgContent) {
15590
+ // Output the `projectionDef` instruction when some `<ng-content>` tags are present.
15591
+ // The `projectionDef` instruction is only emitted for the component template and
15592
+ // is skipped for nested templates (<ng-template> tags).
15593
+ if (this.level === 0 && this._ngContentReservedSlots.length) {
15564
15594
  var parameters = [];
15565
- // Only selectors with a non-default value are generated
15566
- if (this._ngContentSelectors.length) {
15567
- var r3Selectors = this._ngContentSelectors.map(function (s) { return parseSelectorToR3Selector(s); });
15568
- parameters.push(this.constantPool.getConstLiteral(asLiteral(r3Selectors), true));
15595
+ // By default the `projectionDef` instructions creates one slot for the wildcard
15596
+ // selector if no parameters are passed. Therefore we only want to allocate a new
15597
+ // array for the projection slots if the default projection slot is not sufficient.
15598
+ if (this._ngContentReservedSlots.length > 1 || this._ngContentReservedSlots[0] !== '*') {
15599
+ var r3ReservedSlots = this._ngContentReservedSlots.map(function (s) { return s !== '*' ? parseSelectorToR3Selector(s) : s; });
15600
+ parameters.push(this.constantPool.getConstLiteral(asLiteral(r3ReservedSlots), true));
15569
15601
  }
15570
15602
  // Since we accumulate ngContent selectors while processing template elements,
15571
15603
  // we *prepend* `projectionDef` to creation instructions block, to put it before
@@ -15596,6 +15628,8 @@ define(['exports', 'path', 'typescript', 'fs'], function (exports, path, ts, fs)
15596
15628
  };
15597
15629
  // LocalResolver
15598
15630
  TemplateDefinitionBuilder.prototype.getLocal = function (name) { return this._bindingScope.get(name); };
15631
+ // LocalResolver
15632
+ TemplateDefinitionBuilder.prototype.notifyImplicitReceiverUse = function () { this._bindingScope.notifyImplicitReceiverUse(); };
15599
15633
  TemplateDefinitionBuilder.prototype.i18nTranslate = function (message, params, ref, transformFn) {
15600
15634
  var _a;
15601
15635
  if (params === void 0) { params = {}; }
@@ -15733,7 +15767,7 @@ define(['exports', 'path', 'typescript', 'fs'], function (exports, path, ts, fs)
15733
15767
  var _a = this.i18n, index = _a.index, bindings = _a.bindings;
15734
15768
  if (bindings.size) {
15735
15769
  bindings.forEach(function (binding) {
15736
- _this.updateInstruction(index, span, Identifiers$1.i18nExp, function () { return [_this.convertPropertyBinding(variable(CONTEXT_NAME), binding)]; });
15770
+ _this.updateInstruction(index, span, Identifiers$1.i18nExp, function () { return [_this.convertPropertyBinding(binding)]; });
15737
15771
  });
15738
15772
  this.updateInstruction(index, span, Identifiers$1.i18nApply, [literal(index)]);
15739
15773
  }
@@ -15743,13 +15777,11 @@ define(['exports', 'path', 'typescript', 'fs'], function (exports, path, ts, fs)
15743
15777
  this.i18n = null; // reset local i18n context
15744
15778
  };
15745
15779
  TemplateDefinitionBuilder.prototype.visitContent = function (ngContent) {
15746
- this._hasNgContent = true;
15747
15780
  var slot = this.allocateDataSlot();
15748
- var selectorIndex = ngContent.selector === DEFAULT_NG_CONTENT_SELECTOR ?
15749
- 0 :
15750
- this._ngContentSelectors.push(ngContent.selector) + this._ngContentSelectorsOffset;
15781
+ var projectionSlotIdx = this._ngContentSelectorsOffset + this._ngContentReservedSlots.length;
15751
15782
  var parameters = [literal(slot)];
15752
15783
  var attributes = [];
15784
+ this._ngContentReservedSlots.push(ngContent.selector);
15753
15785
  ngContent.attributes.forEach(function (attribute) {
15754
15786
  var name = attribute.name, value = attribute.value;
15755
15787
  if (name === NG_PROJECT_AS_ATTR_NAME) {
@@ -15760,10 +15792,10 @@ define(['exports', 'path', 'typescript', 'fs'], function (exports, path, ts, fs)
15760
15792
  }
15761
15793
  });
15762
15794
  if (attributes.length > 0) {
15763
- parameters.push(literal(selectorIndex), literalArr(attributes));
15795
+ parameters.push(literal(projectionSlotIdx), literalArr(attributes));
15764
15796
  }
15765
- else if (selectorIndex !== 0) {
15766
- parameters.push(literal(selectorIndex));
15797
+ else if (projectionSlotIdx !== 0) {
15798
+ parameters.push(literal(projectionSlotIdx));
15767
15799
  }
15768
15800
  this.creationInstruction(ngContent.sourceSpan, Identifiers$1.projection, parameters);
15769
15801
  };
@@ -15871,7 +15903,6 @@ define(['exports', 'path', 'typescript', 'fs'], function (exports, path, ts, fs)
15871
15903
  if (currentNamespace !== wasInNamespace) {
15872
15904
  this.addNamespaceInstruction(currentNamespace, element);
15873
15905
  }
15874
- var implicit = variable(CONTEXT_NAME);
15875
15906
  if (this.i18n) {
15876
15907
  this.i18n.appendElement(element.i18n, elementIndex);
15877
15908
  }
@@ -15913,7 +15944,7 @@ define(['exports', 'path', 'typescript', 'fs'], function (exports, path, ts, fs)
15913
15944
  i18nAttrArgs_1.push(literal(attr.name), _this.i18nTranslate(message, params));
15914
15945
  converted.expressions.forEach(function (expression) {
15915
15946
  hasBindings_1 = true;
15916
- var binding = _this.convertExpressionBinding(implicit, expression);
15947
+ var binding = _this.convertExpressionBinding(expression);
15917
15948
  _this.updateInstruction(elementIndex, element.sourceSpan, Identifiers$1.i18nExp, [binding]);
15918
15949
  });
15919
15950
  }
@@ -15934,7 +15965,7 @@ define(['exports', 'path', 'typescript', 'fs'], function (exports, path, ts, fs)
15934
15965
  // designed to run inside of `elementStart` and `elementEnd`. The update instructions
15935
15966
  // (things like `elementStyleProp`, `elementClassProp`, etc..) are applied later on in this
15936
15967
  // file
15937
- this.processStylingInstruction(implicit, stylingBuilder.buildElementStylingInstruction(element.sourceSpan, this.constantPool), true);
15968
+ this.processStylingInstruction(stylingBuilder.buildElementStylingInstruction(element.sourceSpan, this.constantPool), true);
15938
15969
  // Generate Listeners (outputs)
15939
15970
  element.outputs.forEach(function (outputAst) {
15940
15971
  _this.creationInstruction(outputAst.sourceSpan, Identifiers$1.listener, _this.prepareListenerParameter(element.name, outputAst, elementIndex));
@@ -15951,7 +15982,7 @@ define(['exports', 'path', 'typescript', 'fs'], function (exports, path, ts, fs)
15951
15982
  // and assign in the code below.
15952
15983
  stylingBuilder.buildUpdateLevelInstructions(this._valueConverter).forEach(function (instruction) {
15953
15984
  _this._bindingSlots += instruction.allocateBindingSlots;
15954
- _this.processStylingInstruction(implicit, instruction, false);
15985
+ _this.processStylingInstruction(instruction, false);
15955
15986
  });
15956
15987
  // the reason why `undefined` is used is because the renderer understands this as a
15957
15988
  // special value to symbolize that there is no RHS to this binding
@@ -15977,7 +16008,7 @@ define(['exports', 'path', 'typescript', 'fs'], function (exports, path, ts, fs)
15977
16008
  _this.updateInstruction(elementIndex, input.sourceSpan, Identifiers$1.property, function () {
15978
16009
  return [
15979
16010
  literal(bindingName_1),
15980
- (hasValue_1 ? _this.convertPropertyBinding(implicit, value_1, /* skipBindFn */ true) :
16011
+ (hasValue_1 ? _this.convertPropertyBinding(value_1, /* skipBindFn */ true) :
15981
16012
  emptyValueBindInstruction),
15982
16013
  ];
15983
16014
  });
@@ -16010,15 +16041,13 @@ define(['exports', 'path', 'typescript', 'fs'], function (exports, path, ts, fs)
16010
16041
  if (inputType === 0 /* Property */) {
16011
16042
  if (value_2 instanceof Interpolation) {
16012
16043
  _this.updateInstruction(elementIndex, input.sourceSpan, getPropertyInterpolationExpression(value_2), function () {
16013
- return __spread([literal(attrName_1)], _this.getUpdateInstructionArguments(variable(CONTEXT_NAME), value_2), params_2);
16044
+ return __spread([literal(attrName_1)], _this.getUpdateInstructionArguments(value_2), params_2);
16014
16045
  });
16015
16046
  }
16016
16047
  else {
16017
16048
  // Bound, un-interpolated properties
16018
16049
  _this.updateInstruction(elementIndex, input.sourceSpan, Identifiers$1.property, function () {
16019
- return __spread([
16020
- literal(attrName_1), _this.convertPropertyBinding(implicit, value_2, true)
16021
- ], params_2);
16050
+ return __spread([literal(attrName_1), _this.convertPropertyBinding(value_2, true)], params_2);
16022
16051
  });
16023
16052
  }
16024
16053
  }
@@ -16032,8 +16061,7 @@ define(['exports', 'path', 'typescript', 'fs'], function (exports, path, ts, fs)
16032
16061
  }
16033
16062
  _this.updateInstruction(elementIndex, input.sourceSpan, instruction_1, function () {
16034
16063
  return __spread([
16035
- literal(elementIndex), literal(attrName_1),
16036
- _this.convertPropertyBinding(implicit, value_2)
16064
+ literal(elementIndex), literal(attrName_1), _this.convertPropertyBinding(value_2)
16037
16065
  ], params_2);
16038
16066
  });
16039
16067
  }
@@ -16094,11 +16122,10 @@ define(['exports', 'path', 'typescript', 'fs'], function (exports, path, ts, fs)
16094
16122
  // template definition. e.g. <div *ngIf="showing">{{ foo }}</div> <div #foo></div>
16095
16123
  this._nestedTemplateFns.push(function () {
16096
16124
  var _a;
16097
- var templateFunctionExpr = templateVisitor.buildTemplateFunction(template.children, template.variables, _this._ngContentSelectors.length + _this._ngContentSelectorsOffset, template.i18n);
16125
+ var templateFunctionExpr = templateVisitor.buildTemplateFunction(template.children, template.variables, _this._ngContentReservedSlots.length + _this._ngContentSelectorsOffset, template.i18n);
16098
16126
  _this.constantPool.statements.push(templateFunctionExpr.toDeclStmt(templateName, null));
16099
- if (templateVisitor._hasNgContent) {
16100
- _this._hasNgContent = true;
16101
- (_a = _this._ngContentSelectors).push.apply(_a, __spread(templateVisitor._ngContentSelectors));
16127
+ if (templateVisitor._ngContentReservedSlots.length) {
16128
+ (_a = _this._ngContentReservedSlots).push.apply(_a, __spread(templateVisitor._ngContentReservedSlots));
16102
16129
  }
16103
16130
  });
16104
16131
  // e.g. template(1, MyComp_Template_1)
@@ -16107,12 +16134,11 @@ define(['exports', 'path', 'typescript', 'fs'], function (exports, path, ts, fs)
16107
16134
  return trimTrailingNulls(parameters);
16108
16135
  });
16109
16136
  // handle property bindings e.g. ɵɵproperty('ngForOf', ctx.items), et al;
16110
- var context = variable(CONTEXT_NAME);
16111
- this.templatePropertyBindings(template, templateIndex, context, template.templateAttrs);
16137
+ this.templatePropertyBindings(template, templateIndex, template.templateAttrs);
16112
16138
  // Only add normal input/output binding instructions on explicit ng-template elements.
16113
16139
  if (template.tagName === NG_TEMPLATE_TAG_NAME) {
16114
16140
  // Add the input bindings
16115
- this.templatePropertyBindings(template, templateIndex, context, template.inputs);
16141
+ this.templatePropertyBindings(template, templateIndex, template.inputs);
16116
16142
  // Generate listeners for directive output
16117
16143
  template.outputs.forEach(function (outputAst) {
16118
16144
  _this.creationInstruction(outputAst.sourceSpan, Identifiers$1.listener, _this.prepareListenerParameter('ng_template', outputAst, templateIndex));
@@ -16134,7 +16160,7 @@ define(['exports', 'path', 'typescript', 'fs'], function (exports, path, ts, fs)
16134
16160
  this.creationInstruction(text.sourceSpan, Identifiers$1.text, [literal(nodeIndex)]);
16135
16161
  var value = text.value.visit(this._valueConverter);
16136
16162
  this.allocateBindingSlots(value);
16137
- this.updateInstruction(nodeIndex, text.sourceSpan, Identifiers$1.textBinding, function () { return [literal(nodeIndex), _this.convertPropertyBinding(variable(CONTEXT_NAME), value)]; });
16163
+ this.updateInstruction(nodeIndex, text.sourceSpan, Identifiers$1.textBinding, function () { return [literal(nodeIndex), _this.convertPropertyBinding(value)]; });
16138
16164
  };
16139
16165
  TemplateDefinitionBuilder.prototype.visitText = function (text) {
16140
16166
  // when a text element is located within a translatable
@@ -16181,18 +16207,18 @@ define(['exports', 'path', 'typescript', 'fs'], function (exports, path, ts, fs)
16181
16207
  TemplateDefinitionBuilder.prototype.getConstCount = function () { return this._dataIndex; };
16182
16208
  TemplateDefinitionBuilder.prototype.getVarCount = function () { return this._pureFunctionSlots; };
16183
16209
  TemplateDefinitionBuilder.prototype.getNgContentSelectors = function () {
16184
- return this._hasNgContent ?
16185
- this.constantPool.getConstLiteral(asLiteral(this._ngContentSelectors), true) :
16210
+ return this._ngContentReservedSlots.length ?
16211
+ this.constantPool.getConstLiteral(asLiteral(this._ngContentReservedSlots), true) :
16186
16212
  null;
16187
16213
  };
16188
16214
  TemplateDefinitionBuilder.prototype.bindingContext = function () { return "" + this._bindingContext++; };
16189
- TemplateDefinitionBuilder.prototype.templatePropertyBindings = function (template, templateIndex, context, attrs) {
16215
+ TemplateDefinitionBuilder.prototype.templatePropertyBindings = function (template, templateIndex, attrs) {
16190
16216
  var _this = this;
16191
16217
  attrs.forEach(function (input) {
16192
16218
  if (input instanceof BoundAttribute) {
16193
16219
  var value_4 = input.value.visit(_this._valueConverter);
16194
16220
  _this.allocateBindingSlots(value_4);
16195
- _this.updateInstruction(templateIndex, template.sourceSpan, Identifiers$1.property, function () { return [literal(input.name), _this.convertPropertyBinding(context, value_4, true)]; });
16221
+ _this.updateInstruction(templateIndex, template.sourceSpan, Identifiers$1.property, function () { return [literal(input.name), _this.convertPropertyBinding(value_4, true)]; });
16196
16222
  }
16197
16223
  });
16198
16224
  };
@@ -16207,11 +16233,11 @@ define(['exports', 'path', 'typescript', 'fs'], function (exports, path, ts, fs)
16207
16233
  return instruction(span, reference, params).toStmt();
16208
16234
  });
16209
16235
  };
16210
- TemplateDefinitionBuilder.prototype.processStylingInstruction = function (implicit, instruction, createMode) {
16236
+ TemplateDefinitionBuilder.prototype.processStylingInstruction = function (instruction, createMode) {
16211
16237
  var _this = this;
16212
16238
  if (instruction) {
16213
16239
  var paramsFn = function () {
16214
- return instruction.buildParams(function (value) { return _this.convertPropertyBinding(implicit, value, true); });
16240
+ return instruction.buildParams(function (value) { return _this.convertPropertyBinding(value, true); });
16215
16241
  };
16216
16242
  if (createMode) {
16217
16243
  this.creationInstruction(instruction.sourceSpan, instruction.reference, paramsFn);
@@ -16239,17 +16265,29 @@ define(['exports', 'path', 'typescript', 'fs'], function (exports, path, ts, fs)
16239
16265
  TemplateDefinitionBuilder.prototype.allocateBindingSlots = function (value) {
16240
16266
  this._bindingSlots += value instanceof Interpolation ? value.expressions.length : 1;
16241
16267
  };
16242
- TemplateDefinitionBuilder.prototype.convertExpressionBinding = function (implicit, value) {
16243
- var convertedPropertyBinding = convertPropertyBinding(this, implicit, value, this.bindingContext(), BindingForm.TrySimple);
16268
+ /**
16269
+ * Gets an expression that refers to the implicit receiver. The implicit
16270
+ * receiver is always the root level context.
16271
+ */
16272
+ TemplateDefinitionBuilder.prototype.getImplicitReceiverExpr = function () {
16273
+ if (this._implicitReceiverExpr) {
16274
+ return this._implicitReceiverExpr;
16275
+ }
16276
+ return this._implicitReceiverExpr = this.level === 0 ?
16277
+ variable(CONTEXT_NAME) :
16278
+ this._bindingScope.getOrCreateSharedContextVar(0);
16279
+ };
16280
+ TemplateDefinitionBuilder.prototype.convertExpressionBinding = function (value) {
16281
+ var convertedPropertyBinding = convertPropertyBinding(this, this.getImplicitReceiverExpr(), value, this.bindingContext(), BindingForm.TrySimple);
16244
16282
  var valExpr = convertedPropertyBinding.currValExpr;
16245
16283
  return importExpr(Identifiers$1.bind).callFn([valExpr]);
16246
16284
  };
16247
- TemplateDefinitionBuilder.prototype.convertPropertyBinding = function (implicit, value, skipBindFn) {
16285
+ TemplateDefinitionBuilder.prototype.convertPropertyBinding = function (value, skipBindFn) {
16248
16286
  var _a;
16249
16287
  var interpolationFn = value instanceof Interpolation ? interpolate : function () { return error('Unexpected interpolation'); };
16250
- var convertedPropertyBinding = convertPropertyBinding(this, implicit, value, this.bindingContext(), BindingForm.TrySimple, interpolationFn);
16251
- (_a = this._tempVariables).push.apply(_a, __spread(convertedPropertyBinding.stmts));
16288
+ var convertedPropertyBinding = convertPropertyBinding(this, this.getImplicitReceiverExpr(), value, this.bindingContext(), BindingForm.TrySimple, interpolationFn);
16252
16289
  var valExpr = convertedPropertyBinding.currValExpr;
16290
+ (_a = this._tempVariables).push.apply(_a, __spread(convertedPropertyBinding.stmts));
16253
16291
  return value instanceof Interpolation || skipBindFn ? valExpr :
16254
16292
  importExpr(Identifiers$1.bind).callFn([valExpr]);
16255
16293
  };
@@ -16257,12 +16295,11 @@ define(['exports', 'path', 'typescript', 'fs'], function (exports, path, ts, fs)
16257
16295
  * Gets a list of argument expressions to pass to an update instruction expression. Also updates
16258
16296
  * the temp variables state with temp variables that were identified as needing to be created
16259
16297
  * while visiting the arguments.
16260
- * @param contextExpression The expression for the context variable used to create arguments
16261
16298
  * @param value The original expression we will be resolving an arguments list from.
16262
16299
  */
16263
- TemplateDefinitionBuilder.prototype.getUpdateInstructionArguments = function (contextExpression, value) {
16300
+ TemplateDefinitionBuilder.prototype.getUpdateInstructionArguments = function (value) {
16264
16301
  var _a;
16265
- var _b = convertUpdateArguments(this, contextExpression, value, this.bindingContext()), args = _b.args, stmts = _b.stmts;
16302
+ var _b = convertUpdateArguments(this, this.getImplicitReceiverExpr(), value, this.bindingContext()), args = _b.args, stmts = _b.stmts;
16266
16303
  (_a = this._tempVariables).push.apply(_a, __spread(stmts));
16267
16304
  return args;
16268
16305
  };
@@ -16381,8 +16418,7 @@ define(['exports', 'path', 'typescript', 'fs'], function (exports, path, ts, fs)
16381
16418
  sanitizeIdentifier(eventName);
16382
16419
  var handlerName = _this.templateName + "_" + tagName + "_" + bindingFnName + "_" + index + "_listener";
16383
16420
  var scope = _this._bindingScope.nestedScope(_this._bindingScope.bindingLevel);
16384
- var context = variable(CONTEXT_NAME);
16385
- return prepareEventListenerParameters(outputAst, context, handlerName, scope);
16421
+ return prepareEventListenerParameters(outputAst, handlerName, scope);
16386
16422
  };
16387
16423
  };
16388
16424
  return TemplateDefinitionBuilder;
@@ -16602,13 +16638,35 @@ define(['exports', 'path', 'typescript', 'fs'], function (exports, path, ts, fs)
16602
16638
  });
16603
16639
  return this;
16604
16640
  };
16641
+ // Implemented as part of LocalResolver.
16605
16642
  BindingScope.prototype.getLocal = function (name) { return this.get(name); };
16643
+ // Implemented as part of LocalResolver.
16644
+ BindingScope.prototype.notifyImplicitReceiverUse = function () {
16645
+ if (this.bindingLevel !== 0) {
16646
+ // Since the implicit receiver is accessed in an embedded view, we need to
16647
+ // ensure that we declare a shared context variable for the current template
16648
+ // in the update variables.
16649
+ this.map.get(SHARED_CONTEXT_KEY + 0).declare = true;
16650
+ }
16651
+ };
16606
16652
  BindingScope.prototype.nestedScope = function (level) {
16607
16653
  var newScope = new BindingScope(level, this);
16608
16654
  if (level > 0)
16609
16655
  newScope.generateSharedContextVar(0);
16610
16656
  return newScope;
16611
16657
  };
16658
+ /**
16659
+ * Gets or creates a shared context variable and returns its expression. Note that
16660
+ * this does not mean that the shared variable will be declared. Variables in the
16661
+ * binding scope will be only declared if they are used.
16662
+ */
16663
+ BindingScope.prototype.getOrCreateSharedContextVar = function (retrievalLevel) {
16664
+ var bindingKey = SHARED_CONTEXT_KEY + retrievalLevel;
16665
+ if (!this.map.has(bindingKey)) {
16666
+ this.generateSharedContextVar(retrievalLevel);
16667
+ }
16668
+ return this.map.get(bindingKey).lhs;
16669
+ };
16612
16670
  BindingScope.prototype.getSharedContextName = function (retrievalLevel) {
16613
16671
  var sharedCtxObj = this.map.get(SHARED_CONTEXT_KEY + retrievalLevel);
16614
16672
  return sharedCtxObj && sharedCtxObj.declare ? sharedCtxObj.lhs : null;
@@ -17255,7 +17313,7 @@ define(['exports', 'path', 'typescript', 'fs'], function (exports, path, ts, fs)
17255
17313
  // Calculate host event bindings
17256
17314
  var eventBindings = bindingParser.createDirectiveHostEventAsts(directiveSummary, hostBindingSourceSpan);
17257
17315
  if (eventBindings && eventBindings.length) {
17258
- var listeners = createHostListeners(bindingContext, eventBindings, meta);
17316
+ var listeners = createHostListeners(eventBindings, meta);
17259
17317
  createStatements.push.apply(createStatements, __spread(listeners));
17260
17318
  }
17261
17319
  // Calculate the host property bindings
@@ -17391,14 +17449,14 @@ define(['exports', 'path', 'typescript', 'fs'], function (exports, path, ts, fs)
17391
17449
  }
17392
17450
  return { bindingName: bindingName, instruction: instruction, isAttribute: !!attrMatches };
17393
17451
  }
17394
- function createHostListeners(bindingContext, eventBindings, meta) {
17452
+ function createHostListeners(eventBindings, meta) {
17395
17453
  return eventBindings.map(function (binding) {
17396
17454
  var bindingName = binding.name && sanitizeIdentifier(binding.name);
17397
17455
  var bindingFnName = binding.type === 1 /* Animation */ ?
17398
17456
  prepareSyntheticListenerFunctionName(bindingName, binding.targetOrPhase) :
17399
17457
  bindingName;
17400
17458
  var handlerName = meta.name && bindingName ? meta.name + "_" + bindingFnName + "_HostBindingHandler" : null;
17401
- var params = prepareEventListenerParameters(BoundEvent.fromParsedEvent(binding), bindingContext, handlerName);
17459
+ var params = prepareEventListenerParameters(BoundEvent.fromParsedEvent(binding), handlerName);
17402
17460
  var instruction = binding.type == 1 /* Animation */ ? Identifiers$1.componentHostSyntheticListener : Identifiers$1.listener;
17403
17461
  return importExpr(instruction).callFn(params).toStmt();
17404
17462
  });
@@ -17775,7 +17833,7 @@ define(['exports', 'path', 'typescript', 'fs'], function (exports, path, ts, fs)
17775
17833
  * Use of this source code is governed by an MIT-style license that can be
17776
17834
  * found in the LICENSE file at https://angular.io/license
17777
17835
  */
17778
- var VERSION$1 = new Version('8.0.0-rc.5');
17836
+ var VERSION$1 = new Version('8.0.3');
17779
17837
 
17780
17838
  /**
17781
17839
  * @license
@@ -37462,7 +37520,7 @@ define(['exports', 'path', 'typescript', 'fs'], function (exports, path, ts, fs)
37462
37520
  /**
37463
37521
  * @publicApi
37464
37522
  */
37465
- var VERSION$2 = new Version$1('8.0.0-rc.5');
37523
+ var VERSION$2 = new Version$1('8.0.3');
37466
37524
 
37467
37525
  /**
37468
37526
  * @license
@@ -40367,10 +40425,8 @@ define(['exports', 'path', 'typescript', 'fs'], function (exports, path, ts, fs)
40367
40425
  _this.ngModule = ngModule;
40368
40426
  _this.componentType = componentDef.type;
40369
40427
  _this.selector = componentDef.selectors[0][0];
40370
- // The component definition does not include the wildcard ('*') selector in its list.
40371
- // It is implicitly expected as the first item in the projectable nodes array.
40372
40428
  _this.ngContentSelectors =
40373
- componentDef.ngContentSelectors ? __spread(['*'], componentDef.ngContentSelectors) : [];
40429
+ componentDef.ngContentSelectors ? componentDef.ngContentSelectors : [];
40374
40430
  _this.isBoundToModule = !!ngModule;
40375
40431
  return _this;
40376
40432
  }
@@ -42636,7 +42692,7 @@ ${errors.map((err, i) => `${i + 1}) ${err.toString()}`).join('\n ')}` : '';
42636
42692
  var HostBinding = makePropDecorator('HostBinding', ɵ8);
42637
42693
  var ɵ9 = function (eventName, args) { return ({ eventName: eventName, args: args }); };
42638
42694
  /**
42639
- * Binds a CSS event to a host listener and supplies configuration metadata.
42695
+ * Binds a DOM event to a host listener and supplies configuration metadata.
42640
42696
  * Angular invokes the supplied handler method when the host element emits the specified event,
42641
42697
  * and updates the bound element with the result.
42642
42698
  * If the handler method returns false, applies `preventDefault` on the bound element.
@@ -47956,39 +48012,29 @@ ${errors.map((err, i) => `${i + 1}) ${err.toString()}`).join('\n ')}` : '';
47956
48012
  };
47957
48013
  proxy.getQuickInfoAtPosition = function (fileName, position) {
47958
48014
  var base = oldLS.getQuickInfoAtPosition(fileName, position);
47959
- // TODO(vicb): the tags property has been removed in TS 2.2
47960
- tryOperation('get quick info', function () {
47961
- var e_2, _a;
47962
- var ours = ls.getHoverAt(fileName, position);
47963
- if (ours) {
47964
- var displayParts = [];
47965
- try {
47966
- for (var _b = __values(ours.text), _c = _b.next(); !_c.done; _c = _b.next()) {
47967
- var part = _c.value;
47968
- displayParts.push({ kind: part.language || 'angular', text: part.text });
47969
- }
47970
- }
47971
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
47972
- finally {
47973
- try {
47974
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
47975
- }
47976
- finally { if (e_2) throw e_2.error; }
47977
- }
47978
- var tags = base && base.tags;
47979
- base = {
47980
- displayParts: displayParts,
47981
- documentation: [],
47982
- kind: 'angular',
47983
- kindModifiers: 'what does this do?',
47984
- textSpan: { start: ours.span.start, length: ours.span.end - ours.span.start },
48015
+ var ours = ls.getHoverAt(fileName, position);
48016
+ if (!ours) {
48017
+ return base;
48018
+ }
48019
+ var result = {
48020
+ kind: ts.ScriptElementKind.unknown,
48021
+ kindModifiers: ts.ScriptElementKindModifier.none,
48022
+ textSpan: {
48023
+ start: ours.span.start,
48024
+ length: ours.span.end - ours.span.start,
48025
+ },
48026
+ displayParts: ours.text.map(function (part) {
48027
+ return {
48028
+ text: part.text,
48029
+ kind: part.language || 'angular',
47985
48030
  };
47986
- if (tags) {
47987
- base.tags = tags;
47988
- }
47989
- }
47990
- });
47991
- return base;
48031
+ }),
48032
+ documentation: [],
48033
+ };
48034
+ if (base && base.tags) {
48035
+ result.tags = base.tags;
48036
+ }
48037
+ return result;
47992
48038
  };
47993
48039
  proxy.getSemanticDiagnostics = function (fileName) {
47994
48040
  var result = oldLS.getSemanticDiagnostics(fileName);
@@ -48011,7 +48057,7 @@ ${errors.map((err, i) => `${i + 1}) ${err.toString()}`).join('\n ')}` : '';
48011
48057
  return base;
48012
48058
  }
48013
48059
  return tryOperation('get definition', function () {
48014
- var e_3, _a;
48060
+ var e_2, _a;
48015
48061
  var ours = ls.getDefinitionAt(fileName, position);
48016
48062
  var combined;
48017
48063
  if (ours && ours.length) {
@@ -48030,12 +48076,12 @@ ${errors.map((err, i) => `${i + 1}) ${err.toString()}`).join('\n ')}` : '';
48030
48076
  });
48031
48077
  }
48032
48078
  }
48033
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
48079
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
48034
48080
  finally {
48035
48081
  try {
48036
48082
  if (ours_1_1 && !ours_1_1.done && (_a = ours_1.return)) _a.call(ours_1);
48037
48083
  }
48038
- finally { if (e_3) throw e_3.error; }
48084
+ finally { if (e_2) throw e_2.error; }
48039
48085
  }
48040
48086
  }
48041
48087
  else {
@@ -48054,7 +48100,7 @@ ${errors.map((err, i) => `${i + 1}) ${err.toString()}`).join('\n ')}` : '';
48054
48100
  * Use of this source code is governed by an MIT-style license that can be
48055
48101
  * found in the LICENSE file at https://angular.io/license
48056
48102
  */
48057
- var VERSION$3 = new Version$1('8.0.0-rc.5');
48103
+ var VERSION$3 = new Version$1('8.0.3');
48058
48104
 
48059
48105
  /**
48060
48106
  * @license