@angular/compiler 18.1.0-next.3 → 18.1.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 v18.1.0-next.3
2
+ * @license Angular v18.1.0-rc.0
3
3
  * (c) 2010-2024 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -12528,6 +12528,7 @@ function getScopeForView(view, parent) {
12528
12528
  kind: SemanticVariableKind.Identifier,
12529
12529
  name: null,
12530
12530
  identifier,
12531
+ local: false,
12531
12532
  });
12532
12533
  }
12533
12534
  for (const op of view.create) {
@@ -12548,6 +12549,7 @@ function getScopeForView(view, parent) {
12548
12549
  kind: SemanticVariableKind.Identifier,
12549
12550
  name: null,
12550
12551
  identifier: op.localRefs[offset].name,
12552
+ local: false,
12551
12553
  },
12552
12554
  });
12553
12555
  }
@@ -12560,6 +12562,7 @@ function getScopeForView(view, parent) {
12560
12562
  kind: SemanticVariableKind.Identifier,
12561
12563
  name: null,
12562
12564
  identifier: op.declaredName,
12565
+ local: false,
12563
12566
  },
12564
12567
  });
12565
12568
  break;
@@ -17810,8 +17813,7 @@ class _Tokenizer {
17810
17813
  this._preserveLineEndings = options.preserveLineEndings || false;
17811
17814
  this._i18nNormalizeLineEndingsInICUs = options.i18nNormalizeLineEndingsInICUs || false;
17812
17815
  this._tokenizeBlocks = options.tokenizeBlocks ?? true;
17813
- // TODO(crisbeto): eventually set this to true.
17814
- this._tokenizeLet = options.tokenizeLet || false;
17816
+ this._tokenizeLet = options.tokenizeLet ?? true;
17815
17817
  try {
17816
17818
  this._cursor.init();
17817
17819
  }
@@ -18009,8 +18011,11 @@ class _Tokenizer {
18009
18011
  const nameCursor = this._cursor.clone();
18010
18012
  let allowDigit = false;
18011
18013
  this._attemptCharCodeUntilFn((code) => {
18012
- // `@let` names can't start with a digit, but digits are valid anywhere else in the name.
18013
- if (isAsciiLetter(code) || code === $_ || (allowDigit && isDigit(code))) {
18014
+ if (isAsciiLetter(code) ||
18015
+ code == $$ ||
18016
+ code === $_ ||
18017
+ // `@let` names can't start with a digit, but digits are valid anywhere else in the name.
18018
+ (allowDigit && isDigit(code))) {
18014
18019
  allowDigit = true;
18015
18020
  return false;
18016
18021
  }
@@ -22715,6 +22720,8 @@ function processLexicalScope(unit, ops, savedView) {
22715
22720
  // Since variables are generated in each view for the entire lexical scope (including any
22716
22721
  // identifiers from parent templates) only local variables need be considered here.
22717
22722
  const scope = new Map();
22723
+ // Symbols defined within the current scope. They take precedence over ones defined outside.
22724
+ const localDefinitions = new Map();
22718
22725
  // First, step through the operations list and:
22719
22726
  // 1) build up the `scope` mapping
22720
22727
  // 2) recurse into any listener functions
@@ -22723,6 +22730,17 @@ function processLexicalScope(unit, ops, savedView) {
22723
22730
  case OpKind.Variable:
22724
22731
  switch (op.variable.kind) {
22725
22732
  case SemanticVariableKind.Identifier:
22733
+ if (op.variable.local) {
22734
+ if (localDefinitions.has(op.variable.identifier)) {
22735
+ continue;
22736
+ }
22737
+ localDefinitions.set(op.variable.identifier, op.xref);
22738
+ }
22739
+ else if (scope.has(op.variable.identifier)) {
22740
+ continue;
22741
+ }
22742
+ scope.set(op.variable.identifier, op.xref);
22743
+ break;
22726
22744
  case SemanticVariableKind.Alias:
22727
22745
  // This variable represents some kind of identifier which can be used in the template.
22728
22746
  if (scope.has(op.variable.identifier)) {
@@ -22761,7 +22779,10 @@ function processLexicalScope(unit, ops, savedView) {
22761
22779
  // `expr` is a read of a name within the lexical scope of this view.
22762
22780
  // Either that name is defined within the current view, or it represents a property from the
22763
22781
  // main component context.
22764
- if (scope.has(expr.name)) {
22782
+ if (localDefinitions.has(expr.name)) {
22783
+ return new ReadVariableExpr(localDefinitions.get(expr.name));
22784
+ }
22785
+ else if (scope.has(expr.name)) {
22765
22786
  // This was a defined variable in the current scope.
22766
22787
  return new ReadVariableExpr(scope.get(expr.name));
22767
22788
  }
@@ -23972,6 +23993,7 @@ function generateLocalLetReferences(job) {
23972
23993
  kind: SemanticVariableKind.Identifier,
23973
23994
  name: null,
23974
23995
  identifier: op.declaredName,
23996
+ local: true,
23975
23997
  };
23976
23998
  OpList.replace(op, createVariableOp(job.allocateXrefId(), variable, new StoreLetExpr(op.target, op.value, op.sourceSpan), VariableFlags.None));
23977
23999
  }
@@ -27433,7 +27455,7 @@ function parseTemplate(template, templateUrl, options = {}) {
27433
27455
  ...options,
27434
27456
  tokenizeExpansionForms: true,
27435
27457
  tokenizeBlocks: options.enableBlockSyntax ?? true,
27436
- tokenizeLet: options.enableLetSyntax ?? false,
27458
+ tokenizeLet: options.enableLetSyntax ?? true,
27437
27459
  });
27438
27460
  if (!options.alwaysAttemptHtmlToR3AstConversion &&
27439
27461
  parseResult.errors &&
@@ -29267,7 +29289,10 @@ function parseJitTemplate(template, typeName, sourceMapUrl, preserveWhitespaces,
29267
29289
  ? InterpolationConfig.fromArray(interpolation)
29268
29290
  : DEFAULT_INTERPOLATION_CONFIG;
29269
29291
  // Parse the template and check for errors.
29270
- const parsed = parseTemplate(template, sourceMapUrl, { preserveWhitespaces, interpolationConfig });
29292
+ const parsed = parseTemplate(template, sourceMapUrl, {
29293
+ preserveWhitespaces,
29294
+ interpolationConfig,
29295
+ });
29271
29296
  if (parsed.errors !== null) {
29272
29297
  const errors = parsed.errors.map((err) => err.toString()).join(', ');
29273
29298
  throw new Error(`Errors during JIT compilation of template for ${typeName}: ${errors}`);
@@ -29496,7 +29521,7 @@ function publishFacade(global) {
29496
29521
  * @description
29497
29522
  * Entry point for all public APIs of the compiler package.
29498
29523
  */
29499
- const VERSION = new Version('18.1.0-next.3');
29524
+ const VERSION = new Version('18.1.0-rc.0');
29500
29525
 
29501
29526
  class CompilerConfig {
29502
29527
  constructor({ defaultEncapsulation = ViewEncapsulation.Emulated, preserveWhitespaces, strictInjectionParameters, } = {}) {
@@ -31134,7 +31159,7 @@ const MINIMUM_PARTIAL_LINKER_DEFER_SUPPORT_VERSION = '18.0.0';
31134
31159
  function compileDeclareClassMetadata(metadata) {
31135
31160
  const definitionMap = new DefinitionMap();
31136
31161
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$5));
31137
- definitionMap.set('version', literal('18.1.0-next.3'));
31162
+ definitionMap.set('version', literal('18.1.0-rc.0'));
31138
31163
  definitionMap.set('ngImport', importExpr(Identifiers.core));
31139
31164
  definitionMap.set('type', metadata.type);
31140
31165
  definitionMap.set('decorators', metadata.decorators);
@@ -31152,7 +31177,7 @@ function compileComponentDeclareClassMetadata(metadata, dependencies) {
31152
31177
  callbackReturnDefinitionMap.set('ctorParameters', metadata.ctorParameters ?? literal(null));
31153
31178
  callbackReturnDefinitionMap.set('propDecorators', metadata.propDecorators ?? literal(null));
31154
31179
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_DEFER_SUPPORT_VERSION));
31155
- definitionMap.set('version', literal('18.1.0-next.3'));
31180
+ definitionMap.set('version', literal('18.1.0-rc.0'));
31156
31181
  definitionMap.set('ngImport', importExpr(Identifiers.core));
31157
31182
  definitionMap.set('type', metadata.type);
31158
31183
  definitionMap.set('resolveDeferredDeps', compileComponentMetadataAsyncResolver(dependencies));
@@ -31247,7 +31272,7 @@ function createDirectiveDefinitionMap(meta) {
31247
31272
  const definitionMap = new DefinitionMap();
31248
31273
  const minVersion = getMinimumVersionForPartialOutput(meta);
31249
31274
  definitionMap.set('minVersion', literal(minVersion));
31250
- definitionMap.set('version', literal('18.1.0-next.3'));
31275
+ definitionMap.set('version', literal('18.1.0-rc.0'));
31251
31276
  // e.g. `type: MyDirective`
31252
31277
  definitionMap.set('type', meta.type.value);
31253
31278
  if (meta.isStandalone) {
@@ -31669,7 +31694,7 @@ const MINIMUM_PARTIAL_LINKER_VERSION$4 = '12.0.0';
31669
31694
  function compileDeclareFactoryFunction(meta) {
31670
31695
  const definitionMap = new DefinitionMap();
31671
31696
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$4));
31672
- definitionMap.set('version', literal('18.1.0-next.3'));
31697
+ definitionMap.set('version', literal('18.1.0-rc.0'));
31673
31698
  definitionMap.set('ngImport', importExpr(Identifiers.core));
31674
31699
  definitionMap.set('type', meta.type.value);
31675
31700
  definitionMap.set('deps', compileDependencies(meta.deps));
@@ -31704,7 +31729,7 @@ function compileDeclareInjectableFromMetadata(meta) {
31704
31729
  function createInjectableDefinitionMap(meta) {
31705
31730
  const definitionMap = new DefinitionMap();
31706
31731
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$3));
31707
- definitionMap.set('version', literal('18.1.0-next.3'));
31732
+ definitionMap.set('version', literal('18.1.0-rc.0'));
31708
31733
  definitionMap.set('ngImport', importExpr(Identifiers.core));
31709
31734
  definitionMap.set('type', meta.type.value);
31710
31735
  // Only generate providedIn property if it has a non-null value
@@ -31755,7 +31780,7 @@ function compileDeclareInjectorFromMetadata(meta) {
31755
31780
  function createInjectorDefinitionMap(meta) {
31756
31781
  const definitionMap = new DefinitionMap();
31757
31782
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$2));
31758
- definitionMap.set('version', literal('18.1.0-next.3'));
31783
+ definitionMap.set('version', literal('18.1.0-rc.0'));
31759
31784
  definitionMap.set('ngImport', importExpr(Identifiers.core));
31760
31785
  definitionMap.set('type', meta.type.value);
31761
31786
  definitionMap.set('providers', meta.providers);
@@ -31788,7 +31813,7 @@ function createNgModuleDefinitionMap(meta) {
31788
31813
  throw new Error('Invalid path! Local compilation mode should not get into the partial compilation path');
31789
31814
  }
31790
31815
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$1));
31791
- definitionMap.set('version', literal('18.1.0-next.3'));
31816
+ definitionMap.set('version', literal('18.1.0-rc.0'));
31792
31817
  definitionMap.set('ngImport', importExpr(Identifiers.core));
31793
31818
  definitionMap.set('type', meta.type.value);
31794
31819
  // We only generate the keys in the metadata if the arrays contain values.
@@ -31839,7 +31864,7 @@ function compileDeclarePipeFromMetadata(meta) {
31839
31864
  function createPipeDefinitionMap(meta) {
31840
31865
  const definitionMap = new DefinitionMap();
31841
31866
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION));
31842
- definitionMap.set('version', literal('18.1.0-next.3'));
31867
+ definitionMap.set('version', literal('18.1.0-rc.0'));
31843
31868
  definitionMap.set('ngImport', importExpr(Identifiers.core));
31844
31869
  // e.g. `type: MyPipe`
31845
31870
  definitionMap.set('type', meta.type.value);