@angular/compiler-cli 17.0.0-next.3 → 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.
@@ -5,7 +5,7 @@
5
5
  import {
6
6
  Context,
7
7
  ExpressionTranslatorVisitor
8
- } from "./chunk-QYCH2357.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.3");
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.3") {
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-42ADUVYG.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-I2HNYMSV.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-QYCH2357.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-QYCH2357.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-I2HNYMSV.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
  }
@@ -6044,7 +6044,7 @@ function transformDecoratorResources(dec, component, styles, template) {
6044
6044
  if (dec.name !== "Component") {
6045
6045
  return dec;
6046
6046
  }
6047
- if (!component.has("templateUrl") && !component.has("styleUrls") && !component.has("styles")) {
6047
+ if (!component.has("templateUrl") && !component.has("styleUrls") && !component.has("styleUrl") && !component.has("styles")) {
6048
6048
  return dec;
6049
6049
  }
6050
6050
  const metadata = new Map(component);
@@ -6052,9 +6052,10 @@ function transformDecoratorResources(dec, component, styles, template) {
6052
6052
  metadata.delete("templateUrl");
6053
6053
  metadata.set("template", ts23.factory.createStringLiteral(template.content));
6054
6054
  }
6055
- if (metadata.has("styleUrls") || metadata.has("styles")) {
6055
+ if (metadata.has("styleUrls") || metadata.has("styleUrl") || metadata.has("styles")) {
6056
6056
  metadata.delete("styles");
6057
6057
  metadata.delete("styleUrls");
6058
+ metadata.delete("styleUrl");
6058
6059
  if (styles.length > 0) {
6059
6060
  const styleNodes = styles.reduce((result, style) => {
6060
6061
  if (style.trim().length > 0) {
@@ -6074,10 +6075,26 @@ function transformDecoratorResources(dec, component, styles, template) {
6074
6075
  return { ...dec, args: [ts23.factory.createObjectLiteralExpression(newMetadataFields)] };
6075
6076
  }
6076
6077
  function extractComponentStyleUrls(evaluator, component) {
6077
- if (!component.has("styleUrls")) {
6078
- 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
+ }];
6079
6096
  }
6080
- return extractStyleUrlsFromExpression(evaluator, component.get("styleUrls"));
6097
+ return [];
6081
6098
  }
6082
6099
  function extractStyleUrlsFromExpression(evaluator, styleUrlsExpr) {
6083
6100
  const styleUrls = [];
@@ -6117,24 +6134,41 @@ function extractStyleResources(resourceLoader, component, containingFile) {
6117
6134
  function stringLiteralElements(array) {
6118
6135
  return array.elements.filter((e) => ts23.isStringLiteralLike(e));
6119
6136
  }
6137
+ const styleUrlExpr = component.get("styleUrl");
6120
6138
  const styleUrlsExpr = component.get("styleUrls");
6121
6139
  if (styleUrlsExpr !== void 0 && ts23.isArrayLiteralExpression(styleUrlsExpr)) {
6122
6140
  for (const expression of stringLiteralElements(styleUrlsExpr)) {
6123
- try {
6124
- const resourceUrl = resourceLoader.resolve(expression.text, containingFile);
6125
- styles.add({ path: absoluteFrom(resourceUrl), expression });
6126
- } catch {
6141
+ const resource = stringLiteralUrlToResource(resourceLoader, expression, containingFile);
6142
+ if (resource !== null) {
6143
+ styles.add(resource);
6127
6144
  }
6128
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
+ }
6129
6151
  }
6130
6152
  const stylesExpr = component.get("styles");
6131
- if (stylesExpr !== void 0 && ts23.isArrayLiteralExpression(stylesExpr)) {
6132
- for (const expression of stringLiteralElements(stylesExpr)) {
6133
- 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 });
6134
6160
  }
6135
6161
  }
6136
6162
  return styles;
6137
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
+ }
6138
6172
  function _extractTemplateStyleUrls(template) {
6139
6173
  if (template.styleUrls === null) {
6140
6174
  return [];
@@ -6626,6 +6660,7 @@ var ComponentDecoratorHandler = class {
6626
6660
  file: analysis.template.file
6627
6661
  }
6628
6662
  });
6663
+ return null;
6629
6664
  }
6630
6665
  typeCheck(ctx, node, meta) {
6631
6666
  if (this.typeCheckScopeRegistry === null || !ts24.isClassDeclaration(node)) {
@@ -7505,4 +7540,4 @@ export {
7505
7540
  * Use of this source code is governed by an MIT-style license that can be
7506
7541
  * found in the LICENSE file at https://angular.io/license
7507
7542
  */
7508
- //# sourceMappingURL=chunk-Y4VU3VP2.js.map
7543
+ //# sourceMappingURL=chunk-KC52PQKJ.js.map