@angular/compiler 19.1.0-next.2 → 19.1.0-next.3

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.1.0-next.2
2
+ * @license Angular v19.1.0-next.3
3
3
  * (c) 2010-2024 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -3014,6 +3014,10 @@ class Identifiers {
3014
3014
  static declareLet = { name: 'ɵɵdeclareLet', moduleName: CORE };
3015
3015
  static storeLet = { name: 'ɵɵstoreLet', moduleName: CORE };
3016
3016
  static readContextLet = { name: 'ɵɵreadContextLet', moduleName: CORE };
3017
+ static attachSourceLocations = {
3018
+ name: 'ɵɵattachSourceLocations',
3019
+ moduleName: CORE,
3020
+ };
3017
3021
  static NgOnChangesFeature = { name: 'ɵɵNgOnChangesFeature', moduleName: CORE };
3018
3022
  static InheritDefinitionFeature = {
3019
3023
  name: 'ɵɵInheritDefinitionFeature',
@@ -8937,6 +8941,10 @@ var OpKind;
8937
8941
  * A creation op that corresponds to i18n attributes on an element.
8938
8942
  */
8939
8943
  OpKind[OpKind["I18nAttributes"] = 49] = "I18nAttributes";
8944
+ /**
8945
+ * Creation op that attaches the location at which an element was defined in a template to it.
8946
+ */
8947
+ OpKind[OpKind["SourceLocation"] = 50] = "SourceLocation";
8940
8948
  })(OpKind || (OpKind = {}));
8941
8949
  /**
8942
8950
  * Distinguishes different kinds of IR expressions.
@@ -10478,6 +10486,7 @@ function transformExpressionsInOp(op, transform, flags) {
10478
10486
  case OpKind.I18nAttributes:
10479
10487
  case OpKind.IcuPlaceholder:
10480
10488
  case OpKind.DeclareLet:
10489
+ case OpKind.SourceLocation:
10481
10490
  // These operations contain no expressions.
10482
10491
  break;
10483
10492
  default:
@@ -11269,6 +11278,15 @@ function createI18nAttributesOp(xref, handle, target) {
11269
11278
  ...TRAIT_CONSUMES_SLOT,
11270
11279
  };
11271
11280
  }
11281
+ /** Create a `SourceLocationOp`. */
11282
+ function createSourceLocationOp(templatePath, locations) {
11283
+ return {
11284
+ kind: OpKind.SourceLocation,
11285
+ templatePath,
11286
+ locations,
11287
+ ...NEW_OP,
11288
+ };
11289
+ }
11272
11290
 
11273
11291
  function createHostPropertyOp(name, expression, isAnimationTrigger, i18nContext, securityContext, sourceSpan) {
11274
11292
  return {
@@ -11331,12 +11349,16 @@ class ComponentCompilationJob extends CompilationJob {
11331
11349
  i18nUseExternalIds;
11332
11350
  deferMeta;
11333
11351
  allDeferrableDepsFn;
11334
- constructor(componentName, pool, compatibility, relativeContextFilePath, i18nUseExternalIds, deferMeta, allDeferrableDepsFn) {
11352
+ relativeTemplatePath;
11353
+ enableDebugLocations;
11354
+ constructor(componentName, pool, compatibility, relativeContextFilePath, i18nUseExternalIds, deferMeta, allDeferrableDepsFn, relativeTemplatePath, enableDebugLocations) {
11335
11355
  super(componentName, pool, compatibility);
11336
11356
  this.relativeContextFilePath = relativeContextFilePath;
11337
11357
  this.i18nUseExternalIds = i18nUseExternalIds;
11338
11358
  this.deferMeta = deferMeta;
11339
11359
  this.allDeferrableDepsFn = allDeferrableDepsFn;
11360
+ this.relativeTemplatePath = relativeTemplatePath;
11361
+ this.enableDebugLocations = enableDebugLocations;
11340
11362
  this.root = new ViewCompilationUnit(this, this.allocateXrefId(), null);
11341
11363
  this.views.set(this.root.xref, this.root);
11342
11364
  }
@@ -22840,6 +22862,9 @@ function syntheticHostProperty(name, expression, sourceSpan) {
22840
22862
  function pureFunction(varOffset, fn, args) {
22841
22863
  return callVariadicInstructionExpr(PURE_FUNCTION_CONFIG, [literal(varOffset), fn], args, [], null);
22842
22864
  }
22865
+ function attachSourceLocation(templatePath, locations) {
22866
+ return call(Identifiers.attachSourceLocations, [literal(templatePath), locations], null);
22867
+ }
22843
22868
  /**
22844
22869
  * Collates the string an expression arguments for an interpolation instruction.
22845
22870
  */
@@ -23279,6 +23304,20 @@ function reifyCreateOperations(unit, ops) {
23279
23304
  }
23280
23305
  OpList.replace(op, repeaterCreate(op.handle.slot, repeaterView.fnName, op.decls, op.vars, op.tag, op.attributes, op.trackByFn, op.usesComponentInstance, emptyViewFnName, emptyDecls, emptyVars, op.emptyTag, op.emptyAttributes, op.wholeSourceSpan));
23281
23306
  break;
23307
+ case OpKind.SourceLocation:
23308
+ const locationsLiteral = literalArr(op.locations.map(({ targetSlot, offset, line, column }) => {
23309
+ if (targetSlot.slot === null) {
23310
+ throw new Error('No slot was assigned for source location');
23311
+ }
23312
+ return literalArr([
23313
+ literal(targetSlot.slot),
23314
+ literal(offset),
23315
+ literal(line),
23316
+ literal(column),
23317
+ ]);
23318
+ }));
23319
+ OpList.replace(op, attachSourceLocation(op.templatePath, locationsLiteral));
23320
+ break;
23282
23321
  case OpKind.Statement:
23283
23322
  // Pass statement operations directly through.
23284
23323
  break;
@@ -25238,6 +25277,33 @@ function generateLocalLetReferences(job) {
25238
25277
  }
25239
25278
  }
25240
25279
 
25280
+ /**
25281
+ * Locates all of the elements defined in a creation block and outputs an op
25282
+ * that will expose their definition location in the DOM.
25283
+ */
25284
+ function attachSourceLocations(job) {
25285
+ if (!job.enableDebugLocations || job.relativeTemplatePath === null) {
25286
+ return;
25287
+ }
25288
+ for (const unit of job.units) {
25289
+ const locations = [];
25290
+ for (const op of unit.create) {
25291
+ if (op.kind === OpKind.ElementStart || op.kind === OpKind.Element) {
25292
+ const start = op.startSourceSpan.start;
25293
+ locations.push({
25294
+ targetSlot: op.handle,
25295
+ offset: start.offset,
25296
+ line: start.line,
25297
+ column: start.col,
25298
+ });
25299
+ }
25300
+ }
25301
+ if (locations.length > 0) {
25302
+ unit.create.push(createSourceLocationOp(job.relativeTemplatePath, locations));
25303
+ }
25304
+ }
25305
+ }
25306
+
25241
25307
  /**
25242
25308
  *
25243
25309
  * @license
@@ -25307,6 +25373,7 @@ const phases = [
25307
25373
  { kind: CompilationJobKind.Tmpl, fn: mergeNextContextExpressions },
25308
25374
  { kind: CompilationJobKind.Tmpl, fn: generateNgContainerOps },
25309
25375
  { kind: CompilationJobKind.Tmpl, fn: collapseEmptyInstructions },
25376
+ { kind: CompilationJobKind.Tmpl, fn: attachSourceLocations },
25310
25377
  { kind: CompilationJobKind.Tmpl, fn: disableBindings$1 },
25311
25378
  { kind: CompilationJobKind.Both, fn: extractPureFunctions },
25312
25379
  { kind: CompilationJobKind.Both, fn: reify },
@@ -25425,8 +25492,8 @@ function isSingleI18nIcu(meta) {
25425
25492
  * representation.
25426
25493
  * TODO: Refactor more of the ingestion code into phases.
25427
25494
  */
25428
- function ingestComponent(componentName, template, constantPool, relativeContextFilePath, i18nUseExternalIds, deferMeta, allDeferrableDepsFn) {
25429
- const job = new ComponentCompilationJob(componentName, constantPool, compatibilityMode, relativeContextFilePath, i18nUseExternalIds, deferMeta, allDeferrableDepsFn);
25495
+ function ingestComponent(componentName, template, constantPool, relativeContextFilePath, i18nUseExternalIds, deferMeta, allDeferrableDepsFn, relativeTemplatePath, enableDebugLocations) {
25496
+ const job = new ComponentCompilationJob(componentName, constantPool, compatibilityMode, relativeContextFilePath, i18nUseExternalIds, deferMeta, allDeferrableDepsFn, relativeTemplatePath, enableDebugLocations);
25430
25497
  ingestNodes(job.root, template);
25431
25498
  return job;
25432
25499
  }
@@ -26450,6 +26517,32 @@ function ingestControlFlowInsertionPoint(unit, xref, node) {
26450
26517
  return null;
26451
26518
  }
26452
26519
 
26520
+ /*!
26521
+ * @license
26522
+ * Copyright Google LLC All Rights Reserved.
26523
+ *
26524
+ * Use of this source code is governed by an MIT-style license that can be
26525
+ * found in the LICENSE file at https://angular.dev/license
26526
+ */
26527
+ /**
26528
+ * Whether to produce instructions that will attach the source location to each DOM node.
26529
+ *
26530
+ * !!!Important!!! at the time of writing this flag isn't exposed externally, but internal debug
26531
+ * tools enable it via a local change. Any modifications to this flag need to update the
26532
+ * internal tooling as well.
26533
+ */
26534
+ let ENABLE_TEMPLATE_SOURCE_LOCATIONS = false;
26535
+ /**
26536
+ * Utility function to enable source locations. Intended to be used **only** inside unit tests.
26537
+ */
26538
+ function setEnableTemplateSourceLocations(value) {
26539
+ ENABLE_TEMPLATE_SOURCE_LOCATIONS = value;
26540
+ }
26541
+ /** Gets whether template source locations are enabled. */
26542
+ function getTemplateSourceLocationsEnabled() {
26543
+ return ENABLE_TEMPLATE_SOURCE_LOCATIONS;
26544
+ }
26545
+
26453
26546
  // if (rf & flags) { .. }
26454
26547
  function renderFlagCheckIfStmt(flags, statements) {
26455
26548
  return ifStmt(variable(RENDER_FLAGS).bitwiseAnd(literal(flags), null, false), statements);
@@ -28893,7 +28986,7 @@ function compileComponentFromMetadata(meta, constantPool, bindingParser) {
28893
28986
  allDeferrableDepsFn = variable(fnName);
28894
28987
  }
28895
28988
  // First the template is ingested into IR:
28896
- const tpl = ingestComponent(meta.name, meta.template.nodes, constantPool, meta.relativeContextFilePath, meta.i18nUseExternalIds, meta.defer, allDeferrableDepsFn);
28989
+ const tpl = ingestComponent(meta.name, meta.template.nodes, constantPool, meta.relativeContextFilePath, meta.i18nUseExternalIds, meta.defer, allDeferrableDepsFn, meta.relativeTemplatePath, getTemplateSourceLocationsEnabled());
28897
28990
  // Then the IR is transformed to prepare it for cod egeneration.
28898
28991
  transform(tpl, CompilationJobKind.Tmpl);
28899
28992
  // Finally we emit the template function:
@@ -30353,6 +30446,7 @@ class CompilerFacadeImpl {
30353
30446
  viewProviders: facade.viewProviders != null ? new WrappedNodeExpr(facade.viewProviders) : null,
30354
30447
  relativeContextFilePath: '',
30355
30448
  i18nUseExternalIds: true,
30449
+ relativeTemplatePath: null,
30356
30450
  };
30357
30451
  const jitExpressionSourceMap = `ng:///${facade.name}.js`;
30358
30452
  return this.compileComponentFromMeta(angularCoreEnv, jitExpressionSourceMap, meta);
@@ -30608,6 +30702,7 @@ function convertDeclareComponentFacadeToMetadata(decl, typeSourceSpan, sourceMap
30608
30702
  declarationListEmitMode: 2 /* DeclarationListEmitMode.ClosureResolved */,
30609
30703
  relativeContextFilePath: '',
30610
30704
  i18nUseExternalIds: true,
30705
+ relativeTemplatePath: null,
30611
30706
  };
30612
30707
  }
30613
30708
  function convertDeclarationFacadeToMetadata(declaration) {
@@ -30883,7 +30978,7 @@ function publishFacade(global) {
30883
30978
  * @description
30884
30979
  * Entry point for all public APIs of the compiler package.
30885
30980
  */
30886
- const VERSION = new Version('19.1.0-next.2');
30981
+ const VERSION = new Version('19.1.0-next.3');
30887
30982
 
30888
30983
  class CompilerConfig {
30889
30984
  defaultEncapsulation;
@@ -32735,7 +32830,7 @@ const MINIMUM_PARTIAL_LINKER_DEFER_SUPPORT_VERSION = '18.0.0';
32735
32830
  function compileDeclareClassMetadata(metadata) {
32736
32831
  const definitionMap = new DefinitionMap();
32737
32832
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$5));
32738
- definitionMap.set('version', literal('19.1.0-next.2'));
32833
+ definitionMap.set('version', literal('19.1.0-next.3'));
32739
32834
  definitionMap.set('ngImport', importExpr(Identifiers.core));
32740
32835
  definitionMap.set('type', metadata.type);
32741
32836
  definitionMap.set('decorators', metadata.decorators);
@@ -32753,7 +32848,7 @@ function compileComponentDeclareClassMetadata(metadata, dependencies) {
32753
32848
  callbackReturnDefinitionMap.set('ctorParameters', metadata.ctorParameters ?? literal(null));
32754
32849
  callbackReturnDefinitionMap.set('propDecorators', metadata.propDecorators ?? literal(null));
32755
32850
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_DEFER_SUPPORT_VERSION));
32756
- definitionMap.set('version', literal('19.1.0-next.2'));
32851
+ definitionMap.set('version', literal('19.1.0-next.3'));
32757
32852
  definitionMap.set('ngImport', importExpr(Identifiers.core));
32758
32853
  definitionMap.set('type', metadata.type);
32759
32854
  definitionMap.set('resolveDeferredDeps', compileComponentMetadataAsyncResolver(dependencies));
@@ -32848,7 +32943,7 @@ function createDirectiveDefinitionMap(meta) {
32848
32943
  const definitionMap = new DefinitionMap();
32849
32944
  const minVersion = getMinimumVersionForPartialOutput(meta);
32850
32945
  definitionMap.set('minVersion', literal(minVersion));
32851
- definitionMap.set('version', literal('19.1.0-next.2'));
32946
+ definitionMap.set('version', literal('19.1.0-next.3'));
32852
32947
  // e.g. `type: MyDirective`
32853
32948
  definitionMap.set('type', meta.type.value);
32854
32949
  if (meta.isStandalone !== undefined) {
@@ -33267,7 +33362,7 @@ const MINIMUM_PARTIAL_LINKER_VERSION$4 = '12.0.0';
33267
33362
  function compileDeclareFactoryFunction(meta) {
33268
33363
  const definitionMap = new DefinitionMap();
33269
33364
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$4));
33270
- definitionMap.set('version', literal('19.1.0-next.2'));
33365
+ definitionMap.set('version', literal('19.1.0-next.3'));
33271
33366
  definitionMap.set('ngImport', importExpr(Identifiers.core));
33272
33367
  definitionMap.set('type', meta.type.value);
33273
33368
  definitionMap.set('deps', compileDependencies(meta.deps));
@@ -33302,7 +33397,7 @@ function compileDeclareInjectableFromMetadata(meta) {
33302
33397
  function createInjectableDefinitionMap(meta) {
33303
33398
  const definitionMap = new DefinitionMap();
33304
33399
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$3));
33305
- definitionMap.set('version', literal('19.1.0-next.2'));
33400
+ definitionMap.set('version', literal('19.1.0-next.3'));
33306
33401
  definitionMap.set('ngImport', importExpr(Identifiers.core));
33307
33402
  definitionMap.set('type', meta.type.value);
33308
33403
  // Only generate providedIn property if it has a non-null value
@@ -33353,7 +33448,7 @@ function compileDeclareInjectorFromMetadata(meta) {
33353
33448
  function createInjectorDefinitionMap(meta) {
33354
33449
  const definitionMap = new DefinitionMap();
33355
33450
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$2));
33356
- definitionMap.set('version', literal('19.1.0-next.2'));
33451
+ definitionMap.set('version', literal('19.1.0-next.3'));
33357
33452
  definitionMap.set('ngImport', importExpr(Identifiers.core));
33358
33453
  definitionMap.set('type', meta.type.value);
33359
33454
  definitionMap.set('providers', meta.providers);
@@ -33386,7 +33481,7 @@ function createNgModuleDefinitionMap(meta) {
33386
33481
  throw new Error('Invalid path! Local compilation mode should not get into the partial compilation path');
33387
33482
  }
33388
33483
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$1));
33389
- definitionMap.set('version', literal('19.1.0-next.2'));
33484
+ definitionMap.set('version', literal('19.1.0-next.3'));
33390
33485
  definitionMap.set('ngImport', importExpr(Identifiers.core));
33391
33486
  definitionMap.set('type', meta.type.value);
33392
33487
  // We only generate the keys in the metadata if the arrays contain values.
@@ -33437,7 +33532,7 @@ function compileDeclarePipeFromMetadata(meta) {
33437
33532
  function createPipeDefinitionMap(meta) {
33438
33533
  const definitionMap = new DefinitionMap();
33439
33534
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION));
33440
- definitionMap.set('version', literal('19.1.0-next.2'));
33535
+ definitionMap.set('version', literal('19.1.0-next.3'));
33441
33536
  definitionMap.set('ngImport', importExpr(Identifiers.core));
33442
33537
  // e.g. `type: MyPipe`
33443
33538
  definitionMap.set('type', meta.type.value);