@angular/compiler 19.0.0-rc.0 → 19.0.0-rc.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-rc.0
2
+ * @license Angular v19.0.0-rc.2
3
3
  * (c) 2010-2024 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -1446,8 +1446,7 @@ class ExternalExpr extends Expression {
1446
1446
  isEquivalent(e) {
1447
1447
  return (e instanceof ExternalExpr &&
1448
1448
  this.value.name === e.value.name &&
1449
- this.value.moduleName === e.value.moduleName &&
1450
- this.value.runtime === e.value.runtime);
1449
+ this.value.moduleName === e.value.moduleName);
1451
1450
  }
1452
1451
  isConstant() {
1453
1452
  return false;
@@ -1462,11 +1461,9 @@ class ExternalExpr extends Expression {
1462
1461
  class ExternalReference {
1463
1462
  moduleName;
1464
1463
  name;
1465
- runtime;
1466
- constructor(moduleName, name, runtime) {
1464
+ constructor(moduleName, name) {
1467
1465
  this.moduleName = moduleName;
1468
1466
  this.name = name;
1469
- this.runtime = runtime;
1470
1467
  }
1471
1468
  }
1472
1469
  class ConditionalExpr extends Expression {
@@ -26351,15 +26348,16 @@ function convertSourceSpan(span, baseSourceSpan) {
26351
26348
  * workaround, because it'll include an additional text node as the first child. We can work
26352
26349
  * around it here, but in a discussion it was decided not to, because the user explicitly opted
26353
26350
  * into preserving the whitespace and we would have to drop it from the generated code.
26354
- * The diagnostic mentioned point #1 will flag such cases to users.
26351
+ * The diagnostic mentioned point in #1 will flag such cases to users.
26355
26352
  *
26356
26353
  * @returns Tag name to be used for the control flow template.
26357
26354
  */
26358
26355
  function ingestControlFlowInsertionPoint(unit, xref, node) {
26359
26356
  let root = null;
26360
26357
  for (const child of node.children) {
26361
- // Skip over comment nodes.
26362
- if (child instanceof Comment$1) {
26358
+ // Skip over comment nodes and @let declarations since
26359
+ // it doesn't matter where they end up in the DOM.
26360
+ if (child instanceof Comment$1 || child instanceof LetDeclaration$1) {
26363
26361
  continue;
26364
26362
  }
26365
26363
  // We can only infer the tag name/attributes if there's a single root node.
@@ -26370,6 +26368,9 @@ function ingestControlFlowInsertionPoint(unit, xref, node) {
26370
26368
  if (child instanceof Element$1 || (child instanceof Template && child.tagName !== null)) {
26371
26369
  root = child;
26372
26370
  }
26371
+ else {
26372
+ return null;
26373
+ }
26373
26374
  }
26374
26375
  // If we've found a single root node, its tag name and attributes can be
26375
26376
  // copied to the surrounding template to be used for content projection.
@@ -30839,7 +30840,7 @@ function publishFacade(global) {
30839
30840
  * @description
30840
30841
  * Entry point for all public APIs of the compiler package.
30841
30842
  */
30842
- const VERSION = new Version('19.0.0-rc.0');
30843
+ const VERSION = new Version('19.0.0-rc.2');
30843
30844
 
30844
30845
  class CompilerConfig {
30845
30846
  defaultEncapsulation;
@@ -32594,33 +32595,57 @@ function compileHmrInitializer(meta) {
32594
32595
  const urlPartial = `/@ng/component?c=${id}&t=`;
32595
32596
  const moduleName = 'm';
32596
32597
  const dataName = 'd';
32598
+ const timestampName = 't';
32599
+ const importCallbackName = `${meta.className}_HmrLoad`;
32597
32600
  const locals = meta.locals.map((localName) => variable(localName));
32601
+ // m.default
32602
+ const defaultRead = variable(moduleName).prop('default');
32598
32603
  // ɵɵreplaceMetadata(Comp, m.default, [...]);
32599
- const replaceMetadata = importExpr(Identifiers.replaceMetadata)
32600
- .callFn([meta.type, variable(moduleName).prop('default'), literalArr(locals)]);
32601
- // (m) => ɵɵreplaceMetadata(...)
32602
- const replaceCallback = arrowFn([new FnParam(moduleName)], replaceMetadata);
32603
- // '<urlPartial>' + encodeURIComponent(d.timestamp)
32604
+ const replaceCall = importExpr(Identifiers.replaceMetadata)
32605
+ .callFn([meta.type, defaultRead, new ExternalExpr(Identifiers.core), literalArr(locals)]);
32606
+ // (m) => m.default && ɵɵreplaceMetadata(...)
32607
+ const replaceCallback = arrowFn([new FnParam(moduleName)], defaultRead.and(replaceCall));
32608
+ // '<urlPartial>' + encodeURIComponent(t)
32604
32609
  const urlValue = literal(urlPartial)
32605
- .plus(variable('encodeURIComponent').callFn([variable(dataName).prop('timestamp')]));
32606
- // import(/* @vite-ignore */ url).then(() => replaceMetadata(...));
32607
- // The vite-ignore special comment is required to avoid Vite from generating a superfluous
32608
- // warning for each usage within the development code. If Vite provides a method to
32609
- // programmatically avoid this warning in the future, this added comment can be removed here.
32610
- const dynamicImport = new DynamicImportExpr(urlValue, null, '@vite-ignore')
32611
- .prop('then')
32612
- .callFn([replaceCallback]);
32613
- // (d) => { if (d.id === <id>) { replaceMetadata(...) } }
32614
- const listenerCallback = arrowFn([new FnParam(dataName)], [ifStmt(variable(dataName).prop('id').equals(literal(id)), [dynamicImport.toStmt()])]);
32610
+ .plus(variable('encodeURIComponent').callFn([variable(timestampName)]));
32611
+ // function Cmp_HmrLoad(t) {
32612
+ // import(/* @vite-ignore */ url).then((m) => m.default && replaceMetadata(...));
32613
+ // }
32614
+ const importCallback = new DeclareFunctionStmt(importCallbackName, [new FnParam(timestampName)], [
32615
+ // The vite-ignore special comment is required to prevent Vite from generating a superfluous
32616
+ // warning for each usage within the development code. If Vite provides a method to
32617
+ // programmatically avoid this warning in the future, this added comment can be removed here.
32618
+ new DynamicImportExpr(urlValue, null, '@vite-ignore')
32619
+ .prop('then')
32620
+ .callFn([replaceCallback])
32621
+ .toStmt(),
32622
+ ], null, StmtModifier.Final);
32623
+ // (d) => d.id === <id> && Cmp_HmrLoad(d.timestamp)
32624
+ const updateCallback = arrowFn([new FnParam(dataName)], variable(dataName)
32625
+ .prop('id')
32626
+ .identical(literal(id))
32627
+ .and(variable(importCallbackName).callFn([variable(dataName).prop('timestamp')])));
32628
+ // Cmp_HmrLoad(Date.now());
32629
+ // Initial call to kick off the loading in order to avoid edge cases with components
32630
+ // coming from lazy chunks that change before the chunk has loaded.
32631
+ const initialCall = variable(importCallbackName)
32632
+ .callFn([variable('Date').prop('now').callFn([])]);
32615
32633
  // import.meta.hot
32616
32634
  const hotRead = variable('import').prop('meta').prop('hot');
32617
32635
  // import.meta.hot.on('angular:component-update', () => ...);
32618
32636
  const hotListener = hotRead
32619
32637
  .clone()
32620
32638
  .prop('on')
32621
- .callFn([literal('angular:component-update'), listenerCallback]);
32622
- // import.meta.hot && import.meta.hot.on(...)
32623
- return arrowFn([], [devOnlyGuardedExpression(hotRead.and(hotListener)).toStmt()]).callFn([]);
32639
+ .callFn([literal('angular:component-update'), updateCallback]);
32640
+ return arrowFn([], [
32641
+ // function Cmp_HmrLoad() {...}.
32642
+ importCallback,
32643
+ // ngDevMode && Cmp_HmrLoad(Date.now());
32644
+ devOnlyGuardedExpression(initialCall).toStmt(),
32645
+ // ngDevMode && import.meta.hot && import.meta.hot.on(...)
32646
+ devOnlyGuardedExpression(hotRead.and(hotListener)).toStmt(),
32647
+ ])
32648
+ .callFn([]);
32624
32649
  }
32625
32650
  /**
32626
32651
  * Compiles the HMR update callback for a class.
@@ -32659,7 +32684,7 @@ const MINIMUM_PARTIAL_LINKER_DEFER_SUPPORT_VERSION = '18.0.0';
32659
32684
  function compileDeclareClassMetadata(metadata) {
32660
32685
  const definitionMap = new DefinitionMap();
32661
32686
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$5));
32662
- definitionMap.set('version', literal('19.0.0-rc.0'));
32687
+ definitionMap.set('version', literal('19.0.0-rc.2'));
32663
32688
  definitionMap.set('ngImport', importExpr(Identifiers.core));
32664
32689
  definitionMap.set('type', metadata.type);
32665
32690
  definitionMap.set('decorators', metadata.decorators);
@@ -32677,7 +32702,7 @@ function compileComponentDeclareClassMetadata(metadata, dependencies) {
32677
32702
  callbackReturnDefinitionMap.set('ctorParameters', metadata.ctorParameters ?? literal(null));
32678
32703
  callbackReturnDefinitionMap.set('propDecorators', metadata.propDecorators ?? literal(null));
32679
32704
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_DEFER_SUPPORT_VERSION));
32680
- definitionMap.set('version', literal('19.0.0-rc.0'));
32705
+ definitionMap.set('version', literal('19.0.0-rc.2'));
32681
32706
  definitionMap.set('ngImport', importExpr(Identifiers.core));
32682
32707
  definitionMap.set('type', metadata.type);
32683
32708
  definitionMap.set('resolveDeferredDeps', compileComponentMetadataAsyncResolver(dependencies));
@@ -32772,7 +32797,7 @@ function createDirectiveDefinitionMap(meta) {
32772
32797
  const definitionMap = new DefinitionMap();
32773
32798
  const minVersion = getMinimumVersionForPartialOutput(meta);
32774
32799
  definitionMap.set('minVersion', literal(minVersion));
32775
- definitionMap.set('version', literal('19.0.0-rc.0'));
32800
+ definitionMap.set('version', literal('19.0.0-rc.2'));
32776
32801
  // e.g. `type: MyDirective`
32777
32802
  definitionMap.set('type', meta.type.value);
32778
32803
  if (meta.isStandalone !== undefined) {
@@ -33191,7 +33216,7 @@ const MINIMUM_PARTIAL_LINKER_VERSION$4 = '12.0.0';
33191
33216
  function compileDeclareFactoryFunction(meta) {
33192
33217
  const definitionMap = new DefinitionMap();
33193
33218
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$4));
33194
- definitionMap.set('version', literal('19.0.0-rc.0'));
33219
+ definitionMap.set('version', literal('19.0.0-rc.2'));
33195
33220
  definitionMap.set('ngImport', importExpr(Identifiers.core));
33196
33221
  definitionMap.set('type', meta.type.value);
33197
33222
  definitionMap.set('deps', compileDependencies(meta.deps));
@@ -33226,7 +33251,7 @@ function compileDeclareInjectableFromMetadata(meta) {
33226
33251
  function createInjectableDefinitionMap(meta) {
33227
33252
  const definitionMap = new DefinitionMap();
33228
33253
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$3));
33229
- definitionMap.set('version', literal('19.0.0-rc.0'));
33254
+ definitionMap.set('version', literal('19.0.0-rc.2'));
33230
33255
  definitionMap.set('ngImport', importExpr(Identifiers.core));
33231
33256
  definitionMap.set('type', meta.type.value);
33232
33257
  // Only generate providedIn property if it has a non-null value
@@ -33277,7 +33302,7 @@ function compileDeclareInjectorFromMetadata(meta) {
33277
33302
  function createInjectorDefinitionMap(meta) {
33278
33303
  const definitionMap = new DefinitionMap();
33279
33304
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$2));
33280
- definitionMap.set('version', literal('19.0.0-rc.0'));
33305
+ definitionMap.set('version', literal('19.0.0-rc.2'));
33281
33306
  definitionMap.set('ngImport', importExpr(Identifiers.core));
33282
33307
  definitionMap.set('type', meta.type.value);
33283
33308
  definitionMap.set('providers', meta.providers);
@@ -33310,7 +33335,7 @@ function createNgModuleDefinitionMap(meta) {
33310
33335
  throw new Error('Invalid path! Local compilation mode should not get into the partial compilation path');
33311
33336
  }
33312
33337
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$1));
33313
- definitionMap.set('version', literal('19.0.0-rc.0'));
33338
+ definitionMap.set('version', literal('19.0.0-rc.2'));
33314
33339
  definitionMap.set('ngImport', importExpr(Identifiers.core));
33315
33340
  definitionMap.set('type', meta.type.value);
33316
33341
  // We only generate the keys in the metadata if the arrays contain values.
@@ -33361,7 +33386,7 @@ function compileDeclarePipeFromMetadata(meta) {
33361
33386
  function createPipeDefinitionMap(meta) {
33362
33387
  const definitionMap = new DefinitionMap();
33363
33388
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION));
33364
- definitionMap.set('version', literal('19.0.0-rc.0'));
33389
+ definitionMap.set('version', literal('19.0.0-rc.2'));
33365
33390
  definitionMap.set('ngImport', importExpr(Identifiers.core));
33366
33391
  // e.g. `type: MyPipe`
33367
33392
  definitionMap.set('type', meta.type.value);