@angular/core 20.1.0-next.3 → 20.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/api.d.d.ts +1 -1
- package/chrome_dev_tools_performance.d.d.ts +1 -1
- package/discovery.d.d.ts +1 -1
- package/event_dispatcher.d.d.ts +1 -1
- package/fesm2022/attribute.mjs +1 -1
- package/fesm2022/core.mjs +14 -6
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/debug_node.mjs +8 -6
- package/fesm2022/debug_node.mjs.map +1 -1
- package/fesm2022/{injector.mjs → not_found.mjs} +28 -25
- package/fesm2022/not_found.mjs.map +1 -0
- package/fesm2022/primitives/di.mjs +11 -3
- package/fesm2022/primitives/di.mjs.map +1 -1
- package/fesm2022/primitives/event-dispatch.mjs +1 -1
- package/fesm2022/primitives/signals.mjs +1 -1
- package/fesm2022/resource.mjs +1 -1
- package/fesm2022/root_effect_scheduler.mjs +3 -3
- package/fesm2022/root_effect_scheduler.mjs.map +1 -1
- package/fesm2022/rxjs-interop.mjs +2 -2
- package/fesm2022/signal.mjs +1 -1
- package/fesm2022/testing.mjs +2 -2
- package/fesm2022/untracked.mjs +1 -1
- package/fesm2022/weak_ref.mjs +1 -1
- package/graph.d.d.ts +1 -1
- package/index.d.ts +7 -8
- package/package.json +2 -2
- package/primitives/di/index.d.ts +11 -3
- package/primitives/event-dispatch/index.d.ts +1 -1
- package/primitives/signals/index.d.ts +1 -1
- package/rxjs-interop/index.d.ts +1 -1
- package/schematics/bundles/{apply_import_manager-C11Q8021.cjs → apply_import_manager-B0fYYMpr.cjs} +3 -3
- package/schematics/bundles/{checker-BVnpy__J.cjs → checker-DLInMAS3.cjs} +533 -1264
- package/schematics/bundles/cleanup-unused-imports.cjs +6 -5
- package/schematics/bundles/{compiler_host-j95cyBKm.cjs → compiler_host-Doj9KVJf.cjs} +2 -2
- package/schematics/bundles/control-flow-migration.cjs +3 -3
- package/schematics/bundles/document-core.cjs +6 -5
- package/schematics/bundles/imports-CIX-JgAN.cjs +1 -1
- package/schematics/bundles/{index-BkA2Tb_u.cjs → index-BmuUS1AB.cjs} +947 -71
- package/schematics/bundles/{index-DYpSE68_.cjs → index-Bp8sCiq1.cjs} +5 -4
- package/schematics/bundles/inject-flags.cjs +6 -5
- package/schematics/bundles/inject-migration.cjs +3 -3
- package/schematics/bundles/leading_space-D9nQ8UQC.cjs +1 -1
- package/schematics/bundles/{migrate_ts_type_references-Covsxz7y.cjs → migrate_ts_type_references-CmZ0155c.cjs} +6 -5
- package/schematics/bundles/ng_decorators-B5HCqr20.cjs +1 -1
- package/schematics/bundles/nodes-B16H9JUd.cjs +1 -1
- package/schematics/bundles/output-migration.cjs +7 -6
- package/schematics/bundles/{project_paths-3GwjSb-R.cjs → project_paths-D2SJWT7x.cjs} +39 -3
- package/schematics/bundles/project_tsconfig_paths-CDVxT6Ov.cjs +1 -1
- package/schematics/bundles/property_name-BBwFuqMe.cjs +1 -1
- package/schematics/bundles/route-lazy-loading.cjs +3 -3
- package/schematics/bundles/self-closing-tags-migration.cjs +5 -4
- package/schematics/bundles/signal-input-migration.cjs +8 -7
- package/schematics/bundles/signal-queries-migration.cjs +8 -7
- package/schematics/bundles/signals.cjs +8 -7
- package/schematics/bundles/standalone-migration.cjs +4 -4
- package/schematics/bundles/symbol-VPWguRxr.cjs +1 -1
- package/schematics/bundles/test-bed-get.cjs +5 -4
- package/signal.d.d.ts +1 -1
- package/testing/index.d.ts +1 -1
- package/weak_ref.d.d.ts +1 -1
- package/fesm2022/injector.mjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* @license Angular v20.1.0
|
|
3
|
+
* @license Angular v20.1.0
|
|
4
4
|
* (c) 2010-2025 Google LLC. https://angular.io/
|
|
5
5
|
* License: MIT
|
|
6
6
|
*/
|
|
@@ -32,6 +32,7 @@ function _interopNamespaceDefault(e) {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
var p__namespace = /*#__PURE__*/_interopNamespaceDefault(p);
|
|
35
|
+
var url__namespace = /*#__PURE__*/_interopNamespaceDefault(url);
|
|
35
36
|
|
|
36
37
|
const _SELECTOR_REGEXP = new RegExp('(\\:not\\()|' + // 1: ":not("
|
|
37
38
|
'(([\\.\\#]?)[-\\w]+)|' + // 2: "tag"; 3: "."/"#";
|
|
@@ -2166,7 +2167,7 @@ function ifStmt(condition, thenClause, elseClause, sourceSpan, leadingComments)
|
|
|
2166
2167
|
function taggedTemplate(tag, template, type, sourceSpan) {
|
|
2167
2168
|
return new TaggedTemplateLiteralExpr(tag, template, type, sourceSpan);
|
|
2168
2169
|
}
|
|
2169
|
-
function literal
|
|
2170
|
+
function literal(value, type, sourceSpan) {
|
|
2170
2171
|
return new LiteralExpr(value, type, sourceSpan);
|
|
2171
2172
|
}
|
|
2172
2173
|
function localizedString(metaBlock, messageParts, placeholderNames, expressions, sourceSpan) {
|
|
@@ -3122,7 +3123,7 @@ class _EmittedLine {
|
|
|
3122
3123
|
this.indent = indent;
|
|
3123
3124
|
}
|
|
3124
3125
|
}
|
|
3125
|
-
const BINARY_OPERATORS$
|
|
3126
|
+
const BINARY_OPERATORS$2 = new Map([
|
|
3126
3127
|
[BinaryOperator.And, '&&'],
|
|
3127
3128
|
[BinaryOperator.Bigger, '>'],
|
|
3128
3129
|
[BinaryOperator.BiggerEquals, '>='],
|
|
@@ -3476,7 +3477,7 @@ class AbstractEmitterVisitor {
|
|
|
3476
3477
|
return null;
|
|
3477
3478
|
}
|
|
3478
3479
|
visitBinaryOperatorExpr(ast, ctx) {
|
|
3479
|
-
const operator = BINARY_OPERATORS$
|
|
3480
|
+
const operator = BINARY_OPERATORS$2.get(ast.operator);
|
|
3480
3481
|
if (!operator) {
|
|
3481
3482
|
throw new Error(`Unknown operator ${ast.operator}`);
|
|
3482
3483
|
}
|
|
@@ -3613,7 +3614,7 @@ function devOnlyGuardedExpression(expr) {
|
|
|
3613
3614
|
}
|
|
3614
3615
|
function guardedExpression(guard, expr) {
|
|
3615
3616
|
const guardExpr = new ExternalExpr({ name: guard, moduleName: null });
|
|
3616
|
-
const guardNotDefined = new BinaryOperatorExpr(BinaryOperator.Identical, new TypeofExpr(guardExpr), literal
|
|
3617
|
+
const guardNotDefined = new BinaryOperatorExpr(BinaryOperator.Identical, new TypeofExpr(guardExpr), literal('undefined'));
|
|
3617
3618
|
const guardUndefinedOrTrue = new BinaryOperatorExpr(BinaryOperator.Or, guardNotDefined, guardExpr,
|
|
3618
3619
|
/* type */ undefined,
|
|
3619
3620
|
/* sourceSpan */ undefined);
|
|
@@ -3759,7 +3760,7 @@ function injectDependencies(deps, target) {
|
|
|
3759
3760
|
function compileInjectDependency(dep, target, index) {
|
|
3760
3761
|
// Interpret the dependency according to its resolved type.
|
|
3761
3762
|
if (dep.token === null) {
|
|
3762
|
-
return importExpr(Identifiers.invalidFactoryDep).callFn([literal
|
|
3763
|
+
return importExpr(Identifiers.invalidFactoryDep).callFn([literal(index)]);
|
|
3763
3764
|
}
|
|
3764
3765
|
else if (dep.attributeNameType === null) {
|
|
3765
3766
|
// Build up the injection flags according to the metadata.
|
|
@@ -3772,7 +3773,7 @@ function compileInjectDependency(dep, target, index) {
|
|
|
3772
3773
|
// If this dependency is optional or otherwise has non-default flags, then additional
|
|
3773
3774
|
// parameters describing how to inject the dependency must be passed to the inject function
|
|
3774
3775
|
// that's being used.
|
|
3775
|
-
let flagsParam = flags !== 0 /* InjectFlags.Default */ || dep.optional ? literal
|
|
3776
|
+
let flagsParam = flags !== 0 /* InjectFlags.Default */ || dep.optional ? literal(flags) : null;
|
|
3776
3777
|
// Build up the arguments to the injectFn call.
|
|
3777
3778
|
const injectArgs = [dep.token];
|
|
3778
3779
|
if (flagsParam) {
|
|
@@ -3801,7 +3802,7 @@ function createCtorDepsType(deps) {
|
|
|
3801
3802
|
return type;
|
|
3802
3803
|
}
|
|
3803
3804
|
else {
|
|
3804
|
-
return literal
|
|
3805
|
+
return literal(null);
|
|
3805
3806
|
}
|
|
3806
3807
|
});
|
|
3807
3808
|
if (hasTypes) {
|
|
@@ -3817,16 +3818,16 @@ function createCtorDepType(dep) {
|
|
|
3817
3818
|
entries.push({ key: 'attribute', value: dep.attributeNameType, quoted: false });
|
|
3818
3819
|
}
|
|
3819
3820
|
if (dep.optional) {
|
|
3820
|
-
entries.push({ key: 'optional', value: literal
|
|
3821
|
+
entries.push({ key: 'optional', value: literal(true), quoted: false });
|
|
3821
3822
|
}
|
|
3822
3823
|
if (dep.host) {
|
|
3823
|
-
entries.push({ key: 'host', value: literal
|
|
3824
|
+
entries.push({ key: 'host', value: literal(true), quoted: false });
|
|
3824
3825
|
}
|
|
3825
3826
|
if (dep.self) {
|
|
3826
|
-
entries.push({ key: 'self', value: literal
|
|
3827
|
+
entries.push({ key: 'self', value: literal(true), quoted: false });
|
|
3827
3828
|
}
|
|
3828
3829
|
if (dep.skipSelf) {
|
|
3829
|
-
entries.push({ key: 'skipSelf', value: literal
|
|
3830
|
+
entries.push({ key: 'skipSelf', value: literal(true), quoted: false });
|
|
3830
3831
|
}
|
|
3831
3832
|
return entries.length > 0 ? literalMap(entries) : null;
|
|
3832
3833
|
}
|
|
@@ -4409,7 +4410,7 @@ class ParsedProperty {
|
|
|
4409
4410
|
keySpan;
|
|
4410
4411
|
valueSpan;
|
|
4411
4412
|
isLiteral;
|
|
4412
|
-
|
|
4413
|
+
isLegacyAnimation;
|
|
4413
4414
|
constructor(name, expression, type, sourceSpan, keySpan, valueSpan) {
|
|
4414
4415
|
this.name = name;
|
|
4415
4416
|
this.expression = expression;
|
|
@@ -4418,22 +4419,22 @@ class ParsedProperty {
|
|
|
4418
4419
|
this.keySpan = keySpan;
|
|
4419
4420
|
this.valueSpan = valueSpan;
|
|
4420
4421
|
this.isLiteral = this.type === ParsedPropertyType.LITERAL_ATTR;
|
|
4421
|
-
this.
|
|
4422
|
+
this.isLegacyAnimation = this.type === ParsedPropertyType.LEGACY_ANIMATION;
|
|
4422
4423
|
}
|
|
4423
4424
|
}
|
|
4424
4425
|
var ParsedPropertyType;
|
|
4425
4426
|
(function (ParsedPropertyType) {
|
|
4426
4427
|
ParsedPropertyType[ParsedPropertyType["DEFAULT"] = 0] = "DEFAULT";
|
|
4427
4428
|
ParsedPropertyType[ParsedPropertyType["LITERAL_ATTR"] = 1] = "LITERAL_ATTR";
|
|
4428
|
-
ParsedPropertyType[ParsedPropertyType["
|
|
4429
|
+
ParsedPropertyType[ParsedPropertyType["LEGACY_ANIMATION"] = 2] = "LEGACY_ANIMATION";
|
|
4429
4430
|
ParsedPropertyType[ParsedPropertyType["TWO_WAY"] = 3] = "TWO_WAY";
|
|
4430
4431
|
})(ParsedPropertyType || (ParsedPropertyType = {}));
|
|
4431
4432
|
exports.ParsedEventType = void 0;
|
|
4432
4433
|
(function (ParsedEventType) {
|
|
4433
4434
|
// DOM or Directive event
|
|
4434
4435
|
ParsedEventType[ParsedEventType["Regular"] = 0] = "Regular";
|
|
4435
|
-
//
|
|
4436
|
-
ParsedEventType[ParsedEventType["
|
|
4436
|
+
// Legacy animation specific event
|
|
4437
|
+
ParsedEventType[ParsedEventType["LegacyAnimation"] = 1] = "LegacyAnimation";
|
|
4437
4438
|
// Event side of a two-way binding (e.g. `[(property)]="expression"`).
|
|
4438
4439
|
ParsedEventType[ParsedEventType["TwoWay"] = 2] = "TwoWay";
|
|
4439
4440
|
})(exports.ParsedEventType || (exports.ParsedEventType = {}));
|
|
@@ -4482,8 +4483,8 @@ exports.BindingType = void 0;
|
|
|
4482
4483
|
BindingType[BindingType["Class"] = 2] = "Class";
|
|
4483
4484
|
// A binding to a style rule (e.g. `[style.rule]="expression"`).
|
|
4484
4485
|
BindingType[BindingType["Style"] = 3] = "Style";
|
|
4485
|
-
// A binding to
|
|
4486
|
-
BindingType[BindingType["
|
|
4486
|
+
// A binding to a legacy animation reference (e.g. `[animate.key]="expression"`).
|
|
4487
|
+
BindingType[BindingType["LegacyAnimation"] = 4] = "LegacyAnimation";
|
|
4487
4488
|
// Property side of a two-way binding (e.g. `[(property)]="expression"`).
|
|
4488
4489
|
BindingType[BindingType["TwoWay"] = 5] = "TwoWay";
|
|
4489
4490
|
})(exports.BindingType || (exports.BindingType = {}));
|
|
@@ -4666,7 +4667,7 @@ class BoundEvent {
|
|
|
4666
4667
|
}
|
|
4667
4668
|
static fromParsedEvent(event) {
|
|
4668
4669
|
const target = event.type === exports.ParsedEventType.Regular ? event.targetOrPhase : null;
|
|
4669
|
-
const phase = event.type === exports.ParsedEventType.
|
|
4670
|
+
const phase = event.type === exports.ParsedEventType.LegacyAnimation ? event.targetOrPhase : null;
|
|
4670
4671
|
if (event.keySpan === undefined) {
|
|
4671
4672
|
throw new Error(`Unexpected state: keySpan must be defined for bound event but was not for ${event.name}: ${event.sourceSpan}`);
|
|
4672
4673
|
}
|
|
@@ -5971,7 +5972,7 @@ function asLiteral(value) {
|
|
|
5971
5972
|
if (Array.isArray(value)) {
|
|
5972
5973
|
return literalArr(value.map(asLiteral));
|
|
5973
5974
|
}
|
|
5974
|
-
return literal
|
|
5975
|
+
return literal(value, INFERRED_TYPE);
|
|
5975
5976
|
}
|
|
5976
5977
|
/**
|
|
5977
5978
|
* Serializes inputs and outputs for `defineDirective` and `defineComponent`.
|
|
@@ -6015,7 +6016,7 @@ function conditionallyCreateDirectiveBindingLiteral(map, forInputs) {
|
|
|
6015
6016
|
// decorator input transform functions, or store flag information if there is any.
|
|
6016
6017
|
if (forInputs &&
|
|
6017
6018
|
(differentDeclaringName || hasDecoratorInputTransform || flags !== InputFlags.None)) {
|
|
6018
|
-
const result = [literal
|
|
6019
|
+
const result = [literal(flags), asLiteral(publicName)];
|
|
6019
6020
|
if (differentDeclaringName || hasDecoratorInputTransform) {
|
|
6020
6021
|
result.push(asLiteral(declaredName));
|
|
6021
6022
|
if (hasDecoratorInputTransform) {
|
|
@@ -6498,7 +6499,7 @@ var ParseErrorLevel;
|
|
|
6498
6499
|
ParseErrorLevel[ParseErrorLevel["WARNING"] = 0] = "WARNING";
|
|
6499
6500
|
ParseErrorLevel[ParseErrorLevel["ERROR"] = 1] = "ERROR";
|
|
6500
6501
|
})(ParseErrorLevel || (ParseErrorLevel = {}));
|
|
6501
|
-
class ParseError {
|
|
6502
|
+
class ParseError extends Error {
|
|
6502
6503
|
span;
|
|
6503
6504
|
msg;
|
|
6504
6505
|
level;
|
|
@@ -6515,10 +6516,15 @@ class ParseError {
|
|
|
6515
6516
|
* couldn't be parsed. Not guaranteed to be defined, but can be used to provide more context.
|
|
6516
6517
|
*/
|
|
6517
6518
|
relatedError) {
|
|
6519
|
+
super(msg);
|
|
6518
6520
|
this.span = span;
|
|
6519
6521
|
this.msg = msg;
|
|
6520
6522
|
this.level = level;
|
|
6521
6523
|
this.relatedError = relatedError;
|
|
6524
|
+
// Extending `Error` ends up breaking some internal tests. This appears to be a known issue
|
|
6525
|
+
// when extending errors in TS and the workaround is to explicitly set the prototype.
|
|
6526
|
+
// https://stackoverflow.com/questions/41102060/typescript-extending-error-class
|
|
6527
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
6522
6528
|
}
|
|
6523
6529
|
contextualMessage() {
|
|
6524
6530
|
const ctx = this.span.start.getContext(100, 3);
|
|
@@ -6821,7 +6827,7 @@ class JitEvaluator {
|
|
|
6821
6827
|
const ctx = EmitterVisitorContext.createRoot();
|
|
6822
6828
|
// Ensure generated code is in strict mode
|
|
6823
6829
|
if (statements.length > 0 && !isUseStrictStatement(statements[0])) {
|
|
6824
|
-
statements = [literal
|
|
6830
|
+
statements = [literal('use strict').toStmt(), ...statements];
|
|
6825
6831
|
}
|
|
6826
6832
|
converter.visitAllStatements(statements, ctx);
|
|
6827
6833
|
converter.createReturnStmt(ctx);
|
|
@@ -6927,7 +6933,7 @@ class JitEmitterVisitor extends AbstractJsEmitterVisitor {
|
|
|
6927
6933
|
}
|
|
6928
6934
|
}
|
|
6929
6935
|
function isUseStrictStatement(statement) {
|
|
6930
|
-
return statement.isEquivalent(literal
|
|
6936
|
+
return statement.isEquivalent(literal('use strict').toStmt());
|
|
6931
6937
|
}
|
|
6932
6938
|
|
|
6933
6939
|
function compileInjector(meta) {
|
|
@@ -7172,15 +7178,15 @@ function compilePipeFromMetadata(metadata) {
|
|
|
7172
7178
|
// e.g. `name: 'myPipe'`
|
|
7173
7179
|
definitionMapValues.push({
|
|
7174
7180
|
key: 'name',
|
|
7175
|
-
value: literal
|
|
7181
|
+
value: literal(metadata.pipeName ?? metadata.name),
|
|
7176
7182
|
quoted: false,
|
|
7177
7183
|
});
|
|
7178
7184
|
// e.g. `type: MyPipe`
|
|
7179
7185
|
definitionMapValues.push({ key: 'type', value: metadata.type.value, quoted: false });
|
|
7180
7186
|
// e.g. `pure: true`
|
|
7181
|
-
definitionMapValues.push({ key: 'pure', value: literal
|
|
7187
|
+
definitionMapValues.push({ key: 'pure', value: literal(metadata.pure), quoted: false });
|
|
7182
7188
|
if (metadata.isStandalone === false) {
|
|
7183
|
-
definitionMapValues.push({ key: 'standalone', value: literal
|
|
7189
|
+
definitionMapValues.push({ key: 'standalone', value: literal(false), quoted: false });
|
|
7184
7190
|
}
|
|
7185
7191
|
const expression = importExpr(Identifiers.definePipe)
|
|
7186
7192
|
.callFn([literalMap(definitionMapValues)], undefined, true);
|
|
@@ -8792,9 +8798,9 @@ var BindingKind;
|
|
|
8792
8798
|
*/
|
|
8793
8799
|
BindingKind[BindingKind["I18n"] = 5] = "I18n";
|
|
8794
8800
|
/**
|
|
8795
|
-
*
|
|
8801
|
+
* Legacy animation property bindings.
|
|
8796
8802
|
*/
|
|
8797
|
-
BindingKind[BindingKind["
|
|
8803
|
+
BindingKind[BindingKind["LegacyAnimation"] = 6] = "LegacyAnimation";
|
|
8798
8804
|
/**
|
|
8799
8805
|
* Property side of a two-way binding.
|
|
8800
8806
|
*/
|
|
@@ -9039,13 +9045,13 @@ function createBindingOp(target, kind, name, expression, unit, securityContext,
|
|
|
9039
9045
|
/**
|
|
9040
9046
|
* Create a `PropertyOp`.
|
|
9041
9047
|
*/
|
|
9042
|
-
function createPropertyOp(target, name, expression,
|
|
9048
|
+
function createPropertyOp(target, name, expression, isLegacyAnimationTrigger, securityContext, isStructuralTemplateAttribute, templateKind, i18nContext, i18nMessage, sourceSpan) {
|
|
9043
9049
|
return {
|
|
9044
9050
|
kind: OpKind.Property,
|
|
9045
9051
|
target,
|
|
9046
9052
|
name,
|
|
9047
9053
|
expression,
|
|
9048
|
-
|
|
9054
|
+
isLegacyAnimationTrigger,
|
|
9049
9055
|
securityContext,
|
|
9050
9056
|
sanitizer: null,
|
|
9051
9057
|
isStructuralTemplateAttribute,
|
|
@@ -10444,7 +10450,7 @@ class OpList {
|
|
|
10444
10450
|
oldOp.next = null;
|
|
10445
10451
|
let prev = oldPrev;
|
|
10446
10452
|
for (const newOp of newOps) {
|
|
10447
|
-
|
|
10453
|
+
OpList.assertIsUnowned(newOp);
|
|
10448
10454
|
newOp.debugListId = listId;
|
|
10449
10455
|
prev.next = newOp;
|
|
10450
10456
|
newOp.prev = prev;
|
|
@@ -10485,7 +10491,7 @@ class OpList {
|
|
|
10485
10491
|
static insertBefore(op, target) {
|
|
10486
10492
|
if (Array.isArray(op)) {
|
|
10487
10493
|
for (const o of op) {
|
|
10488
|
-
|
|
10494
|
+
OpList.insertBefore(o, target);
|
|
10489
10495
|
}
|
|
10490
10496
|
return;
|
|
10491
10497
|
}
|
|
@@ -10732,7 +10738,7 @@ function createTextOp(xref, initialValue, icuPlaceholder, sourceSpan) {
|
|
|
10732
10738
|
/**
|
|
10733
10739
|
* Create a `ListenerOp`. Host bindings reuse all the listener logic.
|
|
10734
10740
|
*/
|
|
10735
|
-
function createListenerOp(target, targetSlot, name, tag, handlerOps,
|
|
10741
|
+
function createListenerOp(target, targetSlot, name, tag, handlerOps, legacyAnimationPhase, eventTarget, hostListener, sourceSpan) {
|
|
10736
10742
|
const handlerList = new OpList();
|
|
10737
10743
|
handlerList.push(handlerOps);
|
|
10738
10744
|
return {
|
|
@@ -10745,8 +10751,8 @@ function createListenerOp(target, targetSlot, name, tag, handlerOps, animationPh
|
|
|
10745
10751
|
handlerOps: handlerList,
|
|
10746
10752
|
handlerFnName: null,
|
|
10747
10753
|
consumesDollarEvent: false,
|
|
10748
|
-
|
|
10749
|
-
|
|
10754
|
+
isLegacyAnimationListener: legacyAnimationPhase !== null,
|
|
10755
|
+
legacyAnimationPhase: legacyAnimationPhase,
|
|
10750
10756
|
eventTarget,
|
|
10751
10757
|
sourceSpan,
|
|
10752
10758
|
...NEW_OP,
|
|
@@ -11001,12 +11007,12 @@ function createSourceLocationOp(templatePath, locations) {
|
|
|
11001
11007
|
};
|
|
11002
11008
|
}
|
|
11003
11009
|
|
|
11004
|
-
function createDomPropertyOp(name, expression,
|
|
11010
|
+
function createDomPropertyOp(name, expression, isLegacyAnimationTrigger, i18nContext, securityContext, sourceSpan) {
|
|
11005
11011
|
return {
|
|
11006
11012
|
kind: OpKind.DomProperty,
|
|
11007
11013
|
name,
|
|
11008
11014
|
expression,
|
|
11009
|
-
|
|
11015
|
+
isLegacyAnimationTrigger,
|
|
11010
11016
|
i18nContext,
|
|
11011
11017
|
securityContext,
|
|
11012
11018
|
sanitizer: null,
|
|
@@ -11453,7 +11459,7 @@ function extractAttributes(job) {
|
|
|
11453
11459
|
extractAttributeOp(unit, op, elements);
|
|
11454
11460
|
break;
|
|
11455
11461
|
case OpKind.Property:
|
|
11456
|
-
if (!op.
|
|
11462
|
+
if (!op.isLegacyAnimationTrigger) {
|
|
11457
11463
|
let bindingKind;
|
|
11458
11464
|
if (op.i18nMessage !== null && op.templateKind === null) {
|
|
11459
11465
|
// If the binding has an i18n context, it is an i18n attribute, and should have that
|
|
@@ -11495,7 +11501,7 @@ function extractAttributes(job) {
|
|
|
11495
11501
|
}
|
|
11496
11502
|
break;
|
|
11497
11503
|
case OpKind.Listener:
|
|
11498
|
-
if (!op.
|
|
11504
|
+
if (!op.isLegacyAnimationListener) {
|
|
11499
11505
|
const extractedAttributeOp = createExtractedAttributeOp(op.target, BindingKind.Property, null, op.name,
|
|
11500
11506
|
/* expression */ null,
|
|
11501
11507
|
/* i18nContext */ null,
|
|
@@ -11605,12 +11611,12 @@ function specializeBindings(job) {
|
|
|
11605
11611
|
}
|
|
11606
11612
|
break;
|
|
11607
11613
|
case BindingKind.Property:
|
|
11608
|
-
case BindingKind.
|
|
11614
|
+
case BindingKind.LegacyAnimation:
|
|
11609
11615
|
if (job.kind === CompilationJobKind.Host) {
|
|
11610
|
-
OpList.replace(op, createDomPropertyOp(op.name, op.expression, op.bindingKind === BindingKind.
|
|
11616
|
+
OpList.replace(op, createDomPropertyOp(op.name, op.expression, op.bindingKind === BindingKind.LegacyAnimation, op.i18nContext, op.securityContext, op.sourceSpan));
|
|
11611
11617
|
}
|
|
11612
11618
|
else {
|
|
11613
|
-
OpList.replace(op, createPropertyOp(op.target, op.name, op.expression, op.bindingKind === BindingKind.
|
|
11619
|
+
OpList.replace(op, createPropertyOp(op.target, op.name, op.expression, op.bindingKind === BindingKind.LegacyAnimation, op.securityContext, op.isStructuralTemplateAttribute, op.templateKind, op.i18nContext, op.i18nMessage, op.sourceSpan));
|
|
11614
11620
|
}
|
|
11615
11621
|
break;
|
|
11616
11622
|
case BindingKind.TwoWayProperty:
|
|
@@ -11781,7 +11787,7 @@ function generateConditionalExpressions(job) {
|
|
|
11781
11787
|
}
|
|
11782
11788
|
else {
|
|
11783
11789
|
// By default, a switch evaluates to `-1`, causing no template to be displayed.
|
|
11784
|
-
test = literal
|
|
11790
|
+
test = literal(-1);
|
|
11785
11791
|
}
|
|
11786
11792
|
// Switch expressions assign their main test to a temporary, to avoid re-executing it.
|
|
11787
11793
|
let tmp = op.test == null ? null : new AssignTemporaryExpr(op.test, job.allocateXrefId());
|
|
@@ -11812,7 +11818,7 @@ function generateConditionalExpressions(job) {
|
|
|
11812
11818
|
}
|
|
11813
11819
|
}
|
|
11814
11820
|
|
|
11815
|
-
const BINARY_OPERATORS$
|
|
11821
|
+
const BINARY_OPERATORS$1 = new Map([
|
|
11816
11822
|
['&&', BinaryOperator.And],
|
|
11817
11823
|
['>', BinaryOperator.Bigger],
|
|
11818
11824
|
['>=', BinaryOperator.BiggerEquals],
|
|
@@ -11876,7 +11882,7 @@ function literalOrArrayLiteral(value) {
|
|
|
11876
11882
|
if (Array.isArray(value)) {
|
|
11877
11883
|
return literalArr(value.map(literalOrArrayLiteral));
|
|
11878
11884
|
}
|
|
11879
|
-
return literal
|
|
11885
|
+
return literal(value);
|
|
11880
11886
|
}
|
|
11881
11887
|
|
|
11882
11888
|
/**
|
|
@@ -12047,9 +12053,9 @@ class ElementAttributes {
|
|
|
12047
12053
|
* Gets an array of literal expressions representing the attribute's namespaced name.
|
|
12048
12054
|
*/
|
|
12049
12055
|
function getAttributeNameLiterals(namespace, name) {
|
|
12050
|
-
const nameLiteral = literal
|
|
12056
|
+
const nameLiteral = literal(name);
|
|
12051
12057
|
if (namespace) {
|
|
12052
|
-
return [literal
|
|
12058
|
+
return [literal(0 /* core.AttributeMarker.NamespaceURI */), literal(namespace), nameLiteral];
|
|
12053
12059
|
}
|
|
12054
12060
|
return [nameLiteral];
|
|
12055
12061
|
}
|
|
@@ -12062,22 +12068,22 @@ function serializeAttributes({ attributes, bindings, classes, i18n, projectAs, s
|
|
|
12062
12068
|
// Parse the attribute value into a CssSelectorList. Note that we only take the
|
|
12063
12069
|
// first selector, because we don't support multiple selectors in ngProjectAs.
|
|
12064
12070
|
const parsedR3Selector = parseSelectorToR3Selector(projectAs)[0];
|
|
12065
|
-
attrArray.push(literal
|
|
12071
|
+
attrArray.push(literal(5 /* core.AttributeMarker.ProjectAs */), literalOrArrayLiteral(parsedR3Selector));
|
|
12066
12072
|
}
|
|
12067
12073
|
if (classes.length > 0) {
|
|
12068
|
-
attrArray.push(literal
|
|
12074
|
+
attrArray.push(literal(1 /* core.AttributeMarker.Classes */), ...classes);
|
|
12069
12075
|
}
|
|
12070
12076
|
if (styles.length > 0) {
|
|
12071
|
-
attrArray.push(literal
|
|
12077
|
+
attrArray.push(literal(2 /* core.AttributeMarker.Styles */), ...styles);
|
|
12072
12078
|
}
|
|
12073
12079
|
if (bindings.length > 0) {
|
|
12074
|
-
attrArray.push(literal
|
|
12080
|
+
attrArray.push(literal(3 /* core.AttributeMarker.Bindings */), ...bindings);
|
|
12075
12081
|
}
|
|
12076
12082
|
if (template.length > 0) {
|
|
12077
|
-
attrArray.push(literal
|
|
12083
|
+
attrArray.push(literal(4 /* core.AttributeMarker.Template */), ...template);
|
|
12078
12084
|
}
|
|
12079
12085
|
if (i18n.length > 0) {
|
|
12080
|
-
attrArray.push(literal
|
|
12086
|
+
attrArray.push(literal(6 /* core.AttributeMarker.I18n */), ...i18n);
|
|
12081
12087
|
}
|
|
12082
12088
|
return literalArr(attrArray);
|
|
12083
12089
|
}
|
|
@@ -12699,7 +12705,7 @@ function extractI18nMessages(job) {
|
|
|
12699
12705
|
throw Error('AssertionError: Unexpected ICU placeholder outside of i18n context');
|
|
12700
12706
|
}
|
|
12701
12707
|
const msg = i18nMessagesByContext.get(currentIcu.context);
|
|
12702
|
-
msg.postprocessingParams.set(op.name, literal
|
|
12708
|
+
msg.postprocessingParams.set(op.name, literal(formatIcuPlaceholder(op)));
|
|
12703
12709
|
OpList.remove(op);
|
|
12704
12710
|
break;
|
|
12705
12711
|
}
|
|
@@ -12733,7 +12739,7 @@ function formatParams(params) {
|
|
|
12733
12739
|
for (const [placeholder, placeholderValues] of params) {
|
|
12734
12740
|
const serializedValues = formatParamValues(placeholderValues);
|
|
12735
12741
|
if (serializedValues !== null) {
|
|
12736
|
-
formattedParams.set(placeholder, literal
|
|
12742
|
+
formattedParams.set(placeholder, literal(serializedValues));
|
|
12737
12743
|
}
|
|
12738
12744
|
}
|
|
12739
12745
|
return formattedParams;
|
|
@@ -13110,7 +13116,7 @@ function collectConstExpressions(job) {
|
|
|
13110
13116
|
if (!(expr instanceof ConstCollectedExpr)) {
|
|
13111
13117
|
return expr;
|
|
13112
13118
|
}
|
|
13113
|
-
return literal
|
|
13119
|
+
return literal(job.addConst(expr.expr));
|
|
13114
13120
|
}, VisitorContextFlag.None);
|
|
13115
13121
|
}
|
|
13116
13122
|
}
|
|
@@ -16984,12 +16990,16 @@ class EscapedCharacterCursor extends PlainCharacterCursor {
|
|
|
16984
16990
|
}
|
|
16985
16991
|
}
|
|
16986
16992
|
}
|
|
16987
|
-
class CursorError {
|
|
16993
|
+
class CursorError extends Error {
|
|
16988
16994
|
msg;
|
|
16989
16995
|
cursor;
|
|
16990
16996
|
constructor(msg, cursor) {
|
|
16997
|
+
super(msg);
|
|
16991
16998
|
this.msg = msg;
|
|
16992
16999
|
this.cursor = cursor;
|
|
17000
|
+
// Extending `Error` does not always work when code is transpiled. See:
|
|
17001
|
+
// https://stackoverflow.com/questions/41102060/typescript-extending-error-class
|
|
17002
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
16993
17003
|
}
|
|
16994
17004
|
}
|
|
16995
17005
|
|
|
@@ -17976,9 +17986,11 @@ class Token {
|
|
|
17976
17986
|
return this.type === TokenType.Number ? this.numValue : -1;
|
|
17977
17987
|
}
|
|
17978
17988
|
isTemplateLiteralPart() {
|
|
17989
|
+
// Note: Explicit type is needed for Closure.
|
|
17979
17990
|
return this.isString() && this.kind === StringTokenKind.TemplateLiteralPart;
|
|
17980
17991
|
}
|
|
17981
17992
|
isTemplateLiteralEnd() {
|
|
17993
|
+
// Note: Explicit type is needed for Closure.
|
|
17982
17994
|
return this.isString() && this.kind === StringTokenKind.TemplateLiteralEnd;
|
|
17983
17995
|
}
|
|
17984
17996
|
isTemplateLiteralInterpolationStart() {
|
|
@@ -18524,10 +18536,14 @@ class Parser {
|
|
|
18524
18536
|
return null;
|
|
18525
18537
|
const expressionNodes = [];
|
|
18526
18538
|
for (let i = 0; i < expressions.length; ++i) {
|
|
18539
|
+
// If we have a token for the specific expression, it's preferrable to use it because it
|
|
18540
|
+
// allows us to produce more accurate error messages. The expressions are always at the odd
|
|
18541
|
+
// indexes inside the tokens.
|
|
18542
|
+
const expressionSpan = interpolatedTokens?.[i * 2 + 1]?.sourceSpan;
|
|
18527
18543
|
const expressionText = expressions[i].text;
|
|
18528
18544
|
const sourceToLex = this._stripComments(expressionText);
|
|
18529
18545
|
const tokens = this._lexer.tokenize(sourceToLex);
|
|
18530
|
-
const ast = new _ParseAST(input, parseSourceSpan, absoluteOffset, tokens, 0 /* ParseFlags.None */, errors, offsets[i], this._supportsDirectPipeReferences).parseChain();
|
|
18546
|
+
const ast = new _ParseAST(expressionSpan ? expressionText : input, expressionSpan || parseSourceSpan, absoluteOffset, tokens, 0 /* ParseFlags.None */, errors, offsets[i], this._supportsDirectPipeReferences).parseChain();
|
|
18531
18547
|
expressionNodes.push(ast);
|
|
18532
18548
|
}
|
|
18533
18549
|
return this.createInterpolationAst(strings.map((s) => s.text), expressionNodes, input, getLocation(parseSourceSpan), absoluteOffset, errors);
|
|
@@ -21424,7 +21440,7 @@ const GOOG_GET_MSG = 'goog.getMsg';
|
|
|
21424
21440
|
*/
|
|
21425
21441
|
function createGoogleGetMsgStatements(variable$1, message, closureVar, placeholderValues) {
|
|
21426
21442
|
const messageString = serializeI18nMessageForGetMsg(message);
|
|
21427
|
-
const args = [literal
|
|
21443
|
+
const args = [literal(messageString)];
|
|
21428
21444
|
if (Object.keys(placeholderValues).length) {
|
|
21429
21445
|
// Message template parameters containing the magic strings replaced by the Angular runtime with
|
|
21430
21446
|
// real data, e.g. `{'interpolation': '\uFFFD0\uFFFD'}`.
|
|
@@ -21438,9 +21454,9 @@ function createGoogleGetMsgStatements(variable$1, message, closureVar, placehold
|
|
|
21438
21454
|
quoted: true,
|
|
21439
21455
|
value: message.placeholders[param]
|
|
21440
21456
|
? // Get source span for typical placeholder if it exists.
|
|
21441
|
-
literal
|
|
21457
|
+
literal(message.placeholders[param].sourceSpan.toString())
|
|
21442
21458
|
: // Otherwise must be an ICU expression, get it's source span.
|
|
21443
|
-
literal
|
|
21459
|
+
literal(message.placeholderToMessage[param].nodes
|
|
21444
21460
|
.map((node) => node.sourceSpan.toString())
|
|
21445
21461
|
.join('')),
|
|
21446
21462
|
}))),
|
|
@@ -21755,7 +21771,7 @@ function collectI18nConsts(job) {
|
|
|
21755
21771
|
if (i18nExprValue === undefined) {
|
|
21756
21772
|
throw new Error("AssertionError: Could not find i18n expression's value");
|
|
21757
21773
|
}
|
|
21758
|
-
return [literal
|
|
21774
|
+
return [literal(i18nExpr.name), i18nExprValue];
|
|
21759
21775
|
});
|
|
21760
21776
|
i18nAttributes.i18nAttributesConfig = job.addConst(new LiteralArrayExpr(i18nAttributeConfig));
|
|
21761
21777
|
}
|
|
@@ -21833,7 +21849,7 @@ function addSubMessageParams(messageOp, subMessagePlaceholders) {
|
|
|
21833
21849
|
messageOp.params.set(placeholder, subMessages[0]);
|
|
21834
21850
|
}
|
|
21835
21851
|
else {
|
|
21836
|
-
messageOp.params.set(placeholder, literal
|
|
21852
|
+
messageOp.params.set(placeholder, literal(`${ESCAPE}${I18N_ICU_MAPPING_PREFIX}${placeholder}${ESCAPE}`));
|
|
21837
21853
|
messageOp.postprocessingParams.set(placeholder, literalArr(subMessages));
|
|
21838
21854
|
}
|
|
21839
21855
|
}
|
|
@@ -21886,7 +21902,7 @@ function getTranslationDeclStmts(message, variable, closureVar, params, transfor
|
|
|
21886
21902
|
*/
|
|
21887
21903
|
function createClosureModeGuard() {
|
|
21888
21904
|
return typeofExpr(variable(NG_I18N_CLOSURE_MODE))
|
|
21889
|
-
.notIdentical(literal
|
|
21905
|
+
.notIdentical(literal('undefined', STRING_TYPE))
|
|
21890
21906
|
.and(variable(NG_I18N_CLOSURE_MODE));
|
|
21891
21907
|
}
|
|
21892
21908
|
/**
|
|
@@ -22027,7 +22043,7 @@ function liftLocalRefs(job) {
|
|
|
22027
22043
|
function serializeLocalRefs(refs) {
|
|
22028
22044
|
const constRefs = [];
|
|
22029
22045
|
for (const ref of refs) {
|
|
22030
|
-
constRefs.push(literal
|
|
22046
|
+
constRefs.push(literal(ref.name), literal(ref.target));
|
|
22031
22047
|
}
|
|
22032
22048
|
return literalArr(constRefs);
|
|
22033
22049
|
}
|
|
@@ -22163,7 +22179,7 @@ function parseExtractedStyles(job) {
|
|
|
22163
22179
|
if (op.name === 'style') {
|
|
22164
22180
|
const parsedStyles = parse(op.expression.value);
|
|
22165
22181
|
for (let i = 0; i < parsedStyles.length - 1; i += 2) {
|
|
22166
|
-
OpList.insertBefore(createExtractedAttributeOp(op.target, BindingKind.StyleProperty, null, parsedStyles[i], literal
|
|
22182
|
+
OpList.insertBefore(createExtractedAttributeOp(op.target, BindingKind.StyleProperty, null, parsedStyles[i], literal(parsedStyles[i + 1]), null, null, SecurityContext.STYLE), op);
|
|
22167
22183
|
}
|
|
22168
22184
|
OpList.remove(op);
|
|
22169
22185
|
}
|
|
@@ -22203,7 +22219,7 @@ function addNamesToView(unit, baseName, state, compatibility) {
|
|
|
22203
22219
|
switch (op.kind) {
|
|
22204
22220
|
case OpKind.Property:
|
|
22205
22221
|
case OpKind.DomProperty:
|
|
22206
|
-
if (op.
|
|
22222
|
+
if (op.isLegacyAnimationTrigger) {
|
|
22207
22223
|
op.name = '@' + op.name;
|
|
22208
22224
|
}
|
|
22209
22225
|
break;
|
|
@@ -22215,8 +22231,8 @@ function addNamesToView(unit, baseName, state, compatibility) {
|
|
|
22215
22231
|
throw new Error(`Expected a slot to be assigned`);
|
|
22216
22232
|
}
|
|
22217
22233
|
let animation = '';
|
|
22218
|
-
if (op.
|
|
22219
|
-
op.name = `@${op.name}.${op.
|
|
22234
|
+
if (op.isLegacyAnimationListener) {
|
|
22235
|
+
op.name = `@${op.name}.${op.legacyAnimationPhase}`;
|
|
22220
22236
|
animation = 'animation';
|
|
22221
22237
|
}
|
|
22222
22238
|
if (op.hostListener) {
|
|
@@ -22484,7 +22500,7 @@ function kindWithInterpolationTest(kind, interpolation) {
|
|
|
22484
22500
|
};
|
|
22485
22501
|
}
|
|
22486
22502
|
function basicListenerKindTest(op) {
|
|
22487
|
-
return ((op.kind === OpKind.Listener && !(op.hostListener && op.
|
|
22503
|
+
return ((op.kind === OpKind.Listener && !(op.hostListener && op.isLegacyAnimationListener)) ||
|
|
22488
22504
|
op.kind === OpKind.TwoWayListener);
|
|
22489
22505
|
}
|
|
22490
22506
|
function nonInterpolationPropertyKindTest(op) {
|
|
@@ -22497,7 +22513,7 @@ function nonInterpolationPropertyKindTest(op) {
|
|
|
22497
22513
|
* the groups in the order defined here.
|
|
22498
22514
|
*/
|
|
22499
22515
|
const CREATE_ORDERING = [
|
|
22500
|
-
{ test: (op) => op.kind === OpKind.Listener && op.hostListener && op.
|
|
22516
|
+
{ test: (op) => op.kind === OpKind.Listener && op.hostListener && op.isLegacyAnimationListener },
|
|
22501
22517
|
{ test: basicListenerKindTest },
|
|
22502
22518
|
];
|
|
22503
22519
|
/**
|
|
@@ -22906,30 +22922,30 @@ function elementStart(slot, tag, constIndex, localRefIndex, sourceSpan) {
|
|
|
22906
22922
|
return elementOrContainerBase(Identifiers.elementStart, slot, tag, constIndex, localRefIndex, sourceSpan);
|
|
22907
22923
|
}
|
|
22908
22924
|
function elementOrContainerBase(instruction, slot, tag, constIndex, localRefIndex, sourceSpan) {
|
|
22909
|
-
const args = [literal
|
|
22925
|
+
const args = [literal(slot)];
|
|
22910
22926
|
if (tag !== null) {
|
|
22911
|
-
args.push(literal
|
|
22927
|
+
args.push(literal(tag));
|
|
22912
22928
|
}
|
|
22913
22929
|
if (localRefIndex !== null) {
|
|
22914
|
-
args.push(literal
|
|
22915
|
-
literal
|
|
22930
|
+
args.push(literal(constIndex), // might be null, but that's okay.
|
|
22931
|
+
literal(localRefIndex));
|
|
22916
22932
|
}
|
|
22917
22933
|
else if (constIndex !== null) {
|
|
22918
|
-
args.push(literal
|
|
22934
|
+
args.push(literal(constIndex));
|
|
22919
22935
|
}
|
|
22920
22936
|
return call(instruction, args, sourceSpan);
|
|
22921
22937
|
}
|
|
22922
22938
|
function templateBase(instruction, slot, templateFnRef, decls, vars, tag, constIndex, localRefs, sourceSpan) {
|
|
22923
22939
|
const args = [
|
|
22924
|
-
literal
|
|
22940
|
+
literal(slot),
|
|
22925
22941
|
templateFnRef,
|
|
22926
|
-
literal
|
|
22927
|
-
literal
|
|
22928
|
-
literal
|
|
22929
|
-
literal
|
|
22942
|
+
literal(decls),
|
|
22943
|
+
literal(vars),
|
|
22944
|
+
literal(tag),
|
|
22945
|
+
literal(constIndex),
|
|
22930
22946
|
];
|
|
22931
22947
|
if (localRefs !== null) {
|
|
22932
|
-
args.push(literal
|
|
22948
|
+
args.push(literal(localRefs));
|
|
22933
22949
|
args.push(importExpr(Identifiers.templateRefExtractor));
|
|
22934
22950
|
}
|
|
22935
22951
|
while (args[args.length - 1].isEquivalent(NULL_EXPR)) {
|
|
@@ -22938,7 +22954,7 @@ function templateBase(instruction, slot, templateFnRef, decls, vars, tag, constI
|
|
|
22938
22954
|
return call(instruction, args, sourceSpan);
|
|
22939
22955
|
}
|
|
22940
22956
|
function propertyBase(instruction, name, expression, sanitizer, sourceSpan) {
|
|
22941
|
-
const args = [literal
|
|
22957
|
+
const args = [literal(name)];
|
|
22942
22958
|
if (expression instanceof Interpolation) {
|
|
22943
22959
|
args.push(interpolationToExpression(expression, sourceSpan));
|
|
22944
22960
|
}
|
|
@@ -22974,7 +22990,7 @@ function enableBindings() {
|
|
|
22974
22990
|
return call(Identifiers.enableBindings, [], null);
|
|
22975
22991
|
}
|
|
22976
22992
|
function listener(name, handlerFn, eventTargetResolver, syntheticHost, sourceSpan) {
|
|
22977
|
-
const args = [literal
|
|
22993
|
+
const args = [literal(name), handlerFn];
|
|
22978
22994
|
if (eventTargetResolver !== null) {
|
|
22979
22995
|
args.push(importExpr(eventTargetResolver));
|
|
22980
22996
|
}
|
|
@@ -22984,10 +23000,10 @@ function twoWayBindingSet(target, value) {
|
|
|
22984
23000
|
return importExpr(Identifiers.twoWayBindingSet).callFn([target, value]);
|
|
22985
23001
|
}
|
|
22986
23002
|
function twoWayListener(name, handlerFn, sourceSpan) {
|
|
22987
|
-
return call(Identifiers.twoWayListener, [literal
|
|
23003
|
+
return call(Identifiers.twoWayListener, [literal(name), handlerFn], sourceSpan);
|
|
22988
23004
|
}
|
|
22989
23005
|
function pipe(slot, name) {
|
|
22990
|
-
return call(Identifiers.pipe, [literal
|
|
23006
|
+
return call(Identifiers.pipe, [literal(slot), literal(name)], null);
|
|
22991
23007
|
}
|
|
22992
23008
|
function namespaceHTML() {
|
|
22993
23009
|
return call(Identifiers.namespaceHTML, [], null);
|
|
@@ -22999,13 +23015,13 @@ function namespaceMath() {
|
|
|
22999
23015
|
return call(Identifiers.namespaceMathML, [], null);
|
|
23000
23016
|
}
|
|
23001
23017
|
function advance(delta, sourceSpan) {
|
|
23002
|
-
return call(Identifiers.advance, delta > 1 ? [literal
|
|
23018
|
+
return call(Identifiers.advance, delta > 1 ? [literal(delta)] : [], sourceSpan);
|
|
23003
23019
|
}
|
|
23004
23020
|
function reference(slot) {
|
|
23005
|
-
return importExpr(Identifiers.reference).callFn([literal
|
|
23021
|
+
return importExpr(Identifiers.reference).callFn([literal(slot)]);
|
|
23006
23022
|
}
|
|
23007
23023
|
function nextContext(steps) {
|
|
23008
|
-
return importExpr(Identifiers.nextContext).callFn(steps === 1 ? [] : [literal
|
|
23024
|
+
return importExpr(Identifiers.nextContext).callFn(steps === 1 ? [] : [literal(steps)]);
|
|
23009
23025
|
}
|
|
23010
23026
|
function getCurrentView() {
|
|
23011
23027
|
return importExpr(Identifiers.getCurrentView).callFn([]);
|
|
@@ -23017,24 +23033,24 @@ function resetView(returnValue) {
|
|
|
23017
23033
|
return importExpr(Identifiers.resetView).callFn([returnValue]);
|
|
23018
23034
|
}
|
|
23019
23035
|
function text(slot, initialValue, sourceSpan) {
|
|
23020
|
-
const args = [literal
|
|
23036
|
+
const args = [literal(slot, null)];
|
|
23021
23037
|
if (initialValue !== '') {
|
|
23022
|
-
args.push(literal
|
|
23038
|
+
args.push(literal(initialValue));
|
|
23023
23039
|
}
|
|
23024
23040
|
return call(Identifiers.text, args, sourceSpan);
|
|
23025
23041
|
}
|
|
23026
23042
|
function defer(selfSlot, primarySlot, dependencyResolverFn, loadingSlot, placeholderSlot, errorSlot, loadingConfig, placeholderConfig, enableTimerScheduling, sourceSpan, flags) {
|
|
23027
23043
|
const args = [
|
|
23028
|
-
literal
|
|
23029
|
-
literal
|
|
23030
|
-
dependencyResolverFn ?? literal
|
|
23031
|
-
literal
|
|
23032
|
-
literal
|
|
23033
|
-
literal
|
|
23034
|
-
loadingConfig ?? literal
|
|
23035
|
-
placeholderConfig ?? literal
|
|
23036
|
-
enableTimerScheduling ? importExpr(Identifiers.deferEnableTimerScheduling) : literal
|
|
23037
|
-
literal
|
|
23044
|
+
literal(selfSlot),
|
|
23045
|
+
literal(primarySlot),
|
|
23046
|
+
dependencyResolverFn ?? literal(null),
|
|
23047
|
+
literal(loadingSlot),
|
|
23048
|
+
literal(placeholderSlot),
|
|
23049
|
+
literal(errorSlot),
|
|
23050
|
+
loadingConfig ?? literal(null),
|
|
23051
|
+
placeholderConfig ?? literal(null),
|
|
23052
|
+
enableTimerScheduling ? importExpr(Identifiers.deferEnableTimerScheduling) : literal(null),
|
|
23053
|
+
literal(flags),
|
|
23038
23054
|
];
|
|
23039
23055
|
let expr;
|
|
23040
23056
|
while ((expr = args[args.length - 1]) !== null &&
|
|
@@ -23107,45 +23123,45 @@ function deferOn(trigger, args, modifier, sourceSpan) {
|
|
|
23107
23123
|
if (instructionToCall === undefined) {
|
|
23108
23124
|
throw new Error(`Unable to determine instruction for trigger ${trigger}`);
|
|
23109
23125
|
}
|
|
23110
|
-
return call(instructionToCall, args.map((a) => literal
|
|
23126
|
+
return call(instructionToCall, args.map((a) => literal(a)), sourceSpan);
|
|
23111
23127
|
}
|
|
23112
23128
|
function projectionDef(def) {
|
|
23113
23129
|
return call(Identifiers.projectionDef, def ? [def] : [], null);
|
|
23114
23130
|
}
|
|
23115
23131
|
function projection(slot, projectionSlotIndex, attributes, fallbackFnName, fallbackDecls, fallbackVars, sourceSpan) {
|
|
23116
|
-
const args = [literal
|
|
23132
|
+
const args = [literal(slot)];
|
|
23117
23133
|
if (projectionSlotIndex !== 0 || attributes !== null || fallbackFnName !== null) {
|
|
23118
|
-
args.push(literal
|
|
23134
|
+
args.push(literal(projectionSlotIndex));
|
|
23119
23135
|
if (attributes !== null) {
|
|
23120
23136
|
args.push(attributes);
|
|
23121
23137
|
}
|
|
23122
23138
|
if (fallbackFnName !== null) {
|
|
23123
23139
|
if (attributes === null) {
|
|
23124
|
-
args.push(literal
|
|
23140
|
+
args.push(literal(null));
|
|
23125
23141
|
}
|
|
23126
|
-
args.push(variable(fallbackFnName), literal
|
|
23142
|
+
args.push(variable(fallbackFnName), literal(fallbackDecls), literal(fallbackVars));
|
|
23127
23143
|
}
|
|
23128
23144
|
}
|
|
23129
23145
|
return call(Identifiers.projection, args, sourceSpan);
|
|
23130
23146
|
}
|
|
23131
23147
|
function i18nStart(slot, constIndex, subTemplateIndex, sourceSpan) {
|
|
23132
|
-
const args = [literal
|
|
23148
|
+
const args = [literal(slot), literal(constIndex)];
|
|
23133
23149
|
if (subTemplateIndex !== null) {
|
|
23134
|
-
args.push(literal
|
|
23150
|
+
args.push(literal(subTemplateIndex));
|
|
23135
23151
|
}
|
|
23136
23152
|
return call(Identifiers.i18nStart, args, sourceSpan);
|
|
23137
23153
|
}
|
|
23138
23154
|
function conditionalCreate(slot, templateFnRef, decls, vars, tag, constIndex, localRefs, sourceSpan) {
|
|
23139
23155
|
const args = [
|
|
23140
|
-
literal
|
|
23156
|
+
literal(slot),
|
|
23141
23157
|
templateFnRef,
|
|
23142
|
-
literal
|
|
23143
|
-
literal
|
|
23144
|
-
literal
|
|
23145
|
-
literal
|
|
23158
|
+
literal(decls),
|
|
23159
|
+
literal(vars),
|
|
23160
|
+
literal(tag),
|
|
23161
|
+
literal(constIndex),
|
|
23146
23162
|
];
|
|
23147
23163
|
if (localRefs !== null) {
|
|
23148
|
-
args.push(literal
|
|
23164
|
+
args.push(literal(localRefs));
|
|
23149
23165
|
args.push(importExpr(Identifiers.templateRefExtractor));
|
|
23150
23166
|
}
|
|
23151
23167
|
while (args[args.length - 1].isEquivalent(NULL_EXPR)) {
|
|
@@ -23155,15 +23171,15 @@ function conditionalCreate(slot, templateFnRef, decls, vars, tag, constIndex, lo
|
|
|
23155
23171
|
}
|
|
23156
23172
|
function conditionalBranchCreate(slot, templateFnRef, decls, vars, tag, constIndex, localRefs, sourceSpan) {
|
|
23157
23173
|
const args = [
|
|
23158
|
-
literal
|
|
23174
|
+
literal(slot),
|
|
23159
23175
|
templateFnRef,
|
|
23160
|
-
literal
|
|
23161
|
-
literal
|
|
23162
|
-
literal
|
|
23163
|
-
literal
|
|
23176
|
+
literal(decls),
|
|
23177
|
+
literal(vars),
|
|
23178
|
+
literal(tag),
|
|
23179
|
+
literal(constIndex),
|
|
23164
23180
|
];
|
|
23165
23181
|
if (localRefs !== null) {
|
|
23166
|
-
args.push(literal
|
|
23182
|
+
args.push(literal(localRefs));
|
|
23167
23183
|
args.push(importExpr(Identifiers.templateRefExtractor));
|
|
23168
23184
|
}
|
|
23169
23185
|
while (args[args.length - 1].isEquivalent(NULL_EXPR)) {
|
|
@@ -23173,23 +23189,23 @@ function conditionalBranchCreate(slot, templateFnRef, decls, vars, tag, constInd
|
|
|
23173
23189
|
}
|
|
23174
23190
|
function repeaterCreate(slot, viewFnName, decls, vars, tag, constIndex, trackByFn, trackByUsesComponentInstance, emptyViewFnName, emptyDecls, emptyVars, emptyTag, emptyConstIndex, sourceSpan) {
|
|
23175
23191
|
const args = [
|
|
23176
|
-
literal
|
|
23192
|
+
literal(slot),
|
|
23177
23193
|
variable(viewFnName),
|
|
23178
|
-
literal
|
|
23179
|
-
literal
|
|
23180
|
-
literal
|
|
23181
|
-
literal
|
|
23194
|
+
literal(decls),
|
|
23195
|
+
literal(vars),
|
|
23196
|
+
literal(tag),
|
|
23197
|
+
literal(constIndex),
|
|
23182
23198
|
trackByFn,
|
|
23183
23199
|
];
|
|
23184
23200
|
if (trackByUsesComponentInstance || emptyViewFnName !== null) {
|
|
23185
|
-
args.push(literal
|
|
23201
|
+
args.push(literal(trackByUsesComponentInstance));
|
|
23186
23202
|
if (emptyViewFnName !== null) {
|
|
23187
|
-
args.push(variable(emptyViewFnName), literal
|
|
23203
|
+
args.push(variable(emptyViewFnName), literal(emptyDecls), literal(emptyVars));
|
|
23188
23204
|
if (emptyTag !== null || emptyConstIndex !== null) {
|
|
23189
|
-
args.push(literal
|
|
23205
|
+
args.push(literal(emptyTag));
|
|
23190
23206
|
}
|
|
23191
23207
|
if (emptyConstIndex !== null) {
|
|
23192
|
-
args.push(literal
|
|
23208
|
+
args.push(literal(emptyConstIndex));
|
|
23193
23209
|
}
|
|
23194
23210
|
}
|
|
23195
23211
|
}
|
|
@@ -23208,18 +23224,18 @@ function deferWhen(modifier, expr, sourceSpan) {
|
|
|
23208
23224
|
return call(Identifiers.deferWhen, [expr], sourceSpan);
|
|
23209
23225
|
}
|
|
23210
23226
|
function declareLet(slot, sourceSpan) {
|
|
23211
|
-
return call(Identifiers.declareLet, [literal
|
|
23227
|
+
return call(Identifiers.declareLet, [literal(slot)], sourceSpan);
|
|
23212
23228
|
}
|
|
23213
23229
|
function storeLet(value, sourceSpan) {
|
|
23214
23230
|
return importExpr(Identifiers.storeLet).callFn([value], sourceSpan);
|
|
23215
23231
|
}
|
|
23216
23232
|
function readContextLet(slot) {
|
|
23217
|
-
return importExpr(Identifiers.readContextLet).callFn([literal
|
|
23233
|
+
return importExpr(Identifiers.readContextLet).callFn([literal(slot)]);
|
|
23218
23234
|
}
|
|
23219
23235
|
function i18n(slot, constIndex, subTemplateIndex, sourceSpan) {
|
|
23220
|
-
const args = [literal
|
|
23236
|
+
const args = [literal(slot), literal(constIndex)];
|
|
23221
23237
|
if (subTemplateIndex) {
|
|
23222
|
-
args.push(literal
|
|
23238
|
+
args.push(literal(subTemplateIndex));
|
|
23223
23239
|
}
|
|
23224
23240
|
return call(Identifiers.i18n, args, sourceSpan);
|
|
23225
23241
|
}
|
|
@@ -23227,21 +23243,21 @@ function i18nEnd(endSourceSpan) {
|
|
|
23227
23243
|
return call(Identifiers.i18nEnd, [], endSourceSpan);
|
|
23228
23244
|
}
|
|
23229
23245
|
function i18nAttributes(slot, i18nAttributesConfig) {
|
|
23230
|
-
const args = [literal
|
|
23246
|
+
const args = [literal(slot), literal(i18nAttributesConfig)];
|
|
23231
23247
|
return call(Identifiers.i18nAttributes, args, null);
|
|
23232
23248
|
}
|
|
23233
23249
|
function property(name, expression, sanitizer, sourceSpan) {
|
|
23234
23250
|
return propertyBase(Identifiers.property, name, expression, sanitizer, sourceSpan);
|
|
23235
23251
|
}
|
|
23236
23252
|
function twoWayProperty(name, expression, sanitizer, sourceSpan) {
|
|
23237
|
-
const args = [literal
|
|
23253
|
+
const args = [literal(name), expression];
|
|
23238
23254
|
if (sanitizer !== null) {
|
|
23239
23255
|
args.push(sanitizer);
|
|
23240
23256
|
}
|
|
23241
23257
|
return call(Identifiers.twoWayProperty, args, sourceSpan);
|
|
23242
23258
|
}
|
|
23243
23259
|
function attribute(name, expression, sanitizer, namespace, sourceSpan) {
|
|
23244
|
-
const args = [literal
|
|
23260
|
+
const args = [literal(name)];
|
|
23245
23261
|
if (expression instanceof Interpolation) {
|
|
23246
23262
|
args.push(interpolationToExpression(expression, sourceSpan));
|
|
23247
23263
|
}
|
|
@@ -23249,15 +23265,15 @@ function attribute(name, expression, sanitizer, namespace, sourceSpan) {
|
|
|
23249
23265
|
args.push(expression);
|
|
23250
23266
|
}
|
|
23251
23267
|
if (sanitizer !== null || namespace !== null) {
|
|
23252
|
-
args.push(sanitizer ?? literal
|
|
23268
|
+
args.push(sanitizer ?? literal(null));
|
|
23253
23269
|
}
|
|
23254
23270
|
if (namespace !== null) {
|
|
23255
|
-
args.push(literal
|
|
23271
|
+
args.push(literal(namespace));
|
|
23256
23272
|
}
|
|
23257
23273
|
return call(Identifiers.attribute, args, null);
|
|
23258
23274
|
}
|
|
23259
23275
|
function styleProp(name, expression, unit, sourceSpan) {
|
|
23260
|
-
const args = [literal
|
|
23276
|
+
const args = [literal(name)];
|
|
23261
23277
|
if (expression instanceof Interpolation) {
|
|
23262
23278
|
args.push(interpolationToExpression(expression, sourceSpan));
|
|
23263
23279
|
}
|
|
@@ -23265,12 +23281,12 @@ function styleProp(name, expression, unit, sourceSpan) {
|
|
|
23265
23281
|
args.push(expression);
|
|
23266
23282
|
}
|
|
23267
23283
|
if (unit !== null) {
|
|
23268
|
-
args.push(literal
|
|
23284
|
+
args.push(literal(unit));
|
|
23269
23285
|
}
|
|
23270
23286
|
return call(Identifiers.styleProp, args, sourceSpan);
|
|
23271
23287
|
}
|
|
23272
23288
|
function classProp(name, expression, sourceSpan) {
|
|
23273
|
-
return call(Identifiers.classProp, [literal
|
|
23289
|
+
return call(Identifiers.classProp, [literal(name), expression], sourceSpan);
|
|
23274
23290
|
}
|
|
23275
23291
|
function styleMap(expression, sourceSpan) {
|
|
23276
23292
|
const value = expression instanceof Interpolation
|
|
@@ -23305,7 +23321,7 @@ function domElementContainerEnd() {
|
|
|
23305
23321
|
return call(Identifiers.domElementContainerEnd, [], null);
|
|
23306
23322
|
}
|
|
23307
23323
|
function domListener(name, handlerFn, eventTargetResolver, sourceSpan) {
|
|
23308
|
-
const args = [literal
|
|
23324
|
+
const args = [literal(name), handlerFn];
|
|
23309
23325
|
if (eventTargetResolver !== null) {
|
|
23310
23326
|
args.push(importExpr(eventTargetResolver));
|
|
23311
23327
|
}
|
|
@@ -23325,10 +23341,10 @@ function pipeBind(slot, varOffset, args) {
|
|
|
23325
23341
|
throw new Error(`pipeBind() argument count out of bounds`);
|
|
23326
23342
|
}
|
|
23327
23343
|
const instruction = PIPE_BINDINGS[args.length - 1];
|
|
23328
|
-
return importExpr(instruction).callFn([literal
|
|
23344
|
+
return importExpr(instruction).callFn([literal(slot), literal(varOffset), ...args]);
|
|
23329
23345
|
}
|
|
23330
23346
|
function pipeBindV(slot, varOffset, args) {
|
|
23331
|
-
return importExpr(Identifiers.pipeBindV).callFn([literal
|
|
23347
|
+
return importExpr(Identifiers.pipeBindV).callFn([literal(slot), literal(varOffset), args]);
|
|
23332
23348
|
}
|
|
23333
23349
|
function textInterpolate(strings, expressions, sourceSpan) {
|
|
23334
23350
|
const interpolationArgs = collateInterpolationArgs(strings, expressions);
|
|
@@ -23338,19 +23354,19 @@ function i18nExp(expr, sourceSpan) {
|
|
|
23338
23354
|
return call(Identifiers.i18nExp, [expr], sourceSpan);
|
|
23339
23355
|
}
|
|
23340
23356
|
function i18nApply(slot, sourceSpan) {
|
|
23341
|
-
return call(Identifiers.i18nApply, [literal
|
|
23357
|
+
return call(Identifiers.i18nApply, [literal(slot)], sourceSpan);
|
|
23342
23358
|
}
|
|
23343
23359
|
function domProperty(name, expression, sanitizer, sourceSpan) {
|
|
23344
23360
|
return propertyBase(Identifiers.domProperty, name, expression, sanitizer, sourceSpan);
|
|
23345
23361
|
}
|
|
23346
23362
|
function syntheticHostProperty(name, expression, sourceSpan) {
|
|
23347
|
-
return call(Identifiers.syntheticHostProperty, [literal
|
|
23363
|
+
return call(Identifiers.syntheticHostProperty, [literal(name), expression], sourceSpan);
|
|
23348
23364
|
}
|
|
23349
23365
|
function pureFunction(varOffset, fn, args) {
|
|
23350
|
-
return callVariadicInstructionExpr(PURE_FUNCTION_CONFIG, [literal
|
|
23366
|
+
return callVariadicInstructionExpr(PURE_FUNCTION_CONFIG, [literal(varOffset), fn], args, [], null);
|
|
23351
23367
|
}
|
|
23352
23368
|
function attachSourceLocation(templatePath, locations) {
|
|
23353
|
-
return call(Identifiers.attachSourceLocations, [literal
|
|
23369
|
+
return call(Identifiers.attachSourceLocations, [literal(templatePath), locations], null);
|
|
23354
23370
|
}
|
|
23355
23371
|
/**
|
|
23356
23372
|
* Collates the string an expression arguments for an interpolation instruction.
|
|
@@ -23366,10 +23382,10 @@ function collateInterpolationArgs(strings, expressions) {
|
|
|
23366
23382
|
else {
|
|
23367
23383
|
let idx;
|
|
23368
23384
|
for (idx = 0; idx < expressions.length; idx++) {
|
|
23369
|
-
interpolationArgs.push(literal
|
|
23385
|
+
interpolationArgs.push(literal(strings[idx]), expressions[idx]);
|
|
23370
23386
|
}
|
|
23371
23387
|
// idx points at the last string.
|
|
23372
|
-
interpolationArgs.push(literal
|
|
23388
|
+
interpolationArgs.push(literal(strings[idx]));
|
|
23373
23389
|
}
|
|
23374
23390
|
return interpolationArgs;
|
|
23375
23391
|
}
|
|
@@ -23484,6 +23500,18 @@ const GLOBAL_TARGET_RESOLVERS = new Map([
|
|
|
23484
23500
|
['document', Identifiers.resolveDocument],
|
|
23485
23501
|
['body', Identifiers.resolveBody],
|
|
23486
23502
|
]);
|
|
23503
|
+
/**
|
|
23504
|
+
* DOM properties that need to be remapped on the compiler side.
|
|
23505
|
+
* Note: this mapping has to be kept in sync with the equally named mapping in the runtime.
|
|
23506
|
+
*/
|
|
23507
|
+
const DOM_PROPERTY_REMAPPING = new Map([
|
|
23508
|
+
['class', 'className'],
|
|
23509
|
+
['for', 'htmlFor'],
|
|
23510
|
+
['formaction', 'formAction'],
|
|
23511
|
+
['innerHtml', 'innerHTML'],
|
|
23512
|
+
['readonly', 'readOnly'],
|
|
23513
|
+
['tabindex', 'tabIndex'],
|
|
23514
|
+
]);
|
|
23487
23515
|
/**
|
|
23488
23516
|
* Compiles semantic operations across all views and generates output `o.Statement`s with actual
|
|
23489
23517
|
* runtime calls in their place.
|
|
@@ -23587,9 +23615,9 @@ function reifyCreateOperations(unit, ops) {
|
|
|
23587
23615
|
}
|
|
23588
23616
|
OpList.replace(op, unit.job.mode === TemplateCompilationMode.DomOnly &&
|
|
23589
23617
|
!op.hostListener &&
|
|
23590
|
-
!op.
|
|
23618
|
+
!op.isLegacyAnimationListener
|
|
23591
23619
|
? domListener(op.name, listenerFn, eventTargetResolver, op.sourceSpan)
|
|
23592
|
-
: listener(op.name, listenerFn, eventTargetResolver, op.hostListener && op.
|
|
23620
|
+
: listener(op.name, listenerFn, eventTargetResolver, op.hostListener && op.isLegacyAnimationListener, op.sourceSpan));
|
|
23593
23621
|
break;
|
|
23594
23622
|
case OpKind.TwoWayListener:
|
|
23595
23623
|
OpList.replace(op, twoWayListener(op.name, reifyListenerHandler(unit, op.handlerFnName, op.handlerOps, true), op.sourceSpan));
|
|
@@ -23731,10 +23759,10 @@ function reifyCreateOperations(unit, ops) {
|
|
|
23731
23759
|
throw new Error('No slot was assigned for source location');
|
|
23732
23760
|
}
|
|
23733
23761
|
return literalArr([
|
|
23734
|
-
literal
|
|
23735
|
-
literal
|
|
23736
|
-
literal
|
|
23737
|
-
literal
|
|
23762
|
+
literal(targetSlot.slot),
|
|
23763
|
+
literal(offset),
|
|
23764
|
+
literal(line),
|
|
23765
|
+
literal(column),
|
|
23738
23766
|
]);
|
|
23739
23767
|
}));
|
|
23740
23768
|
OpList.replace(op, attachSourceLocation(op.templatePath, locationsLiteral));
|
|
@@ -23755,8 +23783,8 @@ function reifyUpdateOperations(unit, ops) {
|
|
|
23755
23783
|
OpList.replace(op, advance(op.delta, op.sourceSpan));
|
|
23756
23784
|
break;
|
|
23757
23785
|
case OpKind.Property:
|
|
23758
|
-
OpList.replace(op, unit.job.mode === TemplateCompilationMode.DomOnly && !op.
|
|
23759
|
-
? domProperty(op.name, op.expression, op.sanitizer, op.sourceSpan)
|
|
23786
|
+
OpList.replace(op, unit.job.mode === TemplateCompilationMode.DomOnly && !op.isLegacyAnimationTrigger
|
|
23787
|
+
? domProperty(DOM_PROPERTY_REMAPPING.get(op.name) ?? op.name, op.expression, op.sanitizer, op.sourceSpan)
|
|
23760
23788
|
: property(op.name, op.expression, op.sanitizer, op.sourceSpan));
|
|
23761
23789
|
break;
|
|
23762
23790
|
case OpKind.TwoWayProperty:
|
|
@@ -23791,11 +23819,11 @@ function reifyUpdateOperations(unit, ops) {
|
|
|
23791
23819
|
throw new Error('not yet handled');
|
|
23792
23820
|
}
|
|
23793
23821
|
else {
|
|
23794
|
-
if (op.
|
|
23822
|
+
if (op.isLegacyAnimationTrigger) {
|
|
23795
23823
|
OpList.replace(op, syntheticHostProperty(op.name, op.expression, op.sourceSpan));
|
|
23796
23824
|
}
|
|
23797
23825
|
else {
|
|
23798
|
-
OpList.replace(op, domProperty(op.name, op.expression, op.sanitizer, op.sourceSpan));
|
|
23826
|
+
OpList.replace(op, domProperty(DOM_PROPERTY_REMAPPING.get(op.name) ?? op.name, op.expression, op.sanitizer, op.sourceSpan));
|
|
23799
23827
|
}
|
|
23800
23828
|
}
|
|
23801
23829
|
break;
|
|
@@ -23876,7 +23904,7 @@ function reifyIrExpression(expr) {
|
|
|
23876
23904
|
case ExpressionKind.PipeBindingVariadic:
|
|
23877
23905
|
return pipeBindV(expr.targetSlot.slot, expr.varOffset, expr.args);
|
|
23878
23906
|
case ExpressionKind.SlotLiteralExpr:
|
|
23879
|
-
return literal
|
|
23907
|
+
return literal(expr.slot.slot);
|
|
23880
23908
|
case ExpressionKind.ContextLetReference:
|
|
23881
23909
|
return readContextLet(expr.targetSlot.slot);
|
|
23882
23910
|
case ExpressionKind.StoreLet:
|
|
@@ -24010,7 +24038,7 @@ function removeIllegalLetReferences(job) {
|
|
|
24010
24038
|
const name = op.variable.identifier;
|
|
24011
24039
|
let current = op;
|
|
24012
24040
|
while (current && current.kind !== OpKind.ListEnd) {
|
|
24013
|
-
transformExpressionsInOp(current, (expr) => expr instanceof LexicalReadExpr && expr.name === name ? literal
|
|
24041
|
+
transformExpressionsInOp(current, (expr) => expr instanceof LexicalReadExpr && expr.name === name ? literal(undefined) : expr, VisitorContextFlag.None);
|
|
24014
24042
|
current = current.prev;
|
|
24015
24043
|
}
|
|
24016
24044
|
}
|
|
@@ -25948,7 +25976,7 @@ function maybeGenerateRfBlock(flag, statements) {
|
|
|
25948
25976
|
return [];
|
|
25949
25977
|
}
|
|
25950
25978
|
return [
|
|
25951
|
-
ifStmt(new BinaryOperatorExpr(BinaryOperator.BitwiseAnd, variable('rf'), literal
|
|
25979
|
+
ifStmt(new BinaryOperatorExpr(BinaryOperator.BitwiseAnd, variable('rf'), literal(flag)), statements),
|
|
25952
25980
|
];
|
|
25953
25981
|
}
|
|
25954
25982
|
function emitHostBindingFunction(job) {
|
|
@@ -26013,8 +26041,8 @@ function ingestHostBinding(input, bindingParser, constantPool) {
|
|
|
26013
26041
|
property.name = property.name.substring('attr.'.length);
|
|
26014
26042
|
bindingKind = BindingKind.Attribute;
|
|
26015
26043
|
}
|
|
26016
|
-
if (property.
|
|
26017
|
-
bindingKind = BindingKind.
|
|
26044
|
+
if (property.isLegacyAnimation) {
|
|
26045
|
+
bindingKind = BindingKind.LegacyAnimation;
|
|
26018
26046
|
}
|
|
26019
26047
|
const securityContexts = bindingParser
|
|
26020
26048
|
.calcPossibleSecurityContexts(input.componentSelector, property.name, bindingKind === BindingKind.Attribute)
|
|
@@ -26056,7 +26084,7 @@ function ingestHostAttribute(job, name, value, securityContexts) {
|
|
|
26056
26084
|
job.root.update.push(attrBinding);
|
|
26057
26085
|
}
|
|
26058
26086
|
function ingestHostEvent(job, event) {
|
|
26059
|
-
const [phase, target] = event.type !== exports.ParsedEventType.
|
|
26087
|
+
const [phase, target] = event.type !== exports.ParsedEventType.LegacyAnimation
|
|
26060
26088
|
? [null, event.targetOrPhase]
|
|
26061
26089
|
: [event.targetOrPhase, null];
|
|
26062
26090
|
const eventBinding = createListenerOp(job.root.xref, new SlotHandle(), event.name, null, makeListenerHandlerOps(job.root, event.handler, event.handlerSpan), phase, target, true, event.sourceSpan);
|
|
@@ -26196,7 +26224,7 @@ function ingestContent(unit, content) {
|
|
|
26196
26224
|
const op = createProjectionOp(id, content.selector, content.i18n, fallbackView?.xref ?? null, content.sourceSpan);
|
|
26197
26225
|
for (const attr of content.attributes) {
|
|
26198
26226
|
const securityContext = domSchema.securityContext(content.name, attr.name, true);
|
|
26199
|
-
unit.update.push(createBindingOp(op.xref, BindingKind.Attribute, attr.name, literal
|
|
26227
|
+
unit.update.push(createBindingOp(op.xref, BindingKind.Attribute, attr.name, literal(attr.value), null, securityContext, true, false, null, asMessage(attr.i18n), attr.sourceSpan));
|
|
26200
26228
|
}
|
|
26201
26229
|
unit.create.push(op);
|
|
26202
26230
|
}
|
|
@@ -26522,13 +26550,13 @@ function getComputedForLoopVariableExpression(variable, indexName, countName) {
|
|
|
26522
26550
|
case '$count':
|
|
26523
26551
|
return new LexicalReadExpr(countName);
|
|
26524
26552
|
case '$first':
|
|
26525
|
-
return new LexicalReadExpr(indexName).identical(literal
|
|
26553
|
+
return new LexicalReadExpr(indexName).identical(literal(0));
|
|
26526
26554
|
case '$last':
|
|
26527
|
-
return new LexicalReadExpr(indexName).identical(new LexicalReadExpr(countName).minus(literal
|
|
26555
|
+
return new LexicalReadExpr(indexName).identical(new LexicalReadExpr(countName).minus(literal(1)));
|
|
26528
26556
|
case '$even':
|
|
26529
|
-
return new LexicalReadExpr(indexName).modulo(literal
|
|
26557
|
+
return new LexicalReadExpr(indexName).modulo(literal(2)).identical(literal(0));
|
|
26530
26558
|
case '$odd':
|
|
26531
|
-
return new LexicalReadExpr(indexName).modulo(literal
|
|
26559
|
+
return new LexicalReadExpr(indexName).modulo(literal(2)).notIdentical(literal(0));
|
|
26532
26560
|
default:
|
|
26533
26561
|
throw new Error(`AssertionError: unknown @for loop variable ${variable.value}`);
|
|
26534
26562
|
}
|
|
@@ -26564,7 +26592,7 @@ function convertAst(ast, job, baseSourceSpan) {
|
|
|
26564
26592
|
}
|
|
26565
26593
|
}
|
|
26566
26594
|
else if (ast instanceof LiteralPrimitive) {
|
|
26567
|
-
return literal
|
|
26595
|
+
return literal(ast.value, undefined, convertSourceSpan(ast.span, baseSourceSpan));
|
|
26568
26596
|
}
|
|
26569
26597
|
else if (ast instanceof Unary) {
|
|
26570
26598
|
switch (ast.operator) {
|
|
@@ -26577,7 +26605,7 @@ function convertAst(ast, job, baseSourceSpan) {
|
|
|
26577
26605
|
}
|
|
26578
26606
|
}
|
|
26579
26607
|
else if (ast instanceof Binary) {
|
|
26580
|
-
const operator = BINARY_OPERATORS$
|
|
26608
|
+
const operator = BINARY_OPERATORS$1.get(ast.operation);
|
|
26581
26609
|
if (operator === undefined) {
|
|
26582
26610
|
throw new Error(`AssertionError: unknown binary operator ${ast.operation}`);
|
|
26583
26611
|
}
|
|
@@ -26670,7 +26698,7 @@ function convertAstWithInterpolation(job, value, i18nMeta, sourceSpan) {
|
|
|
26670
26698
|
expression = convertAst(value, job, null);
|
|
26671
26699
|
}
|
|
26672
26700
|
else {
|
|
26673
|
-
expression = literal
|
|
26701
|
+
expression = literal(value);
|
|
26674
26702
|
}
|
|
26675
26703
|
return expression;
|
|
26676
26704
|
}
|
|
@@ -26681,7 +26709,7 @@ const BINDING_KINDS = new Map([
|
|
|
26681
26709
|
[exports.BindingType.Attribute, BindingKind.Attribute],
|
|
26682
26710
|
[exports.BindingType.Class, BindingKind.ClassName],
|
|
26683
26711
|
[exports.BindingType.Style, BindingKind.StyleProperty],
|
|
26684
|
-
[exports.BindingType.
|
|
26712
|
+
[exports.BindingType.LegacyAnimation, BindingKind.LegacyAnimation],
|
|
26685
26713
|
]);
|
|
26686
26714
|
/**
|
|
26687
26715
|
* Checks whether the given template is a plain ng-template (as opposed to another kind of template
|
|
@@ -26740,7 +26768,7 @@ function ingestElementBindings(unit, op, element) {
|
|
|
26740
26768
|
unit.create.push(bindings.filter((b) => b?.kind === OpKind.ExtractedAttribute));
|
|
26741
26769
|
unit.update.push(bindings.filter((b) => b?.kind === OpKind.Binding));
|
|
26742
26770
|
for (const output of element.outputs) {
|
|
26743
|
-
if (output.type === exports.ParsedEventType.
|
|
26771
|
+
if (output.type === exports.ParsedEventType.LegacyAnimation && output.phase === null) {
|
|
26744
26772
|
throw Error('Animation listener should have a phase');
|
|
26745
26773
|
}
|
|
26746
26774
|
if (output.type === exports.ParsedEventType.TwoWay) {
|
|
@@ -26783,7 +26811,7 @@ function ingestTemplateBindings(unit, op, template, templateKind) {
|
|
|
26783
26811
|
unit.create.push(bindings.filter((b) => b?.kind === OpKind.ExtractedAttribute));
|
|
26784
26812
|
unit.update.push(bindings.filter((b) => b?.kind === OpKind.Binding));
|
|
26785
26813
|
for (const output of template.outputs) {
|
|
26786
|
-
if (output.type === exports.ParsedEventType.
|
|
26814
|
+
if (output.type === exports.ParsedEventType.LegacyAnimation && output.phase === null) {
|
|
26787
26815
|
throw Error('Animation listener should have a phase');
|
|
26788
26816
|
}
|
|
26789
26817
|
if (templateKind === TemplateKind.NgTemplate) {
|
|
@@ -26795,7 +26823,7 @@ function ingestTemplateBindings(unit, op, template, templateKind) {
|
|
|
26795
26823
|
}
|
|
26796
26824
|
}
|
|
26797
26825
|
if (templateKind === TemplateKind.Structural &&
|
|
26798
|
-
output.type !== exports.ParsedEventType.
|
|
26826
|
+
output.type !== exports.ParsedEventType.LegacyAnimation) {
|
|
26799
26827
|
// Animation bindings are excluded from the structural template's const array.
|
|
26800
26828
|
const securityContext = domSchema.securityContext(NG_TEMPLATE_TAG_NAME, output.name, false);
|
|
26801
26829
|
unit.create.push(createExtractedAttributeOp(op.xref, BindingKind.Property, null, output.name, null, null, null, securityContext));
|
|
@@ -26853,7 +26881,8 @@ function createTemplateBinding(view, xref, type, name, value, unit, securityCont
|
|
|
26853
26881
|
return createExtractedAttributeOp(xref, BindingKind.TwoWayProperty, null, name, null, null, i18nMessage, securityContext);
|
|
26854
26882
|
}
|
|
26855
26883
|
}
|
|
26856
|
-
if (!isTextBinding &&
|
|
26884
|
+
if (!isTextBinding &&
|
|
26885
|
+
(type === exports.BindingType.Attribute || type === exports.BindingType.LegacyAnimation)) {
|
|
26857
26886
|
// Again, this binding doesn't really target the ng-template; it actually targets the element
|
|
26858
26887
|
// inside the structural template. In the case of non-text attribute or animation bindings,
|
|
26859
26888
|
// the binding doesn't even show up on the ng-template const array, so we just skip it
|
|
@@ -27012,13 +27041,13 @@ function ingestControlFlowInsertionPoint(unit, xref, node) {
|
|
|
27012
27041
|
// Collect the static attributes for content projection purposes.
|
|
27013
27042
|
for (const attr of root.attributes) {
|
|
27014
27043
|
const securityContext = domSchema.securityContext(NG_TEMPLATE_TAG_NAME, attr.name, true);
|
|
27015
|
-
unit.update.push(createBindingOp(xref, BindingKind.Attribute, attr.name, literal
|
|
27044
|
+
unit.update.push(createBindingOp(xref, BindingKind.Attribute, attr.name, literal(attr.value), null, securityContext, true, false, null, asMessage(attr.i18n), attr.sourceSpan));
|
|
27016
27045
|
}
|
|
27017
27046
|
// Also collect the inputs since they participate in content projection as well.
|
|
27018
27047
|
// Note that TDB used to collect the outputs as well, but it wasn't passing them into
|
|
27019
27048
|
// the template instruction. Here we just don't collect them.
|
|
27020
27049
|
for (const attr of root.inputs) {
|
|
27021
|
-
if (attr.type !== exports.BindingType.
|
|
27050
|
+
if (attr.type !== exports.BindingType.LegacyAnimation && attr.type !== exports.BindingType.Attribute) {
|
|
27022
27051
|
const securityContext = domSchema.securityContext(NG_TEMPLATE_TAG_NAME, attr.name, true);
|
|
27023
27052
|
unit.create.push(createExtractedAttributeOp(xref, BindingKind.Property, null, attr.name, null, null, null, securityContext));
|
|
27024
27053
|
}
|
|
@@ -27052,7 +27081,7 @@ function getTemplateSourceLocationsEnabled() {
|
|
|
27052
27081
|
|
|
27053
27082
|
// if (rf & flags) { .. }
|
|
27054
27083
|
function renderFlagCheckIfStmt(flags, statements) {
|
|
27055
|
-
return ifStmt(variable(RENDER_FLAGS).bitwiseAnd(literal
|
|
27084
|
+
return ifStmt(variable(RENDER_FLAGS).bitwiseAnd(literal(flags), null), statements);
|
|
27056
27085
|
}
|
|
27057
27086
|
/**
|
|
27058
27087
|
* Translates query flags into `TQueryFlags` type in
|
|
@@ -27071,7 +27100,7 @@ function getQueryPredicate(query, constantPool) {
|
|
|
27071
27100
|
// Each item in predicates array may contain strings with comma-separated refs
|
|
27072
27101
|
// (for ex. 'ref, ref1, ..., refN'), thus we extract individual refs and store them
|
|
27073
27102
|
// as separate array entities
|
|
27074
|
-
const selectors = selector.split(',').map((token) => literal
|
|
27103
|
+
const selectors = selector.split(',').map((token) => literal(token.trim()));
|
|
27075
27104
|
predicate.push(...selectors);
|
|
27076
27105
|
});
|
|
27077
27106
|
return constantPool.getConstLiteral(literalArr(predicate), true);
|
|
@@ -27095,7 +27124,7 @@ function createQueryCreateCall(query, constantPool, queryTypeFns, prependParams)
|
|
|
27095
27124
|
if (query.isSignal) {
|
|
27096
27125
|
parameters.push(new ReadPropExpr(variable(CONTEXT_NAME), query.propertyName));
|
|
27097
27126
|
}
|
|
27098
|
-
parameters.push(getQueryPredicate(query, constantPool), literal
|
|
27127
|
+
parameters.push(getQueryPredicate(query, constantPool), literal(toQueryFlags(query)));
|
|
27099
27128
|
if (query.read) {
|
|
27100
27129
|
parameters.push(query.read);
|
|
27101
27130
|
}
|
|
@@ -27132,7 +27161,7 @@ function collapseAdvanceStatements(statements) {
|
|
|
27132
27161
|
const flushAdvanceCount = () => {
|
|
27133
27162
|
if (advanceCollapseCount > 0) {
|
|
27134
27163
|
result.unshift(importExpr(Identifiers.queryAdvance)
|
|
27135
|
-
.callFn(advanceCollapseCount === 1 ? [] : [literal
|
|
27164
|
+
.callFn(advanceCollapseCount === 1 ? [] : [literal(advanceCollapseCount)])
|
|
27136
27165
|
.toStmt());
|
|
27137
27166
|
advanceCollapseCount = 0;
|
|
27138
27167
|
}
|
|
@@ -27233,7 +27262,7 @@ const ATTRIBUTE_PREFIX = 'attr';
|
|
|
27233
27262
|
const CLASS_PREFIX = 'class';
|
|
27234
27263
|
const STYLE_PREFIX = 'style';
|
|
27235
27264
|
const TEMPLATE_ATTR_PREFIX$1 = '*';
|
|
27236
|
-
const
|
|
27265
|
+
const LEGACY_ANIMATE_PROP_PREFIX = 'animate-';
|
|
27237
27266
|
/**
|
|
27238
27267
|
* Parses bindings in templates and in the directive host area.
|
|
27239
27268
|
*/
|
|
@@ -27392,7 +27421,7 @@ class BindingParser {
|
|
|
27392
27421
|
}
|
|
27393
27422
|
}
|
|
27394
27423
|
parseLiteralAttr(name, value, sourceSpan, absoluteOffset, valueSpan, targetMatchableAttrs, targetProps, keySpan) {
|
|
27395
|
-
if (
|
|
27424
|
+
if (isLegacyAnimationLabel(name)) {
|
|
27396
27425
|
name = name.substring(1);
|
|
27397
27426
|
if (keySpan !== undefined) {
|
|
27398
27427
|
keySpan = moveParseSourceSpan(keySpan, new AbsoluteSourceSpan(keySpan.start.offset + 1, keySpan.end.offset));
|
|
@@ -27401,7 +27430,7 @@ class BindingParser {
|
|
|
27401
27430
|
this._reportError(`Assigning animation triggers via @prop="exp" attributes with an expression is invalid.` +
|
|
27402
27431
|
` Use property bindings (e.g. [@prop]="exp") or use an attribute without a value (e.g. @prop) instead.`, sourceSpan, ParseErrorLevel.ERROR);
|
|
27403
27432
|
}
|
|
27404
|
-
this.
|
|
27433
|
+
this._parseLegacyAnimation(name, value, sourceSpan, absoluteOffset, keySpan, valueSpan, targetMatchableAttrs, targetProps);
|
|
27405
27434
|
}
|
|
27406
27435
|
else {
|
|
27407
27436
|
targetProps.push(new ParsedProperty(name, this._exprParser.wrapLiteralPrimitive(value, '', absoluteOffset), ParsedPropertyType.LITERAL_ATTR, sourceSpan, keySpan, valueSpan));
|
|
@@ -27411,23 +27440,23 @@ class BindingParser {
|
|
|
27411
27440
|
if (name.length === 0) {
|
|
27412
27441
|
this._reportError(`Property name is missing in binding`, sourceSpan);
|
|
27413
27442
|
}
|
|
27414
|
-
let
|
|
27415
|
-
if (name.startsWith(
|
|
27416
|
-
|
|
27417
|
-
name = name.substring(
|
|
27443
|
+
let isLegacyAnimationProp = false;
|
|
27444
|
+
if (name.startsWith(LEGACY_ANIMATE_PROP_PREFIX)) {
|
|
27445
|
+
isLegacyAnimationProp = true;
|
|
27446
|
+
name = name.substring(LEGACY_ANIMATE_PROP_PREFIX.length);
|
|
27418
27447
|
if (keySpan !== undefined) {
|
|
27419
|
-
keySpan = moveParseSourceSpan(keySpan, new AbsoluteSourceSpan(keySpan.start.offset +
|
|
27448
|
+
keySpan = moveParseSourceSpan(keySpan, new AbsoluteSourceSpan(keySpan.start.offset + LEGACY_ANIMATE_PROP_PREFIX.length, keySpan.end.offset));
|
|
27420
27449
|
}
|
|
27421
27450
|
}
|
|
27422
|
-
else if (
|
|
27423
|
-
|
|
27451
|
+
else if (isLegacyAnimationLabel(name)) {
|
|
27452
|
+
isLegacyAnimationProp = true;
|
|
27424
27453
|
name = name.substring(1);
|
|
27425
27454
|
if (keySpan !== undefined) {
|
|
27426
27455
|
keySpan = moveParseSourceSpan(keySpan, new AbsoluteSourceSpan(keySpan.start.offset + 1, keySpan.end.offset));
|
|
27427
27456
|
}
|
|
27428
27457
|
}
|
|
27429
|
-
if (
|
|
27430
|
-
this.
|
|
27458
|
+
if (isLegacyAnimationProp) {
|
|
27459
|
+
this._parseLegacyAnimation(name, expression, sourceSpan, absoluteOffset, keySpan, valueSpan, targetMatchableAttrs, targetProps);
|
|
27431
27460
|
}
|
|
27432
27461
|
else {
|
|
27433
27462
|
this._parsePropertyAst(name, this.parseBinding(expression, isHost, valueSpan || sourceSpan, absoluteOffset), isPartOfAssignmentBinding, sourceSpan, keySpan, valueSpan, targetMatchableAttrs, targetProps);
|
|
@@ -27445,7 +27474,7 @@ class BindingParser {
|
|
|
27445
27474
|
targetMatchableAttrs.push([name, ast.source]);
|
|
27446
27475
|
targetProps.push(new ParsedProperty(name, ast, isPartOfAssignmentBinding ? ParsedPropertyType.TWO_WAY : ParsedPropertyType.DEFAULT, sourceSpan, keySpan, valueSpan));
|
|
27447
27476
|
}
|
|
27448
|
-
|
|
27477
|
+
_parseLegacyAnimation(name, expression, sourceSpan, absoluteOffset, keySpan, valueSpan, targetMatchableAttrs, targetProps) {
|
|
27449
27478
|
if (name.length === 0) {
|
|
27450
27479
|
this._reportError('Animation trigger is missing', sourceSpan);
|
|
27451
27480
|
}
|
|
@@ -27454,7 +27483,7 @@ class BindingParser {
|
|
|
27454
27483
|
// states will be applied by angular when the element is attached/detached
|
|
27455
27484
|
const ast = this.parseBinding(expression || 'undefined', false, valueSpan || sourceSpan, absoluteOffset);
|
|
27456
27485
|
targetMatchableAttrs.push([name, ast.source]);
|
|
27457
|
-
targetProps.push(new ParsedProperty(name, ast, ParsedPropertyType.
|
|
27486
|
+
targetProps.push(new ParsedProperty(name, ast, ParsedPropertyType.LEGACY_ANIMATION, sourceSpan, keySpan, valueSpan));
|
|
27458
27487
|
}
|
|
27459
27488
|
parseBinding(value, isHostBinding, sourceSpan, absoluteOffset) {
|
|
27460
27489
|
try {
|
|
@@ -27472,8 +27501,8 @@ class BindingParser {
|
|
|
27472
27501
|
}
|
|
27473
27502
|
}
|
|
27474
27503
|
createBoundElementProperty(elementSelector, boundProp, skipValidation = false, mapPropertyName = true) {
|
|
27475
|
-
if (boundProp.
|
|
27476
|
-
return new BoundElementProperty(boundProp.name, exports.BindingType.
|
|
27504
|
+
if (boundProp.isLegacyAnimation) {
|
|
27505
|
+
return new BoundElementProperty(boundProp.name, exports.BindingType.LegacyAnimation, SecurityContext.NONE, boundProp.expression, null, boundProp.sourceSpan, boundProp.keySpan, boundProp.valueSpan);
|
|
27477
27506
|
}
|
|
27478
27507
|
let unit = null;
|
|
27479
27508
|
let bindingType = undefined;
|
|
@@ -27526,12 +27555,12 @@ class BindingParser {
|
|
|
27526
27555
|
if (name.length === 0) {
|
|
27527
27556
|
this._reportError(`Event name is missing in binding`, sourceSpan);
|
|
27528
27557
|
}
|
|
27529
|
-
if (
|
|
27558
|
+
if (isLegacyAnimationLabel(name)) {
|
|
27530
27559
|
name = name.slice(1);
|
|
27531
27560
|
if (keySpan !== undefined) {
|
|
27532
27561
|
keySpan = moveParseSourceSpan(keySpan, new AbsoluteSourceSpan(keySpan.start.offset + 1, keySpan.end.offset));
|
|
27533
27562
|
}
|
|
27534
|
-
this.
|
|
27563
|
+
this._parseLegacyAnimationEvent(name, expression, sourceSpan, handlerSpan, targetEvents, keySpan);
|
|
27535
27564
|
}
|
|
27536
27565
|
else {
|
|
27537
27566
|
this._parseRegularEvent(name, expression, isAssignmentEvent, sourceSpan, handlerSpan, targetMatchableAttrs, targetEvents, keySpan);
|
|
@@ -27545,14 +27574,14 @@ class BindingParser {
|
|
|
27545
27574
|
const [target, eventName] = splitAtColon(rawName, [null, rawName]);
|
|
27546
27575
|
return { eventName: eventName, target };
|
|
27547
27576
|
}
|
|
27548
|
-
|
|
27577
|
+
parseLegacyAnimationEventName(rawName) {
|
|
27549
27578
|
const matches = splitAtPeriod(rawName, [rawName, null]);
|
|
27550
27579
|
return { eventName: matches[0], phase: matches[1] === null ? null : matches[1].toLowerCase() };
|
|
27551
27580
|
}
|
|
27552
|
-
|
|
27553
|
-
const { eventName, phase } = this.
|
|
27581
|
+
_parseLegacyAnimationEvent(name, expression, sourceSpan, handlerSpan, targetEvents, keySpan) {
|
|
27582
|
+
const { eventName, phase } = this.parseLegacyAnimationEventName(name);
|
|
27554
27583
|
const ast = this._parseAction(expression, handlerSpan);
|
|
27555
|
-
targetEvents.push(new ParsedEvent(eventName, phase, exports.ParsedEventType.
|
|
27584
|
+
targetEvents.push(new ParsedEvent(eventName, phase, exports.ParsedEventType.LegacyAnimation, ast, sourceSpan, handlerSpan, keySpan));
|
|
27556
27585
|
if (eventName.length === 0) {
|
|
27557
27586
|
this._reportError(`Animation event name is missing in binding`, sourceSpan);
|
|
27558
27587
|
}
|
|
@@ -27640,7 +27669,7 @@ class BindingParser {
|
|
|
27640
27669
|
return false;
|
|
27641
27670
|
}
|
|
27642
27671
|
}
|
|
27643
|
-
function
|
|
27672
|
+
function isLegacyAnimationLabel(name) {
|
|
27644
27673
|
return name[0] == '@';
|
|
27645
27674
|
}
|
|
27646
27675
|
function calcPossibleSecurityContexts(registry, selector, propName, isAttribute) {
|
|
@@ -29553,13 +29582,13 @@ function baseDirectiveFields(meta, constantPool, bindingParser) {
|
|
|
29553
29582
|
// e.g 'outputs: {a: 'a'}`
|
|
29554
29583
|
definitionMap.set('outputs', conditionallyCreateDirectiveBindingLiteral(meta.outputs));
|
|
29555
29584
|
if (meta.exportAs !== null) {
|
|
29556
|
-
definitionMap.set('exportAs', literalArr(meta.exportAs.map((e) => literal
|
|
29585
|
+
definitionMap.set('exportAs', literalArr(meta.exportAs.map((e) => literal(e))));
|
|
29557
29586
|
}
|
|
29558
29587
|
if (meta.isStandalone === false) {
|
|
29559
|
-
definitionMap.set('standalone', literal
|
|
29588
|
+
definitionMap.set('standalone', literal(false));
|
|
29560
29589
|
}
|
|
29561
29590
|
if (meta.isSignal) {
|
|
29562
|
-
definitionMap.set('signals', literal
|
|
29591
|
+
definitionMap.set('signals', literal(true));
|
|
29563
29592
|
}
|
|
29564
29593
|
return definitionMap;
|
|
29565
29594
|
}
|
|
@@ -29594,7 +29623,7 @@ function addFeatures(definitionMap, meta) {
|
|
|
29594
29623
|
features.push(importExpr(Identifiers.NgOnChangesFeature));
|
|
29595
29624
|
}
|
|
29596
29625
|
if ('externalStyles' in meta && meta.externalStyles?.length) {
|
|
29597
|
-
const externalStyleNodes = meta.externalStyles.map((externalStyle) => literal
|
|
29626
|
+
const externalStyleNodes = meta.externalStyles.map((externalStyle) => literal(externalStyle));
|
|
29598
29627
|
features.push(importExpr(Identifiers.ExternalStylesFeature).callFn([literalArr(externalStyleNodes)]));
|
|
29599
29628
|
}
|
|
29600
29629
|
if (features.length) {
|
|
@@ -29625,7 +29654,7 @@ function compileComponentFromMetadata(meta, constantPool, bindingParser) {
|
|
|
29625
29654
|
if (firstSelector) {
|
|
29626
29655
|
const selectorAttributes = firstSelector.getAttrs();
|
|
29627
29656
|
if (selectorAttributes.length) {
|
|
29628
|
-
definitionMap.set('attrs', constantPool.getConstLiteral(literalArr(selectorAttributes.map((value) => value != null ? literal
|
|
29657
|
+
definitionMap.set('attrs', constantPool.getConstLiteral(literalArr(selectorAttributes.map((value) => value != null ? literal(value) : literal(undefined))),
|
|
29629
29658
|
/* forceShared */ true));
|
|
29630
29659
|
}
|
|
29631
29660
|
}
|
|
@@ -29650,8 +29679,8 @@ function compileComponentFromMetadata(meta, constantPool, bindingParser) {
|
|
|
29650
29679
|
if (tpl.contentSelectors !== null) {
|
|
29651
29680
|
definitionMap.set('ngContentSelectors', tpl.contentSelectors);
|
|
29652
29681
|
}
|
|
29653
|
-
definitionMap.set('decls', literal
|
|
29654
|
-
definitionMap.set('vars', literal
|
|
29682
|
+
definitionMap.set('decls', literal(tpl.root.decls));
|
|
29683
|
+
definitionMap.set('vars', literal(tpl.root.vars));
|
|
29655
29684
|
if (tpl.consts.length > 0) {
|
|
29656
29685
|
if (tpl.constsInitializers.length > 0) {
|
|
29657
29686
|
definitionMap.set('consts', arrowFn([], [...tpl.constsInitializers, new ReturnStatement(literalArr(tpl.consts))]));
|
|
@@ -29683,7 +29712,7 @@ function compileComponentFromMetadata(meta, constantPool, bindingParser) {
|
|
|
29683
29712
|
: meta.styles;
|
|
29684
29713
|
const styleNodes = styleValues.reduce((result, style) => {
|
|
29685
29714
|
if (style.trim().length > 0) {
|
|
29686
|
-
result.push(constantPool.getConstLiteral(literal
|
|
29715
|
+
result.push(constantPool.getConstLiteral(literal(style)));
|
|
29687
29716
|
}
|
|
29688
29717
|
return result;
|
|
29689
29718
|
}, []);
|
|
@@ -29698,7 +29727,7 @@ function compileComponentFromMetadata(meta, constantPool, bindingParser) {
|
|
|
29698
29727
|
}
|
|
29699
29728
|
// Only set view encapsulation if it's not the default value
|
|
29700
29729
|
if (meta.encapsulation !== exports.ViewEncapsulation.Emulated) {
|
|
29701
|
-
definitionMap.set('encapsulation', literal
|
|
29730
|
+
definitionMap.set('encapsulation', literal(meta.encapsulation));
|
|
29702
29731
|
}
|
|
29703
29732
|
// e.g. `animation: [trigger('123', [])]`
|
|
29704
29733
|
if (meta.animations !== null) {
|
|
@@ -29709,7 +29738,7 @@ function compileComponentFromMetadata(meta, constantPool, bindingParser) {
|
|
|
29709
29738
|
if (typeof meta.changeDetection === 'number' &&
|
|
29710
29739
|
meta.changeDetection !== exports.ChangeDetectionStrategy.Default) {
|
|
29711
29740
|
// changeDetection is resolved during analysis. Only set it if not the default.
|
|
29712
|
-
definitionMap.set('changeDetection', literal
|
|
29741
|
+
definitionMap.set('changeDetection', literal(meta.changeDetection));
|
|
29713
29742
|
}
|
|
29714
29743
|
else if (typeof meta.changeDetection === 'object') {
|
|
29715
29744
|
// changeDetection is not resolved during analysis (e.g., we are in local compilation mode).
|
|
@@ -29729,13 +29758,13 @@ function compileComponentFromMetadata(meta, constantPool, bindingParser) {
|
|
|
29729
29758
|
function createComponentType(meta) {
|
|
29730
29759
|
const typeParams = createBaseDirectiveTypeParams(meta);
|
|
29731
29760
|
typeParams.push(stringArrayAsType(meta.template.ngContentSelectors));
|
|
29732
|
-
typeParams.push(expressionType(literal
|
|
29761
|
+
typeParams.push(expressionType(literal(meta.isStandalone)));
|
|
29733
29762
|
typeParams.push(createHostDirectivesType(meta));
|
|
29734
29763
|
// TODO(signals): Always include this metadata starting with v17. Right
|
|
29735
29764
|
// now Angular v16.0.x does not support this field and library distributions
|
|
29736
29765
|
// would then be incompatible with v16.0.x framework users.
|
|
29737
29766
|
if (meta.isSignal) {
|
|
29738
|
-
typeParams.push(expressionType(literal
|
|
29767
|
+
typeParams.push(expressionType(literal(meta.isSignal)));
|
|
29739
29768
|
}
|
|
29740
29769
|
return expressionType(importExpr(Identifiers.ComponentDeclaration, typeParams));
|
|
29741
29770
|
}
|
|
@@ -29760,14 +29789,14 @@ function compileDeclarationList(list, mode) {
|
|
|
29760
29789
|
}
|
|
29761
29790
|
}
|
|
29762
29791
|
function stringAsType(str) {
|
|
29763
|
-
return expressionType(literal
|
|
29792
|
+
return expressionType(literal(str));
|
|
29764
29793
|
}
|
|
29765
29794
|
function stringMapAsLiteralExpression(map) {
|
|
29766
29795
|
const mapValues = Object.keys(map).map((key) => {
|
|
29767
29796
|
const value = Array.isArray(map[key]) ? map[key][0] : map[key];
|
|
29768
29797
|
return {
|
|
29769
29798
|
key,
|
|
29770
|
-
value: literal
|
|
29799
|
+
value: literal(value),
|
|
29771
29800
|
quoted: true,
|
|
29772
29801
|
};
|
|
29773
29802
|
});
|
|
@@ -29775,7 +29804,7 @@ function stringMapAsLiteralExpression(map) {
|
|
|
29775
29804
|
}
|
|
29776
29805
|
function stringArrayAsType(arr) {
|
|
29777
29806
|
return arr.length > 0
|
|
29778
|
-
? expressionType(literalArr(arr.map((value) => literal
|
|
29807
|
+
? expressionType(literalArr(arr.map((value) => literal(value))))
|
|
29779
29808
|
: NONE_TYPE;
|
|
29780
29809
|
}
|
|
29781
29810
|
function createBaseDirectiveTypeParams(meta) {
|
|
@@ -29795,13 +29824,13 @@ function getInputsTypeExpression(meta) {
|
|
|
29795
29824
|
return literalMap(Object.keys(meta.inputs).map((key) => {
|
|
29796
29825
|
const value = meta.inputs[key];
|
|
29797
29826
|
const values = [
|
|
29798
|
-
{ key: 'alias', value: literal
|
|
29799
|
-
{ key: 'required', value: literal
|
|
29827
|
+
{ key: 'alias', value: literal(value.bindingPropertyName), quoted: true },
|
|
29828
|
+
{ key: 'required', value: literal(value.required), quoted: true },
|
|
29800
29829
|
];
|
|
29801
29830
|
// TODO(legacy-partial-output-inputs): Consider always emitting this information,
|
|
29802
29831
|
// or leaving it as is.
|
|
29803
29832
|
if (value.isSignal) {
|
|
29804
|
-
values.push({ key: 'isSignal', value: literal
|
|
29833
|
+
values.push({ key: 'isSignal', value: literal(value.isSignal), quoted: true });
|
|
29805
29834
|
}
|
|
29806
29835
|
return { key, value: literalMap(values), quoted: true };
|
|
29807
29836
|
}));
|
|
@@ -29815,13 +29844,13 @@ function createDirectiveType(meta) {
|
|
|
29815
29844
|
// Directives have no NgContentSelectors slot, but instead express a `never` type
|
|
29816
29845
|
// so that future fields align.
|
|
29817
29846
|
typeParams.push(NONE_TYPE);
|
|
29818
|
-
typeParams.push(expressionType(literal
|
|
29847
|
+
typeParams.push(expressionType(literal(meta.isStandalone)));
|
|
29819
29848
|
typeParams.push(createHostDirectivesType(meta));
|
|
29820
29849
|
// TODO(signals): Always include this metadata starting with v17. Right
|
|
29821
29850
|
// now Angular v16.0.x does not support this field and library distributions
|
|
29822
29851
|
// would then be incompatible with v16.0.x framework users.
|
|
29823
29852
|
if (meta.isSignal) {
|
|
29824
|
-
typeParams.push(expressionType(literal
|
|
29853
|
+
typeParams.push(expressionType(literal(meta.isSignal)));
|
|
29825
29854
|
}
|
|
29826
29855
|
return expressionType(importExpr(Identifiers.DirectiveDeclaration, typeParams));
|
|
29827
29856
|
}
|
|
@@ -29835,10 +29864,10 @@ function createHostBindingsFunction(hostBindingsMetadata, typeSourceSpan, bindin
|
|
|
29835
29864
|
// actually already handle these special attributes internally. Therefore, we just drop them
|
|
29836
29865
|
// into the attributes map.
|
|
29837
29866
|
if (hostBindingsMetadata.specialAttributes.styleAttr) {
|
|
29838
|
-
hostBindingsMetadata.attributes['style'] = literal
|
|
29867
|
+
hostBindingsMetadata.attributes['style'] = literal(hostBindingsMetadata.specialAttributes.styleAttr);
|
|
29839
29868
|
}
|
|
29840
29869
|
if (hostBindingsMetadata.specialAttributes.classAttr) {
|
|
29841
|
-
hostBindingsMetadata.attributes['class'] = literal
|
|
29870
|
+
hostBindingsMetadata.attributes['class'] = literal(hostBindingsMetadata.specialAttributes.classAttr);
|
|
29842
29871
|
}
|
|
29843
29872
|
const hostJob = ingestHostBinding({
|
|
29844
29873
|
componentName: name,
|
|
@@ -29851,7 +29880,7 @@ function createHostBindingsFunction(hostBindingsMetadata, typeSourceSpan, bindin
|
|
|
29851
29880
|
definitionMap.set('hostAttrs', hostJob.root.attributes);
|
|
29852
29881
|
const varCount = hostJob.root.vars;
|
|
29853
29882
|
if (varCount !== null && varCount > 0) {
|
|
29854
|
-
definitionMap.set('hostVars', literal
|
|
29883
|
+
definitionMap.set('hostVars', literal(varCount));
|
|
29855
29884
|
}
|
|
29856
29885
|
return emitHostBindingFunction(hostJob);
|
|
29857
29886
|
}
|
|
@@ -29882,7 +29911,7 @@ function parseHostBindings(host) {
|
|
|
29882
29911
|
break;
|
|
29883
29912
|
default:
|
|
29884
29913
|
if (typeof value === 'string') {
|
|
29885
|
-
attributes[key] = literal
|
|
29914
|
+
attributes[key] = literal(value);
|
|
29886
29915
|
}
|
|
29887
29916
|
else {
|
|
29888
29917
|
attributes[key] = value;
|
|
@@ -29996,7 +30025,7 @@ function createHostDirectivesMappingArray(mapping) {
|
|
|
29996
30025
|
const elements = [];
|
|
29997
30026
|
for (const publicName in mapping) {
|
|
29998
30027
|
if (mapping.hasOwnProperty(publicName)) {
|
|
29999
|
-
elements.push(literal
|
|
30028
|
+
elements.push(literal(publicName), literal(mapping[publicName]));
|
|
30000
30029
|
}
|
|
30001
30030
|
}
|
|
30002
30031
|
return elements.length > 0 ? literalArr(elements) : null;
|
|
@@ -31549,7 +31578,7 @@ function createR3DependencyMetadata(token, isAttributeDep, host, optional, self,
|
|
|
31549
31578
|
// If the dep is an `@Attribute()` the `attributeNameType` ought to be the `unknown` type.
|
|
31550
31579
|
// But types are not available at runtime so we just use a literal `"<unknown>"` string as a dummy
|
|
31551
31580
|
// marker.
|
|
31552
|
-
const attributeNameType = isAttributeDep ? literal
|
|
31581
|
+
const attributeNameType = isAttributeDep ? literal('unknown') : null;
|
|
31553
31582
|
return { token, attributeNameType, host, optional, self, skipSelf };
|
|
31554
31583
|
}
|
|
31555
31584
|
function createR3ComponentDeferMetadata(boundTarget, deferBlockDependencies) {
|
|
@@ -32199,7 +32228,7 @@ function isAttrNode(ast) {
|
|
|
32199
32228
|
* @description
|
|
32200
32229
|
* Entry point for all public APIs of the compiler package.
|
|
32201
32230
|
*/
|
|
32202
|
-
new Version('20.1.0
|
|
32231
|
+
new Version('20.1.0');
|
|
32203
32232
|
|
|
32204
32233
|
//////////////////////////////////////
|
|
32205
32234
|
// THIS FILE HAS GLOBAL SIDE EFFECT //
|
|
@@ -33219,8 +33248,11 @@ class NodeJSPathManipulation {
|
|
|
33219
33248
|
// G3-ESM-MARKER: G3 uses CommonJS, but externally everything in ESM.
|
|
33220
33249
|
// CommonJS/ESM interop for determining the current file name and containing dir.
|
|
33221
33250
|
const isCommonJS = typeof __filename !== 'undefined';
|
|
33222
|
-
const currentFileUrl = isCommonJS ? null : (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('checker-
|
|
33223
|
-
|
|
33251
|
+
const currentFileUrl = isCommonJS ? null : (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('checker-DLInMAS3.cjs', document.baseURI).href));
|
|
33252
|
+
// Note, when this code loads in the browser, `url` may be an empty `{}` due to the Closure shims.
|
|
33253
|
+
const currentFileName = isCommonJS
|
|
33254
|
+
? __filename
|
|
33255
|
+
: (url__namespace.fileURLToPath?.(currentFileUrl) ?? null);
|
|
33224
33256
|
/**
|
|
33225
33257
|
* A wrapper around the Node.js file-system that supports readonly operations and path manipulation.
|
|
33226
33258
|
*/
|
|
@@ -33230,7 +33262,10 @@ class NodeJSReadonlyFileSystem extends NodeJSPathManipulation {
|
|
|
33230
33262
|
if (this._caseSensitive === undefined) {
|
|
33231
33263
|
// Note the use of the real file-system is intentional:
|
|
33232
33264
|
// `this.exists()` relies upon `isCaseSensitive()` so that would cause an infinite recursion.
|
|
33233
|
-
this._caseSensitive =
|
|
33265
|
+
this._caseSensitive =
|
|
33266
|
+
currentFileName !== null
|
|
33267
|
+
? !fs$1.existsSync(this.normalize(toggleCase(currentFileName)))
|
|
33268
|
+
: true;
|
|
33234
33269
|
}
|
|
33235
33270
|
return this._caseSensitive;
|
|
33236
33271
|
}
|
|
@@ -36513,790 +36548,6 @@ function getContainerNode(node) {
|
|
|
36513
36548
|
return node.getSourceFile();
|
|
36514
36549
|
}
|
|
36515
36550
|
|
|
36516
|
-
class ArraySliceBuiltinFn extends KnownFn {
|
|
36517
|
-
lhs;
|
|
36518
|
-
constructor(lhs) {
|
|
36519
|
-
super();
|
|
36520
|
-
this.lhs = lhs;
|
|
36521
|
-
}
|
|
36522
|
-
evaluate(node, args) {
|
|
36523
|
-
if (args.length === 0) {
|
|
36524
|
-
return this.lhs;
|
|
36525
|
-
}
|
|
36526
|
-
else {
|
|
36527
|
-
return DynamicValue.fromUnknown(node);
|
|
36528
|
-
}
|
|
36529
|
-
}
|
|
36530
|
-
}
|
|
36531
|
-
class ArrayConcatBuiltinFn extends KnownFn {
|
|
36532
|
-
lhs;
|
|
36533
|
-
constructor(lhs) {
|
|
36534
|
-
super();
|
|
36535
|
-
this.lhs = lhs;
|
|
36536
|
-
}
|
|
36537
|
-
evaluate(node, args) {
|
|
36538
|
-
const result = [...this.lhs];
|
|
36539
|
-
for (const arg of args) {
|
|
36540
|
-
if (arg instanceof DynamicValue) {
|
|
36541
|
-
result.push(DynamicValue.fromDynamicInput(node, arg));
|
|
36542
|
-
}
|
|
36543
|
-
else if (Array.isArray(arg)) {
|
|
36544
|
-
result.push(...arg);
|
|
36545
|
-
}
|
|
36546
|
-
else {
|
|
36547
|
-
result.push(arg);
|
|
36548
|
-
}
|
|
36549
|
-
}
|
|
36550
|
-
return result;
|
|
36551
|
-
}
|
|
36552
|
-
}
|
|
36553
|
-
class StringConcatBuiltinFn extends KnownFn {
|
|
36554
|
-
lhs;
|
|
36555
|
-
constructor(lhs) {
|
|
36556
|
-
super();
|
|
36557
|
-
this.lhs = lhs;
|
|
36558
|
-
}
|
|
36559
|
-
evaluate(node, args) {
|
|
36560
|
-
let result = this.lhs;
|
|
36561
|
-
for (const arg of args) {
|
|
36562
|
-
const resolved = arg instanceof EnumValue ? arg.resolved : arg;
|
|
36563
|
-
if (typeof resolved === 'string' ||
|
|
36564
|
-
typeof resolved === 'number' ||
|
|
36565
|
-
typeof resolved === 'boolean' ||
|
|
36566
|
-
resolved == null) {
|
|
36567
|
-
// Cast to `any`, because `concat` will convert
|
|
36568
|
-
// anything to a string, but TS only allows strings.
|
|
36569
|
-
result = result.concat(resolved);
|
|
36570
|
-
}
|
|
36571
|
-
else {
|
|
36572
|
-
return DynamicValue.fromUnknown(node);
|
|
36573
|
-
}
|
|
36574
|
-
}
|
|
36575
|
-
return result;
|
|
36576
|
-
}
|
|
36577
|
-
}
|
|
36578
|
-
|
|
36579
|
-
/**
|
|
36580
|
-
* A value produced which originated in a `ForeignFunctionResolver` and doesn't come from the
|
|
36581
|
-
* template itself.
|
|
36582
|
-
*
|
|
36583
|
-
* Synthetic values cannot be further evaluated, and attempts to do so produce `DynamicValue`s
|
|
36584
|
-
* instead.
|
|
36585
|
-
*/
|
|
36586
|
-
class SyntheticValue {
|
|
36587
|
-
value;
|
|
36588
|
-
constructor(value) {
|
|
36589
|
-
this.value = value;
|
|
36590
|
-
}
|
|
36591
|
-
}
|
|
36592
|
-
|
|
36593
|
-
function literalBinaryOp(op) {
|
|
36594
|
-
return { op, literal: true };
|
|
36595
|
-
}
|
|
36596
|
-
function referenceBinaryOp(op) {
|
|
36597
|
-
return { op, literal: false };
|
|
36598
|
-
}
|
|
36599
|
-
const BINARY_OPERATORS$2 = new Map([
|
|
36600
|
-
[ts.SyntaxKind.PlusToken, literalBinaryOp((a, b) => a + b)],
|
|
36601
|
-
[ts.SyntaxKind.MinusToken, literalBinaryOp((a, b) => a - b)],
|
|
36602
|
-
[ts.SyntaxKind.AsteriskToken, literalBinaryOp((a, b) => a * b)],
|
|
36603
|
-
[ts.SyntaxKind.SlashToken, literalBinaryOp((a, b) => a / b)],
|
|
36604
|
-
[ts.SyntaxKind.PercentToken, literalBinaryOp((a, b) => a % b)],
|
|
36605
|
-
[ts.SyntaxKind.AmpersandToken, literalBinaryOp((a, b) => a & b)],
|
|
36606
|
-
[ts.SyntaxKind.BarToken, literalBinaryOp((a, b) => a | b)],
|
|
36607
|
-
[ts.SyntaxKind.CaretToken, literalBinaryOp((a, b) => a ^ b)],
|
|
36608
|
-
[ts.SyntaxKind.LessThanToken, literalBinaryOp((a, b) => a < b)],
|
|
36609
|
-
[ts.SyntaxKind.LessThanEqualsToken, literalBinaryOp((a, b) => a <= b)],
|
|
36610
|
-
[ts.SyntaxKind.GreaterThanToken, literalBinaryOp((a, b) => a > b)],
|
|
36611
|
-
[ts.SyntaxKind.GreaterThanEqualsToken, literalBinaryOp((a, b) => a >= b)],
|
|
36612
|
-
[ts.SyntaxKind.EqualsEqualsToken, literalBinaryOp((a, b) => a == b)],
|
|
36613
|
-
[ts.SyntaxKind.EqualsEqualsEqualsToken, literalBinaryOp((a, b) => a === b)],
|
|
36614
|
-
[ts.SyntaxKind.ExclamationEqualsToken, literalBinaryOp((a, b) => a != b)],
|
|
36615
|
-
[ts.SyntaxKind.ExclamationEqualsEqualsToken, literalBinaryOp((a, b) => a !== b)],
|
|
36616
|
-
[ts.SyntaxKind.LessThanLessThanToken, literalBinaryOp((a, b) => a << b)],
|
|
36617
|
-
[ts.SyntaxKind.GreaterThanGreaterThanToken, literalBinaryOp((a, b) => a >> b)],
|
|
36618
|
-
[ts.SyntaxKind.GreaterThanGreaterThanGreaterThanToken, literalBinaryOp((a, b) => a >>> b)],
|
|
36619
|
-
[ts.SyntaxKind.AsteriskAsteriskToken, literalBinaryOp((a, b) => Math.pow(a, b))],
|
|
36620
|
-
[ts.SyntaxKind.AmpersandAmpersandToken, referenceBinaryOp((a, b) => a && b)],
|
|
36621
|
-
[ts.SyntaxKind.BarBarToken, referenceBinaryOp((a, b) => a || b)],
|
|
36622
|
-
]);
|
|
36623
|
-
const UNARY_OPERATORS$2 = new Map([
|
|
36624
|
-
[ts.SyntaxKind.TildeToken, (a) => ~a],
|
|
36625
|
-
[ts.SyntaxKind.MinusToken, (a) => -a],
|
|
36626
|
-
[ts.SyntaxKind.PlusToken, (a) => +a],
|
|
36627
|
-
[ts.SyntaxKind.ExclamationToken, (a) => !a],
|
|
36628
|
-
]);
|
|
36629
|
-
class StaticInterpreter {
|
|
36630
|
-
host;
|
|
36631
|
-
checker;
|
|
36632
|
-
dependencyTracker;
|
|
36633
|
-
constructor(host, checker, dependencyTracker) {
|
|
36634
|
-
this.host = host;
|
|
36635
|
-
this.checker = checker;
|
|
36636
|
-
this.dependencyTracker = dependencyTracker;
|
|
36637
|
-
}
|
|
36638
|
-
visit(node, context) {
|
|
36639
|
-
return this.visitExpression(node, context);
|
|
36640
|
-
}
|
|
36641
|
-
visitExpression(node, context) {
|
|
36642
|
-
let result;
|
|
36643
|
-
if (node.kind === ts.SyntaxKind.TrueKeyword) {
|
|
36644
|
-
return true;
|
|
36645
|
-
}
|
|
36646
|
-
else if (node.kind === ts.SyntaxKind.FalseKeyword) {
|
|
36647
|
-
return false;
|
|
36648
|
-
}
|
|
36649
|
-
else if (node.kind === ts.SyntaxKind.NullKeyword) {
|
|
36650
|
-
return null;
|
|
36651
|
-
}
|
|
36652
|
-
else if (ts.isStringLiteral(node)) {
|
|
36653
|
-
return node.text;
|
|
36654
|
-
}
|
|
36655
|
-
else if (ts.isNoSubstitutionTemplateLiteral(node)) {
|
|
36656
|
-
return node.text;
|
|
36657
|
-
}
|
|
36658
|
-
else if (ts.isTemplateExpression(node)) {
|
|
36659
|
-
result = this.visitTemplateExpression(node, context);
|
|
36660
|
-
}
|
|
36661
|
-
else if (ts.isNumericLiteral(node)) {
|
|
36662
|
-
return parseFloat(node.text);
|
|
36663
|
-
}
|
|
36664
|
-
else if (ts.isObjectLiteralExpression(node)) {
|
|
36665
|
-
result = this.visitObjectLiteralExpression(node, context);
|
|
36666
|
-
}
|
|
36667
|
-
else if (ts.isIdentifier(node)) {
|
|
36668
|
-
result = this.visitIdentifier(node, context);
|
|
36669
|
-
}
|
|
36670
|
-
else if (ts.isPropertyAccessExpression(node)) {
|
|
36671
|
-
result = this.visitPropertyAccessExpression(node, context);
|
|
36672
|
-
}
|
|
36673
|
-
else if (ts.isCallExpression(node)) {
|
|
36674
|
-
result = this.visitCallExpression(node, context);
|
|
36675
|
-
}
|
|
36676
|
-
else if (ts.isConditionalExpression(node)) {
|
|
36677
|
-
result = this.visitConditionalExpression(node, context);
|
|
36678
|
-
}
|
|
36679
|
-
else if (ts.isPrefixUnaryExpression(node)) {
|
|
36680
|
-
result = this.visitPrefixUnaryExpression(node, context);
|
|
36681
|
-
}
|
|
36682
|
-
else if (ts.isBinaryExpression(node)) {
|
|
36683
|
-
result = this.visitBinaryExpression(node, context);
|
|
36684
|
-
}
|
|
36685
|
-
else if (ts.isArrayLiteralExpression(node)) {
|
|
36686
|
-
result = this.visitArrayLiteralExpression(node, context);
|
|
36687
|
-
}
|
|
36688
|
-
else if (ts.isParenthesizedExpression(node)) {
|
|
36689
|
-
result = this.visitParenthesizedExpression(node, context);
|
|
36690
|
-
}
|
|
36691
|
-
else if (ts.isElementAccessExpression(node)) {
|
|
36692
|
-
result = this.visitElementAccessExpression(node, context);
|
|
36693
|
-
}
|
|
36694
|
-
else if (ts.isAsExpression(node)) {
|
|
36695
|
-
result = this.visitExpression(node.expression, context);
|
|
36696
|
-
}
|
|
36697
|
-
else if (ts.isNonNullExpression(node)) {
|
|
36698
|
-
result = this.visitExpression(node.expression, context);
|
|
36699
|
-
}
|
|
36700
|
-
else if (this.host.isClass(node)) {
|
|
36701
|
-
result = this.visitDeclaration(node, context);
|
|
36702
|
-
}
|
|
36703
|
-
else {
|
|
36704
|
-
return DynamicValue.fromUnsupportedSyntax(node);
|
|
36705
|
-
}
|
|
36706
|
-
if (result instanceof DynamicValue && result.node !== node) {
|
|
36707
|
-
return DynamicValue.fromDynamicInput(node, result);
|
|
36708
|
-
}
|
|
36709
|
-
return result;
|
|
36710
|
-
}
|
|
36711
|
-
visitArrayLiteralExpression(node, context) {
|
|
36712
|
-
const array = [];
|
|
36713
|
-
for (let i = 0; i < node.elements.length; i++) {
|
|
36714
|
-
const element = node.elements[i];
|
|
36715
|
-
if (ts.isSpreadElement(element)) {
|
|
36716
|
-
array.push(...this.visitSpreadElement(element, context));
|
|
36717
|
-
}
|
|
36718
|
-
else {
|
|
36719
|
-
array.push(this.visitExpression(element, context));
|
|
36720
|
-
}
|
|
36721
|
-
}
|
|
36722
|
-
return array;
|
|
36723
|
-
}
|
|
36724
|
-
visitObjectLiteralExpression(node, context) {
|
|
36725
|
-
const map = new Map();
|
|
36726
|
-
for (let i = 0; i < node.properties.length; i++) {
|
|
36727
|
-
const property = node.properties[i];
|
|
36728
|
-
if (ts.isPropertyAssignment(property)) {
|
|
36729
|
-
const name = this.stringNameFromPropertyName(property.name, context);
|
|
36730
|
-
// Check whether the name can be determined statically.
|
|
36731
|
-
if (name === undefined) {
|
|
36732
|
-
return DynamicValue.fromDynamicInput(node, DynamicValue.fromDynamicString(property.name));
|
|
36733
|
-
}
|
|
36734
|
-
map.set(name, this.visitExpression(property.initializer, context));
|
|
36735
|
-
}
|
|
36736
|
-
else if (ts.isShorthandPropertyAssignment(property)) {
|
|
36737
|
-
const symbol = this.checker.getShorthandAssignmentValueSymbol(property);
|
|
36738
|
-
if (symbol === undefined || symbol.valueDeclaration === undefined) {
|
|
36739
|
-
map.set(property.name.text, DynamicValue.fromUnknown(property));
|
|
36740
|
-
}
|
|
36741
|
-
else {
|
|
36742
|
-
map.set(property.name.text, this.visitDeclaration(symbol.valueDeclaration, context));
|
|
36743
|
-
}
|
|
36744
|
-
}
|
|
36745
|
-
else if (ts.isSpreadAssignment(property)) {
|
|
36746
|
-
const spread = this.visitExpression(property.expression, context);
|
|
36747
|
-
if (spread instanceof DynamicValue) {
|
|
36748
|
-
return DynamicValue.fromDynamicInput(node, spread);
|
|
36749
|
-
}
|
|
36750
|
-
else if (spread instanceof Map) {
|
|
36751
|
-
spread.forEach((value, key) => map.set(key, value));
|
|
36752
|
-
}
|
|
36753
|
-
else if (spread instanceof ResolvedModule) {
|
|
36754
|
-
spread.getExports().forEach((value, key) => map.set(key, value));
|
|
36755
|
-
}
|
|
36756
|
-
else {
|
|
36757
|
-
return DynamicValue.fromDynamicInput(node, DynamicValue.fromInvalidExpressionType(property, spread));
|
|
36758
|
-
}
|
|
36759
|
-
}
|
|
36760
|
-
else {
|
|
36761
|
-
return DynamicValue.fromUnknown(node);
|
|
36762
|
-
}
|
|
36763
|
-
}
|
|
36764
|
-
return map;
|
|
36765
|
-
}
|
|
36766
|
-
visitTemplateExpression(node, context) {
|
|
36767
|
-
const pieces = [node.head.text];
|
|
36768
|
-
for (let i = 0; i < node.templateSpans.length; i++) {
|
|
36769
|
-
const span = node.templateSpans[i];
|
|
36770
|
-
const value = literal(this.visit(span.expression, context), () => DynamicValue.fromDynamicString(span.expression));
|
|
36771
|
-
if (value instanceof DynamicValue) {
|
|
36772
|
-
return DynamicValue.fromDynamicInput(node, value);
|
|
36773
|
-
}
|
|
36774
|
-
pieces.push(`${value}`, span.literal.text);
|
|
36775
|
-
}
|
|
36776
|
-
return pieces.join('');
|
|
36777
|
-
}
|
|
36778
|
-
visitIdentifier(node, context) {
|
|
36779
|
-
const decl = this.host.getDeclarationOfIdentifier(node);
|
|
36780
|
-
if (decl === null) {
|
|
36781
|
-
if (ts.identifierToKeywordKind(node) === ts.SyntaxKind.UndefinedKeyword) {
|
|
36782
|
-
return undefined;
|
|
36783
|
-
}
|
|
36784
|
-
else {
|
|
36785
|
-
// Check if the symbol here is imported.
|
|
36786
|
-
if (this.dependencyTracker !== null && this.host.getImportOfIdentifier(node) !== null) {
|
|
36787
|
-
// It was, but no declaration for the node could be found. This means that the dependency
|
|
36788
|
-
// graph for the current file cannot be properly updated to account for this (broken)
|
|
36789
|
-
// import. Instead, the originating file is reported as failing dependency analysis,
|
|
36790
|
-
// ensuring that future compilations will always attempt to re-resolve the previously
|
|
36791
|
-
// broken identifier.
|
|
36792
|
-
this.dependencyTracker.recordDependencyAnalysisFailure(context.originatingFile);
|
|
36793
|
-
}
|
|
36794
|
-
return DynamicValue.fromUnknownIdentifier(node);
|
|
36795
|
-
}
|
|
36796
|
-
}
|
|
36797
|
-
const declContext = { ...context, ...joinModuleContext(context, node, decl) };
|
|
36798
|
-
const result = this.visitDeclaration(decl.node, declContext);
|
|
36799
|
-
if (result instanceof Reference) {
|
|
36800
|
-
// Only record identifiers to non-synthetic references. Synthetic references may not have the
|
|
36801
|
-
// same value at runtime as they do at compile time, so it's not legal to refer to them by the
|
|
36802
|
-
// identifier here.
|
|
36803
|
-
if (!result.synthetic) {
|
|
36804
|
-
result.addIdentifier(node);
|
|
36805
|
-
}
|
|
36806
|
-
}
|
|
36807
|
-
else if (result instanceof DynamicValue) {
|
|
36808
|
-
return DynamicValue.fromDynamicInput(node, result);
|
|
36809
|
-
}
|
|
36810
|
-
return result;
|
|
36811
|
-
}
|
|
36812
|
-
visitDeclaration(node, context) {
|
|
36813
|
-
if (this.dependencyTracker !== null) {
|
|
36814
|
-
this.dependencyTracker.addDependency(context.originatingFile, node.getSourceFile());
|
|
36815
|
-
}
|
|
36816
|
-
if (this.host.isClass(node)) {
|
|
36817
|
-
return this.getReference(node, context);
|
|
36818
|
-
}
|
|
36819
|
-
else if (ts.isVariableDeclaration(node)) {
|
|
36820
|
-
return this.visitVariableDeclaration(node, context);
|
|
36821
|
-
}
|
|
36822
|
-
else if (ts.isParameter(node) && context.scope.has(node)) {
|
|
36823
|
-
return context.scope.get(node);
|
|
36824
|
-
}
|
|
36825
|
-
else if (ts.isExportAssignment(node)) {
|
|
36826
|
-
return this.visitExpression(node.expression, context);
|
|
36827
|
-
}
|
|
36828
|
-
else if (ts.isEnumDeclaration(node)) {
|
|
36829
|
-
return this.visitEnumDeclaration(node, context);
|
|
36830
|
-
}
|
|
36831
|
-
else if (ts.isSourceFile(node)) {
|
|
36832
|
-
return this.visitSourceFile(node, context);
|
|
36833
|
-
}
|
|
36834
|
-
else if (ts.isBindingElement(node)) {
|
|
36835
|
-
return this.visitBindingElement(node, context);
|
|
36836
|
-
}
|
|
36837
|
-
else {
|
|
36838
|
-
return this.getReference(node, context);
|
|
36839
|
-
}
|
|
36840
|
-
}
|
|
36841
|
-
visitVariableDeclaration(node, context) {
|
|
36842
|
-
const value = this.host.getVariableValue(node);
|
|
36843
|
-
if (value !== null) {
|
|
36844
|
-
return this.visitExpression(value, context);
|
|
36845
|
-
}
|
|
36846
|
-
else if (isVariableDeclarationDeclared(node)) {
|
|
36847
|
-
// If the declaration has a literal type that can be statically reduced to a value, resolve to
|
|
36848
|
-
// that value. If not, the historical behavior for variable declarations is to return a
|
|
36849
|
-
// `Reference` to the variable, as the consumer could use it in a context where knowing its
|
|
36850
|
-
// static value is not necessary.
|
|
36851
|
-
//
|
|
36852
|
-
// Arguably, since the value cannot be statically determined, we should return a
|
|
36853
|
-
// `DynamicValue`. This returns a `Reference` because it's the same behavior as before
|
|
36854
|
-
// `visitType` was introduced.
|
|
36855
|
-
//
|
|
36856
|
-
// TODO(zarend): investigate switching to a `DynamicValue` and verify this won't break any
|
|
36857
|
-
// use cases, especially in ngcc
|
|
36858
|
-
if (node.type !== undefined) {
|
|
36859
|
-
const evaluatedType = this.visitType(node.type, context);
|
|
36860
|
-
if (!(evaluatedType instanceof DynamicValue)) {
|
|
36861
|
-
return evaluatedType;
|
|
36862
|
-
}
|
|
36863
|
-
}
|
|
36864
|
-
return this.getReference(node, context);
|
|
36865
|
-
}
|
|
36866
|
-
else {
|
|
36867
|
-
return undefined;
|
|
36868
|
-
}
|
|
36869
|
-
}
|
|
36870
|
-
visitEnumDeclaration(node, context) {
|
|
36871
|
-
const enumRef = this.getReference(node, context);
|
|
36872
|
-
const map = new Map();
|
|
36873
|
-
node.members.forEach((member, index) => {
|
|
36874
|
-
const name = this.stringNameFromPropertyName(member.name, context);
|
|
36875
|
-
if (name !== undefined) {
|
|
36876
|
-
const resolved = member.initializer ? this.visit(member.initializer, context) : index;
|
|
36877
|
-
map.set(name, new EnumValue(enumRef, name, resolved));
|
|
36878
|
-
}
|
|
36879
|
-
});
|
|
36880
|
-
return map;
|
|
36881
|
-
}
|
|
36882
|
-
visitElementAccessExpression(node, context) {
|
|
36883
|
-
const lhs = this.visitExpression(node.expression, context);
|
|
36884
|
-
if (lhs instanceof DynamicValue) {
|
|
36885
|
-
return DynamicValue.fromDynamicInput(node, lhs);
|
|
36886
|
-
}
|
|
36887
|
-
const rhs = this.visitExpression(node.argumentExpression, context);
|
|
36888
|
-
if (rhs instanceof DynamicValue) {
|
|
36889
|
-
return DynamicValue.fromDynamicInput(node, rhs);
|
|
36890
|
-
}
|
|
36891
|
-
if (typeof rhs !== 'string' && typeof rhs !== 'number') {
|
|
36892
|
-
return DynamicValue.fromInvalidExpressionType(node, rhs);
|
|
36893
|
-
}
|
|
36894
|
-
return this.accessHelper(node, lhs, rhs, context);
|
|
36895
|
-
}
|
|
36896
|
-
visitPropertyAccessExpression(node, context) {
|
|
36897
|
-
const lhs = this.visitExpression(node.expression, context);
|
|
36898
|
-
const rhs = node.name.text;
|
|
36899
|
-
// TODO: handle reference to class declaration.
|
|
36900
|
-
if (lhs instanceof DynamicValue) {
|
|
36901
|
-
return DynamicValue.fromDynamicInput(node, lhs);
|
|
36902
|
-
}
|
|
36903
|
-
return this.accessHelper(node, lhs, rhs, context);
|
|
36904
|
-
}
|
|
36905
|
-
visitSourceFile(node, context) {
|
|
36906
|
-
const declarations = this.host.getExportsOfModule(node);
|
|
36907
|
-
if (declarations === null) {
|
|
36908
|
-
return DynamicValue.fromUnknown(node);
|
|
36909
|
-
}
|
|
36910
|
-
return new ResolvedModule(declarations, (decl) => {
|
|
36911
|
-
const declContext = {
|
|
36912
|
-
...context,
|
|
36913
|
-
...joinModuleContext(context, node, decl),
|
|
36914
|
-
};
|
|
36915
|
-
// Visit both concrete and inline declarations.
|
|
36916
|
-
return this.visitDeclaration(decl.node, declContext);
|
|
36917
|
-
});
|
|
36918
|
-
}
|
|
36919
|
-
accessHelper(node, lhs, rhs, context) {
|
|
36920
|
-
const strIndex = `${rhs}`;
|
|
36921
|
-
if (lhs instanceof Map) {
|
|
36922
|
-
if (lhs.has(strIndex)) {
|
|
36923
|
-
return lhs.get(strIndex);
|
|
36924
|
-
}
|
|
36925
|
-
else {
|
|
36926
|
-
return undefined;
|
|
36927
|
-
}
|
|
36928
|
-
}
|
|
36929
|
-
else if (lhs instanceof ResolvedModule) {
|
|
36930
|
-
return lhs.getExport(strIndex);
|
|
36931
|
-
}
|
|
36932
|
-
else if (Array.isArray(lhs)) {
|
|
36933
|
-
if (rhs === 'length') {
|
|
36934
|
-
return lhs.length;
|
|
36935
|
-
}
|
|
36936
|
-
else if (rhs === 'slice') {
|
|
36937
|
-
return new ArraySliceBuiltinFn(lhs);
|
|
36938
|
-
}
|
|
36939
|
-
else if (rhs === 'concat') {
|
|
36940
|
-
return new ArrayConcatBuiltinFn(lhs);
|
|
36941
|
-
}
|
|
36942
|
-
if (typeof rhs !== 'number' || !Number.isInteger(rhs)) {
|
|
36943
|
-
return DynamicValue.fromInvalidExpressionType(node, rhs);
|
|
36944
|
-
}
|
|
36945
|
-
return lhs[rhs];
|
|
36946
|
-
}
|
|
36947
|
-
else if (typeof lhs === 'string' && rhs === 'concat') {
|
|
36948
|
-
return new StringConcatBuiltinFn(lhs);
|
|
36949
|
-
}
|
|
36950
|
-
else if (lhs instanceof Reference) {
|
|
36951
|
-
const ref = lhs.node;
|
|
36952
|
-
if (this.host.isClass(ref)) {
|
|
36953
|
-
const module = owningModule(context, lhs.bestGuessOwningModule);
|
|
36954
|
-
let value = undefined;
|
|
36955
|
-
const member = this.host
|
|
36956
|
-
.getMembersOfClass(ref)
|
|
36957
|
-
.find((member) => member.isStatic && member.name === strIndex);
|
|
36958
|
-
if (member !== undefined) {
|
|
36959
|
-
if (member.value !== null) {
|
|
36960
|
-
value = this.visitExpression(member.value, context);
|
|
36961
|
-
}
|
|
36962
|
-
else if (member.implementation !== null) {
|
|
36963
|
-
value = new Reference(member.implementation, module);
|
|
36964
|
-
}
|
|
36965
|
-
else if (member.node) {
|
|
36966
|
-
value = new Reference(member.node, module);
|
|
36967
|
-
}
|
|
36968
|
-
}
|
|
36969
|
-
return value;
|
|
36970
|
-
}
|
|
36971
|
-
else if (isDeclaration(ref)) {
|
|
36972
|
-
return DynamicValue.fromDynamicInput(node, DynamicValue.fromExternalReference(ref, lhs));
|
|
36973
|
-
}
|
|
36974
|
-
}
|
|
36975
|
-
else if (lhs instanceof DynamicValue) {
|
|
36976
|
-
return DynamicValue.fromDynamicInput(node, lhs);
|
|
36977
|
-
}
|
|
36978
|
-
else if (lhs instanceof SyntheticValue) {
|
|
36979
|
-
return DynamicValue.fromSyntheticInput(node, lhs);
|
|
36980
|
-
}
|
|
36981
|
-
return DynamicValue.fromUnknown(node);
|
|
36982
|
-
}
|
|
36983
|
-
visitCallExpression(node, context) {
|
|
36984
|
-
const lhs = this.visitExpression(node.expression, context);
|
|
36985
|
-
if (lhs instanceof DynamicValue) {
|
|
36986
|
-
return DynamicValue.fromDynamicInput(node, lhs);
|
|
36987
|
-
}
|
|
36988
|
-
// If the call refers to a builtin function, attempt to evaluate the function.
|
|
36989
|
-
if (lhs instanceof KnownFn) {
|
|
36990
|
-
return lhs.evaluate(node, this.evaluateFunctionArguments(node, context));
|
|
36991
|
-
}
|
|
36992
|
-
if (!(lhs instanceof Reference)) {
|
|
36993
|
-
return DynamicValue.fromInvalidExpressionType(node.expression, lhs);
|
|
36994
|
-
}
|
|
36995
|
-
const fn = this.host.getDefinitionOfFunction(lhs.node);
|
|
36996
|
-
if (fn === null) {
|
|
36997
|
-
return DynamicValue.fromInvalidExpressionType(node.expression, lhs);
|
|
36998
|
-
}
|
|
36999
|
-
if (!isFunctionOrMethodReference(lhs)) {
|
|
37000
|
-
return DynamicValue.fromInvalidExpressionType(node.expression, lhs);
|
|
37001
|
-
}
|
|
37002
|
-
const resolveFfrExpr = (expr) => {
|
|
37003
|
-
let contextExtension = {};
|
|
37004
|
-
// TODO(alxhub): the condition `fn.body === null` here is vestigial - we probably _do_ want to
|
|
37005
|
-
// change the context like this even for non-null function bodies. But, this is being
|
|
37006
|
-
// redesigned as a refactoring with no behavior changes so that should be done as a follow-up.
|
|
37007
|
-
if (fn.body === null &&
|
|
37008
|
-
expr.getSourceFile() !== node.expression.getSourceFile() &&
|
|
37009
|
-
lhs.bestGuessOwningModule !== null) {
|
|
37010
|
-
contextExtension = {
|
|
37011
|
-
absoluteModuleName: lhs.bestGuessOwningModule.specifier,
|
|
37012
|
-
resolutionContext: lhs.bestGuessOwningModule.resolutionContext,
|
|
37013
|
-
};
|
|
37014
|
-
}
|
|
37015
|
-
return this.visitFfrExpression(expr, { ...context, ...contextExtension });
|
|
37016
|
-
};
|
|
37017
|
-
// If the function is foreign (declared through a d.ts file), attempt to resolve it with the
|
|
37018
|
-
// foreignFunctionResolver, if one is specified.
|
|
37019
|
-
if (fn.body === null && context.foreignFunctionResolver !== undefined) {
|
|
37020
|
-
const unresolvable = DynamicValue.fromDynamicInput(node, DynamicValue.fromExternalReference(node.expression, lhs));
|
|
37021
|
-
return context.foreignFunctionResolver(lhs, node, resolveFfrExpr, unresolvable);
|
|
37022
|
-
}
|
|
37023
|
-
const res = this.visitFunctionBody(node, fn, context);
|
|
37024
|
-
// If the result of attempting to resolve the function body was a DynamicValue, attempt to use
|
|
37025
|
-
// the foreignFunctionResolver if one is present. This could still potentially yield a usable
|
|
37026
|
-
// value.
|
|
37027
|
-
if (res instanceof DynamicValue && context.foreignFunctionResolver !== undefined) {
|
|
37028
|
-
const unresolvable = DynamicValue.fromComplexFunctionCall(node, fn);
|
|
37029
|
-
return context.foreignFunctionResolver(lhs, node, resolveFfrExpr, unresolvable);
|
|
37030
|
-
}
|
|
37031
|
-
return res;
|
|
37032
|
-
}
|
|
37033
|
-
/**
|
|
37034
|
-
* Visit an expression which was extracted from a foreign-function resolver.
|
|
37035
|
-
*
|
|
37036
|
-
* This will process the result and ensure it's correct for FFR-resolved values, including marking
|
|
37037
|
-
* `Reference`s as synthetic.
|
|
37038
|
-
*/
|
|
37039
|
-
visitFfrExpression(expr, context) {
|
|
37040
|
-
const res = this.visitExpression(expr, context);
|
|
37041
|
-
if (res instanceof Reference) {
|
|
37042
|
-
// This Reference was created synthetically, via a foreign function resolver. The real
|
|
37043
|
-
// runtime value of the function expression may be different than the foreign function
|
|
37044
|
-
// resolved value, so mark the Reference as synthetic to avoid it being misinterpreted.
|
|
37045
|
-
res.synthetic = true;
|
|
37046
|
-
}
|
|
37047
|
-
return res;
|
|
37048
|
-
}
|
|
37049
|
-
visitFunctionBody(node, fn, context) {
|
|
37050
|
-
if (fn.body === null) {
|
|
37051
|
-
return DynamicValue.fromUnknown(node);
|
|
37052
|
-
}
|
|
37053
|
-
else if (fn.body.length !== 1 || !ts.isReturnStatement(fn.body[0])) {
|
|
37054
|
-
return DynamicValue.fromComplexFunctionCall(node, fn);
|
|
37055
|
-
}
|
|
37056
|
-
const ret = fn.body[0];
|
|
37057
|
-
const args = this.evaluateFunctionArguments(node, context);
|
|
37058
|
-
const newScope = new Map();
|
|
37059
|
-
const calleeContext = { ...context, scope: newScope };
|
|
37060
|
-
fn.parameters.forEach((param, index) => {
|
|
37061
|
-
let arg = args[index];
|
|
37062
|
-
if (param.node.dotDotDotToken !== undefined) {
|
|
37063
|
-
arg = args.slice(index);
|
|
37064
|
-
}
|
|
37065
|
-
if (arg === undefined && param.initializer !== null) {
|
|
37066
|
-
arg = this.visitExpression(param.initializer, calleeContext);
|
|
37067
|
-
}
|
|
37068
|
-
newScope.set(param.node, arg);
|
|
37069
|
-
});
|
|
37070
|
-
return ret.expression !== undefined
|
|
37071
|
-
? this.visitExpression(ret.expression, calleeContext)
|
|
37072
|
-
: undefined;
|
|
37073
|
-
}
|
|
37074
|
-
visitConditionalExpression(node, context) {
|
|
37075
|
-
const condition = this.visitExpression(node.condition, context);
|
|
37076
|
-
if (condition instanceof DynamicValue) {
|
|
37077
|
-
return DynamicValue.fromDynamicInput(node, condition);
|
|
37078
|
-
}
|
|
37079
|
-
if (condition) {
|
|
37080
|
-
return this.visitExpression(node.whenTrue, context);
|
|
37081
|
-
}
|
|
37082
|
-
else {
|
|
37083
|
-
return this.visitExpression(node.whenFalse, context);
|
|
37084
|
-
}
|
|
37085
|
-
}
|
|
37086
|
-
visitPrefixUnaryExpression(node, context) {
|
|
37087
|
-
const operatorKind = node.operator;
|
|
37088
|
-
if (!UNARY_OPERATORS$2.has(operatorKind)) {
|
|
37089
|
-
return DynamicValue.fromUnsupportedSyntax(node);
|
|
37090
|
-
}
|
|
37091
|
-
const op = UNARY_OPERATORS$2.get(operatorKind);
|
|
37092
|
-
const value = this.visitExpression(node.operand, context);
|
|
37093
|
-
if (value instanceof DynamicValue) {
|
|
37094
|
-
return DynamicValue.fromDynamicInput(node, value);
|
|
37095
|
-
}
|
|
37096
|
-
else {
|
|
37097
|
-
return op(value);
|
|
37098
|
-
}
|
|
37099
|
-
}
|
|
37100
|
-
visitBinaryExpression(node, context) {
|
|
37101
|
-
const tokenKind = node.operatorToken.kind;
|
|
37102
|
-
if (!BINARY_OPERATORS$2.has(tokenKind)) {
|
|
37103
|
-
return DynamicValue.fromUnsupportedSyntax(node);
|
|
37104
|
-
}
|
|
37105
|
-
const opRecord = BINARY_OPERATORS$2.get(tokenKind);
|
|
37106
|
-
let lhs, rhs;
|
|
37107
|
-
if (opRecord.literal) {
|
|
37108
|
-
lhs = literal(this.visitExpression(node.left, context), (value) => DynamicValue.fromInvalidExpressionType(node.left, value));
|
|
37109
|
-
rhs = literal(this.visitExpression(node.right, context), (value) => DynamicValue.fromInvalidExpressionType(node.right, value));
|
|
37110
|
-
}
|
|
37111
|
-
else {
|
|
37112
|
-
lhs = this.visitExpression(node.left, context);
|
|
37113
|
-
rhs = this.visitExpression(node.right, context);
|
|
37114
|
-
}
|
|
37115
|
-
if (lhs instanceof DynamicValue) {
|
|
37116
|
-
return DynamicValue.fromDynamicInput(node, lhs);
|
|
37117
|
-
}
|
|
37118
|
-
else if (rhs instanceof DynamicValue) {
|
|
37119
|
-
return DynamicValue.fromDynamicInput(node, rhs);
|
|
37120
|
-
}
|
|
37121
|
-
else {
|
|
37122
|
-
return opRecord.op(lhs, rhs);
|
|
37123
|
-
}
|
|
37124
|
-
}
|
|
37125
|
-
visitParenthesizedExpression(node, context) {
|
|
37126
|
-
return this.visitExpression(node.expression, context);
|
|
37127
|
-
}
|
|
37128
|
-
evaluateFunctionArguments(node, context) {
|
|
37129
|
-
const args = [];
|
|
37130
|
-
for (const arg of node.arguments) {
|
|
37131
|
-
if (ts.isSpreadElement(arg)) {
|
|
37132
|
-
args.push(...this.visitSpreadElement(arg, context));
|
|
37133
|
-
}
|
|
37134
|
-
else {
|
|
37135
|
-
args.push(this.visitExpression(arg, context));
|
|
37136
|
-
}
|
|
37137
|
-
}
|
|
37138
|
-
return args;
|
|
37139
|
-
}
|
|
37140
|
-
visitSpreadElement(node, context) {
|
|
37141
|
-
const spread = this.visitExpression(node.expression, context);
|
|
37142
|
-
if (spread instanceof DynamicValue) {
|
|
37143
|
-
return [DynamicValue.fromDynamicInput(node, spread)];
|
|
37144
|
-
}
|
|
37145
|
-
else if (!Array.isArray(spread)) {
|
|
37146
|
-
return [DynamicValue.fromInvalidExpressionType(node, spread)];
|
|
37147
|
-
}
|
|
37148
|
-
else {
|
|
37149
|
-
return spread;
|
|
37150
|
-
}
|
|
37151
|
-
}
|
|
37152
|
-
visitBindingElement(node, context) {
|
|
37153
|
-
const path = [];
|
|
37154
|
-
let closestDeclaration = node;
|
|
37155
|
-
while (ts.isBindingElement(closestDeclaration) ||
|
|
37156
|
-
ts.isArrayBindingPattern(closestDeclaration) ||
|
|
37157
|
-
ts.isObjectBindingPattern(closestDeclaration)) {
|
|
37158
|
-
if (ts.isBindingElement(closestDeclaration)) {
|
|
37159
|
-
path.unshift(closestDeclaration);
|
|
37160
|
-
}
|
|
37161
|
-
closestDeclaration = closestDeclaration.parent;
|
|
37162
|
-
}
|
|
37163
|
-
if (!ts.isVariableDeclaration(closestDeclaration) ||
|
|
37164
|
-
closestDeclaration.initializer === undefined) {
|
|
37165
|
-
return DynamicValue.fromUnknown(node);
|
|
37166
|
-
}
|
|
37167
|
-
let value = this.visit(closestDeclaration.initializer, context);
|
|
37168
|
-
for (const element of path) {
|
|
37169
|
-
let key;
|
|
37170
|
-
if (ts.isArrayBindingPattern(element.parent)) {
|
|
37171
|
-
key = element.parent.elements.indexOf(element);
|
|
37172
|
-
}
|
|
37173
|
-
else {
|
|
37174
|
-
const name = element.propertyName || element.name;
|
|
37175
|
-
if (ts.isIdentifier(name)) {
|
|
37176
|
-
key = name.text;
|
|
37177
|
-
}
|
|
37178
|
-
else {
|
|
37179
|
-
return DynamicValue.fromUnknown(element);
|
|
37180
|
-
}
|
|
37181
|
-
}
|
|
37182
|
-
value = this.accessHelper(element, value, key, context);
|
|
37183
|
-
if (value instanceof DynamicValue) {
|
|
37184
|
-
return value;
|
|
37185
|
-
}
|
|
37186
|
-
}
|
|
37187
|
-
return value;
|
|
37188
|
-
}
|
|
37189
|
-
stringNameFromPropertyName(node, context) {
|
|
37190
|
-
if (ts.isIdentifier(node) || ts.isStringLiteral(node) || ts.isNumericLiteral(node)) {
|
|
37191
|
-
return node.text;
|
|
37192
|
-
}
|
|
37193
|
-
else if (ts.isComputedPropertyName(node)) {
|
|
37194
|
-
const literal = this.visitExpression(node.expression, context);
|
|
37195
|
-
return typeof literal === 'string' ? literal : undefined;
|
|
37196
|
-
}
|
|
37197
|
-
else {
|
|
37198
|
-
return undefined;
|
|
37199
|
-
}
|
|
37200
|
-
}
|
|
37201
|
-
getReference(node, context) {
|
|
37202
|
-
return new Reference(node, owningModule(context));
|
|
37203
|
-
}
|
|
37204
|
-
visitType(node, context) {
|
|
37205
|
-
if (ts.isLiteralTypeNode(node)) {
|
|
37206
|
-
return this.visitExpression(node.literal, context);
|
|
37207
|
-
}
|
|
37208
|
-
else if (ts.isTupleTypeNode(node)) {
|
|
37209
|
-
return this.visitTupleType(node, context);
|
|
37210
|
-
}
|
|
37211
|
-
else if (ts.isNamedTupleMember(node)) {
|
|
37212
|
-
return this.visitType(node.type, context);
|
|
37213
|
-
}
|
|
37214
|
-
else if (ts.isTypeOperatorNode(node) && node.operator === ts.SyntaxKind.ReadonlyKeyword) {
|
|
37215
|
-
return this.visitType(node.type, context);
|
|
37216
|
-
}
|
|
37217
|
-
else if (ts.isTypeQueryNode(node)) {
|
|
37218
|
-
return this.visitTypeQuery(node, context);
|
|
37219
|
-
}
|
|
37220
|
-
return DynamicValue.fromDynamicType(node);
|
|
37221
|
-
}
|
|
37222
|
-
visitTupleType(node, context) {
|
|
37223
|
-
const res = [];
|
|
37224
|
-
for (const elem of node.elements) {
|
|
37225
|
-
res.push(this.visitType(elem, context));
|
|
37226
|
-
}
|
|
37227
|
-
return res;
|
|
37228
|
-
}
|
|
37229
|
-
visitTypeQuery(node, context) {
|
|
37230
|
-
if (!ts.isIdentifier(node.exprName)) {
|
|
37231
|
-
return DynamicValue.fromUnknown(node);
|
|
37232
|
-
}
|
|
37233
|
-
const decl = this.host.getDeclarationOfIdentifier(node.exprName);
|
|
37234
|
-
if (decl === null) {
|
|
37235
|
-
return DynamicValue.fromUnknownIdentifier(node.exprName);
|
|
37236
|
-
}
|
|
37237
|
-
const declContext = { ...context, ...joinModuleContext(context, node, decl) };
|
|
37238
|
-
return this.visitDeclaration(decl.node, declContext);
|
|
37239
|
-
}
|
|
37240
|
-
}
|
|
37241
|
-
function isFunctionOrMethodReference(ref) {
|
|
37242
|
-
return (ts.isFunctionDeclaration(ref.node) ||
|
|
37243
|
-
ts.isMethodDeclaration(ref.node) ||
|
|
37244
|
-
ts.isFunctionExpression(ref.node));
|
|
37245
|
-
}
|
|
37246
|
-
function literal(value, reject) {
|
|
37247
|
-
if (value instanceof EnumValue) {
|
|
37248
|
-
value = value.resolved;
|
|
37249
|
-
}
|
|
37250
|
-
if (value instanceof DynamicValue ||
|
|
37251
|
-
value === null ||
|
|
37252
|
-
value === undefined ||
|
|
37253
|
-
typeof value === 'string' ||
|
|
37254
|
-
typeof value === 'number' ||
|
|
37255
|
-
typeof value === 'boolean') {
|
|
37256
|
-
return value;
|
|
37257
|
-
}
|
|
37258
|
-
return reject(value);
|
|
37259
|
-
}
|
|
37260
|
-
function isVariableDeclarationDeclared(node) {
|
|
37261
|
-
if (node.parent === undefined || !ts.isVariableDeclarationList(node.parent)) {
|
|
37262
|
-
return false;
|
|
37263
|
-
}
|
|
37264
|
-
const declList = node.parent;
|
|
37265
|
-
if (declList.parent === undefined || !ts.isVariableStatement(declList.parent)) {
|
|
37266
|
-
return false;
|
|
37267
|
-
}
|
|
37268
|
-
const varStmt = declList.parent;
|
|
37269
|
-
const modifiers = ts.getModifiers(varStmt);
|
|
37270
|
-
return (modifiers !== undefined && modifiers.some((mod) => mod.kind === ts.SyntaxKind.DeclareKeyword));
|
|
37271
|
-
}
|
|
37272
|
-
const EMPTY = {};
|
|
37273
|
-
function joinModuleContext(existing, node, decl) {
|
|
37274
|
-
if (typeof decl.viaModule === 'string' && decl.viaModule !== existing.absoluteModuleName) {
|
|
37275
|
-
return {
|
|
37276
|
-
absoluteModuleName: decl.viaModule,
|
|
37277
|
-
resolutionContext: node.getSourceFile().fileName,
|
|
37278
|
-
};
|
|
37279
|
-
}
|
|
37280
|
-
else {
|
|
37281
|
-
return EMPTY;
|
|
37282
|
-
}
|
|
37283
|
-
}
|
|
37284
|
-
function owningModule(context, override = null) {
|
|
37285
|
-
let specifier = context.absoluteModuleName;
|
|
37286
|
-
if (override !== null) {
|
|
37287
|
-
specifier = override.specifier;
|
|
37288
|
-
}
|
|
37289
|
-
if (specifier !== null) {
|
|
37290
|
-
return {
|
|
37291
|
-
specifier,
|
|
37292
|
-
resolutionContext: context.resolutionContext,
|
|
37293
|
-
};
|
|
37294
|
-
}
|
|
37295
|
-
else {
|
|
37296
|
-
return null;
|
|
37297
|
-
}
|
|
37298
|
-
}
|
|
37299
|
-
|
|
37300
36551
|
/**
|
|
37301
36552
|
* Specifies the compilation mode that is used for the compilation.
|
|
37302
36553
|
*/
|
|
@@ -37753,10 +37004,14 @@ function createGenerateUniqueIdentifierHelper() {
|
|
|
37753
37004
|
const markIdentifierAsGenerated = (sf, identifierName) => generatedIdentifiers.add(`${sf.fileName}@@${identifierName}`);
|
|
37754
37005
|
return (sourceFile, symbolName) => {
|
|
37755
37006
|
const sf = sourceFile;
|
|
37756
|
-
|
|
37007
|
+
// NOTE: Typically accesses to TS fields are not renamed because the 1P externs
|
|
37008
|
+
// produced from TypeScript are ensuring public fields are considered "external".
|
|
37009
|
+
// See: https://developers.google.com/closure/compiler/docs/externs-and-exports.
|
|
37010
|
+
// This property is internal, so not part of the externs— so we need be cautious
|
|
37011
|
+
if (sf['identifiers'] === undefined) {
|
|
37757
37012
|
throw new Error('Source file unexpectedly lacks map of parsed `identifiers`.');
|
|
37758
37013
|
}
|
|
37759
|
-
const isUniqueIdentifier = (name) => !sf
|
|
37014
|
+
const isUniqueIdentifier = (name) => !sf['identifiers'].has(name) && !isGeneratedIdentifier(sf, name);
|
|
37760
37015
|
if (isUniqueIdentifier(symbolName)) {
|
|
37761
37016
|
markIdentifierAsGenerated(sf, symbolName);
|
|
37762
37017
|
return null;
|
|
@@ -38292,11 +37547,11 @@ function createImportReference(asTypeReference, ref) {
|
|
|
38292
37547
|
}
|
|
38293
37548
|
}
|
|
38294
37549
|
|
|
38295
|
-
const UNARY_OPERATORS
|
|
37550
|
+
const UNARY_OPERATORS = /* @__PURE__ */ new Map([
|
|
38296
37551
|
[UnaryOperator.Minus, '-'],
|
|
38297
37552
|
[UnaryOperator.Plus, '+'],
|
|
38298
37553
|
]);
|
|
38299
|
-
const BINARY_OPERATORS
|
|
37554
|
+
const BINARY_OPERATORS = /* @__PURE__ */ new Map([
|
|
38300
37555
|
[BinaryOperator.And, '&&'],
|
|
38301
37556
|
[BinaryOperator.Bigger, '>'],
|
|
38302
37557
|
[BinaryOperator.BiggerEquals, '>='],
|
|
@@ -38490,10 +37745,10 @@ class ExpressionTranslatorVisitor {
|
|
|
38490
37745
|
: ast.body.visitExpression(this, context));
|
|
38491
37746
|
}
|
|
38492
37747
|
visitBinaryOperatorExpr(ast, context) {
|
|
38493
|
-
if (!BINARY_OPERATORS
|
|
37748
|
+
if (!BINARY_OPERATORS.has(ast.operator)) {
|
|
38494
37749
|
throw new Error(`Unknown binary operator: ${BinaryOperator[ast.operator]}`);
|
|
38495
37750
|
}
|
|
38496
|
-
const operator = BINARY_OPERATORS
|
|
37751
|
+
const operator = BINARY_OPERATORS.get(ast.operator);
|
|
38497
37752
|
if (ast.isAssignment()) {
|
|
38498
37753
|
return this.factory.createAssignment(ast.lhs.visitExpression(this, context), operator, ast.rhs.visitExpression(this, context));
|
|
38499
37754
|
}
|
|
@@ -38535,10 +37790,10 @@ class ExpressionTranslatorVisitor {
|
|
|
38535
37790
|
return this.factory.createVoidExpression(ast.expr.visitExpression(this, context));
|
|
38536
37791
|
}
|
|
38537
37792
|
visitUnaryOperatorExpr(ast, context) {
|
|
38538
|
-
if (!UNARY_OPERATORS
|
|
37793
|
+
if (!UNARY_OPERATORS.has(ast.operator)) {
|
|
38539
37794
|
throw new Error(`Unknown unary operator: ${UnaryOperator[ast.operator]}`);
|
|
38540
37795
|
}
|
|
38541
|
-
return this.factory.createUnaryExpression(UNARY_OPERATORS
|
|
37796
|
+
return this.factory.createUnaryExpression(UNARY_OPERATORS.get(ast.operator), ast.expr.visitExpression(this, context));
|
|
38542
37797
|
}
|
|
38543
37798
|
visitParenthesizedExpr(ast, context) {
|
|
38544
37799
|
const result = ast.expr.visitExpression(this, context);
|
|
@@ -39003,64 +38258,67 @@ var PureAnnotation;
|
|
|
39003
38258
|
PureAnnotation["CLOSURE"] = "* @pureOrBreakMyCode ";
|
|
39004
38259
|
PureAnnotation["TERSER"] = "@__PURE__";
|
|
39005
38260
|
})(PureAnnotation || (PureAnnotation = {}));
|
|
39006
|
-
const UNARY_OPERATORS = /* @__PURE__ */ (() => ({
|
|
39007
|
-
'+': ts.SyntaxKind.PlusToken,
|
|
39008
|
-
'-': ts.SyntaxKind.MinusToken,
|
|
39009
|
-
'!': ts.SyntaxKind.ExclamationToken,
|
|
39010
|
-
}))();
|
|
39011
|
-
const BINARY_OPERATORS = /* @__PURE__ */ (() => ({
|
|
39012
|
-
'&&': ts.SyntaxKind.AmpersandAmpersandToken,
|
|
39013
|
-
'>': ts.SyntaxKind.GreaterThanToken,
|
|
39014
|
-
'>=': ts.SyntaxKind.GreaterThanEqualsToken,
|
|
39015
|
-
'&': ts.SyntaxKind.AmpersandToken,
|
|
39016
|
-
'|': ts.SyntaxKind.BarToken,
|
|
39017
|
-
'/': ts.SyntaxKind.SlashToken,
|
|
39018
|
-
'==': ts.SyntaxKind.EqualsEqualsToken,
|
|
39019
|
-
'===': ts.SyntaxKind.EqualsEqualsEqualsToken,
|
|
39020
|
-
'<': ts.SyntaxKind.LessThanToken,
|
|
39021
|
-
'<=': ts.SyntaxKind.LessThanEqualsToken,
|
|
39022
|
-
'-': ts.SyntaxKind.MinusToken,
|
|
39023
|
-
'%': ts.SyntaxKind.PercentToken,
|
|
39024
|
-
'*': ts.SyntaxKind.AsteriskToken,
|
|
39025
|
-
'**': ts.SyntaxKind.AsteriskAsteriskToken,
|
|
39026
|
-
'!=': ts.SyntaxKind.ExclamationEqualsToken,
|
|
39027
|
-
'!==': ts.SyntaxKind.ExclamationEqualsEqualsToken,
|
|
39028
|
-
'||': ts.SyntaxKind.BarBarToken,
|
|
39029
|
-
'+': ts.SyntaxKind.PlusToken,
|
|
39030
|
-
'??': ts.SyntaxKind.QuestionQuestionToken,
|
|
39031
|
-
'in': ts.SyntaxKind.InKeyword,
|
|
39032
|
-
'=': ts.SyntaxKind.EqualsToken,
|
|
39033
|
-
'+=': ts.SyntaxKind.PlusEqualsToken,
|
|
39034
|
-
'-=': ts.SyntaxKind.MinusEqualsToken,
|
|
39035
|
-
'*=': ts.SyntaxKind.AsteriskEqualsToken,
|
|
39036
|
-
'/=': ts.SyntaxKind.SlashEqualsToken,
|
|
39037
|
-
'%=': ts.SyntaxKind.PercentEqualsToken,
|
|
39038
|
-
'**=': ts.SyntaxKind.AsteriskAsteriskEqualsToken,
|
|
39039
|
-
'&&=': ts.SyntaxKind.AmpersandAmpersandEqualsToken,
|
|
39040
|
-
'||=': ts.SyntaxKind.BarBarEqualsToken,
|
|
39041
|
-
'??=': ts.SyntaxKind.QuestionQuestionEqualsToken,
|
|
39042
|
-
}))();
|
|
39043
|
-
const VAR_TYPES = /* @__PURE__ */ (() => ({
|
|
39044
|
-
'const': ts.NodeFlags.Const,
|
|
39045
|
-
'let': ts.NodeFlags.Let,
|
|
39046
|
-
'var': ts.NodeFlags.None,
|
|
39047
|
-
}))();
|
|
39048
38261
|
/**
|
|
39049
38262
|
* A TypeScript flavoured implementation of the AstFactory.
|
|
39050
38263
|
*/
|
|
39051
38264
|
class TypeScriptAstFactory {
|
|
39052
38265
|
annotateForClosureCompiler;
|
|
39053
38266
|
externalSourceFiles = new Map();
|
|
38267
|
+
UNARY_OPERATORS =
|
|
38268
|
+
/* @__PURE__ */ (() => ({
|
|
38269
|
+
'+': ts.SyntaxKind.PlusToken,
|
|
38270
|
+
'-': ts.SyntaxKind.MinusToken,
|
|
38271
|
+
'!': ts.SyntaxKind.ExclamationToken,
|
|
38272
|
+
}))();
|
|
38273
|
+
BINARY_OPERATORS =
|
|
38274
|
+
/* @__PURE__ */ (() => ({
|
|
38275
|
+
'&&': ts.SyntaxKind.AmpersandAmpersandToken,
|
|
38276
|
+
'>': ts.SyntaxKind.GreaterThanToken,
|
|
38277
|
+
'>=': ts.SyntaxKind.GreaterThanEqualsToken,
|
|
38278
|
+
'&': ts.SyntaxKind.AmpersandToken,
|
|
38279
|
+
'|': ts.SyntaxKind.BarToken,
|
|
38280
|
+
'/': ts.SyntaxKind.SlashToken,
|
|
38281
|
+
'==': ts.SyntaxKind.EqualsEqualsToken,
|
|
38282
|
+
'===': ts.SyntaxKind.EqualsEqualsEqualsToken,
|
|
38283
|
+
'<': ts.SyntaxKind.LessThanToken,
|
|
38284
|
+
'<=': ts.SyntaxKind.LessThanEqualsToken,
|
|
38285
|
+
'-': ts.SyntaxKind.MinusToken,
|
|
38286
|
+
'%': ts.SyntaxKind.PercentToken,
|
|
38287
|
+
'*': ts.SyntaxKind.AsteriskToken,
|
|
38288
|
+
'**': ts.SyntaxKind.AsteriskAsteriskToken,
|
|
38289
|
+
'!=': ts.SyntaxKind.ExclamationEqualsToken,
|
|
38290
|
+
'!==': ts.SyntaxKind.ExclamationEqualsEqualsToken,
|
|
38291
|
+
'||': ts.SyntaxKind.BarBarToken,
|
|
38292
|
+
'+': ts.SyntaxKind.PlusToken,
|
|
38293
|
+
'??': ts.SyntaxKind.QuestionQuestionToken,
|
|
38294
|
+
'in': ts.SyntaxKind.InKeyword,
|
|
38295
|
+
'=': ts.SyntaxKind.EqualsToken,
|
|
38296
|
+
'+=': ts.SyntaxKind.PlusEqualsToken,
|
|
38297
|
+
'-=': ts.SyntaxKind.MinusEqualsToken,
|
|
38298
|
+
'*=': ts.SyntaxKind.AsteriskEqualsToken,
|
|
38299
|
+
'/=': ts.SyntaxKind.SlashEqualsToken,
|
|
38300
|
+
'%=': ts.SyntaxKind.PercentEqualsToken,
|
|
38301
|
+
'**=': ts.SyntaxKind.AsteriskAsteriskEqualsToken,
|
|
38302
|
+
'&&=': ts.SyntaxKind.AmpersandAmpersandEqualsToken,
|
|
38303
|
+
'||=': ts.SyntaxKind.BarBarEqualsToken,
|
|
38304
|
+
'??=': ts.SyntaxKind.QuestionQuestionEqualsToken,
|
|
38305
|
+
}))();
|
|
38306
|
+
VAR_TYPES =
|
|
38307
|
+
/* @__PURE__ */ (() => ({
|
|
38308
|
+
'const': ts.NodeFlags.Const,
|
|
38309
|
+
'let': ts.NodeFlags.Let,
|
|
38310
|
+
'var': ts.NodeFlags.None,
|
|
38311
|
+
}))();
|
|
39054
38312
|
constructor(annotateForClosureCompiler) {
|
|
39055
38313
|
this.annotateForClosureCompiler = annotateForClosureCompiler;
|
|
39056
38314
|
}
|
|
39057
38315
|
attachComments = attachComments;
|
|
39058
38316
|
createArrayLiteral = ts.factory.createArrayLiteralExpression;
|
|
39059
38317
|
createAssignment(target, operator, value) {
|
|
39060
|
-
return ts.factory.createBinaryExpression(target, BINARY_OPERATORS[operator], value);
|
|
38318
|
+
return ts.factory.createBinaryExpression(target, this.BINARY_OPERATORS[operator], value);
|
|
39061
38319
|
}
|
|
39062
38320
|
createBinaryExpression(leftOperand, operator, rightOperand) {
|
|
39063
|
-
return ts.factory.createBinaryExpression(leftOperand, BINARY_OPERATORS[operator], rightOperand);
|
|
38321
|
+
return ts.factory.createBinaryExpression(leftOperand, this.BINARY_OPERATORS[operator], rightOperand);
|
|
39064
38322
|
}
|
|
39065
38323
|
createBlock(body) {
|
|
39066
38324
|
return ts.factory.createBlock(body);
|
|
@@ -39175,12 +38433,12 @@ class TypeScriptAstFactory {
|
|
|
39175
38433
|
createTypeOfExpression = ts.factory.createTypeOfExpression;
|
|
39176
38434
|
createVoidExpression = ts.factory.createVoidExpression;
|
|
39177
38435
|
createUnaryExpression(operator, operand) {
|
|
39178
|
-
return ts.factory.createPrefixUnaryExpression(UNARY_OPERATORS[operator], operand);
|
|
38436
|
+
return ts.factory.createPrefixUnaryExpression(this.UNARY_OPERATORS[operator], operand);
|
|
39179
38437
|
}
|
|
39180
38438
|
createVariableDeclaration(variableName, initializer, type) {
|
|
39181
38439
|
return ts.factory.createVariableStatement(undefined, ts.factory.createVariableDeclarationList([
|
|
39182
38440
|
ts.factory.createVariableDeclaration(variableName, undefined, undefined, initializer ?? undefined),
|
|
39183
|
-
], VAR_TYPES[type]));
|
|
38441
|
+
], this.VAR_TYPES[type]));
|
|
39184
38442
|
}
|
|
39185
38443
|
setSourceMapRange(node, sourceMapRange) {
|
|
39186
38444
|
if (sourceMapRange === null) {
|
|
@@ -41282,6 +40540,19 @@ function makeTemplateDiagnostic(id, mapping, span, category, code, messageText,
|
|
|
41282
40540
|
relatedInformation,
|
|
41283
40541
|
};
|
|
41284
40542
|
}
|
|
40543
|
+
let typeForMessage;
|
|
40544
|
+
if (category === ts.DiagnosticCategory.Warning) {
|
|
40545
|
+
typeForMessage = 'Warning';
|
|
40546
|
+
}
|
|
40547
|
+
else if (category === ts.DiagnosticCategory.Suggestion) {
|
|
40548
|
+
typeForMessage = 'Suggestion';
|
|
40549
|
+
}
|
|
40550
|
+
else if (category === ts.DiagnosticCategory.Message) {
|
|
40551
|
+
typeForMessage = 'Message';
|
|
40552
|
+
}
|
|
40553
|
+
else {
|
|
40554
|
+
typeForMessage = 'Error';
|
|
40555
|
+
}
|
|
41285
40556
|
relatedInformation.push({
|
|
41286
40557
|
category: ts.DiagnosticCategory.Message,
|
|
41287
40558
|
code: 0,
|
|
@@ -41290,7 +40561,7 @@ function makeTemplateDiagnostic(id, mapping, span, category, code, messageText,
|
|
|
41290
40561
|
// and getEnd() are used because they don't include surrounding whitespace.
|
|
41291
40562
|
start: mapping.node.getStart(),
|
|
41292
40563
|
length: mapping.node.getEnd() - mapping.node.getStart(),
|
|
41293
|
-
messageText:
|
|
40564
|
+
messageText: `${typeForMessage} occurs in the template of component ${componentName}.`,
|
|
41294
40565
|
});
|
|
41295
40566
|
return {
|
|
41296
40567
|
source: 'ngtsc',
|
|
@@ -41705,97 +40976,88 @@ class CompletionEngine {
|
|
|
41705
40976
|
}
|
|
41706
40977
|
}
|
|
41707
40978
|
|
|
41708
|
-
|
|
41709
|
-
|
|
41710
|
-
|
|
41711
|
-
|
|
41712
|
-
|
|
40979
|
+
// src/vlq.ts
|
|
40980
|
+
var comma = ",".charCodeAt(0);
|
|
40981
|
+
var semicolon = ";".charCodeAt(0);
|
|
40982
|
+
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
40983
|
+
var intToChar = new Uint8Array(64);
|
|
40984
|
+
var charToInt = new Uint8Array(128);
|
|
41713
40985
|
for (let i = 0; i < chars.length; i++) {
|
|
41714
|
-
|
|
41715
|
-
|
|
41716
|
-
|
|
40986
|
+
const c = chars.charCodeAt(i);
|
|
40987
|
+
intToChar[i] = c;
|
|
40988
|
+
charToInt[c] = i;
|
|
41717
40989
|
}
|
|
41718
40990
|
function encodeInteger(builder, num, relative) {
|
|
41719
|
-
|
|
41720
|
-
|
|
41721
|
-
|
|
41722
|
-
|
|
41723
|
-
|
|
41724
|
-
|
|
41725
|
-
|
|
41726
|
-
|
|
41727
|
-
|
|
41728
|
-
|
|
41729
|
-
|
|
41730
|
-
|
|
41731
|
-
|
|
41732
|
-
|
|
41733
|
-
|
|
41734
|
-
|
|
41735
|
-
|
|
41736
|
-
|
|
41737
|
-
|
|
41738
|
-
|
|
41739
|
-
|
|
41740
|
-
|
|
41741
|
-
|
|
41742
|
-
: {
|
|
41743
|
-
decode(buf) {
|
|
41744
|
-
let out = '';
|
|
41745
|
-
for (let i = 0; i < buf.length; i++) {
|
|
41746
|
-
out += String.fromCharCode(buf[i]);
|
|
41747
|
-
}
|
|
41748
|
-
return out;
|
|
41749
|
-
},
|
|
41750
|
-
};
|
|
41751
|
-
class StringWriter {
|
|
41752
|
-
constructor() {
|
|
41753
|
-
this.pos = 0;
|
|
41754
|
-
this.out = '';
|
|
41755
|
-
this.buffer = new Uint8Array(bufLength);
|
|
41756
|
-
}
|
|
41757
|
-
write(v) {
|
|
41758
|
-
const { buffer } = this;
|
|
41759
|
-
buffer[this.pos++] = v;
|
|
41760
|
-
if (this.pos === bufLength) {
|
|
41761
|
-
this.out += td.decode(buffer);
|
|
41762
|
-
this.pos = 0;
|
|
41763
|
-
}
|
|
41764
|
-
}
|
|
41765
|
-
flush() {
|
|
41766
|
-
const { buffer, out, pos } = this;
|
|
41767
|
-
return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
|
|
40991
|
+
let delta = num - relative;
|
|
40992
|
+
delta = delta < 0 ? -delta << 1 | 1 : delta << 1;
|
|
40993
|
+
do {
|
|
40994
|
+
let clamped = delta & 31;
|
|
40995
|
+
delta >>>= 5;
|
|
40996
|
+
if (delta > 0) clamped |= 32;
|
|
40997
|
+
builder.write(intToChar[clamped]);
|
|
40998
|
+
} while (delta > 0);
|
|
40999
|
+
return num;
|
|
41000
|
+
}
|
|
41001
|
+
|
|
41002
|
+
// src/strings.ts
|
|
41003
|
+
var bufLength = 1024 * 16;
|
|
41004
|
+
var td = typeof TextDecoder !== "undefined" ? /* @__PURE__ */ new TextDecoder() : typeof Buffer !== "undefined" ? {
|
|
41005
|
+
decode(buf) {
|
|
41006
|
+
const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
41007
|
+
return out.toString();
|
|
41008
|
+
}
|
|
41009
|
+
} : {
|
|
41010
|
+
decode(buf) {
|
|
41011
|
+
let out = "";
|
|
41012
|
+
for (let i = 0; i < buf.length; i++) {
|
|
41013
|
+
out += String.fromCharCode(buf[i]);
|
|
41768
41014
|
}
|
|
41769
|
-
|
|
41015
|
+
return out;
|
|
41016
|
+
}
|
|
41017
|
+
};
|
|
41018
|
+
var StringWriter = class {
|
|
41019
|
+
constructor() {
|
|
41020
|
+
this.pos = 0;
|
|
41021
|
+
this.out = "";
|
|
41022
|
+
this.buffer = new Uint8Array(bufLength);
|
|
41023
|
+
}
|
|
41024
|
+
write(v) {
|
|
41025
|
+
const { buffer } = this;
|
|
41026
|
+
buffer[this.pos++] = v;
|
|
41027
|
+
if (this.pos === bufLength) {
|
|
41028
|
+
this.out += td.decode(buffer);
|
|
41029
|
+
this.pos = 0;
|
|
41030
|
+
}
|
|
41031
|
+
}
|
|
41032
|
+
flush() {
|
|
41033
|
+
const { buffer, out, pos } = this;
|
|
41034
|
+
return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
|
|
41035
|
+
}
|
|
41036
|
+
};
|
|
41770
41037
|
function encode(decoded) {
|
|
41771
|
-
|
|
41772
|
-
|
|
41773
|
-
|
|
41774
|
-
|
|
41775
|
-
|
|
41776
|
-
|
|
41777
|
-
|
|
41778
|
-
|
|
41779
|
-
|
|
41780
|
-
|
|
41781
|
-
|
|
41782
|
-
|
|
41783
|
-
|
|
41784
|
-
|
|
41785
|
-
|
|
41786
|
-
|
|
41787
|
-
|
|
41788
|
-
|
|
41789
|
-
|
|
41790
|
-
|
|
41791
|
-
|
|
41792
|
-
|
|
41793
|
-
|
|
41794
|
-
continue;
|
|
41795
|
-
namesIndex = encodeInteger(writer, segment[4], namesIndex);
|
|
41796
|
-
}
|
|
41797
|
-
}
|
|
41798
|
-
return writer.flush();
|
|
41038
|
+
const writer = new StringWriter();
|
|
41039
|
+
let sourcesIndex = 0;
|
|
41040
|
+
let sourceLine = 0;
|
|
41041
|
+
let sourceColumn = 0;
|
|
41042
|
+
let namesIndex = 0;
|
|
41043
|
+
for (let i = 0; i < decoded.length; i++) {
|
|
41044
|
+
const line = decoded[i];
|
|
41045
|
+
if (i > 0) writer.write(semicolon);
|
|
41046
|
+
if (line.length === 0) continue;
|
|
41047
|
+
let genColumn = 0;
|
|
41048
|
+
for (let j = 0; j < line.length; j++) {
|
|
41049
|
+
const segment = line[j];
|
|
41050
|
+
if (j > 0) writer.write(comma);
|
|
41051
|
+
genColumn = encodeInteger(writer, segment[0], genColumn);
|
|
41052
|
+
if (segment.length === 1) continue;
|
|
41053
|
+
sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex);
|
|
41054
|
+
sourceLine = encodeInteger(writer, segment[2], sourceLine);
|
|
41055
|
+
sourceColumn = encodeInteger(writer, segment[3], sourceColumn);
|
|
41056
|
+
if (segment.length === 4) continue;
|
|
41057
|
+
namesIndex = encodeInteger(writer, segment[4], namesIndex);
|
|
41058
|
+
}
|
|
41059
|
+
}
|
|
41060
|
+
return writer.flush();
|
|
41799
41061
|
}
|
|
41800
41062
|
|
|
41801
41063
|
class BitSet {
|
|
@@ -43222,26 +42484,29 @@ class ReferenceEmitEnvironment {
|
|
|
43222
42484
|
* `ts.BinaryExpression`s need to be wrapped in parentheses before casting.
|
|
43223
42485
|
*/
|
|
43224
42486
|
//
|
|
43225
|
-
|
|
43226
|
-
// Expressions which are already parenthesized can be cast without further wrapping.
|
|
43227
|
-
ts.SyntaxKind.ParenthesizedExpression,
|
|
43228
|
-
// Expressions which form a single lexical unit leave no room for precedence issues with the cast.
|
|
43229
|
-
ts.SyntaxKind.Identifier,
|
|
43230
|
-
ts.SyntaxKind.CallExpression,
|
|
43231
|
-
ts.SyntaxKind.NonNullExpression,
|
|
43232
|
-
ts.SyntaxKind.ElementAccessExpression,
|
|
43233
|
-
ts.SyntaxKind.PropertyAccessExpression,
|
|
43234
|
-
ts.SyntaxKind.ArrayLiteralExpression,
|
|
43235
|
-
ts.SyntaxKind.ObjectLiteralExpression,
|
|
43236
|
-
// The same goes for various literals.
|
|
43237
|
-
ts.SyntaxKind.StringLiteral,
|
|
43238
|
-
ts.SyntaxKind.NumericLiteral,
|
|
43239
|
-
ts.SyntaxKind.TrueKeyword,
|
|
43240
|
-
ts.SyntaxKind.FalseKeyword,
|
|
43241
|
-
ts.SyntaxKind.NullKeyword,
|
|
43242
|
-
ts.SyntaxKind.UndefinedKeyword,
|
|
43243
|
-
]);
|
|
42487
|
+
let SAFE_TO_CAST_WITHOUT_PARENS = null;
|
|
43244
42488
|
function tsCastToAny(expr) {
|
|
42489
|
+
if (SAFE_TO_CAST_WITHOUT_PARENS === null) {
|
|
42490
|
+
SAFE_TO_CAST_WITHOUT_PARENS = new Set([
|
|
42491
|
+
// Expressions which are already parenthesized can be cast without further wrapping.
|
|
42492
|
+
ts.SyntaxKind.ParenthesizedExpression,
|
|
42493
|
+
// Expressions which form a single lexical unit leave no room for precedence issues with the cast.
|
|
42494
|
+
ts.SyntaxKind.Identifier,
|
|
42495
|
+
ts.SyntaxKind.CallExpression,
|
|
42496
|
+
ts.SyntaxKind.NonNullExpression,
|
|
42497
|
+
ts.SyntaxKind.ElementAccessExpression,
|
|
42498
|
+
ts.SyntaxKind.PropertyAccessExpression,
|
|
42499
|
+
ts.SyntaxKind.ArrayLiteralExpression,
|
|
42500
|
+
ts.SyntaxKind.ObjectLiteralExpression,
|
|
42501
|
+
// The same goes for various literals.
|
|
42502
|
+
ts.SyntaxKind.StringLiteral,
|
|
42503
|
+
ts.SyntaxKind.NumericLiteral,
|
|
42504
|
+
ts.SyntaxKind.TrueKeyword,
|
|
42505
|
+
ts.SyntaxKind.FalseKeyword,
|
|
42506
|
+
ts.SyntaxKind.NullKeyword,
|
|
42507
|
+
ts.SyntaxKind.UndefinedKeyword,
|
|
42508
|
+
]);
|
|
42509
|
+
}
|
|
43245
42510
|
// Wrap `expr` in parentheses if needed (see `SAFE_TO_CAST_WITHOUT_PARENS` above).
|
|
43246
42511
|
if (!SAFE_TO_CAST_WITHOUT_PARENS.has(expr.kind)) {
|
|
43247
42512
|
expr = ts.factory.createParenthesizedExpression(expr);
|
|
@@ -43683,8 +42948,8 @@ function createNodeFromListenerDecorator(decorator, parser, listeners) {
|
|
|
43683
42948
|
let phase;
|
|
43684
42949
|
let target;
|
|
43685
42950
|
if (eventNameNode.text.startsWith('@')) {
|
|
43686
|
-
const parsedName = parser.
|
|
43687
|
-
type = exports.ParsedEventType.
|
|
42951
|
+
const parsedName = parser.parseLegacyAnimationEventName(eventNameNode.text);
|
|
42952
|
+
type = exports.ParsedEventType.LegacyAnimation;
|
|
43688
42953
|
eventName = parsedName.eventName;
|
|
43689
42954
|
phase = parsedName.phase;
|
|
43690
42955
|
target = null;
|
|
@@ -43724,7 +42989,7 @@ function inferBoundAttribute(name) {
|
|
|
43724
42989
|
}
|
|
43725
42990
|
else if (name.startsWith(animationPrefix)) {
|
|
43726
42991
|
attrName = name.slice(animationPrefix.length);
|
|
43727
|
-
type = exports.BindingType.
|
|
42992
|
+
type = exports.BindingType.LegacyAnimation;
|
|
43728
42993
|
}
|
|
43729
42994
|
else {
|
|
43730
42995
|
attrName = name;
|
|
@@ -44732,7 +43997,7 @@ function translateDiagnostic(diagnostic, resolver) {
|
|
|
44732
43997
|
}
|
|
44733
43998
|
|
|
44734
43999
|
/**
|
|
44735
|
-
*
|
|
44000
|
+
* Gets an expression that is cast to any. Currently represented as `0 as any`.
|
|
44736
44001
|
*
|
|
44737
44002
|
* Historically this expression was using `null as any`, but a newly-added check in TypeScript 5.6
|
|
44738
44003
|
* (https://devblogs.microsoft.com/typescript/announcing-typescript-5-6-beta/#disallowed-nullish-and-truthy-checks)
|
|
@@ -44742,45 +44007,9 @@ function translateDiagnostic(diagnostic, resolver) {
|
|
|
44742
44007
|
* - Some flavor of function call, like `isNan(0) as any` - requires even more characters than the
|
|
44743
44008
|
* NaN option and has the same issue with `noLib`.
|
|
44744
44009
|
*/
|
|
44745
|
-
|
|
44746
|
-
|
|
44747
|
-
|
|
44748
|
-
['+', ts.SyntaxKind.PlusToken],
|
|
44749
|
-
['-', ts.SyntaxKind.MinusToken],
|
|
44750
|
-
]);
|
|
44751
|
-
const BINARY_OPS = new Map([
|
|
44752
|
-
['+', ts.SyntaxKind.PlusToken],
|
|
44753
|
-
['-', ts.SyntaxKind.MinusToken],
|
|
44754
|
-
['<', ts.SyntaxKind.LessThanToken],
|
|
44755
|
-
['>', ts.SyntaxKind.GreaterThanToken],
|
|
44756
|
-
['<=', ts.SyntaxKind.LessThanEqualsToken],
|
|
44757
|
-
['>=', ts.SyntaxKind.GreaterThanEqualsToken],
|
|
44758
|
-
['=', ts.SyntaxKind.EqualsToken],
|
|
44759
|
-
['==', ts.SyntaxKind.EqualsEqualsToken],
|
|
44760
|
-
['===', ts.SyntaxKind.EqualsEqualsEqualsToken],
|
|
44761
|
-
['*', ts.SyntaxKind.AsteriskToken],
|
|
44762
|
-
['**', ts.SyntaxKind.AsteriskAsteriskToken],
|
|
44763
|
-
['/', ts.SyntaxKind.SlashToken],
|
|
44764
|
-
['%', ts.SyntaxKind.PercentToken],
|
|
44765
|
-
['!=', ts.SyntaxKind.ExclamationEqualsToken],
|
|
44766
|
-
['!==', ts.SyntaxKind.ExclamationEqualsEqualsToken],
|
|
44767
|
-
['||', ts.SyntaxKind.BarBarToken],
|
|
44768
|
-
['&&', ts.SyntaxKind.AmpersandAmpersandToken],
|
|
44769
|
-
['&', ts.SyntaxKind.AmpersandToken],
|
|
44770
|
-
['|', ts.SyntaxKind.BarToken],
|
|
44771
|
-
['??', ts.SyntaxKind.QuestionQuestionToken],
|
|
44772
|
-
['in', ts.SyntaxKind.InKeyword],
|
|
44773
|
-
['=', ts.SyntaxKind.EqualsToken],
|
|
44774
|
-
['+=', ts.SyntaxKind.PlusEqualsToken],
|
|
44775
|
-
['-=', ts.SyntaxKind.MinusEqualsToken],
|
|
44776
|
-
['*=', ts.SyntaxKind.AsteriskEqualsToken],
|
|
44777
|
-
['/=', ts.SyntaxKind.SlashEqualsToken],
|
|
44778
|
-
['%=', ts.SyntaxKind.PercentEqualsToken],
|
|
44779
|
-
['**=', ts.SyntaxKind.AsteriskAsteriskEqualsToken],
|
|
44780
|
-
['&&=', ts.SyntaxKind.AmpersandAmpersandEqualsToken],
|
|
44781
|
-
['||=', ts.SyntaxKind.BarBarEqualsToken],
|
|
44782
|
-
['??=', ts.SyntaxKind.QuestionQuestionEqualsToken],
|
|
44783
|
-
]);
|
|
44010
|
+
function getAnyExpression() {
|
|
44011
|
+
return ts.factory.createAsExpression(ts.factory.createNumericLiteral('0'), ts.factory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword));
|
|
44012
|
+
}
|
|
44784
44013
|
/**
|
|
44785
44014
|
* Convert an `AST` to TypeScript code directly, without going through an intermediate `Expression`
|
|
44786
44015
|
* AST.
|
|
@@ -44792,6 +44021,44 @@ function astToTypescript(ast, maybeResolve, config) {
|
|
|
44792
44021
|
class AstTranslator {
|
|
44793
44022
|
maybeResolve;
|
|
44794
44023
|
config;
|
|
44024
|
+
UNDEFINED = ts.factory.createIdentifier('undefined');
|
|
44025
|
+
UNARY_OPS = new Map([
|
|
44026
|
+
['+', ts.SyntaxKind.PlusToken],
|
|
44027
|
+
['-', ts.SyntaxKind.MinusToken],
|
|
44028
|
+
]);
|
|
44029
|
+
BINARY_OPS = new Map([
|
|
44030
|
+
['+', ts.SyntaxKind.PlusToken],
|
|
44031
|
+
['-', ts.SyntaxKind.MinusToken],
|
|
44032
|
+
['<', ts.SyntaxKind.LessThanToken],
|
|
44033
|
+
['>', ts.SyntaxKind.GreaterThanToken],
|
|
44034
|
+
['<=', ts.SyntaxKind.LessThanEqualsToken],
|
|
44035
|
+
['>=', ts.SyntaxKind.GreaterThanEqualsToken],
|
|
44036
|
+
['=', ts.SyntaxKind.EqualsToken],
|
|
44037
|
+
['==', ts.SyntaxKind.EqualsEqualsToken],
|
|
44038
|
+
['===', ts.SyntaxKind.EqualsEqualsEqualsToken],
|
|
44039
|
+
['*', ts.SyntaxKind.AsteriskToken],
|
|
44040
|
+
['**', ts.SyntaxKind.AsteriskAsteriskToken],
|
|
44041
|
+
['/', ts.SyntaxKind.SlashToken],
|
|
44042
|
+
['%', ts.SyntaxKind.PercentToken],
|
|
44043
|
+
['!=', ts.SyntaxKind.ExclamationEqualsToken],
|
|
44044
|
+
['!==', ts.SyntaxKind.ExclamationEqualsEqualsToken],
|
|
44045
|
+
['||', ts.SyntaxKind.BarBarToken],
|
|
44046
|
+
['&&', ts.SyntaxKind.AmpersandAmpersandToken],
|
|
44047
|
+
['&', ts.SyntaxKind.AmpersandToken],
|
|
44048
|
+
['|', ts.SyntaxKind.BarToken],
|
|
44049
|
+
['??', ts.SyntaxKind.QuestionQuestionToken],
|
|
44050
|
+
['in', ts.SyntaxKind.InKeyword],
|
|
44051
|
+
['=', ts.SyntaxKind.EqualsToken],
|
|
44052
|
+
['+=', ts.SyntaxKind.PlusEqualsToken],
|
|
44053
|
+
['-=', ts.SyntaxKind.MinusEqualsToken],
|
|
44054
|
+
['*=', ts.SyntaxKind.AsteriskEqualsToken],
|
|
44055
|
+
['/=', ts.SyntaxKind.SlashEqualsToken],
|
|
44056
|
+
['%=', ts.SyntaxKind.PercentEqualsToken],
|
|
44057
|
+
['**=', ts.SyntaxKind.AsteriskAsteriskEqualsToken],
|
|
44058
|
+
['&&=', ts.SyntaxKind.AmpersandAmpersandEqualsToken],
|
|
44059
|
+
['||=', ts.SyntaxKind.BarBarEqualsToken],
|
|
44060
|
+
['??=', ts.SyntaxKind.QuestionQuestionEqualsToken],
|
|
44061
|
+
]);
|
|
44795
44062
|
constructor(maybeResolve, config) {
|
|
44796
44063
|
this.maybeResolve = maybeResolve;
|
|
44797
44064
|
this.config = config;
|
|
@@ -44817,7 +44084,7 @@ class AstTranslator {
|
|
|
44817
44084
|
}
|
|
44818
44085
|
visitUnary(ast) {
|
|
44819
44086
|
const expr = this.translate(ast.expr);
|
|
44820
|
-
const op = UNARY_OPS.get(ast.operator);
|
|
44087
|
+
const op = this.UNARY_OPS.get(ast.operator);
|
|
44821
44088
|
if (op === undefined) {
|
|
44822
44089
|
throw new Error(`Unsupported Unary.operator: ${ast.operator}`);
|
|
44823
44090
|
}
|
|
@@ -44828,7 +44095,7 @@ class AstTranslator {
|
|
|
44828
44095
|
visitBinary(ast) {
|
|
44829
44096
|
const lhs = wrapForDiagnostics(this.translate(ast.left));
|
|
44830
44097
|
const rhs = wrapForDiagnostics(this.translate(ast.right));
|
|
44831
|
-
const op = BINARY_OPS.get(ast.operation);
|
|
44098
|
+
const op = this.BINARY_OPS.get(ast.operation);
|
|
44832
44099
|
if (op === undefined) {
|
|
44833
44100
|
throw new Error(`Unsupported Binary.operation: ${ast.operation}`);
|
|
44834
44101
|
}
|
|
@@ -44966,7 +44233,7 @@ class AstTranslator {
|
|
|
44966
44233
|
// The type of this expression is (typeof a!.b) | undefined, which is exactly as desired.
|
|
44967
44234
|
const expr = ts.factory.createPropertyAccessExpression(ts.factory.createNonNullExpression(receiver), ast.name);
|
|
44968
44235
|
addParseSpanInfo(expr, ast.nameSpan);
|
|
44969
|
-
node = ts.factory.createParenthesizedExpression(ts.factory.createConditionalExpression(
|
|
44236
|
+
node = ts.factory.createParenthesizedExpression(ts.factory.createConditionalExpression(getAnyExpression(), undefined, expr, undefined, this.UNDEFINED));
|
|
44970
44237
|
}
|
|
44971
44238
|
else if (VeSafeLhsInferenceBugDetector.veWillInferAnyFor(ast)) {
|
|
44972
44239
|
// Emulate a View Engine bug where 'any' is inferred for the left-hand side of the safe
|
|
@@ -44996,7 +44263,7 @@ class AstTranslator {
|
|
|
44996
44263
|
// "a?.[...]" becomes (0 as any ? a![...] : undefined)
|
|
44997
44264
|
const expr = ts.factory.createElementAccessExpression(ts.factory.createNonNullExpression(receiver), key);
|
|
44998
44265
|
addParseSpanInfo(expr, ast.sourceSpan);
|
|
44999
|
-
node = ts.factory.createParenthesizedExpression(ts.factory.createConditionalExpression(
|
|
44266
|
+
node = ts.factory.createParenthesizedExpression(ts.factory.createConditionalExpression(getAnyExpression(), undefined, expr, undefined, this.UNDEFINED));
|
|
45000
44267
|
}
|
|
45001
44268
|
else if (VeSafeLhsInferenceBugDetector.veWillInferAnyFor(ast)) {
|
|
45002
44269
|
// "a?.[...]" becomes (a as any)[...]
|
|
@@ -45085,7 +44352,7 @@ class AstTranslator {
|
|
|
45085
44352
|
if (this.config.strictSafeNavigationTypes) {
|
|
45086
44353
|
// "a?.method(...)" becomes (0 as any ? a!.method(...) : undefined)
|
|
45087
44354
|
const call = ts.factory.createCallExpression(ts.factory.createNonNullExpression(expr), undefined, args);
|
|
45088
|
-
return ts.factory.createParenthesizedExpression(ts.factory.createConditionalExpression(
|
|
44355
|
+
return ts.factory.createParenthesizedExpression(ts.factory.createConditionalExpression(getAnyExpression(), undefined, call, undefined, this.UNDEFINED));
|
|
45089
44356
|
}
|
|
45090
44357
|
if (VeSafeLhsInferenceBugDetector.veWillInferAnyFor(ast)) {
|
|
45091
44358
|
// "a?.method(...)" becomes (a as any).method(...)
|
|
@@ -45328,7 +44595,13 @@ class TcbOp {
|
|
|
45328
44595
|
* circular references.
|
|
45329
44596
|
*/
|
|
45330
44597
|
circularFallback() {
|
|
45331
|
-
|
|
44598
|
+
// Value used to break a circular reference between `TcbOp`s.
|
|
44599
|
+
//
|
|
44600
|
+
// This value is returned whenever `TcbOp`s have a circular dependency. The
|
|
44601
|
+
// expression is a non-null assertion of the null value (in TypeScript, the
|
|
44602
|
+
// expression `null!`). This construction will infer the least narrow type
|
|
44603
|
+
// for whatever it's assigned to.
|
|
44604
|
+
return ts.factory.createNonNullExpression(ts.factory.createNull());
|
|
45332
44605
|
}
|
|
45333
44606
|
}
|
|
45334
44607
|
/**
|
|
@@ -45781,7 +45054,7 @@ class TcbInvalidReferenceOp extends TcbOp {
|
|
|
45781
45054
|
optional = true;
|
|
45782
45055
|
execute() {
|
|
45783
45056
|
const id = this.tcb.allocateId();
|
|
45784
|
-
this.scope.addStatement(tsCreateVariable(id,
|
|
45057
|
+
this.scope.addStatement(tsCreateVariable(id, getAnyExpression()));
|
|
45785
45058
|
return id;
|
|
45786
45059
|
}
|
|
45787
45060
|
}
|
|
@@ -46352,7 +45625,7 @@ class TcbDirectiveOutputsOp extends TcbOp {
|
|
|
46352
45625
|
let dirId = null;
|
|
46353
45626
|
const outputs = this.dir.outputs;
|
|
46354
45627
|
for (const output of this.node.outputs) {
|
|
46355
|
-
if (output.type === exports.ParsedEventType.
|
|
45628
|
+
if (output.type === exports.ParsedEventType.LegacyAnimation ||
|
|
46356
45629
|
!outputs.hasBindingPropertyName(output.name)) {
|
|
46357
45630
|
continue;
|
|
46358
45631
|
}
|
|
@@ -46437,7 +45710,7 @@ class TcbUnclaimedOutputsOp extends TcbOp {
|
|
|
46437
45710
|
continue;
|
|
46438
45711
|
}
|
|
46439
45712
|
}
|
|
46440
|
-
if (output.type === exports.ParsedEventType.
|
|
45713
|
+
if (output.type === exports.ParsedEventType.LegacyAnimation) {
|
|
46441
45714
|
// Animation output bindings always have an `$event` parameter of type `AnimationEvent`.
|
|
46442
45715
|
const eventType = this.tcb.env.config.checkTypeOfAnimationEvents
|
|
46443
45716
|
? this.tcb.env.referenceExternalType('@angular/animations', 'AnimationEvent')
|
|
@@ -46763,14 +46036,6 @@ class TcbForOfOp extends TcbOp {
|
|
|
46763
46036
|
return null;
|
|
46764
46037
|
}
|
|
46765
46038
|
}
|
|
46766
|
-
/**
|
|
46767
|
-
* Value used to break a circular reference between `TcbOp`s.
|
|
46768
|
-
*
|
|
46769
|
-
* This value is returned whenever `TcbOp`s have a circular dependency. The expression is a non-null
|
|
46770
|
-
* assertion of the null value (in TypeScript, the expression `null!`). This construction will infer
|
|
46771
|
-
* the least narrow type for whatever it's assigned to.
|
|
46772
|
-
*/
|
|
46773
|
-
const INFER_TYPE_FOR_CIRCULAR_OP_EXPR = ts.factory.createNonNullExpression(ts.factory.createNull());
|
|
46774
46039
|
/**
|
|
46775
46040
|
* Overall generation context for the type check block.
|
|
46776
46041
|
*
|
|
@@ -46892,16 +46157,18 @@ class Scope {
|
|
|
46892
46157
|
*/
|
|
46893
46158
|
statements = [];
|
|
46894
46159
|
/**
|
|
46895
|
-
*
|
|
46160
|
+
* Gets names of the for loop context variables and their types.
|
|
46896
46161
|
*/
|
|
46897
|
-
static
|
|
46898
|
-
[
|
|
46899
|
-
|
|
46900
|
-
|
|
46901
|
-
|
|
46902
|
-
|
|
46903
|
-
|
|
46904
|
-
|
|
46162
|
+
static getForLoopContextVariableTypes() {
|
|
46163
|
+
return new Map([
|
|
46164
|
+
['$first', ts.SyntaxKind.BooleanKeyword],
|
|
46165
|
+
['$last', ts.SyntaxKind.BooleanKeyword],
|
|
46166
|
+
['$even', ts.SyntaxKind.BooleanKeyword],
|
|
46167
|
+
['$odd', ts.SyntaxKind.BooleanKeyword],
|
|
46168
|
+
['$index', ts.SyntaxKind.NumberKeyword],
|
|
46169
|
+
['$count', ts.SyntaxKind.NumberKeyword],
|
|
46170
|
+
]);
|
|
46171
|
+
}
|
|
46905
46172
|
constructor(tcb, parent = null, guard = null) {
|
|
46906
46173
|
this.tcb = tcb;
|
|
46907
46174
|
this.parent = parent;
|
|
@@ -46938,13 +46205,13 @@ class Scope {
|
|
|
46938
46205
|
const firstDecl = varMap.get(v.name);
|
|
46939
46206
|
tcb.oobRecorder.duplicateTemplateVar(tcb.id, v, firstDecl);
|
|
46940
46207
|
}
|
|
46941
|
-
|
|
46208
|
+
Scope.registerVariable(scope, v, new TcbTemplateVariableOp(tcb, scope, scopedNode, v));
|
|
46942
46209
|
}
|
|
46943
46210
|
}
|
|
46944
46211
|
else if (scopedNode instanceof IfBlockBranch) {
|
|
46945
46212
|
const { expression, expressionAlias } = scopedNode;
|
|
46946
46213
|
if (expression !== null && expressionAlias !== null) {
|
|
46947
|
-
|
|
46214
|
+
Scope.registerVariable(scope, expressionAlias, new TcbBlockVariableOp(tcb, scope, tcbExpression(expression, tcb, scope), expressionAlias));
|
|
46948
46215
|
}
|
|
46949
46216
|
}
|
|
46950
46217
|
else if (scopedNode instanceof ForLoopBlock) {
|
|
@@ -46953,12 +46220,13 @@ class Scope {
|
|
|
46953
46220
|
const loopInitializer = tcb.allocateId();
|
|
46954
46221
|
addParseSpanInfo(loopInitializer, scopedNode.item.sourceSpan);
|
|
46955
46222
|
scope.varMap.set(scopedNode.item, loopInitializer);
|
|
46223
|
+
const forLoopContextVariableTypes = Scope.getForLoopContextVariableTypes();
|
|
46956
46224
|
for (const variable of scopedNode.contextVariables) {
|
|
46957
|
-
if (!
|
|
46225
|
+
if (!forLoopContextVariableTypes.has(variable.value)) {
|
|
46958
46226
|
throw new Error(`Unrecognized for loop context variable ${variable.name}`);
|
|
46959
46227
|
}
|
|
46960
|
-
const type = ts.factory.createKeywordTypeNode(
|
|
46961
|
-
|
|
46228
|
+
const type = ts.factory.createKeywordTypeNode(forLoopContextVariableTypes.get(variable.value));
|
|
46229
|
+
Scope.registerVariable(scope, variable, new TcbBlockImplicitVariableOp(tcb, scope, type, variable));
|
|
46962
46230
|
}
|
|
46963
46231
|
}
|
|
46964
46232
|
else if (scopedNode instanceof HostElement) {
|
|
@@ -47699,7 +46967,7 @@ class TcbExpressionTranslator {
|
|
|
47699
46967
|
// No pipe by that name exists in scope. Record this as an error.
|
|
47700
46968
|
this.tcb.oobRecorder.missingPipe(this.tcb.id, ast, this.tcb.hostIsStandalone);
|
|
47701
46969
|
// Use an 'any' value to at least allow the rest of the expression to be checked.
|
|
47702
|
-
pipe =
|
|
46970
|
+
pipe = getAnyExpression();
|
|
47703
46971
|
}
|
|
47704
46972
|
else if (pipeMeta.isExplicitlyDeferred &&
|
|
47705
46973
|
this.tcb.boundTarget.getEagerlyUsedPipes().includes(ast.name)) {
|
|
@@ -47707,7 +46975,7 @@ class TcbExpressionTranslator {
|
|
|
47707
46975
|
// but was used outside of a `@defer` block, which is the error.
|
|
47708
46976
|
this.tcb.oobRecorder.deferredPipeUsedEagerly(this.tcb.id, ast);
|
|
47709
46977
|
// Use an 'any' value to at least allow the rest of the expression to be checked.
|
|
47710
|
-
pipe =
|
|
46978
|
+
pipe = getAnyExpression();
|
|
47711
46979
|
}
|
|
47712
46980
|
else {
|
|
47713
46981
|
// Use a variable declared as the pipe's type.
|
|
@@ -47798,7 +47066,7 @@ function tcbCallTypeCtor(dir, tcb, inputs) {
|
|
|
47798
47066
|
else {
|
|
47799
47067
|
// A type constructor is required to be called with all input properties, so any unset
|
|
47800
47068
|
// inputs are simply assigned a value of type `any` to ignore them.
|
|
47801
|
-
return ts.factory.createPropertyAssignment(propertyName,
|
|
47069
|
+
return ts.factory.createPropertyAssignment(propertyName, getAnyExpression());
|
|
47802
47070
|
}
|
|
47803
47071
|
});
|
|
47804
47072
|
// Call the `ngTypeCtor` method on the directive class, with an object literal argument created
|
|
@@ -50525,6 +49793,7 @@ exports.ImportManager = ImportManager;
|
|
|
50525
49793
|
exports.Interpolation = Interpolation$1;
|
|
50526
49794
|
exports.InterpolationConfig = InterpolationConfig;
|
|
50527
49795
|
exports.InvokeFunctionExpr = InvokeFunctionExpr;
|
|
49796
|
+
exports.KnownFn = KnownFn;
|
|
50528
49797
|
exports.LetDeclaration = LetDeclaration$1;
|
|
50529
49798
|
exports.LiteralArrayExpr = LiteralArrayExpr;
|
|
50530
49799
|
exports.LiteralExpr = LiteralExpr;
|
|
@@ -50557,6 +49826,7 @@ exports.Reference = Reference;
|
|
|
50557
49826
|
exports.Reference$1 = Reference$1;
|
|
50558
49827
|
exports.ReferenceEmitter = ReferenceEmitter;
|
|
50559
49828
|
exports.RelativePathStrategy = RelativePathStrategy;
|
|
49829
|
+
exports.ResolvedModule = ResolvedModule;
|
|
50560
49830
|
exports.ReturnStatement = ReturnStatement;
|
|
50561
49831
|
exports.SafeCall = SafeCall;
|
|
50562
49832
|
exports.SafeKeyedRead = SafeKeyedRead;
|
|
@@ -50564,8 +49834,6 @@ exports.SafePropertyRead = SafePropertyRead;
|
|
|
50564
49834
|
exports.SelectorMatcher = SelectorMatcher;
|
|
50565
49835
|
exports.SelectorlessMatcher = SelectorlessMatcher;
|
|
50566
49836
|
exports.Serializer = Serializer;
|
|
50567
|
-
exports.StaticInterpreter = StaticInterpreter;
|
|
50568
|
-
exports.SyntheticValue = SyntheticValue;
|
|
50569
49837
|
exports.Tag = Tag;
|
|
50570
49838
|
exports.TagPlaceholder = TagPlaceholder;
|
|
50571
49839
|
exports.Template = Template;
|
|
@@ -50654,6 +49922,7 @@ exports.isAliasImportDeclaration = isAliasImportDeclaration;
|
|
|
50654
49922
|
exports.isAngularCore = isAngularCore;
|
|
50655
49923
|
exports.isAngularCoreReferenceWithPotentialAliasing = isAngularCoreReferenceWithPotentialAliasing;
|
|
50656
49924
|
exports.isAngularDecorator = isAngularDecorator;
|
|
49925
|
+
exports.isDeclaration = isDeclaration;
|
|
50657
49926
|
exports.isDtsPath = isDtsPath;
|
|
50658
49927
|
exports.isExpressionForwardReference = isExpressionForwardReference;
|
|
50659
49928
|
exports.isFatalDiagnosticError = isFatalDiagnosticError;
|
|
@@ -50664,7 +49933,7 @@ exports.isNamedClassDeclaration = isNamedClassDeclaration;
|
|
|
50664
49933
|
exports.isNonDeclarationTsPath = isNonDeclarationTsPath;
|
|
50665
49934
|
exports.isShim = isShim;
|
|
50666
49935
|
exports.join = join;
|
|
50667
|
-
exports.literal = literal
|
|
49936
|
+
exports.literal = literal;
|
|
50668
49937
|
exports.literalArr = literalArr;
|
|
50669
49938
|
exports.literalMap = literalMap;
|
|
50670
49939
|
exports.loadIsReferencedAliasDeclarationPatch = loadIsReferencedAliasDeclarationPatch;
|