@angular/compiler 19.0.0 → 19.0.2

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 v19.0.0
2
+ * @license Angular v19.0.2
3
3
  * (c) 2010-2024 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -6894,10 +6894,23 @@ class ParseError {
6894
6894
  span;
6895
6895
  msg;
6896
6896
  level;
6897
- constructor(span, msg, level = ParseErrorLevel.ERROR) {
6897
+ relatedError;
6898
+ constructor(
6899
+ /** Location of the error. */
6900
+ span,
6901
+ /** Error message. */
6902
+ msg,
6903
+ /** Severity level of the error. */
6904
+ level = ParseErrorLevel.ERROR,
6905
+ /**
6906
+ * Error that caused the error to be surfaced. For example, an error in a sub-expression that
6907
+ * couldn't be parsed. Not guaranteed to be defined, but can be used to provide more context.
6908
+ */
6909
+ relatedError) {
6898
6910
  this.span = span;
6899
6911
  this.msg = msg;
6900
6912
  this.level = level;
6913
+ this.relatedError = relatedError;
6901
6914
  }
6902
6915
  contextualMessage() {
6903
6916
  const ctx = this.span.start.getContext(100, 3);
@@ -11114,6 +11127,7 @@ function createDeferOp(xref, main, mainSlot, ownResolverFn, resolverFn, sourceSp
11114
11127
  errorSlot: null,
11115
11128
  ownResolverFn,
11116
11129
  resolverFn,
11130
+ flags: null,
11117
11131
  sourceSpan,
11118
11132
  ...NEW_OP,
11119
11133
  ...TRAIT_CONSUMES_SLOT,
@@ -22544,7 +22558,7 @@ function text(slot, initialValue, sourceSpan) {
22544
22558
  }
22545
22559
  return call(Identifiers.text, args, sourceSpan);
22546
22560
  }
22547
- function defer(selfSlot, primarySlot, dependencyResolverFn, loadingSlot, placeholderSlot, errorSlot, loadingConfig, placeholderConfig, enableTimerScheduling, sourceSpan) {
22561
+ function defer(selfSlot, primarySlot, dependencyResolverFn, loadingSlot, placeholderSlot, errorSlot, loadingConfig, placeholderConfig, enableTimerScheduling, sourceSpan, flags) {
22548
22562
  const args = [
22549
22563
  literal(selfSlot),
22550
22564
  literal(primarySlot),
@@ -22555,6 +22569,7 @@ function defer(selfSlot, primarySlot, dependencyResolverFn, loadingSlot, placeho
22555
22569
  loadingConfig ?? literal(null),
22556
22570
  placeholderConfig ?? literal(null),
22557
22571
  enableTimerScheduling ? importExpr(Identifiers.deferEnableTimerScheduling) : literal(null),
22572
+ literal(flags),
22558
22573
  ];
22559
22574
  let expr;
22560
22575
  while ((expr = args[args.length - 1]) !== null &&
@@ -23173,7 +23188,7 @@ function reifyCreateOperations(unit, ops) {
23173
23188
  break;
23174
23189
  case OpKind.Defer:
23175
23190
  const timerScheduling = !!op.loadingMinimumTime || !!op.loadingAfterTime || !!op.placeholderMinimumTime;
23176
- OpList.replace(op, defer(op.handle.slot, op.mainSlot.slot, op.resolverFn, op.loadingSlot?.slot ?? null, op.placeholderSlot?.slot ?? null, op.errorSlot?.slot ?? null, op.loadingConfig, op.placeholderConfig, timerScheduling, op.sourceSpan));
23191
+ OpList.replace(op, defer(op.handle.slot, op.mainSlot.slot, op.resolverFn, op.loadingSlot?.slot ?? null, op.placeholderSlot?.slot ?? null, op.errorSlot?.slot ?? null, op.loadingConfig, op.placeholderConfig, timerScheduling, op.sourceSpan, op.flags));
23177
23192
  break;
23178
23193
  case OpKind.DeferOn:
23179
23194
  let args = [];
@@ -25752,6 +25767,7 @@ function ingestDeferBlock(unit, deferBlock) {
25752
25767
  deferOp.placeholderMinimumTime = deferBlock.placeholder?.minimumTime ?? null;
25753
25768
  deferOp.loadingMinimumTime = deferBlock.loading?.minimumTime ?? null;
25754
25769
  deferOp.loadingAfterTime = deferBlock.loading?.afterTime ?? null;
25770
+ deferOp.flags = calcDeferBlockFlags(deferBlock);
25755
25771
  unit.create.push(deferOp);
25756
25772
  // Configure all defer `on` conditions.
25757
25773
  // TODO: refactor prefetch triggers to use a separate op type, with a shared superclass. This will
@@ -25771,6 +25787,12 @@ function ingestDeferBlock(unit, deferBlock) {
25771
25787
  unit.create.push(deferOnOps);
25772
25788
  unit.update.push(deferWhenOps);
25773
25789
  }
25790
+ function calcDeferBlockFlags(deferBlockDetails) {
25791
+ if (Object.keys(deferBlockDetails.hydrateTriggers).length > 0) {
25792
+ return 1 /* ir.TDeferDetailsFlags.HasHydrateTriggers */;
25793
+ }
25794
+ return null;
25795
+ }
25774
25796
  function ingestDeferTriggers(modifier, triggers, onOps, whenOps, unit, deferXref) {
25775
25797
  if (triggers.idle !== undefined) {
25776
25798
  const deferOnOp = createDeferOnOp(deferXref, { kind: DeferTriggerKind.Idle }, modifier, triggers.idle.sourceSpan);
@@ -26620,13 +26642,11 @@ class BindingParser {
26620
26642
  _interpolationConfig;
26621
26643
  _schemaRegistry;
26622
26644
  errors;
26623
- _allowInvalidAssignmentEvents;
26624
- constructor(_exprParser, _interpolationConfig, _schemaRegistry, errors, _allowInvalidAssignmentEvents = false) {
26645
+ constructor(_exprParser, _interpolationConfig, _schemaRegistry, errors) {
26625
26646
  this._exprParser = _exprParser;
26626
26647
  this._interpolationConfig = _interpolationConfig;
26627
26648
  this._schemaRegistry = _schemaRegistry;
26628
26649
  this.errors = errors;
26629
- this._allowInvalidAssignmentEvents = _allowInvalidAssignmentEvents;
26630
26650
  }
26631
26651
  get interpolationConfig() {
26632
26652
  return this._interpolationConfig;
@@ -26975,12 +26995,12 @@ class BindingParser {
26975
26995
  return this._exprParser.wrapLiteralPrimitive('ERROR', sourceInfo, absoluteOffset);
26976
26996
  }
26977
26997
  }
26978
- _reportError(message, sourceSpan, level = ParseErrorLevel.ERROR) {
26979
- this.errors.push(new ParseError(sourceSpan, message, level));
26998
+ _reportError(message, sourceSpan, level = ParseErrorLevel.ERROR, relatedError) {
26999
+ this.errors.push(new ParseError(sourceSpan, message, level, relatedError));
26980
27000
  }
26981
27001
  _reportExpressionParserErrors(errors, sourceSpan) {
26982
27002
  for (const error of errors) {
26983
- this._reportError(error.message, sourceSpan);
27003
+ this._reportError(error.message, sourceSpan, undefined, error);
26984
27004
  }
26985
27005
  }
26986
27006
  /**
@@ -27010,16 +27030,7 @@ class BindingParser {
27010
27030
  if (ast instanceof PropertyRead || ast instanceof KeyedRead) {
27011
27031
  return true;
27012
27032
  }
27013
- // TODO(crisbeto): this logic is only here to support the automated migration away
27014
- // from invalid bindings. It should be removed once the migration is deleted.
27015
- if (!this._allowInvalidAssignmentEvents) {
27016
- return false;
27017
- }
27018
- if (ast instanceof Binary) {
27019
- return ((ast.operation === '&&' || ast.operation === '||' || ast.operation === '??') &&
27020
- (ast.right instanceof PropertyRead || ast.right instanceof KeyedRead));
27021
- }
27022
- return ast instanceof Conditional || ast instanceof PrefixNot;
27033
+ return false;
27023
27034
  }
27024
27035
  }
27025
27036
  class PipeCollector extends RecursiveAstVisitor {
@@ -28652,8 +28663,8 @@ const LEADING_TRIVIA_CHARS = [' ', '\n', '\r', '\t'];
28652
28663
  * @param options options to modify how the template is parsed
28653
28664
  */
28654
28665
  function parseTemplate(template, templateUrl, options = {}) {
28655
- const { interpolationConfig, preserveWhitespaces, enableI18nLegacyMessageIdFormat, allowInvalidAssignmentEvents, } = options;
28656
- const bindingParser = makeBindingParser(interpolationConfig, allowInvalidAssignmentEvents);
28666
+ const { interpolationConfig, preserveWhitespaces, enableI18nLegacyMessageIdFormat } = options;
28667
+ const bindingParser = makeBindingParser(interpolationConfig);
28657
28668
  const htmlParser = new HtmlParser();
28658
28669
  const parseResult = htmlParser.parse(template, templateUrl, {
28659
28670
  leadingTriviaChars: LEADING_TRIVIA_CHARS,
@@ -28759,8 +28770,8 @@ const elementRegistry = new DomElementSchemaRegistry();
28759
28770
  /**
28760
28771
  * Construct a `BindingParser` with a default configuration.
28761
28772
  */
28762
- function makeBindingParser(interpolationConfig = DEFAULT_INTERPOLATION_CONFIG, allowInvalidAssignmentEvents = false) {
28763
- return new BindingParser(new Parser(new Lexer()), interpolationConfig, elementRegistry, [], allowInvalidAssignmentEvents);
28773
+ function makeBindingParser(interpolationConfig = DEFAULT_INTERPOLATION_CONFIG) {
28774
+ return new BindingParser(new Parser(new Lexer()), interpolationConfig, elementRegistry, []);
28764
28775
  }
28765
28776
 
28766
28777
  const COMPONENT_VARIABLE = '%COMP%';
@@ -30872,7 +30883,7 @@ function publishFacade(global) {
30872
30883
  * @description
30873
30884
  * Entry point for all public APIs of the compiler package.
30874
30885
  */
30875
- const VERSION = new Version('19.0.0');
30886
+ const VERSION = new Version('19.0.2');
30876
30887
 
30877
30888
  class CompilerConfig {
30878
30889
  defaultEncapsulation;
@@ -32629,12 +32640,15 @@ function compileHmrInitializer(meta) {
32629
32640
  const dataName = 'd';
32630
32641
  const timestampName = 't';
32631
32642
  const importCallbackName = `${meta.className}_HmrLoad`;
32632
- const locals = meta.locals.map((localName) => variable(localName));
32643
+ const locals = meta.localDependencies.map((localName) => variable(localName));
32644
+ const namespaces = meta.namespaceDependencies.map((dep) => {
32645
+ return new ExternalExpr({ moduleName: dep.moduleName, name: null });
32646
+ });
32633
32647
  // m.default
32634
32648
  const defaultRead = variable(moduleName).prop('default');
32635
- // ɵɵreplaceMetadata(Comp, m.default, [...]);
32649
+ // ɵɵreplaceMetadata(Comp, m.default, [...namespaces], [...locals]);
32636
32650
  const replaceCall = importExpr(Identifiers.replaceMetadata)
32637
- .callFn([meta.type, defaultRead, new ExternalExpr(Identifiers.core), literalArr(locals)]);
32651
+ .callFn([meta.type, defaultRead, literalArr(namespaces), literalArr(locals)]);
32638
32652
  // (m) => m.default && ɵɵreplaceMetadata(...)
32639
32653
  const replaceCallback = arrowFn([new FnParam(moduleName)], defaultRead.and(replaceCall));
32640
32654
  // '<urlPartial>' + encodeURIComponent(t)
@@ -32687,9 +32701,14 @@ function compileHmrInitializer(meta) {
32687
32701
  * @param meta HMR metadata extracted from the class.
32688
32702
  */
32689
32703
  function compileHmrUpdateCallback(definitions, constantStatements, meta) {
32690
- // The class name should always be first and core should be second.
32691
- const params = [meta.className, meta.coreName, ...meta.locals].map((name) => new FnParam(name, DYNAMIC_TYPE));
32692
- const body = [...constantStatements];
32704
+ const namespaces = 'ɵɵnamespaces';
32705
+ const params = [meta.className, namespaces, ...meta.localDependencies].map((name) => new FnParam(name, DYNAMIC_TYPE));
32706
+ const body = [];
32707
+ // Declare variables that read out the individual namespaces.
32708
+ for (let i = 0; i < meta.namespaceDependencies.length; i++) {
32709
+ body.push(new DeclareVarStmt(meta.namespaceDependencies[i].assignedName, variable(namespaces).key(literal(i)), DYNAMIC_TYPE, StmtModifier.Final));
32710
+ }
32711
+ body.push(...constantStatements);
32693
32712
  for (const field of definitions) {
32694
32713
  if (field.initializer !== null) {
32695
32714
  body.push(variable(meta.className).prop(field.name).set(field.initializer).toStmt());
@@ -32716,7 +32735,7 @@ const MINIMUM_PARTIAL_LINKER_DEFER_SUPPORT_VERSION = '18.0.0';
32716
32735
  function compileDeclareClassMetadata(metadata) {
32717
32736
  const definitionMap = new DefinitionMap();
32718
32737
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$5));
32719
- definitionMap.set('version', literal('19.0.0'));
32738
+ definitionMap.set('version', literal('19.0.2'));
32720
32739
  definitionMap.set('ngImport', importExpr(Identifiers.core));
32721
32740
  definitionMap.set('type', metadata.type);
32722
32741
  definitionMap.set('decorators', metadata.decorators);
@@ -32734,7 +32753,7 @@ function compileComponentDeclareClassMetadata(metadata, dependencies) {
32734
32753
  callbackReturnDefinitionMap.set('ctorParameters', metadata.ctorParameters ?? literal(null));
32735
32754
  callbackReturnDefinitionMap.set('propDecorators', metadata.propDecorators ?? literal(null));
32736
32755
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_DEFER_SUPPORT_VERSION));
32737
- definitionMap.set('version', literal('19.0.0'));
32756
+ definitionMap.set('version', literal('19.0.2'));
32738
32757
  definitionMap.set('ngImport', importExpr(Identifiers.core));
32739
32758
  definitionMap.set('type', metadata.type);
32740
32759
  definitionMap.set('resolveDeferredDeps', compileComponentMetadataAsyncResolver(dependencies));
@@ -32829,7 +32848,7 @@ function createDirectiveDefinitionMap(meta) {
32829
32848
  const definitionMap = new DefinitionMap();
32830
32849
  const minVersion = getMinimumVersionForPartialOutput(meta);
32831
32850
  definitionMap.set('minVersion', literal(minVersion));
32832
- definitionMap.set('version', literal('19.0.0'));
32851
+ definitionMap.set('version', literal('19.0.2'));
32833
32852
  // e.g. `type: MyDirective`
32834
32853
  definitionMap.set('type', meta.type.value);
32835
32854
  if (meta.isStandalone !== undefined) {
@@ -33248,7 +33267,7 @@ const MINIMUM_PARTIAL_LINKER_VERSION$4 = '12.0.0';
33248
33267
  function compileDeclareFactoryFunction(meta) {
33249
33268
  const definitionMap = new DefinitionMap();
33250
33269
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$4));
33251
- definitionMap.set('version', literal('19.0.0'));
33270
+ definitionMap.set('version', literal('19.0.2'));
33252
33271
  definitionMap.set('ngImport', importExpr(Identifiers.core));
33253
33272
  definitionMap.set('type', meta.type.value);
33254
33273
  definitionMap.set('deps', compileDependencies(meta.deps));
@@ -33283,7 +33302,7 @@ function compileDeclareInjectableFromMetadata(meta) {
33283
33302
  function createInjectableDefinitionMap(meta) {
33284
33303
  const definitionMap = new DefinitionMap();
33285
33304
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$3));
33286
- definitionMap.set('version', literal('19.0.0'));
33305
+ definitionMap.set('version', literal('19.0.2'));
33287
33306
  definitionMap.set('ngImport', importExpr(Identifiers.core));
33288
33307
  definitionMap.set('type', meta.type.value);
33289
33308
  // Only generate providedIn property if it has a non-null value
@@ -33334,7 +33353,7 @@ function compileDeclareInjectorFromMetadata(meta) {
33334
33353
  function createInjectorDefinitionMap(meta) {
33335
33354
  const definitionMap = new DefinitionMap();
33336
33355
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$2));
33337
- definitionMap.set('version', literal('19.0.0'));
33356
+ definitionMap.set('version', literal('19.0.2'));
33338
33357
  definitionMap.set('ngImport', importExpr(Identifiers.core));
33339
33358
  definitionMap.set('type', meta.type.value);
33340
33359
  definitionMap.set('providers', meta.providers);
@@ -33367,7 +33386,7 @@ function createNgModuleDefinitionMap(meta) {
33367
33386
  throw new Error('Invalid path! Local compilation mode should not get into the partial compilation path');
33368
33387
  }
33369
33388
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$1));
33370
- definitionMap.set('version', literal('19.0.0'));
33389
+ definitionMap.set('version', literal('19.0.2'));
33371
33390
  definitionMap.set('ngImport', importExpr(Identifiers.core));
33372
33391
  definitionMap.set('type', meta.type.value);
33373
33392
  // We only generate the keys in the metadata if the arrays contain values.
@@ -33418,7 +33437,7 @@ function compileDeclarePipeFromMetadata(meta) {
33418
33437
  function createPipeDefinitionMap(meta) {
33419
33438
  const definitionMap = new DefinitionMap();
33420
33439
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION));
33421
- definitionMap.set('version', literal('19.0.0'));
33440
+ definitionMap.set('version', literal('19.0.2'));
33422
33441
  definitionMap.set('ngImport', importExpr(Identifiers.core));
33423
33442
  // e.g. `type: MyPipe`
33424
33443
  definitionMap.set('type', meta.type.value);