@angular/compiler 20.0.0-next.8 → 20.0.0-rc.0

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.8
2
+ * @license Angular v20.0.0-rc.0
3
3
  * (c) 2010-2025 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -403,7 +403,7 @@ class SelectorlessMatcher {
403
403
  this.registry = registry;
404
404
  }
405
405
  match(name) {
406
- return this.registry.get(name) ?? null;
406
+ return this.registry.has(name) ? this.registry.get(name) : [];
407
407
  }
408
408
  }
409
409
 
@@ -3218,28 +3218,26 @@ function stringify(token) {
3218
3218
  return token;
3219
3219
  }
3220
3220
  if (Array.isArray(token)) {
3221
- return '[' + token.map(stringify).join(', ') + ']';
3221
+ return `[${token.map(stringify).join(', ')}]`;
3222
3222
  }
3223
3223
  if (token == null) {
3224
3224
  return '' + token;
3225
3225
  }
3226
- if (token.overriddenName) {
3227
- return `${token.overriddenName}`;
3228
- }
3229
- if (token.name) {
3230
- return `${token.name}`;
3226
+ const name = token.overriddenName || token.name;
3227
+ if (name) {
3228
+ return `${name}`;
3231
3229
  }
3232
3230
  if (!token.toString) {
3233
3231
  return 'object';
3234
3232
  }
3235
3233
  // WARNING: do not try to `JSON.stringify(token)` here
3236
3234
  // see https://github.com/angular/angular/issues/23440
3237
- const res = token.toString();
3238
- if (res == null) {
3239
- return '' + res;
3235
+ const result = token.toString();
3236
+ if (result == null) {
3237
+ return '' + result;
3240
3238
  }
3241
- const newLineIndex = res.indexOf('\n');
3242
- return newLineIndex === -1 ? res : res.substring(0, newLineIndex);
3239
+ const newLineIndex = result.indexOf('\n');
3240
+ return newLineIndex >= 0 ? result.slice(0, newLineIndex) : result;
3243
3241
  }
3244
3242
  class Version {
3245
3243
  full;
@@ -26448,6 +26446,7 @@ function ingestNodes(unit, template) {
26448
26446
  else if (node instanceof LetDeclaration$1) {
26449
26447
  ingestLetDeclaration(unit, node);
26450
26448
  }
26449
+ else if (node instanceof Component$1) ;
26451
26450
  else {
26452
26451
  throw new Error(`Unsupported template node: ${node.constructor.name}`);
26453
26452
  }
@@ -30509,6 +30508,7 @@ class R3TargetBinder {
30509
30508
  }
30510
30509
  const directives = new Map();
30511
30510
  const eagerDirectives = [];
30511
+ const missingDirectives = new Set();
30512
30512
  const bindings = new Map();
30513
30513
  const references = new Map();
30514
30514
  const scopedNodeEntities = new Map();
@@ -30529,7 +30529,9 @@ class R3TargetBinder {
30529
30529
  // - bindings: Map of inputs, outputs, and attributes to the directive/element that claims
30530
30530
  // them. TODO(alxhub): handle multiple directives claiming an input/output/etc.
30531
30531
  // - references: Map of #references to their targets.
30532
- DirectiveBinder.apply(target.template, this.directiveMatcher, directives, eagerDirectives, bindings, references);
30532
+ if (this.directiveMatcher !== null) {
30533
+ DirectiveBinder.apply(target.template, this.directiveMatcher, directives, eagerDirectives, missingDirectives, bindings, references);
30534
+ }
30533
30535
  // Finally, run the TemplateBinder to bind references, variables, and other entities within the
30534
30536
  // template. This extracts all the metadata that doesn't depend on directive matching.
30535
30537
  TemplateBinder.applyWithScope(target.template, scope, expressions, symbols, nestingLevel, usedPipes, eagerPipes, deferBlocks);
@@ -30539,7 +30541,7 @@ class R3TargetBinder {
30539
30541
  if (target.host) {
30540
30542
  TemplateBinder.applyWithScope(target.host, Scope.apply(target.host), expressions, symbols, nestingLevel, usedPipes, eagerPipes, deferBlocks);
30541
30543
  }
30542
- return new R3BoundTarget(target, directives, eagerDirectives, bindings, references, expressions, symbols, nestingLevel, scopedNodeEntities, usedPipes, eagerPipes, deferBlocks);
30544
+ return new R3BoundTarget(target, directives, eagerDirectives, missingDirectives, bindings, references, expressions, symbols, nestingLevel, scopedNodeEntities, usedPipes, eagerPipes, deferBlocks);
30543
30545
  }
30544
30546
  }
30545
30547
  /**
@@ -30751,14 +30753,16 @@ class DirectiveBinder {
30751
30753
  directiveMatcher;
30752
30754
  directives;
30753
30755
  eagerDirectives;
30756
+ missingDirectives;
30754
30757
  bindings;
30755
30758
  references;
30756
30759
  // Indicates whether we are visiting elements within a `defer` block
30757
30760
  isInDeferBlock = false;
30758
- constructor(directiveMatcher, directives, eagerDirectives, bindings, references) {
30761
+ constructor(directiveMatcher, directives, eagerDirectives, missingDirectives, bindings, references) {
30759
30762
  this.directiveMatcher = directiveMatcher;
30760
30763
  this.directives = directives;
30761
30764
  this.eagerDirectives = eagerDirectives;
30765
+ this.missingDirectives = missingDirectives;
30762
30766
  this.bindings = bindings;
30763
30767
  this.references = references;
30764
30768
  }
@@ -30774,8 +30778,8 @@ class DirectiveBinder {
30774
30778
  * map which resolves #references (`Reference`s) within the template to the named directive or
30775
30779
  * template node.
30776
30780
  */
30777
- static apply(template, directiveMatcher, directives, eagerDirectives, bindings, references) {
30778
- const matcher = new DirectiveBinder(directiveMatcher, directives, eagerDirectives, bindings, references);
30781
+ static apply(template, directiveMatcher, directives, eagerDirectives, missingDirectives, bindings, references) {
30782
+ const matcher = new DirectiveBinder(directiveMatcher, directives, eagerDirectives, missingDirectives, bindings, references);
30779
30783
  matcher.ingest(template);
30780
30784
  }
30781
30785
  ingest(template) {
@@ -30831,55 +30835,36 @@ class DirectiveBinder {
30831
30835
  content.children.forEach((child) => child.visit(this));
30832
30836
  }
30833
30837
  visitComponent(node) {
30834
- const directives = [];
30835
- let componentMetas = null;
30836
30838
  if (this.directiveMatcher instanceof SelectorlessMatcher) {
30837
- componentMetas = this.directiveMatcher.match(node.componentName);
30838
- if (componentMetas !== null) {
30839
- directives.push(...componentMetas);
30839
+ const componentMatches = this.directiveMatcher.match(node.componentName);
30840
+ if (componentMatches.length > 0) {
30841
+ this.trackSelectorlessMatchesAndDirectives(node, componentMatches);
30840
30842
  }
30841
- for (const directive of node.directives) {
30842
- const directiveMetas = this.directiveMatcher.match(directive.name);
30843
- if (directiveMetas !== null) {
30844
- directives.push(...directiveMetas);
30845
- }
30843
+ else {
30844
+ this.missingDirectives.add(node.componentName);
30846
30845
  }
30847
30846
  }
30848
- this.trackMatchedDirectives(node, directives);
30849
- if (componentMetas !== null) {
30850
- this.trackSelectorlessBindings(node, componentMetas);
30851
- }
30852
30847
  node.directives.forEach((directive) => directive.visit(this));
30853
30848
  node.children.forEach((child) => child.visit(this));
30854
30849
  }
30855
30850
  visitDirective(node) {
30856
- const directives = this.directiveMatcher instanceof SelectorlessMatcher
30857
- ? this.directiveMatcher.match(node.name)
30858
- : null;
30859
- if (directives !== null) {
30860
- this.trackSelectorlessBindings(node, directives);
30851
+ if (this.directiveMatcher instanceof SelectorlessMatcher) {
30852
+ const directives = this.directiveMatcher.match(node.name);
30853
+ if (directives.length > 0) {
30854
+ this.trackSelectorlessMatchesAndDirectives(node, directives);
30855
+ }
30856
+ else {
30857
+ this.missingDirectives.add(node.name);
30858
+ }
30861
30859
  }
30862
30860
  }
30863
30861
  visitElementOrTemplate(node) {
30864
- const directives = [];
30865
30862
  if (this.directiveMatcher instanceof SelectorMatcher) {
30866
- // First, determine the HTML shape of the node for the purpose of directive matching.
30867
- // Do this by building up a `CssSelector` for the node.
30863
+ const directives = [];
30868
30864
  const cssSelector = createCssSelectorFromNode(node);
30869
- this.directiveMatcher.match(cssSelector, (_selector, results) => {
30870
- directives.push(...results);
30871
- });
30872
- this.trackSelectorMatchedBindings(node, directives);
30873
- }
30874
- else {
30875
- for (const directive of node.directives) {
30876
- const matchedDirectives = this.directiveMatcher.match(directive.name);
30877
- if (matchedDirectives !== null) {
30878
- directives.push(...matchedDirectives);
30879
- }
30880
- }
30865
+ this.directiveMatcher.match(cssSelector, (_, results) => directives.push(...results));
30866
+ this.trackSelectorBasedBindingsAndDirectives(node, directives);
30881
30867
  }
30882
- this.trackMatchedDirectives(node, directives);
30883
30868
  node.directives.forEach((directive) => directive.visit(this));
30884
30869
  node.children.forEach((child) => child.visit(this));
30885
30870
  }
@@ -30891,25 +30876,28 @@ class DirectiveBinder {
30891
30876
  }
30892
30877
  }
30893
30878
  }
30894
- trackSelectorlessBindings(node, metas) {
30879
+ trackSelectorlessMatchesAndDirectives(node, directives) {
30880
+ if (directives.length === 0) {
30881
+ return;
30882
+ }
30883
+ this.trackMatchedDirectives(node, directives);
30895
30884
  const setBinding = (meta, attribute, ioType) => {
30896
30885
  if (meta[ioType].hasBindingPropertyName(attribute.name)) {
30897
30886
  this.bindings.set(attribute, meta);
30898
30887
  }
30899
30888
  };
30900
- for (const meta of metas) {
30901
- node.inputs.forEach((input) => setBinding(meta, input, 'inputs'));
30902
- node.attributes.forEach((attr) => setBinding(meta, attr, 'inputs'));
30903
- node.outputs.forEach((output) => setBinding(meta, output, 'outputs'));
30889
+ for (const directive of directives) {
30890
+ node.inputs.forEach((input) => setBinding(directive, input, 'inputs'));
30891
+ node.attributes.forEach((attr) => setBinding(directive, attr, 'inputs'));
30892
+ node.outputs.forEach((output) => setBinding(directive, output, 'outputs'));
30904
30893
  }
30905
30894
  // TODO(crisbeto): currently it's unclear how references should behave under selectorless,
30906
30895
  // given that there's one named class which can bring in multiple host directives.
30907
30896
  // For the time being only register the first directive as the reference target.
30908
- if (metas.length > 0) {
30909
- node.references.forEach((ref) => this.references.set(ref, { directive: metas[0], node: node }));
30910
- }
30897
+ node.references.forEach((ref) => this.references.set(ref, { directive: directives[0], node: node }));
30911
30898
  }
30912
- trackSelectorMatchedBindings(node, directives) {
30899
+ trackSelectorBasedBindingsAndDirectives(node, directives) {
30900
+ this.trackMatchedDirectives(node, directives);
30913
30901
  // Resolve any references that are created on this node.
30914
30902
  node.references.forEach((ref) => {
30915
30903
  let dirTarget = null;
@@ -31243,6 +31231,7 @@ class R3BoundTarget {
31243
31231
  target;
31244
31232
  directives;
31245
31233
  eagerDirectives;
31234
+ missingDirectives;
31246
31235
  bindings;
31247
31236
  references;
31248
31237
  exprTargets;
@@ -31255,10 +31244,11 @@ class R3BoundTarget {
31255
31244
  deferredBlocks;
31256
31245
  /** Map of deferred blocks to their scope. */
31257
31246
  deferredScopes;
31258
- constructor(target, directives, eagerDirectives, bindings, references, exprTargets, symbols, nestingLevel, scopedNodeEntities, usedPipes, eagerPipes, rawDeferred) {
31247
+ constructor(target, directives, eagerDirectives, missingDirectives, bindings, references, exprTargets, symbols, nestingLevel, scopedNodeEntities, usedPipes, eagerPipes, rawDeferred) {
31259
31248
  this.target = target;
31260
31249
  this.directives = directives;
31261
31250
  this.eagerDirectives = eagerDirectives;
31251
+ this.missingDirectives = missingDirectives;
31262
31252
  this.bindings = bindings;
31263
31253
  this.references = references;
31264
31254
  this.exprTargets = exprTargets;
@@ -31374,6 +31364,9 @@ class R3BoundTarget {
31374
31364
  }
31375
31365
  return false;
31376
31366
  }
31367
+ referencedDirectiveExists(name) {
31368
+ return !this.missingDirectives.has(name);
31369
+ }
31377
31370
  /**
31378
31371
  * Finds an entity with a specific name in a scope.
31379
31372
  * @param rootNode Root node of the scope.
@@ -31876,7 +31869,7 @@ function parseJitTemplate(template, typeName, sourceMapUrl, preserveWhitespaces,
31876
31869
  const errors = parsed.errors.map((err) => err.toString()).join(', ');
31877
31870
  throw new Error(`Errors during JIT compilation of template for ${typeName}: ${errors}`);
31878
31871
  }
31879
- const binder = new R3TargetBinder(new SelectorMatcher());
31872
+ const binder = new R3TargetBinder(null);
31880
31873
  const boundTarget = binder.bind({ template: parsed.nodes });
31881
31874
  return {
31882
31875
  template: parsed,
@@ -33875,7 +33868,7 @@ const MINIMUM_PARTIAL_LINKER_DEFER_SUPPORT_VERSION = '18.0.0';
33875
33868
  function compileDeclareClassMetadata(metadata) {
33876
33869
  const definitionMap = new DefinitionMap();
33877
33870
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$5));
33878
- definitionMap.set('version', literal('20.0.0-next.8'));
33871
+ definitionMap.set('version', literal('20.0.0-rc.0'));
33879
33872
  definitionMap.set('ngImport', importExpr(Identifiers.core));
33880
33873
  definitionMap.set('type', metadata.type);
33881
33874
  definitionMap.set('decorators', metadata.decorators);
@@ -33893,7 +33886,7 @@ function compileComponentDeclareClassMetadata(metadata, dependencies) {
33893
33886
  callbackReturnDefinitionMap.set('ctorParameters', metadata.ctorParameters ?? literal(null));
33894
33887
  callbackReturnDefinitionMap.set('propDecorators', metadata.propDecorators ?? literal(null));
33895
33888
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_DEFER_SUPPORT_VERSION));
33896
- definitionMap.set('version', literal('20.0.0-next.8'));
33889
+ definitionMap.set('version', literal('20.0.0-rc.0'));
33897
33890
  definitionMap.set('ngImport', importExpr(Identifiers.core));
33898
33891
  definitionMap.set('type', metadata.type);
33899
33892
  definitionMap.set('resolveDeferredDeps', compileComponentMetadataAsyncResolver(dependencies));
@@ -33988,7 +33981,7 @@ function createDirectiveDefinitionMap(meta) {
33988
33981
  const definitionMap = new DefinitionMap();
33989
33982
  const minVersion = getMinimumVersionForPartialOutput(meta);
33990
33983
  definitionMap.set('minVersion', literal(minVersion));
33991
- definitionMap.set('version', literal('20.0.0-next.8'));
33984
+ definitionMap.set('version', literal('20.0.0-rc.0'));
33992
33985
  // e.g. `type: MyDirective`
33993
33986
  definitionMap.set('type', meta.type.value);
33994
33987
  if (meta.isStandalone !== undefined) {
@@ -34404,7 +34397,7 @@ const MINIMUM_PARTIAL_LINKER_VERSION$4 = '12.0.0';
34404
34397
  function compileDeclareFactoryFunction(meta) {
34405
34398
  const definitionMap = new DefinitionMap();
34406
34399
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$4));
34407
- definitionMap.set('version', literal('20.0.0-next.8'));
34400
+ definitionMap.set('version', literal('20.0.0-rc.0'));
34408
34401
  definitionMap.set('ngImport', importExpr(Identifiers.core));
34409
34402
  definitionMap.set('type', meta.type.value);
34410
34403
  definitionMap.set('deps', compileDependencies(meta.deps));
@@ -34439,7 +34432,7 @@ function compileDeclareInjectableFromMetadata(meta) {
34439
34432
  function createInjectableDefinitionMap(meta) {
34440
34433
  const definitionMap = new DefinitionMap();
34441
34434
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$3));
34442
- definitionMap.set('version', literal('20.0.0-next.8'));
34435
+ definitionMap.set('version', literal('20.0.0-rc.0'));
34443
34436
  definitionMap.set('ngImport', importExpr(Identifiers.core));
34444
34437
  definitionMap.set('type', meta.type.value);
34445
34438
  // Only generate providedIn property if it has a non-null value
@@ -34490,7 +34483,7 @@ function compileDeclareInjectorFromMetadata(meta) {
34490
34483
  function createInjectorDefinitionMap(meta) {
34491
34484
  const definitionMap = new DefinitionMap();
34492
34485
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$2));
34493
- definitionMap.set('version', literal('20.0.0-next.8'));
34486
+ definitionMap.set('version', literal('20.0.0-rc.0'));
34494
34487
  definitionMap.set('ngImport', importExpr(Identifiers.core));
34495
34488
  definitionMap.set('type', meta.type.value);
34496
34489
  definitionMap.set('providers', meta.providers);
@@ -34523,7 +34516,7 @@ function createNgModuleDefinitionMap(meta) {
34523
34516
  throw new Error('Invalid path! Local compilation mode should not get into the partial compilation path');
34524
34517
  }
34525
34518
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$1));
34526
- definitionMap.set('version', literal('20.0.0-next.8'));
34519
+ definitionMap.set('version', literal('20.0.0-rc.0'));
34527
34520
  definitionMap.set('ngImport', importExpr(Identifiers.core));
34528
34521
  definitionMap.set('type', meta.type.value);
34529
34522
  // We only generate the keys in the metadata if the arrays contain values.
@@ -34574,7 +34567,7 @@ function compileDeclarePipeFromMetadata(meta) {
34574
34567
  function createPipeDefinitionMap(meta) {
34575
34568
  const definitionMap = new DefinitionMap();
34576
34569
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION));
34577
- definitionMap.set('version', literal('20.0.0-next.8'));
34570
+ definitionMap.set('version', literal('20.0.0-rc.0'));
34578
34571
  definitionMap.set('ngImport', importExpr(Identifiers.core));
34579
34572
  // e.g. `type: MyPipe`
34580
34573
  definitionMap.set('type', meta.type.value);
@@ -34732,7 +34725,7 @@ function compileHmrUpdateCallback(definitions, constantStatements, meta) {
34732
34725
  * @description
34733
34726
  * Entry point for all public APIs of the compiler package.
34734
34727
  */
34735
- const VERSION = new Version('20.0.0-next.8');
34728
+ const VERSION = new Version('20.0.0-rc.0');
34736
34729
 
34737
34730
  //////////////////////////////////////
34738
34731
  // THIS FILE HAS GLOBAL SIDE EFFECT //