@angular/compiler 20.0.0-next.7 → 20.0.0-next.9

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 v20.0.0-next.7
2
+ * @license Angular v20.0.0-next.9
3
3
  * (c) 2010-2025 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -397,6 +397,15 @@ class SelectorContext {
397
397
  return result;
398
398
  }
399
399
  }
400
+ class SelectorlessMatcher {
401
+ registry;
402
+ constructor(registry) {
403
+ this.registry = registry;
404
+ }
405
+ match(name) {
406
+ return this.registry.has(name) ? this.registry.get(name) : [];
407
+ }
408
+ }
400
409
 
401
410
  // Attention:
402
411
  // This file duplicates types and values from @angular/core
@@ -928,6 +937,7 @@ var BinaryOperator;
928
937
  BinaryOperator[BinaryOperator["BiggerEquals"] = 16] = "BiggerEquals";
929
938
  BinaryOperator[BinaryOperator["NullishCoalesce"] = 17] = "NullishCoalesce";
930
939
  BinaryOperator[BinaryOperator["Exponentiation"] = 18] = "Exponentiation";
940
+ BinaryOperator[BinaryOperator["In"] = 19] = "In";
931
941
  })(BinaryOperator || (BinaryOperator = {}));
932
942
  function nullSafeIsEquivalent(base, other) {
933
943
  if (base == null || other == null) {
@@ -3835,6 +3845,9 @@ class AbstractEmitterVisitor {
3835
3845
  case BinaryOperator.NullishCoalesce:
3836
3846
  opStr = '??';
3837
3847
  break;
3848
+ case BinaryOperator.In:
3849
+ opStr = 'in';
3850
+ break;
3838
3851
  default:
3839
3852
  throw new Error(`Unknown operator ${ast.operator}`);
3840
3853
  }
@@ -12191,6 +12204,7 @@ const BINARY_OPERATORS = new Map([
12191
12204
  ['??', BinaryOperator.NullishCoalesce],
12192
12205
  ['||', BinaryOperator.Or],
12193
12206
  ['+', BinaryOperator.Plus],
12207
+ ['in', BinaryOperator.In],
12194
12208
  ]);
12195
12209
  function namespaceForKey(namespacePrefixKey) {
12196
12210
  const NAMESPACES = new Map([
@@ -18246,6 +18260,7 @@ const KEYWORDS = [
18246
18260
  'this',
18247
18261
  'typeof',
18248
18262
  'void',
18263
+ 'in',
18249
18264
  ];
18250
18265
  class Lexer {
18251
18266
  tokenize(text) {
@@ -18313,6 +18328,9 @@ class Token {
18313
18328
  isKeywordVoid() {
18314
18329
  return this.type === TokenType.Keyword && this.strValue === 'void';
18315
18330
  }
18331
+ isKeywordIn() {
18332
+ return this.type === TokenType.Keyword && this.strValue === 'in';
18333
+ }
18316
18334
  isError() {
18317
18335
  return this.type === TokenType.Error;
18318
18336
  }
@@ -19356,16 +19374,17 @@ class _ParseAST {
19356
19374
  return result;
19357
19375
  }
19358
19376
  parseRelational() {
19359
- // '<', '>', '<=', '>='
19377
+ // '<', '>', '<=', '>=', 'in'
19360
19378
  const start = this.inputIndex;
19361
19379
  let result = this.parseAdditive();
19362
- while (this.next.type == TokenType.Operator) {
19380
+ while (this.next.type == TokenType.Operator || this.next.isKeywordIn) {
19363
19381
  const operator = this.next.strValue;
19364
19382
  switch (operator) {
19365
19383
  case '<':
19366
19384
  case '>':
19367
19385
  case '<=':
19368
19386
  case '>=':
19387
+ case 'in':
19369
19388
  this.advance();
19370
19389
  const right = this.parseAdditive();
19371
19390
  result = new Binary(this.span(start), this.sourceSpan(start), operator, result, right);
@@ -19528,6 +19547,10 @@ class _ParseAST {
19528
19547
  this.advance();
19529
19548
  return new LiteralPrimitive(this.span(start), this.sourceSpan(start), false);
19530
19549
  }
19550
+ else if (this.next.isKeywordIn()) {
19551
+ this.advance();
19552
+ return new LiteralPrimitive(this.span(start), this.sourceSpan(start), 'in');
19553
+ }
19531
19554
  else if (this.next.isKeywordThis()) {
19532
19555
  this.advance();
19533
19556
  return new ThisReceiver(this.span(start), this.sourceSpan(start));
@@ -26425,6 +26448,7 @@ function ingestNodes(unit, template) {
26425
26448
  else if (node instanceof LetDeclaration$1) {
26426
26449
  ingestLetDeclaration(unit, node);
26427
26450
  }
26451
+ else if (node instanceof Component$1) ;
26428
26452
  else {
26429
26453
  throw new Error(`Unsupported template node: ${node.constructor.name}`);
26430
26454
  }
@@ -29270,6 +29294,7 @@ class HtmlAstToIvyAst {
29270
29294
  return null;
29271
29295
  }
29272
29296
  const { attributes, boundEvents, references, templateVariables, elementHasInlineTemplate, parsedProperties, templateParsedProperties, i18nAttrsMeta, } = this.prepareAttributes(component.attrs, false);
29297
+ this.validateSelectorlessReferences(references);
29273
29298
  const directives = this.extractDirectives(component);
29274
29299
  let children;
29275
29300
  if (component.attrs.find((attr) => attr.name === 'ngNonBindable')) {
@@ -29572,6 +29597,7 @@ class HtmlAstToIvyAst {
29572
29597
  continue;
29573
29598
  }
29574
29599
  const { attributes, parsedProperties, boundEvents, references, i18nAttrsMeta } = this.prepareAttributes(directive.attrs, false);
29600
+ this.validateSelectorlessReferences(references);
29575
29601
  const { bound: inputs } = this.categorizePropertyAttributes(elementName, parsedProperties, i18nAttrsMeta);
29576
29602
  for (const input of inputs) {
29577
29603
  if (input.type !== BindingType.Property && input.type !== BindingType.TwoWay) {
@@ -29655,6 +29681,23 @@ class HtmlAstToIvyAst {
29655
29681
  /* isAssignmentEvent */ true, sourceSpan, valueSpan || sourceSpan, targetMatchableAttrs, events, keySpan);
29656
29682
  addEvents(events, boundEvents);
29657
29683
  }
29684
+ validateSelectorlessReferences(references) {
29685
+ if (references.length === 0) {
29686
+ return;
29687
+ }
29688
+ const seenNames = new Set();
29689
+ for (const ref of references) {
29690
+ if (ref.value.length > 0) {
29691
+ this.reportError('Cannot specify a value for a local reference in this context', ref.valueSpan || ref.sourceSpan);
29692
+ }
29693
+ else if (seenNames.has(ref.name)) {
29694
+ this.reportError('Duplicate reference names are not allowed', ref.sourceSpan);
29695
+ }
29696
+ else {
29697
+ seenNames.add(ref.name);
29698
+ }
29699
+ }
29700
+ }
29658
29701
  reportError(message, sourceSpan, level = ParseErrorLevel.ERROR) {
29659
29702
  this.errors.push(new ParseError(sourceSpan, message, level));
29660
29703
  }
@@ -29756,6 +29799,7 @@ function parseTemplate(template, templateUrl, options = {}) {
29756
29799
  tokenizeExpansionForms: true,
29757
29800
  tokenizeBlocks: options.enableBlockSyntax ?? true,
29758
29801
  tokenizeLet: options.enableLetSyntax ?? true,
29802
+ selectorlessEnabled: options.enableSelectorless ?? false,
29759
29803
  });
29760
29804
  if (!options.alwaysAttemptHtmlToR3AstConversion &&
29761
29805
  parseResult.errors &&
@@ -30466,6 +30510,7 @@ class R3TargetBinder {
30466
30510
  }
30467
30511
  const directives = new Map();
30468
30512
  const eagerDirectives = [];
30513
+ const missingDirectives = new Set();
30469
30514
  const bindings = new Map();
30470
30515
  const references = new Map();
30471
30516
  const scopedNodeEntities = new Map();
@@ -30486,7 +30531,9 @@ class R3TargetBinder {
30486
30531
  // - bindings: Map of inputs, outputs, and attributes to the directive/element that claims
30487
30532
  // them. TODO(alxhub): handle multiple directives claiming an input/output/etc.
30488
30533
  // - references: Map of #references to their targets.
30489
- DirectiveBinder.apply(target.template, this.directiveMatcher, directives, eagerDirectives, bindings, references);
30534
+ if (this.directiveMatcher !== null) {
30535
+ DirectiveBinder.apply(target.template, this.directiveMatcher, directives, eagerDirectives, missingDirectives, bindings, references);
30536
+ }
30490
30537
  // Finally, run the TemplateBinder to bind references, variables, and other entities within the
30491
30538
  // template. This extracts all the metadata that doesn't depend on directive matching.
30492
30539
  TemplateBinder.applyWithScope(target.template, scope, expressions, symbols, nestingLevel, usedPipes, eagerPipes, deferBlocks);
@@ -30496,7 +30543,7 @@ class R3TargetBinder {
30496
30543
  if (target.host) {
30497
30544
  TemplateBinder.applyWithScope(target.host, Scope.apply(target.host), expressions, symbols, nestingLevel, usedPipes, eagerPipes, deferBlocks);
30498
30545
  }
30499
- return new R3BoundTarget(target, directives, eagerDirectives, bindings, references, expressions, symbols, nestingLevel, scopedNodeEntities, usedPipes, eagerPipes, deferBlocks);
30546
+ return new R3BoundTarget(target, directives, eagerDirectives, missingDirectives, bindings, references, expressions, symbols, nestingLevel, scopedNodeEntities, usedPipes, eagerPipes, deferBlocks);
30500
30547
  }
30501
30548
  }
30502
30549
  /**
@@ -30514,9 +30561,9 @@ class Scope {
30514
30561
  */
30515
30562
  namedEntities = new Map();
30516
30563
  /**
30517
- * Set of elements that belong to this scope.
30564
+ * Set of element-like nodes that belong to this scope.
30518
30565
  */
30519
- elementsInScope = new Set();
30566
+ elementLikeInScope = new Set();
30520
30567
  /**
30521
30568
  * Child `Scope`s for immediately nested `ScopedNode`s.
30522
30569
  */
@@ -30577,12 +30624,7 @@ class Scope {
30577
30624
  }
30578
30625
  }
30579
30626
  visitElement(element) {
30580
- element.directives.forEach((node) => node.visit(this));
30581
- // `Element`s in the template may have `Reference`s which are captured in the scope.
30582
- element.references.forEach((node) => this.visitReference(node));
30583
- // Recurse into the `Element`'s children.
30584
- element.children.forEach((node) => node.visit(this));
30585
- this.elementsInScope.add(element);
30627
+ this.visitElementLike(element);
30586
30628
  }
30587
30629
  visitTemplate(template) {
30588
30630
  template.directives.forEach((node) => node.visit(this));
@@ -30641,10 +30683,10 @@ class Scope {
30641
30683
  this.maybeDeclare(decl);
30642
30684
  }
30643
30685
  visitComponent(component) {
30644
- throw new Error('TODO');
30686
+ this.visitElementLike(component);
30645
30687
  }
30646
30688
  visitDirective(directive) {
30647
- throw new Error('TODO');
30689
+ directive.references.forEach((current) => this.visitReference(current));
30648
30690
  }
30649
30691
  // Unused visitors.
30650
30692
  visitBoundAttribute(attr) { }
@@ -30655,6 +30697,12 @@ class Scope {
30655
30697
  visitIcu(icu) { }
30656
30698
  visitDeferredTrigger(trigger) { }
30657
30699
  visitUnknownBlock(block) { }
30700
+ visitElementLike(node) {
30701
+ node.directives.forEach((current) => current.visit(this));
30702
+ node.references.forEach((current) => this.visitReference(current));
30703
+ node.children.forEach((current) => current.visit(this));
30704
+ this.elementLikeInScope.add(node);
30705
+ }
30658
30706
  maybeDeclare(thing) {
30659
30707
  // Declare something with a name, as long as that name isn't taken.
30660
30708
  if (!this.namedEntities.has(thing.name)) {
@@ -30704,17 +30752,19 @@ class Scope {
30704
30752
  * Usually used via the static `apply()` method.
30705
30753
  */
30706
30754
  class DirectiveBinder {
30707
- matcher;
30755
+ directiveMatcher;
30708
30756
  directives;
30709
30757
  eagerDirectives;
30758
+ missingDirectives;
30710
30759
  bindings;
30711
30760
  references;
30712
30761
  // Indicates whether we are visiting elements within a `defer` block
30713
30762
  isInDeferBlock = false;
30714
- constructor(matcher, directives, eagerDirectives, bindings, references) {
30715
- this.matcher = matcher;
30763
+ constructor(directiveMatcher, directives, eagerDirectives, missingDirectives, bindings, references) {
30764
+ this.directiveMatcher = directiveMatcher;
30716
30765
  this.directives = directives;
30717
30766
  this.eagerDirectives = eagerDirectives;
30767
+ this.missingDirectives = missingDirectives;
30718
30768
  this.bindings = bindings;
30719
30769
  this.references = references;
30720
30770
  }
@@ -30730,8 +30780,8 @@ class DirectiveBinder {
30730
30780
  * map which resolves #references (`Reference`s) within the template to the named directive or
30731
30781
  * template node.
30732
30782
  */
30733
- static apply(template, selectorMatcher, directives, eagerDirectives, bindings, references) {
30734
- const matcher = new DirectiveBinder(selectorMatcher, directives, eagerDirectives, bindings, references);
30783
+ static apply(template, directiveMatcher, directives, eagerDirectives, missingDirectives, bindings, references) {
30784
+ const matcher = new DirectiveBinder(directiveMatcher, directives, eagerDirectives, missingDirectives, bindings, references);
30735
30785
  matcher.ingest(template);
30736
30786
  }
30737
30787
  ingest(template) {
@@ -30743,23 +30793,113 @@ class DirectiveBinder {
30743
30793
  visitTemplate(template) {
30744
30794
  this.visitElementOrTemplate(template);
30745
30795
  }
30796
+ visitDeferredBlock(deferred) {
30797
+ const wasInDeferBlock = this.isInDeferBlock;
30798
+ this.isInDeferBlock = true;
30799
+ deferred.children.forEach((child) => child.visit(this));
30800
+ this.isInDeferBlock = wasInDeferBlock;
30801
+ deferred.placeholder?.visit(this);
30802
+ deferred.loading?.visit(this);
30803
+ deferred.error?.visit(this);
30804
+ }
30805
+ visitDeferredBlockPlaceholder(block) {
30806
+ block.children.forEach((child) => child.visit(this));
30807
+ }
30808
+ visitDeferredBlockError(block) {
30809
+ block.children.forEach((child) => child.visit(this));
30810
+ }
30811
+ visitDeferredBlockLoading(block) {
30812
+ block.children.forEach((child) => child.visit(this));
30813
+ }
30814
+ visitSwitchBlock(block) {
30815
+ block.cases.forEach((node) => node.visit(this));
30816
+ }
30817
+ visitSwitchBlockCase(block) {
30818
+ block.children.forEach((node) => node.visit(this));
30819
+ }
30820
+ visitForLoopBlock(block) {
30821
+ block.item.visit(this);
30822
+ block.contextVariables.forEach((v) => v.visit(this));
30823
+ block.children.forEach((node) => node.visit(this));
30824
+ block.empty?.visit(this);
30825
+ }
30826
+ visitForLoopBlockEmpty(block) {
30827
+ block.children.forEach((node) => node.visit(this));
30828
+ }
30829
+ visitIfBlock(block) {
30830
+ block.branches.forEach((node) => node.visit(this));
30831
+ }
30832
+ visitIfBlockBranch(block) {
30833
+ block.expressionAlias?.visit(this);
30834
+ block.children.forEach((node) => node.visit(this));
30835
+ }
30836
+ visitContent(content) {
30837
+ content.children.forEach((child) => child.visit(this));
30838
+ }
30839
+ visitComponent(node) {
30840
+ if (this.directiveMatcher instanceof SelectorlessMatcher) {
30841
+ const componentMatches = this.directiveMatcher.match(node.componentName);
30842
+ if (componentMatches.length > 0) {
30843
+ this.trackSelectorlessMatchesAndDirectives(node, componentMatches);
30844
+ }
30845
+ else {
30846
+ this.missingDirectives.add(node.componentName);
30847
+ }
30848
+ }
30849
+ node.directives.forEach((directive) => directive.visit(this));
30850
+ node.children.forEach((child) => child.visit(this));
30851
+ }
30852
+ visitDirective(node) {
30853
+ if (this.directiveMatcher instanceof SelectorlessMatcher) {
30854
+ const directives = this.directiveMatcher.match(node.name);
30855
+ if (directives.length > 0) {
30856
+ this.trackSelectorlessMatchesAndDirectives(node, directives);
30857
+ }
30858
+ else {
30859
+ this.missingDirectives.add(node.name);
30860
+ }
30861
+ }
30862
+ }
30746
30863
  visitElementOrTemplate(node) {
30747
- // First, determine the HTML shape of the node for the purpose of directive matching.
30748
- // Do this by building up a `CssSelector` for the node.
30749
- const cssSelector = createCssSelectorFromNode(node);
30750
- // TODO(crisbeto): account for selectorless directives here.
30751
- if (node.directives.length > 0) {
30752
- throw new Error('TODO');
30753
- }
30754
- // Next, use the `SelectorMatcher` to get the list of directives on the node.
30755
- const directives = [];
30756
- this.matcher.match(cssSelector, (_selector, results) => directives.push(...results));
30864
+ if (this.directiveMatcher instanceof SelectorMatcher) {
30865
+ const directives = [];
30866
+ const cssSelector = createCssSelectorFromNode(node);
30867
+ this.directiveMatcher.match(cssSelector, (_, results) => directives.push(...results));
30868
+ this.trackSelectorBasedBindingsAndDirectives(node, directives);
30869
+ }
30870
+ node.directives.forEach((directive) => directive.visit(this));
30871
+ node.children.forEach((child) => child.visit(this));
30872
+ }
30873
+ trackMatchedDirectives(node, directives) {
30757
30874
  if (directives.length > 0) {
30758
30875
  this.directives.set(node, directives);
30759
30876
  if (!this.isInDeferBlock) {
30760
30877
  this.eagerDirectives.push(...directives);
30761
30878
  }
30762
30879
  }
30880
+ }
30881
+ trackSelectorlessMatchesAndDirectives(node, directives) {
30882
+ if (directives.length === 0) {
30883
+ return;
30884
+ }
30885
+ this.trackMatchedDirectives(node, directives);
30886
+ const setBinding = (meta, attribute, ioType) => {
30887
+ if (meta[ioType].hasBindingPropertyName(attribute.name)) {
30888
+ this.bindings.set(attribute, meta);
30889
+ }
30890
+ };
30891
+ for (const directive of directives) {
30892
+ node.inputs.forEach((input) => setBinding(directive, input, 'inputs'));
30893
+ node.attributes.forEach((attr) => setBinding(directive, attr, 'inputs'));
30894
+ node.outputs.forEach((output) => setBinding(directive, output, 'outputs'));
30895
+ }
30896
+ // TODO(crisbeto): currently it's unclear how references should behave under selectorless,
30897
+ // given that there's one named class which can bring in multiple host directives.
30898
+ // For the time being only register the first directive as the reference target.
30899
+ node.references.forEach((ref) => this.references.set(ref, { directive: directives[0], node: node }));
30900
+ }
30901
+ trackSelectorBasedBindingsAndDirectives(node, directives) {
30902
+ this.trackMatchedDirectives(node, directives);
30763
30903
  // Resolve any references that are created on this node.
30764
30904
  node.references.forEach((ref) => {
30765
30905
  let dirTarget = null;
@@ -30790,6 +30930,7 @@ class DirectiveBinder {
30790
30930
  this.references.set(ref, node);
30791
30931
  }
30792
30932
  });
30933
+ // Associate attributes/bindings on the node with directives or with the node itself.
30793
30934
  const setAttributeBinding = (attribute, ioType) => {
30794
30935
  const dir = directives.find((dir) => dir[ioType].hasBindingPropertyName(attribute.name));
30795
30936
  const binding = dir !== undefined ? dir : node;
@@ -30804,57 +30945,6 @@ class DirectiveBinder {
30804
30945
  }
30805
30946
  // Node outputs (bound events) can be bound to an output on a directive.
30806
30947
  node.outputs.forEach((output) => setAttributeBinding(output, 'outputs'));
30807
- // Recurse into the node's children.
30808
- node.children.forEach((child) => child.visit(this));
30809
- }
30810
- visitDeferredBlock(deferred) {
30811
- const wasInDeferBlock = this.isInDeferBlock;
30812
- this.isInDeferBlock = true;
30813
- deferred.children.forEach((child) => child.visit(this));
30814
- this.isInDeferBlock = wasInDeferBlock;
30815
- deferred.placeholder?.visit(this);
30816
- deferred.loading?.visit(this);
30817
- deferred.error?.visit(this);
30818
- }
30819
- visitDeferredBlockPlaceholder(block) {
30820
- block.children.forEach((child) => child.visit(this));
30821
- }
30822
- visitDeferredBlockError(block) {
30823
- block.children.forEach((child) => child.visit(this));
30824
- }
30825
- visitDeferredBlockLoading(block) {
30826
- block.children.forEach((child) => child.visit(this));
30827
- }
30828
- visitSwitchBlock(block) {
30829
- block.cases.forEach((node) => node.visit(this));
30830
- }
30831
- visitSwitchBlockCase(block) {
30832
- block.children.forEach((node) => node.visit(this));
30833
- }
30834
- visitForLoopBlock(block) {
30835
- block.item.visit(this);
30836
- block.contextVariables.forEach((v) => v.visit(this));
30837
- block.children.forEach((node) => node.visit(this));
30838
- block.empty?.visit(this);
30839
- }
30840
- visitForLoopBlockEmpty(block) {
30841
- block.children.forEach((node) => node.visit(this));
30842
- }
30843
- visitIfBlock(block) {
30844
- block.branches.forEach((node) => node.visit(this));
30845
- }
30846
- visitIfBlockBranch(block) {
30847
- block.expressionAlias?.visit(this);
30848
- block.children.forEach((node) => node.visit(this));
30849
- }
30850
- visitContent(content) {
30851
- content.children.forEach((child) => child.visit(this));
30852
- }
30853
- visitComponent(component) {
30854
- throw new Error('TODO');
30855
- }
30856
- visitDirective(directive) {
30857
- throw new Error('TODO');
30858
30948
  }
30859
30949
  // Unused visitors.
30860
30950
  visitVariable(variable) { }
@@ -31013,10 +31103,16 @@ class TemplateBinder extends RecursiveAstVisitor {
31013
31103
  }
31014
31104
  }
31015
31105
  visitComponent(component) {
31016
- throw new Error('TODO');
31106
+ component.inputs.forEach(this.visitNode);
31107
+ component.outputs.forEach(this.visitNode);
31108
+ component.directives.forEach(this.visitNode);
31109
+ component.children.forEach(this.visitNode);
31110
+ component.references.forEach(this.visitNode);
31017
31111
  }
31018
31112
  visitDirective(directive) {
31019
- throw new Error('TODO');
31113
+ directive.inputs.forEach(this.visitNode);
31114
+ directive.outputs.forEach(this.visitNode);
31115
+ directive.references.forEach(this.visitNode);
31020
31116
  }
31021
31117
  // Unused template visitors
31022
31118
  visitText(text) { }
@@ -31137,6 +31233,7 @@ class R3BoundTarget {
31137
31233
  target;
31138
31234
  directives;
31139
31235
  eagerDirectives;
31236
+ missingDirectives;
31140
31237
  bindings;
31141
31238
  references;
31142
31239
  exprTargets;
@@ -31149,10 +31246,11 @@ class R3BoundTarget {
31149
31246
  deferredBlocks;
31150
31247
  /** Map of deferred blocks to their scope. */
31151
31248
  deferredScopes;
31152
- constructor(target, directives, eagerDirectives, bindings, references, exprTargets, symbols, nestingLevel, scopedNodeEntities, usedPipes, eagerPipes, rawDeferred) {
31249
+ constructor(target, directives, eagerDirectives, missingDirectives, bindings, references, exprTargets, symbols, nestingLevel, scopedNodeEntities, usedPipes, eagerPipes, rawDeferred) {
31153
31250
  this.target = target;
31154
31251
  this.directives = directives;
31155
31252
  this.eagerDirectives = eagerDirectives;
31253
+ this.missingDirectives = missingDirectives;
31156
31254
  this.bindings = bindings;
31157
31255
  this.references = references;
31158
31256
  this.exprTargets = exprTargets;
@@ -31260,7 +31358,7 @@ class R3BoundTarget {
31260
31358
  const stack = [this.deferredScopes.get(block)];
31261
31359
  while (stack.length > 0) {
31262
31360
  const current = stack.pop();
31263
- if (current.elementsInScope.has(element)) {
31361
+ if (current.elementLikeInScope.has(element)) {
31264
31362
  return true;
31265
31363
  }
31266
31364
  stack.push(...current.childScopes.values());
@@ -31268,6 +31366,9 @@ class R3BoundTarget {
31268
31366
  }
31269
31367
  return false;
31270
31368
  }
31369
+ referencedDirectiveExists(name) {
31370
+ return !this.missingDirectives.has(name);
31371
+ }
31271
31372
  /**
31272
31373
  * Finds an entity with a specific name in a scope.
31273
31374
  * @param rootNode Root node of the scope.
@@ -31287,7 +31388,9 @@ class R3BoundTarget {
31287
31388
  if (target instanceof Element$1) {
31288
31389
  return target;
31289
31390
  }
31290
- if (target instanceof Template) {
31391
+ if (target instanceof Template ||
31392
+ target.node instanceof Component$1 ||
31393
+ target.node instanceof Directive$1) {
31291
31394
  return null;
31292
31395
  }
31293
31396
  return this.referenceTargetToElement(target.node);
@@ -31768,7 +31871,7 @@ function parseJitTemplate(template, typeName, sourceMapUrl, preserveWhitespaces,
31768
31871
  const errors = parsed.errors.map((err) => err.toString()).join(', ');
31769
31872
  throw new Error(`Errors during JIT compilation of template for ${typeName}: ${errors}`);
31770
31873
  }
31771
- const binder = new R3TargetBinder(new SelectorMatcher());
31874
+ const binder = new R3TargetBinder(null);
31772
31875
  const boundTarget = binder.bind({ template: parsed.nodes });
31773
31876
  return {
31774
31877
  template: parsed,
@@ -33767,7 +33870,7 @@ const MINIMUM_PARTIAL_LINKER_DEFER_SUPPORT_VERSION = '18.0.0';
33767
33870
  function compileDeclareClassMetadata(metadata) {
33768
33871
  const definitionMap = new DefinitionMap();
33769
33872
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$5));
33770
- definitionMap.set('version', literal('20.0.0-next.7'));
33873
+ definitionMap.set('version', literal('20.0.0-next.9'));
33771
33874
  definitionMap.set('ngImport', importExpr(Identifiers.core));
33772
33875
  definitionMap.set('type', metadata.type);
33773
33876
  definitionMap.set('decorators', metadata.decorators);
@@ -33785,7 +33888,7 @@ function compileComponentDeclareClassMetadata(metadata, dependencies) {
33785
33888
  callbackReturnDefinitionMap.set('ctorParameters', metadata.ctorParameters ?? literal(null));
33786
33889
  callbackReturnDefinitionMap.set('propDecorators', metadata.propDecorators ?? literal(null));
33787
33890
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_DEFER_SUPPORT_VERSION));
33788
- definitionMap.set('version', literal('20.0.0-next.7'));
33891
+ definitionMap.set('version', literal('20.0.0-next.9'));
33789
33892
  definitionMap.set('ngImport', importExpr(Identifiers.core));
33790
33893
  definitionMap.set('type', metadata.type);
33791
33894
  definitionMap.set('resolveDeferredDeps', compileComponentMetadataAsyncResolver(dependencies));
@@ -33880,7 +33983,7 @@ function createDirectiveDefinitionMap(meta) {
33880
33983
  const definitionMap = new DefinitionMap();
33881
33984
  const minVersion = getMinimumVersionForPartialOutput(meta);
33882
33985
  definitionMap.set('minVersion', literal(minVersion));
33883
- definitionMap.set('version', literal('20.0.0-next.7'));
33986
+ definitionMap.set('version', literal('20.0.0-next.9'));
33884
33987
  // e.g. `type: MyDirective`
33885
33988
  definitionMap.set('type', meta.type.value);
33886
33989
  if (meta.isStandalone !== undefined) {
@@ -34296,7 +34399,7 @@ const MINIMUM_PARTIAL_LINKER_VERSION$4 = '12.0.0';
34296
34399
  function compileDeclareFactoryFunction(meta) {
34297
34400
  const definitionMap = new DefinitionMap();
34298
34401
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$4));
34299
- definitionMap.set('version', literal('20.0.0-next.7'));
34402
+ definitionMap.set('version', literal('20.0.0-next.9'));
34300
34403
  definitionMap.set('ngImport', importExpr(Identifiers.core));
34301
34404
  definitionMap.set('type', meta.type.value);
34302
34405
  definitionMap.set('deps', compileDependencies(meta.deps));
@@ -34331,7 +34434,7 @@ function compileDeclareInjectableFromMetadata(meta) {
34331
34434
  function createInjectableDefinitionMap(meta) {
34332
34435
  const definitionMap = new DefinitionMap();
34333
34436
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$3));
34334
- definitionMap.set('version', literal('20.0.0-next.7'));
34437
+ definitionMap.set('version', literal('20.0.0-next.9'));
34335
34438
  definitionMap.set('ngImport', importExpr(Identifiers.core));
34336
34439
  definitionMap.set('type', meta.type.value);
34337
34440
  // Only generate providedIn property if it has a non-null value
@@ -34382,7 +34485,7 @@ function compileDeclareInjectorFromMetadata(meta) {
34382
34485
  function createInjectorDefinitionMap(meta) {
34383
34486
  const definitionMap = new DefinitionMap();
34384
34487
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$2));
34385
- definitionMap.set('version', literal('20.0.0-next.7'));
34488
+ definitionMap.set('version', literal('20.0.0-next.9'));
34386
34489
  definitionMap.set('ngImport', importExpr(Identifiers.core));
34387
34490
  definitionMap.set('type', meta.type.value);
34388
34491
  definitionMap.set('providers', meta.providers);
@@ -34415,7 +34518,7 @@ function createNgModuleDefinitionMap(meta) {
34415
34518
  throw new Error('Invalid path! Local compilation mode should not get into the partial compilation path');
34416
34519
  }
34417
34520
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$1));
34418
- definitionMap.set('version', literal('20.0.0-next.7'));
34521
+ definitionMap.set('version', literal('20.0.0-next.9'));
34419
34522
  definitionMap.set('ngImport', importExpr(Identifiers.core));
34420
34523
  definitionMap.set('type', meta.type.value);
34421
34524
  // We only generate the keys in the metadata if the arrays contain values.
@@ -34466,7 +34569,7 @@ function compileDeclarePipeFromMetadata(meta) {
34466
34569
  function createPipeDefinitionMap(meta) {
34467
34570
  const definitionMap = new DefinitionMap();
34468
34571
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION));
34469
- definitionMap.set('version', literal('20.0.0-next.7'));
34572
+ definitionMap.set('version', literal('20.0.0-next.9'));
34470
34573
  definitionMap.set('ngImport', importExpr(Identifiers.core));
34471
34574
  // e.g. `type: MyPipe`
34472
34575
  definitionMap.set('type', meta.type.value);
@@ -34624,7 +34727,7 @@ function compileHmrUpdateCallback(definitions, constantStatements, meta) {
34624
34727
  * @description
34625
34728
  * Entry point for all public APIs of the compiler package.
34626
34729
  */
34627
- const VERSION = new Version('20.0.0-next.7');
34730
+ const VERSION = new Version('20.0.0-next.9');
34628
34731
 
34629
34732
  //////////////////////////////////////
34630
34733
  // THIS FILE HAS GLOBAL SIDE EFFECT //
@@ -34650,5 +34753,5 @@ const VERSION = new Version('20.0.0-next.7');
34650
34753
  // the late binding of the Compiler to the @angular/core for jit compilation.
34651
34754
  publishFacade(_global);
34652
34755
 
34653
- export { AST, ASTWithName, ASTWithSource, AbsoluteSourceSpan, ArrayType, ArrowFunctionExpr, Attribute, Binary, BinaryOperator, BinaryOperatorExpr, BindingPipe, BindingType, Block, BlockParameter, BoundElementProperty, BuiltinType, BuiltinTypeName, CUSTOM_ELEMENTS_SCHEMA, Call, Chain, ChangeDetectionStrategy, CommaExpr, Comment, CompilerConfig, Component, Conditional, ConditionalExpr, ConstantPool, CssSelector, DEFAULT_INTERPOLATION_CONFIG, DYNAMIC_TYPE, DeclareFunctionStmt, DeclareVarStmt, Directive, DomElementSchemaRegistry, DynamicImportExpr, EOF, Element, ElementSchemaRegistry, EmitterVisitorContext, EmptyExpr$1 as EmptyExpr, Expansion, ExpansionCase, Expression, ExpressionBinding, ExpressionStatement, ExpressionType, ExternalExpr, ExternalReference, FactoryTarget$1 as FactoryTarget, FunctionExpr, HtmlParser, HtmlTagDefinition, I18NHtmlParser, IfStmt, ImplicitReceiver, InstantiateExpr, Interpolation$1 as Interpolation, InterpolationConfig, InvokeFunctionExpr, JSDocComment, JitEvaluator, KeyedRead, KeyedWrite, LeadingComment, LetDeclaration, Lexer, LiteralArray, LiteralArrayExpr, LiteralExpr, LiteralMap, LiteralMapExpr, LiteralPrimitive, LocalizedString, MapType, MessageBundle, NONE_TYPE, NO_ERRORS_SCHEMA, NodeWithI18n, NonNullAssert, NotExpr, ParenthesizedExpr, ParenthesizedExpression, ParseError, ParseErrorLevel, ParseLocation, ParseSourceFile, ParseSourceSpan, ParseSpan, ParseTreeResult, ParsedEvent, ParsedEventType, ParsedProperty, ParsedPropertyType, ParsedVariable, Parser, ParserError, PrefixNot, PropertyRead, PropertyWrite, Identifiers as R3Identifiers, R3NgModuleMetadataKind, R3SelectorScopeMode, R3TargetBinder, R3TemplateDependencyKind, ReadKeyExpr, ReadPropExpr, ReadVarExpr, RecursiveAstVisitor, RecursiveVisitor, ResourceLoader, ReturnStatement, STRING_TYPE, SafeCall, SafeKeyedRead, SafePropertyRead, SelectorContext, SelectorListContext, SelectorMatcher, Serializer, SplitInterpolation, Statement, StmtModifier, StringToken, StringTokenKind, TagContentType, TaggedTemplateLiteral, TaggedTemplateLiteralExpr, TemplateBindingParseResult, TemplateLiteral, TemplateLiteralElement, TemplateLiteralElementExpr, TemplateLiteralExpr, Text, ThisReceiver, BlockNode as TmplAstBlockNode, BoundAttribute as TmplAstBoundAttribute, BoundDeferredTrigger as TmplAstBoundDeferredTrigger, BoundEvent as TmplAstBoundEvent, BoundText as TmplAstBoundText, Component$1 as TmplAstComponent, Content as TmplAstContent, DeferredBlock as TmplAstDeferredBlock, DeferredBlockError as TmplAstDeferredBlockError, DeferredBlockLoading as TmplAstDeferredBlockLoading, DeferredBlockPlaceholder as TmplAstDeferredBlockPlaceholder, DeferredTrigger as TmplAstDeferredTrigger, Directive$1 as TmplAstDirective, Element$1 as TmplAstElement, ForLoopBlock as TmplAstForLoopBlock, ForLoopBlockEmpty as TmplAstForLoopBlockEmpty, HostElement as TmplAstHostElement, HoverDeferredTrigger as TmplAstHoverDeferredTrigger, Icu$1 as TmplAstIcu, IdleDeferredTrigger as TmplAstIdleDeferredTrigger, IfBlock as TmplAstIfBlock, IfBlockBranch as TmplAstIfBlockBranch, ImmediateDeferredTrigger as TmplAstImmediateDeferredTrigger, InteractionDeferredTrigger as TmplAstInteractionDeferredTrigger, LetDeclaration$1 as TmplAstLetDeclaration, NeverDeferredTrigger as TmplAstNeverDeferredTrigger, RecursiveVisitor$1 as TmplAstRecursiveVisitor, Reference as TmplAstReference, SwitchBlock as TmplAstSwitchBlock, SwitchBlockCase as TmplAstSwitchBlockCase, Template as TmplAstTemplate, Text$3 as TmplAstText, TextAttribute as TmplAstTextAttribute, TimerDeferredTrigger as TmplAstTimerDeferredTrigger, UnknownBlock as TmplAstUnknownBlock, Variable as TmplAstVariable, ViewportDeferredTrigger as TmplAstViewportDeferredTrigger, Token, TokenType, TransplantedType, TreeError, Type, TypeModifier, TypeofExpr, TypeofExpression, Unary, UnaryOperator, UnaryOperatorExpr, VERSION, VariableBinding, Version, ViewEncapsulation, VoidExpr, VoidExpression, WrappedNodeExpr, WriteKeyExpr, WritePropExpr, WriteVarExpr, Xliff, Xliff2, Xmb, XmlParser, Xtb, compileClassDebugInfo, compileClassMetadata, compileComponentClassMetadata, compileComponentDeclareClassMetadata, compileComponentFromMetadata, compileDeclareClassMetadata, compileDeclareComponentFromMetadata, compileDeclareDirectiveFromMetadata, compileDeclareFactoryFunction, compileDeclareInjectableFromMetadata, compileDeclareInjectorFromMetadata, compileDeclareNgModuleFromMetadata, compileDeclarePipeFromMetadata, compileDeferResolverFunction, compileDirectiveFromMetadata, compileFactoryFunction, compileHmrInitializer, compileHmrUpdateCallback, compileInjectable, compileInjector, compileNgModule, compileOpaqueAsyncClassMetadata, compilePipeFromMetadata, computeMsgId, core, createCssSelectorFromNode, createInjectableType, createMayBeForwardRefExpression, devOnlyGuardedExpression, emitDistinctChangesOnlyDefaultValue, encapsulateStyle, findMatchingDirectivesAndPipes, getHtmlTagDefinition, getNsPrefix, getSafePropertyAccessString, identifierName, isNgContainer, isNgContent, isNgTemplate, jsDocComment, leadingComment, literal, literalMap, makeBindingParser, mergeNsAndName, output_ast as outputAst, parseHostBindings, parseTemplate, preserveWhitespacesDefault, publishFacade, r3JitTypeSourceSpan, sanitizeIdentifier, splitNsName, visitAll$1 as tmplAstVisitAll, verifyHostBindings, visitAll };
34756
+ export { AST, ASTWithName, ASTWithSource, AbsoluteSourceSpan, ArrayType, ArrowFunctionExpr, Attribute, Binary, BinaryOperator, BinaryOperatorExpr, BindingPipe, BindingType, Block, BlockParameter, BoundElementProperty, BuiltinType, BuiltinTypeName, CUSTOM_ELEMENTS_SCHEMA, Call, Chain, ChangeDetectionStrategy, CommaExpr, Comment, CompilerConfig, Component, Conditional, ConditionalExpr, ConstantPool, CssSelector, DEFAULT_INTERPOLATION_CONFIG, DYNAMIC_TYPE, DeclareFunctionStmt, DeclareVarStmt, Directive, DomElementSchemaRegistry, DynamicImportExpr, EOF, Element, ElementSchemaRegistry, EmitterVisitorContext, EmptyExpr$1 as EmptyExpr, Expansion, ExpansionCase, Expression, ExpressionBinding, ExpressionStatement, ExpressionType, ExternalExpr, ExternalReference, FactoryTarget$1 as FactoryTarget, FunctionExpr, HtmlParser, HtmlTagDefinition, I18NHtmlParser, IfStmt, ImplicitReceiver, InstantiateExpr, Interpolation$1 as Interpolation, InterpolationConfig, InvokeFunctionExpr, JSDocComment, JitEvaluator, KeyedRead, KeyedWrite, LeadingComment, LetDeclaration, Lexer, LiteralArray, LiteralArrayExpr, LiteralExpr, LiteralMap, LiteralMapExpr, LiteralPrimitive, LocalizedString, MapType, MessageBundle, NONE_TYPE, NO_ERRORS_SCHEMA, NodeWithI18n, NonNullAssert, NotExpr, ParenthesizedExpr, ParenthesizedExpression, ParseError, ParseErrorLevel, ParseLocation, ParseSourceFile, ParseSourceSpan, ParseSpan, ParseTreeResult, ParsedEvent, ParsedEventType, ParsedProperty, ParsedPropertyType, ParsedVariable, Parser, ParserError, PrefixNot, PropertyRead, PropertyWrite, Identifiers as R3Identifiers, R3NgModuleMetadataKind, R3SelectorScopeMode, R3TargetBinder, R3TemplateDependencyKind, ReadKeyExpr, ReadPropExpr, ReadVarExpr, RecursiveAstVisitor, RecursiveVisitor, ResourceLoader, ReturnStatement, STRING_TYPE, SafeCall, SafeKeyedRead, SafePropertyRead, SelectorContext, SelectorListContext, SelectorMatcher, SelectorlessMatcher, Serializer, SplitInterpolation, Statement, StmtModifier, StringToken, StringTokenKind, TagContentType, TaggedTemplateLiteral, TaggedTemplateLiteralExpr, TemplateBindingParseResult, TemplateLiteral, TemplateLiteralElement, TemplateLiteralElementExpr, TemplateLiteralExpr, Text, ThisReceiver, BlockNode as TmplAstBlockNode, BoundAttribute as TmplAstBoundAttribute, BoundDeferredTrigger as TmplAstBoundDeferredTrigger, BoundEvent as TmplAstBoundEvent, BoundText as TmplAstBoundText, Component$1 as TmplAstComponent, Content as TmplAstContent, DeferredBlock as TmplAstDeferredBlock, DeferredBlockError as TmplAstDeferredBlockError, DeferredBlockLoading as TmplAstDeferredBlockLoading, DeferredBlockPlaceholder as TmplAstDeferredBlockPlaceholder, DeferredTrigger as TmplAstDeferredTrigger, Directive$1 as TmplAstDirective, Element$1 as TmplAstElement, ForLoopBlock as TmplAstForLoopBlock, ForLoopBlockEmpty as TmplAstForLoopBlockEmpty, HostElement as TmplAstHostElement, HoverDeferredTrigger as TmplAstHoverDeferredTrigger, Icu$1 as TmplAstIcu, IdleDeferredTrigger as TmplAstIdleDeferredTrigger, IfBlock as TmplAstIfBlock, IfBlockBranch as TmplAstIfBlockBranch, ImmediateDeferredTrigger as TmplAstImmediateDeferredTrigger, InteractionDeferredTrigger as TmplAstInteractionDeferredTrigger, LetDeclaration$1 as TmplAstLetDeclaration, NeverDeferredTrigger as TmplAstNeverDeferredTrigger, RecursiveVisitor$1 as TmplAstRecursiveVisitor, Reference as TmplAstReference, SwitchBlock as TmplAstSwitchBlock, SwitchBlockCase as TmplAstSwitchBlockCase, Template as TmplAstTemplate, Text$3 as TmplAstText, TextAttribute as TmplAstTextAttribute, TimerDeferredTrigger as TmplAstTimerDeferredTrigger, UnknownBlock as TmplAstUnknownBlock, Variable as TmplAstVariable, ViewportDeferredTrigger as TmplAstViewportDeferredTrigger, Token, TokenType, TransplantedType, TreeError, Type, TypeModifier, TypeofExpr, TypeofExpression, Unary, UnaryOperator, UnaryOperatorExpr, VERSION, VariableBinding, Version, ViewEncapsulation, VoidExpr, VoidExpression, WrappedNodeExpr, WriteKeyExpr, WritePropExpr, WriteVarExpr, Xliff, Xliff2, Xmb, XmlParser, Xtb, compileClassDebugInfo, compileClassMetadata, compileComponentClassMetadata, compileComponentDeclareClassMetadata, compileComponentFromMetadata, compileDeclareClassMetadata, compileDeclareComponentFromMetadata, compileDeclareDirectiveFromMetadata, compileDeclareFactoryFunction, compileDeclareInjectableFromMetadata, compileDeclareInjectorFromMetadata, compileDeclareNgModuleFromMetadata, compileDeclarePipeFromMetadata, compileDeferResolverFunction, compileDirectiveFromMetadata, compileFactoryFunction, compileHmrInitializer, compileHmrUpdateCallback, compileInjectable, compileInjector, compileNgModule, compileOpaqueAsyncClassMetadata, compilePipeFromMetadata, computeMsgId, core, createCssSelectorFromNode, createInjectableType, createMayBeForwardRefExpression, devOnlyGuardedExpression, emitDistinctChangesOnlyDefaultValue, encapsulateStyle, findMatchingDirectivesAndPipes, getHtmlTagDefinition, getNsPrefix, getSafePropertyAccessString, identifierName, isNgContainer, isNgContent, isNgTemplate, jsDocComment, leadingComment, literal, literalMap, makeBindingParser, mergeNsAndName, output_ast as outputAst, parseHostBindings, parseTemplate, preserveWhitespacesDefault, publishFacade, r3JitTypeSourceSpan, sanitizeIdentifier, splitNsName, visitAll$1 as tmplAstVisitAll, verifyHostBindings, visitAll };
34654
34757
  //# sourceMappingURL=compiler.mjs.map