@angular/core 17.0.5 → 17.0.7
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/primitives/signals/src/signal.mjs +2 -9
- package/esm2022/src/application/application_config.mjs +21 -0
- package/esm2022/src/application/application_init.mjs +188 -0
- package/esm2022/src/application/application_module.mjs +29 -0
- package/esm2022/src/application/application_ref.mjs +509 -0
- package/esm2022/src/application/application_tokens.mjs +121 -0
- package/esm2022/src/application/create_application.mjs +102 -0
- package/esm2022/src/change_detection/scheduling.mjs +103 -0
- package/esm2022/src/core.mjs +10 -7
- package/esm2022/src/core_private_export.mjs +5 -3
- package/esm2022/src/core_reactivity_export_internal.mjs +2 -2
- package/esm2022/src/core_render3_private_export.mjs +2 -2
- package/esm2022/src/error_handler.mjs +15 -1
- package/esm2022/src/hydration/annotate.mjs +30 -20
- package/esm2022/src/hydration/api.mjs +2 -2
- package/esm2022/src/hydration/cleanup.mjs +1 -1
- package/esm2022/src/hydration/interfaces.mjs +1 -1
- package/esm2022/src/hydration/node_lookup_utils.mjs +23 -2
- package/esm2022/src/image_performance_warning.mjs +2 -2
- package/esm2022/src/linker/query_list.mjs +8 -6
- package/esm2022/src/metadata/do_bootstrap.mjs +1 -1
- package/esm2022/src/platform/platform.mjs +135 -0
- package/esm2022/src/platform/platform_core_providers.mjs +15 -0
- package/esm2022/src/platform/platform_ref.mjs +179 -0
- package/esm2022/src/render3/instructions/change_detection.mjs +2 -4
- package/esm2022/src/render3/list_reconciliation.mjs +58 -24
- package/esm2022/src/render3/node_manipulation.mjs +2 -2
- package/esm2022/src/render3/util/change_detection_utils.mjs +3 -1
- package/esm2022/src/render3/util/misc_utils.mjs +2 -2
- package/esm2022/src/render3/view_manipulation.mjs +13 -5
- package/esm2022/src/render3/view_ref.mjs +7 -1
- package/esm2022/src/transfer_state.mjs +2 -2
- package/esm2022/src/util/performance.mjs +2 -2
- package/esm2022/src/version.mjs +1 -1
- package/esm2022/src/zone/ng_zone.mjs +10 -1
- package/esm2022/testing/src/component_fixture.mjs +20 -36
- package/esm2022/testing/src/logger.mjs +3 -3
- package/esm2022/testing/src/test_bed.mjs +5 -6
- package/fesm2022/core.mjs +1263 -1191
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/primitives/signals.mjs +2 -9
- package/fesm2022/primitives/signals.mjs.map +1 -1
- package/fesm2022/rxjs-interop.mjs +1 -1
- package/fesm2022/testing.mjs +46 -64
- package/fesm2022/testing.mjs.map +1 -1
- package/index.d.ts +18 -14
- 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 +958 -457
- package/schematics/migrations/block-template-entities/bundle.js.map +4 -4
- package/schematics/ng-generate/control-flow-migration/bundle.js +1221 -525
- package/schematics/ng-generate/control-flow-migration/bundle.js.map +4 -4
- package/schematics/ng-generate/standalone-migration/bundle.js +1143 -509
- package/schematics/ng-generate/standalone-migration/bundle.js.map +4 -4
- package/testing/index.d.ts +6 -10
- package/esm2022/src/application_config.mjs +0 -21
- package/esm2022/src/application_init.mjs +0 -188
- package/esm2022/src/application_module.mjs +0 -29
- package/esm2022/src/application_ref.mjs +0 -997
- package/esm2022/src/application_tokens.mjs +0 -121
- package/esm2022/src/platform_core_providers.mjs +0 -15
|
@@ -3430,6 +3430,39 @@ function getInjectFn(target) {
|
|
|
3430
3430
|
}
|
|
3431
3431
|
}
|
|
3432
3432
|
|
|
3433
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/ml_parser/tags.mjs
|
|
3434
|
+
var TagContentType;
|
|
3435
|
+
(function(TagContentType2) {
|
|
3436
|
+
TagContentType2[TagContentType2["RAW_TEXT"] = 0] = "RAW_TEXT";
|
|
3437
|
+
TagContentType2[TagContentType2["ESCAPABLE_RAW_TEXT"] = 1] = "ESCAPABLE_RAW_TEXT";
|
|
3438
|
+
TagContentType2[TagContentType2["PARSABLE_DATA"] = 2] = "PARSABLE_DATA";
|
|
3439
|
+
})(TagContentType || (TagContentType = {}));
|
|
3440
|
+
function splitNsName(elementName) {
|
|
3441
|
+
if (elementName[0] != ":") {
|
|
3442
|
+
return [null, elementName];
|
|
3443
|
+
}
|
|
3444
|
+
const colonIndex = elementName.indexOf(":", 1);
|
|
3445
|
+
if (colonIndex === -1) {
|
|
3446
|
+
throw new Error(`Unsupported format "${elementName}" expecting ":namespace:name"`);
|
|
3447
|
+
}
|
|
3448
|
+
return [elementName.slice(1, colonIndex), elementName.slice(colonIndex + 1)];
|
|
3449
|
+
}
|
|
3450
|
+
function isNgContainer(tagName) {
|
|
3451
|
+
return splitNsName(tagName)[1] === "ng-container";
|
|
3452
|
+
}
|
|
3453
|
+
function isNgContent(tagName) {
|
|
3454
|
+
return splitNsName(tagName)[1] === "ng-content";
|
|
3455
|
+
}
|
|
3456
|
+
function isNgTemplate(tagName) {
|
|
3457
|
+
return splitNsName(tagName)[1] === "ng-template";
|
|
3458
|
+
}
|
|
3459
|
+
function getNsPrefix(fullName) {
|
|
3460
|
+
return fullName === null ? null : splitNsName(fullName)[0];
|
|
3461
|
+
}
|
|
3462
|
+
function mergeNsAndName(prefix, localName) {
|
|
3463
|
+
return prefix ? `:${prefix}:${localName}` : localName;
|
|
3464
|
+
}
|
|
3465
|
+
|
|
3433
3466
|
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/render3/r3_ast.mjs
|
|
3434
3467
|
var Comment = class {
|
|
3435
3468
|
constructor(value, sourceSpan) {
|
|
@@ -4273,6 +4306,23 @@ var DefinitionMap = class {
|
|
|
4273
4306
|
return literalMap(this.values);
|
|
4274
4307
|
}
|
|
4275
4308
|
};
|
|
4309
|
+
function createCssSelectorFromNode(node) {
|
|
4310
|
+
const elementName = node instanceof Element ? node.name : "ng-template";
|
|
4311
|
+
const attributes = getAttrsForDirectiveMatching(node);
|
|
4312
|
+
const cssSelector = new CssSelector();
|
|
4313
|
+
const elementNameNoNs = splitNsName(elementName)[1];
|
|
4314
|
+
cssSelector.setElement(elementNameNoNs);
|
|
4315
|
+
Object.getOwnPropertyNames(attributes).forEach((name) => {
|
|
4316
|
+
const nameNoNs = splitNsName(name)[1];
|
|
4317
|
+
const value = attributes[name];
|
|
4318
|
+
cssSelector.addAttribute(nameNoNs, value);
|
|
4319
|
+
if (name.toLowerCase() === "class") {
|
|
4320
|
+
const classes = value.trim().split(/\s+/);
|
|
4321
|
+
classes.forEach((className) => cssSelector.addClassName(className));
|
|
4322
|
+
}
|
|
4323
|
+
});
|
|
4324
|
+
return cssSelector;
|
|
4325
|
+
}
|
|
4276
4326
|
function getAttrsForDirectiveMatching(elOrTpl) {
|
|
4277
4327
|
const attributesMap = {};
|
|
4278
4328
|
if (elOrTpl instanceof Template && elOrTpl.tagName !== "ng-template") {
|
|
@@ -6990,6 +7040,7 @@ var OpKind;
|
|
|
6990
7040
|
OpKind2[OpKind2["IcuStart"] = 41] = "IcuStart";
|
|
6991
7041
|
OpKind2[OpKind2["IcuEnd"] = 42] = "IcuEnd";
|
|
6992
7042
|
OpKind2[OpKind2["I18nContext"] = 43] = "I18nContext";
|
|
7043
|
+
OpKind2[OpKind2["I18nAttributes"] = 44] = "I18nAttributes";
|
|
6993
7044
|
})(OpKind || (OpKind = {}));
|
|
6994
7045
|
var ExpressionKind;
|
|
6995
7046
|
(function(ExpressionKind2) {
|
|
@@ -7014,10 +7065,11 @@ var ExpressionKind;
|
|
|
7014
7065
|
ExpressionKind2[ExpressionKind2["AssignTemporaryExpr"] = 18] = "AssignTemporaryExpr";
|
|
7015
7066
|
ExpressionKind2[ExpressionKind2["ReadTemporaryExpr"] = 19] = "ReadTemporaryExpr";
|
|
7016
7067
|
ExpressionKind2[ExpressionKind2["SanitizerExpr"] = 20] = "SanitizerExpr";
|
|
7017
|
-
ExpressionKind2[ExpressionKind2["
|
|
7018
|
-
ExpressionKind2[ExpressionKind2["
|
|
7019
|
-
ExpressionKind2[ExpressionKind2["
|
|
7020
|
-
ExpressionKind2[ExpressionKind2["
|
|
7068
|
+
ExpressionKind2[ExpressionKind2["TrustedValueFnExpr"] = 21] = "TrustedValueFnExpr";
|
|
7069
|
+
ExpressionKind2[ExpressionKind2["SlotLiteralExpr"] = 22] = "SlotLiteralExpr";
|
|
7070
|
+
ExpressionKind2[ExpressionKind2["ConditionalCase"] = 23] = "ConditionalCase";
|
|
7071
|
+
ExpressionKind2[ExpressionKind2["DerivedRepeaterVar"] = 24] = "DerivedRepeaterVar";
|
|
7072
|
+
ExpressionKind2[ExpressionKind2["ConstCollected"] = 25] = "ConstCollected";
|
|
7021
7073
|
})(ExpressionKind || (ExpressionKind = {}));
|
|
7022
7074
|
var VariableFlags;
|
|
7023
7075
|
(function(VariableFlags2) {
|
|
@@ -7036,15 +7088,6 @@ var CompatibilityMode;
|
|
|
7036
7088
|
CompatibilityMode2[CompatibilityMode2["Normal"] = 0] = "Normal";
|
|
7037
7089
|
CompatibilityMode2[CompatibilityMode2["TemplateDefinitionBuilder"] = 1] = "TemplateDefinitionBuilder";
|
|
7038
7090
|
})(CompatibilityMode || (CompatibilityMode = {}));
|
|
7039
|
-
var SanitizerFn;
|
|
7040
|
-
(function(SanitizerFn2) {
|
|
7041
|
-
SanitizerFn2[SanitizerFn2["Html"] = 0] = "Html";
|
|
7042
|
-
SanitizerFn2[SanitizerFn2["Script"] = 1] = "Script";
|
|
7043
|
-
SanitizerFn2[SanitizerFn2["Style"] = 2] = "Style";
|
|
7044
|
-
SanitizerFn2[SanitizerFn2["Url"] = 3] = "Url";
|
|
7045
|
-
SanitizerFn2[SanitizerFn2["ResourceUrl"] = 4] = "ResourceUrl";
|
|
7046
|
-
SanitizerFn2[SanitizerFn2["IframeAttribute"] = 5] = "IframeAttribute";
|
|
7047
|
-
})(SanitizerFn || (SanitizerFn = {}));
|
|
7048
7091
|
var DeferSecondaryKind;
|
|
7049
7092
|
(function(DeferSecondaryKind2) {
|
|
7050
7093
|
DeferSecondaryKind2[DeferSecondaryKind2["Loading"] = 0] = "Loading";
|
|
@@ -7066,6 +7109,11 @@ var I18nParamResolutionTime;
|
|
|
7066
7109
|
I18nParamResolutionTime2[I18nParamResolutionTime2["Creation"] = 0] = "Creation";
|
|
7067
7110
|
I18nParamResolutionTime2[I18nParamResolutionTime2["Postproccessing"] = 1] = "Postproccessing";
|
|
7068
7111
|
})(I18nParamResolutionTime || (I18nParamResolutionTime = {}));
|
|
7112
|
+
var I18nExpressionFor;
|
|
7113
|
+
(function(I18nExpressionFor2) {
|
|
7114
|
+
I18nExpressionFor2[I18nExpressionFor2["I18nText"] = 0] = "I18nText";
|
|
7115
|
+
I18nExpressionFor2[I18nExpressionFor2["I18nAttribute"] = 1] = "I18nAttribute";
|
|
7116
|
+
})(I18nExpressionFor || (I18nExpressionFor = {}));
|
|
7069
7117
|
var I18nParamValueFlags;
|
|
7070
7118
|
(function(I18nParamValueFlags2) {
|
|
7071
7119
|
I18nParamValueFlags2[I18nParamValueFlags2["None"] = 0] = "None";
|
|
@@ -7101,7 +7149,14 @@ var I18nContextKind;
|
|
|
7101
7149
|
(function(I18nContextKind2) {
|
|
7102
7150
|
I18nContextKind2[I18nContextKind2["RootI18n"] = 0] = "RootI18n";
|
|
7103
7151
|
I18nContextKind2[I18nContextKind2["Icu"] = 1] = "Icu";
|
|
7152
|
+
I18nContextKind2[I18nContextKind2["Attr"] = 2] = "Attr";
|
|
7104
7153
|
})(I18nContextKind || (I18nContextKind = {}));
|
|
7154
|
+
var TemplateKind;
|
|
7155
|
+
(function(TemplateKind2) {
|
|
7156
|
+
TemplateKind2[TemplateKind2["NgTemplate"] = 0] = "NgTemplate";
|
|
7157
|
+
TemplateKind2[TemplateKind2["Structural"] = 1] = "Structural";
|
|
7158
|
+
TemplateKind2[TemplateKind2["Block"] = 2] = "Block";
|
|
7159
|
+
})(TemplateKind || (TemplateKind = {}));
|
|
7105
7160
|
|
|
7106
7161
|
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/ir/src/traits.mjs
|
|
7107
7162
|
var ConsumesSlot = Symbol("ConsumesSlot");
|
|
@@ -7158,22 +7213,25 @@ var NEW_OP = {
|
|
|
7158
7213
|
};
|
|
7159
7214
|
|
|
7160
7215
|
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/ir/src/ops/update.mjs
|
|
7161
|
-
function createInterpolateTextOp(xref, interpolation,
|
|
7216
|
+
function createInterpolateTextOp(xref, interpolation, sourceSpan) {
|
|
7162
7217
|
return __spreadValues(__spreadValues(__spreadValues({
|
|
7163
7218
|
kind: OpKind.InterpolateText,
|
|
7164
7219
|
target: xref,
|
|
7165
7220
|
interpolation,
|
|
7166
|
-
i18nPlaceholders,
|
|
7167
7221
|
sourceSpan
|
|
7168
7222
|
}, TRAIT_DEPENDS_ON_SLOT_CONTEXT), TRAIT_CONSUMES_VARS), NEW_OP);
|
|
7169
7223
|
}
|
|
7170
7224
|
var Interpolation2 = class {
|
|
7171
|
-
constructor(strings, expressions) {
|
|
7225
|
+
constructor(strings, expressions, i18nPlaceholders) {
|
|
7172
7226
|
this.strings = strings;
|
|
7173
7227
|
this.expressions = expressions;
|
|
7228
|
+
this.i18nPlaceholders = i18nPlaceholders;
|
|
7229
|
+
if (i18nPlaceholders.length !== 0 && i18nPlaceholders.length !== expressions.length) {
|
|
7230
|
+
throw new Error(`Expected ${expressions.length} placeholders to match interpolation expression count, but got ${i18nPlaceholders.length}`);
|
|
7231
|
+
}
|
|
7174
7232
|
}
|
|
7175
7233
|
};
|
|
7176
|
-
function createBindingOp(target, kind, name, expression, unit, securityContext, isTextAttribute,
|
|
7234
|
+
function createBindingOp(target, kind, name, expression, unit, securityContext, isTextAttribute, isStructuralTemplateAttribute, templateKind, i18nMessage, sourceSpan) {
|
|
7177
7235
|
return __spreadValues({
|
|
7178
7236
|
kind: OpKind.Binding,
|
|
7179
7237
|
bindingKind: kind,
|
|
@@ -7183,11 +7241,14 @@ function createBindingOp(target, kind, name, expression, unit, securityContext,
|
|
|
7183
7241
|
unit,
|
|
7184
7242
|
securityContext,
|
|
7185
7243
|
isTextAttribute,
|
|
7186
|
-
|
|
7244
|
+
isStructuralTemplateAttribute,
|
|
7245
|
+
templateKind,
|
|
7246
|
+
i18nContext: null,
|
|
7247
|
+
i18nMessage,
|
|
7187
7248
|
sourceSpan
|
|
7188
7249
|
}, NEW_OP);
|
|
7189
7250
|
}
|
|
7190
|
-
function createPropertyOp(target, name, expression, isAnimationTrigger, securityContext,
|
|
7251
|
+
function createPropertyOp(target, name, expression, isAnimationTrigger, securityContext, isStructuralTemplateAttribute, templateKind, i18nContext, i18nMessage, sourceSpan) {
|
|
7191
7252
|
return __spreadValues(__spreadValues(__spreadValues({
|
|
7192
7253
|
kind: OpKind.Property,
|
|
7193
7254
|
target,
|
|
@@ -7196,7 +7257,10 @@ function createPropertyOp(target, name, expression, isAnimationTrigger, security
|
|
|
7196
7257
|
isAnimationTrigger,
|
|
7197
7258
|
securityContext,
|
|
7198
7259
|
sanitizer: null,
|
|
7199
|
-
|
|
7260
|
+
isStructuralTemplateAttribute,
|
|
7261
|
+
templateKind,
|
|
7262
|
+
i18nContext,
|
|
7263
|
+
i18nMessage,
|
|
7200
7264
|
sourceSpan
|
|
7201
7265
|
}, TRAIT_DEPENDS_ON_SLOT_CONTEXT), TRAIT_CONSUMES_VARS), NEW_OP);
|
|
7202
7266
|
}
|
|
@@ -7235,7 +7299,7 @@ function createClassMapOp(xref, expression, sourceSpan) {
|
|
|
7235
7299
|
sourceSpan
|
|
7236
7300
|
}, TRAIT_DEPENDS_ON_SLOT_CONTEXT), TRAIT_CONSUMES_VARS), NEW_OP);
|
|
7237
7301
|
}
|
|
7238
|
-
function createAttributeOp(target, name, expression, securityContext, isTextAttribute,
|
|
7302
|
+
function createAttributeOp(target, name, expression, securityContext, isTextAttribute, isStructuralTemplateAttribute, templateKind, i18nMessage, sourceSpan) {
|
|
7239
7303
|
return __spreadValues(__spreadValues(__spreadValues({
|
|
7240
7304
|
kind: OpKind.Attribute,
|
|
7241
7305
|
target,
|
|
@@ -7244,7 +7308,10 @@ function createAttributeOp(target, name, expression, securityContext, isTextAttr
|
|
|
7244
7308
|
securityContext,
|
|
7245
7309
|
sanitizer: null,
|
|
7246
7310
|
isTextAttribute,
|
|
7247
|
-
|
|
7311
|
+
isStructuralTemplateAttribute,
|
|
7312
|
+
templateKind,
|
|
7313
|
+
i18nContext: null,
|
|
7314
|
+
i18nMessage,
|
|
7248
7315
|
sourceSpan
|
|
7249
7316
|
}, TRAIT_DEPENDS_ON_SLOT_CONTEXT), TRAIT_CONSUMES_VARS), NEW_OP);
|
|
7250
7317
|
}
|
|
@@ -7285,22 +7352,25 @@ function createDeferWhenOp(target, expr, prefetch, sourceSpan) {
|
|
|
7285
7352
|
sourceSpan
|
|
7286
7353
|
}, NEW_OP), TRAIT_DEPENDS_ON_SLOT_CONTEXT);
|
|
7287
7354
|
}
|
|
7288
|
-
function createI18nExpressionOp(context, target, handle, expression, i18nPlaceholder, resolutionTime, sourceSpan) {
|
|
7355
|
+
function createI18nExpressionOp(context, target, i18nOwner, handle, expression, i18nPlaceholder, resolutionTime, usage, name, sourceSpan) {
|
|
7289
7356
|
return __spreadValues(__spreadValues(__spreadValues({
|
|
7290
7357
|
kind: OpKind.I18nExpression,
|
|
7291
7358
|
context,
|
|
7292
7359
|
target,
|
|
7360
|
+
i18nOwner,
|
|
7293
7361
|
handle,
|
|
7294
7362
|
expression,
|
|
7295
7363
|
i18nPlaceholder,
|
|
7296
7364
|
resolutionTime,
|
|
7365
|
+
usage,
|
|
7366
|
+
name,
|
|
7297
7367
|
sourceSpan
|
|
7298
7368
|
}, NEW_OP), TRAIT_CONSUMES_VARS), TRAIT_DEPENDS_ON_SLOT_CONTEXT);
|
|
7299
7369
|
}
|
|
7300
|
-
function createI18nApplyOp(
|
|
7370
|
+
function createI18nApplyOp(owner, handle, sourceSpan) {
|
|
7301
7371
|
return __spreadValues({
|
|
7302
7372
|
kind: OpKind.I18nApply,
|
|
7303
|
-
|
|
7373
|
+
owner,
|
|
7304
7374
|
handle,
|
|
7305
7375
|
sourceSpan
|
|
7306
7376
|
}, NEW_OP);
|
|
@@ -7837,26 +7907,6 @@ var ReadTemporaryExpr = class extends ExpressionBase {
|
|
|
7837
7907
|
return r;
|
|
7838
7908
|
}
|
|
7839
7909
|
};
|
|
7840
|
-
var SanitizerExpr = class extends ExpressionBase {
|
|
7841
|
-
constructor(fn2) {
|
|
7842
|
-
super();
|
|
7843
|
-
this.fn = fn2;
|
|
7844
|
-
this.kind = ExpressionKind.SanitizerExpr;
|
|
7845
|
-
}
|
|
7846
|
-
visitExpression(visitor, context) {
|
|
7847
|
-
}
|
|
7848
|
-
isEquivalent(e) {
|
|
7849
|
-
return e instanceof SanitizerExpr && e.fn === this.fn;
|
|
7850
|
-
}
|
|
7851
|
-
isConstant() {
|
|
7852
|
-
return true;
|
|
7853
|
-
}
|
|
7854
|
-
clone() {
|
|
7855
|
-
return new SanitizerExpr(this.fn);
|
|
7856
|
-
}
|
|
7857
|
-
transformInternalExpressions() {
|
|
7858
|
-
}
|
|
7859
|
-
};
|
|
7860
7910
|
var SlotLiteralExpr = class extends ExpressionBase {
|
|
7861
7911
|
constructor(slot) {
|
|
7862
7912
|
super();
|
|
@@ -7975,7 +8025,6 @@ function transformExpressionsInOp(op, transform2, flags) {
|
|
|
7975
8025
|
case OpKind.ClassProp:
|
|
7976
8026
|
case OpKind.ClassMap:
|
|
7977
8027
|
case OpKind.Binding:
|
|
7978
|
-
case OpKind.HostProperty:
|
|
7979
8028
|
if (op.expression instanceof Interpolation2) {
|
|
7980
8029
|
transformExpressionsInInterpolation(op.expression, transform2, flags);
|
|
7981
8030
|
} else {
|
|
@@ -7983,6 +8032,7 @@ function transformExpressionsInOp(op, transform2, flags) {
|
|
|
7983
8032
|
}
|
|
7984
8033
|
break;
|
|
7985
8034
|
case OpKind.Property:
|
|
8035
|
+
case OpKind.HostProperty:
|
|
7986
8036
|
case OpKind.Attribute:
|
|
7987
8037
|
if (op.expression instanceof Interpolation2) {
|
|
7988
8038
|
transformExpressionsInInterpolation(op.expression, transform2, flags);
|
|
@@ -8024,6 +8074,7 @@ function transformExpressionsInOp(op, transform2, flags) {
|
|
|
8024
8074
|
break;
|
|
8025
8075
|
case OpKind.ExtractedAttribute:
|
|
8026
8076
|
op.expression = op.expression && transformExpressionsInExpression(op.expression, transform2, flags);
|
|
8077
|
+
op.trustedValueFn = op.trustedValueFn && transformExpressionsInExpression(op.trustedValueFn, transform2, flags);
|
|
8027
8078
|
break;
|
|
8028
8079
|
case OpKind.RepeaterCreate:
|
|
8029
8080
|
op.track = transformExpressionsInExpression(op.track, transform2, flags);
|
|
@@ -8076,6 +8127,7 @@ function transformExpressionsInOp(op, transform2, flags) {
|
|
|
8076
8127
|
case OpKind.ProjectionDef:
|
|
8077
8128
|
case OpKind.Template:
|
|
8078
8129
|
case OpKind.Text:
|
|
8130
|
+
case OpKind.I18nAttributes:
|
|
8079
8131
|
break;
|
|
8080
8132
|
default:
|
|
8081
8133
|
throw new Error(`AssertionError: transformExpressionsInOp doesn't handle ${OpKind[op.kind]}`);
|
|
@@ -8087,6 +8139,8 @@ function transformExpressionsInExpression(expr, transform2, flags) {
|
|
|
8087
8139
|
} else if (expr instanceof BinaryOperatorExpr) {
|
|
8088
8140
|
expr.lhs = transformExpressionsInExpression(expr.lhs, transform2, flags);
|
|
8089
8141
|
expr.rhs = transformExpressionsInExpression(expr.rhs, transform2, flags);
|
|
8142
|
+
} else if (expr instanceof UnaryOperatorExpr) {
|
|
8143
|
+
expr.expr = transformExpressionsInExpression(expr.expr, transform2, flags);
|
|
8090
8144
|
} else if (expr instanceof ReadPropExpr) {
|
|
8091
8145
|
expr.receiver = transformExpressionsInExpression(expr.receiver, transform2, flags);
|
|
8092
8146
|
} else if (expr instanceof ReadKeyExpr) {
|
|
@@ -8126,6 +8180,12 @@ function transformExpressionsInExpression(expr, transform2, flags) {
|
|
|
8126
8180
|
for (let i = 0; i < expr.expressions.length; i++) {
|
|
8127
8181
|
expr.expressions[i] = transformExpressionsInExpression(expr.expressions[i], transform2, flags);
|
|
8128
8182
|
}
|
|
8183
|
+
} else if (expr instanceof NotExpr) {
|
|
8184
|
+
expr.condition = transformExpressionsInExpression(expr.condition, transform2, flags);
|
|
8185
|
+
} else if (expr instanceof TaggedTemplateExpr) {
|
|
8186
|
+
expr.tag = transformExpressionsInExpression(expr.tag, transform2, flags);
|
|
8187
|
+
expr.template.expressions = expr.template.expressions.map((e) => transformExpressionsInExpression(e, transform2, flags));
|
|
8188
|
+
} else if (expr instanceof WrappedNodeExpr) {
|
|
8129
8189
|
} else if (expr instanceof ReadVarExpr || expr instanceof ExternalExpr || expr instanceof LiteralExpr) {
|
|
8130
8190
|
} else {
|
|
8131
8191
|
throw new Error(`Unhandled expression kind: ${expr.constructor.name}`);
|
|
@@ -8381,10 +8441,11 @@ function createElementStartOp(tag, xref, namespace, i18nPlaceholder, sourceSpan)
|
|
|
8381
8441
|
sourceSpan
|
|
8382
8442
|
}, TRAIT_CONSUMES_SLOT), NEW_OP);
|
|
8383
8443
|
}
|
|
8384
|
-
function createTemplateOp(xref, tag, functionNameSuffix, namespace, i18nPlaceholder, sourceSpan) {
|
|
8444
|
+
function createTemplateOp(xref, templateKind, tag, functionNameSuffix, namespace, i18nPlaceholder, sourceSpan) {
|
|
8385
8445
|
return __spreadValues(__spreadValues({
|
|
8386
8446
|
kind: OpKind.Template,
|
|
8387
8447
|
xref,
|
|
8448
|
+
templateKind,
|
|
8388
8449
|
attributes: null,
|
|
8389
8450
|
tag,
|
|
8390
8451
|
handle: new SlotHandle(),
|
|
@@ -8398,7 +8459,7 @@ function createTemplateOp(xref, tag, functionNameSuffix, namespace, i18nPlacehol
|
|
|
8398
8459
|
sourceSpan
|
|
8399
8460
|
}, TRAIT_CONSUMES_SLOT), NEW_OP);
|
|
8400
8461
|
}
|
|
8401
|
-
function createRepeaterCreateOp(primaryView, emptyView, tag, track, varNames, sourceSpan) {
|
|
8462
|
+
function createRepeaterCreateOp(primaryView, emptyView, tag, track, varNames, i18nPlaceholder, emptyI18nPlaceholder, sourceSpan) {
|
|
8402
8463
|
return __spreadProps(__spreadValues(__spreadValues({
|
|
8403
8464
|
kind: OpKind.RepeaterCreate,
|
|
8404
8465
|
attributes: null,
|
|
@@ -8416,6 +8477,8 @@ function createRepeaterCreateOp(primaryView, emptyView, tag, track, varNames, so
|
|
|
8416
8477
|
vars: null,
|
|
8417
8478
|
varNames,
|
|
8418
8479
|
usesComponentInstance: false,
|
|
8480
|
+
i18nPlaceholder,
|
|
8481
|
+
emptyI18nPlaceholder,
|
|
8419
8482
|
sourceSpan
|
|
8420
8483
|
}, TRAIT_CONSUMES_SLOT), NEW_OP), {
|
|
8421
8484
|
numSlotsUsed: emptyView === null ? 2 : 3
|
|
@@ -8449,7 +8512,9 @@ function createTextOp(xref, initialValue, sourceSpan) {
|
|
|
8449
8512
|
sourceSpan
|
|
8450
8513
|
}, TRAIT_CONSUMES_SLOT), NEW_OP);
|
|
8451
8514
|
}
|
|
8452
|
-
function createListenerOp(target, targetSlot, name, tag, animationPhase, hostListener, sourceSpan) {
|
|
8515
|
+
function createListenerOp(target, targetSlot, name, tag, handlerOps, animationPhase, eventTarget, hostListener, sourceSpan) {
|
|
8516
|
+
const handlerList = new OpList();
|
|
8517
|
+
handlerList.push(handlerOps);
|
|
8453
8518
|
return __spreadValues({
|
|
8454
8519
|
kind: OpKind.Listener,
|
|
8455
8520
|
target,
|
|
@@ -8457,11 +8522,12 @@ function createListenerOp(target, targetSlot, name, tag, animationPhase, hostLis
|
|
|
8457
8522
|
tag,
|
|
8458
8523
|
hostListener,
|
|
8459
8524
|
name,
|
|
8460
|
-
handlerOps:
|
|
8525
|
+
handlerOps: handlerList,
|
|
8461
8526
|
handlerFnName: null,
|
|
8462
8527
|
consumesDollarEvent: false,
|
|
8463
8528
|
isAnimationListener: animationPhase !== null,
|
|
8464
8529
|
animationPhase,
|
|
8530
|
+
eventTarget,
|
|
8465
8531
|
sourceSpan
|
|
8466
8532
|
}, NEW_OP);
|
|
8467
8533
|
}
|
|
@@ -8485,25 +8551,30 @@ function createProjectionDefOp(def) {
|
|
|
8485
8551
|
def
|
|
8486
8552
|
}, NEW_OP);
|
|
8487
8553
|
}
|
|
8488
|
-
function createProjectionOp(xref, selector, sourceSpan) {
|
|
8554
|
+
function createProjectionOp(xref, selector, i18nPlaceholder, attributes, sourceSpan) {
|
|
8489
8555
|
return __spreadValues(__spreadValues({
|
|
8490
8556
|
kind: OpKind.Projection,
|
|
8491
8557
|
xref,
|
|
8492
8558
|
handle: new SlotHandle(),
|
|
8493
8559
|
selector,
|
|
8560
|
+
i18nPlaceholder,
|
|
8494
8561
|
projectionSlotIndex: 0,
|
|
8495
|
-
attributes
|
|
8562
|
+
attributes,
|
|
8496
8563
|
localRefs: [],
|
|
8497
8564
|
sourceSpan
|
|
8498
8565
|
}, NEW_OP), TRAIT_CONSUMES_SLOT);
|
|
8499
8566
|
}
|
|
8500
|
-
function createExtractedAttributeOp(target, bindingKind, name, expression) {
|
|
8567
|
+
function createExtractedAttributeOp(target, bindingKind, name, expression, i18nContext, i18nMessage, securityContext) {
|
|
8501
8568
|
return __spreadValues({
|
|
8502
8569
|
kind: OpKind.ExtractedAttribute,
|
|
8503
8570
|
target,
|
|
8504
8571
|
bindingKind,
|
|
8505
8572
|
name,
|
|
8506
|
-
expression
|
|
8573
|
+
expression,
|
|
8574
|
+
i18nContext,
|
|
8575
|
+
i18nMessage,
|
|
8576
|
+
securityContext,
|
|
8577
|
+
trustedValueFn: null
|
|
8507
8578
|
}, NEW_OP);
|
|
8508
8579
|
}
|
|
8509
8580
|
function createDeferOp(xref, main, mainSlot, metadata, sourceSpan) {
|
|
@@ -8540,10 +8611,11 @@ function createDeferOnOp(defer2, trigger, prefetch, sourceSpan) {
|
|
|
8540
8611
|
sourceSpan
|
|
8541
8612
|
}, NEW_OP);
|
|
8542
8613
|
}
|
|
8543
|
-
function createI18nMessageOp(xref, i18nBlock, message, messagePlaceholder, params, postprocessingParams, needsPostprocessing) {
|
|
8614
|
+
function createI18nMessageOp(xref, i18nContext, i18nBlock, message, messagePlaceholder, params, postprocessingParams, needsPostprocessing) {
|
|
8544
8615
|
return __spreadValues({
|
|
8545
8616
|
kind: OpKind.I18nMessage,
|
|
8546
8617
|
xref,
|
|
8618
|
+
i18nContext,
|
|
8547
8619
|
i18nBlock,
|
|
8548
8620
|
message,
|
|
8549
8621
|
messagePlaceholder,
|
|
@@ -8588,6 +8660,9 @@ function createIcuEndOp(xref) {
|
|
|
8588
8660
|
}, NEW_OP);
|
|
8589
8661
|
}
|
|
8590
8662
|
function createI18nContextOp(contextKind, xref, i18nBlock, message, sourceSpan) {
|
|
8663
|
+
if (i18nBlock === null && contextKind !== I18nContextKind.Attr) {
|
|
8664
|
+
throw new Error("AssertionError: i18nBlock must be provided for non-attribute contexts.");
|
|
8665
|
+
}
|
|
8591
8666
|
return __spreadValues({
|
|
8592
8667
|
kind: OpKind.I18nContext,
|
|
8593
8668
|
contextKind,
|
|
@@ -8599,14 +8674,26 @@ function createI18nContextOp(contextKind, xref, i18nBlock, message, sourceSpan)
|
|
|
8599
8674
|
postprocessingParams: /* @__PURE__ */ new Map()
|
|
8600
8675
|
}, NEW_OP);
|
|
8601
8676
|
}
|
|
8677
|
+
function createI18nAttributesOp(xref, handle, target) {
|
|
8678
|
+
return __spreadValues(__spreadValues({
|
|
8679
|
+
kind: OpKind.I18nAttributes,
|
|
8680
|
+
xref,
|
|
8681
|
+
handle,
|
|
8682
|
+
target,
|
|
8683
|
+
i18nAttributesConfig: null
|
|
8684
|
+
}, NEW_OP), TRAIT_CONSUMES_SLOT);
|
|
8685
|
+
}
|
|
8602
8686
|
|
|
8603
8687
|
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/ir/src/ops/host.mjs
|
|
8604
|
-
function createHostPropertyOp(name, expression, isAnimationTrigger, sourceSpan) {
|
|
8688
|
+
function createHostPropertyOp(name, expression, isAnimationTrigger, i18nContext, securityContext, sourceSpan) {
|
|
8605
8689
|
return __spreadValues(__spreadValues({
|
|
8606
8690
|
kind: OpKind.HostProperty,
|
|
8607
8691
|
name,
|
|
8608
8692
|
expression,
|
|
8609
8693
|
isAnimationTrigger,
|
|
8694
|
+
i18nContext,
|
|
8695
|
+
securityContext,
|
|
8696
|
+
sanitizer: null,
|
|
8610
8697
|
sourceSpan
|
|
8611
8698
|
}, TRAIT_CONSUMES_VARS), NEW_OP);
|
|
8612
8699
|
}
|
|
@@ -8752,7 +8839,7 @@ function applyI18nExpressions(job) {
|
|
|
8752
8839
|
for (const unit of job.units) {
|
|
8753
8840
|
for (const op of unit.update) {
|
|
8754
8841
|
if (op.kind === OpKind.I18nExpression && needsApplication(i18nContexts, op)) {
|
|
8755
|
-
OpList.insertAfter(createI18nApplyOp(op.
|
|
8842
|
+
OpList.insertAfter(createI18nApplyOp(op.i18nOwner, op.handle, null), op);
|
|
8756
8843
|
}
|
|
8757
8844
|
}
|
|
8758
8845
|
}
|
|
@@ -8764,7 +8851,19 @@ function needsApplication(i18nContexts, op) {
|
|
|
8764
8851
|
}
|
|
8765
8852
|
const context = i18nContexts.get(op.context);
|
|
8766
8853
|
const nextContext2 = i18nContexts.get(op.next.context);
|
|
8767
|
-
if (context
|
|
8854
|
+
if (context === void 0) {
|
|
8855
|
+
throw new Error("AssertionError: expected an I18nContextOp to exist for the I18nExpressionOp's context");
|
|
8856
|
+
}
|
|
8857
|
+
if (nextContext2 === void 0) {
|
|
8858
|
+
throw new Error("AssertionError: expected an I18nContextOp to exist for the next I18nExpressionOp's context");
|
|
8859
|
+
}
|
|
8860
|
+
if (context.i18nBlock !== null) {
|
|
8861
|
+
if (context.i18nBlock !== nextContext2.i18nBlock) {
|
|
8862
|
+
return true;
|
|
8863
|
+
}
|
|
8864
|
+
return false;
|
|
8865
|
+
}
|
|
8866
|
+
if (op.i18nOwner !== op.next.i18nOwner) {
|
|
8768
8867
|
return true;
|
|
8769
8868
|
}
|
|
8770
8869
|
return false;
|
|
@@ -8772,27 +8871,44 @@ function needsApplication(i18nContexts, op) {
|
|
|
8772
8871
|
|
|
8773
8872
|
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/assign_i18n_slot_dependencies.mjs
|
|
8774
8873
|
function assignI18nSlotDependencies(job) {
|
|
8775
|
-
const i18nLastSlotConsumers = /* @__PURE__ */ new Map();
|
|
8776
|
-
let lastSlotConsumer = null;
|
|
8777
|
-
let currentI18nOp = null;
|
|
8778
8874
|
for (const unit of job.units) {
|
|
8779
|
-
|
|
8780
|
-
|
|
8781
|
-
|
|
8782
|
-
|
|
8783
|
-
|
|
8784
|
-
|
|
8785
|
-
|
|
8786
|
-
|
|
8787
|
-
|
|
8788
|
-
|
|
8789
|
-
|
|
8790
|
-
|
|
8875
|
+
let updateOp = unit.update.head;
|
|
8876
|
+
let i18nExpressionsInProgress = [];
|
|
8877
|
+
let state = null;
|
|
8878
|
+
for (const createOp of unit.create) {
|
|
8879
|
+
if (createOp.kind === OpKind.I18nStart) {
|
|
8880
|
+
state = {
|
|
8881
|
+
blockXref: createOp.xref,
|
|
8882
|
+
lastSlotConsumer: createOp.xref
|
|
8883
|
+
};
|
|
8884
|
+
} else if (createOp.kind === OpKind.I18nEnd) {
|
|
8885
|
+
for (const op of i18nExpressionsInProgress) {
|
|
8886
|
+
op.target = state.lastSlotConsumer;
|
|
8887
|
+
OpList.insertBefore(op, updateOp);
|
|
8888
|
+
}
|
|
8889
|
+
i18nExpressionsInProgress.length = 0;
|
|
8890
|
+
state = null;
|
|
8791
8891
|
}
|
|
8792
|
-
|
|
8793
|
-
|
|
8794
|
-
|
|
8795
|
-
|
|
8892
|
+
if (hasConsumesSlotTrait(createOp)) {
|
|
8893
|
+
if (state !== null) {
|
|
8894
|
+
state.lastSlotConsumer = createOp.xref;
|
|
8895
|
+
}
|
|
8896
|
+
while (true) {
|
|
8897
|
+
if (updateOp.next === null) {
|
|
8898
|
+
break;
|
|
8899
|
+
}
|
|
8900
|
+
if (state !== null && updateOp.kind === OpKind.I18nExpression && updateOp.usage === I18nExpressionFor.I18nText && updateOp.i18nOwner === state.blockXref) {
|
|
8901
|
+
const opToRemove = updateOp;
|
|
8902
|
+
updateOp = updateOp.next;
|
|
8903
|
+
OpList.remove(opToRemove);
|
|
8904
|
+
i18nExpressionsInProgress.push(opToRemove);
|
|
8905
|
+
continue;
|
|
8906
|
+
}
|
|
8907
|
+
if (hasDependsOnSlotContextTrait(updateOp) && updateOp.target !== createOp.xref) {
|
|
8908
|
+
break;
|
|
8909
|
+
}
|
|
8910
|
+
updateOp = updateOp.next;
|
|
8911
|
+
}
|
|
8796
8912
|
}
|
|
8797
8913
|
}
|
|
8798
8914
|
}
|
|
@@ -8821,18 +8937,53 @@ function extractAttributes(job) {
|
|
|
8821
8937
|
break;
|
|
8822
8938
|
case OpKind.Property:
|
|
8823
8939
|
if (!op.isAnimationTrigger) {
|
|
8824
|
-
|
|
8940
|
+
let bindingKind;
|
|
8941
|
+
if (op.i18nMessage !== null && op.templateKind === null) {
|
|
8942
|
+
bindingKind = BindingKind.I18n;
|
|
8943
|
+
} else if (op.isStructuralTemplateAttribute) {
|
|
8944
|
+
bindingKind = BindingKind.Template;
|
|
8945
|
+
} else {
|
|
8946
|
+
bindingKind = BindingKind.Property;
|
|
8947
|
+
}
|
|
8948
|
+
OpList.insertBefore(
|
|
8949
|
+
createExtractedAttributeOp(
|
|
8950
|
+
op.target,
|
|
8951
|
+
bindingKind,
|
|
8952
|
+
op.name,
|
|
8953
|
+
null,
|
|
8954
|
+
null,
|
|
8955
|
+
null,
|
|
8956
|
+
op.securityContext
|
|
8957
|
+
),
|
|
8958
|
+
lookupElement(elements, op.target)
|
|
8959
|
+
);
|
|
8825
8960
|
}
|
|
8826
8961
|
break;
|
|
8827
8962
|
case OpKind.StyleProp:
|
|
8828
8963
|
case OpKind.ClassProp:
|
|
8829
8964
|
if (unit.job.compatibility === CompatibilityMode.TemplateDefinitionBuilder && op.expression instanceof EmptyExpr2) {
|
|
8830
|
-
OpList.insertBefore(createExtractedAttributeOp(
|
|
8965
|
+
OpList.insertBefore(createExtractedAttributeOp(
|
|
8966
|
+
op.target,
|
|
8967
|
+
BindingKind.Property,
|
|
8968
|
+
op.name,
|
|
8969
|
+
null,
|
|
8970
|
+
null,
|
|
8971
|
+
null,
|
|
8972
|
+
SecurityContext.STYLE
|
|
8973
|
+
), lookupElement(elements, op.target));
|
|
8831
8974
|
}
|
|
8832
8975
|
break;
|
|
8833
8976
|
case OpKind.Listener:
|
|
8834
8977
|
if (!op.isAnimationListener) {
|
|
8835
|
-
const extractedAttributeOp = createExtractedAttributeOp(
|
|
8978
|
+
const extractedAttributeOp = createExtractedAttributeOp(
|
|
8979
|
+
op.target,
|
|
8980
|
+
BindingKind.Property,
|
|
8981
|
+
op.name,
|
|
8982
|
+
null,
|
|
8983
|
+
null,
|
|
8984
|
+
null,
|
|
8985
|
+
SecurityContext.NONE
|
|
8986
|
+
);
|
|
8836
8987
|
if (job.kind === CompilationJobKind.Host) {
|
|
8837
8988
|
unit.create.push(extractedAttributeOp);
|
|
8838
8989
|
} else {
|
|
@@ -8866,7 +9017,7 @@ function extractAttributeOp(unit, op, elements) {
|
|
|
8866
9017
|
}
|
|
8867
9018
|
}
|
|
8868
9019
|
if (extractable) {
|
|
8869
|
-
const extractedAttributeOp = createExtractedAttributeOp(op.target, op.
|
|
9020
|
+
const extractedAttributeOp = createExtractedAttributeOp(op.target, op.isStructuralTemplateAttribute ? BindingKind.Template : BindingKind.Attribute, op.name, op.expression, op.i18nContext, op.i18nMessage, op.securityContext);
|
|
8870
9021
|
if (unit.job.kind === CompilationJobKind.Host) {
|
|
8871
9022
|
unit.create.push(extractedAttributeOp);
|
|
8872
9023
|
} else {
|
|
@@ -8907,15 +9058,15 @@ function specializeBindings(job) {
|
|
|
8907
9058
|
const target = lookupElement2(elements, op.target);
|
|
8908
9059
|
target.nonBindable = true;
|
|
8909
9060
|
} else {
|
|
8910
|
-
OpList.replace(op, createAttributeOp(op.target, op.name, op.expression, op.securityContext, op.isTextAttribute, op.
|
|
9061
|
+
OpList.replace(op, createAttributeOp(op.target, op.name, op.expression, op.securityContext, op.isTextAttribute, op.isStructuralTemplateAttribute, op.templateKind, op.i18nMessage, op.sourceSpan));
|
|
8911
9062
|
}
|
|
8912
9063
|
break;
|
|
8913
9064
|
case BindingKind.Property:
|
|
8914
9065
|
case BindingKind.Animation:
|
|
8915
9066
|
if (job.kind === CompilationJobKind.Host) {
|
|
8916
|
-
OpList.replace(op, createHostPropertyOp(op.name, op.expression, op.bindingKind === BindingKind.Animation, op.sourceSpan));
|
|
9067
|
+
OpList.replace(op, createHostPropertyOp(op.name, op.expression, op.bindingKind === BindingKind.Animation, op.i18nContext, op.securityContext, op.sourceSpan));
|
|
8917
9068
|
} else {
|
|
8918
|
-
OpList.replace(op, createPropertyOp(op.target, op.name, op.expression, op.bindingKind === BindingKind.Animation, op.securityContext, op.
|
|
9069
|
+
OpList.replace(op, createPropertyOp(op.target, op.name, op.expression, op.bindingKind === BindingKind.Animation, op.securityContext, op.isStructuralTemplateAttribute, op.templateKind, op.i18nContext, op.i18nMessage, op.sourceSpan));
|
|
8919
9070
|
}
|
|
8920
9071
|
break;
|
|
8921
9072
|
case BindingKind.I18n:
|
|
@@ -9042,39 +9193,6 @@ function generateConditionalExpressions(job) {
|
|
|
9042
9193
|
}
|
|
9043
9194
|
}
|
|
9044
9195
|
|
|
9045
|
-
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/ml_parser/tags.mjs
|
|
9046
|
-
var TagContentType;
|
|
9047
|
-
(function(TagContentType2) {
|
|
9048
|
-
TagContentType2[TagContentType2["RAW_TEXT"] = 0] = "RAW_TEXT";
|
|
9049
|
-
TagContentType2[TagContentType2["ESCAPABLE_RAW_TEXT"] = 1] = "ESCAPABLE_RAW_TEXT";
|
|
9050
|
-
TagContentType2[TagContentType2["PARSABLE_DATA"] = 2] = "PARSABLE_DATA";
|
|
9051
|
-
})(TagContentType || (TagContentType = {}));
|
|
9052
|
-
function splitNsName(elementName) {
|
|
9053
|
-
if (elementName[0] != ":") {
|
|
9054
|
-
return [null, elementName];
|
|
9055
|
-
}
|
|
9056
|
-
const colonIndex = elementName.indexOf(":", 1);
|
|
9057
|
-
if (colonIndex === -1) {
|
|
9058
|
-
throw new Error(`Unsupported format "${elementName}" expecting ":namespace:name"`);
|
|
9059
|
-
}
|
|
9060
|
-
return [elementName.slice(1, colonIndex), elementName.slice(colonIndex + 1)];
|
|
9061
|
-
}
|
|
9062
|
-
function isNgContainer(tagName) {
|
|
9063
|
-
return splitNsName(tagName)[1] === "ng-container";
|
|
9064
|
-
}
|
|
9065
|
-
function isNgContent(tagName) {
|
|
9066
|
-
return splitNsName(tagName)[1] === "ng-content";
|
|
9067
|
-
}
|
|
9068
|
-
function isNgTemplate(tagName) {
|
|
9069
|
-
return splitNsName(tagName)[1] === "ng-template";
|
|
9070
|
-
}
|
|
9071
|
-
function getNsPrefix(fullName) {
|
|
9072
|
-
return fullName === null ? null : splitNsName(fullName)[0];
|
|
9073
|
-
}
|
|
9074
|
-
function mergeNsAndName(prefix, localName) {
|
|
9075
|
-
return prefix ? `:${prefix}:${localName}` : localName;
|
|
9076
|
-
}
|
|
9077
|
-
|
|
9078
9196
|
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/conversion.mjs
|
|
9079
9197
|
var BINARY_OPERATORS = /* @__PURE__ */ new Map([
|
|
9080
9198
|
["&&", BinaryOperator.And],
|
|
@@ -9133,7 +9251,7 @@ function collectElementConsts(job) {
|
|
|
9133
9251
|
if (op.kind === OpKind.ExtractedAttribute) {
|
|
9134
9252
|
const attributes = allElementAttributes.get(op.target) || new ElementAttributes();
|
|
9135
9253
|
allElementAttributes.set(op.target, attributes);
|
|
9136
|
-
attributes.add(op.bindingKind, op.name, op.expression);
|
|
9254
|
+
attributes.add(op.bindingKind, op.name, op.expression, op.trustedValueFn);
|
|
9137
9255
|
OpList.remove(op);
|
|
9138
9256
|
}
|
|
9139
9257
|
}
|
|
@@ -9195,7 +9313,7 @@ var ElementAttributes = class {
|
|
|
9195
9313
|
var _a2;
|
|
9196
9314
|
return (_a2 = this.byKind.get(BindingKind.I18n)) != null ? _a2 : FLYWEIGHT_ARRAY;
|
|
9197
9315
|
}
|
|
9198
|
-
add(kind, name, value) {
|
|
9316
|
+
add(kind, name, value, trustedValueFn) {
|
|
9199
9317
|
var _a2;
|
|
9200
9318
|
if (this.known.has(name)) {
|
|
9201
9319
|
return;
|
|
@@ -9211,9 +9329,16 @@ var ElementAttributes = class {
|
|
|
9211
9329
|
array.push(...getAttributeNameLiterals(name));
|
|
9212
9330
|
if (kind === BindingKind.Attribute || kind === BindingKind.StyleProperty) {
|
|
9213
9331
|
if (value === null) {
|
|
9214
|
-
throw Error("Attribute & style element attributes must have a value");
|
|
9332
|
+
throw Error("Attribute, i18n attribute, & style element attributes must have a value");
|
|
9333
|
+
}
|
|
9334
|
+
if (trustedValueFn !== null) {
|
|
9335
|
+
if (!isStringLiteral(value)) {
|
|
9336
|
+
throw Error("AssertionError: extracted attribute value should be string literal");
|
|
9337
|
+
}
|
|
9338
|
+
array.push(taggedTemplate(trustedValueFn, new TemplateLiteral([new TemplateLiteralElement(value.value)], []), void 0, value.sourceSpan));
|
|
9339
|
+
} else {
|
|
9340
|
+
array.push(value);
|
|
9215
9341
|
}
|
|
9216
|
-
array.push(value);
|
|
9217
9342
|
}
|
|
9218
9343
|
}
|
|
9219
9344
|
arrayFor(kind) {
|
|
@@ -9259,6 +9384,47 @@ function serializeAttributes({ attributes, bindings, classes, i18n: i18n2, proje
|
|
|
9259
9384
|
return literalArr(attrArray);
|
|
9260
9385
|
}
|
|
9261
9386
|
|
|
9387
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/convert_i18n_bindings.mjs
|
|
9388
|
+
function convertI18nBindings(job) {
|
|
9389
|
+
const i18nAttributesByElem = /* @__PURE__ */ new Map();
|
|
9390
|
+
for (const unit of job.units) {
|
|
9391
|
+
for (const op of unit.create) {
|
|
9392
|
+
if (op.kind === OpKind.I18nAttributes) {
|
|
9393
|
+
i18nAttributesByElem.set(op.target, op);
|
|
9394
|
+
}
|
|
9395
|
+
}
|
|
9396
|
+
for (const op of unit.update) {
|
|
9397
|
+
switch (op.kind) {
|
|
9398
|
+
case OpKind.Property:
|
|
9399
|
+
case OpKind.Attribute:
|
|
9400
|
+
if (op.i18nContext === null) {
|
|
9401
|
+
continue;
|
|
9402
|
+
}
|
|
9403
|
+
if (!(op.expression instanceof Interpolation2)) {
|
|
9404
|
+
continue;
|
|
9405
|
+
}
|
|
9406
|
+
const i18nAttributesForElem = i18nAttributesByElem.get(op.target);
|
|
9407
|
+
if (i18nAttributesForElem === void 0) {
|
|
9408
|
+
throw new Error("AssertionError: An i18n attribute binding instruction requires the owning element to have an I18nAttributes create instruction");
|
|
9409
|
+
}
|
|
9410
|
+
if (i18nAttributesForElem.target !== op.target) {
|
|
9411
|
+
throw new Error("AssertionError: Expected i18nAttributes target element to match binding target element");
|
|
9412
|
+
}
|
|
9413
|
+
const ops = [];
|
|
9414
|
+
for (let i = 0; i < op.expression.expressions.length; i++) {
|
|
9415
|
+
const expr = op.expression.expressions[i];
|
|
9416
|
+
if (op.expression.i18nPlaceholders.length !== op.expression.expressions.length) {
|
|
9417
|
+
throw new Error(`AssertionError: An i18n attribute binding instruction requires the same number of expressions and placeholders, but found ${op.expression.i18nPlaceholders.length} placeholders and ${op.expression.expressions.length} expressions`);
|
|
9418
|
+
}
|
|
9419
|
+
ops.push(createI18nExpressionOp(op.i18nContext, i18nAttributesForElem.target, i18nAttributesForElem.xref, i18nAttributesForElem.handle, expr, op.expression.i18nPlaceholders[i], I18nParamResolutionTime.Creation, I18nExpressionFor.I18nAttribute, op.name, op.sourceSpan));
|
|
9420
|
+
}
|
|
9421
|
+
OpList.replaceWithMany(op, ops);
|
|
9422
|
+
break;
|
|
9423
|
+
}
|
|
9424
|
+
}
|
|
9425
|
+
}
|
|
9426
|
+
}
|
|
9427
|
+
|
|
9262
9428
|
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/create_defer_deps_fns.mjs
|
|
9263
9429
|
function createDeferDepsFns(job) {
|
|
9264
9430
|
for (const unit of job.units) {
|
|
@@ -9292,6 +9458,7 @@ function createI18nContexts(job) {
|
|
|
9292
9458
|
const rootContexts = /* @__PURE__ */ new Map();
|
|
9293
9459
|
let currentI18nOp = null;
|
|
9294
9460
|
let xref;
|
|
9461
|
+
const messageToContext = /* @__PURE__ */ new Map();
|
|
9295
9462
|
for (const unit of job.units) {
|
|
9296
9463
|
for (const op of unit.create) {
|
|
9297
9464
|
switch (op.kind) {
|
|
@@ -9321,6 +9488,24 @@ function createI18nContexts(job) {
|
|
|
9321
9488
|
break;
|
|
9322
9489
|
}
|
|
9323
9490
|
}
|
|
9491
|
+
for (const op of unit.ops()) {
|
|
9492
|
+
switch (op.kind) {
|
|
9493
|
+
case OpKind.Binding:
|
|
9494
|
+
case OpKind.Property:
|
|
9495
|
+
case OpKind.Attribute:
|
|
9496
|
+
case OpKind.ExtractedAttribute:
|
|
9497
|
+
if (!op.i18nMessage) {
|
|
9498
|
+
continue;
|
|
9499
|
+
}
|
|
9500
|
+
if (!messageToContext.has(op.i18nMessage)) {
|
|
9501
|
+
const i18nContext = job.allocateXrefId();
|
|
9502
|
+
unit.create.push(createI18nContextOp(I18nContextKind.Attr, i18nContext, null, op.i18nMessage, null));
|
|
9503
|
+
messageToContext.set(op.i18nMessage, i18nContext);
|
|
9504
|
+
}
|
|
9505
|
+
op.i18nContext = messageToContext.get(op.i18nMessage);
|
|
9506
|
+
break;
|
|
9507
|
+
}
|
|
9508
|
+
}
|
|
9324
9509
|
}
|
|
9325
9510
|
for (const unit of job.units) {
|
|
9326
9511
|
for (const op of unit.create) {
|
|
@@ -9629,6 +9814,15 @@ function extractI18nMessages(job) {
|
|
|
9629
9814
|
}
|
|
9630
9815
|
}
|
|
9631
9816
|
}
|
|
9817
|
+
for (const unit of job.units) {
|
|
9818
|
+
for (const op of unit.create) {
|
|
9819
|
+
if (op.kind !== OpKind.I18nContext || op.contextKind !== I18nContextKind.Attr) {
|
|
9820
|
+
continue;
|
|
9821
|
+
}
|
|
9822
|
+
const i18nMessageOp = createI18nMessage(job, op);
|
|
9823
|
+
unit.create.push(i18nMessageOp);
|
|
9824
|
+
}
|
|
9825
|
+
}
|
|
9632
9826
|
const i18nBlockMessages = /* @__PURE__ */ new Map();
|
|
9633
9827
|
for (const unit of job.units) {
|
|
9634
9828
|
for (const op of unit.create) {
|
|
@@ -9651,6 +9845,9 @@ function extractI18nMessages(job) {
|
|
|
9651
9845
|
}
|
|
9652
9846
|
const i18nContext = i18nContexts.get(op.context);
|
|
9653
9847
|
if (i18nContext.contextKind === I18nContextKind.Icu) {
|
|
9848
|
+
if (i18nContext.i18nBlock === null) {
|
|
9849
|
+
throw Error("ICU context should have its i18n block set.");
|
|
9850
|
+
}
|
|
9654
9851
|
const subMessage = createI18nMessage(job, i18nContext, op.messagePlaceholder);
|
|
9655
9852
|
unit.create.push(subMessage);
|
|
9656
9853
|
const rootI18nId = i18nBlocks.get(i18nContext.i18nBlock).root;
|
|
@@ -9667,69 +9864,54 @@ function extractI18nMessages(job) {
|
|
|
9667
9864
|
}
|
|
9668
9865
|
}
|
|
9669
9866
|
function createI18nMessage(job, context, messagePlaceholder) {
|
|
9670
|
-
let
|
|
9671
|
-
const
|
|
9672
|
-
|
|
9673
|
-
|
|
9867
|
+
let formattedParams = formatParams(context.params);
|
|
9868
|
+
const formattedPostprocessingParams = formatParams(context.postprocessingParams);
|
|
9869
|
+
let needsPostprocessing = formattedPostprocessingParams.size > 0;
|
|
9870
|
+
for (const values of context.params.values()) {
|
|
9871
|
+
if (values.length > 1) {
|
|
9872
|
+
needsPostprocessing = true;
|
|
9873
|
+
}
|
|
9874
|
+
}
|
|
9875
|
+
return createI18nMessageOp(job.allocateXrefId(), context.xref, context.i18nBlock, context.message, messagePlaceholder != null ? messagePlaceholder : null, formattedParams, formattedPostprocessingParams, needsPostprocessing);
|
|
9674
9876
|
}
|
|
9675
9877
|
function formatParams(params) {
|
|
9676
9878
|
const formattedParams = /* @__PURE__ */ new Map();
|
|
9677
|
-
let needsPostprocessing = false;
|
|
9678
9879
|
for (const [placeholder, placeholderValues] of params) {
|
|
9679
|
-
const
|
|
9680
|
-
needsPostprocessing || (needsPostprocessing = paramNeedsPostprocessing);
|
|
9880
|
+
const serializedValues = formatParamValues(placeholderValues);
|
|
9681
9881
|
if (serializedValues !== null) {
|
|
9682
9882
|
formattedParams.set(placeholder, literal(serializedValues));
|
|
9683
9883
|
}
|
|
9684
9884
|
}
|
|
9685
|
-
return
|
|
9885
|
+
return formattedParams;
|
|
9686
9886
|
}
|
|
9687
9887
|
function formatParamValues(values) {
|
|
9688
9888
|
if (values.length === 0) {
|
|
9689
|
-
return
|
|
9889
|
+
return null;
|
|
9690
9890
|
}
|
|
9691
|
-
collapseElementTemplatePairs(values);
|
|
9692
9891
|
const serializedValues = values.map((value) => formatValue(value));
|
|
9693
|
-
return serializedValues.length === 1 ?
|
|
9892
|
+
return serializedValues.length === 1 ? serializedValues[0] : `${LIST_START_MARKER}${serializedValues.join(LIST_DELIMITER)}${LIST_END_MARKER}`;
|
|
9694
9893
|
}
|
|
9695
|
-
function
|
|
9696
|
-
|
|
9697
|
-
|
|
9698
|
-
|
|
9699
|
-
const value = values[i];
|
|
9700
|
-
if (value.subTemplateIndex !== null && value.flags & (I18nParamValueFlags.ElementTag | I18nParamValueFlags.TemplateTag)) {
|
|
9701
|
-
const valueIndicies = (_a2 = valueIndiciesBySubTemplateIndex.get(value.subTemplateIndex)) != null ? _a2 : [];
|
|
9702
|
-
valueIndicies.push(i);
|
|
9703
|
-
valueIndiciesBySubTemplateIndex.set(value.subTemplateIndex, valueIndicies);
|
|
9704
|
-
}
|
|
9705
|
-
}
|
|
9706
|
-
for (const [subTemplateIndex, valueIndicies] of valueIndiciesBySubTemplateIndex) {
|
|
9707
|
-
if (valueIndicies.length > 1) {
|
|
9708
|
-
const elementIndex = valueIndicies.find((index) => values[index].flags & I18nParamValueFlags.ElementTag);
|
|
9709
|
-
const templateIndex = valueIndicies.find((index) => values[index].flags & I18nParamValueFlags.TemplateTag);
|
|
9710
|
-
if (elementIndex !== void 0 && templateIndex !== void 0) {
|
|
9711
|
-
const elementValue = values[elementIndex];
|
|
9712
|
-
const templateValue = values[templateIndex];
|
|
9713
|
-
let compundValue;
|
|
9714
|
-
if (elementValue.flags & I18nParamValueFlags.OpenTag && elementValue.flags & I18nParamValueFlags.CloseTag) {
|
|
9715
|
-
compundValue = `${formatValue(templateValue)}${formatValue(elementValue)}${formatValue(templateValue)}`;
|
|
9716
|
-
} else if (elementValue.flags & I18nParamValueFlags.OpenTag) {
|
|
9717
|
-
compundValue = `${formatValue(templateValue)}${formatValue(elementValue)}`;
|
|
9718
|
-
} else {
|
|
9719
|
-
compundValue = `${formatValue(elementValue)}${formatValue(templateValue)}`;
|
|
9720
|
-
}
|
|
9721
|
-
values.splice(elementIndex, 1, { value: compundValue, subTemplateIndex, flags: I18nParamValueFlags.None });
|
|
9722
|
-
values.splice(templateIndex, 1, null);
|
|
9723
|
-
}
|
|
9894
|
+
function formatValue(value) {
|
|
9895
|
+
if (value.flags & I18nParamValueFlags.ElementTag && value.flags & I18nParamValueFlags.TemplateTag) {
|
|
9896
|
+
if (typeof value.value !== "object") {
|
|
9897
|
+
throw Error("AssertionError: Expected i18n param value to have an element and template slot");
|
|
9724
9898
|
}
|
|
9725
|
-
|
|
9726
|
-
|
|
9727
|
-
|
|
9728
|
-
|
|
9899
|
+
const elementValue = formatValue(__spreadProps(__spreadValues({}, value), {
|
|
9900
|
+
value: value.value.element,
|
|
9901
|
+
flags: value.flags & ~I18nParamValueFlags.TemplateTag
|
|
9902
|
+
}));
|
|
9903
|
+
const templateValue = formatValue(__spreadProps(__spreadValues({}, value), {
|
|
9904
|
+
value: value.value.template,
|
|
9905
|
+
flags: value.flags & ~I18nParamValueFlags.ElementTag
|
|
9906
|
+
}));
|
|
9907
|
+
if (value.flags & I18nParamValueFlags.OpenTag && value.flags & I18nParamValueFlags.CloseTag) {
|
|
9908
|
+
return `${templateValue}${elementValue}${templateValue}`;
|
|
9729
9909
|
}
|
|
9910
|
+
return value.flags & I18nParamValueFlags.CloseTag ? `${elementValue}${templateValue}` : `${templateValue}${elementValue}`;
|
|
9911
|
+
}
|
|
9912
|
+
if (value.flags & I18nParamValueFlags.OpenTag && value.flags & I18nParamValueFlags.CloseTag) {
|
|
9913
|
+
return `${formatValue(__spreadProps(__spreadValues({}, value), { flags: value.flags & ~I18nParamValueFlags.CloseTag }))}${formatValue(__spreadProps(__spreadValues({}, value), { flags: value.flags & ~I18nParamValueFlags.OpenTag }))}`;
|
|
9730
9914
|
}
|
|
9731
|
-
}
|
|
9732
|
-
function formatValue(value) {
|
|
9733
9915
|
if (value.flags === I18nParamValueFlags.None) {
|
|
9734
9916
|
return `${value.value}`;
|
|
9735
9917
|
}
|
|
@@ -9744,9 +9926,6 @@ function formatValue(value) {
|
|
|
9744
9926
|
closeMarker = value.flags & I18nParamValueFlags.CloseTag ? TAG_CLOSE_MARKER : "";
|
|
9745
9927
|
}
|
|
9746
9928
|
const context = value.subTemplateIndex === null ? "" : `${CONTEXT_MARKER}${value.subTemplateIndex}`;
|
|
9747
|
-
if (value.flags & I18nParamValueFlags.OpenTag && value.flags & I18nParamValueFlags.CloseTag) {
|
|
9748
|
-
return `${ESCAPE}${tagMarker}${value.value}${context}${ESCAPE}${ESCAPE}${closeMarker}${tagMarker}${value.value}${context}${ESCAPE}`;
|
|
9749
|
-
}
|
|
9750
9929
|
return `${ESCAPE}${closeMarker}${tagMarker}${value.value}${context}${ESCAPE}`;
|
|
9751
9930
|
}
|
|
9752
9931
|
|
|
@@ -9767,7 +9946,7 @@ function generateAdvance(job) {
|
|
|
9767
9946
|
if (!hasDependsOnSlotContextTrait(op)) {
|
|
9768
9947
|
continue;
|
|
9769
9948
|
} else if (!slotMap.has(op.target)) {
|
|
9770
|
-
throw new Error(`AssertionError: reference to unknown slot for
|
|
9949
|
+
throw new Error(`AssertionError: reference to unknown slot for target ${op.target}`);
|
|
9771
9950
|
}
|
|
9772
9951
|
const slot = slotMap.get(op.target);
|
|
9773
9952
|
if (slotContext !== slot) {
|
|
@@ -9815,8 +9994,13 @@ function recursivelyProcessView(view, parentScope) {
|
|
|
9815
9994
|
for (const op of view.create) {
|
|
9816
9995
|
switch (op.kind) {
|
|
9817
9996
|
case OpKind.Template:
|
|
9997
|
+
recursivelyProcessView(view.job.views.get(op.xref), scope);
|
|
9998
|
+
break;
|
|
9818
9999
|
case OpKind.RepeaterCreate:
|
|
9819
10000
|
recursivelyProcessView(view.job.views.get(op.xref), scope);
|
|
10001
|
+
if (op.emptyView) {
|
|
10002
|
+
recursivelyProcessView(view.job.views.get(op.emptyView), scope);
|
|
10003
|
+
}
|
|
9820
10004
|
break;
|
|
9821
10005
|
case OpKind.Listener:
|
|
9822
10006
|
op.handlerOps.prepend(generateVariablesInScopeForView(view, scope));
|
|
@@ -15950,56 +16134,137 @@ function createEmptyMessagePart(location) {
|
|
|
15950
16134
|
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/i18n_const_collection.mjs
|
|
15951
16135
|
var NG_I18N_CLOSURE_MODE = "ngI18nClosureMode";
|
|
15952
16136
|
var TRANSLATION_VAR_PREFIX2 = "i18n_";
|
|
16137
|
+
var I18N_ICU_MAPPING_PREFIX2 = "I18N_EXP_";
|
|
16138
|
+
var ESCAPE2 = "\uFFFD";
|
|
15953
16139
|
function collectI18nConsts(job) {
|
|
16140
|
+
var _a2, _b2;
|
|
15954
16141
|
const fileBasedI18nSuffix = job.relativeContextFilePath.replace(/[^A-Za-z0-9]/g, "_").toUpperCase() + "_";
|
|
15955
|
-
const
|
|
16142
|
+
const extractedAttributesByI18nContext = /* @__PURE__ */ new Map();
|
|
16143
|
+
const i18nAttributesByElement = /* @__PURE__ */ new Map();
|
|
16144
|
+
const i18nExpressionsByElement = /* @__PURE__ */ new Map();
|
|
15956
16145
|
const messages = /* @__PURE__ */ new Map();
|
|
16146
|
+
for (const unit of job.units) {
|
|
16147
|
+
for (const op of unit.ops()) {
|
|
16148
|
+
if (op.kind === OpKind.ExtractedAttribute && op.i18nContext !== null) {
|
|
16149
|
+
const attributes = (_a2 = extractedAttributesByI18nContext.get(op.i18nContext)) != null ? _a2 : [];
|
|
16150
|
+
attributes.push(op);
|
|
16151
|
+
extractedAttributesByI18nContext.set(op.i18nContext, attributes);
|
|
16152
|
+
} else if (op.kind === OpKind.I18nAttributes) {
|
|
16153
|
+
i18nAttributesByElement.set(op.target, op);
|
|
16154
|
+
} else if (op.kind === OpKind.I18nExpression && op.usage === I18nExpressionFor.I18nAttribute) {
|
|
16155
|
+
const expressions = (_b2 = i18nExpressionsByElement.get(op.target)) != null ? _b2 : [];
|
|
16156
|
+
expressions.push(op);
|
|
16157
|
+
i18nExpressionsByElement.set(op.target, expressions);
|
|
16158
|
+
} else if (op.kind === OpKind.I18nMessage) {
|
|
16159
|
+
messages.set(op.xref, op);
|
|
16160
|
+
}
|
|
16161
|
+
}
|
|
16162
|
+
}
|
|
16163
|
+
const i18nValuesByContext = /* @__PURE__ */ new Map();
|
|
16164
|
+
const messageConstIndices = /* @__PURE__ */ new Map();
|
|
15957
16165
|
for (const unit of job.units) {
|
|
15958
16166
|
for (const op of unit.create) {
|
|
15959
16167
|
if (op.kind === OpKind.I18nMessage) {
|
|
15960
|
-
|
|
16168
|
+
if (op.messagePlaceholder === null) {
|
|
16169
|
+
const { mainVar, statements } = collectMessage(job, fileBasedI18nSuffix, messages, op);
|
|
16170
|
+
if (op.i18nBlock !== null) {
|
|
16171
|
+
const i18nConst = job.addConst(mainVar, statements);
|
|
16172
|
+
messageConstIndices.set(op.i18nBlock, i18nConst);
|
|
16173
|
+
} else {
|
|
16174
|
+
job.constsInitializers.push(...statements);
|
|
16175
|
+
i18nValuesByContext.set(op.i18nContext, mainVar);
|
|
16176
|
+
const attributesForMessage = extractedAttributesByI18nContext.get(op.i18nContext);
|
|
16177
|
+
if (attributesForMessage !== void 0) {
|
|
16178
|
+
for (const attr of attributesForMessage) {
|
|
16179
|
+
attr.expression = mainVar.clone();
|
|
16180
|
+
}
|
|
16181
|
+
}
|
|
16182
|
+
}
|
|
16183
|
+
}
|
|
15961
16184
|
OpList.remove(op);
|
|
15962
16185
|
}
|
|
15963
16186
|
}
|
|
15964
16187
|
}
|
|
15965
|
-
for (const
|
|
15966
|
-
|
|
15967
|
-
|
|
15968
|
-
|
|
16188
|
+
for (const unit of job.units) {
|
|
16189
|
+
for (const elem of unit.create) {
|
|
16190
|
+
if (isElementOrContainerOp(elem)) {
|
|
16191
|
+
const i18nAttributes2 = i18nAttributesByElement.get(elem.xref);
|
|
16192
|
+
if (i18nAttributes2 === void 0) {
|
|
16193
|
+
continue;
|
|
16194
|
+
}
|
|
16195
|
+
let i18nExpressions = i18nExpressionsByElement.get(elem.xref);
|
|
16196
|
+
if (i18nExpressions === void 0) {
|
|
16197
|
+
throw new Error("AssertionError: Could not find any i18n expressions associated with an I18nAttributes instruction");
|
|
16198
|
+
}
|
|
16199
|
+
const seenPropertyNames = /* @__PURE__ */ new Set();
|
|
16200
|
+
i18nExpressions = i18nExpressions.filter((i18nExpr) => {
|
|
16201
|
+
const seen = seenPropertyNames.has(i18nExpr.name);
|
|
16202
|
+
seenPropertyNames.add(i18nExpr.name);
|
|
16203
|
+
return !seen;
|
|
16204
|
+
});
|
|
16205
|
+
const i18nAttributeConfig = i18nExpressions.flatMap((i18nExpr) => {
|
|
16206
|
+
const i18nExprValue = i18nValuesByContext.get(i18nExpr.context);
|
|
16207
|
+
if (i18nExprValue === void 0) {
|
|
16208
|
+
throw new Error("AssertionError: Could not find i18n expression's value");
|
|
16209
|
+
}
|
|
16210
|
+
return [literal(i18nExpr.name), i18nExprValue];
|
|
16211
|
+
});
|
|
16212
|
+
i18nAttributes2.i18nAttributesConfig = job.addConst(new LiteralArrayExpr(i18nAttributeConfig));
|
|
16213
|
+
}
|
|
15969
16214
|
}
|
|
15970
16215
|
}
|
|
15971
16216
|
for (const unit of job.units) {
|
|
15972
16217
|
for (const op of unit.create) {
|
|
15973
16218
|
if (op.kind === OpKind.I18nStart) {
|
|
15974
|
-
|
|
16219
|
+
const msgIndex = messageConstIndices.get(op.root);
|
|
16220
|
+
if (msgIndex === void 0) {
|
|
16221
|
+
throw new Error("AssertionError: Could not find corresponding i18n block index for an i18n message op; was an i18n message incorrectly assumed to correspond to an attribute?");
|
|
16222
|
+
}
|
|
16223
|
+
op.messageIndex = msgIndex;
|
|
15975
16224
|
}
|
|
15976
16225
|
}
|
|
15977
16226
|
}
|
|
15978
16227
|
}
|
|
15979
16228
|
function collectMessage(job, fileBasedI18nSuffix, messages, messageOp) {
|
|
16229
|
+
var _a2;
|
|
15980
16230
|
const statements = [];
|
|
16231
|
+
const subMessagePlaceholders = /* @__PURE__ */ new Map();
|
|
15981
16232
|
for (const subMessageId of messageOp.subMessages) {
|
|
15982
16233
|
const subMessage = messages.get(subMessageId);
|
|
15983
16234
|
const { mainVar: subMessageVar, statements: subMessageStatements } = collectMessage(job, fileBasedI18nSuffix, messages, subMessage);
|
|
15984
16235
|
statements.push(...subMessageStatements);
|
|
15985
|
-
|
|
16236
|
+
const subMessages = (_a2 = subMessagePlaceholders.get(subMessage.messagePlaceholder)) != null ? _a2 : [];
|
|
16237
|
+
subMessages.push(subMessageVar);
|
|
16238
|
+
subMessagePlaceholders.set(subMessage.messagePlaceholder, subMessages);
|
|
15986
16239
|
}
|
|
16240
|
+
addSubMessageParams(messageOp, subMessagePlaceholders);
|
|
15987
16241
|
messageOp.params = new Map([...messageOp.params.entries()].sort());
|
|
15988
|
-
assertAllParamsResolved(messageOp);
|
|
15989
16242
|
const mainVar = variable(job.pool.uniqueName(TRANSLATION_VAR_PREFIX2));
|
|
15990
16243
|
const closureVar = i18nGenerateClosureVar(job.pool, messageOp.message.id, fileBasedI18nSuffix, job.i18nUseExternalIds);
|
|
15991
16244
|
let transformFn = void 0;
|
|
15992
16245
|
if (messageOp.needsPostprocessing) {
|
|
15993
|
-
|
|
16246
|
+
const postprocessingParams = Object.fromEntries([...messageOp.postprocessingParams.entries()].sort());
|
|
16247
|
+
const formattedPostprocessingParams = formatI18nPlaceholderNamesInMap(postprocessingParams, false);
|
|
15994
16248
|
const extraTransformFnParams = [];
|
|
15995
16249
|
if (messageOp.postprocessingParams.size > 0) {
|
|
15996
|
-
extraTransformFnParams.push(
|
|
16250
|
+
extraTransformFnParams.push(mapLiteral(formattedPostprocessingParams, true));
|
|
15997
16251
|
}
|
|
15998
16252
|
transformFn = (expr) => importExpr(Identifiers.i18nPostprocess).callFn([expr, ...extraTransformFnParams]);
|
|
15999
16253
|
}
|
|
16000
16254
|
statements.push(...getTranslationDeclStmts(messageOp.message, mainVar, closureVar, messageOp.params, transformFn));
|
|
16001
16255
|
return { mainVar, statements };
|
|
16002
16256
|
}
|
|
16257
|
+
function addSubMessageParams(messageOp, subMessagePlaceholders) {
|
|
16258
|
+
for (const [placeholder, subMessages] of subMessagePlaceholders) {
|
|
16259
|
+
if (subMessages.length === 1) {
|
|
16260
|
+
messageOp.params.set(placeholder, subMessages[0]);
|
|
16261
|
+
} else {
|
|
16262
|
+
messageOp.params.set(placeholder, literal(`${ESCAPE2}${I18N_ICU_MAPPING_PREFIX2}${placeholder}${ESCAPE2}`));
|
|
16263
|
+
messageOp.postprocessingParams.set(placeholder, literalArr(subMessages));
|
|
16264
|
+
messageOp.needsPostprocessing = true;
|
|
16265
|
+
}
|
|
16266
|
+
}
|
|
16267
|
+
}
|
|
16003
16268
|
function getTranslationDeclStmts(message, variable2, closureVar, params, transformFn) {
|
|
16004
16269
|
const paramsObject = Object.fromEntries(params);
|
|
16005
16270
|
const statements = [
|
|
@@ -16027,23 +16292,9 @@ function i18nGenerateClosureVar(pool, messageId, fileBasedI18nSuffix, useExterna
|
|
|
16027
16292
|
}
|
|
16028
16293
|
return variable(name);
|
|
16029
16294
|
}
|
|
16030
|
-
function assertAllParamsResolved(op) {
|
|
16031
|
-
for (let placeholder in op.message.placeholders) {
|
|
16032
|
-
placeholder = placeholder.trimEnd();
|
|
16033
|
-
if (!op.params.has(placeholder) && !op.postprocessingParams.has(placeholder)) {
|
|
16034
|
-
throw Error(`Failed to resolve i18n placeholder: ${placeholder}`);
|
|
16035
|
-
}
|
|
16036
|
-
}
|
|
16037
|
-
for (let placeholder in op.message.placeholderToMessage) {
|
|
16038
|
-
placeholder = placeholder.trimEnd();
|
|
16039
|
-
if (!op.params.has(placeholder) && !op.postprocessingParams.has(placeholder)) {
|
|
16040
|
-
throw Error(`Failed to resolve i18n message placeholder: ${placeholder}`);
|
|
16041
|
-
}
|
|
16042
|
-
}
|
|
16043
|
-
}
|
|
16044
16295
|
|
|
16045
16296
|
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/i18n_text_extraction.mjs
|
|
16046
|
-
function
|
|
16297
|
+
function convertI18nText(job) {
|
|
16047
16298
|
var _a2;
|
|
16048
16299
|
for (const unit of job.units) {
|
|
16049
16300
|
let currentI18n = null;
|
|
@@ -16092,7 +16343,7 @@ function extractI18nText(job) {
|
|
|
16092
16343
|
const ops = [];
|
|
16093
16344
|
for (let i = 0; i < op.interpolation.expressions.length; i++) {
|
|
16094
16345
|
const expr = op.interpolation.expressions[i];
|
|
16095
|
-
ops.push(createI18nExpressionOp(contextId, i18nOp.xref, i18nOp.handle, expr, op.i18nPlaceholders[i], resolutionTime, (_a2 = expr.sourceSpan) != null ? _a2 : op.sourceSpan));
|
|
16346
|
+
ops.push(createI18nExpressionOp(contextId, i18nOp.xref, i18nOp.xref, i18nOp.handle, expr, op.interpolation.i18nPlaceholders[i], resolutionTime, I18nExpressionFor.I18nText, "", (_a2 = expr.sourceSpan) != null ? _a2 : op.sourceSpan));
|
|
16096
16347
|
}
|
|
16097
16348
|
OpList.replaceWithMany(op, ops);
|
|
16098
16349
|
break;
|
|
@@ -16514,13 +16765,13 @@ function parseExtractedStyles(job) {
|
|
|
16514
16765
|
if (op.name === "style") {
|
|
16515
16766
|
const parsedStyles = parse(op.expression.value);
|
|
16516
16767
|
for (let i = 0; i < parsedStyles.length - 1; i += 2) {
|
|
16517
|
-
OpList.insertBefore(createExtractedAttributeOp(op.target, BindingKind.StyleProperty, parsedStyles[i], literal(parsedStyles[i + 1])), op);
|
|
16768
|
+
OpList.insertBefore(createExtractedAttributeOp(op.target, BindingKind.StyleProperty, parsedStyles[i], literal(parsedStyles[i + 1]), null, null, SecurityContext.STYLE), op);
|
|
16518
16769
|
}
|
|
16519
16770
|
OpList.remove(op);
|
|
16520
16771
|
} else if (op.name === "class") {
|
|
16521
16772
|
const parsedClasses = op.expression.value.trim().split(/\s+/g);
|
|
16522
16773
|
for (const parsedClass of parsedClasses) {
|
|
16523
|
-
OpList.insertBefore(createExtractedAttributeOp(op.target, BindingKind.ClassName, parsedClass, null), op);
|
|
16774
|
+
OpList.insertBefore(createExtractedAttributeOp(op.target, BindingKind.ClassName, parsedClass, null, null, null, SecurityContext.NONE), op);
|
|
16524
16775
|
}
|
|
16525
16776
|
OpList.remove(op);
|
|
16526
16777
|
}
|
|
@@ -16533,18 +16784,28 @@ function parseExtractedStyles(job) {
|
|
|
16533
16784
|
function removeContentSelectors(job) {
|
|
16534
16785
|
for (const unit of job.units) {
|
|
16535
16786
|
const elements = createOpXrefMap(unit);
|
|
16536
|
-
for (const op of unit.
|
|
16787
|
+
for (const op of unit.ops()) {
|
|
16537
16788
|
switch (op.kind) {
|
|
16538
16789
|
case OpKind.Binding:
|
|
16539
16790
|
const target = lookupInXrefMap(elements, op.target);
|
|
16540
|
-
if (op.name
|
|
16791
|
+
if (isSelectAttribute(op.name) && target.kind === OpKind.Projection) {
|
|
16541
16792
|
OpList.remove(op);
|
|
16542
16793
|
}
|
|
16543
16794
|
break;
|
|
16795
|
+
case OpKind.Projection:
|
|
16796
|
+
for (let i = op.attributes.length - 2; i >= 0; i -= 2) {
|
|
16797
|
+
if (isSelectAttribute(op.attributes[i])) {
|
|
16798
|
+
op.attributes.splice(i, 2);
|
|
16799
|
+
}
|
|
16800
|
+
}
|
|
16801
|
+
break;
|
|
16544
16802
|
}
|
|
16545
16803
|
}
|
|
16546
16804
|
}
|
|
16547
16805
|
}
|
|
16806
|
+
function isSelectAttribute(name) {
|
|
16807
|
+
return name.toLowerCase() === "select";
|
|
16808
|
+
}
|
|
16548
16809
|
function lookupInXrefMap(map, xref) {
|
|
16549
16810
|
const el = map.get(xref);
|
|
16550
16811
|
if (el === void 0) {
|
|
@@ -16631,22 +16892,35 @@ function propagateI18nBlocksToTemplates(unit, subTemplateIndex) {
|
|
|
16631
16892
|
i18nBlock = op;
|
|
16632
16893
|
break;
|
|
16633
16894
|
case OpKind.I18nEnd:
|
|
16895
|
+
if (i18nBlock.subTemplateIndex === null) {
|
|
16896
|
+
subTemplateIndex = 0;
|
|
16897
|
+
}
|
|
16634
16898
|
i18nBlock = null;
|
|
16635
16899
|
break;
|
|
16636
16900
|
case OpKind.Template:
|
|
16637
|
-
|
|
16638
|
-
|
|
16639
|
-
|
|
16640
|
-
|
|
16641
|
-
|
|
16642
|
-
|
|
16643
|
-
|
|
16901
|
+
subTemplateIndex = propagateI18nBlocksForView(unit.job.views.get(op.xref), i18nBlock, op.i18nPlaceholder, subTemplateIndex);
|
|
16902
|
+
break;
|
|
16903
|
+
case OpKind.RepeaterCreate:
|
|
16904
|
+
const forView = unit.job.views.get(op.xref);
|
|
16905
|
+
subTemplateIndex = propagateI18nBlocksForView(unit.job.views.get(op.xref), i18nBlock, op.i18nPlaceholder, subTemplateIndex);
|
|
16906
|
+
if (op.emptyView !== null) {
|
|
16907
|
+
subTemplateIndex = propagateI18nBlocksForView(unit.job.views.get(op.emptyView), i18nBlock, op.emptyI18nPlaceholder, subTemplateIndex);
|
|
16644
16908
|
}
|
|
16645
|
-
|
|
16909
|
+
break;
|
|
16646
16910
|
}
|
|
16647
16911
|
}
|
|
16648
16912
|
return subTemplateIndex;
|
|
16649
16913
|
}
|
|
16914
|
+
function propagateI18nBlocksForView(view, i18nBlock, i18nPlaceholder, subTemplateIndex) {
|
|
16915
|
+
if (i18nPlaceholder !== void 0) {
|
|
16916
|
+
if (i18nBlock === null) {
|
|
16917
|
+
throw Error("Expected template with i18n placeholder to be in an i18n block.");
|
|
16918
|
+
}
|
|
16919
|
+
subTemplateIndex++;
|
|
16920
|
+
wrapTemplateWithI18n(view, i18nBlock);
|
|
16921
|
+
}
|
|
16922
|
+
return propagateI18nBlocksToTemplates(view, subTemplateIndex);
|
|
16923
|
+
}
|
|
16650
16924
|
function wrapTemplateWithI18n(unit, parentI18n) {
|
|
16651
16925
|
var _a2;
|
|
16652
16926
|
if (((_a2 = unit.create.head.next) == null ? void 0 : _a2.kind) !== OpKind.I18nStart) {
|
|
@@ -16803,17 +17077,13 @@ function disableBindings2() {
|
|
|
16803
17077
|
function enableBindings() {
|
|
16804
17078
|
return call(Identifiers.enableBindings, [], null);
|
|
16805
17079
|
}
|
|
16806
|
-
function listener(name, handlerFn, sourceSpan) {
|
|
16807
|
-
|
|
16808
|
-
|
|
16809
|
-
|
|
16810
|
-
|
|
16811
|
-
}
|
|
16812
|
-
|
|
16813
|
-
return call(Identifiers.syntheticHostListener, [
|
|
16814
|
-
literal(name),
|
|
16815
|
-
handlerFn
|
|
16816
|
-
], sourceSpan);
|
|
17080
|
+
function listener(name, handlerFn, eventTargetResolver, syntheticHost, sourceSpan) {
|
|
17081
|
+
const args = [literal(name), handlerFn];
|
|
17082
|
+
if (eventTargetResolver !== null) {
|
|
17083
|
+
args.push(literal(false));
|
|
17084
|
+
args.push(importExpr(eventTargetResolver));
|
|
17085
|
+
}
|
|
17086
|
+
return call(syntheticHost ? Identifiers.syntheticHostListener : Identifiers.listener, args, sourceSpan);
|
|
16817
17087
|
}
|
|
16818
17088
|
function pipe(slot, name) {
|
|
16819
17089
|
return call(Identifiers.pipe, [
|
|
@@ -16960,6 +17230,10 @@ function i18n(slot, constIndex, subTemplateIndex) {
|
|
|
16960
17230
|
function i18nEnd() {
|
|
16961
17231
|
return call(Identifiers.i18nEnd, [], null);
|
|
16962
17232
|
}
|
|
17233
|
+
function i18nAttributes(slot, i18nAttributesConfig) {
|
|
17234
|
+
const args = [literal(slot), literal(i18nAttributesConfig)];
|
|
17235
|
+
return call(Identifiers.i18nAttributes, args, null);
|
|
17236
|
+
}
|
|
16963
17237
|
function property(name, expression, sanitizer, sourceSpan) {
|
|
16964
17238
|
const args = [literal(name), expression];
|
|
16965
17239
|
if (sanitizer !== null) {
|
|
@@ -17068,8 +17342,12 @@ function classMapInterpolate(strings, expressions, sourceSpan) {
|
|
|
17068
17342
|
const interpolationArgs = collateInterpolationArgs(strings, expressions);
|
|
17069
17343
|
return callVariadicInstruction(CLASS_MAP_INTERPOLATE_CONFIG, [], interpolationArgs, [], sourceSpan);
|
|
17070
17344
|
}
|
|
17071
|
-
function hostProperty(name, expression, sourceSpan) {
|
|
17072
|
-
|
|
17345
|
+
function hostProperty(name, expression, sanitizer, sourceSpan) {
|
|
17346
|
+
const args = [literal(name), expression];
|
|
17347
|
+
if (sanitizer !== null) {
|
|
17348
|
+
args.push(sanitizer);
|
|
17349
|
+
}
|
|
17350
|
+
return call(Identifiers.hostProperty, args, sourceSpan);
|
|
17073
17351
|
}
|
|
17074
17352
|
function syntheticHostProperty(name, expression, sourceSpan) {
|
|
17075
17353
|
return call(Identifiers.syntheticHostProperty, [literal(name), expression], sourceSpan);
|
|
@@ -17257,13 +17535,10 @@ function callVariadicInstruction(config, baseArgs, interpolationArgs, extraArgs,
|
|
|
17257
17535
|
}
|
|
17258
17536
|
|
|
17259
17537
|
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/reify.mjs
|
|
17260
|
-
var
|
|
17261
|
-
[
|
|
17262
|
-
[
|
|
17263
|
-
[
|
|
17264
|
-
[SanitizerFn.Script, Identifiers.sanitizeScript],
|
|
17265
|
-
[SanitizerFn.Style, Identifiers.sanitizeStyle],
|
|
17266
|
-
[SanitizerFn.Url, Identifiers.sanitizeUrl]
|
|
17538
|
+
var GLOBAL_TARGET_RESOLVERS = /* @__PURE__ */ new Map([
|
|
17539
|
+
["window", Identifiers.resolveWindow],
|
|
17540
|
+
["document", Identifiers.resolveDocument],
|
|
17541
|
+
["body", Identifiers.resolveBody]
|
|
17267
17542
|
]);
|
|
17268
17543
|
function reify(job) {
|
|
17269
17544
|
for (const unit of job.units) {
|
|
@@ -17306,6 +17581,12 @@ function reifyCreateOperations(unit, ops) {
|
|
|
17306
17581
|
case OpKind.I18n:
|
|
17307
17582
|
OpList.replace(op, i18n(op.handle.slot, op.messageIndex, op.subTemplateIndex));
|
|
17308
17583
|
break;
|
|
17584
|
+
case OpKind.I18nAttributes:
|
|
17585
|
+
if (op.i18nAttributesConfig === null) {
|
|
17586
|
+
throw new Error(`AssertionError: i18nAttributesConfig was not set`);
|
|
17587
|
+
}
|
|
17588
|
+
OpList.replace(op, i18nAttributes(op.handle.slot, op.i18nAttributesConfig));
|
|
17589
|
+
break;
|
|
17309
17590
|
case OpKind.Template:
|
|
17310
17591
|
if (!(unit instanceof ViewCompilationUnit)) {
|
|
17311
17592
|
throw new Error(`AssertionError: must be compiling a component`);
|
|
@@ -17327,8 +17608,11 @@ function reifyCreateOperations(unit, ops) {
|
|
|
17327
17608
|
break;
|
|
17328
17609
|
case OpKind.Listener:
|
|
17329
17610
|
const listenerFn = reifyListenerHandler(unit, op.handlerFnName, op.handlerOps, op.consumesDollarEvent);
|
|
17330
|
-
const
|
|
17331
|
-
|
|
17611
|
+
const eventTargetResolver = op.eventTarget ? GLOBAL_TARGET_RESOLVERS.get(op.eventTarget) : null;
|
|
17612
|
+
if (eventTargetResolver === void 0) {
|
|
17613
|
+
throw new Error(`AssertionError: unknown event target ${op.eventTarget}`);
|
|
17614
|
+
}
|
|
17615
|
+
OpList.replace(op, listener(op.name, listenerFn, eventTargetResolver, op.hostListener && op.isAnimationListener, op.sourceSpan));
|
|
17332
17616
|
break;
|
|
17333
17617
|
case OpKind.Variable:
|
|
17334
17618
|
if (op.variable.name === null) {
|
|
@@ -17483,7 +17767,7 @@ function reifyUpdateOperations(_unit, ops) {
|
|
|
17483
17767
|
if (op.isAnimationTrigger) {
|
|
17484
17768
|
OpList.replace(op, syntheticHostProperty(op.name, op.expression, op.sourceSpan));
|
|
17485
17769
|
} else {
|
|
17486
|
-
OpList.replace(op, hostProperty(op.name, op.expression, op.sourceSpan));
|
|
17770
|
+
OpList.replace(op, hostProperty(op.name, op.expression, op.sanitizer, op.sourceSpan));
|
|
17487
17771
|
}
|
|
17488
17772
|
}
|
|
17489
17773
|
break;
|
|
@@ -17561,8 +17845,6 @@ function reifyIrExpression(expr) {
|
|
|
17561
17845
|
return pipeBind(expr.targetSlot.slot, expr.varOffset, expr.args);
|
|
17562
17846
|
case ExpressionKind.PipeBindingVariadic:
|
|
17563
17847
|
return pipeBindV(expr.targetSlot.slot, expr.varOffset, expr.args);
|
|
17564
|
-
case ExpressionKind.SanitizerExpr:
|
|
17565
|
-
return importExpr(sanitizerIdentifierMap.get(expr.fn));
|
|
17566
17848
|
case ExpressionKind.SlotLiteralExpr:
|
|
17567
17849
|
return literal(expr.slot.slot);
|
|
17568
17850
|
default:
|
|
@@ -17622,6 +17904,28 @@ function removeI18nContexts(job) {
|
|
|
17622
17904
|
}
|
|
17623
17905
|
}
|
|
17624
17906
|
|
|
17907
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/remove_unused_i18n_attrs.mjs
|
|
17908
|
+
function removeUnusedI18nAttributesOps(job) {
|
|
17909
|
+
for (const unit of job.units) {
|
|
17910
|
+
const ownersWithI18nExpressions = /* @__PURE__ */ new Set();
|
|
17911
|
+
for (const op of unit.update) {
|
|
17912
|
+
switch (op.kind) {
|
|
17913
|
+
case OpKind.I18nExpression:
|
|
17914
|
+
ownersWithI18nExpressions.add(op.i18nOwner);
|
|
17915
|
+
}
|
|
17916
|
+
}
|
|
17917
|
+
for (const op of unit.create) {
|
|
17918
|
+
switch (op.kind) {
|
|
17919
|
+
case OpKind.I18nAttributes:
|
|
17920
|
+
if (ownersWithI18nExpressions.has(op.xref)) {
|
|
17921
|
+
continue;
|
|
17922
|
+
}
|
|
17923
|
+
OpList.remove(op);
|
|
17924
|
+
}
|
|
17925
|
+
}
|
|
17926
|
+
}
|
|
17927
|
+
}
|
|
17928
|
+
|
|
17625
17929
|
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/repeater_derived_vars.mjs
|
|
17626
17930
|
function generateRepeaterDerivedVars(job) {
|
|
17627
17931
|
const repeaters = /* @__PURE__ */ new Map();
|
|
@@ -17734,8 +18038,9 @@ function resolveI18nElementPlaceholders(job) {
|
|
|
17734
18038
|
}
|
|
17735
18039
|
resolvePlaceholdersForView(job, job.root, i18nContexts, elements);
|
|
17736
18040
|
}
|
|
17737
|
-
function resolvePlaceholdersForView(job, unit, i18nContexts, elements) {
|
|
18041
|
+
function resolvePlaceholdersForView(job, unit, i18nContexts, elements, pendingStructuralDirective) {
|
|
17738
18042
|
let currentOps = null;
|
|
18043
|
+
let pendingStructuralDirectiveCloses = /* @__PURE__ */ new Map();
|
|
17739
18044
|
for (const op of unit.create) {
|
|
17740
18045
|
switch (op.kind) {
|
|
17741
18046
|
case OpKind.I18nStart:
|
|
@@ -17752,52 +18057,135 @@ function resolvePlaceholdersForView(job, unit, i18nContexts, elements) {
|
|
|
17752
18057
|
if (currentOps === null) {
|
|
17753
18058
|
throw Error("i18n tag placeholder should only occur inside an i18n block");
|
|
17754
18059
|
}
|
|
17755
|
-
|
|
17756
|
-
|
|
17757
|
-
|
|
17758
|
-
flags |= I18nParamValueFlags.CloseTag;
|
|
18060
|
+
recordElementStart(op, currentOps.i18nContext, currentOps.i18nBlock, pendingStructuralDirective);
|
|
18061
|
+
if (pendingStructuralDirective && op.i18nPlaceholder.closeName) {
|
|
18062
|
+
pendingStructuralDirectiveCloses.set(op.xref, pendingStructuralDirective);
|
|
17759
18063
|
}
|
|
17760
|
-
|
|
18064
|
+
pendingStructuralDirective = void 0;
|
|
17761
18065
|
}
|
|
17762
18066
|
break;
|
|
17763
18067
|
case OpKind.ElementEnd:
|
|
17764
18068
|
const startOp = elements.get(op.xref);
|
|
17765
18069
|
if (startOp && startOp.i18nPlaceholder !== void 0) {
|
|
17766
18070
|
if (currentOps === null) {
|
|
17767
|
-
throw Error("i18n tag placeholder should only occur inside an i18n block");
|
|
17768
|
-
}
|
|
17769
|
-
const { closeName } = startOp.i18nPlaceholder;
|
|
17770
|
-
if (closeName !== "") {
|
|
17771
|
-
addParam(currentOps.i18nContext.params, closeName, startOp.handle.slot, currentOps.i18nBlock.subTemplateIndex, I18nParamValueFlags.ElementTag | I18nParamValueFlags.CloseTag);
|
|
18071
|
+
throw Error("AssertionError: i18n tag placeholder should only occur inside an i18n block");
|
|
17772
18072
|
}
|
|
18073
|
+
recordElementClose(startOp, currentOps.i18nContext, currentOps.i18nBlock, pendingStructuralDirectiveCloses.get(op.xref));
|
|
18074
|
+
pendingStructuralDirectiveCloses.delete(op.xref);
|
|
17773
18075
|
}
|
|
17774
18076
|
break;
|
|
17775
|
-
case OpKind.
|
|
18077
|
+
case OpKind.Projection:
|
|
17776
18078
|
if (op.i18nPlaceholder !== void 0) {
|
|
17777
18079
|
if (currentOps === null) {
|
|
17778
18080
|
throw Error("i18n tag placeholder should only occur inside an i18n block");
|
|
17779
18081
|
}
|
|
17780
|
-
|
|
17781
|
-
|
|
17782
|
-
|
|
17783
|
-
|
|
17784
|
-
|
|
17785
|
-
|
|
18082
|
+
recordElementStart(op, currentOps.i18nContext, currentOps.i18nBlock, pendingStructuralDirective);
|
|
18083
|
+
recordElementClose(op, currentOps.i18nContext, currentOps.i18nBlock, pendingStructuralDirective);
|
|
18084
|
+
pendingStructuralDirective = void 0;
|
|
18085
|
+
}
|
|
18086
|
+
break;
|
|
18087
|
+
case OpKind.Template:
|
|
18088
|
+
const view = job.views.get(op.xref);
|
|
18089
|
+
if (op.i18nPlaceholder === void 0) {
|
|
18090
|
+
resolvePlaceholdersForView(job, view, i18nContexts, elements);
|
|
18091
|
+
} else {
|
|
18092
|
+
if (currentOps === null) {
|
|
18093
|
+
throw Error("i18n tag placeholder should only occur inside an i18n block");
|
|
17786
18094
|
}
|
|
17787
|
-
|
|
17788
|
-
|
|
17789
|
-
|
|
17790
|
-
|
|
18095
|
+
if (op.templateKind === TemplateKind.Structural) {
|
|
18096
|
+
resolvePlaceholdersForView(job, view, i18nContexts, elements, op);
|
|
18097
|
+
} else {
|
|
18098
|
+
recordTemplateStart(job, view, op.handle.slot, op.i18nPlaceholder, currentOps.i18nContext, currentOps.i18nBlock, pendingStructuralDirective);
|
|
18099
|
+
resolvePlaceholdersForView(job, view, i18nContexts, elements);
|
|
18100
|
+
recordTemplateClose(job, view, op.handle.slot, op.i18nPlaceholder, currentOps.i18nContext, currentOps.i18nBlock, pendingStructuralDirective);
|
|
18101
|
+
pendingStructuralDirective = void 0;
|
|
17791
18102
|
}
|
|
18103
|
+
}
|
|
18104
|
+
break;
|
|
18105
|
+
case OpKind.RepeaterCreate:
|
|
18106
|
+
if (pendingStructuralDirective !== void 0) {
|
|
18107
|
+
throw Error("AssertionError: Unexpected structural directive associated with @for block");
|
|
18108
|
+
}
|
|
18109
|
+
const forSlot = op.handle.slot + 1;
|
|
18110
|
+
const forView = job.views.get(op.xref);
|
|
18111
|
+
if (op.i18nPlaceholder === void 0) {
|
|
18112
|
+
resolvePlaceholdersForView(job, forView, i18nContexts, elements);
|
|
17792
18113
|
} else {
|
|
17793
|
-
|
|
18114
|
+
if (currentOps === null) {
|
|
18115
|
+
throw Error("i18n tag placeholder should only occur inside an i18n block");
|
|
18116
|
+
}
|
|
18117
|
+
recordTemplateStart(job, forView, forSlot, op.i18nPlaceholder, currentOps.i18nContext, currentOps.i18nBlock, pendingStructuralDirective);
|
|
18118
|
+
resolvePlaceholdersForView(job, forView, i18nContexts, elements);
|
|
18119
|
+
recordTemplateClose(job, forView, forSlot, op.i18nPlaceholder, currentOps.i18nContext, currentOps.i18nBlock, pendingStructuralDirective);
|
|
18120
|
+
pendingStructuralDirective = void 0;
|
|
18121
|
+
}
|
|
18122
|
+
if (op.emptyView !== null) {
|
|
18123
|
+
const emptySlot = op.handle.slot + 2;
|
|
18124
|
+
const emptyView = job.views.get(op.emptyView);
|
|
18125
|
+
if (op.emptyI18nPlaceholder === void 0) {
|
|
18126
|
+
resolvePlaceholdersForView(job, emptyView, i18nContexts, elements);
|
|
18127
|
+
} else {
|
|
18128
|
+
if (currentOps === null) {
|
|
18129
|
+
throw Error("i18n tag placeholder should only occur inside an i18n block");
|
|
18130
|
+
}
|
|
18131
|
+
recordTemplateStart(job, emptyView, emptySlot, op.emptyI18nPlaceholder, currentOps.i18nContext, currentOps.i18nBlock, pendingStructuralDirective);
|
|
18132
|
+
resolvePlaceholdersForView(job, emptyView, i18nContexts, elements);
|
|
18133
|
+
recordTemplateClose(job, emptyView, emptySlot, op.emptyI18nPlaceholder, currentOps.i18nContext, currentOps.i18nBlock, pendingStructuralDirective);
|
|
18134
|
+
pendingStructuralDirective = void 0;
|
|
18135
|
+
}
|
|
17794
18136
|
}
|
|
17795
18137
|
break;
|
|
17796
18138
|
}
|
|
17797
18139
|
}
|
|
17798
18140
|
}
|
|
17799
|
-
function
|
|
17800
|
-
|
|
18141
|
+
function recordElementStart(op, i18nContext, i18nBlock, structuralDirective) {
|
|
18142
|
+
const { startName, closeName } = op.i18nPlaceholder;
|
|
18143
|
+
let flags = I18nParamValueFlags.ElementTag | I18nParamValueFlags.OpenTag;
|
|
18144
|
+
let value = op.handle.slot;
|
|
18145
|
+
if (structuralDirective !== void 0) {
|
|
18146
|
+
flags |= I18nParamValueFlags.TemplateTag;
|
|
18147
|
+
value = { element: value, template: structuralDirective.handle.slot };
|
|
18148
|
+
}
|
|
18149
|
+
if (!closeName) {
|
|
18150
|
+
flags |= I18nParamValueFlags.CloseTag;
|
|
18151
|
+
}
|
|
18152
|
+
addParam(i18nContext.params, startName, value, i18nBlock.subTemplateIndex, flags);
|
|
18153
|
+
}
|
|
18154
|
+
function recordElementClose(op, i18nContext, i18nBlock, structuralDirective) {
|
|
18155
|
+
const { closeName } = op.i18nPlaceholder;
|
|
18156
|
+
if (closeName) {
|
|
18157
|
+
let flags = I18nParamValueFlags.ElementTag | I18nParamValueFlags.CloseTag;
|
|
18158
|
+
let value = op.handle.slot;
|
|
18159
|
+
if (structuralDirective !== void 0) {
|
|
18160
|
+
flags |= I18nParamValueFlags.TemplateTag;
|
|
18161
|
+
value = { element: value, template: structuralDirective.handle.slot };
|
|
18162
|
+
}
|
|
18163
|
+
addParam(i18nContext.params, closeName, value, i18nBlock.subTemplateIndex, flags);
|
|
18164
|
+
}
|
|
18165
|
+
}
|
|
18166
|
+
function recordTemplateStart(job, view, slot, i18nPlaceholder, i18nContext, i18nBlock, structuralDirective) {
|
|
18167
|
+
let { startName, closeName } = i18nPlaceholder;
|
|
18168
|
+
let flags = I18nParamValueFlags.TemplateTag | I18nParamValueFlags.OpenTag;
|
|
18169
|
+
if (!closeName) {
|
|
18170
|
+
flags |= I18nParamValueFlags.CloseTag;
|
|
18171
|
+
}
|
|
18172
|
+
if (structuralDirective !== void 0) {
|
|
18173
|
+
addParam(i18nContext.params, startName, structuralDirective.handle.slot, i18nBlock.subTemplateIndex, flags);
|
|
18174
|
+
}
|
|
18175
|
+
addParam(i18nContext.params, startName, slot, getSubTemplateIndexForTemplateTag(job, i18nBlock, view), flags);
|
|
18176
|
+
}
|
|
18177
|
+
function recordTemplateClose(job, view, slot, i18nPlaceholder, i18nContext, i18nBlock, structuralDirective) {
|
|
18178
|
+
const { startName, closeName } = i18nPlaceholder;
|
|
18179
|
+
const flags = I18nParamValueFlags.TemplateTag | I18nParamValueFlags.CloseTag;
|
|
18180
|
+
if (closeName) {
|
|
18181
|
+
addParam(i18nContext.params, closeName, slot, getSubTemplateIndexForTemplateTag(job, i18nBlock, view), flags);
|
|
18182
|
+
if (structuralDirective !== void 0) {
|
|
18183
|
+
addParam(i18nContext.params, closeName, structuralDirective.handle.slot, i18nBlock.subTemplateIndex, flags);
|
|
18184
|
+
}
|
|
18185
|
+
}
|
|
18186
|
+
}
|
|
18187
|
+
function getSubTemplateIndexForTemplateTag(job, i18nOp, view) {
|
|
18188
|
+
for (const childOp of view.create) {
|
|
17801
18189
|
if (childOp.kind === OpKind.I18nStart) {
|
|
17802
18190
|
return childOp.subTemplateIndex;
|
|
17803
18191
|
}
|
|
@@ -17813,6 +18201,7 @@ function addParam(params, placeholder, value, subTemplateIndex, flags) {
|
|
|
17813
18201
|
|
|
17814
18202
|
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/resolve_i18n_expression_placeholders.mjs
|
|
17815
18203
|
function resolveI18nExpressionPlaceholders(job) {
|
|
18204
|
+
var _a2;
|
|
17816
18205
|
const subTemplateIndicies = /* @__PURE__ */ new Map();
|
|
17817
18206
|
const i18nContexts = /* @__PURE__ */ new Map();
|
|
17818
18207
|
for (const unit of job.units) {
|
|
@@ -17828,12 +18217,13 @@ function resolveI18nExpressionPlaceholders(job) {
|
|
|
17828
18217
|
}
|
|
17829
18218
|
}
|
|
17830
18219
|
const expressionIndices = /* @__PURE__ */ new Map();
|
|
18220
|
+
const referenceIndex = (op) => op.usage === I18nExpressionFor.I18nText ? op.i18nOwner : op.context;
|
|
17831
18221
|
for (const unit of job.units) {
|
|
17832
18222
|
for (const op of unit.update) {
|
|
17833
18223
|
if (op.kind === OpKind.I18nExpression) {
|
|
17834
18224
|
const i18nContext = i18nContexts.get(op.context);
|
|
17835
|
-
const index = expressionIndices.get(op
|
|
17836
|
-
const subTemplateIndex = subTemplateIndicies.get(op.
|
|
18225
|
+
const index = expressionIndices.get(referenceIndex(op)) || 0;
|
|
18226
|
+
const subTemplateIndex = (_a2 = subTemplateIndicies.get(op.i18nOwner)) != null ? _a2 : null;
|
|
17837
18227
|
const params = op.resolutionTime === I18nParamResolutionTime.Creation ? i18nContext.params : i18nContext.postprocessingParams;
|
|
17838
18228
|
const values = params.get(op.i18nPlaceholder) || [];
|
|
17839
18229
|
values.push({
|
|
@@ -17842,7 +18232,7 @@ function resolveI18nExpressionPlaceholders(job) {
|
|
|
17842
18232
|
flags: I18nParamValueFlags.ExpressionIndex
|
|
17843
18233
|
});
|
|
17844
18234
|
params.set(op.i18nPlaceholder, values);
|
|
17845
|
-
expressionIndices.set(op
|
|
18235
|
+
expressionIndices.set(referenceIndex(op), index + 1);
|
|
17846
18236
|
}
|
|
17847
18237
|
}
|
|
17848
18238
|
}
|
|
@@ -17957,30 +18347,54 @@ function processLexicalScope2(unit, ops, savedView) {
|
|
|
17957
18347
|
}
|
|
17958
18348
|
|
|
17959
18349
|
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/resolve_sanitizers.mjs
|
|
17960
|
-
var
|
|
17961
|
-
[SecurityContext.HTML,
|
|
17962
|
-
[SecurityContext.
|
|
17963
|
-
[SecurityContext.
|
|
17964
|
-
[SecurityContext.
|
|
17965
|
-
[SecurityContext.
|
|
18350
|
+
var sanitizerFns = /* @__PURE__ */ new Map([
|
|
18351
|
+
[SecurityContext.HTML, Identifiers.sanitizeHtml],
|
|
18352
|
+
[SecurityContext.RESOURCE_URL, Identifiers.sanitizeResourceUrl],
|
|
18353
|
+
[SecurityContext.SCRIPT, Identifiers.sanitizeScript],
|
|
18354
|
+
[SecurityContext.STYLE, Identifiers.sanitizeStyle],
|
|
18355
|
+
[SecurityContext.URL, Identifiers.sanitizeUrl]
|
|
18356
|
+
]);
|
|
18357
|
+
var trustedValueFns = /* @__PURE__ */ new Map([
|
|
18358
|
+
[SecurityContext.HTML, Identifiers.trustConstantHtml],
|
|
18359
|
+
[SecurityContext.RESOURCE_URL, Identifiers.trustConstantResourceUrl]
|
|
17966
18360
|
]);
|
|
17967
18361
|
function resolveSanitizers(job) {
|
|
18362
|
+
var _a2, _b2;
|
|
17968
18363
|
for (const unit of job.units) {
|
|
17969
18364
|
const elements = createOpXrefMap(unit);
|
|
17970
|
-
|
|
18365
|
+
if (job.kind !== CompilationJobKind.Host) {
|
|
18366
|
+
for (const op of unit.create) {
|
|
18367
|
+
if (op.kind === OpKind.ExtractedAttribute) {
|
|
18368
|
+
const trustedValueFn = (_a2 = trustedValueFns.get(getOnlySecurityContext(op.securityContext))) != null ? _a2 : null;
|
|
18369
|
+
op.trustedValueFn = trustedValueFn !== null ? importExpr(trustedValueFn) : null;
|
|
18370
|
+
}
|
|
18371
|
+
}
|
|
18372
|
+
}
|
|
17971
18373
|
for (const op of unit.update) {
|
|
17972
18374
|
switch (op.kind) {
|
|
17973
18375
|
case OpKind.Property:
|
|
17974
18376
|
case OpKind.Attribute:
|
|
17975
|
-
|
|
17976
|
-
|
|
18377
|
+
case OpKind.HostProperty:
|
|
18378
|
+
let sanitizerFn = null;
|
|
18379
|
+
if (Array.isArray(op.securityContext) && op.securityContext.length === 2 && op.securityContext.indexOf(SecurityContext.URL) > -1 && op.securityContext.indexOf(SecurityContext.RESOURCE_URL) > -1) {
|
|
18380
|
+
sanitizerFn = Identifiers.sanitizeUrlOrResourceUrl;
|
|
18381
|
+
} else {
|
|
18382
|
+
sanitizerFn = (_b2 = sanitizerFns.get(getOnlySecurityContext(op.securityContext))) != null ? _b2 : null;
|
|
18383
|
+
}
|
|
18384
|
+
op.sanitizer = sanitizerFn !== null ? importExpr(sanitizerFn) : null;
|
|
17977
18385
|
if (op.sanitizer === null) {
|
|
17978
|
-
|
|
17979
|
-
if (
|
|
17980
|
-
|
|
18386
|
+
let isIframe = false;
|
|
18387
|
+
if (job.kind === CompilationJobKind.Host || op.kind === OpKind.HostProperty) {
|
|
18388
|
+
isIframe = true;
|
|
18389
|
+
} else {
|
|
18390
|
+
const ownerOp = elements.get(op.target);
|
|
18391
|
+
if (ownerOp === void 0 || !isElementOrContainerOp(ownerOp)) {
|
|
18392
|
+
throw Error("Property should have an element-like owner");
|
|
18393
|
+
}
|
|
18394
|
+
isIframe = isIframeElement(ownerOp);
|
|
17981
18395
|
}
|
|
17982
|
-
if (
|
|
17983
|
-
op.sanitizer =
|
|
18396
|
+
if (isIframe && isIframeSecuritySensitiveAttr(op.name)) {
|
|
18397
|
+
op.sanitizer = importExpr(Identifiers.validateIframeAttribute);
|
|
17984
18398
|
}
|
|
17985
18399
|
}
|
|
17986
18400
|
break;
|
|
@@ -17992,6 +18406,15 @@ function isIframeElement(op) {
|
|
|
17992
18406
|
var _a2;
|
|
17993
18407
|
return op.kind === OpKind.ElementStart && ((_a2 = op.tag) == null ? void 0 : _a2.toLowerCase()) === "iframe";
|
|
17994
18408
|
}
|
|
18409
|
+
function getOnlySecurityContext(securityContext) {
|
|
18410
|
+
if (Array.isArray(securityContext)) {
|
|
18411
|
+
if (securityContext.length > 1) {
|
|
18412
|
+
throw Error(`AssertionError: Ambiguous security context`);
|
|
18413
|
+
}
|
|
18414
|
+
return securityContext[0] || SecurityContext.NONE;
|
|
18415
|
+
}
|
|
18416
|
+
return securityContext;
|
|
18417
|
+
}
|
|
17995
18418
|
|
|
17996
18419
|
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/save_restore_view.mjs
|
|
17997
18420
|
function saveAndRestoreView(job) {
|
|
@@ -18639,12 +19062,12 @@ var phases = [
|
|
|
18639
19062
|
{ kind: CompilationJobKind.Tmpl, fn: removeContentSelectors },
|
|
18640
19063
|
{ kind: CompilationJobKind.Host, fn: parseHostStyleProperties },
|
|
18641
19064
|
{ kind: CompilationJobKind.Tmpl, fn: emitNamespaceChanges },
|
|
18642
|
-
{ kind: CompilationJobKind.Both, fn: specializeStyleBindings },
|
|
18643
|
-
{ kind: CompilationJobKind.Both, fn: specializeBindings },
|
|
18644
19065
|
{ kind: CompilationJobKind.Tmpl, fn: propagateI18nBlocks },
|
|
18645
19066
|
{ kind: CompilationJobKind.Tmpl, fn: wrapI18nIcus },
|
|
18646
|
-
{ kind: CompilationJobKind.
|
|
19067
|
+
{ kind: CompilationJobKind.Both, fn: specializeStyleBindings },
|
|
19068
|
+
{ kind: CompilationJobKind.Both, fn: specializeBindings },
|
|
18647
19069
|
{ kind: CompilationJobKind.Both, fn: extractAttributes },
|
|
19070
|
+
{ kind: CompilationJobKind.Tmpl, fn: createI18nContexts },
|
|
18648
19071
|
{ kind: CompilationJobKind.Both, fn: parseExtractedStyles },
|
|
18649
19072
|
{ kind: CompilationJobKind.Tmpl, fn: removeEmptyBindings },
|
|
18650
19073
|
{ kind: CompilationJobKind.Both, fn: collapseSingletonInterpolations },
|
|
@@ -18652,14 +19075,17 @@ var phases = [
|
|
|
18652
19075
|
{ kind: CompilationJobKind.Tmpl, fn: generateConditionalExpressions },
|
|
18653
19076
|
{ kind: CompilationJobKind.Tmpl, fn: createPipes },
|
|
18654
19077
|
{ kind: CompilationJobKind.Tmpl, fn: configureDeferInstructions },
|
|
18655
|
-
{ kind: CompilationJobKind.Tmpl, fn:
|
|
19078
|
+
{ kind: CompilationJobKind.Tmpl, fn: convertI18nText },
|
|
19079
|
+
{ kind: CompilationJobKind.Tmpl, fn: convertI18nBindings },
|
|
19080
|
+
{ kind: CompilationJobKind.Tmpl, fn: removeUnusedI18nAttributesOps },
|
|
19081
|
+
{ kind: CompilationJobKind.Tmpl, fn: assignI18nSlotDependencies },
|
|
18656
19082
|
{ kind: CompilationJobKind.Tmpl, fn: applyI18nExpressions },
|
|
18657
19083
|
{ kind: CompilationJobKind.Tmpl, fn: createVariadicPipes },
|
|
18658
19084
|
{ kind: CompilationJobKind.Both, fn: generatePureLiteralStructures },
|
|
18659
19085
|
{ kind: CompilationJobKind.Tmpl, fn: generateProjectionDefs },
|
|
18660
19086
|
{ kind: CompilationJobKind.Tmpl, fn: generateVariables },
|
|
18661
19087
|
{ kind: CompilationJobKind.Tmpl, fn: saveAndRestoreView },
|
|
18662
|
-
{ kind: CompilationJobKind.
|
|
19088
|
+
{ kind: CompilationJobKind.Both, fn: deleteAnyCasts },
|
|
18663
19089
|
{ kind: CompilationJobKind.Both, fn: resolveDollarEvent },
|
|
18664
19090
|
{ kind: CompilationJobKind.Tmpl, fn: generateRepeaterDerivedVars },
|
|
18665
19091
|
{ kind: CompilationJobKind.Tmpl, fn: generateTrackVariables },
|
|
@@ -18667,7 +19093,7 @@ var phases = [
|
|
|
18667
19093
|
{ kind: CompilationJobKind.Tmpl, fn: resolveDeferTargetNames },
|
|
18668
19094
|
{ kind: CompilationJobKind.Tmpl, fn: optimizeTrackFns },
|
|
18669
19095
|
{ kind: CompilationJobKind.Both, fn: resolveContexts },
|
|
18670
|
-
{ kind: CompilationJobKind.
|
|
19096
|
+
{ kind: CompilationJobKind.Both, fn: resolveSanitizers },
|
|
18671
19097
|
{ kind: CompilationJobKind.Tmpl, fn: liftLocalRefs },
|
|
18672
19098
|
{ kind: CompilationJobKind.Both, fn: generateNullishCoalesceExpressions },
|
|
18673
19099
|
{ kind: CompilationJobKind.Both, fn: expandSafeReads },
|
|
@@ -18682,7 +19108,6 @@ var phases = [
|
|
|
18682
19108
|
{ kind: CompilationJobKind.Tmpl, fn: collectI18nConsts },
|
|
18683
19109
|
{ kind: CompilationJobKind.Tmpl, fn: collectConstExpressions },
|
|
18684
19110
|
{ kind: CompilationJobKind.Both, fn: collectElementConsts },
|
|
18685
|
-
{ kind: CompilationJobKind.Tmpl, fn: assignI18nSlotDependencies },
|
|
18686
19111
|
{ kind: CompilationJobKind.Tmpl, fn: removeI18nContexts },
|
|
18687
19112
|
{ kind: CompilationJobKind.Both, fn: countVariables },
|
|
18688
19113
|
{ kind: CompilationJobKind.Tmpl, fn: generateAdvance },
|
|
@@ -18800,6 +19225,8 @@ function emitHostBindingFunction(job) {
|
|
|
18800
19225
|
|
|
18801
19226
|
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/ingest.mjs
|
|
18802
19227
|
var compatibilityMode = CompatibilityMode.TemplateDefinitionBuilder;
|
|
19228
|
+
var domSchema = new DomElementSchemaRegistry();
|
|
19229
|
+
var NG_TEMPLATE_TAG_NAME = "ng-template";
|
|
18803
19230
|
function ingestComponent(componentName, template2, constantPool, relativeContextFilePath, i18nUseExternalIds, deferBlocksMeta) {
|
|
18804
19231
|
const job = new ComponentCompilationJob(componentName, constantPool, compatibilityMode, relativeContextFilePath, i18nUseExternalIds, deferBlocksMeta);
|
|
18805
19232
|
ingestNodes(job.root, template2);
|
|
@@ -18809,50 +19236,55 @@ function ingestHostBinding(input, bindingParser, constantPool) {
|
|
|
18809
19236
|
var _a2, _b2, _c2;
|
|
18810
19237
|
const job = new HostBindingCompilationJob(input.componentName, constantPool, compatibilityMode);
|
|
18811
19238
|
for (const property2 of (_a2 = input.properties) != null ? _a2 : []) {
|
|
18812
|
-
|
|
19239
|
+
let bindingKind = BindingKind.Property;
|
|
19240
|
+
if (property2.name.startsWith("attr.")) {
|
|
19241
|
+
property2.name = property2.name.substring("attr.".length);
|
|
19242
|
+
bindingKind = BindingKind.Attribute;
|
|
19243
|
+
}
|
|
19244
|
+
if (property2.isAnimation) {
|
|
19245
|
+
bindingKind = BindingKind.Animation;
|
|
19246
|
+
}
|
|
19247
|
+
const securityContexts = bindingParser.calcPossibleSecurityContexts(input.componentSelector, property2.name, bindingKind === BindingKind.Attribute).filter((context) => context !== SecurityContext.NONE);
|
|
19248
|
+
ingestHostProperty(job, property2, bindingKind, false, securityContexts);
|
|
18813
19249
|
}
|
|
18814
19250
|
for (const [name, expr] of (_b2 = Object.entries(input.attributes)) != null ? _b2 : []) {
|
|
18815
|
-
|
|
19251
|
+
const securityContexts = bindingParser.calcPossibleSecurityContexts(input.componentSelector, name, true).filter((context) => context !== SecurityContext.NONE);
|
|
19252
|
+
ingestHostAttribute(job, name, expr, securityContexts);
|
|
18816
19253
|
}
|
|
18817
19254
|
for (const event of (_c2 = input.events) != null ? _c2 : []) {
|
|
18818
19255
|
ingestHostEvent(job, event);
|
|
18819
19256
|
}
|
|
18820
19257
|
return job;
|
|
18821
19258
|
}
|
|
18822
|
-
function ingestHostProperty(job, property2, isTextAttribute) {
|
|
19259
|
+
function ingestHostProperty(job, property2, bindingKind, isTextAttribute, securityContexts) {
|
|
18823
19260
|
let expression;
|
|
18824
19261
|
const ast = property2.expression.ast;
|
|
18825
19262
|
if (ast instanceof Interpolation) {
|
|
18826
|
-
expression = new Interpolation2(ast.strings, ast.expressions.map((expr) => convertAst(expr, job, property2.sourceSpan)));
|
|
19263
|
+
expression = new Interpolation2(ast.strings, ast.expressions.map((expr) => convertAst(expr, job, property2.sourceSpan)), []);
|
|
18827
19264
|
} else {
|
|
18828
19265
|
expression = convertAst(ast, job, property2.sourceSpan);
|
|
18829
19266
|
}
|
|
18830
|
-
|
|
18831
|
-
if (property2.name.startsWith("attr.")) {
|
|
18832
|
-
property2.name = property2.name.substring("attr.".length);
|
|
18833
|
-
bindingKind = BindingKind.Attribute;
|
|
18834
|
-
}
|
|
18835
|
-
if (property2.isAnimation) {
|
|
18836
|
-
bindingKind = BindingKind.Animation;
|
|
18837
|
-
}
|
|
18838
|
-
job.root.update.push(createBindingOp(job.root.xref, bindingKind, property2.name, expression, null, SecurityContext.NONE, isTextAttribute, false, property2.sourceSpan));
|
|
19267
|
+
job.root.update.push(createBindingOp(job.root.xref, bindingKind, property2.name, expression, null, securityContexts, isTextAttribute, false, null, null, property2.sourceSpan));
|
|
18839
19268
|
}
|
|
18840
|
-
function ingestHostAttribute(job, name, value) {
|
|
19269
|
+
function ingestHostAttribute(job, name, value, securityContexts) {
|
|
18841
19270
|
const attrBinding = createBindingOp(
|
|
18842
19271
|
job.root.xref,
|
|
18843
19272
|
BindingKind.Attribute,
|
|
18844
19273
|
name,
|
|
18845
19274
|
value,
|
|
18846
19275
|
null,
|
|
18847
|
-
|
|
19276
|
+
securityContexts,
|
|
18848
19277
|
true,
|
|
18849
19278
|
false,
|
|
19279
|
+
null,
|
|
19280
|
+
null,
|
|
18850
19281
|
null
|
|
18851
19282
|
);
|
|
18852
19283
|
job.root.update.push(attrBinding);
|
|
18853
19284
|
}
|
|
18854
19285
|
function ingestHostEvent(job, event) {
|
|
18855
|
-
const
|
|
19286
|
+
const [phase, target] = event.type === 0 ? [null, event.targetOrPhase] : [event.targetOrPhase, null];
|
|
19287
|
+
const eventBinding = createListenerOp(job.root.xref, new SlotHandle(), event.name, null, [], phase, target, true, event.sourceSpan);
|
|
18856
19288
|
eventBinding.handlerOps.push(createStatementOp(new ReturnStatement(convertAst(event.handler.ast, job, event.sourceSpan), event.handlerSpan)));
|
|
18857
19289
|
job.root.create.push(eventBinding);
|
|
18858
19290
|
}
|
|
@@ -18892,14 +19324,17 @@ function ingestElement(unit, element2) {
|
|
|
18892
19324
|
const [namespaceKey, elementName] = splitNsName(element2.name);
|
|
18893
19325
|
const startOp = createElementStartOp(elementName, id, namespaceForKey(namespaceKey), element2.i18n instanceof TagPlaceholder ? element2.i18n : void 0, element2.startSourceSpan);
|
|
18894
19326
|
unit.create.push(startOp);
|
|
18895
|
-
|
|
19327
|
+
ingestElementBindings(unit, startOp, element2);
|
|
18896
19328
|
ingestReferences(startOp, element2);
|
|
19329
|
+
let i18nBlockId = null;
|
|
19330
|
+
if (element2.i18n instanceof Message) {
|
|
19331
|
+
i18nBlockId = unit.job.allocateXrefId();
|
|
19332
|
+
unit.create.push(createI18nStartOp(i18nBlockId, element2.i18n));
|
|
19333
|
+
}
|
|
18897
19334
|
ingestNodes(unit, element2.children);
|
|
18898
19335
|
const endOp = createElementEndOp(id, (_a2 = element2.endSourceSpan) != null ? _a2 : element2.startSourceSpan);
|
|
18899
19336
|
unit.create.push(endOp);
|
|
18900
|
-
if (
|
|
18901
|
-
const i18nBlockId = unit.job.allocateXrefId();
|
|
18902
|
-
OpList.insertAfter(createI18nStartOp(i18nBlockId, element2.i18n), startOp);
|
|
19337
|
+
if (i18nBlockId !== null) {
|
|
18903
19338
|
OpList.insertBefore(createI18nEndOp(i18nBlockId), endOp);
|
|
18904
19339
|
}
|
|
18905
19340
|
}
|
|
@@ -18916,24 +19351,30 @@ function ingestTemplate(unit, tmpl) {
|
|
|
18916
19351
|
const i18nPlaceholder = tmpl.i18n instanceof TagPlaceholder ? tmpl.i18n : void 0;
|
|
18917
19352
|
const namespace = namespaceForKey(namespacePrefix);
|
|
18918
19353
|
const functionNameSuffix = tagNameWithoutNamespace === null ? "" : prefixWithNamespace(tagNameWithoutNamespace, namespace);
|
|
18919
|
-
const
|
|
18920
|
-
|
|
18921
|
-
|
|
18922
|
-
|
|
19354
|
+
const templateKind = isPlainTemplate(tmpl) ? TemplateKind.NgTemplate : TemplateKind.Structural;
|
|
19355
|
+
const templateOp = createTemplateOp(childView.xref, templateKind, tagNameWithoutNamespace, functionNameSuffix, namespace, i18nPlaceholder, tmpl.startSourceSpan);
|
|
19356
|
+
unit.create.push(templateOp);
|
|
19357
|
+
ingestTemplateBindings(unit, templateOp, tmpl, templateKind);
|
|
19358
|
+
ingestReferences(templateOp, tmpl);
|
|
18923
19359
|
ingestNodes(childView, tmpl.children);
|
|
18924
19360
|
for (const { name, value } of tmpl.variables) {
|
|
18925
19361
|
childView.contextVariables.set(name, value !== "" ? value : "$implicit");
|
|
18926
19362
|
}
|
|
18927
|
-
if (
|
|
19363
|
+
if (templateKind === TemplateKind.NgTemplate && tmpl.i18n instanceof Message) {
|
|
18928
19364
|
const id = unit.job.allocateXrefId();
|
|
18929
19365
|
OpList.insertAfter(createI18nStartOp(id, tmpl.i18n), childView.create.head);
|
|
18930
19366
|
OpList.insertBefore(createI18nEndOp(id), childView.create.tail);
|
|
18931
19367
|
}
|
|
18932
19368
|
}
|
|
18933
19369
|
function ingestContent(unit, content) {
|
|
18934
|
-
|
|
19370
|
+
if (content.i18n !== void 0 && !(content.i18n instanceof TagPlaceholder)) {
|
|
19371
|
+
throw Error(`Unhandled i18n metadata type for element: ${content.i18n.constructor.name}`);
|
|
19372
|
+
}
|
|
19373
|
+
const attrs = content.attributes.flatMap((a) => [a.name, a.value]);
|
|
19374
|
+
const op = createProjectionOp(unit.job.allocateXrefId(), content.selector, content.i18n, attrs, content.sourceSpan);
|
|
18935
19375
|
for (const attr of content.attributes) {
|
|
18936
|
-
|
|
19376
|
+
const securityContext = domSchema.securityContext(content.name, attr.name, true);
|
|
19377
|
+
unit.update.push(createBindingOp(op.xref, BindingKind.Attribute, attr.name, literal(attr.value), null, securityContext, true, false, null, asMessage(attr.i18n), attr.sourceSpan));
|
|
18937
19378
|
}
|
|
18938
19379
|
unit.create.push(op);
|
|
18939
19380
|
}
|
|
@@ -18961,9 +19402,10 @@ function ingestBoundText(unit, text2, i18nPlaceholders) {
|
|
|
18961
19402
|
const textXref = unit.job.allocateXrefId();
|
|
18962
19403
|
unit.create.push(createTextOp(textXref, "", text2.sourceSpan));
|
|
18963
19404
|
const baseSourceSpan = unit.job.compatibility ? null : text2.sourceSpan;
|
|
18964
|
-
unit.update.push(createInterpolateTextOp(textXref, new Interpolation2(value.strings, value.expressions.map((expr) => convertAst(expr, unit.job, baseSourceSpan))
|
|
19405
|
+
unit.update.push(createInterpolateTextOp(textXref, new Interpolation2(value.strings, value.expressions.map((expr) => convertAst(expr, unit.job, baseSourceSpan)), i18nPlaceholders), text2.sourceSpan));
|
|
18965
19406
|
}
|
|
18966
19407
|
function ingestIfBlock(unit, ifBlock) {
|
|
19408
|
+
var _a2;
|
|
18967
19409
|
let firstXref = null;
|
|
18968
19410
|
let firstSlotHandle = null;
|
|
18969
19411
|
let conditions = [];
|
|
@@ -18977,14 +19419,21 @@ function ingestIfBlock(unit, ifBlock) {
|
|
|
18977
19419
|
if (ifCase.expressionAlias !== null) {
|
|
18978
19420
|
cView.contextVariables.set(ifCase.expressionAlias.name, CTX_REF);
|
|
18979
19421
|
}
|
|
18980
|
-
|
|
18981
|
-
|
|
19422
|
+
let ifCaseI18nMeta = void 0;
|
|
19423
|
+
if (ifCase.i18n !== void 0) {
|
|
19424
|
+
if (!(ifCase.i18n instanceof BlockPlaceholder)) {
|
|
19425
|
+
throw Error(`Unhandled i18n metadata type for if block: ${(_a2 = ifCase.i18n) == null ? void 0 : _a2.constructor.name}`);
|
|
19426
|
+
}
|
|
19427
|
+
ifCaseI18nMeta = ifCase.i18n;
|
|
19428
|
+
}
|
|
19429
|
+
const templateOp = createTemplateOp(cView.xref, TemplateKind.Block, tagName, "Conditional", Namespace.HTML, ifCaseI18nMeta, ifCase.sourceSpan);
|
|
19430
|
+
unit.create.push(templateOp);
|
|
18982
19431
|
if (firstXref === null) {
|
|
18983
19432
|
firstXref = cView.xref;
|
|
18984
|
-
firstSlotHandle =
|
|
19433
|
+
firstSlotHandle = templateOp.handle;
|
|
18985
19434
|
}
|
|
18986
19435
|
const caseExpr = ifCase.expression ? convertAst(ifCase.expression, unit.job, null) : null;
|
|
18987
|
-
const conditionalCaseExpr = new ConditionalCaseExpr(caseExpr,
|
|
19436
|
+
const conditionalCaseExpr = new ConditionalCaseExpr(caseExpr, templateOp.xref, templateOp.handle, ifCase.expressionAlias);
|
|
18988
19437
|
conditions.push(conditionalCaseExpr);
|
|
18989
19438
|
ingestNodes(cView, ifCase.children);
|
|
18990
19439
|
}
|
|
@@ -18992,54 +19441,65 @@ function ingestIfBlock(unit, ifBlock) {
|
|
|
18992
19441
|
unit.update.push(conditional2);
|
|
18993
19442
|
}
|
|
18994
19443
|
function ingestSwitchBlock(unit, switchBlock) {
|
|
19444
|
+
var _a2;
|
|
18995
19445
|
let firstXref = null;
|
|
18996
19446
|
let firstSlotHandle = null;
|
|
18997
19447
|
let conditions = [];
|
|
18998
19448
|
for (const switchCase of switchBlock.cases) {
|
|
18999
19449
|
const cView = unit.job.allocateView(unit.xref);
|
|
19000
|
-
|
|
19001
|
-
|
|
19450
|
+
let switchCaseI18nMeta = void 0;
|
|
19451
|
+
if (switchCase.i18n !== void 0) {
|
|
19452
|
+
if (!(switchCase.i18n instanceof BlockPlaceholder)) {
|
|
19453
|
+
throw Error(`Unhandled i18n metadata type for switch block: ${(_a2 = switchCase.i18n) == null ? void 0 : _a2.constructor.name}`);
|
|
19454
|
+
}
|
|
19455
|
+
switchCaseI18nMeta = switchCase.i18n;
|
|
19456
|
+
}
|
|
19457
|
+
const templateOp = createTemplateOp(cView.xref, TemplateKind.Block, null, "Case", Namespace.HTML, switchCaseI18nMeta, switchCase.sourceSpan);
|
|
19458
|
+
unit.create.push(templateOp);
|
|
19002
19459
|
if (firstXref === null) {
|
|
19003
19460
|
firstXref = cView.xref;
|
|
19004
|
-
firstSlotHandle =
|
|
19461
|
+
firstSlotHandle = templateOp.handle;
|
|
19005
19462
|
}
|
|
19006
19463
|
const caseExpr = switchCase.expression ? convertAst(switchCase.expression, unit.job, switchBlock.startSourceSpan) : null;
|
|
19007
|
-
const conditionalCaseExpr = new ConditionalCaseExpr(caseExpr,
|
|
19464
|
+
const conditionalCaseExpr = new ConditionalCaseExpr(caseExpr, templateOp.xref, templateOp.handle);
|
|
19008
19465
|
conditions.push(conditionalCaseExpr);
|
|
19009
19466
|
ingestNodes(cView, switchCase.children);
|
|
19010
19467
|
}
|
|
19011
19468
|
const conditional2 = createConditionalOp(firstXref, firstSlotHandle, convertAst(switchBlock.expression, unit.job, null), conditions, switchBlock.sourceSpan);
|
|
19012
19469
|
unit.update.push(conditional2);
|
|
19013
19470
|
}
|
|
19014
|
-
function ingestDeferView(unit, suffix, children, sourceSpan) {
|
|
19471
|
+
function ingestDeferView(unit, suffix, i18nMeta, children, sourceSpan) {
|
|
19472
|
+
if (i18nMeta !== void 0 && !(i18nMeta instanceof BlockPlaceholder)) {
|
|
19473
|
+
throw Error("Unhandled i18n metadata type for defer block");
|
|
19474
|
+
}
|
|
19015
19475
|
if (children === void 0) {
|
|
19016
19476
|
return null;
|
|
19017
19477
|
}
|
|
19018
19478
|
const secondaryView = unit.job.allocateView(unit.xref);
|
|
19019
19479
|
ingestNodes(secondaryView, children);
|
|
19020
|
-
const templateOp = createTemplateOp(secondaryView.xref, null, `Defer${suffix}`, Namespace.HTML,
|
|
19480
|
+
const templateOp = createTemplateOp(secondaryView.xref, TemplateKind.Block, null, `Defer${suffix}`, Namespace.HTML, i18nMeta, sourceSpan);
|
|
19021
19481
|
unit.create.push(templateOp);
|
|
19022
19482
|
return templateOp;
|
|
19023
19483
|
}
|
|
19024
19484
|
function ingestDeferBlock(unit, deferBlock) {
|
|
19025
|
-
var _a2, _b2, _c2, _d2, _e2, _f2, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
19485
|
+
var _a2, _b2, _c2, _d2, _e2, _f2, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
19026
19486
|
const blockMeta = unit.job.deferBlocksMeta.get(deferBlock);
|
|
19027
19487
|
if (blockMeta === void 0) {
|
|
19028
19488
|
throw new Error(`AssertionError: unable to find metadata for deferred block`);
|
|
19029
19489
|
}
|
|
19030
|
-
const main = ingestDeferView(unit, "", deferBlock.children, deferBlock.sourceSpan);
|
|
19031
|
-
const loading = ingestDeferView(unit, "Loading", (_a2 = deferBlock.loading) == null ? void 0 : _a2.
|
|
19032
|
-
const placeholder = ingestDeferView(unit, "Placeholder", (
|
|
19033
|
-
const error2 = ingestDeferView(unit, "Error", (
|
|
19490
|
+
const main = ingestDeferView(unit, "", deferBlock.i18n, deferBlock.children, deferBlock.sourceSpan);
|
|
19491
|
+
const loading = ingestDeferView(unit, "Loading", (_a2 = deferBlock.loading) == null ? void 0 : _a2.i18n, (_b2 = deferBlock.loading) == null ? void 0 : _b2.children, (_c2 = deferBlock.loading) == null ? void 0 : _c2.sourceSpan);
|
|
19492
|
+
const placeholder = ingestDeferView(unit, "Placeholder", (_d2 = deferBlock.placeholder) == null ? void 0 : _d2.i18n, (_e2 = deferBlock.placeholder) == null ? void 0 : _e2.children, (_f2 = deferBlock.placeholder) == null ? void 0 : _f2.sourceSpan);
|
|
19493
|
+
const error2 = ingestDeferView(unit, "Error", (_g = deferBlock.error) == null ? void 0 : _g.i18n, (_h = deferBlock.error) == null ? void 0 : _h.children, (_i = deferBlock.error) == null ? void 0 : _i.sourceSpan);
|
|
19034
19494
|
const deferXref = unit.job.allocateXrefId();
|
|
19035
19495
|
const deferOp = createDeferOp(deferXref, main.xref, main.handle, blockMeta, deferBlock.sourceSpan);
|
|
19036
|
-
deferOp.placeholderView = (
|
|
19037
|
-
deferOp.placeholderSlot = (
|
|
19038
|
-
deferOp.loadingSlot = (
|
|
19039
|
-
deferOp.errorSlot = (
|
|
19040
|
-
deferOp.placeholderMinimumTime = (
|
|
19041
|
-
deferOp.loadingMinimumTime = (
|
|
19042
|
-
deferOp.loadingAfterTime = (
|
|
19496
|
+
deferOp.placeholderView = (_j = placeholder == null ? void 0 : placeholder.xref) != null ? _j : null;
|
|
19497
|
+
deferOp.placeholderSlot = (_k = placeholder == null ? void 0 : placeholder.handle) != null ? _k : null;
|
|
19498
|
+
deferOp.loadingSlot = (_l = loading == null ? void 0 : loading.handle) != null ? _l : null;
|
|
19499
|
+
deferOp.errorSlot = (_m = error2 == null ? void 0 : error2.handle) != null ? _m : null;
|
|
19500
|
+
deferOp.placeholderMinimumTime = (_o = (_n = deferBlock.placeholder) == null ? void 0 : _n.minimumTime) != null ? _o : null;
|
|
19501
|
+
deferOp.loadingMinimumTime = (_q = (_p = deferBlock.loading) == null ? void 0 : _p.minimumTime) != null ? _q : null;
|
|
19502
|
+
deferOp.loadingAfterTime = (_s = (_r = deferBlock.loading) == null ? void 0 : _r.afterTime) != null ? _s : null;
|
|
19043
19503
|
unit.create.push(deferOp);
|
|
19044
19504
|
let prefetch = false;
|
|
19045
19505
|
let deferOnOps = [];
|
|
@@ -19103,17 +19563,12 @@ function ingestDeferBlock(unit, deferBlock) {
|
|
|
19103
19563
|
unit.update.push(deferWhenOps);
|
|
19104
19564
|
}
|
|
19105
19565
|
function ingestIcu(unit, icu) {
|
|
19106
|
-
var _a2
|
|
19566
|
+
var _a2;
|
|
19107
19567
|
if (icu.i18n instanceof Message && isSingleI18nIcu(icu.i18n)) {
|
|
19108
19568
|
const xref = unit.job.allocateXrefId();
|
|
19109
19569
|
const icuNode = icu.i18n.nodes[0];
|
|
19110
19570
|
unit.create.push(createIcuStartOp(xref, icu.i18n, icuFromI18nMessage(icu.i18n).name, null));
|
|
19111
|
-
const
|
|
19112
|
-
if (expressionPlaceholder === void 0 || icu.vars[expressionPlaceholder] === void 0) {
|
|
19113
|
-
throw Error("ICU should have a text binding");
|
|
19114
|
-
}
|
|
19115
|
-
ingestBoundText(unit, icu.vars[expressionPlaceholder], [expressionPlaceholder]);
|
|
19116
|
-
for (const [placeholder, text2] of Object.entries(icu.placeholders)) {
|
|
19571
|
+
for (const [placeholder, text2] of Object.entries(__spreadValues(__spreadValues({}, icu.vars), icu.placeholders))) {
|
|
19117
19572
|
if (text2 instanceof BoundText) {
|
|
19118
19573
|
ingestBoundText(unit, text2, [placeholder]);
|
|
19119
19574
|
} else {
|
|
@@ -19122,11 +19577,11 @@ function ingestIcu(unit, icu) {
|
|
|
19122
19577
|
}
|
|
19123
19578
|
unit.create.push(createIcuEndOp(xref));
|
|
19124
19579
|
} else {
|
|
19125
|
-
throw Error(`Unhandled i18n metadata type for ICU: ${(
|
|
19580
|
+
throw Error(`Unhandled i18n metadata type for ICU: ${(_a2 = icu.i18n) == null ? void 0 : _a2.constructor.name}`);
|
|
19126
19581
|
}
|
|
19127
19582
|
}
|
|
19128
19583
|
function ingestForBlock(unit, forBlock) {
|
|
19129
|
-
var _a2;
|
|
19584
|
+
var _a2, _b2, _c2;
|
|
19130
19585
|
const repeaterView = unit.job.allocateView(unit.xref);
|
|
19131
19586
|
const createRepeaterAlias = (ident, repeaterVar) => {
|
|
19132
19587
|
repeaterView.aliases.add({
|
|
@@ -19160,8 +19615,16 @@ function ingestForBlock(unit, forBlock) {
|
|
|
19160
19615
|
$odd: forBlock.contextVariables.$odd.name,
|
|
19161
19616
|
$implicit: forBlock.item.name
|
|
19162
19617
|
};
|
|
19618
|
+
if (forBlock.i18n !== void 0 && !(forBlock.i18n instanceof BlockPlaceholder)) {
|
|
19619
|
+
throw Error("AssertionError: Unhandled i18n metadata type or @for");
|
|
19620
|
+
}
|
|
19621
|
+
if (((_a2 = forBlock.empty) == null ? void 0 : _a2.i18n) !== void 0 && !(forBlock.empty.i18n instanceof BlockPlaceholder)) {
|
|
19622
|
+
throw Error("AssertionError: Unhandled i18n metadata type or @empty");
|
|
19623
|
+
}
|
|
19624
|
+
const i18nPlaceholder = forBlock.i18n;
|
|
19625
|
+
const emptyI18nPlaceholder = (_b2 = forBlock.empty) == null ? void 0 : _b2.i18n;
|
|
19163
19626
|
const tagName = ingestControlFlowInsertionPoint(unit, repeaterView.xref, forBlock);
|
|
19164
|
-
const repeaterCreate2 = createRepeaterCreateOp(repeaterView.xref, (
|
|
19627
|
+
const repeaterCreate2 = createRepeaterCreateOp(repeaterView.xref, (_c2 = emptyView == null ? void 0 : emptyView.xref) != null ? _c2 : null, tagName, track, varNames, i18nPlaceholder, emptyI18nPlaceholder, forBlock.sourceSpan);
|
|
19165
19628
|
unit.create.push(repeaterCreate2);
|
|
19166
19629
|
const expression = convertAst(forBlock.expression, unit.job, convertSourceSpan(forBlock.expression.span, forBlock.sourceSpan));
|
|
19167
19630
|
const repeater2 = createRepeaterOp(repeaterCreate2.xref, repeaterCreate2.handle, expression, forBlock.sourceSpan);
|
|
@@ -19197,6 +19660,15 @@ function convertAst(ast, job, baseSourceSpan) {
|
|
|
19197
19660
|
}
|
|
19198
19661
|
} else if (ast instanceof LiteralPrimitive) {
|
|
19199
19662
|
return literal(ast.value, void 0, convertSourceSpan(ast.span, baseSourceSpan));
|
|
19663
|
+
} else if (ast instanceof Unary) {
|
|
19664
|
+
switch (ast.operator) {
|
|
19665
|
+
case "+":
|
|
19666
|
+
return new UnaryOperatorExpr(UnaryOperator.Plus, convertAst(ast.expr, job, baseSourceSpan), void 0, convertSourceSpan(ast.span, baseSourceSpan));
|
|
19667
|
+
case "-":
|
|
19668
|
+
return new UnaryOperatorExpr(UnaryOperator.Minus, convertAst(ast.expr, job, baseSourceSpan), void 0, convertSourceSpan(ast.span, baseSourceSpan));
|
|
19669
|
+
default:
|
|
19670
|
+
throw new Error(`AssertionError: unknown unary operator ${ast.operator}`);
|
|
19671
|
+
}
|
|
19200
19672
|
} else if (ast instanceof Binary) {
|
|
19201
19673
|
const operator = BINARY_OPERATORS.get(ast.operation);
|
|
19202
19674
|
if (operator === void 0) {
|
|
@@ -19234,104 +19706,134 @@ function convertAst(ast, job, baseSourceSpan) {
|
|
|
19234
19706
|
return new SafeInvokeFunctionExpr(convertAst(ast.receiver, job, baseSourceSpan), ast.args.map((a) => convertAst(a, job, baseSourceSpan)));
|
|
19235
19707
|
} else if (ast instanceof EmptyExpr) {
|
|
19236
19708
|
return new EmptyExpr2(convertSourceSpan(ast.span, baseSourceSpan));
|
|
19709
|
+
} else if (ast instanceof PrefixNot) {
|
|
19710
|
+
return not(convertAst(ast.expression, job, baseSourceSpan), convertSourceSpan(ast.span, baseSourceSpan));
|
|
19237
19711
|
} else {
|
|
19238
19712
|
throw new Error(`Unhandled expression type "${ast.constructor.name}" in file "${baseSourceSpan == null ? void 0 : baseSourceSpan.start.file.url}"`);
|
|
19239
19713
|
}
|
|
19240
19714
|
}
|
|
19715
|
+
function convertAstWithInterpolation(job, value, i18nMeta) {
|
|
19716
|
+
var _a2, _b2;
|
|
19717
|
+
let expression;
|
|
19718
|
+
if (value instanceof Interpolation) {
|
|
19719
|
+
expression = new Interpolation2(value.strings, value.expressions.map((e) => convertAst(e, job, null)), Object.keys((_b2 = (_a2 = asMessage(i18nMeta)) == null ? void 0 : _a2.placeholders) != null ? _b2 : {}));
|
|
19720
|
+
} else if (value instanceof AST) {
|
|
19721
|
+
expression = convertAst(value, job, null);
|
|
19722
|
+
} else {
|
|
19723
|
+
expression = literal(value);
|
|
19724
|
+
}
|
|
19725
|
+
return expression;
|
|
19726
|
+
}
|
|
19727
|
+
var BINDING_KINDS = /* @__PURE__ */ new Map([
|
|
19728
|
+
[0, BindingKind.Property],
|
|
19729
|
+
[1, BindingKind.Attribute],
|
|
19730
|
+
[2, BindingKind.ClassName],
|
|
19731
|
+
[3, BindingKind.StyleProperty],
|
|
19732
|
+
[4, BindingKind.Animation]
|
|
19733
|
+
]);
|
|
19241
19734
|
function isPlainTemplate(tmpl) {
|
|
19242
19735
|
var _a2;
|
|
19243
|
-
return splitNsName((_a2 = tmpl.tagName) != null ? _a2 : "")[1] ===
|
|
19244
|
-
}
|
|
19245
|
-
function
|
|
19246
|
-
|
|
19247
|
-
|
|
19248
|
-
flags |= BindingFlags.OnNgTemplateElement;
|
|
19249
|
-
if (element2 instanceof Template && isPlainTemplate(element2)) {
|
|
19250
|
-
flags |= BindingFlags.BindingTargetsTemplate;
|
|
19251
|
-
}
|
|
19252
|
-
const templateAttrFlags = flags | BindingFlags.BindingTargetsTemplate | BindingFlags.IsStructuralTemplateAttribute;
|
|
19253
|
-
for (const attr of element2.templateAttrs) {
|
|
19254
|
-
if (attr instanceof TextAttribute) {
|
|
19255
|
-
ingestBinding(unit, op.xref, attr.name, literal(attr.value), 1, null, SecurityContext.NONE, attr.sourceSpan, templateAttrFlags | BindingFlags.TextValue);
|
|
19256
|
-
} else {
|
|
19257
|
-
ingestBinding(unit, op.xref, attr.name, attr.value, attr.type, attr.unit, attr.securityContext, attr.sourceSpan, templateAttrFlags);
|
|
19258
|
-
}
|
|
19259
|
-
}
|
|
19736
|
+
return splitNsName((_a2 = tmpl.tagName) != null ? _a2 : "")[1] === NG_TEMPLATE_TAG_NAME;
|
|
19737
|
+
}
|
|
19738
|
+
function asMessage(i18nMeta) {
|
|
19739
|
+
if (i18nMeta == null) {
|
|
19740
|
+
return null;
|
|
19260
19741
|
}
|
|
19742
|
+
if (!(i18nMeta instanceof Message)) {
|
|
19743
|
+
throw Error(`Expected i18n meta to be a Message, but got: ${i18nMeta.constructor.name}`);
|
|
19744
|
+
}
|
|
19745
|
+
return i18nMeta;
|
|
19746
|
+
}
|
|
19747
|
+
function ingestElementBindings(unit, op, element2) {
|
|
19748
|
+
var _a2;
|
|
19749
|
+
let bindings = new Array();
|
|
19261
19750
|
for (const attr of element2.attributes) {
|
|
19262
|
-
|
|
19751
|
+
const securityContext = domSchema.securityContext(element2.name, attr.name, true);
|
|
19752
|
+
bindings.push(createBindingOp(op.xref, BindingKind.Attribute, attr.name, convertAstWithInterpolation(unit.job, attr.value, attr.i18n), null, securityContext, true, false, null, asMessage(attr.i18n), attr.sourceSpan));
|
|
19263
19753
|
}
|
|
19264
19754
|
for (const input of element2.inputs) {
|
|
19265
|
-
|
|
19755
|
+
bindings.push(createBindingOp(op.xref, BINDING_KINDS.get(input.type), input.name, convertAstWithInterpolation(unit.job, astOf(input.value), input.i18n), input.unit, input.securityContext, false, false, null, (_a2 = asMessage(input.i18n)) != null ? _a2 : null, input.sourceSpan));
|
|
19266
19756
|
}
|
|
19757
|
+
unit.create.push(bindings.filter((b) => (b == null ? void 0 : b.kind) === OpKind.ExtractedAttribute));
|
|
19758
|
+
unit.update.push(bindings.filter((b) => (b == null ? void 0 : b.kind) === OpKind.Binding));
|
|
19267
19759
|
for (const output of element2.outputs) {
|
|
19268
|
-
|
|
19269
|
-
|
|
19270
|
-
if (output.phase === null) {
|
|
19271
|
-
throw Error("Animation listener should have a phase");
|
|
19272
|
-
}
|
|
19273
|
-
}
|
|
19274
|
-
if (element2 instanceof Template && !isPlainTemplate(element2)) {
|
|
19275
|
-
unit.create.push(createExtractedAttributeOp(op.xref, BindingKind.Property, output.name, null));
|
|
19276
|
-
continue;
|
|
19760
|
+
if (output.type === 1 && output.phase === null) {
|
|
19761
|
+
throw Error("Animation listener should have a phase");
|
|
19277
19762
|
}
|
|
19278
|
-
|
|
19279
|
-
|
|
19280
|
-
|
|
19281
|
-
|
|
19282
|
-
|
|
19283
|
-
|
|
19284
|
-
|
|
19285
|
-
|
|
19763
|
+
unit.create.push(createListenerOp(op.xref, op.handle, output.name, op.tag, makeListenerHandlerOps(unit, output.handler, output.handlerSpan), output.phase, output.target, false, output.sourceSpan));
|
|
19764
|
+
}
|
|
19765
|
+
if (bindings.some((b) => b == null ? void 0 : b.i18nMessage) !== null) {
|
|
19766
|
+
unit.create.push(createI18nAttributesOp(unit.job.allocateXrefId(), new SlotHandle(), op.xref));
|
|
19767
|
+
}
|
|
19768
|
+
}
|
|
19769
|
+
function ingestTemplateBindings(unit, op, template2, templateKind) {
|
|
19770
|
+
let bindings = new Array();
|
|
19771
|
+
for (const attr of template2.templateAttrs) {
|
|
19772
|
+
if (attr instanceof TextAttribute) {
|
|
19773
|
+
const securityContext = domSchema.securityContext(NG_TEMPLATE_TAG_NAME, attr.name, true);
|
|
19774
|
+
bindings.push(createTemplateBinding(unit, op.xref, 1, attr.name, attr.value, null, securityContext, true, templateKind, asMessage(attr.i18n), attr.sourceSpan));
|
|
19286
19775
|
} else {
|
|
19287
|
-
|
|
19776
|
+
bindings.push(createTemplateBinding(unit, op.xref, attr.type, attr.name, astOf(attr.value), attr.unit, attr.securityContext, true, templateKind, asMessage(attr.i18n), attr.sourceSpan));
|
|
19288
19777
|
}
|
|
19289
|
-
|
|
19290
|
-
|
|
19778
|
+
}
|
|
19779
|
+
for (const attr of template2.attributes) {
|
|
19780
|
+
const securityContext = domSchema.securityContext(NG_TEMPLATE_TAG_NAME, attr.name, true);
|
|
19781
|
+
bindings.push(createTemplateBinding(unit, op.xref, 1, attr.name, attr.value, null, securityContext, false, templateKind, asMessage(attr.i18n), attr.sourceSpan));
|
|
19782
|
+
}
|
|
19783
|
+
for (const input of template2.inputs) {
|
|
19784
|
+
bindings.push(createTemplateBinding(unit, op.xref, input.type, input.name, astOf(input.value), input.unit, input.securityContext, false, templateKind, asMessage(input.i18n), input.sourceSpan));
|
|
19785
|
+
}
|
|
19786
|
+
unit.create.push(bindings.filter((b) => (b == null ? void 0 : b.kind) === OpKind.ExtractedAttribute));
|
|
19787
|
+
unit.update.push(bindings.filter((b) => (b == null ? void 0 : b.kind) === OpKind.Binding));
|
|
19788
|
+
for (const output of template2.outputs) {
|
|
19789
|
+
if (output.type === 1 && output.phase === null) {
|
|
19790
|
+
throw Error("Animation listener should have a phase");
|
|
19791
|
+
}
|
|
19792
|
+
if (templateKind === TemplateKind.NgTemplate) {
|
|
19793
|
+
unit.create.push(createListenerOp(op.xref, op.handle, output.name, op.tag, makeListenerHandlerOps(unit, output.handler, output.handlerSpan), output.phase, output.target, false, output.sourceSpan));
|
|
19291
19794
|
}
|
|
19292
|
-
|
|
19293
|
-
|
|
19294
|
-
|
|
19295
|
-
const stmtOp = createStatementOp(new ExpressionStatement(expr, expr.sourceSpan));
|
|
19296
|
-
listenerOp.handlerOps.push(stmtOp);
|
|
19795
|
+
if (templateKind === TemplateKind.Structural && output.type !== 1) {
|
|
19796
|
+
const securityContext = domSchema.securityContext(NG_TEMPLATE_TAG_NAME, output.name, false);
|
|
19797
|
+
unit.create.push(createExtractedAttributeOp(op.xref, BindingKind.Property, output.name, null, null, null, securityContext));
|
|
19297
19798
|
}
|
|
19298
|
-
|
|
19299
|
-
|
|
19799
|
+
}
|
|
19800
|
+
if (bindings.some((b) => b == null ? void 0 : b.i18nMessage) !== null) {
|
|
19801
|
+
unit.create.push(createI18nAttributesOp(unit.job.allocateXrefId(), new SlotHandle(), op.xref));
|
|
19300
19802
|
}
|
|
19301
19803
|
}
|
|
19302
|
-
|
|
19303
|
-
|
|
19304
|
-
|
|
19305
|
-
|
|
19306
|
-
|
|
19307
|
-
|
|
19308
|
-
|
|
19309
|
-
|
|
19310
|
-
|
|
19311
|
-
BindingFlags2[BindingFlags2["None"] = 0] = "None";
|
|
19312
|
-
BindingFlags2[BindingFlags2["TextValue"] = 1] = "TextValue";
|
|
19313
|
-
BindingFlags2[BindingFlags2["BindingTargetsTemplate"] = 2] = "BindingTargetsTemplate";
|
|
19314
|
-
BindingFlags2[BindingFlags2["IsStructuralTemplateAttribute"] = 4] = "IsStructuralTemplateAttribute";
|
|
19315
|
-
BindingFlags2[BindingFlags2["OnNgTemplateElement"] = 8] = "OnNgTemplateElement";
|
|
19316
|
-
})(BindingFlags || (BindingFlags = {}));
|
|
19317
|
-
function ingestBinding(view, xref, name, value, type, unit, securityContext, sourceSpan, flags) {
|
|
19318
|
-
if (value instanceof ASTWithSource) {
|
|
19319
|
-
value = value.ast;
|
|
19804
|
+
function createTemplateBinding(view, xref, type, name, value, unit, securityContext, isStructuralTemplateAttribute, templateKind, i18nMessage, sourceSpan) {
|
|
19805
|
+
const isTextBinding = typeof value === "string";
|
|
19806
|
+
if (templateKind === TemplateKind.Structural) {
|
|
19807
|
+
if (!isStructuralTemplateAttribute && (type === 0 || type === 2 || type === 3)) {
|
|
19808
|
+
return createExtractedAttributeOp(xref, BindingKind.Property, name, null, null, i18nMessage, securityContext);
|
|
19809
|
+
}
|
|
19810
|
+
if (!isTextBinding && (type === 1 || type === 4)) {
|
|
19811
|
+
return null;
|
|
19812
|
+
}
|
|
19320
19813
|
}
|
|
19321
|
-
|
|
19322
|
-
|
|
19323
|
-
|
|
19814
|
+
let bindingType = BINDING_KINDS.get(type);
|
|
19815
|
+
if (templateKind === TemplateKind.NgTemplate) {
|
|
19816
|
+
if (type === 2 || type === 3 || type === 1 && !isTextBinding) {
|
|
19817
|
+
bindingType = BindingKind.Property;
|
|
19818
|
+
}
|
|
19324
19819
|
}
|
|
19325
|
-
|
|
19326
|
-
|
|
19327
|
-
|
|
19328
|
-
|
|
19329
|
-
|
|
19330
|
-
|
|
19331
|
-
|
|
19820
|
+
return createBindingOp(xref, bindingType, name, convertAstWithInterpolation(view.job, value, i18nMessage), unit, securityContext, isTextBinding, isStructuralTemplateAttribute, templateKind, i18nMessage, sourceSpan);
|
|
19821
|
+
}
|
|
19822
|
+
function makeListenerHandlerOps(unit, handler, handlerSpan) {
|
|
19823
|
+
handler = astOf(handler);
|
|
19824
|
+
const handlerOps = new Array();
|
|
19825
|
+
let handlerExprs = handler instanceof Chain ? handler.expressions : [handler];
|
|
19826
|
+
if (handlerExprs.length === 0) {
|
|
19827
|
+
throw new Error("Expected listener to have non-empty expression list.");
|
|
19332
19828
|
}
|
|
19333
|
-
const
|
|
19334
|
-
|
|
19829
|
+
const expressions = handlerExprs.map((expr) => convertAst(expr, unit.job, handlerSpan));
|
|
19830
|
+
const returnExpr = expressions.pop();
|
|
19831
|
+
handlerOps.push(...expressions.map((e) => createStatementOp(new ExpressionStatement(e, e.sourceSpan))));
|
|
19832
|
+
handlerOps.push(createStatementOp(new ReturnStatement(returnExpr, returnExpr.sourceSpan)));
|
|
19833
|
+
return handlerOps;
|
|
19834
|
+
}
|
|
19835
|
+
function astOf(ast) {
|
|
19836
|
+
return ast instanceof ASTWithSource ? ast.ast : ast;
|
|
19335
19837
|
}
|
|
19336
19838
|
function ingestReferences(op, element2) {
|
|
19337
19839
|
assertIsArray(op.localRefs);
|
|
@@ -19371,10 +19873,11 @@ function ingestControlFlowInsertionPoint(unit, xref, node) {
|
|
|
19371
19873
|
}
|
|
19372
19874
|
if (root !== null) {
|
|
19373
19875
|
for (const attr of root.attributes) {
|
|
19374
|
-
|
|
19876
|
+
const securityContext = domSchema.securityContext(NG_TEMPLATE_TAG_NAME, attr.name, true);
|
|
19877
|
+
unit.update.push(createBindingOp(xref, BindingKind.Attribute, attr.name, literal(attr.value), null, securityContext, true, false, null, asMessage(attr.i18n), attr.sourceSpan));
|
|
19375
19878
|
}
|
|
19376
19879
|
const tagName = root instanceof Element ? root.name : root.tagName;
|
|
19377
|
-
return tagName ===
|
|
19880
|
+
return tagName === NG_TEMPLATE_TAG_NAME ? null : tagName;
|
|
19378
19881
|
}
|
|
19379
19882
|
return null;
|
|
19380
19883
|
}
|
|
@@ -21460,17 +21963,17 @@ function serializePlaceholderValue(value) {
|
|
|
21460
21963
|
var NG_CONTENT_SELECT_ATTR2 = "select";
|
|
21461
21964
|
var NG_PROJECT_AS_ATTR_NAME = "ngProjectAs";
|
|
21462
21965
|
var EVENT_BINDING_SCOPE_GLOBALS = /* @__PURE__ */ new Set(["$event"]);
|
|
21463
|
-
var
|
|
21464
|
-
var
|
|
21966
|
+
var NG_TEMPLATE_TAG_NAME2 = "ng-template";
|
|
21967
|
+
var GLOBAL_TARGET_RESOLVERS2 = /* @__PURE__ */ new Map([["window", Identifiers.resolveWindow], ["document", Identifiers.resolveDocument], ["body", Identifiers.resolveBody]]);
|
|
21465
21968
|
var LEADING_TRIVIA_CHARS = [" ", "\n", "\r", " "];
|
|
21466
21969
|
function renderFlagCheckIfStmt(flags, statements) {
|
|
21467
21970
|
return ifStmt(variable(RENDER_FLAGS).bitwiseAnd(literal(flags), null, false), statements);
|
|
21468
21971
|
}
|
|
21469
21972
|
function prepareEventListenerParameters(eventAst, handlerName = null, scope = null) {
|
|
21470
21973
|
const { type, name, target, phase, handler } = eventAst;
|
|
21471
|
-
if (target && !
|
|
21974
|
+
if (target && !GLOBAL_TARGET_RESOLVERS2.has(target)) {
|
|
21472
21975
|
throw new Error(`Unexpected global target '${target}' defined for '${name}' event.
|
|
21473
|
-
Supported list of global targets: ${Array.from(
|
|
21976
|
+
Supported list of global targets: ${Array.from(GLOBAL_TARGET_RESOLVERS2.keys())}.`);
|
|
21474
21977
|
}
|
|
21475
21978
|
const eventArgumentName = "$event";
|
|
21476
21979
|
const implicitReceiverAccesses = /* @__PURE__ */ new Set();
|
|
@@ -21503,7 +22006,7 @@ function prepareEventListenerParameters(eventAst, handlerName = null, scope = nu
|
|
|
21503
22006
|
if (target) {
|
|
21504
22007
|
params.push(
|
|
21505
22008
|
literal(false),
|
|
21506
|
-
importExpr(
|
|
22009
|
+
importExpr(GLOBAL_TARGET_RESOLVERS2.get(target))
|
|
21507
22010
|
);
|
|
21508
22011
|
}
|
|
21509
22012
|
return params;
|
|
@@ -22049,10 +22552,10 @@ var TemplateDefinitionBuilder = class {
|
|
|
22049
22552
|
var _a2;
|
|
22050
22553
|
const tagNameWithoutNamespace = template2.tagName ? splitNsName(template2.tagName)[1] : template2.tagName;
|
|
22051
22554
|
const contextNameSuffix = template2.tagName ? "_" + sanitizeIdentifier(template2.tagName) : "";
|
|
22052
|
-
const attrsExprs = this.getAttributeExpressions(
|
|
22555
|
+
const attrsExprs = this.getAttributeExpressions(NG_TEMPLATE_TAG_NAME2, template2.attributes, template2.inputs, template2.outputs, void 0, template2.templateAttrs);
|
|
22053
22556
|
const templateIndex = this.createEmbeddedTemplateFn(tagNameWithoutNamespace, template2.children, contextNameSuffix, template2.sourceSpan, template2.variables, attrsExprs, template2.references, template2.i18n);
|
|
22054
22557
|
this.templatePropertyBindings(templateIndex, template2.templateAttrs);
|
|
22055
|
-
if (tagNameWithoutNamespace ===
|
|
22558
|
+
if (tagNameWithoutNamespace === NG_TEMPLATE_TAG_NAME2) {
|
|
22056
22559
|
const [i18nInputs, inputs] = partitionArray(template2.inputs, hasI18nMeta);
|
|
22057
22560
|
if (i18nInputs.length > 0) {
|
|
22058
22561
|
this.i18nAttributesInstruction(templateIndex, i18nInputs, (_a2 = template2.startSourceSpan) != null ? _a2 : template2.sourceSpan);
|
|
@@ -22293,8 +22796,8 @@ var TemplateDefinitionBuilder = class {
|
|
|
22293
22796
|
}
|
|
22294
22797
|
if (root !== null) {
|
|
22295
22798
|
const name = root instanceof Element ? root.name : root.tagName;
|
|
22296
|
-
tagName = name ===
|
|
22297
|
-
attrsExprs = this.getAttributeExpressions(
|
|
22799
|
+
tagName = name === NG_TEMPLATE_TAG_NAME2 ? null : name;
|
|
22800
|
+
attrsExprs = this.getAttributeExpressions(NG_TEMPLATE_TAG_NAME2, root.attributes, root.inputs, []);
|
|
22298
22801
|
}
|
|
22299
22802
|
return { tagName, attrsExprs };
|
|
22300
22803
|
}
|
|
@@ -22916,21 +23419,6 @@ var TrackByBindingScope = class extends BindingScope {
|
|
|
22916
23419
|
return this.componentAccessCount;
|
|
22917
23420
|
}
|
|
22918
23421
|
};
|
|
22919
|
-
function createCssSelector(elementName, attributes) {
|
|
22920
|
-
const cssSelector = new CssSelector();
|
|
22921
|
-
const elementNameNoNs = splitNsName(elementName)[1];
|
|
22922
|
-
cssSelector.setElement(elementNameNoNs);
|
|
22923
|
-
Object.getOwnPropertyNames(attributes).forEach((name) => {
|
|
22924
|
-
const nameNoNs = splitNsName(name)[1];
|
|
22925
|
-
const value = attributes[name];
|
|
22926
|
-
cssSelector.addAttribute(nameNoNs, value);
|
|
22927
|
-
if (name.toLowerCase() === "class") {
|
|
22928
|
-
const classes = value.trim().split(/\s+/);
|
|
22929
|
-
classes.forEach((className) => cssSelector.addClassName(className));
|
|
22930
|
-
}
|
|
22931
|
-
});
|
|
22932
|
-
return cssSelector;
|
|
22933
|
-
}
|
|
22934
23422
|
function getNgProjectAsLiteral(attribute2) {
|
|
22935
23423
|
const parsedR3Selector = parseSelectorToR3Selector(attribute2.value)[0];
|
|
22936
23424
|
return [literal(5), asLiteral(parsedR3Selector)];
|
|
@@ -23469,6 +23957,7 @@ function createHostBindingsFunction(hostBindingsMetadata, typeSourceSpan, bindin
|
|
|
23469
23957
|
}
|
|
23470
23958
|
const hostJob = ingestHostBinding({
|
|
23471
23959
|
componentName: name,
|
|
23960
|
+
componentSelector: selector,
|
|
23472
23961
|
properties: bindings,
|
|
23473
23962
|
events: eventBindings,
|
|
23474
23963
|
attributes: hostBindingsMetadata.attributes
|
|
@@ -23481,6 +23970,8 @@ function createHostBindingsFunction(hostBindingsMetadata, typeSourceSpan, bindin
|
|
|
23481
23970
|
}
|
|
23482
23971
|
return emitHostBindingFunction(hostJob);
|
|
23483
23972
|
}
|
|
23973
|
+
let bindingId = 0;
|
|
23974
|
+
const getNextBindingId = () => `${bindingId++}`;
|
|
23484
23975
|
const bindingContext = variable(CONTEXT_NAME);
|
|
23485
23976
|
const styleBuilder = new StylingBuilder(bindingContext);
|
|
23486
23977
|
const { styleAttr, classAttr } = hostBindingsMetadata.specialAttributes;
|
|
@@ -23530,7 +24021,7 @@ function createHostBindingsFunction(hostBindingsMetadata, typeSourceSpan, bindin
|
|
|
23530
24021
|
const syntheticHostBindings = [];
|
|
23531
24022
|
for (const binding of allOtherBindings) {
|
|
23532
24023
|
const value = binding.expression.visit(getValueConverter());
|
|
23533
|
-
const bindingExpr = bindingFn(bindingContext, value);
|
|
24024
|
+
const bindingExpr = bindingFn(bindingContext, value, getNextBindingId);
|
|
23534
24025
|
const { bindingName, instruction, isAttribute } = getBindingNameAndInstruction(binding);
|
|
23535
24026
|
const securityContexts = bindingParser.calcPossibleSecurityContexts(selector, bindingName, isAttribute).filter((context) => context !== SecurityContext.NONE);
|
|
23536
24027
|
let sanitizerFn = null;
|
|
@@ -23575,9 +24066,11 @@ function createHostBindingsFunction(hostBindingsMetadata, typeSourceSpan, bindin
|
|
|
23575
24066
|
styleBuilder.buildUpdateLevelInstructions(getValueConverter()).forEach((instruction) => {
|
|
23576
24067
|
for (const call2 of instruction.calls) {
|
|
23577
24068
|
totalHostVarsCount += Math.max(call2.allocateBindingSlots - MIN_STYLING_BINDING_SLOTS_REQUIRED, 0);
|
|
24069
|
+
const { params, stmts } = convertStylingCall(call2, bindingContext, bindingFn, getNextBindingId);
|
|
24070
|
+
updateVariables.push(...stmts);
|
|
23578
24071
|
updateInstructions.push({
|
|
23579
24072
|
reference: instruction.reference,
|
|
23580
|
-
paramsOrFn:
|
|
24073
|
+
paramsOrFn: params,
|
|
23581
24074
|
span: null
|
|
23582
24075
|
});
|
|
23583
24076
|
}
|
|
@@ -23599,11 +24092,19 @@ function createHostBindingsFunction(hostBindingsMetadata, typeSourceSpan, bindin
|
|
|
23599
24092
|
}
|
|
23600
24093
|
return null;
|
|
23601
24094
|
}
|
|
23602
|
-
function bindingFn(implicit, value) {
|
|
23603
|
-
return convertPropertyBinding(null, implicit, value,
|
|
24095
|
+
function bindingFn(implicit, value, getNextBindingIdFn) {
|
|
24096
|
+
return convertPropertyBinding(null, implicit, value, getNextBindingIdFn());
|
|
23604
24097
|
}
|
|
23605
|
-
function convertStylingCall(call2, bindingContext, bindingFn2) {
|
|
23606
|
-
|
|
24098
|
+
function convertStylingCall(call2, bindingContext, bindingFn2, getNextBindingIdFn) {
|
|
24099
|
+
const stmts = [];
|
|
24100
|
+
const params = call2.params((value) => {
|
|
24101
|
+
const result = bindingFn2(bindingContext, value, getNextBindingIdFn);
|
|
24102
|
+
if (Array.isArray(result.stmts) && result.stmts.length > 0) {
|
|
24103
|
+
stmts.push(...result.stmts);
|
|
24104
|
+
}
|
|
24105
|
+
return result.currValExpr;
|
|
24106
|
+
});
|
|
24107
|
+
return { params, stmts };
|
|
23607
24108
|
}
|
|
23608
24109
|
function getBindingNameAndInstruction(binding) {
|
|
23609
24110
|
let bindingName = binding.name;
|
|
@@ -23918,13 +24419,13 @@ var DirectiveBinder = class {
|
|
|
23918
24419
|
template2.forEach((node) => node.visit(this));
|
|
23919
24420
|
}
|
|
23920
24421
|
visitElement(element2) {
|
|
23921
|
-
this.visitElementOrTemplate(element2
|
|
24422
|
+
this.visitElementOrTemplate(element2);
|
|
23922
24423
|
}
|
|
23923
24424
|
visitTemplate(template2) {
|
|
23924
|
-
this.visitElementOrTemplate(
|
|
24425
|
+
this.visitElementOrTemplate(template2);
|
|
23925
24426
|
}
|
|
23926
|
-
visitElementOrTemplate(
|
|
23927
|
-
const cssSelector =
|
|
24427
|
+
visitElementOrTemplate(node) {
|
|
24428
|
+
const cssSelector = createCssSelectorFromNode(node);
|
|
23928
24429
|
const directives = [];
|
|
23929
24430
|
this.matcher.match(cssSelector, (_selector, results) => directives.push(...results));
|
|
23930
24431
|
if (directives.length > 0) {
|
|
@@ -24912,7 +25413,7 @@ function publishFacade(global) {
|
|
|
24912
25413
|
}
|
|
24913
25414
|
|
|
24914
25415
|
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/version.mjs
|
|
24915
|
-
var VERSION2 = new Version("17.0.
|
|
25416
|
+
var VERSION2 = new Version("17.0.7");
|
|
24916
25417
|
|
|
24917
25418
|
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/i18n/extractor_merger.mjs
|
|
24918
25419
|
var _VisitorMode;
|
|
@@ -24962,6 +25463,10 @@ var boundngifelse = "[ngIfElse]";
|
|
|
24962
25463
|
var boundngifthenelse = "[ngIfThenElse]";
|
|
24963
25464
|
var boundngifthen = "[ngIfThen]";
|
|
24964
25465
|
var nakedngfor = "ngFor";
|
|
25466
|
+
var startMarker = "\u25EC";
|
|
25467
|
+
var endMarker = "\u2722";
|
|
25468
|
+
var startI18nMarker = "\u2688";
|
|
25469
|
+
var endI18nMarker = "\u2689";
|
|
24965
25470
|
function allFormsOf(selector) {
|
|
24966
25471
|
return [
|
|
24967
25472
|
selector,
|
|
@@ -25003,12 +25508,13 @@ var commonModulePipes = [
|
|
|
25003
25508
|
"titlecase"
|
|
25004
25509
|
].map((name) => pipeMatchRegExpFor(name));
|
|
25005
25510
|
var ElementToMigrate = class {
|
|
25006
|
-
constructor(el, attr, elseAttr = void 0, thenAttr = void 0, forAttrs = void 0) {
|
|
25511
|
+
constructor(el, attr, elseAttr = void 0, thenAttr = void 0, forAttrs = void 0, aliasAttrs = void 0) {
|
|
25007
25512
|
__publicField(this, "el");
|
|
25008
25513
|
__publicField(this, "attr");
|
|
25009
25514
|
__publicField(this, "elseAttr");
|
|
25010
25515
|
__publicField(this, "thenAttr");
|
|
25011
25516
|
__publicField(this, "forAttrs");
|
|
25517
|
+
__publicField(this, "aliasAttrs");
|
|
25012
25518
|
__publicField(this, "nestCount", 0);
|
|
25013
25519
|
__publicField(this, "hasLineBreaks", false);
|
|
25014
25520
|
this.el = el;
|
|
@@ -25016,6 +25522,7 @@ var ElementToMigrate = class {
|
|
|
25016
25522
|
this.elseAttr = elseAttr;
|
|
25017
25523
|
this.thenAttr = thenAttr;
|
|
25018
25524
|
this.forAttrs = forAttrs;
|
|
25525
|
+
this.aliasAttrs = aliasAttrs;
|
|
25019
25526
|
}
|
|
25020
25527
|
getCondition() {
|
|
25021
25528
|
const chunks = this.attr.value.split(";");
|
|
@@ -25033,7 +25540,11 @@ var ElementToMigrate = class {
|
|
|
25033
25540
|
getTemplateName(targetStr, secondStr) {
|
|
25034
25541
|
const targetLocation = this.attr.value.indexOf(targetStr);
|
|
25035
25542
|
const secondTargetLocation = secondStr ? this.attr.value.indexOf(secondStr) : void 0;
|
|
25036
|
-
|
|
25543
|
+
let templateName = this.attr.value.slice(targetLocation + targetStr.length, secondTargetLocation);
|
|
25544
|
+
if (templateName.startsWith(":")) {
|
|
25545
|
+
templateName = templateName.slice(1).trim();
|
|
25546
|
+
}
|
|
25547
|
+
return templateName.split(";")[0].trim();
|
|
25037
25548
|
}
|
|
25038
25549
|
getValueEnd(offset) {
|
|
25039
25550
|
return (this.attr.valueSpan ? this.attr.valueSpan.end.offset + 1 : this.attr.keySpan.end.offset) - offset;
|
|
@@ -25108,6 +25619,7 @@ var AnalyzedFile = class {
|
|
|
25108
25619
|
constructor() {
|
|
25109
25620
|
__publicField(this, "ranges", []);
|
|
25110
25621
|
__publicField(this, "removeCommonModule", false);
|
|
25622
|
+
__publicField(this, "canRemoveImports", false);
|
|
25111
25623
|
__publicField(this, "sourceFilePath", "");
|
|
25112
25624
|
}
|
|
25113
25625
|
getSortedRanges() {
|
|
@@ -25155,6 +25667,18 @@ var CommonCollector = class extends RecursiveVisitor {
|
|
|
25155
25667
|
return commonModulePipes.some((regexp) => regexp.test(input));
|
|
25156
25668
|
}
|
|
25157
25669
|
};
|
|
25670
|
+
var i18nCollector = class extends RecursiveVisitor {
|
|
25671
|
+
constructor() {
|
|
25672
|
+
super(...arguments);
|
|
25673
|
+
__publicField(this, "elements", []);
|
|
25674
|
+
}
|
|
25675
|
+
visitElement(el) {
|
|
25676
|
+
if (el.attrs.find((a) => a.name === "i18n") !== void 0) {
|
|
25677
|
+
this.elements.push(el);
|
|
25678
|
+
}
|
|
25679
|
+
super.visitElement(el, null);
|
|
25680
|
+
}
|
|
25681
|
+
};
|
|
25158
25682
|
var ElementCollector = class extends RecursiveVisitor {
|
|
25159
25683
|
constructor(_attributes = []) {
|
|
25160
25684
|
super();
|
|
@@ -25169,15 +25693,14 @@ var ElementCollector = class extends RecursiveVisitor {
|
|
|
25169
25693
|
const elseAttr = el.attrs.find((x) => x.name === boundngifelse);
|
|
25170
25694
|
const thenAttr = el.attrs.find((x) => x.name === boundngifthenelse || x.name === boundngifthen);
|
|
25171
25695
|
const forAttrs = attr.name === nakedngfor ? this.getForAttrs(el) : void 0;
|
|
25172
|
-
this.
|
|
25696
|
+
const aliasAttrs = this.getAliasAttrs(el);
|
|
25697
|
+
this.elements.push(new ElementToMigrate(el, attr, elseAttr, thenAttr, forAttrs, aliasAttrs));
|
|
25173
25698
|
}
|
|
25174
25699
|
}
|
|
25175
25700
|
}
|
|
25176
25701
|
super.visitElement(el, null);
|
|
25177
25702
|
}
|
|
25178
25703
|
getForAttrs(el) {
|
|
25179
|
-
const aliases = /* @__PURE__ */ new Map();
|
|
25180
|
-
let item = "";
|
|
25181
25704
|
let trackBy = "";
|
|
25182
25705
|
let forOf = "";
|
|
25183
25706
|
for (const attr of el.attrs) {
|
|
@@ -25187,6 +25710,13 @@ var ElementCollector = class extends RecursiveVisitor {
|
|
|
25187
25710
|
if (attr.name === "[ngForOf]") {
|
|
25188
25711
|
forOf = attr.value;
|
|
25189
25712
|
}
|
|
25713
|
+
}
|
|
25714
|
+
return { forOf, trackBy };
|
|
25715
|
+
}
|
|
25716
|
+
getAliasAttrs(el) {
|
|
25717
|
+
const aliases = /* @__PURE__ */ new Map();
|
|
25718
|
+
let item = "";
|
|
25719
|
+
for (const attr of el.attrs) {
|
|
25190
25720
|
if (attr.name.startsWith("let-")) {
|
|
25191
25721
|
if (attr.value === "") {
|
|
25192
25722
|
item = attr.name.replace("let-", "");
|
|
@@ -25195,7 +25725,7 @@ var ElementCollector = class extends RecursiveVisitor {
|
|
|
25195
25725
|
}
|
|
25196
25726
|
}
|
|
25197
25727
|
}
|
|
25198
|
-
return {
|
|
25728
|
+
return { item, aliases };
|
|
25199
25729
|
}
|
|
25200
25730
|
};
|
|
25201
25731
|
var TemplateCollector = class extends RecursiveVisitor {
|
|
@@ -25242,6 +25772,11 @@ var importRemovals = [
|
|
|
25242
25772
|
"NgSwitchDefault"
|
|
25243
25773
|
];
|
|
25244
25774
|
var importWithCommonRemovals = [...importRemovals, "CommonModule"];
|
|
25775
|
+
var startMarkerRegex = new RegExp(startMarker, "gm");
|
|
25776
|
+
var endMarkerRegex = new RegExp(endMarker, "gm");
|
|
25777
|
+
var startI18nMarkerRegex = new RegExp(startI18nMarker, "gm");
|
|
25778
|
+
var endI18nMarkerRegex = new RegExp(endI18nMarker, "gm");
|
|
25779
|
+
var replaceMarkerRegex = new RegExp(`${startMarker}|${endMarker}`, "gm");
|
|
25245
25780
|
function analyze(sourceFile, analyzedFiles) {
|
|
25246
25781
|
forEachClass(sourceFile, (node) => {
|
|
25247
25782
|
if (import_typescript5.default.isClassDeclaration(node)) {
|
|
@@ -25279,9 +25814,7 @@ function updateImportClause(clause, removeCommonModule) {
|
|
|
25279
25814
|
return clause;
|
|
25280
25815
|
}
|
|
25281
25816
|
function updateClassImports(propAssignment, removeCommonModule) {
|
|
25282
|
-
const printer = import_typescript5.default.createPrinter(
|
|
25283
|
-
removeComments: true
|
|
25284
|
-
});
|
|
25817
|
+
const printer = import_typescript5.default.createPrinter();
|
|
25285
25818
|
const importList = propAssignment.initializer;
|
|
25286
25819
|
const removals = removeCommonModule ? importWithCommonRemovals : importRemovals;
|
|
25287
25820
|
const elements = importList.elements.filter((el) => !removals.includes(el.getText()));
|
|
@@ -25364,12 +25897,13 @@ function parseTemplate2(template2) {
|
|
|
25364
25897
|
preserveLineEndings: true
|
|
25365
25898
|
});
|
|
25366
25899
|
if (parsed.errors && parsed.errors.length > 0) {
|
|
25367
|
-
|
|
25900
|
+
const errors = parsed.errors.map((e) => ({ type: "parse", error: e }));
|
|
25901
|
+
return { tree: void 0, errors };
|
|
25368
25902
|
}
|
|
25369
25903
|
} catch (e) {
|
|
25370
|
-
return
|
|
25904
|
+
return { tree: void 0, errors: [{ type: "parse", error: e }] };
|
|
25371
25905
|
}
|
|
25372
|
-
return parsed;
|
|
25906
|
+
return { tree: parsed, errors: [] };
|
|
25373
25907
|
}
|
|
25374
25908
|
function calculateNesting(visitor, hasLineBreaks2) {
|
|
25375
25909
|
let nestedQueue = [];
|
|
@@ -25406,12 +25940,12 @@ function reduceNestingOffset(el, nestLevel, offset, postOffsets) {
|
|
|
25406
25940
|
function getTemplates(template2) {
|
|
25407
25941
|
var _a2;
|
|
25408
25942
|
const parsed = parseTemplate2(template2);
|
|
25409
|
-
if (parsed !==
|
|
25943
|
+
if (parsed.tree !== void 0) {
|
|
25410
25944
|
const visitor = new TemplateCollector();
|
|
25411
|
-
visitAll2(visitor, parsed.rootNodes);
|
|
25945
|
+
visitAll2(visitor, parsed.tree.rootNodes);
|
|
25412
25946
|
for (let [key, tmpl] of visitor.templates) {
|
|
25413
25947
|
const escapeKey = escapeRegExp(key.slice(1));
|
|
25414
|
-
const regex = new RegExp(`[^a-zA-Z0-9-<']${escapeKey}\\W`, "gm");
|
|
25948
|
+
const regex = new RegExp(`[^a-zA-Z0-9-<(']${escapeKey}\\W`, "gm");
|
|
25415
25949
|
const matches = template2.match(regex);
|
|
25416
25950
|
tmpl.count = (_a2 = matches == null ? void 0 : matches.length) != null ? _a2 : 0;
|
|
25417
25951
|
tmpl.generateContents(template2);
|
|
@@ -25420,6 +25954,13 @@ function getTemplates(template2) {
|
|
|
25420
25954
|
}
|
|
25421
25955
|
return /* @__PURE__ */ new Map();
|
|
25422
25956
|
}
|
|
25957
|
+
function updateTemplates(template2, templates) {
|
|
25958
|
+
const updatedTemplates = getTemplates(template2);
|
|
25959
|
+
for (let [key, tmpl] of updatedTemplates) {
|
|
25960
|
+
templates.set(key, tmpl);
|
|
25961
|
+
}
|
|
25962
|
+
return templates;
|
|
25963
|
+
}
|
|
25423
25964
|
function wrapIntoI18nContainer(i18nAttr, content) {
|
|
25424
25965
|
const { start, middle, end } = generatei18nContainer(i18nAttr, content);
|
|
25425
25966
|
return `${start}${middle}${end}`;
|
|
@@ -25432,8 +25973,8 @@ function processNgTemplates(template2) {
|
|
|
25432
25973
|
try {
|
|
25433
25974
|
const templates = getTemplates(template2);
|
|
25434
25975
|
for (const [name, t] of templates) {
|
|
25435
|
-
const replaceRegex = new RegExp(
|
|
25436
|
-
const forRegex = new RegExp(
|
|
25976
|
+
const replaceRegex = new RegExp(`\u03B8${name.slice(1)}\\\u03B4`, "g");
|
|
25977
|
+
const forRegex = new RegExp(`\u03B8${name.slice(1)}\\\u03C6`, "g");
|
|
25437
25978
|
const forMatches = [...template2.matchAll(forRegex)];
|
|
25438
25979
|
const matches = [...forMatches, ...template2.matchAll(replaceRegex)];
|
|
25439
25980
|
let safeToRemove = true;
|
|
@@ -25454,21 +25995,33 @@ function processNgTemplates(template2) {
|
|
|
25454
25995
|
template2 = template2.replace(replaceRegex, t.children);
|
|
25455
25996
|
}
|
|
25456
25997
|
if (t.count === matches.length + 1 && safeToRemove) {
|
|
25457
|
-
template2 = template2.replace(t.contents,
|
|
25998
|
+
template2 = template2.replace(t.contents, `${startMarker}${endMarker}`);
|
|
25458
25999
|
}
|
|
26000
|
+
updateTemplates(template2, templates);
|
|
25459
26001
|
}
|
|
25460
26002
|
}
|
|
26003
|
+
template2 = replaceRemainingPlaceholders(template2);
|
|
25461
26004
|
return { migrated: template2, err: void 0 };
|
|
25462
26005
|
} catch (err) {
|
|
25463
26006
|
return { migrated: template2, err };
|
|
25464
26007
|
}
|
|
25465
26008
|
}
|
|
26009
|
+
function replaceRemainingPlaceholders(template2) {
|
|
26010
|
+
const replaceRegex = new RegExp(`\u03B8.*\u03B4`, "g");
|
|
26011
|
+
const placeholders = [...template2.matchAll(replaceRegex)];
|
|
26012
|
+
for (let ph of placeholders) {
|
|
26013
|
+
const placeholder = ph[0];
|
|
26014
|
+
const name = placeholder.slice(1, placeholder.length - 1);
|
|
26015
|
+
template2 = template2.replace(placeholder, `<ng-template [ngTemplateOutlet]="${name}"></ng-template>`);
|
|
26016
|
+
}
|
|
26017
|
+
return template2;
|
|
26018
|
+
}
|
|
25466
26019
|
function canRemoveCommonModule(template2) {
|
|
25467
26020
|
const parsed = parseTemplate2(template2);
|
|
25468
26021
|
let removeCommonModule = false;
|
|
25469
|
-
if (parsed !==
|
|
26022
|
+
if (parsed.tree !== void 0) {
|
|
25470
26023
|
const visitor = new CommonCollector();
|
|
25471
|
-
visitAll2(visitor, parsed.rootNodes);
|
|
26024
|
+
visitAll2(visitor, parsed.tree.rootNodes);
|
|
25472
26025
|
removeCommonModule = visitor.count === 0;
|
|
25473
26026
|
}
|
|
25474
26027
|
return removeCommonModule;
|
|
@@ -25489,16 +26042,46 @@ function getOriginals(etm, tmpl, offset) {
|
|
|
25489
26042
|
const start2 = tmpl.slice(etm.el.sourceSpan.start.offset - offset, etm.el.children[0].sourceSpan.start.offset - offset);
|
|
25490
26043
|
const end = tmpl.slice(etm.el.children[etm.el.children.length - 1].sourceSpan.end.offset - offset, etm.el.sourceSpan.end.offset - offset);
|
|
25491
26044
|
const childLength = childEnd - childStart;
|
|
25492
|
-
return {
|
|
26045
|
+
return {
|
|
26046
|
+
start: start2,
|
|
26047
|
+
end,
|
|
26048
|
+
childLength,
|
|
26049
|
+
children: getOriginalChildren(etm.el.children, tmpl, offset),
|
|
26050
|
+
childNodes: etm.el.children
|
|
26051
|
+
};
|
|
25493
26052
|
}
|
|
25494
26053
|
const start = tmpl.slice(etm.el.sourceSpan.start.offset - offset, etm.el.sourceSpan.end.offset - offset);
|
|
25495
|
-
return { start, end: "", childLength: 0 };
|
|
26054
|
+
return { start, end: "", childLength: 0, children: [], childNodes: [] };
|
|
26055
|
+
}
|
|
26056
|
+
function getOriginalChildren(children, tmpl, offset) {
|
|
26057
|
+
return children.map((child) => {
|
|
26058
|
+
return tmpl.slice(child.sourceSpan.start.offset - offset, child.sourceSpan.end.offset - offset);
|
|
26059
|
+
});
|
|
25496
26060
|
}
|
|
25497
26061
|
function isI18nTemplate(etm, i18nAttr) {
|
|
25498
|
-
|
|
26062
|
+
let attrCount = countAttributes(etm);
|
|
26063
|
+
const safeToRemove = etm.el.attrs.length === attrCount + (i18nAttr !== void 0 ? 1 : 0);
|
|
26064
|
+
return etm.el.name === "ng-template" && i18nAttr !== void 0 && safeToRemove;
|
|
25499
26065
|
}
|
|
25500
26066
|
function isRemovableContainer(etm) {
|
|
25501
|
-
|
|
26067
|
+
let attrCount = countAttributes(etm);
|
|
26068
|
+
const safeToRemove = etm.el.attrs.length === attrCount;
|
|
26069
|
+
return (etm.el.name === "ng-container" || etm.el.name === "ng-template") && safeToRemove;
|
|
26070
|
+
}
|
|
26071
|
+
function countAttributes(etm) {
|
|
26072
|
+
var _a2, _b2, _c2, _d2, _e2;
|
|
26073
|
+
let attrCount = 1;
|
|
26074
|
+
if (etm.elseAttr !== void 0) {
|
|
26075
|
+
attrCount++;
|
|
26076
|
+
}
|
|
26077
|
+
if (etm.thenAttr !== void 0) {
|
|
26078
|
+
attrCount++;
|
|
26079
|
+
}
|
|
26080
|
+
attrCount += (_b2 = (_a2 = etm.aliasAttrs) == null ? void 0 : _a2.aliases.size) != null ? _b2 : 0;
|
|
26081
|
+
attrCount += ((_c2 = etm.aliasAttrs) == null ? void 0 : _c2.item) ? 1 : 0;
|
|
26082
|
+
attrCount += ((_d2 = etm.forAttrs) == null ? void 0 : _d2.trackBy) ? 1 : 0;
|
|
26083
|
+
attrCount += ((_e2 = etm.forAttrs) == null ? void 0 : _e2.forOf) ? 1 : 0;
|
|
26084
|
+
return attrCount;
|
|
25502
26085
|
}
|
|
25503
26086
|
function getMainBlock(etm, tmpl, offset) {
|
|
25504
26087
|
const i18nAttr = etm.el.attrs.find((x) => x.name === "i18n");
|
|
@@ -25507,6 +26090,8 @@ function getMainBlock(etm, tmpl, offset) {
|
|
|
25507
26090
|
if (etm.hasChildren()) {
|
|
25508
26091
|
const { childStart: childStart2, childEnd: childEnd2 } = etm.getChildSpan(offset);
|
|
25509
26092
|
middle2 = tmpl.slice(childStart2, childEnd2);
|
|
26093
|
+
} else {
|
|
26094
|
+
middle2 = startMarker + endMarker;
|
|
25510
26095
|
}
|
|
25511
26096
|
return { start: "", middle: middle2, end: "" };
|
|
25512
26097
|
} else if (isI18nTemplate(etm, i18nAttr)) {
|
|
@@ -25517,16 +26102,37 @@ function getMainBlock(etm, tmpl, offset) {
|
|
|
25517
26102
|
const valEnd = etm.getValueEnd(offset);
|
|
25518
26103
|
const { childStart, childEnd } = etm.hasChildren() ? etm.getChildSpan(offset) : { childStart: valEnd, childEnd: valEnd };
|
|
25519
26104
|
let start = tmpl.slice(etm.start(offset), attrStart) + tmpl.slice(valEnd, childStart);
|
|
26105
|
+
const middle = tmpl.slice(childStart, childEnd);
|
|
26106
|
+
let end = tmpl.slice(childEnd, etm.end(offset));
|
|
25520
26107
|
if (etm.shouldRemoveElseAttr()) {
|
|
25521
26108
|
start = start.replace(etm.getElseAttrStr(), "");
|
|
26109
|
+
end = end.replace(etm.getElseAttrStr(), "");
|
|
25522
26110
|
}
|
|
25523
|
-
const middle = tmpl.slice(childStart, childEnd);
|
|
25524
|
-
const end = tmpl.slice(childEnd, etm.end(offset));
|
|
25525
26111
|
return { start, middle, end };
|
|
25526
26112
|
}
|
|
26113
|
+
function generateI18nMarkers(tmpl) {
|
|
26114
|
+
let parsed = parseTemplate2(tmpl);
|
|
26115
|
+
if (parsed.tree !== void 0) {
|
|
26116
|
+
const visitor = new i18nCollector();
|
|
26117
|
+
visitAll2(visitor, parsed.tree.rootNodes);
|
|
26118
|
+
for (const [ix, el] of visitor.elements.entries()) {
|
|
26119
|
+
const offset = ix * 2;
|
|
26120
|
+
if (el.children.length > 0) {
|
|
26121
|
+
tmpl = addI18nMarkers(tmpl, el, offset);
|
|
26122
|
+
}
|
|
26123
|
+
}
|
|
26124
|
+
}
|
|
26125
|
+
return tmpl;
|
|
26126
|
+
}
|
|
26127
|
+
function addI18nMarkers(tmpl, el, offset) {
|
|
26128
|
+
const startPos = el.children[0].sourceSpan.start.offset + offset;
|
|
26129
|
+
const endPos = el.children[el.children.length - 1].sourceSpan.end.offset + offset;
|
|
26130
|
+
return tmpl.slice(0, startPos) + startI18nMarker + tmpl.slice(startPos, endPos) + endI18nMarker + tmpl.slice(endPos);
|
|
26131
|
+
}
|
|
25527
26132
|
var selfClosingList = "input|br|img|base|wbr|area|col|embed|hr|link|meta|param|source|track";
|
|
25528
26133
|
function formatTemplate(tmpl, templateType) {
|
|
25529
26134
|
if (tmpl.indexOf("\n") > -1) {
|
|
26135
|
+
tmpl = generateI18nMarkers(tmpl);
|
|
25530
26136
|
let openSelfClosingEl = false;
|
|
25531
26137
|
const openBlockRegex = /^\s*\@(if|switch|case|default|for)|^\s*\}\s\@else/;
|
|
25532
26138
|
const openElRegex = /^\s*<([a-z0-9]+)(?![^>]*\/>)[^>]*>?/;
|
|
@@ -25541,8 +26147,20 @@ function formatTemplate(tmpl, templateType) {
|
|
|
25541
26147
|
const formatted = [];
|
|
25542
26148
|
let indent = "";
|
|
25543
26149
|
let mindent = "";
|
|
26150
|
+
let depth = 0;
|
|
26151
|
+
let i18nDepth = 0;
|
|
26152
|
+
let inMigratedBlock = false;
|
|
26153
|
+
let inI18nBlock = false;
|
|
25544
26154
|
for (let [index, line] of lines.entries()) {
|
|
25545
|
-
|
|
26155
|
+
depth += [...line.matchAll(startMarkerRegex)].length - [...line.matchAll(endMarkerRegex)].length;
|
|
26156
|
+
inMigratedBlock = depth > 0;
|
|
26157
|
+
i18nDepth += [...line.matchAll(startI18nMarkerRegex)].length - [...line.matchAll(endI18nMarkerRegex)].length;
|
|
26158
|
+
let lineWasMigrated = false;
|
|
26159
|
+
if (line.match(replaceMarkerRegex)) {
|
|
26160
|
+
line = line.replace(replaceMarkerRegex, "");
|
|
26161
|
+
lineWasMigrated = true;
|
|
26162
|
+
}
|
|
26163
|
+
if (line.trim() === "" && index !== 0 && index !== lines.length - 1 && (inMigratedBlock || lineWasMigrated)) {
|
|
25546
26164
|
continue;
|
|
25547
26165
|
}
|
|
25548
26166
|
if (templateType === "template" && index <= 1) {
|
|
@@ -25552,7 +26170,8 @@ function formatTemplate(tmpl, templateType) {
|
|
|
25552
26170
|
if ((closeBlockRegex.test(line) || closeElRegex.test(line) && (!singleLineElRegex.test(line) && !closeMultiLineElRegex.test(line))) && indent !== "") {
|
|
25553
26171
|
indent = indent.slice(2);
|
|
25554
26172
|
}
|
|
25555
|
-
|
|
26173
|
+
const newLine = inI18nBlock ? line : mindent + (line.trim() !== "" ? indent : "") + line.trim();
|
|
26174
|
+
formatted.push(newLine);
|
|
25556
26175
|
if (closeMultiLineElRegex.test(line)) {
|
|
25557
26176
|
indent = indent.slice(2);
|
|
25558
26177
|
if (openSelfClosingEl) {
|
|
@@ -25570,6 +26189,7 @@ function formatTemplate(tmpl, templateType) {
|
|
|
25570
26189
|
openSelfClosingEl = true;
|
|
25571
26190
|
indent += " ";
|
|
25572
26191
|
}
|
|
26192
|
+
inI18nBlock = i18nDepth > 0;
|
|
25573
26193
|
}
|
|
25574
26194
|
tmpl = formatted.join("\n");
|
|
25575
26195
|
}
|
|
@@ -25600,12 +26220,12 @@ var cases = [
|
|
|
25600
26220
|
function migrateCase(template2) {
|
|
25601
26221
|
let errors = [];
|
|
25602
26222
|
let parsed = parseTemplate2(template2);
|
|
25603
|
-
if (parsed ===
|
|
26223
|
+
if (parsed.tree === void 0) {
|
|
25604
26224
|
return { migrated: template2, errors, changed: false };
|
|
25605
26225
|
}
|
|
25606
26226
|
let result = template2;
|
|
25607
26227
|
const visitor = new ElementCollector(cases);
|
|
25608
|
-
visitAll2(visitor, parsed.rootNodes);
|
|
26228
|
+
visitAll2(visitor, parsed.tree.rootNodes);
|
|
25609
26229
|
calculateNesting(visitor, hasLineBreaks(template2));
|
|
25610
26230
|
let offset = 0;
|
|
25611
26231
|
let nestLevel = -1;
|
|
@@ -25640,8 +26260,8 @@ function migrateNgSwitchCase(etm, tmpl, offset) {
|
|
|
25640
26260
|
const condition = etm.attr.value;
|
|
25641
26261
|
const originals = getOriginals(etm, tmpl, offset);
|
|
25642
26262
|
const { start, middle, end } = getMainBlock(etm, tmpl, offset);
|
|
25643
|
-
const startBlock = `${leadingSpace}@case (${condition}) {${leadingSpace}${lbString}${start}`;
|
|
25644
|
-
const endBlock = `${end}${lbString}${leadingSpace}}`;
|
|
26263
|
+
const startBlock = `${startMarker}${leadingSpace}@case (${condition}) {${leadingSpace}${lbString}${start}`;
|
|
26264
|
+
const endBlock = `${end}${lbString}${leadingSpace}}${endMarker}`;
|
|
25645
26265
|
const defaultBlock = startBlock + middle + endBlock;
|
|
25646
26266
|
const updatedTmpl = tmpl.slice(0, etm.start(offset)) + defaultBlock + tmpl.slice(etm.end(offset));
|
|
25647
26267
|
const pre = originals.start.length - startBlock.length;
|
|
@@ -25653,8 +26273,8 @@ function migrateNgSwitchDefault(etm, tmpl, offset) {
|
|
|
25653
26273
|
const leadingSpace = etm.hasLineBreaks ? "" : " ";
|
|
25654
26274
|
const originals = getOriginals(etm, tmpl, offset);
|
|
25655
26275
|
const { start, middle, end } = getMainBlock(etm, tmpl, offset);
|
|
25656
|
-
const startBlock = `${leadingSpace}@default {${leadingSpace}${lbString}${start}`;
|
|
25657
|
-
const endBlock = `${end}${lbString}${leadingSpace}}`;
|
|
26276
|
+
const startBlock = `${startMarker}${leadingSpace}@default {${leadingSpace}${lbString}${start}`;
|
|
26277
|
+
const endBlock = `${end}${lbString}${leadingSpace}}${endMarker}`;
|
|
25658
26278
|
const defaultBlock = startBlock + middle + endBlock;
|
|
25659
26279
|
const updatedTmpl = tmpl.slice(0, etm.start(offset)) + defaultBlock + tmpl.slice(etm.end(offset));
|
|
25660
26280
|
const pre = originals.start.length - startBlock.length;
|
|
@@ -25681,12 +26301,12 @@ var stringPairs = /* @__PURE__ */ new Map([
|
|
|
25681
26301
|
function migrateFor(template2) {
|
|
25682
26302
|
let errors = [];
|
|
25683
26303
|
let parsed = parseTemplate2(template2);
|
|
25684
|
-
if (parsed ===
|
|
26304
|
+
if (parsed.tree === void 0) {
|
|
25685
26305
|
return { migrated: template2, errors, changed: false };
|
|
25686
26306
|
}
|
|
25687
26307
|
let result = template2;
|
|
25688
26308
|
const visitor = new ElementCollector(fors);
|
|
25689
|
-
visitAll2(visitor, parsed.rootNodes);
|
|
26309
|
+
visitAll2(visitor, parsed.tree.rootNodes);
|
|
25690
26310
|
calculateNesting(visitor, hasLineBreaks(template2));
|
|
25691
26311
|
let offset = 0;
|
|
25692
26312
|
let nestLevel = -1;
|
|
@@ -25736,7 +26356,7 @@ function migrateStandardNgFor(etm, tmpl, offset) {
|
|
|
25736
26356
|
trackBy = `${trackByFn}($index, ${loopVar})`;
|
|
25737
26357
|
}
|
|
25738
26358
|
if (part.startsWith("template:")) {
|
|
25739
|
-
tmplPlaceholder =
|
|
26359
|
+
tmplPlaceholder = `\u03B8${part.split(":")[1].trim()}\u03C6`;
|
|
25740
26360
|
}
|
|
25741
26361
|
if (part.match(aliasWithEqualRegexp)) {
|
|
25742
26362
|
const aliasParts = part.split("=");
|
|
@@ -25757,8 +26377,8 @@ function migrateStandardNgFor(etm, tmpl, offset) {
|
|
|
25757
26377
|
trackBy = trackBy.replace("$index", aliasedIndex);
|
|
25758
26378
|
}
|
|
25759
26379
|
const aliasStr = aliases.length > 0 ? `;${aliases.join(";")}` : "";
|
|
25760
|
-
let startBlock =
|
|
25761
|
-
let endBlock = `${lbString}}`;
|
|
26380
|
+
let startBlock = `${startMarker}@for (${condition}; track ${trackBy}${aliasStr}) {${lbString}`;
|
|
26381
|
+
let endBlock = `${lbString}}${endMarker}`;
|
|
25762
26382
|
let forBlock = "";
|
|
25763
26383
|
if (tmplPlaceholder !== "") {
|
|
25764
26384
|
startBlock = startBlock + tmplPlaceholder;
|
|
@@ -25776,9 +26396,10 @@ function migrateStandardNgFor(etm, tmpl, offset) {
|
|
|
25776
26396
|
}
|
|
25777
26397
|
function migrateBoundNgFor(etm, tmpl, offset) {
|
|
25778
26398
|
const forAttrs = etm.forAttrs;
|
|
25779
|
-
const
|
|
26399
|
+
const aliasAttrs = etm.aliasAttrs;
|
|
26400
|
+
const aliasMap = aliasAttrs.aliases;
|
|
25780
26401
|
const originals = getOriginals(etm, tmpl, offset);
|
|
25781
|
-
const condition = `${
|
|
26402
|
+
const condition = `${aliasAttrs.item} of ${forAttrs.forOf}`;
|
|
25782
26403
|
const aliases = [];
|
|
25783
26404
|
let aliasedIndex = "$index";
|
|
25784
26405
|
for (const [key, val] of aliasMap) {
|
|
@@ -25788,15 +26409,15 @@ function migrateBoundNgFor(etm, tmpl, offset) {
|
|
|
25788
26409
|
}
|
|
25789
26410
|
}
|
|
25790
26411
|
const aliasStr = aliases.length > 0 ? `;${aliases.join(";")}` : "";
|
|
25791
|
-
let trackBy =
|
|
26412
|
+
let trackBy = aliasAttrs.item;
|
|
25792
26413
|
if (forAttrs.trackBy !== "") {
|
|
25793
|
-
trackBy = `${forAttrs.trackBy.trim()}(${aliasedIndex}, ${
|
|
26414
|
+
trackBy = `${forAttrs.trackBy.trim()}(${aliasedIndex}, ${aliasAttrs.item})`;
|
|
25794
26415
|
}
|
|
25795
26416
|
const { start, middle, end } = getMainBlock(etm, tmpl, offset);
|
|
25796
|
-
const startBlock =
|
|
26417
|
+
const startBlock = `${startMarker}@for (${condition}; track ${trackBy}${aliasStr}) {
|
|
25797
26418
|
${start}`;
|
|
25798
26419
|
const endBlock = `${end}
|
|
25799
|
-
}`;
|
|
26420
|
+
}${endMarker}`;
|
|
25800
26421
|
const forBlock = startBlock + middle + endBlock;
|
|
25801
26422
|
const updatedTmpl = tmpl.slice(0, etm.start(offset)) + forBlock + tmpl.slice(etm.end(offset));
|
|
25802
26423
|
const pre = originals.start.length - startBlock.length;
|
|
@@ -25847,12 +26468,12 @@ var ifs = [
|
|
|
25847
26468
|
function migrateIf(template2) {
|
|
25848
26469
|
let errors = [];
|
|
25849
26470
|
let parsed = parseTemplate2(template2);
|
|
25850
|
-
if (parsed ===
|
|
26471
|
+
if (parsed.tree === void 0) {
|
|
25851
26472
|
return { migrated: template2, errors, changed: false };
|
|
25852
26473
|
}
|
|
25853
26474
|
let result = template2;
|
|
25854
26475
|
const visitor = new ElementCollector(ifs);
|
|
25855
|
-
visitAll2(visitor, parsed.rootNodes);
|
|
26476
|
+
visitAll2(visitor, parsed.tree.rootNodes);
|
|
25856
26477
|
calculateNesting(visitor, hasLineBreaks(template2));
|
|
25857
26478
|
let offset = 0;
|
|
25858
26479
|
let nestLevel = -1;
|
|
@@ -25874,24 +26495,36 @@ function migrateIf(template2) {
|
|
|
25874
26495
|
return { migrated: result, errors, changed };
|
|
25875
26496
|
}
|
|
25876
26497
|
function migrateNgIf(etm, tmpl, offset) {
|
|
25877
|
-
const matchThen = etm.attr.value.match(
|
|
25878
|
-
const matchElse = etm.attr.value.match(
|
|
26498
|
+
const matchThen = etm.attr.value.match(/[^\w\d];?\s*then/gm);
|
|
26499
|
+
const matchElse = etm.attr.value.match(/[^\w\d];?\s*else/gm);
|
|
25879
26500
|
if (etm.thenAttr !== void 0 || etm.elseAttr !== void 0) {
|
|
25880
26501
|
return buildBoundIfElseBlock(etm, tmpl, offset);
|
|
25881
|
-
} else if (matchThen && matchThen.length > 0) {
|
|
26502
|
+
} else if (matchThen && matchThen.length > 0 && matchElse && matchElse.length > 0) {
|
|
25882
26503
|
return buildStandardIfThenElseBlock(etm, tmpl, matchThen[0], matchElse[0], offset);
|
|
26504
|
+
} else if (matchThen && matchThen.length > 0) {
|
|
26505
|
+
return buildStandardIfThenBlock(etm, tmpl, matchThen[0], offset);
|
|
25883
26506
|
} else if (matchElse && matchElse.length > 0) {
|
|
25884
26507
|
return buildStandardIfElseBlock(etm, tmpl, matchElse[0], offset);
|
|
25885
26508
|
}
|
|
25886
26509
|
return buildIfBlock(etm, tmpl, offset);
|
|
25887
26510
|
}
|
|
25888
26511
|
function buildIfBlock(etm, tmpl, offset) {
|
|
26512
|
+
const aliasAttrs = etm.aliasAttrs;
|
|
26513
|
+
const aliases = [...aliasAttrs.aliases.keys()];
|
|
26514
|
+
if (aliasAttrs.item) {
|
|
26515
|
+
aliases.push(aliasAttrs.item);
|
|
26516
|
+
}
|
|
25889
26517
|
const lbString = etm.hasLineBreaks ? "\n" : "";
|
|
25890
|
-
|
|
26518
|
+
let condition = etm.attr.value.replace(" as ", "; as ").replace(/;\s*let/g, "; as");
|
|
26519
|
+
if (aliases.length > 1 || aliases.length === 1 && condition.indexOf("; as") > -1) {
|
|
26520
|
+
throw new Error("Found more than one alias on your ngIf. Remove one of them and re-run the migration.");
|
|
26521
|
+
} else if (aliases.length === 1) {
|
|
26522
|
+
condition += `; as ${aliases[0]}`;
|
|
26523
|
+
}
|
|
25891
26524
|
const originals = getOriginals(etm, tmpl, offset);
|
|
25892
26525
|
const { start, middle, end } = getMainBlock(etm, tmpl, offset);
|
|
25893
|
-
const startBlock =
|
|
25894
|
-
const endBlock = `${end}${lbString}}`;
|
|
26526
|
+
const startBlock = `${startMarker}@if (${condition}) {${lbString}${start}`;
|
|
26527
|
+
const endBlock = `${end}${lbString}}${endMarker}`;
|
|
25895
26528
|
const ifBlock = startBlock + middle + endBlock;
|
|
25896
26529
|
const updatedTmpl = tmpl.slice(0, etm.start(offset)) + ifBlock + tmpl.slice(etm.end(offset));
|
|
25897
26530
|
const pre = originals.start.length - startBlock.length;
|
|
@@ -25900,14 +26533,24 @@ function buildIfBlock(etm, tmpl, offset) {
|
|
|
25900
26533
|
}
|
|
25901
26534
|
function buildStandardIfElseBlock(etm, tmpl, elseString, offset) {
|
|
25902
26535
|
const condition = etm.getCondition().replace(" as ", "; as ").replace(/;\s*let/g, "; as");
|
|
25903
|
-
const elsePlaceholder =
|
|
26536
|
+
const elsePlaceholder = `\u03B8${etm.getTemplateName(elseString)}\u03B4`;
|
|
25904
26537
|
return buildIfElseBlock(etm, tmpl, condition, elsePlaceholder, offset);
|
|
25905
26538
|
}
|
|
25906
26539
|
function buildBoundIfElseBlock(etm, tmpl, offset) {
|
|
25907
|
-
const
|
|
25908
|
-
const
|
|
26540
|
+
const aliasAttrs = etm.aliasAttrs;
|
|
26541
|
+
const aliases = [...aliasAttrs.aliases.keys()];
|
|
26542
|
+
if (aliasAttrs.item) {
|
|
26543
|
+
aliases.push(aliasAttrs.item);
|
|
26544
|
+
}
|
|
26545
|
+
let condition = etm.attr.value.replace(" as ", "; as ");
|
|
26546
|
+
if (aliases.length > 1 || aliases.length === 1 && condition.indexOf("; as") > -1) {
|
|
26547
|
+
throw new Error("Found more than one alias on your ngIf. Remove one of them and re-run the migration.");
|
|
26548
|
+
} else if (aliases.length === 1) {
|
|
26549
|
+
condition += `; as ${aliases[0]}`;
|
|
26550
|
+
}
|
|
26551
|
+
const elsePlaceholder = `\u03B8${etm.elseAttr.value.trim()}\u03B4`;
|
|
25909
26552
|
if (etm.thenAttr !== void 0) {
|
|
25910
|
-
const thenPlaceholder =
|
|
26553
|
+
const thenPlaceholder = `\u03B8${etm.thenAttr.value.trim()}\u03B4`;
|
|
25911
26554
|
return buildIfThenElseBlock(etm, tmpl, condition, thenPlaceholder, elsePlaceholder, offset);
|
|
25912
26555
|
}
|
|
25913
26556
|
return buildIfElseBlock(etm, tmpl, condition, elsePlaceholder, offset);
|
|
@@ -25916,9 +26559,9 @@ function buildIfElseBlock(etm, tmpl, condition, elsePlaceholder, offset) {
|
|
|
25916
26559
|
const lbString = etm.hasLineBreaks ? "\n" : "";
|
|
25917
26560
|
const originals = getOriginals(etm, tmpl, offset);
|
|
25918
26561
|
const { start, middle, end } = getMainBlock(etm, tmpl, offset);
|
|
25919
|
-
const startBlock =
|
|
26562
|
+
const startBlock = `${startMarker}@if (${condition}) {${lbString}${start}`;
|
|
25920
26563
|
const elseBlock = `${end}${lbString}} @else {${lbString}`;
|
|
25921
|
-
const postBlock = elseBlock + elsePlaceholder + `${lbString}}`;
|
|
26564
|
+
const postBlock = elseBlock + elsePlaceholder + `${lbString}}${endMarker}`;
|
|
25922
26565
|
const ifElseBlock = startBlock + middle + postBlock;
|
|
25923
26566
|
const tmplStart = tmpl.slice(0, etm.start(offset));
|
|
25924
26567
|
const tmplEnd = tmpl.slice(etm.end(offset));
|
|
@@ -25929,16 +26572,21 @@ function buildIfElseBlock(etm, tmpl, condition, elsePlaceholder, offset) {
|
|
|
25929
26572
|
}
|
|
25930
26573
|
function buildStandardIfThenElseBlock(etm, tmpl, thenString, elseString, offset) {
|
|
25931
26574
|
const condition = etm.getCondition().replace(" as ", "; as ").replace(/;\s*let/g, "; as");
|
|
25932
|
-
const thenPlaceholder =
|
|
25933
|
-
const elsePlaceholder =
|
|
26575
|
+
const thenPlaceholder = `\u03B8${etm.getTemplateName(thenString, elseString)}\u03B4`;
|
|
26576
|
+
const elsePlaceholder = `\u03B8${etm.getTemplateName(elseString)}\u03B4`;
|
|
25934
26577
|
return buildIfThenElseBlock(etm, tmpl, condition, thenPlaceholder, elsePlaceholder, offset);
|
|
25935
26578
|
}
|
|
26579
|
+
function buildStandardIfThenBlock(etm, tmpl, thenString, offset) {
|
|
26580
|
+
const condition = etm.getCondition().replace(" as ", "; as ").replace(/;\s*let/g, "; as");
|
|
26581
|
+
const thenPlaceholder = `\u03B8${etm.getTemplateName(thenString)}\u03B4`;
|
|
26582
|
+
return buildIfThenBlock(etm, tmpl, condition, thenPlaceholder, offset);
|
|
26583
|
+
}
|
|
25936
26584
|
function buildIfThenElseBlock(etm, tmpl, condition, thenPlaceholder, elsePlaceholder, offset) {
|
|
25937
26585
|
const lbString = etm.hasLineBreaks ? "\n" : "";
|
|
25938
26586
|
const originals = getOriginals(etm, tmpl, offset);
|
|
25939
|
-
const startBlock =
|
|
26587
|
+
const startBlock = `${startMarker}@if (${condition}) {${lbString}`;
|
|
25940
26588
|
const elseBlock = `${lbString}} @else {${lbString}`;
|
|
25941
|
-
const postBlock = thenPlaceholder + elseBlock + elsePlaceholder + `${lbString}}`;
|
|
26589
|
+
const postBlock = thenPlaceholder + elseBlock + elsePlaceholder + `${lbString}}${endMarker}`;
|
|
25942
26590
|
const ifThenElseBlock = startBlock + postBlock;
|
|
25943
26591
|
const tmplStart = tmpl.slice(0, etm.start(offset));
|
|
25944
26592
|
const tmplEnd = tmpl.slice(etm.end(offset));
|
|
@@ -25947,6 +26595,19 @@ function buildIfThenElseBlock(etm, tmpl, condition, thenPlaceholder, elsePlaceho
|
|
|
25947
26595
|
const post = originals.end.length - postBlock.length;
|
|
25948
26596
|
return { tmpl: updatedTmpl, offsets: { pre, post } };
|
|
25949
26597
|
}
|
|
26598
|
+
function buildIfThenBlock(etm, tmpl, condition, thenPlaceholder, offset) {
|
|
26599
|
+
const lbString = etm.hasLineBreaks ? "\n" : "";
|
|
26600
|
+
const originals = getOriginals(etm, tmpl, offset);
|
|
26601
|
+
const startBlock = `${startMarker}@if (${condition}) {${lbString}`;
|
|
26602
|
+
const postBlock = thenPlaceholder + `${lbString}}${endMarker}`;
|
|
26603
|
+
const ifThenBlock = startBlock + postBlock;
|
|
26604
|
+
const tmplStart = tmpl.slice(0, etm.start(offset));
|
|
26605
|
+
const tmplEnd = tmpl.slice(etm.end(offset));
|
|
26606
|
+
const updatedTmpl = tmplStart + ifThenBlock + tmplEnd;
|
|
26607
|
+
const pre = originals.start.length + originals.childLength - startBlock.length;
|
|
26608
|
+
const post = originals.end.length - postBlock.length;
|
|
26609
|
+
return { tmpl: updatedTmpl, offsets: { pre, post } };
|
|
26610
|
+
}
|
|
25950
26611
|
|
|
25951
26612
|
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/ng-generate/control-flow-migration/switches.mjs
|
|
25952
26613
|
var ngswitch = "[ngSwitch]";
|
|
@@ -25956,12 +26617,12 @@ var switches = [
|
|
|
25956
26617
|
function migrateSwitch(template2) {
|
|
25957
26618
|
let errors = [];
|
|
25958
26619
|
let parsed = parseTemplate2(template2);
|
|
25959
|
-
if (parsed ===
|
|
26620
|
+
if (parsed.tree === void 0) {
|
|
25960
26621
|
return { migrated: template2, errors, changed: false };
|
|
25961
26622
|
}
|
|
25962
26623
|
let result = template2;
|
|
25963
26624
|
const visitor = new ElementCollector(switches);
|
|
25964
|
-
visitAll2(visitor, parsed.rootNodes);
|
|
26625
|
+
visitAll2(visitor, parsed.tree.rootNodes);
|
|
25965
26626
|
calculateNesting(visitor, hasLineBreaks(template2));
|
|
25966
26627
|
let offset = 0;
|
|
25967
26628
|
let nestLevel = -1;
|
|
@@ -25984,13 +26645,31 @@ function migrateSwitch(template2) {
|
|
|
25984
26645
|
const changed = visitor.elements.length > 0;
|
|
25985
26646
|
return { migrated: result, errors, changed };
|
|
25986
26647
|
}
|
|
26648
|
+
function assertValidSwitchStructure(children) {
|
|
26649
|
+
for (const child of children) {
|
|
26650
|
+
if (child instanceof Text4 && child.value.trim() !== "") {
|
|
26651
|
+
throw new Error(`Text node: "${child.value}" would result in invalid migrated @switch block structure. @switch can only have @case or @default as children.`);
|
|
26652
|
+
} else if (child instanceof Element2) {
|
|
26653
|
+
let hasCase = false;
|
|
26654
|
+
for (const attr of child.attrs) {
|
|
26655
|
+
if (cases.includes(attr.name)) {
|
|
26656
|
+
hasCase = true;
|
|
26657
|
+
}
|
|
26658
|
+
}
|
|
26659
|
+
if (!hasCase) {
|
|
26660
|
+
throw new Error(`Element node: "${child.name}" would result in invalid migrated @switch block structure. @switch can only have @case or @default as children.`);
|
|
26661
|
+
}
|
|
26662
|
+
}
|
|
26663
|
+
}
|
|
26664
|
+
}
|
|
25987
26665
|
function migrateNgSwitch(etm, tmpl, offset) {
|
|
25988
26666
|
const lbString = etm.hasLineBreaks ? "\n" : "";
|
|
25989
26667
|
const condition = etm.attr.value;
|
|
25990
26668
|
const originals = getOriginals(etm, tmpl, offset);
|
|
26669
|
+
assertValidSwitchStructure(originals.childNodes);
|
|
25991
26670
|
const { start, middle, end } = getMainBlock(etm, tmpl, offset);
|
|
25992
|
-
const startBlock = `${start}${lbString}@switch (${condition}) {`;
|
|
25993
|
-
const endBlock = `}${lbString}${end}`;
|
|
26671
|
+
const startBlock = `${startMarker}${start}${lbString}@switch (${condition}) {`;
|
|
26672
|
+
const endBlock = `}${lbString}${end}${endMarker}`;
|
|
25994
26673
|
const switchBlock = startBlock + middle + endBlock;
|
|
25995
26674
|
const updatedTmpl = tmpl.slice(0, etm.start(offset)) + switchBlock + tmpl.slice(etm.end(offset));
|
|
25996
26675
|
const pre = originals.start.length - startBlock.length;
|
|
@@ -26006,6 +26685,9 @@ function migrateTemplate(template2, templateType, node, file, format = true, ana
|
|
|
26006
26685
|
const ifResult = migrateIf(template2);
|
|
26007
26686
|
const forResult = migrateFor(ifResult.migrated);
|
|
26008
26687
|
const switchResult = migrateSwitch(forResult.migrated);
|
|
26688
|
+
if (switchResult.errors.length > 0) {
|
|
26689
|
+
return { migrated: template2, errors: switchResult.errors };
|
|
26690
|
+
}
|
|
26009
26691
|
const caseResult = migrateCase(switchResult.migrated);
|
|
26010
26692
|
const templateResult = processNgTemplates(caseResult.migrated);
|
|
26011
26693
|
if (templateResult.err !== void 0) {
|
|
@@ -26013,13 +26695,27 @@ function migrateTemplate(template2, templateType, node, file, format = true, ana
|
|
|
26013
26695
|
}
|
|
26014
26696
|
migrated = templateResult.migrated;
|
|
26015
26697
|
const changed = ifResult.changed || forResult.changed || switchResult.changed || caseResult.changed;
|
|
26698
|
+
if (changed) {
|
|
26699
|
+
const parsed = parseTemplate2(migrated);
|
|
26700
|
+
if (parsed.errors.length > 0) {
|
|
26701
|
+
const parsingError = {
|
|
26702
|
+
type: "parse",
|
|
26703
|
+
error: new Error(`The migration resulted in invalid HTML for ${file.sourceFilePath}. Please check the template for valid HTML structures and run the migration again.`)
|
|
26704
|
+
};
|
|
26705
|
+
return { migrated: template2, errors: [parsingError] };
|
|
26706
|
+
}
|
|
26707
|
+
}
|
|
26016
26708
|
if (format && changed) {
|
|
26017
26709
|
migrated = formatTemplate(migrated, templateType);
|
|
26018
26710
|
}
|
|
26711
|
+
const markerRegex = new RegExp(`${startMarker}|${endMarker}|${startI18nMarker}|${endI18nMarker}`, "gm");
|
|
26712
|
+
migrated = migrated.replace(markerRegex, "");
|
|
26019
26713
|
file.removeCommonModule = canRemoveCommonModule(template2);
|
|
26714
|
+
file.canRemoveImports = true;
|
|
26020
26715
|
if (templateType === "templateUrl" && analyzedFiles !== null && analyzedFiles.has(file.sourceFilePath)) {
|
|
26021
26716
|
const componentFile = analyzedFiles.get(file.sourceFilePath);
|
|
26022
26717
|
componentFile.removeCommonModule = file.removeCommonModule;
|
|
26718
|
+
componentFile.canRemoveImports = file.canRemoveImports;
|
|
26023
26719
|
}
|
|
26024
26720
|
errors = [
|
|
26025
26721
|
...ifResult.errors,
|
|
@@ -26027,7 +26723,7 @@ function migrateTemplate(template2, templateType, node, file, format = true, ana
|
|
|
26027
26723
|
...switchResult.errors,
|
|
26028
26724
|
...caseResult.errors
|
|
26029
26725
|
];
|
|
26030
|
-
} else {
|
|
26726
|
+
} else if (file.canRemoveImports) {
|
|
26031
26727
|
migrated = removeImports(template2, node, file.removeCommonModule);
|
|
26032
26728
|
}
|
|
26033
26729
|
return { migrated, errors };
|