@angular/core 17.0.2 → 17.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.
Files changed (31) hide show
  1. package/esm2022/src/core_render3_private_export.mjs +2 -2
  2. package/esm2022/src/render3/index.mjs +2 -2
  3. package/esm2022/src/render3/instructions/change_detection.mjs +9 -19
  4. package/esm2022/src/render3/instructions/shared.mjs +4 -5
  5. package/esm2022/src/render3/interfaces/container.mjs +22 -17
  6. package/esm2022/src/render3/interfaces/view.mjs +2 -2
  7. package/esm2022/src/render3/node_manipulation.mjs +3 -3
  8. package/esm2022/src/render3/util/change_detection_utils.mjs +13 -2
  9. package/esm2022/src/render3/util/injector_discovery_utils.mjs +10 -13
  10. package/esm2022/src/render3/util/view_utils.mjs +4 -4
  11. package/esm2022/src/render3/view_ref.mjs +3 -3
  12. package/esm2022/src/version.mjs +1 -1
  13. package/esm2022/testing/src/logger.mjs +3 -3
  14. package/esm2022/testing/src/test_bed_compiler.mjs +4 -1
  15. package/fesm2022/core.mjs +59 -56
  16. package/fesm2022/core.mjs.map +1 -1
  17. package/fesm2022/primitives/signals.mjs +1 -1
  18. package/fesm2022/rxjs-interop.mjs +1 -1
  19. package/fesm2022/testing.mjs +4 -1
  20. package/fesm2022/testing.mjs.map +1 -1
  21. package/index.d.ts +27 -36
  22. package/package.json +1 -1
  23. package/primitives/signals/index.d.ts +1 -1
  24. package/rxjs-interop/index.d.ts +1 -1
  25. package/schematics/migrations/block-template-entities/bundle.js +187 -98
  26. package/schematics/migrations/block-template-entities/bundle.js.map +4 -4
  27. package/schematics/ng-generate/control-flow-migration/bundle.js +518 -232
  28. package/schematics/ng-generate/control-flow-migration/bundle.js.map +4 -4
  29. package/schematics/ng-generate/standalone-migration/bundle.js +176 -106
  30. package/schematics/ng-generate/standalone-migration/bundle.js.map +4 -4
  31. package/testing/index.d.ts +1 -1
@@ -83,86 +83,6 @@ function normalizePath(path2) {
83
83
  return path2.replace(/\\/g, "/");
84
84
  }
85
85
 
86
- // bazel-out/k8-fastbuild/bin/packages/core/schematics/utils/project_tsconfig_paths.mjs
87
- var import_core = require("@angular-devkit/core");
88
- function getProjectTsConfigPaths(tree) {
89
- return __async(this, null, function* () {
90
- const buildPaths = /* @__PURE__ */ new Set();
91
- const testPaths = /* @__PURE__ */ new Set();
92
- const workspace = yield getWorkspace(tree);
93
- for (const [, project] of workspace.projects) {
94
- for (const [name, target] of project.targets) {
95
- if (name !== "build" && name !== "test") {
96
- continue;
97
- }
98
- for (const [, options] of allTargetOptions(target)) {
99
- const tsConfig = options["tsConfig"];
100
- if (typeof tsConfig !== "string" || !tree.exists(tsConfig)) {
101
- continue;
102
- }
103
- if (name === "build") {
104
- buildPaths.add((0, import_core.normalize)(tsConfig));
105
- } else {
106
- testPaths.add((0, import_core.normalize)(tsConfig));
107
- }
108
- }
109
- }
110
- }
111
- return {
112
- buildPaths: [...buildPaths],
113
- testPaths: [...testPaths]
114
- };
115
- });
116
- }
117
- function* allTargetOptions(target) {
118
- if (target.options) {
119
- yield [void 0, target.options];
120
- }
121
- if (!target.configurations) {
122
- return;
123
- }
124
- for (const [name, options] of Object.entries(target.configurations)) {
125
- if (options) {
126
- yield [name, options];
127
- }
128
- }
129
- }
130
- function createHost(tree) {
131
- return {
132
- readFile(path2) {
133
- return __async(this, null, function* () {
134
- const data = tree.read(path2);
135
- if (!data) {
136
- throw new Error("File not found.");
137
- }
138
- return import_core.virtualFs.fileBufferToString(data);
139
- });
140
- },
141
- writeFile(path2, data) {
142
- return __async(this, null, function* () {
143
- return tree.overwrite(path2, data);
144
- });
145
- },
146
- isDirectory(path2) {
147
- return __async(this, null, function* () {
148
- return !tree.exists(path2) && tree.getDir(path2).subfiles.length > 0;
149
- });
150
- },
151
- isFile(path2) {
152
- return __async(this, null, function* () {
153
- return tree.exists(path2);
154
- });
155
- }
156
- };
157
- }
158
- function getWorkspace(tree) {
159
- return __async(this, null, function* () {
160
- const host = createHost(tree);
161
- const { workspace } = yield import_core.workspaces.readWorkspace("/", host);
162
- return workspace;
163
- });
164
- }
165
-
166
86
  // bazel-out/k8-fastbuild/bin/packages/core/schematics/utils/typescript/compiler_host.mjs
167
87
  var import_path = require("path");
168
88
  var import_typescript4 = __toESM(require("typescript"), 1);
@@ -3971,6 +3891,25 @@ var IcuPlaceholder = class {
3971
3891
  return visitor.visitIcuPlaceholder(this, context);
3972
3892
  }
3973
3893
  };
3894
+ var RecurseVisitor = class {
3895
+ visitText(text2, context) {
3896
+ }
3897
+ visitContainer(container, context) {
3898
+ container.children.forEach((child) => child.visit(this));
3899
+ }
3900
+ visitIcu(icu, context) {
3901
+ Object.keys(icu.cases).forEach((k) => {
3902
+ icu.cases[k].visit(this);
3903
+ });
3904
+ }
3905
+ visitTagPlaceholder(ph, context) {
3906
+ ph.children.forEach((child) => child.visit(this));
3907
+ }
3908
+ visitPlaceholder(ph, context) {
3909
+ }
3910
+ visitIcuPlaceholder(ph, context) {
3911
+ }
3912
+ };
3974
3913
  function serializeMessage(messageNodes) {
3975
3914
  const visitor = new LocalizeMessageStringVisitor();
3976
3915
  const str = messageNodes.map((n) => n.visit(visitor)).join("");
@@ -7014,8 +6953,8 @@ var OpKind;
7014
6953
  OpKind2[OpKind2["I18nEnd"] = 38] = "I18nEnd";
7015
6954
  OpKind2[OpKind2["I18nExpression"] = 39] = "I18nExpression";
7016
6955
  OpKind2[OpKind2["I18nApply"] = 40] = "I18nApply";
7017
- OpKind2[OpKind2["Icu"] = 41] = "Icu";
7018
- OpKind2[OpKind2["IcuUpdate"] = 42] = "IcuUpdate";
6956
+ OpKind2[OpKind2["IcuStart"] = 41] = "IcuStart";
6957
+ OpKind2[OpKind2["IcuEnd"] = 42] = "IcuEnd";
7019
6958
  OpKind2[OpKind2["I18nContext"] = 43] = "I18nContext";
7020
6959
  })(OpKind || (OpKind = {}));
7021
6960
  var ExpressionKind;
@@ -7100,6 +7039,7 @@ var I18nParamValueFlags;
7100
7039
  I18nParamValueFlags2[I18nParamValueFlags2["TemplateTag"] = 2] = "TemplateTag";
7101
7040
  I18nParamValueFlags2[I18nParamValueFlags2["OpenTag"] = 4] = "OpenTag";
7102
7041
  I18nParamValueFlags2[I18nParamValueFlags2["CloseTag"] = 8] = "CloseTag";
7042
+ I18nParamValueFlags2[I18nParamValueFlags2["ExpressionIndex"] = 16] = "ExpressionIndex";
7103
7043
  })(I18nParamValueFlags || (I18nParamValueFlags = {}));
7104
7044
  var Namespace;
7105
7045
  (function(Namespace2) {
@@ -7326,13 +7266,6 @@ function createI18nApplyOp(target, handle, sourceSpan) {
7326
7266
  sourceSpan
7327
7267
  }, NEW_OP);
7328
7268
  }
7329
- function createIcuUpdateOp(xref, sourceSpan) {
7330
- return __spreadValues({
7331
- kind: OpKind.IcuUpdate,
7332
- xref,
7333
- sourceSpan
7334
- }, NEW_OP);
7335
- }
7336
7269
 
7337
7270
  // bazel-out/k8-fastbuild/bin/packages/compiler/src/template/pipeline/ir/src/expression.mjs
7338
7271
  var _a;
@@ -8096,8 +8029,8 @@ function transformExpressionsInOp(op, transform2, flags) {
8096
8029
  case OpKind.I18nContext:
8097
8030
  case OpKind.I18nEnd:
8098
8031
  case OpKind.I18nStart:
8099
- case OpKind.Icu:
8100
- case OpKind.IcuUpdate:
8032
+ case OpKind.IcuEnd:
8033
+ case OpKind.IcuStart:
8101
8034
  case OpKind.Namespace:
8102
8035
  case OpKind.Pipe:
8103
8036
  case OpKind.Projection:
@@ -8599,17 +8532,22 @@ function createI18nEndOp(xref) {
8599
8532
  xref
8600
8533
  }, NEW_OP);
8601
8534
  }
8602
- function createIcuOp(xref, message, icu, messagePlaceholder, sourceSpan) {
8535
+ function createIcuStartOp(xref, message, messagePlaceholder, sourceSpan) {
8603
8536
  return __spreadValues({
8604
- kind: OpKind.Icu,
8537
+ kind: OpKind.IcuStart,
8605
8538
  xref,
8606
8539
  message,
8607
- icu,
8608
8540
  messagePlaceholder,
8609
8541
  context: null,
8610
8542
  sourceSpan
8611
8543
  }, NEW_OP);
8612
8544
  }
8545
+ function createIcuEndOp(xref) {
8546
+ return __spreadValues({
8547
+ kind: OpKind.IcuEnd,
8548
+ xref
8549
+ }, NEW_OP);
8550
+ }
8613
8551
  function createI18nContextOp(xref, i18nBlock, message, sourceSpan) {
8614
8552
  return __spreadValues({
8615
8553
  kind: OpKind.I18nContext,
@@ -8763,20 +8701,30 @@ function removeAnys(e) {
8763
8701
 
8764
8702
  // bazel-out/k8-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/apply_i18n_expressions.mjs
8765
8703
  function applyI18nExpressions(job) {
8704
+ const i18nContexts = /* @__PURE__ */ new Map();
8705
+ for (const unit of job.units) {
8706
+ for (const op of unit.create) {
8707
+ if (op.kind === OpKind.I18nContext) {
8708
+ i18nContexts.set(op.xref, op);
8709
+ }
8710
+ }
8711
+ }
8766
8712
  for (const unit of job.units) {
8767
8713
  for (const op of unit.update) {
8768
- if (op.kind === OpKind.I18nExpression && needsApplication(op)) {
8714
+ if (op.kind === OpKind.I18nExpression && needsApplication(i18nContexts, op)) {
8769
8715
  OpList.insertAfter(createI18nApplyOp(op.target, op.handle, null), op);
8770
8716
  }
8771
8717
  }
8772
8718
  }
8773
8719
  }
8774
- function needsApplication(op) {
8720
+ function needsApplication(i18nContexts, op) {
8775
8721
  var _a2;
8776
8722
  if (((_a2 = op.next) == null ? void 0 : _a2.kind) !== OpKind.I18nExpression) {
8777
8723
  return true;
8778
8724
  }
8779
- if (op.next.context !== op.context) {
8725
+ const context = i18nContexts.get(op.context);
8726
+ const nextContext2 = i18nContexts.get(op.next.context);
8727
+ if (context.i18nBlock !== nextContext2.i18nBlock) {
8780
8728
  return true;
8781
8729
  }
8782
8730
  return false;
@@ -9320,7 +9268,7 @@ function createI18nContexts(job) {
9320
9268
  case OpKind.I18nEnd:
9321
9269
  currentI18nOp = null;
9322
9270
  break;
9323
- case OpKind.Icu:
9271
+ case OpKind.IcuStart:
9324
9272
  if (currentI18nOp === null) {
9325
9273
  throw Error("Unexpected ICU outside of an i18n block.");
9326
9274
  }
@@ -9337,52 +9285,6 @@ function createI18nContexts(job) {
9337
9285
  }
9338
9286
  }
9339
9287
 
9340
- // bazel-out/k8-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/create_i18n_icu_expressions.mjs
9341
- function createI18nIcuExpressions(job) {
9342
- const icus = /* @__PURE__ */ new Map();
9343
- const i18nContexts = /* @__PURE__ */ new Map();
9344
- const i18nBlocks = /* @__PURE__ */ new Map();
9345
- for (const unit of job.units) {
9346
- for (const op of unit.create) {
9347
- switch (op.kind) {
9348
- case OpKind.Icu:
9349
- icus.set(op.xref, op);
9350
- break;
9351
- case OpKind.I18nContext:
9352
- i18nContexts.set(op.xref, op);
9353
- break;
9354
- case OpKind.I18nStart:
9355
- i18nBlocks.set(op.xref, op);
9356
- break;
9357
- }
9358
- }
9359
- for (const op of unit.update) {
9360
- switch (op.kind) {
9361
- case OpKind.IcuUpdate:
9362
- const icuOp = icus.get(op.xref);
9363
- if ((icuOp == null ? void 0 : icuOp.icu.expressionPlaceholder) === void 0) {
9364
- throw Error("ICU should have an i18n placeholder");
9365
- }
9366
- if (icuOp.context === null) {
9367
- throw Error("ICU should have its i18n context set");
9368
- }
9369
- const i18nContext = i18nContexts.get(icuOp.context);
9370
- const i18nBlock = i18nBlocks.get(i18nContext.i18nBlock);
9371
- OpList.replace(op, createI18nExpressionOp(
9372
- i18nContext.xref,
9373
- i18nBlock.xref,
9374
- i18nBlock.handle,
9375
- new LexicalReadExpr(icuOp.icu.expression),
9376
- icuOp.icu.expressionPlaceholder,
9377
- I18nParamResolutionTime.Postproccessing,
9378
- null
9379
- ));
9380
- break;
9381
- }
9382
- }
9383
- }
9384
- }
9385
-
9386
9288
  // bazel-out/k8-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/defer_configs.mjs
9387
9289
  function configureDeferInstructions(job) {
9388
9290
  for (const unit of job.units) {
@@ -9696,18 +9598,23 @@ function extractI18nMessages(job) {
9696
9598
  }
9697
9599
  for (const unit of job.units) {
9698
9600
  for (const op of unit.create) {
9699
- if (op.kind === OpKind.Icu) {
9700
- if (!op.context) {
9701
- throw Error("ICU op should have its context set.");
9702
- }
9703
- if (!i18nBlockContexts.has(op.context)) {
9704
- const i18nContext = i18nContexts.get(op.context);
9705
- const subMessage = createI18nMessage(job, i18nContext, op.messagePlaceholder);
9706
- unit.create.push(subMessage);
9707
- const parentMessage = i18nBlockMessages.get(i18nContext.i18nBlock);
9708
- parentMessage == null ? void 0 : parentMessage.subMessages.push(subMessage.xref);
9709
- }
9710
- OpList.remove(op);
9601
+ switch (op.kind) {
9602
+ case OpKind.IcuStart:
9603
+ if (!op.context) {
9604
+ throw Error("ICU op should have its context set.");
9605
+ }
9606
+ if (!i18nBlockContexts.has(op.context)) {
9607
+ const i18nContext = i18nContexts.get(op.context);
9608
+ const subMessage = createI18nMessage(job, i18nContext, op.messagePlaceholder);
9609
+ unit.create.push(subMessage);
9610
+ const parentMessage = i18nBlockMessages.get(i18nContext.i18nBlock);
9611
+ parentMessage == null ? void 0 : parentMessage.subMessages.push(subMessage.xref);
9612
+ }
9613
+ OpList.remove(op);
9614
+ break;
9615
+ case OpKind.IcuEnd:
9616
+ OpList.remove(op);
9617
+ break;
9711
9618
  }
9712
9619
  }
9713
9620
  }
@@ -9723,7 +9630,7 @@ function createI18nMessage(job, context, messagePlaceholder) {
9723
9630
  }
9724
9631
  function formatParams(params) {
9725
9632
  const result = /* @__PURE__ */ new Map();
9726
- for (const [placeholder, placeholderValues] of [...params].sort()) {
9633
+ for (const [placeholder, placeholderValues] of params) {
9727
9634
  const serializedValues = formatParamValues(placeholderValues);
9728
9635
  if (serializedValues !== null) {
9729
9636
  result.set(placeholder, literal(formatParamValues(placeholderValues)));
@@ -9739,6 +9646,9 @@ function formatParamValues(values) {
9739
9646
  return serializedValues.length === 1 ? serializedValues[0] : `${LIST_START_MARKER}${serializedValues.join(LIST_DELIMITER)}${LIST_END_MARKER}`;
9740
9647
  }
9741
9648
  function formatValue(value) {
9649
+ if (value.flags === I18nParamValueFlags.None) {
9650
+ return `${value.value}`;
9651
+ }
9742
9652
  let tagMarker = "";
9743
9653
  let closeMarker = "";
9744
9654
  if (value.flags & I18nParamValueFlags.ElementTag) {
@@ -15932,11 +15842,13 @@ function collectMessage(job, fileBasedI18nSuffix, messages, messageOp) {
15932
15842
  statements.push(...subMessageStatements);
15933
15843
  messageOp.params.set(subMessage.messagePlaceholder, subMessageVar);
15934
15844
  }
15845
+ messageOp.params = new Map([...messageOp.params.entries()].sort());
15935
15846
  assertAllParamsResolved(messageOp);
15936
15847
  const mainVar = variable(job.pool.uniqueName(TRANSLATION_VAR_PREFIX2));
15937
15848
  const closureVar = i18nGenerateClosureVar(job.pool, messageOp.message.id, fileBasedI18nSuffix, job.i18nUseExternalIds);
15938
15849
  let transformFn = void 0;
15939
15850
  if (messageOp.needsPostprocessing) {
15851
+ messageOp.postprocessingParams = new Map([...messageOp.postprocessingParams.entries()].sort());
15940
15852
  const extraTransformFnParams = [];
15941
15853
  if (messageOp.postprocessingParams.size > 0) {
15942
15854
  extraTransformFnParams.push(literalMap([...messageOp.postprocessingParams].map(([key, value]) => ({ key, value, quoted: true }))));
@@ -15974,12 +15886,14 @@ function i18nGenerateClosureVar(pool, messageId, fileBasedI18nSuffix, useExterna
15974
15886
  return variable(name);
15975
15887
  }
15976
15888
  function assertAllParamsResolved(op) {
15977
- for (const placeholder in op.message.placeholders) {
15889
+ for (let placeholder in op.message.placeholders) {
15890
+ placeholder = placeholder.trimEnd();
15978
15891
  if (!op.params.has(placeholder) && !op.postprocessingParams.has(placeholder)) {
15979
15892
  throw Error(`Failed to resolve i18n placeholder: ${placeholder}`);
15980
15893
  }
15981
15894
  }
15982
- for (const placeholder in op.message.placeholderToMessage) {
15895
+ for (let placeholder in op.message.placeholderToMessage) {
15896
+ placeholder = placeholder.trimEnd();
15983
15897
  if (!op.params.has(placeholder) && !op.postprocessingParams.has(placeholder)) {
15984
15898
  throw Error(`Failed to resolve i18n message placeholder: ${placeholder}`);
15985
15899
  }
@@ -15991,7 +15905,9 @@ function extractI18nText(job) {
15991
15905
  var _a2;
15992
15906
  for (const unit of job.units) {
15993
15907
  let currentI18n = null;
15908
+ let currentIcu = null;
15994
15909
  const textNodeI18nBlocks = /* @__PURE__ */ new Map();
15910
+ const textNodeIcus = /* @__PURE__ */ new Map();
15995
15911
  for (const op of unit.create) {
15996
15912
  switch (op.kind) {
15997
15913
  case OpKind.I18nStart:
@@ -16003,9 +15919,19 @@ function extractI18nText(job) {
16003
15919
  case OpKind.I18nEnd:
16004
15920
  currentI18n = null;
16005
15921
  break;
15922
+ case OpKind.IcuStart:
15923
+ if (op.context === null) {
15924
+ throw Error("Icu op should have its context set.");
15925
+ }
15926
+ currentIcu = op;
15927
+ break;
15928
+ case OpKind.IcuEnd:
15929
+ currentIcu = null;
15930
+ break;
16006
15931
  case OpKind.Text:
16007
15932
  if (currentI18n !== null) {
16008
15933
  textNodeI18nBlocks.set(op.xref, currentI18n);
15934
+ textNodeIcus.set(op.xref, currentIcu);
16009
15935
  OpList.remove(op);
16010
15936
  }
16011
15937
  break;
@@ -16018,11 +15944,13 @@ function extractI18nText(job) {
16018
15944
  continue;
16019
15945
  }
16020
15946
  const i18nOp = textNodeI18nBlocks.get(op.target);
15947
+ const icuOp = textNodeIcus.get(op.target);
15948
+ const contextId = icuOp ? icuOp.context : i18nOp.context;
15949
+ const resolutionTime = icuOp ? I18nParamResolutionTime.Postproccessing : I18nParamResolutionTime.Creation;
16021
15950
  const ops = [];
16022
15951
  for (let i = 0; i < op.interpolation.expressions.length; i++) {
16023
15952
  const expr = op.interpolation.expressions[i];
16024
- const placeholder = op.i18nPlaceholders[i];
16025
- ops.push(createI18nExpressionOp(i18nOp.context, i18nOp.xref, i18nOp.handle, expr, placeholder.name, I18nParamResolutionTime.Creation, (_a2 = expr.sourceSpan) != null ? _a2 : op.sourceSpan));
15953
+ ops.push(createI18nExpressionOp(contextId, i18nOp.xref, i18nOp.handle, expr, op.i18nPlaceholders[i], resolutionTime, (_a2 = expr.sourceSpan) != null ? _a2 : op.sourceSpan));
16026
15954
  }
16027
15955
  OpList.replaceWithMany(op, ops);
16028
15956
  break;
@@ -17762,7 +17690,7 @@ function getSubTemplateIndexForTemplateTag(job, i18nOp, op) {
17762
17690
  }
17763
17691
  return i18nOp.subTemplateIndex;
17764
17692
  }
17765
- function addParam(params, placeholder, value, subTemplateIndex, flags = I18nParamValueFlags.None) {
17693
+ function addParam(params, placeholder, value, subTemplateIndex, flags) {
17766
17694
  var _a2;
17767
17695
  const values = (_a2 = params.get(placeholder)) != null ? _a2 : [];
17768
17696
  values.push({ value, subTemplateIndex, flags });
@@ -17789,19 +17717,76 @@ function resolveI18nExpressionPlaceholders(job) {
17789
17717
  for (const unit of job.units) {
17790
17718
  for (const op of unit.update) {
17791
17719
  if (op.kind === OpKind.I18nExpression) {
17792
- const index = expressionIndices.get(op.context) || 0;
17793
17720
  const i18nContext = i18nContexts.get(op.context);
17721
+ const index = expressionIndices.get(i18nContext.i18nBlock) || 0;
17794
17722
  const subTemplateIndex = subTemplateIndicies.get(i18nContext.i18nBlock);
17795
17723
  const params = op.resolutionTime === I18nParamResolutionTime.Creation ? i18nContext.params : i18nContext.postprocessingParams;
17796
17724
  const values = params.get(op.i18nPlaceholder) || [];
17797
- values.push({ value: index, subTemplateIndex, flags: I18nParamValueFlags.None });
17725
+ values.push({
17726
+ value: index,
17727
+ subTemplateIndex,
17728
+ flags: I18nParamValueFlags.ExpressionIndex
17729
+ });
17798
17730
  params.set(op.i18nPlaceholder, values);
17799
- expressionIndices.set(op.context, index + 1);
17731
+ expressionIndices.set(i18nContext.i18nBlock, index + 1);
17800
17732
  }
17801
17733
  }
17802
17734
  }
17803
17735
  }
17804
17736
 
17737
+ // bazel-out/k8-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/resolve_i18n_icu_placeholders.mjs
17738
+ function resolveI18nIcuPlaceholders(job) {
17739
+ const contextOps = /* @__PURE__ */ new Map();
17740
+ for (const unit of job.units) {
17741
+ for (const op of unit.create) {
17742
+ switch (op.kind) {
17743
+ case OpKind.I18nContext:
17744
+ contextOps.set(op.xref, op);
17745
+ break;
17746
+ }
17747
+ }
17748
+ }
17749
+ for (const unit of job.units) {
17750
+ for (const op of unit.create) {
17751
+ switch (op.kind) {
17752
+ case OpKind.IcuStart:
17753
+ if (op.context === null) {
17754
+ throw Error("Icu should have its i18n context set.");
17755
+ }
17756
+ const i18nContext = contextOps.get(op.context);
17757
+ for (const node of op.message.nodes) {
17758
+ node.visit(new ResolveIcuPlaceholdersVisitor(i18nContext.postprocessingParams));
17759
+ }
17760
+ break;
17761
+ }
17762
+ }
17763
+ }
17764
+ }
17765
+ var ResolveIcuPlaceholdersVisitor = class extends RecurseVisitor {
17766
+ constructor(params) {
17767
+ super();
17768
+ this.params = params;
17769
+ }
17770
+ visitTagPlaceholder(placeholder) {
17771
+ var _a2, _b2;
17772
+ super.visitTagPlaceholder(placeholder);
17773
+ if (placeholder.startName && placeholder.startSourceSpan && !this.params.has(placeholder.startName)) {
17774
+ this.params.set(placeholder.startName, [{
17775
+ value: (_a2 = placeholder.startSourceSpan) == null ? void 0 : _a2.toString(),
17776
+ subTemplateIndex: null,
17777
+ flags: I18nParamValueFlags.None
17778
+ }]);
17779
+ }
17780
+ if (placeholder.closeName && placeholder.endSourceSpan && !this.params.has(placeholder.closeName)) {
17781
+ this.params.set(placeholder.closeName, [{
17782
+ value: (_b2 = placeholder.endSourceSpan) == null ? void 0 : _b2.toString(),
17783
+ subTemplateIndex: null,
17784
+ flags: I18nParamValueFlags.None
17785
+ }]);
17786
+ }
17787
+ }
17788
+ };
17789
+
17805
17790
  // bazel-out/k8-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/resolve_names.mjs
17806
17791
  function resolveNames(job) {
17807
17792
  for (const unit of job.units) {
@@ -18518,6 +18503,7 @@ function allowConservativeInlining(decl, target) {
18518
18503
  function wrapI18nIcus(job) {
18519
18504
  for (const unit of job.units) {
18520
18505
  let currentI18nOp = null;
18506
+ let addedI18nId = null;
18521
18507
  for (const op of unit.create) {
18522
18508
  switch (op.kind) {
18523
18509
  case OpKind.I18nStart:
@@ -18526,11 +18512,16 @@ function wrapI18nIcus(job) {
18526
18512
  case OpKind.I18nEnd:
18527
18513
  currentI18nOp = null;
18528
18514
  break;
18529
- case OpKind.Icu:
18515
+ case OpKind.IcuStart:
18530
18516
  if (currentI18nOp === null) {
18531
- const id = job.allocateXrefId();
18532
- OpList.insertBefore(createI18nStartOp(id, op.message), op);
18533
- OpList.insertAfter(createI18nEndOp(id), op);
18517
+ addedI18nId = job.allocateXrefId();
18518
+ OpList.insertBefore(createI18nStartOp(addedI18nId, op.message), op);
18519
+ }
18520
+ break;
18521
+ case OpKind.IcuEnd:
18522
+ if (addedI18nId !== null) {
18523
+ OpList.insertAfter(createI18nEndOp(addedI18nId), op);
18524
+ addedI18nId = null;
18534
18525
  }
18535
18526
  break;
18536
18527
  }
@@ -18557,7 +18548,6 @@ var phases = [
18557
18548
  { kind: CompilationJobKind.Tmpl, fn: createPipes },
18558
18549
  { kind: CompilationJobKind.Tmpl, fn: configureDeferInstructions },
18559
18550
  { kind: CompilationJobKind.Tmpl, fn: extractI18nText },
18560
- { kind: CompilationJobKind.Tmpl, fn: createI18nIcuExpressions },
18561
18551
  { kind: CompilationJobKind.Tmpl, fn: applyI18nExpressions },
18562
18552
  { kind: CompilationJobKind.Tmpl, fn: createVariadicPipes },
18563
18553
  { kind: CompilationJobKind.Both, fn: generatePureLiteralStructures },
@@ -18581,6 +18571,7 @@ var phases = [
18581
18571
  { kind: CompilationJobKind.Tmpl, fn: createDeferDepsFns },
18582
18572
  { kind: CompilationJobKind.Tmpl, fn: resolveI18nElementPlaceholders },
18583
18573
  { kind: CompilationJobKind.Tmpl, fn: resolveI18nExpressionPlaceholders },
18574
+ { kind: CompilationJobKind.Tmpl, fn: resolveI18nIcuPlaceholders },
18584
18575
  { kind: CompilationJobKind.Tmpl, fn: mergeI18nContexts },
18585
18576
  { kind: CompilationJobKind.Tmpl, fn: extractI18nMessages },
18586
18577
  { kind: CompilationJobKind.Tmpl, fn: generateTrackFns },
@@ -18845,7 +18836,7 @@ function ingestContent(unit, content) {
18845
18836
  function ingestText(unit, text2) {
18846
18837
  unit.create.push(createTextOp(unit.job.allocateXrefId(), text2.value, text2.sourceSpan));
18847
18838
  }
18848
- function ingestBoundText(unit, text2) {
18839
+ function ingestBoundText(unit, text2, i18nPlaceholders) {
18849
18840
  var _a2;
18850
18841
  let value = text2.value;
18851
18842
  if (value instanceof ASTWithSource) {
@@ -18857,7 +18848,12 @@ function ingestBoundText(unit, text2) {
18857
18848
  if (text2.i18n !== void 0 && !(text2.i18n instanceof Container)) {
18858
18849
  throw Error(`Unhandled i18n metadata type for text interpolation: ${(_a2 = text2.i18n) == null ? void 0 : _a2.constructor.name}`);
18859
18850
  }
18860
- const i18nPlaceholders = text2.i18n instanceof Container ? text2.i18n.children.filter((node) => node instanceof Placeholder) : [];
18851
+ if (i18nPlaceholders === void 0) {
18852
+ i18nPlaceholders = text2.i18n instanceof Container ? text2.i18n.children.filter((node) => node instanceof Placeholder).map((placeholder) => placeholder.name) : [];
18853
+ }
18854
+ if (i18nPlaceholders.length > 0 && i18nPlaceholders.length !== value.expressions.length) {
18855
+ throw Error(`Unexpected number of i18n placeholders (${value.expressions.length}) for BoundText with ${value.expressions.length} expressions`);
18856
+ }
18861
18857
  const textXref = unit.job.allocateXrefId();
18862
18858
  unit.create.push(createTextOp(textXref, "", text2.sourceSpan));
18863
18859
  const baseSourceSpan = unit.job.compatibility ? null : text2.sourceSpan;
@@ -19003,13 +18999,26 @@ function ingestDeferBlock(unit, deferBlock) {
19003
18999
  unit.update.push(deferWhenOps);
19004
19000
  }
19005
19001
  function ingestIcu(unit, icu) {
19006
- var _a2;
19002
+ var _a2, _b2;
19007
19003
  if (icu.i18n instanceof Message && isSingleI18nIcu(icu.i18n)) {
19008
19004
  const xref = unit.job.allocateXrefId();
19009
- unit.create.push(createIcuOp(xref, icu.i18n, icu.i18n.nodes[0], icuFromI18nMessage(icu.i18n).name, null));
19010
- unit.update.push(createIcuUpdateOp(xref, null));
19005
+ const icuNode = icu.i18n.nodes[0];
19006
+ unit.create.push(createIcuStartOp(xref, icu.i18n, icuFromI18nMessage(icu.i18n).name, null));
19007
+ const expressionPlaceholder = (_a2 = icuNode.expressionPlaceholder) == null ? void 0 : _a2.trimEnd();
19008
+ if (expressionPlaceholder === void 0 || icu.vars[expressionPlaceholder] === void 0) {
19009
+ throw Error("ICU should have a text binding");
19010
+ }
19011
+ ingestBoundText(unit, icu.vars[expressionPlaceholder], [expressionPlaceholder]);
19012
+ for (const [placeholder, text2] of Object.entries(icu.placeholders)) {
19013
+ if (text2 instanceof BoundText) {
19014
+ ingestBoundText(unit, text2, [placeholder]);
19015
+ } else {
19016
+ ingestText(unit, text2);
19017
+ }
19018
+ }
19019
+ unit.create.push(createIcuEndOp(xref));
19011
19020
  } else {
19012
- throw Error(`Unhandled i18n metadata type for ICU: ${(_a2 = icu.i18n) == null ? void 0 : _a2.constructor.name}`);
19021
+ throw Error(`Unhandled i18n metadata type for ICU: ${(_b2 = icu.i18n) == null ? void 0 : _b2.constructor.name}`);
19013
19022
  }
19014
19023
  }
19015
19024
  function ingestForBlock(unit, forBlock) {
@@ -21968,7 +21977,7 @@ var TemplateDefinitionBuilder = class {
21968
21977
  const placeholders = this.i18nBindProps(icu.placeholders);
21969
21978
  const message = icu.i18n;
21970
21979
  const transformFn = (raw) => {
21971
- const params = __spreadValues(__spreadValues({}, vars), placeholders);
21980
+ const params = Object.fromEntries(Object.entries(__spreadValues(__spreadValues({}, vars), placeholders)).sort());
21972
21981
  const formatted = formatI18nPlaceholderNamesInMap(params, false);
21973
21982
  return invokeInstruction(null, Identifiers.i18nPostprocess, [raw, mapLiteral(formatted, true)]);
21974
21983
  };
@@ -24761,7 +24770,7 @@ function publishFacade(global) {
24761
24770
  }
24762
24771
 
24763
24772
  // bazel-out/k8-fastbuild/bin/packages/compiler/src/version.mjs
24764
- var VERSION2 = new Version("17.0.2");
24773
+ var VERSION2 = new Version("17.0.3");
24765
24774
 
24766
24775
  // bazel-out/k8-fastbuild/bin/packages/compiler/src/i18n/extractor_merger.mjs
24767
24776
  var _VisitorMode;
@@ -24807,14 +24816,63 @@ publishFacade(_global);
24807
24816
 
24808
24817
  // bazel-out/k8-fastbuild/bin/packages/core/schematics/ng-generate/control-flow-migration/types.mjs
24809
24818
  var ngtemplate = "ng-template";
24819
+ var boundngifelse = "[ngIfElse]";
24820
+ var boundngifthenelse = "[ngIfThenElse]";
24821
+ var nakedngfor = "ngFor";
24822
+ function allFormsOf(selector) {
24823
+ return [
24824
+ selector,
24825
+ `*${selector}`,
24826
+ `[${selector}]`
24827
+ ];
24828
+ }
24829
+ var commonModuleDirectives = /* @__PURE__ */ new Set([
24830
+ ...allFormsOf("ngComponentOutlet"),
24831
+ ...allFormsOf("ngTemplateOutlet"),
24832
+ ...allFormsOf("ngClass"),
24833
+ ...allFormsOf("ngPlural"),
24834
+ ...allFormsOf("ngPluralCase"),
24835
+ ...allFormsOf("ngStyle"),
24836
+ ...allFormsOf("ngTemplateOutlet"),
24837
+ ...allFormsOf("ngComponentOutlet"),
24838
+ "[NgForOf]",
24839
+ "[NgForTrackBy]",
24840
+ "[ngIfElse]",
24841
+ "[ngIfThenElse]"
24842
+ ]);
24843
+ function pipeMatchRegExpFor(name) {
24844
+ return new RegExp(`\\|\\s*${name}`);
24845
+ }
24846
+ var commonModulePipes = [
24847
+ "date",
24848
+ "async",
24849
+ "currency",
24850
+ "number",
24851
+ "i18nPlural",
24852
+ "i18nSelect",
24853
+ "json",
24854
+ "keyvalue",
24855
+ "slice",
24856
+ "lowercase",
24857
+ "uppercase",
24858
+ "titlecase",
24859
+ "percent",
24860
+ "titlecase"
24861
+ ].map((name) => pipeMatchRegExpFor(name));
24810
24862
  var ElementToMigrate = class {
24811
- constructor(el, attr) {
24863
+ constructor(el, attr, elseAttr = void 0, thenAttr = void 0, forAttrs = void 0) {
24812
24864
  __publicField(this, "el");
24813
24865
  __publicField(this, "attr");
24866
+ __publicField(this, "elseAttr");
24867
+ __publicField(this, "thenAttr");
24868
+ __publicField(this, "forAttrs");
24814
24869
  __publicField(this, "nestCount", 0);
24815
24870
  __publicField(this, "hasLineBreaks", false);
24816
24871
  this.el = el;
24817
24872
  this.attr = attr;
24873
+ this.elseAttr = elseAttr;
24874
+ this.thenAttr = thenAttr;
24875
+ this.forAttrs = forAttrs;
24818
24876
  }
24819
24877
  getCondition(targetStr) {
24820
24878
  const targetLocation = this.attr.value.indexOf(targetStr);
@@ -24862,9 +24920,12 @@ var Template2 = class {
24862
24920
  var AnalyzedFile = class {
24863
24921
  constructor() {
24864
24922
  __publicField(this, "ranges", []);
24923
+ __publicField(this, "removeCommonModule", false);
24865
24924
  }
24866
24925
  getSortedRanges() {
24867
- return this.ranges.slice().sort(([aStart], [bStart]) => bStart - aStart);
24926
+ const templateRanges = this.ranges.slice().filter((x) => x.type === "template").sort((aStart, bStart) => bStart.start - aStart.start);
24927
+ const importRanges = this.ranges.slice().filter((x) => x.type === "import").sort((aStart, bStart) => bStart.start - aStart.start);
24928
+ return [...templateRanges, ...importRanges];
24868
24929
  }
24869
24930
  static addRange(path2, analyzedFiles, range) {
24870
24931
  let analysis = analyzedFiles.get(path2);
@@ -24872,12 +24933,39 @@ var AnalyzedFile = class {
24872
24933
  analysis = new AnalyzedFile();
24873
24934
  analyzedFiles.set(path2, analysis);
24874
24935
  }
24875
- const duplicate = analysis.ranges.find((current) => current[0] === range[0] && current[1] === range[1]);
24936
+ const duplicate = analysis.ranges.find((current) => current.start === range.start && current.end === range.end);
24876
24937
  if (!duplicate) {
24877
24938
  analysis.ranges.push(range);
24878
24939
  }
24879
24940
  }
24880
24941
  };
24942
+ var CommonCollector = class extends RecursiveVisitor {
24943
+ constructor() {
24944
+ super(...arguments);
24945
+ __publicField(this, "count", 0);
24946
+ }
24947
+ visitElement(el) {
24948
+ if (el.attrs.length > 0) {
24949
+ for (const attr of el.attrs) {
24950
+ if (this.hasDirectives(attr.name) || this.hasPipes(attr.value)) {
24951
+ this.count++;
24952
+ }
24953
+ }
24954
+ }
24955
+ super.visitElement(el, null);
24956
+ }
24957
+ visitText(ast) {
24958
+ if (this.hasPipes(ast.value)) {
24959
+ this.count++;
24960
+ }
24961
+ }
24962
+ hasDirectives(input) {
24963
+ return commonModuleDirectives.has(input);
24964
+ }
24965
+ hasPipes(input) {
24966
+ return commonModulePipes.some((regexp) => regexp.test(input));
24967
+ }
24968
+ };
24881
24969
  var ElementCollector = class extends RecursiveVisitor {
24882
24970
  constructor(_attributes = []) {
24883
24971
  super();
@@ -24889,12 +24977,37 @@ var ElementCollector = class extends RecursiveVisitor {
24889
24977
  if (el.attrs.length > 0) {
24890
24978
  for (const attr of el.attrs) {
24891
24979
  if (this._attributes.includes(attr.name)) {
24892
- this.elements.push(new ElementToMigrate(el, attr));
24980
+ const elseAttr = el.attrs.find((x) => x.name === boundngifelse);
24981
+ const thenAttr = el.attrs.find((x) => x.name === boundngifthenelse);
24982
+ const forAttrs = attr.name === nakedngfor ? this.getForAttrs(el) : void 0;
24983
+ this.elements.push(new ElementToMigrate(el, attr, elseAttr, thenAttr, forAttrs));
24893
24984
  }
24894
24985
  }
24895
24986
  }
24896
24987
  super.visitElement(el, null);
24897
24988
  }
24989
+ getForAttrs(el) {
24990
+ const aliases = /* @__PURE__ */ new Map();
24991
+ let item = "";
24992
+ let trackBy = "";
24993
+ let forOf = "";
24994
+ for (const attr of el.attrs) {
24995
+ if (attr.name === "[ngForTrackBy]") {
24996
+ trackBy = attr.value;
24997
+ }
24998
+ if (attr.name === "[ngForOf]") {
24999
+ forOf = attr.value;
25000
+ }
25001
+ if (attr.name.startsWith("let-")) {
25002
+ if (attr.value === "") {
25003
+ item = attr.name.replace("let-", "");
25004
+ } else {
25005
+ aliases.set(attr.name.replace("let-", ""), attr.value);
25006
+ }
25007
+ }
25008
+ }
25009
+ return { forOf, trackBy, item, aliases };
25010
+ }
24898
25011
  };
24899
25012
  var TemplateCollector = class extends RecursiveVisitor {
24900
25013
  constructor() {
@@ -24926,31 +25039,107 @@ var TemplateCollector = class extends RecursiveVisitor {
24926
25039
  // bazel-out/k8-fastbuild/bin/packages/core/schematics/ng-generate/control-flow-migration/util.mjs
24927
25040
  var import_path2 = require("path");
24928
25041
  var import_typescript5 = __toESM(require("typescript"), 1);
25042
+ var importRemovals = [
25043
+ "NgIf",
25044
+ "NgIfElse",
25045
+ "NgIfThenElse",
25046
+ "NgFor",
25047
+ "NgForOf",
25048
+ "NgForTrackBy",
25049
+ "NgSwitch",
25050
+ "NgSwitchCase",
25051
+ "NgSwitchDefault"
25052
+ ];
25053
+ var importWithCommonRemovals = [...importRemovals, "CommonModule"];
24929
25054
  function analyze(sourceFile, analyzedFiles) {
24930
25055
  forEachClass(sourceFile, (node) => {
24931
- var _a2;
24932
- const decorator = (_a2 = import_typescript5.default.getDecorators(node)) == null ? void 0 : _a2.find((dec) => {
24933
- return import_typescript5.default.isCallExpression(dec.expression) && import_typescript5.default.isIdentifier(dec.expression.expression) && dec.expression.expression.text === "Component";
24934
- });
24935
- const metadata = decorator && decorator.expression.arguments.length > 0 && import_typescript5.default.isObjectLiteralExpression(decorator.expression.arguments[0]) ? decorator.expression.arguments[0] : null;
24936
- if (!metadata) {
24937
- return;
25056
+ if (import_typescript5.default.isClassDeclaration(node)) {
25057
+ analyzeDecorators(node, sourceFile, analyzedFiles);
25058
+ } else {
25059
+ analyzeImportDeclarations(node, sourceFile, analyzedFiles);
24938
25060
  }
24939
- for (const prop of metadata.properties) {
24940
- if (!import_typescript5.default.isPropertyAssignment(prop) || !import_typescript5.default.isStringLiteralLike(prop.initializer) || !import_typescript5.default.isIdentifier(prop.name) && !import_typescript5.default.isStringLiteralLike(prop.name)) {
24941
- continue;
24942
- }
24943
- switch (prop.name.text) {
24944
- case "template":
24945
- AnalyzedFile.addRange(sourceFile.fileName, analyzedFiles, [prop.initializer.getStart() + 1, prop.initializer.getEnd() - 1]);
24946
- break;
24947
- case "templateUrl":
24948
- const path2 = (0, import_path2.join)((0, import_path2.dirname)(sourceFile.fileName), prop.initializer.text);
24949
- AnalyzedFile.addRange(path2, analyzedFiles, [0]);
24950
- break;
24951
- }
25061
+ });
25062
+ }
25063
+ function updateImportDeclaration(decl, removeCommonModule) {
25064
+ const clause = decl.getChildAt(1);
25065
+ const updatedClause = updateImportClause(clause, removeCommonModule);
25066
+ if (updatedClause === null) {
25067
+ return "";
25068
+ }
25069
+ const printer = import_typescript5.default.createPrinter();
25070
+ const updated = import_typescript5.default.factory.updateImportDeclaration(decl, decl.modifiers, updatedClause, decl.moduleSpecifier, void 0);
25071
+ return printer.printNode(import_typescript5.default.EmitHint.Unspecified, updated, clause.getSourceFile());
25072
+ }
25073
+ function updateImportClause(clause, removeCommonModule) {
25074
+ if (clause.namedBindings && import_typescript5.default.isNamedImports(clause.namedBindings)) {
25075
+ const removals = removeCommonModule ? importWithCommonRemovals : importRemovals;
25076
+ const elements = clause.namedBindings.elements.filter((el) => !removals.includes(el.getText()));
25077
+ if (elements.length === 0) {
25078
+ return null;
25079
+ }
25080
+ clause = import_typescript5.default.factory.updateImportClause(clause, clause.isTypeOnly, clause.name, import_typescript5.default.factory.createNamedImports(elements));
25081
+ }
25082
+ return clause;
25083
+ }
25084
+ function updateClassImports(propAssignment, removeCommonModule) {
25085
+ const printer = import_typescript5.default.createPrinter();
25086
+ const importList = propAssignment.initializer;
25087
+ const removals = removeCommonModule ? importWithCommonRemovals : importRemovals;
25088
+ const elements = importList.elements.filter((el) => !removals.includes(el.getText()));
25089
+ const updatedElements = import_typescript5.default.factory.updateArrayLiteralExpression(importList, elements);
25090
+ const updatedAssignment = import_typescript5.default.factory.updatePropertyAssignment(propAssignment, propAssignment.name, updatedElements);
25091
+ return printer.printNode(import_typescript5.default.EmitHint.Unspecified, updatedAssignment, updatedAssignment.getSourceFile());
25092
+ }
25093
+ function analyzeImportDeclarations(node, sourceFile, analyzedFiles) {
25094
+ if (node.getText().indexOf("@angular/common") === -1) {
25095
+ return;
25096
+ }
25097
+ const clause = node.getChildAt(1);
25098
+ if (clause.namedBindings && import_typescript5.default.isNamedImports(clause.namedBindings)) {
25099
+ const elements = clause.namedBindings.elements.filter((el) => importWithCommonRemovals.includes(el.getText()));
25100
+ if (elements.length > 0) {
25101
+ AnalyzedFile.addRange(sourceFile.fileName, analyzedFiles, { start: node.getStart(), end: node.getEnd(), node, type: "import" });
24952
25102
  }
25103
+ }
25104
+ }
25105
+ function analyzeDecorators(node, sourceFile, analyzedFiles) {
25106
+ var _a2;
25107
+ const decorator = (_a2 = import_typescript5.default.getDecorators(node)) == null ? void 0 : _a2.find((dec) => {
25108
+ return import_typescript5.default.isCallExpression(dec.expression) && import_typescript5.default.isIdentifier(dec.expression.expression) && dec.expression.expression.text === "Component";
24953
25109
  });
25110
+ const metadata = decorator && decorator.expression.arguments.length > 0 && import_typescript5.default.isObjectLiteralExpression(decorator.expression.arguments[0]) ? decorator.expression.arguments[0] : null;
25111
+ if (!metadata) {
25112
+ return;
25113
+ }
25114
+ for (const prop of metadata.properties) {
25115
+ if (!import_typescript5.default.isPropertyAssignment(prop) || !import_typescript5.default.isIdentifier(prop.name) && !import_typescript5.default.isStringLiteralLike(prop.name)) {
25116
+ continue;
25117
+ }
25118
+ switch (prop.name.text) {
25119
+ case "template":
25120
+ AnalyzedFile.addRange(sourceFile.fileName, analyzedFiles, {
25121
+ start: prop.initializer.getStart() + 1,
25122
+ end: prop.initializer.getEnd() - 1,
25123
+ node: prop,
25124
+ type: "template"
25125
+ });
25126
+ break;
25127
+ case "imports":
25128
+ AnalyzedFile.addRange(sourceFile.fileName, analyzedFiles, {
25129
+ start: prop.name.getStart(),
25130
+ end: prop.initializer.getEnd(),
25131
+ node: prop,
25132
+ type: "import"
25133
+ });
25134
+ break;
25135
+ case "templateUrl":
25136
+ if (import_typescript5.default.isStringLiteralLike(prop.initializer)) {
25137
+ const path2 = (0, import_path2.join)((0, import_path2.dirname)(sourceFile.fileName), prop.initializer.text);
25138
+ AnalyzedFile.addRange(path2, analyzedFiles, { start: 0, node: prop, type: "template" });
25139
+ }
25140
+ break;
25141
+ }
25142
+ }
24954
25143
  }
24955
25144
  function getNestedCount(etm, aggregator) {
24956
25145
  if (aggregator.length === 0) {
@@ -25036,21 +25225,40 @@ function wrapIntoI18nContainer(i18nAttr, content) {
25036
25225
  function processNgTemplates(template2) {
25037
25226
  const templates = countTemplateUsage(template2);
25038
25227
  for (const [name, t] of templates) {
25039
- const placeholder = `${name}|`;
25040
- if (template2.indexOf(placeholder) > -1) {
25228
+ const replaceRegex = new RegExp(`${name}\\|`, "g");
25229
+ const matches = [...template2.matchAll(replaceRegex)];
25230
+ if (matches.length > 0) {
25041
25231
  if (t.i18n !== null) {
25042
25232
  const container = wrapIntoI18nContainer(t.i18n, t.children);
25043
- template2 = template2.replace(placeholder, container);
25233
+ template2 = template2.replace(replaceRegex, container);
25044
25234
  } else {
25045
- template2 = template2.replace(placeholder, t.children);
25235
+ template2 = template2.replace(replaceRegex, t.children);
25046
25236
  }
25047
- if (t.count <= 2) {
25237
+ if (t.count === matches.length + 1) {
25048
25238
  template2 = template2.replace(t.contents, "");
25049
25239
  }
25050
25240
  }
25051
25241
  }
25052
25242
  return template2;
25053
25243
  }
25244
+ function canRemoveCommonModule(template2) {
25245
+ const parsed = parseTemplate2(template2);
25246
+ let removeCommonModule = false;
25247
+ if (parsed !== null) {
25248
+ const visitor = new CommonCollector();
25249
+ visitAll2(visitor, parsed.rootNodes);
25250
+ removeCommonModule = visitor.count === 0;
25251
+ }
25252
+ return removeCommonModule;
25253
+ }
25254
+ function removeImports(template2, node, removeCommonModule) {
25255
+ if (template2.startsWith("imports") && import_typescript5.default.isPropertyAssignment(node)) {
25256
+ return updateClassImports(node, removeCommonModule);
25257
+ } else if (import_typescript5.default.isImportDeclaration(node)) {
25258
+ return updateImportDeclaration(node, removeCommonModule);
25259
+ }
25260
+ return template2;
25261
+ }
25054
25262
  function getOriginals(etm, tmpl, offset) {
25055
25263
  if (etm.el.children.length > 0) {
25056
25264
  const start2 = tmpl.slice(etm.el.sourceSpan.start.offset - offset, etm.el.children[0].sourceSpan.start.offset - offset);
@@ -25060,14 +25268,20 @@ function getOriginals(etm, tmpl, offset) {
25060
25268
  const start = tmpl.slice(etm.el.sourceSpan.start.offset - offset, etm.el.sourceSpan.end.offset - offset);
25061
25269
  return { start, end: "" };
25062
25270
  }
25271
+ function isI18nTemplate(etm, i18nAttr) {
25272
+ return etm.el.name === "ng-template" && i18nAttr !== void 0 && (etm.el.attrs.length === 2 || etm.el.attrs.length === 3 && etm.elseAttr !== void 0);
25273
+ }
25274
+ function isRemovableContainer(etm) {
25275
+ return (etm.el.name === "ng-container" || etm.el.name === "ng-template") && (etm.el.attrs.length === 1 || etm.forAttrs !== void 0 || etm.el.attrs.length === 2 && etm.elseAttr !== void 0 || etm.el.attrs.length === 3 && etm.elseAttr !== void 0 && etm.thenAttr !== void 0);
25276
+ }
25063
25277
  function getMainBlock(etm, tmpl, offset) {
25064
25278
  const i18nAttr = etm.el.attrs.find((x) => x.name === "i18n");
25065
- if ((etm.el.name === "ng-container" || etm.el.name === "ng-template") && etm.el.attrs.length === 1) {
25279
+ if (isRemovableContainer(etm)) {
25066
25280
  const childStart2 = etm.el.children[0].sourceSpan.start.offset - offset;
25067
25281
  const childEnd2 = etm.el.children[etm.el.children.length - 1].sourceSpan.end.offset - offset;
25068
25282
  const middle2 = tmpl.slice(childStart2, childEnd2);
25069
25283
  return { start: "", middle: middle2, end: "" };
25070
- } else if (etm.el.name === "ng-template" && etm.el.attrs.length === 2 && i18nAttr !== void 0) {
25284
+ } else if (isI18nTemplate(etm, i18nAttr)) {
25071
25285
  const childStart2 = etm.el.children[0].sourceSpan.start.offset - offset;
25072
25286
  const childEnd2 = etm.el.children[etm.el.children.length - 1].sourceSpan.end.offset - offset;
25073
25287
  const middle2 = wrapIntoI18nContainer(i18nAttr, tmpl.slice(childStart2, childEnd2));
@@ -25089,7 +25303,7 @@ function getMainBlock(etm, tmpl, offset) {
25089
25303
  }
25090
25304
  function forEachClass(sourceFile, callback) {
25091
25305
  sourceFile.forEachChild(function walk(node) {
25092
- if (import_typescript5.default.isClassDeclaration(node)) {
25306
+ if (import_typescript5.default.isClassDeclaration(node) || import_typescript5.default.isImportDeclaration(node)) {
25093
25307
  callback(node);
25094
25308
  }
25095
25309
  node.forEachChild(walk);
@@ -25098,6 +25312,11 @@ function forEachClass(sourceFile, callback) {
25098
25312
 
25099
25313
  // bazel-out/k8-fastbuild/bin/packages/core/schematics/ng-generate/control-flow-migration/fors.mjs
25100
25314
  var ngfor = "*ngFor";
25315
+ var nakedngfor2 = "ngFor";
25316
+ var fors = [
25317
+ ngfor,
25318
+ nakedngfor2
25319
+ ];
25101
25320
  var commaSeparatedSyntax = /* @__PURE__ */ new Map([
25102
25321
  ["(", ")"],
25103
25322
  ["{", "}"],
@@ -25114,7 +25333,7 @@ function migrateFor(template2) {
25114
25333
  return { migrated: template2, errors };
25115
25334
  }
25116
25335
  let result = template2;
25117
- const visitor = new ElementCollector([ngfor]);
25336
+ const visitor = new ElementCollector(fors);
25118
25337
  visitAll2(visitor, parsed.rootNodes);
25119
25338
  calculateNesting(visitor, hasLineBreaks(template2));
25120
25339
  let offset = 0;
@@ -25136,6 +25355,12 @@ function migrateFor(template2) {
25136
25355
  return { migrated: result, errors };
25137
25356
  }
25138
25357
  function migrateNgFor(etm, tmpl, offset) {
25358
+ if (etm.forAttrs !== void 0) {
25359
+ return migrateBoundNgFor(etm, tmpl, offset);
25360
+ }
25361
+ return migrateStandardNgFor(etm, tmpl, offset);
25362
+ }
25363
+ function migrateStandardNgFor(etm, tmpl, offset) {
25139
25364
  const aliasWithEqualRegexp = /=\s*(count|index|first|last|even|odd)/gm;
25140
25365
  const aliasWithAsRegexp = /(count|index|first|last|even|odd)\s+as/gm;
25141
25366
  const aliases = [];
@@ -25182,6 +25407,35 @@ function migrateNgFor(etm, tmpl, offset) {
25182
25407
  const post = originals.end.length - endBlock.length;
25183
25408
  return { tmpl: updatedTmpl, offsets: { pre, post } };
25184
25409
  }
25410
+ function migrateBoundNgFor(etm, tmpl, offset) {
25411
+ const forAttrs = etm.forAttrs;
25412
+ const aliasMap = forAttrs.aliases;
25413
+ const originals = getOriginals(etm, tmpl, offset);
25414
+ const condition = `${forAttrs.item} of ${forAttrs.forOf}`;
25415
+ const aliases = [];
25416
+ let aliasedIndex = "$index";
25417
+ for (const [key, val] of aliasMap) {
25418
+ aliases.push(` let ${key.trim()} = $${val}`);
25419
+ if (val.trim() === "index") {
25420
+ aliasedIndex = key;
25421
+ }
25422
+ }
25423
+ const aliasStr = aliases.length > 0 ? `;${aliases.join(";")}` : "";
25424
+ let trackBy = forAttrs.item;
25425
+ if (forAttrs.trackBy !== "") {
25426
+ trackBy = `${forAttrs.trackBy.trim()}(${aliasedIndex}, ${forAttrs.item})`;
25427
+ }
25428
+ const { start, middle, end } = getMainBlock(etm, tmpl, offset);
25429
+ const startBlock = `@for (${condition}; track ${trackBy}${aliasStr}) {
25430
+ ${start}`;
25431
+ const endBlock = `${end}
25432
+ }`;
25433
+ const forBlock = startBlock + middle + endBlock;
25434
+ const updatedTmpl = tmpl.slice(0, etm.start(offset)) + forBlock + tmpl.slice(etm.end(offset));
25435
+ const pre = originals.start.length - startBlock.length;
25436
+ const post = originals.end.length - endBlock.length;
25437
+ return { tmpl: updatedTmpl, offsets: { pre, post } };
25438
+ }
25185
25439
  function getNgForParts(expression) {
25186
25440
  const parts = [];
25187
25441
  const commaSeparatedStack = [];
@@ -25254,10 +25508,12 @@ function migrateIf(template2) {
25254
25508
  function migrateNgIf(etm, tmpl, offset) {
25255
25509
  const matchThen = etm.attr.value.match(/;\s*then/gm);
25256
25510
  const matchElse = etm.attr.value.match(/;\s*else/gm);
25257
- if (matchThen && matchThen.length > 0) {
25258
- return buildIfThenElseBlock(etm, tmpl, matchThen[0], matchElse[0], offset);
25511
+ if (etm.thenAttr !== void 0 || etm.elseAttr !== void 0) {
25512
+ return buildBoundIfElseBlock(etm, tmpl, offset);
25513
+ } else if (matchThen && matchThen.length > 0) {
25514
+ return buildStandardIfThenElseBlock(etm, tmpl, matchThen[0], matchElse[0], offset);
25259
25515
  } else if (matchElse && matchElse.length > 0) {
25260
- return buildIfElseBlock(etm, tmpl, matchElse[0], offset);
25516
+ return buildStandardIfElseBlock(etm, tmpl, matchElse[0], offset);
25261
25517
  }
25262
25518
  return buildIfBlock(etm, tmpl, offset);
25263
25519
  }
@@ -25274,11 +25530,23 @@ function buildIfBlock(etm, tmpl, offset) {
25274
25530
  const post = originals.end.length - endBlock.length;
25275
25531
  return { tmpl: updatedTmpl, offsets: { pre, post } };
25276
25532
  }
25277
- function buildIfElseBlock(etm, tmpl, elseString, offset) {
25278
- const lbString = etm.hasLineBreaks ? "\n" : "";
25533
+ function buildStandardIfElseBlock(etm, tmpl, elseString, offset) {
25279
25534
  const condition = etm.getCondition(elseString).replace(" as ", "; as ");
25280
- const originals = getOriginals(etm, tmpl, offset);
25281
25535
  const elsePlaceholder = `#${etm.getTemplateName(elseString)}|`;
25536
+ return buildIfElseBlock(etm, tmpl, condition, elsePlaceholder, offset);
25537
+ }
25538
+ function buildBoundIfElseBlock(etm, tmpl, offset) {
25539
+ const condition = etm.attr.value.replace(" as ", "; as ");
25540
+ const elsePlaceholder = `#${etm.elseAttr.value}|`;
25541
+ if (etm.thenAttr !== void 0) {
25542
+ const thenPlaceholder = `#${etm.thenAttr.value}|`;
25543
+ return buildIfThenElseBlock(etm, tmpl, condition, thenPlaceholder, elsePlaceholder, offset);
25544
+ }
25545
+ return buildIfElseBlock(etm, tmpl, condition, elsePlaceholder, offset);
25546
+ }
25547
+ function buildIfElseBlock(etm, tmpl, condition, elsePlaceholder, offset) {
25548
+ const lbString = etm.hasLineBreaks ? "\n" : "";
25549
+ const originals = getOriginals(etm, tmpl, offset);
25282
25550
  const { start, middle, end } = getMainBlock(etm, tmpl, offset);
25283
25551
  const startBlock = `@if (${condition}) {${lbString}${start}`;
25284
25552
  const elseBlock = `${end}${lbString}} @else {${lbString}`;
@@ -25291,14 +25559,17 @@ function buildIfElseBlock(etm, tmpl, elseString, offset) {
25291
25559
  const post = originals.end.length - postBlock.length;
25292
25560
  return { tmpl: updatedTmpl, offsets: { pre, post } };
25293
25561
  }
25294
- function buildIfThenElseBlock(etm, tmpl, thenString, elseString, offset) {
25562
+ function buildStandardIfThenElseBlock(etm, tmpl, thenString, elseString, offset) {
25295
25563
  const condition = etm.getCondition(thenString).replace(" as ", "; as ");
25564
+ const thenPlaceholder = `#${etm.getTemplateName(thenString, elseString)}|`;
25565
+ const elsePlaceholder = `#${etm.getTemplateName(elseString)}|`;
25566
+ return buildIfThenElseBlock(etm, tmpl, condition, thenPlaceholder, elsePlaceholder, offset);
25567
+ }
25568
+ function buildIfThenElseBlock(etm, tmpl, condition, thenPlaceholder, elsePlaceholder, offset) {
25296
25569
  const lbString = etm.hasLineBreaks ? "\n" : "";
25297
25570
  const originals = getOriginals(etm, tmpl, offset);
25298
25571
  const startBlock = `@if (${condition}) {${lbString}`;
25299
25572
  const elseBlock = `${lbString}} @else {${lbString}`;
25300
- const thenPlaceholder = `#${etm.getTemplateName(thenString, elseString)}|`;
25301
- const elsePlaceholder = `#${etm.getTemplateName(elseString)}|`;
25302
25573
  const postBlock = thenPlaceholder + elseBlock + elsePlaceholder + `${lbString}}`;
25303
25574
  const ifThenElseBlock = startBlock + postBlock;
25304
25575
  const tmplStart = tmpl.slice(0, etm.start(offset));
@@ -25409,13 +25680,36 @@ function migrateNgSwitchDefault(etm, tmpl, offset) {
25409
25680
  return { tmpl: updatedTmpl, offsets: { pre, post } };
25410
25681
  }
25411
25682
 
25683
+ // bazel-out/k8-fastbuild/bin/packages/core/schematics/ng-generate/control-flow-migration/migration.mjs
25684
+ function migrateTemplate(template2, templateType, node, file) {
25685
+ let errors = [];
25686
+ let migrated = template2;
25687
+ if (templateType === "template") {
25688
+ const ifResult = migrateIf(template2);
25689
+ const forResult = migrateFor(ifResult.migrated);
25690
+ const switchResult = migrateSwitch(forResult.migrated);
25691
+ migrated = processNgTemplates(switchResult.migrated);
25692
+ file.removeCommonModule = canRemoveCommonModule(template2);
25693
+ errors = [
25694
+ ...ifResult.errors,
25695
+ ...forResult.errors,
25696
+ ...switchResult.errors
25697
+ ];
25698
+ } else {
25699
+ migrated = removeImports(template2, node, file.removeCommonModule);
25700
+ }
25701
+ return { migrated, errors };
25702
+ }
25703
+
25412
25704
  // bazel-out/k8-fastbuild/bin/packages/core/schematics/ng-generate/control-flow-migration/index.mjs
25413
25705
  function control_flow_migration_default(options) {
25414
25706
  return (tree, context) => __async(this, null, function* () {
25415
- const { buildPaths, testPaths } = yield getProjectTsConfigPaths(tree);
25416
25707
  const basePath = process.cwd();
25417
25708
  const pathToMigrate = normalizePath((0, import_path3.join)(basePath, options.path));
25418
- const allPaths = options.path !== "./" ? [...buildPaths, ...testPaths] : [pathToMigrate];
25709
+ let allPaths = [];
25710
+ if (pathToMigrate.trim() !== "") {
25711
+ allPaths.push(pathToMigrate);
25712
+ }
25419
25713
  if (!allPaths.length) {
25420
25714
  throw new import_schematics.SchematicsException("Could not find any tsconfig file. Cannot run the control flow migration.");
25421
25715
  }
@@ -25453,18 +25747,10 @@ function runControlFlowMigration(tree, tsconfigPath, basePath, pathToMigrate, sc
25453
25747
  const relativePath = (0, import_path3.relative)(basePath, path2);
25454
25748
  const content = tree.readText(relativePath);
25455
25749
  const update = tree.beginUpdate(relativePath);
25456
- for (const [start, end] of ranges) {
25750
+ for (const { start, end, node, type } of ranges) {
25457
25751
  const template2 = content.slice(start, end);
25458
25752
  const length = (end != null ? end : content.length) - start;
25459
- const ifResult = migrateIf(template2);
25460
- const forResult = migrateFor(ifResult.migrated);
25461
- const switchResult = migrateSwitch(forResult.migrated);
25462
- const errors = [
25463
- ...ifResult.errors,
25464
- ...forResult.errors,
25465
- ...switchResult.errors
25466
- ];
25467
- const migrated = processNgTemplates(switchResult.migrated);
25753
+ const { migrated, errors } = migrateTemplate(template2, type, node, file);
25468
25754
  if (migrated !== null) {
25469
25755
  update.remove(start, length);
25470
25756
  update.insertLeft(start, migrated);