@angular/core 17.0.2 → 17.0.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.
- package/esm2022/src/core_render3_private_export.mjs +2 -2
- package/esm2022/src/defer/instructions.mjs +3 -2
- package/esm2022/src/defer/utils.mjs +2 -2
- package/esm2022/src/image_performance_warning.mjs +14 -3
- package/esm2022/src/render3/index.mjs +2 -2
- package/esm2022/src/render3/instructions/change_detection.mjs +10 -20
- package/esm2022/src/render3/instructions/control_flow.mjs +9 -11
- package/esm2022/src/render3/instructions/shared.mjs +4 -5
- package/esm2022/src/render3/interfaces/container.mjs +22 -17
- package/esm2022/src/render3/interfaces/view.mjs +2 -2
- package/esm2022/src/render3/node_manipulation.mjs +3 -3
- package/esm2022/src/render3/util/change_detection_utils.mjs +13 -2
- package/esm2022/src/render3/util/injector_discovery_utils.mjs +10 -13
- package/esm2022/src/render3/util/view_utils.mjs +4 -4
- package/esm2022/src/render3/view_ref.mjs +3 -3
- package/esm2022/src/version.mjs +1 -1
- package/esm2022/testing/src/logger.mjs +3 -3
- package/esm2022/testing/src/test_bed_compiler.mjs +4 -1
- package/fesm2022/core.mjs +83 -70
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/primitives/signals.mjs +1 -1
- package/fesm2022/rxjs-interop.mjs +1 -1
- package/fesm2022/testing.mjs +4 -1
- package/fesm2022/testing.mjs.map +1 -1
- package/index.d.ts +28 -40
- package/package.json +1 -1
- package/primitives/signals/index.d.ts +1 -1
- package/rxjs-interop/index.d.ts +1 -1
- package/schematics/migrations/block-template-entities/bundle.js +385 -159
- package/schematics/migrations/block-template-entities/bundle.js.map +4 -4
- package/schematics/ng-generate/control-flow-migration/bundle.js +867 -371
- package/schematics/ng-generate/control-flow-migration/bundle.js.map +4 -4
- package/schematics/ng-generate/control-flow-migration/schema.json +6 -0
- package/schematics/ng-generate/standalone-migration/bundle.js +422 -168
- package/schematics/ng-generate/standalone-migration/bundle.js.map +4 -4
- 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);
|
|
@@ -620,6 +540,9 @@ var _SerializerVisitor = class {
|
|
|
620
540
|
visitIcuPlaceholder(ph, context) {
|
|
621
541
|
return `<ph icu name="${ph.name}">${ph.value.visit(this)}</ph>`;
|
|
622
542
|
}
|
|
543
|
+
visitBlockPlaceholder(ph, context) {
|
|
544
|
+
return `<ph block name="${ph.startName}">${ph.children.map((child) => child.visit(this)).join(", ")}</ph name="${ph.closeName}">`;
|
|
545
|
+
}
|
|
623
546
|
};
|
|
624
547
|
var serializerVisitor = new _SerializerVisitor();
|
|
625
548
|
function serializeNodes(nodes) {
|
|
@@ -3665,43 +3588,47 @@ var BlockNode = class {
|
|
|
3665
3588
|
}
|
|
3666
3589
|
};
|
|
3667
3590
|
var DeferredBlockPlaceholder = class extends BlockNode {
|
|
3668
|
-
constructor(children, minimumTime, nameSpan, sourceSpan, startSourceSpan, endSourceSpan) {
|
|
3591
|
+
constructor(children, minimumTime, nameSpan, sourceSpan, startSourceSpan, endSourceSpan, i18n2) {
|
|
3669
3592
|
super(nameSpan, sourceSpan, startSourceSpan, endSourceSpan);
|
|
3670
3593
|
this.children = children;
|
|
3671
3594
|
this.minimumTime = minimumTime;
|
|
3595
|
+
this.i18n = i18n2;
|
|
3672
3596
|
}
|
|
3673
3597
|
visit(visitor) {
|
|
3674
3598
|
return visitor.visitDeferredBlockPlaceholder(this);
|
|
3675
3599
|
}
|
|
3676
3600
|
};
|
|
3677
3601
|
var DeferredBlockLoading = class extends BlockNode {
|
|
3678
|
-
constructor(children, afterTime, minimumTime, nameSpan, sourceSpan, startSourceSpan, endSourceSpan) {
|
|
3602
|
+
constructor(children, afterTime, minimumTime, nameSpan, sourceSpan, startSourceSpan, endSourceSpan, i18n2) {
|
|
3679
3603
|
super(nameSpan, sourceSpan, startSourceSpan, endSourceSpan);
|
|
3680
3604
|
this.children = children;
|
|
3681
3605
|
this.afterTime = afterTime;
|
|
3682
3606
|
this.minimumTime = minimumTime;
|
|
3607
|
+
this.i18n = i18n2;
|
|
3683
3608
|
}
|
|
3684
3609
|
visit(visitor) {
|
|
3685
3610
|
return visitor.visitDeferredBlockLoading(this);
|
|
3686
3611
|
}
|
|
3687
3612
|
};
|
|
3688
3613
|
var DeferredBlockError = class extends BlockNode {
|
|
3689
|
-
constructor(children, nameSpan, sourceSpan, startSourceSpan, endSourceSpan) {
|
|
3614
|
+
constructor(children, nameSpan, sourceSpan, startSourceSpan, endSourceSpan, i18n2) {
|
|
3690
3615
|
super(nameSpan, sourceSpan, startSourceSpan, endSourceSpan);
|
|
3691
3616
|
this.children = children;
|
|
3617
|
+
this.i18n = i18n2;
|
|
3692
3618
|
}
|
|
3693
3619
|
visit(visitor) {
|
|
3694
3620
|
return visitor.visitDeferredBlockError(this);
|
|
3695
3621
|
}
|
|
3696
3622
|
};
|
|
3697
3623
|
var DeferredBlock = class extends BlockNode {
|
|
3698
|
-
constructor(children, triggers, prefetchTriggers, placeholder, loading, error2, nameSpan, sourceSpan, mainBlockSpan, startSourceSpan, endSourceSpan) {
|
|
3624
|
+
constructor(children, triggers, prefetchTriggers, placeholder, loading, error2, nameSpan, sourceSpan, mainBlockSpan, startSourceSpan, endSourceSpan, i18n2) {
|
|
3699
3625
|
super(nameSpan, sourceSpan, startSourceSpan, endSourceSpan);
|
|
3700
3626
|
this.children = children;
|
|
3701
3627
|
this.placeholder = placeholder;
|
|
3702
3628
|
this.loading = loading;
|
|
3703
3629
|
this.error = error2;
|
|
3704
3630
|
this.mainBlockSpan = mainBlockSpan;
|
|
3631
|
+
this.i18n = i18n2;
|
|
3705
3632
|
this.triggers = triggers;
|
|
3706
3633
|
this.prefetchTriggers = prefetchTriggers;
|
|
3707
3634
|
this.definedTriggers = Object.keys(triggers);
|
|
@@ -3722,10 +3649,10 @@ var DeferredBlock = class extends BlockNode {
|
|
|
3722
3649
|
}
|
|
3723
3650
|
};
|
|
3724
3651
|
var SwitchBlock = class extends BlockNode {
|
|
3725
|
-
constructor(expression,
|
|
3652
|
+
constructor(expression, cases2, unknownBlocks, sourceSpan, startSourceSpan, endSourceSpan, nameSpan) {
|
|
3726
3653
|
super(nameSpan, sourceSpan, startSourceSpan, endSourceSpan);
|
|
3727
3654
|
this.expression = expression;
|
|
3728
|
-
this.cases =
|
|
3655
|
+
this.cases = cases2;
|
|
3729
3656
|
this.unknownBlocks = unknownBlocks;
|
|
3730
3657
|
}
|
|
3731
3658
|
visit(visitor) {
|
|
@@ -3733,17 +3660,18 @@ var SwitchBlock = class extends BlockNode {
|
|
|
3733
3660
|
}
|
|
3734
3661
|
};
|
|
3735
3662
|
var SwitchBlockCase = class extends BlockNode {
|
|
3736
|
-
constructor(expression, children, sourceSpan, startSourceSpan, endSourceSpan, nameSpan) {
|
|
3663
|
+
constructor(expression, children, sourceSpan, startSourceSpan, endSourceSpan, nameSpan, i18n2) {
|
|
3737
3664
|
super(nameSpan, sourceSpan, startSourceSpan, endSourceSpan);
|
|
3738
3665
|
this.expression = expression;
|
|
3739
3666
|
this.children = children;
|
|
3667
|
+
this.i18n = i18n2;
|
|
3740
3668
|
}
|
|
3741
3669
|
visit(visitor) {
|
|
3742
3670
|
return visitor.visitSwitchBlockCase(this);
|
|
3743
3671
|
}
|
|
3744
3672
|
};
|
|
3745
3673
|
var ForLoopBlock = class extends BlockNode {
|
|
3746
|
-
constructor(item, expression, trackBy, trackKeywordSpan, contextVariables, children, empty, sourceSpan, mainBlockSpan, startSourceSpan, endSourceSpan, nameSpan) {
|
|
3674
|
+
constructor(item, expression, trackBy, trackKeywordSpan, contextVariables, children, empty, sourceSpan, mainBlockSpan, startSourceSpan, endSourceSpan, nameSpan, i18n2) {
|
|
3747
3675
|
super(nameSpan, sourceSpan, startSourceSpan, endSourceSpan);
|
|
3748
3676
|
this.item = item;
|
|
3749
3677
|
this.expression = expression;
|
|
@@ -3753,15 +3681,17 @@ var ForLoopBlock = class extends BlockNode {
|
|
|
3753
3681
|
this.children = children;
|
|
3754
3682
|
this.empty = empty;
|
|
3755
3683
|
this.mainBlockSpan = mainBlockSpan;
|
|
3684
|
+
this.i18n = i18n2;
|
|
3756
3685
|
}
|
|
3757
3686
|
visit(visitor) {
|
|
3758
3687
|
return visitor.visitForLoopBlock(this);
|
|
3759
3688
|
}
|
|
3760
3689
|
};
|
|
3761
3690
|
var ForLoopBlockEmpty = class extends BlockNode {
|
|
3762
|
-
constructor(children, sourceSpan, startSourceSpan, endSourceSpan, nameSpan) {
|
|
3691
|
+
constructor(children, sourceSpan, startSourceSpan, endSourceSpan, nameSpan, i18n2) {
|
|
3763
3692
|
super(nameSpan, sourceSpan, startSourceSpan, endSourceSpan);
|
|
3764
3693
|
this.children = children;
|
|
3694
|
+
this.i18n = i18n2;
|
|
3765
3695
|
}
|
|
3766
3696
|
visit(visitor) {
|
|
3767
3697
|
return visitor.visitForLoopBlockEmpty(this);
|
|
@@ -3777,11 +3707,12 @@ var IfBlock = class extends BlockNode {
|
|
|
3777
3707
|
}
|
|
3778
3708
|
};
|
|
3779
3709
|
var IfBlockBranch = class extends BlockNode {
|
|
3780
|
-
constructor(expression, children, expressionAlias, sourceSpan, startSourceSpan, endSourceSpan, nameSpan) {
|
|
3710
|
+
constructor(expression, children, expressionAlias, sourceSpan, startSourceSpan, endSourceSpan, nameSpan, i18n2) {
|
|
3781
3711
|
super(nameSpan, sourceSpan, startSourceSpan, endSourceSpan);
|
|
3782
3712
|
this.expression = expression;
|
|
3783
3713
|
this.children = children;
|
|
3784
3714
|
this.expressionAlias = expressionAlias;
|
|
3715
|
+
this.i18n = i18n2;
|
|
3785
3716
|
}
|
|
3786
3717
|
visit(visitor) {
|
|
3787
3718
|
return visitor.visitIfBlockBranch(this);
|
|
@@ -3924,10 +3855,10 @@ var Container = class {
|
|
|
3924
3855
|
}
|
|
3925
3856
|
};
|
|
3926
3857
|
var Icu2 = class {
|
|
3927
|
-
constructor(expression, type,
|
|
3858
|
+
constructor(expression, type, cases2, sourceSpan, expressionPlaceholder) {
|
|
3928
3859
|
this.expression = expression;
|
|
3929
3860
|
this.type = type;
|
|
3930
|
-
this.cases =
|
|
3861
|
+
this.cases = cases2;
|
|
3931
3862
|
this.sourceSpan = sourceSpan;
|
|
3932
3863
|
this.expressionPlaceholder = expressionPlaceholder;
|
|
3933
3864
|
}
|
|
@@ -3971,6 +3902,43 @@ var IcuPlaceholder = class {
|
|
|
3971
3902
|
return visitor.visitIcuPlaceholder(this, context);
|
|
3972
3903
|
}
|
|
3973
3904
|
};
|
|
3905
|
+
var BlockPlaceholder = class {
|
|
3906
|
+
constructor(name, parameters, startName, closeName, children, sourceSpan, startSourceSpan, endSourceSpan) {
|
|
3907
|
+
this.name = name;
|
|
3908
|
+
this.parameters = parameters;
|
|
3909
|
+
this.startName = startName;
|
|
3910
|
+
this.closeName = closeName;
|
|
3911
|
+
this.children = children;
|
|
3912
|
+
this.sourceSpan = sourceSpan;
|
|
3913
|
+
this.startSourceSpan = startSourceSpan;
|
|
3914
|
+
this.endSourceSpan = endSourceSpan;
|
|
3915
|
+
}
|
|
3916
|
+
visit(visitor, context) {
|
|
3917
|
+
return visitor.visitBlockPlaceholder(this, context);
|
|
3918
|
+
}
|
|
3919
|
+
};
|
|
3920
|
+
var RecurseVisitor = class {
|
|
3921
|
+
visitText(text2, context) {
|
|
3922
|
+
}
|
|
3923
|
+
visitContainer(container, context) {
|
|
3924
|
+
container.children.forEach((child) => child.visit(this));
|
|
3925
|
+
}
|
|
3926
|
+
visitIcu(icu, context) {
|
|
3927
|
+
Object.keys(icu.cases).forEach((k) => {
|
|
3928
|
+
icu.cases[k].visit(this);
|
|
3929
|
+
});
|
|
3930
|
+
}
|
|
3931
|
+
visitTagPlaceholder(ph, context) {
|
|
3932
|
+
ph.children.forEach((child) => child.visit(this));
|
|
3933
|
+
}
|
|
3934
|
+
visitPlaceholder(ph, context) {
|
|
3935
|
+
}
|
|
3936
|
+
visitIcuPlaceholder(ph, context) {
|
|
3937
|
+
}
|
|
3938
|
+
visitBlockPlaceholder(ph, context) {
|
|
3939
|
+
ph.children.forEach((child) => child.visit(this));
|
|
3940
|
+
}
|
|
3941
|
+
};
|
|
3974
3942
|
function serializeMessage(messageNodes) {
|
|
3975
3943
|
const visitor = new LocalizeMessageStringVisitor();
|
|
3976
3944
|
const str = messageNodes.map((n) => n.visit(visitor)).join("");
|
|
@@ -3997,6 +3965,10 @@ var LocalizeMessageStringVisitor = class {
|
|
|
3997
3965
|
visitIcuPlaceholder(ph) {
|
|
3998
3966
|
return `{$${ph.name}}`;
|
|
3999
3967
|
}
|
|
3968
|
+
visitBlockPlaceholder(ph) {
|
|
3969
|
+
const children = ph.children.map((child) => child.visit(this)).join("");
|
|
3970
|
+
return `{$${ph.startName}}${children}{$${ph.closeName}}`;
|
|
3971
|
+
}
|
|
4000
3972
|
};
|
|
4001
3973
|
|
|
4002
3974
|
// bazel-out/k8-fastbuild/bin/packages/compiler/src/i18n/serializers/xml_helper.mjs
|
|
@@ -4464,7 +4436,7 @@ function assertInterpolationSymbols(identifier, value) {
|
|
|
4464
4436
|
}
|
|
4465
4437
|
}
|
|
4466
4438
|
|
|
4467
|
-
// bazel-out/k8-fastbuild/bin/packages/compiler/src/ml_parser/
|
|
4439
|
+
// bazel-out/k8-fastbuild/bin/packages/compiler/src/ml_parser/defaults.mjs
|
|
4468
4440
|
var InterpolationConfig = class {
|
|
4469
4441
|
static fromArray(markers) {
|
|
4470
4442
|
if (!markers) {
|
|
@@ -4479,6 +4451,7 @@ var InterpolationConfig = class {
|
|
|
4479
4451
|
}
|
|
4480
4452
|
};
|
|
4481
4453
|
var DEFAULT_INTERPOLATION_CONFIG = new InterpolationConfig("{{", "}}");
|
|
4454
|
+
var DEFAULT_CONTAINER_BLOCKS = /* @__PURE__ */ new Set(["switch"]);
|
|
4482
4455
|
|
|
4483
4456
|
// bazel-out/k8-fastbuild/bin/packages/compiler/src/chars.mjs
|
|
4484
4457
|
var $EOF = 0;
|
|
@@ -7014,8 +6987,8 @@ var OpKind;
|
|
|
7014
6987
|
OpKind2[OpKind2["I18nEnd"] = 38] = "I18nEnd";
|
|
7015
6988
|
OpKind2[OpKind2["I18nExpression"] = 39] = "I18nExpression";
|
|
7016
6989
|
OpKind2[OpKind2["I18nApply"] = 40] = "I18nApply";
|
|
7017
|
-
OpKind2[OpKind2["
|
|
7018
|
-
OpKind2[OpKind2["
|
|
6990
|
+
OpKind2[OpKind2["IcuStart"] = 41] = "IcuStart";
|
|
6991
|
+
OpKind2[OpKind2["IcuEnd"] = 42] = "IcuEnd";
|
|
7019
6992
|
OpKind2[OpKind2["I18nContext"] = 43] = "I18nContext";
|
|
7020
6993
|
})(OpKind || (OpKind = {}));
|
|
7021
6994
|
var ExpressionKind;
|
|
@@ -7100,6 +7073,7 @@ var I18nParamValueFlags;
|
|
|
7100
7073
|
I18nParamValueFlags2[I18nParamValueFlags2["TemplateTag"] = 2] = "TemplateTag";
|
|
7101
7074
|
I18nParamValueFlags2[I18nParamValueFlags2["OpenTag"] = 4] = "OpenTag";
|
|
7102
7075
|
I18nParamValueFlags2[I18nParamValueFlags2["CloseTag"] = 8] = "CloseTag";
|
|
7076
|
+
I18nParamValueFlags2[I18nParamValueFlags2["ExpressionIndex"] = 16] = "ExpressionIndex";
|
|
7103
7077
|
})(I18nParamValueFlags || (I18nParamValueFlags = {}));
|
|
7104
7078
|
var Namespace;
|
|
7105
7079
|
(function(Namespace2) {
|
|
@@ -7289,13 +7263,13 @@ function createConditionalOp(target, targetSlot, test, conditions, sourceSpan) {
|
|
|
7289
7263
|
}, NEW_OP), TRAIT_DEPENDS_ON_SLOT_CONTEXT), TRAIT_CONSUMES_VARS);
|
|
7290
7264
|
}
|
|
7291
7265
|
function createRepeaterOp(repeaterCreate2, targetSlot, collection, sourceSpan) {
|
|
7292
|
-
return __spreadValues({
|
|
7266
|
+
return __spreadValues(__spreadValues({
|
|
7293
7267
|
kind: OpKind.Repeater,
|
|
7294
7268
|
target: repeaterCreate2,
|
|
7295
7269
|
targetSlot,
|
|
7296
7270
|
collection,
|
|
7297
7271
|
sourceSpan
|
|
7298
|
-
}, NEW_OP);
|
|
7272
|
+
}, NEW_OP), TRAIT_DEPENDS_ON_SLOT_CONTEXT);
|
|
7299
7273
|
}
|
|
7300
7274
|
function createDeferWhenOp(target, expr, prefetch, sourceSpan) {
|
|
7301
7275
|
return __spreadValues(__spreadValues({
|
|
@@ -7326,13 +7300,6 @@ function createI18nApplyOp(target, handle, sourceSpan) {
|
|
|
7326
7300
|
sourceSpan
|
|
7327
7301
|
}, NEW_OP);
|
|
7328
7302
|
}
|
|
7329
|
-
function createIcuUpdateOp(xref, sourceSpan) {
|
|
7330
|
-
return __spreadValues({
|
|
7331
|
-
kind: OpKind.IcuUpdate,
|
|
7332
|
-
xref,
|
|
7333
|
-
sourceSpan
|
|
7334
|
-
}, NEW_OP);
|
|
7335
|
-
}
|
|
7336
7303
|
|
|
7337
7304
|
// bazel-out/k8-fastbuild/bin/packages/compiler/src/template/pipeline/ir/src/expression.mjs
|
|
7338
7305
|
var _a;
|
|
@@ -8096,8 +8063,8 @@ function transformExpressionsInOp(op, transform2, flags) {
|
|
|
8096
8063
|
case OpKind.I18nContext:
|
|
8097
8064
|
case OpKind.I18nEnd:
|
|
8098
8065
|
case OpKind.I18nStart:
|
|
8099
|
-
case OpKind.
|
|
8100
|
-
case OpKind.
|
|
8066
|
+
case OpKind.IcuEnd:
|
|
8067
|
+
case OpKind.IcuStart:
|
|
8101
8068
|
case OpKind.Namespace:
|
|
8102
8069
|
case OpKind.Pipe:
|
|
8103
8070
|
case OpKind.Projection:
|
|
@@ -8599,17 +8566,22 @@ function createI18nEndOp(xref) {
|
|
|
8599
8566
|
xref
|
|
8600
8567
|
}, NEW_OP);
|
|
8601
8568
|
}
|
|
8602
|
-
function
|
|
8569
|
+
function createIcuStartOp(xref, message, messagePlaceholder, sourceSpan) {
|
|
8603
8570
|
return __spreadValues({
|
|
8604
|
-
kind: OpKind.
|
|
8571
|
+
kind: OpKind.IcuStart,
|
|
8605
8572
|
xref,
|
|
8606
8573
|
message,
|
|
8607
|
-
icu,
|
|
8608
8574
|
messagePlaceholder,
|
|
8609
8575
|
context: null,
|
|
8610
8576
|
sourceSpan
|
|
8611
8577
|
}, NEW_OP);
|
|
8612
8578
|
}
|
|
8579
|
+
function createIcuEndOp(xref) {
|
|
8580
|
+
return __spreadValues({
|
|
8581
|
+
kind: OpKind.IcuEnd,
|
|
8582
|
+
xref
|
|
8583
|
+
}, NEW_OP);
|
|
8584
|
+
}
|
|
8613
8585
|
function createI18nContextOp(xref, i18nBlock, message, sourceSpan) {
|
|
8614
8586
|
return __spreadValues({
|
|
8615
8587
|
kind: OpKind.I18nContext,
|
|
@@ -8763,20 +8735,30 @@ function removeAnys(e) {
|
|
|
8763
8735
|
|
|
8764
8736
|
// bazel-out/k8-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/apply_i18n_expressions.mjs
|
|
8765
8737
|
function applyI18nExpressions(job) {
|
|
8738
|
+
const i18nContexts = /* @__PURE__ */ new Map();
|
|
8739
|
+
for (const unit of job.units) {
|
|
8740
|
+
for (const op of unit.create) {
|
|
8741
|
+
if (op.kind === OpKind.I18nContext) {
|
|
8742
|
+
i18nContexts.set(op.xref, op);
|
|
8743
|
+
}
|
|
8744
|
+
}
|
|
8745
|
+
}
|
|
8766
8746
|
for (const unit of job.units) {
|
|
8767
8747
|
for (const op of unit.update) {
|
|
8768
|
-
if (op.kind === OpKind.I18nExpression && needsApplication(op)) {
|
|
8748
|
+
if (op.kind === OpKind.I18nExpression && needsApplication(i18nContexts, op)) {
|
|
8769
8749
|
OpList.insertAfter(createI18nApplyOp(op.target, op.handle, null), op);
|
|
8770
8750
|
}
|
|
8771
8751
|
}
|
|
8772
8752
|
}
|
|
8773
8753
|
}
|
|
8774
|
-
function needsApplication(op) {
|
|
8754
|
+
function needsApplication(i18nContexts, op) {
|
|
8775
8755
|
var _a2;
|
|
8776
8756
|
if (((_a2 = op.next) == null ? void 0 : _a2.kind) !== OpKind.I18nExpression) {
|
|
8777
8757
|
return true;
|
|
8778
8758
|
}
|
|
8779
|
-
|
|
8759
|
+
const context = i18nContexts.get(op.context);
|
|
8760
|
+
const nextContext2 = i18nContexts.get(op.next.context);
|
|
8761
|
+
if (context.i18nBlock !== nextContext2.i18nBlock) {
|
|
8780
8762
|
return true;
|
|
8781
8763
|
}
|
|
8782
8764
|
return false;
|
|
@@ -9320,7 +9302,7 @@ function createI18nContexts(job) {
|
|
|
9320
9302
|
case OpKind.I18nEnd:
|
|
9321
9303
|
currentI18nOp = null;
|
|
9322
9304
|
break;
|
|
9323
|
-
case OpKind.
|
|
9305
|
+
case OpKind.IcuStart:
|
|
9324
9306
|
if (currentI18nOp === null) {
|
|
9325
9307
|
throw Error("Unexpected ICU outside of an i18n block.");
|
|
9326
9308
|
}
|
|
@@ -9337,52 +9319,6 @@ function createI18nContexts(job) {
|
|
|
9337
9319
|
}
|
|
9338
9320
|
}
|
|
9339
9321
|
|
|
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
9322
|
// bazel-out/k8-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/defer_configs.mjs
|
|
9387
9323
|
function configureDeferInstructions(job) {
|
|
9388
9324
|
for (const unit of job.units) {
|
|
@@ -9696,18 +9632,23 @@ function extractI18nMessages(job) {
|
|
|
9696
9632
|
}
|
|
9697
9633
|
for (const unit of job.units) {
|
|
9698
9634
|
for (const op of unit.create) {
|
|
9699
|
-
|
|
9700
|
-
|
|
9701
|
-
|
|
9702
|
-
|
|
9703
|
-
|
|
9704
|
-
|
|
9705
|
-
|
|
9706
|
-
|
|
9707
|
-
|
|
9708
|
-
|
|
9709
|
-
|
|
9710
|
-
|
|
9635
|
+
switch (op.kind) {
|
|
9636
|
+
case OpKind.IcuStart:
|
|
9637
|
+
if (!op.context) {
|
|
9638
|
+
throw Error("ICU op should have its context set.");
|
|
9639
|
+
}
|
|
9640
|
+
if (!i18nBlockContexts.has(op.context)) {
|
|
9641
|
+
const i18nContext = i18nContexts.get(op.context);
|
|
9642
|
+
const subMessage = createI18nMessage(job, i18nContext, op.messagePlaceholder);
|
|
9643
|
+
unit.create.push(subMessage);
|
|
9644
|
+
const parentMessage = i18nBlockMessages.get(i18nContext.i18nBlock);
|
|
9645
|
+
parentMessage == null ? void 0 : parentMessage.subMessages.push(subMessage.xref);
|
|
9646
|
+
}
|
|
9647
|
+
OpList.remove(op);
|
|
9648
|
+
break;
|
|
9649
|
+
case OpKind.IcuEnd:
|
|
9650
|
+
OpList.remove(op);
|
|
9651
|
+
break;
|
|
9711
9652
|
}
|
|
9712
9653
|
}
|
|
9713
9654
|
}
|
|
@@ -9723,7 +9664,7 @@ function createI18nMessage(job, context, messagePlaceholder) {
|
|
|
9723
9664
|
}
|
|
9724
9665
|
function formatParams(params) {
|
|
9725
9666
|
const result = /* @__PURE__ */ new Map();
|
|
9726
|
-
for (const [placeholder, placeholderValues] of
|
|
9667
|
+
for (const [placeholder, placeholderValues] of params) {
|
|
9727
9668
|
const serializedValues = formatParamValues(placeholderValues);
|
|
9728
9669
|
if (serializedValues !== null) {
|
|
9729
9670
|
result.set(placeholder, literal(formatParamValues(placeholderValues)));
|
|
@@ -9739,6 +9680,9 @@ function formatParamValues(values) {
|
|
|
9739
9680
|
return serializedValues.length === 1 ? serializedValues[0] : `${LIST_START_MARKER}${serializedValues.join(LIST_DELIMITER)}${LIST_END_MARKER}`;
|
|
9740
9681
|
}
|
|
9741
9682
|
function formatValue(value) {
|
|
9683
|
+
if (value.flags === I18nParamValueFlags.None) {
|
|
9684
|
+
return `${value.value}`;
|
|
9685
|
+
}
|
|
9742
9686
|
let tagMarker = "";
|
|
9743
9687
|
let closeMarker = "";
|
|
9744
9688
|
if (value.flags & I18nParamValueFlags.ElementTag) {
|
|
@@ -10000,6 +9944,9 @@ var IcuSerializerVisitor = class {
|
|
|
10000
9944
|
visitPlaceholder(ph) {
|
|
10001
9945
|
return this.formatPh(ph.name);
|
|
10002
9946
|
}
|
|
9947
|
+
visitBlockPlaceholder(ph) {
|
|
9948
|
+
return `${this.formatPh(ph.startName)}${ph.children.map((child) => child.visit(this)).join("")}${this.formatPh(ph.closeName)}`;
|
|
9949
|
+
}
|
|
10003
9950
|
visitIcuPlaceholder(ph, context) {
|
|
10004
9951
|
return this.formatPh(ph.name);
|
|
10005
9952
|
}
|
|
@@ -11285,11 +11232,11 @@ var Text4 = class extends NodeWithI18n {
|
|
|
11285
11232
|
}
|
|
11286
11233
|
};
|
|
11287
11234
|
var Expansion = class extends NodeWithI18n {
|
|
11288
|
-
constructor(switchValue, type,
|
|
11235
|
+
constructor(switchValue, type, cases2, sourceSpan, switchValueSourceSpan, i18n2) {
|
|
11289
11236
|
super(sourceSpan, i18n2);
|
|
11290
11237
|
this.switchValue = switchValue;
|
|
11291
11238
|
this.type = type;
|
|
11292
|
-
this.cases =
|
|
11239
|
+
this.cases = cases2;
|
|
11293
11240
|
this.switchValueSourceSpan = switchValueSourceSpan;
|
|
11294
11241
|
}
|
|
11295
11242
|
visit(visitor, context) {
|
|
@@ -11343,12 +11290,12 @@ var Comment2 = class {
|
|
|
11343
11290
|
return visitor.visitComment(this, context);
|
|
11344
11291
|
}
|
|
11345
11292
|
};
|
|
11346
|
-
var Block = class {
|
|
11347
|
-
constructor(name, parameters, children, sourceSpan, nameSpan, startSourceSpan, endSourceSpan = null) {
|
|
11293
|
+
var Block = class extends NodeWithI18n {
|
|
11294
|
+
constructor(name, parameters, children, sourceSpan, nameSpan, startSourceSpan, endSourceSpan = null, i18n2) {
|
|
11295
|
+
super(sourceSpan, i18n2);
|
|
11348
11296
|
this.name = name;
|
|
11349
11297
|
this.parameters = parameters;
|
|
11350
11298
|
this.children = children;
|
|
11351
|
-
this.sourceSpan = sourceSpan;
|
|
11352
11299
|
this.nameSpan = nameSpan;
|
|
11353
11300
|
this.startSourceSpan = startSourceSpan;
|
|
11354
11301
|
this.endSourceSpan = endSourceSpan;
|
|
@@ -11967,6 +11914,24 @@ var PlaceholderRegistry = class {
|
|
|
11967
11914
|
getUniquePlaceholder(name) {
|
|
11968
11915
|
return this._generateUniqueName(name.toUpperCase());
|
|
11969
11916
|
}
|
|
11917
|
+
getStartBlockPlaceholderName(name, parameters) {
|
|
11918
|
+
const signature = this._hashBlock(name, parameters);
|
|
11919
|
+
if (this._signatureToName[signature]) {
|
|
11920
|
+
return this._signatureToName[signature];
|
|
11921
|
+
}
|
|
11922
|
+
const placeholder = this._generateUniqueName(`START_BLOCK_${this._toSnakeCase(name)}`);
|
|
11923
|
+
this._signatureToName[signature] = placeholder;
|
|
11924
|
+
return placeholder;
|
|
11925
|
+
}
|
|
11926
|
+
getCloseBlockPlaceholderName(name) {
|
|
11927
|
+
const signature = this._hashClosingBlock(name);
|
|
11928
|
+
if (this._signatureToName[signature]) {
|
|
11929
|
+
return this._signatureToName[signature];
|
|
11930
|
+
}
|
|
11931
|
+
const placeholder = this._generateUniqueName(`CLOSE_BLOCK_${this._toSnakeCase(name)}`);
|
|
11932
|
+
this._signatureToName[signature] = placeholder;
|
|
11933
|
+
return placeholder;
|
|
11934
|
+
}
|
|
11970
11935
|
_hashTag(tag, attrs, isVoid) {
|
|
11971
11936
|
const start = `<${tag}`;
|
|
11972
11937
|
const strAttrs = Object.keys(attrs).sort().map((name) => ` ${name}=${attrs[name]}`).join("");
|
|
@@ -11976,6 +11941,16 @@ var PlaceholderRegistry = class {
|
|
|
11976
11941
|
_hashClosingTag(tag) {
|
|
11977
11942
|
return this._hashTag(`/${tag}`, {}, false);
|
|
11978
11943
|
}
|
|
11944
|
+
_hashBlock(name, parameters) {
|
|
11945
|
+
const params = parameters.length === 0 ? "" : ` (${parameters.sort().join("; ")})`;
|
|
11946
|
+
return `@${name}${params} {}`;
|
|
11947
|
+
}
|
|
11948
|
+
_hashClosingBlock(name) {
|
|
11949
|
+
return this._hashBlock(`close_${name}`, []);
|
|
11950
|
+
}
|
|
11951
|
+
_toSnakeCase(name) {
|
|
11952
|
+
return name.toUpperCase().replace(/[^A-Z0-9]/g, "_");
|
|
11953
|
+
}
|
|
11979
11954
|
_generateUniqueName(base) {
|
|
11980
11955
|
const seen = this._placeHolderNameCounts.hasOwnProperty(base);
|
|
11981
11956
|
if (!seen) {
|
|
@@ -11990,17 +11965,18 @@ var PlaceholderRegistry = class {
|
|
|
11990
11965
|
|
|
11991
11966
|
// bazel-out/k8-fastbuild/bin/packages/compiler/src/i18n/i18n_parser.mjs
|
|
11992
11967
|
var _expParser = new Parser(new Lexer());
|
|
11993
|
-
function createI18nMessageFactory(interpolationConfig) {
|
|
11994
|
-
const visitor = new _I18nVisitor(_expParser, interpolationConfig);
|
|
11968
|
+
function createI18nMessageFactory(interpolationConfig, containerBlocks) {
|
|
11969
|
+
const visitor = new _I18nVisitor(_expParser, interpolationConfig, containerBlocks);
|
|
11995
11970
|
return (nodes, meaning, description, customId, visitNodeFn) => visitor.toI18nMessage(nodes, meaning, description, customId, visitNodeFn);
|
|
11996
11971
|
}
|
|
11997
11972
|
function noopVisitNodeFn(_html, i18n2) {
|
|
11998
11973
|
return i18n2;
|
|
11999
11974
|
}
|
|
12000
11975
|
var _I18nVisitor = class {
|
|
12001
|
-
constructor(_expressionParser, _interpolationConfig) {
|
|
11976
|
+
constructor(_expressionParser, _interpolationConfig, _containerBlocks) {
|
|
12002
11977
|
this._expressionParser = _expressionParser;
|
|
12003
11978
|
this._interpolationConfig = _interpolationConfig;
|
|
11979
|
+
this._containerBlocks = _containerBlocks;
|
|
12004
11980
|
}
|
|
12005
11981
|
toI18nMessage(nodes, meaning = "", description = "", customId = "", visitNodeFn) {
|
|
12006
11982
|
const context = {
|
|
@@ -12075,11 +12051,27 @@ var _I18nVisitor = class {
|
|
|
12075
12051
|
throw new Error("Unreachable code");
|
|
12076
12052
|
}
|
|
12077
12053
|
visitBlock(block, context) {
|
|
12054
|
+
var _a2;
|
|
12078
12055
|
const children = visitAll2(this, block.children, context);
|
|
12079
|
-
|
|
12056
|
+
if (this._containerBlocks.has(block.name)) {
|
|
12057
|
+
return new Container(children, block.sourceSpan);
|
|
12058
|
+
}
|
|
12059
|
+
const parameters = block.parameters.map((param) => param.expression);
|
|
12060
|
+
const startPhName = context.placeholderRegistry.getStartBlockPlaceholderName(block.name, parameters);
|
|
12061
|
+
const closePhName = context.placeholderRegistry.getCloseBlockPlaceholderName(block.name);
|
|
12062
|
+
context.placeholderToContent[startPhName] = {
|
|
12063
|
+
text: block.startSourceSpan.toString(),
|
|
12064
|
+
sourceSpan: block.startSourceSpan
|
|
12065
|
+
};
|
|
12066
|
+
context.placeholderToContent[closePhName] = {
|
|
12067
|
+
text: block.endSourceSpan ? block.endSourceSpan.toString() : "}",
|
|
12068
|
+
sourceSpan: (_a2 = block.endSourceSpan) != null ? _a2 : block.sourceSpan
|
|
12069
|
+
};
|
|
12070
|
+
const node = new BlockPlaceholder(block.name, parameters, startPhName, closePhName, children, block.sourceSpan, block.startSourceSpan, block.endSourceSpan);
|
|
12080
12071
|
return context.visitNodeFn(block, node);
|
|
12081
12072
|
}
|
|
12082
12073
|
visitBlockParameter(_parameter, _context) {
|
|
12074
|
+
throw new Error("Unreachable code");
|
|
12083
12075
|
}
|
|
12084
12076
|
_visitTextWithInterpolation(tokens, sourceSpan, context, previousI18n) {
|
|
12085
12077
|
const nodes = [];
|
|
@@ -15310,19 +15302,19 @@ var _TreeBuilder = class {
|
|
|
15310
15302
|
_consumeExpansion(token) {
|
|
15311
15303
|
const switchValue = this._advance();
|
|
15312
15304
|
const type = this._advance();
|
|
15313
|
-
const
|
|
15305
|
+
const cases2 = [];
|
|
15314
15306
|
while (this._peek.type === 20) {
|
|
15315
15307
|
const expCase = this._parseExpansionCase();
|
|
15316
15308
|
if (!expCase)
|
|
15317
15309
|
return;
|
|
15318
|
-
|
|
15310
|
+
cases2.push(expCase);
|
|
15319
15311
|
}
|
|
15320
15312
|
if (this._peek.type !== 23) {
|
|
15321
15313
|
this.errors.push(TreeError.create(null, this._peek.sourceSpan, `Invalid ICU message. Missing '}'.`));
|
|
15322
15314
|
return;
|
|
15323
15315
|
}
|
|
15324
15316
|
const sourceSpan = new ParseSourceSpan(token.sourceSpan.start, this._peek.sourceSpan.end, token.sourceSpan.fullStart);
|
|
15325
|
-
this._addToParent(new Expansion(switchValue.parts[0], type.parts[0],
|
|
15317
|
+
this._addToParent(new Expansion(switchValue.parts[0], type.parts[0], cases2, sourceSpan, switchValue.sourceSpan));
|
|
15326
15318
|
this._advance();
|
|
15327
15319
|
}
|
|
15328
15320
|
_parseExpansionCase() {
|
|
@@ -15619,16 +15611,17 @@ var setI18nRefs = (htmlNode, i18nNode) => {
|
|
|
15619
15611
|
return i18nNode;
|
|
15620
15612
|
};
|
|
15621
15613
|
var I18nMetaVisitor = class {
|
|
15622
|
-
constructor(interpolationConfig = DEFAULT_INTERPOLATION_CONFIG, keepI18nAttrs = false, enableI18nLegacyMessageIdFormat = false) {
|
|
15614
|
+
constructor(interpolationConfig = DEFAULT_INTERPOLATION_CONFIG, keepI18nAttrs = false, enableI18nLegacyMessageIdFormat = false, containerBlocks = DEFAULT_CONTAINER_BLOCKS) {
|
|
15623
15615
|
this.interpolationConfig = interpolationConfig;
|
|
15624
15616
|
this.keepI18nAttrs = keepI18nAttrs;
|
|
15625
15617
|
this.enableI18nLegacyMessageIdFormat = enableI18nLegacyMessageIdFormat;
|
|
15618
|
+
this.containerBlocks = containerBlocks;
|
|
15626
15619
|
this.hasI18nMeta = false;
|
|
15627
15620
|
this._errors = [];
|
|
15628
15621
|
}
|
|
15629
15622
|
_generateI18nMessage(nodes, meta = "", visitNodeFn) {
|
|
15630
15623
|
const { meaning, description, customId } = this._parseMetadata(meta);
|
|
15631
|
-
const createI18nMessage2 = createI18nMessageFactory(this.interpolationConfig);
|
|
15624
|
+
const createI18nMessage2 = createI18nMessageFactory(this.interpolationConfig, this.containerBlocks);
|
|
15632
15625
|
const message = createI18nMessage2(nodes, meaning, description, customId, visitNodeFn);
|
|
15633
15626
|
this._setMessageId(message, meta);
|
|
15634
15627
|
this._setLegacyIds(message, meta);
|
|
@@ -15803,6 +15796,9 @@ var GetMsgSerializerVisitor = class {
|
|
|
15803
15796
|
visitPlaceholder(ph) {
|
|
15804
15797
|
return this.formatPh(ph.name);
|
|
15805
15798
|
}
|
|
15799
|
+
visitBlockPlaceholder(ph) {
|
|
15800
|
+
return `${this.formatPh(ph.startName)}${ph.children.map((child) => child.visit(this)).join("")}${this.formatPh(ph.closeName)}`;
|
|
15801
|
+
}
|
|
15806
15802
|
visitIcuPlaceholder(ph, context) {
|
|
15807
15803
|
return this.formatPh(ph.name);
|
|
15808
15804
|
}
|
|
@@ -15851,6 +15847,12 @@ var LocalizeSerializerVisitor = class {
|
|
|
15851
15847
|
visitPlaceholder(ph) {
|
|
15852
15848
|
this.pieces.push(this.createPlaceholderPiece(ph.name, ph.sourceSpan));
|
|
15853
15849
|
}
|
|
15850
|
+
visitBlockPlaceholder(ph) {
|
|
15851
|
+
var _a2, _b2;
|
|
15852
|
+
this.pieces.push(this.createPlaceholderPiece(ph.startName, (_a2 = ph.startSourceSpan) != null ? _a2 : ph.sourceSpan));
|
|
15853
|
+
ph.children.forEach((child) => child.visit(this));
|
|
15854
|
+
this.pieces.push(this.createPlaceholderPiece(ph.closeName, (_b2 = ph.endSourceSpan) != null ? _b2 : ph.sourceSpan));
|
|
15855
|
+
}
|
|
15854
15856
|
visitIcuPlaceholder(ph) {
|
|
15855
15857
|
this.pieces.push(this.createPlaceholderPiece(ph.name, ph.sourceSpan, this.placeholderToMessage[ph.name]));
|
|
15856
15858
|
}
|
|
@@ -15932,11 +15934,13 @@ function collectMessage(job, fileBasedI18nSuffix, messages, messageOp) {
|
|
|
15932
15934
|
statements.push(...subMessageStatements);
|
|
15933
15935
|
messageOp.params.set(subMessage.messagePlaceholder, subMessageVar);
|
|
15934
15936
|
}
|
|
15937
|
+
messageOp.params = new Map([...messageOp.params.entries()].sort());
|
|
15935
15938
|
assertAllParamsResolved(messageOp);
|
|
15936
15939
|
const mainVar = variable(job.pool.uniqueName(TRANSLATION_VAR_PREFIX2));
|
|
15937
15940
|
const closureVar = i18nGenerateClosureVar(job.pool, messageOp.message.id, fileBasedI18nSuffix, job.i18nUseExternalIds);
|
|
15938
15941
|
let transformFn = void 0;
|
|
15939
15942
|
if (messageOp.needsPostprocessing) {
|
|
15943
|
+
messageOp.postprocessingParams = new Map([...messageOp.postprocessingParams.entries()].sort());
|
|
15940
15944
|
const extraTransformFnParams = [];
|
|
15941
15945
|
if (messageOp.postprocessingParams.size > 0) {
|
|
15942
15946
|
extraTransformFnParams.push(literalMap([...messageOp.postprocessingParams].map(([key, value]) => ({ key, value, quoted: true }))));
|
|
@@ -15974,12 +15978,14 @@ function i18nGenerateClosureVar(pool, messageId, fileBasedI18nSuffix, useExterna
|
|
|
15974
15978
|
return variable(name);
|
|
15975
15979
|
}
|
|
15976
15980
|
function assertAllParamsResolved(op) {
|
|
15977
|
-
for (
|
|
15981
|
+
for (let placeholder in op.message.placeholders) {
|
|
15982
|
+
placeholder = placeholder.trimEnd();
|
|
15978
15983
|
if (!op.params.has(placeholder) && !op.postprocessingParams.has(placeholder)) {
|
|
15979
15984
|
throw Error(`Failed to resolve i18n placeholder: ${placeholder}`);
|
|
15980
15985
|
}
|
|
15981
15986
|
}
|
|
15982
|
-
for (
|
|
15987
|
+
for (let placeholder in op.message.placeholderToMessage) {
|
|
15988
|
+
placeholder = placeholder.trimEnd();
|
|
15983
15989
|
if (!op.params.has(placeholder) && !op.postprocessingParams.has(placeholder)) {
|
|
15984
15990
|
throw Error(`Failed to resolve i18n message placeholder: ${placeholder}`);
|
|
15985
15991
|
}
|
|
@@ -15991,7 +15997,9 @@ function extractI18nText(job) {
|
|
|
15991
15997
|
var _a2;
|
|
15992
15998
|
for (const unit of job.units) {
|
|
15993
15999
|
let currentI18n = null;
|
|
16000
|
+
let currentIcu = null;
|
|
15994
16001
|
const textNodeI18nBlocks = /* @__PURE__ */ new Map();
|
|
16002
|
+
const textNodeIcus = /* @__PURE__ */ new Map();
|
|
15995
16003
|
for (const op of unit.create) {
|
|
15996
16004
|
switch (op.kind) {
|
|
15997
16005
|
case OpKind.I18nStart:
|
|
@@ -16003,9 +16011,19 @@ function extractI18nText(job) {
|
|
|
16003
16011
|
case OpKind.I18nEnd:
|
|
16004
16012
|
currentI18n = null;
|
|
16005
16013
|
break;
|
|
16014
|
+
case OpKind.IcuStart:
|
|
16015
|
+
if (op.context === null) {
|
|
16016
|
+
throw Error("Icu op should have its context set.");
|
|
16017
|
+
}
|
|
16018
|
+
currentIcu = op;
|
|
16019
|
+
break;
|
|
16020
|
+
case OpKind.IcuEnd:
|
|
16021
|
+
currentIcu = null;
|
|
16022
|
+
break;
|
|
16006
16023
|
case OpKind.Text:
|
|
16007
16024
|
if (currentI18n !== null) {
|
|
16008
16025
|
textNodeI18nBlocks.set(op.xref, currentI18n);
|
|
16026
|
+
textNodeIcus.set(op.xref, currentIcu);
|
|
16009
16027
|
OpList.remove(op);
|
|
16010
16028
|
}
|
|
16011
16029
|
break;
|
|
@@ -16018,11 +16036,13 @@ function extractI18nText(job) {
|
|
|
16018
16036
|
continue;
|
|
16019
16037
|
}
|
|
16020
16038
|
const i18nOp = textNodeI18nBlocks.get(op.target);
|
|
16039
|
+
const icuOp = textNodeIcus.get(op.target);
|
|
16040
|
+
const contextId = icuOp ? icuOp.context : i18nOp.context;
|
|
16041
|
+
const resolutionTime = icuOp ? I18nParamResolutionTime.Postproccessing : I18nParamResolutionTime.Creation;
|
|
16021
16042
|
const ops = [];
|
|
16022
16043
|
for (let i = 0; i < op.interpolation.expressions.length; i++) {
|
|
16023
16044
|
const expr = op.interpolation.expressions[i];
|
|
16024
|
-
|
|
16025
|
-
ops.push(createI18nExpressionOp(i18nOp.context, i18nOp.xref, i18nOp.handle, expr, placeholder.name, I18nParamResolutionTime.Creation, (_a2 = expr.sourceSpan) != null ? _a2 : op.sourceSpan));
|
|
16045
|
+
ops.push(createI18nExpressionOp(contextId, i18nOp.xref, i18nOp.handle, expr, op.i18nPlaceholders[i], resolutionTime, (_a2 = expr.sourceSpan) != null ? _a2 : op.sourceSpan));
|
|
16026
16046
|
}
|
|
16027
16047
|
OpList.replaceWithMany(op, ops);
|
|
16028
16048
|
break;
|
|
@@ -16914,8 +16934,8 @@ function repeaterCreate(slot, viewFnName, decls, vars, tag, constIndex, trackByF
|
|
|
16914
16934
|
}
|
|
16915
16935
|
return call(Identifiers.repeaterCreate, args, sourceSpan);
|
|
16916
16936
|
}
|
|
16917
|
-
function repeater(
|
|
16918
|
-
return call(Identifiers.repeater, [
|
|
16937
|
+
function repeater(collection, sourceSpan) {
|
|
16938
|
+
return call(Identifiers.repeater, [collection], sourceSpan);
|
|
16919
16939
|
}
|
|
16920
16940
|
function deferWhen(prefetch, expr, sourceSpan) {
|
|
16921
16941
|
return call(prefetch ? Identifiers.deferPrefetchWhen : Identifiers.deferWhen, [expr], sourceSpan);
|
|
@@ -17473,7 +17493,7 @@ function reifyUpdateOperations(_unit, ops) {
|
|
|
17473
17493
|
OpList.replace(op, conditional(op.targetSlot.slot, op.processed, op.contextValue, op.sourceSpan));
|
|
17474
17494
|
break;
|
|
17475
17495
|
case OpKind.Repeater:
|
|
17476
|
-
OpList.replace(op, repeater(op.
|
|
17496
|
+
OpList.replace(op, repeater(op.collection, op.sourceSpan));
|
|
17477
17497
|
break;
|
|
17478
17498
|
case OpKind.DeferWhen:
|
|
17479
17499
|
OpList.replace(op, deferWhen(op.prefetch, op.expr, op.sourceSpan));
|
|
@@ -17762,7 +17782,7 @@ function getSubTemplateIndexForTemplateTag(job, i18nOp, op) {
|
|
|
17762
17782
|
}
|
|
17763
17783
|
return i18nOp.subTemplateIndex;
|
|
17764
17784
|
}
|
|
17765
|
-
function addParam(params, placeholder, value, subTemplateIndex, flags
|
|
17785
|
+
function addParam(params, placeholder, value, subTemplateIndex, flags) {
|
|
17766
17786
|
var _a2;
|
|
17767
17787
|
const values = (_a2 = params.get(placeholder)) != null ? _a2 : [];
|
|
17768
17788
|
values.push({ value, subTemplateIndex, flags });
|
|
@@ -17789,18 +17809,82 @@ function resolveI18nExpressionPlaceholders(job) {
|
|
|
17789
17809
|
for (const unit of job.units) {
|
|
17790
17810
|
for (const op of unit.update) {
|
|
17791
17811
|
if (op.kind === OpKind.I18nExpression) {
|
|
17792
|
-
const index = expressionIndices.get(op.context) || 0;
|
|
17793
17812
|
const i18nContext = i18nContexts.get(op.context);
|
|
17813
|
+
const index = expressionIndices.get(i18nContext.i18nBlock) || 0;
|
|
17794
17814
|
const subTemplateIndex = subTemplateIndicies.get(i18nContext.i18nBlock);
|
|
17795
17815
|
const params = op.resolutionTime === I18nParamResolutionTime.Creation ? i18nContext.params : i18nContext.postprocessingParams;
|
|
17796
17816
|
const values = params.get(op.i18nPlaceholder) || [];
|
|
17797
|
-
values.push({
|
|
17817
|
+
values.push({
|
|
17818
|
+
value: index,
|
|
17819
|
+
subTemplateIndex,
|
|
17820
|
+
flags: I18nParamValueFlags.ExpressionIndex
|
|
17821
|
+
});
|
|
17798
17822
|
params.set(op.i18nPlaceholder, values);
|
|
17799
|
-
expressionIndices.set(
|
|
17823
|
+
expressionIndices.set(i18nContext.i18nBlock, index + 1);
|
|
17824
|
+
}
|
|
17825
|
+
}
|
|
17826
|
+
}
|
|
17827
|
+
}
|
|
17828
|
+
|
|
17829
|
+
// bazel-out/k8-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/resolve_i18n_icu_placeholders.mjs
|
|
17830
|
+
function resolveI18nIcuPlaceholders(job) {
|
|
17831
|
+
const contextOps = /* @__PURE__ */ new Map();
|
|
17832
|
+
for (const unit of job.units) {
|
|
17833
|
+
for (const op of unit.create) {
|
|
17834
|
+
switch (op.kind) {
|
|
17835
|
+
case OpKind.I18nContext:
|
|
17836
|
+
contextOps.set(op.xref, op);
|
|
17837
|
+
break;
|
|
17838
|
+
}
|
|
17839
|
+
}
|
|
17840
|
+
}
|
|
17841
|
+
for (const unit of job.units) {
|
|
17842
|
+
for (const op of unit.create) {
|
|
17843
|
+
switch (op.kind) {
|
|
17844
|
+
case OpKind.IcuStart:
|
|
17845
|
+
if (op.context === null) {
|
|
17846
|
+
throw Error("Icu should have its i18n context set.");
|
|
17847
|
+
}
|
|
17848
|
+
const i18nContext = contextOps.get(op.context);
|
|
17849
|
+
for (const node of op.message.nodes) {
|
|
17850
|
+
node.visit(new ResolveIcuPlaceholdersVisitor(i18nContext.postprocessingParams));
|
|
17851
|
+
}
|
|
17852
|
+
break;
|
|
17800
17853
|
}
|
|
17801
17854
|
}
|
|
17802
17855
|
}
|
|
17803
17856
|
}
|
|
17857
|
+
var ResolveIcuPlaceholdersVisitor = class extends RecurseVisitor {
|
|
17858
|
+
constructor(params) {
|
|
17859
|
+
super();
|
|
17860
|
+
this.params = params;
|
|
17861
|
+
}
|
|
17862
|
+
visitContainerPlaceholder(placeholder) {
|
|
17863
|
+
var _a2, _b2;
|
|
17864
|
+
if (placeholder.startName && placeholder.startSourceSpan && !this.params.has(placeholder.startName)) {
|
|
17865
|
+
this.params.set(placeholder.startName, [{
|
|
17866
|
+
value: (_a2 = placeholder.startSourceSpan) == null ? void 0 : _a2.toString(),
|
|
17867
|
+
subTemplateIndex: null,
|
|
17868
|
+
flags: I18nParamValueFlags.None
|
|
17869
|
+
}]);
|
|
17870
|
+
}
|
|
17871
|
+
if (placeholder.closeName && placeholder.endSourceSpan && !this.params.has(placeholder.closeName)) {
|
|
17872
|
+
this.params.set(placeholder.closeName, [{
|
|
17873
|
+
value: (_b2 = placeholder.endSourceSpan) == null ? void 0 : _b2.toString(),
|
|
17874
|
+
subTemplateIndex: null,
|
|
17875
|
+
flags: I18nParamValueFlags.None
|
|
17876
|
+
}]);
|
|
17877
|
+
}
|
|
17878
|
+
}
|
|
17879
|
+
visitTagPlaceholder(placeholder) {
|
|
17880
|
+
super.visitTagPlaceholder(placeholder);
|
|
17881
|
+
this.visitContainerPlaceholder(placeholder);
|
|
17882
|
+
}
|
|
17883
|
+
visitBlockPlaceholder(placeholder) {
|
|
17884
|
+
super.visitBlockPlaceholder(placeholder);
|
|
17885
|
+
this.visitContainerPlaceholder(placeholder);
|
|
17886
|
+
}
|
|
17887
|
+
};
|
|
17804
17888
|
|
|
17805
17889
|
// bazel-out/k8-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/resolve_names.mjs
|
|
17806
17890
|
function resolveNames(job) {
|
|
@@ -18518,6 +18602,7 @@ function allowConservativeInlining(decl, target) {
|
|
|
18518
18602
|
function wrapI18nIcus(job) {
|
|
18519
18603
|
for (const unit of job.units) {
|
|
18520
18604
|
let currentI18nOp = null;
|
|
18605
|
+
let addedI18nId = null;
|
|
18521
18606
|
for (const op of unit.create) {
|
|
18522
18607
|
switch (op.kind) {
|
|
18523
18608
|
case OpKind.I18nStart:
|
|
@@ -18526,11 +18611,16 @@ function wrapI18nIcus(job) {
|
|
|
18526
18611
|
case OpKind.I18nEnd:
|
|
18527
18612
|
currentI18nOp = null;
|
|
18528
18613
|
break;
|
|
18529
|
-
case OpKind.
|
|
18614
|
+
case OpKind.IcuStart:
|
|
18530
18615
|
if (currentI18nOp === null) {
|
|
18531
|
-
|
|
18532
|
-
OpList.insertBefore(createI18nStartOp(
|
|
18533
|
-
|
|
18616
|
+
addedI18nId = job.allocateXrefId();
|
|
18617
|
+
OpList.insertBefore(createI18nStartOp(addedI18nId, op.message), op);
|
|
18618
|
+
}
|
|
18619
|
+
break;
|
|
18620
|
+
case OpKind.IcuEnd:
|
|
18621
|
+
if (addedI18nId !== null) {
|
|
18622
|
+
OpList.insertAfter(createI18nEndOp(addedI18nId), op);
|
|
18623
|
+
addedI18nId = null;
|
|
18534
18624
|
}
|
|
18535
18625
|
break;
|
|
18536
18626
|
}
|
|
@@ -18557,7 +18647,6 @@ var phases = [
|
|
|
18557
18647
|
{ kind: CompilationJobKind.Tmpl, fn: createPipes },
|
|
18558
18648
|
{ kind: CompilationJobKind.Tmpl, fn: configureDeferInstructions },
|
|
18559
18649
|
{ kind: CompilationJobKind.Tmpl, fn: extractI18nText },
|
|
18560
|
-
{ kind: CompilationJobKind.Tmpl, fn: createI18nIcuExpressions },
|
|
18561
18650
|
{ kind: CompilationJobKind.Tmpl, fn: applyI18nExpressions },
|
|
18562
18651
|
{ kind: CompilationJobKind.Tmpl, fn: createVariadicPipes },
|
|
18563
18652
|
{ kind: CompilationJobKind.Both, fn: generatePureLiteralStructures },
|
|
@@ -18581,6 +18670,7 @@ var phases = [
|
|
|
18581
18670
|
{ kind: CompilationJobKind.Tmpl, fn: createDeferDepsFns },
|
|
18582
18671
|
{ kind: CompilationJobKind.Tmpl, fn: resolveI18nElementPlaceholders },
|
|
18583
18672
|
{ kind: CompilationJobKind.Tmpl, fn: resolveI18nExpressionPlaceholders },
|
|
18673
|
+
{ kind: CompilationJobKind.Tmpl, fn: resolveI18nIcuPlaceholders },
|
|
18584
18674
|
{ kind: CompilationJobKind.Tmpl, fn: mergeI18nContexts },
|
|
18585
18675
|
{ kind: CompilationJobKind.Tmpl, fn: extractI18nMessages },
|
|
18586
18676
|
{ kind: CompilationJobKind.Tmpl, fn: generateTrackFns },
|
|
@@ -18845,7 +18935,7 @@ function ingestContent(unit, content) {
|
|
|
18845
18935
|
function ingestText(unit, text2) {
|
|
18846
18936
|
unit.create.push(createTextOp(unit.job.allocateXrefId(), text2.value, text2.sourceSpan));
|
|
18847
18937
|
}
|
|
18848
|
-
function ingestBoundText(unit, text2) {
|
|
18938
|
+
function ingestBoundText(unit, text2, i18nPlaceholders) {
|
|
18849
18939
|
var _a2;
|
|
18850
18940
|
let value = text2.value;
|
|
18851
18941
|
if (value instanceof ASTWithSource) {
|
|
@@ -18857,7 +18947,12 @@ function ingestBoundText(unit, text2) {
|
|
|
18857
18947
|
if (text2.i18n !== void 0 && !(text2.i18n instanceof Container)) {
|
|
18858
18948
|
throw Error(`Unhandled i18n metadata type for text interpolation: ${(_a2 = text2.i18n) == null ? void 0 : _a2.constructor.name}`);
|
|
18859
18949
|
}
|
|
18860
|
-
|
|
18950
|
+
if (i18nPlaceholders === void 0) {
|
|
18951
|
+
i18nPlaceholders = text2.i18n instanceof Container ? text2.i18n.children.filter((node) => node instanceof Placeholder).map((placeholder) => placeholder.name) : [];
|
|
18952
|
+
}
|
|
18953
|
+
if (i18nPlaceholders.length > 0 && i18nPlaceholders.length !== value.expressions.length) {
|
|
18954
|
+
throw Error(`Unexpected number of i18n placeholders (${value.expressions.length}) for BoundText with ${value.expressions.length} expressions`);
|
|
18955
|
+
}
|
|
18861
18956
|
const textXref = unit.job.allocateXrefId();
|
|
18862
18957
|
unit.create.push(createTextOp(textXref, "", text2.sourceSpan));
|
|
18863
18958
|
const baseSourceSpan = unit.job.compatibility ? null : text2.sourceSpan;
|
|
@@ -19003,13 +19098,26 @@ function ingestDeferBlock(unit, deferBlock) {
|
|
|
19003
19098
|
unit.update.push(deferWhenOps);
|
|
19004
19099
|
}
|
|
19005
19100
|
function ingestIcu(unit, icu) {
|
|
19006
|
-
var _a2;
|
|
19101
|
+
var _a2, _b2;
|
|
19007
19102
|
if (icu.i18n instanceof Message && isSingleI18nIcu(icu.i18n)) {
|
|
19008
19103
|
const xref = unit.job.allocateXrefId();
|
|
19009
|
-
|
|
19010
|
-
unit.
|
|
19104
|
+
const icuNode = icu.i18n.nodes[0];
|
|
19105
|
+
unit.create.push(createIcuStartOp(xref, icu.i18n, icuFromI18nMessage(icu.i18n).name, null));
|
|
19106
|
+
const expressionPlaceholder = (_a2 = icuNode.expressionPlaceholder) == null ? void 0 : _a2.trimEnd();
|
|
19107
|
+
if (expressionPlaceholder === void 0 || icu.vars[expressionPlaceholder] === void 0) {
|
|
19108
|
+
throw Error("ICU should have a text binding");
|
|
19109
|
+
}
|
|
19110
|
+
ingestBoundText(unit, icu.vars[expressionPlaceholder], [expressionPlaceholder]);
|
|
19111
|
+
for (const [placeholder, text2] of Object.entries(icu.placeholders)) {
|
|
19112
|
+
if (text2 instanceof BoundText) {
|
|
19113
|
+
ingestBoundText(unit, text2, [placeholder]);
|
|
19114
|
+
} else {
|
|
19115
|
+
ingestText(unit, text2);
|
|
19116
|
+
}
|
|
19117
|
+
}
|
|
19118
|
+
unit.create.push(createIcuEndOp(xref));
|
|
19011
19119
|
} else {
|
|
19012
|
-
throw Error(`Unhandled i18n metadata type for ICU: ${(
|
|
19120
|
+
throw Error(`Unhandled i18n metadata type for ICU: ${(_b2 = icu.i18n) == null ? void 0 : _b2.constructor.name}`);
|
|
19013
19121
|
}
|
|
19014
19122
|
}
|
|
19015
19123
|
function ingestForBlock(unit, forBlock) {
|
|
@@ -20095,18 +20203,18 @@ function createIfBlock(ast, connectedBlocks, visitor, bindingParser) {
|
|
|
20095
20203
|
const branches = [];
|
|
20096
20204
|
const mainBlockParams = parseConditionalBlockParameters(ast, errors, bindingParser);
|
|
20097
20205
|
if (mainBlockParams !== null) {
|
|
20098
|
-
branches.push(new IfBlockBranch(mainBlockParams.expression, visitAll2(visitor, ast.children, ast.children), mainBlockParams.expressionAlias, ast.sourceSpan, ast.startSourceSpan, ast.endSourceSpan, ast.nameSpan));
|
|
20206
|
+
branches.push(new IfBlockBranch(mainBlockParams.expression, visitAll2(visitor, ast.children, ast.children), mainBlockParams.expressionAlias, ast.sourceSpan, ast.startSourceSpan, ast.endSourceSpan, ast.nameSpan, ast.i18n));
|
|
20099
20207
|
}
|
|
20100
20208
|
for (const block of connectedBlocks) {
|
|
20101
20209
|
if (ELSE_IF_PATTERN.test(block.name)) {
|
|
20102
20210
|
const params = parseConditionalBlockParameters(block, errors, bindingParser);
|
|
20103
20211
|
if (params !== null) {
|
|
20104
20212
|
const children = visitAll2(visitor, block.children, block.children);
|
|
20105
|
-
branches.push(new IfBlockBranch(params.expression, children, params.expressionAlias, block.sourceSpan, block.startSourceSpan, block.endSourceSpan, block.nameSpan));
|
|
20213
|
+
branches.push(new IfBlockBranch(params.expression, children, params.expressionAlias, block.sourceSpan, block.startSourceSpan, block.endSourceSpan, block.nameSpan, block.i18n));
|
|
20106
20214
|
}
|
|
20107
20215
|
} else if (block.name === "else") {
|
|
20108
20216
|
const children = visitAll2(visitor, block.children, block.children);
|
|
20109
|
-
branches.push(new IfBlockBranch(null, children, null, block.sourceSpan, block.startSourceSpan, block.endSourceSpan, block.nameSpan));
|
|
20217
|
+
branches.push(new IfBlockBranch(null, children, null, block.sourceSpan, block.startSourceSpan, block.endSourceSpan, block.nameSpan, block.i18n));
|
|
20110
20218
|
}
|
|
20111
20219
|
}
|
|
20112
20220
|
const ifBlockStartSourceSpan = branches.length > 0 ? branches[0].startSourceSpan : ast.startSourceSpan;
|
|
@@ -20134,7 +20242,7 @@ function createForLoop(ast, connectedBlocks, visitor, bindingParser) {
|
|
|
20134
20242
|
} else if (block.parameters.length > 0) {
|
|
20135
20243
|
errors.push(new ParseError(block.sourceSpan, "@empty block cannot have parameters"));
|
|
20136
20244
|
} else {
|
|
20137
|
-
empty = new ForLoopBlockEmpty(visitAll2(visitor, block.children, block.children), block.sourceSpan, block.startSourceSpan, block.endSourceSpan, block.nameSpan);
|
|
20245
|
+
empty = new ForLoopBlockEmpty(visitAll2(visitor, block.children, block.children), block.sourceSpan, block.startSourceSpan, block.endSourceSpan, block.nameSpan, block.i18n);
|
|
20138
20246
|
}
|
|
20139
20247
|
} else {
|
|
20140
20248
|
errors.push(new ParseError(block.sourceSpan, `Unrecognized @for loop block "${block.name}"`));
|
|
@@ -20146,7 +20254,7 @@ function createForLoop(ast, connectedBlocks, visitor, bindingParser) {
|
|
|
20146
20254
|
} else {
|
|
20147
20255
|
const endSpan = (_a2 = empty == null ? void 0 : empty.endSourceSpan) != null ? _a2 : ast.endSourceSpan;
|
|
20148
20256
|
const sourceSpan = new ParseSourceSpan(ast.sourceSpan.start, (_b2 = endSpan == null ? void 0 : endSpan.end) != null ? _b2 : ast.sourceSpan.end);
|
|
20149
|
-
node = new ForLoopBlock(params.itemName, params.expression, params.trackBy.expression, params.trackBy.keywordSpan, params.context, visitAll2(visitor, ast.children, ast.children), empty, sourceSpan, ast.sourceSpan, ast.startSourceSpan, endSpan, ast.nameSpan);
|
|
20257
|
+
node = new ForLoopBlock(params.itemName, params.expression, params.trackBy.expression, params.trackBy.keywordSpan, params.context, visitAll2(visitor, ast.children, ast.children), empty, sourceSpan, ast.sourceSpan, ast.startSourceSpan, endSpan, ast.nameSpan, ast.i18n);
|
|
20150
20258
|
}
|
|
20151
20259
|
}
|
|
20152
20260
|
return { node, errors };
|
|
@@ -20154,7 +20262,7 @@ function createForLoop(ast, connectedBlocks, visitor, bindingParser) {
|
|
|
20154
20262
|
function createSwitchBlock(ast, visitor, bindingParser) {
|
|
20155
20263
|
const errors = validateSwitchBlock(ast);
|
|
20156
20264
|
const primaryExpression = ast.parameters.length > 0 ? parseBlockParameterToBinding(ast.parameters[0], bindingParser) : bindingParser.parseBinding("", false, ast.sourceSpan, 0);
|
|
20157
|
-
const
|
|
20265
|
+
const cases2 = [];
|
|
20158
20266
|
const unknownBlocks = [];
|
|
20159
20267
|
let defaultCase = null;
|
|
20160
20268
|
for (const node of ast.children) {
|
|
@@ -20166,18 +20274,18 @@ function createSwitchBlock(ast, visitor, bindingParser) {
|
|
|
20166
20274
|
continue;
|
|
20167
20275
|
}
|
|
20168
20276
|
const expression = node.name === "case" ? parseBlockParameterToBinding(node.parameters[0], bindingParser) : null;
|
|
20169
|
-
const ast2 = new SwitchBlockCase(expression, visitAll2(visitor, node.children, node.children), node.sourceSpan, node.startSourceSpan, node.endSourceSpan, node.nameSpan);
|
|
20277
|
+
const ast2 = new SwitchBlockCase(expression, visitAll2(visitor, node.children, node.children), node.sourceSpan, node.startSourceSpan, node.endSourceSpan, node.nameSpan, node.i18n);
|
|
20170
20278
|
if (expression === null) {
|
|
20171
20279
|
defaultCase = ast2;
|
|
20172
20280
|
} else {
|
|
20173
|
-
|
|
20281
|
+
cases2.push(ast2);
|
|
20174
20282
|
}
|
|
20175
20283
|
}
|
|
20176
20284
|
if (defaultCase !== null) {
|
|
20177
|
-
|
|
20285
|
+
cases2.push(defaultCase);
|
|
20178
20286
|
}
|
|
20179
20287
|
return {
|
|
20180
|
-
node: new SwitchBlock(primaryExpression,
|
|
20288
|
+
node: new SwitchBlock(primaryExpression, cases2, unknownBlocks, ast.sourceSpan, ast.startSourceSpan, ast.endSourceSpan, ast.nameSpan),
|
|
20181
20289
|
errors
|
|
20182
20290
|
};
|
|
20183
20291
|
}
|
|
@@ -20654,7 +20762,7 @@ function createDeferredBlock(ast, connectedBlocks, visitor, bindingParser) {
|
|
|
20654
20762
|
endOfLastSourceSpan = lastConnectedBlock.sourceSpan.end;
|
|
20655
20763
|
}
|
|
20656
20764
|
const sourceSpanWithConnectedBlocks = new ParseSourceSpan(ast.sourceSpan.start, endOfLastSourceSpan);
|
|
20657
|
-
const node = new DeferredBlock(visitAll2(visitor, ast.children, ast.children), triggers, prefetchTriggers, placeholder, loading, error2, ast.nameSpan, sourceSpanWithConnectedBlocks, ast.sourceSpan, ast.startSourceSpan, lastEndSourceSpan);
|
|
20765
|
+
const node = new DeferredBlock(visitAll2(visitor, ast.children, ast.children), triggers, prefetchTriggers, placeholder, loading, error2, ast.nameSpan, sourceSpanWithConnectedBlocks, ast.sourceSpan, ast.startSourceSpan, lastEndSourceSpan, ast.i18n);
|
|
20658
20766
|
return { node, errors };
|
|
20659
20767
|
}
|
|
20660
20768
|
function parseConnectedBlocks(connectedBlocks, errors, visitor) {
|
|
@@ -20712,7 +20820,7 @@ function parsePlaceholderBlock(ast, visitor) {
|
|
|
20712
20820
|
throw new Error(`Unrecognized parameter in @placeholder block: "${param.expression}"`);
|
|
20713
20821
|
}
|
|
20714
20822
|
}
|
|
20715
|
-
return new DeferredBlockPlaceholder(visitAll2(visitor, ast.children, ast.children), minimumTime, ast.nameSpan, ast.sourceSpan, ast.startSourceSpan, ast.endSourceSpan);
|
|
20823
|
+
return new DeferredBlockPlaceholder(visitAll2(visitor, ast.children, ast.children), minimumTime, ast.nameSpan, ast.sourceSpan, ast.startSourceSpan, ast.endSourceSpan, ast.i18n);
|
|
20716
20824
|
}
|
|
20717
20825
|
function parseLoadingBlock(ast, visitor) {
|
|
20718
20826
|
let afterTime = null;
|
|
@@ -20740,13 +20848,13 @@ function parseLoadingBlock(ast, visitor) {
|
|
|
20740
20848
|
throw new Error(`Unrecognized parameter in @loading block: "${param.expression}"`);
|
|
20741
20849
|
}
|
|
20742
20850
|
}
|
|
20743
|
-
return new DeferredBlockLoading(visitAll2(visitor, ast.children, ast.children), afterTime, minimumTime, ast.nameSpan, ast.sourceSpan, ast.startSourceSpan, ast.endSourceSpan);
|
|
20851
|
+
return new DeferredBlockLoading(visitAll2(visitor, ast.children, ast.children), afterTime, minimumTime, ast.nameSpan, ast.sourceSpan, ast.startSourceSpan, ast.endSourceSpan, ast.i18n);
|
|
20744
20852
|
}
|
|
20745
20853
|
function parseErrorBlock(ast, visitor) {
|
|
20746
20854
|
if (ast.parameters.length > 0) {
|
|
20747
20855
|
throw new Error(`@error block cannot have parameters`);
|
|
20748
20856
|
}
|
|
20749
|
-
return new DeferredBlockError(visitAll2(visitor, ast.children, ast.children), ast.nameSpan, ast.sourceSpan, ast.startSourceSpan, ast.endSourceSpan);
|
|
20857
|
+
return new DeferredBlockError(visitAll2(visitor, ast.children, ast.children), ast.nameSpan, ast.sourceSpan, ast.startSourceSpan, ast.endSourceSpan, ast.i18n);
|
|
20750
20858
|
}
|
|
20751
20859
|
function parsePrimaryTriggers(params, bindingParser, errors, placeholder) {
|
|
20752
20860
|
const triggers = {};
|
|
@@ -21230,6 +21338,11 @@ var I18nContext = class {
|
|
|
21230
21338
|
const content = { type, index, ctx: this.id, isVoid: node.isVoid, closed };
|
|
21231
21339
|
updatePlaceholderMap(this.placeholders, ph, content);
|
|
21232
21340
|
}
|
|
21341
|
+
appendBlockPart(node, index, closed) {
|
|
21342
|
+
const ph = closed ? node.closeName : node.startName;
|
|
21343
|
+
const content = { type: TagType.TEMPLATE, index, ctx: this.id, closed };
|
|
21344
|
+
updatePlaceholderMap(this.placeholders, ph, content);
|
|
21345
|
+
}
|
|
21233
21346
|
get icus() {
|
|
21234
21347
|
return this._registry.icus;
|
|
21235
21348
|
}
|
|
@@ -21259,6 +21372,11 @@ var I18nContext = class {
|
|
|
21259
21372
|
this.appendTag(TagType.TEMPLATE, node, index, true);
|
|
21260
21373
|
this._unresolvedCtxCount++;
|
|
21261
21374
|
}
|
|
21375
|
+
appendBlock(node, index) {
|
|
21376
|
+
this.appendBlockPart(node, index, false);
|
|
21377
|
+
this.appendBlockPart(node, index, true);
|
|
21378
|
+
this._unresolvedCtxCount++;
|
|
21379
|
+
}
|
|
21262
21380
|
appendElement(node, index, closed) {
|
|
21263
21381
|
this.appendTag(TagType.ELEMENT, node, index, closed);
|
|
21264
21382
|
}
|
|
@@ -21454,12 +21572,18 @@ var TemplateDefinitionBuilder = class {
|
|
|
21454
21572
|
this.creationInstruction(null, Identifiers.pipe, [literal(slot), literal(name)]);
|
|
21455
21573
|
});
|
|
21456
21574
|
}
|
|
21457
|
-
buildTemplateFunction(nodes, variables, ngContentSelectorsOffset = 0, i18n2) {
|
|
21575
|
+
buildTemplateFunction(nodes, variables, ngContentSelectorsOffset = 0, i18n2, variableAliases) {
|
|
21458
21576
|
this._ngContentSelectorsOffset = ngContentSelectorsOffset;
|
|
21459
21577
|
if (this._namespace !== Identifiers.namespaceHTML) {
|
|
21460
21578
|
this.creationInstruction(null, this._namespace);
|
|
21461
21579
|
}
|
|
21462
|
-
variables.forEach((v) =>
|
|
21580
|
+
variables.forEach((v) => {
|
|
21581
|
+
const alias = variableAliases == null ? void 0 : variableAliases[v.name];
|
|
21582
|
+
this.registerContextVariables(v.name, v.value);
|
|
21583
|
+
if (alias) {
|
|
21584
|
+
this.registerContextVariables(alias, v.value);
|
|
21585
|
+
}
|
|
21586
|
+
});
|
|
21463
21587
|
const initI18nContext = this.i18nContext || isI18nRootNode(i18n2) && !isSingleI18nIcu(i18n2) && !(isSingleElementTemplate(nodes) && nodes[0].i18n === i18n2);
|
|
21464
21588
|
const selfClosingI18nInstruction = hasTextChildrenOnly(nodes);
|
|
21465
21589
|
if (initI18nContext) {
|
|
@@ -21514,12 +21638,12 @@ var TemplateDefinitionBuilder = class {
|
|
|
21514
21638
|
this._constants.prepareStatements.push(...statements);
|
|
21515
21639
|
return _ref;
|
|
21516
21640
|
}
|
|
21517
|
-
registerContextVariables(
|
|
21641
|
+
registerContextVariables(name, value) {
|
|
21518
21642
|
const scopedName = this._bindingScope.freshReferenceName();
|
|
21519
21643
|
const retrievalLevel = this.level;
|
|
21520
|
-
const isDirect =
|
|
21521
|
-
const lhs = variable(
|
|
21522
|
-
this._bindingScope.set(retrievalLevel,
|
|
21644
|
+
const isDirect = value === DIRECT_CONTEXT_REFERENCE;
|
|
21645
|
+
const lhs = variable(name + scopedName);
|
|
21646
|
+
this._bindingScope.set(retrievalLevel, name, (scope) => {
|
|
21523
21647
|
return isDirect && scope.bindingLevel === retrievalLevel && !scope.isListenerScope() ? variable(CONTEXT_NAME) : lhs;
|
|
21524
21648
|
}, 1, (scope, relativeLevel) => {
|
|
21525
21649
|
let rhs;
|
|
@@ -21537,7 +21661,7 @@ var TemplateDefinitionBuilder = class {
|
|
|
21537
21661
|
rhs = sharedCtxVar ? sharedCtxVar : generateNextContextExpr(relativeLevel);
|
|
21538
21662
|
}
|
|
21539
21663
|
return [
|
|
21540
|
-
lhs.set(isDirect ? rhs : rhs.prop(
|
|
21664
|
+
lhs.set(isDirect ? rhs : rhs.prop(value || IMPLICIT_REFERENCE)).toConstDecl()
|
|
21541
21665
|
];
|
|
21542
21666
|
});
|
|
21543
21667
|
}
|
|
@@ -21876,16 +22000,20 @@ var TemplateDefinitionBuilder = class {
|
|
|
21876
22000
|
this.creationInstruction(span, isNgContainer2 ? Identifiers.elementContainerEnd : Identifiers.elementEnd);
|
|
21877
22001
|
}
|
|
21878
22002
|
}
|
|
21879
|
-
prepareEmbeddedTemplateFn(children, contextNameSuffix, variables = [],
|
|
22003
|
+
prepareEmbeddedTemplateFn(children, contextNameSuffix, variables = [], i18nMeta, variableAliases) {
|
|
21880
22004
|
const index = this.allocateDataSlot();
|
|
21881
|
-
if (this.i18n &&
|
|
21882
|
-
|
|
22005
|
+
if (this.i18n && i18nMeta) {
|
|
22006
|
+
if (i18nMeta instanceof BlockPlaceholder) {
|
|
22007
|
+
this.i18n.appendBlock(i18nMeta, index);
|
|
22008
|
+
} else {
|
|
22009
|
+
this.i18n.appendTemplate(i18nMeta, index);
|
|
22010
|
+
}
|
|
21883
22011
|
}
|
|
21884
22012
|
const contextName = `${this.contextName}${contextNameSuffix}_${index}`;
|
|
21885
22013
|
const name = `${contextName}_Template`;
|
|
21886
22014
|
const visitor = new TemplateDefinitionBuilder(this.constantPool, this._bindingScope, this.level + 1, contextName, this.i18n, index, name, this._namespace, this.fileBasedI18nSuffix, this.i18nUseExternalIds, this.deferBlocks, this.elementLocations, this._constants);
|
|
21887
22015
|
this._nestedTemplateFns.push(() => {
|
|
21888
|
-
const templateFunctionExpr = visitor.buildTemplateFunction(children, variables, this._ngContentReservedSlots.length + this._ngContentSelectorsOffset,
|
|
22016
|
+
const templateFunctionExpr = visitor.buildTemplateFunction(children, variables, this._ngContentReservedSlots.length + this._ngContentSelectorsOffset, i18nMeta, variableAliases);
|
|
21889
22017
|
this.constantPool.statements.push(templateFunctionExpr.toDeclStmt(name));
|
|
21890
22018
|
if (visitor._ngContentReservedSlots.length) {
|
|
21891
22019
|
this._ngContentReservedSlots.push(...visitor._ngContentReservedSlots);
|
|
@@ -21968,7 +22096,7 @@ var TemplateDefinitionBuilder = class {
|
|
|
21968
22096
|
const placeholders = this.i18nBindProps(icu.placeholders);
|
|
21969
22097
|
const message = icu.i18n;
|
|
21970
22098
|
const transformFn = (raw) => {
|
|
21971
|
-
const params = __spreadValues(__spreadValues({}, vars), placeholders);
|
|
22099
|
+
const params = Object.fromEntries(Object.entries(__spreadValues(__spreadValues({}, vars), placeholders)).sort());
|
|
21972
22100
|
const formatted = formatI18nPlaceholderNamesInMap(params, false);
|
|
21973
22101
|
return invokeInstruction(null, Identifiers.i18nPostprocess, [raw, mapLiteral(formatted, true)]);
|
|
21974
22102
|
};
|
|
@@ -21995,7 +22123,7 @@ var TemplateDefinitionBuilder = class {
|
|
|
21995
22123
|
tagName = inferredData.tagName;
|
|
21996
22124
|
attrsExprs = inferredData.attrsExprs;
|
|
21997
22125
|
}
|
|
21998
|
-
const templateIndex = this.createEmbeddedTemplateFn(tagName, children, "_Conditional", sourceSpan, variables, attrsExprs);
|
|
22126
|
+
const templateIndex = this.createEmbeddedTemplateFn(tagName, children, "_Conditional", sourceSpan, variables, attrsExprs, void 0, branch.i18n);
|
|
21999
22127
|
const processedExpression = expression === null ? null : expression.visit(this._valueConverter);
|
|
22000
22128
|
return { index: templateIndex, expression: processedExpression, alias: expressionAlias };
|
|
22001
22129
|
});
|
|
@@ -22029,7 +22157,7 @@ var TemplateDefinitionBuilder = class {
|
|
|
22029
22157
|
}
|
|
22030
22158
|
visitSwitchBlock(block) {
|
|
22031
22159
|
const caseData = block.cases.map((currentCase) => {
|
|
22032
|
-
const index = this.createEmbeddedTemplateFn(null, currentCase.children, "_Case", currentCase.sourceSpan);
|
|
22160
|
+
const index = this.createEmbeddedTemplateFn(null, currentCase.children, "_Case", currentCase.sourceSpan, void 0, void 0, void 0, currentCase.i18n);
|
|
22033
22161
|
const expression = currentCase.expression === null ? null : currentCase.expression.visit(this._valueConverter);
|
|
22034
22162
|
return { index, expression };
|
|
22035
22163
|
});
|
|
@@ -22057,12 +22185,12 @@ var TemplateDefinitionBuilder = class {
|
|
|
22057
22185
|
if (!metadata) {
|
|
22058
22186
|
throw new Error("Could not resolve `defer` block metadata. Block may need to be analyzed.");
|
|
22059
22187
|
}
|
|
22060
|
-
const primaryTemplateIndex = this.createEmbeddedTemplateFn(null, deferred.children, "_Defer", deferred.sourceSpan);
|
|
22061
|
-
const loadingIndex = loading ? this.createEmbeddedTemplateFn(null, loading.children, "_DeferLoading", loading.sourceSpan) : null;
|
|
22188
|
+
const primaryTemplateIndex = this.createEmbeddedTemplateFn(null, deferred.children, "_Defer", deferred.sourceSpan, void 0, void 0, void 0, deferred.i18n);
|
|
22189
|
+
const loadingIndex = loading ? this.createEmbeddedTemplateFn(null, loading.children, "_DeferLoading", loading.sourceSpan, void 0, void 0, void 0, loading.i18n) : null;
|
|
22062
22190
|
const loadingConsts = loading ? trimTrailingNulls([literal(loading.minimumTime), literal(loading.afterTime)]) : null;
|
|
22063
|
-
const placeholderIndex = placeholder ? this.createEmbeddedTemplateFn(null, placeholder.children, "_DeferPlaceholder", placeholder.sourceSpan) : null;
|
|
22191
|
+
const placeholderIndex = placeholder ? this.createEmbeddedTemplateFn(null, placeholder.children, "_DeferPlaceholder", placeholder.sourceSpan, void 0, void 0, void 0, placeholder.i18n) : null;
|
|
22064
22192
|
const placeholderConsts = placeholder && placeholder.minimumTime !== null ? literalArr([literal(placeholder.minimumTime)]) : null;
|
|
22065
|
-
const errorIndex = error2 ? this.createEmbeddedTemplateFn(null, error2.children, "_DeferError", error2.sourceSpan) : null;
|
|
22193
|
+
const errorIndex = error2 ? this.createEmbeddedTemplateFn(null, error2.children, "_DeferError", error2.sourceSpan, void 0, void 0, void 0, error2.i18n) : null;
|
|
22066
22194
|
const deferredIndex = this.allocateDataSlot();
|
|
22067
22195
|
const depsFnName = `${this.contextName}_Defer_${deferredIndex}_DepsFn`;
|
|
22068
22196
|
this.creationInstruction(deferred.sourceSpan, Identifiers.defer, trimTrailingNulls([
|
|
@@ -22171,11 +22299,14 @@ var TemplateDefinitionBuilder = class {
|
|
|
22171
22299
|
visitForLoopBlock(block) {
|
|
22172
22300
|
const blockIndex = this.allocateDataSlot();
|
|
22173
22301
|
const { tagName, attrsExprs } = this.inferProjectionDataFromInsertionPoint(block);
|
|
22174
|
-
const primaryData = this.prepareEmbeddedTemplateFn(block.children, "_For", [block.item, block.contextVariables.$index, block.contextVariables.$count]
|
|
22302
|
+
const primaryData = this.prepareEmbeddedTemplateFn(block.children, "_For", [block.item, block.contextVariables.$index, block.contextVariables.$count], block.i18n, {
|
|
22303
|
+
[block.contextVariables.$index.name]: this.getLevelSpecificVariableName("$index", this.level + 1),
|
|
22304
|
+
[block.contextVariables.$count.name]: this.getLevelSpecificVariableName("$count", this.level + 1)
|
|
22305
|
+
});
|
|
22175
22306
|
const { expression: trackByExpression, usesComponentInstance: trackByUsesComponentInstance } = this.createTrackByFunction(block);
|
|
22176
22307
|
let emptyData = null;
|
|
22177
22308
|
if (block.empty !== null) {
|
|
22178
|
-
emptyData = this.prepareEmbeddedTemplateFn(block.empty.children, "_ForEmpty");
|
|
22309
|
+
emptyData = this.prepareEmbeddedTemplateFn(block.empty.children, "_ForEmpty", void 0, block.empty.i18n);
|
|
22179
22310
|
this.allocateBindingSlots(null);
|
|
22180
22311
|
}
|
|
22181
22312
|
this.registerComputedLoopVariables(block, primaryData.scope);
|
|
@@ -22197,16 +22328,31 @@ var TemplateDefinitionBuilder = class {
|
|
|
22197
22328
|
return params;
|
|
22198
22329
|
});
|
|
22199
22330
|
const value = block.expression.visit(this._valueConverter);
|
|
22200
|
-
this.
|
|
22331
|
+
this.updateInstructionWithAdvance(blockIndex, block.sourceSpan, Identifiers.repeater, () => [this.convertPropertyBinding(value)]);
|
|
22201
22332
|
}
|
|
22202
22333
|
registerComputedLoopVariables(block, bindingScope) {
|
|
22203
|
-
const indexLocalName = block.contextVariables.$index.name;
|
|
22204
|
-
const countLocalName = block.contextVariables.$count.name;
|
|
22205
22334
|
const level = bindingScope.bindingLevel;
|
|
22206
|
-
bindingScope.set(level, block.contextVariables.$odd.name, (scope) =>
|
|
22207
|
-
|
|
22208
|
-
|
|
22209
|
-
bindingScope.set(level, block.contextVariables.$
|
|
22335
|
+
bindingScope.set(level, block.contextVariables.$odd.name, (scope, retrievalLevel) => {
|
|
22336
|
+
return this.getLevelSpecificForLoopVariable(block, scope, retrievalLevel, "$index").modulo(literal(2)).notIdentical(literal(0));
|
|
22337
|
+
});
|
|
22338
|
+
bindingScope.set(level, block.contextVariables.$even.name, (scope, retrievalLevel) => {
|
|
22339
|
+
return this.getLevelSpecificForLoopVariable(block, scope, retrievalLevel, "$index").modulo(literal(2)).identical(literal(0));
|
|
22340
|
+
});
|
|
22341
|
+
bindingScope.set(level, block.contextVariables.$first.name, (scope, retrievalLevel) => {
|
|
22342
|
+
return this.getLevelSpecificForLoopVariable(block, scope, retrievalLevel, "$index").identical(literal(0));
|
|
22343
|
+
});
|
|
22344
|
+
bindingScope.set(level, block.contextVariables.$last.name, (scope, retrievalLevel) => {
|
|
22345
|
+
const index = this.getLevelSpecificForLoopVariable(block, scope, retrievalLevel, "$index");
|
|
22346
|
+
const count = this.getLevelSpecificForLoopVariable(block, scope, retrievalLevel, "$count");
|
|
22347
|
+
return index.identical(count.minus(literal(1)));
|
|
22348
|
+
});
|
|
22349
|
+
}
|
|
22350
|
+
getLevelSpecificVariableName(name, level) {
|
|
22351
|
+
return `\u0275${name}_${level}`;
|
|
22352
|
+
}
|
|
22353
|
+
getLevelSpecificForLoopVariable(block, scope, retrievalLevel, name) {
|
|
22354
|
+
const scopeName = scope.bindingLevel === retrievalLevel ? block.contextVariables[name].name : this.getLevelSpecificVariableName(name, retrievalLevel);
|
|
22355
|
+
return scope.get(scopeName);
|
|
22210
22356
|
}
|
|
22211
22357
|
optimizeTrackByFunction(block) {
|
|
22212
22358
|
const indexLocalName = block.contextVariables.$index.name;
|
|
@@ -22616,7 +22762,7 @@ var BindingScope = class {
|
|
|
22616
22762
|
if (value.declareLocalCallback && !value.declare) {
|
|
22617
22763
|
value.declare = true;
|
|
22618
22764
|
}
|
|
22619
|
-
return typeof value.lhs === "function" ? value.lhs(this) : value.lhs;
|
|
22765
|
+
return typeof value.lhs === "function" ? value.lhs(this, value.retrievalLevel) : value.lhs;
|
|
22620
22766
|
}
|
|
22621
22767
|
current = current.parent;
|
|
22622
22768
|
}
|
|
@@ -22692,7 +22838,7 @@ var BindingScope = class {
|
|
|
22692
22838
|
const componentValue = this.map.get(SHARED_CONTEXT_KEY + 0);
|
|
22693
22839
|
componentValue.declare = true;
|
|
22694
22840
|
this.maybeRestoreView();
|
|
22695
|
-
const lhs = typeof componentValue.lhs === "function" ? componentValue.lhs(this) : componentValue.lhs;
|
|
22841
|
+
const lhs = typeof componentValue.lhs === "function" ? componentValue.lhs(this, componentValue.retrievalLevel) : componentValue.lhs;
|
|
22696
22842
|
return name === DIRECT_CONTEXT_REFERENCE ? lhs : lhs.prop(name);
|
|
22697
22843
|
}
|
|
22698
22844
|
maybeRestoreView() {
|
|
@@ -24761,7 +24907,7 @@ function publishFacade(global) {
|
|
|
24761
24907
|
}
|
|
24762
24908
|
|
|
24763
24909
|
// bazel-out/k8-fastbuild/bin/packages/compiler/src/version.mjs
|
|
24764
|
-
var VERSION2 = new Version("17.0.
|
|
24910
|
+
var VERSION2 = new Version("17.0.4");
|
|
24765
24911
|
|
|
24766
24912
|
// bazel-out/k8-fastbuild/bin/packages/compiler/src/i18n/extractor_merger.mjs
|
|
24767
24913
|
var _VisitorMode;
|
|
@@ -24807,14 +24953,63 @@ publishFacade(_global);
|
|
|
24807
24953
|
|
|
24808
24954
|
// bazel-out/k8-fastbuild/bin/packages/core/schematics/ng-generate/control-flow-migration/types.mjs
|
|
24809
24955
|
var ngtemplate = "ng-template";
|
|
24956
|
+
var boundngifelse = "[ngIfElse]";
|
|
24957
|
+
var boundngifthenelse = "[ngIfThenElse]";
|
|
24958
|
+
var nakedngfor = "ngFor";
|
|
24959
|
+
function allFormsOf(selector) {
|
|
24960
|
+
return [
|
|
24961
|
+
selector,
|
|
24962
|
+
`*${selector}`,
|
|
24963
|
+
`[${selector}]`
|
|
24964
|
+
];
|
|
24965
|
+
}
|
|
24966
|
+
var commonModuleDirectives = /* @__PURE__ */ new Set([
|
|
24967
|
+
...allFormsOf("ngComponentOutlet"),
|
|
24968
|
+
...allFormsOf("ngTemplateOutlet"),
|
|
24969
|
+
...allFormsOf("ngClass"),
|
|
24970
|
+
...allFormsOf("ngPlural"),
|
|
24971
|
+
...allFormsOf("ngPluralCase"),
|
|
24972
|
+
...allFormsOf("ngStyle"),
|
|
24973
|
+
...allFormsOf("ngTemplateOutlet"),
|
|
24974
|
+
...allFormsOf("ngComponentOutlet"),
|
|
24975
|
+
"[NgForOf]",
|
|
24976
|
+
"[NgForTrackBy]",
|
|
24977
|
+
"[ngIfElse]",
|
|
24978
|
+
"[ngIfThenElse]"
|
|
24979
|
+
]);
|
|
24980
|
+
function pipeMatchRegExpFor(name) {
|
|
24981
|
+
return new RegExp(`\\|\\s*${name}`);
|
|
24982
|
+
}
|
|
24983
|
+
var commonModulePipes = [
|
|
24984
|
+
"date",
|
|
24985
|
+
"async",
|
|
24986
|
+
"currency",
|
|
24987
|
+
"number",
|
|
24988
|
+
"i18nPlural",
|
|
24989
|
+
"i18nSelect",
|
|
24990
|
+
"json",
|
|
24991
|
+
"keyvalue",
|
|
24992
|
+
"slice",
|
|
24993
|
+
"lowercase",
|
|
24994
|
+
"uppercase",
|
|
24995
|
+
"titlecase",
|
|
24996
|
+
"percent",
|
|
24997
|
+
"titlecase"
|
|
24998
|
+
].map((name) => pipeMatchRegExpFor(name));
|
|
24810
24999
|
var ElementToMigrate = class {
|
|
24811
|
-
constructor(el, attr) {
|
|
25000
|
+
constructor(el, attr, elseAttr = void 0, thenAttr = void 0, forAttrs = void 0) {
|
|
24812
25001
|
__publicField(this, "el");
|
|
24813
25002
|
__publicField(this, "attr");
|
|
25003
|
+
__publicField(this, "elseAttr");
|
|
25004
|
+
__publicField(this, "thenAttr");
|
|
25005
|
+
__publicField(this, "forAttrs");
|
|
24814
25006
|
__publicField(this, "nestCount", 0);
|
|
24815
25007
|
__publicField(this, "hasLineBreaks", false);
|
|
24816
25008
|
this.el = el;
|
|
24817
25009
|
this.attr = attr;
|
|
25010
|
+
this.elseAttr = elseAttr;
|
|
25011
|
+
this.thenAttr = thenAttr;
|
|
25012
|
+
this.forAttrs = forAttrs;
|
|
24818
25013
|
}
|
|
24819
25014
|
getCondition(targetStr) {
|
|
24820
25015
|
const targetLocation = this.attr.value.indexOf(targetStr);
|
|
@@ -24862,9 +25057,12 @@ var Template2 = class {
|
|
|
24862
25057
|
var AnalyzedFile = class {
|
|
24863
25058
|
constructor() {
|
|
24864
25059
|
__publicField(this, "ranges", []);
|
|
25060
|
+
__publicField(this, "removeCommonModule", false);
|
|
24865
25061
|
}
|
|
24866
25062
|
getSortedRanges() {
|
|
24867
|
-
|
|
25063
|
+
const templateRanges = this.ranges.slice().filter((x) => x.type === "template").sort((aStart, bStart) => bStart.start - aStart.start);
|
|
25064
|
+
const importRanges = this.ranges.slice().filter((x) => x.type === "import").sort((aStart, bStart) => bStart.start - aStart.start);
|
|
25065
|
+
return [...templateRanges, ...importRanges];
|
|
24868
25066
|
}
|
|
24869
25067
|
static addRange(path2, analyzedFiles, range) {
|
|
24870
25068
|
let analysis = analyzedFiles.get(path2);
|
|
@@ -24872,12 +25070,39 @@ var AnalyzedFile = class {
|
|
|
24872
25070
|
analysis = new AnalyzedFile();
|
|
24873
25071
|
analyzedFiles.set(path2, analysis);
|
|
24874
25072
|
}
|
|
24875
|
-
const duplicate = analysis.ranges.find((current) => current
|
|
25073
|
+
const duplicate = analysis.ranges.find((current) => current.start === range.start && current.end === range.end);
|
|
24876
25074
|
if (!duplicate) {
|
|
24877
25075
|
analysis.ranges.push(range);
|
|
24878
25076
|
}
|
|
24879
25077
|
}
|
|
24880
25078
|
};
|
|
25079
|
+
var CommonCollector = class extends RecursiveVisitor {
|
|
25080
|
+
constructor() {
|
|
25081
|
+
super(...arguments);
|
|
25082
|
+
__publicField(this, "count", 0);
|
|
25083
|
+
}
|
|
25084
|
+
visitElement(el) {
|
|
25085
|
+
if (el.attrs.length > 0) {
|
|
25086
|
+
for (const attr of el.attrs) {
|
|
25087
|
+
if (this.hasDirectives(attr.name) || this.hasPipes(attr.value)) {
|
|
25088
|
+
this.count++;
|
|
25089
|
+
}
|
|
25090
|
+
}
|
|
25091
|
+
}
|
|
25092
|
+
super.visitElement(el, null);
|
|
25093
|
+
}
|
|
25094
|
+
visitText(ast) {
|
|
25095
|
+
if (this.hasPipes(ast.value)) {
|
|
25096
|
+
this.count++;
|
|
25097
|
+
}
|
|
25098
|
+
}
|
|
25099
|
+
hasDirectives(input) {
|
|
25100
|
+
return commonModuleDirectives.has(input);
|
|
25101
|
+
}
|
|
25102
|
+
hasPipes(input) {
|
|
25103
|
+
return commonModulePipes.some((regexp) => regexp.test(input));
|
|
25104
|
+
}
|
|
25105
|
+
};
|
|
24881
25106
|
var ElementCollector = class extends RecursiveVisitor {
|
|
24882
25107
|
constructor(_attributes = []) {
|
|
24883
25108
|
super();
|
|
@@ -24889,12 +25114,37 @@ var ElementCollector = class extends RecursiveVisitor {
|
|
|
24889
25114
|
if (el.attrs.length > 0) {
|
|
24890
25115
|
for (const attr of el.attrs) {
|
|
24891
25116
|
if (this._attributes.includes(attr.name)) {
|
|
24892
|
-
|
|
25117
|
+
const elseAttr = el.attrs.find((x) => x.name === boundngifelse);
|
|
25118
|
+
const thenAttr = el.attrs.find((x) => x.name === boundngifthenelse);
|
|
25119
|
+
const forAttrs = attr.name === nakedngfor ? this.getForAttrs(el) : void 0;
|
|
25120
|
+
this.elements.push(new ElementToMigrate(el, attr, elseAttr, thenAttr, forAttrs));
|
|
24893
25121
|
}
|
|
24894
25122
|
}
|
|
24895
25123
|
}
|
|
24896
25124
|
super.visitElement(el, null);
|
|
24897
25125
|
}
|
|
25126
|
+
getForAttrs(el) {
|
|
25127
|
+
const aliases = /* @__PURE__ */ new Map();
|
|
25128
|
+
let item = "";
|
|
25129
|
+
let trackBy = "";
|
|
25130
|
+
let forOf = "";
|
|
25131
|
+
for (const attr of el.attrs) {
|
|
25132
|
+
if (attr.name === "[ngForTrackBy]") {
|
|
25133
|
+
trackBy = attr.value;
|
|
25134
|
+
}
|
|
25135
|
+
if (attr.name === "[ngForOf]") {
|
|
25136
|
+
forOf = attr.value;
|
|
25137
|
+
}
|
|
25138
|
+
if (attr.name.startsWith("let-")) {
|
|
25139
|
+
if (attr.value === "") {
|
|
25140
|
+
item = attr.name.replace("let-", "");
|
|
25141
|
+
} else {
|
|
25142
|
+
aliases.set(attr.name.replace("let-", ""), attr.value);
|
|
25143
|
+
}
|
|
25144
|
+
}
|
|
25145
|
+
}
|
|
25146
|
+
return { forOf, trackBy, item, aliases };
|
|
25147
|
+
}
|
|
24898
25148
|
};
|
|
24899
25149
|
var TemplateCollector = class extends RecursiveVisitor {
|
|
24900
25150
|
constructor() {
|
|
@@ -24926,31 +25176,113 @@ var TemplateCollector = class extends RecursiveVisitor {
|
|
|
24926
25176
|
// bazel-out/k8-fastbuild/bin/packages/core/schematics/ng-generate/control-flow-migration/util.mjs
|
|
24927
25177
|
var import_path2 = require("path");
|
|
24928
25178
|
var import_typescript5 = __toESM(require("typescript"), 1);
|
|
25179
|
+
var importRemovals = [
|
|
25180
|
+
"NgIf",
|
|
25181
|
+
"NgIfElse",
|
|
25182
|
+
"NgIfThenElse",
|
|
25183
|
+
"NgFor",
|
|
25184
|
+
"NgForOf",
|
|
25185
|
+
"NgForTrackBy",
|
|
25186
|
+
"NgSwitch",
|
|
25187
|
+
"NgSwitchCase",
|
|
25188
|
+
"NgSwitchDefault"
|
|
25189
|
+
];
|
|
25190
|
+
var importWithCommonRemovals = [...importRemovals, "CommonModule"];
|
|
24929
25191
|
function analyze(sourceFile, analyzedFiles) {
|
|
24930
25192
|
forEachClass(sourceFile, (node) => {
|
|
24931
|
-
|
|
24932
|
-
|
|
24933
|
-
|
|
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;
|
|
25193
|
+
if (import_typescript5.default.isClassDeclaration(node)) {
|
|
25194
|
+
analyzeDecorators(node, sourceFile, analyzedFiles);
|
|
25195
|
+
} else {
|
|
25196
|
+
analyzeImportDeclarations(node, sourceFile, analyzedFiles);
|
|
24938
25197
|
}
|
|
24939
|
-
|
|
24940
|
-
|
|
24941
|
-
|
|
24942
|
-
|
|
24943
|
-
|
|
24944
|
-
|
|
24945
|
-
|
|
24946
|
-
|
|
24947
|
-
|
|
24948
|
-
|
|
24949
|
-
|
|
24950
|
-
|
|
24951
|
-
|
|
25198
|
+
});
|
|
25199
|
+
}
|
|
25200
|
+
function checkIfShouldChange(decl, removeCommonModule) {
|
|
25201
|
+
const clause = decl.getChildAt(1);
|
|
25202
|
+
return !(!removeCommonModule && clause.namedBindings && import_typescript5.default.isNamedImports(clause.namedBindings) && clause.namedBindings.elements.length === 1 && clause.namedBindings.elements[0].getText() === "CommonModule");
|
|
25203
|
+
}
|
|
25204
|
+
function updateImportDeclaration(decl, removeCommonModule) {
|
|
25205
|
+
const clause = decl.getChildAt(1);
|
|
25206
|
+
const updatedClause = updateImportClause(clause, removeCommonModule);
|
|
25207
|
+
if (updatedClause === null) {
|
|
25208
|
+
return "";
|
|
25209
|
+
}
|
|
25210
|
+
const printer = import_typescript5.default.createPrinter({
|
|
25211
|
+
removeComments: true
|
|
25212
|
+
});
|
|
25213
|
+
const updated = import_typescript5.default.factory.updateImportDeclaration(decl, decl.modifiers, updatedClause, decl.moduleSpecifier, void 0);
|
|
25214
|
+
return printer.printNode(import_typescript5.default.EmitHint.Unspecified, updated, clause.getSourceFile());
|
|
25215
|
+
}
|
|
25216
|
+
function updateImportClause(clause, removeCommonModule) {
|
|
25217
|
+
if (clause.namedBindings && import_typescript5.default.isNamedImports(clause.namedBindings)) {
|
|
25218
|
+
const removals = removeCommonModule ? importWithCommonRemovals : importRemovals;
|
|
25219
|
+
const elements = clause.namedBindings.elements.filter((el) => !removals.includes(el.getText()));
|
|
25220
|
+
if (elements.length === 0) {
|
|
25221
|
+
return null;
|
|
24952
25222
|
}
|
|
25223
|
+
clause = import_typescript5.default.factory.updateImportClause(clause, clause.isTypeOnly, clause.name, import_typescript5.default.factory.createNamedImports(elements));
|
|
25224
|
+
}
|
|
25225
|
+
return clause;
|
|
25226
|
+
}
|
|
25227
|
+
function updateClassImports(propAssignment, removeCommonModule) {
|
|
25228
|
+
const printer = import_typescript5.default.createPrinter();
|
|
25229
|
+
const importList = propAssignment.initializer;
|
|
25230
|
+
const removals = removeCommonModule ? importWithCommonRemovals : importRemovals;
|
|
25231
|
+
const elements = importList.elements.filter((el) => !removals.includes(el.getText()));
|
|
25232
|
+
const updatedElements = import_typescript5.default.factory.updateArrayLiteralExpression(importList, elements);
|
|
25233
|
+
const updatedAssignment = import_typescript5.default.factory.updatePropertyAssignment(propAssignment, propAssignment.name, updatedElements);
|
|
25234
|
+
return printer.printNode(import_typescript5.default.EmitHint.Unspecified, updatedAssignment, updatedAssignment.getSourceFile());
|
|
25235
|
+
}
|
|
25236
|
+
function analyzeImportDeclarations(node, sourceFile, analyzedFiles) {
|
|
25237
|
+
if (node.getText().indexOf("@angular/common") === -1) {
|
|
25238
|
+
return;
|
|
25239
|
+
}
|
|
25240
|
+
const clause = node.getChildAt(1);
|
|
25241
|
+
if (clause.namedBindings && import_typescript5.default.isNamedImports(clause.namedBindings)) {
|
|
25242
|
+
const elements = clause.namedBindings.elements.filter((el) => importWithCommonRemovals.includes(el.getText()));
|
|
25243
|
+
if (elements.length > 0) {
|
|
25244
|
+
AnalyzedFile.addRange(sourceFile.fileName, analyzedFiles, { start: node.getStart(), end: node.getEnd(), node, type: "import" });
|
|
25245
|
+
}
|
|
25246
|
+
}
|
|
25247
|
+
}
|
|
25248
|
+
function analyzeDecorators(node, sourceFile, analyzedFiles) {
|
|
25249
|
+
var _a2;
|
|
25250
|
+
const decorator = (_a2 = import_typescript5.default.getDecorators(node)) == null ? void 0 : _a2.find((dec) => {
|
|
25251
|
+
return import_typescript5.default.isCallExpression(dec.expression) && import_typescript5.default.isIdentifier(dec.expression.expression) && dec.expression.expression.text === "Component";
|
|
24953
25252
|
});
|
|
25253
|
+
const metadata = decorator && decorator.expression.arguments.length > 0 && import_typescript5.default.isObjectLiteralExpression(decorator.expression.arguments[0]) ? decorator.expression.arguments[0] : null;
|
|
25254
|
+
if (!metadata) {
|
|
25255
|
+
return;
|
|
25256
|
+
}
|
|
25257
|
+
for (const prop of metadata.properties) {
|
|
25258
|
+
if (!import_typescript5.default.isPropertyAssignment(prop) || !import_typescript5.default.isIdentifier(prop.name) && !import_typescript5.default.isStringLiteralLike(prop.name)) {
|
|
25259
|
+
continue;
|
|
25260
|
+
}
|
|
25261
|
+
switch (prop.name.text) {
|
|
25262
|
+
case "template":
|
|
25263
|
+
AnalyzedFile.addRange(sourceFile.fileName, analyzedFiles, {
|
|
25264
|
+
start: prop.initializer.getStart() + 1,
|
|
25265
|
+
end: prop.initializer.getEnd() - 1,
|
|
25266
|
+
node: prop,
|
|
25267
|
+
type: "template"
|
|
25268
|
+
});
|
|
25269
|
+
break;
|
|
25270
|
+
case "imports":
|
|
25271
|
+
AnalyzedFile.addRange(sourceFile.fileName, analyzedFiles, {
|
|
25272
|
+
start: prop.name.getStart(),
|
|
25273
|
+
end: prop.initializer.getEnd(),
|
|
25274
|
+
node: prop,
|
|
25275
|
+
type: "import"
|
|
25276
|
+
});
|
|
25277
|
+
break;
|
|
25278
|
+
case "templateUrl":
|
|
25279
|
+
if (import_typescript5.default.isStringLiteralLike(prop.initializer)) {
|
|
25280
|
+
const path2 = (0, import_path2.join)((0, import_path2.dirname)(sourceFile.fileName), prop.initializer.text);
|
|
25281
|
+
AnalyzedFile.addRange(path2, analyzedFiles, { start: 0, node: prop, type: "template" });
|
|
25282
|
+
}
|
|
25283
|
+
break;
|
|
25284
|
+
}
|
|
25285
|
+
}
|
|
24954
25286
|
}
|
|
24955
25287
|
function getNestedCount(etm, aggregator) {
|
|
24956
25288
|
if (aggregator.length === 0) {
|
|
@@ -25036,38 +25368,66 @@ function wrapIntoI18nContainer(i18nAttr, content) {
|
|
|
25036
25368
|
function processNgTemplates(template2) {
|
|
25037
25369
|
const templates = countTemplateUsage(template2);
|
|
25038
25370
|
for (const [name, t] of templates) {
|
|
25039
|
-
const
|
|
25040
|
-
|
|
25371
|
+
const replaceRegex = new RegExp(`${name}\\|`, "g");
|
|
25372
|
+
const matches = [...template2.matchAll(replaceRegex)];
|
|
25373
|
+
if (matches.length > 0) {
|
|
25041
25374
|
if (t.i18n !== null) {
|
|
25042
25375
|
const container = wrapIntoI18nContainer(t.i18n, t.children);
|
|
25043
|
-
template2 = template2.replace(
|
|
25376
|
+
template2 = template2.replace(replaceRegex, container);
|
|
25044
25377
|
} else {
|
|
25045
|
-
template2 = template2.replace(
|
|
25378
|
+
template2 = template2.replace(replaceRegex, t.children);
|
|
25046
25379
|
}
|
|
25047
|
-
if (t.count
|
|
25380
|
+
if (t.count === matches.length + 1) {
|
|
25048
25381
|
template2 = template2.replace(t.contents, "");
|
|
25049
25382
|
}
|
|
25050
25383
|
}
|
|
25051
25384
|
}
|
|
25052
25385
|
return template2;
|
|
25053
25386
|
}
|
|
25387
|
+
function canRemoveCommonModule(template2) {
|
|
25388
|
+
const parsed = parseTemplate2(template2);
|
|
25389
|
+
let removeCommonModule = false;
|
|
25390
|
+
if (parsed !== null) {
|
|
25391
|
+
const visitor = new CommonCollector();
|
|
25392
|
+
visitAll2(visitor, parsed.rootNodes);
|
|
25393
|
+
removeCommonModule = visitor.count === 0;
|
|
25394
|
+
}
|
|
25395
|
+
return removeCommonModule;
|
|
25396
|
+
}
|
|
25397
|
+
function removeImports(template2, node, removeCommonModule) {
|
|
25398
|
+
if (template2.startsWith("imports") && import_typescript5.default.isPropertyAssignment(node)) {
|
|
25399
|
+
return updateClassImports(node, removeCommonModule);
|
|
25400
|
+
} else if (import_typescript5.default.isImportDeclaration(node) && checkIfShouldChange(node, removeCommonModule)) {
|
|
25401
|
+
return updateImportDeclaration(node, removeCommonModule);
|
|
25402
|
+
}
|
|
25403
|
+
return template2;
|
|
25404
|
+
}
|
|
25054
25405
|
function getOriginals(etm, tmpl, offset) {
|
|
25055
25406
|
if (etm.el.children.length > 0) {
|
|
25407
|
+
const childStart = etm.el.children[0].sourceSpan.start.offset - offset;
|
|
25408
|
+
const childEnd = etm.el.children[etm.el.children.length - 1].sourceSpan.end.offset - offset;
|
|
25056
25409
|
const start2 = tmpl.slice(etm.el.sourceSpan.start.offset - offset, etm.el.children[0].sourceSpan.start.offset - offset);
|
|
25057
25410
|
const end = tmpl.slice(etm.el.children[etm.el.children.length - 1].sourceSpan.end.offset - offset, etm.el.sourceSpan.end.offset - offset);
|
|
25058
|
-
|
|
25411
|
+
const childLength = childEnd - childStart;
|
|
25412
|
+
return { start: start2, end, childLength };
|
|
25059
25413
|
}
|
|
25060
25414
|
const start = tmpl.slice(etm.el.sourceSpan.start.offset - offset, etm.el.sourceSpan.end.offset - offset);
|
|
25061
|
-
return { start, end: "" };
|
|
25415
|
+
return { start, end: "", childLength: 0 };
|
|
25416
|
+
}
|
|
25417
|
+
function isI18nTemplate(etm, i18nAttr) {
|
|
25418
|
+
return etm.el.name === "ng-template" && i18nAttr !== void 0 && (etm.el.attrs.length === 2 || etm.el.attrs.length === 3 && etm.elseAttr !== void 0);
|
|
25419
|
+
}
|
|
25420
|
+
function isRemovableContainer(etm) {
|
|
25421
|
+
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);
|
|
25062
25422
|
}
|
|
25063
25423
|
function getMainBlock(etm, tmpl, offset) {
|
|
25064
25424
|
const i18nAttr = etm.el.attrs.find((x) => x.name === "i18n");
|
|
25065
|
-
if ((etm
|
|
25425
|
+
if (isRemovableContainer(etm)) {
|
|
25066
25426
|
const childStart2 = etm.el.children[0].sourceSpan.start.offset - offset;
|
|
25067
25427
|
const childEnd2 = etm.el.children[etm.el.children.length - 1].sourceSpan.end.offset - offset;
|
|
25068
25428
|
const middle2 = tmpl.slice(childStart2, childEnd2);
|
|
25069
25429
|
return { start: "", middle: middle2, end: "" };
|
|
25070
|
-
} else if (etm
|
|
25430
|
+
} else if (isI18nTemplate(etm, i18nAttr)) {
|
|
25071
25431
|
const childStart2 = etm.el.children[0].sourceSpan.start.offset - offset;
|
|
25072
25432
|
const childEnd2 = etm.el.children[etm.el.children.length - 1].sourceSpan.end.offset - offset;
|
|
25073
25433
|
const middle2 = wrapIntoI18nContainer(i18nAttr, tmpl.slice(childStart2, childEnd2));
|
|
@@ -25087,17 +25447,130 @@ function getMainBlock(etm, tmpl, offset) {
|
|
|
25087
25447
|
const end = tmpl.slice(childEnd, etm.end(offset));
|
|
25088
25448
|
return { start, middle, end };
|
|
25089
25449
|
}
|
|
25450
|
+
function formatTemplate(tmpl) {
|
|
25451
|
+
if (tmpl.indexOf("\n") > -1) {
|
|
25452
|
+
const openBlockRegex = /^\s*\@(if|switch|case|default|for)|^\s*\}\s\@else/;
|
|
25453
|
+
const openElRegex = /^\s*<([a-z0-9]+)(?![^>]*\/>)[^>]*>?/;
|
|
25454
|
+
const closeBlockRegex = /^\s*\}\s*$|^\s*\}\s\@else/;
|
|
25455
|
+
const closeElRegex = /\s*<\/([a-z0-9\-]+)*>/;
|
|
25456
|
+
const closeMultiLineElRegex = /^\s*([a-z0-9\-\[\]]+)?=?"?([^”<]+)?"?\s?\/>$/;
|
|
25457
|
+
const singleLineElRegex = /^\s*<([a-z0-9]+)(?![^>]*\/>)[^>]*>.*<\/([a-z0-9\-]+)*>/;
|
|
25458
|
+
const lines = tmpl.split("\n");
|
|
25459
|
+
const formatted = [];
|
|
25460
|
+
let indent = "";
|
|
25461
|
+
for (let [index, line] of lines.entries()) {
|
|
25462
|
+
if (line.trim() === "" && index !== 0 && index !== lines.length - 1) {
|
|
25463
|
+
continue;
|
|
25464
|
+
}
|
|
25465
|
+
if ((closeBlockRegex.test(line) || closeElRegex.test(line) && (!singleLineElRegex.test(line) && !closeMultiLineElRegex.test(line))) && indent !== "") {
|
|
25466
|
+
indent = indent.slice(2);
|
|
25467
|
+
}
|
|
25468
|
+
formatted.push(indent + line.trim());
|
|
25469
|
+
if (closeMultiLineElRegex.test(line)) {
|
|
25470
|
+
indent = indent.slice(2);
|
|
25471
|
+
}
|
|
25472
|
+
if ((openBlockRegex.test(line) || openElRegex.test(line)) && !singleLineElRegex.test(line)) {
|
|
25473
|
+
indent += " ";
|
|
25474
|
+
}
|
|
25475
|
+
}
|
|
25476
|
+
tmpl = formatted.join("\n");
|
|
25477
|
+
}
|
|
25478
|
+
return tmpl;
|
|
25479
|
+
}
|
|
25090
25480
|
function forEachClass(sourceFile, callback) {
|
|
25091
25481
|
sourceFile.forEachChild(function walk(node) {
|
|
25092
|
-
if (import_typescript5.default.isClassDeclaration(node)) {
|
|
25482
|
+
if (import_typescript5.default.isClassDeclaration(node) || import_typescript5.default.isImportDeclaration(node)) {
|
|
25093
25483
|
callback(node);
|
|
25094
25484
|
}
|
|
25095
25485
|
node.forEachChild(walk);
|
|
25096
25486
|
});
|
|
25097
25487
|
}
|
|
25098
25488
|
|
|
25489
|
+
// bazel-out/k8-fastbuild/bin/packages/core/schematics/ng-generate/control-flow-migration/cases.mjs
|
|
25490
|
+
var boundcase = "[ngSwitchCase]";
|
|
25491
|
+
var switchcase = "*ngSwitchCase";
|
|
25492
|
+
var nakedcase = "ngSwitchCase";
|
|
25493
|
+
var switchdefault = "*ngSwitchDefault";
|
|
25494
|
+
var nakeddefault = "ngSwitchDefault";
|
|
25495
|
+
var cases = [
|
|
25496
|
+
boundcase,
|
|
25497
|
+
switchcase,
|
|
25498
|
+
nakedcase,
|
|
25499
|
+
switchdefault,
|
|
25500
|
+
nakeddefault
|
|
25501
|
+
];
|
|
25502
|
+
function migrateCase(template2) {
|
|
25503
|
+
let errors = [];
|
|
25504
|
+
let parsed = parseTemplate2(template2);
|
|
25505
|
+
if (parsed === null) {
|
|
25506
|
+
return { migrated: template2, errors, changed: false };
|
|
25507
|
+
}
|
|
25508
|
+
let result = template2;
|
|
25509
|
+
const visitor = new ElementCollector(cases);
|
|
25510
|
+
visitAll2(visitor, parsed.rootNodes);
|
|
25511
|
+
calculateNesting(visitor, hasLineBreaks(template2));
|
|
25512
|
+
let offset = 0;
|
|
25513
|
+
let nestLevel = -1;
|
|
25514
|
+
let postOffsets = [];
|
|
25515
|
+
for (const el of visitor.elements) {
|
|
25516
|
+
let migrateResult = { tmpl: result, offsets: { pre: 0, post: 0 } };
|
|
25517
|
+
offset = reduceNestingOffset(el, nestLevel, offset, postOffsets);
|
|
25518
|
+
if (el.attr.name === switchcase || el.attr.name === nakedcase || el.attr.name === boundcase) {
|
|
25519
|
+
try {
|
|
25520
|
+
migrateResult = migrateNgSwitchCase(el, result, offset);
|
|
25521
|
+
} catch (error2) {
|
|
25522
|
+
errors.push({ type: switchcase, error: error2 });
|
|
25523
|
+
}
|
|
25524
|
+
} else if (el.attr.name === switchdefault || el.attr.name === nakeddefault) {
|
|
25525
|
+
try {
|
|
25526
|
+
migrateResult = migrateNgSwitchDefault(el, result, offset);
|
|
25527
|
+
} catch (error2) {
|
|
25528
|
+
errors.push({ type: switchdefault, error: error2 });
|
|
25529
|
+
}
|
|
25530
|
+
}
|
|
25531
|
+
result = migrateResult.tmpl;
|
|
25532
|
+
offset += migrateResult.offsets.pre;
|
|
25533
|
+
postOffsets.push(migrateResult.offsets.post);
|
|
25534
|
+
nestLevel = el.nestCount;
|
|
25535
|
+
}
|
|
25536
|
+
const changed = visitor.elements.length > 0;
|
|
25537
|
+
return { migrated: result, errors, changed };
|
|
25538
|
+
}
|
|
25539
|
+
function migrateNgSwitchCase(etm, tmpl, offset) {
|
|
25540
|
+
const lbString = etm.hasLineBreaks ? "\n" : "";
|
|
25541
|
+
const leadingSpace = etm.hasLineBreaks ? "" : " ";
|
|
25542
|
+
const condition = etm.attr.value;
|
|
25543
|
+
const originals = getOriginals(etm, tmpl, offset);
|
|
25544
|
+
const { start, middle, end } = getMainBlock(etm, tmpl, offset);
|
|
25545
|
+
const startBlock = `${leadingSpace}@case (${condition}) {${leadingSpace}${lbString}${start}`;
|
|
25546
|
+
const endBlock = `${end}${lbString}${leadingSpace}}`;
|
|
25547
|
+
const defaultBlock = startBlock + middle + endBlock;
|
|
25548
|
+
const updatedTmpl = tmpl.slice(0, etm.start(offset)) + defaultBlock + tmpl.slice(etm.end(offset));
|
|
25549
|
+
const pre = originals.start.length - startBlock.length;
|
|
25550
|
+
const post = originals.end.length - endBlock.length;
|
|
25551
|
+
return { tmpl: updatedTmpl, offsets: { pre, post } };
|
|
25552
|
+
}
|
|
25553
|
+
function migrateNgSwitchDefault(etm, tmpl, offset) {
|
|
25554
|
+
const lbString = etm.hasLineBreaks ? "\n" : "";
|
|
25555
|
+
const leadingSpace = etm.hasLineBreaks ? "" : " ";
|
|
25556
|
+
const originals = getOriginals(etm, tmpl, offset);
|
|
25557
|
+
const { start, middle, end } = getMainBlock(etm, tmpl, offset);
|
|
25558
|
+
const startBlock = `${leadingSpace}@default {${leadingSpace}${lbString}${start}`;
|
|
25559
|
+
const endBlock = `${end}${lbString}${leadingSpace}}`;
|
|
25560
|
+
const defaultBlock = startBlock + middle + endBlock;
|
|
25561
|
+
const updatedTmpl = tmpl.slice(0, etm.start(offset)) + defaultBlock + tmpl.slice(etm.end(offset));
|
|
25562
|
+
const pre = originals.start.length - startBlock.length;
|
|
25563
|
+
const post = originals.end.length - endBlock.length;
|
|
25564
|
+
return { tmpl: updatedTmpl, offsets: { pre, post } };
|
|
25565
|
+
}
|
|
25566
|
+
|
|
25099
25567
|
// bazel-out/k8-fastbuild/bin/packages/core/schematics/ng-generate/control-flow-migration/fors.mjs
|
|
25100
25568
|
var ngfor = "*ngFor";
|
|
25569
|
+
var nakedngfor2 = "ngFor";
|
|
25570
|
+
var fors = [
|
|
25571
|
+
ngfor,
|
|
25572
|
+
nakedngfor2
|
|
25573
|
+
];
|
|
25101
25574
|
var commaSeparatedSyntax = /* @__PURE__ */ new Map([
|
|
25102
25575
|
["(", ")"],
|
|
25103
25576
|
["{", "}"],
|
|
@@ -25111,10 +25584,10 @@ function migrateFor(template2) {
|
|
|
25111
25584
|
let errors = [];
|
|
25112
25585
|
let parsed = parseTemplate2(template2);
|
|
25113
25586
|
if (parsed === null) {
|
|
25114
|
-
return { migrated: template2, errors };
|
|
25587
|
+
return { migrated: template2, errors, changed: false };
|
|
25115
25588
|
}
|
|
25116
25589
|
let result = template2;
|
|
25117
|
-
const visitor = new ElementCollector(
|
|
25590
|
+
const visitor = new ElementCollector(fors);
|
|
25118
25591
|
visitAll2(visitor, parsed.rootNodes);
|
|
25119
25592
|
calculateNesting(visitor, hasLineBreaks(template2));
|
|
25120
25593
|
let offset = 0;
|
|
@@ -25133,15 +25606,20 @@ function migrateFor(template2) {
|
|
|
25133
25606
|
postOffsets.push(migrateResult.offsets.post);
|
|
25134
25607
|
nestLevel = el.nestCount;
|
|
25135
25608
|
}
|
|
25136
|
-
|
|
25609
|
+
const changed = visitor.elements.length > 0;
|
|
25610
|
+
return { migrated: result, errors, changed };
|
|
25137
25611
|
}
|
|
25138
25612
|
function migrateNgFor(etm, tmpl, offset) {
|
|
25613
|
+
if (etm.forAttrs !== void 0) {
|
|
25614
|
+
return migrateBoundNgFor(etm, tmpl, offset);
|
|
25615
|
+
}
|
|
25616
|
+
return migrateStandardNgFor(etm, tmpl, offset);
|
|
25617
|
+
}
|
|
25618
|
+
function migrateStandardNgFor(etm, tmpl, offset) {
|
|
25139
25619
|
const aliasWithEqualRegexp = /=\s*(count|index|first|last|even|odd)/gm;
|
|
25140
25620
|
const aliasWithAsRegexp = /(count|index|first|last|even|odd)\s+as/gm;
|
|
25141
25621
|
const aliases = [];
|
|
25142
25622
|
const lbString = etm.hasLineBreaks ? "\n" : "";
|
|
25143
|
-
const lbSpaces = etm.hasLineBreaks ? `
|
|
25144
|
-
` : "";
|
|
25145
25623
|
const parts = getNgForParts(etm.attr.value);
|
|
25146
25624
|
const originals = getOriginals(etm, tmpl, offset);
|
|
25147
25625
|
const condition = parts[0].replace("let ", "");
|
|
@@ -25174,7 +25652,7 @@ function migrateNgFor(etm, tmpl, offset) {
|
|
|
25174
25652
|
}
|
|
25175
25653
|
const aliasStr = aliases.length > 0 ? `;${aliases.join(";")}` : "";
|
|
25176
25654
|
const { start, middle, end } = getMainBlock(etm, tmpl, offset);
|
|
25177
|
-
const startBlock = `@for (${condition}; track ${trackBy}${aliasStr}) {${
|
|
25655
|
+
const startBlock = `@for (${condition}; track ${trackBy}${aliasStr}) {${lbString}${start}`;
|
|
25178
25656
|
const endBlock = `${end}${lbString}}`;
|
|
25179
25657
|
const forBlock = startBlock + middle + endBlock;
|
|
25180
25658
|
const updatedTmpl = tmpl.slice(0, etm.start(offset)) + forBlock + tmpl.slice(etm.end(offset));
|
|
@@ -25182,6 +25660,35 @@ function migrateNgFor(etm, tmpl, offset) {
|
|
|
25182
25660
|
const post = originals.end.length - endBlock.length;
|
|
25183
25661
|
return { tmpl: updatedTmpl, offsets: { pre, post } };
|
|
25184
25662
|
}
|
|
25663
|
+
function migrateBoundNgFor(etm, tmpl, offset) {
|
|
25664
|
+
const forAttrs = etm.forAttrs;
|
|
25665
|
+
const aliasMap = forAttrs.aliases;
|
|
25666
|
+
const originals = getOriginals(etm, tmpl, offset);
|
|
25667
|
+
const condition = `${forAttrs.item} of ${forAttrs.forOf}`;
|
|
25668
|
+
const aliases = [];
|
|
25669
|
+
let aliasedIndex = "$index";
|
|
25670
|
+
for (const [key, val] of aliasMap) {
|
|
25671
|
+
aliases.push(` let ${key.trim()} = $${val}`);
|
|
25672
|
+
if (val.trim() === "index") {
|
|
25673
|
+
aliasedIndex = key;
|
|
25674
|
+
}
|
|
25675
|
+
}
|
|
25676
|
+
const aliasStr = aliases.length > 0 ? `;${aliases.join(";")}` : "";
|
|
25677
|
+
let trackBy = forAttrs.item;
|
|
25678
|
+
if (forAttrs.trackBy !== "") {
|
|
25679
|
+
trackBy = `${forAttrs.trackBy.trim()}(${aliasedIndex}, ${forAttrs.item})`;
|
|
25680
|
+
}
|
|
25681
|
+
const { start, middle, end } = getMainBlock(etm, tmpl, offset);
|
|
25682
|
+
const startBlock = `@for (${condition}; track ${trackBy}${aliasStr}) {
|
|
25683
|
+
${start}`;
|
|
25684
|
+
const endBlock = `${end}
|
|
25685
|
+
}`;
|
|
25686
|
+
const forBlock = startBlock + middle + endBlock;
|
|
25687
|
+
const updatedTmpl = tmpl.slice(0, etm.start(offset)) + forBlock + tmpl.slice(etm.end(offset));
|
|
25688
|
+
const pre = originals.start.length - startBlock.length;
|
|
25689
|
+
const post = originals.end.length - endBlock.length;
|
|
25690
|
+
return { tmpl: updatedTmpl, offsets: { pre, post } };
|
|
25691
|
+
}
|
|
25185
25692
|
function getNgForParts(expression) {
|
|
25186
25693
|
const parts = [];
|
|
25187
25694
|
const commaSeparatedStack = [];
|
|
@@ -25227,7 +25734,7 @@ function migrateIf(template2) {
|
|
|
25227
25734
|
let errors = [];
|
|
25228
25735
|
let parsed = parseTemplate2(template2);
|
|
25229
25736
|
if (parsed === null) {
|
|
25230
|
-
return { migrated: template2, errors };
|
|
25737
|
+
return { migrated: template2, errors, changed: false };
|
|
25231
25738
|
}
|
|
25232
25739
|
let result = template2;
|
|
25233
25740
|
const visitor = new ElementCollector(ifs);
|
|
@@ -25249,21 +25756,24 @@ function migrateIf(template2) {
|
|
|
25249
25756
|
postOffsets.push(migrateResult.offsets.post);
|
|
25250
25757
|
nestLevel = el.nestCount;
|
|
25251
25758
|
}
|
|
25252
|
-
|
|
25759
|
+
const changed = visitor.elements.length > 0;
|
|
25760
|
+
return { migrated: result, errors, changed };
|
|
25253
25761
|
}
|
|
25254
25762
|
function migrateNgIf(etm, tmpl, offset) {
|
|
25255
25763
|
const matchThen = etm.attr.value.match(/;\s*then/gm);
|
|
25256
25764
|
const matchElse = etm.attr.value.match(/;\s*else/gm);
|
|
25257
|
-
if (
|
|
25258
|
-
return
|
|
25765
|
+
if (etm.thenAttr !== void 0 || etm.elseAttr !== void 0) {
|
|
25766
|
+
return buildBoundIfElseBlock(etm, tmpl, offset);
|
|
25767
|
+
} else if (matchThen && matchThen.length > 0) {
|
|
25768
|
+
return buildStandardIfThenElseBlock(etm, tmpl, matchThen[0], matchElse[0], offset);
|
|
25259
25769
|
} else if (matchElse && matchElse.length > 0) {
|
|
25260
|
-
return
|
|
25770
|
+
return buildStandardIfElseBlock(etm, tmpl, matchElse[0], offset);
|
|
25261
25771
|
}
|
|
25262
25772
|
return buildIfBlock(etm, tmpl, offset);
|
|
25263
25773
|
}
|
|
25264
25774
|
function buildIfBlock(etm, tmpl, offset) {
|
|
25265
25775
|
const lbString = etm.hasLineBreaks ? "\n" : "";
|
|
25266
|
-
const condition = etm.attr.value.replace(" as ", "; as ");
|
|
25776
|
+
const condition = etm.attr.value.replace(" as ", "; as ").replace(/;\s*let/g, "; as");
|
|
25267
25777
|
const originals = getOriginals(etm, tmpl, offset);
|
|
25268
25778
|
const { start, middle, end } = getMainBlock(etm, tmpl, offset);
|
|
25269
25779
|
const startBlock = `@if (${condition}) {${lbString}${start}`;
|
|
@@ -25274,11 +25784,23 @@ function buildIfBlock(etm, tmpl, offset) {
|
|
|
25274
25784
|
const post = originals.end.length - endBlock.length;
|
|
25275
25785
|
return { tmpl: updatedTmpl, offsets: { pre, post } };
|
|
25276
25786
|
}
|
|
25277
|
-
function
|
|
25787
|
+
function buildStandardIfElseBlock(etm, tmpl, elseString, offset) {
|
|
25788
|
+
const condition = etm.getCondition(elseString).replace(" as ", "; as ").replace(/;\s*let/g, "; as");
|
|
25789
|
+
const elsePlaceholder = `#${etm.getTemplateName(elseString)}|`;
|
|
25790
|
+
return buildIfElseBlock(etm, tmpl, condition, elsePlaceholder, offset);
|
|
25791
|
+
}
|
|
25792
|
+
function buildBoundIfElseBlock(etm, tmpl, offset) {
|
|
25793
|
+
const condition = etm.attr.value.replace(" as ", "; as ");
|
|
25794
|
+
const elsePlaceholder = `#${etm.elseAttr.value}|`;
|
|
25795
|
+
if (etm.thenAttr !== void 0) {
|
|
25796
|
+
const thenPlaceholder = `#${etm.thenAttr.value}|`;
|
|
25797
|
+
return buildIfThenElseBlock(etm, tmpl, condition, thenPlaceholder, elsePlaceholder, offset);
|
|
25798
|
+
}
|
|
25799
|
+
return buildIfElseBlock(etm, tmpl, condition, elsePlaceholder, offset);
|
|
25800
|
+
}
|
|
25801
|
+
function buildIfElseBlock(etm, tmpl, condition, elsePlaceholder, offset) {
|
|
25278
25802
|
const lbString = etm.hasLineBreaks ? "\n" : "";
|
|
25279
|
-
const condition = etm.getCondition(elseString).replace(" as ", "; as ");
|
|
25280
25803
|
const originals = getOriginals(etm, tmpl, offset);
|
|
25281
|
-
const elsePlaceholder = `#${etm.getTemplateName(elseString)}|`;
|
|
25282
25804
|
const { start, middle, end } = getMainBlock(etm, tmpl, offset);
|
|
25283
25805
|
const startBlock = `@if (${condition}) {${lbString}${start}`;
|
|
25284
25806
|
const elseBlock = `${end}${lbString}} @else {${lbString}`;
|
|
@@ -25291,44 +25813,37 @@ function buildIfElseBlock(etm, tmpl, elseString, offset) {
|
|
|
25291
25813
|
const post = originals.end.length - postBlock.length;
|
|
25292
25814
|
return { tmpl: updatedTmpl, offsets: { pre, post } };
|
|
25293
25815
|
}
|
|
25294
|
-
function
|
|
25295
|
-
const condition = etm.getCondition(thenString).replace(" as ", "; as ");
|
|
25816
|
+
function buildStandardIfThenElseBlock(etm, tmpl, thenString, elseString, offset) {
|
|
25817
|
+
const condition = etm.getCondition(thenString).replace(" as ", "; as ").replace(/;\s*let/g, "; as");
|
|
25818
|
+
const thenPlaceholder = `#${etm.getTemplateName(thenString, elseString)}|`;
|
|
25819
|
+
const elsePlaceholder = `#${etm.getTemplateName(elseString)}|`;
|
|
25820
|
+
return buildIfThenElseBlock(etm, tmpl, condition, thenPlaceholder, elsePlaceholder, offset);
|
|
25821
|
+
}
|
|
25822
|
+
function buildIfThenElseBlock(etm, tmpl, condition, thenPlaceholder, elsePlaceholder, offset) {
|
|
25296
25823
|
const lbString = etm.hasLineBreaks ? "\n" : "";
|
|
25297
25824
|
const originals = getOriginals(etm, tmpl, offset);
|
|
25298
25825
|
const startBlock = `@if (${condition}) {${lbString}`;
|
|
25299
25826
|
const elseBlock = `${lbString}} @else {${lbString}`;
|
|
25300
|
-
const thenPlaceholder = `#${etm.getTemplateName(thenString, elseString)}|`;
|
|
25301
|
-
const elsePlaceholder = `#${etm.getTemplateName(elseString)}|`;
|
|
25302
25827
|
const postBlock = thenPlaceholder + elseBlock + elsePlaceholder + `${lbString}}`;
|
|
25303
25828
|
const ifThenElseBlock = startBlock + postBlock;
|
|
25304
25829
|
const tmplStart = tmpl.slice(0, etm.start(offset));
|
|
25305
25830
|
const tmplEnd = tmpl.slice(etm.end(offset));
|
|
25306
25831
|
const updatedTmpl = tmplStart + ifThenElseBlock + tmplEnd;
|
|
25307
|
-
const pre = originals.start.length - startBlock.length;
|
|
25832
|
+
const pre = originals.start.length + originals.childLength - startBlock.length;
|
|
25308
25833
|
const post = originals.end.length - postBlock.length;
|
|
25309
25834
|
return { tmpl: updatedTmpl, offsets: { pre, post } };
|
|
25310
25835
|
}
|
|
25311
25836
|
|
|
25312
25837
|
// bazel-out/k8-fastbuild/bin/packages/core/schematics/ng-generate/control-flow-migration/switches.mjs
|
|
25313
25838
|
var ngswitch = "[ngSwitch]";
|
|
25314
|
-
var boundcase = "[ngSwitchCase]";
|
|
25315
|
-
var switchcase = "*ngSwitchCase";
|
|
25316
|
-
var nakedcase = "ngSwitchCase";
|
|
25317
|
-
var switchdefault = "*ngSwitchDefault";
|
|
25318
|
-
var nakeddefault = "ngSwitchDefault";
|
|
25319
25839
|
var switches = [
|
|
25320
|
-
ngswitch
|
|
25321
|
-
boundcase,
|
|
25322
|
-
switchcase,
|
|
25323
|
-
nakedcase,
|
|
25324
|
-
switchdefault,
|
|
25325
|
-
nakeddefault
|
|
25840
|
+
ngswitch
|
|
25326
25841
|
];
|
|
25327
25842
|
function migrateSwitch(template2) {
|
|
25328
25843
|
let errors = [];
|
|
25329
25844
|
let parsed = parseTemplate2(template2);
|
|
25330
25845
|
if (parsed === null) {
|
|
25331
|
-
return { migrated: template2, errors };
|
|
25846
|
+
return { migrated: template2, errors, changed: false };
|
|
25332
25847
|
}
|
|
25333
25848
|
let result = template2;
|
|
25334
25849
|
const visitor = new ElementCollector(switches);
|
|
@@ -25346,25 +25861,14 @@ function migrateSwitch(template2) {
|
|
|
25346
25861
|
} catch (error2) {
|
|
25347
25862
|
errors.push({ type: ngswitch, error: error2 });
|
|
25348
25863
|
}
|
|
25349
|
-
} else if (el.attr.name === switchcase || el.attr.name === nakedcase || el.attr.name === boundcase) {
|
|
25350
|
-
try {
|
|
25351
|
-
migrateResult = migrateNgSwitchCase(el, result, offset);
|
|
25352
|
-
} catch (error2) {
|
|
25353
|
-
errors.push({ type: ngswitch, error: error2 });
|
|
25354
|
-
}
|
|
25355
|
-
} else if (el.attr.name === switchdefault || el.attr.name === nakeddefault) {
|
|
25356
|
-
try {
|
|
25357
|
-
migrateResult = migrateNgSwitchDefault(el, result, offset);
|
|
25358
|
-
} catch (error2) {
|
|
25359
|
-
errors.push({ type: ngswitch, error: error2 });
|
|
25360
|
-
}
|
|
25361
25864
|
}
|
|
25362
25865
|
result = migrateResult.tmpl;
|
|
25363
25866
|
offset += migrateResult.offsets.pre;
|
|
25364
25867
|
postOffsets.push(migrateResult.offsets.post);
|
|
25365
25868
|
nestLevel = el.nestCount;
|
|
25366
25869
|
}
|
|
25367
|
-
|
|
25870
|
+
const changed = visitor.elements.length > 0;
|
|
25871
|
+
return { migrated: result, errors, changed };
|
|
25368
25872
|
}
|
|
25369
25873
|
function migrateNgSwitch(etm, tmpl, offset) {
|
|
25370
25874
|
const lbString = etm.hasLineBreaks ? "\n" : "";
|
|
@@ -25379,43 +25883,43 @@ function migrateNgSwitch(etm, tmpl, offset) {
|
|
|
25379
25883
|
const post = originals.end.length - endBlock.length;
|
|
25380
25884
|
return { tmpl: updatedTmpl, offsets: { pre, post } };
|
|
25381
25885
|
}
|
|
25382
|
-
|
|
25383
|
-
|
|
25384
|
-
|
|
25385
|
-
|
|
25386
|
-
|
|
25387
|
-
|
|
25388
|
-
|
|
25389
|
-
|
|
25390
|
-
|
|
25391
|
-
|
|
25392
|
-
|
|
25393
|
-
|
|
25394
|
-
|
|
25395
|
-
|
|
25396
|
-
}
|
|
25397
|
-
|
|
25398
|
-
|
|
25399
|
-
|
|
25400
|
-
|
|
25401
|
-
|
|
25402
|
-
|
|
25403
|
-
|
|
25404
|
-
|
|
25405
|
-
|
|
25406
|
-
|
|
25407
|
-
|
|
25408
|
-
const post = originals.end.length - endBlock.length;
|
|
25409
|
-
return { tmpl: updatedTmpl, offsets: { pre, post } };
|
|
25886
|
+
|
|
25887
|
+
// bazel-out/k8-fastbuild/bin/packages/core/schematics/ng-generate/control-flow-migration/migration.mjs
|
|
25888
|
+
function migrateTemplate(template2, templateType, node, file, format = true) {
|
|
25889
|
+
let errors = [];
|
|
25890
|
+
let migrated = template2;
|
|
25891
|
+
if (templateType === "template") {
|
|
25892
|
+
const ifResult = migrateIf(template2);
|
|
25893
|
+
const forResult = migrateFor(ifResult.migrated);
|
|
25894
|
+
const switchResult = migrateSwitch(forResult.migrated);
|
|
25895
|
+
const caseResult = migrateCase(switchResult.migrated);
|
|
25896
|
+
migrated = processNgTemplates(caseResult.migrated);
|
|
25897
|
+
const changed = ifResult.changed || forResult.changed || switchResult.changed || caseResult.changed;
|
|
25898
|
+
if (format && changed) {
|
|
25899
|
+
migrated = formatTemplate(migrated);
|
|
25900
|
+
}
|
|
25901
|
+
file.removeCommonModule = canRemoveCommonModule(template2);
|
|
25902
|
+
errors = [
|
|
25903
|
+
...ifResult.errors,
|
|
25904
|
+
...forResult.errors,
|
|
25905
|
+
...switchResult.errors,
|
|
25906
|
+
...caseResult.errors
|
|
25907
|
+
];
|
|
25908
|
+
} else {
|
|
25909
|
+
migrated = removeImports(template2, node, file.removeCommonModule);
|
|
25910
|
+
}
|
|
25911
|
+
return { migrated, errors };
|
|
25410
25912
|
}
|
|
25411
25913
|
|
|
25412
25914
|
// bazel-out/k8-fastbuild/bin/packages/core/schematics/ng-generate/control-flow-migration/index.mjs
|
|
25413
25915
|
function control_flow_migration_default(options) {
|
|
25414
25916
|
return (tree, context) => __async(this, null, function* () {
|
|
25415
|
-
const { buildPaths, testPaths } = yield getProjectTsConfigPaths(tree);
|
|
25416
25917
|
const basePath = process.cwd();
|
|
25417
25918
|
const pathToMigrate = normalizePath((0, import_path3.join)(basePath, options.path));
|
|
25418
|
-
|
|
25919
|
+
let allPaths = [];
|
|
25920
|
+
if (pathToMigrate.trim() !== "") {
|
|
25921
|
+
allPaths.push(pathToMigrate);
|
|
25922
|
+
}
|
|
25419
25923
|
if (!allPaths.length) {
|
|
25420
25924
|
throw new import_schematics.SchematicsException("Could not find any tsconfig file. Cannot run the control flow migration.");
|
|
25421
25925
|
}
|
|
@@ -25453,18 +25957,10 @@ function runControlFlowMigration(tree, tsconfigPath, basePath, pathToMigrate, sc
|
|
|
25453
25957
|
const relativePath = (0, import_path3.relative)(basePath, path2);
|
|
25454
25958
|
const content = tree.readText(relativePath);
|
|
25455
25959
|
const update = tree.beginUpdate(relativePath);
|
|
25456
|
-
for (const
|
|
25960
|
+
for (const { start, end, node, type } of ranges) {
|
|
25457
25961
|
const template2 = content.slice(start, end);
|
|
25458
25962
|
const length = (end != null ? end : content.length) - start;
|
|
25459
|
-
const
|
|
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);
|
|
25963
|
+
const { migrated, errors } = migrateTemplate(template2, type, node, file, schematicOptions.format);
|
|
25468
25964
|
if (migrated !== null) {
|
|
25469
25965
|
update.remove(start, length);
|
|
25470
25966
|
update.insertLeft(start, migrated);
|