@angular/compiler 14.0.0-next.3 → 14.0.0-next.6

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 v14.0.0-next.3
2
+ * @license Angular v14.0.0-next.6
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -1 +1 @@
1
- {"version":3,"file":"testing.mjs","sources":["../../../../../../packages/compiler/testing/src/testing.ts","../../../../../../packages/compiler/testing/public_api.ts","../../../../../../packages/compiler/testing/index.ts","../../../../../../packages/compiler/testing/testing.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\n/**\n * @module\n * @description\n * Entry point for all APIs of the compiler package.\n *\n * <div class=\"callout is-critical\">\n * <header>Unstable APIs</header>\n * <p>\n * All compiler apis are currently considered experimental and private!\n * </p>\n * <p>\n * We expect the APIs in this package to keep on changing. Do not rely on them.\n * </p>\n * </div>\n */\n\n// TODO(alxhub): @angular/compiler/testing is unused in Ivy. A placeholder\n// is left here because the components repo still depends on this package\n// directly. It will be cleaned up at a later date.\n//\n// This export ensures this package is not empty.\nexport const unusedExport = true;\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\n/// <reference types=\"node\" />\n\n/**\n * @module\n * @description\n * Entry point for all public APIs of this package.\n */\nexport * from './src/testing';\n\n// This file only reexports content of the `src` folder. Keep it that way.\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\n// This file is not used to build this module. It is only used during editing\n// by the TypeScript language service and during build for verification. `ngc`\n// replaces this file with production index.ts when it rewrites private symbol\n// names.\n\nexport * from './public_api';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AAAA;;;;;;;AAQA;;;;;;;;;;;;;;;AAgBA;AACA;AACA;AACA;AACA;MACa,YAAY,GAAG;;AC7B5B;;;;;;;AAiBA;;ACjBA;;;;;;;;ACAA;;;;;;"}
1
+ {"version":3,"file":"testing.mjs","sources":["../../../../../../packages/compiler/testing/src/testing.ts","../../../../../../packages/compiler/testing/public_api.ts","../../../../../../packages/compiler/testing/index.ts","../../../../../../packages/compiler/testing/testing.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\n/**\n * @module\n * @description\n * Entry point for all APIs of the compiler package.\n *\n * <div class=\"callout is-critical\">\n * <header>Unstable APIs</header>\n * <p>\n * All compiler apis are currently considered experimental and private!\n * </p>\n * <p>\n * We expect the APIs in this package to keep on changing. Do not rely on them.\n * </p>\n * </div>\n */\n\n// TODO(alxhub): @angular/compiler/testing is unused in Ivy. A placeholder\n// is left here because the components repo still depends on this package\n// directly. It will be cleaned up at a later date.\n//\n// This export ensures this package is not empty.\nexport const unusedExport = true;\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\n/// <reference types=\"node\" />\n\n/**\n * @module\n * @description\n * Entry point for all public APIs of this package.\n */\nexport * from './src/testing';\n\n// This file only reexports content of the `src` folder. Keep it that way.\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\n// This file is not used to build this module. It is only used during editing\n// by the TypeScript language service and during build for verification. `ngc`\n// replaces this file with production index.ts when it rewrites private symbol\n// names.\n\nexport * from './public_api';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AAAA;;;;;;AAMG;AAEH;;;;;;;;;;;;;;AAcG;AAEH;AACA;AACA;AACA;AACA;AACO,MAAM,YAAY,GAAG;;AC7B5B;;;;;;AAMG;AAWH;;ACjBA;;;;;;AAMG;;ACNH;;AAEG;;;;"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v14.0.0-next.3
2
+ * @license Angular v14.0.0-next.6
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -9499,8 +9499,8 @@ class Parser$1 {
9499
9499
  span: new AbsoluteSourceSpan(absoluteKeyOffset, absoluteKeyOffset + templateKey.length),
9500
9500
  });
9501
9501
  }
9502
- parseInterpolation(input, location, absoluteOffset, interpolationConfig = DEFAULT_INTERPOLATION_CONFIG) {
9503
- const { strings, expressions, offsets } = this.splitInterpolation(input, location, interpolationConfig);
9502
+ parseInterpolation(input, location, absoluteOffset, interpolatedTokens, interpolationConfig = DEFAULT_INTERPOLATION_CONFIG) {
9503
+ const { strings, expressions, offsets } = this.splitInterpolation(input, location, interpolatedTokens, interpolationConfig);
9504
9504
  if (expressions.length === 0)
9505
9505
  return null;
9506
9506
  const expressionNodes = [];
@@ -9539,10 +9539,11 @@ class Parser$1 {
9539
9539
  * `SplitInterpolation` with splits that look like
9540
9540
  * <raw text> <expression> <raw text> ... <raw text> <expression> <raw text>
9541
9541
  */
9542
- splitInterpolation(input, location, interpolationConfig = DEFAULT_INTERPOLATION_CONFIG) {
9542
+ splitInterpolation(input, location, interpolatedTokens, interpolationConfig = DEFAULT_INTERPOLATION_CONFIG) {
9543
9543
  const strings = [];
9544
9544
  const expressions = [];
9545
9545
  const offsets = [];
9546
+ const inputToTemplateIndexMap = interpolatedTokens ? getIndexMapForOriginalTemplate(interpolatedTokens) : null;
9546
9547
  let i = 0;
9547
9548
  let atInterpolation = false;
9548
9549
  let extendLastString = false;
@@ -9577,7 +9578,9 @@ class Parser$1 {
9577
9578
  this._reportError('Blank expressions are not allowed in interpolated strings', input, `at column ${i} in`, location);
9578
9579
  }
9579
9580
  expressions.push({ text, start: fullStart, end: fullEnd });
9580
- offsets.push(exprStart);
9581
+ const startInOriginalTemplate = inputToTemplateIndexMap?.get(fullStart) ?? fullStart;
9582
+ const offset = startInOriginalTemplate + interpStart.length;
9583
+ offsets.push(offset);
9581
9584
  i = fullEnd;
9582
9585
  atInterpolation = false;
9583
9586
  }
@@ -10585,6 +10588,41 @@ class SimpleExpressionChecker extends RecursiveAstVisitor {
10585
10588
  this.errors.push('pipes');
10586
10589
  }
10587
10590
  }
10591
+ /**
10592
+ * Computes the real offset in the original template for indexes in an interpolation.
10593
+ *
10594
+ * Because templates can have encoded HTML entities and the input passed to the parser at this stage
10595
+ * of the compiler is the _decoded_ value, we need to compute the real offset using the original
10596
+ * encoded values in the interpolated tokens. Note that this is only a special case handling for
10597
+ * `MlParserTokenType.ENCODED_ENTITY` token types. All other interpolated tokens are expected to
10598
+ * have parts which exactly match the input string for parsing the interpolation.
10599
+ *
10600
+ * @param interpolatedTokens The tokens for the interpolated value.
10601
+ *
10602
+ * @returns A map of index locations in the decoded template to indexes in the original template
10603
+ */
10604
+ function getIndexMapForOriginalTemplate(interpolatedTokens) {
10605
+ let offsetMap = new Map();
10606
+ let consumedInOriginalTemplate = 0;
10607
+ let consumedInInput = 0;
10608
+ let tokenIndex = 0;
10609
+ while (tokenIndex < interpolatedTokens.length) {
10610
+ const currentToken = interpolatedTokens[tokenIndex];
10611
+ if (currentToken.type === 9 /* ENCODED_ENTITY */) {
10612
+ const [decoded, encoded] = currentToken.parts;
10613
+ consumedInOriginalTemplate += encoded.length;
10614
+ consumedInInput += decoded.length;
10615
+ }
10616
+ else {
10617
+ const lengthOfParts = currentToken.parts.reduce((sum, current) => sum + current.length, 0);
10618
+ consumedInInput += lengthOfParts;
10619
+ consumedInOriginalTemplate += lengthOfParts;
10620
+ }
10621
+ offsetMap.set(consumedInInput, consumedInOriginalTemplate);
10622
+ tokenIndex++;
10623
+ }
10624
+ return offsetMap;
10625
+ }
10588
10626
 
10589
10627
  /**
10590
10628
  * @license
@@ -14990,11 +15028,11 @@ class BindingParser {
14990
15028
  }
14991
15029
  return targetEvents;
14992
15030
  }
14993
- parseInterpolation(value, sourceSpan) {
15031
+ parseInterpolation(value, sourceSpan, interpolatedTokens) {
14994
15032
  const sourceInfo = sourceSpan.start.toString();
14995
15033
  const absoluteOffset = sourceSpan.fullStart.offset;
14996
15034
  try {
14997
- const ast = this._exprParser.parseInterpolation(value, sourceInfo, absoluteOffset, this._interpolationConfig);
15035
+ const ast = this._exprParser.parseInterpolation(value, sourceInfo, absoluteOffset, interpolatedTokens, this._interpolationConfig);
14998
15036
  if (ast)
14999
15037
  this._reportExpressionParserErrors(ast.errors, sourceSpan);
15000
15038
  return ast;
@@ -15131,8 +15169,8 @@ class BindingParser {
15131
15169
  this._parsePropertyAst(name, this._parseBinding(expression, isHost, valueSpan || sourceSpan, absoluteOffset), sourceSpan, keySpan, valueSpan, targetMatchableAttrs, targetProps);
15132
15170
  }
15133
15171
  }
15134
- parsePropertyInterpolation(name, value, sourceSpan, valueSpan, targetMatchableAttrs, targetProps, keySpan) {
15135
- const expr = this.parseInterpolation(value, valueSpan || sourceSpan);
15172
+ parsePropertyInterpolation(name, value, sourceSpan, valueSpan, targetMatchableAttrs, targetProps, keySpan, interpolatedTokens) {
15173
+ const expr = this.parseInterpolation(value, valueSpan || sourceSpan, interpolatedTokens);
15136
15174
  if (expr) {
15137
15175
  this._parsePropertyAst(name, expr, sourceSpan, keySpan, valueSpan, targetMatchableAttrs, targetProps);
15138
15176
  return true;
@@ -15629,7 +15667,7 @@ class HtmlAstToIvyAst {
15629
15667
  return new TextAttribute(attribute.name, attribute.value, attribute.sourceSpan, attribute.keySpan, attribute.valueSpan, attribute.i18n);
15630
15668
  }
15631
15669
  visitText(text) {
15632
- return this._visitTextWithInterpolation(text.value, text.sourceSpan, text.i18n);
15670
+ return this._visitTextWithInterpolation(text.value, text.sourceSpan, text.tokens, text.i18n);
15633
15671
  }
15634
15672
  visitExpansion(expansion) {
15635
15673
  if (!expansion.i18n) {
@@ -15659,7 +15697,7 @@ class HtmlAstToIvyAst {
15659
15697
  vars[formattedKey] = new BoundText(ast, value.sourceSpan);
15660
15698
  }
15661
15699
  else {
15662
- placeholders[key] = this._visitTextWithInterpolation(value.text, value.sourceSpan);
15700
+ placeholders[key] = this._visitTextWithInterpolation(value.text, value.sourceSpan, null);
15663
15701
  }
15664
15702
  });
15665
15703
  return new Icu$1(vars, placeholders, expansion.sourceSpan, message);
@@ -15782,12 +15820,12 @@ class HtmlAstToIvyAst {
15782
15820
  }
15783
15821
  // No explicit binding found.
15784
15822
  const keySpan = createKeySpan(srcSpan, '' /* prefix */, name);
15785
- const hasBinding = this.bindingParser.parsePropertyInterpolation(name, value, srcSpan, attribute.valueSpan, matchableAttributes, parsedProperties, keySpan);
15823
+ const hasBinding = this.bindingParser.parsePropertyInterpolation(name, value, srcSpan, attribute.valueSpan, matchableAttributes, parsedProperties, keySpan, attribute.valueTokens ?? null);
15786
15824
  return hasBinding;
15787
15825
  }
15788
- _visitTextWithInterpolation(value, sourceSpan, i18n) {
15826
+ _visitTextWithInterpolation(value, sourceSpan, interpolatedTokens, i18n) {
15789
15827
  const valueNoNgsp = replaceNgsp(value);
15790
- const expr = this.bindingParser.parseInterpolation(valueNoNgsp, sourceSpan);
15828
+ const expr = this.bindingParser.parseInterpolation(valueNoNgsp, sourceSpan, interpolatedTokens);
15791
15829
  return expr ? new BoundText(expr, sourceSpan, i18n) : new Text$3(valueNoNgsp, sourceSpan);
15792
15830
  }
15793
15831
  parseVariable(identifier, value, sourceSpan, keySpan, valueSpan, variables) {
@@ -19676,7 +19714,7 @@ function publishFacade(global) {
19676
19714
  * Use of this source code is governed by an MIT-style license that can be
19677
19715
  * found in the LICENSE file at https://angular.io/license
19678
19716
  */
19679
- const VERSION = new Version('14.0.0-next.3');
19717
+ const VERSION = new Version('14.0.0-next.6');
19680
19718
 
19681
19719
  /**
19682
19720
  * @license
@@ -21717,7 +21755,7 @@ const MINIMUM_PARTIAL_LINKER_VERSION$6 = '12.0.0';
21717
21755
  function compileDeclareClassMetadata(metadata) {
21718
21756
  const definitionMap = new DefinitionMap();
21719
21757
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$6));
21720
- definitionMap.set('version', literal('14.0.0-next.3'));
21758
+ definitionMap.set('version', literal('14.0.0-next.6'));
21721
21759
  definitionMap.set('ngImport', importExpr(Identifiers.core));
21722
21760
  definitionMap.set('type', metadata.type);
21723
21761
  definitionMap.set('decorators', metadata.decorators);
@@ -21834,7 +21872,7 @@ function compileDeclareDirectiveFromMetadata(meta) {
21834
21872
  function createDirectiveDefinitionMap(meta) {
21835
21873
  const definitionMap = new DefinitionMap();
21836
21874
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$5));
21837
- definitionMap.set('version', literal('14.0.0-next.3'));
21875
+ definitionMap.set('version', literal('14.0.0-next.6'));
21838
21876
  // e.g. `type: MyDirective`
21839
21877
  definitionMap.set('type', meta.internalType);
21840
21878
  // e.g. `selector: 'some-dir'`
@@ -22055,7 +22093,7 @@ const MINIMUM_PARTIAL_LINKER_VERSION$4 = '12.0.0';
22055
22093
  function compileDeclareFactoryFunction(meta) {
22056
22094
  const definitionMap = new DefinitionMap();
22057
22095
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$4));
22058
- definitionMap.set('version', literal('14.0.0-next.3'));
22096
+ definitionMap.set('version', literal('14.0.0-next.6'));
22059
22097
  definitionMap.set('ngImport', importExpr(Identifiers.core));
22060
22098
  definitionMap.set('type', meta.internalType);
22061
22099
  definitionMap.set('deps', compileDependencies(meta.deps));
@@ -22097,7 +22135,7 @@ function compileDeclareInjectableFromMetadata(meta) {
22097
22135
  function createInjectableDefinitionMap(meta) {
22098
22136
  const definitionMap = new DefinitionMap();
22099
22137
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$3));
22100
- definitionMap.set('version', literal('14.0.0-next.3'));
22138
+ definitionMap.set('version', literal('14.0.0-next.6'));
22101
22139
  definitionMap.set('ngImport', importExpr(Identifiers.core));
22102
22140
  definitionMap.set('type', meta.internalType);
22103
22141
  // Only generate providedIn property if it has a non-null value
@@ -22155,7 +22193,7 @@ function compileDeclareInjectorFromMetadata(meta) {
22155
22193
  function createInjectorDefinitionMap(meta) {
22156
22194
  const definitionMap = new DefinitionMap();
22157
22195
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$2));
22158
- definitionMap.set('version', literal('14.0.0-next.3'));
22196
+ definitionMap.set('version', literal('14.0.0-next.6'));
22159
22197
  definitionMap.set('ngImport', importExpr(Identifiers.core));
22160
22198
  definitionMap.set('type', meta.internalType);
22161
22199
  definitionMap.set('providers', meta.providers);
@@ -22192,7 +22230,7 @@ function compileDeclareNgModuleFromMetadata(meta) {
22192
22230
  function createNgModuleDefinitionMap(meta) {
22193
22231
  const definitionMap = new DefinitionMap();
22194
22232
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$1));
22195
- definitionMap.set('version', literal('14.0.0-next.3'));
22233
+ definitionMap.set('version', literal('14.0.0-next.6'));
22196
22234
  definitionMap.set('ngImport', importExpr(Identifiers.core));
22197
22235
  definitionMap.set('type', meta.internalType);
22198
22236
  // We only generate the keys in the metadata if the arrays contain values.
@@ -22250,7 +22288,7 @@ function compileDeclarePipeFromMetadata(meta) {
22250
22288
  function createPipeDefinitionMap(meta) {
22251
22289
  const definitionMap = new DefinitionMap();
22252
22290
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION));
22253
- definitionMap.set('version', literal('14.0.0-next.3'));
22291
+ definitionMap.set('version', literal('14.0.0-next.6'));
22254
22292
  definitionMap.set('ngImport', importExpr(Identifiers.core));
22255
22293
  // e.g. `type: MyPipe`
22256
22294
  definitionMap.set('type', meta.internalType);