@angular/compiler-cli 17.0.0-next.2 → 17.0.0-next.4

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.
Files changed (28) hide show
  1. package/bundles/{chunk-DJV5J7EO.js → chunk-AIIYON4K.js} +4 -4
  2. package/bundles/{chunk-RM26Z7GR.js → chunk-EJSJTIHK.js} +2 -2
  3. package/bundles/{chunk-R6MWMHVR.js → chunk-KC52PQKJ.js} +58 -22
  4. package/bundles/chunk-KC52PQKJ.js.map +6 -0
  5. package/bundles/{chunk-NGWY7NOB.js → chunk-T6QD5I2A.js} +2 -2
  6. package/bundles/{chunk-NGWY7NOB.js.map → chunk-T6QD5I2A.js.map} +1 -1
  7. package/bundles/{chunk-HO5VC7JE.js → chunk-UYFEPQRA.js} +43 -22
  8. package/bundles/chunk-UYFEPQRA.js.map +6 -0
  9. package/bundles/{chunk-OYEEKZWP.js → chunk-VISOZQNG.js} +2 -2
  10. package/bundles/{chunk-NLLBDH7F.js → chunk-WPCCXY7F.js} +2 -2
  11. package/bundles/index.js +6 -6
  12. package/bundles/linker/babel/index.js +3 -3
  13. package/bundles/linker/index.js +3 -3
  14. package/bundles/private/migrations.js +3 -3
  15. package/bundles/private/tooling.js +2 -2
  16. package/bundles/src/bin/ng_xi18n.js +5 -5
  17. package/bundles/src/bin/ngc.js +5 -5
  18. package/bundles_metadata.json +1 -1
  19. package/package.json +2 -2
  20. package/src/ngtsc/annotations/component/src/handler.d.ts +1 -1
  21. package/src/ngtsc/diagnostics/src/error_code.d.ts +4 -3
  22. package/src/ngtsc/typecheck/src/type_check_block.d.ts +1 -0
  23. package/bundles/chunk-HO5VC7JE.js.map +0 -6
  24. package/bundles/chunk-R6MWMHVR.js.map +0 -6
  25. /package/bundles/{chunk-DJV5J7EO.js.map → chunk-AIIYON4K.js.map} +0 -0
  26. /package/bundles/{chunk-RM26Z7GR.js.map → chunk-EJSJTIHK.js.map} +0 -0
  27. /package/bundles/{chunk-OYEEKZWP.js.map → chunk-VISOZQNG.js.map} +0 -0
  28. /package/bundles/{chunk-NLLBDH7F.js.map → chunk-WPCCXY7F.js.map} +0 -0
@@ -5,7 +5,7 @@
5
5
  import {
6
6
  Context,
7
7
  ExpressionTranslatorVisitor
8
- } from "./chunk-RM26Z7GR.js";
8
+ } from "./chunk-EJSJTIHK.js";
9
9
  import {
10
10
  SourceFileLoader
11
11
  } from "./chunk-EKTJ7622.js";
@@ -855,7 +855,7 @@ var declarationFunctions = [
855
855
  ];
856
856
  function createLinkerMap(environment, sourceUrl, code) {
857
857
  const linkers = /* @__PURE__ */ new Map();
858
- const LATEST_VERSION_RANGE = getRange("<=", "17.0.0-next.2");
858
+ const LATEST_VERSION_RANGE = getRange("<=", "17.0.0-next.4");
859
859
  linkers.set(\u0275\u0275ngDeclareDirective, [
860
860
  { range: LATEST_VERSION_RANGE, linker: new PartialDirectiveLinkerVersion1(sourceUrl, code) }
861
861
  ]);
@@ -902,7 +902,7 @@ var PartialLinkerSelector = class {
902
902
  throw new Error(`Unknown partial declaration function ${functionName}.`);
903
903
  }
904
904
  const linkerRanges = this.linkers.get(functionName);
905
- if (version === "17.0.0-next.2") {
905
+ if (version === "17.0.0-next.4") {
906
906
  return linkerRanges[linkerRanges.length - 1].linker;
907
907
  }
908
908
  const declarationRange = getRange(">=", minVersion);
@@ -1033,4 +1033,4 @@ export {
1033
1033
  * Use of this source code is governed by an MIT-style license that can be
1034
1034
  * found in the LICENSE file at https://angular.io/license
1035
1035
  */
1036
- //# sourceMappingURL=chunk-DJV5J7EO.js.map
1036
+ //# sourceMappingURL=chunk-AIIYON4K.js.map
@@ -7,7 +7,7 @@ import {
7
7
  NoopImportRewriter,
8
8
  Reference,
9
9
  assertSuccessfulReferenceEmit
10
- } from "./chunk-NGWY7NOB.js";
10
+ } from "./chunk-T6QD5I2A.js";
11
11
 
12
12
  // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/context.mjs
13
13
  var Context = class {
@@ -738,4 +738,4 @@ export {
738
738
  * Use of this source code is governed by an MIT-style license that can be
739
739
  * found in the LICENSE file at https://angular.io/license
740
740
  */
741
- //# sourceMappingURL=chunk-RM26Z7GR.js.map
741
+ //# sourceMappingURL=chunk-EJSJTIHK.js.map
@@ -7,7 +7,7 @@ import {
7
7
  translateExpression,
8
8
  translateStatement,
9
9
  translateType
10
- } from "./chunk-RM26Z7GR.js";
10
+ } from "./chunk-EJSJTIHK.js";
11
11
  import {
12
12
  ClassMemberKind,
13
13
  ErrorCode,
@@ -30,7 +30,7 @@ import {
30
30
  reflectObjectLiteral,
31
31
  reflectTypeEntityToDeclaration,
32
32
  typeNodeToValueExpr
33
- } from "./chunk-NGWY7NOB.js";
33
+ } from "./chunk-T6QD5I2A.js";
34
34
  import {
35
35
  PerfEvent,
36
36
  PerfPhase
@@ -2527,10 +2527,9 @@ function readMapType(type, valueTransform) {
2527
2527
  return;
2528
2528
  }
2529
2529
  const value = valueTransform(member.type);
2530
- if (value === null) {
2531
- return null;
2530
+ if (value !== null) {
2531
+ obj[member.name.text] = value;
2532
2532
  }
2533
- obj[member.name.text] = value;
2534
2533
  });
2535
2534
  return obj;
2536
2535
  }
@@ -4602,13 +4601,14 @@ function parseDirectiveStyles(directive, evaluator, compilationMode) {
4602
4601
  if (!expression) {
4603
4602
  return null;
4604
4603
  }
4605
- const value = evaluator.evaluate(expression);
4604
+ const evaluated = evaluator.evaluate(expression);
4605
+ const value = typeof evaluated === "string" ? [evaluated] : evaluated;
4606
4606
  if (compilationMode === CompilationMode.LOCAL && Array.isArray(value)) {
4607
4607
  for (const entry of value) {
4608
4608
  if (entry instanceof DynamicValue && entry.isFromUnknownIdentifier()) {
4609
4609
  const relatedInformation = traceDynamicValue(expression, entry);
4610
4610
  const chain = {
4611
- messageText: `Unknown identifier used as styles string: ${entry.node.getText()} (did you import this string from another file? This is not allowed in local compilation mode. Please either inline it or move it to a separate file and include it using'styleUrls')`,
4611
+ messageText: `Unknown identifier used as styles string: ${entry.node.getText()} (did you import this string from another file? This is not allowed in local compilation mode. Please either inline it or move it to a separate file and include it using 'styleUrl')`,
4612
4612
  category: ts20.DiagnosticCategory.Error,
4613
4613
  code: 0
4614
4614
  };
@@ -4617,7 +4617,7 @@ function parseDirectiveStyles(directive, evaluator, compilationMode) {
4617
4617
  }
4618
4618
  }
4619
4619
  if (!isStringArrayOrDie(value, "styles", expression)) {
4620
- throw createValueHasWrongTypeError(expression, value, `Failed to resolve @Directive.styles to a string array`);
4620
+ throw createValueHasWrongTypeError(expression, value, `Failed to resolve @Component.styles to a string or an array of strings`);
4621
4621
  }
4622
4622
  return value;
4623
4623
  }
@@ -5919,7 +5919,8 @@ function parseExtractedTemplate(template, sourceStr, sourceParseRange, escapedSt
5919
5919
  enableI18nLegacyMessageIdFormat: options.enableI18nLegacyMessageIdFormat,
5920
5920
  i18nNormalizeLineEndingsInICUs,
5921
5921
  leadingTriviaChars: [],
5922
- alwaysAttemptHtmlToR3AstConversion: options.usePoisonedData
5922
+ alwaysAttemptHtmlToR3AstConversion: options.usePoisonedData,
5923
+ enabledBlockTypes: options.enabledBlockTypes
5923
5924
  });
5924
5925
  return {
5925
5926
  ...parsedTemplate,
@@ -6043,7 +6044,7 @@ function transformDecoratorResources(dec, component, styles, template) {
6043
6044
  if (dec.name !== "Component") {
6044
6045
  return dec;
6045
6046
  }
6046
- if (!component.has("templateUrl") && !component.has("styleUrls") && !component.has("styles")) {
6047
+ if (!component.has("templateUrl") && !component.has("styleUrls") && !component.has("styleUrl") && !component.has("styles")) {
6047
6048
  return dec;
6048
6049
  }
6049
6050
  const metadata = new Map(component);
@@ -6051,9 +6052,10 @@ function transformDecoratorResources(dec, component, styles, template) {
6051
6052
  metadata.delete("templateUrl");
6052
6053
  metadata.set("template", ts23.factory.createStringLiteral(template.content));
6053
6054
  }
6054
- if (metadata.has("styleUrls") || metadata.has("styles")) {
6055
+ if (metadata.has("styleUrls") || metadata.has("styleUrl") || metadata.has("styles")) {
6055
6056
  metadata.delete("styles");
6056
6057
  metadata.delete("styleUrls");
6058
+ metadata.delete("styleUrl");
6057
6059
  if (styles.length > 0) {
6058
6060
  const styleNodes = styles.reduce((result, style) => {
6059
6061
  if (style.trim().length > 0) {
@@ -6073,10 +6075,26 @@ function transformDecoratorResources(dec, component, styles, template) {
6073
6075
  return { ...dec, args: [ts23.factory.createObjectLiteralExpression(newMetadataFields)] };
6074
6076
  }
6075
6077
  function extractComponentStyleUrls(evaluator, component) {
6076
- if (!component.has("styleUrls")) {
6077
- return [];
6078
+ const styleUrlsExpr = component.get("styleUrls");
6079
+ const styleUrlExpr = component.get("styleUrl");
6080
+ if (styleUrlsExpr !== void 0 && styleUrlExpr !== void 0) {
6081
+ throw new FatalDiagnosticError(ErrorCode.COMPONENT_INVALID_STYLE_URLS, styleUrlExpr, "@Component cannot define both `styleUrl` and `styleUrls`. Use `styleUrl` if the component has one stylesheet, or `styleUrls` if it has multiple");
6082
+ }
6083
+ if (styleUrlsExpr !== void 0) {
6084
+ return extractStyleUrlsFromExpression(evaluator, component.get("styleUrls"));
6085
+ }
6086
+ if (styleUrlExpr !== void 0) {
6087
+ const styleUrl = evaluator.evaluate(styleUrlExpr);
6088
+ if (typeof styleUrl !== "string") {
6089
+ throw createValueHasWrongTypeError(styleUrlExpr, styleUrl, "styleUrl must be a string");
6090
+ }
6091
+ return [{
6092
+ url: styleUrl,
6093
+ source: 2,
6094
+ nodeForError: styleUrlExpr
6095
+ }];
6078
6096
  }
6079
- return extractStyleUrlsFromExpression(evaluator, component.get("styleUrls"));
6097
+ return [];
6080
6098
  }
6081
6099
  function extractStyleUrlsFromExpression(evaluator, styleUrlsExpr) {
6082
6100
  const styleUrls = [];
@@ -6116,24 +6134,41 @@ function extractStyleResources(resourceLoader, component, containingFile) {
6116
6134
  function stringLiteralElements(array) {
6117
6135
  return array.elements.filter((e) => ts23.isStringLiteralLike(e));
6118
6136
  }
6137
+ const styleUrlExpr = component.get("styleUrl");
6119
6138
  const styleUrlsExpr = component.get("styleUrls");
6120
6139
  if (styleUrlsExpr !== void 0 && ts23.isArrayLiteralExpression(styleUrlsExpr)) {
6121
6140
  for (const expression of stringLiteralElements(styleUrlsExpr)) {
6122
- try {
6123
- const resourceUrl = resourceLoader.resolve(expression.text, containingFile);
6124
- styles.add({ path: absoluteFrom(resourceUrl), expression });
6125
- } catch {
6141
+ const resource = stringLiteralUrlToResource(resourceLoader, expression, containingFile);
6142
+ if (resource !== null) {
6143
+ styles.add(resource);
6126
6144
  }
6127
6145
  }
6146
+ } else if (styleUrlExpr !== void 0 && ts23.isStringLiteralLike(styleUrlExpr)) {
6147
+ const resource = stringLiteralUrlToResource(resourceLoader, styleUrlExpr, containingFile);
6148
+ if (resource !== null) {
6149
+ styles.add(resource);
6150
+ }
6128
6151
  }
6129
6152
  const stylesExpr = component.get("styles");
6130
- if (stylesExpr !== void 0 && ts23.isArrayLiteralExpression(stylesExpr)) {
6131
- for (const expression of stringLiteralElements(stylesExpr)) {
6132
- styles.add({ path: null, expression });
6153
+ if (stylesExpr !== void 0) {
6154
+ if (ts23.isArrayLiteralExpression(stylesExpr)) {
6155
+ for (const expression of stringLiteralElements(stylesExpr)) {
6156
+ styles.add({ path: null, expression });
6157
+ }
6158
+ } else if (ts23.isStringLiteralLike(stylesExpr)) {
6159
+ styles.add({ path: null, expression: stylesExpr });
6133
6160
  }
6134
6161
  }
6135
6162
  return styles;
6136
6163
  }
6164
+ function stringLiteralUrlToResource(resourceLoader, expression, containingFile) {
6165
+ try {
6166
+ const resourceUrl = resourceLoader.resolve(expression.text, containingFile);
6167
+ return { path: absoluteFrom(resourceUrl), expression };
6168
+ } catch {
6169
+ return null;
6170
+ }
6171
+ }
6137
6172
  function _extractTemplateStyleUrls(template) {
6138
6173
  if (template.styleUrls === null) {
6139
6174
  return [];
@@ -6625,6 +6660,7 @@ var ComponentDecoratorHandler = class {
6625
6660
  file: analysis.template.file
6626
6661
  }
6627
6662
  });
6663
+ return null;
6628
6664
  }
6629
6665
  typeCheck(ctx, node, meta) {
6630
6666
  if (this.typeCheckScopeRegistry === null || !ts24.isClassDeclaration(node)) {
@@ -7504,4 +7540,4 @@ export {
7504
7540
  * Use of this source code is governed by an MIT-style license that can be
7505
7541
  * found in the LICENSE file at https://angular.io/license
7506
7542
  */
7507
- //# sourceMappingURL=chunk-R6MWMHVR.js.map
7543
+ //# sourceMappingURL=chunk-KC52PQKJ.js.map