@angular/language-service 13.0.2 → 13.0.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 v13.0.2
2
+ * @license Angular v13.0.3
3
3
  * Copyright Google LLC All Rights Reserved.
4
4
  * License: MIT
5
5
  */
@@ -16869,7 +16869,8 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
16869
16869
  */
16870
16870
  _parseMetadata(meta) {
16871
16871
  return typeof meta === 'string' ? parseI18nMeta(meta) :
16872
- meta instanceof Message ? meta : {};
16872
+ meta instanceof Message ? meta :
16873
+ {};
16873
16874
  }
16874
16875
  /**
16875
16876
  * Generate (or restore) message id if not specified already.
@@ -16894,9 +16895,9 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
16894
16895
  // `packages/compiler/src/render3/view/template.ts`).
16895
16896
  // In that case we want to reuse the legacy message generated in the 1st pass (see
16896
16897
  // `setI18nRefs()`).
16897
- const previousMessage = meta instanceof Message ?
16898
- meta :
16899
- meta instanceof IcuPlaceholder ? meta.previousMessage : undefined;
16898
+ const previousMessage = meta instanceof Message ? meta :
16899
+ meta instanceof IcuPlaceholder ? meta.previousMessage :
16900
+ undefined;
16900
16901
  message.legacyIds = previousMessage ? previousMessage.legacyIds : [];
16901
16902
  }
16902
16903
  }
@@ -20015,7 +20016,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
20015
20016
  * Use of this source code is governed by an MIT-style license that can be
20016
20017
  * found in the LICENSE file at https://angular.io/license
20017
20018
  */
20018
- new Version('13.0.2');
20019
+ new Version('13.0.3');
20019
20020
 
20020
20021
  /**
20021
20022
  * @license
@@ -20644,7 +20645,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
20644
20645
  function compileDeclareClassMetadata(metadata) {
20645
20646
  const definitionMap = new DefinitionMap();
20646
20647
  definitionMap.set('minVersion', literal$1(MINIMUM_PARTIAL_LINKER_VERSION$6));
20647
- definitionMap.set('version', literal$1('13.0.2'));
20648
+ definitionMap.set('version', literal$1('13.0.3'));
20648
20649
  definitionMap.set('ngImport', importExpr(Identifiers$1.core));
20649
20650
  definitionMap.set('type', metadata.type);
20650
20651
  definitionMap.set('decorators', metadata.decorators);
@@ -20761,7 +20762,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
20761
20762
  function createDirectiveDefinitionMap(meta) {
20762
20763
  const definitionMap = new DefinitionMap();
20763
20764
  definitionMap.set('minVersion', literal$1(MINIMUM_PARTIAL_LINKER_VERSION$5));
20764
- definitionMap.set('version', literal$1('13.0.2'));
20765
+ definitionMap.set('version', literal$1('13.0.3'));
20765
20766
  // e.g. `type: MyDirective`
20766
20767
  definitionMap.set('type', meta.internalType);
20767
20768
  // e.g. `selector: 'some-dir'`
@@ -20979,7 +20980,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
20979
20980
  function compileDeclareFactoryFunction(meta) {
20980
20981
  const definitionMap = new DefinitionMap();
20981
20982
  definitionMap.set('minVersion', literal$1(MINIMUM_PARTIAL_LINKER_VERSION$4));
20982
- definitionMap.set('version', literal$1('13.0.2'));
20983
+ definitionMap.set('version', literal$1('13.0.3'));
20983
20984
  definitionMap.set('ngImport', importExpr(Identifiers$1.core));
20984
20985
  definitionMap.set('type', meta.internalType);
20985
20986
  definitionMap.set('deps', compileDependencies(meta.deps));
@@ -21021,7 +21022,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
21021
21022
  function createInjectableDefinitionMap(meta) {
21022
21023
  const definitionMap = new DefinitionMap();
21023
21024
  definitionMap.set('minVersion', literal$1(MINIMUM_PARTIAL_LINKER_VERSION$3));
21024
- definitionMap.set('version', literal$1('13.0.2'));
21025
+ definitionMap.set('version', literal$1('13.0.3'));
21025
21026
  definitionMap.set('ngImport', importExpr(Identifiers$1.core));
21026
21027
  definitionMap.set('type', meta.internalType);
21027
21028
  // Only generate providedIn property if it has a non-null value
@@ -21079,7 +21080,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
21079
21080
  function createInjectorDefinitionMap(meta) {
21080
21081
  const definitionMap = new DefinitionMap();
21081
21082
  definitionMap.set('minVersion', literal$1(MINIMUM_PARTIAL_LINKER_VERSION$2));
21082
- definitionMap.set('version', literal$1('13.0.2'));
21083
+ definitionMap.set('version', literal$1('13.0.3'));
21083
21084
  definitionMap.set('ngImport', importExpr(Identifiers$1.core));
21084
21085
  definitionMap.set('type', meta.internalType);
21085
21086
  definitionMap.set('providers', meta.providers);
@@ -21116,7 +21117,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
21116
21117
  function createNgModuleDefinitionMap(meta) {
21117
21118
  const definitionMap = new DefinitionMap();
21118
21119
  definitionMap.set('minVersion', literal$1(MINIMUM_PARTIAL_LINKER_VERSION$1));
21119
- definitionMap.set('version', literal$1('13.0.2'));
21120
+ definitionMap.set('version', literal$1('13.0.3'));
21120
21121
  definitionMap.set('ngImport', importExpr(Identifiers$1.core));
21121
21122
  definitionMap.set('type', meta.internalType);
21122
21123
  // We only generate the keys in the metadata if the arrays contain values.
@@ -21174,7 +21175,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
21174
21175
  function createPipeDefinitionMap(meta) {
21175
21176
  const definitionMap = new DefinitionMap();
21176
21177
  definitionMap.set('minVersion', literal$1(MINIMUM_PARTIAL_LINKER_VERSION));
21177
- definitionMap.set('version', literal$1('13.0.2'));
21178
+ definitionMap.set('version', literal$1('13.0.3'));
21178
21179
  definitionMap.set('ngImport', importExpr(Identifiers$1.core));
21179
21180
  // e.g. `type: MyPipe`
21180
21181
  definitionMap.set('type', meta.internalType);
@@ -21206,7 +21207,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
21206
21207
  * Use of this source code is governed by an MIT-style license that can be
21207
21208
  * found in the LICENSE file at https://angular.io/license
21208
21209
  */
21209
- new Version('13.0.2');
21210
+ new Version('13.0.3');
21210
21211
 
21211
21212
  /**
21212
21213
  * @license
@@ -24834,6 +24835,28 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
24834
24835
  return result;
24835
24836
  }
24836
24837
  }
24838
+ class StringConcatBuiltinFn extends KnownFn {
24839
+ constructor(lhs) {
24840
+ super();
24841
+ this.lhs = lhs;
24842
+ }
24843
+ evaluate(node, args) {
24844
+ let result = this.lhs;
24845
+ for (const arg of args) {
24846
+ const resolved = arg instanceof EnumValue ? arg.resolved : arg;
24847
+ if (typeof resolved === 'string' || typeof resolved === 'number' ||
24848
+ typeof resolved === 'boolean' || resolved == null) {
24849
+ // Cast to `any`, because `concat` will convert
24850
+ // anything to a string, but TS only allows strings.
24851
+ result = result.concat(resolved);
24852
+ }
24853
+ else {
24854
+ return DynamicValue.fromUnknown(node);
24855
+ }
24856
+ }
24857
+ return result;
24858
+ }
24859
+ }
24837
24860
  class ObjectAssignBuiltinFn extends KnownFn {
24838
24861
  evaluate(node, args) {
24839
24862
  if (args.length === 0) {
@@ -25339,6 +25362,9 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
25339
25362
  }
25340
25363
  return lhs[rhs];
25341
25364
  }
25365
+ else if (typeof lhs === 'string' && rhs === 'concat') {
25366
+ return new StringConcatBuiltinFn(lhs);
25367
+ }
25342
25368
  else if (lhs instanceof Reference) {
25343
25369
  const ref = lhs.node;
25344
25370
  if (this.host.isClass(ref)) {
@@ -34334,120 +34360,6 @@ Either add the @Injectable() decorator to '${provider.node.name
34334
34360
  }
34335
34361
  }
34336
34362
 
34337
- /**
34338
- * @license
34339
- * Copyright Google LLC All Rights Reserved.
34340
- *
34341
- * Use of this source code is governed by an MIT-style license that can be
34342
- * found in the LICENSE file at https://angular.io/license
34343
- */
34344
- const IVY_SWITCH_PRE_SUFFIX = '__PRE_R3__';
34345
- const IVY_SWITCH_POST_SUFFIX = '__POST_R3__';
34346
- function ivySwitchTransform(_) {
34347
- return flipIvySwitchInFile;
34348
- }
34349
- function flipIvySwitchInFile(sf) {
34350
- // To replace the statements array, it must be copied. This only needs to happen if a statement
34351
- // must actually be replaced within the array, so the newStatements array is lazily initialized.
34352
- let newStatements = undefined;
34353
- // Iterate over the statements in the file.
34354
- for (let i = 0; i < sf.statements.length; i++) {
34355
- const statement = sf.statements[i];
34356
- // Skip over everything that isn't a variable statement.
34357
- if (!ts__default["default"].isVariableStatement(statement) || !hasIvySwitches(statement)) {
34358
- continue;
34359
- }
34360
- // This statement needs to be replaced. Check if the newStatements array needs to be lazily
34361
- // initialized to a copy of the original statements.
34362
- if (newStatements === undefined) {
34363
- newStatements = [...sf.statements];
34364
- }
34365
- // Flip any switches in the VariableStatement. If there were any, a new statement will be
34366
- // returned; otherwise the old statement will be.
34367
- newStatements[i] = flipIvySwitchesInVariableStatement(statement, sf.statements);
34368
- }
34369
- // Only update the statements in the SourceFile if any have changed.
34370
- if (newStatements !== undefined) {
34371
- return ts__default["default"].updateSourceFileNode(sf, newStatements);
34372
- }
34373
- return sf;
34374
- }
34375
- /**
34376
- * Look for the ts.Identifier of a ts.Declaration with this name.
34377
- *
34378
- * The real identifier is needed (rather than fabricating one) as TypeScript decides how to
34379
- * reference this identifier based on information stored against its node in the AST, which a
34380
- * synthetic node would not have. In particular, since the post-switch variable is often exported,
34381
- * TypeScript needs to know this so it can write `exports.VAR` instead of just `VAR` when emitting
34382
- * code.
34383
- *
34384
- * Only variable, function, and class declarations are currently searched.
34385
- */
34386
- function findPostSwitchIdentifier(statements, name) {
34387
- for (const stmt of statements) {
34388
- if (ts__default["default"].isVariableStatement(stmt)) {
34389
- const decl = stmt.declarationList.declarations.find(decl => ts__default["default"].isIdentifier(decl.name) && decl.name.text === name);
34390
- if (decl !== undefined) {
34391
- return decl.name;
34392
- }
34393
- }
34394
- else if (ts__default["default"].isFunctionDeclaration(stmt) || ts__default["default"].isClassDeclaration(stmt)) {
34395
- if (stmt.name !== undefined && ts__default["default"].isIdentifier(stmt.name) && stmt.name.text === name) {
34396
- return stmt.name;
34397
- }
34398
- }
34399
- }
34400
- return null;
34401
- }
34402
- /**
34403
- * Flip any Ivy switches which are discovered in the given ts.VariableStatement.
34404
- */
34405
- function flipIvySwitchesInVariableStatement(stmt, statements) {
34406
- // Build a new list of variable declarations. Specific declarations that are initialized to a
34407
- // pre-switch identifier will be replaced with a declaration initialized to the post-switch
34408
- // identifier.
34409
- const newDeclarations = [...stmt.declarationList.declarations];
34410
- for (let i = 0; i < newDeclarations.length; i++) {
34411
- const decl = newDeclarations[i];
34412
- // Skip declarations that aren't initialized to an identifier.
34413
- if (decl.initializer === undefined || !ts__default["default"].isIdentifier(decl.initializer)) {
34414
- continue;
34415
- }
34416
- // Skip declarations that aren't Ivy switches.
34417
- if (!decl.initializer.text.endsWith(IVY_SWITCH_PRE_SUFFIX)) {
34418
- continue;
34419
- }
34420
- // Determine the name of the post-switch variable.
34421
- const postSwitchName = decl.initializer.text.replace(IVY_SWITCH_PRE_SUFFIX, IVY_SWITCH_POST_SUFFIX);
34422
- // Find the post-switch variable identifier. If one can't be found, it's an error. This is
34423
- // reported as a thrown error and not a diagnostic as transformers cannot output diagnostics.
34424
- const newIdentifier = findPostSwitchIdentifier(statements, postSwitchName);
34425
- if (newIdentifier === null) {
34426
- throw new Error(`Unable to find identifier ${postSwitchName} in ${stmt.getSourceFile().fileName} for the Ivy switch.`);
34427
- }
34428
- newDeclarations[i] = ts__default["default"].updateVariableDeclaration(
34429
- /* node */ decl,
34430
- /* name */ decl.name,
34431
- /* type */ decl.type,
34432
- /* initializer */ newIdentifier);
34433
- }
34434
- const newDeclList = ts__default["default"].updateVariableDeclarationList(
34435
- /* declarationList */ stmt.declarationList,
34436
- /* declarations */ newDeclarations);
34437
- const newStmt = ts__default["default"].updateVariableStatement(
34438
- /* statement */ stmt,
34439
- /* modifiers */ stmt.modifiers,
34440
- /* declarationList */ newDeclList);
34441
- return newStmt;
34442
- }
34443
- /**
34444
- * Check whether the given VariableStatement has any Ivy switch variables.
34445
- */
34446
- function hasIvySwitches(stmt) {
34447
- return stmt.declarationList.declarations.some(decl => decl.initializer !== undefined && ts__default["default"].isIdentifier(decl.initializer) &&
34448
- decl.initializer.text.endsWith(IVY_SWITCH_PRE_SUFFIX));
34449
- }
34450
-
34451
34363
  /**
34452
34364
  * @license
34453
34365
  * Copyright Google LLC All Rights Reserved.
@@ -40661,7 +40573,6 @@ Either add the @Injectable() decorator to '${provider.node.name
40661
40573
  if (this.adapter.factoryTracker !== null) {
40662
40574
  before.push(generatedFactoryTransform(this.adapter.factoryTracker.sourceInfo, importRewriter));
40663
40575
  }
40664
- before.push(ivySwitchTransform);
40665
40576
  return { transformers: { before, afterDeclarations } };
40666
40577
  }
40667
40578
  /**
@@ -41657,15 +41568,20 @@ https://angular.io/guide/ivy for more information.
41657
41568
  return undefined;
41658
41569
  }
41659
41570
  /**
41660
- * Given an attribute node, converts it to string form.
41571
+ * Given an attribute node, converts it to string form for use as a CSS selector.
41661
41572
  */
41662
- function toAttributeString(attribute) {
41573
+ function toAttributeCssSelector(attribute) {
41574
+ let selector;
41663
41575
  if (attribute instanceof BoundEvent || attribute instanceof BoundAttribute) {
41664
- return `[${attribute.name}]`;
41576
+ selector = `[${attribute.name}]`;
41665
41577
  }
41666
41578
  else {
41667
- return `[${attribute.name}=${attribute.valueSpan?.toString() ?? ''}]`;
41579
+ selector = `[${attribute.name}=${attribute.valueSpan?.toString() ?? ''}]`;
41668
41580
  }
41581
+ // Any dollar signs that appear in the attribute name and/or value need to be escaped because they
41582
+ // need to be taken as literal characters rather than special selector behavior of dollar signs in
41583
+ // CSS.
41584
+ return selector.replace('$', '\\$');
41669
41585
  }
41670
41586
  function getNodeName(node) {
41671
41587
  return node instanceof Template ? node.tagName : node.name;
@@ -41706,14 +41622,14 @@ https://angular.io/guide/ivy for more information.
41706
41622
  // TODO(atscott): Add unit tests for this and the one for attributes
41707
41623
  function getDirectiveMatchesForElementTag(element, directives) {
41708
41624
  const attributes = getAttributes(element);
41709
- const allAttrs = attributes.map(toAttributeString);
41625
+ const allAttrs = attributes.map(toAttributeCssSelector);
41710
41626
  const allDirectiveMatches = getDirectiveMatchesForSelector(directives, getNodeName(element) + allAttrs.join(''));
41711
41627
  const matchesWithoutElement = getDirectiveMatchesForSelector(directives, allAttrs.join(''));
41712
41628
  return difference(allDirectiveMatches, matchesWithoutElement);
41713
41629
  }
41714
41630
  function makeElementSelector(element) {
41715
41631
  const attributes = getAttributes(element);
41716
- const allAttrs = attributes.map(toAttributeString);
41632
+ const allAttrs = attributes.map(toAttributeCssSelector);
41717
41633
  return getNodeName(element) + allAttrs.join('');
41718
41634
  }
41719
41635
  /**
@@ -41729,9 +41645,9 @@ https://angular.io/guide/ivy for more information.
41729
41645
  */
41730
41646
  function getDirectiveMatchesForAttribute(name, hostNode, directives) {
41731
41647
  const attributes = getAttributes(hostNode);
41732
- const allAttrs = attributes.map(toAttributeString);
41648
+ const allAttrs = attributes.map(toAttributeCssSelector);
41733
41649
  const allDirectiveMatches = getDirectiveMatchesForSelector(directives, getNodeName(hostNode) + allAttrs.join(''));
41734
- const attrsExcludingName = attributes.filter(a => a.name !== name).map(toAttributeString);
41650
+ const attrsExcludingName = attributes.filter(a => a.name !== name).map(toAttributeCssSelector);
41735
41651
  const matchesWithoutAttr = getDirectiveMatchesForSelector(directives, getNodeName(hostNode) + attrsExcludingName.join(''));
41736
41652
  return difference(allDirectiveMatches, matchesWithoutAttr);
41737
41653
  }
@@ -41740,18 +41656,25 @@ https://angular.io/guide/ivy for more information.
41740
41656
  * for the selector.
41741
41657
  */
41742
41658
  function getDirectiveMatchesForSelector(directives, selector) {
41743
- const selectors = CssSelector.parse(selector);
41744
- if (selectors.length === 0) {
41659
+ try {
41660
+ const selectors = CssSelector.parse(selector);
41661
+ if (selectors.length === 0) {
41662
+ return new Set();
41663
+ }
41664
+ return new Set(directives.filter((dir) => {
41665
+ if (dir.selector === null) {
41666
+ return false;
41667
+ }
41668
+ const matcher = new SelectorMatcher();
41669
+ matcher.addSelectables(CssSelector.parse(dir.selector));
41670
+ return selectors.some(selector => matcher.match(selector, null));
41671
+ }));
41672
+ }
41673
+ catch {
41674
+ // An invalid selector may throw an error. There would be no directive matches for an invalid
41675
+ // selector.
41745
41676
  return new Set();
41746
41677
  }
41747
- return new Set(directives.filter((dir) => {
41748
- if (dir.selector === null) {
41749
- return false;
41750
- }
41751
- const matcher = new SelectorMatcher();
41752
- matcher.addSelectables(CssSelector.parse(dir.selector));
41753
- return selectors.some(selector => matcher.match(selector, null));
41754
- }));
41755
41678
  }
41756
41679
  /**
41757
41680
  * Returns a new `ts.SymbolDisplayPart` array which has the alias imports from the tcb filtered
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular/language-service",
3
- "version": "13.0.2",
3
+ "version": "13.0.3",
4
4
  "description": "Angular - language services",
5
5
  "main": "./index.js",
6
6
  "typings": "./index.d.ts",