@angular/compiler 17.1.0-next.5 → 17.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2022/src/compiler_facade_interface.mjs +1 -1
- package/esm2022/src/core.mjs +8 -1
- package/esm2022/src/jit_compiler_facade.mjs +9 -7
- package/esm2022/src/output/abstract_emitter.mjs +4 -1
- package/esm2022/src/output/output_ast.mjs +11 -7
- package/esm2022/src/render3/partial/class_metadata.mjs +1 -1
- package/esm2022/src/render3/partial/directive.mjs +4 -4
- package/esm2022/src/render3/partial/factory.mjs +1 -1
- package/esm2022/src/render3/partial/injectable.mjs +1 -1
- package/esm2022/src/render3/partial/injector.mjs +1 -1
- package/esm2022/src/render3/partial/ng_module.mjs +1 -1
- package/esm2022/src/render3/partial/pipe.mjs +1 -1
- package/esm2022/src/render3/r3_class_metadata_compiler.mjs +2 -2
- package/esm2022/src/render3/r3_identifiers.mjs +5 -1
- package/esm2022/src/render3/view/api.mjs +1 -1
- package/esm2022/src/render3/view/compiler.mjs +26 -2
- package/esm2022/src/render3/view/style_parser.mjs +2 -1
- package/esm2022/src/render3/view/t2_api.mjs +1 -1
- package/esm2022/src/render3/view/t2_binder.mjs +18 -3
- package/esm2022/src/render3/view/template.mjs +9 -5
- package/esm2022/src/render3/view/util.mjs +35 -7
- package/esm2022/src/template/pipeline/ir/src/enums.mjs +1 -11
- package/esm2022/src/template/pipeline/ir/src/expression.mjs +1 -21
- package/esm2022/src/template/pipeline/ir/src/ops/create.mjs +3 -2
- package/esm2022/src/template/pipeline/ir/src/ops/update.mjs +3 -2
- package/esm2022/src/template/pipeline/src/conversion.mjs +2 -1
- package/esm2022/src/template/pipeline/src/emit.mjs +1 -3
- package/esm2022/src/template/pipeline/src/ingest.mjs +40 -15
- package/esm2022/src/template/pipeline/src/instruction.mjs +8 -7
- package/esm2022/src/template/pipeline/src/phases/attribute_extraction.mjs +6 -5
- package/esm2022/src/template/pipeline/src/phases/binding_specialization.mjs +4 -2
- package/esm2022/src/template/pipeline/src/phases/const_collection.mjs +8 -12
- package/esm2022/src/template/pipeline/src/phases/host_style_property_parsing.mjs +2 -2
- package/esm2022/src/template/pipeline/src/phases/parse_extracted_styles.mjs +3 -3
- package/esm2022/src/template/pipeline/src/phases/reify.mjs +2 -2
- package/esm2022/src/version.mjs +1 -1
- package/fesm2022/compiler.mjs +198 -145
- package/fesm2022/compiler.mjs.map +1 -1
- package/index.d.ts +135 -9
- package/package.json +2 -2
- package/esm2022/src/template/pipeline/src/phases/repeater_derived_vars.mjs +0 -45
package/fesm2022/compiler.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v17.1.0
|
|
2
|
+
* @license Angular v17.1.0
|
|
3
3
|
* (c) 2010-2022 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -409,6 +409,13 @@ var ChangeDetectionStrategy;
|
|
|
409
409
|
ChangeDetectionStrategy[ChangeDetectionStrategy["OnPush"] = 0] = "OnPush";
|
|
410
410
|
ChangeDetectionStrategy[ChangeDetectionStrategy["Default"] = 1] = "Default";
|
|
411
411
|
})(ChangeDetectionStrategy || (ChangeDetectionStrategy = {}));
|
|
412
|
+
/** Flags describing an input for a directive. */
|
|
413
|
+
var InputFlags;
|
|
414
|
+
(function (InputFlags) {
|
|
415
|
+
InputFlags[InputFlags["None"] = 0] = "None";
|
|
416
|
+
InputFlags[InputFlags["SignalBased"] = 1] = "SignalBased";
|
|
417
|
+
InputFlags[InputFlags["HasDecoratorInputTransform"] = 2] = "HasDecoratorInputTransform";
|
|
418
|
+
})(InputFlags || (InputFlags = {}));
|
|
412
419
|
const CUSTOM_ELEMENTS_SCHEMA = {
|
|
413
420
|
name: 'custom-elements'
|
|
414
421
|
};
|
|
@@ -472,6 +479,7 @@ var core = /*#__PURE__*/Object.freeze({
|
|
|
472
479
|
emitDistinctChangesOnlyDefaultValue: emitDistinctChangesOnlyDefaultValue,
|
|
473
480
|
get ViewEncapsulation () { return ViewEncapsulation; },
|
|
474
481
|
get ChangeDetectionStrategy () { return ChangeDetectionStrategy; },
|
|
482
|
+
get InputFlags () { return InputFlags; },
|
|
475
483
|
CUSTOM_ELEMENTS_SCHEMA: CUSTOM_ELEMENTS_SCHEMA,
|
|
476
484
|
NO_ERRORS_SCHEMA: NO_ERRORS_SCHEMA,
|
|
477
485
|
Type: Type$1,
|
|
@@ -890,12 +898,13 @@ var BinaryOperator;
|
|
|
890
898
|
BinaryOperator[BinaryOperator["Modulo"] = 8] = "Modulo";
|
|
891
899
|
BinaryOperator[BinaryOperator["And"] = 9] = "And";
|
|
892
900
|
BinaryOperator[BinaryOperator["Or"] = 10] = "Or";
|
|
893
|
-
BinaryOperator[BinaryOperator["
|
|
894
|
-
BinaryOperator[BinaryOperator["
|
|
895
|
-
BinaryOperator[BinaryOperator["
|
|
896
|
-
BinaryOperator[BinaryOperator["
|
|
897
|
-
BinaryOperator[BinaryOperator["
|
|
898
|
-
BinaryOperator[BinaryOperator["
|
|
901
|
+
BinaryOperator[BinaryOperator["BitwiseOr"] = 11] = "BitwiseOr";
|
|
902
|
+
BinaryOperator[BinaryOperator["BitwiseAnd"] = 12] = "BitwiseAnd";
|
|
903
|
+
BinaryOperator[BinaryOperator["Lower"] = 13] = "Lower";
|
|
904
|
+
BinaryOperator[BinaryOperator["LowerEquals"] = 14] = "LowerEquals";
|
|
905
|
+
BinaryOperator[BinaryOperator["Bigger"] = 15] = "Bigger";
|
|
906
|
+
BinaryOperator[BinaryOperator["BiggerEquals"] = 16] = "BiggerEquals";
|
|
907
|
+
BinaryOperator[BinaryOperator["NullishCoalesce"] = 17] = "NullishCoalesce";
|
|
899
908
|
})(BinaryOperator || (BinaryOperator = {}));
|
|
900
909
|
function nullSafeIsEquivalent(base, other) {
|
|
901
910
|
if (base == null || other == null) {
|
|
@@ -968,6 +977,9 @@ class Expression {
|
|
|
968
977
|
and(rhs, sourceSpan) {
|
|
969
978
|
return new BinaryOperatorExpr(BinaryOperator.And, this, rhs, null, sourceSpan);
|
|
970
979
|
}
|
|
980
|
+
bitwiseOr(rhs, sourceSpan, parens = true) {
|
|
981
|
+
return new BinaryOperatorExpr(BinaryOperator.BitwiseOr, this, rhs, null, sourceSpan, parens);
|
|
982
|
+
}
|
|
971
983
|
bitwiseAnd(rhs, sourceSpan, parens = true) {
|
|
972
984
|
return new BinaryOperatorExpr(BinaryOperator.BitwiseAnd, this, rhs, null, sourceSpan, parens);
|
|
973
985
|
}
|
|
@@ -2628,6 +2640,10 @@ class Identifiers {
|
|
|
2628
2640
|
name: 'ɵɵgetInheritedFactory',
|
|
2629
2641
|
moduleName: CORE,
|
|
2630
2642
|
}; }
|
|
2643
|
+
static { this.InputFlags = {
|
|
2644
|
+
name: 'ɵɵInputFlags',
|
|
2645
|
+
moduleName: CORE,
|
|
2646
|
+
}; }
|
|
2631
2647
|
// sanitization-related functions
|
|
2632
2648
|
static { this.sanitizeHtml = { name: 'ɵɵsanitizeHtml', moduleName: CORE }; }
|
|
2633
2649
|
static { this.sanitizeStyle = { name: 'ɵɵsanitizeStyle', moduleName: CORE }; }
|
|
@@ -3269,6 +3285,9 @@ class AbstractEmitterVisitor {
|
|
|
3269
3285
|
case BinaryOperator.And:
|
|
3270
3286
|
opStr = '&&';
|
|
3271
3287
|
break;
|
|
3288
|
+
case BinaryOperator.BitwiseOr:
|
|
3289
|
+
opStr = '|';
|
|
3290
|
+
break;
|
|
3272
3291
|
case BinaryOperator.BitwiseAnd:
|
|
3273
3292
|
opStr = '&';
|
|
3274
3293
|
break;
|
|
@@ -4973,7 +4992,7 @@ function asLiteral(value) {
|
|
|
4973
4992
|
* This will attempt to generate optimized data structures to minimize memory or
|
|
4974
4993
|
* file size of fully compiled applications.
|
|
4975
4994
|
*/
|
|
4976
|
-
function conditionallyCreateDirectiveBindingLiteral(map,
|
|
4995
|
+
function conditionallyCreateDirectiveBindingLiteral(map, forInputs) {
|
|
4977
4996
|
const keys = Object.getOwnPropertyNames(map);
|
|
4978
4997
|
if (keys.length === 0) {
|
|
4979
4998
|
return null;
|
|
@@ -4995,12 +5014,28 @@ function conditionallyCreateDirectiveBindingLiteral(map, keepDeclared) {
|
|
|
4995
5014
|
minifiedName = key;
|
|
4996
5015
|
declaredName = value.classPropertyName;
|
|
4997
5016
|
publicName = value.bindingPropertyName;
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5017
|
+
const differentDeclaringName = publicName !== declaredName;
|
|
5018
|
+
const hasDecoratorInputTransform = value.transformFunction !== null;
|
|
5019
|
+
// Build up input flags
|
|
5020
|
+
let flags = null;
|
|
5021
|
+
if (value.isSignal) {
|
|
5022
|
+
flags = bitwiseOrInputFlagsExpr(InputFlags.SignalBased, flags);
|
|
5023
|
+
}
|
|
5024
|
+
if (hasDecoratorInputTransform) {
|
|
5025
|
+
flags = bitwiseOrInputFlagsExpr(InputFlags.HasDecoratorInputTransform, flags);
|
|
5026
|
+
}
|
|
5027
|
+
// Inputs, compared to outputs, will track their declared name (for `ngOnChanges`), support
|
|
5028
|
+
// decorator input transform functions, or store flag information if there is any.
|
|
5029
|
+
if (forInputs && (differentDeclaringName || hasDecoratorInputTransform || flags !== null)) {
|
|
5030
|
+
const flagsExpr = flags ?? importExpr(Identifiers.InputFlags).prop(InputFlags[InputFlags.None]);
|
|
5031
|
+
const result = [flagsExpr, asLiteral(publicName)];
|
|
5032
|
+
if (differentDeclaringName || hasDecoratorInputTransform) {
|
|
5033
|
+
result.push(asLiteral(declaredName));
|
|
5034
|
+
if (hasDecoratorInputTransform) {
|
|
5035
|
+
result.push(value.transformFunction);
|
|
5036
|
+
}
|
|
5002
5037
|
}
|
|
5003
|
-
expressionValue = literalArr(
|
|
5038
|
+
expressionValue = literalArr(result);
|
|
5004
5039
|
}
|
|
5005
5040
|
else {
|
|
5006
5041
|
expressionValue = asLiteral(publicName);
|
|
@@ -5014,6 +5049,17 @@ function conditionallyCreateDirectiveBindingLiteral(map, keepDeclared) {
|
|
|
5014
5049
|
};
|
|
5015
5050
|
}));
|
|
5016
5051
|
}
|
|
5052
|
+
/** Gets an output AST expression referencing the given flag. */
|
|
5053
|
+
function getInputFlagExpr(flag) {
|
|
5054
|
+
return importExpr(Identifiers.InputFlags).prop(InputFlags[flag]);
|
|
5055
|
+
}
|
|
5056
|
+
/** Combines a given input flag with an existing flag expression, if present. */
|
|
5057
|
+
function bitwiseOrInputFlagsExpr(flag, expr) {
|
|
5058
|
+
if (expr === null) {
|
|
5059
|
+
return getInputFlagExpr(flag);
|
|
5060
|
+
}
|
|
5061
|
+
return getInputFlagExpr(flag).bitwiseOr(expr);
|
|
5062
|
+
}
|
|
5017
5063
|
/**
|
|
5018
5064
|
* Remove trailing null nodes as they are implied.
|
|
5019
5065
|
*/
|
|
@@ -9270,16 +9316,6 @@ var DeferTriggerKind;
|
|
|
9270
9316
|
DeferTriggerKind[DeferTriggerKind["Interaction"] = 4] = "Interaction";
|
|
9271
9317
|
DeferTriggerKind[DeferTriggerKind["Viewport"] = 5] = "Viewport";
|
|
9272
9318
|
})(DeferTriggerKind || (DeferTriggerKind = {}));
|
|
9273
|
-
/**
|
|
9274
|
-
* Repeaters implicitly define these derived variables, and child nodes may read them.
|
|
9275
|
-
*/
|
|
9276
|
-
var DerivedRepeaterVarIdentity;
|
|
9277
|
-
(function (DerivedRepeaterVarIdentity) {
|
|
9278
|
-
DerivedRepeaterVarIdentity[DerivedRepeaterVarIdentity["First"] = 0] = "First";
|
|
9279
|
-
DerivedRepeaterVarIdentity[DerivedRepeaterVarIdentity["Last"] = 1] = "Last";
|
|
9280
|
-
DerivedRepeaterVarIdentity[DerivedRepeaterVarIdentity["Even"] = 2] = "Even";
|
|
9281
|
-
DerivedRepeaterVarIdentity[DerivedRepeaterVarIdentity["Odd"] = 3] = "Odd";
|
|
9282
|
-
})(DerivedRepeaterVarIdentity || (DerivedRepeaterVarIdentity = {}));
|
|
9283
9319
|
/**
|
|
9284
9320
|
* Kinds of i18n contexts. They can be created because of root i18n blocks, or ICUs.
|
|
9285
9321
|
*/
|
|
@@ -9524,10 +9560,11 @@ function createClassMapOp(xref, expression, sourceSpan) {
|
|
|
9524
9560
|
/**
|
|
9525
9561
|
* Create an `AttributeOp`.
|
|
9526
9562
|
*/
|
|
9527
|
-
function createAttributeOp(target, name, expression, securityContext, isTextAttribute, isStructuralTemplateAttribute, templateKind, i18nMessage, sourceSpan) {
|
|
9563
|
+
function createAttributeOp(target, namespace, name, expression, securityContext, isTextAttribute, isStructuralTemplateAttribute, templateKind, i18nMessage, sourceSpan) {
|
|
9528
9564
|
return {
|
|
9529
9565
|
kind: OpKind.Attribute,
|
|
9530
9566
|
target,
|
|
9567
|
+
namespace,
|
|
9531
9568
|
name,
|
|
9532
9569
|
expression,
|
|
9533
9570
|
securityContext,
|
|
@@ -10224,26 +10261,6 @@ class ConditionalCaseExpr extends ExpressionBase {
|
|
|
10224
10261
|
}
|
|
10225
10262
|
}
|
|
10226
10263
|
}
|
|
10227
|
-
class DerivedRepeaterVarExpr extends ExpressionBase {
|
|
10228
|
-
constructor(xref, identity) {
|
|
10229
|
-
super();
|
|
10230
|
-
this.xref = xref;
|
|
10231
|
-
this.identity = identity;
|
|
10232
|
-
this.kind = ExpressionKind.DerivedRepeaterVar;
|
|
10233
|
-
}
|
|
10234
|
-
transformInternalExpressions(transform, flags) { }
|
|
10235
|
-
visitExpression(visitor, context) { }
|
|
10236
|
-
isEquivalent(e) {
|
|
10237
|
-
return e instanceof DerivedRepeaterVarExpr && e.identity === this.identity &&
|
|
10238
|
-
e.xref === this.xref;
|
|
10239
|
-
}
|
|
10240
|
-
isConstant() {
|
|
10241
|
-
return false;
|
|
10242
|
-
}
|
|
10243
|
-
clone() {
|
|
10244
|
-
return new DerivedRepeaterVarExpr(this.xref, this.identity);
|
|
10245
|
-
}
|
|
10246
|
-
}
|
|
10247
10264
|
class ConstCollectedExpr extends ExpressionBase {
|
|
10248
10265
|
constructor(expr) {
|
|
10249
10266
|
super();
|
|
@@ -11009,11 +11026,12 @@ function createProjectionOp(xref, selector, i18nPlaceholder, sourceSpan) {
|
|
|
11009
11026
|
/**
|
|
11010
11027
|
* Create an `ExtractedAttributeOp`.
|
|
11011
11028
|
*/
|
|
11012
|
-
function createExtractedAttributeOp(target, bindingKind, name, expression, i18nContext, i18nMessage, securityContext) {
|
|
11029
|
+
function createExtractedAttributeOp(target, bindingKind, namespace, name, expression, i18nContext, i18nMessage, securityContext) {
|
|
11013
11030
|
return {
|
|
11014
11031
|
kind: OpKind.ExtractedAttribute,
|
|
11015
11032
|
target,
|
|
11016
11033
|
bindingKind,
|
|
11034
|
+
namespace,
|
|
11017
11035
|
name,
|
|
11018
11036
|
expression,
|
|
11019
11037
|
i18nContext,
|
|
@@ -11563,7 +11581,8 @@ function extractAttributes(job) {
|
|
|
11563
11581
|
}
|
|
11564
11582
|
OpList.insertBefore(
|
|
11565
11583
|
// Deliberaly null i18nMessage value
|
|
11566
|
-
createExtractedAttributeOp(op.target, bindingKind, op.name, /* expression */ null,
|
|
11584
|
+
createExtractedAttributeOp(op.target, bindingKind, null, op.name, /* expression */ null,
|
|
11585
|
+
/* i18nContext */ null,
|
|
11567
11586
|
/* i18nMessage */ null, op.securityContext), lookupElement$2(elements, op.target));
|
|
11568
11587
|
}
|
|
11569
11588
|
break;
|
|
@@ -11575,14 +11594,14 @@ function extractAttributes(job) {
|
|
|
11575
11594
|
// mode.
|
|
11576
11595
|
if (unit.job.compatibility === CompatibilityMode.TemplateDefinitionBuilder &&
|
|
11577
11596
|
op.expression instanceof EmptyExpr) {
|
|
11578
|
-
OpList.insertBefore(createExtractedAttributeOp(op.target, BindingKind.Property, op.name, /* expression */ null,
|
|
11597
|
+
OpList.insertBefore(createExtractedAttributeOp(op.target, BindingKind.Property, null, op.name, /* expression */ null,
|
|
11579
11598
|
/* i18nContext */ null,
|
|
11580
11599
|
/* i18nMessage */ null, SecurityContext.STYLE), lookupElement$2(elements, op.target));
|
|
11581
11600
|
}
|
|
11582
11601
|
break;
|
|
11583
11602
|
case OpKind.Listener:
|
|
11584
11603
|
if (!op.isAnimationListener) {
|
|
11585
|
-
const extractedAttributeOp = createExtractedAttributeOp(op.target, BindingKind.Property, op.name, /* expression */ null,
|
|
11604
|
+
const extractedAttributeOp = createExtractedAttributeOp(op.target, BindingKind.Property, null, op.name, /* expression */ null,
|
|
11586
11605
|
/* i18nContext */ null,
|
|
11587
11606
|
/* i18nMessage */ null, SecurityContext.NONE);
|
|
11588
11607
|
if (job.kind === CompilationJobKind.Host) {
|
|
@@ -11628,7 +11647,7 @@ function extractAttributeOp(unit, op, elements) {
|
|
|
11628
11647
|
extractable &&= op.isTextAttribute;
|
|
11629
11648
|
}
|
|
11630
11649
|
if (extractable) {
|
|
11631
|
-
const extractedAttributeOp = createExtractedAttributeOp(op.target, op.isStructuralTemplateAttribute ? BindingKind.Template : BindingKind.Attribute, op.name, op.expression, op.i18nContext, op.i18nMessage, op.securityContext);
|
|
11650
|
+
const extractedAttributeOp = createExtractedAttributeOp(op.target, op.isStructuralTemplateAttribute ? BindingKind.Template : BindingKind.Attribute, op.namespace, op.name, op.expression, op.i18nContext, op.i18nMessage, op.securityContext);
|
|
11632
11651
|
if (unit.job.kind === CompilationJobKind.Host) {
|
|
11633
11652
|
// This attribute will apply to the enclosing host binding compilation unit, so order doesn't
|
|
11634
11653
|
// matter.
|
|
@@ -11675,7 +11694,8 @@ function specializeBindings(job) {
|
|
|
11675
11694
|
target.nonBindable = true;
|
|
11676
11695
|
}
|
|
11677
11696
|
else {
|
|
11678
|
-
|
|
11697
|
+
const [namespace, name] = splitNsName(op.name);
|
|
11698
|
+
OpList.replace(op, createAttributeOp(op.target, namespace, name, op.expression, op.securityContext, op.isTextAttribute, op.isStructuralTemplateAttribute, op.templateKind, op.i18nMessage, op.sourceSpan));
|
|
11679
11699
|
}
|
|
11680
11700
|
break;
|
|
11681
11701
|
case BindingKind.Property:
|
|
@@ -11865,6 +11885,7 @@ const BINARY_OPERATORS = new Map([
|
|
|
11865
11885
|
['&&', BinaryOperator.And],
|
|
11866
11886
|
['>', BinaryOperator.Bigger],
|
|
11867
11887
|
['>=', BinaryOperator.BiggerEquals],
|
|
11888
|
+
['|', BinaryOperator.BitwiseOr],
|
|
11868
11889
|
['&', BinaryOperator.BitwiseAnd],
|
|
11869
11890
|
['/', BinaryOperator.Divide],
|
|
11870
11891
|
['==', BinaryOperator.Equals],
|
|
@@ -11921,7 +11942,7 @@ function collectElementConsts(job) {
|
|
|
11921
11942
|
if (op.kind === OpKind.ExtractedAttribute) {
|
|
11922
11943
|
const attributes = allElementAttributes.get(op.target) || new ElementAttributes(job.compatibility);
|
|
11923
11944
|
allElementAttributes.set(op.target, attributes);
|
|
11924
|
-
attributes.add(op.bindingKind, op.name, op.expression, op.trustedValueFn);
|
|
11945
|
+
attributes.add(op.bindingKind, op.name, op.expression, op.namespace, op.trustedValueFn);
|
|
11925
11946
|
OpList.remove(op);
|
|
11926
11947
|
}
|
|
11927
11948
|
}
|
|
@@ -12018,7 +12039,7 @@ class ElementAttributes {
|
|
|
12018
12039
|
nameToValue.add(name);
|
|
12019
12040
|
return false;
|
|
12020
12041
|
}
|
|
12021
|
-
add(kind, name, value, trustedValueFn) {
|
|
12042
|
+
add(kind, name, value, namespace, trustedValueFn) {
|
|
12022
12043
|
// TemplateDefinitionBuilder puts duplicate attribute, class, and style values into the consts
|
|
12023
12044
|
// array. This seems inefficient, we can probably keep just the first one or the last value
|
|
12024
12045
|
// (whichever actually gets applied when multiple values are listed for the same attribute).
|
|
@@ -12039,7 +12060,7 @@ class ElementAttributes {
|
|
|
12039
12060
|
// attribute. Is this sane?
|
|
12040
12061
|
}
|
|
12041
12062
|
const array = this.arrayFor(kind);
|
|
12042
|
-
array.push(...getAttributeNameLiterals$1(name));
|
|
12063
|
+
array.push(...getAttributeNameLiterals$1(namespace, name));
|
|
12043
12064
|
if (kind === BindingKind.Attribute || kind === BindingKind.StyleProperty) {
|
|
12044
12065
|
if (value === null) {
|
|
12045
12066
|
throw Error('Attribute, i18n attribute, & style element attributes must have a value');
|
|
@@ -12065,13 +12086,10 @@ class ElementAttributes {
|
|
|
12065
12086
|
/**
|
|
12066
12087
|
* Gets an array of literal expressions representing the attribute's namespaced name.
|
|
12067
12088
|
*/
|
|
12068
|
-
function getAttributeNameLiterals$1(name) {
|
|
12069
|
-
const
|
|
12070
|
-
|
|
12071
|
-
|
|
12072
|
-
return [
|
|
12073
|
-
literal(0 /* core.AttributeMarker.NamespaceURI */), literal(attributeNamespace), nameLiteral
|
|
12074
|
-
];
|
|
12089
|
+
function getAttributeNameLiterals$1(namespace, name) {
|
|
12090
|
+
const nameLiteral = literal(name);
|
|
12091
|
+
if (namespace) {
|
|
12092
|
+
return [literal(0 /* core.AttributeMarker.NamespaceURI */), literal(namespace), nameLiteral];
|
|
12075
12093
|
}
|
|
12076
12094
|
return [nameLiteral];
|
|
12077
12095
|
}
|
|
@@ -13126,7 +13144,7 @@ function parseHostStyleProperties(job) {
|
|
|
13126
13144
|
if (op.name.startsWith(STYLE_DOT)) {
|
|
13127
13145
|
op.bindingKind = BindingKind.StyleProperty;
|
|
13128
13146
|
op.name = op.name.substring(STYLE_DOT.length);
|
|
13129
|
-
if (isCssCustomProperty$1(op.name)) {
|
|
13147
|
+
if (!isCssCustomProperty$1(op.name)) {
|
|
13130
13148
|
op.name = hyphenate$1(op.name);
|
|
13131
13149
|
}
|
|
13132
13150
|
const { property, suffix } = parseProperty$1(op.name);
|
|
@@ -20566,6 +20584,7 @@ function parse(value) {
|
|
|
20566
20584
|
break;
|
|
20567
20585
|
case 58 /* Char.Colon */:
|
|
20568
20586
|
if (!currentProp && parenDepth === 0 && quote === 0 /* Char.QuoteNone */) {
|
|
20587
|
+
// TODO: Do not hyphenate CSS custom property names like: `--intentionallyCamelCase`
|
|
20569
20588
|
currentProp = hyphenate(value.substring(propStart, i - 1).trim());
|
|
20570
20589
|
valueStart = i;
|
|
20571
20590
|
}
|
|
@@ -21030,14 +21049,14 @@ function parseExtractedStyles(job) {
|
|
|
21030
21049
|
if (op.name === 'style') {
|
|
21031
21050
|
const parsedStyles = parse(op.expression.value);
|
|
21032
21051
|
for (let i = 0; i < parsedStyles.length - 1; i += 2) {
|
|
21033
|
-
OpList.insertBefore(createExtractedAttributeOp(op.target, BindingKind.StyleProperty, parsedStyles[i], literal(parsedStyles[i + 1]), null, null, SecurityContext.STYLE), op);
|
|
21052
|
+
OpList.insertBefore(createExtractedAttributeOp(op.target, BindingKind.StyleProperty, null, parsedStyles[i], literal(parsedStyles[i + 1]), null, null, SecurityContext.STYLE), op);
|
|
21034
21053
|
}
|
|
21035
21054
|
OpList.remove(op);
|
|
21036
21055
|
}
|
|
21037
21056
|
else if (op.name === 'class') {
|
|
21038
21057
|
const parsedClasses = op.expression.value.trim().split(/\s+/g);
|
|
21039
21058
|
for (const parsedClass of parsedClasses) {
|
|
21040
|
-
OpList.insertBefore(createExtractedAttributeOp(op.target, BindingKind.ClassName, parsedClass, null, null, null, SecurityContext.NONE), op);
|
|
21059
|
+
OpList.insertBefore(createExtractedAttributeOp(op.target, BindingKind.ClassName, null, parsedClass, null, null, null, SecurityContext.NONE), op);
|
|
21041
21060
|
}
|
|
21042
21061
|
OpList.remove(op);
|
|
21043
21062
|
}
|
|
@@ -21416,9 +21435,7 @@ function namespaceMath() {
|
|
|
21416
21435
|
return call(Identifiers.namespaceMathML, [], null);
|
|
21417
21436
|
}
|
|
21418
21437
|
function advance(delta, sourceSpan) {
|
|
21419
|
-
return call(Identifiers.advance, [
|
|
21420
|
-
literal(delta),
|
|
21421
|
-
], sourceSpan);
|
|
21438
|
+
return call(Identifiers.advance, delta > 1 ? [literal(delta)] : [], sourceSpan);
|
|
21422
21439
|
}
|
|
21423
21440
|
function reference(slot) {
|
|
21424
21441
|
return importExpr(Identifiers.reference).callFn([
|
|
@@ -21562,10 +21579,13 @@ function property(name, expression, sanitizer, sourceSpan) {
|
|
|
21562
21579
|
}
|
|
21563
21580
|
return call(Identifiers.property, args, sourceSpan);
|
|
21564
21581
|
}
|
|
21565
|
-
function attribute(name, expression, sanitizer) {
|
|
21582
|
+
function attribute(name, expression, sanitizer, namespace) {
|
|
21566
21583
|
const args = [literal(name), expression];
|
|
21567
|
-
if (sanitizer !== null) {
|
|
21568
|
-
args.push(sanitizer);
|
|
21584
|
+
if (sanitizer !== null || namespace !== null) {
|
|
21585
|
+
args.push(sanitizer ?? literal(null));
|
|
21586
|
+
}
|
|
21587
|
+
if (namespace !== null) {
|
|
21588
|
+
args.push(literal(namespace));
|
|
21569
21589
|
}
|
|
21570
21590
|
return call(Identifiers.attribute, args, null);
|
|
21571
21591
|
}
|
|
@@ -22150,7 +22170,7 @@ function reifyUpdateOperations(_unit, ops) {
|
|
|
22150
22170
|
OpList.replace(op, attributeInterpolate(op.name, op.expression.strings, op.expression.expressions, op.sanitizer, op.sourceSpan));
|
|
22151
22171
|
}
|
|
22152
22172
|
else {
|
|
22153
|
-
OpList.replace(op, attribute(op.name, op.expression, op.sanitizer));
|
|
22173
|
+
OpList.replace(op, attribute(op.name, op.expression, op.sanitizer, op.namespace));
|
|
22154
22174
|
}
|
|
22155
22175
|
break;
|
|
22156
22176
|
case OpKind.HostProperty:
|
|
@@ -22339,42 +22359,6 @@ function removeUnusedI18nAttributesOps(job) {
|
|
|
22339
22359
|
}
|
|
22340
22360
|
}
|
|
22341
22361
|
|
|
22342
|
-
/**
|
|
22343
|
-
* Inside the body of a repeater, certain context variables (such as `$first`) are ambiently
|
|
22344
|
-
* available. This phase finds those variable usages, and replaces them with the appropriate
|
|
22345
|
-
* expression.
|
|
22346
|
-
*/
|
|
22347
|
-
function generateRepeaterDerivedVars(job) {
|
|
22348
|
-
const repeaters = new Map();
|
|
22349
|
-
for (const unit of job.units) {
|
|
22350
|
-
for (const op of unit.ops()) {
|
|
22351
|
-
if (op.kind === OpKind.RepeaterCreate) {
|
|
22352
|
-
repeaters.set(op.xref, op);
|
|
22353
|
-
}
|
|
22354
|
-
}
|
|
22355
|
-
}
|
|
22356
|
-
for (const unit of job.units) {
|
|
22357
|
-
for (const op of unit.ops()) {
|
|
22358
|
-
transformExpressionsInOp(op, expr => {
|
|
22359
|
-
if (!(expr instanceof DerivedRepeaterVarExpr)) {
|
|
22360
|
-
return expr;
|
|
22361
|
-
}
|
|
22362
|
-
const repeaterOp = repeaters.get(expr.xref);
|
|
22363
|
-
switch (expr.identity) {
|
|
22364
|
-
case DerivedRepeaterVarIdentity.First:
|
|
22365
|
-
return new BinaryOperatorExpr(BinaryOperator.Identical, new LexicalReadExpr(repeaterOp.varNames.$index), literal(0));
|
|
22366
|
-
case DerivedRepeaterVarIdentity.Last:
|
|
22367
|
-
return new BinaryOperatorExpr(BinaryOperator.Identical, new LexicalReadExpr(repeaterOp.varNames.$index), new BinaryOperatorExpr(BinaryOperator.Minus, new LexicalReadExpr(repeaterOp.varNames.$count), literal(1)));
|
|
22368
|
-
case DerivedRepeaterVarIdentity.Even:
|
|
22369
|
-
return new BinaryOperatorExpr(BinaryOperator.Identical, new BinaryOperatorExpr(BinaryOperator.Modulo, new LexicalReadExpr(repeaterOp.varNames.$index), literal(2)), literal(0));
|
|
22370
|
-
case DerivedRepeaterVarIdentity.Odd:
|
|
22371
|
-
return new BinaryOperatorExpr(BinaryOperator.NotIdentical, new BinaryOperatorExpr(BinaryOperator.Modulo, new LexicalReadExpr(repeaterOp.varNames.$index), literal(2)), literal(0));
|
|
22372
|
-
}
|
|
22373
|
-
}, VisitorContextFlag.None);
|
|
22374
|
-
}
|
|
22375
|
-
}
|
|
22376
|
-
}
|
|
22377
|
-
|
|
22378
22362
|
/**
|
|
22379
22363
|
* Resolves `ir.ContextExpr` expressions (which represent embedded view or component contexts) to
|
|
22380
22364
|
* either the `ctx` parameter to component functions (for the current view context) or to variables
|
|
@@ -23959,7 +23943,6 @@ const phases = [
|
|
|
23959
23943
|
{ kind: CompilationJobKind.Tmpl, fn: saveAndRestoreView },
|
|
23960
23944
|
{ kind: CompilationJobKind.Both, fn: deleteAnyCasts },
|
|
23961
23945
|
{ kind: CompilationJobKind.Both, fn: resolveDollarEvent },
|
|
23962
|
-
{ kind: CompilationJobKind.Tmpl, fn: generateRepeaterDerivedVars },
|
|
23963
23946
|
{ kind: CompilationJobKind.Tmpl, fn: generateTrackVariables },
|
|
23964
23947
|
{ kind: CompilationJobKind.Both, fn: resolveNames },
|
|
23965
23948
|
{ kind: CompilationJobKind.Tmpl, fn: resolveDeferTargetNames },
|
|
@@ -24377,6 +24360,10 @@ function ingestIfBlock(unit, ifBlock) {
|
|
|
24377
24360
|
* Ingest an `@switch` block into the given `ViewCompilation`.
|
|
24378
24361
|
*/
|
|
24379
24362
|
function ingestSwitchBlock(unit, switchBlock) {
|
|
24363
|
+
// Don't ingest empty switches since they won't render anything.
|
|
24364
|
+
if (switchBlock.cases.length === 0) {
|
|
24365
|
+
return;
|
|
24366
|
+
}
|
|
24380
24367
|
let firstXref = null;
|
|
24381
24368
|
let firstSlotHandle = null;
|
|
24382
24369
|
let conditions = [];
|
|
@@ -24533,22 +24520,43 @@ function ingestIcu(unit, icu) {
|
|
|
24533
24520
|
*/
|
|
24534
24521
|
function ingestForBlock(unit, forBlock) {
|
|
24535
24522
|
const repeaterView = unit.job.allocateView(unit.xref);
|
|
24536
|
-
const createRepeaterAlias = (ident, repeaterVar) => {
|
|
24537
|
-
repeaterView.aliases.add({
|
|
24538
|
-
kind: SemanticVariableKind.Alias,
|
|
24539
|
-
name: null,
|
|
24540
|
-
identifier: ident,
|
|
24541
|
-
expression: new DerivedRepeaterVarExpr(repeaterView.xref, repeaterVar),
|
|
24542
|
-
});
|
|
24543
|
-
};
|
|
24544
24523
|
// Set all the context variables and aliases available in the repeater.
|
|
24545
24524
|
repeaterView.contextVariables.set(forBlock.item.name, forBlock.item.value);
|
|
24546
24525
|
repeaterView.contextVariables.set(forBlock.contextVariables.$index.name, forBlock.contextVariables.$index.value);
|
|
24547
24526
|
repeaterView.contextVariables.set(forBlock.contextVariables.$count.name, forBlock.contextVariables.$count.value);
|
|
24548
|
-
|
|
24549
|
-
|
|
24550
|
-
|
|
24551
|
-
|
|
24527
|
+
// We copy TemplateDefinitionBuilder's scheme of creating names for `$count` and `$index` that are
|
|
24528
|
+
// suffixed with special information, to disambiguate which level of nested loop the below aliases
|
|
24529
|
+
// refer to.
|
|
24530
|
+
// TODO: We should refactor Template Pipeline's variable phases to gracefully handle shadowing,
|
|
24531
|
+
// and arbitrarily many levels of variables depending on each other.
|
|
24532
|
+
const indexName = `ɵ${forBlock.contextVariables.$index.name}_${repeaterView.xref}`;
|
|
24533
|
+
const countName = `ɵ${forBlock.contextVariables.$count.name}_${repeaterView.xref}`;
|
|
24534
|
+
repeaterView.contextVariables.set(indexName, forBlock.contextVariables.$index.value);
|
|
24535
|
+
repeaterView.contextVariables.set(countName, forBlock.contextVariables.$count.value);
|
|
24536
|
+
repeaterView.aliases.add({
|
|
24537
|
+
kind: SemanticVariableKind.Alias,
|
|
24538
|
+
name: null,
|
|
24539
|
+
identifier: forBlock.contextVariables.$first.name,
|
|
24540
|
+
expression: new LexicalReadExpr(indexName).identical(literal(0))
|
|
24541
|
+
});
|
|
24542
|
+
repeaterView.aliases.add({
|
|
24543
|
+
kind: SemanticVariableKind.Alias,
|
|
24544
|
+
name: null,
|
|
24545
|
+
identifier: forBlock.contextVariables.$last.name,
|
|
24546
|
+
expression: new LexicalReadExpr(indexName).identical(new LexicalReadExpr(countName).minus(literal(1)))
|
|
24547
|
+
});
|
|
24548
|
+
repeaterView.aliases.add({
|
|
24549
|
+
kind: SemanticVariableKind.Alias,
|
|
24550
|
+
name: null,
|
|
24551
|
+
identifier: forBlock.contextVariables.$even.name,
|
|
24552
|
+
expression: new LexicalReadExpr(indexName).modulo(literal(2)).identical(literal(0))
|
|
24553
|
+
});
|
|
24554
|
+
repeaterView.aliases.add({
|
|
24555
|
+
kind: SemanticVariableKind.Alias,
|
|
24556
|
+
name: null,
|
|
24557
|
+
identifier: forBlock.contextVariables.$odd.name,
|
|
24558
|
+
expression: new LexicalReadExpr(indexName).modulo(literal(2)).notIdentical(literal(0))
|
|
24559
|
+
});
|
|
24552
24560
|
const sourceSpan = convertSourceSpan(forBlock.trackBy.span, forBlock.sourceSpan);
|
|
24553
24561
|
const track = convertAst(forBlock.trackBy, unit.job, sourceSpan);
|
|
24554
24562
|
ingestNodes(repeaterView, forBlock.children);
|
|
@@ -24837,7 +24845,7 @@ function ingestTemplateBindings(unit, op, template, templateKind) {
|
|
|
24837
24845
|
output.type !== 1 /* e.ParsedEventType.Animation */) {
|
|
24838
24846
|
// Animation bindings are excluded from the structural template's const array.
|
|
24839
24847
|
const securityContext = domSchema.securityContext(NG_TEMPLATE_TAG_NAME$1, output.name, false);
|
|
24840
|
-
unit.create.push(createExtractedAttributeOp(op.xref, BindingKind.Property, output.name, null, null, null, securityContext));
|
|
24848
|
+
unit.create.push(createExtractedAttributeOp(op.xref, BindingKind.Property, null, output.name, null, null, null, securityContext));
|
|
24841
24849
|
}
|
|
24842
24850
|
}
|
|
24843
24851
|
// TODO: Perhaps we could do this in a phase? (It likely wouldn't change the slot indices.)
|
|
@@ -24885,7 +24893,7 @@ function createTemplateBinding(view, xref, type, name, value, unit, securityCont
|
|
|
24885
24893
|
// inner node of a structural template. We can't skip it entirely, because we still need it on
|
|
24886
24894
|
// the ng-template's consts (e.g. for the purposes of directive matching). However, we should
|
|
24887
24895
|
// not generate an update instruction for it.
|
|
24888
|
-
return createExtractedAttributeOp(xref, BindingKind.Property, name, null, null, i18nMessage, securityContext);
|
|
24896
|
+
return createExtractedAttributeOp(xref, BindingKind.Property, null, name, null, null, i18nMessage, securityContext);
|
|
24889
24897
|
}
|
|
24890
24898
|
if (!isTextBinding && (type === 1 /* e.BindingType.Attribute */ || type === 4 /* e.BindingType.Animation */)) {
|
|
24891
24899
|
// Again, this binding doesn't really target the ng-template; it actually targets the element
|
|
@@ -27811,7 +27819,7 @@ class TemplateData {
|
|
|
27811
27819
|
}
|
|
27812
27820
|
}
|
|
27813
27821
|
class TemplateDefinitionBuilder {
|
|
27814
|
-
constructor(constantPool, parentBindingScope, level = 0, contextName, i18nContext, templateIndex, templateName, _namespace, relativeContextFilePath, i18nUseExternalIds, deferBlocks, elementLocations, _constants = createComponentDefConsts()) {
|
|
27822
|
+
constructor(constantPool, parentBindingScope, level = 0, contextName, i18nContext, templateIndex, templateName, _namespace, relativeContextFilePath, i18nUseExternalIds, deferBlocks, elementLocations, allDeferrableDepsFn, _constants = createComponentDefConsts()) {
|
|
27815
27823
|
this.constantPool = constantPool;
|
|
27816
27824
|
this.level = level;
|
|
27817
27825
|
this.contextName = contextName;
|
|
@@ -27822,6 +27830,7 @@ class TemplateDefinitionBuilder {
|
|
|
27822
27830
|
this.i18nUseExternalIds = i18nUseExternalIds;
|
|
27823
27831
|
this.deferBlocks = deferBlocks;
|
|
27824
27832
|
this.elementLocations = elementLocations;
|
|
27833
|
+
this.allDeferrableDepsFn = allDeferrableDepsFn;
|
|
27825
27834
|
this._constants = _constants;
|
|
27826
27835
|
this._dataIndex = 0;
|
|
27827
27836
|
this._bindingContext = 0;
|
|
@@ -28476,7 +28485,7 @@ class TemplateDefinitionBuilder {
|
|
|
28476
28485
|
const contextName = `${this.contextName}${contextNameSuffix}_${index}`;
|
|
28477
28486
|
const name = `${contextName}_Template`;
|
|
28478
28487
|
// Create the template function
|
|
28479
|
-
const visitor = new TemplateDefinitionBuilder(this.constantPool, this._bindingScope, this.level + 1, contextName, this.i18n, index, name, this._namespace, this.fileBasedI18nSuffix, this.i18nUseExternalIds, this.deferBlocks, this.elementLocations, this._constants);
|
|
28488
|
+
const visitor = new TemplateDefinitionBuilder(this.constantPool, this._bindingScope, this.level + 1, contextName, this.i18n, index, name, this._namespace, this.fileBasedI18nSuffix, this.i18nUseExternalIds, this.deferBlocks, this.elementLocations, this.allDeferrableDepsFn, this._constants);
|
|
28480
28489
|
// Nested templates must not be visited until after their parent templates have completed
|
|
28481
28490
|
// processing, so they are queued here until after the initial pass. Otherwise, we wouldn't
|
|
28482
28491
|
// be able to support bindings in nested templates to local refs that occur after the
|
|
@@ -28687,6 +28696,9 @@ class TemplateDefinitionBuilder {
|
|
|
28687
28696
|
this.updateInstructionWithAdvance(containerIndex, block.branches[0].sourceSpan, Identifiers.conditional, paramsCallback);
|
|
28688
28697
|
}
|
|
28689
28698
|
visitSwitchBlock(block) {
|
|
28699
|
+
if (block.cases.length === 0) {
|
|
28700
|
+
return;
|
|
28701
|
+
}
|
|
28690
28702
|
// We have to process the block in two steps: once here and again in the update instruction
|
|
28691
28703
|
// callback in order to generate the correct expressions when pipes or pure functions are used.
|
|
28692
28704
|
const caseData = block.cases.map(currentCase => {
|
|
@@ -28761,7 +28773,7 @@ class TemplateDefinitionBuilder {
|
|
|
28761
28773
|
this.creationInstruction(deferred.sourceSpan, Identifiers.defer, trimTrailingNulls([
|
|
28762
28774
|
literal(deferredIndex),
|
|
28763
28775
|
literal(primaryTemplateIndex),
|
|
28764
|
-
this.createDeferredDepsFunction(depsFnName, metadata),
|
|
28776
|
+
this.allDeferrableDepsFn ?? this.createDeferredDepsFunction(depsFnName, metadata),
|
|
28765
28777
|
literal(loadingIndex),
|
|
28766
28778
|
literal(placeholderIndex),
|
|
28767
28779
|
literal(errorIndex),
|
|
@@ -29150,7 +29162,7 @@ class TemplateDefinitionBuilder {
|
|
|
29150
29162
|
if (delta < 1) {
|
|
29151
29163
|
throw new Error('advance instruction can only go forwards');
|
|
29152
29164
|
}
|
|
29153
|
-
this.instructionFn(this._updateCodeFns, span, Identifiers.advance, [literal(delta)]);
|
|
29165
|
+
this.instructionFn(this._updateCodeFns, span, Identifiers.advance, delta > 1 ? [literal(delta)] : []);
|
|
29154
29166
|
this._currentIndex = nodeIndex;
|
|
29155
29167
|
}
|
|
29156
29168
|
}
|
|
@@ -30123,6 +30135,24 @@ function compileDirectiveFromMetadata(meta, constantPool, bindingParser) {
|
|
|
30123
30135
|
const type = createDirectiveType(meta);
|
|
30124
30136
|
return { expression, type, statements: [] };
|
|
30125
30137
|
}
|
|
30138
|
+
/**
|
|
30139
|
+
* Creates an AST for a function that contains dynamic imports representing
|
|
30140
|
+
* deferrable dependencies.
|
|
30141
|
+
*/
|
|
30142
|
+
function createDeferredDepsFunction(constantPool, name, deps) {
|
|
30143
|
+
// This defer block has deps for which we need to generate dynamic imports.
|
|
30144
|
+
const dependencyExp = [];
|
|
30145
|
+
for (const [symbolName, importPath] of deps) {
|
|
30146
|
+
// Callback function, e.g. `m () => m.MyCmp;`.
|
|
30147
|
+
const innerFn = arrowFn([new FnParam('m', DYNAMIC_TYPE)], variable('m').prop(symbolName));
|
|
30148
|
+
// Dynamic import, e.g. `import('./a').then(...)`.
|
|
30149
|
+
const importExpr = (new DynamicImportExpr(importPath)).prop('then').callFn([innerFn]);
|
|
30150
|
+
dependencyExp.push(importExpr);
|
|
30151
|
+
}
|
|
30152
|
+
const depsFnExpr = arrowFn([], literalArr(dependencyExp));
|
|
30153
|
+
constantPool.statements.push(depsFnExpr.toDeclStmt(name, StmtModifier.Final));
|
|
30154
|
+
return variable(name);
|
|
30155
|
+
}
|
|
30126
30156
|
/**
|
|
30127
30157
|
* Compile a component for the render3 runtime as defined by the `R3ComponentMetadata`.
|
|
30128
30158
|
*/
|
|
@@ -30147,8 +30177,14 @@ function compileComponentFromMetadata(meta, constantPool, bindingParser) {
|
|
|
30147
30177
|
if (!USE_TEMPLATE_PIPELINE) {
|
|
30148
30178
|
// This is the main path currently used in compilation, which compiles the template with the
|
|
30149
30179
|
// legacy `TemplateDefinitionBuilder`.
|
|
30180
|
+
let allDeferrableDepsFn = null;
|
|
30181
|
+
if (meta.deferBlocks.size > 0 && meta.deferrableTypes.size > 0 &&
|
|
30182
|
+
meta.deferBlockDepsEmitMode === 1 /* DeferBlockDepsEmitMode.PerComponent */) {
|
|
30183
|
+
const fnName = `${templateTypeName}_DeferFn`;
|
|
30184
|
+
allDeferrableDepsFn = createDeferredDepsFunction(constantPool, fnName, meta.deferrableTypes);
|
|
30185
|
+
}
|
|
30150
30186
|
const template = meta.template;
|
|
30151
|
-
const templateBuilder = new TemplateDefinitionBuilder(constantPool, BindingScope.createRootScope(), 0, templateTypeName, null, null, templateName, Identifiers.namespaceHTML, meta.relativeContextFilePath, meta.i18nUseExternalIds, meta.deferBlocks, new Map());
|
|
30187
|
+
const templateBuilder = new TemplateDefinitionBuilder(constantPool, BindingScope.createRootScope(), 0, templateTypeName, null, null, templateName, Identifiers.namespaceHTML, meta.relativeContextFilePath, meta.i18nUseExternalIds, meta.deferBlocks, new Map(), allDeferrableDepsFn);
|
|
30152
30188
|
const templateFunctionExpression = templateBuilder.buildTemplateFunction(template.nodes, []);
|
|
30153
30189
|
// We need to provide this so that dynamically generated components know what
|
|
30154
30190
|
// projected content blocks to pass through to the component when it is
|
|
@@ -30879,7 +30915,7 @@ class R3TargetBinder {
|
|
|
30879
30915
|
// Finally, run the TemplateBinder to bind references, variables, and other entities within the
|
|
30880
30916
|
// template. This extracts all the metadata that doesn't depend on directive matching.
|
|
30881
30917
|
const { expressions, symbols, nestingLevel, usedPipes, eagerPipes, deferBlocks } = TemplateBinder.applyWithScope(target.template, scope);
|
|
30882
|
-
return new R3BoundTarget(target, directives, eagerDirectives, bindings, references, expressions, symbols, nestingLevel, scopedNodeEntities, usedPipes, eagerPipes, deferBlocks);
|
|
30918
|
+
return new R3BoundTarget(target, directives, eagerDirectives, bindings, references, expressions, symbols, nestingLevel, scopedNodeEntities, usedPipes, eagerPipes, deferBlocks, scope);
|
|
30883
30919
|
}
|
|
30884
30920
|
}
|
|
30885
30921
|
/**
|
|
@@ -30897,6 +30933,10 @@ class Scope {
|
|
|
30897
30933
|
* Named members of the `Scope`, such as `Reference`s or `Variable`s.
|
|
30898
30934
|
*/
|
|
30899
30935
|
this.namedEntities = new Map();
|
|
30936
|
+
/**
|
|
30937
|
+
* Set of elements that belong to this scope.
|
|
30938
|
+
*/
|
|
30939
|
+
this.elementsInScope = new Set();
|
|
30900
30940
|
/**
|
|
30901
30941
|
* Child `Scope`s for immediately nested `ScopedNode`s.
|
|
30902
30942
|
*/
|
|
@@ -30953,6 +30993,7 @@ class Scope {
|
|
|
30953
30993
|
element.references.forEach(node => this.visitReference(node));
|
|
30954
30994
|
// Recurse into the `Element`'s children.
|
|
30955
30995
|
element.children.forEach(node => node.visit(this));
|
|
30996
|
+
this.elementsInScope.add(element);
|
|
30956
30997
|
}
|
|
30957
30998
|
visitTemplate(template) {
|
|
30958
30999
|
// References on a <ng-template> are defined in the outer scope, so capture them before
|
|
@@ -31446,7 +31487,7 @@ class TemplateBinder extends RecursiveAstVisitor {
|
|
|
31446
31487
|
* See `BoundTarget` for documentation on the individual methods.
|
|
31447
31488
|
*/
|
|
31448
31489
|
class R3BoundTarget {
|
|
31449
|
-
constructor(target, directives, eagerDirectives, bindings, references, exprTargets, symbols, nestingLevel, scopedNodeEntities, usedPipes, eagerPipes, deferredBlocks) {
|
|
31490
|
+
constructor(target, directives, eagerDirectives, bindings, references, exprTargets, symbols, nestingLevel, scopedNodeEntities, usedPipes, eagerPipes, deferredBlocks, rootScope) {
|
|
31450
31491
|
this.target = target;
|
|
31451
31492
|
this.directives = directives;
|
|
31452
31493
|
this.eagerDirectives = eagerDirectives;
|
|
@@ -31459,6 +31500,7 @@ class R3BoundTarget {
|
|
|
31459
31500
|
this.usedPipes = usedPipes;
|
|
31460
31501
|
this.eagerPipes = eagerPipes;
|
|
31461
31502
|
this.deferredBlocks = deferredBlocks;
|
|
31503
|
+
this.rootScope = rootScope;
|
|
31462
31504
|
}
|
|
31463
31505
|
getEntitiesInScope(node) {
|
|
31464
31506
|
return this.scopedNodeEntities.get(node) ?? new Set();
|
|
@@ -31548,6 +31590,15 @@ class R3BoundTarget {
|
|
|
31548
31590
|
}
|
|
31549
31591
|
return null;
|
|
31550
31592
|
}
|
|
31593
|
+
isDeferred(element) {
|
|
31594
|
+
for (const deferBlock of this.deferredBlocks) {
|
|
31595
|
+
const scope = this.rootScope.childScopes.get(deferBlock);
|
|
31596
|
+
if (scope && scope.elementsInScope.has(element)) {
|
|
31597
|
+
return true;
|
|
31598
|
+
}
|
|
31599
|
+
}
|
|
31600
|
+
return false;
|
|
31601
|
+
}
|
|
31551
31602
|
/**
|
|
31552
31603
|
* Finds an entity with a specific name in a scope.
|
|
31553
31604
|
* @param rootNode Root node of the scope.
|
|
@@ -31736,9 +31787,9 @@ class CompilerFacadeImpl {
|
|
|
31736
31787
|
declarations: facade.declarations.map(convertDeclarationFacadeToMetadata),
|
|
31737
31788
|
declarationListEmitMode: 0 /* DeclarationListEmitMode.Direct */,
|
|
31738
31789
|
deferBlocks,
|
|
31739
|
-
|
|
31740
|
-
// to be implemented as one of the next steps.
|
|
31790
|
+
deferrableTypes: new Map(),
|
|
31741
31791
|
deferrableDeclToImportDecl: new Map(),
|
|
31792
|
+
deferBlockDepsEmitMode: 0 /* DeferBlockDepsEmitMode.PerBlock */,
|
|
31742
31793
|
styles: [...facade.styles, ...template.styles],
|
|
31743
31794
|
encapsulation: facade.encapsulation,
|
|
31744
31795
|
interpolation,
|
|
@@ -31849,8 +31900,10 @@ function convertDirectiveFacadeToMetadata(facade) {
|
|
|
31849
31900
|
bindingPropertyName: ann.alias || field,
|
|
31850
31901
|
classPropertyName: field,
|
|
31851
31902
|
required: ann.required || false,
|
|
31852
|
-
//
|
|
31853
|
-
|
|
31903
|
+
// For JIT, decorators are used to declare signal inputs. That is because of
|
|
31904
|
+
// a technical limitation where it's not possible to statically reflect class
|
|
31905
|
+
// members of a directive/component at runtime before instantiating the class.
|
|
31906
|
+
isSignal: !!ann.isSignal,
|
|
31854
31907
|
transformFunction: ann.transform != null ? new WrappedNodeExpr(ann.transform) : null,
|
|
31855
31908
|
};
|
|
31856
31909
|
}
|
|
@@ -31972,9 +32025,9 @@ function convertDeclareComponentFacadeToMetadata(decl, typeSourceSpan, sourceMap
|
|
|
31972
32025
|
null,
|
|
31973
32026
|
animations: decl.animations !== undefined ? new WrappedNodeExpr(decl.animations) : null,
|
|
31974
32027
|
deferBlocks,
|
|
31975
|
-
|
|
31976
|
-
// to be implemented as one of the next steps.
|
|
32028
|
+
deferrableTypes: new Map(),
|
|
31977
32029
|
deferrableDeclToImportDecl: new Map(),
|
|
32030
|
+
deferBlockDepsEmitMode: 0 /* DeferBlockDepsEmitMode.PerBlock */,
|
|
31978
32031
|
changeDetection: decl.changeDetection ?? ChangeDetectionStrategy.Default,
|
|
31979
32032
|
encapsulation: decl.encapsulation ?? ViewEncapsulation.Emulated,
|
|
31980
32033
|
interpolation,
|
|
@@ -32262,7 +32315,7 @@ function publishFacade(global) {
|
|
|
32262
32315
|
* @description
|
|
32263
32316
|
* Entry point for all public APIs of the compiler package.
|
|
32264
32317
|
*/
|
|
32265
|
-
const VERSION = new Version('17.1.0
|
|
32318
|
+
const VERSION = new Version('17.1.0');
|
|
32266
32319
|
|
|
32267
32320
|
class CompilerConfig {
|
|
32268
32321
|
constructor({ defaultEncapsulation = ViewEncapsulation.Emulated, preserveWhitespaces, strictInjectionParameters } = {}) {
|
|
@@ -33757,7 +33810,7 @@ function compileClassMetadata(metadata) {
|
|
|
33757
33810
|
* check to tree-shake away this code in production mode.
|
|
33758
33811
|
*/
|
|
33759
33812
|
function compileComponentClassMetadata(metadata, deferrableTypes) {
|
|
33760
|
-
if (deferrableTypes.size === 0) {
|
|
33813
|
+
if (deferrableTypes === null || deferrableTypes.size === 0) {
|
|
33761
33814
|
// If there are no deferrable symbols - just generate a regular `setClassMetadata` call.
|
|
33762
33815
|
return compileClassMetadata(metadata);
|
|
33763
33816
|
}
|
|
@@ -33828,7 +33881,7 @@ const MINIMUM_PARTIAL_LINKER_VERSION$5 = '12.0.0';
|
|
|
33828
33881
|
function compileDeclareClassMetadata(metadata) {
|
|
33829
33882
|
const definitionMap = new DefinitionMap();
|
|
33830
33883
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$5));
|
|
33831
|
-
definitionMap.set('version', literal('17.1.0
|
|
33884
|
+
definitionMap.set('version', literal('17.1.0'));
|
|
33832
33885
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
33833
33886
|
definitionMap.set('type', metadata.type);
|
|
33834
33887
|
definitionMap.set('decorators', metadata.decorators);
|
|
@@ -33924,7 +33977,7 @@ function createDirectiveDefinitionMap(meta) {
|
|
|
33924
33977
|
const definitionMap = new DefinitionMap();
|
|
33925
33978
|
const minVersion = getMinimumVersionForPartialOutput(meta);
|
|
33926
33979
|
definitionMap.set('minVersion', literal(minVersion));
|
|
33927
|
-
definitionMap.set('version', literal('17.1.0
|
|
33980
|
+
definitionMap.set('version', literal('17.1.0'));
|
|
33928
33981
|
// e.g. `type: MyDirective`
|
|
33929
33982
|
definitionMap.set('type', meta.type.value);
|
|
33930
33983
|
if (meta.isStandalone) {
|
|
@@ -33982,8 +34035,8 @@ function getMinimumVersionForPartialOutput(meta) {
|
|
|
33982
34035
|
// Note: in order to allow consuming Angular libraries that have been compiled with 16.1+ in
|
|
33983
34036
|
// Angular 16.0, we only force a minimum version of 16.1 if input transform feature as introduced
|
|
33984
34037
|
// in 16.1 is actually used.
|
|
33985
|
-
const
|
|
33986
|
-
if (
|
|
34038
|
+
const hasDecoratorTransformFunctions = Object.values(meta.inputs).some(input => input.transformFunction !== null);
|
|
34039
|
+
if (hasDecoratorTransformFunctions) {
|
|
33987
34040
|
minVersion = '16.1.0';
|
|
33988
34041
|
}
|
|
33989
34042
|
// If there are input flags and we need the new emit, use the actual minimum version,
|
|
@@ -34308,7 +34361,7 @@ const MINIMUM_PARTIAL_LINKER_VERSION$4 = '12.0.0';
|
|
|
34308
34361
|
function compileDeclareFactoryFunction(meta) {
|
|
34309
34362
|
const definitionMap = new DefinitionMap();
|
|
34310
34363
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$4));
|
|
34311
|
-
definitionMap.set('version', literal('17.1.0
|
|
34364
|
+
definitionMap.set('version', literal('17.1.0'));
|
|
34312
34365
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
34313
34366
|
definitionMap.set('type', meta.type.value);
|
|
34314
34367
|
definitionMap.set('deps', compileDependencies(meta.deps));
|
|
@@ -34343,7 +34396,7 @@ function compileDeclareInjectableFromMetadata(meta) {
|
|
|
34343
34396
|
function createInjectableDefinitionMap(meta) {
|
|
34344
34397
|
const definitionMap = new DefinitionMap();
|
|
34345
34398
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$3));
|
|
34346
|
-
definitionMap.set('version', literal('17.1.0
|
|
34399
|
+
definitionMap.set('version', literal('17.1.0'));
|
|
34347
34400
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
34348
34401
|
definitionMap.set('type', meta.type.value);
|
|
34349
34402
|
// Only generate providedIn property if it has a non-null value
|
|
@@ -34394,7 +34447,7 @@ function compileDeclareInjectorFromMetadata(meta) {
|
|
|
34394
34447
|
function createInjectorDefinitionMap(meta) {
|
|
34395
34448
|
const definitionMap = new DefinitionMap();
|
|
34396
34449
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$2));
|
|
34397
|
-
definitionMap.set('version', literal('17.1.0
|
|
34450
|
+
definitionMap.set('version', literal('17.1.0'));
|
|
34398
34451
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
34399
34452
|
definitionMap.set('type', meta.type.value);
|
|
34400
34453
|
definitionMap.set('providers', meta.providers);
|
|
@@ -34427,7 +34480,7 @@ function createNgModuleDefinitionMap(meta) {
|
|
|
34427
34480
|
throw new Error('Invalid path! Local compilation mode should not get into the partial compilation path');
|
|
34428
34481
|
}
|
|
34429
34482
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$1));
|
|
34430
|
-
definitionMap.set('version', literal('17.1.0
|
|
34483
|
+
definitionMap.set('version', literal('17.1.0'));
|
|
34431
34484
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
34432
34485
|
definitionMap.set('type', meta.type.value);
|
|
34433
34486
|
// We only generate the keys in the metadata if the arrays contain values.
|
|
@@ -34478,7 +34531,7 @@ function compileDeclarePipeFromMetadata(meta) {
|
|
|
34478
34531
|
function createPipeDefinitionMap(meta) {
|
|
34479
34532
|
const definitionMap = new DefinitionMap();
|
|
34480
34533
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION));
|
|
34481
|
-
definitionMap.set('version', literal('17.1.0
|
|
34534
|
+
definitionMap.set('version', literal('17.1.0'));
|
|
34482
34535
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
34483
34536
|
// e.g. `type: MyPipe`
|
|
34484
34537
|
definitionMap.set('type', meta.type.value);
|